aboutsummaryrefslogtreecommitdiff
path: root/zumo/protocol.cpp
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2023-06-07 14:13:04 +0200
committerlonkaars <loek@pipeframe.xyz>2023-06-07 14:13:04 +0200
commit2903e61cbe2eeff3121f67da516ea195999f0bba (patch)
tree66b639d73c6f35012732e4e8b9db508691aee28e /zumo/protocol.cpp
parent74527f9b5a51eca49734a50a5b78e26e2d824776 (diff)
string lookup for display
Diffstat (limited to 'zumo/protocol.cpp')
-rw-r--r--zumo/protocol.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/zumo/protocol.cpp b/zumo/protocol.cpp
index d176c24..06e2993 100644
--- a/zumo/protocol.cpp
+++ b/zumo/protocol.cpp
@@ -13,18 +13,18 @@
Zumo32U4OLED display;
void handle_cmd(unsigned char cmd, dui_state_t *state) {
- Serial.println(cmd,HEX);
+ Serial.println(cmd, HEX);
if (cmd == DUI_CMD_NULL) return;
else if (DUI_CMD_SIGN_START <= cmd && cmd <= DUI_CMD_SIGN_END) {
state->current_sign = (dui_e_sign) (cmd - DUI_CMD_SIGN_START);
- display.clear();
- display.print(state->current_sign+1);
- display.gotoXY(0, 1);
+ display.clear();
+ if (DUI_SIGN_LOOKUP[state->current_sign] == nullptr) return;
+ display.print(DUI_SIGN_LOOKUP[state->current_sign]);
} else if (DUI_CMD_SPEED_START <= cmd && cmd <= DUI_CMD_SPEED_END) {
- Serial.print(" Hallo: " );
+ Serial.print(" Hallo: " );
state->Speed = (float) (cmd - DUI_CMD_SPEED_START) / (float) (DUI_CMD_SPEED_END - DUI_CMD_SPEED_START);
- Serial.println(state->Speed);
+ Serial.println(state->Speed);
} else if (DUI_CMD_STEER_START <= cmd && cmd <= DUI_CMD_STEER_END) {
state->steer = (float) (cmd - DUI_CMD_STEER_START) / (float) (DUI_CMD_STEER_END - DUI_CMD_STEER_START) * (float) 2 - (float) 1;
}