Skip to content
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
5 changes: 0 additions & 5 deletions www/src/Contexts/AppContext.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ export const AppContextProvider = ({ children, ...props }) => {
buttonLabelType: newType,
swapTpShareLabels: newSwap,
}) => {
console.log('buttonLabelType is', newType);
newType && localStorage.setItem('buttonLabelType', newType);
newSwap !== undefined &&
localStorage.setItem('swapTpShareLabels', parseBoolean(newSwap));
Expand Down Expand Up @@ -194,28 +193,24 @@ export const AppContextProvider = ({ children, ...props }) => {
const updateUsedPins = async () => {
const data = await WebApi.getUsedPins(setLoading);
setUsedPins(data.usedPins);
console.log('usedPins updated:', data.usedPins);
return data;
};

const updateExpansionPins = async () => {
const data = await WebApi.getExpansionPins(setLoading);
setExpansionPins(data);
console.log('expansionPins updated:', data);
return data;
};

const updateHETriggerOptions = async () => {
const data = await WebApi.getHETriggerOptions(setLoading);
setHETriggerOptions(data);
console.log('HETrigger Options updated:', data);
return data;
};

const updatePeripherals = async () => {
const peripherals = await WebApi.getPeripheralOptions(setLoading);
setAvailablePeripherals(peripherals);
console.log('availablePeripherals updated:', peripherals);
};

useEffect(() => {
Expand Down
34 changes: 2 additions & 32 deletions www/src/Data/Buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ const AUX_BUTTONS = ['S1', 'S2', 'L3', 'R3', 'A1', 'A2'];
const AUX_BUTTONS_STICKLESS_13 = ['S1', 'S2', 'L3', 'R3', 'A2'];
const AUX_BUTTONS_STICKLESS_14 = ['S1', 'S2', 'A1', 'A2'];
const AUX_BUTTONS_STICKLESS_16 = ['S1', 'S2'];
const AUX_BUTTONS_STICKLESS_16_A = ['S1', 'S2'];
const MAIN_BUTTONS = [
'Up',
'Down',
Expand Down Expand Up @@ -328,24 +327,6 @@ const MAIN_BUTTONS_STICKLESS_16 = [
'L3',
'A2',
];
const MAIN_BUTTONS_STICKLESS_16_A = [
'Up',
'A1',
'Down',
'Left',
'Right',
'B1',
'B2',
'B3',
'B4',
'L1',
'R1',
'L2',
'R2',
'R3',
'L3',
'A2',
];

const STICK_LAYOUT = [
[null, 'Left', null],
Expand Down Expand Up @@ -401,17 +382,6 @@ const STICKLESS_16_LAYOUT = [
[null, 'L1', 'L2', null],
];

const STICKLESS_16_A_LAYOUT = [
['L3', null, null, null],
[null, 'Left', null, null],
['A1', 'Down', null, null],
[null, 'Right', null, null],
['A2', 'B3', 'B1', 'Up'],
[null, 'B4', 'B2', 'R3'],
[null, 'R1', 'R2', null],
[null, 'L1', 'L2', null],
];

const KEYBOARD_LAYOUT = [
[null, 'Left'],
['Up', 'Down'],
Expand Down Expand Up @@ -590,7 +560,7 @@ export const BUTTON_LAYOUTS = [
mainButtons: MAIN_BUTTONS,
},
{
label: 'Pop\'n Music',
label: "Pop'n Music",
value: 20,
stickLayout: 'standard',
matrix: STICK_LAYOUT,
Expand Down Expand Up @@ -740,7 +710,7 @@ export const BUTTON_LAYOUTS = [
matrix: STICK_LAYOUT,
auxButtons: AUX_BUTTONS,
mainButtons: MAIN_BUTTONS,
}
},
];

export const BUTTON_MASKS = [
Expand Down
39 changes: 12 additions & 27 deletions www/src/Pages/LEDConfigPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ const PLED_LABELS = [
];

const CASE_TYPE = [
{ value: -1, label: 'Off'},
{ value: 0, label: 'Ambient'},
{ value: 1, label: 'Linked'}
{ value: -1, label: 'Off' },
{ value: 0, label: 'Ambient' },
{ value: 1, label: 'Linked' },
];

const defaultValue = {
Expand Down Expand Up @@ -184,21 +184,12 @@ const getLedButtons = (buttonLabels, map, excludeNulls, swapTpShareLabels) => {
);
};

const getLedMap = (buttonLabels, ledButtons, excludeNulls) => {
const createLedMap = (ledButtons, clear) => {
if (!ledButtons) return;

const buttons = getButtonLabels(buttonLabels, false);
const map = Object.keys(buttons)
.filter((p) => p !== 'label' && p !== 'value')
.filter((p) => (excludeNulls ? ledButtons[p].value > -1 : true))
.reduce((p, n) => {
p[n] = null;
return p;
}, {});

for (let i = 0; i < ledButtons.length; i++) map[ledButtons[i].id] = i;

return map;
return ledButtons.reduce(
(acc, btn) => ({ ...acc, [btn.id]: clear ? null : btn.value }),
{},
);
};

const FormContext = ({
Expand All @@ -221,7 +212,6 @@ const FormContext = ({
setDataSources(dataSources);
setValues(data);
}

fetchData();
}, []);

Expand Down Expand Up @@ -262,15 +252,10 @@ export default function LEDConfigPage() {
const ledOrderChanged = (setFieldValue, ledOrderArrays, ledsPerButton) => {
if (ledOrderArrays.length === 2) {
setRgbLedStartIndex(ledOrderArrays[1].length * (ledsPerButton || 0));
setFieldValue(
'ledButtonMap',
getLedMap(buttonLabelType, ledOrderArrays[1]),
);
console.log(
'new start index: ',
ledOrderArrays[1].length * (ledsPerButton || 0),
ledOrderArrays,
);
setFieldValue('ledButtonMap', {
...createLedMap(ledOrderArrays[0], true),
...createLedMap(ledOrderArrays[1], false),
});
}
};

Expand Down