Browse Source

added contrast control function for gLCDs

Michael Mayer 11 years ago
parent
commit
e509cdbeb0

+ 7
- 0
Marlin/Configuration.h View File

517
   #endif
517
   #endif
518
 #endif
518
 #endif
519
 
519
 
520
+// default LCD contrast for dogm-like LCD displays
521
+#ifdef DOGLCD
522
+# ifndef DEFAULT_LCD_CONTRAST
523
+#  define DEFAULT_LCD_CONTRAST 32
524
+# endif
525
+#endif
526
+
520
 // Increase the FAN pwm frequency. Removes the PWM noise but increases heating in the FET/Arduino
527
 // Increase the FAN pwm frequency. Removes the PWM noise but increases heating in the FET/Arduino
521
 //#define FAST_PWM_FAN
528
 //#define FAST_PWM_FAN
522
 
529
 

+ 12
- 1
Marlin/ConfigurationStore.cpp View File

37
 // the default values are used whenever there is a change to the data, to prevent
37
 // the default values are used whenever there is a change to the data, to prevent
38
 // wrong data being written to the variables.
38
 // wrong data being written to the variables.
39
 // ALSO:  always make sure the variables in the Store and retrieve sections are in the same order.
39
 // ALSO:  always make sure the variables in the Store and retrieve sections are in the same order.
40
-#define EEPROM_VERSION "V07"
40
+#define EEPROM_VERSION "V08"
41
 
41
 
42
 #ifdef EEPROM_SETTINGS
42
 #ifdef EEPROM_SETTINGS
43
 void Config_StoreSettings() 
43
 void Config_StoreSettings() 
78
     EEPROM_WRITE_VAR(i,dummy);
78
     EEPROM_WRITE_VAR(i,dummy);
79
     EEPROM_WRITE_VAR(i,dummy);
79
     EEPROM_WRITE_VAR(i,dummy);
80
   #endif
80
   #endif
81
+  #ifndef DOGLCD
82
+    int lcd_contrast = 32;
83
+  #endif
84
+  EEPROM_WRITE_VAR(i,lcd_contrast);
81
   char ver2[4]=EEPROM_VERSION;
85
   char ver2[4]=EEPROM_VERSION;
82
   i=EEPROM_OFFSET;
86
   i=EEPROM_OFFSET;
83
   EEPROM_WRITE_VAR(i,ver2); // validate data
87
   EEPROM_WRITE_VAR(i,ver2); // validate data
198
         EEPROM_READ_VAR(i,Kp);
202
         EEPROM_READ_VAR(i,Kp);
199
         EEPROM_READ_VAR(i,Ki);
203
         EEPROM_READ_VAR(i,Ki);
200
         EEPROM_READ_VAR(i,Kd);
204
         EEPROM_READ_VAR(i,Kd);
205
+        #ifndef DOGLCD
206
+        int lcd_contrast;
207
+        #endif
208
+        EEPROM_READ_VAR(i,lcd_contrast);
201
 
209
 
202
 		// Call updatePID (similar to when we have processed M301)
210
 		// Call updatePID (similar to when we have processed M301)
203
 		updatePID();
211
 		updatePID();
244
     absPreheatHPBTemp = ABS_PREHEAT_HPB_TEMP;
252
     absPreheatHPBTemp = ABS_PREHEAT_HPB_TEMP;
245
     absPreheatFanSpeed = ABS_PREHEAT_FAN_SPEED;
253
     absPreheatFanSpeed = ABS_PREHEAT_FAN_SPEED;
246
 #endif
254
 #endif
255
+#ifdef DOGLCD
256
+    lcd_contrast = DEFAULT_LCD_CONTRAST;
257
+#endif
247
 #ifdef PIDTEMP
258
 #ifdef PIDTEMP
248
     Kp = DEFAULT_Kp;
259
     Kp = DEFAULT_Kp;
249
     Ki = scalePID_i(DEFAULT_Ki);
260
     Ki = scalePID_i(DEFAULT_Ki);

+ 14
- 0
Marlin/Marlin_main.cpp View File

125
 // M220 S<factor in percent>- set speed factor override percentage
125
 // M220 S<factor in percent>- set speed factor override percentage
126
 // M221 S<factor in percent>- set extrude factor override percentage
126
 // M221 S<factor in percent>- set extrude factor override percentage
127
 // M240 - Trigger a camera to take a photograph
127
 // M240 - Trigger a camera to take a photograph
128
+// M250 - Set LCD contrast C<contrast value> (value 0..63)
128
 // M280 - set servo position absolute. P: servo index, S: angle or microseconds
129
 // M280 - set servo position absolute. P: servo index, S: angle or microseconds
129
 // M300 - Play beepsound S<frequency Hz> P<duration ms>
130
 // M300 - Play beepsound S<frequency Hz> P<duration ms>
130
 // M301 - Set PID parameters P I and D
131
 // M301 - Set PID parameters P I and D
421
   servo_init();
422
   servo_init();
422
 
423
 
423
   lcd_init();
424
   lcd_init();
425
+  _delay_ms(1000);	// wait 1sec to display the splash screen
424
   
426
   
425
   #if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1
427
   #if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1
426
     SET_OUTPUT(CONTROLLERFAN_PIN); //Set pin used for driver cooling fan
428
     SET_OUTPUT(CONTROLLERFAN_PIN); //Set pin used for driver cooling fan
1699
       #endif
1701
       #endif
1700
      }
1702
      }
1701
     break;
1703
     break;
1704
+#ifdef DOGLCD
1705
+    case 250: // M250  Set LCD contrast value: C<value> (value 0..63)
1706
+     {
1707
+	  if (code_seen('C')) {
1708
+	   lcd_setcontrast( ((int)code_value())&63 );
1709
+          }
1710
+          SERIAL_PROTOCOLPGM("lcd contrast value: ");
1711
+          SERIAL_PROTOCOL(lcd_contrast);
1712
+          SERIAL_PROTOCOLLN("");
1713
+     }
1714
+    break;
1715
+#endif
1702
     #ifdef PREVENT_DANGEROUS_EXTRUDE
1716
     #ifdef PREVENT_DANGEROUS_EXTRUDE
1703
     case 302: // allow cold extrudes, or set the minimum extrude temperature
1717
     case 302: // allow cold extrudes, or set the minimum extrude temperature
1704
     {
1718
     {

+ 10
- 2
Marlin/dogm_lcd_implementation.h View File

74
 
74
 
75
 #define FONT_STATUSMENU	u8g_font_6x9
75
 #define FONT_STATUSMENU	u8g_font_6x9
76
 
76
 
77
+int lcd_contrast;
78
+
77
 // LCD selection
79
 // LCD selection
78
 #ifdef U8GLIB_ST7920
80
 #ifdef U8GLIB_ST7920
79
 //U8GLIB_ST7920_128X64_RRD u8g(0,0,0);
81
 //U8GLIB_ST7920_128X64_RRD u8g(0,0,0);
88
 
90
 
89
 static void lcd_implementation_init()
91
 static void lcd_implementation_init()
90
 {
92
 {
93
+#ifdef LCD_PIN_BL
94
+	pinMode(LCD_PIN_BL, OUTPUT);	// Enable LCD backlight
95
+	digitalWrite(LCD_PIN_BL, HIGH);
96
+#endif
97
+
98
+        u8g.setContrast(lcd_contrast);	
91
 	//  Uncomment this if you have the first generation (V1.10) of STBs board
99
 	//  Uncomment this if you have the first generation (V1.10) of STBs board
92
 	//  pinMode(17, OUTPUT);	// Enable LCD backlight
100
 	//  pinMode(17, OUTPUT);	// Enable LCD backlight
93
 	//  digitalWrite(17, HIGH);
101
 	//  digitalWrite(17, HIGH);
121
 			u8g.setFont(u8g_font_6x10_marlin);
129
 			u8g.setFont(u8g_font_6x10_marlin);
122
 			u8g.drawStr(62,10,"MARLIN"); 
130
 			u8g.drawStr(62,10,"MARLIN"); 
123
 			u8g.setFont(u8g_font_5x8);
131
 			u8g.setFont(u8g_font_5x8);
124
-			u8g.drawStr(62,19,"V1.0.0 RC2");
132
+			u8g.drawStr(62,19,"V1.0.0 RC2-mm");
125
 			u8g.setFont(u8g_font_6x10_marlin);
133
 			u8g.setFont(u8g_font_6x10_marlin);
126
 			u8g.drawStr(62,28,"by ErikZalm");
134
 			u8g.drawStr(62,28,"by ErikZalm");
127
 			u8g.drawStr(62,41,"DOGM128 LCD");
135
 			u8g.drawStr(62,41,"DOGM128 LCD");
128
 			u8g.setFont(u8g_font_5x8);
136
 			u8g.setFont(u8g_font_5x8);
129
 			u8g.drawStr(62,48,"enhancements");
137
 			u8g.drawStr(62,48,"enhancements");
130
 			u8g.setFont(u8g_font_5x8);
138
 			u8g.setFont(u8g_font_5x8);
131
-			u8g.drawStr(62,55,"by STB");
139
+			u8g.drawStr(62,55,"by STB, MM");
132
 			u8g.drawStr(62,61,"uses u");
140
 			u8g.drawStr(62,61,"uses u");
133
 			u8g.drawStr90(92,57,"8");
141
 			u8g.drawStr90(92,57,"8");
134
 			u8g.drawStr(100,61,"glib");
142
 			u8g.drawStr(100,61,"glib");

+ 9
- 2
Marlin/language.h View File

101
 	#define MSG_RECTRACT "Rectract"
101
 	#define MSG_RECTRACT "Rectract"
102
 	#define MSG_TEMPERATURE "Temperature"
102
 	#define MSG_TEMPERATURE "Temperature"
103
 	#define MSG_MOTION "Motion"
103
 	#define MSG_MOTION "Motion"
104
+	#define MSG_CONTRAST "LCD contrast"
104
 	#define MSG_STORE_EPROM "Store memory"
105
 	#define MSG_STORE_EPROM "Store memory"
105
 	#define MSG_LOAD_EPROM "Load memory"
106
 	#define MSG_LOAD_EPROM "Load memory"
106
 	#define MSG_RESTORE_FAILSAFE "Restore Failsafe"
107
 	#define MSG_RESTORE_FAILSAFE "Restore Failsafe"
260
 	#define MSG_RECTRACT "Wycofanie"
261
 	#define MSG_RECTRACT "Wycofanie"
261
 	#define MSG_TEMPERATURE "Temperatura"
262
 	#define MSG_TEMPERATURE "Temperatura"
262
 	#define MSG_MOTION "Ruch"
263
 	#define MSG_MOTION "Ruch"
264
+	#define MSG_CONTRAST "LCD contrast"
263
 	#define MSG_STORE_EPROM "Zapisz w pamieci"
265
 	#define MSG_STORE_EPROM "Zapisz w pamieci"
264
 	#define MSG_LOAD_EPROM "Wczytaj z pamieci"
266
 	#define MSG_LOAD_EPROM "Wczytaj z pamieci"
265
 	#define MSG_RESTORE_FAILSAFE " Ustawienia fabryczne"
267
 	#define MSG_RESTORE_FAILSAFE " Ustawienia fabryczne"
423
 #define MSG_TEMPERATURE_WIDE " Temperature \x7E"
425
 #define MSG_TEMPERATURE_WIDE " Temperature \x7E"
424
 #define MSG_TEMPERATURE_RTN " Temperature \003"
426
 #define MSG_TEMPERATURE_RTN " Temperature \003"
425
 #define MSG_MOTION_WIDE " Mouvement \x7E"
427
 #define MSG_MOTION_WIDE " Mouvement \x7E"
428
+	#define MSG_CONTRAST "LCD contrast"
426
 #define MSG_STORE_EPROM " Sauvegarder memoire"
429
 #define MSG_STORE_EPROM " Sauvegarder memoire"
427
 #define MSG_LOAD_EPROM " Lire memoire"
430
 #define MSG_LOAD_EPROM " Lire memoire"
428
 #define MSG_RESTORE_FAILSAFE " Restaurer memoire"
431
 #define MSG_RESTORE_FAILSAFE " Restaurer memoire"
535
 
538
 
536
 	#define MSG_SD_INSERTED      "SDKarte erkannt"
539
 	#define MSG_SD_INSERTED      "SDKarte erkannt"
537
 	#define MSG_SD_REMOVED       "SDKarte entfernt"
540
 	#define MSG_SD_REMOVED       "SDKarte entfernt"
538
-	#define MSG_MAIN             "Hauptmneü"
541
+	#define MSG_MAIN             "Hauptmenü"
539
 	#define MSG_AUTOSTART        "Autostart"
542
 	#define MSG_AUTOSTART        "Autostart"
540
 	#define MSG_DISABLE_STEPPERS "Stepper abschalten"
543
 	#define MSG_DISABLE_STEPPERS "Stepper abschalten"
541
 	#define MSG_AUTO_HOME        "Auto Nullpunkt"
544
 	#define MSG_AUTO_HOME        "Auto Nullpunkt"
554
 	#define MSG_NOZZLE2          "Düse3"
557
 	#define MSG_NOZZLE2          "Düse3"
555
 	#define MSG_BED              "Bett"
558
 	#define MSG_BED              "Bett"
556
 	#define MSG_FAN_SPEED        "Lüftergeschw."
559
 	#define MSG_FAN_SPEED        "Lüftergeschw."
557
-	#define MSG_FLOW             "Fluß"
560
+	#define MSG_FLOW             "Fluss"
558
 	#define MSG_CONTROL          "Einstellungen"
561
 	#define MSG_CONTROL          "Einstellungen"
559
 	#define MSG_MIN              "\002 Min"
562
 	#define MSG_MIN              "\002 Min"
560
 	#define MSG_MAX              "\002 Max"
563
 	#define MSG_MAX              "\002 Max"
587
 	#define MSG_WATCH            "Beobachten"
590
 	#define MSG_WATCH            "Beobachten"
588
 	#define MSG_TEMPERATURE      "Temperatur"
591
 	#define MSG_TEMPERATURE      "Temperatur"
589
 	#define MSG_MOTION           "Bewegung"
592
 	#define MSG_MOTION           "Bewegung"
593
+	#define MSG_CONTRAST "LCD contrast"
590
 	#define MSG_STORE_EPROM      "EPROM speichern"
594
 	#define MSG_STORE_EPROM      "EPROM speichern"
591
 	#define MSG_LOAD_EPROM       "EPROM laden"
595
 	#define MSG_LOAD_EPROM       "EPROM laden"
592
 	#define MSG_RESTORE_FAILSAFE "Standardkonfig."
596
 	#define MSG_RESTORE_FAILSAFE "Standardkonfig."
906
 #define MSG_RECTRACT    					" Откат подачи      \x7E"
910
 #define MSG_RECTRACT    					" Откат подачи      \x7E"
907
 #define MSG_TEMPERATURE  				" Температура       \x7E"
911
 #define MSG_TEMPERATURE  				" Температура       \x7E"
908
 #define MSG_MOTION						" Скорости          \x7E"
912
 #define MSG_MOTION						" Скорости          \x7E"
913
+	#define MSG_CONTRAST "LCD contrast"
909
 #define MSG_STORE_EPROM						" Сохранить настройки"
914
 #define MSG_STORE_EPROM						" Сохранить настройки"
910
 #define MSG_LOAD_EPROM						" Загрузить настройки"
915
 #define MSG_LOAD_EPROM						" Загрузить настройки"
911
 #define MSG_RESTORE_FAILSAFE				" Сброс настроек     "
916
 #define MSG_RESTORE_FAILSAFE				" Сброс настроек     "
1061
 	#define MSG_RECTRACT             "Ritrai"
1066
 	#define MSG_RECTRACT             "Ritrai"
1062
 	#define MSG_TEMPERATURE          "Temperatura"
1067
 	#define MSG_TEMPERATURE          "Temperatura"
1063
 	#define MSG_MOTION               "Movimento"
1068
 	#define MSG_MOTION               "Movimento"
1069
+	#define MSG_CONTRAST "LCD contrast"
1064
 	#define MSG_STORE_EPROM          "Salva in EEPROM"
1070
 	#define MSG_STORE_EPROM          "Salva in EEPROM"
1065
 	#define MSG_LOAD_EPROM           "Carica da EEPROM"
1071
 	#define MSG_LOAD_EPROM           "Carica da EEPROM"
1066
 	#define MSG_RESTORE_FAILSAFE     "Impostaz. default"
1072
 	#define MSG_RESTORE_FAILSAFE     "Impostaz. default"
1391
 	#define MSG_RECTRACT "Veda takaisin"
1397
 	#define MSG_RECTRACT "Veda takaisin"
1392
 	#define MSG_TEMPERATURE "Lampotila"
1398
 	#define MSG_TEMPERATURE "Lampotila"
1393
 	#define MSG_MOTION "Liike"
1399
 	#define MSG_MOTION "Liike"
1400
+	#define MSG_CONTRAST "LCD contrast"
1394
 	#define MSG_STORE_EPROM "Tallenna muistiin"
1401
 	#define MSG_STORE_EPROM "Tallenna muistiin"
1395
 	#define MSG_LOAD_EPROM "Lataa muistista"
1402
 	#define MSG_LOAD_EPROM "Lataa muistista"
1396
 	#define MSG_RESTORE_FAILSAFE "Palauta oletus"
1403
 	#define MSG_RESTORE_FAILSAFE "Palauta oletus"

+ 40
- 0
Marlin/ultralcd.cpp View File

47
 static void lcd_control_temperature_preheat_pla_settings_menu();
47
 static void lcd_control_temperature_preheat_pla_settings_menu();
48
 static void lcd_control_temperature_preheat_abs_settings_menu();
48
 static void lcd_control_temperature_preheat_abs_settings_menu();
49
 static void lcd_control_motion_menu();
49
 static void lcd_control_motion_menu();
50
+#ifdef DOGLCD
51
+static void lcd_set_contrast();
52
+#endif
50
 static void lcd_control_retract_menu();
53
 static void lcd_control_retract_menu();
51
 static void lcd_sdcard_menu();
54
 static void lcd_sdcard_menu();
52
 
55
 
492
     MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
495
     MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
493
     MENU_ITEM(submenu, MSG_TEMPERATURE, lcd_control_temperature_menu);
496
     MENU_ITEM(submenu, MSG_TEMPERATURE, lcd_control_temperature_menu);
494
     MENU_ITEM(submenu, MSG_MOTION, lcd_control_motion_menu);
497
     MENU_ITEM(submenu, MSG_MOTION, lcd_control_motion_menu);
498
+#ifdef DOGLCD
499
+//    MENU_ITEM_EDIT(int3, MSG_CONTRAST, &lcd_contrast, 0, 63);
500
+    MENU_ITEM(submenu, MSG_CONTRAST, lcd_set_contrast);
501
+#endif
495
 #ifdef FWRETRACT
502
 #ifdef FWRETRACT
496
     MENU_ITEM(submenu, MSG_RETRACT, lcd_control_retract_menu);
503
     MENU_ITEM(submenu, MSG_RETRACT, lcd_control_retract_menu);
497
 #endif
504
 #endif
603
     END_MENU();
610
     END_MENU();
604
 }
611
 }
605
 
612
 
613
+#ifdef DOGLCD
614
+static void lcd_set_contrast()
615
+{
616
+    if (encoderPosition != 0)
617
+    {
618
+        lcd_contrast -= encoderPosition;
619
+        if (lcd_contrast < 0) lcd_contrast = 0;
620
+        else if (lcd_contrast > 63) lcd_contrast = 63;
621
+        encoderPosition = 0;
622
+        lcdDrawUpdate = 1;
623
+        u8g.setContrast(lcd_contrast);
624
+    }
625
+    if (lcdDrawUpdate)
626
+    {
627
+        lcd_implementation_drawedit(PSTR("Contrast"), itostr2(lcd_contrast));
628
+    }
629
+    if (LCD_CLICKED)
630
+    {
631
+        lcd_quick_feedback();
632
+        currentMenu = lcd_control_menu;
633
+        encoderPosition = 0;
634
+    }
635
+}
636
+#endif
637
+
606
 #ifdef FWRETRACT
638
 #ifdef FWRETRACT
607
 static void lcd_control_retract_menu()
639
 static void lcd_control_retract_menu()
608
 {
640
 {
962
     lcd_status_message_level = 0;
994
     lcd_status_message_level = 0;
963
 }
995
 }
964
 
996
 
997
+#ifdef DOGLCD
998
+void lcd_setcontrast(uint8_t value)
999
+{
1000
+    lcd_contrast = value & 63;
1001
+    u8g.setContrast(lcd_contrast);	
1002
+}
1003
+#endif
1004
+
965
 #ifdef ULTIPANEL
1005
 #ifdef ULTIPANEL
966
 /* Warning: This function is called from interrupt context */
1006
 /* Warning: This function is called from interrupt context */
967
 void lcd_buttons_update()
1007
 void lcd_buttons_update()

+ 6
- 1
Marlin/ultralcd.h View File

11
   void lcd_setstatuspgm(const char* message);
11
   void lcd_setstatuspgm(const char* message);
12
   void lcd_setalertstatuspgm(const char* message);
12
   void lcd_setalertstatuspgm(const char* message);
13
   void lcd_reset_alert_level();
13
   void lcd_reset_alert_level();
14
-  
14
+
15
+#ifdef DOGLCD
16
+  extern int lcd_contrast;
17
+  void lcd_setcontrast(uint8_t value);
18
+#endif
19
+
15
   static unsigned char blink = 0;	// Variable for visualisation of fan rotation in GLCD
20
   static unsigned char blink = 0;	// Variable for visualisation of fan rotation in GLCD
16
 
21
 
17
   #define LCD_MESSAGEPGM(x) lcd_setstatuspgm(PSTR(x))
22
   #define LCD_MESSAGEPGM(x) lcd_setstatuspgm(PSTR(x))

Loading…
Cancel
Save