Skip to content

Commit

Permalink
force decrement time in DST off when flashing in factory
Browse files Browse the repository at this point in the history
Signed-off-by: Michal Jenikovsky <[email protected]>
  • Loading branch information
jendo42 committed Dec 10, 2024
1 parent c1c9d0d commit 1c0feb2
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions P162101.ino
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ static uint32_t viewport_x = 0;
static HardwareTimer display_timer;
static DST dst_state = DST::UNKNOWN;
static bool dst_fts = false;
static bool dst_factory_force = false;

extern "C" void HardFault_Handler(void)
{
Expand Down Expand Up @@ -261,6 +262,13 @@ bool readClock(char *str, int type)
} else {
dst_state = newDst;
}
if (dst_factory_force) {
// force decrement hour, factory override
dst_state = DST::ON;
dst_factory_force = false;
uint32_t sign = 0xFAC7BABE;
writeEEPROM(0x04, (uint8_t *)&sign, 4);
}
break;
case DST::OFF:
// check for OFF -> ON transition
Expand Down Expand Up @@ -568,6 +576,13 @@ void setup()
writeEEPROM(0x00, seed, 4);
}

*(uint32_t *)seed = 0;
readEEPROM(0x04, seed, 4);
if (*(uint32_t *)seed != 0xFAC7BABE) {
// force add DST
dst_factory_force = true;
}

// load DST state
readRTC(0x24, seed, 2);
if ((seed[0] ^ seed[1]) == 0xFF) {
Expand Down Expand Up @@ -1017,6 +1032,7 @@ void loop() {
clearScreen(0);

if (light_receiver_status() & 1) {
dst_fts = false;
xorPixel(0, 0);
}

Expand Down

0 comments on commit 1c0feb2

Please sign in to comment.