summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2016-02-24 18:38:31 +0100
committerDaniel Friesel <derf@finalrewind.org>2016-02-24 18:38:31 +0100
commitc6dfb32be9d6fa79f098c3a3e8dfa22c5acafe72 (patch)
tree30e752fac08c25ff22396232fcee2007f375c183
parent00750ab7749b3f26303020410b5240a4cf26d249 (diff)
system: Use private enum for special modem control bytes
-rw-r--r--src/system.cc14
-rw-r--r--src/system.h6
2 files changed, 13 insertions, 7 deletions
diff --git a/src/system.cc b/src/system.cc
index 5729c57..fdf3e4d 100644
--- a/src/system.cc
+++ b/src/system.cc
@@ -136,13 +136,13 @@ void System::receive(void)
switch(rxExpect) {
case START1:
- if (rx_byte == 0x99)
+ if (rx_byte == BYTE_START)
rxExpect = START2;
else
rxExpect = NEXT_BLOCK;
break;
case START2:
- if (rx_byte == 0x99) {
+ if (rx_byte == BYTE_START) {
rxExpect = PATTERN1;
storage.reset();
} else {
@@ -150,11 +150,11 @@ void System::receive(void)
}
break;
case NEXT_BLOCK:
- if (rx_byte == 0x99)
+ if (rx_byte == BYTE_START)
rxExpect = START2;
- else if (rx_byte == 0xa9)
+ else if (rx_byte == BYTE_PATTERN)
rxExpect = PATTERN2;
- else if (rx_byte == 0x84) {
+ else if (rx_byte == BYTE_END) {
storage.sync();
current_anim_no = 0;
loadPattern(0);
@@ -162,14 +162,14 @@ void System::receive(void)
}
break;
case PATTERN1:
- if (rx_byte == 0xa9)
+ if (rx_byte == BYTE_PATTERN)
rxExpect = PATTERN2;
else
rxExpect = NEXT_BLOCK;
break;
case PATTERN2:
rx_pos = 0;
- if (rx_byte == 0xa9)
+ if (rx_byte == BYTE_PATTERN)
rxExpect = HEADER1;
else
rxExpect = NEXT_BLOCK;
diff --git a/src/system.h b/src/system.h
index f192389..d72fe8a 100644
--- a/src/system.h
+++ b/src/system.h
@@ -14,6 +14,12 @@ class System {
void receive(void);
void loadPattern(uint8_t anim_no);
+ enum TransmissionControl : uint8_t {
+ BYTE_END = 0x84,
+ BYTE_START = 0x99,
+ BYTE_PATTERN = 0xa9,
+ };
+
enum ButtonMask : uint8_t {
BUTTON_NONE = 0,
BUTTON_LEFT = 1,