|
@@ -211,7 +211,7 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
|
211
|
211
|
/* Helper macros for menus */
|
212
|
212
|
|
213
|
213
|
/**
|
214
|
|
- * START_MENU generates the init code for a menu function
|
|
214
|
+ * START_SCREEN generates the init code for a screen function
|
215
|
215
|
*
|
216
|
216
|
* encoderLine is the position based on the encoder
|
217
|
217
|
* currentMenuViewOffset is the top menu line to display
|
|
@@ -219,17 +219,26 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
|
219
|
219
|
* _lineNr is the menu item to draw and process
|
220
|
220
|
* _menuItemNr is the index of each MENU_ITEM
|
221
|
221
|
*/
|
222
|
|
- #define START_MENU() do { \
|
|
222
|
+ #define _START_SCREEN(CODE) do { \
|
223
|
223
|
ENCODER_DIRECTION_MENUS(); \
|
224
|
224
|
encoderRateMultiplierEnabled = false; \
|
225
|
225
|
if (encoderPosition > 0x8000) encoderPosition = 0; \
|
226
|
226
|
uint8_t encoderLine = encoderPosition / ENCODER_STEPS_PER_MENU_ITEM; \
|
227
|
227
|
NOMORE(currentMenuViewOffset, encoderLine); \
|
228
|
228
|
uint8_t _lineNr = currentMenuViewOffset, _menuItemNr; \
|
229
|
|
- bool wasClicked = LCD_CLICKED, itemSelected; \
|
|
229
|
+ CODE; \
|
230
|
230
|
for (uint8_t _drawLineNr = 0; _drawLineNr < LCD_HEIGHT; _drawLineNr++, _lineNr++) { \
|
231
|
231
|
_menuItemNr = 0;
|
232
|
232
|
|
|
233
|
+ #define START_SCREEN() _START_SCREEN(0)
|
|
234
|
+
|
|
235
|
+ /**
|
|
236
|
+ * START_MENU generates the init code for a menu function
|
|
237
|
+ *
|
|
238
|
+ * wasClicked indicates the controller was clicked
|
|
239
|
+ */
|
|
240
|
+ #define START_MENU() _START_SCREEN(bool wasClicked = LCD_CLICKED)
|
|
241
|
+
|
233
|
242
|
/**
|
234
|
243
|
* MENU_ITEM generates draw & handler code for a menu item, potentially calling:
|
235
|
244
|
*
|
|
@@ -253,10 +262,9 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
|
253
|
262
|
*/
|
254
|
263
|
#define _MENU_ITEM_PART_1(type, label, args...) \
|
255
|
264
|
if (_menuItemNr == _lineNr) { \
|
256
|
|
- itemSelected = encoderLine == _menuItemNr; \
|
257
|
265
|
if (lcdDrawUpdate) \
|
258
|
|
- lcd_implementation_drawmenu_ ## type(itemSelected, _drawLineNr, PSTR(label), ## args); \
|
259
|
|
- if (wasClicked && itemSelected) { \
|
|
266
|
+ lcd_implementation_drawmenu_ ## type(encoderLine == _menuItemNr, _drawLineNr, PSTR(label), ## args); \
|
|
267
|
+ if (wasClicked && encoderLine == _menuItemNr) { \
|
260
|
268
|
lcd_quick_feedback()
|
261
|
269
|
|
262
|
270
|
#define _MENU_ITEM_PART_2(type, args...) \
|
|
@@ -281,6 +289,21 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
|
281
|
289
|
} \
|
282
|
290
|
_menuItemNr++
|
283
|
291
|
|
|
292
|
+ #define END_SCREEN() \
|
|
293
|
+ if (encoderLine >= _menuItemNr) { \
|
|
294
|
+ encoderPosition = _menuItemNr * (ENCODER_STEPS_PER_MENU_ITEM) - 1; \
|
|
295
|
+ encoderLine = _menuItemNr - 1; \
|
|
296
|
+ } \
|
|
297
|
+ if (encoderLine >= currentMenuViewOffset + LCD_HEIGHT) { \
|
|
298
|
+ currentMenuViewOffset = encoderLine - (LCD_HEIGHT) + 1; \
|
|
299
|
+ lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT; \
|
|
300
|
+ _lineNr = currentMenuViewOffset - 1; \
|
|
301
|
+ _drawLineNr = -1; \
|
|
302
|
+ } \
|
|
303
|
+ } } while(0)
|
|
304
|
+
|
|
305
|
+ #define END_MENU() END_SCREEN()
|
|
306
|
+
|
284
|
307
|
#if ENABLED(ENCODER_RATE_MULTIPLIER)
|
285
|
308
|
|
286
|
309
|
//#define ENCODER_RATE_MULTIPLIER_DEBUG // If defined, output the encoder steps per second value
|
|
@@ -307,10 +330,6 @@ uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to
|
307
|
330
|
#define MENU_MULTIPLIER_ITEM_EDIT(type, label, args...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label), ## args)
|
308
|
331
|
#define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label), ## args)
|
309
|
332
|
#endif //!ENCODER_RATE_MULTIPLIER
|
310
|
|
- #define END_MENU() \
|
311
|
|
- if (encoderLine >= _menuItemNr) { encoderPosition = _menuItemNr * (ENCODER_STEPS_PER_MENU_ITEM) - 1; encoderLine = _menuItemNr - 1; }\
|
312
|
|
- if (encoderLine >= currentMenuViewOffset + LCD_HEIGHT) { currentMenuViewOffset = encoderLine - (LCD_HEIGHT) + 1; lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT; _lineNr = currentMenuViewOffset - 1; _drawLineNr = -1; } \
|
313
|
|
- } } while(0)
|
314
|
333
|
|
315
|
334
|
/** Used variables to keep track of the menu */
|
316
|
335
|
volatile uint8_t buttons; //the last checked buttons in a bit array.
|
|
@@ -1927,14 +1946,14 @@ static void lcd_status_screen() {
|
1927
|
1946
|
printStatistics stats = print_job_counter.getStats();
|
1928
|
1947
|
|
1929
|
1948
|
char printTime[6];
|
1930
|
|
- sprintf(printTime, "%02d:%02d", stats.printTime / 60, stats.printTime % 60);
|
|
1949
|
+ sprintf(printTime, "%02d:%02d", int(stats.printTime / 60), int(stats.printTime % 60));
|
1931
|
1950
|
|
1932
|
1951
|
if (LCD_CLICKED) lcd_goto_previous_menu(true);
|
1933
|
|
- START_MENU();
|
|
1952
|
+ START_SCREEN();
|
1934
|
1953
|
STATIC_ITEM(MSG_INFO_TOTAL_PRINTS ": ", itostr3left(stats.totalPrints)); // Total Prints: 999
|
1935
|
1954
|
STATIC_ITEM(MSG_INFO_FINISHED_PRINTS ": ", itostr3left(stats.finishedPrints)); // Finished Prints: 666
|
1936
|
1955
|
STATIC_ITEM(MSG_INFO_PRINT_TIME ": ", printTime); // Total Print Time: 123456
|
1937
|
|
- END_MENU();
|
|
1956
|
+ END_SCREEN();
|
1938
|
1957
|
}
|
1939
|
1958
|
#endif // PRINTCOUNTER
|
1940
|
1959
|
|
|
@@ -1945,7 +1964,7 @@ static void lcd_status_screen() {
|
1945
|
1964
|
*/
|
1946
|
1965
|
static void lcd_info_thermistors_menu() {
|
1947
|
1966
|
if (LCD_CLICKED) lcd_goto_previous_menu(true);
|
1948
|
|
- START_MENU();
|
|
1967
|
+ START_SCREEN();
|
1949
|
1968
|
#define THERMISTOR_ID TEMP_SENSOR_0
|
1950
|
1969
|
#include "thermistornames.h"
|
1951
|
1970
|
STATIC_ITEM("T0: " THERMISTOR_NAME);
|
|
@@ -1987,7 +2006,7 @@ static void lcd_status_screen() {
|
1987
|
2006
|
STATIC_ITEM(MSG_INFO_MIN_TEMP ": " STRINGIFY(BED_MINTEMP));
|
1988
|
2007
|
STATIC_ITEM(MSG_INFO_MAX_TEMP ": " STRINGIFY(BED_MAXTEMP));
|
1989
|
2008
|
#endif
|
1990
|
|
- END_MENU();
|
|
2009
|
+ END_SCREEN();
|
1991
|
2010
|
}
|
1992
|
2011
|
|
1993
|
2012
|
/**
|
|
@@ -1997,7 +2016,7 @@ static void lcd_status_screen() {
|
1997
|
2016
|
*/
|
1998
|
2017
|
static void lcd_info_board_menu() {
|
1999
|
2018
|
if (LCD_CLICKED) lcd_goto_previous_menu(true);
|
2000
|
|
- START_MENU();
|
|
2019
|
+ START_SCREEN();
|
2001
|
2020
|
STATIC_ITEM(BOARD_NAME); // MyPrinterController
|
2002
|
2021
|
STATIC_ITEM(MSG_INFO_BAUDRATE ": " STRINGIFY(BAUDRATE)); // Baud: 250000
|
2003
|
2022
|
STATIC_ITEM(MSG_INFO_PROTOCOL ": " PROTOCOL_VERSION); // Protocol: 1.0
|
|
@@ -2008,7 +2027,7 @@ static void lcd_status_screen() {
|
2008
|
2027
|
STATIC_ITEM(MSG_INFO_PSU ": XBox"); // Power Supply: XBox
|
2009
|
2028
|
#endif
|
2010
|
2029
|
#endif // POWER_SUPPLY
|
2011
|
|
- END_MENU();
|
|
2030
|
+ END_SCREEN();
|
2012
|
2031
|
}
|
2013
|
2032
|
|
2014
|
2033
|
/**
|
|
@@ -2018,14 +2037,14 @@ static void lcd_status_screen() {
|
2018
|
2037
|
*/
|
2019
|
2038
|
static void lcd_info_printer_menu() {
|
2020
|
2039
|
if (LCD_CLICKED) lcd_goto_previous_menu(true);
|
2021
|
|
- START_MENU();
|
|
2040
|
+ START_SCREEN();
|
2022
|
2041
|
STATIC_ITEM(MSG_MARLIN); // Marlin
|
2023
|
2042
|
STATIC_ITEM(SHORT_BUILD_VERSION); // x.x.x-Branch
|
2024
|
2043
|
STATIC_ITEM(STRING_DISTRIBUTION_DATE); // YYYY-MM-DD HH:MM
|
2025
|
2044
|
STATIC_ITEM(MACHINE_NAME); // My3DPrinter
|
2026
|
2045
|
STATIC_ITEM(WEBSITE_URL); // www.my3dprinter.com
|
2027
|
2046
|
STATIC_ITEM(MSG_INFO_EXTRUDERS ": " STRINGIFY(EXTRUDERS)); // Extruders: 2
|
2028
|
|
- END_MENU();
|
|
2047
|
+ END_SCREEN();
|
2029
|
2048
|
}
|
2030
|
2049
|
|
2031
|
2050
|
/**
|
|
@@ -2069,7 +2088,7 @@ static void lcd_status_screen() {
|
2069
|
2088
|
}
|
2070
|
2089
|
|
2071
|
2090
|
static void lcd_filament_change_init_message() {
|
2072
|
|
- START_MENU();
|
|
2091
|
+ START_SCREEN();
|
2073
|
2092
|
STATIC_ITEM(MSG_FILAMENT_CHANGE_HEADER);
|
2074
|
2093
|
STATIC_ITEM(MSG_FILAMENT_CHANGE_INIT_1);
|
2075
|
2094
|
#ifdef MSG_FILAMENT_CHANGE_INIT_2
|
|
@@ -2078,11 +2097,11 @@ static void lcd_status_screen() {
|
2078
|
2097
|
#ifdef MSG_FILAMENT_CHANGE_INIT_3
|
2079
|
2098
|
STATIC_ITEM(MSG_FILAMENT_CHANGE_INIT_3);
|
2080
|
2099
|
#endif
|
2081
|
|
- END_MENU();
|
|
2100
|
+ END_SCREEN();
|
2082
|
2101
|
}
|
2083
|
2102
|
|
2084
|
2103
|
static void lcd_filament_change_unload_message() {
|
2085
|
|
- START_MENU();
|
|
2104
|
+ START_SCREEN();
|
2086
|
2105
|
STATIC_ITEM(MSG_FILAMENT_CHANGE_HEADER);
|
2087
|
2106
|
STATIC_ITEM(MSG_FILAMENT_CHANGE_UNLOAD_1);
|
2088
|
2107
|
#ifdef MSG_FILAMENT_CHANGE_UNLOAD_2
|
|
@@ -2091,11 +2110,11 @@ static void lcd_status_screen() {
|
2091
|
2110
|
#ifdef MSG_FILAMENT_CHANGE_UNLOAD_3
|
2092
|
2111
|
STATIC_ITEM(MSG_FILAMENT_CHANGE_UNLOAD_3);
|
2093
|
2112
|
#endif
|
2094
|
|
- END_MENU();
|
|
2113
|
+ END_SCREEN();
|
2095
|
2114
|
}
|
2096
|
2115
|
|
2097
|
2116
|
static void lcd_filament_change_insert_message() {
|
2098
|
|
- START_MENU();
|
|
2117
|
+ START_SCREEN();
|
2099
|
2118
|
STATIC_ITEM(MSG_FILAMENT_CHANGE_HEADER);
|
2100
|
2119
|
STATIC_ITEM(MSG_FILAMENT_CHANGE_INSERT_1);
|
2101
|
2120
|
#ifdef MSG_FILAMENT_CHANGE_INSERT_2
|
|
@@ -2104,11 +2123,11 @@ static void lcd_status_screen() {
|
2104
|
2123
|
#ifdef MSG_FILAMENT_CHANGE_INSERT_3
|
2105
|
2124
|
STATIC_ITEM(MSG_FILAMENT_CHANGE_INSERT_3);
|
2106
|
2125
|
#endif
|
2107
|
|
- END_MENU();
|
|
2126
|
+ END_SCREEN();
|
2108
|
2127
|
}
|
2109
|
2128
|
|
2110
|
2129
|
static void lcd_filament_change_load_message() {
|
2111
|
|
- START_MENU();
|
|
2130
|
+ START_SCREEN();
|
2112
|
2131
|
STATIC_ITEM(MSG_FILAMENT_CHANGE_HEADER);
|
2113
|
2132
|
STATIC_ITEM(MSG_FILAMENT_CHANGE_LOAD_1);
|
2114
|
2133
|
#ifdef MSG_FILAMENT_CHANGE_LOAD_2
|
|
@@ -2117,11 +2136,11 @@ static void lcd_status_screen() {
|
2117
|
2136
|
#ifdef MSG_FILAMENT_CHANGE_LOAD_3
|
2118
|
2137
|
STATIC_ITEM(MSG_FILAMENT_CHANGE_LOAD_3);
|
2119
|
2138
|
#endif
|
2120
|
|
- END_MENU();
|
|
2139
|
+ END_SCREEN();
|
2121
|
2140
|
}
|
2122
|
2141
|
|
2123
|
2142
|
static void lcd_filament_change_extrude_message() {
|
2124
|
|
- START_MENU();
|
|
2143
|
+ START_SCREEN();
|
2125
|
2144
|
STATIC_ITEM(MSG_FILAMENT_CHANGE_HEADER);
|
2126
|
2145
|
STATIC_ITEM(MSG_FILAMENT_CHANGE_EXTRUDE_1);
|
2127
|
2146
|
#ifdef MSG_FILAMENT_CHANGE_EXTRUDE_2
|
|
@@ -2130,11 +2149,11 @@ static void lcd_status_screen() {
|
2130
|
2149
|
#ifdef MSG_FILAMENT_CHANGE_EXTRUDE_3
|
2131
|
2150
|
STATIC_ITEM(MSG_FILAMENT_CHANGE_EXTRUDE_3);
|
2132
|
2151
|
#endif
|
2133
|
|
- END_MENU();
|
|
2152
|
+ END_SCREEN();
|
2134
|
2153
|
}
|
2135
|
2154
|
|
2136
|
2155
|
static void lcd_filament_change_resume_message() {
|
2137
|
|
- START_MENU();
|
|
2156
|
+ START_SCREEN();
|
2138
|
2157
|
STATIC_ITEM(MSG_FILAMENT_CHANGE_HEADER);
|
2139
|
2158
|
STATIC_ITEM(MSG_FILAMENT_CHANGE_RESUME_1);
|
2140
|
2159
|
#ifdef MSG_FILAMENT_CHANGE_RESUME_2
|
|
@@ -2143,7 +2162,7 @@ static void lcd_status_screen() {
|
2143
|
2162
|
#ifdef MSG_FILAMENT_CHANGE_RESUME_3
|
2144
|
2163
|
STATIC_ITEM(MSG_FILAMENT_CHANGE_RESUME_3);
|
2145
|
2164
|
#endif
|
2146
|
|
- END_MENU();
|
|
2165
|
+ END_SCREEN();
|
2147
|
2166
|
}
|
2148
|
2167
|
|
2149
|
2168
|
void lcd_filament_change_show_message(FilamentChangeMessage message) {
|