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
6 changes: 6 additions & 0 deletions src/Containers/App/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -967,8 +967,14 @@ class App extends Component {
const { escs } = this.state;
const individual = [ ...escs.individual ];
const converted = melodies.map((melody) => Rtttl.toBluejayStartupMelody(melody));

// Set wait time after melody to synchronize playback on all ESCs
const melodyDurations = melodies.map((melody) => Rtttl.parse(melody).melody.reduce((a, b) => a + b.duration, 0));
const maxMelodyDuration = Math.max(...melodyDurations);

for(let i = 0; i < converted.length; i += 1) {
individual[i].individualSettings.STARTUP_MELODY = converted[i].data;
individual[i].individualSettings.STARTUP_MELODY_WAIT_MS = maxMelodyDuration - melodyDurations[i];
Comment thread
mathiasvr marked this conversation as resolved.
}

// Update individual settings, then write them.
Expand Down
6 changes: 5 additions & 1 deletion src/sources/Bluejay/eeprom.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const EEPROM_OFFSET = 0x1A00;
const PAGE_SIZE = 0x0200;
const LAYOUT_SIZE = 0xF0;
const LAYOUT_SIZE = 0xFF;

const NAMES = [
'Bluejay',
Expand Down Expand Up @@ -188,6 +188,10 @@ const LAYOUT = {
offset: 0x70,
size: 128,
},
STARTUP_MELODY_WAIT_MS: {
offset: 0xF0,
size: 2,
},
};

const EEPROM = {
Expand Down
33 changes: 29 additions & 4 deletions src/sources/Bluejay/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,27 @@ SETTINGS_DESCRIPTIONS['204'] = {
],
};

SETTINGS_DESCRIPTIONS['205'] = {
base: [
...SETTINGS_DESCRIPTIONS['204'].base,
{
name: 'STARTUP_BEEP',
type: 'enum',
label: 'escStartupBeep',
options: [{
value: '0',
label: 'Off',
}, {
value: '1',
label: 'Normal',
}, {
value: '2',
label: 'Custom',
}],
},
],
};

const INDIVIDUAL_SETTINGS = [{
name: 'MOTOR_DIRECTION',
type: 'enum',
Expand Down Expand Up @@ -341,12 +362,10 @@ const INDIVIDUAL_SETTINGS_203 = [{
}, {
name: 'STARTUP_MELODY',
type: 'melody',
label: 'startupMelody',
value: [2, 58, 4, 32, 52, 66, 13, 0, 69, 45, 13, 0, 52, 66, 13, 0, 78, 39, 211, 0, 69, 45, 208, 25, 52, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
melodyLength: 128,
}];

const INDIVIDUAL_SETTINGS_DESCRIPTIONS = {
'205': { base: INDIVIDUAL_SETTINGS_203 },
'204': { base: INDIVIDUAL_SETTINGS_203 },
'203': { base: INDIVIDUAL_SETTINGS_203 },
'202': { base: INDIVIDUAL_SETTINGS },
Expand Down Expand Up @@ -387,7 +406,7 @@ DEFAULTS['202'] = { // unreleased

DEFAULTS['203'] = { // v0.12
...DEFAULTS['201'],
STARTUP_MELODY: [2, 58, 4, 32, 52, 66, 13, 0, 69, 45, 13, 0, 52, 66, 13, 0, 78, 39, 211, 0, 69, 45, 208, 25, 52, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
STARTUP_MELODY: [2, 58, 4, 32, 52, 66, 13, 0, 69, 45, 13, 0, 52, 66, 13, 0, 78, 39, 211, 0, 69, 45, 208, 25, 52, 25, 0],
};
delete DEFAULTS['203'].STARTUP_BEEP;

Expand All @@ -396,6 +415,12 @@ DEFAULTS['204'] = { // v0.15
BRAKING_STRENGTH: 255,
};

DEFAULTS['205'] = {
...DEFAULTS['204'],
STARTUP_BEEP: 1,
STARTUP_MELODY_WAIT_MS: 0,
};

const settings = {
DEFAULTS,
INDIVIDUAL_SETTINGS_DESCRIPTIONS,
Expand Down
4 changes: 2 additions & 2 deletions 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(44);
expect(keys.length).toEqual(45);

layout.MAIN_REVISION.size = 0;
expect(() => Convert.arrayToSettingsObject(settingsArray, layout)).toThrow();
Expand All @@ -24,7 +24,7 @@ test('settingsArray', () => {
const shortArray = settingsArray.subarray(0, settingsArray.length - 2);
const settingsObject = Convert.arrayToSettingsObject(shortArray, layout);
const settingsArrayResult = Convert.objectToSettingsArray(settingsObject, layout, EEPROM.LAYOUT_SIZE);
expect(settingsArrayResult.length).toEqual(240);
expect(settingsArrayResult.length).toEqual(255);

layout.MAIN_REVISION.size = 0;
expect(() => Convert.objectToSettingsArray(settingsObject, layout, EEPROM.LAYOUT_SIZE)).toThrow();
Expand Down