added contrast control function for gLCDs
This commit is contained in:
parent
99b7e926e7
commit
e509cdbeb0
|
@ -517,6 +517,13 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
|
|||
#endif
|
||||
#endif
|
||||
|
||||
// default LCD contrast for dogm-like LCD displays
|
||||
#ifdef DOGLCD
|
||||
# ifndef DEFAULT_LCD_CONTRAST
|
||||
# define DEFAULT_LCD_CONTRAST 32
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// Increase the FAN pwm frequency. Removes the PWM noise but increases heating in the FET/Arduino
|
||||
//#define FAST_PWM_FAN
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size)
|
|||
// the default values are used whenever there is a change to the data, to prevent
|
||||
// wrong data being written to the variables.
|
||||
// ALSO: always make sure the variables in the Store and retrieve sections are in the same order.
|
||||
#define EEPROM_VERSION "V07"
|
||||
#define EEPROM_VERSION "V08"
|
||||
|
||||
#ifdef EEPROM_SETTINGS
|
||||
void Config_StoreSettings()
|
||||
|
@ -78,6 +78,10 @@ void Config_StoreSettings()
|
|||
EEPROM_WRITE_VAR(i,dummy);
|
||||
EEPROM_WRITE_VAR(i,dummy);
|
||||
#endif
|
||||
#ifndef DOGLCD
|
||||
int lcd_contrast = 32;
|
||||
#endif
|
||||
EEPROM_WRITE_VAR(i,lcd_contrast);
|
||||
char ver2[4]=EEPROM_VERSION;
|
||||
i=EEPROM_OFFSET;
|
||||
EEPROM_WRITE_VAR(i,ver2); // validate data
|
||||
|
@ -198,6 +202,10 @@ void Config_RetrieveSettings()
|
|||
EEPROM_READ_VAR(i,Kp);
|
||||
EEPROM_READ_VAR(i,Ki);
|
||||
EEPROM_READ_VAR(i,Kd);
|
||||
#ifndef DOGLCD
|
||||
int lcd_contrast;
|
||||
#endif
|
||||
EEPROM_READ_VAR(i,lcd_contrast);
|
||||
|
||||
// Call updatePID (similar to when we have processed M301)
|
||||
updatePID();
|
||||
|
@ -244,6 +252,9 @@ void Config_ResetDefault()
|
|||
absPreheatHPBTemp = ABS_PREHEAT_HPB_TEMP;
|
||||
absPreheatFanSpeed = ABS_PREHEAT_FAN_SPEED;
|
||||
#endif
|
||||
#ifdef DOGLCD
|
||||
lcd_contrast = DEFAULT_LCD_CONTRAST;
|
||||
#endif
|
||||
#ifdef PIDTEMP
|
||||
Kp = DEFAULT_Kp;
|
||||
Ki = scalePID_i(DEFAULT_Ki);
|
||||
|
|
|
@ -125,6 +125,7 @@
|
|||
// M220 S<factor in percent>- set speed factor override percentage
|
||||
// M221 S<factor in percent>- set extrude factor override percentage
|
||||
// M240 - Trigger a camera to take a photograph
|
||||
// M250 - Set LCD contrast C<contrast value> (value 0..63)
|
||||
// M280 - set servo position absolute. P: servo index, S: angle or microseconds
|
||||
// M300 - Play beepsound S<frequency Hz> P<duration ms>
|
||||
// M301 - Set PID parameters P I and D
|
||||
|
@ -421,6 +422,7 @@ void setup()
|
|||
servo_init();
|
||||
|
||||
lcd_init();
|
||||
_delay_ms(1000); // wait 1sec to display the splash screen
|
||||
|
||||
#if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1
|
||||
SET_OUTPUT(CONTROLLERFAN_PIN); //Set pin used for driver cooling fan
|
||||
|
@ -1699,6 +1701,18 @@ void process_commands()
|
|||
#endif
|
||||
}
|
||||
break;
|
||||
#ifdef DOGLCD
|
||||
case 250: // M250 Set LCD contrast value: C<value> (value 0..63)
|
||||
{
|
||||
if (code_seen('C')) {
|
||||
lcd_setcontrast( ((int)code_value())&63 );
|
||||
}
|
||||
SERIAL_PROTOCOLPGM("lcd contrast value: ");
|
||||
SERIAL_PROTOCOL(lcd_contrast);
|
||||
SERIAL_PROTOCOLLN("");
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#ifdef PREVENT_DANGEROUS_EXTRUDE
|
||||
case 302: // allow cold extrudes, or set the minimum extrude temperature
|
||||
{
|
||||
|
|
|
@ -74,6 +74,8 @@
|
|||
|
||||
#define FONT_STATUSMENU u8g_font_6x9
|
||||
|
||||
int lcd_contrast;
|
||||
|
||||
// LCD selection
|
||||
#ifdef U8GLIB_ST7920
|
||||
//U8GLIB_ST7920_128X64_RRD u8g(0,0,0);
|
||||
|
@ -88,6 +90,12 @@ U8GLIB_DOGM128 u8g(DOGLCD_CS, DOGLCD_A0); // HW-SPI Com: CS, A0
|
|||
|
||||
static void lcd_implementation_init()
|
||||
{
|
||||
#ifdef LCD_PIN_BL
|
||||
pinMode(LCD_PIN_BL, OUTPUT); // Enable LCD backlight
|
||||
digitalWrite(LCD_PIN_BL, HIGH);
|
||||
#endif
|
||||
|
||||
u8g.setContrast(lcd_contrast);
|
||||
// Uncomment this if you have the first generation (V1.10) of STBs board
|
||||
// pinMode(17, OUTPUT); // Enable LCD backlight
|
||||
// digitalWrite(17, HIGH);
|
||||
|
@ -121,14 +129,14 @@ static void lcd_implementation_init()
|
|||
u8g.setFont(u8g_font_6x10_marlin);
|
||||
u8g.drawStr(62,10,"MARLIN");
|
||||
u8g.setFont(u8g_font_5x8);
|
||||
u8g.drawStr(62,19,"V1.0.0 RC2");
|
||||
u8g.drawStr(62,19,"V1.0.0 RC2-mm");
|
||||
u8g.setFont(u8g_font_6x10_marlin);
|
||||
u8g.drawStr(62,28,"by ErikZalm");
|
||||
u8g.drawStr(62,41,"DOGM128 LCD");
|
||||
u8g.setFont(u8g_font_5x8);
|
||||
u8g.drawStr(62,48,"enhancements");
|
||||
u8g.setFont(u8g_font_5x8);
|
||||
u8g.drawStr(62,55,"by STB");
|
||||
u8g.drawStr(62,55,"by STB, MM");
|
||||
u8g.drawStr(62,61,"uses u");
|
||||
u8g.drawStr90(92,57,"8");
|
||||
u8g.drawStr(100,61,"glib");
|
||||
|
|
|
@ -101,6 +101,7 @@
|
|||
#define MSG_RECTRACT "Rectract"
|
||||
#define MSG_TEMPERATURE "Temperature"
|
||||
#define MSG_MOTION "Motion"
|
||||
#define MSG_CONTRAST "LCD contrast"
|
||||
#define MSG_STORE_EPROM "Store memory"
|
||||
#define MSG_LOAD_EPROM "Load memory"
|
||||
#define MSG_RESTORE_FAILSAFE "Restore Failsafe"
|
||||
|
@ -260,6 +261,7 @@
|
|||
#define MSG_RECTRACT "Wycofanie"
|
||||
#define MSG_TEMPERATURE "Temperatura"
|
||||
#define MSG_MOTION "Ruch"
|
||||
#define MSG_CONTRAST "LCD contrast"
|
||||
#define MSG_STORE_EPROM "Zapisz w pamieci"
|
||||
#define MSG_LOAD_EPROM "Wczytaj z pamieci"
|
||||
#define MSG_RESTORE_FAILSAFE " Ustawienia fabryczne"
|
||||
|
@ -423,6 +425,7 @@
|
|||
#define MSG_TEMPERATURE_WIDE " Temperature \x7E"
|
||||
#define MSG_TEMPERATURE_RTN " Temperature \003"
|
||||
#define MSG_MOTION_WIDE " Mouvement \x7E"
|
||||
#define MSG_CONTRAST "LCD contrast"
|
||||
#define MSG_STORE_EPROM " Sauvegarder memoire"
|
||||
#define MSG_LOAD_EPROM " Lire memoire"
|
||||
#define MSG_RESTORE_FAILSAFE " Restaurer memoire"
|
||||
|
@ -535,7 +538,7 @@
|
|||
|
||||
#define MSG_SD_INSERTED "SDKarte erkannt"
|
||||
#define MSG_SD_REMOVED "SDKarte entfernt"
|
||||
#define MSG_MAIN "Hauptmneü"
|
||||
#define MSG_MAIN "Hauptmenü"
|
||||
#define MSG_AUTOSTART "Autostart"
|
||||
#define MSG_DISABLE_STEPPERS "Stepper abschalten"
|
||||
#define MSG_AUTO_HOME "Auto Nullpunkt"
|
||||
|
@ -554,7 +557,7 @@
|
|||
#define MSG_NOZZLE2 "Düse3"
|
||||
#define MSG_BED "Bett"
|
||||
#define MSG_FAN_SPEED "Lüftergeschw."
|
||||
#define MSG_FLOW "Fluß"
|
||||
#define MSG_FLOW "Fluss"
|
||||
#define MSG_CONTROL "Einstellungen"
|
||||
#define MSG_MIN "\002 Min"
|
||||
#define MSG_MAX "\002 Max"
|
||||
|
@ -587,6 +590,7 @@
|
|||
#define MSG_WATCH "Beobachten"
|
||||
#define MSG_TEMPERATURE "Temperatur"
|
||||
#define MSG_MOTION "Bewegung"
|
||||
#define MSG_CONTRAST "LCD contrast"
|
||||
#define MSG_STORE_EPROM "EPROM speichern"
|
||||
#define MSG_LOAD_EPROM "EPROM laden"
|
||||
#define MSG_RESTORE_FAILSAFE "Standardkonfig."
|
||||
|
@ -906,6 +910,7 @@
|
|||
#define MSG_RECTRACT " Откат подачи \x7E"
|
||||
#define MSG_TEMPERATURE " Температура \x7E"
|
||||
#define MSG_MOTION " Скорости \x7E"
|
||||
#define MSG_CONTRAST "LCD contrast"
|
||||
#define MSG_STORE_EPROM " Сохранить настройки"
|
||||
#define MSG_LOAD_EPROM " Загрузить настройки"
|
||||
#define MSG_RESTORE_FAILSAFE " Сброс настроек "
|
||||
|
@ -1061,6 +1066,7 @@
|
|||
#define MSG_RECTRACT "Ritrai"
|
||||
#define MSG_TEMPERATURE "Temperatura"
|
||||
#define MSG_MOTION "Movimento"
|
||||
#define MSG_CONTRAST "LCD contrast"
|
||||
#define MSG_STORE_EPROM "Salva in EEPROM"
|
||||
#define MSG_LOAD_EPROM "Carica da EEPROM"
|
||||
#define MSG_RESTORE_FAILSAFE "Impostaz. default"
|
||||
|
@ -1391,6 +1397,7 @@
|
|||
#define MSG_RECTRACT "Veda takaisin"
|
||||
#define MSG_TEMPERATURE "Lampotila"
|
||||
#define MSG_MOTION "Liike"
|
||||
#define MSG_CONTRAST "LCD contrast"
|
||||
#define MSG_STORE_EPROM "Tallenna muistiin"
|
||||
#define MSG_LOAD_EPROM "Lataa muistista"
|
||||
#define MSG_RESTORE_FAILSAFE "Palauta oletus"
|
||||
|
|
|
@ -47,6 +47,9 @@ static void lcd_control_temperature_menu();
|
|||
static void lcd_control_temperature_preheat_pla_settings_menu();
|
||||
static void lcd_control_temperature_preheat_abs_settings_menu();
|
||||
static void lcd_control_motion_menu();
|
||||
#ifdef DOGLCD
|
||||
static void lcd_set_contrast();
|
||||
#endif
|
||||
static void lcd_control_retract_menu();
|
||||
static void lcd_sdcard_menu();
|
||||
|
||||
|
@ -492,6 +495,10 @@ static void lcd_control_menu()
|
|||
MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
|
||||
MENU_ITEM(submenu, MSG_TEMPERATURE, lcd_control_temperature_menu);
|
||||
MENU_ITEM(submenu, MSG_MOTION, lcd_control_motion_menu);
|
||||
#ifdef DOGLCD
|
||||
// MENU_ITEM_EDIT(int3, MSG_CONTRAST, &lcd_contrast, 0, 63);
|
||||
MENU_ITEM(submenu, MSG_CONTRAST, lcd_set_contrast);
|
||||
#endif
|
||||
#ifdef FWRETRACT
|
||||
MENU_ITEM(submenu, MSG_RETRACT, lcd_control_retract_menu);
|
||||
#endif
|
||||
|
@ -603,6 +610,31 @@ static void lcd_control_motion_menu()
|
|||
END_MENU();
|
||||
}
|
||||
|
||||
#ifdef DOGLCD
|
||||
static void lcd_set_contrast()
|
||||
{
|
||||
if (encoderPosition != 0)
|
||||
{
|
||||
lcd_contrast -= encoderPosition;
|
||||
if (lcd_contrast < 0) lcd_contrast = 0;
|
||||
else if (lcd_contrast > 63) lcd_contrast = 63;
|
||||
encoderPosition = 0;
|
||||
lcdDrawUpdate = 1;
|
||||
u8g.setContrast(lcd_contrast);
|
||||
}
|
||||
if (lcdDrawUpdate)
|
||||
{
|
||||
lcd_implementation_drawedit(PSTR("Contrast"), itostr2(lcd_contrast));
|
||||
}
|
||||
if (LCD_CLICKED)
|
||||
{
|
||||
lcd_quick_feedback();
|
||||
currentMenu = lcd_control_menu;
|
||||
encoderPosition = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FWRETRACT
|
||||
static void lcd_control_retract_menu()
|
||||
{
|
||||
|
@ -962,6 +994,14 @@ void lcd_reset_alert_level()
|
|||
lcd_status_message_level = 0;
|
||||
}
|
||||
|
||||
#ifdef DOGLCD
|
||||
void lcd_setcontrast(uint8_t value)
|
||||
{
|
||||
lcd_contrast = value & 63;
|
||||
u8g.setContrast(lcd_contrast);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ULTIPANEL
|
||||
/* Warning: This function is called from interrupt context */
|
||||
void lcd_buttons_update()
|
||||
|
|
|
@ -11,7 +11,12 @@
|
|||
void lcd_setstatuspgm(const char* message);
|
||||
void lcd_setalertstatuspgm(const char* message);
|
||||
void lcd_reset_alert_level();
|
||||
|
||||
|
||||
#ifdef DOGLCD
|
||||
extern int lcd_contrast;
|
||||
void lcd_setcontrast(uint8_t value);
|
||||
#endif
|
||||
|
||||
static unsigned char blink = 0; // Variable for visualisation of fan rotation in GLCD
|
||||
|
||||
#define LCD_MESSAGEPGM(x) lcd_setstatuspgm(PSTR(x))
|
||||
|
|
Loading…
Reference in a new issue