fix(tone_alarm): stop without waiting for the next note

The driver only checks should_exit() in Run(), which is not scheduled while no tune is played, and is scheduled at the next note while a tune is played. "tone_alarm stop" then waited for the next note, or for its 5 s timeout and deleted the driver with "timeout, forcing stop" when no tune was played. The driver now schedules Run() when it is asked to stop.

Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
This commit is contained in:
Benjamin Cabé authored and Ramon Roche committed 2026-10-14 12:08:40 +02:00
1 parent 0ea6a82b3d
commit f9858e1fb7
2 files changed
+11

No files matched your search

+8
View File
@@ -73,6 +73,14 @@ bool ToneAlarm::Init()
return true;
}
void ToneAlarm::request_stop()
{
ModuleBase::request_stop();
// Run() is not scheduled while no tune is played
ScheduleNow();
}
void ToneAlarm::InterruptStopNote(void *arg)
{
ToneAlarmInterface::stop_note();
+3
View File
@@ -72,6 +72,9 @@ public:
/** @see ModuleBase */
static int print_usage(const char *reason = nullptr);
/** @see ModuleBase */
void request_stop() override;
private:
static void InterruptStopNote(void *arg);