Browse Source

Formatting and lcd contrast masking

Scott Lahteine 10 years ago
parent
commit
43773ff735
2 changed files with 55 additions and 54 deletions
  1. 14
    15
      Marlin/dogm_lcd_implementation.h
  2. 41
    39
      Marlin/ultralcd.cpp

+ 14
- 15
Marlin/dogm_lcd_implementation.h View File

@@ -198,16 +198,16 @@ static void lcd_implementation_init()
198 198
   u8g.setContrast(lcd_contrast);	
199 199
 	// FIXME: remove this workaround
200 200
   // Uncomment this if you have the first generation (V1.10) of STBs board
201
-	// pinMode(17, OUTPUT);	// Enable LCD backlight
202
-	// digitalWrite(17, HIGH);
203
-  
204
-#ifdef LCD_SCREEN_ROT_90
205
-	u8g.setRot90();   // Rotate screen by 90°
206
-#elif defined(LCD_SCREEN_ROT_180)
207
-	u8g.setRot180();	// Rotate screen by 180°
208
-#elif defined(LCD_SCREEN_ROT_270)
209
-	u8g.setRot270();	// Rotate screen by 270°
210
-#endif
201
+  // pinMode(17, OUTPUT);	// Enable LCD backlight
202
+  // digitalWrite(17, HIGH);
203
+
204
+  #ifdef LCD_SCREEN_ROT_90
205
+    u8g.setRot90();   // Rotate screen by 90°
206
+  #elif defined(LCD_SCREEN_ROT_180)
207
+    u8g.setRot180();	// Rotate screen by 180°
208
+  #elif defined(LCD_SCREEN_ROT_270)
209
+    u8g.setRot270();	// Rotate screen by 270°
210
+  #endif
211 211
 	
212 212
   // Show splashscreen
213 213
   int offx = (u8g.getWidth() - START_BMPWIDTH) / 2;
@@ -220,7 +220,7 @@ static void lcd_implementation_init()
220 220
   int txt1X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE1) - 1)*DOG_CHAR_WIDTH) / 2;
221 221
 
222 222
 	u8g.firstPage();
223
-	do {
223
+  do {
224 224
     if (show_splashscreen) {
225 225
       u8g.drawBitmapP(offx, offy, START_BMPBYTEWIDTH, START_BMPHEIGHT, start_bmp);
226 226
       lcd_setFont(FONT_MENU);
@@ -232,7 +232,7 @@ static void lcd_implementation_init()
232 232
         u8g.drawStr(txt2X, u8g.getHeight() - DOG_CHAR_HEIGHT*1/2, STRING_SPLASH_LINE2);
233 233
       #endif
234 234
     }
235
-	} while (u8g.nextPage());
235
+  } while (u8g.nextPage());
236 236
   show_splashscreen = false;
237 237
 }
238 238
 
@@ -295,20 +295,19 @@ static void lcd_implementation_status_screen() {
295 295
       lcd_printPGM(PSTR("--:--"));
296 296
     }
297 297
   #endif
298
- 
298
+
299 299
   // Extruders
300 300
   for (int i=0; i<EXTRUDERS; i++) _draw_heater_status(6 + i * 25, i);
301 301
 
302 302
   // Heatbed
303 303
   if (EXTRUDERS < 4) _draw_heater_status(81, -1);
304
- 
304
+
305 305
   // Fan
306 306
   lcd_setFont(FONT_STATUSMENU);
307 307
   u8g.setPrintPos(104,27);
308 308
   #if HAS_FAN
309 309
     int per = ((fanSpeed + 1) * 100) / 256;
310 310
     if (per) {
311
-
312 311
       lcd_print(itostr3(per));
313 312
       lcd_print('%');
314 313
     }

+ 41
- 39
Marlin/ultralcd.cpp View File

@@ -422,7 +422,7 @@ static void lcd_main_menu() {
422 422
   END_MENU();
423 423
 }
424 424
 
425
-#if defined( SDSUPPORT ) && defined( MENU_ADDAUTOSTART )
425
+#if defined(SDSUPPORT) && defined(MENU_ADDAUTOSTART)
426 426
   static void lcd_autostart_sd() {
427 427
     card.autostart_index = 0;
428 428
     card.setroot();
@@ -431,7 +431,7 @@ static void lcd_main_menu() {
431 431
 #endif
432 432
 
433 433
 void lcd_set_home_offsets() {
434
-  for(int8_t i=0; i < NUM_AXIS; i++) {
434
+  for (int8_t i=0; i < NUM_AXIS; i++) {
435 435
     if (i != E_AXIS) {
436 436
       home_offset[i] -= current_position[i];
437 437
       current_position[i] = 0.0;
@@ -965,48 +965,49 @@ static void lcd_control_volumetric_menu() {
965 965
 
966 966
 #ifdef DOGLCD
967 967
 
968
-static void lcd_set_contrast() {
969
-  if (encoderPosition != 0) {
970
-    lcd_contrast -= encoderPosition;
971
-    if (lcd_contrast < 0) lcd_contrast = 0;
972
-    else if (lcd_contrast > 63) lcd_contrast = 63;
973
-    encoderPosition = 0;
974
-    lcdDrawUpdate = 1;
975
-    u8g.setContrast(lcd_contrast);
968
+  static void lcd_set_contrast() {
969
+    if (encoderPosition != 0) {
970
+      lcd_contrast -= encoderPosition;
971
+      lcd_contrast &= 0x3F;
972
+      encoderPosition = 0;
973
+      lcdDrawUpdate = 1;
974
+      u8g.setContrast(lcd_contrast);
975
+    }
976
+    if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_CONTRAST), itostr2(lcd_contrast));
977
+    if (LCD_CLICKED) lcd_goto_menu(lcd_control_menu);
976 978
   }
977
-  if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_CONTRAST), itostr2(lcd_contrast));
978
-  if (LCD_CLICKED) lcd_goto_menu(lcd_control_menu);
979
-}
980 979
 
981
-#endif //DOGLCD
980
+#endif // DOGLCD
982 981
 
983 982
 #ifdef FWRETRACT
984 983
 
985
-static void lcd_control_retract_menu() {
986
-  START_MENU();
987
-  MENU_ITEM(back, MSG_CONTROL, lcd_control_menu);
988
-  MENU_ITEM_EDIT(bool, MSG_AUTORETRACT, &autoretract_enabled);
989
-  MENU_ITEM_EDIT(float52, MSG_CONTROL_RETRACT, &retract_length, 0, 100);
990
-  #if EXTRUDERS > 1
991
-    MENU_ITEM_EDIT(float52, MSG_CONTROL_RETRACT_SWAP, &retract_length_swap, 0, 100);
992
-  #endif
993
-  MENU_ITEM_EDIT(float3, MSG_CONTROL_RETRACTF, &retract_feedrate, 1, 999);
994
-  MENU_ITEM_EDIT(float52, MSG_CONTROL_RETRACT_ZLIFT, &retract_zlift, 0, 999);
995
-  MENU_ITEM_EDIT(float52, MSG_CONTROL_RETRACT_RECOVER, &retract_recover_length, 0, 100);
996
-  #if EXTRUDERS > 1
997
-    MENU_ITEM_EDIT(float52, MSG_CONTROL_RETRACT_RECOVER_SWAP, &retract_recover_length_swap, 0, 100);
998
-  #endif
999
-  MENU_ITEM_EDIT(float3, MSG_CONTROL_RETRACT_RECOVERF, &retract_recover_feedrate, 1, 999);
1000
-  END_MENU();
1001
-}
984
+  static void lcd_control_retract_menu() {
985
+    START_MENU();
986
+    MENU_ITEM(back, MSG_CONTROL, lcd_control_menu);
987
+    MENU_ITEM_EDIT(bool, MSG_AUTORETRACT, &autoretract_enabled);
988
+    MENU_ITEM_EDIT(float52, MSG_CONTROL_RETRACT, &retract_length, 0, 100);
989
+    #if EXTRUDERS > 1
990
+      MENU_ITEM_EDIT(float52, MSG_CONTROL_RETRACT_SWAP, &retract_length_swap, 0, 100);
991
+    #endif
992
+    MENU_ITEM_EDIT(float3, MSG_CONTROL_RETRACTF, &retract_feedrate, 1, 999);
993
+    MENU_ITEM_EDIT(float52, MSG_CONTROL_RETRACT_ZLIFT, &retract_zlift, 0, 999);
994
+    MENU_ITEM_EDIT(float52, MSG_CONTROL_RETRACT_RECOVER, &retract_recover_length, 0, 100);
995
+    #if EXTRUDERS > 1
996
+      MENU_ITEM_EDIT(float52, MSG_CONTROL_RETRACT_RECOVER_SWAP, &retract_recover_length_swap, 0, 100);
997
+    #endif
998
+    MENU_ITEM_EDIT(float3, MSG_CONTROL_RETRACT_RECOVERF, &retract_recover_feedrate, 1, 999);
999
+    END_MENU();
1000
+  }
1002 1001
 
1003
-#endif //FWRETRACT
1002
+#endif // FWRETRACT
1004 1003
 
1005 1004
 #if SDCARDDETECT == -1
1005
+
1006 1006
   static void lcd_sd_refresh() {
1007 1007
     card.initsd();
1008 1008
     currentMenuViewOffset = 0;
1009 1009
   }
1010
+
1010 1011
 #endif
1011 1012
 
1012 1013
 static void lcd_sd_updir() {
@@ -1029,13 +1030,14 @@ void lcd_sdcard_menu() {
1029 1030
     MENU_ITEM(function, LCD_STR_FOLDER "..", lcd_sd_updir);
1030 1031
   }
1031 1032
 
1032
-  for(uint16_t i = 0; i < fileCnt; i++) {
1033
+  for (uint16_t i = 0; i < fileCnt; i++) {
1033 1034
     if (_menuItemNr == _lineNr) {
1034
-      #ifndef SDCARD_RATHERRECENTFIRST
1035
-        card.getfilename(i);
1036
-      #else
1037
-        card.getfilename(fileCnt-1-i);
1038
-      #endif
1035
+      card.getfilename(
1036
+        #ifdef SDCARD_RATHERRECENTFIRST
1037
+          fileCnt-1 -
1038
+        #endif
1039
+        i
1040
+      );
1039 1041
       if (card.filenameIsDir)
1040 1042
         MENU_ITEM(sddirectory, MSG_CARD_MENU, card.filename, card.longFilename);
1041 1043
       else
@@ -1456,7 +1458,7 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
1456 1458
 
1457 1459
 #ifdef DOGLCD
1458 1460
   void lcd_setcontrast(uint8_t value) {
1459
-    lcd_contrast = value & 63;
1461
+    lcd_contrast = value & 0x3F;
1460 1462
     u8g.setContrast(lcd_contrast);
1461 1463
   }
1462 1464
 #endif

Loading…
Cancel
Save