-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgApp.h
181 lines (133 loc) · 4.84 KB
/
gApp.h
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
//--------------------------------------
// The FluidNC_UI application class
//--------------------------------------
#pragma once
#include "gDefs.h"
#include "uiWindow.h"
#include <gStatus.h> // FluidNC_extensions
#define WITH_SCREEN_GRAB
// comment in for development verioon of
// TFT screen grabbing
#ifdef WITH_SCREEN_GRAB
#define CMD_UI_SCREEN_GRAB 0x10 // ctrl-P
#define CMD_UI_SCREEN_GRAB_PENDING 0x0F // ctrl-O
// here for agreement between apps
#endif
typedef struct appLast_t
// A structure that holds previous state of
// application for change detection.
{
JobState job_state;
// system change detection
uint32_t mem_avail;
uint32_t min_avail;
// gStatus change detection
uint8_t wifi_state;
State sys_state;
SDState sd_state;
float pct;
float pos[UI_NUM_AXES * 2];
// gApplication change detection
int16_t prog_w;
uint16_t prog_color;
char app_title[UI_MAX_TITLE + 1];
uiWindow *window;
uint8_t status_mode; // 0 == sys.state/memory 1==Feed Rate/zOffs
float feed_rate;
float feed_override;
float rapid_feed_override;
float spindle_override;
#ifdef UI_WITH_MESH
float live_z;
float mesh_z;
#endif
};
class gApplication : public uiWindow
{
public:
gApplication();
virtual void begin() override;
virtual void update() override;
void setTitle(const char *text);
void openWindow(uiWindow *win);
void endModal();
void setBaseWindow(uiWindow *win);
// the menu sets the base window directly
JobState getJobState() { return job_state; }
JobState getLastJobState() { return last.job_state; }
// UI Windows besides the application should NOT
// use g_status directly.
void redrawAll()
// needed layer violation so that uiWindow can
// do the TFT calibration
{
draw_needed = true;
}
const char *getActiveFilename();
// the last active filename, gotten whenever
// a job is started
void clearLastJobState()
// for use in reset from dlgConfirm
// to cause progress bar to clear correctly
// and not get a toast when a job was in progress ..
{
job_state = JOB_NONE;
last.job_state = JOB_NONE;
}
void suppressStatus() { suppress_status = true; }
#ifdef WITH_SCREEN_GRAB
static void doScreenGrab(bool pending=false);
// if "pending" is passed as true, the
// grab will be "pending" the next button
// press, and will take place with the
// button highlighted.
#endif
private:
State sys_state;
SDState sd_state;
JobState job_state;
bool draw_needed;
bool suppress_status;
uint8_t status_mode;
float feed_rate;
#ifdef UI_WITH_MESH
float live_z;
float mesh_z;
#endif
// progress bar
int16_t prog_x;
int16_t prog_w;
uint16_t prog_color;
// previous state
appLast_t last;
//-----------------------------
// methods
//-----------------------------
void setDefaultWindow(uiWindow *win);
void setAppButtonText(const char *text);
uint16_t indColor(uint8_t ind_state);
void doText(const uiElement *ele, const char *text);
void initProgress();
void doTextProgress(const uiElement *ele, const char *text, bool changed);
virtual void onButton(const uiElement *ele, bool pressed) override;
// dispatched functions
void doWin(const uiElement *ele);
void doAppButton(const uiElement *ele);
void doAppTitle(const uiElement *ele);
void doSDIndicator(const uiElement *ele);
void doWifiIndicator(const uiElement *ele);
void doMachinePosition(const uiElement *ele);
void doWorkPosition(const uiElement *ele);
void doSysState(const uiElement *ele);
void doMemAvail(const uiElement *ele);
void doJobProgress(const uiElement *ele);
// override to check for clicking on status bar
bool hitTest();
};
extern gApplication the_app;
#ifdef WITH_SCREEN_GRAB
// in gScreenGrab.cpp
extern volatile bool in_screen_grab;
extern volatile bool screen_grab_pending;
extern volatile bool do_next_screen_grab;
#endif