|
@@ -37,118 +37,79 @@ extern bool screen_changed;
|
37
|
37
|
void scroll_screen(const uint8_t limit, const bool is_menu);
|
38
|
38
|
bool printer_busy();
|
39
|
39
|
|
40
|
|
-////////////////////////////////////////////
|
41
|
|
-////////// Menu Item Numeric Types /////////
|
42
|
|
-////////////////////////////////////////////
|
43
|
|
-
|
44
|
|
-#define DECLARE_MENU_EDIT_TYPE(TYPE, NAME, STRFUNC, SCALE) \
|
45
|
|
- struct MenuEditItemInfo_##NAME { \
|
46
|
|
- typedef TYPE type_t; \
|
47
|
|
- static constexpr float scale = SCALE; \
|
48
|
|
- static inline const char* strfunc(const float value) { return STRFUNC((TYPE) value); } \
|
49
|
|
- };
|
50
|
|
-
|
51
|
|
-DECLARE_MENU_EDIT_TYPE(uint8_t, percent, ui8tostr4pct, 100.0/255); // 100% right-justified
|
52
|
|
-DECLARE_MENU_EDIT_TYPE(int16_t, int3, i16tostr3, 1 ); // 123, -12 right-justified
|
53
|
|
-DECLARE_MENU_EDIT_TYPE(int16_t, int4, i16tostr4sign, 1 ); // 1234, -123 right-justified
|
54
|
|
-DECLARE_MENU_EDIT_TYPE(int8_t, int8, i8tostr3, 1 ); // 123, -12 right-justified
|
55
|
|
-DECLARE_MENU_EDIT_TYPE(uint8_t, uint8, ui8tostr3, 1 ); // 123 right-justified
|
56
|
|
-DECLARE_MENU_EDIT_TYPE(uint16_t, uint16_3, ui16tostr3, 1 ); // 123 right-justified
|
57
|
|
-DECLARE_MENU_EDIT_TYPE(uint16_t, uint16_4, ui16tostr4, 0.1 ); // 1234 right-justified
|
58
|
|
-DECLARE_MENU_EDIT_TYPE(uint16_t, uint16_5, ui16tostr5, 0.01 ); // 12345 right-justified
|
59
|
|
-DECLARE_MENU_EDIT_TYPE(float, float3, ftostr3, 1 ); // 123 right-justified
|
60
|
|
-DECLARE_MENU_EDIT_TYPE(float, float52, ftostr42_52, 100 ); // _2.34, 12.34, -2.34 or 123.45, -23.45
|
61
|
|
-DECLARE_MENU_EDIT_TYPE(float, float43, ftostr43sign, 1000 ); // 1.234
|
62
|
|
-DECLARE_MENU_EDIT_TYPE(float, float5, ftostr5rj, 1 ); // 12345 right-justified
|
63
|
|
-DECLARE_MENU_EDIT_TYPE(float, float5_25, ftostr5rj, 0.04f ); // 12345 right-justified (25 increment)
|
64
|
|
-DECLARE_MENU_EDIT_TYPE(float, float51, ftostr51rj, 10 ); // 1234.5 right-justified
|
65
|
|
-DECLARE_MENU_EDIT_TYPE(float, float51sign, ftostr51sign, 10 ); // +1234.5
|
66
|
|
-DECLARE_MENU_EDIT_TYPE(float, float52sign, ftostr52sign, 100 ); // +123.45
|
67
|
|
-DECLARE_MENU_EDIT_TYPE(uint32_t, long5, ftostr5rj, 0.01f ); // 12345 right-justified
|
68
|
|
-DECLARE_MENU_EDIT_TYPE(uint32_t, long5_25, ftostr5rj, 0.04f ); // 12345 right-justified (25 increment)
|
69
|
|
-
|
70
|
|
-////////////////////////////////////////////
|
71
|
|
-///////// Menu Item Draw Functions /////////
|
72
|
|
-////////////////////////////////////////////
|
73
|
|
-
|
74
|
40
|
typedef void (*selectFunc_t)();
|
75
|
|
-void draw_select_screen(PGM_P const yes, PGM_P const no, const bool yesno, PGM_P const pref, const char * const string, PGM_P const suff);
|
76
|
|
-void do_select_screen(PGM_P const yes, PGM_P const no, selectFunc_t yesFunc, selectFunc_t noFunc, PGM_P const pref, const char * const string=nullptr, PGM_P const suff=nullptr);
|
77
|
|
-inline void do_select_screen_yn(selectFunc_t yesFunc, selectFunc_t noFunc, PGM_P const pref, const char * const string=nullptr, PGM_P const suff=nullptr) {
|
78
|
|
- do_select_screen(GET_TEXT(MSG_YES), GET_TEXT(MSG_NO), yesFunc, noFunc, pref, string, suff);
|
79
|
|
-}
|
80
|
41
|
|
81
|
42
|
#define SS_LEFT 0x00
|
82
|
43
|
#define SS_CENTER 0x01
|
83
|
44
|
#define SS_INVERT 0x02
|
84
|
45
|
#define SS_DEFAULT SS_CENTER
|
85
|
46
|
|
86
|
|
-void draw_edit_screen(PGM_P const pstr, const char* const value=nullptr);
|
87
|
|
-void draw_menu_item(const bool sel, const uint8_t row, PGM_P const pstr, const char pre_char, const char post_char);
|
88
|
|
-void draw_menu_item_static(const uint8_t row, PGM_P const pstr, const uint8_t style=SS_DEFAULT, const char * const valstr=nullptr);
|
89
|
|
-void _draw_menu_item_edit(const bool sel, const uint8_t row, PGM_P const pstr, const char* const data, const bool pgm);
|
90
|
|
-FORCE_INLINE void draw_menu_item_back(const bool sel, const uint8_t row, PGM_P const pstr) { draw_menu_item(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0]); }
|
91
|
|
-FORCE_INLINE void draw_menu_item_edit(const bool sel, const uint8_t row, PGM_P const pstr, const char* const data) { _draw_menu_item_edit(sel, row, pstr, data, false); }
|
92
|
|
-FORCE_INLINE void draw_menu_item_edit_P(const bool sel, const uint8_t row, PGM_P const pstr, const char* const data) { _draw_menu_item_edit(sel, row, pstr, data, true); }
|
93
|
|
-#define draw_menu_item_submenu(sel, row, pstr, data) draw_menu_item(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0])
|
94
|
|
-#define draw_menu_item_gcode(sel, row, pstr, gcode) draw_menu_item(sel, row, pstr, '>', ' ')
|
95
|
|
-#define draw_menu_item_function(sel, row, pstr, data) draw_menu_item(sel, row, pstr, '>', ' ')
|
96
|
|
-#define DRAW_MENU_ITEM_SETTING_EDIT_GENERIC(VAL) draw_menu_item_edit(sel, row, pstr, VAL)
|
97
|
|
-#define DRAW_BOOL_SETTING(sel, row, pstr, data) draw_menu_item_edit_P(sel, row, pstr, (*(data))?GET_TEXT(MSG_LCD_ON):GET_TEXT(MSG_LCD_OFF))
|
98
|
|
-
|
99
|
|
-#if ENABLED(SDSUPPORT)
|
100
|
|
- class CardReader;
|
101
|
|
- void draw_sd_menu_item(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard, const bool isDir);
|
102
|
|
- FORCE_INLINE void draw_menu_item_sdfile(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard) { draw_sd_menu_item(sel, row, pstr, theCard, false); }
|
103
|
|
- FORCE_INLINE void draw_menu_item_sdfolder(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard) { draw_sd_menu_item(sel, row, pstr, theCard, true); }
|
104
|
|
-#endif
|
105
|
|
-
|
106
|
47
|
#if HAS_GRAPHICAL_LCD && EITHER(BABYSTEP_ZPROBE_GFX_OVERLAY, MESH_EDIT_GFX_OVERLAY)
|
107
|
48
|
void _lcd_zoffset_overlay_gfx(const float zvalue);
|
108
|
49
|
#endif
|
109
|
50
|
|
110
|
51
|
////////////////////////////////////////////
|
111
|
|
-/////// Edit Setting Draw Functions ////////
|
|
52
|
+///////////// Base Menu Items //////////////
|
112
|
53
|
////////////////////////////////////////////
|
113
|
54
|
|
114
|
|
-#define _DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(TYPE, NAME, STRFUNC) \
|
115
|
|
- FORCE_INLINE void draw_menu_item_##NAME (const bool sel, const uint8_t row, PGM_P const pstr, TYPE * const data, ...) { \
|
116
|
|
- DRAW_MENU_ITEM_SETTING_EDIT_GENERIC(STRFUNC(*(data))); \
|
117
|
|
- } \
|
118
|
|
- FORCE_INLINE void draw_menu_item_accessor_##NAME (const bool sel, const uint8_t row, PGM_P const pstr, PGM_P const, TYPE (*pget)(), void (*)(TYPE), ...) { \
|
119
|
|
- DRAW_MENU_ITEM_SETTING_EDIT_GENERIC(STRFUNC(pget())); \
|
120
|
|
- } \
|
121
|
|
- typedef void NAME##_void
|
122
|
|
-#define DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(NAME) _DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(MenuEditItemInfo_##NAME::type_t, NAME, MenuEditItemInfo_##NAME::strfunc)
|
123
|
|
-
|
124
|
|
-DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(percent); // 100% right-justified
|
125
|
|
-DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(int3); // 123, -12 right-justified
|
126
|
|
-DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(int4); // 1234, -123 right-justified
|
127
|
|
-DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(int8); // 123, -12 right-justified
|
128
|
|
-DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(uint8); // 123 right-justified
|
129
|
|
-DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(uint16_3); // 123 right-justified
|
130
|
|
-DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(uint16_4); // 1234 right-justified
|
131
|
|
-DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(uint16_5); // 12345 right-justified
|
132
|
|
-DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float3); // 123 right-justified
|
133
|
|
-DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float52); // _2.34, 12.34, -2.34 or 123.45, -23.45
|
134
|
|
-DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float43); // 1.234
|
135
|
|
-DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float5); // 12345 right-justified
|
136
|
|
-DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float5_25); // 12345 right-justified (25 increment)
|
137
|
|
-DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float51); // _1234.5 right-justified
|
138
|
|
-DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float51sign); // +1234.5
|
139
|
|
-DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(float52sign); // +123.45
|
140
|
|
-DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(long5); // 12345 right-justified
|
141
|
|
-DEFINE_DRAW_MENU_ITEM_SETTING_EDIT(long5_25); // 12345 right-justified (25 increment)
|
142
|
|
-
|
143
|
|
-#define draw_menu_item_bool(sel, row, pstr, data, ...) DRAW_BOOL_SETTING(sel, row, pstr, data)
|
144
|
|
-#define draw_menu_item_accessor_bool(sel, row, pstr, pget, pset) DRAW_BOOL_SETTING(sel, row, pstr, data)
|
|
55
|
+class MenuItem_static {
|
|
56
|
+ public:
|
|
57
|
+ static void draw(const uint8_t row, PGM_P const pstr, const uint8_t style=SS_DEFAULT, const char * const valstr=nullptr);
|
|
58
|
+};
|
145
|
59
|
|
146
|
|
-////////////////////////////////////////////
|
147
|
|
-/////////////// Menu Actions ///////////////
|
148
|
|
-////////////////////////////////////////////
|
|
60
|
+class MenuItemBase {
|
|
61
|
+ public:
|
|
62
|
+ // Draw an item either selected (pre_char) or not (space) with post_char
|
|
63
|
+ static void _draw(const bool sel, const uint8_t row, PGM_P const pstr, const char pre_char, const char post_char);
|
|
64
|
+
|
|
65
|
+ // Draw an item either selected ('>') or not (space) with post_char
|
|
66
|
+ FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, const char post_char) {
|
|
67
|
+ _draw(sel, row, pstr, '>', post_char);
|
|
68
|
+ }
|
|
69
|
+};
|
149
|
70
|
|
150
|
|
-class MenuItem_back {
|
|
71
|
+// CONFIRM_ITEM(PLABEL,Y,N,FY,FN,V...), YESNO_ITEM(PLABEL,FY,FN,V...)
|
|
72
|
+class MenuItem_confirm : MenuItemBase {
|
151
|
73
|
public:
|
|
74
|
+ FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) {
|
|
75
|
+ _draw(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0]);
|
|
76
|
+ }
|
|
77
|
+ // Implemented for HD44780 and DOGM
|
|
78
|
+ // Draw the prompt, buttons, and state
|
|
79
|
+ static void draw_select_screen(
|
|
80
|
+ PGM_P const yes, // Right option label
|
|
81
|
+ PGM_P const no, // Left option label
|
|
82
|
+ const bool yesno, // Is "yes" selected?
|
|
83
|
+ PGM_P const pref, // Prompt prefix
|
|
84
|
+ const char * const string, // Prompt runtime string
|
|
85
|
+ PGM_P const suff // Prompt suffix
|
|
86
|
+ );
|
|
87
|
+ static void select_screen(
|
|
88
|
+ PGM_P const yes, PGM_P const no,
|
|
89
|
+ selectFunc_t yesFunc, selectFunc_t noFunc,
|
|
90
|
+ PGM_P const pref, const char * const string=nullptr, PGM_P const suff=nullptr
|
|
91
|
+ );
|
|
92
|
+ static inline void select_screen(
|
|
93
|
+ PGM_P const yes, PGM_P const no,
|
|
94
|
+ selectFunc_t yesFunc, selectFunc_t noFunc,
|
|
95
|
+ PGM_P const pref, const progmem_str string, PGM_P const suff=nullptr
|
|
96
|
+ ) {
|
|
97
|
+ char str[strlen_P((PGM_P)string) + 1];
|
|
98
|
+ strcpy_P(str, (PGM_P)string);
|
|
99
|
+ select_screen(yes, no, yesFunc, noFunc, pref, str, suff);
|
|
100
|
+ }
|
|
101
|
+ // Shortcut for prompt with "NO"/ "YES" labels
|
|
102
|
+ FORCE_INLINE static void confirm_screen(selectFunc_t yesFunc, selectFunc_t noFunc, PGM_P const pref, const char * const string=nullptr, PGM_P const suff=nullptr) {
|
|
103
|
+ select_screen(GET_TEXT(MSG_YES), GET_TEXT(MSG_NO), yesFunc, noFunc, pref, string, suff);
|
|
104
|
+ }
|
|
105
|
+};
|
|
106
|
+
|
|
107
|
+// BACK_ITEM(PLABEL)
|
|
108
|
+class MenuItem_back : public MenuItemBase {
|
|
109
|
+ public:
|
|
110
|
+ FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr) {
|
|
111
|
+ _draw(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0]);
|
|
112
|
+ }
|
152
|
113
|
static inline void action(PGM_P const=nullptr) {
|
153
|
114
|
ui.goto_previous_screen(
|
154
|
115
|
#if ENABLED(TURBO_BACK_MENU_ITEM)
|
|
@@ -158,30 +119,46 @@ class MenuItem_back {
|
158
|
119
|
}
|
159
|
120
|
};
|
160
|
121
|
|
161
|
|
-class MenuItem_submenu {
|
|
122
|
+// SUBMENU(PLABEL, screen_handler)
|
|
123
|
+class MenuItem_submenu : public MenuItemBase {
|
162
|
124
|
public:
|
|
125
|
+ FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) {
|
|
126
|
+ _draw(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0]);
|
|
127
|
+ }
|
163
|
128
|
static inline void action(PGM_P const, const screenFunc_t func) { ui.save_previous_screen(); ui.goto_screen(func); }
|
164
|
129
|
};
|
165
|
130
|
|
166
|
|
-class MenuItem_gcode {
|
|
131
|
+// GCODE_ITEM(PLABEL, gcode)
|
|
132
|
+class MenuItem_gcode : public MenuItemBase {
|
167
|
133
|
public:
|
|
134
|
+ FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) {
|
|
135
|
+ _draw(sel, row, pstr, '>', ' ');
|
|
136
|
+ }
|
168
|
137
|
static void action(PGM_P const, const char * const pgcode);
|
169
|
138
|
};
|
170
|
139
|
|
171
|
|
-class MenuItem_function {
|
|
140
|
+// ACTION_ITEM(PLABEL, function)
|
|
141
|
+class MenuItem_function : public MenuItemBase {
|
172
|
142
|
public:
|
|
143
|
+ FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) {
|
|
144
|
+ _draw(sel, row, pstr, '>', ' ');
|
|
145
|
+ }
|
173
|
146
|
static inline void action(PGM_P const, const menuAction_t func) { (*func)(); };
|
174
|
147
|
};
|
175
|
148
|
|
|
149
|
+#if ENABLED(SDSUPPORT)
|
|
150
|
+ class CardReader;
|
|
151
|
+ class MenuItem_sdbase {
|
|
152
|
+ public:
|
|
153
|
+ static void draw(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard, const bool isDir);
|
|
154
|
+ };
|
|
155
|
+#endif
|
|
156
|
+
|
176
|
157
|
////////////////////////////////////////////
|
177
|
|
-/////////// Menu Editing Actions ///////////
|
|
158
|
+///////////// Edit Menu Items //////////////
|
178
|
159
|
////////////////////////////////////////////
|
179
|
160
|
|
180
|
|
-//
|
181
|
161
|
// The Menu Edit shadow value
|
182
|
|
-// Only one edit value is needed at a time
|
183
|
|
-//
|
184
|
|
-
|
185
|
162
|
typedef union {
|
186
|
163
|
bool state;
|
187
|
164
|
float decimal;
|
|
@@ -192,11 +169,10 @@ typedef union {
|
192
|
169
|
uint16_t uint16;
|
193
|
170
|
uint32_t uint32;
|
194
|
171
|
} chimera_t;
|
195
|
|
-
|
196
|
172
|
extern chimera_t editable;
|
197
|
173
|
|
198
|
174
|
// Edit items use long integer encoder units
|
199
|
|
-class MenuEditItemBase {
|
|
175
|
+class MenuEditItemBase : public MenuItemBase {
|
200
|
176
|
private:
|
201
|
177
|
static PGM_P editLabel;
|
202
|
178
|
static void *editValue;
|
|
@@ -208,6 +184,17 @@ class MenuEditItemBase {
|
208
|
184
|
typedef void (*loadfunc_t)(void *, const int32_t);
|
209
|
185
|
static void init(PGM_P const el, void * const ev, const int32_t minv, const int32_t maxv, const uint16_t ep, const screenFunc_t cs, const screenFunc_t cb, const bool le);
|
210
|
186
|
static void edit(strfunc_t, loadfunc_t);
|
|
187
|
+ public:
|
|
188
|
+ // Implemented for HD44780 and DOGM
|
|
189
|
+ // Draw the current item at specified row with edit data
|
|
190
|
+ static void draw(const bool sel, const uint8_t row, PGM_P const pstr, const char* const data, const bool pgm);
|
|
191
|
+
|
|
192
|
+ FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, const char* const data) { draw(sel, row, pstr, data, false); }
|
|
193
|
+ FORCE_INLINE static void draw_P(const bool sel, const uint8_t row, PGM_P const pstr, const char* const data) { draw(sel, row, pstr, data, true); }
|
|
194
|
+
|
|
195
|
+ // Implemented for HD44780 and DOGM
|
|
196
|
+ // This low-level method is good to draw from anywhere
|
|
197
|
+ static void edit_screen(PGM_P const pstr, const char* const value=nullptr);
|
211
|
198
|
};
|
212
|
199
|
|
213
|
200
|
template<typename NAME>
|
|
@@ -219,6 +206,12 @@ class TMenuEditItem : MenuEditItemBase {
|
219
|
206
|
static void load(void *ptr, const int32_t value) { *((type_t*)ptr) = unscale(value); }
|
220
|
207
|
static const char* to_string(const int32_t value) { return NAME::strfunc(unscale(value)); }
|
221
|
208
|
public:
|
|
209
|
+ FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, type_t * const data, ...) {
|
|
210
|
+ MenuEditItemBase::draw(sel, row, pstr, NAME::strfunc(*(data)));
|
|
211
|
+ }
|
|
212
|
+ FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, type_t (*pget)(), ...) {
|
|
213
|
+ MenuEditItemBase::draw(sel, row, pstr, NAME::strfunc(pget()));
|
|
214
|
+ }
|
222
|
215
|
static void action(
|
223
|
216
|
PGM_P const pstr, // Edit label
|
224
|
217
|
type_t * const ptr, // Value pointer
|
|
@@ -235,30 +228,53 @@ class TMenuEditItem : MenuEditItemBase {
|
235
|
228
|
static void edit() { MenuEditItemBase::edit(to_string, load); }
|
236
|
229
|
};
|
237
|
230
|
|
238
|
|
-#define DECLARE_MENU_EDIT_ITEM(NAME) typedef TMenuEditItem<MenuEditItemInfo_##NAME> MenuItem_##NAME;
|
239
|
|
-
|
240
|
|
-DECLARE_MENU_EDIT_ITEM(percent);
|
241
|
|
-DECLARE_MENU_EDIT_ITEM(int3);
|
242
|
|
-DECLARE_MENU_EDIT_ITEM(int4);
|
243
|
|
-DECLARE_MENU_EDIT_ITEM(int8);
|
244
|
|
-DECLARE_MENU_EDIT_ITEM(uint8);
|
245
|
|
-DECLARE_MENU_EDIT_ITEM(uint16_3);
|
246
|
|
-DECLARE_MENU_EDIT_ITEM(uint16_4);
|
247
|
|
-DECLARE_MENU_EDIT_ITEM(uint16_5);
|
248
|
|
-DECLARE_MENU_EDIT_ITEM(float3);
|
249
|
|
-DECLARE_MENU_EDIT_ITEM(float52);
|
250
|
|
-DECLARE_MENU_EDIT_ITEM(float43);
|
251
|
|
-DECLARE_MENU_EDIT_ITEM(float5);
|
252
|
|
-DECLARE_MENU_EDIT_ITEM(float5_25);
|
253
|
|
-DECLARE_MENU_EDIT_ITEM(float51);
|
254
|
|
-DECLARE_MENU_EDIT_ITEM(float51sign);
|
255
|
|
-DECLARE_MENU_EDIT_ITEM(float52sign);
|
256
|
|
-DECLARE_MENU_EDIT_ITEM(long5);
|
257
|
|
-DECLARE_MENU_EDIT_ITEM(long5_25);
|
258
|
|
-
|
259
|
|
-class MenuItem_bool {
|
|
231
|
+// Provide a set of Edit Item Types which encompass a primitive
|
|
232
|
+// type, a string function, and a scale factor for edit and display.
|
|
233
|
+// These items call the Edit Item draw method passing the prepared string.
|
|
234
|
+#define DEFINE_MENU_EDIT_ITEM_TYPE(TYPE, NAME, STRFUNC, SCALE) \
|
|
235
|
+ struct MenuEditItemInfo_##NAME { \
|
|
236
|
+ typedef TYPE type_t; \
|
|
237
|
+ static constexpr float scale = SCALE; \
|
|
238
|
+ static inline const char* strfunc(const float value) { return STRFUNC((TYPE)value); } \
|
|
239
|
+ }; \
|
|
240
|
+ typedef TMenuEditItem<MenuEditItemInfo_##NAME> MenuItem_##NAME
|
|
241
|
+
|
|
242
|
+// TYPE NAME STRFUNC SCALE
|
|
243
|
+DEFINE_MENU_EDIT_ITEM_TYPE(uint8_t, percent, ui8tostr4pct, 100.0/255); // 100% right-justified
|
|
244
|
+DEFINE_MENU_EDIT_ITEM_TYPE(int16_t, int3, i16tostr3, 1 ); // 123, -12 right-justified
|
|
245
|
+DEFINE_MENU_EDIT_ITEM_TYPE(int16_t, int4, i16tostr4sign, 1 ); // 1234, -123 right-justified
|
|
246
|
+DEFINE_MENU_EDIT_ITEM_TYPE(int8_t, int8, i8tostr3, 1 ); // 123, -12 right-justified
|
|
247
|
+DEFINE_MENU_EDIT_ITEM_TYPE(uint8_t, uint8, ui8tostr3, 1 ); // 123 right-justified
|
|
248
|
+DEFINE_MENU_EDIT_ITEM_TYPE(uint16_t, uint16_3, ui16tostr3, 1 ); // 123 right-justified
|
|
249
|
+DEFINE_MENU_EDIT_ITEM_TYPE(uint16_t, uint16_4, ui16tostr4, 0.1 ); // 1234 right-justified
|
|
250
|
+DEFINE_MENU_EDIT_ITEM_TYPE(uint16_t, uint16_5, ui16tostr5, 0.01 ); // 12345 right-justified
|
|
251
|
+DEFINE_MENU_EDIT_ITEM_TYPE(float, float3, ftostr3, 1 ); // 123 right-justified
|
|
252
|
+DEFINE_MENU_EDIT_ITEM_TYPE(float, float52, ftostr42_52, 100 ); // _2.34, 12.34, -2.34 or 123.45, -23.45
|
|
253
|
+DEFINE_MENU_EDIT_ITEM_TYPE(float, float43, ftostr43sign, 1000 ); // 1.234
|
|
254
|
+DEFINE_MENU_EDIT_ITEM_TYPE(float, float5, ftostr5rj, 1 ); // 12345 right-justified
|
|
255
|
+DEFINE_MENU_EDIT_ITEM_TYPE(float, float5_25, ftostr5rj, 0.04f ); // 12345 right-justified (25 increment)
|
|
256
|
+DEFINE_MENU_EDIT_ITEM_TYPE(float, float51, ftostr51rj, 10 ); // 1234.5 right-justified
|
|
257
|
+DEFINE_MENU_EDIT_ITEM_TYPE(float, float41sign, ftostr41sign, 10 ); // +123.4
|
|
258
|
+DEFINE_MENU_EDIT_ITEM_TYPE(float, float51sign, ftostr51sign, 10 ); // +1234.5
|
|
259
|
+DEFINE_MENU_EDIT_ITEM_TYPE(float, float52sign, ftostr52sign, 100 ); // +123.45
|
|
260
|
+DEFINE_MENU_EDIT_ITEM_TYPE(uint32_t, long5, ftostr5rj, 0.01f ); // 12345 right-justified
|
|
261
|
+DEFINE_MENU_EDIT_ITEM_TYPE(uint32_t, long5_25, ftostr5rj, 0.04f ); // 12345 right-justified (25 increment)
|
|
262
|
+
|
|
263
|
+class MenuItem_bool : public MenuEditItemBase {
|
260
|
264
|
public:
|
261
|
|
- static void action(PGM_P const pstr, bool* ptr, const screenFunc_t callbackFunc=nullptr);
|
|
265
|
+ //#define DRAW_BOOL_SETTING(sel, row, pstr, data) draw_menu_item_edit_P(sel, row, pstr, (*(data))?GET_TEXT(MSG_LCD_ON):GET_TEXT(MSG_LCD_OFF))
|
|
266
|
+ FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, const bool onoff) {
|
|
267
|
+ MenuEditItemBase::draw(sel, row, pstr, onoff ? GET_TEXT(MSG_LCD_ON) : GET_TEXT(MSG_LCD_OFF), true);
|
|
268
|
+ }
|
|
269
|
+ //#define draw_menu_item_bool(sel, row, pstr, data, ...) DRAW_BOOL_SETTING(sel, row, pstr, data)
|
|
270
|
+ FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, bool * const data, ...) {
|
|
271
|
+ draw(sel, row, pstr, *data);
|
|
272
|
+ }
|
|
273
|
+ //#define draw_menu_item_accessor_bool(sel, row, pstr, pget, pset) DRAW_BOOL_SETTING(sel, row, pstr, data)
|
|
274
|
+ FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, PGM_P const, bool (*pget)(), ...) {
|
|
275
|
+ draw(sel, row, pstr, pget());
|
|
276
|
+ }
|
|
277
|
+ static void action(PGM_P const pstr, bool * const ptr, const screenFunc_t callbackFunc=nullptr);
|
262
|
278
|
};
|
263
|
279
|
|
264
|
280
|
////////////////////////////////////////////
|
|
@@ -313,39 +329,39 @@ class MenuItem_bool {
|
313
|
329
|
/**
|
314
|
330
|
* MENU_ITEM generates draw & handler code for a menu item, potentially calling:
|
315
|
331
|
*
|
316
|
|
- * draw_menu_item_<type>(sel, row, label, arg3...)
|
|
332
|
+ * MenuItem_<type>::draw(sel, row, label, arg3...)
|
317
|
333
|
* MenuItem_<type>::action(arg3...)
|
318
|
334
|
*
|
319
|
335
|
* Examples:
|
320
|
336
|
* BACK_ITEM(MSG_WATCH)
|
321
|
337
|
* MENU_ITEM(back, MSG_WATCH)
|
322
|
|
- * draw_menu_item_back(sel, row, GET_TEXT(MSG_WATCH))
|
|
338
|
+ * MenuItem_back::draw(sel, row, GET_TEXT(MSG_WATCH))
|
323
|
339
|
* MenuItem_back::action()
|
324
|
340
|
*
|
325
|
341
|
* ACTION_ITEM(MSG_PAUSE_PRINT, lcd_sdcard_pause)
|
326
|
342
|
* MENU_ITEM(function, MSG_PAUSE_PRINT, lcd_sdcard_pause)
|
327
|
|
- * draw_menu_item_function(sel, row, GET_TEXT(MSG_PAUSE_PRINT), lcd_sdcard_pause)
|
328
|
|
- * MenuItem_function::action(lcd_sdcard_pause)
|
|
343
|
+ * MenuItem_function::draw(sel, row, GET_TEXT(MSG_PAUSE_PRINT), lcd_sdcard_pause)
|
|
344
|
+ * MenuItem_function::action(GET_TEXT(MSG_PAUSE_PRINT), lcd_sdcard_pause)
|
329
|
345
|
*
|
330
|
346
|
* EDIT_ITEM(int3, MSG_SPEED, &feedrate_percentage, 10, 999)
|
331
|
|
- * draw_menu_item_int3(sel, row, GET_TEXT(MSG_SPEED), &feedrate_percentage, 10, 999)
|
|
347
|
+ * MenuItem_int3::draw(sel, row, GET_TEXT(MSG_SPEED), &feedrate_percentage, 10, 999)
|
332
|
348
|
* MenuItem_int3::action(GET_TEXT(MSG_SPEED), &feedrate_percentage, 10, 999)
|
333
|
349
|
*
|
334
|
350
|
*/
|
335
|
|
-#define _MENU_ITEM_P(TYPE, USE_MULTIPLIER, PLABEL, V...) do { \
|
336
|
|
- _skipStatic = false; \
|
337
|
|
- if (_menuLineNr == _thisItemNr) { \
|
338
|
|
- PGM_P const plabel = PLABEL; \
|
339
|
|
- if (encoderLine == _thisItemNr && ui.use_click()) { \
|
340
|
|
- _MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER); \
|
341
|
|
- MenuItem_##TYPE ::action(plabel, ##V); \
|
342
|
|
- if (screen_changed) return; \
|
343
|
|
- } \
|
344
|
|
- if (ui.should_draw()) \
|
345
|
|
- draw_menu_item_ ## TYPE \
|
346
|
|
- (encoderLine == _thisItemNr, _lcdLineNr, plabel, ##V); \
|
347
|
|
- } \
|
348
|
|
- ++_thisItemNr; \
|
|
351
|
+#define _MENU_ITEM_P(TYPE, USE_MULTIPLIER, PLABEL, V...) do { \
|
|
352
|
+ _skipStatic = false; \
|
|
353
|
+ if (_menuLineNr == _thisItemNr) { \
|
|
354
|
+ PGM_P const plabel = PLABEL; \
|
|
355
|
+ if (encoderLine == _thisItemNr && ui.use_click()) { \
|
|
356
|
+ _MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER); \
|
|
357
|
+ MenuItem_##TYPE::action(plabel, ##V); \
|
|
358
|
+ if (screen_changed) return; \
|
|
359
|
+ } \
|
|
360
|
+ if (ui.should_draw()) \
|
|
361
|
+ MenuItem_##TYPE::draw \
|
|
362
|
+ (encoderLine == _thisItemNr, _lcdLineNr, plabel, ##V); \
|
|
363
|
+ } \
|
|
364
|
+ ++_thisItemNr; \
|
349
|
365
|
}while(0)
|
350
|
366
|
|
351
|
367
|
// Used to print static text with no visible cursor.
|
|
@@ -357,7 +373,7 @@ class MenuItem_bool {
|
357
|
373
|
++encoderLine; \
|
358
|
374
|
} \
|
359
|
375
|
if (ui.should_draw()) \
|
360
|
|
- draw_menu_item_static(_lcdLineNr, PLABEL, ##V); \
|
|
376
|
+ MenuItem_static::draw(_lcdLineNr, PLABEL, ##V); \
|
361
|
377
|
} \
|
362
|
378
|
++_thisItemNr; \
|
363
|
379
|
} while(0)
|
|
@@ -385,6 +401,24 @@ class MenuItem_bool {
|
385
|
401
|
#define BACK_ITEM(LABEL) MENU_ITEM(back, LABEL)
|
386
|
402
|
#define SKIP_ITEM() (_thisItemNr++)
|
387
|
403
|
|
|
404
|
+#define _CONFIRM_ITEM_P(PLABEL, V...) do { \
|
|
405
|
+ _skipStatic = false; \
|
|
406
|
+ if (_menuLineNr == _thisItemNr) { \
|
|
407
|
+ if (encoderLine == _thisItemNr && ui.use_click()) { \
|
|
408
|
+ ui.goto_screen([]{MenuItem_confirm::select_screen(V);}); \
|
|
409
|
+ return; \
|
|
410
|
+ } \
|
|
411
|
+ if (ui.should_draw()) MenuItem_confirm::draw \
|
|
412
|
+ (encoderLine == _thisItemNr, _lcdLineNr, PLABEL, ##V); \
|
|
413
|
+ } \
|
|
414
|
+ ++_thisItemNr; \
|
|
415
|
+}while(0)
|
|
416
|
+
|
|
417
|
+#define CONFIRM_ITEM_P(PLABEL,A,B,V...) _CONFIRM_ITEM_P(PLABEL, GET_TEXT(A), GET_TEXT(B), ##V)
|
|
418
|
+#define CONFIRM_ITEM(LABEL, V...) CONFIRM_ITEM_P(GET_TEXT(LABEL), ##V)
|
|
419
|
+#define YESNO_ITEM_P(PLABEL, V...) _CONFIRM_ITEM_P(PLABEL, ##V)
|
|
420
|
+#define YESNO_ITEM(LABEL, V...) _CONFIRM_ITEM_P(GET_TEXT(LABEL), ##V)
|
|
421
|
+
|
388
|
422
|
////////////////////////////////////////////
|
389
|
423
|
/////////////// Menu Screens ///////////////
|
390
|
424
|
////////////////////////////////////////////
|