summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2022-06-06 15:31:36 +0200
committerlonkaars <loek@pipeframe.xyz>2022-06-06 15:31:36 +0200
commitd69b8110517114d884c185c4dc8053858670c81f (patch)
tree8912cc5cb1b7ead5ce7469cd60356af189e926ce
parent9cbd1ed3bd8e59e24bd4db92b749213ac2c0c8f9 (diff)
scal and spin done, removed lcal
-rw-r--r--client/serial_win32.c16
-rw-r--r--client/strings.c1
-rw-r--r--client/time_windows.c4
-rw-r--r--client/ui.c6
-rw-r--r--robot/mode_scal.c17
-rw-r--r--robot/mode_spin.c3
-rw-r--r--robot/modes.c1
-rw-r--r--robot/readme.md8
-rw-r--r--robot/sercomm.c6
-rw-r--r--shared/modes.h11
10 files changed, 32 insertions, 41 deletions
diff --git a/client/serial_win32.c b/client/serial_win32.c
index edc9db1..99f4160 100644
--- a/client/serial_win32.c
+++ b/client/serial_win32.c
@@ -2,20 +2,12 @@
#include "serial.h"
-int w2_serial_read() {
- return 0x00;
-}
+int w2_serial_read() { return 0x00; }
-bool w2_serial_write(char *data, uint8_t length) {
- return true;
-}
+bool w2_serial_write(char *data, uint8_t length) { return true; }
-bool w2_serial_open(const char *port_name) {
- return true;
-}
+bool w2_serial_open(const char *port_name) { return true; }
-void w2_serial_close() {
- return;
-}
+void w2_serial_close() { return; }
#endif
diff --git a/client/strings.c b/client/strings.c
index b97d4b2..a119d9a 100644
--- a/client/strings.c
+++ b/client/strings.c
@@ -7,7 +7,6 @@ void w2_strings_modes_init() {
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;
diff --git a/client/time_windows.c b/client/time_windows.c
index f9082d6..76d1879 100644
--- a/client/time_windows.c
+++ b/client/time_windows.c
@@ -2,9 +2,7 @@
#include "time.h"
-unsigned long w2_get_time() {
- return 0;
-}
+unsigned long w2_get_time() { return 0; }
void w2_timer_start(w2_e_client_timers label) { g_w2_client_timers[label] = w2_get_time(); }
diff --git a/client/ui.c b/client/ui.c
index f636501..3835126 100644
--- a/client/ui.c
+++ b/client/ui.c
@@ -41,9 +41,9 @@ void w2_ui_paint_statusbar() {
mvaddnstr(1, 0, temp, g_w2_ui_width);
mvaddnstr(2, 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);
+ 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);
mvaddstr(0, 0, temp);
sprintf(temp, "(%s)", g_w2_state.info.build_str);
diff --git a/robot/mode_scal.c b/robot/mode_scal.c
index f3178d7..53cbf67 100644
--- a/robot/mode_scal.c
+++ b/robot/mode_scal.c
@@ -1,19 +1,20 @@
#include "mode_scal.h"
+#include "modes.h"
+#include "orangutan_shim.h"
void w2_mode_scal() {
- // TODO ???
- /* pololu_3pi_init(2000);
+ pololu_3pi_init(2000);
for (int counter = 0; counter < 80; counter++) {
if (counter < 20 || counter >= 60) {
- g_w2_io.motor_left.speed = 40;
- g_w2_io.motor_right.speed = -40;
+ set_motors(40, -40);
} else {
- g_w2_io.motor_left.speed = -40;
- g_w2_io.motor_right.speed = 40;
+ set_motors(-40, 40);
}
calibrate_line_sensors(IR_EMITTERS_ON);
- delay_ms(20); // TODO foei
- } */
+ delay_ms(20);
+ }
+
+ w2_modes_call(W2_M_PREV);
}
diff --git a/robot/mode_spin.c b/robot/mode_spin.c
index 9145eb3..9ee83b0 100644
--- a/robot/mode_spin.c
+++ b/robot/mode_spin.c
@@ -1,3 +1,4 @@
#include "mode_spin.h"
+#include "orangutan_shim.h"
-void w2_mode_spin() {}
+void w2_mode_spin() { set_motors(255, -255); }
diff --git a/robot/modes.c b/robot/modes.c
index 7decf47..fd062a8 100644
--- a/robot/modes.c
+++ b/robot/modes.c
@@ -22,7 +22,6 @@ void w2_modes_init() {
g_w2_modes[W2_M_DIRC] = &w2_mode_dirc;
g_w2_modes[W2_M_GRID] = &w2_mode_grid;
g_w2_modes[W2_M_HALT] = &w2_mode_halt;
- g_w2_modes[W2_M_LCAL] = &w2_mode_lcal;
g_w2_modes[W2_M_MAZE] = &w2_mode_maze;
g_w2_modes[W2_M_SCAL] = &w2_mode_scal;
g_w2_modes[W2_M_SPIN] = &w2_mode_spin;
diff --git a/robot/readme.md b/robot/readme.md
index f54af21..e8316e3 100644
--- a/robot/readme.md
+++ b/robot/readme.md
@@ -50,8 +50,7 @@ organizational and form more of a software 'skeleton', while the 'maze' and
Maze ─┤
Warehouse ─┤
Emergency stop ─┤
- *logic modes* -> Line finding ─┤
- Charge station ─┤
+ *logic modes* -> Charge station ─┤
Direct control ─┤
Wet floor ─┤
Sensor calibration ─┘
@@ -74,11 +73,10 @@ what they're supposed to do:
|maze |`mode_maze `|done|Jorn & Abdullaahi| controls robot during maze portion of map; hands off control to warehouse module|
|warehouse |`mode_grid `|may 31|Loek| controls robot during warehouse portion of map; hands off control to maze module|
|emergency stop |`mode_halt `|done|Fiona| stops all execution until emergency mode is reset by software or user|
-|line finding |`mode_lcal `|may 31|Fiona| find line by turning on own axis if lost|
|charge station |`mode_chrg `|may 31|Fiona| go to the charging station transition in the grid, and continue until a black circle is found|
|direct control |`mode_dirc `|done|Loek| respond to [DIRC](../protocol.md#DIRC) commands|
-|wet floor |`mode_spin `|may 31|Fiona| spin uncontrollably (simulating wet floor??)|
-|sensor calibration|`mode_scal `|may 31|Jorn & Abdullaahi| calibrate underside uv sensors|
+|wet floor |`mode_spin `|done|Fiona| spin uncontrollably (simulating wet floor??)|
+|sensor calibration|`mode_scal `|done|Jorn & Abdullaahi| calibrate underside uv sensors|
## some standards
diff --git a/robot/sercomm.c b/robot/sercomm.c
index c50dd15..f52eb7e 100644
--- a/robot/sercomm.c
+++ b/robot/sercomm.c
@@ -99,7 +99,11 @@ void w2_cmd_ping_rx(w2_s_bin *data) { w2_sercomm_append_msg(data); }
void w2_cmd_mode_rx(w2_s_bin *data) {
W2_CAST_BIN(w2_s_cmd_mode_rx, data, req);
- w2_modes_swap(req->mode);
+ if (req->mode == W2_M_SCAL) {
+ w2_modes_call(req->mode);
+ } else {
+ w2_modes_swap(req->mode);
+ }
}
void w2_cmd_sped_rx(w2_s_bin *data) { return; }
diff --git a/shared/modes.h b/shared/modes.h
index ff939ea..b58a760 100644
--- a/shared/modes.h
+++ b/shared/modes.h
@@ -1,6 +1,6 @@
#pragma once
-#define W2_MODE_COUNT 8
+#define W2_MODE_COUNT 7
/** mode constants */
typedef enum {
@@ -8,9 +8,8 @@ typedef enum {
W2_M_MAZE = 0,
W2_M_GRID = 1,
W2_M_HALT = 2,
- W2_M_LCAL = 3,
- W2_M_CHRG = 4,
- W2_M_DIRC = 5,
- W2_M_SPIN = 6,
- W2_M_SCAL = 7,
+ W2_M_CHRG = 3,
+ W2_M_DIRC = 4,
+ W2_M_SPIN = 5,
+ W2_M_SCAL = 6,
} w2_e_mode;