|
@@ -18,10 +18,12 @@
|
18
|
18
|
|
19
|
19
|
#include <inttypes.h>
|
20
|
20
|
#include <string.h>
|
21
|
|
-#include "pico/stdlib.h"
|
22
|
21
|
#include <unistd.h>
|
23
|
22
|
#include <stdio.h>
|
24
|
23
|
|
|
24
|
+#include "pico/stdlib.h"
|
|
25
|
+#include "hardware/watchdog.h"
|
|
26
|
+
|
25
|
27
|
#include "config.h"
|
26
|
28
|
#include "log.h"
|
27
|
29
|
#include "util.h"
|
|
@@ -36,12 +38,11 @@
|
36
|
38
|
#include "image.h"
|
37
|
39
|
#include "volcano.h"
|
38
|
40
|
#include "serial.h"
|
|
41
|
+#include "main.h"
|
39
|
42
|
|
40
|
|
-#define CNSL_BUFF_SIZE 1024
|
|
43
|
+#define CNSL_BUFF_SIZE 64
|
41
|
44
|
#define CNSL_REPEAT_MS 500
|
42
|
45
|
|
43
|
|
-//#define TEST_VOLCANO_AUTO_CONNECT "xx:xx:xx:xx:xx:xx 1"
|
44
|
|
-
|
45
|
46
|
#define VOLCANO_AUTO_CONNECT { \
|
46
|
47
|
ble_scan(BLE_SCAN_OFF); \
|
47
|
48
|
bd_addr_t addr; \
|
|
@@ -112,6 +113,7 @@ static void cnsl_interpret(const char *line) {
|
112
|
113
|
println(" vwtt X - Volcano write target temperature");
|
113
|
114
|
println(" vwh X - Set heater to 1 or 0");
|
114
|
115
|
println(" vwp X - Set heater to 1 or 0");
|
|
116
|
+ println(" vt - Run a hard-coded test workflow");
|
115
|
117
|
println("");
|
116
|
118
|
println("Press Enter with no input to repeat last command.");
|
117
|
119
|
println("Use repeat to continuously execute last command.");
|
|
@@ -306,6 +308,94 @@ static void cnsl_interpret(const char *line) {
|
306
|
308
|
println("success");
|
307
|
309
|
}
|
308
|
310
|
}
|
|
311
|
+ } else if (strcmp(line, "vt") == 0) {
|
|
312
|
+#ifdef TEST_VOLCANO_AUTO_CONNECT
|
|
313
|
+ VOLCANO_AUTO_CONNECT
|
|
314
|
+#endif // TEST_VOLCANO_AUTO_CONNECT
|
|
315
|
+
|
|
316
|
+ println("init workflow test");
|
|
317
|
+ volcano_set_pump_state(false);
|
|
318
|
+ volcano_set_heater_state(false);
|
|
319
|
+ volcano_set_target_temp(1850);
|
|
320
|
+ volcano_set_heater_state(true);
|
|
321
|
+
|
|
322
|
+ println("wait for 185");
|
|
323
|
+ while (volcano_get_current_temp() < 1840) {
|
|
324
|
+ main_loop_hw();
|
|
325
|
+ }
|
|
326
|
+
|
|
327
|
+ println("wait for 10s");
|
|
328
|
+ uint32_t start = to_ms_since_boot(get_absolute_time());
|
|
329
|
+ while ((to_ms_since_boot(get_absolute_time()) - start) < (10 * 1000)) {
|
|
330
|
+ main_loop_hw();
|
|
331
|
+ }
|
|
332
|
+
|
|
333
|
+ println("pumping");
|
|
334
|
+ volcano_set_pump_state(true);
|
|
335
|
+
|
|
336
|
+ println("wait for 10s");
|
|
337
|
+ start = to_ms_since_boot(get_absolute_time());
|
|
338
|
+ while ((to_ms_since_boot(get_absolute_time()) - start) < (10 * 1000)) {
|
|
339
|
+ main_loop_hw();
|
|
340
|
+ }
|
|
341
|
+
|
|
342
|
+ println("step done");
|
|
343
|
+ volcano_set_pump_state(false);
|
|
344
|
+ volcano_set_target_temp(1950);
|
|
345
|
+
|
|
346
|
+ println("wait for 195");
|
|
347
|
+ while (volcano_get_current_temp() < 1940) {
|
|
348
|
+ main_loop_hw();
|
|
349
|
+ }
|
|
350
|
+
|
|
351
|
+ println("wait for 5s");
|
|
352
|
+ start = to_ms_since_boot(get_absolute_time());
|
|
353
|
+ while ((to_ms_since_boot(get_absolute_time()) - start) < (5 * 1000)) {
|
|
354
|
+ main_loop_hw();
|
|
355
|
+ }
|
|
356
|
+
|
|
357
|
+ println("pumping");
|
|
358
|
+ volcano_set_pump_state(true);
|
|
359
|
+
|
|
360
|
+ println("wait for 20s");
|
|
361
|
+ start = to_ms_since_boot(get_absolute_time());
|
|
362
|
+ while ((to_ms_since_boot(get_absolute_time()) - start) < (20 * 1000)) {
|
|
363
|
+ main_loop_hw();
|
|
364
|
+ }
|
|
365
|
+
|
|
366
|
+ println("step done");
|
|
367
|
+ volcano_set_pump_state(false);
|
|
368
|
+ volcano_set_target_temp(2050);
|
|
369
|
+
|
|
370
|
+ println("wait for 205");
|
|
371
|
+ while (volcano_get_current_temp() < 2040) {
|
|
372
|
+ main_loop_hw();
|
|
373
|
+ }
|
|
374
|
+
|
|
375
|
+ println("wait for 5s");
|
|
376
|
+ start = to_ms_since_boot(get_absolute_time());
|
|
377
|
+ while ((to_ms_since_boot(get_absolute_time()) - start) < (5 * 1000)) {
|
|
378
|
+ main_loop_hw();
|
|
379
|
+ }
|
|
380
|
+
|
|
381
|
+ println("pumping");
|
|
382
|
+ volcano_set_pump_state(true);
|
|
383
|
+
|
|
384
|
+ println("wait for 20s");
|
|
385
|
+ start = to_ms_since_boot(get_absolute_time());
|
|
386
|
+ while ((to_ms_since_boot(get_absolute_time()) - start) < (20 * 1000)) {
|
|
387
|
+ main_loop_hw();
|
|
388
|
+ }
|
|
389
|
+
|
|
390
|
+ println("turning off");
|
|
391
|
+ volcano_set_pump_state(false);
|
|
392
|
+ volcano_set_heater_state(false);
|
|
393
|
+
|
|
394
|
+ println("done");
|
|
395
|
+
|
|
396
|
+#ifdef TEST_VOLCANO_AUTO_CONNECT
|
|
397
|
+ ble_disconnect();
|
|
398
|
+#endif // TEST_VOLCANO_AUTO_CONNECT
|
309
|
399
|
} else {
|
310
|
400
|
println("unknown command \"%s\"", line);
|
311
|
401
|
}
|