Browse Source

print current value in workflow

Thomas Buck 1 year ago
parent
commit
965cf087d8
3 changed files with 37 additions and 12 deletions
  1. 1
    0
      include/workflow.h
  2. 16
    8
      src/state_volcano_run.c
  3. 20
    4
      src/workflow.c

+ 1
- 0
include/workflow.h View File

44
     uint16_t index;
44
     uint16_t index;
45
     uint16_t count;
45
     uint16_t count;
46
     struct wf_step step;
46
     struct wf_step step;
47
+    uint16_t start_val, curr_val;
47
 };
48
 };
48
 
49
 
49
 uint16_t wf_count(void);
50
 uint16_t wf_count(void);

+ 16
- 8
src/state_volcano_run.c View File

81
 
81
 
82
     int pos = 0;
82
     int pos = 0;
83
     pos += snprintf(menu->buff + pos, MENU_MAX_LEN - pos,
83
     pos += snprintf(menu->buff + pos, MENU_MAX_LEN - pos,
84
-                    "step %d / %d\n\n", state.index, state.count);
84
+                    "step %d / %d\n", state.index, state.count);
85
 
85
 
86
     switch (state.step.op) {
86
     switch (state.step.op) {
87
     case OP_SET_TEMPERATURE:
87
     case OP_SET_TEMPERATURE:
88
         pos += snprintf(menu->buff + pos, MENU_MAX_LEN - pos,
88
         pos += snprintf(menu->buff + pos, MENU_MAX_LEN - pos,
89
-                        "set temp %.1f C", state.step.val / 10.0f);
89
+                        "\nset temp %.1f C", state.step.val / 10.0f);
90
         break;
90
         break;
91
 
91
 
92
     case OP_WAIT_TEMPERATURE:
92
     case OP_WAIT_TEMPERATURE:
93
         pos += snprintf(menu->buff + pos, MENU_MAX_LEN - pos,
93
         pos += snprintf(menu->buff + pos, MENU_MAX_LEN - pos,
94
-                        "wait temp %.1f C", state.step.val / 10.0f);
95
-        break;
96
-
97
-    case OP_WAIT_TIME:
94
+                        "wait temp %.1f C\n", state.step.val / 10.0f);
98
         pos += snprintf(menu->buff + pos, MENU_MAX_LEN - pos,
95
         pos += snprintf(menu->buff + pos, MENU_MAX_LEN - pos,
99
-                        "wait time %.1f s", state.step.val / 1000.0f);
96
+                        "%.1f -> %.1f -> %.1f",
97
+                        state.start_val / 10.0f,
98
+                        state.curr_val / 10.0f,
99
+                        state.step.val / 10.0f);
100
         break;
100
         break;
101
 
101
 
102
+    case OP_WAIT_TIME:
102
     case OP_PUMP_TIME:
103
     case OP_PUMP_TIME:
103
         pos += snprintf(menu->buff + pos, MENU_MAX_LEN - pos,
104
         pos += snprintf(menu->buff + pos, MENU_MAX_LEN - pos,
104
-                        "pump time %.1f s", state.step.val / 1000.0f);
105
+                        "%s time %.1f s\n",
106
+                        (state.step.op == OP_WAIT_TIME) ? "wait" : "pump",
107
+                        state.step.val / 1000.0f);
108
+        pos += snprintf(menu->buff + pos, MENU_MAX_LEN - pos,
109
+                        "%.1f -> %.1f -> %.1f",
110
+                        state.start_val / 1000.0f,
111
+                        state.curr_val / 1000.0f,
112
+                        state.step.val / 1000.0f);
105
         break;
113
         break;
106
     }
114
     }
107
 
115
 

+ 20
- 4
src/workflow.c View File

129
 static uint16_t wf_i = 0;
129
 static uint16_t wf_i = 0;
130
 static uint16_t step = 0;
130
 static uint16_t step = 0;
131
 static uint32_t start_t = 0;
131
 static uint32_t start_t = 0;
132
+static uint16_t start_val = 0;
133
+static uint16_t curr_val = 0;
132
 
134
 
133
 static void do_step(void) {
135
 static void do_step(void) {
134
     switch (wf[wf_i].steps[step].op) {
136
     switch (wf[wf_i].steps[step].op) {
135
     case OP_SET_TEMPERATURE:
137
     case OP_SET_TEMPERATURE:
136
     case OP_WAIT_TEMPERATURE:
138
     case OP_WAIT_TEMPERATURE:
137
         debug("workflow temp %.1f C", wf[wf_i].steps[step].val / 10.0);
139
         debug("workflow temp %.1f C", wf[wf_i].steps[step].val / 10.0);
140
+        start_val = volcano_get_current_temp();
138
         volcano_set_target_temp(wf[wf_i].steps[step].val);
141
         volcano_set_target_temp(wf[wf_i].steps[step].val);
139
         break;
142
         break;
140
 
143
 
141
     case OP_PUMP_TIME:
144
     case OP_PUMP_TIME:
142
         volcano_set_pump_state(true);
145
         volcano_set_pump_state(true);
143
         start_t = to_ms_since_boot(get_absolute_time());
146
         start_t = to_ms_since_boot(get_absolute_time());
147
+        start_val = 0;
144
         debug("workflow pump %.3f s", wf[wf_i].steps[step].val / 1000.0);
148
         debug("workflow pump %.3f s", wf[wf_i].steps[step].val / 1000.0);
145
         break;
149
         break;
146
 
150
 
147
     case OP_WAIT_TIME:
151
     case OP_WAIT_TIME:
148
         start_t = to_ms_since_boot(get_absolute_time());
152
         start_t = to_ms_since_boot(get_absolute_time());
153
+        start_val = 0;
149
         debug("workflow time %.3f s", wf[wf_i].steps[step].val / 1000.0);
154
         debug("workflow time %.3f s", wf[wf_i].steps[step].val / 1000.0);
150
         break;
155
         break;
151
     }
156
     }
157
+
158
+    curr_val = start_val;
152
 }
159
 }
153
 
160
 
154
 uint16_t wf_count(void) {
161
 uint16_t wf_count(void) {
177
         .index = step,
184
         .index = step,
178
         .count = wf[wf_i].count,
185
         .count = wf[wf_i].count,
179
         .step = wf[wf_i].steps[step],
186
         .step = wf[wf_i].steps[step],
187
+        .start_val = start_val,
188
+        .curr_val = curr_val,
180
     };
189
     };
181
     return s;
190
     return s;
182
 }
191
 }
221
         done = true;
230
         done = true;
222
         break;
231
         break;
223
 
232
 
224
-    case OP_WAIT_TEMPERATURE:
225
-        done = (volcano_get_current_temp() >= (wf[wf_i].steps[step].val - 5));
233
+    case OP_WAIT_TEMPERATURE: {
234
+        uint16_t temp = volcano_get_current_temp();
235
+        curr_val = temp;
236
+        done = (temp >= (wf[wf_i].steps[step].val - 5));
226
         break;
237
         break;
238
+    }
227
 
239
 
228
     case OP_PUMP_TIME:
240
     case OP_PUMP_TIME:
229
-    case OP_WAIT_TIME:
230
-        done = ((to_ms_since_boot(get_absolute_time()) - start_t) >= wf[wf_i].steps[step].val);
241
+    case OP_WAIT_TIME: {
242
+        uint32_t now = to_ms_since_boot(get_absolute_time());
243
+        uint32_t diff = now - start_t;
244
+        curr_val = diff;
245
+        done = (diff >= wf[wf_i].steps[step].val);
231
         break;
246
         break;
232
     }
247
     }
248
+    }
233
 
249
 
234
     if (done) {
250
     if (done) {
235
         if (wf[wf_i].steps[step].op == OP_PUMP_TIME) {
251
         if (wf[wf_i].steps[step].op == OP_PUMP_TIME) {

Loading…
Cancel
Save