mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 17:40:46 -04:00
also beep roomba at the same time
This commit is contained in:
@@ -6,6 +6,9 @@ const {
|
||||
HELP_HORN_DURATION_MS,
|
||||
HELP_HORN_FREQUENCY_HZ,
|
||||
HELP_HORN_INTERVAL_MS,
|
||||
HELP_ROOMBA_NOTE,
|
||||
HELP_ROOMBA_NOTE_DURATION,
|
||||
HELP_ROOMBA_SONG_SLOT,
|
||||
createHelpHornNotifier,
|
||||
} = require('./hornNotifier');
|
||||
|
||||
@@ -35,17 +38,29 @@ function createHarness({ enabled = true } = {}) {
|
||||
return { clearedIntervals, clearedTimeouts, commands, intervals, notifier, timeouts };
|
||||
}
|
||||
|
||||
test('starts an immediate 2000 Hz saw chirp and schedules the agreed cadence', () => {
|
||||
test('starts matching external and Roomba chirps and schedules the agreed cadence', () => {
|
||||
const harness = createHarness();
|
||||
harness.notifier.start('red');
|
||||
|
||||
assert.deepEqual(harness.commands, [{
|
||||
roverId: 'red',
|
||||
payload: {
|
||||
type: 'horn',
|
||||
horn: { action: 'start', waveform: 'saw', freqs: [HELP_HORN_FREQUENCY_HZ] },
|
||||
assert.deepEqual(harness.commands, [
|
||||
{
|
||||
roverId: 'red',
|
||||
payload: {
|
||||
type: 'horn',
|
||||
horn: { action: 'start', waveform: 'saw', freqs: [HELP_HORN_FREQUENCY_HZ] },
|
||||
},
|
||||
},
|
||||
}]);
|
||||
{
|
||||
roverId: 'red',
|
||||
payload: {
|
||||
type: 'song',
|
||||
song: {
|
||||
slot: HELP_ROOMBA_SONG_SLOT,
|
||||
notes: [{ note: HELP_ROOMBA_NOTE, duration: HELP_ROOMBA_NOTE_DURATION }],
|
||||
},
|
||||
},
|
||||
},
|
||||
]);
|
||||
assert.equal(Array.from(harness.intervals.values())[0].ms, HELP_HORN_INTERVAL_MS);
|
||||
assert.equal(Array.from(harness.timeouts.values())[0].ms, HELP_HORN_DURATION_MS);
|
||||
|
||||
@@ -65,10 +80,19 @@ test('stop cancels cadence and pending pulse before issuing a final horn stop',
|
||||
assert.equal(harness.commands.at(-1).payload.horn.action, 'stop');
|
||||
});
|
||||
|
||||
test('does not schedule chirps for a rover without an enabled horn', () => {
|
||||
test('still schedules the Roomba song when the external horn is disabled', () => {
|
||||
const harness = createHarness({ enabled: false });
|
||||
harness.notifier.start('green');
|
||||
assert.equal(harness.commands.length, 0);
|
||||
assert.equal(harness.intervals.size, 0);
|
||||
assert.deepEqual(harness.commands, [{
|
||||
roverId: 'green',
|
||||
payload: {
|
||||
type: 'song',
|
||||
song: {
|
||||
slot: HELP_ROOMBA_SONG_SLOT,
|
||||
notes: [{ note: HELP_ROOMBA_NOTE, duration: HELP_ROOMBA_NOTE_DURATION }],
|
||||
},
|
||||
},
|
||||
}]);
|
||||
assert.equal(harness.intervals.size, 1);
|
||||
assert.equal(harness.timeouts.size, 0);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user