Sfoglia il codice sorgente

Add helpers for custom text in menu items (#12214)

For some features it can be useful to write custom text in a menu item. This commit provides helpers to make this easier.
Scott Lahteine 6 anni fa
parent
commit
bf9dd4f4cf
Nessun account collegato all'indirizzo email del committer
2 ha cambiato i file con 34 aggiunte e 22 eliminazioni
  1. 25
    21
      Marlin/src/lcd/ultralcd.cpp
  2. 9
    1
      Marlin/src/lcd/ultralcd.h

+ 25
- 21
Marlin/src/lcd/ultralcd.cpp Vedi File

@@ -121,6 +121,13 @@ LCDViewAction lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
121 121
 uint16_t max_display_update_time = 0;
122 122
 millis_t next_lcd_update_ms;
123 123
 
124
+#if HAS_LCD_CONTRAST
125
+  void set_lcd_contrast(const int16_t value) {
126
+    lcd_contrast = constrain(value, LCD_CONTRAST_MIN, LCD_CONTRAST_MAX);
127
+    u8g.setContrast(lcd_contrast);
128
+  }
129
+#endif
130
+
124 131
 #if ENABLED(ULTIPANEL)
125 132
 
126 133
   #define DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(_type, _name, _strFunc) \
@@ -339,6 +346,12 @@ millis_t next_lcd_update_ms;
339 346
 
340 347
   #define MENU_BACK(LABEL) MENU_ITEM(back, LABEL, 0)
341 348
 
349
+  #define MENU_ITEM_ADDON_START(X) \
350
+    if (lcdDrawUpdate && _menuLineNr == _thisItemNr - 1) { \
351
+      SETCURSOR(X, _lcdLineNr)
352
+
353
+  #define MENU_ITEM_ADDON_END() } (0)
354
+
342 355
   // Used to print static text with no visible cursor.
343 356
   // Parameters: label [, bool center [, bool invert [, char *value] ] ]
344 357
   #define STATIC_ITEM_P(LABEL, ...) do{ \
@@ -3264,21 +3277,11 @@ void lcd_quick_feedback(const bool clear_buttons) {
3264 3277
    * "Motion" > "Move Axis" submenu
3265 3278
    *
3266 3279
    */
3267
-
3268
-  #if IS_KINEMATIC || ENABLED(NO_MOTION_BEFORE_HOMING)
3269
-    #define _MOVE_XYZ_ALLOWED (all_axes_homed())
3270
-  #else
3271
-    #define _MOVE_XYZ_ALLOWED true
3272
-  #endif
3273
-
3274 3280
   #if ENABLED(DELTA)
3275
-    #define _MOVE_XY_ALLOWED (current_position[Z_AXIS] <= delta_clip_start_height)
3276 3281
     void lcd_lower_z_to_clip_height() {
3277 3282
       line_to_z(delta_clip_start_height);
3278 3283
       lcd_synchronize();
3279 3284
     }
3280
-  #else
3281
-    #define _MOVE_XY_ALLOWED true
3282 3285
   #endif
3283 3286
 
3284 3287
   void lcd_move_menu() {
@@ -3289,8 +3292,18 @@ void lcd_quick_feedback(const bool clear_buttons) {
3289 3292
       MENU_ITEM_EDIT(bool, MSG_LCD_SOFT_ENDSTOPS, &soft_endstops_enabled);
3290 3293
     #endif
3291 3294
 
3292
-    if (_MOVE_XYZ_ALLOWED) {
3293
-      if (_MOVE_XY_ALLOWED) {
3295
+    #if IS_KINEMATIC || ENABLED(NO_MOTION_BEFORE_HOMING)
3296
+      const bool do_move_xyz = all_axes_homed();
3297
+    #else
3298
+      constexpr bool do_move_xyz = true;
3299
+    #endif
3300
+    if (do_move_xyz) {
3301
+      #if ENABLED(DELTA)
3302
+        const bool do_move_xy = current_position[Z_AXIS] <= delta_clip_start_height;
3303
+      #else
3304
+        constexpr bool do_move_xy = true;
3305
+      #endif
3306
+      if (do_move_xy) {
3294 3307
         MENU_ITEM(submenu, MSG_MOVE_X, lcd_move_get_x_amount);
3295 3308
         MENU_ITEM(submenu, MSG_MOVE_Y, lcd_move_get_y_amount);
3296 3309
       }
@@ -5804,15 +5817,6 @@ void lcd_setalertstatusPGM(PGM_P const message) {
5804 5817
 
5805 5818
 void lcd_reset_alert_level() { lcd_status_message_level = 0; }
5806 5819
 
5807
-#if HAS_LCD_CONTRAST
5808
-
5809
-  void set_lcd_contrast(const int16_t value) {
5810
-    lcd_contrast = constrain(value, LCD_CONTRAST_MIN, LCD_CONTRAST_MAX);
5811
-    u8g.setContrast(lcd_contrast);
5812
-  }
5813
-
5814
-#endif
5815
-
5816 5820
 #if ENABLED(ULTIPANEL)
5817 5821
 
5818 5822
   /**

+ 9
- 1
Marlin/src/lcd/ultralcd.h Vedi File

@@ -87,11 +87,19 @@
87 87
     uint8_t get_ADC_keyValue();
88 88
   #endif
89 89
 
90
-  #if ENABLED(DOGLCD)
90
+  #if HAS_LCD_CONTRAST
91 91
     extern int16_t lcd_contrast;
92 92
     void set_lcd_contrast(const int16_t value);
93 93
   #endif
94 94
 
95
+  #if ENABLED(DOGLCD)
96
+    #define SETCURSOR(col, row) lcd_moveto(col * (DOG_CHAR_WIDTH), (row + 1) * row_height)
97
+    #define SETCURSOR_RJ(len, row) lcd_moveto(LCD_PIXEL_WIDTH - len * (DOG_CHAR_WIDTH), (row + 1) * row_height)
98
+  #else
99
+    #define SETCURSOR(col, row) lcd_moveto(col, row)
100
+    #define SETCURSOR_RJ(len, row) lcd_moveto(LCD_WIDTH - len, row)
101
+  #endif
102
+
95 103
   #if ENABLED(SHOW_BOOTSCREEN)
96 104
     void lcd_bootscreen();
97 105
   #endif

Loading…
Annulla
Salva