Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Channel Check mode #29

Merged
merged 3 commits into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/api/preset/presetRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Preset } from './../../database/model/Preset'
import { DatabasePreset, PresetRepository } from './../../database/repository/preset'
import { createDatabaseObject, Database, sendDatabaseObject } from './../database'
import axios from 'axios'
import { OSCFormValue } from '../../app/Components/Admin/Controls/Presets/EditModal/OSC'
/**
* This is a REST router for the preset API.
* @param path - The path requested by the original route requestor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ export const MacroPresetEditModal = (props: GetInputProps<'input'>) => {
<Select
placeholder="Page"
{...form.getListInputProps('steps', index, 'value')}
data={[{ value: '/controlPanel/lxKeypad', label: 'Lighting Keypad' }]}
data={[
{ value: '/controlPanel/lxKeypad', label: 'Lighting Keypad' },
{ value: '/controlPanel/channelCheck', label: 'Lighting Channel Check' },
]}
/>
) : null}
<ActionIcon color="red" variant="hover" onClick={() => form.removeListItem('steps', index)}>
Expand Down
1 change: 0 additions & 1 deletion src/app/Navigation/ControlPanelNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { NavbarItem } from './NavbarItem'
import { useAppSelector } from './../apis/redux/mainStore'
import { DatabasePresetFolder } from './../../database/repository/presetFolder'
import { PresetFolderIcon } from './../Components/ControlPanel/PresetFolderIcon'
import { FaCogs } from '@react-icons/all-files/fa/FaCogs'

const TopLevelPresetFolders = ({
active,
Expand Down
98 changes: 98 additions & 0 deletions src/app/Pages/ControlPanel/ChannelCheck.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import { Button, Center, Container, SimpleGrid, Space, Text } from '@mantine/core'
import React, { useEffect, useState } from 'react'
import { ApiCall } from '../../../app/apis/wrapper'
import { channelData } from '../../../output/e131'

export const ChannelCheckPage = () => {
const [channel, setChannel] = useState<number>(-1)
const [channelText, setChannelText] = useState<string>('Off')

useEffect(() => {
if (channel > 0) {
setChannelText(channel.toString())
setChannelLX(channel, 180)
} else if (channel === 0) {
setAllLX(180)
setChannelText('All')
} else {
setAllLX(0)
setChannelText('Off')
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [channel])

function setAllLX(intensity: number) {
const channels: Array<channelData> = []
for (let i = 1; i <= 512; i++) {
channels.push({ channel: i, level: intensity })
}
const data: apiObject = {
universe: 1,
channelData: channels,
fadeTime: 0,
}
ApiCall.get('/outputModules/e131/output', data)
}

function setChannelLX(thisChannel: number, intensity: number) {
setAllLX(0)
const data: apiObject = {
universe: 1,
channelData: [{ channel: thisChannel, level: intensity }],
fadeTime: 0,
}
ApiCall.get('/outputModules/e131/output', data)
}

function checkPrevious() {
if (channel == 1 || channel < 1) {
setChannel(512)
} else {
setChannel(channel - 1)
}
}

function checkNext() {
if (channel == 512 || channel < 1) {
setChannel(1)
} else {
setChannel(channel + 1)
}
}

return (
<Container>
<Space h="xl" />
<SimpleGrid cols={3}>
<Button size="xl" onClick={checkPrevious}>
Previous
</Button>
<Center>
<Text size="xl" color="white">
{channelText}
</Text>
</Center>
<Button size="xl" onClick={checkNext}>
Next
</Button>
<Button
size="xl"
onClick={() => {
setChannel(-1)
}}
>
Off
</Button>
<Space />
<Button
size="xl"
onClick={() => {
setChannel(0)
}}
>
All
</Button>
</SimpleGrid>
</Container>
)
}
2 changes: 2 additions & 0 deletions src/app/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { PresetsConfigurationPage } from './Pages/Admin/Presets'
import { FadersConfigurationPage } from './Pages/Admin/Faders'
import { ControlsConfigurationPage } from './Pages/Admin/Controls'
import { Locked } from './Components/Locked'
import { ChannelCheckPage } from './Pages/ControlPanel/ChannelCheck'
import { KeypadPage } from './Pages/ControlPanel/Keypad'

const Router = () => {
Expand All @@ -29,6 +30,7 @@ const Router = () => {
>
<Route path="presetFolder/:folderId" element={<PresetPage />} />
<Route path="help" element={<HelpPage />} />
<Route path="channelCheck" element={<ChannelCheckPage />} />
<Route path="lxkeypad" element={<KeypadPage />} />
</Route>
<Route path="e131sampler" element={<div>Sampling E1.31</div>} />
Expand Down