MRMS
mrm-action.h
1 #pragma once
2 #include <Arduino.h>
3 #include <mrm-board.h>
4 #include <mrm-ref-can.h>
5 
6 class Robot;
7 class ActionBase {
8 protected:
9  BoardId _boardsId;
10  bool _preprocessing = true;
11  Robot* _robot;
12 
13 public:
14  char _shortcut[4];
15  char _text[19];
16  uint8_t _menuLevel;
17 
26  ActionBase(Robot* robot, const char shortcut[4], const char text[20], uint8_t menuLevel = 1, BoardId boardsId = ID_ANY);
27 
28  BoardId boardsId() { return _boardsId; }
29 
30  bool preprocessing() { return _preprocessing; }
31 
32  void preprocessingEnd() { _preprocessing = false; }
33 
34  void preprocessingStart() { _preprocessing = true; }
35 
36  virtual void performAfter() {}; // todo, not implemented.
37 
38  virtual void performBefore() {};
39 
40  virtual void perform() = 0;
41 };
42 
43 class Action8x8Test : public ActionBase {
44  void perform();
45 public:
46  Action8x8Test(Robot* robot) : ActionBase(robot, "led", "Test 8x8", 1, ID_MRM_8x8A) {}
47 };
48 
50  void perform();
51 public:
52  ActionBluetoothTest(Robot* robot) : ActionBase(robot, "blt", "Test Bluetooth", 16) {}
53 };
54 
55 class ActionCANBusScan : public ActionBase {
56  void perform();
57 public:
58  ActionCANBusScan(Robot* robot) : ActionBase(robot, "can", "Report devices", 1) {}
59 };
60 
61 class ActionCANBusSniff : public ActionBase {
62  void perform();
63 public:
64  ActionCANBusSniff(Robot* robot) : ActionBase(robot, "sni", "Sniff bus toggle", 16) {}
65 };
66 
68  void perform();
69 public:
70  ActionCANBusStress(Robot* robot) : ActionBase(robot, "all", "CAN Bus stress", 16) {}//1 | 2 | 4 | 8 | 16 | 32 | 64 | 128-> in all menus. 0 - in no menu.
71 };
72 
74  void perform();
75 public:
76  ActionColorBTest6Colors(Robot* robot) : ActionBase(robot, "10c", "Test 10 colors", 4, ID_MRM_COL_B) {}
77 };
78 
80  void perform();
81 public:
82  ActionColorBTestHSV(Robot* robot) : ActionBase(robot, "hsv", "Test HSV", 4, ID_MRM_COL_B) {}
83 };
84 
86  void perform();
87 public:
88  ActionColorIlluminationOff(Robot* robot) : ActionBase(robot, "lof", "Light off", 4, ID_MRM_COL_CAN) {}
89 };
90 
92  void perform();
93 public:
94  ActionColorIlluminationOn(Robot* robot) : ActionBase(robot, "lon", "Light on", 4, ID_MRM_COL_CAN) {}
95 };
96 
98  void perform();
99 public:
100  ActionColorPatternErase(Robot* robot) : ActionBase(robot, "per", "Erase patterns", 4, ID_MRM_COL_CAN) {}
101 };
102 
104  void perform();
105 public:
106  ActionColorPatternPrint(Robot* robot) : ActionBase(robot, "ppr", "Print patterns", 4, ID_MRM_COL_CAN) {}
107 };
108 
110  void perform();
111 public:
112  ActionColorPatternRecognize(Robot* robot) : ActionBase(robot, "pre", "Recognize pattern", 4, ID_MRM_COL_CAN) {}
113 };
114 
116  void perform();
117 public:
118  ActionColorPatternRecord(Robot* robot) : ActionBase(robot, "par", "Record patterns", 4, ID_MRM_COL_CAN) {}
119 };
120 
122  void perform();
123 public:
124  ActionColorTest6Colors(Robot* robot) : ActionBase(robot, "6co", "Test 6 colors", 4, ID_MRM_COL_CAN) {}
125 };
126 
128  void perform();
129 public:
130  ActionColorTestHSV(Robot* robot) : ActionBase(robot, "hsv", "Test HSV", 4, ID_MRM_COL_CAN) {}
131 };
132 
134  void perform();
135 public:
136  ActionDeviceIdChange(Robot* robot) : ActionBase(robot, "idc", "Device's id change", 1) {}
137 };
138 
139 class ActionDoNothing : public ActionBase {
140  void perform() {}
141 public:
142  ActionDoNothing(Robot* robot) : ActionBase(robot, "", "No action", 0) {}
143 };
144 
145 class ActionFirmware : public ActionBase {
146  void perform();
147 public:
148  ActionFirmware(Robot* robot) : ActionBase(robot, "fir", "Firmware", 16) {}
149 };
150 
151 class ActionFPS : public ActionBase {
152  void perform();
153 public:
154  ActionFPS(Robot* robot) : ActionBase(robot, "fps", "FPS", 16) {}
155 };
156 
157 class ActionGoAhead : public ActionBase {
158  void perform();
159 public:
160  ActionGoAhead(Robot* robot) : ActionBase(robot, "ahe", "Go ahead", 1) {}
161 };
162 
163 class ActionI2CTest : public ActionBase {
164  void perform();
165 public:
166  ActionI2CTest(Robot* robot) : ActionBase(robot, "i2c", "Test I2C", 16) {}
167 };
168 
169 class ActionIMUTest : public ActionBase {
170  void perform();
171 public:
172  ActionIMUTest(Robot* robot) : ActionBase(robot, "imu", "Test IMU", 1) {}
173 };
174 
175 class ActionInfo : public ActionBase {
176  void perform();
177 public:
178  ActionInfo(Robot* robot) : ActionBase(robot, "inf", "Info", 1) {}
179 };
180 
182  void perform();
183 public:
184  ActionIRFinderTest(Robot* robot) : ActionBase(robot, "irf", "Test ball analog", 1) {}
185 };
186 
188  void perform();
189 public:
190  ActionIRFinderCanTest(Robot* robot) : ActionBase(robot, "irs", "Test ball every", 1, ID_MRM_IR_FINDER3) {}
191 };
192 
194  void perform();
195 public:
196  ActionIRFinderCanTestCalculated(Robot* robot) : ActionBase(robot, "irc", "Test ball calcul.", 1, ID_MRM_IR_FINDER3) {}
197 };
198 
200  void perform();
201 public:
202  ActionLidar2mTest(Robot* robot) : ActionBase(robot, "li2", "Test li. 2m", 1, ID_MRM_LID_CAN_B) {}
203 };
204 
206  void perform();
207 public:
208  ActionLidar4mTest(Robot* robot) : ActionBase(robot, "li4", "Test li. 4m", 1, ID_MRM_LID_CAN_B2){}
209 };
210 
212  void perform();
213 public:
214  ActionLidarCalibrate(Robot* robot) : ActionBase(robot, "lic", "Cal. lidar", 1) {}
215 };
216 
217 class ActionLoop : public ActionBase {
218  void perform();
219 public:
220  ActionLoop(Robot* robot) : ActionBase(robot, "loo", "Loop test", 1) {}
221 };
222 
223 class ActionMenuColor : public ActionBase {
224  void perform();
225 public:
226  ActionMenuColor(Robot* robot) : ActionBase(robot, "col", "Color (menu)", 1, ID_MRM_COL_CAN) {}
227 };
228 
229 class ActionMenuColorB : public ActionBase {
230  void perform();
231 public:
232  ActionMenuColorB(Robot* robot) : ActionBase(robot, "col", "Color (menu)", 1, ID_MRM_COL_B) {}
233 };
234 
235 class ActionMenuMain : public ActionBase {
236  void perform();
237 public:
238  ActionMenuMain(Robot* robot) : ActionBase(robot, "x", "Escape", 2 | 4 | 8 | 16 | 32 | 64 | 128) {}//2 | 4 | 8 | 16 -> in all menus except 1. 0 - in no menu.
239 };
240 
242  void perform();
243 public:
244  ActionMenuReflectance(Robot* robot) : ActionBase(robot, "ref", "Reflectance (menu)", 1, ID_MRM_REF_CAN) {}
245 };
246 
247 class ActionMenuSystem : public ActionBase {
248  void perform();
249 public:
250  ActionMenuSystem(Robot* robot) : ActionBase(robot, "sys", "System (menu)", 1) {}
251 };
252 
253 class ActionMotorTest : public ActionBase {
254  void perform();
255 public:
256  ActionMotorTest(Robot* robot) : ActionBase(robot, "mot", "Test motors", 1) {}
257 };
258 
259 class ActionNodeTest : public ActionBase {
260  void perform();
261 public:
262  ActionNodeTest(Robot* robot) : ActionBase(robot, "nod", "Test node", 1, ID_MRM_NODE) {}
263 };
264 
266  void perform();
267 public:
268  ActionNodeServoTest(Robot* robot) : ActionBase(robot, "nos", "Test node servo", 1, ID_MRM_NODE) {}
269 };
270 
271 //class ActionOscillatorTest : public ActionBase {
272 // void perform();
273 //public:
274 // ActionOscillatorTest(Robot* robot) : ActionBase(robot, "osc", "Oscillator test", 1, ID_ANY) {}
275 //};
276 
277 class ActionStop : public ActionBase {
278  void perform();
279 public:
280  ActionStop(Robot* robot) : ActionBase(robot, "sto", "Stop", 1) {}
281 };
282 
284  void perform();
285 public:
286  ActionReflectanceArrayAnalogTest(Robot* robot) : ActionBase(robot, "anr", "Test refl. anal.", 2, ID_MRM_REF_CAN) {}
287 };
288 
290  void perform();
291 public:
292  ActionReflectanceArrayDigitalTest(Robot* robot) : ActionBase(robot, "dgr", "Test refl. digi.", 2, ID_MRM_REF_CAN) {}
293 };
294 
296  void perform();
297 public:
298  ActionReflectanceArrayCalibrate(Robot* robot) : ActionBase(robot, "cal", "Calibrate refl.", 2, ID_MRM_REF_CAN) {}
299 };
300 
302  void perform();
303 public:
304  ActionReflectanceArrayCalibrationPrint(Robot* robot) : ActionBase(robot, "pri", "Calibration print", 2, ID_MRM_REF_CAN) {}
305 };
306 
307 class ActionServoTest : public ActionBase {
308  void perform();
309 public:
310  ActionServoTest(Robot* robot) : ActionBase(robot, "ser", "Test servo", 1) {}
311 };
312 
314  void perform();
315 public:
316  ActionServoInteractive(Robot* robot) : ActionBase(robot, "ses", "Set servo", 1) {}
317 };
318 
319 class ActionThermoTest : public ActionBase {
320  void perform();
321 public:
322  ActionThermoTest(Robot* robot) : ActionBase(robot, "the", "Test thermo", 1, ID_MRM_THERM_B_CAN) {}
323 };
324 
325 class ActionUS_BTest : public ActionBase {
326  void perform();
327 public:
328  ActionUS_BTest(Robot* robot) : ActionBase(robot, "uls", "Test ultras.", 1, ID_MRM_US_B) {}
329 };
330 
331 class ActionUS1Test : public ActionBase {
332  void perform();
333 public:
334  ActionUS1Test(Robot* robot) : ActionBase(robot, "ult", "Test ultras.", 1, ID_MRM_US1) {}
335 };
Definition: mrm-action.h:43
Definition: mrm-action.h:7
ActionBase(Robot *robot, const char shortcut[4], const char text[20], uint8_t menuLevel=1, BoardId boardsId=ID_ANY)
Definition: mrm-action.cpp:23
Definition: mrm-action.h:49
Definition: mrm-action.h:55
Definition: mrm-action.h:61
Definition: mrm-action.h:67
Definition: mrm-action.h:73
Definition: mrm-action.h:79
Definition: mrm-action.h:85
Definition: mrm-action.h:91
Definition: mrm-action.h:97
Definition: mrm-action.h:103
Definition: mrm-action.h:109
Definition: mrm-action.h:115
Definition: mrm-action.h:121
Definition: mrm-action.h:127
Definition: mrm-action.h:133
Definition: mrm-action.h:139
Definition: mrm-action.h:151
Definition: mrm-action.h:145
Definition: mrm-action.h:157
Definition: mrm-action.h:163
Definition: mrm-action.h:169
Definition: mrm-action.h:193
Definition: mrm-action.h:187
Definition: mrm-action.h:181
Definition: mrm-action.h:175
Definition: mrm-action.h:199
Definition: mrm-action.h:205
Definition: mrm-action.h:211
Definition: mrm-action.h:217
Definition: mrm-action.h:229
Definition: mrm-action.h:223
Definition: mrm-action.h:235
Definition: mrm-action.h:241
Definition: mrm-action.h:247
Definition: mrm-action.h:253
Definition: mrm-action.h:265
Definition: mrm-action.h:259
Definition: mrm-action.h:283
Definition: mrm-action.h:295
Definition: mrm-action.h:301
Definition: mrm-action.h:289
Definition: mrm-action.h:313
Definition: mrm-action.h:307
Definition: mrm-action.h:277
Definition: mrm-action.h:319
Definition: mrm-action.h:331
Definition: mrm-action.h:325
Definition: mrm-robot.h:42