Skip to content

Commit

Permalink
Add set opt command (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewturner authored Nov 3, 2023
1 parent 0ebcdee commit c029e9e
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 19 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/platformio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Cache pip
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache PlatformIO
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.platformio
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v3
- name: Install PlatformIO
run: |
python -m pip install --upgrade pip
pip install --upgrade platformio
- name: Install native environment
run: pio pkg install -e native
- name: Run PlatformIO
run: pio test -e native
run: pio test -e native
22 changes: 13 additions & 9 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ board = uno
framework = arduino
monitor_filters = time, default
monitor_speed = 115200
build_flags =
-D EVENTUALLY_MAX_COMMANDS=5
-D EVENTUALLY_COMMAND_BUFFER_LENGTH=14
-D EVENTUALLY_DATA_BUFFER_LENGTH=11
lib_deps =
fastled/FastLED@^3.4.0
adafruit/RTClib@^1.14.1
https://github.com/matthewturner/Eventually.git
https://github.com/matthewturner/Eventually-StateMachineListener.git
https://github.com/matthewturner/Eventually-CommandListener.git
matthewturner/Eventually2@^2.1.0
matthewturner/EventuallyCommand@^0.4.0
matthewturner/EventuallyStateMachine@^0.3.0
featherfly/SoftwareSerial@^1.0
https://github.com/MHotchin/Timezone.git
paulstoffregen/Time@^1.6.1
Expand All @@ -33,9 +37,9 @@ platform = native
lib_deps =
fastled/FastLED@^3.4.0
adafruit/RTClib@^1.14.1
https://github.com/matthewturner/Eventually.git
https://github.com/matthewturner/Eventually-StateMachineListener.git
https://github.com/matthewturner/Eventually-CommandListener.git
matthewturner/Eventually2@^2.1.0
matthewturner/EventuallyCommand@^0.4.0
matthewturner/EventuallyStateMachine@^0.3.0
featherfly/SoftwareSerial@^1.0
https://github.com/MHotchin/Timezone.git
paulstoffregen/Time@^1.6.1
Expand All @@ -49,9 +53,9 @@ debug_test = test_schedule
lib_deps =
fastled/FastLED@^3.4.0
adafruit/RTClib@^1.14.1
https://github.com/matthewturner/Eventually.git
https://github.com/matthewturner/Eventually-StateMachineListener.git
https://github.com/matthewturner/Eventually-CommandListener.git
matthewturner/Eventually2@^2.1.0
matthewturner/EventuallyCommand@^0.4.0
matthewturner/EventuallyStateMachine@^0.3.0
featherfly/SoftwareSerial@^1.0
https://github.com/MHotchin/Timezone.git
paulstoffregen/Time@^1.6.1
Expand Down
25 changes: 20 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -60,7 +61,10 @@ bool set(EvtListener *, EvtContext *, long data)
Serial.print(F("Command: SET "));
Serial.println(data);
clock.adjust(DateTime(data));
stateMachine.transition(SHOWING);
if (showAfterSet)
{
stateMachine.transition(SHOWING);
}
return true;
}

Expand All @@ -69,7 +73,10 @@ bool setSchedule(EvtListener *, EvtContext *, long data)
Serial.print(F("Command: SET SCHEDULE "));
Serial.println(data);
displaySchedule.update(data);
stateMachine.transition(SHOWING);
if (showAfterSet)
{
stateMachine.transition(SHOWING);
}
return true;
}

Expand All @@ -80,6 +87,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..."));
Expand Down Expand Up @@ -230,9 +245,9 @@ void setupDisplaySchedule()
{
Serial.println(F("Setting up display schedule..."));

displaySchedule.setup(6, 6, Flags::MINIMAL);
displaySchedule.setup(7, 7, Flags::STANDARD);
displaySchedule.setup(10, 18, Flags::BRIGHT);
// displaySchedule.setup(6, 6, Flags::MINIMAL);
// displaySchedule.setup(7, 7, Flags::STANDARD);
// displaySchedule.setup(10, 18, (Flags)(Flags::STANDARD | Flags::BRIGHT));
displaySchedule.setValueFor(20, BlockFlags::SECOND_HALF, Flags::STANDARD);
}

Expand Down
4 changes: 3 additions & 1 deletion src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,17 @@ SoftwareSerial bluetoothSerial(RECEIVE_PIN, TRANSMIT_PIN);
EvtCommandListener commandListener(&bluetoothSerial, 20);
EvtStateMachineListener stateMachine;

bool showAfterSet = false;

void onInterrupt();
void render();
void render(CRGB::HTMLColorCode colorCode, byte brightness);
bool updating();
bool idle();
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);
Expand Down

0 comments on commit c029e9e

Please sign in to comment.