Skip to content

Commit be60112

Browse files
committed
feat: Synchronize Individual after playing back startup tune
Since we allow each ESC to set it's own startup tune, we can now automatically configure each of them to wait until all the others have finished playing their tune. The support for this is implemented using the new Eeprom variables in Bluejay: Eep_Pgm_Tune_Wait_MSB_ms - most significant byte Eep_Pgm_Tune_Wait_LSB_ms - least significant byte This should allow us to wait for 65536ms now. This should typically be enough for most usecases imo. If not, we can add another byte later on.
1 parent ed96d31 commit be60112

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

js/bluejay_defaults.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
11
'use strict';
22

33
var BLUEJAY_DEFAULTS = {
4+
'204': { // 201 with STARTUP_MELODY
5+
RPM_POWER_SLOPE: 9,
6+
MOTOR_DIRECTION: 1,
7+
COMMUTATION_TIMING: 4,
8+
BEEP_STRENGTH: 40,
9+
BEACON_STRENGTH: 80,
10+
BEACON_DELAY: 4,
11+
DEMAG_COMPENSATION: 2,
12+
TEMPERATURE_PROTECTION: 7,
13+
BRAKE_ON_STOP: 0,
14+
LED_CONTROL: 0,
15+
16+
STARTUP_POWER_MIN: 51,
17+
DITHERING: 1,
18+
19+
STARTUP_POWER_MAX: 25,
20+
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],
21+
STARTUP_MELODY_WAIT_MS_MSB: 0,
22+
STARTUP_MELODY_WAIT_MS_LSB: 0
23+
},
424
'203': { // 201 with STARTUP_MELODY
525
RPM_POWER_SLOPE: 9,
626
MOTOR_DIRECTION: 1,

js/bluejay_eeprom_layout.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var BLHELI_SILABS_BOOTLOADER_SIZE = 0x0200
2323
var BLHELI_SILABS_FLASH_SIZE = 0x2000
2424
var BLHELI_SILABS_ADDRESS_SPACE_SIZE = BLHELI_SILABS_BOOTLOADER_ADDRESS
2525

26-
var BLHELI_LAYOUT_SIZE = 0xF0
26+
var BLHELI_LAYOUT_SIZE = 0xF2
2727
var BLHELI_MIN_SUPPORTED_LAYOUT_REVISION = 0x13
2828

2929
var BLHELI_S_MIN_LAYOUT_REVISION = 0x20
@@ -76,7 +76,9 @@ var BLHELI_LAYOUT = {
7676
MCU: { offset: 0x50, size: 16 },
7777
NAME: { offset: 0x60, size: 16 },
7878

79-
STARTUP_MELODY: { offset: 0x70, size: 128 }
79+
STARTUP_MELODY: { offset: 0x70, size: 128 },
80+
STARTUP_MELODY_WAIT_MS_MSB: { offset: 0xF0, size: 1 },
81+
STARTUP_MELODY_WAIT_MS_LSB: { offset: 0xF1, size: 1 }
8082
};
8183

8284
function blheliModeToString(mode) {

jsx/blheli_configurator.jsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,14 @@ var Configurator = React.createClass({
215215
},
216216
// @todo add validation of each setting via BLHELI_SETTINGS_DESCRIPTION
217217
writeSetupAll: async function() {
218+
//Update escSettings' wait time after playing back their tune so they all start the dshot beacons at the same time
219+
const melodyDurations = this.state.escSettings.map((s) => { Rtttl.parse(Rtttl.fromBluejayStartupMelody(s.STARTUP_MELODY)).melody.reduce((a, b)=> a + b.duration, 0) });
220+
const maxMelodyDuration = melodyDurations.reduce((a, b) => Math.max(a, b), 0);
221+
218222
for (var esc = 0; esc < this.state.escSettings.length; ++esc) {
223+
const melodyWaitDifference = maxMelodyDuration - melodyDurations[esc];
224+
this.state.escSettings[esc].STARTUP_MELODY_WAIT_MS_MSB = (melodyWaitDifference >> 8) & (2**8 - 1);
225+
this.state.escSettings[esc].STARTUP_MELODY_WAIT_MS_LSB = (melodyWaitDifference) & (2**8 - 1);
219226
await this.writeSetupImpl(esc);
220227
}
221228
},

0 commit comments

Comments
 (0)