|
@@ -20,7 +20,9 @@
|
20
|
20
|
#include <string.h>
|
21
|
21
|
|
22
|
22
|
#include "config.h"
|
|
23
|
+#include "buttons.h"
|
23
|
24
|
#include "log.h"
|
|
25
|
+#include "volcano.h"
|
24
|
26
|
#include "workflow.h"
|
25
|
27
|
#include "state.h"
|
26
|
28
|
#include "state_volcano_run.h"
|
|
@@ -42,19 +44,62 @@ void state_volcano_run_target(bd_addr_t addr, bd_addr_type_t type) {
|
42
|
44
|
ble_type = type;
|
43
|
45
|
}
|
44
|
46
|
|
|
47
|
+static void volcano_buttons(enum buttons btn, bool state) {
|
|
48
|
+ if (state && (btn == BTN_Y)) {
|
|
49
|
+ if ((!wait_for_connect) && (!wait_for_disconnect)) {
|
|
50
|
+ debug("workflow abort");
|
|
51
|
+ wf_reset();
|
|
52
|
+ volcano_set_pump_state(false);
|
|
53
|
+ volcano_set_heater_state(false);
|
|
54
|
+ ble_disconnect();
|
|
55
|
+ wait_for_disconnect = true;
|
|
56
|
+ }
|
|
57
|
+ }
|
|
58
|
+}
|
|
59
|
+
|
45
|
60
|
void state_volcano_run_enter(void) {
|
|
61
|
+ menu_init(NULL, NULL);
|
|
62
|
+ buttons_callback(volcano_buttons);
|
|
63
|
+
|
46
|
64
|
debug("workflow connect");
|
47
|
65
|
ble_connect(ble_addr, ble_type);
|
48
|
66
|
wait_for_connect = true;
|
49
|
67
|
}
|
50
|
68
|
|
51
|
69
|
void state_volcano_run_exit(void) {
|
|
70
|
+ menu_deinit();
|
52
|
71
|
wf_reset();
|
53
|
72
|
}
|
54
|
73
|
|
55
|
74
|
static void draw(struct menu_state *menu) {
|
56
|
75
|
struct wf_state state = wf_status();
|
57
|
|
- snprintf(menu->buff, MENU_MAX_LEN, "%d / %d", state.step, state.count);
|
|
76
|
+
|
|
77
|
+ int pos = 0;
|
|
78
|
+ pos += snprintf(menu->buff + pos, MENU_MAX_LEN - pos,
|
|
79
|
+ "step %d / %d\n\n", state.index, state.count);
|
|
80
|
+
|
|
81
|
+ switch (state.step.op) {
|
|
82
|
+ case OP_SET_TEMPERATURE:
|
|
83
|
+ pos += snprintf(menu->buff + pos, MENU_MAX_LEN - pos,
|
|
84
|
+ "set temp %.1f C", state.step.val / 10.0f);
|
|
85
|
+ break;
|
|
86
|
+
|
|
87
|
+ case OP_WAIT_TEMPERATURE:
|
|
88
|
+ pos += snprintf(menu->buff + pos, MENU_MAX_LEN - pos,
|
|
89
|
+ "wait temp %.1f C", state.step.val / 10.0f);
|
|
90
|
+ break;
|
|
91
|
+
|
|
92
|
+ case OP_WAIT_TIME:
|
|
93
|
+ pos += snprintf(menu->buff + pos, MENU_MAX_LEN - pos,
|
|
94
|
+ "wait time %.1f s", state.step.val / 1000.0f);
|
|
95
|
+ break;
|
|
96
|
+
|
|
97
|
+ case OP_PUMP_TIME:
|
|
98
|
+ pos += snprintf(menu->buff + pos, MENU_MAX_LEN - pos,
|
|
99
|
+ "pump time %.1f s", state.step.val / 1000.0f);
|
|
100
|
+ break;
|
|
101
|
+ }
|
|
102
|
+
|
58
|
103
|
// TODO visualize
|
59
|
104
|
}
|
60
|
105
|
|