From 83e33bdd266e16ffaa322e664f67fdda3471f197 Mon Sep 17 00:00:00 2001 From: Bob Clough Date: Mon, 25 Feb 2013 14:01:48 +0000 Subject: [PATCH 01/14] Added LiquidCrystal_I2C library to ArduinoAddons --- ArduinoAddons/Arduino_0.xx/libraries/LiquidCrystal_I2C | 1 + ArduinoAddons/Arduino_1.x.x/libraries/LiquidCrystal_I2C | 1 + 2 files changed, 2 insertions(+) create mode 160000 ArduinoAddons/Arduino_0.xx/libraries/LiquidCrystal_I2C create mode 160000 ArduinoAddons/Arduino_1.x.x/libraries/LiquidCrystal_I2C diff --git a/ArduinoAddons/Arduino_0.xx/libraries/LiquidCrystal_I2C b/ArduinoAddons/Arduino_0.xx/libraries/LiquidCrystal_I2C new file mode 160000 index 000000000..bfb71c875 --- /dev/null +++ b/ArduinoAddons/Arduino_0.xx/libraries/LiquidCrystal_I2C @@ -0,0 +1 @@ +Subproject commit bfb71c87594ab904db9e41d9f57c6e2df89dc632 diff --git a/ArduinoAddons/Arduino_1.x.x/libraries/LiquidCrystal_I2C b/ArduinoAddons/Arduino_1.x.x/libraries/LiquidCrystal_I2C new file mode 160000 index 000000000..bfb71c875 --- /dev/null +++ b/ArduinoAddons/Arduino_1.x.x/libraries/LiquidCrystal_I2C @@ -0,0 +1 @@ +Subproject commit bfb71c87594ab904db9e41d9f57c6e2df89dc632 From 06272f463d523a914a972e9b5ec1ef687c3f41c7 Mon Sep 17 00:00:00 2001 From: Bob Clough Date: Mon, 25 Feb 2013 14:14:46 +0000 Subject: [PATCH 02/14] Added Config variables for activating I2C LCDs and setting type and address --- Marlin/Configuration.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 9d1027a0f..75dcc3cc4 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -316,9 +316,9 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th // The RepRapDiscount Smart Controller (white PCB) // http://reprap.org/wiki/RepRapDiscount_Smart_Controller //#define REPRAP_DISCOUNT_SMART_CONTROLLER - -// The GADGETS3D G3D LCD/SD Controller (blue PCB) -// http://reprap.org/wiki/RAMPS_1.3/1.4_GADGETS3D_Shield_with_Panel + +// The GADGETS3D G3D LCD/SD Controller (blue PCB) +// http://reprap.org/wiki/RAMPS_1.3/1.4_GADGETS3D_Shield_with_Panel //#define G3D_PANEL //automatic expansion @@ -351,6 +351,15 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th #endif #endif +//The LCD is attached via an I2C port expander. +//#define LCD_I2C +#ifdef LCD_I2C + // Port Expander Type - PCF8574 or MCP23008 + #define LCD_I2C_TYPE PCF8574 + // I2C Address of the port expander + #define LCD_I2C_ADDRESS 0x20 +#endif + // Increase the FAN pwm frequency. Removes the PWM noise but increases heating in the FET/Arduino //#define FAST_PWM_FAN From 2b567d1df55b9762f79736df7c9eb9f64e22cc73 Mon Sep 17 00:00:00 2001 From: Bob Clough Date: Mon, 25 Feb 2013 14:22:14 +0000 Subject: [PATCH 03/14] Added I2C port expander support to HD44780 --- Marlin/Configuration.h | 4 +-- .../ultralcd_implementation_hitachi_HD44780.h | 26 ++++++++++++++----- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 75dcc3cc4..bd0ac931f 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -354,8 +354,8 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th //The LCD is attached via an I2C port expander. //#define LCD_I2C #ifdef LCD_I2C - // Port Expander Type - PCF8574 or MCP23008 - #define LCD_I2C_TYPE PCF8574 + // Port Expander Type - 0=PCF8574 or 1=MCP23008 + #define LCD_I2C_TYPE 0 // I2C Address of the port expander #define LCD_I2C_ADDRESS 0x20 #endif diff --git a/Marlin/ultralcd_implementation_hitachi_HD44780.h b/Marlin/ultralcd_implementation_hitachi_HD44780.h index 1d19b7718..526dd8df0 100644 --- a/Marlin/ultralcd_implementation_hitachi_HD44780.h +++ b/Marlin/ultralcd_implementation_hitachi_HD44780.h @@ -7,11 +7,16 @@ **/ #if LANGUAGE_CHOICE == 6 -#include "LiquidCrystalRus.h" -#define LCD_CLASS LiquidCrystalRus + #include "LiquidCrystalRus.h" + #define LCD_CLASS LiquidCrystalRus #else -#include -#define LCD_CLASS LiquidCrystal + #ifdef LCD_I2C + #include + #define LCD_CLASS LiquidCrystal_I2C + #else + #include + #define LCD_CLASS LiquidCrystal + #endif #endif /* Custom characters defined in the first 8 characters of the LCD */ @@ -25,7 +30,12 @@ #define LCD_STR_CLOCK "\x07" #define LCD_STR_ARROW_RIGHT "\x7E" /* from the default character set */ -LCD_CLASS lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7); //RS,Enable,D4,D5,D6,D7 +#ifdef LCD_I2C + LCD_CLASS lcd(LCD_I2C_ADDRESS, LCD_WIDTH, LCD_HEIGHT, LCD_I2C_TYPE); //address, columns, rows, type +#else + LCD_CLASS lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7); //RS,Enable,D4,D5,D6,D7 +#endif + static void lcd_implementation_init() { byte bedTemp[8] = @@ -111,7 +121,11 @@ static void lcd_implementation_init() B00000, B00000 }; //thanks Sonny Mounicou - lcd.begin(LCD_WIDTH, LCD_HEIGHT); + #ifdef LCD_I2C + lcd.init(); + #else + lcd.begin(LCD_WIDTH, LCD_HEIGHT); + #endif lcd.createChar(LCD_STR_BEDTEMP[0], bedTemp); lcd.createChar(LCD_STR_DEGREE[0], degree); lcd.createChar(LCD_STR_THERMOMETER[0], thermometer); From b6209c86dd0890970a9bb041755a74dc88d62a0a Mon Sep 17 00:00:00 2001 From: Bob Clough Date: Mon, 25 Feb 2013 15:15:23 +0000 Subject: [PATCH 04/14] Added import of Wire Library to make I2C LCD support compilable --- Marlin/Marlin.pde | 7 ++++++- Marlin/ultralcd_implementation_hitachi_HD44780.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Marlin/Marlin.pde b/Marlin/Marlin.pde index 5cd646e46..6602f6c86 100644 --- a/Marlin/Marlin.pde +++ b/Marlin/Marlin.pde @@ -34,7 +34,12 @@ #include "pins.h" #ifdef ULTRA_LCD -#include + #ifdef LCD_I2C + #include + #include + #else + #include + #endif #endif #if DIGIPOTSS_PIN > -1 diff --git a/Marlin/ultralcd_implementation_hitachi_HD44780.h b/Marlin/ultralcd_implementation_hitachi_HD44780.h index 526dd8df0..aa94b93ec 100644 --- a/Marlin/ultralcd_implementation_hitachi_HD44780.h +++ b/Marlin/ultralcd_implementation_hitachi_HD44780.h @@ -11,6 +11,7 @@ #define LCD_CLASS LiquidCrystalRus #else #ifdef LCD_I2C + #include #include #define LCD_CLASS LiquidCrystal_I2C #else From 67710df9f3ac7921502f0444f4cc5621fbd645ce Mon Sep 17 00:00:00 2001 From: MendelMax Date: Tue, 26 Feb 2013 22:22:12 +0000 Subject: [PATCH 05/14] Made i2c mode wok with the hardware I am able to test (ywrobot / sainsmart i2c LCD 2004) Removed incorrect LiquidCrystal_I2C Library --- .../Arduino_0.xx/libraries/LiquidCrystal_I2C | 1 - .../Arduino_1.x.x/libraries/LiquidCrystal_I2C | 1 - Marlin/Configuration.h | 4 ++-- .../ultralcd_implementation_hitachi_HD44780.h | 24 +++++++++++++++---- 4 files changed, 22 insertions(+), 8 deletions(-) delete mode 160000 ArduinoAddons/Arduino_0.xx/libraries/LiquidCrystal_I2C delete mode 160000 ArduinoAddons/Arduino_1.x.x/libraries/LiquidCrystal_I2C diff --git a/ArduinoAddons/Arduino_0.xx/libraries/LiquidCrystal_I2C b/ArduinoAddons/Arduino_0.xx/libraries/LiquidCrystal_I2C deleted file mode 160000 index bfb71c875..000000000 --- a/ArduinoAddons/Arduino_0.xx/libraries/LiquidCrystal_I2C +++ /dev/null @@ -1 +0,0 @@ -Subproject commit bfb71c87594ab904db9e41d9f57c6e2df89dc632 diff --git a/ArduinoAddons/Arduino_1.x.x/libraries/LiquidCrystal_I2C b/ArduinoAddons/Arduino_1.x.x/libraries/LiquidCrystal_I2C deleted file mode 160000 index bfb71c875..000000000 --- a/ArduinoAddons/Arduino_1.x.x/libraries/LiquidCrystal_I2C +++ /dev/null @@ -1 +0,0 @@ -Subproject commit bfb71c87594ab904db9e41d9f57c6e2df89dc632 diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index bd0ac931f..d47b24cc4 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -354,10 +354,10 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th //The LCD is attached via an I2C port expander. //#define LCD_I2C #ifdef LCD_I2C - // Port Expander Type - 0=PCF8574 or 1=MCP23008 + // Port Expander Type - 0=PCF8574 sainsmart/ywrobot #define LCD_I2C_TYPE 0 // I2C Address of the port expander - #define LCD_I2C_ADDRESS 0x20 + #define LCD_I2C_ADDRESS 0x27 #endif // Increase the FAN pwm frequency. Removes the PWM noise but increases heating in the FET/Arduino diff --git a/Marlin/ultralcd_implementation_hitachi_HD44780.h b/Marlin/ultralcd_implementation_hitachi_HD44780.h index aa94b93ec..81195d21e 100644 --- a/Marlin/ultralcd_implementation_hitachi_HD44780.h +++ b/Marlin/ultralcd_implementation_hitachi_HD44780.h @@ -11,7 +11,19 @@ #define LCD_CLASS LiquidCrystalRus #else #ifdef LCD_I2C + #if LCD_I2C_TYPE = 0 + #define LCD_I2C_PIN_BL 3 + #define LCD_I2C_PIN_EN 2 + #define LCD_I2C_PIN_RW 1 + #define LCD_I2C_PIN_RS 0 + #define LCD_I2C_PIN_D4 4 + #define LCD_I2C_PIN_D5 5 + #define LCD_I2C_PIN_D6 6 + #define LCD_I2C_PIN_D7 7 + #endif + #include + #include #include #define LCD_CLASS LiquidCrystal_I2C #else @@ -32,7 +44,7 @@ #define LCD_STR_ARROW_RIGHT "\x7E" /* from the default character set */ #ifdef LCD_I2C - LCD_CLASS lcd(LCD_I2C_ADDRESS, LCD_WIDTH, LCD_HEIGHT, LCD_I2C_TYPE); //address, columns, rows, type + LCD_CLASS lcd(LCD_I2C_ADDRESS,LCD_I2C_PIN_EN,LCD_I2C_PIN_RW,LCD_I2C_PIN_RS,LCD_I2C_PIN_D4,LCD_I2C_PIN_D5,LCD_I2C_PIN_D6,LCD_I2C_PIN_D7); #else LCD_CLASS lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7); //RS,Enable,D4,D5,D6,D7 #endif @@ -122,11 +134,15 @@ static void lcd_implementation_init() B00000, B00000 }; //thanks Sonny Mounicou + #ifdef LCD_I2C - lcd.init(); - #else - lcd.begin(LCD_WIDTH, LCD_HEIGHT); + #ifdef LCD_I2C_PIN_BL + lcd.setBacklightPin(LCD_I2C_PIN_BL,POSITIVE); + lcd.setBacklight(HIGH); + #endif #endif + + lcd.begin(LCD_WIDTH, LCD_HEIGHT); lcd.createChar(LCD_STR_BEDTEMP[0], bedTemp); lcd.createChar(LCD_STR_DEGREE[0], degree); lcd.createChar(LCD_STR_THERMOMETER[0], thermometer); From 1292d735baa8106996d7c2b545e0f4470624375d Mon Sep 17 00:00:00 2001 From: Robert F-C Date: Thu, 28 Feb 2013 02:04:51 +1100 Subject: [PATCH 06/14] Converge all I2C LCD branches (PANELOLU2, VIKI & PCF8575) This includes refactoring the buttons code to remove a large amount of non-pin dependent duplication from pins.h. --- Marlin/Configuration.h | 61 +- Marlin/Marlin.pde | 16 +- Marlin/Marlin_main.cpp | 22 +- Marlin/pins.h | 105 +- Marlin/ultralcd.cpp | 9 + Marlin/ultralcd.h | 21 +- .../ultralcd_implementation_hitachi_HD44780.h | 1205 ++++++++++------- 7 files changed, 765 insertions(+), 674 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index d47b24cc4..e88515b5e 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -306,12 +306,21 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th // please keep turned on if you can. //#define EEPROM_CHITCHAT +// Preheat Constants +#define PLA_PREHEAT_HOTEND_TEMP 180 +#define PLA_PREHEAT_HPB_TEMP 70 +#define PLA_PREHEAT_FAN_SPEED 255 // Insert Value between 0 and 255 + +#define ABS_PREHEAT_HOTEND_TEMP 240 +#define ABS_PREHEAT_HPB_TEMP 100 +#define ABS_PREHEAT_FAN_SPEED 255 // Insert Value between 0 and 255 + //LCD and SD support //#define ULTRA_LCD //general lcd support, also 16x2 //#define SDSUPPORT // Enable SD Card Support in Hardware Console //#define ULTIMAKERCONTROLLER //as available from the ultimaker online store. -//#define ULTIPANEL //the ultipanel as on thingiverse +#define ULTIPANEL //the ultipanel as on thingiverse // The RepRapDiscount Smart Controller (white PCB) // http://reprap.org/wiki/RepRapDiscount_Smart_Controller @@ -327,15 +336,42 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th #define NEWPANEL #endif -// Preheat Constants -#define PLA_PREHEAT_HOTEND_TEMP 180 -#define PLA_PREHEAT_HPB_TEMP 70 -#define PLA_PREHEAT_FAN_SPEED 255 // Insert Value between 0 and 255 +// I2C PANELS -#define ABS_PREHEAT_HOTEND_TEMP 240 -#define ABS_PREHEAT_HPB_TEMP 100 -#define ABS_PREHEAT_FAN_SPEED 255 // Insert Value between 0 and 255 +#define LCD_I2C_SAINSMART_YWROBOT +#ifdef LCD_I2C_SAINSMART_YWROBOT + // This uses the LiquidCrystal_I2C library ( https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home ) + // Make sure it is placed in the Arduino libraries directory. + #define LCD_I2C_TYPE_PCF8575 + #define ULTIPANEL + #define NEWPANEL + #define LCD_I2C_ADDRESS 0x27 // I2C Address of the port expander +#endif +// PANELOLU2 LCD with status LEDs, separate encoder and click inputs +//#define LCD_I2C_PANELOLU2 +#ifdef LCD_I2C_PANELOLU2 + // This uses the LiquidTWI2 library ( https://github.com/lincomatic/LiquidTWI2 ). + // Make sure it is placed in the Arduino libraries directory. + #define LCD_I2C_TYPE_MCP23017 + #define ULTIPANEL + #define NEWPANEL + #define LCD_I2C_ADDRESS 0x20 + #define LCD_HAS_I2C_BUZZ //comment out to disable buzzer on LCD + #define LCD_HAS_STATUS_INDICATORS +#endif + +// VIKI LCD with status LEDs, integrated click & L/R/U/P buttons, separate encoder inputs +//#define LCD_I2C_VIKI +#ifdef LCD_I2C_VIKI + // This uses the LiquidTWI2 library (https://github.com/lincomatic/LiquidTWI2). + // Make sure it is placed in the Arduino libraries directory. + #define LCD_I2C_TYPE_MCP23017 + #define ULTIPANEL + #define NEWPANEL + #define LCD_I2C_ADDRESS 0x20 + #define LCD_HAS_STATUS_INDICATORS +#endif #ifdef ULTIPANEL // #define NEWPANEL //enable this if you have a click-encoder panel @@ -351,15 +387,6 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th #endif #endif -//The LCD is attached via an I2C port expander. -//#define LCD_I2C -#ifdef LCD_I2C - // Port Expander Type - 0=PCF8574 sainsmart/ywrobot - #define LCD_I2C_TYPE 0 - // I2C Address of the port expander - #define LCD_I2C_ADDRESS 0x27 -#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/Marlin.pde b/Marlin/Marlin.pde index 6602f6c86..93a6504cb 100644 --- a/Marlin/Marlin.pde +++ b/Marlin/Marlin.pde @@ -36,7 +36,21 @@ #ifdef ULTRA_LCD #ifdef LCD_I2C #include - #include + #if defined(LCD_I2C_TYPE_PCF8575) + #include + #elif defined(LCD_I2C_TYPE_MCP23017) + #ifdef PANELOLU2 + #undef PANELOLU2 + #include + #ifndef PANELOLU2 + #error You must uncomment #define PANELOLU2 in LiquidTWI2.h for LiquidTWI2.cpp to compile correctly + #endif + #else + #include + #endif + #else + #error Unknown I2C LCD type + #endif #else #include #endif diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 39efdf454..2f2d449c9 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -124,7 +124,7 @@ // M500 - stores paramters in EEPROM // 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. -// M503 - print the current settings (from memory not from eeprom) +// M503 - print the current settings (from memory not from eeprom) // M540 - Use S[0|1] to enable or disable the stop SD card print on endstop hit (requires ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) // M600 - Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal] // M907 - Set digital trimpot motor current using axis codes. @@ -853,13 +853,13 @@ void process_commands() previous_millis_cmd = millis(); if (codenum > 0){ codenum += millis(); // keep track of when we started waiting - while(millis() < codenum && !LCD_CLICKED){ + while(millis() < codenum && !lcd_clicked()){ manage_heater(); manage_inactivity(); lcd_update(); } }else{ - while(!LCD_CLICKED){ + while(!lcd_clicked()){ manage_heater(); manage_inactivity(); lcd_update(); @@ -1499,13 +1499,13 @@ void process_commands() { Config_PrintSettings(); } - break; - #ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED - case 540: - { - if(code_seen('S')) abort_on_endstop_hit = code_value() > 0; - } - break; + break; + #ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED + case 540: + { + if(code_seen('S')) abort_on_endstop_hit = code_value() > 0; + } + break; #endif #ifdef FILAMENTCHANGEENABLE case 600: //Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal] @@ -1592,7 +1592,7 @@ void process_commands() delay(100); LCD_ALERTMESSAGEPGM(MSG_FILAMENTCHANGE); uint8_t cnt=0; - while(!LCD_CLICKED){ + while(!lcd_clicked()){ cnt++; manage_heater(); manage_inactivity(); diff --git a/Marlin/pins.h b/Marlin/pins.h index 41aae2e22..d81b3abb6 100644 --- a/Marlin/pins.h +++ b/Marlin/pins.h @@ -290,15 +290,6 @@ #define BTN_EN1 11 #define BTN_EN2 10 #define BTN_ENC 12 //the click - - #define BLEN_C 2 - #define BLEN_B 1 - #define BLEN_A 0 - - #define encrot0 0 - #define encrot1 2 - #define encrot2 3 - #define encrot3 1 #endif /**************************************************************************************** @@ -384,16 +375,6 @@ #ifdef ULTRA_LCD #ifdef NEWPANEL - //encoder rotation values - #define encrot0 0 - #define encrot1 2 - #define encrot2 3 - #define encrot3 1 - - #define BLEN_A 0 - #define BLEN_B 1 - #define BLEN_C 2 - #define LCD_PINS_RS 16 #define LCD_PINS_ENABLE 17 #define LCD_PINS_D4 23 @@ -427,7 +408,7 @@ #else //old style panel with shift register //arduino pin witch triggers an piezzo beeper - #define BEEPER 33 No Beeper added + #define BEEPER 33 // No Beeper added //buttons are attached to a shift register // Not wired this yet @@ -442,25 +423,6 @@ #define LCD_PINS_D5 25 #define LCD_PINS_D6 27 #define LCD_PINS_D7 29 - - //encoder rotation values - #define encrot0 0 - #define encrot1 2 - #define encrot2 3 - #define encrot3 1 - - - //bits in the shift register that carry the buttons for: - // left up center down right red - #define BL_LE 7 - #define BL_UP 6 - #define BL_MI 5 - #define BL_DW 4 - #define BL_RI 3 - #define BL_ST 2 - - #define BLEN_B 1 - #define BLEN_A 0 #endif #endif //ULTRA_LCD @@ -735,23 +697,12 @@ #define LCD_PINS_D7 27 //The encoder and click button - #define BTN_EN1 11 //must be a hardware interrupt pin - #define BTN_EN2 10 //must be hardware interrupt pin + #define BTN_EN1 11 + #define BTN_EN2 10 #define BTN_ENC 16 //the switch //not connected to a pin - #define SDCARDDETECT -1 - - //from the same bit in the RAMPS Newpanel define - //encoder rotation values - #define encrot0 0 - #define encrot1 2 - #define encrot2 3 - #define encrot3 1 - - #define BLEN_C 2 - #define BLEN_B 1 - #define BLEN_A 0 - + #define SDCARDDETECT -1 + #endif //Newpanel #endif //Ultipanel @@ -834,17 +785,8 @@ #define BTN_EN2 42 #define BTN_ENC 19 //the click - #define BLEN_C 2 - #define BLEN_B 1 - #define BLEN_A 0 - #define SDCARDDETECT 38 - //encoder rotation values - #define encrot0 0 - #define encrot1 2 - #define encrot2 3 - #define encrot3 1 #else //old style panel with shift register //arduino pin witch triggers an piezzo beeper #define BEEPER 18 @@ -861,33 +803,8 @@ #define LCD_PINS_D5 21 #define LCD_PINS_D6 20 #define LCD_PINS_D7 19 - - //encoder rotation values - #ifndef ULTIMAKERCONTROLLER - #define encrot0 0 - #define encrot1 2 - #define encrot2 3 - #define encrot3 1 - #else - #define encrot0 0 - #define encrot1 1 - #define encrot2 3 - #define encrot3 2 - - #endif - + #define SDCARDDETECT -1 - //bits in the shift register that carry the buttons for: - // left up center down right red - #define BL_LE 7 - #define BL_UP 6 - #define BL_MI 5 - #define BL_DW 4 - #define BL_RI 3 - #define BL_ST 2 - - #define BLEN_B 1 - #define BLEN_A 0 #endif #endif //ULTRA_LCD @@ -1455,17 +1372,7 @@ #define BTN_EN2 64 #define BTN_ENC 43 //the click - #define BLEN_C 2 - #define BLEN_B 1 - #define BLEN_A 0 - #define SDCARDDETECT -1 // Ramps does not use this port - - //encoder rotation values - #define encrot0 0 - #define encrot1 2 - #define encrot2 3 - #define encrot3 1 #endif #endif //ULTRA_LCD diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index db2d2766c..8e223ed00 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -714,6 +714,10 @@ void lcd_update() lcd_buttons_update(); + #ifdef LCD_HAS_EXTRA_BUTTONS + buttons |= lcd_read_extra_buttons(); // buttons which take too long to read in interrupt context + #endif + #if (SDCARDDETECT > -1) if((IS_SD_INSERTED != lcd_oldcardstatus)) { @@ -858,6 +862,11 @@ void lcd_buttons_update() } #endif//ULTIPANEL +bool lcd_clicked() +{ + return LCD_CLICKED; +} + /********************************/ /** Float conversion utilities **/ /********************************/ diff --git a/Marlin/ultralcd.h b/Marlin/ultralcd.h index df7746a1a..40116d762 100644 --- a/Marlin/ultralcd.h +++ b/Marlin/ultralcd.h @@ -20,7 +20,6 @@ #ifdef ULTIPANEL void lcd_buttons_update(); - extern volatile uint8_t buttons; //the last checked buttons in a bit array. #else FORCE_INLINE void lcd_buttons_update() {} #endif @@ -33,25 +32,7 @@ extern int absPreheatHPBTemp; extern int absPreheatFanSpeed; - #ifdef NEWPANEL - #define EN_C (1< - #include - #include - #define LCD_CLASS LiquidCrystal_I2C - #else - #include - #define LCD_CLASS LiquidCrystal - #endif -#endif - -/* Custom characters defined in the first 8 characters of the LCD */ -#define LCD_STR_BEDTEMP "\x00" -#define LCD_STR_DEGREE "\x01" -#define LCD_STR_THERMOMETER "\x02" -#define LCD_STR_UPLEVEL "\x03" -#define LCD_STR_REFRESH "\x04" -#define LCD_STR_FOLDER "\x05" -#define LCD_STR_FEEDRATE "\x06" -#define LCD_STR_CLOCK "\x07" -#define LCD_STR_ARROW_RIGHT "\x7E" /* from the default character set */ - -#ifdef LCD_I2C - LCD_CLASS lcd(LCD_I2C_ADDRESS,LCD_I2C_PIN_EN,LCD_I2C_PIN_RW,LCD_I2C_PIN_RS,LCD_I2C_PIN_D4,LCD_I2C_PIN_D5,LCD_I2C_PIN_D6,LCD_I2C_PIN_D7); -#else - LCD_CLASS lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7); //RS,Enable,D4,D5,D6,D7 -#endif - -static void lcd_implementation_init() -{ - byte bedTemp[8] = - { - B00000, - B11111, - B10101, - B10001, - B10101, - B11111, - B00000, - B00000 - }; //thanks Sonny Mounicou - byte degree[8] = - { - B01100, - B10010, - B10010, - B01100, - B00000, - B00000, - B00000, - B00000 - }; - byte thermometer[8] = - { - B00100, - B01010, - B01010, - B01010, - B01010, - B10001, - B10001, - B01110 - }; - byte uplevel[8]={ - B00100, - B01110, - B11111, - B00100, - B11100, - B00000, - B00000, - B00000 - }; //thanks joris - byte refresh[8]={ - B00000, - B00110, - B11001, - B11000, - B00011, - B10011, - B01100, - B00000, - }; //thanks joris - byte folder [8]={ - B00000, - B11100, - B11111, - B10001, - B10001, - B11111, - B00000, - B00000 - }; //thanks joris - byte feedrate [8]={ - B11100, - B10000, - B11000, - B10111, - B00101, - B00110, - B00101, - B00000 - }; //thanks Sonny Mounicou - byte clock [8]={ - B00000, - B01110, - B10011, - B10101, - B10001, - B01110, - B00000, - B00000 - }; //thanks Sonny Mounicou - - #ifdef LCD_I2C - #ifdef LCD_I2C_PIN_BL - lcd.setBacklightPin(LCD_I2C_PIN_BL,POSITIVE); - lcd.setBacklight(HIGH); - #endif - #endif - - lcd.begin(LCD_WIDTH, LCD_HEIGHT); - lcd.createChar(LCD_STR_BEDTEMP[0], bedTemp); - lcd.createChar(LCD_STR_DEGREE[0], degree); - lcd.createChar(LCD_STR_THERMOMETER[0], thermometer); - lcd.createChar(LCD_STR_UPLEVEL[0], uplevel); - lcd.createChar(LCD_STR_REFRESH[0], refresh); - lcd.createChar(LCD_STR_FOLDER[0], folder); - lcd.createChar(LCD_STR_FEEDRATE[0], feedrate); - lcd.createChar(LCD_STR_CLOCK[0], clock); - lcd.clear(); -} -static void lcd_implementation_clear() -{ - lcd.clear(); -} -/* Arduino < 1.0.0 is missing a function to print PROGMEM strings, so we need to implement our own */ -static void lcd_printPGM(const char* str) -{ - char c; - while((c = pgm_read_byte(str++)) != '\0') - { - lcd.write(c); - } -} -/* -Possible status screens: -16x2 |0123456789012345| - |000/000 B000/000| - |Status line.....| - -16x4 |0123456789012345| - |000/000 B000/000| - |SD100% Z000.0| - |F100% T--:--| - |Status line.....| - -20x2 |01234567890123456789| - |T000/000D B000/000D | - |Status line.........| - -20x4 |01234567890123456789| - |T000/000D B000/000D | - |X+000.0 Y+000.0 Z+000.0| - |F100% SD100% T--:--| - |Status line.........| - -20x4 |01234567890123456789| - |T000/000D B000/000D | - |T000/000D Z000.0| - |F100% SD100% T--:--| - |Status line.........| -*/ -static void lcd_implementation_status_screen() -{ - int tHotend=int(degHotend(0) + 0.5); - int tTarget=int(degTargetHotend(0) + 0.5); - -#if LCD_WIDTH < 20 - lcd.setCursor(0, 0); - lcd.print(itostr3(tHotend)); - lcd.print('/'); - lcd.print(itostr3left(tTarget)); - -# if EXTRUDERS > 1 || TEMP_SENSOR_BED != 0 - //If we have an 2nd extruder or heated bed, show that in the top right corner - lcd.setCursor(8, 0); -# if EXTRUDERS > 1 - tHotend = int(degHotend(1) + 0.5); - tTarget = int(degTargetHotend(1) + 0.5); - lcd.print(LCD_STR_THERMOMETER[0]); -# else//Heated bed - tHotend=int(degBed() + 0.5); - tTarget=int(degTargetBed() + 0.5); - lcd.print(LCD_STR_BEDTEMP[0]); -# endif - lcd.print(itostr3(tHotend)); - lcd.print('/'); - lcd.print(itostr3left(tTarget)); -# endif//EXTRUDERS > 1 || TEMP_SENSOR_BED != 0 - -#else//LCD_WIDTH > 19 - lcd.setCursor(0, 0); - lcd.print(LCD_STR_THERMOMETER[0]); - lcd.print(itostr3(tHotend)); - lcd.print('/'); - lcd.print(itostr3left(tTarget)); - lcd_printPGM(PSTR(LCD_STR_DEGREE " ")); - if (tTarget < 10) - lcd.print(' '); - -# if EXTRUDERS > 1 || TEMP_SENSOR_BED != 0 - //If we have an 2nd extruder or heated bed, show that in the top right corner - lcd.setCursor(10, 0); -# if EXTRUDERS > 1 - tHotend = int(degHotend(1) + 0.5); - tTarget = int(degTargetHotend(1) + 0.5); - lcd.print(LCD_STR_THERMOMETER[0]); -# else//Heated bed - tHotend=int(degBed() + 0.5); - tTarget=int(degTargetBed() + 0.5); - lcd.print(LCD_STR_BEDTEMP[0]); -# endif - lcd.print(itostr3(tHotend)); - lcd.print('/'); - lcd.print(itostr3left(tTarget)); - lcd_printPGM(PSTR(LCD_STR_DEGREE " ")); - if (tTarget < 10) - lcd.print(' '); -# endif//EXTRUDERS > 1 || TEMP_SENSOR_BED != 0 -#endif//LCD_WIDTH > 19 - -#if LCD_HEIGHT > 2 -//Lines 2 for 4 line LCD -# if LCD_WIDTH < 20 -# ifdef SDSUPPORT - lcd.setCursor(0, 2); - lcd_printPGM(PSTR("SD")); - if (IS_SD_PRINTING) - lcd.print(itostr3(card.percentDone())); - else - lcd_printPGM(PSTR("---")); - lcd.print('%'); -# endif//SDSUPPORT -# else//LCD_WIDTH > 19 -# if EXTRUDERS > 1 && TEMP_SENSOR_BED != 0 - //If we both have a 2nd extruder and a heated bed, show the heated bed temp on the 2nd line on the left, as the first line is filled with extruder temps - tHotend=int(degBed() + 0.5); - tTarget=int(degTargetBed() + 0.5); - - lcd.setCursor(0, 1); - lcd.print(LCD_STR_BEDTEMP[0]); - lcd.print(itostr3(tHotend)); - lcd.print('/'); - lcd.print(itostr3left(tTarget)); - lcd_printPGM(PSTR(LCD_STR_DEGREE " ")); - if (tTarget < 10) - lcd.print(' '); -# else - lcd.setCursor(0,1); - lcd.print('X'); - lcd.print(ftostr3(current_position[X_AXIS])); - lcd_printPGM(PSTR(" Y")); - lcd.print(ftostr3(current_position[Y_AXIS])); -# endif//EXTRUDERS > 1 || TEMP_SENSOR_BED != 0 -# endif//LCD_WIDTH > 19 - lcd.setCursor(LCD_WIDTH - 8, 1); - lcd.print('Z'); - lcd.print(ftostr32(current_position[Z_AXIS])); -#endif//LCD_HEIGHT > 2 - -#if LCD_HEIGHT > 3 - lcd.setCursor(0, 2); - lcd.print(LCD_STR_FEEDRATE[0]); - lcd.print(itostr3(feedmultiply)); - lcd.print('%'); -# if LCD_WIDTH > 19 -# ifdef SDSUPPORT - lcd.setCursor(7, 2); - lcd_printPGM(PSTR("SD")); - if (IS_SD_PRINTING) - lcd.print(itostr3(card.percentDone())); - else - lcd_printPGM(PSTR("---")); - lcd.print('%'); -# endif//SDSUPPORT -# endif//LCD_WIDTH > 19 - lcd.setCursor(LCD_WIDTH - 6, 2); - lcd.print(LCD_STR_CLOCK[0]); - if(starttime != 0) - { - uint16_t time = millis()/60000 - starttime/60000; - lcd.print(itostr2(time/60)); - lcd.print(':'); - lcd.print(itostr2(time%60)); - }else{ - lcd_printPGM(PSTR("--:--")); - } -#endif - - //Status message line on the last line - lcd.setCursor(0, LCD_HEIGHT - 1); - lcd.print(lcd_status_message); -} -static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, char pre_char, char post_char) -{ - char c; - //Use all characters in narrow LCDs - #if LCD_WIDTH < 20 - uint8_t n = LCD_WIDTH - 1 - 1; - #else - uint8_t n = LCD_WIDTH - 1 - 2; - #endif - lcd.setCursor(0, row); - lcd.print(pre_char); - while((c = pgm_read_byte(pstr)) != '\0') - { - lcd.print(c); - pstr++; - n--; - } - while(n--) - lcd.print(' '); - lcd.print(post_char); - lcd.print(' '); -} -static void lcd_implementation_drawmenu_setting_edit_generic(uint8_t row, const char* pstr, char pre_char, char* data) -{ - char c; - //Use all characters in narrow LCDs - #if LCD_WIDTH < 20 - uint8_t n = LCD_WIDTH - 1 - 1 - strlen(data); - #else - uint8_t n = LCD_WIDTH - 1 - 2 - strlen(data); - #endif - lcd.setCursor(0, row); - lcd.print(pre_char); - while((c = pgm_read_byte(pstr)) != '\0') - { - lcd.print(c); - pstr++; - n--; - } - lcd.print(':'); - while(n--) - lcd.print(' '); - lcd.print(data); -} -static void lcd_implementation_drawmenu_setting_edit_generic_P(uint8_t row, const char* pstr, char pre_char, const char* data) -{ - char c; - //Use all characters in narrow LCDs - #if LCD_WIDTH < 20 - uint8_t n = LCD_WIDTH - 1 - 1 - strlen_P(data); - #else - uint8_t n = LCD_WIDTH - 1 - 2 - strlen_P(data); - #endif - lcd.setCursor(0, row); - lcd.print(pre_char); - while((c = pgm_read_byte(pstr)) != '\0') - { - lcd.print(c); - pstr++; - n--; - } - lcd.print(':'); - while(n--) - lcd.print(' '); - lcd_printPGM(data); -} -#define lcd_implementation_drawmenu_setting_edit_int3_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', itostr3(*(data))) -#define lcd_implementation_drawmenu_setting_edit_int3(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', itostr3(*(data))) -#define lcd_implementation_drawmenu_setting_edit_float3_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr3(*(data))) -#define lcd_implementation_drawmenu_setting_edit_float3(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr3(*(data))) -#define lcd_implementation_drawmenu_setting_edit_float32_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr32(*(data))) -#define lcd_implementation_drawmenu_setting_edit_float32(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr32(*(data))) -#define lcd_implementation_drawmenu_setting_edit_float5_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr5(*(data))) -#define lcd_implementation_drawmenu_setting_edit_float5(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data))) -#define lcd_implementation_drawmenu_setting_edit_float52_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr52(*(data))) -#define lcd_implementation_drawmenu_setting_edit_float52(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr52(*(data))) -#define lcd_implementation_drawmenu_setting_edit_float51_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr51(*(data))) -#define lcd_implementation_drawmenu_setting_edit_float51(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr51(*(data))) -#define lcd_implementation_drawmenu_setting_edit_long5_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr5(*(data))) -#define lcd_implementation_drawmenu_setting_edit_long5(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data))) -#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)) -#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)) -void lcd_implementation_drawedit(const char* pstr, char* value) -{ - lcd.setCursor(1, 1); - lcd_printPGM(pstr); - lcd.print(':'); - #if LCD_WIDTH < 20 - lcd.setCursor(LCD_WIDTH - strlen(value), 1); - #else - lcd.setCursor(LCD_WIDTH -1 - strlen(value), 1); - #endif - lcd.print(value); -} -static void lcd_implementation_drawmenu_sdfile_selected(uint8_t row, const char* pstr, const char* filename, char* longFilename) -{ - char c; - uint8_t n = LCD_WIDTH - 1; - lcd.setCursor(0, row); - lcd.print('>'); - if (longFilename[0] != '\0') - { - filename = longFilename; - longFilename[LCD_WIDTH-1] = '\0'; - } - while((c = *filename) != '\0') - { - lcd.print(c); - filename++; - n--; - } - while(n--) - lcd.print(' '); -} -static void lcd_implementation_drawmenu_sdfile(uint8_t row, const char* pstr, const char* filename, char* longFilename) -{ - char c; - uint8_t n = LCD_WIDTH - 1; - lcd.setCursor(0, row); - lcd.print(' '); - if (longFilename[0] != '\0') - { - filename = longFilename; - longFilename[LCD_WIDTH-1] = '\0'; - } - while((c = *filename) != '\0') - { - lcd.print(c); - filename++; - n--; - } - while(n--) - lcd.print(' '); -} -static void lcd_implementation_drawmenu_sddirectory_selected(uint8_t row, const char* pstr, const char* filename, char* longFilename) -{ - char c; - uint8_t n = LCD_WIDTH - 2; - lcd.setCursor(0, row); - lcd.print('>'); - lcd.print(LCD_STR_FOLDER[0]); - if (longFilename[0] != '\0') - { - filename = longFilename; - longFilename[LCD_WIDTH-2] = '\0'; - } - while((c = *filename) != '\0') - { - lcd.print(c); - filename++; - n--; - } - while(n--) - lcd.print(' '); -} -static void lcd_implementation_drawmenu_sddirectory(uint8_t row, const char* pstr, const char* filename, char* longFilename) -{ - char c; - uint8_t n = LCD_WIDTH - 2; - lcd.setCursor(0, row); - lcd.print(' '); - lcd.print(LCD_STR_FOLDER[0]); - if (longFilename[0] != '\0') - { - filename = longFilename; - longFilename[LCD_WIDTH-2] = '\0'; - } - while((c = *filename) != '\0') - { - lcd.print(c); - filename++; - n--; - } - while(n--) - lcd.print(' '); -} -#define lcd_implementation_drawmenu_back_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0]) -#define lcd_implementation_drawmenu_back(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', LCD_STR_UPLEVEL[0]) -#define lcd_implementation_drawmenu_submenu_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, '>', LCD_STR_ARROW_RIGHT[0]) -#define lcd_implementation_drawmenu_submenu(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', LCD_STR_ARROW_RIGHT[0]) -#define lcd_implementation_drawmenu_gcode_selected(row, pstr, gcode) lcd_implementation_drawmenu_generic(row, pstr, '>', ' ') -#define lcd_implementation_drawmenu_gcode(row, pstr, gcode) lcd_implementation_drawmenu_generic(row, pstr, ' ', ' ') -#define lcd_implementation_drawmenu_function_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, '>', ' ') -#define lcd_implementation_drawmenu_function(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', ' ') - -static void lcd_implementation_quick_feedback() -{ -#if BEEPER > -1 - SET_OUTPUT(BEEPER); - for(int8_t i=0;i<10;i++) - { - WRITE(BEEPER,HIGH); - delay(3); - WRITE(BEEPER,LOW); - delay(3); - } -#endif -} -#endif//ULTRA_LCD_IMPLEMENTATION_HITACHI_HD44780_H +#ifndef ULTRA_LCD_IMPLEMENTATION_HITACHI_HD44780_H +#define ULTRA_LCD_IMPLEMENTATION_HITACHI_HD44780_H + +/** +* Implementation of the LCD display routines for a hitachi HD44780 display. These are common LCD character displays. +* When selecting the rusian language, a slightly different LCD implementation is used to handle UTF8 characters. +**/ + +// Declare LCD class to use +#if defined(LCD_I2C_TYPE_PCF8575) + // note: these are virtual pins on the PCF8575 controller not Arduino pins + #define LCD_I2C_PIN_BL 3 + #define LCD_I2C_PIN_EN 2 + #define LCD_I2C_PIN_RW 1 + #define LCD_I2C_PIN_RS 0 + #define LCD_I2C_PIN_D4 4 + #define LCD_I2C_PIN_D5 5 + #define LCD_I2C_PIN_D6 6 + #define LCD_I2C_PIN_D7 7 + + #include + #include + #include + #define LCD_CLASS LiquidCrystal_I2C + LCD_CLASS lcd(LCD_I2C_ADDRESS,LCD_I2C_PIN_EN,LCD_I2C_PIN_RW,LCD_I2C_PIN_RS,LCD_I2C_PIN_D4,LCD_I2C_PIN_D5,LCD_I2C_PIN_D6,LCD_I2C_PIN_D7); +#elif defined(LCD_I2C_TYPE_MCP23017) + //for the LED indicators (which maybe mapped to different things in lcd_implementation_update_indicators()) + #define LED_A 0x04 //100 + #define LED_B 0x02 //010 + #define LED_C 0x01 //001 + + #include + #include + #define LCD_CLASS LiquidTWI2 + LCD_CLASS lcd(LCD_I2C_ADDRESS); //An alternative I2C master address can be used in place of "0" +#elif defined(LCD_I2C_TYPE_MCP23008) + #include + #include + #define LCD_CLASS LiquidTWI2 + LCD_CLASS lcd(LCD_I2C_ADDRESS); //An alternative I2C master address can be used in place of "0" +#else + #if LANGUAGE_CHOICE == 6 + #include "LiquidCrystalRus.h" + #define LCD_CLASS LiquidCrystalRus + #else + #include + #define LCD_CLASS LiquidCrystal + #endif + LCD_CLASS lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7); //RS,Enable,D4,D5,D6,D7 +#endif + +extern volatile uint8_t buttons; //the last checked buttons in a bit array. + +// provide default button bitmask and encoder definitions (note this is not pin or motherboard specific) +#ifdef LCD_I2C_VIKI + //encoder rotation values + #define encrot0 0 + #define encrot1 2 + #define encrot2 3 + #define encrot3 1 + + #define BLEN_C 2 + #define BLEN_B 1 + #define BLEN_A 0 + + #define EN_C (1< 1 || TEMP_SENSOR_BED != 0 + //If we have an 2nd extruder or heated bed, show that in the top right corner + lcd.setCursor(8, 0); +# if EXTRUDERS > 1 + tHotend = int(degHotend(1) + 0.5); + tTarget = int(degTargetHotend(1) + 0.5); + lcd.print(LCD_STR_THERMOMETER[0]); +# else//Heated bed + tHotend=int(degBed() + 0.5); + tTarget=int(degTargetBed() + 0.5); + lcd.print(LCD_STR_BEDTEMP[0]); +# endif + lcd.print(itostr3(tHotend)); + lcd.print('/'); + lcd.print(itostr3left(tTarget)); +# endif//EXTRUDERS > 1 || TEMP_SENSOR_BED != 0 + +#else//LCD_WIDTH > 19 + lcd.setCursor(0, 0); + lcd.print(LCD_STR_THERMOMETER[0]); + lcd.print(itostr3(tHotend)); + lcd.print('/'); + lcd.print(itostr3left(tTarget)); + lcd_printPGM(PSTR(LCD_STR_DEGREE " ")); + if (tTarget < 10) + lcd.print(' '); + +# if EXTRUDERS > 1 || TEMP_SENSOR_BED != 0 + //If we have an 2nd extruder or heated bed, show that in the top right corner + lcd.setCursor(10, 0); +# if EXTRUDERS > 1 + tHotend = int(degHotend(1) + 0.5); + tTarget = int(degTargetHotend(1) + 0.5); + lcd.print(LCD_STR_THERMOMETER[0]); +# else//Heated bed + tHotend=int(degBed() + 0.5); + tTarget=int(degTargetBed() + 0.5); + lcd.print(LCD_STR_BEDTEMP[0]); +# endif + lcd.print(itostr3(tHotend)); + lcd.print('/'); + lcd.print(itostr3left(tTarget)); + lcd_printPGM(PSTR(LCD_STR_DEGREE " ")); + if (tTarget < 10) + lcd.print(' '); +# endif//EXTRUDERS > 1 || TEMP_SENSOR_BED != 0 +#endif//LCD_WIDTH > 19 + +#if LCD_HEIGHT > 2 +//Lines 2 for 4 line LCD +# if LCD_WIDTH < 20 +# ifdef SDSUPPORT + lcd.setCursor(0, 2); + lcd_printPGM(PSTR("SD")); + if (IS_SD_PRINTING) + lcd.print(itostr3(card.percentDone())); + else + lcd_printPGM(PSTR("---")); + lcd.print('%'); +# endif//SDSUPPORT +# else//LCD_WIDTH > 19 +# if EXTRUDERS > 1 && TEMP_SENSOR_BED != 0 + //If we both have a 2nd extruder and a heated bed, show the heated bed temp on the 2nd line on the left, as the first line is filled with extruder temps + tHotend=int(degBed() + 0.5); + tTarget=int(degTargetBed() + 0.5); + + lcd.setCursor(0, 1); + lcd.print(LCD_STR_BEDTEMP[0]); + lcd.print(itostr3(tHotend)); + lcd.print('/'); + lcd.print(itostr3left(tTarget)); + lcd_printPGM(PSTR(LCD_STR_DEGREE " ")); + if (tTarget < 10) + lcd.print(' '); +# else + lcd.setCursor(0,1); + lcd.print('X'); + lcd.print(ftostr3(current_position[X_AXIS])); + lcd_printPGM(PSTR(" Y")); + lcd.print(ftostr3(current_position[Y_AXIS])); +# endif//EXTRUDERS > 1 || TEMP_SENSOR_BED != 0 +# endif//LCD_WIDTH > 19 + lcd.setCursor(LCD_WIDTH - 8, 1); + lcd.print('Z'); + lcd.print(ftostr32(current_position[Z_AXIS])); +#endif//LCD_HEIGHT > 2 + +#if LCD_HEIGHT > 3 + lcd.setCursor(0, 2); + lcd.print(LCD_STR_FEEDRATE[0]); + lcd.print(itostr3(feedmultiply)); + lcd.print('%'); +# if LCD_WIDTH > 19 +# ifdef SDSUPPORT + lcd.setCursor(7, 2); + lcd_printPGM(PSTR("SD")); + if (IS_SD_PRINTING) + lcd.print(itostr3(card.percentDone())); + else + lcd_printPGM(PSTR("---")); + lcd.print('%'); +# endif//SDSUPPORT +# endif//LCD_WIDTH > 19 + lcd.setCursor(LCD_WIDTH - 6, 2); + lcd.print(LCD_STR_CLOCK[0]); + if(starttime != 0) + { + uint16_t time = millis()/60000 - starttime/60000; + lcd.print(itostr2(time/60)); + lcd.print(':'); + lcd.print(itostr2(time%60)); + }else{ + lcd_printPGM(PSTR("--:--")); + } +#endif + + //Status message line on the last line + lcd.setCursor(0, LCD_HEIGHT - 1); + lcd.print(lcd_status_message); +#ifdef LCD_HAS_STATUS_INDICATORS + lcd_implementation_update_indicators(); +#endif +} +static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, char pre_char, char post_char) +{ + char c; + //Use all characters in narrow LCDs + #if LCD_WIDTH < 20 + uint8_t n = LCD_WIDTH - 1 - 1; + #else + uint8_t n = LCD_WIDTH - 1 - 2; + #endif + lcd.setCursor(0, row); + lcd.print(pre_char); + while((c = pgm_read_byte(pstr)) != '\0') + { + lcd.print(c); + pstr++; + n--; + } + while(n--) + lcd.print(' '); + lcd.print(post_char); + lcd.print(' '); +} +static void lcd_implementation_drawmenu_setting_edit_generic(uint8_t row, const char* pstr, char pre_char, char* data) +{ + char c; + //Use all characters in narrow LCDs + #if LCD_WIDTH < 20 + uint8_t n = LCD_WIDTH - 1 - 1 - strlen(data); + #else + uint8_t n = LCD_WIDTH - 1 - 2 - strlen(data); + #endif + lcd.setCursor(0, row); + lcd.print(pre_char); + while((c = pgm_read_byte(pstr)) != '\0') + { + lcd.print(c); + pstr++; + n--; + } + lcd.print(':'); + while(n--) + lcd.print(' '); + lcd.print(data); +} +static void lcd_implementation_drawmenu_setting_edit_generic_P(uint8_t row, const char* pstr, char pre_char, const char* data) +{ + char c; + //Use all characters in narrow LCDs + #if LCD_WIDTH < 20 + uint8_t n = LCD_WIDTH - 1 - 1 - strlen_P(data); + #else + uint8_t n = LCD_WIDTH - 1 - 2 - strlen_P(data); + #endif + lcd.setCursor(0, row); + lcd.print(pre_char); + while((c = pgm_read_byte(pstr)) != '\0') + { + lcd.print(c); + pstr++; + n--; + } + lcd.print(':'); + while(n--) + lcd.print(' '); + lcd_printPGM(data); +} +#define lcd_implementation_drawmenu_setting_edit_int3_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', itostr3(*(data))) +#define lcd_implementation_drawmenu_setting_edit_int3(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', itostr3(*(data))) +#define lcd_implementation_drawmenu_setting_edit_float3_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr3(*(data))) +#define lcd_implementation_drawmenu_setting_edit_float3(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr3(*(data))) +#define lcd_implementation_drawmenu_setting_edit_float32_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr32(*(data))) +#define lcd_implementation_drawmenu_setting_edit_float32(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr32(*(data))) +#define lcd_implementation_drawmenu_setting_edit_float5_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr5(*(data))) +#define lcd_implementation_drawmenu_setting_edit_float5(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data))) +#define lcd_implementation_drawmenu_setting_edit_float52_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr52(*(data))) +#define lcd_implementation_drawmenu_setting_edit_float52(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr52(*(data))) +#define lcd_implementation_drawmenu_setting_edit_float51_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr51(*(data))) +#define lcd_implementation_drawmenu_setting_edit_float51(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr51(*(data))) +#define lcd_implementation_drawmenu_setting_edit_long5_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr5(*(data))) +#define lcd_implementation_drawmenu_setting_edit_long5(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data))) +#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)) +#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)) +void lcd_implementation_drawedit(const char* pstr, char* value) +{ + lcd.setCursor(1, 1); + lcd_printPGM(pstr); + lcd.print(':'); + #if LCD_WIDTH < 20 + lcd.setCursor(LCD_WIDTH - strlen(value), 1); + #else + lcd.setCursor(LCD_WIDTH -1 - strlen(value), 1); + #endif + lcd.print(value); +} +static void lcd_implementation_drawmenu_sdfile_selected(uint8_t row, const char* pstr, const char* filename, char* longFilename) +{ + char c; + uint8_t n = LCD_WIDTH - 1; + lcd.setCursor(0, row); + lcd.print('>'); + if (longFilename[0] != '\0') + { + filename = longFilename; + longFilename[LCD_WIDTH-1] = '\0'; + } + while((c = *filename) != '\0') + { + lcd.print(c); + filename++; + n--; + } + while(n--) + lcd.print(' '); +} +static void lcd_implementation_drawmenu_sdfile(uint8_t row, const char* pstr, const char* filename, char* longFilename) +{ + char c; + uint8_t n = LCD_WIDTH - 1; + lcd.setCursor(0, row); + lcd.print(' '); + if (longFilename[0] != '\0') + { + filename = longFilename; + longFilename[LCD_WIDTH-1] = '\0'; + } + while((c = *filename) != '\0') + { + lcd.print(c); + filename++; + n--; + } + while(n--) + lcd.print(' '); +} +static void lcd_implementation_drawmenu_sddirectory_selected(uint8_t row, const char* pstr, const char* filename, char* longFilename) +{ + char c; + uint8_t n = LCD_WIDTH - 2; + lcd.setCursor(0, row); + lcd.print('>'); + lcd.print(LCD_STR_FOLDER[0]); + if (longFilename[0] != '\0') + { + filename = longFilename; + longFilename[LCD_WIDTH-2] = '\0'; + } + while((c = *filename) != '\0') + { + lcd.print(c); + filename++; + n--; + } + while(n--) + lcd.print(' '); +} +static void lcd_implementation_drawmenu_sddirectory(uint8_t row, const char* pstr, const char* filename, char* longFilename) +{ + char c; + uint8_t n = LCD_WIDTH - 2; + lcd.setCursor(0, row); + lcd.print(' '); + lcd.print(LCD_STR_FOLDER[0]); + if (longFilename[0] != '\0') + { + filename = longFilename; + longFilename[LCD_WIDTH-2] = '\0'; + } + while((c = *filename) != '\0') + { + lcd.print(c); + filename++; + n--; + } + while(n--) + lcd.print(' '); +} +#define lcd_implementation_drawmenu_back_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0]) +#define lcd_implementation_drawmenu_back(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', LCD_STR_UPLEVEL[0]) +#define lcd_implementation_drawmenu_submenu_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, '>', LCD_STR_ARROW_RIGHT[0]) +#define lcd_implementation_drawmenu_submenu(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', LCD_STR_ARROW_RIGHT[0]) +#define lcd_implementation_drawmenu_gcode_selected(row, pstr, gcode) lcd_implementation_drawmenu_generic(row, pstr, '>', ' ') +#define lcd_implementation_drawmenu_gcode(row, pstr, gcode) lcd_implementation_drawmenu_generic(row, pstr, ' ', ' ') +#define lcd_implementation_drawmenu_function_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, '>', ' ') +#define lcd_implementation_drawmenu_function(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', ' ') + +static void lcd_implementation_quick_feedback() +{ +#ifdef LCD_HAS_I2C_BUZZ + lcd.buzz(300,4000); +#elif defined(BEEPER) && BEEPER > -1 + SET_OUTPUT(BEEPER); + for(int8_t i=0;i<10;i++) + { + WRITE(BEEPER,HIGH); + delay(3); + WRITE(BEEPER,LOW); + delay(3); + } +#endif +} + +#ifdef LCD_HAS_STATUS_INDICATORS +static void lcd_implementation_update_indicators() +{ + #if defined(LCD_I2C_PANELOLU2) || defined(LCD_I2C_VIKI) + //set the LEDS - referred to as backlights by the LiquidTWI2 library + static uint8_t ledsprev = 0; + uint8_t leds = 0; + if (isHeatingBed()) leds |= LED_A; + if (isHeatingHotend(0)) leds |= LED_B; + if (fanSpeed) leds |= LED_C; + #if EXTRUDERS > 1 + if (isHeatingHotend(1)) leds |= LED_C; + #endif + if (leds != ledsprev) { + lcd.setBacklight(leds); + ledsprev = leds; + } + #endif +} +#endif + +#ifdef LCD_HAS_EXTRA_BUTTONS +static uint8_t lcd_read_extra_buttons() +{ + #ifdef LCD_I2C_TYPE_MCP23017 + // the I2C button bit positions are shifted by three bits from the native LiquidTWI2 position + // this is potentially too slow to call inside interrupt context + return lcd.readButtons() << B_I2C_BTN_OFFSET; + #endif +} +#endif + +#endif//ULTRA_LCD_IMPLEMENTATION_HITACHI_HD44780_H From 839bef6d5d436055c6cef051b6b32a84bd18d05a Mon Sep 17 00:00:00 2001 From: Robert F-C Date: Thu, 28 Feb 2013 02:32:20 +1100 Subject: [PATCH 07/14] Fix Configuration.h file to not define LCDs be default. Also fix compile time check in Marlin.pde --- Marlin/Configuration.h | 7 +++++-- Marlin/Marlin.pde | 3 +-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index e88515b5e..2cc80dd30 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -320,7 +320,7 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th //#define SDSUPPORT // Enable SD Card Support in Hardware Console //#define ULTIMAKERCONTROLLER //as available from the ultimaker online store. -#define ULTIPANEL //the ultipanel as on thingiverse +//#define ULTIPANEL //the ultipanel as on thingiverse // The RepRapDiscount Smart Controller (white PCB) // http://reprap.org/wiki/RepRapDiscount_Smart_Controller @@ -338,11 +338,12 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th // I2C PANELS -#define LCD_I2C_SAINSMART_YWROBOT +//#define LCD_I2C_SAINSMART_YWROBOT #ifdef LCD_I2C_SAINSMART_YWROBOT // This uses the LiquidCrystal_I2C library ( https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home ) // Make sure it is placed in the Arduino libraries directory. #define LCD_I2C_TYPE_PCF8575 + #define LCD_I2C #define ULTIPANEL #define NEWPANEL #define LCD_I2C_ADDRESS 0x27 // I2C Address of the port expander @@ -354,6 +355,7 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th // This uses the LiquidTWI2 library ( https://github.com/lincomatic/LiquidTWI2 ). // Make sure it is placed in the Arduino libraries directory. #define LCD_I2C_TYPE_MCP23017 + #define LCD_I2C #define ULTIPANEL #define NEWPANEL #define LCD_I2C_ADDRESS 0x20 @@ -367,6 +369,7 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th // This uses the LiquidTWI2 library (https://github.com/lincomatic/LiquidTWI2). // Make sure it is placed in the Arduino libraries directory. #define LCD_I2C_TYPE_MCP23017 + #define LCD_I2C #define ULTIPANEL #define NEWPANEL #define LCD_I2C_ADDRESS 0x20 diff --git a/Marlin/Marlin.pde b/Marlin/Marlin.pde index 93a6504cb..082bb0694 100644 --- a/Marlin/Marlin.pde +++ b/Marlin/Marlin.pde @@ -39,8 +39,7 @@ #if defined(LCD_I2C_TYPE_PCF8575) #include #elif defined(LCD_I2C_TYPE_MCP23017) - #ifdef PANELOLU2 - #undef PANELOLU2 + #ifdef LCD_I2C_PANELOLU2 #include #ifndef PANELOLU2 #error You must uncomment #define PANELOLU2 in LiquidTWI2.h for LiquidTWI2.cpp to compile correctly From 6beb42cdf65971aeca93868305ed93ae6ed732eb Mon Sep 17 00:00:00 2001 From: Robert F-C Date: Fri, 1 Mar 2013 01:17:07 +1100 Subject: [PATCH 08/14] Attempt to address Bernhard's comments Refactor configuration to try to make items clearer (what defines a panel vs what is user changeable). --- Marlin/Configuration.h | 27 +-- Marlin/Marlin.pde | 21 +- Marlin/ultralcd.cpp | 14 +- .../ultralcd_implementation_hitachi_HD44780.h | 214 +++++++++--------- 4 files changed, 134 insertions(+), 142 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 2cc80dd30..492a32361 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -336,44 +336,39 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th #define NEWPANEL #endif -// I2C PANELS +//I2C PANELS //#define LCD_I2C_SAINSMART_YWROBOT #ifdef LCD_I2C_SAINSMART_YWROBOT // This uses the LiquidCrystal_I2C library ( https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home ) // Make sure it is placed in the Arduino libraries directory. #define LCD_I2C_TYPE_PCF8575 - #define LCD_I2C - #define ULTIPANEL - #define NEWPANEL #define LCD_I2C_ADDRESS 0x27 // I2C Address of the port expander + #define NEWPANEL + #define ULTIPANEL #endif -// PANELOLU2 LCD with status LEDs, separate encoder and click inputs +//PANELOLU2 LCD with status LEDs, separate encoder and click inputs //#define LCD_I2C_PANELOLU2 #ifdef LCD_I2C_PANELOLU2 // This uses the LiquidTWI2 library ( https://github.com/lincomatic/LiquidTWI2 ). // Make sure it is placed in the Arduino libraries directory. #define LCD_I2C_TYPE_MCP23017 - #define LCD_I2C - #define ULTIPANEL + #define LCD_I2C_ADDRESS 0x20 // I2C Address of the port expander + #define LCD_USE_I2C_BUZZER //comment out to disable buzzer on LCD #define NEWPANEL - #define LCD_I2C_ADDRESS 0x20 - #define LCD_HAS_I2C_BUZZ //comment out to disable buzzer on LCD - #define LCD_HAS_STATUS_INDICATORS + #define ULTIPANEL #endif -// VIKI LCD with status LEDs, integrated click & L/R/U/P buttons, separate encoder inputs +//VIKI LCD with status LEDs, integrated click & L/R/U/P buttons, separate encoder inputs //#define LCD_I2C_VIKI #ifdef LCD_I2C_VIKI // This uses the LiquidTWI2 library (https://github.com/lincomatic/LiquidTWI2). // Make sure it is placed in the Arduino libraries directory. - #define LCD_I2C_TYPE_MCP23017 - #define LCD_I2C - #define ULTIPANEL + #define LCD_I2C_TYPE_MCP23017 + #define LCD_I2C_ADDRESS 0x20 // I2C Address of the port expander #define NEWPANEL - #define LCD_I2C_ADDRESS 0x20 - #define LCD_HAS_STATUS_INDICATORS + #define ULTIPANEL #endif #ifdef ULTIPANEL diff --git a/Marlin/Marlin.pde b/Marlin/Marlin.pde index 082bb0694..a3ebf4756 100644 --- a/Marlin/Marlin.pde +++ b/Marlin/Marlin.pde @@ -34,21 +34,14 @@ #include "pins.h" #ifdef ULTRA_LCD - #ifdef LCD_I2C + #if defined(LCD_I2C_TYPE_PCF8575) #include - #if defined(LCD_I2C_TYPE_PCF8575) - #include - #elif defined(LCD_I2C_TYPE_MCP23017) - #ifdef LCD_I2C_PANELOLU2 - #include - #ifndef PANELOLU2 - #error You must uncomment #define PANELOLU2 in LiquidTWI2.h for LiquidTWI2.cpp to compile correctly - #endif - #else - #include - #endif - #else - #error Unknown I2C LCD type + #include + #elif defined(LCD_I2C_TYPE_MCP23017) || defined(LCD_I2C_TYPE_MCP23008) + #include + #include + #if defined(LCD_I2C_PANELOLU2) && !defined(PANELOLU2) + #error You must uncomment "#define PANELOLU2" in LiquidTWI2.h for LiquidTWI2.cpp to compile correctly #endif #else #include diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 8e223ed00..ed259196d 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -705,7 +705,9 @@ void lcd_init() lcd_oldcardstatus = IS_SD_INSERTED; #endif//(SDCARDDETECT > -1) lcd_buttons_update(); +#ifdef ULTIPANEL encoderDiff = 0; +#endif } void lcd_update() @@ -714,8 +716,8 @@ void lcd_update() lcd_buttons_update(); - #ifdef LCD_HAS_EXTRA_BUTTONS - buttons |= lcd_read_extra_buttons(); // buttons which take too long to read in interrupt context + #ifdef LCD_HAS_SLOW_BUTTONS + buttons |= lcd_implementation_read_slow_buttons(); // buttons which take too long to read in interrupt context #endif #if (SDCARDDETECT > -1) @@ -751,8 +753,12 @@ void lcd_update() if (LCD_CLICKED) timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS; #endif//ULTIPANEL - (*currentMenu)(); + +#ifdef LCD_HAS_STATUS_INDICATORS + lcd_implementation_update_indicators(); +#endif + #ifdef ULTIPANEL if(timeoutToStatus < millis() && currentMenu != lcd_status_screen) { @@ -860,12 +866,12 @@ void lcd_buttons_update() } lastEncoderBits = enc; } -#endif//ULTIPANEL bool lcd_clicked() { return LCD_CLICKED; } +#endif//ULTIPANEL /********************************/ /** Float conversion utilities **/ diff --git a/Marlin/ultralcd_implementation_hitachi_HD44780.h b/Marlin/ultralcd_implementation_hitachi_HD44780.h index 651b1484c..a606f642d 100644 --- a/Marlin/ultralcd_implementation_hitachi_HD44780.h +++ b/Marlin/ultralcd_implementation_hitachi_HD44780.h @@ -6,9 +6,96 @@ * When selecting the rusian language, a slightly different LCD implementation is used to handle UTF8 characters. **/ -// Declare LCD class to use +extern volatile uint8_t buttons; //the last checked buttons in a bit array. + +//////////////////////////////////// +// Setup button and encode mappings for each panel (into 'buttons' variable) +// +// This is just to map common functions (across different panels) onto the same +// macro name. The mapping is independent of whether the button is directly connected or +// via a shift/i2c register. + +#ifdef ULTIPANEL +// All Ultipanels might have an encoder - so this is always be mapped onto first two bits +#define BLEN_B 1 +#define BLEN_A 0 + +#define EN_B (1< #define LCD_CLASS LiquidCrystal_I2C LCD_CLASS lcd(LCD_I2C_ADDRESS,LCD_I2C_PIN_EN,LCD_I2C_PIN_RW,LCD_I2C_PIN_RS,LCD_I2C_PIN_D4,LCD_I2C_PIN_D5,LCD_I2C_PIN_D6,LCD_I2C_PIN_D7); + #elif defined(LCD_I2C_TYPE_MCP23017) //for the LED indicators (which maybe mapped to different things in lcd_implementation_update_indicators()) #define LED_A 0x04 //100 #define LED_B 0x02 //010 - #define LED_C 0x01 //001 + #define LED_C 0x01 //001 + + #define LCD_HAS_STATUS_INDICATORS #include #include #define LCD_CLASS LiquidTWI2 - LCD_CLASS lcd(LCD_I2C_ADDRESS); //An alternative I2C master address can be used in place of "0" + LCD_CLASS lcd(LCD_I2C_ADDRESS); + #elif defined(LCD_I2C_TYPE_MCP23008) #include #include #define LCD_CLASS LiquidTWI2 - LCD_CLASS lcd(LCD_I2C_ADDRESS); //An alternative I2C master address can be used in place of "0" + LCD_CLASS lcd(LCD_I2C_ADDRESS); + #else + // Standard directly connected LCD implementations #if LANGUAGE_CHOICE == 6 #include "LiquidCrystalRus.h" #define LCD_CLASS LiquidCrystalRus @@ -49,101 +142,6 @@ LCD_CLASS lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7); //RS,Enable,D4,D5,D6,D7 #endif -extern volatile uint8_t buttons; //the last checked buttons in a bit array. - -// provide default button bitmask and encoder definitions (note this is not pin or motherboard specific) -#ifdef LCD_I2C_VIKI - //encoder rotation values - #define encrot0 0 - #define encrot1 2 - #define encrot2 3 - #define encrot3 1 - - #define BLEN_C 2 - #define BLEN_B 1 - #define BLEN_A 0 - - #define EN_C (1< -1 SET_OUTPUT(BEEPER); @@ -665,12 +663,12 @@ static void lcd_implementation_update_indicators() } #endif -#ifdef LCD_HAS_EXTRA_BUTTONS -static uint8_t lcd_read_extra_buttons() +#ifdef LCD_HAS_SLOW_BUTTONS +static uint8_t lcd_implementation_read_slow_buttons() { #ifdef LCD_I2C_TYPE_MCP23017 - // the I2C button bit positions are shifted by three bits from the native LiquidTWI2 position - // this is potentially too slow to call inside interrupt context + // Reading these buttons this is likely to be too slow to call inside interrupt context + // so they are called during normal lcd_update return lcd.readButtons() << B_I2C_BTN_OFFSET; #endif } From 7bad72359c5f2c78096810fffbf809bb8c30b58b Mon Sep 17 00:00:00 2001 From: Robert F-C Date: Sun, 3 Mar 2013 18:47:50 +1100 Subject: [PATCH 09/14] Support encoder click on PANELOLU2 being read through I2C This change also handles the case where the pause/stop/restart button on the VIKI is not used. Make LCD I2C buzz sound the same as the normal buzz (300ms is too long for quick feedback). --- Marlin/Configuration.h | 14 ++++--- Marlin/ultralcd.cpp | 6 ++- .../ultralcd_implementation_hitachi_HD44780.h | 42 ++++++++++++++----- 3 files changed, 45 insertions(+), 17 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 492a32361..ba20c6c04 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -351,8 +351,10 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th //PANELOLU2 LCD with status LEDs, separate encoder and click inputs //#define LCD_I2C_PANELOLU2 #ifdef LCD_I2C_PANELOLU2 - // This uses the LiquidTWI2 library ( https://github.com/lincomatic/LiquidTWI2 ). - // Make sure it is placed in the Arduino libraries directory. + // This uses the LiquidTWI2 library ( https://github.com/lincomatic/LiquidTWI2 ) + // Make sure it is placed in the Arduino or Sketchbook libraries directory. + // Note: The PANELOLU2 encoder click input can either be directly connected to a pin + // (if BTN_ENC defined to != -1) or read through I2C (when BTN_ENC == -1). #define LCD_I2C_TYPE_MCP23017 #define LCD_I2C_ADDRESS 0x20 // I2C Address of the port expander #define LCD_USE_I2C_BUZZER //comment out to disable buzzer on LCD @@ -360,11 +362,13 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th #define ULTIPANEL #endif -//VIKI LCD with status LEDs, integrated click & L/R/U/P buttons, separate encoder inputs +//Panucatt VIKI LCD with status LEDs, integrated click & L/R/U/P buttons, separate encoder inputs //#define LCD_I2C_VIKI #ifdef LCD_I2C_VIKI - // This uses the LiquidTWI2 library (https://github.com/lincomatic/LiquidTWI2). - // Make sure it is placed in the Arduino libraries directory. + // This uses the LiquidTWI2 library ( https://github.com/lincomatic/LiquidTWI2 ) + // Make sure it is placed in the Arduino or Sketchbook libraries directory. + // Note: The pause/stop/resume LCD button pin should be connected to the Arduino + // BTN_ENC pin (or set BTN_ENC to -1 if not used) #define LCD_I2C_TYPE_MCP23017 #define LCD_I2C_ADDRESS 0x20 // I2C Address of the port expander #define NEWPANEL diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index ed259196d..523fcd461 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -686,11 +686,13 @@ void lcd_init() #ifdef NEWPANEL pinMode(BTN_EN1,INPUT); pinMode(BTN_EN2,INPUT); - pinMode(BTN_ENC,INPUT); pinMode(SDCARDDETECT,INPUT); WRITE(BTN_EN1,HIGH); WRITE(BTN_EN2,HIGH); + #if defined(BTN_ENC) && BTN_ENC > -1 + pinMode(BTN_ENC,INPUT); WRITE(BTN_ENC,HIGH); + #endif #else pinMode(SHIFT_CLK,OUTPUT); pinMode(SHIFT_LD,OUTPUT); @@ -809,8 +811,10 @@ void lcd_buttons_update() uint8_t newbutton=0; if(READ(BTN_EN1)==0) newbutton|=EN_A; if(READ(BTN_EN2)==0) newbutton|=EN_B; + #if defined(BTN_ENC) && BTN_ENC > -1 if((blocking_enc -1 + // encoder click is directly connected + #define BLEN_C 2 + #define EN_C (1< -1 + // the pause/stop/restart button is connected to BTN_ENC when used + #define B_ST (EN_C) // Map the pause/stop/resume button into its normalized functional name + #define LCD_CLICKED (buttons&(B_MI|B_RI|B_ST)) // pause/stop button also acts as click until we implement proper pause/stop. + #else + #define LCD_CLICKED (buttons&(B_MI|B_RI)) + #endif // I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update #define LCD_HAS_SLOW_BUTTONS +#elif defined(LCD_I2C_PANELOLU2) + #if !defined(BTN_ENC) || BTN_ENC == -1 + // encoder click is connected through I2C (rather than directly connected) + #define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C) + + #define B_MI (ENCODER_C< -1 SET_OUTPUT(BEEPER); for(int8_t i=0;i<10;i++) From 9322c408c68bc7c5edd88bf674f9f85fa0d2ffc5 Mon Sep 17 00:00:00 2001 From: Robert F-C Date: Sun, 24 Mar 2013 18:19:58 +1100 Subject: [PATCH 10/14] Updated for LiquidTWI2 library version 1.2.3 The new version of the library means that PANELOLU no longer needs to be defined in LiquidTWI.h (the library file can be used as is) and the new version of the library also enables the buzzer on the Panucatt VIKI panel. --- Marlin/Configuration.h | 14 ++++++++------ Marlin/Marlin.pde | 3 --- Marlin/ultralcd_implementation_hitachi_HD44780.h | 4 ++-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index ba20c6c04..71f0ca455 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -348,11 +348,12 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th #define ULTIPANEL #endif -//PANELOLU2 LCD with status LEDs, separate encoder and click inputs +// PANELOLU2 LCD with status LEDs, separate encoder and click inputs //#define LCD_I2C_PANELOLU2 #ifdef LCD_I2C_PANELOLU2 - // This uses the LiquidTWI2 library ( https://github.com/lincomatic/LiquidTWI2 ) - // Make sure it is placed in the Arduino or Sketchbook libraries directory. + // This uses the LiquidTWI2 library v1.2.3 or later ( https://github.com/lincomatic/LiquidTWI2 ) + // Make sure the LiquidTWI2 directory is placed in the Arduino or Sketchbook libraries subdirectory. + // (v1.2.3 no longer requires you to define PANELOLU in the LiquidTWI2.h library header file) // Note: The PANELOLU2 encoder click input can either be directly connected to a pin // (if BTN_ENC defined to != -1) or read through I2C (when BTN_ENC == -1). #define LCD_I2C_TYPE_MCP23017 @@ -362,15 +363,16 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th #define ULTIPANEL #endif -//Panucatt VIKI LCD with status LEDs, integrated click & L/R/U/P buttons, separate encoder inputs +// Panucatt VIKI LCD with status LEDs, integrated click & L/R/U/P buttons, separate encoder inputs //#define LCD_I2C_VIKI #ifdef LCD_I2C_VIKI - // This uses the LiquidTWI2 library ( https://github.com/lincomatic/LiquidTWI2 ) - // Make sure it is placed in the Arduino or Sketchbook libraries directory. + // This uses the LiquidTWI2 library v1.2.3 or later ( https://github.com/lincomatic/LiquidTWI2 ) + // Make sure the LiquidTWI2 directory is placed in the Arduino or Sketchbook libraries subdirectory. // Note: The pause/stop/resume LCD button pin should be connected to the Arduino // BTN_ENC pin (or set BTN_ENC to -1 if not used) #define LCD_I2C_TYPE_MCP23017 #define LCD_I2C_ADDRESS 0x20 // I2C Address of the port expander + #define LCD_USE_I2C_BUZZER //comment out to disable buzzer on LCD (requires LiquidTWI2 v1.2.3 or later) #define NEWPANEL #define ULTIPANEL #endif diff --git a/Marlin/Marlin.pde b/Marlin/Marlin.pde index a3ebf4756..f7442feb7 100644 --- a/Marlin/Marlin.pde +++ b/Marlin/Marlin.pde @@ -40,9 +40,6 @@ #elif defined(LCD_I2C_TYPE_MCP23017) || defined(LCD_I2C_TYPE_MCP23008) #include #include - #if defined(LCD_I2C_PANELOLU2) && !defined(PANELOLU2) - #error You must uncomment "#define PANELOLU2" in LiquidTWI2.h for LiquidTWI2.cpp to compile correctly - #endif #else #include #endif diff --git a/Marlin/ultralcd_implementation_hitachi_HD44780.h b/Marlin/ultralcd_implementation_hitachi_HD44780.h index c5d1e26c2..845cc33df 100644 --- a/Marlin/ultralcd_implementation_hitachi_HD44780.h +++ b/Marlin/ultralcd_implementation_hitachi_HD44780.h @@ -54,11 +54,11 @@ extern volatile uint8_t buttons; //the last checked buttons in a bit array. #define LCD_HAS_SLOW_BUTTONS #elif defined(LCD_I2C_PANELOLU2) + // encoder click can be read through I2C if not directly connected #if !defined(BTN_ENC) || BTN_ENC == -1 - // encoder click is connected through I2C (rather than directly connected) #define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C) - #define B_MI (ENCODER_C< Date: Mon, 29 Apr 2013 21:50:52 +1000 Subject: [PATCH 11/14] Add lcd_buzz function to ultralcd.h so that non-LCD code can make use of lcd's buzzer. Argument order of lcd_buzz was set to mirror that on tone(). Change default M300 frequency to something audible. --- Marlin/Marlin_main.cpp | 20 +++++++++++++------- Marlin/ultralcd.cpp | 7 +++++++ Marlin/ultralcd.h | 3 +++ 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 875795f7d..abe27d32b 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1446,16 +1446,20 @@ void process_commands() } break; - #if defined(LARGE_FLASH) && LARGE_FLASH == true && defined(BEEPER) && BEEPER > -1 + #if defined(LARGE_FLASH) && LARGE_FLASH == true case 300: // M300 { - int beepS = 1; + int beepS = 400; int beepP = 1000; if(code_seen('S')) beepS = code_value(); if(code_seen('P')) beepP = code_value(); - tone(BEEPER, beepS); - delay(beepP); - noTone(BEEPER); + #if defined(BEEPER) && BEEPER > -1 + tone(BEEPER, beepS); + delay(beepP); + noTone(BEEPER); + #elif defined(ULTRALCD) + lcd_buzz(beepS, beepP); + #endif } break; #endif // M300 @@ -1672,17 +1676,19 @@ void process_commands() manage_inactivity(); lcd_update(); - #if BEEPER > -1 if(cnt==0) { + #if defined(BEEPER) && BEEPER > -1 SET_OUTPUT(BEEPER); WRITE(BEEPER,HIGH); delay(3); WRITE(BEEPER,LOW); delay(3); - } + #else + lcd_buzz(1000/6,100); #endif + } } //return to normal diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index dafd2502a..2dae90a5d 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -946,6 +946,13 @@ void lcd_buttons_update() lastEncoderBits = enc; } +void lcd_buzz(long duration, uint16_t freq) +{ +#ifdef LCD_USE_I2C_BUZZER + lcd.buzz(duration,freq); +#endif +} + bool lcd_clicked() { return LCD_CLICKED; diff --git a/Marlin/ultralcd.h b/Marlin/ultralcd.h index d84c948bb..ed9c10978 100644 --- a/Marlin/ultralcd.h +++ b/Marlin/ultralcd.h @@ -34,6 +34,8 @@ extern int absPreheatHPBTemp; extern int absPreheatFanSpeed; + void lcd_buzz(long duration,uint16_t freq); + bool lcd_clicked(); #else //no lcd @@ -42,6 +44,7 @@ FORCE_INLINE void lcd_setstatus(const char* message) {} FORCE_INLINE void lcd_buttons_update() {} FORCE_INLINE void lcd_reset_alert_level() {} + FORCE_INLINE void lcd_buzz(long duration,uint16_t freq) {} #define LCD_MESSAGEPGM(x) #define LCD_ALERTMESSAGEPGM(x) From 1c127217df70ba25d0eb611688063c245fb2c36d Mon Sep 17 00:00:00 2001 From: Robert F-C Date: Mon, 29 Apr 2013 22:03:37 +1000 Subject: [PATCH 12/14] Make DOGLCD merge neater. --- Marlin/Marlin.pde | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Marlin/Marlin.pde b/Marlin/Marlin.pde index 8514216e6..e02803ceb 100644 --- a/Marlin/Marlin.pde +++ b/Marlin/Marlin.pde @@ -40,10 +40,7 @@ #elif defined(LCD_I2C_TYPE_MCP23017) || defined(LCD_I2C_TYPE_MCP23008) #include #include - #else - #include - #endif - #ifdef DOGLCD + #elif defined(DOGLCD) #include // library for graphics LCD by Oli Kraus (https://code.google.com/p/u8glib/) #else #include // library for character LCD From 015d0594b01c42a43be446e3ef2311e5ede845a1 Mon Sep 17 00:00:00 2001 From: Robert F-C Date: Sun, 12 May 2013 07:51:28 +1000 Subject: [PATCH 13/14] Optimize menu selection for Viki rotary encoder. The Viki LCD rotary encoder uses a different number of steps per rotation. This fixes the seeming "missed" steps when selecting a menu. --- Marlin/ultralcd.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 2dae90a5d..72404da03 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -76,7 +76,11 @@ static void menu_action_setting_edit_callback_float51(const char* pstr, float* p static void menu_action_setting_edit_callback_float52(const char* pstr, float* ptr, float minValue, float maxValue, menuFunc_t callbackFunc); static void menu_action_setting_edit_callback_long5(const char* pstr, unsigned long* ptr, unsigned long minValue, unsigned long maxValue, menuFunc_t callbackFunc); -#define ENCODER_STEPS_PER_MENU_ITEM 5 +#if !defined(LCD_I2C_VIKI) + #define ENCODER_STEPS_PER_MENU_ITEM 5 +#else + #define ENCODER_STEPS_PER_MENU_ITEM 2 // VIKI LCD rotary encoder uses a different number of steps per rotation +#endif /* Helper macros for menus */ #define START_MENU() do { \ From 4121311b9d13dc2d0c26f4b4c767c6b6952029c3 Mon Sep 17 00:00:00 2001 From: Robert F-C Date: Sat, 18 May 2013 22:30:42 +1000 Subject: [PATCH 14/14] Change to LCD status indicators The I2C LCD status indicators now indicate when the hotends or bed are turned on at all (rather than just when they are in their heating phase) --- .../ultralcd_implementation_hitachi_HD44780.h | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Marlin/ultralcd_implementation_hitachi_HD44780.h b/Marlin/ultralcd_implementation_hitachi_HD44780.h index 23fa8b421..d4e996741 100644 --- a/Marlin/ultralcd_implementation_hitachi_HD44780.h +++ b/Marlin/ultralcd_implementation_hitachi_HD44780.h @@ -298,12 +298,12 @@ static void lcd_implementation_init() #endif #elif defined(LCD_I2C_TYPE_MCP23017) - lcd.setMCPType(LTI_TYPE_MCP23017); + lcd.setMCPType(LTI_TYPE_MCP23017); lcd.begin(LCD_WIDTH, LCD_HEIGHT); lcd.setBacklight(0); //set all the LEDs off to begin with #elif defined(LCD_I2C_TYPE_MCP23008) - lcd.setMCPType(LTI_TYPE_MCP23008); + lcd.setMCPType(LTI_TYPE_MCP23008); lcd.begin(LCD_WIDTH, LCD_HEIGHT); #else @@ -497,9 +497,9 @@ static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, c char c; //Use all characters in narrow LCDs #if LCD_WIDTH < 20 - uint8_t n = LCD_WIDTH - 1 - 1; + uint8_t n = LCD_WIDTH - 1 - 1; #else - uint8_t n = LCD_WIDTH - 1 - 2; + uint8_t n = LCD_WIDTH - 1 - 2; #endif lcd.setCursor(0, row); lcd.print(pre_char); @@ -519,9 +519,9 @@ static void lcd_implementation_drawmenu_setting_edit_generic(uint8_t row, const char c; //Use all characters in narrow LCDs #if LCD_WIDTH < 20 - uint8_t n = LCD_WIDTH - 1 - 1 - strlen(data); + uint8_t n = LCD_WIDTH - 1 - 1 - strlen(data); #else - uint8_t n = LCD_WIDTH - 1 - 2 - strlen(data); + uint8_t n = LCD_WIDTH - 1 - 2 - strlen(data); #endif lcd.setCursor(0, row); lcd.print(pre_char); @@ -541,9 +541,9 @@ static void lcd_implementation_drawmenu_setting_edit_generic_P(uint8_t row, cons char c; //Use all characters in narrow LCDs #if LCD_WIDTH < 20 - uint8_t n = LCD_WIDTH - 1 - 1 - strlen_P(data); + uint8_t n = LCD_WIDTH - 1 - 1 - strlen_P(data); #else - uint8_t n = LCD_WIDTH - 1 - 2 - strlen_P(data); + uint8_t n = LCD_WIDTH - 1 - 2 - strlen_P(data); #endif lcd.setCursor(0, row); lcd.print(pre_char); @@ -600,9 +600,9 @@ void lcd_implementation_drawedit(const char* pstr, char* value) lcd_printPGM(pstr); lcd.print(':'); #if LCD_WIDTH < 20 - lcd.setCursor(LCD_WIDTH - strlen(value), 1); + lcd.setCursor(LCD_WIDTH - strlen(value), 1); #else - lcd.setCursor(LCD_WIDTH -1 - strlen(value), 1); + lcd.setCursor(LCD_WIDTH -1 - strlen(value), 1); #endif lcd.print(value); } @@ -720,11 +720,11 @@ static void lcd_implementation_update_indicators() //set the LEDS - referred to as backlights by the LiquidTWI2 library static uint8_t ledsprev = 0; uint8_t leds = 0; - if (isHeatingBed()) leds |= LED_A; - if (isHeatingHotend(0)) leds |= LED_B; + if (target_temperature_bed > 0) leds |= LED_A; + if (target_temperature[0] > 0) leds |= LED_B; if (fanSpeed) leds |= LED_C; #if EXTRUDERS > 1 - if (isHeatingHotend(1)) leds |= LED_C; + if (target_temperature[1] > 0) leds |= LED_C; #endif if (leds != ledsprev) { lcd.setBacklight(leds);