Browse Source

Merge branch 'optimize_menu_code' of https://github.com/thinkyhead/Marlin into beautify

Conflicts:
	Marlin/dogm_lcd_implementation.h

solved merge conflict.
AnHardt 9 years ago
parent
commit
f1d3d1524d

+ 2
- 2
Marlin/SdBaseFile.h View File

171
   return 2*(fatTime & 0X1F);
171
   return 2*(fatTime & 0X1F);
172
 }
172
 }
173
 /** Default date for file timestamps is 1 Jan 2000 */
173
 /** Default date for file timestamps is 1 Jan 2000 */
174
-uint16_t const FAT_DEFAULT_DATE = ((2000 - 1980) << 9) | BIT(5) | 1;
174
+uint16_t const FAT_DEFAULT_DATE = ((2000 - 1980) << 9) | (1 << 5) | 1;
175
 /** Default time for file timestamp is 1 am */
175
 /** Default time for file timestamp is 1 am */
176
-uint16_t const FAT_DEFAULT_TIME = BIT(11);
176
+uint16_t const FAT_DEFAULT_TIME = (1 << 11);
177
 //------------------------------------------------------------------------------
177
 //------------------------------------------------------------------------------
178
 /**
178
 /**
179
  * \class SdBaseFile
179
  * \class SdBaseFile

+ 54
- 78
Marlin/dogm_lcd_implementation.h View File

139
       u8g.drawStr(txt1X, u8g.getHeight() - DOG_CHAR_HEIGHT*3/2, STRING_SPLASH_LINE1);
139
       u8g.drawStr(txt1X, u8g.getHeight() - DOG_CHAR_HEIGHT*3/2, STRING_SPLASH_LINE1);
140
       u8g.drawStr(txt2X, u8g.getHeight() - DOG_CHAR_HEIGHT*1/2, STRING_SPLASH_LINE2);
140
       u8g.drawStr(txt2X, u8g.getHeight() - DOG_CHAR_HEIGHT*1/2, STRING_SPLASH_LINE2);
141
     #endif
141
     #endif
142
-	} while(u8g.nextPage());
142
+	} while (u8g.nextPage());
143
 }
143
 }
144
 
144
 
145
 static void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
145
 static void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
222
     int per = ((fanSpeed + 1) * 100) / 256;
222
     int per = ((fanSpeed + 1) * 100) / 256;
223
     if (per) {
223
     if (per) {
224
       u8g.print(itostr3(per));
224
       u8g.print(itostr3(per));
225
-      u8g.print("%");
225
+      u8g.print('%');
226
     }
226
     }
227
     else
227
     else
228
   #endif
228
   #endif
236
   u8g.drawBox(0,30,128,9);
236
   u8g.drawBox(0,30,128,9);
237
   u8g.setColorIndex(0); // white on black
237
   u8g.setColorIndex(0); // white on black
238
   u8g.setPrintPos(2,XYZ_BASELINE);
238
   u8g.setPrintPos(2,XYZ_BASELINE);
239
-  u8g.print("X");
239
+  u8g.print('X');
240
   u8g.drawPixel(8,XYZ_BASELINE - 5);
240
   u8g.drawPixel(8,XYZ_BASELINE - 5);
241
   u8g.drawPixel(8,XYZ_BASELINE - 3);
241
   u8g.drawPixel(8,XYZ_BASELINE - 3);
242
   u8g.setPrintPos(10,XYZ_BASELINE);
242
   u8g.setPrintPos(10,XYZ_BASELINE);
243
   u8g.print(ftostr31ns(current_position[X_AXIS]));
243
   u8g.print(ftostr31ns(current_position[X_AXIS]));
244
   u8g.setPrintPos(43,XYZ_BASELINE);
244
   u8g.setPrintPos(43,XYZ_BASELINE);
245
-  lcd_printPGM(PSTR("Y"));
245
+  u8g.print('Y');
246
   u8g.drawPixel(49,XYZ_BASELINE - 5);
246
   u8g.drawPixel(49,XYZ_BASELINE - 5);
247
   u8g.drawPixel(49,XYZ_BASELINE - 3);
247
   u8g.drawPixel(49,XYZ_BASELINE - 3);
248
   u8g.setPrintPos(51,XYZ_BASELINE);
248
   u8g.setPrintPos(51,XYZ_BASELINE);
249
   u8g.print(ftostr31ns(current_position[Y_AXIS]));
249
   u8g.print(ftostr31ns(current_position[Y_AXIS]));
250
   u8g.setPrintPos(83,XYZ_BASELINE);
250
   u8g.setPrintPos(83,XYZ_BASELINE);
251
-  u8g.print("Z");
251
+  u8g.print('Z');
252
   u8g.drawPixel(89,XYZ_BASELINE - 5);
252
   u8g.drawPixel(89,XYZ_BASELINE - 5);
253
   u8g.drawPixel(89,XYZ_BASELINE - 3);
253
   u8g.drawPixel(89,XYZ_BASELINE - 3);
254
   u8g.setPrintPos(91,XYZ_BASELINE);
254
   u8g.setPrintPos(91,XYZ_BASELINE);
283
   #endif
283
   #endif
284
 }
284
 }
285
 
285
 
286
-static void lcd_implementation_mark_as_selected(uint8_t row, char pr_char) {
287
-  if ((pr_char == '>') || (pr_char == LCD_STR_UPLEVEL[0] )) {
286
+static void lcd_implementation_mark_as_selected(uint8_t row, bool isSelected) {
287
+  if (isSelected) {
288
     u8g.setColorIndex(1);  // black on white
288
     u8g.setColorIndex(1);  // black on white
289
-    u8g.drawBox (0, row*DOG_CHAR_HEIGHT + 3, 128, DOG_CHAR_HEIGHT);
289
+    u8g.drawBox(0, row * DOG_CHAR_HEIGHT + 3, 128, DOG_CHAR_HEIGHT);
290
     u8g.setColorIndex(0);  // following text must be white on black
290
     u8g.setColorIndex(0);  // following text must be white on black
291
   }
291
   }
292
   else {
292
   else {
295
   u8g.setPrintPos(START_ROW * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT);
295
   u8g.setPrintPos(START_ROW * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT);
296
 }
296
 }
297
 
297
 
298
-static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, char pre_char, char post_char) {
298
+static void lcd_implementation_drawmenu_generic(bool isSelected, uint8_t row, const char* pstr, char pre_char, char post_char) {
299
   char c;
299
   char c;
300
   uint8_t n = LCD_WIDTH - 2;
300
   uint8_t n = LCD_WIDTH - 2;
301
 
301
 
302
-  lcd_implementation_mark_as_selected(row, pre_char);
302
+  lcd_implementation_mark_as_selected(row, isSelected);
303
 
303
 
304
-  while((c = pgm_read_byte(pstr))) {
304
+  while ((c = pgm_read_byte(pstr))) {
305
     u8g.print(c);
305
     u8g.print(c);
306
     pstr++;
306
     pstr++;
307
     n--;
307
     n--;
308
   }
308
   }
309
-  while(n--) u8g.print(' ');
309
+  while (n--) u8g.print(' ');
310
   u8g.print(post_char);
310
   u8g.print(post_char);
311
   u8g.print(' ');
311
   u8g.print(' ');
312
 }
312
 }
313
 
313
 
314
-static void _drawmenu_setting_edit_generic(uint8_t row, const char* pstr, char pre_char, const char* data, bool pgm) {
314
+static void _drawmenu_setting_edit_generic(bool isSelected, uint8_t row, const char* pstr, const char* data, bool pgm) {
315
   char c;
315
   char c;
316
   uint8_t n = LCD_WIDTH - 2 - (pgm ? lcd_strlen_P(data) : (lcd_strlen((char*)data)));
316
   uint8_t n = LCD_WIDTH - 2 - (pgm ? lcd_strlen_P(data) : (lcd_strlen((char*)data)));
317
 
317
 
318
-  lcd_implementation_mark_as_selected(row, pre_char);
318
+  lcd_implementation_mark_as_selected(row, isSelected);
319
 
319
 
320
-  while( (c = pgm_read_byte(pstr))) {
320
+  while ((c = pgm_read_byte(pstr))) {
321
     u8g.print(c);
321
     u8g.print(c);
322
     pstr++;
322
     pstr++;
323
     n--;
323
     n--;
324
   }
324
   }
325
   u8g.print(':');
325
   u8g.print(':');
326
-  while(n--) u8g.print(' ');
326
+  while (n--) u8g.print(' ');
327
   if (pgm) { lcd_printPGM(data); } else { u8g.print(data); }
327
   if (pgm) { lcd_printPGM(data); } else { u8g.print(data); }
328
 }
328
 }
329
 
329
 
330
-#define lcd_implementation_drawmenu_setting_edit_generic(row, pstr, pre_char, data) _drawmenu_setting_edit_generic(row, pstr, pre_char, data, false)
331
-#define lcd_implementation_drawmenu_setting_edit_generic_P(row, pstr, pre_char, data) _drawmenu_setting_edit_generic(row, pstr, pre_char, data, true)
332
-
333
-#define lcd_implementation_drawmenu_setting_edit_int3_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', itostr3(*(data)))
334
-#define lcd_implementation_drawmenu_setting_edit_int3(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', itostr3(*(data)))
335
-#define lcd_implementation_drawmenu_setting_edit_float3_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr3(*(data)))
336
-#define lcd_implementation_drawmenu_setting_edit_float3(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr3(*(data)))
337
-#define lcd_implementation_drawmenu_setting_edit_float32_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr32(*(data)))
338
-#define lcd_implementation_drawmenu_setting_edit_float32(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr32(*(data)))
339
-#define lcd_implementation_drawmenu_setting_edit_float43_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr43(*(data)))
340
-#define lcd_implementation_drawmenu_setting_edit_float43(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr43(*(data)))
341
-#define lcd_implementation_drawmenu_setting_edit_float5_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr5(*(data)))
342
-#define lcd_implementation_drawmenu_setting_edit_float5(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data)))
343
-#define lcd_implementation_drawmenu_setting_edit_float52_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr52(*(data)))
344
-#define lcd_implementation_drawmenu_setting_edit_float52(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr52(*(data)))
345
-#define lcd_implementation_drawmenu_setting_edit_float51_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr51(*(data)))
346
-#define lcd_implementation_drawmenu_setting_edit_float51(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr51(*(data)))
347
-#define lcd_implementation_drawmenu_setting_edit_long5_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr5(*(data)))
348
-#define lcd_implementation_drawmenu_setting_edit_long5(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data)))
349
-#define lcd_implementation_drawmenu_setting_edit_bool_selected(row, pstr, pstr2, data) lcd_implementation_drawmenu_setting_edit_generic_P(row, pstr, '>', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
350
-#define lcd_implementation_drawmenu_setting_edit_bool(row, pstr, pstr2, data) lcd_implementation_drawmenu_setting_edit_generic_P(row, pstr, ' ', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
330
+#define lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, data) _drawmenu_setting_edit_generic(sel, row, pstr, data, false)
331
+#define lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, data) _drawmenu_setting_edit_generic(sel, row, pstr, data, true)
332
+
333
+#define lcd_implementation_drawmenu_setting_edit_int3(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, itostr3(*(data)))
334
+#define lcd_implementation_drawmenu_setting_edit_float3(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr3(*(data)))
335
+#define lcd_implementation_drawmenu_setting_edit_float32(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr32(*(data)))
336
+#define lcd_implementation_drawmenu_setting_edit_float43(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr43(*(data)))
337
+#define lcd_implementation_drawmenu_setting_edit_float5(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr5(*(data)))
338
+#define lcd_implementation_drawmenu_setting_edit_float52(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr52(*(data)))
339
+#define lcd_implementation_drawmenu_setting_edit_float51(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr51(*(data)))
340
+#define lcd_implementation_drawmenu_setting_edit_long5(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr5(*(data)))
341
+#define lcd_implementation_drawmenu_setting_edit_bool(sel, row, pstr, pstr2, data) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
351
 
342
 
352
 //Add version for callback functions
343
 //Add version for callback functions
353
-#define lcd_implementation_drawmenu_setting_edit_callback_int3_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', itostr3(*(data)))
354
-#define lcd_implementation_drawmenu_setting_edit_callback_int3(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', itostr3(*(data)))
355
-#define lcd_implementation_drawmenu_setting_edit_callback_float3_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr3(*(data)))
356
-#define lcd_implementation_drawmenu_setting_edit_callback_float3(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr3(*(data)))
357
-#define lcd_implementation_drawmenu_setting_edit_callback_float32_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr32(*(data)))
358
-#define lcd_implementation_drawmenu_setting_edit_callback_float32(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr32(*(data)))
359
-#define lcd_implementation_drawmenu_setting_edit_callback_float43_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr43(*(data)))
360
-#define lcd_implementation_drawmenu_setting_edit_callback_float43(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr43(*(data)))
361
-#define lcd_implementation_drawmenu_setting_edit_callback_float5_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr5(*(data)))
362
-#define lcd_implementation_drawmenu_setting_edit_callback_float5(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data)))
363
-#define lcd_implementation_drawmenu_setting_edit_callback_float52_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr52(*(data)))
364
-#define lcd_implementation_drawmenu_setting_edit_callback_float52(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr52(*(data)))
365
-#define lcd_implementation_drawmenu_setting_edit_callback_float51_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr51(*(data)))
366
-#define lcd_implementation_drawmenu_setting_edit_callback_float51(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr51(*(data)))
367
-#define lcd_implementation_drawmenu_setting_edit_callback_long5_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr5(*(data)))
368
-#define lcd_implementation_drawmenu_setting_edit_callback_long5(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data)))
369
-#define lcd_implementation_drawmenu_setting_edit_callback_bool_selected(row, pstr, pstr2, data, callback) lcd_implementation_drawmenu_setting_edit_generic_P(row, pstr, '>', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
370
-#define lcd_implementation_drawmenu_setting_edit_callback_bool(row, pstr, pstr2, data, callback) lcd_implementation_drawmenu_setting_edit_generic_P(row, pstr, ' ', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
344
+#define lcd_implementation_drawmenu_setting_edit_callback_int3(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, itostr3(*(data)))
345
+#define lcd_implementation_drawmenu_setting_edit_callback_float3(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr3(*(data)))
346
+#define lcd_implementation_drawmenu_setting_edit_callback_float32(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr32(*(data)))
347
+#define lcd_implementation_drawmenu_setting_edit_callback_float43(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr43(*(data)))
348
+#define lcd_implementation_drawmenu_setting_edit_callback_float5(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr5(*(data)))
349
+#define lcd_implementation_drawmenu_setting_edit_callback_float52(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr52(*(data)))
350
+#define lcd_implementation_drawmenu_setting_edit_callback_float51(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr51(*(data)))
351
+#define lcd_implementation_drawmenu_setting_edit_callback_long5(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ftostr5(*(data)))
352
+#define lcd_implementation_drawmenu_setting_edit_callback_bool(sel, row, pstr, pstr2, data, callback) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
371
 
353
 
372
 void lcd_implementation_drawedit(const char* pstr, char* value) {
354
 void lcd_implementation_drawedit(const char* pstr, char* value) {
373
   uint8_t rows = 1;
355
   uint8_t rows = 1;
374
-  uint8_t lcd_width = LCD_WIDTH;
375
-  uint8_t char_width = DOG_CHAR_WIDTH;
356
+  uint8_t lcd_width = LCD_WIDTH, char_width = DOG_CHAR_WIDTH;
357
+  uint8_t vallen = lcd_strlen(value);
376
 
358
 
377
   #ifdef USE_BIG_EDIT_FONT
359
   #ifdef USE_BIG_EDIT_FONT
378
     if (lcd_strlen_P(pstr) <= LCD_WIDTH_EDIT - 1) {
360
     if (lcd_strlen_P(pstr) <= LCD_WIDTH_EDIT - 1) {
379
       u8g.setFont(FONT_MENU_EDIT);
361
       u8g.setFont(FONT_MENU_EDIT);
380
       lcd_width = LCD_WIDTH_EDIT + 1;
362
       lcd_width = LCD_WIDTH_EDIT + 1;
381
       char_width = DOG_CHAR_WIDTH_EDIT;
363
       char_width = DOG_CHAR_WIDTH_EDIT;
382
-      if (lcd_strlen_P(pstr) >= LCD_WIDTH_EDIT - lcd_strlen(value)) rows = 2;
364
+      if (lcd_strlen_P(pstr) >= LCD_WIDTH_EDIT - vallen) rows = 2;
383
     }
365
     }
384
     else {
366
     else {
385
       u8g.setFont(FONT_MENU);
367
       u8g.setFont(FONT_MENU);
386
     }
368
     }
387
   #endif
369
   #endif
388
 
370
 
389
-  if (lcd_strlen_P(pstr) > LCD_WIDTH - 2 - lcd_strlen(value)) rows = 2;
371
+  if (lcd_strlen_P(pstr) > LCD_WIDTH - 2 - vallen) rows = 2;
390
 
372
 
391
   const float kHalfChar = DOG_CHAR_HEIGHT_EDIT / 2;
373
   const float kHalfChar = DOG_CHAR_HEIGHT_EDIT / 2;
392
   float rowHeight = u8g.getHeight() / (rows + 1); // 1/(rows+1) = 1/2 or 1/3
374
   float rowHeight = u8g.getHeight() / (rows + 1); // 1/(rows+1) = 1/2 or 1/3
394
   u8g.setPrintPos(0, rowHeight + kHalfChar);
376
   u8g.setPrintPos(0, rowHeight + kHalfChar);
395
   lcd_printPGM(pstr);
377
   lcd_printPGM(pstr);
396
   u8g.print(':');
378
   u8g.print(':');
397
-  u8g.setPrintPos((lcd_width-1-lcd_strlen(value)) * char_width, rows * rowHeight + kHalfChar);
379
+  u8g.setPrintPos((lcd_width - 1 - vallen) * char_width, rows * rowHeight + kHalfChar);
398
   u8g.print(value);
380
   u8g.print(value);
399
 }
381
 }
400
 
382
 
401
-static void _drawmenu_sd(uint8_t row, const char* pstr, const char* filename, char * const longFilename, bool isDir, bool isSelected) {
383
+static void _drawmenu_sd(bool isSelected, uint8_t row, const char* pstr, const char* filename, char * const longFilename, bool isDir) {
402
   char c;
384
   char c;
403
   uint8_t n = LCD_WIDTH - 1;
385
   uint8_t n = LCD_WIDTH - 1;
404
 
386
 
405
-  if (longFilename[0] != '\0') {
387
+  if (longFilename[0]) {
406
     filename = longFilename;
388
     filename = longFilename;
407
     longFilename[n] = '\0';
389
     longFilename[n] = '\0';
408
   }
390
   }
409
 
391
 
410
-  lcd_implementation_mark_as_selected(row, ((isSelected) ? '>' : ' '));
392
+  lcd_implementation_mark_as_selected(row, isSelected);
411
 
393
 
412
   if (isDir) u8g.print(LCD_STR_FOLDER[0]);
394
   if (isDir) u8g.print(LCD_STR_FOLDER[0]);
413
-  while((c = *filename) != '\0') {
395
+  while ((c = *filename)) {
414
     u8g.print(c);
396
     u8g.print(c);
415
     filename++;
397
     filename++;
416
     n--;
398
     n--;
417
   }
399
   }
418
-  while(n--) u8g.print(' ');
400
+  while (n--) u8g.print(' ');
419
 }
401
 }
420
 
402
 
421
-#define lcd_implementation_drawmenu_sdfile_selected(row, pstr, filename, longFilename) _drawmenu_sd(row, pstr, filename, longFilename, false, true)
422
-#define lcd_implementation_drawmenu_sdfile(row, pstr, filename, longFilename) _drawmenu_sd(row, pstr, filename, longFilename, false, false)
423
-#define lcd_implementation_drawmenu_sddirectory_selected(row, pstr, filename, longFilename) _drawmenu_sd(row, pstr, filename, longFilename, true, true)
424
-#define lcd_implementation_drawmenu_sddirectory(row, pstr, filename, longFilename) _drawmenu_sd(row, pstr, filename, longFilename, true, false)
425
-
426
-#define lcd_implementation_drawmenu_back_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0])
427
-#define lcd_implementation_drawmenu_back(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', LCD_STR_UPLEVEL[0])
428
-#define lcd_implementation_drawmenu_submenu_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, '>', LCD_STR_ARROW_RIGHT[0])
429
-#define lcd_implementation_drawmenu_submenu(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', LCD_STR_ARROW_RIGHT[0])
430
-#define lcd_implementation_drawmenu_gcode_selected(row, pstr, gcode) lcd_implementation_drawmenu_generic(row, pstr, '>', ' ')
431
-#define lcd_implementation_drawmenu_gcode(row, pstr, gcode) lcd_implementation_drawmenu_generic(row, pstr, ' ', ' ')
432
-#define lcd_implementation_drawmenu_function_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, '>', ' ')
433
-#define lcd_implementation_drawmenu_function(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', ' ')
403
+#define lcd_implementation_drawmenu_sdfile(sel, row, pstr, filename, longFilename) _drawmenu_sd(sel, row, pstr, filename, longFilename, false)
404
+#define lcd_implementation_drawmenu_sddirectory(sel, row, pstr, filename, longFilename) _drawmenu_sd(sel, row, pstr, filename, longFilename, true)
405
+
406
+#define lcd_implementation_drawmenu_back(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0])
407
+#define lcd_implementation_drawmenu_submenu(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0])
408
+#define lcd_implementation_drawmenu_gcode(sel, row, pstr, gcode) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
409
+#define lcd_implementation_drawmenu_function(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
434
 
410
 
435
 static void lcd_implementation_quick_feedback() {
411
 static void lcd_implementation_quick_feedback() {
436
   #if BEEPER > -1
412
   #if BEEPER > -1

+ 64
- 44
Marlin/ultralcd.cpp View File

118
 
118
 
119
 
119
 
120
 /* Helper macros for menus */
120
 /* Helper macros for menus */
121
+
122
+/**
123
+ * START_MENU generates the init code for a menu function
124
+ */
121
 #define START_MENU() do { \
125
 #define START_MENU() do { \
122
-	encoderRateMultiplierEnabled = false; \
123
-    if (encoderPosition > 0x8000) encoderPosition = 0; \
124
-    if (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM < currentMenuViewOffset) currentMenuViewOffset = encoderPosition / ENCODER_STEPS_PER_MENU_ITEM;\
125
-    uint8_t _lineNr = currentMenuViewOffset, _menuItemNr; \
126
-    bool wasClicked = LCD_CLICKED;\
127
-    for(uint8_t _drawLineNr = 0; _drawLineNr < LCD_HEIGHT; _drawLineNr++, _lineNr++) { \
128
-        _menuItemNr = 0;
126
+  encoderRateMultiplierEnabled = false; \
127
+  if (encoderPosition > 0x8000) encoderPosition = 0; \
128
+  uint8_t encoderLine = encoderPosition / ENCODER_STEPS_PER_MENU_ITEM; \
129
+  if (encoderLine < currentMenuViewOffset) currentMenuViewOffset = encoderLine; \
130
+  uint8_t _lineNr = currentMenuViewOffset, _menuItemNr; \
131
+  bool wasClicked = LCD_CLICKED, itemSelected; \
132
+  if (wasClicked) lcd_quick_feedback(); \
133
+  for (uint8_t _drawLineNr = 0; _drawLineNr < LCD_HEIGHT; _drawLineNr++, _lineNr++) { \
134
+    _menuItemNr = 0;
135
+
136
+/**
137
+ * MENU_ITEM generates draw & handler code for a menu item, potentially calling:
138
+ *
139
+ *   lcd_implementation_drawmenu_[type](sel, row, label, arg3...)
140
+ *   menu_action_[type](arg3...)
141
+ *
142
+ * Examples:
143
+ *   MENU_ITEM(back, MSG_WATCH, lcd_status_screen)
144
+ *     lcd_implementation_drawmenu_back(sel, row, PSTR(MSG_WATCH), lcd_status_screen)
145
+ *     menu_action_back(lcd_status_screen)
146
+ *
147
+ *   MENU_ITEM(function, MSG_PAUSE_PRINT, lcd_sdcard_pause)
148
+ *     lcd_implementation_drawmenu_function(sel, row, PSTR(MSG_PAUSE_PRINT), lcd_sdcard_pause)
149
+ *     menu_action_function(lcd_sdcard_pause)
150
+ *
151
+ *   MENU_ITEM_EDIT(int3, MSG_SPEED, &feedmultiply, 10, 999)
152
+ *   MENU_ITEM(setting_edit_int3, MSG_SPEED, PSTR(MSG_SPEED), &feedmultiply, 10, 999)
153
+ *     lcd_implementation_drawmenu_setting_edit_int3(sel, row, PSTR(MSG_SPEED), PSTR(MSG_SPEED), &feedmultiply, 10, 999)
154
+ *     menu_action_setting_edit_int3(PSTR(MSG_SPEED), &feedmultiply, 10, 999)
155
+ *
156
+ */
129
 #define MENU_ITEM(type, label, args...) do { \
157
 #define MENU_ITEM(type, label, args...) do { \
130
-    if (_menuItemNr == _lineNr) { \
131
-        if (lcdDrawUpdate) { \
132
-            const char* _label_pstr = PSTR(label); \
133
-            if ((encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) == _menuItemNr) { \
134
-                lcd_implementation_drawmenu_ ## type ## _selected (_drawLineNr, _label_pstr , ## args ); \
135
-            }else{\
136
-                lcd_implementation_drawmenu_ ## type (_drawLineNr, _label_pstr , ## args ); \
137
-            }\
138
-        }\
139
-        if (wasClicked && (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) == _menuItemNr) {\
140
-            lcd_quick_feedback(); \
141
-            menu_action_ ## type ( args ); \
142
-            return;\
143
-        }\
144
-    }\
145
-    _menuItemNr++;\
158
+  if (_menuItemNr == _lineNr) { \
159
+    itemSelected = encoderLine == _menuItemNr; \
160
+    if (lcdDrawUpdate) \
161
+      lcd_implementation_drawmenu_ ## type(itemSelected, _drawLineNr, PSTR(label), ## args); \
162
+    if (wasClicked && itemSelected) { \
163
+      menu_action_ ## type(args); \
164
+      return; \
165
+    } \
166
+  } \
167
+  _menuItemNr++; \
146
 } while(0)
168
 } while(0)
169
+
147
 #ifdef ENCODER_RATE_MULTIPLIER
170
 #ifdef ENCODER_RATE_MULTIPLIER
171
+  /**
172
+   * MENU_MULTIPLIER_ITEM generates drawing and handling code for a multiplier menu item
173
+   */
148
   #define MENU_MULTIPLIER_ITEM(type, label, args...) do { \
174
   #define MENU_MULTIPLIER_ITEM(type, label, args...) do { \
149
     if (_menuItemNr == _lineNr) { \
175
     if (_menuItemNr == _lineNr) { \
150
-      if (lcdDrawUpdate) { \
151
-        const char* _label_pstr = PSTR(label); \
152
-        if ((encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) == _menuItemNr) { \
153
-          lcd_implementation_drawmenu_ ## type ## _selected (_drawLineNr, _label_pstr , ## args ); \
154
-        } \
155
-        else { \
156
-          lcd_implementation_drawmenu_ ## type (_drawLineNr, _label_pstr , ## args ); \
157
-        } \
158
-      } \
159
-      if (wasClicked && (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) == _menuItemNr) { \
160
-        lcd_quick_feedback(); \
176
+      itemSelected = encoderLine == _menuItemNr; \
177
+      if (lcdDrawUpdate) \
178
+        lcd_implementation_drawmenu_ ## type(itemSelected, _drawLineNr, PSTR(label), ## args); \
179
+      if (wasClicked && itemSelected) { \
161
         encoderRateMultiplierEnabled = true; \
180
         encoderRateMultiplierEnabled = true; \
162
         lastEncoderMovementMillis = 0; \
181
         lastEncoderMovementMillis = 0; \
163
-        menu_action_ ## type ( args ); \
182
+        menu_action_ ## type(args); \
164
         return; \
183
         return; \
165
       } \
184
       } \
166
     } \
185
     } \
167
     _menuItemNr++; \
186
     _menuItemNr++; \
168
   } while(0)
187
   } while(0)
169
 #endif //ENCODER_RATE_MULTIPLIER
188
 #endif //ENCODER_RATE_MULTIPLIER
189
+
170
 #define MENU_ITEM_DUMMY() do { _menuItemNr++; } while(0)
190
 #define MENU_ITEM_DUMMY() do { _menuItemNr++; } while(0)
171
-#define MENU_ITEM_EDIT(type, label, args...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label) , ## args )
172
-#define MENU_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label) , ## args )
191
+#define MENU_ITEM_EDIT(type, label, args...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label), ## args)
192
+#define MENU_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label), ## args)
173
 #ifdef ENCODER_RATE_MULTIPLIER
193
 #ifdef ENCODER_RATE_MULTIPLIER
174
-  #define MENU_MULTIPLIER_ITEM_EDIT(type, label, args...) MENU_MULTIPLIER_ITEM(setting_edit_ ## type, label, PSTR(label) , ## args )
175
-  #define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(type, label, args...) MENU_MULTIPLIER_ITEM(setting_edit_callback_ ## type, label, PSTR(label) , ## args )
194
+  #define MENU_MULTIPLIER_ITEM_EDIT(type, label, args...) MENU_MULTIPLIER_ITEM(setting_edit_ ## type, label, PSTR(label), ## args)
195
+  #define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(type, label, args...) MENU_MULTIPLIER_ITEM(setting_edit_callback_ ## type, label, PSTR(label), ## args)
176
 #else //!ENCODER_RATE_MULTIPLIER
196
 #else //!ENCODER_RATE_MULTIPLIER
177
-  #define MENU_MULTIPLIER_ITEM_EDIT(type, label, args...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label) , ## args )
178
-  #define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label) , ## args )
197
+  #define MENU_MULTIPLIER_ITEM_EDIT(type, label, args...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label), ## args)
198
+  #define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label), ## args)
179
 #endif //!ENCODER_RATE_MULTIPLIER
199
 #endif //!ENCODER_RATE_MULTIPLIER
180
 #define END_MENU() \
200
 #define END_MENU() \
181
     if (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM >= _menuItemNr) encoderPosition = _menuItemNr * ENCODER_STEPS_PER_MENU_ITEM - 1; \
201
     if (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM >= _menuItemNr) encoderPosition = _menuItemNr * ENCODER_STEPS_PER_MENU_ITEM - 1; \
458
   #if TEMP_SENSOR_BED != 0
478
   #if TEMP_SENSOR_BED != 0
459
     MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_BED, &target_temperature_bed, 0, BED_MAXTEMP - 15);
479
     MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_BED, &target_temperature_bed, 0, BED_MAXTEMP - 15);
460
   #endif
480
   #endif
461
-    MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED, &fanSpeed, 0, 255);
462
-    MENU_ITEM_EDIT(int3, MSG_FLOW, &extrudemultiply, 10, 999);
463
-    MENU_ITEM_EDIT(int3, MSG_FLOW MSG_F0, &extruder_multiply[0], 10, 999);
481
+  MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED, &fanSpeed, 0, 255);
482
+  MENU_ITEM_EDIT(int3, MSG_FLOW, &extrudemultiply, 10, 999);
483
+  MENU_ITEM_EDIT(int3, MSG_FLOW MSG_F0, &extruder_multiply[0], 10, 999);
464
   #if TEMP_SENSOR_1 != 0
484
   #if TEMP_SENSOR_1 != 0
465
     MENU_ITEM_EDIT(int3, MSG_FLOW MSG_F1, &extruder_multiply[1], 10, 999);
485
     MENU_ITEM_EDIT(int3, MSG_FLOW MSG_F1, &extruder_multiply[1], 10, 999);
466
   #endif
486
   #endif

+ 89
- 199
Marlin/ultralcd_implementation_hitachi_HD44780.h View File

610
 
610
 
611
   lcd.print(lcd_status_message);
611
   lcd.print(lcd_status_message);
612
 }
612
 }
613
-static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, char pre_char, char post_char)
614
-{
615
-    char c;
616
-    //Use all characters in narrow LCDs
617
-  #if LCD_WIDTH < 20
618
-      uint8_t n = LCD_WIDTH - 1 - 1;
619
-    #else
620
-      uint8_t n = LCD_WIDTH - 1 - 2;
621
-  #endif
622
-    lcd.setCursor(0, row);
623
-    lcd.print(pre_char);
624
-    while( ((c = pgm_read_byte(pstr)) != '\0') && (n>0) )
625
-    {
626
-        lcd.print(c);
627
-        pstr++;
628
-        if ((pgm_read_byte(pstr) & 0xc0) != 0x80) n--;
629
-    }
630
-    while(n--)
631
-        lcd.print(' ');
632
-    lcd.print(post_char);
633
-    lcd.print(' ');
613
+
614
+static void lcd_implementation_drawmenu_generic(bool sel, uint8_t row, const char* pstr, char pre_char, char post_char) {
615
+  char c;
616
+  uint8_t n = LCD_WIDTH - 1 - (LCD_WIDTH < 20 ? 1 : 2);
617
+  lcd.setCursor(0, row);
618
+  lcd.print(sel ? pre_char : ' ');
619
+  while ((c = pgm_read_byte(pstr)) && n > 0) {
620
+    lcd.print(c);
621
+    pstr++;
622
+    if ((pgm_read_byte(pstr) & 0xc0) != 0x80) n--;
623
+  }
624
+  while(n--) lcd.print(' ');
625
+  lcd.print(post_char);
626
+  lcd.print(' ');
634
 }
627
 }
635
-static void lcd_implementation_drawmenu_setting_edit_generic(uint8_t row, const char* pstr, char pre_char, char* data)
636
-{
637
-    char c;
638
-    //Use all characters in narrow LCDs
639
-  #if LCD_WIDTH < 20
640
-      uint8_t n = LCD_WIDTH - 1 - 1 - lcd_strlen(data);
641
-    #else
642
-      uint8_t n = LCD_WIDTH - 1 - 2 - lcd_strlen(data);
643
-  #endif
644
-    lcd.setCursor(0, row);
645
-    lcd.print(pre_char);
646
-    while( ((c = pgm_read_byte(pstr)) != '\0') && (n>0) )
647
-    {
648
-        lcd.print(c);
649
-        pstr++;
650
-        if ((pgm_read_byte(pstr) & 0xc0) != 0x80) n--;
651
-    }
652
-    lcd.print(':');
653
-    while(n--)
654
-        lcd.print(' ');
655
-    lcd.print(data);
628
+static void lcd_implementation_drawmenu_setting_edit_generic(bool sel, uint8_t row, const char* pstr, char pre_char, char* data) {
629
+  char c;
630
+  uint8_t n = LCD_WIDTH - 1 - (LCD_WIDTH < 20 ? 1 : 2) - lcd_strlen(data);
631
+  lcd.setCursor(0, row);
632
+  lcd.print(sel ? pre_char : ' ');
633
+  while ((c = pgm_read_byte(pstr)) && n > 0) {
634
+    lcd.print(c);
635
+    pstr++;
636
+    if ((pgm_read_byte(pstr) & 0xc0) != 0x80) n--;
637
+  }
638
+  lcd.print(':');
639
+  while (n--) lcd.print(' ');
640
+  lcd.print(data);
656
 }
641
 }
657
-static void lcd_implementation_drawmenu_setting_edit_generic_P(uint8_t row, const char* pstr, char pre_char, const char* data)
658
-{
659
-    char c;
660
-    //Use all characters in narrow LCDs
661
-  #if LCD_WIDTH < 20
662
-      uint8_t n = LCD_WIDTH - 1 - 1 - lcd_strlen_P(data);
663
-    #else
664
-      uint8_t n = LCD_WIDTH - 1 - 2 - lcd_strlen_P(data);
665
-  #endif
666
-    lcd.setCursor(0, row);
667
-    lcd.print(pre_char);
668
-    while( ((c = pgm_read_byte(pstr)) != '\0') && (n>0) )
669
-    {
670
-        lcd.print(c);
671
-        pstr++;
672
-        if ((pgm_read_byte(pstr) & 0xc0) != 0x80) n--;
673
-    }
674
-    lcd.print(':');
675
-    while(n--)
676
-        lcd.print(' ');
677
-    lcd_printPGM(data);
642
+static void lcd_implementation_drawmenu_setting_edit_generic_P(bool sel, uint8_t row, const char* pstr, char pre_char, const char* data) {
643
+  char c;
644
+  uint8_t n = LCD_WIDTH - 1 - (LCD_WIDTH < 20 ? 1 : 2) - lcd_strlen_P(data);
645
+  lcd.setCursor(0, row);
646
+  lcd.print(sel ? pre_char : ' ');
647
+  while ((c = pgm_read_byte(pstr)) && n > 0) {
648
+    lcd.print(c);
649
+    pstr++;
650
+    if ((pgm_read_byte(pstr) & 0xc0) != 0x80) n--;
651
+  }
652
+  lcd.print(':');
653
+  while (n--) lcd.print(' ');
654
+  lcd_printPGM(data);
678
 }
655
 }
679
-#define lcd_implementation_drawmenu_setting_edit_int3_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', itostr3(*(data)))
680
-#define lcd_implementation_drawmenu_setting_edit_int3(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', itostr3(*(data)))
681
-#define lcd_implementation_drawmenu_setting_edit_float3_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr3(*(data)))
682
-#define lcd_implementation_drawmenu_setting_edit_float3(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr3(*(data)))
683
-#define lcd_implementation_drawmenu_setting_edit_float32_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr32(*(data)))
684
-#define lcd_implementation_drawmenu_setting_edit_float32(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr32(*(data)))
685
-#define lcd_implementation_drawmenu_setting_edit_float43_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr43(*(data)))
686
-#define lcd_implementation_drawmenu_setting_edit_float43(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr43(*(data)))
687
-#define lcd_implementation_drawmenu_setting_edit_float5_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr5(*(data)))
688
-#define lcd_implementation_drawmenu_setting_edit_float5(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data)))
689
-#define lcd_implementation_drawmenu_setting_edit_float52_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr52(*(data)))
690
-#define lcd_implementation_drawmenu_setting_edit_float52(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr52(*(data)))
691
-#define lcd_implementation_drawmenu_setting_edit_float51_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr51(*(data)))
692
-#define lcd_implementation_drawmenu_setting_edit_float51(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr51(*(data)))
693
-#define lcd_implementation_drawmenu_setting_edit_long5_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr5(*(data)))
694
-#define lcd_implementation_drawmenu_setting_edit_long5(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data)))
695
-#define lcd_implementation_drawmenu_setting_edit_bool_selected(row, pstr, pstr2, data) lcd_implementation_drawmenu_setting_edit_generic_P(row, pstr, '>', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
696
-#define lcd_implementation_drawmenu_setting_edit_bool(row, pstr, pstr2, data) lcd_implementation_drawmenu_setting_edit_generic_P(row, pstr, ' ', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
656
+#define lcd_implementation_drawmenu_setting_edit_int3(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ' ', itostr3(*(data)))
657
+#define lcd_implementation_drawmenu_setting_edit_float3(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ' ', ftostr3(*(data)))
658
+#define lcd_implementation_drawmenu_setting_edit_float32(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ' ', ftostr32(*(data)))
659
+#define lcd_implementation_drawmenu_setting_edit_float43(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ' ', ftostr43(*(data)))
660
+#define lcd_implementation_drawmenu_setting_edit_float5(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ' ', ftostr5(*(data)))
661
+#define lcd_implementation_drawmenu_setting_edit_float52(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ' ', ftostr52(*(data)))
662
+#define lcd_implementation_drawmenu_setting_edit_float51(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ' ', ftostr51(*(data)))
663
+#define lcd_implementation_drawmenu_setting_edit_long5(sel, row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ' ', ftostr5(*(data)))
664
+#define lcd_implementation_drawmenu_setting_edit_bool(sel, row, pstr, pstr2, data) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, ' ', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
697
 
665
 
698
 //Add version for callback functions
666
 //Add version for callback functions
699
-#define lcd_implementation_drawmenu_setting_edit_callback_int3_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', itostr3(*(data)))
700
-#define lcd_implementation_drawmenu_setting_edit_callback_int3(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', itostr3(*(data)))
701
-#define lcd_implementation_drawmenu_setting_edit_callback_float3_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr3(*(data)))
702
-#define lcd_implementation_drawmenu_setting_edit_callback_float3(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr3(*(data)))
703
-#define lcd_implementation_drawmenu_setting_edit_callback_float32_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr32(*(data)))
704
-#define lcd_implementation_drawmenu_setting_edit_callback_float32(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr32(*(data)))
705
-#define lcd_implementation_drawmenu_setting_edit_callback_float43_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr43(*(data)))
706
-#define lcd_implementation_drawmenu_setting_edit_callback_float43(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr43(*(data)))
707
-#define lcd_implementation_drawmenu_setting_edit_callback_float5_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr5(*(data)))
708
-#define lcd_implementation_drawmenu_setting_edit_callback_float5(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data)))
709
-#define lcd_implementation_drawmenu_setting_edit_callback_float52_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr52(*(data)))
710
-#define lcd_implementation_drawmenu_setting_edit_callback_float52(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr52(*(data)))
711
-#define lcd_implementation_drawmenu_setting_edit_callback_float51_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr51(*(data)))
712
-#define lcd_implementation_drawmenu_setting_edit_callback_float51(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr51(*(data)))
713
-#define lcd_implementation_drawmenu_setting_edit_callback_long5_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr5(*(data)))
714
-#define lcd_implementation_drawmenu_setting_edit_callback_long5(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data)))
715
-#define lcd_implementation_drawmenu_setting_edit_callback_bool_selected(row, pstr, pstr2, data, callback) lcd_implementation_drawmenu_setting_edit_generic_P(row, pstr, '>', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
716
-#define lcd_implementation_drawmenu_setting_edit_callback_bool(row, pstr, pstr2, data, callback) lcd_implementation_drawmenu_setting_edit_generic_P(row, pstr, ' ', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
717
-
718
-
719
-void lcd_implementation_drawedit(const char* pstr, char* value)
720
-{
721
-    lcd.setCursor(1, 1);
722
-    lcd_printPGM(pstr);
723
-    lcd.print(':');
724
-   #if LCD_WIDTH < 20
725
-      lcd.setCursor(LCD_WIDTH - lcd_strlen(value), 1);
726
-    #else
727
-      lcd.setCursor(LCD_WIDTH -1 - lcd_strlen(value), 1);
728
-   #endif
729
-    lcd.print(value);
730
-}
731
-static void lcd_implementation_drawmenu_sdfile_selected(uint8_t row, const char* pstr, const char* filename, char* longFilename)
732
-{
733
-    char c;
734
-    uint8_t n = LCD_WIDTH - 1;
735
-    lcd.setCursor(0, row);
736
-    lcd.print('>');
737
-    if (longFilename[0] != '\0')
738
-    {
739
-        filename = longFilename;
740
-        longFilename[LCD_WIDTH-1] = '\0';
741
-    }
742
-    while( ((c = *filename) != '\0') && (n>0) )
743
-    {
744
-        lcd.print(c);
745
-        filename++;
746
-        n--;
747
-    }
748
-    while(n--)
749
-        lcd.print(' ');
667
+#define lcd_implementation_drawmenu_setting_edit_callback_int3(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ' ', itostr3(*(data)))
668
+#define lcd_implementation_drawmenu_setting_edit_callback_float3(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ' ', ftostr3(*(data)))
669
+#define lcd_implementation_drawmenu_setting_edit_callback_float32(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ' ', ftostr32(*(data)))
670
+#define lcd_implementation_drawmenu_setting_edit_callback_float43(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ' ', ftostr43(*(data)))
671
+#define lcd_implementation_drawmenu_setting_edit_callback_float5(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ' ', ftostr5(*(data)))
672
+#define lcd_implementation_drawmenu_setting_edit_callback_float52(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ' ', ftostr52(*(data)))
673
+#define lcd_implementation_drawmenu_setting_edit_callback_float51(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ' ', ftostr51(*(data)))
674
+#define lcd_implementation_drawmenu_setting_edit_callback_long5(sel, row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(sel, row, pstr, ' ', ftostr5(*(data)))
675
+#define lcd_implementation_drawmenu_setting_edit_callback_bool(sel, row, pstr, pstr2, data, callback) lcd_implementation_drawmenu_setting_edit_generic_P(sel, row, pstr, ' ', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
676
+
677
+void lcd_implementation_drawedit(const char* pstr, char* value) {
678
+  lcd.setCursor(1, 1);
679
+  lcd_printPGM(pstr);
680
+  lcd.print(':');
681
+  lcd.setCursor(LCD_WIDTH - (LCD_WIDTH < 20 ? 0 : 1) - lcd_strlen(value), 1);
682
+  lcd.print(value);
750
 }
683
 }
751
-static void lcd_implementation_drawmenu_sdfile(uint8_t row, const char* pstr, const char* filename, char* longFilename)
752
-{
753
-    char c;
754
-    uint8_t n = LCD_WIDTH - 1;
755
-    lcd.setCursor(0, row);
756
-    lcd.print(' ');
757
-    if (longFilename[0] != '\0')
758
-    {
759
-        filename = longFilename;
760
-        longFilename[LCD_WIDTH-1] = '\0';
761
-    }
762
-    while( ((c = *filename) != '\0') && (n>0) )
763
-    {
764
-        lcd.print(c);
765
-        filename++;
766
-        n--;
767
-    }
768
-    while(n--)
769
-        lcd.print(' ');
684
+static void lcd_implementation_drawmenu_sd(bool sel, uint8_t row, const char* pstr, const char* filename, char* longFilename, uint8_t concat) {
685
+  char c;
686
+  uint8_t n = LCD_WIDTH - concat;
687
+  lcd.setCursor(0, row);
688
+  lcd.print(sel ? '>' : ' ');
689
+  if (longFilename[0]) {
690
+    filename = longFilename;
691
+    longFilename[n] = '\0';
692
+  }
693
+  while ((c = *filename) && n > 0) {
694
+    lcd.print(c);
695
+    filename++;
696
+    n--;
697
+  }
698
+  while (n--) lcd.print(' ');
770
 }
699
 }
771
-static void lcd_implementation_drawmenu_sddirectory_selected(uint8_t row, const char* pstr, const char* filename, char* longFilename)
772
-{
773
-    char c;
774
-    uint8_t n = LCD_WIDTH - 2;
775
-    lcd.setCursor(0, row);
776
-    lcd.print('>');
777
-    lcd.print(LCD_STR_FOLDER[0]);
778
-    if (longFilename[0] != '\0')
779
-    {
780
-        filename = longFilename;
781
-        longFilename[LCD_WIDTH-2] = '\0';
782
-    }
783
-    while( ((c = *filename) != '\0') && (n>0) )
784
-    {
785
-        lcd.print(c);
786
-        filename++;
787
-        n--;
788
-    }
789
-    while(n--)
790
-        lcd.print(' ');
700
+
701
+static void lcd_implementation_drawmenu_sdfile(bool sel, uint8_t row, const char* pstr, const char* filename, char* longFilename) {
702
+  lcd_implementation_drawmenu_sd(sel, row, pstr, filename, longFilename, 1);
791
 }
703
 }
792
-static void lcd_implementation_drawmenu_sddirectory(uint8_t row, const char* pstr, const char* filename, char* longFilename)
793
-{
794
-    char c;
795
-    uint8_t n = LCD_WIDTH - 2;
796
-    lcd.setCursor(0, row);
797
-    lcd.print(' ');
798
-    lcd.print(LCD_STR_FOLDER[0]);
799
-    if (longFilename[0] != '\0')
800
-    {
801
-        filename = longFilename;
802
-        longFilename[LCD_WIDTH-2] = '\0';
803
-    }
804
-    while( ((c = *filename) != '\0') && (n>0) )
805
-    {
806
-        lcd.print(c);
807
-        filename++;
808
-        n--;
809
-    }
810
-    while(n--)
811
-        lcd.print(' ');
704
+static void lcd_implementation_drawmenu_sddirectory(bool sel, uint8_t row, const char* pstr, const char* filename, char* longFilename) {
705
+  lcd_implementation_drawmenu_sd(sel, row, pstr, filename, longFilename, 2);
812
 }
706
 }
813
-#define lcd_implementation_drawmenu_back_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0])
814
-#define lcd_implementation_drawmenu_back(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', LCD_STR_UPLEVEL[0])
815
-#define lcd_implementation_drawmenu_submenu_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, '>', LCD_STR_ARROW_RIGHT[0])
816
-#define lcd_implementation_drawmenu_submenu(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', LCD_STR_ARROW_RIGHT[0])
817
-#define lcd_implementation_drawmenu_gcode_selected(row, pstr, gcode) lcd_implementation_drawmenu_generic(row, pstr, '>', ' ')
818
-#define lcd_implementation_drawmenu_gcode(row, pstr, gcode) lcd_implementation_drawmenu_generic(row, pstr, ' ', ' ')
819
-#define lcd_implementation_drawmenu_function_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, '>', ' ')
820
-#define lcd_implementation_drawmenu_function(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', ' ')
707
+#define lcd_implementation_drawmenu_back(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0])
708
+#define lcd_implementation_drawmenu_submenu(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0])
709
+#define lcd_implementation_drawmenu_gcode(sel, row, pstr, gcode) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
710
+#define lcd_implementation_drawmenu_function(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
821
 
711
 
822
 static void lcd_implementation_quick_feedback()
712
 static void lcd_implementation_quick_feedback()
823
 {
713
 {

Loading…
Cancel
Save