diff --git a/www/server/app.js b/www/server/app.js index 7a4f5a92d..8b80343d0 100644 --- a/www/server/app.js +++ b/www/server/app.js @@ -474,7 +474,7 @@ app.get('/api/getAddonsOptions', (req, res) => { pinShmupDial: -1, turboLedType: 1, turboLedIndex: 16, - turboLedColor: '#065280', + turboLedColor: 16711680, sliderSOCDModeDefault: 1, snesPadClockPin: -1, snesPadLatchPin: -1, diff --git a/www/src/Addons/Rotary.tsx b/www/src/Addons/Rotary.tsx index be7a30a7c..81a6d31e4 100644 --- a/www/src/Addons/Rotary.tsx +++ b/www/src/Addons/Rotary.tsx @@ -43,7 +43,7 @@ export const rotaryScheme = { .number() .required() .label('Rotary Encoder Add-On Enabled'), - encoderOneEnabled: yup.boolean().required().label('Encoder One Enabled'), + encoderOneEnabled: yup.number().required().label('Encoder One Enabled'), encoderOnePinA: yup .number() .label('Encoder One Pin A') @@ -61,11 +61,11 @@ export const rotaryScheme = { .label('Encoder One Reset After') .required(), encoderOneAllowWrapAround: yup - .boolean() + .number() .required() .label('Encoder One Allow Wrap Around'), encoderOneMultiplier: yup.number().label('Encoder One Multiplier').required(), - encoderTwoEnabled: yup.boolean().required().label('Encoder Two Enabled'), + encoderTwoEnabled: yup.number().required().label('Encoder Two Enabled'), encoderTwoPinA: yup .number() .label('Encoder Two Pin A') @@ -83,7 +83,7 @@ export const rotaryScheme = { .label('Encoder Two Reset After') .required(), encoderTwoAllowWrapAround: yup - .boolean() + .number() .required() .label('Encoder Two Allow Wrap Around'), encoderTwoMultiplier: yup.number().label('Encoder Two Multiplier').required(), diff --git a/www/src/Pages/AddonsConfigPage.jsx b/www/src/Pages/AddonsConfigPage.jsx index 5e0a8b67c..e02ff591b 100644 --- a/www/src/Pages/AddonsConfigPage.jsx +++ b/www/src/Pages/AddonsConfigPage.jsx @@ -9,6 +9,8 @@ import set from 'lodash/set'; import { AppContext } from '../Contexts/AppContext'; +import { hexToInt } from '../Services/Utilities'; + import WebApi from '../Services/WebApi'; import Analog, { analogScheme, analogState } from '../Addons/Analog'; import Analog1256, { @@ -59,6 +61,7 @@ import ReactiveLED, { reactiveLEDScheme, reactiveLEDState, } from '../Addons/ReactiveLED'; +import { rgbIntToHex } from '../Services/Utilities'; const schema = yup.object().shape({ ...analogScheme, @@ -198,6 +201,9 @@ export default function AddonsConfigPage() { const flattened = flattenObject(storedData); const valuesCopy = schema.cast(values); // Strip invalid values + // Convert turbo LED color if available + values.turboLedColor = hexToInt(values.turboLedColor || '#000000'); + // Compare what's changed and set it to resultObject let resultObject = {}; Object.entries(flattened)?.map((entry) => { diff --git a/www/src/Services/WebApi.js b/www/src/Services/WebApi.js index 92416d180..02d650ee6 100644 --- a/www/src/Services/WebApi.js +++ b/www/src/Services/WebApi.js @@ -461,6 +461,8 @@ async function getAddonsOptions(setLoading) { const data = response.data; setLoading(false); + response.data.turboLedColor = rgbIntToHex(response.data.turboLedColor) || '#ffffff'; + // Merge saved keyMappings with defaults const keyboardHostMap = Object.entries(data.keyboardHostMap).reduce( (acc, [key, value]) => ({ ...acc, [key]: { ...acc[key], key: value } }),