From 99b7e926e7704d74c0a0ea9f4112bc04e5b730e4 Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Sun, 14 Jul 2013 15:17:55 +0700 Subject: [PATCH 1/2] added MaKr3d Melzi board --- Marlin/Configuration.h | 20 ++++++++++++++++---- Marlin/Makefile | 6 ++++++ Marlin/dogm_lcd_implementation.h | 4 ++++ Marlin/pins.h | 27 +++++++++++++++++++++++++-- 4 files changed, 51 insertions(+), 6 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 50b74a5fe..987dbf8e8 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -17,8 +17,7 @@ #define SERIAL_PORT 0 // This determines the communication speed of the printer -#define BAUDRATE 250000 -//#define BAUDRATE 115200 +#define BAUDRATE 115200 //// The following define selects which electronics board you have. Please choose the one that matches your setup // 10 = Gen7 custom (Alfons3 Version) "https://github.com/Alfons3/Generation_7_Electronics" @@ -36,6 +35,7 @@ // 63 = Melzi // 64 = STB V1.1 // 65 = Azteeg X1 +// 66 = Melzi with ATmega1284 (MaKr3d version) // 7 = Ultimaker // 71 = Ultimaker (Older electronics. Pre 1.5.4. This is rare) // 77 = 3Drag Controller @@ -371,10 +371,10 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th // M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily). // M502 - reverts to the default "factory settings". You still need to store them in EEPROM afterwards if you want to. //define this to enable eeprom support -//#define EEPROM_SETTINGS +#define EEPROM_SETTINGS //to disable EEPROM Serial responses and decrease program space by ~1700 byte: comment this out: // please keep turned on if you can. -//#define EEPROM_CHITCHAT +#define EEPROM_CHITCHAT // Preheat Constants #define PLA_PREHEAT_HOTEND_TEMP 180 @@ -394,6 +394,10 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th //#define ULTIMAKERCONTROLLER //as available from the ultimaker online store. //#define ULTIPANEL //the ultipanel as on thingiverse +// The MaKr3d Makr-Panel with graphic controller and SD support +// http://reprap.org/wiki/MaKr3d_MaKrPanel +//#define MAKRPANEL + // The RepRapDiscount Smart Controller (white PCB) // http://reprap.org/wiki/RepRapDiscount_Smart_Controller //#define REPRAP_DISCOUNT_SMART_CONTROLLER @@ -419,6 +423,14 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th //#define RA_CONTROL_PANEL //automatic expansion +#if defined (MAKRPANEL) + #define DOGLCD + #define SDSUPPORT + #define ULTIPANEL + #define NEWPANEL + #define DEFAULT_LCD_CONTRAST 17 +#endif + #if defined (REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) #define DOGLCD #define U8GLIB_ST7920 diff --git a/Marlin/Makefile b/Marlin/Makefile index 3d04d3677..a4ae1d73a 100644 --- a/Marlin/Makefile +++ b/Marlin/Makefile @@ -114,6 +114,12 @@ MCU ?= atmega644p else ifeq ($(HARDWARE_MOTHERBOARD),63) HARDWARE_VARIANT ?= Sanguino MCU ?= atmega644p +else ifeq ($(HARDWARE_MOTHERBOARD),65) +HARDWARE_VARIANT ?= Sanguino +MCU ?= atmega1284p +else ifeq ($(HARDWARE_MOTHERBOARD),66) +HARDWARE_VARIANT ?= Sanguino +MCU ?= atmega1284p #Ultimaker else ifeq ($(HARDWARE_MOTHERBOARD),7) diff --git a/Marlin/dogm_lcd_implementation.h b/Marlin/dogm_lcd_implementation.h index 17a56adba..03c7fd739 100644 --- a/Marlin/dogm_lcd_implementation.h +++ b/Marlin/dogm_lcd_implementation.h @@ -78,7 +78,11 @@ #ifdef U8GLIB_ST7920 //U8GLIB_ST7920_128X64_RRD u8g(0,0,0); U8GLIB_ST7920_128X64_RRD u8g(0); +#elsif defined(MAKRPANEL) +// The MaKrPanel display, ST7565 controller as well +U8GLIB_NHD_C12864 u8g(DOGLCD_CS, DOGLCD_A0); #else +// for regular DOGM128 display with HW-SPI U8GLIB_DOGM128 u8g(DOGLCD_CS, DOGLCD_A0); // HW-SPI Com: CS, A0 #endif diff --git a/Marlin/pins.h b/Marlin/pins.h index 88dc1f563..877b86024 100644 --- a/Marlin/pins.h +++ b/Marlin/pins.h @@ -843,13 +843,13 @@ #if MOTHERBOARD == 64 #define STB #endif -#if MOTHERBOARD == 63 +#if MOTHERBOARD == 63 || MOTHERBOARD == 66 #define MELZI #endif #if MOTHERBOARD == 65 #define AZTEEG_X1 #endif -#if MOTHERBOARD == 62 || MOTHERBOARD == 63 || MOTHERBOARD == 64 || MOTHERBOARD == 65 +#if MOTHERBOARD == 62 || MOTHERBOARD == 63 || MOTHERBOARD == 64 || MOTHERBOARD == 65 || MOTHERBOARD == 66 #undef MOTHERBOARD #define MOTHERBOARD 6 #define SANGUINOLOLU_V_1_2 @@ -891,6 +891,8 @@ #ifdef STB #define FAN_PIN 4 + // Uncomment this if you have the first generation (V1.10) of STBs board +#define LCD_PIN_BL 17 // LCD backlight LED #endif #ifdef AZTEEG_X1 @@ -975,6 +977,27 @@ #endif //Newpanel #endif //Ultipanel + #ifdef MAKRPANEL + #define BEEPER 29 + // Pins for DOGM SPI LCD Support + #define DOGLCD_A0 30 + #define DOGLCD_CS 17 + #define LCD_PIN_BL 28 // backlight LED on PA3 + // GLCD features + #define LCD_CONTRAST 1 + // Uncomment screen orientation + #define LCD_SCREEN_ROT_0 + // #define LCD_SCREEN_ROT_90 + // #define LCD_SCREEN_ROT_180 + // #define LCD_SCREEN_ROT_270 + //The encoder and click button + #define BTN_EN1 11 + #define BTN_EN2 10 + #define BTN_ENC 16 //the click switch + //not connected to a pin + #define SDCARDDETECT -1 + #endif //Makrpanel + #endif From e509cdbeb020a5d47ede81ead6767c9a747adbe6 Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Sun, 14 Jul 2013 15:28:26 +0700 Subject: [PATCH 2/2] added contrast control function for gLCDs --- Marlin/Configuration.h | 7 ++++++ Marlin/ConfigurationStore.cpp | 13 ++++++++++- Marlin/Marlin_main.cpp | 14 +++++++++++ Marlin/dogm_lcd_implementation.h | 12 ++++++++-- Marlin/language.h | 11 +++++++-- Marlin/ultralcd.cpp | 40 ++++++++++++++++++++++++++++++++ Marlin/ultralcd.h | 7 +++++- 7 files changed, 98 insertions(+), 6 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 987dbf8e8..33e0d3376 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -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 diff --git a/Marlin/ConfigurationStore.cpp b/Marlin/ConfigurationStore.cpp index 4e11c447a..65d030279 100644 --- a/Marlin/ConfigurationStore.cpp +++ b/Marlin/ConfigurationStore.cpp @@ -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); diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 0677c0b43..79911fccf 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -125,6 +125,7 @@ // M220 S- set speed factor override percentage // M221 S- set extrude factor override percentage // M240 - Trigger a camera to take a photograph +// M250 - Set LCD contrast C (value 0..63) // M280 - set servo position absolute. P: servo index, S: angle or microseconds // M300 - Play beepsound S P // 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 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 { diff --git a/Marlin/dogm_lcd_implementation.h b/Marlin/dogm_lcd_implementation.h index 03c7fd739..489a122b3 100644 --- a/Marlin/dogm_lcd_implementation.h +++ b/Marlin/dogm_lcd_implementation.h @@ -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"); diff --git a/Marlin/language.h b/Marlin/language.h index 796e17797..287cc026b 100644 --- a/Marlin/language.h +++ b/Marlin/language.h @@ -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" diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 4e1456c02..4ddb247ad 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -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() diff --git a/Marlin/ultralcd.h b/Marlin/ultralcd.h index 5d3c3c0be..8f2b376d5 100644 --- a/Marlin/ultralcd.h +++ b/Marlin/ultralcd.h @@ -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))