-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgApp.cpp
840 lines (681 loc) · 22.9 KB
/
gApp.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
//--------------------------------------
// Application specific classes
//--------------------------------------
#include "gApp.h"
#include "gPrefs.h"
#include "winMain.h"
#include "winFiles.h"
#include "dlgMsg.h"
// #include "dlgMainMenu.h"
#include "dlgWifiSettings.h"
#ifdef UI_WITH_MESH
#include <Mesh.h> // FluidNC_extensions
#endif
#define DEBUG_APP 0
#define MAX_WINDOW_STACK 5
#define MAX_ACTIVE_FILENAME 80
// IDS OF ANY PARENTS MUST BE GLOBALLY UNIQUE !!
#define ID_APP_BUTTON (0x0021 | ID_TYPE_TEXT | ID_TYPE_BUTTON | ID_TYPE_MUTABLE)
#define ID_APP_TITLE (0x0022 | ID_TYPE_TEXT | ID_TYPE_MUTABLE | ID_TYPE_NO_BORDER | ID_TYPE_BUTTON)
#define ID_SD_INDICATOR (0x0023)
#define ID_WIFI_INDICATOR (0x0024)
#define ID_STATUSBAR (0x0030)
#define ID_MACHINE_X (0x0031)
#define ID_MACHINE_Y (0x0032)
#define ID_MACHINE_Z (0x0033)
#define ID_WORK_X (0x0034)
#define ID_WORK_Y (0x0035)
#define ID_WORK_Z (0x0036)
#define ID_GRBL_STATE (0x0037)
#define ID_MEMAVAIL (0x0038)
#define ID_MEMAVAIL_MIN (0x0039)
gApplication the_app;
static uint8_t win_stack_ptr = 0;
static uiWindow *win_stack[MAX_WINDOW_STACK] = {0};
static char app_button_buf[UI_MAX_BUTTON + 1] = "MAIN";
static char app_title_buf[UI_MAX_TITLE + 1] = "";
static char active_filename[MAX_ACTIVE_FILENAME + 1] = "";
//----------------------------------------------------------------------
// FRAME DEFINITION
//----------------------------------------------------------------------
static uiMutable app_button = {
app_button_buf,
COLOR_BLUE,
COLOR_WHITE,
FONT_BIG
};
static uiMutable app_title = {
app_title_buf,
COLOR_DARKBLUE,
COLOR_WHITE,
FONT_SMALL
};
#define CHAR_WIFI_SYMBOL "\x20"
#define CHAR_SD_SYMBOL "\x21"
static const uiElement app_elements[] =
{
{ ID_APP_BUTTON, 0, 0, 90, 35, V(&app_button) },
{ ID_APP_TITLE, 94, 0, 180, 35, V(&app_title) },
{ ID_SD_INDICATOR, 274, 0, 23, 35, 0, COLOR_DARKBLUE, COLOR_WHITE, FONT_SYMBOL, JUST_CENTER, },
{ ID_WIFI_INDICATOR, 297, 0, 23, 35, 0, COLOR_DARKBLUE, COLOR_WHITE, FONT_SYMBOL, JUST_CENTER, },
{ ID_STATUSBAR, 0, 205, 320, 35, 0, COLOR_DARKBLUE, COLOR_WHITE, },
{ ID_MACHINE_X, 10, 205, 55, 16, V(UI_AXIS_X), COLOR_DARKBLUE, COLOR_WHITE, FONT_MONO, JUST_RIGHT, },
{ ID_MACHINE_Y, 75, 205, 55, 16, V(UI_AXIS_Y), COLOR_DARKBLUE, COLOR_WHITE, FONT_MONO, JUST_RIGHT, },
{ ID_MACHINE_Z, 140, 205, 50, 16, V(UI_AXIS_Z), COLOR_DARKBLUE, COLOR_WHITE, FONT_MONO, JUST_RIGHT, },
{ ID_WORK_X, 10, 222, 55, 16, V(UI_AXIS_X), COLOR_DARKBLUE, COLOR_WHITE, FONT_MONO, JUST_RIGHT, },
{ ID_WORK_Y, 75, 222, 55, 16, V(UI_AXIS_Y), COLOR_DARKBLUE, COLOR_WHITE, FONT_MONO, JUST_RIGHT, },
{ ID_WORK_Z, 140, 222, 50, 16, V(UI_AXIS_Z), COLOR_DARKBLUE, COLOR_WHITE, FONT_MONO, JUST_RIGHT, },
{ ID_GRBL_STATE, 192, 205, 76, 35, 0, COLOR_DARKBLUE, COLOR_WHITE, FONT_NORMAL, JUST_CENTER, },
{ ID_MEMAVAIL, 270, 205, 49, 15, 0, COLOR_DARKBLUE, COLOR_WHITE, FONT_MONO, JUST_RIGHT, },
{ ID_MEMAVAIL_MIN, 270, 222, 49, 15, 0, COLOR_DARKBLUE, COLOR_WHITE, FONT_MONO, JUST_RIGHT, },
};
#define IDX_STATUSBAR 4
//----------------------------
// implementation
//----------------------------
gApplication::gApplication() :
uiWindow(app_elements,sizeof(app_elements)/sizeof(uiElement))
{
}
void gApplication::begin()
{
delay(400); // more attempt to stop garbling output
g_info("gApplication::begin() started ...");
readPrefs();
status_mode = 1;
draw_needed = true;
suppress_status = false;
g_status.initWifiEventHandler();
setDefaultWindow((uiWindow *)&main_win);
g_info("gApplication::begin() finished.");
}
void gApplication::openWindow(uiWindow *win)
{
if (win->isModal())
{
win_stack_ptr++;
#if DEBUG_APP
g_debug("openWindow(modal) stack=%d",win_stack_ptr);
#endif
if (win_stack_ptr>1)
{
strcpy(app_button_buf,"back");
drawTypedElement(&app_elements[0]);
}
}
win_stack[win_stack_ptr] = win;
win->begin();
}
void gApplication::endModal()
{
if (win_stack[win_stack_ptr]->isModal())
{
#if DEBUG_APP
g_debug("endModal stack=%d",win_stack_ptr);
#endif
setTitle("");
draw_needed = true;
win_stack_ptr--;
suppress_status = false;
win_stack[win_stack_ptr]->begin();
}
}
void gApplication::setBaseWindow(uiWindow *win)
{
win_stack_ptr = 0;
setAppButtonText(win->getMenuLabel());
openWindow(win);
}
void gApplication::onButton(const uiElement *ele, bool pressed)
{
if (!pressed && ele->id_type == ID_APP_BUTTON)
{
if (win_stack[win_stack_ptr]->isModal())
endModal();
else if (win_stack[0] == &main_win)
setBaseWindow(&files_win);
else
setBaseWindow(&main_win);
}
else if (!pressed && ele->id_type == ID_APP_TITLE)
{
if (win_stack[win_stack_ptr]->isModal())
endModal();
else
openWindow(&dlg_wifi_settings);
}
}
bool gApplication::hitTest()
{
if (g_pressed && !g_win_pressed)
{
if (!suppress_status &&
g_press_y > UI_SCREEN_HEIGHT - UI_BOTTOM_MARGIN &&
g_press_x < UI_SCREEN_WIDTH - 80 ) // to avoid conflict with z button
{
status_mode = !status_mode;
const uiElement *ele =&m_elements[IDX_STATUSBAR];
g_win_pressed = ele;
g_window_pressed = this;
#if DEBUG_APP
g_debug("gApplication hitTest()");
#endif
return true;
}
}
return uiWindow::hitTest();
}
//------------------------
// utilities
//------------------------
const char *gApplication::getActiveFilename()
{
return active_filename;
}
void gApplication::setAppButtonText(const char *text)
{
int len = strlen(text);
if (len > UI_MAX_BUTTON) len = UI_MAX_BUTTON;
memcpy(app_button_buf,text,len);
app_button_buf[len] = 0;
}
void gApplication::setTitle(const char *text)
{
int len = strlen(text);
if (len > UI_MAX_TITLE) len = UI_MAX_TITLE;
memcpy(app_title_buf, text,len);
app_title_buf[len] = 0;
}
uint16_t gApplication::indColor(uint8_t ind_state)
{
return
ind_state == IND_STATE_ENABLED ? COLOR_CYAN :
ind_state == IND_STATE_READY ? COLOR_GREEN :
ind_state == IND_STATE_ACTIVE ? COLOR_YELLOW :
ind_state == IND_STATE_ERROR ? COLOR_RED :
COLOR_LIGHTGREY;
}
void gApplication::doText(const uiElement *ele, const char *text)
{
drawText(
text,
ele->just,
ele->font,
ele->x, ele->y, ele->w, ele->h,
ele->fg,
ele->bg );
}
//--------------------------------
// frame callbacks
//--------------------------------
void gApplication::doAppButton(const uiElement *ele)
{
uiWindow *bottom_win = win_stack[0];
uiWindow *win = win_stack[win_stack_ptr];
bool is_main_win = bottom_win == ((uiWindow *)&main_win);
float pct = g_status.filePct();
bool busy_or_hold =
job_state == JOB_BUSY ||
job_state == JOB_HOLD;
bool pct_changed =
is_main_win &&
busy_or_hold &&
last.pct != pct;
if (draw_needed ||
pct_changed ||
win != last.window ||
job_state != last.job_state)
{
if (is_main_win && busy_or_hold)
sprintf(app_button_buf,"%2.1f%%",pct);
else if (win_stack_ptr)
strcpy(app_button_buf,"BACK");
else if (win_stack[0] == &main_win)
strcpy(app_button_buf,"FILES");
else
strcpy(app_button_buf,"MAIN");
app_button.fg =
job_state == JOB_HOLD ? COLOR_CYAN :
job_state != JOB_IDLE ? COLOR_YELLOW :
COLOR_WHITE;
drawTypedElement(ele,false);
}
}
void gApplication::doAppTitle(const uiElement *ele)
{
if (draw_needed ||
job_state != last.job_state ||
strcmp(app_title_buf,last.app_title))
{
// the title, whatever it happens to be
// stays red when alarm, yellow when busy,
// cyan when hold, or white when idle
app_title.fg =
job_state == JOB_HOMING || job_state == JOB_ALARM ? COLOR_YELLOW : // COLOR_RED :
job_state == JOB_HOLD ? COLOR_CYAN :
job_state == JOB_BUSY ? COLOR_YELLOW :
COLOR_WHITE;
drawTypedElement(ele,false);
}
}
void gApplication::doSDIndicator(const uiElement *ele)
{
if (draw_needed || last.sd_state != sd_state)
{
uint8_t ind_state =
sd_state == SDState::NotPresent ? IND_STATE_NONE :
sd_state == SDState::Idle ? IND_STATE_READY :
IND_STATE_ACTIVE;
drawText(
CHAR_SD_SYMBOL,
ele->just,
ele->font,
ele->x, ele->y, ele->w, ele->h,
indColor(ind_state),
ele->bg );
}
}
void gApplication::doWifiIndicator(const uiElement *ele)
{
uint8_t state = g_status.getWifiState();
if (draw_needed || last.wifi_state != state)
{
last.wifi_state = state;
drawText(
CHAR_WIFI_SYMBOL,
ele->just,
ele->font,
ele->x, ele->y, ele->w, ele->h,
indColor(state),
ele->bg );
}
}
void gApplication::doMachinePosition(const uiElement *ele)
{
int idx = (int) ele->param;
float *last_val = &last.pos[idx];
float val = g_status.m_machine_pos[idx];
bool changed = draw_needed || *last_val != val;
if (changed ||
last.prog_w != prog_w)
{
*last_val = val;
char buf[12];
sprintf(buf,"%3.1f",val);
doTextProgress(ele,buf,changed);
}
}
void gApplication::doWorkPosition(const uiElement *ele)
{
int idx = (int) ele->param;
float *last_val = &last.pos[UI_NUM_AXES + idx];
float val = g_status.m_work_pos[idx];
bool changed = draw_needed || *last_val != val;
if (changed ||
last.prog_w != prog_w)
{
*last_val = val;
char buf[12];
sprintf(buf,"%3.1f",val);
doTextProgress(ele,buf,changed);
}
}
void gApplication::doSysState(const uiElement *ele)
{
bool changed = draw_needed ||
(last.sys_state != sys_state) ||
(last.status_mode != status_mode) ||
(status_mode & last.feed_rate != feed_rate);
if (changed ||
last.prog_w != prog_w)
{
if (status_mode)
{
char buf[6];
int i_feed_rate = feed_rate;
sprintf(buf,"F%-3d",i_feed_rate);
doTextProgress(ele,buf,changed);
}
else
{
doTextProgress(ele,sysStateName(sys_state),changed);
}
}
}
void gApplication::doMemAvail(const uiElement *ele)
{
uint16_t id_type = ele->id_type;
#ifdef UI_WITH_MESH
if (status_mode)
{
static bool was_valid = false;
bool is_live_z = id_type == ID_MEMAVAIL;
bool is_valid = the_mesh.isValid();
float z = is_live_z ? live_z : mesh_z ;
float prev = is_live_z ? last.live_z : last.mesh_z ;
bool changed =
draw_needed ||
prev != z ||
was_valid != is_valid ||
last.status_mode != status_mode;
if (changed ||
last.prog_w != prog_w)
{
prev = z;
was_valid = the_mesh.isValid();
if (is_live_z || is_valid) // don't show mesh if not valid
{
char buf[12];
sprintf(buf,"%0.3f",z);
doTextProgress(ele,buf,changed);
}
else
{
doTextProgress(ele,"",changed);
}
}
}
else
#endif
{
uint32_t avail = id_type == ID_MEMAVAIL ?
xPortGetFreeHeapSize() :
xPortGetMinimumEverFreeHeapSize();
avail /= 1024;
uint32_t *prev = id_type == ID_MEMAVAIL ?
&last.mem_avail :
&last.min_avail;
bool changed = draw_needed || *prev != avail ||
last.status_mode != status_mode;
if (changed ||
last.prog_w != prog_w)
{
*prev = avail;
char buf[12];
sprintf(buf,"%dK",avail);
doTextProgress(ele,buf,changed);
}
}
}
//-------------------------
// progress bar
//-------------------------
void gApplication::initProgress()
{
prog_x = 0;
prog_w = 0;
last.prog_w = 0;
#if DEBUG_APP
g_debug("initProgress()");
#endif
}
void gApplication::doTextProgress(const uiElement *ele, const char *text, bool changed)
// Called for fields that lie on the progress bar to draw the text.
// Called if the field has changed or last.prog_w != prog_w,
// which implies that a new bar portion has been drawn.
{
// develop s,e notation
int16_t win_s = ele->x;
int16_t win_e = ele->x + ele->w - 1;
int16_t prog_s = prog_x + last.prog_w;
int16_t prog_e = prog_x + prog_w - 1;
// win_s > prog_e implies that there is no progress bar or
// the field lays completely to the right of the progress bar
// so we only write the value if it changed using default background
if (win_s > prog_e)
{
if (changed)
doText(ele,text);
return;
}
// At least part of the field overlays the progress bar.
// We will redraw if it has changed, or if the field
// is over the "new" bar portion.
// If it was changed, and the field is to the left
// of the progress bar, we stretch prog_s to the beginning
// of the field to draw fully 'changed' bar backgrounds
if (changed && prog_s > win_s)
{
prog_s = win_s;
}
// Constrain the new progress area to the field window.
// bar will always start from the left.
if (prog_s < win_s)
prog_s = win_s;
if (prog_e > win_e)
prog_e = win_e;
// So now we can just compare and see if the window
// falls into the extended region, and leave if not.
if (!changed && (win_e < prog_s || win_s > prog_e))
{
return;
}
// Calculate the "blue" portion if any
int16_t normal_s = win_s;
int16_t normal_w = 0;
if (prog_e < win_e)
{
normal_s = prog_e + 1;
normal_w = win_e - prog_e;
}
// Change se notation back to x,w format and
// draw the bar and normal bg portions, if any.
int16_t bar_w = prog_e - prog_s + 1;
if (bar_w > 0)
tft.fillRect(prog_s,ele->y,bar_w,ele->h,prog_color);
if (normal_w > 0)
tft.fillRect(normal_s,ele->y,normal_w,ele->h,ele->bg);
// Finally ... draw the text with no background color
drawText(
text,
ele->just,
ele->font,
ele->x, ele->y, ele->w, ele->h,
ele->fg,
ele->fg ); // bg <= fg implies no background
}
void gApplication::doJobProgress(const uiElement *ele)
{
if (draw_needed)
{
tft.fillRect(
ele->x, ele->y, ele->w, ele->h,
ele->bg);
}
// we fill the bar if the color has changed
// or the percent has changed
float pct = job_state == JOB_HOLD || job_state == JOB_BUSY ? g_status.filePct() : 0;
prog_color = job_state == JOB_HOLD ? COLOR_DARKCYAN : COLOR_DARKGREEN;
if (last.pct != pct ||
last.prog_color != prog_color)
{
// invalidate the progress bar upon a color change
if (last.prog_color != prog_color)
last.prog_w = 0;
prog_x = ele->x; // 0
prog_w = ((pct * ele->w)/100.0);
// draw from last.prog_w to prog_w
if (last.prog_w != prog_w)
{
tft.fillRect(
prog_x + last.prog_w, ele->y, prog_w - last.prog_w, ele->h,
prog_color);
}
}
}
//----------------------------------
// update()
//----------------------------------
void gApplication::setDefaultWindow(uiWindow *win)
// set window without doing openWindow
// which is deferred
{
win_stack_ptr = 0;
win_stack[0] = win;
setAppButtonText(win->getMenuLabel());
}
void gApplication::update()
{
// screen grabs "freeze" the state of the UI
#ifdef WITH_SCREEN_GRAB
if (in_screen_grab)
return;
#endif
// update the gStatus object
g_status.updateStatus(
#ifdef UI_WITH_MESH
the_mesh.inLeveling()
#endif
);
// copy the state into gApplication variables that are
// valid for one time through update()
sys_state = g_status.getSysState();
sd_state = g_status.getSDState();
job_state = g_status.getJobState();
feed_rate = g_status.getFeedRate();
#ifdef UI_WITH_MESH
live_z = the_mesh.getLiveZ();
mesh_z = the_mesh.getLastMeshZ();
#endif
bool job_finished = false;
if (job_state != last.job_state)
{
#if DEBUG_APP
g_debug("UI JOB_STATE changing from %d to %d",last.job_state, job_state);
#endif
// determine if we need to initProgress() and begin() the window again
bool new_win = false;
if (job_state == JOB_ALARM)
new_win = true;
else if (job_state == JOB_BUSY && last.job_state != JOB_HOLD)
new_win = true;
else if (job_state == JOB_IDLE && (
last.job_state == JOB_ALARM ||
last.job_state == JOB_BUSY ||
last.job_state == JOB_HOLD ))
new_win = true;
// the above *almost* connotes a job well done
// we presume going from BUSY directly to IDLE
// means just that.
if (new_win)
{
draw_needed = true;
initProgress();
setDefaultWindow((uiWindow *)&main_win);
if (job_state == JOB_IDLE)
{
if (last.job_state == JOB_BUSY)
job_finished = true;
}
}
if (job_state == JOB_BUSY ||
job_state == JOB_HOLD)
{
const char *filename = g_status.getActiveFilename();
if (filename && *filename)
{
const char *p = filename;
while (*p)
{
if (*p++ == '/')
filename = p;
}
int len = strlen(filename);
if (len > MAX_ACTIVE_FILENAME) len = MAX_ACTIVE_FILENAME;
memcpy(active_filename,filename,len);
active_filename[len] = 0;
}
else // fix bug using UGS that assumed hold was only from SD Card jobs
{
active_filename[0] = 0;
}
setTitle(active_filename);
}
}
// do hit testing before checking draw_needed
// as tft_calibration may set it ..
uiWindow::updateTouch();
hitTest();
// redraw the whole window if necessary
if (draw_needed)
{
tft.fillRect(0,0,UI_SCREEN_WIDTH,UI_SCREEN_HEIGHT,COLOR_BLACK);
tft.fillRect(0,0,UI_SCREEN_WIDTH,UI_TOP_MARGIN,COLOR_DARKBLUE);
drawTypedElements();
win_stack[win_stack_ptr]->begin();
}
// dispatch to child window if any
if (win_stack[win_stack_ptr])
{
win_stack[win_stack_ptr]->hitTest();
win_stack[win_stack_ptr]->update();
}
// dispatch to frame elements
for (int i=0; i<m_num_elements; i++)
{
const uiElement *ele = &m_elements[i];
switch (ele->id_type)
{
case ID_APP_BUTTON: doAppButton(ele); break;
case ID_APP_TITLE: doAppTitle(ele); break;
case ID_SD_INDICATOR: doSDIndicator(ele); break;
case ID_WIFI_INDICATOR: doWifiIndicator(ele); break;
}
if (!suppress_status)
{
switch (ele->id_type)
{
case ID_STATUSBAR: doJobProgress(ele); break;
case ID_MACHINE_X:
case ID_MACHINE_Y:
case ID_MACHINE_Z: doMachinePosition(ele); break;
case ID_WORK_X:
case ID_WORK_Y:
case ID_WORK_Z: doWorkPosition(ele); break;
case ID_GRBL_STATE: doSysState(ele); break;
case ID_MEMAVAIL:
case ID_MEMAVAIL_MIN: doMemAvail(ele); break;
}
}
}
// save state for next time through update()
draw_needed = false;
last.sys_state = sys_state;
last.sd_state = sd_state;
last.job_state = job_state;
last.status_mode = status_mode;
last.feed_rate = feed_rate;
last.pct = job_state == JOB_HOLD || job_state == JOB_BUSY ? g_status.filePct() : 0;
last.prog_w = prog_w;
last.prog_color = prog_color;
#ifdef UI_WITH_MESH
last.live_z = live_z;
last.mesh_z = mesh_z;
#endif
strcpy(last.app_title,app_title_buf);
last.window = win_stack[win_stack_ptr];
if (job_finished)
{
doToast(COLOR_GREEN,"finished printing",active_filename);
setTitle("");
}
#ifdef WITH_SCREEN_GRAB
if (do_next_screen_grab || (screen_grab_pending && g_win_pressed))
{
do_next_screen_grab = 0;
screen_grab_pending = 0;
doScreenGrab(false);
}
#endif
// debugging to show Axes::debug_steppers_disabled
// requires #define DEBUG_STEPPERS_DISABLED in FluidNC::Machine:Axes.cpp
#if 0
extern volatile bool debug_steppers_disabled;
static bool last_steppers_disabled = 0;
if (last_steppers_disabled != debug_steppers_disabled)
{
last_steppers_disabled = debug_steppers_disabled;
tft.fillRect(0,0,20,20,last_steppers_disabled?COLOR_RED:COLOR_GREEN);
}
#endif
}