diff options
author | Daniel Friesel <derf@finalrewind.org> | 2016-02-22 19:15:16 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2016-02-22 19:15:16 +0100 |
commit | cb1c87e6a371d405b7064b66002127c9d500c7d4 (patch) | |
tree | 9bf29dce0a6d00219f9d8dd3c4200a0913b28207 /src/system.cc | |
parent | 3a02241ad1fbd89a6603fb699989cb9f3c9b200d (diff) |
Working loadPattern() code is working \o/
Diffstat (limited to 'src/system.cc')
-rw-r--r-- | src/system.cc | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/system.cc b/src/system.cc index dd09b5a..1cbeec1 100644 --- a/src/system.cc +++ b/src/system.cc @@ -16,7 +16,7 @@ System rocket; animation_t active_anim; uint8_t disp_buf[260]; // 4 byte header + 256 byte data -uint8_t *rx_buf = disp_buf + 64; +uint8_t *rx_buf = disp_buf + sizeof(disp_buf) - 64; void System::initialize() { @@ -33,11 +33,15 @@ void System::initialize() modem.enable(); storage.enable(); + storage.reset(); + storage.save((uint8_t *)"\x10\x0a\x11\x00nootnoot"); + storage.save((uint8_t *)"\x10\x0a\x20\x00nootnoot"); + sei(); if (storage.hasData()) { current_anim_no = 0; - loadPattern(0); + loadPattern(1); } else { active_anim.type = AnimationType::TEXT; active_anim.speed = (2 << 4) + 15; @@ -82,7 +86,7 @@ void System::loadPattern(uint8_t anim_no) storage.load(anim_no, disp_buf); active_anim.type = (AnimationType)(disp_buf[0] >> 4); - active_anim.length = disp_buf[1]; + active_anim.length = disp_buf[1] - 2; if (active_anim.type == AnimationType::TEXT) { active_anim.speed = (disp_buf[2] & 0xf0) + 15; @@ -116,6 +120,8 @@ void System::receive(void) rx_buf[rx_pos] = modem.buffer_get(); } + // TODO adjust for 32 Byte rx buffer size + switch(rxExpect) { case START1: if (rx_byte == 0x99) |