Skip to content

Commit

Permalink
Added #if to prevent problems in case EVENT_COUNT is changed
Browse files Browse the repository at this point in the history
  • Loading branch information
dlyubimov committed Sep 1, 2017
1 parent 42e9729 commit 46aac9e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Hydra_EVSE/Hydra_EVSE.ino
Original file line number Diff line number Diff line change
Expand Up @@ -180,19 +180,23 @@ void persisted_struct::reset()
// (so on weekdays, if unpaused manually for partial peak, will pause again for full peak).
unsigned char weekdays = -1u >> (sizeof(int) << 3) - 5 << 1;

#if EVENT_COUNT >= 4
// Pause any day at 7am and resume at 11pm on weekdays.
events[0].dow_mask = events[1].dow_mask = weekdays;
events[0].hour = 23; events[1].hour = 7;

// Weekends: start at 7pm and pause (any day) on 3pm
events[2].dow_mask = ~weekdays; events[2].hour = 19;
events[3].dow_mask = ~weekdays; events[3].hour = 15;
#endif

// On weekdays, we some times turn on during partial peek. The full peak on weekdays starts at 2pm,
// so we add a fifth event that switches the station off again at 2pm on weekdays in case we turned
// it on during partial peak.

#if EVENT_COUNT >= 5
events[4].dow_mask = weekdays; events[4].hour = 14;
#endif

calib.reset();
rtc.reset();
Expand Down

0 comments on commit 46aac9e

Please sign in to comment.