Browse Source

LULZBOT_TOUCH_UI fixes. Fix some warnings. (#15276)

Marcio Teixeira 5 years ago
parent
commit
7a569ad4d0

+ 1
- 1
Marlin/src/core/macros.h View File

@@ -63,7 +63,7 @@
63 63
 // Macros for bit masks
64 64
 #undef _BV
65 65
 #define _BV(n) (1<<(n))
66
-#define TEST(n,b) !!((n)&_BV(b))
66
+#define TEST(n,b) (!!((n)&_BV(b)))
67 67
 #define SET_BIT_TO(N,B,TF) do{ if (TF) SBI(N,B); else CBI(N,B); }while(0)
68 68
 
69 69
 #ifndef SBI

+ 2
- 0
Marlin/src/feature/pause.cpp View File

@@ -500,6 +500,8 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep
500 500
 
501 501
   #if HAS_BUZZER
502 502
     filament_change_beep(max_beep_count, true);
503
+  #else
504
+    UNUSED(max_beep_count);
503 505
   #endif
504 506
 
505 507
   // Start the heater idle timers

+ 2
- 0
Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp View File

@@ -612,6 +612,8 @@ void ST7920_Lite_Status_Screen::draw_feedrate_percentage(const uint16_t percenta
612 612
     begin_data();
613 613
     write_number(percentage, 3);
614 614
     write_byte('%');
615
+  #else
616
+    UNUSED(percentage);
615 617
   #endif
616 618
 }
617 619
 

+ 28
- 4
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/command_processor.h View File

@@ -28,6 +28,11 @@ typedef struct {
28 28
   uint32_t rgb;
29 29
 } btn_colors;
30 30
 
31
+// Disable TOUCH_UI_FIT_TEXT on a case-by-case basis
32
+namespace FTDI {
33
+  constexpr uint16_t OPT_NOFIT = OPT_NOTICKS;
34
+}
35
+
31 36
 /**************************** Enhanced Command Processor **************************/
32 37
 
33 38
 /* The CommandProcessor class wraps the CommandFifo with several features to make
@@ -305,7 +310,7 @@ class CommandProcessor : public CLCD::CommandFifo {
305 310
     int8_t apply_fit_text(int16_t w, int16_t h, T text) {
306 311
       using namespace FTDI;
307 312
       int8_t font = _font;
308
-      for (;;) {
313
+      for (;font >= 26;) {
309 314
         #ifdef TOUCH_UI_USE_UTF8
310 315
           const int16_t width  = get_utf8_text_width(text, font_size_t::from_romfont(font));
311 316
           const int16_t height = font_size_t::from_romfont(font).get_height();
@@ -314,7 +319,7 @@ class CommandProcessor : public CLCD::CommandFifo {
314 319
           const int16_t width  = fm.get_text_width(text);
315 320
           const int16_t height = fm.height;
316 321
         #endif
317
-        if ((width < w && height < h) || font == 26) break;
322
+        if (width < w && height < h) break;
318 323
         font--;
319 324
       }
320 325
       return font;
@@ -328,11 +333,22 @@ class CommandProcessor : public CLCD::CommandFifo {
328 333
     }
329 334
 
330 335
     template<typename T>
336
+    uint16_t text_width(T text) {
337
+      using namespace FTDI;
338
+      #ifdef TOUCH_UI_USE_UTF8
339
+        return get_utf8_text_width(text, font_size_t::from_romfont(_font));
340
+      #else
341
+        CLCD::FontMetrics fm(_font);
342
+        return fm.get_text_width(text);
343
+      #endif
344
+    }
345
+
346
+    template<typename T>
331 347
     CommandProcessor& text(int16_t x, int16_t y, int16_t w, int16_t h, T text, uint16_t options = FTDI::OPT_CENTER) {
332 348
       using namespace FTDI;
333 349
       apply_text_alignment(x, y, w, h, options);
334 350
       #ifdef TOUCH_UI_FIT_TEXT
335
-        const int8_t font = apply_fit_text(w, h, text);
351
+        const int8_t font = (options & OPT_NOFIT) ? _font : apply_fit_text(w, h, text);
336 352
       #else
337 353
         const int8_t font = _font;
338 354
       #endif
@@ -367,7 +383,7 @@ class CommandProcessor : public CLCD::CommandFifo {
367 383
       bool styleModified = false;
368 384
       if (_btn_style_callback) styleModified = _btn_style_callback(*this, _tag, _style, options, false);
369 385
       #ifdef TOUCH_UI_FIT_TEXT
370
-        const int8_t font = apply_fit_text(w, h, text);
386
+        const int8_t font = (options & OPT_NOFIT) ? _font : apply_fit_text(w, h, text);
371 387
       #else
372 388
         const int8_t font = _font;
373 389
       #endif
@@ -375,6 +391,14 @@ class CommandProcessor : public CLCD::CommandFifo {
375 391
       #ifdef TOUCH_UI_USE_UTF8
376 392
         apply_text_alignment(x, y, w, h, OPT_CENTER);
377 393
         CLCD::CommandFifo::str(F(""));
394
+        if (!(options & FTDI::OPT_FLAT)) {
395
+          // Reproduce the black "shadow" the FTDI adds to the button label
396
+          CLCD::CommandFifo::cmd(SAVE_CONTEXT());
397
+          CLCD::CommandFifo::cmd(COLOR_RGB(0x00000));
398
+          draw_utf8_text(*this, x-1, y-1, text, font_size_t::from_romfont(font), OPT_CENTER);
399
+          CLCD::CommandFifo::cmd(RESTORE_CONTEXT());
400
+        }
401
+        // Draw the button label
378 402
         draw_utf8_text(*this, x, y, text, font_size_t::from_romfont(font), OPT_CENTER);
379 403
       #else
380 404
         CLCD::CommandFifo::str(text);

+ 1
- 1
Marlin/src/lcd/extensible_ui/lib/lulzbot/ftdi_eve_lib/extended/unicode/unicode.cpp View File

@@ -142,7 +142,7 @@
142 142
   uint16_t FTDI::get_utf8_text_width(progmem_str pstr, font_size_t fs) {
143 143
     char str[strlen_P((const char*)pstr) + 1];
144 144
     strcpy_P(str, (const char*)pstr);
145
-    return get_utf8_text_width((const char*) pstr, fs);
145
+    return get_utf8_text_width(str, fs);
146 146
   }
147 147
 
148 148
    /**

+ 5
- 2
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/base_screen.cpp View File

@@ -32,6 +32,7 @@ using namespace Theme;
32 32
 void BaseScreen::onEntry() {
33 33
   CommandProcessor cmd;
34 34
   cmd.set_button_style_callback(buttonStyleCallback);
35
+  reset_menu_timeout();
35 36
   UIScreen::onEntry();
36 37
 }
37 38
 
@@ -62,9 +63,11 @@ bool BaseScreen::buttonStyleCallback(CommandProcessor &cmd, uint8_t tag, uint8_t
62 63
 
63 64
 void BaseScreen::onIdle() {
64 65
   #ifdef LCD_TIMEOUT_TO_STATUS
65
-    const uint32_t elapsed = millis() - last_interaction;
66
-    if (elapsed > uint32_t(LCD_TIMEOUT_TO_STATUS)) {
66
+    if ((millis() - last_interaction) > LCD_TIMEOUT_TO_STATUS) {
67 67
       reset_menu_timeout();
68
+      #ifdef UI_FRAMEWORK_DEBUG
69
+        SERIAL_ECHO_MSG("Returning to status due to menu timeout");
70
+      #endif
68 71
       GOTO_SCREEN(StatusScreen);
69 72
     }
70 73
   #endif

+ 6
- 6
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/bio_advanced_settings.cpp View File

@@ -55,23 +55,23 @@ void AdvancedSettingsMenu::onRedraw(draw_mode_t what) {
55 55
       #else
56 56
        .enabled(0)
57 57
       #endif
58
-      .tag(4) .button( BTN_POS(1,3), BTN_SIZE(1,1), GET_TEXTF(BUMP_SENSE))
58
+      .tag(4) .button( BTN_POS(1,3), BTN_SIZE(1,1), GET_TEXTF(HOME_SENSE))
59 59
       .tag(5) .button( BTN_POS(1,4), BTN_SIZE(1,1), GET_TEXTF(ENDSTOPS))
60 60
       #if HOTENDS > 1
61 61
       .enabled(1)
62 62
       #else
63 63
       .enabled(0)
64 64
       #endif
65
-      .tag(6) .button( BTN_POS(1,5), BTN_SIZE(1,1), GET_TEXTF(NOZZLE_OFFSETS))
65
+      .tag(6) .button( BTN_POS(1,5), BTN_SIZE(1,1), GET_TEXTF(TOOL_OFFSETS))
66 66
 
67 67
 
68 68
       .tag(7) .button( BTN_POS(2,1), BTN_SIZE(1,1), GET_TEXTF(STEPS_PER_MM))
69
-      .tag(8) .button( BTN_POS(2,2), BTN_SIZE(1,1), GET_TEXTF(MAX_VELOCITY))
70
-      .tag(9) .button( BTN_POS(2,3), BTN_SIZE(1,1), GET_TEXTF(MAX_ACCELERATION))
69
+      .tag(8) .button( BTN_POS(2,2), BTN_SIZE(1,1), GET_TEXTF(VELOCITY))
70
+      .tag(9) .button( BTN_POS(2,3), BTN_SIZE(1,1), GET_TEXTF(ACCELERATION))
71 71
       #if ENABLED(JUNCTION_DEVIATION)
72 72
         .tag(10) .button( BTN_POS(2,4), BTN_SIZE(1,1), GET_TEXTF(JUNCTION_DEVIATION))
73 73
       #else
74
-        .tag(10) .button( BTN_POS(2,4), BTN_SIZE(1,1), GET_TEXTF(MAX_JERK))
74
+        .tag(10) .button( BTN_POS(2,4), BTN_SIZE(1,1), GET_TEXTF(JERK))
75 75
       #endif
76 76
       #if ENABLED(BACKLASH_GCODE)
77 77
       .enabled(1)
@@ -86,7 +86,7 @@ void AdvancedSettingsMenu::onRedraw(draw_mode_t what) {
86 86
       #endif
87 87
       .tag(12) .button( BTN_POS(1,6), BTN_SIZE(2,1), GET_TEXTF(LINEAR_ADVANCE))
88 88
       .tag(13) .button( BTN_POS(1,7), BTN_SIZE(2,1), GET_TEXTF(INTERFACE_SETTINGS))
89
-      .tag(14) .button( BTN_POS(1,8), BTN_SIZE(2,1), GET_TEXTF(RESTORE_FAILSAFE))
89
+      .tag(14) .button( BTN_POS(1,8), BTN_SIZE(2,1), GET_TEXTF(RESTORE_DEFAULTS))
90 90
       .colors(action_btn)
91 91
       .tag(1). button( BTN_POS(1,9), BTN_SIZE(2,1), GET_TEXTF(BACK));
92 92
     #undef GRID_COLS

+ 2
- 2
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/bio_printing_dialog_box.cpp View File

@@ -113,8 +113,8 @@ bool BioPrintingDialogBox::onTouchEnd(uint8_t tag) {
113 113
 }
114 114
 
115 115
 void BioPrintingDialogBox::setStatusMessage(progmem_str message) {
116
-  char buff[strlen_P((const char * const)message)+1];
117
-  strcpy_P(buff, (const char * const) message);
116
+  char buff[strlen_P((const char*)message)+1];
117
+  strcpy_P(buff, (const char*) message);
118 118
   setStatusMessage(buff);
119 119
 }
120 120
 

+ 18
- 17
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/bio_status_screen.cpp View File

@@ -82,6 +82,10 @@ void StatusScreen::draw_temperature(draw_mode_t what) {
82 82
        .icon (x + 2, y + 2, h, v, Bed_Heat_Icon_Info, icon_scale * 2)
83 83
        .cmd(COLOR_RGB(bg_text_enabled))
84 84
        .icon (x, y, h, v, Bed_Heat_Icon_Info, icon_scale * 2);
85
+
86
+    #ifdef TOUCH_UI_USE_UTF8
87
+      load_utf8_bitmaps(cmd); // Restore font bitmap handles
88
+    #endif
85 89
   }
86 90
 
87 91
   if (what & FOREGROUND) {
@@ -91,12 +95,12 @@ void StatusScreen::draw_temperature(draw_mode_t what) {
91 95
        .cmd(COLOR_RGB(bg_text_enabled));
92 96
 
93 97
     if (!isHeaterIdle(BED) && getTargetTemp_celsius(BED) > 0) {
94
-      sprintf_P(bed_str, F("%3d%S"), ROUND(getTargetTemp_celsius(BED), GET_TEXT(UNITS_C)));
98
+      sprintf_P(bed_str, PSTR("%3d%S"), ROUND(getTargetTemp_celsius(BED)), GET_TEXT(UNITS_C));
95 99
       ui.bounds(POLY(target_temp), x, y, h, v);
96 100
       cmd.text(x, y, h, v, bed_str);
97 101
     }
98 102
 
99
-    sprintf_P(bed_str, F("%3d%S"), ROUND(getActualTemp_celsius(BED)), GET_TEXT(UNITS_C));
103
+    sprintf_P(bed_str, PSTR("%3d%S"), ROUND(getActualTemp_celsius(BED)), GET_TEXT(UNITS_C));
100 104
     ui.bounds(POLY(actual_temp), x, y, h, v);
101 105
     cmd.text(x, y, h, v, bed_str);
102 106
   }
@@ -197,17 +201,9 @@ void StatusScreen::draw_overlay_icons(draw_mode_t what) {
197 201
     ui.button_stroke(stroke_rgb, 28);
198 202
     ui.button_shadow(shadow_rgb, shadow_depth);
199 203
 
200
-    if (!jog_xy) {
201
-      ui.button(12, POLY(padlock));
202
-    }
203
-
204
-    if (!e_homed) {
205
-      ui.button(13, POLY(home_e));
206
-    }
207
-
208
-    if (!z_homed) {
209
-      ui.button(14, POLY(home_z));
210
-    }
204
+    if (!jog_xy)  ui.button(12, POLY(padlock));
205
+    if (!e_homed) ui.button(13, POLY(home_e));
206
+    if (!z_homed) ui.button(14, POLY(home_z));
211 207
   }
212 208
 }
213 209
 
@@ -228,19 +224,24 @@ void StatusScreen::draw_buttons(draw_mode_t) {
228 224
         isPrintingFromMedia() ?
229 225
           GET_TEXTF(PRINTING) :
230 226
         #ifdef LULZBOT_MANUAL_USB_STARTUP
231
-        (Sd2Card::ready() ? GET_TEXTF(MEDIA) : GET_TEXTF(ENABLE_MEDIA))
227
+          (Sd2Card::ready() ? GET_TEXTF(MEDIA) : GET_TEXTF(ENABLE_MEDIA))
232 228
         #else
233
-        GET_TEXTF(MEDIA)
229
+          GET_TEXTF(MEDIA)
234 230
         #endif
235 231
       );
236 232
 
237
-  cmd.colors(!has_media ? action_btn : normal_btn).tag(10).button(BTN_POS(2,9), BTN_SIZE(1,1), F("Menu"));
233
+  cmd.colors(!has_media ? action_btn : normal_btn).tag(10).button(BTN_POS(2,9), BTN_SIZE(1,1), GET_TEXTF(MENU));
238 234
 }
239 235
 
240
-void StatusScreen::onStartup() {
236
+void StatusScreen::loadBitmaps() {
241 237
   // Load the bitmaps for the status screen
242 238
   constexpr uint32_t base = ftdi_memory_map::RAM_G;
243 239
   CLCD::mem_write_pgm(base + Bed_Heat_Icon_Info.RAMG_offset, Bed_Heat_Icon, sizeof(Bed_Heat_Icon));
240
+
241
+  // Load fonts for internationalization
242
+  #ifdef TOUCH_UI_USE_UTF8
243
+    load_utf8_data(base + UTF8_FONT_OFFSET);
244
+  #endif
244 245
 }
245 246
 
246 247
 void StatusScreen::onRedraw(draw_mode_t what) {

+ 4
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/dialog_box_base_class.cpp View File

@@ -80,4 +80,8 @@ bool DialogBoxBaseClass::onTouchEnd(uint8_t tag) {
80 80
   }
81 81
 }
82 82
 
83
+void DialogBoxBaseClass::onIdle() {
84
+  reset_menu_timeout();
85
+}
86
+
83 87
 #endif // LULZBOT_TOUCH_UI

+ 2
- 1
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/endstop_state_screen.cpp View File

@@ -108,7 +108,8 @@ void EndstopStatesScreen::onRedraw(draw_mode_t) {
108 108
   #if HAS_SOFTWARE_ENDSTOPS
109 109
     #undef EDGE_R
110 110
     #define EDGE_R 30
111
-    cmd.font(font_small)
111
+    cmd.cmd(COLOR_RGB(bg_text_enabled))
112
+       .font(font_small)
112 113
        .text         (BTN_POS(1,5), BTN_SIZE(3,1), GET_TEXTF(SOFT_ENDSTOPS), OPT_RIGHTX | OPT_CENTERY)
113 114
        .colors(ui_toggle)
114 115
        .tag(2).toggle2(BTN_POS(4,5), BTN_SIZE(3,1), GET_TEXTF(NO), GET_TEXTF(YES), getSoftEndstopState());

+ 7
- 3
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/files_screen.cpp View File

@@ -91,7 +91,11 @@ void FilesScreen::drawFileButton(const char* filename, uint8_t tag, bool is_dir,
91 91
       cmd.cmd(MACRO(0));
92 92
     }
93 93
   #endif
94
-  cmd.text  (BTN_POS(1,header_h+line), BTN_SIZE(6,1), filename, OPT_CENTERY);
94
+  cmd.text  (BTN_POS(1,header_h+line), BTN_SIZE(6,1), filename, OPT_CENTERY
95
+    #if ENABLED(SCROLL_LONG_FILENAMES)
96
+      | OPT_NOFIT
97
+    #endif
98
+  );
95 99
   if (is_dir) {
96 100
     cmd.text(BTN_POS(1,header_h+line), BTN_SIZE(6,1), F("> "),  OPT_CENTERY | OPT_RIGHTX);
97 101
   }
@@ -234,8 +238,8 @@ bool FilesScreen::onTouchEnd(uint8_t tag) {
234 238
           if (FTDI::ftdi_chip >= 810) {
235 239
             const char *longFilename = getSelectedLongFilename();
236 240
             if (longFilename[0]) {
237
-              CLCD::FontMetrics fm(font_medium);
238
-              uint16_t text_width = fm.get_text_width(longFilename);
241
+              CommandProcessor cmd;
242
+              uint16_t text_width = cmd.font(font_medium).text_width(longFilename);
239 243
               screen_data.FilesScreen.scroll_pos = 0;
240 244
               if (text_width > display_width)
241 245
                 screen_data.FilesScreen.scroll_max = text_width - display_width + MARGIN_L + MARGIN_R;

+ 2
- 1
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/screens.h View File

@@ -148,6 +148,7 @@ class DialogBoxBaseClass : public BaseScreen {
148 148
     static void onRedraw(draw_mode_t) {};
149 149
   public:
150 150
     static bool onTouchEnd(uint8_t tag);
151
+    static void onIdle();
151 152
 };
152 153
 
153 154
 class AlertDialogBox : public DialogBoxBaseClass, public CachedScreen<ALERT_BOX_CACHE,ALERT_BOX_DL_SIZE> {
@@ -243,12 +244,12 @@ class StatusScreen : public BaseScreen, public CachedScreen<STATUS_SCREEN_CACHE,
243 244
       static void draw_fine_motion(draw_mode_t what);
244 245
       static void draw_buttons(draw_mode_t what);
245 246
     public:
247
+      static void loadBitmaps();
246 248
       static void unlockMotors();
247 249
 
248 250
       static void setStatusMessage(const char *);
249 251
       static void setStatusMessage(progmem_str);
250 252
 
251
-      static void onStartup();
252 253
       static void onRedraw(draw_mode_t);
253 254
 
254 255
       static bool onTouchStart(uint8_t tag);

+ 1
- 0
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/spinner_dialog_box.cpp View File

@@ -57,6 +57,7 @@ void SpinnerDialogBox::enqueueAndWait_P(const progmem_str message, const progmem
57 57
 }
58 58
 
59 59
 void SpinnerDialogBox::onIdle() {
60
+  reset_menu_timeout();
60 61
   if (screen_data.SpinnerDialogBox.auto_hide && !commandsInQueue()) {
61 62
     screen_data.SpinnerDialogBox.auto_hide = false;
62 63
     hide();

+ 4
- 3
Marlin/src/lcd/extensible_ui/lib/lulzbot/screens/status_screen.cpp View File

@@ -181,6 +181,10 @@ void StatusScreen::draw_temperature(draw_mode_t what) {
181 181
        .cmd(BITMAP_LAYOUT(Fan_Icon_Info))
182 182
        .cmd(BITMAP_SIZE  (Fan_Icon_Info))
183 183
        .icon  (BTN_POS(5,2), BTN_SIZE(1,1), Fan_Icon_Info, icon_scale);
184
+
185
+    #ifdef TOUCH_UI_USE_UTF8
186
+      load_utf8_bitmaps(cmd); // Restore font bitmap handles
187
+    #endif
184 188
   }
185 189
 
186 190
   if (what & FOREGROUND) {
@@ -342,9 +346,6 @@ void StatusScreen::setStatusMessage(const char* message) {
342 346
      .cmd(CLEAR(true,true,true));
343 347
 
344 348
   draw_temperature(BACKGROUND);
345
-  #ifdef TOUCH_UI_USE_UTF8
346
-    load_utf8_bitmaps(cmd);
347
-  #endif
348 349
   draw_progress(BACKGROUND);
349 350
   draw_axis_position(BACKGROUND);
350 351
   draw_status_message(BACKGROUND, message);

+ 7
- 0
Marlin/src/lcd/extensible_ui/ui_api.cpp View File

@@ -170,6 +170,8 @@ namespace ExtUI {
170 170
   void enableHeater(const extruder_t extruder) {
171 171
     #if HOTENDS && HEATER_IDLE_HANDLER
172 172
       thermalManager.reset_heater_idle_timer(extruder - E0);
173
+    #else
174
+      UNUSED(extruder);
173 175
     #endif
174 176
   }
175 177
 
@@ -190,6 +192,8 @@ namespace ExtUI {
190 192
           #endif
191 193
           break;
192 194
       }
195
+    #else
196
+      UNUSED(heater);
193 197
     #endif
194 198
   }
195 199
 
@@ -197,6 +201,8 @@ namespace ExtUI {
197 201
     return false
198 202
       #if HOTENDS && HEATER_IDLE_HANDLER
199 203
         || thermalManager.hotend_idle[extruder - E0].timed_out
204
+      #else
205
+        ; UNUSED(extruder)
200 206
       #endif
201 207
     ;
202 208
   }
@@ -218,6 +224,7 @@ namespace ExtUI {
218 224
           #endif
219 225
       }
220 226
     #else
227
+      UNUSED(heater);
221 228
       return false;
222 229
     #endif
223 230
   }

Loading…
Cancel
Save