Skip to content

Commit

Permalink
Remove dithering setting for Bluejay v0.21.0 and up. #400
Browse files Browse the repository at this point in the history
  • Loading branch information
stylesuxx committed Oct 29, 2023
1 parent 753f1b2 commit ae27768
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/Components/FirmwareSelector/__tests__/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,10 @@ describe('FirmwareSelector', () => {
expect(onSubmit).toHaveBeenCalled();
});

//TODO: Once v0.20.0 is released, add this test
//TODO: Once v0.22.0 is released, add this test
/*
it('should not show PMW selection for Bluejay v0.20.0 and up', async() => {
const json = `[{ "tag_name": "v0.20.0", "assets": [{}] }]`;
it('should not show PMW selection for Bluejay v0.22.0 and up', async() => {
const json = `[{ "tag_name": "v0.22.0", "assets": [{}] }]`;
global.caches = {
open: jest.fn().mockImplementation(() =>
new Promise((resolve) => {
Expand Down Expand Up @@ -445,7 +445,7 @@ describe('FirmwareSelector', () => {
fireEvent.change(screen.getByRole(/combobox/i, { name: 'Version' }), {
target: {
value: 'https://github.com/bird-sanctuary/bluejay/releases/download/v0.20.0/',
value: 'https://github.com/bird-sanctuary/bluejay/releases/download/v0.22.0/',
name: 'Version',
},
});
Expand Down
4 changes: 2 additions & 2 deletions src/sources/Bluejay/__tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('Bluejay', () => {
}
}

expect(visibleIf.length).toEqual(1);
expect(visibleIf.length).toEqual(2);
});

it('should handle conditional visibility with custom settings', () => {
Expand Down Expand Up @@ -262,7 +262,7 @@ describe('Bluejay', () => {

let conditionalFunction = null;

const revision = 208;
const revision = 209;
const commonSettings = source.getCommonSettings(revision);
const base = commonSettings.base;
for(let j = 0; j < base.length; j += 1) {
Expand Down
4 changes: 4 additions & 0 deletions src/sources/Bluejay/eeprom.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ const LAYOUT = {
offset: 0x2B,
size: 1,
},
THRESHOLD_96to48: {
offset: 0x2C,
size: 1,
},

LAYOUT: {
offset: 0x40,
Expand Down
43 changes: 38 additions & 5 deletions src/sources/Bluejay/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,20 +401,29 @@ COMMON['207'] = {
],
};

COMMON['208'] = {
// Dithering deprecated
COMMON['208'] = { base: COMMON['207'].base.filter((item) => item.name !== 'DITHERING') };

COMMON['209'] = {
base: [
...COMMON['207'].base,
...COMMON['208'].base,
{
name: 'PWM_FREQUENCY',
type: 'enum',
label: 'escPwmFrequencyBluejay',
options: [{
value: 24,
label: '24kHz',
}, {
},
{
value: 48,
label: '48kHz',
}, {
},
{
value: 96,
label: '96kHz',
},
{
value: 0,
label: 'Dynamic',
}],
Expand All @@ -425,8 +434,26 @@ COMMON['208'] = {
min: 0,
max: 255,
step: 1,
displayFactor: 100 / 255,
label: '48to24Threshold',
visibleIf: (settings) => ('PWM_FREQUENCY' in settings) && (parseInt(settings.PWM_FREQUENCY, 10) === 0),
sanitize: (value, settings) => {
if(value > settings.THRESHOLD_96to48) {
return settings.THRESHOLD_96to48;
}

return value;
},
},
{
name: 'THRESHOLD_96to48',
type: 'number',
min: 0,
max: 255,
step: 1,
displayFactor: 100 / 255,
label: '96to48Threshold',
visibleIf: (settings) => ('PWM_FREQUENCY' in settings) && (parseInt(settings.PWM_FREQUENCY, 10) === 0),
},
],
};
Expand Down Expand Up @@ -497,7 +524,8 @@ const INDIVIDUAL_SETTINGS_208 = [
];

const INDIVIDUAL = {
'208': { base: INDIVIDUAL_SETTINGS_208 },
'209': { base: INDIVIDUAL_SETTINGS_208 },
'208': { base: INDIVIDUAL_SETTINGS_203 },
'207': { base: INDIVIDUAL_SETTINGS_203 },
'206': { base: INDIVIDUAL_SETTINGS_203 },
'205': { base: INDIVIDUAL_SETTINGS_203 },
Expand Down Expand Up @@ -571,6 +599,11 @@ DEFAULTS['207'] = { // v0.20

DEFAULTS['208'] = { // v0.21
...DEFAULTS['207'],
};
delete DEFAULTS['208'].DITHERING;

DEFAULTS['209'] = { // v0.22
...DEFAULTS['208'],
PWM_FREQUENCY: 24,
STARTUP_MELODY_WAIT_MS: 0,
THRESHOLD_48to24: 170,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/helpers/__tests__/Convert.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test('settingsUint8Array', () => {

const settingsObject = Convert.arrayToSettingsObject(settingsArray, layout);
const keys = Object.keys(settingsObject);
expect(keys.length).toEqual(48);
expect(keys.length).toEqual(49);

layout.MAIN_REVISION.size = 0;
expect(() => Convert.arrayToSettingsObject(settingsArray, layout)).toThrow();
Expand Down

0 comments on commit ae27768

Please sign in to comment.