Browse Source

Merge pull request #4200 from thinkyhead/rc_cleanup_m600

Fix compiler warnings for static screens
Scott Lahteine 8 years ago
parent
commit
4fff9872b9
1 changed files with 50 additions and 31 deletions
  1. 50
    31
      Marlin/ultralcd.cpp

+ 50
- 31
Marlin/ultralcd.cpp View File

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

Loading…
Cancel
Save