Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoffer Engman committed Oct 7, 2023
1 parent 54e171c commit ec4ac84
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/src/components/Pad.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import React, { useEffect } from 'react'
import { useDispatch, useSelector } from 'react-redux'
import { ColorOff, randomRGB, rgbToHex } from '../utils/color'
import { changeColor, setPressed } from '../redux/components/pad/padActions'
import { CHANNELS } from '../constants/ipc'

const Pad = ({ x, y }) => {
const button = parseInt(`${y}${x}`)

const dispatch = useDispatch()
const { isPressed, color } = useSelector((state) => state.pad.buttons[button])

useEffect(() => window.api.send('lpPadColor', { button, color }), [color])
useEffect(() => window.api.send(CHANNELS.LP.PAD_COLOR, { button, color }), [color])

useEffect(() => {
console.log('INVOKE PRESSED =>', button, 'STATE: ', isPressed)
Expand Down
1 change: 1 addition & 0 deletions app/src/constants/ipc.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export const CHANNELS = {
LP: {
CLEAR: 'lpClear',
PAD: 'pad',
PAD_COLOR: 'lpPadColor'
},
DMX: {
Expand Down
2 changes: 1 addition & 1 deletion app/src/pages/launchpad/launchpad.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const Launchpad = (props) => {
const dispatch = useDispatch()

// @ts-ignore
window.api.receive('pad', ({ event, button }) => {
window.api.receive(CHANNELS.LP.PAD, ({ event, button }) => {
dispatch(
setPressed({
pressed: event === 'BUTTON_DOWN' ?? false,
Expand Down

0 comments on commit ec4ac84

Please sign in to comment.