summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2022-06-07 22:23:14 +0200
committerlonkaars <loek@pipeframe.xyz>2022-06-07 22:23:14 +0200
commit377a6b80fb766995566bd77047eef08e0a4b5aae (patch)
treece70846c12d7426f9550f6dc2a88e49397f4bd52 /client
parent3e65c70da770fa31fc8acc6ab9374d908cf1ed17 (diff)
implement mode switching tab
Diffstat (limited to 'client')
-rw-r--r--client/commands.c21
-rw-r--r--client/i18n/en_us.h12
-rw-r--r--client/ui.c4
-rw-r--r--client/ui_modes.c11
4 files changed, 42 insertions, 6 deletions
diff --git a/client/commands.c b/client/commands.c
index 778e9c1..05b92d9 100644
--- a/client/commands.c
+++ b/client/commands.c
@@ -46,10 +46,21 @@ void w2_send_ping() {
}
void w2_send_mode(w2_e_mode mode) {
- W2_CREATE_MSG_BIN(w2_s_cmd_mode_rx, msg, msg_bin);
- msg->opcode = W2_CMD_MODE | W2_CMDDIR_RX;
- msg->mode = mode;
+ if (mode == W2_M_PREV) {
+ W2_CREATE_MSG_BIN(w2_s_cmd_sres_rx, msg, msg_bin);
- w2_send_bin(msg_bin);
- free(msg_bin);
+ msg->opcode = W2_CMD_SRES | W2_CMDDIR_RX;
+ msg->type = W2_CMD_SRES_RX_TYPE_PREVMODE;
+
+ w2_send_bin(msg_bin);
+ free(msg_bin);
+ } else {
+ W2_CREATE_MSG_BIN(w2_s_cmd_mode_rx, msg, msg_bin);
+
+ msg->opcode = W2_CMD_MODE | W2_CMDDIR_RX;
+ msg->mode = mode;
+
+ w2_send_bin(msg_bin);
+ free(msg_bin);
+ }
}
diff --git a/client/i18n/en_us.h b/client/i18n/en_us.h
index ceca215..d198296 100644
--- a/client/i18n/en_us.h
+++ b/client/i18n/en_us.h
@@ -101,3 +101,15 @@
#define W2_UI_ORDER_MSG_ORDER_DONE_ERR "no order active\n\n"
#define W2_UI_ORDER_MSG_ORDER_SENT "order sent to robot\n\n"
+#define W2_UI_MODES_INFO \
+ "press keys (0-9) for:\n" \
+ "\n" \
+ "1 - set to maze mode\n" \
+ "2 - set to grid mode\n" \
+ "3 - halt (emergency stop)\n" \
+ "4 - set to charging station mode\n" \
+ "5 - set to spinning mode (wet floor simulation)\n" \
+ "6 - calibrate sensors\n" \
+ "\n" \
+ "0 - previous\n" \
+
diff --git a/client/ui.c b/client/ui.c
index 13bcfb2..cdf2f3b 100644
--- a/client/ui.c
+++ b/client/ui.c
@@ -75,6 +75,10 @@ void w2_ui_paint() {
void w2_ui_paint_statusbar() {
char temp[g_w2_ui_width];
+ for (int i = 0; i < g_w2_ui_width; i++) temp[i] = ' ';
+ w2_wmvaddnstr(g_w2_ui_pad_statusbar, 0, 0, temp, g_w2_ui_width);
+ w2_wmvaddnstr(g_w2_ui_pad_statusbar, 1, 0, temp, g_w2_ui_width);
+
g_w2_state.connected ? sprintf(temp, W2_UI_CONN_STAT_CONNECTED ", %ims %s", g_w2_state.ping,
W2_UI_CONN_STAT_PING)
: sprintf(temp, W2_UI_CONN_STAT_DISCONNECTED);
diff --git a/client/ui_modes.c b/client/ui_modes.c
index 933f47b..829f807 100644
--- a/client/ui_modes.c
+++ b/client/ui_modes.c
@@ -1,10 +1,19 @@
+#include "commands.h"
#include "ui.h"
+#include "i18n.h"
void w2_ui_onkey_modes(int ch) {
+ if (ch == '1') w2_send_mode(W2_M_MAZE);
+ if (ch == '2') w2_send_mode(W2_M_GRID);
+ if (ch == '3') w2_send_mode(W2_M_HALT);
+ if (ch == '4') w2_send_mode(W2_M_CHRG);
+ if (ch == '5') w2_send_mode(W2_M_SPIN);
+ if (ch == '6') w2_send_mode(W2_M_SCAL);
+ if (ch == '0') w2_send_mode(W2_M_PREV);
}
void w2_ui_tab_modes(bool first) {
-
+ w2_wmvaddstr(g_w2_ui_pad_body, 0, 0, W2_UI_MODES_INFO);
}