From 3183889c1f9f41d8cca3b5eee2f1bf00f07b9217 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 29 Feb 2016 16:13:22 +0100 Subject: Add "currently flashing EEPROM" animation --- src/system.cc | 43 +++++++++++++++++++++++++++++++++++++++---- src/system.h | 22 ++++++++++++++++++++++ 2 files changed, 61 insertions(+), 4 deletions(-) diff --git a/src/system.cc b/src/system.cc index 9867c17..3b6ee3c 100644 --- a/src/system.cc +++ b/src/system.cc @@ -143,6 +143,7 @@ void System::receive(void) if (rx_byte == BYTE_START) { rxExpect = PATTERN1; storage.reset(); + dispFlashing(); } else { rxExpect = NEXT_BLOCK; } @@ -261,11 +262,8 @@ void System::loop() display.update(); } -void System::shutdown() +void System::dispPowerdown() { - modem.disable(); - - // show power down image disp_buf[0] = systemPowerdownImage[0]; disp_buf[1] = systemPowerdownImage[1]; disp_buf[2] = systemPowerdownImage[2]; @@ -278,6 +276,43 @@ void System::shutdown() active_anim.type = AnimationType::FRAMES; active_anim.length = 8; display.show(&active_anim); +} + +void System::dispFlashing() +{ + // manually unrolled loop to make sure systemFlashImage doesn't end up + // in memory + disp_buf[0] = systemFlashImage[0]; + disp_buf[1] = systemFlashImage[1]; + disp_buf[2] = systemFlashImage[2]; + disp_buf[3] = systemFlashImage[3]; + disp_buf[4] = systemFlashImage[4]; + disp_buf[5] = systemFlashImage[5]; + disp_buf[6] = systemFlashImage[6]; + disp_buf[7] = systemFlashImage[7]; + disp_buf[8] = systemFlashImage[8]; + disp_buf[9] = systemFlashImage[9]; + disp_buf[10] = systemFlashImage[10]; + disp_buf[11] = systemFlashImage[11]; + disp_buf[12] = systemFlashImage[12]; + disp_buf[13] = systemFlashImage[13]; + disp_buf[14] = systemFlashImage[14]; + disp_buf[15] = systemFlashImage[15]; + + active_anim.data = disp_buf; + active_anim.type = AnimationType::FRAMES; + active_anim.length = 16; + active_anim.delay = 0; + active_anim.speed = 96; + display.show(&active_anim); +} + +void System::shutdown() +{ + modem.disable(); + + // show power down image + dispPowerdown(); display.update(); // we left the main loop, so we need to call this manually // wait until both buttons are released diff --git a/src/system.h b/src/system.h index 36e8e37..8960b77 100644 --- a/src/system.h +++ b/src/system.h @@ -14,6 +14,26 @@ const uint8_t systemPowerdownImage[] = { 0x00 }; +// TODO dito? +const uint8_t systemFlashImage[] = { + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x07, + 0x33, + 0x55, + 0x98, + 0x00, + 0x00 +}; + /** * Contains the system idle loop. Checks for button presses, handles * standby/resume, reads data from the Modem and updates the Display. @@ -25,6 +45,8 @@ class System { void shutdown(void); void receive(void); void loadPattern(uint8_t anim_no); + void dispPowerdown(); + void dispFlashing(); enum TransmissionControl : uint8_t { BYTE_END = 0x84, -- cgit v1.2.3