Skip to content

Commit 7136644

Browse files
committed
Make beeps a little more reliable.
Every SpeakerDuration triggers a beep and should have a delay after it because the BMC is busy beeping.
1 parent 7c4e614 commit 7136644

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

src/main.rs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,24 +1170,40 @@ impl Hardware {
11701170
fn play_startup_tune(&mut self) -> Result<(), ()> {
11711171
// (delay (ms), command, data)
11721172
let seq: &[(u16, Command, u8)] = &[
1173+
// NB: Due to a BMC bug, this sets the high period
11731174
(0, Command::SpeakerPeriodLow, 137),
1175+
// NB: Due to a BMC bug, this sets the low period
11741176
(0, Command::SpeakerPeriodHigh, 0),
11751177
(0, Command::SpeakerDutyCycle, 127),
1176-
(0, Command::SpeakerDuration, 7),
1178+
// This triggers the beep to occur
1179+
(70, Command::SpeakerDuration, 7),
1180+
// NB: Due to a BMC bug, this sets the high period
11771181
(0, Command::SpeakerPeriodLow, 116),
1182+
// This triggers the beep to occur
11781183
(70, Command::SpeakerDuration, 7),
1184+
// NB: Due to a BMC bug, this sets the high period
11791185
(0, Command::SpeakerPeriodLow, 97),
1186+
// This triggers the beep to occur
11801187
(70, Command::SpeakerDuration, 7),
11811188
];
11821189

11831190
for (delay, reg, val) in seq {
1191+
if self
1192+
.bmc_do_request(
1193+
neotron_bmc_protocol::Request::new_short_write(
1194+
USE_ALT.get(),
1195+
(*reg).into(),
1196+
*val,
1197+
),
1198+
None,
1199+
)
1200+
.is_err()
1201+
{
1202+
defmt::error!("Failed to play note");
1203+
}
11841204
if *delay > 0 {
11851205
self.delay.delay_ms(*delay as u32);
11861206
}
1187-
self.bmc_do_request(
1188-
neotron_bmc_protocol::Request::new_short_write(USE_ALT.get(), (*reg).into(), *val),
1189-
None,
1190-
)?;
11911207
}
11921208
Ok(())
11931209
}

0 commit comments

Comments
 (0)