Skip to content

Commit

Permalink
Fixed hotword brightness
Browse files Browse the repository at this point in the history
  • Loading branch information
Romkabouter committed Apr 30, 2022
1 parent 0573182 commit 2832006
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions PlatformIO/src/StateMachine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ class StateMachine
virtual void entry(void) {
xEventGroupClearBits(audioGroup, PLAY);
xEventGroupClearBits(audioGroup, STREAM);
device->updateBrightness(config.brightness);
device->updateBrightness(hotwordDetected ? config.hotword_brightness : config.brightness);
xSemaphoreTake(wbSemaphore, portMAX_DELAY);
device->updateColors(current_colors);
xSemaphoreGive(wbSemaphore);
};
virtual void run(void) {};
void exit(void) {};
bool hotwordDetected = false;
};

class Tts : public StateMachine
Expand Down Expand Up @@ -108,21 +109,25 @@ class Listening : public StateMachine
void entry(void) override {
publishDebug("Enter Listening");
current_colors = COLORS_HOTWORD;
hotwordDetected = true;
StateMachine::entry();
xEventGroupSetBits(audioGroup, STREAM);
}

void react(IdleEvent const &) override {
publishDebug("IdleEvent in Listening");
hotwordDetected = false;
transit<Idle>();
}

void react(TtsEvent const &) override {
hotwordDetected = false;
transit<Tts>();
}

void react(BeginPlayAudioEvent const &) override {
publishDebug("BeginPlayAudioEvent in Listening");
hotwordDetected = false;
transit<ListeningPlay>();
}
};
Expand All @@ -141,8 +146,6 @@ class ListeningPlay : public StateMachine

class Idle : public StateMachine
{
bool hotwordDetected = false;

void entry(void) override {
publishDebug("Enter Idle");
hotwordDetected = false;
Expand Down

0 comments on commit 2832006

Please sign in to comment.