Skip to content

Commit

Permalink
final unit tests seem to be working.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlyubimov committed Jul 4, 2017
1 parent 90a673c commit 007634f
Show file tree
Hide file tree
Showing 6 changed files with 1,338 additions and 1,332 deletions.
7 changes: 4 additions & 3 deletions Hydra_EVSE/Hydra_EVSE.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#define SW_VERSION "2.4.1-dev"

// Define this for the basic unit tests run in a generica arduino uno board with a display shield.
#define UNIT_TESTS
// #define UNIT_TESTS

#define UINT_BITS (sizeof(unsigned int) << 3)
#define ULONG_BITS (sizeof(unsigned long) << 3)
Expand Down Expand Up @@ -497,14 +497,15 @@ extern char errLetter(unsigned int status);

extern boolean &enable_dst;
extern car_struct cars[];
extern DSTRule dstr[2];
extern DSTRule dstRules[2];


///////////////////////////////////////////////////////////
// Inline declarations
static inline time_t localTime()
{
return toDST(dstr, now()); // for now
time_t t = now();
return persisted.enable_dst && isSummer(dstRules, t)? t + SECS_PER_HOUR : t;
}


Expand Down
24 changes: 13 additions & 11 deletions Hydra_EVSE/Hydra_EVSE.ino
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ unsigned char currentMenuChoices[] = { 12, 16, 20, 24, 28, 30, 32, 36, 40, 44, 5
// Time zone rules.
// Use US_DST_RULES macro for US, EU_... for EU, and AU_... for Australia. Uncomment only one of
// those as applicabble.
US_DST_RULES(dstr);
US_DST_RULES(dstRules);
// EU_DST_RULES(dstr);
// AU_DST_RULES(dstr);

Expand Down Expand Up @@ -956,9 +956,10 @@ unsigned int checkTimer()

event_struct* events(persisted.events);

unsigned char ev_hour = hour(localTime());
unsigned char ev_minute = minute(localTime());
unsigned char ev_dow = dayOfWeek(localTime());
time_t lt = localTime();
unsigned char ev_hour = hour(lt);
unsigned char ev_minute = minute(lt);
unsigned char ev_dow = dayOfWeek(lt);
unsigned char ev_dow_mask = 1 << (ev_dow - 1);
for (unsigned int i = 0; i < EVENT_COUNT; i++)
{
Expand Down Expand Up @@ -1093,17 +1094,18 @@ void doClockMenu(boolean initialize)
{
display.clear();
display.print(P("Set Clock"));
time_t lt = localTime();
#ifdef CLOCK_24HOUR
editHour = hour(localTime());
editHour = hour(lt);
#else
editHour = hourFormat12(localTime());
editMeridian = isPM(localTime()) ? 1 : 0;
editHour = hourFormat12(lt);
editMeridian = isPM(lt) ? 1 : 0;
#endif

editMinute = minute(localTime());
editDay = day(localTime());
editMonth = month(localTime());
editYear = year(localTime());
editMinute = minute(lt);
editDay = day(lt);
editMonth = month(lt);
editYear = year(lt);
if (editYear < FIRST_YEAR || editYear > LAST_YEAR) editYear = FIRST_YEAR;
editCursor = 0;
event = EVENT_LONG_PUSH; // we did a long push to get here.
Expand Down
Loading

0 comments on commit 007634f

Please sign in to comment.