Skip to content

Commit

Permalink
Release 2.0.99-b4
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeon Vinzenz Varapragasam authored and Yeon Vinzenz Varapragasam committed Jul 17, 2024
1 parent 1adbb0b commit cf8ae63
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ledfx",
"version": "2.0.99-b3",
"version": "2.0.99-b4",
"description": "LedFx v2 - BladeMOD",
"author": "YeonV aka Blade",
"private": true,
Expand Down
33 changes: 23 additions & 10 deletions src/components/Webcam/Webcam.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Webc from 'react-webcam'
import { useCallback, useEffect, useRef, useState } from 'react'
import useStore from '../../store/useStore'
import { adjust, calibrate, initialize, preadjust } from './pixelMapper'
import { getLedCount, oneLed } from './pixelUtils'
import { getLedCount, oneLed, setWledBrightness } from './pixelUtils'

const Webcam = ({ colN, rowN }: { colN: number; rowN: number }) => {
const webcamRef = useRef<any>(null)
Expand Down Expand Up @@ -44,6 +44,7 @@ const Webcam = ({ colN, rowN }: { colN: number; rowN: number }) => {
const [ignoreLeft, setIgnoreLeft] = useState(0)
const [ignoreBottom, setIgnoreBottom] = useState(0)
const [ignoreRight, setIgnoreRight] = useState(0)
const [brightness, setBrightness] = useState(255)

const isCalibrating = useStore((state) => state.videoMapper.calibrating)
const setIsCalibrating = useStore((state) => state.setCalibrating)
Expand Down Expand Up @@ -296,15 +297,6 @@ const Webcam = ({ colN, rowN }: { colN: number; rowN: number }) => {
)}
{!isCalibrating && isAdjusting && (
<>
<Stack direction="row" spacing={2}>
<Typography width={120}>Threshold</Typography>
<Slider
min={0}
max={255}
value={threshold}
onChange={(_, v) => setThreshold(v as number)}
/>
</Stack>
<Stack direction="row" spacing={2}>
<Typography width={120}>Led</Typography>
<Slider
Expand All @@ -318,6 +310,27 @@ const Webcam = ({ colN, rowN }: { colN: number; rowN: number }) => {
}}
/>
</Stack>
<Stack direction="row" spacing={2}>
<Typography width={120}>Brightness</Typography>
<Slider
min={0}
max={255}
value={brightness}
onChange={(_, v) => {
setBrightness(v as number)
setWledBrightness(v as number)
}}
/>
</Stack>
<Stack direction="row" spacing={2}>
<Typography width={120}>Threshold</Typography>
<Slider
min={0}
max={255}
value={threshold}
onChange={(_, v) => setThreshold(v as number)}
/>
</Stack>
</>
)}

Expand Down
3 changes: 3 additions & 0 deletions src/components/Webcam/pixelUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ export const oneLed = async (led) => {
}
}

export const setWledBrightness = async (brightness = 255) => {
await wled({ bri: brightness })
}

export function decodeBase64ToImageData(base64String) {
const base64Data = base64String.split(',')[1]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,9 @@ const assignPixels = ({
group: `${row}-${col}`
}
} else {
let startCol = col;
let currentRow = row;
for (
let index = 0;
index < Math.abs(selectedPixel[1] - selectedPixel[0]);
index <= Math.abs(selectedPixel[1] - selectedPixel[0]);
index += 1
) {
const newM = {
Expand Down

0 comments on commit cf8ae63

Please sign in to comment.