Skip to content

Commit

Permalink
scheduler: fix schedule restore flag & refactoring
Browse files Browse the repository at this point in the history
Restore was unintentionally broken after switching from per-relay to
per-schedule setting. Instead of using schedules count it used the
number of relays (or curtains), and never light channels.

Instead, loop over available schedules and check the 'restore' flag,
calling the action when the schedule was supposed to be active.
Similar to the old approach, check for the most recent action and call
it (also, discarding the same type & target pairs, to avoid scheduling
conflicting actions)

time_t seconds offset is refactored into tm.tm_mday offset.
this causes the function to only work with local time, however
it *should* correctly offset day-by-day in case it somehow stumbles
upon dst transition

For settings:
- schSwitch renamed into schTarget
- schTarget default is no longer 0xff, but 0
- schType is a mandatory setting, instead of 1 (switch) default to 0 (none)
- move getSetting into functions to reduce code size
- delSetting case moved into the initial block that runs before restore() and check()

Plus, refactor C-style naming into namespaces similar to the other modules
  • Loading branch information
mcspr committed May 30, 2021
1 parent 71ddf35 commit e22f67e
Show file tree
Hide file tree
Showing 4 changed files with 477 additions and 307 deletions.
1 change: 1 addition & 0 deletions code/espurna/config/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@
// SCHEDULER
// -----------------------------------------------------------------------------

#define SCHEDULER_TYPE_NONE 0
#define SCHEDULER_TYPE_SWITCH 1
#define SCHEDULER_TYPE_DIM 2
#define SCHEDULER_TYPE_CURTAIN 3
Expand Down
Loading

0 comments on commit e22f67e

Please sign in to comment.