diff options
author | Daniel Friesel <derf@finalrewind.org> | 2016-02-24 17:28:53 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2016-02-24 17:28:53 +0100 |
commit | 6cc9c4fa5133e5b2e587735d2cd3cc9272fa7c8a (patch) | |
tree | 60635f12f9b730abfdd57cb6977a0b4e185f89ff /src/system.cc | |
parent | 796805659b6478b6cafeaf743b1540050c3ccdce (diff) |
Add END/EOT signal, only write number of animations at EOT
Diffstat (limited to 'src/system.cc')
-rw-r--r-- | src/system.cc | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/system.cc b/src/system.cc index e829e72..aa21b00 100644 --- a/src/system.cc +++ b/src/system.cc @@ -47,8 +47,8 @@ void System::initialize() sei(); if (storage.hasData()) { - current_anim_no = 3; - loadPattern(3); + current_anim_no = 0; + loadPattern(0); } else { active_anim.type = AnimationType::TEXT; active_anim.speed = (2 << 4) + 15; @@ -139,36 +139,40 @@ void System::receive(void) if (rx_byte == 0x99) rxExpect = START2; else - rxExpect = START_OR_PATTERN; + rxExpect = NEXT_BLOCK; break; case START2: if (rx_byte == 0x99) { rxExpect = PATTERN1; storage.reset(); } else { - rxExpect = START_OR_PATTERN; + rxExpect = NEXT_BLOCK; } break; - case START_OR_PATTERN: + case NEXT_BLOCK: if (rx_byte == 0x99) rxExpect = START2; else if (rx_byte == 0xa9) rxExpect = PATTERN2; - else - rxExpect = START_OR_PATTERN; + else if (rx_byte == 0x84) { + storage.sync(); + current_anim_no = 0; + loadPattern(0); + rxExpect = START1; + } break; case PATTERN1: if (rx_byte == 0xa9) rxExpect = PATTERN2; else - rxExpect = START_OR_PATTERN; + rxExpect = NEXT_BLOCK; break; case PATTERN2: rx_pos = 0; if (rx_byte == 0xa9) rxExpect = HEADER1; else - rxExpect = START_OR_PATTERN; + rxExpect = NEXT_BLOCK; break; case HEADER1: rxExpect = HEADER2; @@ -186,7 +190,7 @@ void System::receive(void) break; case DATA_FIRSTBLOCK: if (remaining_bytes == 0) { - rxExpect = START_OR_PATTERN; + rxExpect = NEXT_BLOCK; storage.save(rx_buf); } else if (rx_pos == 32) { rxExpect = DATA; @@ -196,7 +200,7 @@ void System::receive(void) break; case DATA: if (remaining_bytes == 0) { - rxExpect = START_OR_PATTERN; + rxExpect = NEXT_BLOCK; storage.append(rx_buf); } else if (rx_pos == 32) { rx_pos = 0; |