From 4e5f9558faeb314ee26be9a050f7da8490a61c43 Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Fri, 20 Oct 2023 12:57:57 +0100 Subject: [PATCH] Add set options command --- src/main.cpp | 9 +++++++++ src/main.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 585f38c..8053947 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,6 +25,7 @@ void setup() commandListener.when("set-schedule", (EvtCommandAction)setSchedule); commandListener.when("show", (EvtCommandAction)show); commandListener.when("status", (EvtCommandAction)status); + commandListener.when("set-opt", (EvtCommandAction)setOptions); mgr.addListener(&commandListener); stateMachine.when(IDLE, (EvtAction)idle, UPDATING); @@ -80,6 +81,14 @@ bool status() return true; } +bool setOptions(EvtListener *, EvtContext *, long data) +{ + Serial.print(F("Command: SET-OPT ")); + Serial.println(data); + showAfterSet = data % 10; + return true; +} + bool updating() { Serial.println(F("Updating...")); diff --git a/src/main.h b/src/main.h index 7042280..310b035 100644 --- a/src/main.h +++ b/src/main.h @@ -43,6 +43,7 @@ Schedule displaySchedule(Flags::NONE, 1); SoftwareSerial bluetoothSerial(RECEIVE_PIN, TRANSMIT_PIN); EvtCommandListener commandListener(&bluetoothSerial, 20); EvtStateMachineListener stateMachine; +bool showAfterSet = false; void onInterrupt(); void render(); @@ -53,6 +54,7 @@ bool showing(); bool show(); bool set(EvtListener *, EvtContext *, long data); bool setSchedule(EvtListener *, EvtContext *, long data); +bool setOptions(EvtListener *, EvtContext *, long data); bool status(); byte brightnessFrom(Flags mode); CRGB::HTMLColorCode colorFor(byte hour);