Browse Source

move e axis when filling. fix bug that prevented states showing their heading. fix encoder rpm scaling.

Thomas Buck 3 years ago
parent
commit
01c66d643b
3 changed files with 66 additions and 15 deletions
  1. 1
    1
      include/config.h
  2. 3
    3
      src/statemachine.cpp
  3. 62
    11
      src/states.cpp

+ 1
- 1
include/config.h View File

110
 #define Z_AXIS_EPSILON 1.0 // in mm
110
 #define Z_AXIS_EPSILON 1.0 // in mm
111
 #define E_AXIS_EPSILON 50.0 // TODO
111
 #define E_AXIS_EPSILON 50.0 // TODO
112
 
112
 
113
-#define ENCODER_RPM_VALUE_FACTOR 0.5
113
+#define ENCODER_RPM_VALUE_FACTOR 4.2
114
 #define IDLE_TIMEOUT (5UL * 60UL * 1000UL) // ms, 0 to disable
114
 #define IDLE_TIMEOUT (5UL * 60UL * 1000UL) // ms, 0 to disable
115
 
115
 
116
 // TimerOne freq for steppers
116
 // TimerOne freq for steppers

+ 3
- 3
src/statemachine.cpp View File

28
 void State::updateText(void) {
28
 void State::updateText(void) {
29
     lcd_clear();
29
     lcd_clear();
30
 
30
 
31
-    if (heading != NULL) {
31
+    if ((heading != NULL) && (strlen(heading) > 0)) {
32
         lcd_set_heading(heading);
32
         lcd_set_heading(heading);
33
-    } else if (getTitle() != NULL) {
33
+    } else if ((getTitle() != NULL) && (strlen(getTitle()) > 0)) {
34
         lcd_set_heading(getTitle());
34
         lcd_set_heading(getTitle());
35
     }
35
     }
36
 
36
 
37
-    if (text != NULL) {
37
+    if ((text != NULL) && (strlen(text) > 0)) {
38
         lcd_set_text(text);
38
         lcd_set_text(text);
39
     }
39
     }
40
 }
40
 }

+ 62
- 11
src/states.cpp View File

40
 State sm_disp_run_z_travel = State(&sm_disp_go);
40
 State sm_disp_run_z_travel = State(&sm_disp_go);
41
 State sm_disp_run_xy_travel = State(&sm_disp_run_z_travel);
41
 State sm_disp_run_xy_travel = State(&sm_disp_run_z_travel);
42
 State sm_disp_run_z_disp = State(&sm_disp_run_xy_travel);
42
 State sm_disp_run_z_disp = State(&sm_disp_run_xy_travel);
43
+// TODO add state for extrusion_bottom_wait
43
 State sm_disp_run = State(&sm_disp_run_z_disp);
44
 State sm_disp_run = State(&sm_disp_run_z_disp);
44
-State sm_disp_done = State(&sm_disp_run);
45
+State sm_disp_run_back = State(&sm_disp_run);
46
+// TODO add state for extrusion_top_wait
47
+State sm_disp_done = State(&sm_disp_run_back);
48
+State sm_disp_really_done = State(&sm_disp_done);
45
 
49
 
46
 State sm_new_preset = State(&sm_auto);
50
 State sm_new_preset = State(&sm_auto);
47
 State sm_wiz_move = State(&sm_new_preset);
51
 State sm_wiz_move = State(&sm_new_preset);
260
     sm_disp_run_z_travel.setTitle("Z Travel");
264
     sm_disp_run_z_travel.setTitle("Z Travel");
261
     sm_disp_run_z_travel.onEnter([]() {
265
     sm_disp_run_z_travel.onEnter([]() {
262
         // TODO move z to travel height
266
         // TODO move z to travel height
267
+
268
+        // print status text
269
+        strbuf = String(F("Filling ")) + String(dispense_index + 1);
270
+        strbuf += String(F(" / ")) + String(data_preset(preset_selection)->count_x * data_preset(preset_selection)->count_y);
271
+        sm_disp_run_z_travel.setText(strbuf.c_str());
263
     });
272
     });
264
     sm_disp_run_z_travel.whenIn([](StateMachineInput smi) {
273
     sm_disp_run_z_travel.whenIn([](StateMachineInput smi) {
265
-        // TODO update status screen
266
-
267
         if (smi.all_motors_done) {
274
         if (smi.all_motors_done) {
268
             states_go_to(&sm_disp_run_xy_travel);
275
             states_go_to(&sm_disp_run_xy_travel);
269
         }
276
         }
291
 
298
 
292
         steppers_move_x(x_pos);
299
         steppers_move_x(x_pos);
293
         steppers_move_y(y_pos);
300
         steppers_move_y(y_pos);
301
+
302
+        // print status text
303
+        strbuf = String(F("Filling ")) + String(dispense_index + 1);
304
+        strbuf += String(F(" / ")) + String(data_preset(preset_selection)->count_x * data_preset(preset_selection)->count_y);
305
+        sm_disp_run_xy_travel.setText(strbuf.c_str());
294
     });
306
     });
295
     sm_disp_run_xy_travel.whenIn([](StateMachineInput smi) {
307
     sm_disp_run_xy_travel.whenIn([](StateMachineInput smi) {
296
-        // TODO update status screen
297
-
298
         if (smi.all_motors_done) {
308
         if (smi.all_motors_done) {
299
             states_go_to(&sm_disp_run_z_disp);
309
             states_go_to(&sm_disp_run_z_disp);
300
         }
310
         }
302
 
312
 
303
     sm_disp_run_z_disp.setTitle("Z Dispense");
313
     sm_disp_run_z_disp.setTitle("Z Dispense");
304
     sm_disp_run_z_disp.onEnter([]() {
314
     sm_disp_run_z_disp.onEnter([]() {
305
-        // TODO move z to dispension height
315
+        // TODO move z to bottom_z
316
+
317
+        // print status text
318
+        strbuf = String(F("Filling ")) + String(dispense_index + 1);
319
+        strbuf += String(F(" / ")) + String(data_preset(preset_selection)->count_x * data_preset(preset_selection)->count_y);
320
+        sm_disp_run_z_disp.setText(strbuf.c_str());
306
     });
321
     });
307
     sm_disp_run_z_disp.whenIn([](StateMachineInput smi) {
322
     sm_disp_run_z_disp.whenIn([](StateMachineInput smi) {
308
-        // TODO update status screen
309
-
310
         if (smi.all_motors_done) {
323
         if (smi.all_motors_done) {
311
             states_go_to(&sm_disp_run);
324
             states_go_to(&sm_disp_run);
312
         }
325
         }
314
 
327
 
315
     sm_disp_run.setTitle("Dispensing");
328
     sm_disp_run.setTitle("Dispensing");
316
     sm_disp_run.onEnter([]() {
329
     sm_disp_run.onEnter([]() {
317
-        // TODO start dispensing with e and moving z up
330
+        // TODO move z to top_z
331
+
332
+        // move e to extrusion_length (bottom of press)
333
+        steppers_move_e(data_preset(preset_selection)->extrusion_length);
334
+
335
+        // print status text
336
+        strbuf = String(F("Filling ")) + String(dispense_index + 1);
337
+        strbuf += String(F(" / ")) + String(data_preset(preset_selection)->count_x * data_preset(preset_selection)->count_y);
338
+        sm_disp_run.setText(strbuf.c_str());
318
     });
339
     });
319
     sm_disp_run.whenIn([](StateMachineInput smi) {
340
     sm_disp_run.whenIn([](StateMachineInput smi) {
320
-        // TODO update status screen
341
+        if (smi.all_motors_done) {
342
+            states_go_to(&sm_disp_run_back);
343
+        }
344
+    });
345
+
346
+    sm_disp_run_back.setTitle("Dispensing Back");
347
+    sm_disp_run_back.onEnter([]() {
348
+        // move e back to 0 (top)
349
+        steppers_move_e(0.0);
321
 
350
 
351
+        // print status text
352
+        strbuf = String(F("Filling ")) + String(dispense_index + 1);
353
+        strbuf += String(F(" / ")) + String(data_preset(preset_selection)->count_x * data_preset(preset_selection)->count_y);
354
+        sm_disp_run_back.setText(strbuf.c_str());
355
+    });
356
+    sm_disp_run_back.whenIn([](StateMachineInput smi) {
322
         if (smi.all_motors_done) {
357
         if (smi.all_motors_done) {
323
             dispense_index++;
358
             dispense_index++;
324
             if (dispense_index >= (dispense_count + dispense_off)) {
359
             if (dispense_index >= (dispense_count + dispense_off)) {
330
     });
365
     });
331
 
366
 
332
     sm_disp_done.setTitle("Finished");
367
     sm_disp_done.setTitle("Finished");
368
+    sm_disp_done.setText("Moving to take-out position.");
333
     sm_disp_done.onEnter([]() {
369
     sm_disp_done.onEnter([]() {
334
-        // TODO show end screen, "stats"
370
+        steppers_move_x(X_AXIS_MAX - 20.0);
371
+        steppers_move_y(Y_AXIS_MAX - 20.0);
372
+        // TODO move z to travel height
335
     });
373
     });
336
     sm_disp_done.whenIn([](StateMachineInput smi) {
374
     sm_disp_done.whenIn([](StateMachineInput smi) {
375
+        if (smi.click || smi.all_motors_done) {
376
+            states_go_to(&sm_disp_really_done);
377
+        }
378
+    });
379
+
380
+    sm_disp_really_done.setTitle("Finished");
381
+    sm_disp_really_done.setText("Please remove tray and click to continue.");
382
+    sm_disp_really_done.onEnter([]() {
383
+        // "stop" steppers without killing them
384
+        steppers_move_x(steppers_current_pos(X_AXIS));
385
+        steppers_move_y(steppers_current_pos(Y_AXIS));
386
+    });
387
+    sm_disp_really_done.whenIn([](StateMachineInput smi) {
337
         if (smi.click) {
388
         if (smi.click) {
338
             states_go_to(&sm_auto);
389
             states_go_to(&sm_auto);
339
         }
390
         }

Loading…
Cancel
Save