aboutsummaryrefslogtreecommitdiff
path: root/robot/modes.h
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2022-05-26 15:39:31 +0200
committerlonkaars <loek@pipeframe.xyz>2022-05-26 15:39:31 +0200
commit60f07661602a5dfe8e39b8038964b38bddcb33a5 (patch)
tree0b257acda0797a13cd09e7df2d16a6da0a6aef11 /robot/modes.h
parent333eea840a17d0f8ecf0110d952df2857fea4da0 (diff)
parentf073c9d3848dab915bed4844e9d13684aa5e23eb (diff)
merge dev into master
Diffstat (limited to 'robot/modes.h')
-rw-r--r--robot/modes.h35
1 files changed, 34 insertions, 1 deletions
diff --git a/robot/modes.h b/robot/modes.h
index dd34690..3423a0f 100644
--- a/robot/modes.h
+++ b/robot/modes.h
@@ -1,6 +1,15 @@
#pragma once
-extern void (*g_w2_current_mode)();
+#include "../shared/consts.h"
+
+#include "mode_chrg.h"
+#include "mode_dirc.h"
+#include "mode_grid.h"
+#include "mode_halt.h"
+#include "mode_lcal.h"
+#include "mode_maze.h"
+#include "mode_scal.h"
+#include "mode_spin.h"
/**
* mode logic
@@ -8,3 +17,27 @@ extern void (*g_w2_current_mode)();
* executes mode in g_w2_current_mode
*/
void w2_modes_main();
+
+/** mode constants */
+typedef enum {
+ W2_M_PREV = -1,
+ 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_e_mode;
+
+/** array that maps w2_e_mode to mode function pointers */
+static const void(*const W2_MODES[]) = {
+ &w2_mode_maze, &w2_mode_grid, &w2_mode_grid, &w2_mode_halt,
+ &w2_mode_chrg, &w2_mode_dirc, &w2_mode_spin, &w2_mode_scal,
+};
+
+/** switch current mode (allow switching back to previous mode) */
+void w2_modes_call(w2_e_mode mode);
+/** switch current mode (replace current mode keeping history index) */
+void w2_modes_swap(w2_e_mode mode);