diff options
Diffstat (limited to 'client')
| -rw-r--r-- | client/i18n/en_us.h | 8 | ||||
| -rw-r--r-- | client/setup.c | 4 | ||||
| -rw-r--r-- | client/strings.c | 16 | ||||
| -rw-r--r-- | client/strings.h | 10 | ||||
| -rw-r--r-- | client/ui.c | 17 | ||||
| -rw-r--r-- | client/ui.h | 3 | 
6 files changed, 45 insertions, 13 deletions
| diff --git a/client/i18n/en_us.h b/client/i18n/en_us.h index 80b9f09..206e689 100644 --- a/client/i18n/en_us.h +++ b/client/i18n/en_us.h @@ -6,3 +6,11 @@  #define W2_UI_BATT_STAT_BATTERY "battery"  #define W2_UI_EXPT_STAT_WARNINGS "warning(s)"  #define W2_UI_EXPT_STAT_ERRORS "error(s)" +#define W2_UI_MODE_CHRG "charging station" +#define W2_UI_MODE_DIRC "direct control" +#define W2_UI_MODE_GRID "grid" +#define W2_UI_MODE_HALT "emergency stop" +#define W2_UI_MODE_LCAL "line calibration" +#define W2_UI_MODE_MAZE "maze" +#define W2_UI_MODE_SCAL "sensor calibration" +#define W2_UI_MODE_SPIN "wet floor simulation" diff --git a/client/setup.c b/client/setup.c index 59e43d1..a7db057 100644 --- a/client/setup.c +++ b/client/setup.c @@ -1,12 +1,13 @@ +#include <ncurses.h>  #include <stdio.h>  #include <stdlib.h> -#include <ncurses.h>  #include "../shared/bin.h"  #include "../shared/protocol.h"  #include "commands.h"  #include "serial.h"  #include "setup.h" +#include "strings.h"  #include "ui.h"  // pointers for endianness check @@ -31,6 +32,7 @@ void w2_client_setup(int argc, char **argv) {  	}  	noecho(); +	w2_strings_init();  	w2_cmd_setup_handlers();  	w2_send_info(); diff --git a/client/strings.c b/client/strings.c new file mode 100644 index 0000000..b97d4b2 --- /dev/null +++ b/client/strings.c @@ -0,0 +1,16 @@ +#include "strings.h" + +char *g_w2_mode_strings[W2_MODE_COUNT]; + +void w2_strings_modes_init() { +	g_w2_mode_strings[W2_M_CHRG] = W2_UI_MODE_CHRG; +	g_w2_mode_strings[W2_M_DIRC] = W2_UI_MODE_DIRC; +	g_w2_mode_strings[W2_M_GRID] = W2_UI_MODE_GRID; +	g_w2_mode_strings[W2_M_HALT] = W2_UI_MODE_HALT; +	g_w2_mode_strings[W2_M_LCAL] = W2_UI_MODE_LCAL; +	g_w2_mode_strings[W2_M_MAZE] = W2_UI_MODE_MAZE; +	g_w2_mode_strings[W2_M_SCAL] = W2_UI_MODE_SCAL; +	g_w2_mode_strings[W2_M_SPIN] = W2_UI_MODE_SPIN; +} + +void w2_strings_init() { w2_strings_modes_init(); } diff --git a/client/strings.h b/client/strings.h new file mode 100644 index 0000000..0085228 --- /dev/null +++ b/client/strings.h @@ -0,0 +1,10 @@ +#pragma once + +#include "../shared/modes.h" +#include "i18n.h" + +#define W2_STRINGS_MODE_MAP_BUFFER_SIZE 32 + +extern char *g_w2_mode_strings[W2_MODE_COUNT]; + +void w2_strings_init(); diff --git a/client/ui.c b/client/ui.c index c47e1fb..869a071 100644 --- a/client/ui.c +++ b/client/ui.c @@ -1,19 +1,20 @@ -#include <string.h>  #include <ncurses.h> +#include <string.h>  #include "../shared/bin.h"  #include "../shared/util.h"  #include "i18n.h"  #include "main.h" +#include "strings.h"  #include "term.h"  #include "ui.h"  WINDOW *g_w2_ui_win; -unsigned int g_w2_ui_width = 0; +unsigned int g_w2_ui_width	= 0;  unsigned int g_w2_ui_height = 0;  void w2_ui_main() { -	g_w2_ui_width = getmaxx(g_w2_ui_win); +	g_w2_ui_width  = getmaxx(g_w2_ui_win);  	g_w2_ui_height = getmaxy(g_w2_ui_win);  	w2_ui_paint(); @@ -28,8 +29,7 @@ void w2_ui_paint_statusbar() {  	char temp[g_w2_ui_width + 1];  	sprintf(temp, "%s, %ims %s",  			g_w2_state.connected ? W2_UI_CONN_STAT_CONNECTED : W2_UI_CONN_STAT_DISCONNECTED, -			g_w2_state.ping, -			W2_UI_CONN_STAT_PING); +			g_w2_state.ping, W2_UI_CONN_STAT_PING);  	mvaddstr(0, 0, temp);  	sprintf(temp, "(%s)", g_w2_state.info.build_str); @@ -38,12 +38,10 @@ void w2_ui_paint_statusbar() {  	sprintf(temp, "%s %i%%", W2_UI_BATT_STAT_BATTERY, g_w2_state.battery_level);  	mvaddstr(0, g_w2_ui_width - strlen(temp), temp); -	sprintf(temp, "[mode 0x%02x]", g_w2_state.mode); +	sprintf(temp, "[%s]", g_w2_mode_strings[g_w2_state.mode]);  	mvaddstr(1, 0, temp); -	sprintf(temp, "%i %s, %i %s", -			0, W2_UI_EXPT_STAT_WARNINGS, -			0, W2_UI_EXPT_STAT_ERRORS); +	sprintf(temp, "%i %s, %i %s", 0, W2_UI_EXPT_STAT_WARNINGS, 0, W2_UI_EXPT_STAT_ERRORS);  	mvaddstr(1, g_w2_ui_width - strlen(temp), temp);  	w2_ui_paint_tabbar(); @@ -58,4 +56,3 @@ void w2_ui_paint_tabbar() {  	sprintf(temp, "-- tab bar here --");  	mvaddstr(2, g_w2_ui_width / 2 - strlen(temp) / 2, temp);  } - diff --git a/client/ui.h b/client/ui.h index 06a8cea..cac7f46 100644 --- a/client/ui.h +++ b/client/ui.h @@ -1,7 +1,7 @@  #pragma once -#include <stdint.h>  #include <ncurses.h> +#include <stdint.h>  extern WINDOW *g_w2_ui_win;  extern unsigned int g_w2_ui_width; @@ -20,4 +20,3 @@ void w2_ui_main();  void w2_ui_paint_statusbar();  /** draw tab bar */  void w2_ui_paint_tabbar(); - |