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.
master
Robert F-C 12 years ago
parent 67710df9f3
commit 1292d735ba

@ -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. // please keep turned on if you can.
//#define EEPROM_CHITCHAT //#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 //LCD and SD support
//#define ULTRA_LCD //general lcd support, also 16x2 //#define ULTRA_LCD //general lcd support, also 16x2
//#define SDSUPPORT // Enable SD Card Support in Hardware Console //#define SDSUPPORT // Enable SD Card Support in Hardware Console
//#define ULTIMAKERCONTROLLER //as available from the ultimaker online store. //#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) // The RepRapDiscount Smart Controller (white PCB)
// http://reprap.org/wiki/RepRapDiscount_Smart_Controller // 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 #define NEWPANEL
#endif #endif
// Preheat Constants // I2C PANELS
#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 LCD_I2C_SAINSMART_YWROBOT
#define ABS_PREHEAT_HPB_TEMP 100 #ifdef LCD_I2C_SAINSMART_YWROBOT
#define ABS_PREHEAT_FAN_SPEED 255 // Insert Value between 0 and 255 // 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 #ifdef ULTIPANEL
// #define NEWPANEL //enable this if you have a click-encoder panel // #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
#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 // Increase the FAN pwm frequency. Removes the PWM noise but increases heating in the FET/Arduino
//#define FAST_PWM_FAN //#define FAST_PWM_FAN

@ -36,7 +36,21 @@
#ifdef ULTRA_LCD #ifdef ULTRA_LCD
#ifdef LCD_I2C #ifdef LCD_I2C
#include <Wire.h> #include <Wire.h>
#include <LiquidCrystal_I2C.h> #if defined(LCD_I2C_TYPE_PCF8575)
#include <LiquidCrystal_I2C.h>
#elif defined(LCD_I2C_TYPE_MCP23017)
#ifdef PANELOLU2
#undef PANELOLU2
#include <LiquidTWI2.h>
#ifndef PANELOLU2
#error You must uncomment #define PANELOLU2 in LiquidTWI2.h for LiquidTWI2.cpp to compile correctly
#endif
#else
#include <LiquidTWI2.h>
#endif
#else
#error Unknown I2C LCD type
#endif
#else #else
#include <LiquidCrystal.h> #include <LiquidCrystal.h>
#endif #endif

@ -124,7 +124,7 @@
// M500 - stores paramters in EEPROM // M500 - stores paramters in EEPROM
// M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily). // 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. // 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) // 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] // 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. // M907 - Set digital trimpot motor current using axis codes.
@ -853,13 +853,13 @@ void process_commands()
previous_millis_cmd = millis(); previous_millis_cmd = millis();
if (codenum > 0){ if (codenum > 0){
codenum += millis(); // keep track of when we started waiting codenum += millis(); // keep track of when we started waiting
while(millis() < codenum && !LCD_CLICKED){ while(millis() < codenum && !lcd_clicked()){
manage_heater(); manage_heater();
manage_inactivity(); manage_inactivity();
lcd_update(); lcd_update();
} }
}else{ }else{
while(!LCD_CLICKED){ while(!lcd_clicked()){
manage_heater(); manage_heater();
manage_inactivity(); manage_inactivity();
lcd_update(); lcd_update();
@ -1499,13 +1499,13 @@ void process_commands()
{ {
Config_PrintSettings(); Config_PrintSettings();
} }
break; break;
#ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED #ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
case 540: case 540:
{ {
if(code_seen('S')) abort_on_endstop_hit = code_value() > 0; if(code_seen('S')) abort_on_endstop_hit = code_value() > 0;
} }
break; break;
#endif #endif
#ifdef FILAMENTCHANGEENABLE #ifdef FILAMENTCHANGEENABLE
case 600: //Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal] 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); delay(100);
LCD_ALERTMESSAGEPGM(MSG_FILAMENTCHANGE); LCD_ALERTMESSAGEPGM(MSG_FILAMENTCHANGE);
uint8_t cnt=0; uint8_t cnt=0;
while(!LCD_CLICKED){ while(!lcd_clicked()){
cnt++; cnt++;
manage_heater(); manage_heater();
manage_inactivity(); manage_inactivity();

@ -290,15 +290,6 @@
#define BTN_EN1 11 #define BTN_EN1 11
#define BTN_EN2 10 #define BTN_EN2 10
#define BTN_ENC 12 //the click #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 #endif
/**************************************************************************************** /****************************************************************************************
@ -384,16 +375,6 @@
#ifdef ULTRA_LCD #ifdef ULTRA_LCD
#ifdef NEWPANEL #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_RS 16
#define LCD_PINS_ENABLE 17 #define LCD_PINS_ENABLE 17
#define LCD_PINS_D4 23 #define LCD_PINS_D4 23
@ -427,7 +408,7 @@
#else //old style panel with shift register #else //old style panel with shift register
//arduino pin witch triggers an piezzo beeper //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 //buttons are attached to a shift register
// Not wired this yet // Not wired this yet
@ -442,25 +423,6 @@
#define LCD_PINS_D5 25 #define LCD_PINS_D5 25
#define LCD_PINS_D6 27 #define LCD_PINS_D6 27
#define LCD_PINS_D7 29 #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
#endif //ULTRA_LCD #endif //ULTRA_LCD
@ -735,23 +697,12 @@
#define LCD_PINS_D7 27 #define LCD_PINS_D7 27
//The encoder and click button //The encoder and click button
#define BTN_EN1 11 //must be a hardware interrupt pin #define BTN_EN1 11
#define BTN_EN2 10 //must be hardware interrupt pin #define BTN_EN2 10
#define BTN_ENC 16 //the switch #define BTN_ENC 16 //the switch
//not connected to a pin //not connected to a pin
#define SDCARDDETECT -1 #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
#endif //Newpanel #endif //Newpanel
#endif //Ultipanel #endif //Ultipanel
@ -834,17 +785,8 @@
#define BTN_EN2 42 #define BTN_EN2 42
#define BTN_ENC 19 //the click #define BTN_ENC 19 //the click
#define BLEN_C 2
#define BLEN_B 1
#define BLEN_A 0
#define SDCARDDETECT 38 #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 #else //old style panel with shift register
//arduino pin witch triggers an piezzo beeper //arduino pin witch triggers an piezzo beeper
#define BEEPER 18 #define BEEPER 18
@ -861,33 +803,8 @@
#define LCD_PINS_D5 21 #define LCD_PINS_D5 21
#define LCD_PINS_D6 20 #define LCD_PINS_D6 20
#define LCD_PINS_D7 19 #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 #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
#endif //ULTRA_LCD #endif //ULTRA_LCD
@ -1455,17 +1372,7 @@
#define BTN_EN2 64 #define BTN_EN2 64
#define BTN_ENC 43 //the click #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 #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
#endif //ULTRA_LCD #endif //ULTRA_LCD

@ -714,6 +714,10 @@ void lcd_update()
lcd_buttons_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 (SDCARDDETECT > -1)
if((IS_SD_INSERTED != lcd_oldcardstatus)) if((IS_SD_INSERTED != lcd_oldcardstatus))
{ {
@ -858,6 +862,11 @@ void lcd_buttons_update()
} }
#endif//ULTIPANEL #endif//ULTIPANEL
bool lcd_clicked()
{
return LCD_CLICKED;
}
/********************************/ /********************************/
/** Float conversion utilities **/ /** Float conversion utilities **/
/********************************/ /********************************/

@ -20,7 +20,6 @@
#ifdef ULTIPANEL #ifdef ULTIPANEL
void lcd_buttons_update(); void lcd_buttons_update();
extern volatile uint8_t buttons; //the last checked buttons in a bit array.
#else #else
FORCE_INLINE void lcd_buttons_update() {} FORCE_INLINE void lcd_buttons_update() {}
#endif #endif
@ -33,25 +32,7 @@
extern int absPreheatHPBTemp; extern int absPreheatHPBTemp;
extern int absPreheatFanSpeed; extern int absPreheatFanSpeed;
#ifdef NEWPANEL bool lcd_clicked();
#define EN_C (1<<BLEN_C)
#define EN_B (1<<BLEN_B)
#define EN_A (1<<BLEN_A)
#define LCD_CLICKED (buttons&EN_C)
#else
//atomatic, do not change
#define B_LE (1<<BL_LE)
#define B_UP (1<<BL_UP)
#define B_MI (1<<BL_MI)
#define B_DW (1<<BL_DW)
#define B_RI (1<<BL_RI)
#define B_ST (1<<BL_ST)
#define EN_B (1<<BLEN_B)
#define EN_A (1<<BLEN_A)
#define LCD_CLICKED ((buttons&B_MI)||(buttons&B_ST))
#endif//NEWPANEL
#else //no lcd #else //no lcd
FORCE_INLINE void lcd_update() {} FORCE_INLINE void lcd_update() {}

@ -1,526 +1,679 @@
#ifndef ULTRA_LCD_IMPLEMENTATION_HITACHI_HD44780_H #ifndef ULTRA_LCD_IMPLEMENTATION_HITACHI_HD44780_H
#define 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. * 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. * When selecting the rusian language, a slightly different LCD implementation is used to handle UTF8 characters.
**/ **/
#if LANGUAGE_CHOICE == 6 // Declare LCD class to use
#include "LiquidCrystalRus.h" #if defined(LCD_I2C_TYPE_PCF8575)
#define LCD_CLASS LiquidCrystalRus // note: these are virtual pins on the PCF8575 controller not Arduino pins
#else #define LCD_I2C_PIN_BL 3
#ifdef LCD_I2C #define LCD_I2C_PIN_EN 2
#if LCD_I2C_TYPE = 0 #define LCD_I2C_PIN_RW 1
#define LCD_I2C_PIN_BL 3 #define LCD_I2C_PIN_RS 0
#define LCD_I2C_PIN_EN 2 #define LCD_I2C_PIN_D4 4
#define LCD_I2C_PIN_RW 1 #define LCD_I2C_PIN_D5 5
#define LCD_I2C_PIN_RS 0 #define LCD_I2C_PIN_D6 6
#define LCD_I2C_PIN_D4 4 #define LCD_I2C_PIN_D7 7
#define LCD_I2C_PIN_D5 5
#define LCD_I2C_PIN_D6 6 #include <Wire.h>
#define LCD_I2C_PIN_D7 7 #include <LCD.h>
#endif #include <LiquidCrystal_I2C.h>
#define LCD_CLASS LiquidCrystal_I2C
#include <Wire.h> 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);
#include <LCD.h> #elif defined(LCD_I2C_TYPE_MCP23017)
#include <LiquidCrystal_I2C.h> //for the LED indicators (which maybe mapped to different things in lcd_implementation_update_indicators())
#define LCD_CLASS LiquidCrystal_I2C #define LED_A 0x04 //100
#else #define LED_B 0x02 //010
#include <LiquidCrystal.h> #define LED_C 0x01 //001
#define LCD_CLASS LiquidCrystal
#endif #include <Wire.h>
#endif #include <LiquidTWI2.h>
#define LCD_CLASS LiquidTWI2
/* Custom characters defined in the first 8 characters of the LCD */ LCD_CLASS lcd(LCD_I2C_ADDRESS); //An alternative I2C master address can be used in place of "0"
#define LCD_STR_BEDTEMP "\x00" #elif defined(LCD_I2C_TYPE_MCP23008)
#define LCD_STR_DEGREE "\x01" #include <Wire.h>
#define LCD_STR_THERMOMETER "\x02" #include <LiquidTWI2.h>
#define LCD_STR_UPLEVEL "\x03" #define LCD_CLASS LiquidTWI2
#define LCD_STR_REFRESH "\x04" LCD_CLASS lcd(LCD_I2C_ADDRESS); //An alternative I2C master address can be used in place of "0"
#define LCD_STR_FOLDER "\x05" #else
#define LCD_STR_FEEDRATE "\x06" #if LANGUAGE_CHOICE == 6
#define LCD_STR_CLOCK "\x07" #include "LiquidCrystalRus.h"
#define LCD_STR_ARROW_RIGHT "\x7E" /* from the default character set */ #define LCD_CLASS LiquidCrystalRus
#else
#ifdef LCD_I2C #include <LiquidCrystal.h>
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); #define LCD_CLASS LiquidCrystal
#else #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 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 #endif
static void lcd_implementation_init() extern volatile uint8_t buttons; //the last checked buttons in a bit array.
{
byte bedTemp[8] = // provide default button bitmask and encoder definitions (note this is not pin or motherboard specific)
{ #ifdef LCD_I2C_VIKI
B00000, //encoder rotation values
B11111, #define encrot0 0
B10101, #define encrot1 2
B10001, #define encrot2 3
B10101, #define encrot3 1
B11111,
B00000, #define BLEN_C 2
B00000 #define BLEN_B 1
}; //thanks Sonny Mounicou #define BLEN_A 0
byte degree[8] =
{ #define EN_C (1<<BLEN_C) // The stop/pause/resume button comes through BTN_ENC pin (for consistency with NEWPANEL code)
B01100, #define EN_B (1<<BLEN_B) // The two encoder pins are connected through BTN_EN1 and BTN_EN2
B10010, #define EN_A (1<<BLEN_A)
B10010,
B01100, #define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C)
B00000,
B00000, // button and encoder bit positions within 'buttons'
B00000, #define B_ST (EN_C) // The pause/stop/resume button is mapped to EN_C for consistency with NEWPANEL
B00000 #define B_LE (BUTTON_LEFT<<B_I2C_BTN_OFFSET) // The remaining buttons are I2C read buttons.
}; #define B_UP (BUTTON_UP<<B_I2C_BTN_OFFSET)
byte thermometer[8] = #define B_MI (BUTTON_SELECT<<B_I2C_BTN_OFFSET)
{ #define B_DW (BUTTON_DOWN<<B_I2C_BTN_OFFSET)
B00100, #define B_RI (BUTTON_RIGHT<<B_I2C_BTN_OFFSET)
B01010,
B01010, #define LCD_CLICKED (buttons&(B_MI|B_RI|B_ST)) // pause/stop button also acts as click until we implement proper pause/stop.
B01010,
B01010, // I2C buttons are likely to take too long to read inside interrupt context and so we read them during lcd_update
B10001, #define LCD_HAS_EXTRA_BUTTONS
B10001,
B01110 #elif defined(NEWPANEL)
}; //from the same bit in the RAMPS Newpanel define
byte uplevel[8]={ //encoder rotation values
B00100, #define encrot0 0
B01110, #define encrot1 2
B11111, #define encrot2 3
B00100, #define encrot3 1
B11100,
B00000, #define BLEN_C 2
B00000, #define BLEN_B 1
B00000 #define BLEN_A 0
}; //thanks joris
byte refresh[8]={ #define EN_C (1<<BLEN_C)
B00000, #define EN_B (1<<BLEN_B)
B00110, #define EN_A (1<<BLEN_A)
B11001,
B11000, #define LCD_CLICKED (buttons&EN_C)
B00011,
B10011, #else // old style ULTIPANEL
B01100, //encoder rotation values
B00000, #ifndef ULTIMAKERCONTROLLER
}; //thanks joris #define encrot0 0
byte folder [8]={ #define encrot1 2
B00000, #define encrot2 3
B11100, #define encrot3 1
B11111, #else
B10001, #define encrot0 0
B10001, #define encrot1 1
B11111, #define encrot2 3
B00000, #define encrot3 2
B00000 #endif
}; //thanks joris
byte feedrate [8]={ //bits in the shift register that carry the buttons for:
B11100, // left up center down right red(stop)
B10000, #define BL_LE 7
B11000, #define BL_UP 6
B10111, #define BL_MI 5
B00101, #define BL_DW 4
B00110, #define BL_RI 3
B00101, #define BL_ST 2
B00000
}; //thanks Sonny Mounicou #define BLEN_B 1
byte clock [8]={ #define BLEN_A 0
B00000,
B01110, //automatic, do not change
B10011, #define B_LE (1<<BL_LE)
B10101, #define B_UP (1<<BL_UP)
B10001, #define B_MI (1<<BL_MI)
B01110, #define B_DW (1<<BL_DW)
B00000, #define B_RI (1<<BL_RI)
B00000 #define B_ST (1<<BL_ST)
}; //thanks Sonny Mounicou #define EN_B (1<<BLEN_B)
#define EN_A (1<<BLEN_A)
#ifdef LCD_I2C
#ifdef LCD_I2C_PIN_BL #define LCD_CLICKED (buttons&(B_MI|B_ST))
lcd.setBacklightPin(LCD_I2C_PIN_BL,POSITIVE); #endif//else NEWPANEL
lcd.setBacklight(HIGH);
#endif #ifdef LCD_HAS_STATUS_INDICATORS
#endif //forward declaration
static void lcd_implementation_update_indicators();
lcd.begin(LCD_WIDTH, LCD_HEIGHT); #endif
lcd.createChar(LCD_STR_BEDTEMP[0], bedTemp);
lcd.createChar(LCD_STR_DEGREE[0], degree); /* Custom characters defined in the first 8 characters of the LCD */
lcd.createChar(LCD_STR_THERMOMETER[0], thermometer); #define LCD_STR_BEDTEMP "\x00"
lcd.createChar(LCD_STR_UPLEVEL[0], uplevel); #define LCD_STR_DEGREE "\x01"
lcd.createChar(LCD_STR_REFRESH[0], refresh); #define LCD_STR_THERMOMETER "\x02"
lcd.createChar(LCD_STR_FOLDER[0], folder); #define LCD_STR_UPLEVEL "\x03"
lcd.createChar(LCD_STR_FEEDRATE[0], feedrate); #define LCD_STR_REFRESH "\x04"
lcd.createChar(LCD_STR_CLOCK[0], clock); #define LCD_STR_FOLDER "\x05"
lcd.clear(); #define LCD_STR_FEEDRATE "\x06"
} #define LCD_STR_CLOCK "\x07"
static void lcd_implementation_clear() #define LCD_STR_ARROW_RIGHT "\x7E" /* from the default character set */
{
lcd.clear(); static void lcd_implementation_init()
} {
/* Arduino < 1.0.0 is missing a function to print PROGMEM strings, so we need to implement our own */ byte bedTemp[8] =
static void lcd_printPGM(const char* str) {
{ B00000,
char c; B11111,
while((c = pgm_read_byte(str++)) != '\0') B10101,
{ B10001,
lcd.write(c); B10101,
} B11111,
} B00000,
/* B00000
Possible status screens: }; //thanks Sonny Mounicou
16x2 |0123456789012345| byte degree[8] =
|000/000 B000/000| {
|Status line.....| B01100,
B10010,
16x4 |0123456789012345| B10010,
|000/000 B000/000| B01100,
|SD100% Z000.0| B00000,
|F100% T--:--| B00000,
|Status line.....| B00000,
B00000
20x2 |01234567890123456789| };
|T000/000D B000/000D | byte thermometer[8] =
|Status line.........| {
B00100,
20x4 |01234567890123456789| B01010,
|T000/000D B000/000D | B01010,
|X+000.0 Y+000.0 Z+000.0| B01010,
|F100% SD100% T--:--| B01010,
|Status line.........| B10001,
B10001,
20x4 |01234567890123456789| B01110
|T000/000D B000/000D | };
|T000/000D Z000.0| byte uplevel[8]={
|F100% SD100% T--:--| B00100,
|Status line.........| B01110,
*/ B11111,
static void lcd_implementation_status_screen() B00100,
{ B11100,
int tHotend=int(degHotend(0) + 0.5); B00000,
int tTarget=int(degTargetHotend(0) + 0.5); B00000,
B00000
#if LCD_WIDTH < 20 }; //thanks joris
lcd.setCursor(0, 0); byte refresh[8]={
lcd.print(itostr3(tHotend)); B00000,
lcd.print('/'); B00110,
lcd.print(itostr3left(tTarget)); B11001,
B11000,
# if EXTRUDERS > 1 || TEMP_SENSOR_BED != 0 B00011,
//If we have an 2nd extruder or heated bed, show that in the top right corner B10011,
lcd.setCursor(8, 0); B01100,
# if EXTRUDERS > 1 B00000,
tHotend = int(degHotend(1) + 0.5); }; //thanks joris
tTarget = int(degTargetHotend(1) + 0.5); byte folder [8]={
lcd.print(LCD_STR_THERMOMETER[0]); B00000,
# else//Heated bed B11100,
tHotend=int(degBed() + 0.5); B11111,
tTarget=int(degTargetBed() + 0.5); B10001,
lcd.print(LCD_STR_BEDTEMP[0]); B10001,
# endif B11111,
lcd.print(itostr3(tHotend)); B00000,
lcd.print('/'); B00000
lcd.print(itostr3left(tTarget)); }; //thanks joris
# endif//EXTRUDERS > 1 || TEMP_SENSOR_BED != 0 byte feedrate [8]={
B11100,
#else//LCD_WIDTH > 19 B10000,
lcd.setCursor(0, 0); B11000,
lcd.print(LCD_STR_THERMOMETER[0]); B10111,
lcd.print(itostr3(tHotend)); B00101,
lcd.print('/'); B00110,
lcd.print(itostr3left(tTarget)); B00101,
lcd_printPGM(PSTR(LCD_STR_DEGREE " ")); B00000
if (tTarget < 10) }; //thanks Sonny Mounicou
lcd.print(' '); byte clock [8]={
B00000,
# if EXTRUDERS > 1 || TEMP_SENSOR_BED != 0 B01110,
//If we have an 2nd extruder or heated bed, show that in the top right corner B10011,
lcd.setCursor(10, 0); B10101,
# if EXTRUDERS > 1 B10001,
tHotend = int(degHotend(1) + 0.5); B01110,
tTarget = int(degTargetHotend(1) + 0.5); B00000,
lcd.print(LCD_STR_THERMOMETER[0]); B00000
# else//Heated bed }; //thanks Sonny Mounicou
tHotend=int(degBed() + 0.5);
tTarget=int(degTargetBed() + 0.5); #if defined(LCDI2C_TYPE_PCF8575)
lcd.print(LCD_STR_BEDTEMP[0]); lcd.begin(LCD_WIDTH, LCD_HEIGHT);
# endif #ifdef LCD_I2C_PIN_BL
lcd.print(itostr3(tHotend)); lcd.setBacklightPin(LCD_I2C_PIN_BL,POSITIVE);
lcd.print('/'); lcd.setBacklight(HIGH);
lcd.print(itostr3left(tTarget)); #endif
lcd_printPGM(PSTR(LCD_STR_DEGREE " ")); #elif defined(LCD_I2C_TYPE_MCP23017)
if (tTarget < 10) lcd.setMCPType(LTI_TYPE_MCP23017);
lcd.print(' '); lcd.begin(LCD_WIDTH, LCD_HEIGHT);
# endif//EXTRUDERS > 1 || TEMP_SENSOR_BED != 0 lcd.setBacklight(0); //set all the LEDs off to begin with
#endif//LCD_WIDTH > 19 #elif defined(LCD_I2C_TYPE_MCP23008)
lcd.setMCPType(LTI_TYPE_MCP23008);
#if LCD_HEIGHT > 2 lcd.begin(LCD_WIDTH, LCD_HEIGHT);
//Lines 2 for 4 line LCD #else
# if LCD_WIDTH < 20 lcd.begin(LCD_WIDTH, LCD_HEIGHT);
# ifdef SDSUPPORT #endif
lcd.setCursor(0, 2);
lcd_printPGM(PSTR("SD")); lcd.createChar(LCD_STR_BEDTEMP[0], bedTemp);
if (IS_SD_PRINTING) lcd.createChar(LCD_STR_DEGREE[0], degree);
lcd.print(itostr3(card.percentDone())); lcd.createChar(LCD_STR_THERMOMETER[0], thermometer);
else lcd.createChar(LCD_STR_UPLEVEL[0], uplevel);
lcd_printPGM(PSTR("---")); lcd.createChar(LCD_STR_REFRESH[0], refresh);
lcd.print('%'); lcd.createChar(LCD_STR_FOLDER[0], folder);
# endif//SDSUPPORT lcd.createChar(LCD_STR_FEEDRATE[0], feedrate);
# else//LCD_WIDTH > 19 lcd.createChar(LCD_STR_CLOCK[0], clock);
# if EXTRUDERS > 1 && TEMP_SENSOR_BED != 0 lcd.clear();
//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); static void lcd_implementation_clear()
tTarget=int(degTargetBed() + 0.5); {
lcd.clear();
lcd.setCursor(0, 1); }
lcd.print(LCD_STR_BEDTEMP[0]); /* Arduino < 1.0.0 is missing a function to print PROGMEM strings, so we need to implement our own */
lcd.print(itostr3(tHotend)); static void lcd_printPGM(const char* str)
lcd.print('/'); {
lcd.print(itostr3left(tTarget)); char c;
lcd_printPGM(PSTR(LCD_STR_DEGREE " ")); while((c = pgm_read_byte(str++)) != '\0')
if (tTarget < 10) {
lcd.print(' '); lcd.write(c);
# else }
lcd.setCursor(0,1); }
lcd.print('X'); /*
lcd.print(ftostr3(current_position[X_AXIS])); Possible status screens:
lcd_printPGM(PSTR(" Y")); 16x2 |0123456789012345|
lcd.print(ftostr3(current_position[Y_AXIS])); |000/000 B000/000|
# endif//EXTRUDERS > 1 || TEMP_SENSOR_BED != 0 |Status line.....|
# endif//LCD_WIDTH > 19
lcd.setCursor(LCD_WIDTH - 8, 1); 16x4 |0123456789012345|
lcd.print('Z'); |000/000 B000/000|
lcd.print(ftostr32(current_position[Z_AXIS])); |SD100% Z000.0|
#endif//LCD_HEIGHT > 2 |F100% T--:--|
|Status line.....|
#if LCD_HEIGHT > 3
lcd.setCursor(0, 2); 20x2 |01234567890123456789|
lcd.print(LCD_STR_FEEDRATE[0]); |T000/000D B000/000D |
lcd.print(itostr3(feedmultiply)); |Status line.........|
lcd.print('%');
# if LCD_WIDTH > 19 20x4 |01234567890123456789|
# ifdef SDSUPPORT |T000/000D B000/000D |
lcd.setCursor(7, 2); |X+000.0 Y+000.0 Z+000.0|
lcd_printPGM(PSTR("SD")); |F100% SD100% T--:--|
if (IS_SD_PRINTING) |Status line.........|
lcd.print(itostr3(card.percentDone()));
else 20x4 |01234567890123456789|
lcd_printPGM(PSTR("---")); |T000/000D B000/000D |
lcd.print('%'); |T000/000D Z000.0|
# endif//SDSUPPORT |F100% SD100% T--:--|
# endif//LCD_WIDTH > 19 |Status line.........|
lcd.setCursor(LCD_WIDTH - 6, 2); */
lcd.print(LCD_STR_CLOCK[0]); static void lcd_implementation_status_screen()
if(starttime != 0) {
{ int tHotend=int(degHotend(0) + 0.5);
uint16_t time = millis()/60000 - starttime/60000; int tTarget=int(degTargetHotend(0) + 0.5);
lcd.print(itostr2(time/60));
lcd.print(':'); #if LCD_WIDTH < 20
lcd.print(itostr2(time%60)); lcd.setCursor(0, 0);
}else{ lcd.print(itostr3(tHotend));
lcd_printPGM(PSTR("--:--")); lcd.print('/');
} lcd.print(itostr3left(tTarget));
#endif
# if EXTRUDERS > 1 || TEMP_SENSOR_BED != 0
//Status message line on the last line //If we have an 2nd extruder or heated bed, show that in the top right corner
lcd.setCursor(0, LCD_HEIGHT - 1); lcd.setCursor(8, 0);
lcd.print(lcd_status_message); # if EXTRUDERS > 1
} tHotend = int(degHotend(1) + 0.5);
static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, char pre_char, char post_char) tTarget = int(degTargetHotend(1) + 0.5);
{ lcd.print(LCD_STR_THERMOMETER[0]);
char c; # else//Heated bed
//Use all characters in narrow LCDs tHotend=int(degBed() + 0.5);
#if LCD_WIDTH < 20 tTarget=int(degTargetBed() + 0.5);
uint8_t n = LCD_WIDTH - 1 - 1; lcd.print(LCD_STR_BEDTEMP[0]);
#else # endif
uint8_t n = LCD_WIDTH - 1 - 2; lcd.print(itostr3(tHotend));
#endif lcd.print('/');
lcd.setCursor(0, row); lcd.print(itostr3left(tTarget));
lcd.print(pre_char); # endif//EXTRUDERS > 1 || TEMP_SENSOR_BED != 0
while((c = pgm_read_byte(pstr)) != '\0')
{ #else//LCD_WIDTH > 19
lcd.print(c); lcd.setCursor(0, 0);
pstr++; lcd.print(LCD_STR_THERMOMETER[0]);
n--; lcd.print(itostr3(tHotend));
} lcd.print('/');
while(n--) lcd.print(itostr3left(tTarget));
lcd.print(' '); lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
lcd.print(post_char); if (tTarget < 10)
lcd.print(' '); lcd.print(' ');
}
static void lcd_implementation_drawmenu_setting_edit_generic(uint8_t row, const char* pstr, char pre_char, char* data) # if EXTRUDERS > 1 || TEMP_SENSOR_BED != 0
{ //If we have an 2nd extruder or heated bed, show that in the top right corner
char c; lcd.setCursor(10, 0);
//Use all characters in narrow LCDs # if EXTRUDERS > 1
#if LCD_WIDTH < 20 tHotend = int(degHotend(1) + 0.5);
uint8_t n = LCD_WIDTH - 1 - 1 - strlen(data); tTarget = int(degTargetHotend(1) + 0.5);
#else lcd.print(LCD_STR_THERMOMETER[0]);
uint8_t n = LCD_WIDTH - 1 - 2 - strlen(data); # else//Heated bed
#endif tHotend=int(degBed() + 0.5);
lcd.setCursor(0, row); tTarget=int(degTargetBed() + 0.5);
lcd.print(pre_char); lcd.print(LCD_STR_BEDTEMP[0]);
while((c = pgm_read_byte(pstr)) != '\0') # endif
{ lcd.print(itostr3(tHotend));
lcd.print(c); lcd.print('/');
pstr++; lcd.print(itostr3left(tTarget));
n--; lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
} if (tTarget < 10)
lcd.print(':'); lcd.print(' ');
while(n--) # endif//EXTRUDERS > 1 || TEMP_SENSOR_BED != 0
lcd.print(' '); #endif//LCD_WIDTH > 19
lcd.print(data);
} #if LCD_HEIGHT > 2
static void lcd_implementation_drawmenu_setting_edit_generic_P(uint8_t row, const char* pstr, char pre_char, const char* data) //Lines 2 for 4 line LCD
{ # if LCD_WIDTH < 20
char c; # ifdef SDSUPPORT
//Use all characters in narrow LCDs lcd.setCursor(0, 2);
#if LCD_WIDTH < 20 lcd_printPGM(PSTR("SD"));
uint8_t n = LCD_WIDTH - 1 - 1 - strlen_P(data); if (IS_SD_PRINTING)
#else lcd.print(itostr3(card.percentDone()));
uint8_t n = LCD_WIDTH - 1 - 2 - strlen_P(data); else
#endif lcd_printPGM(PSTR("---"));
lcd.setCursor(0, row); lcd.print('%');
lcd.print(pre_char); # endif//SDSUPPORT
while((c = pgm_read_byte(pstr)) != '\0') # else//LCD_WIDTH > 19
{ # if EXTRUDERS > 1 && TEMP_SENSOR_BED != 0
lcd.print(c); //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
pstr++; tHotend=int(degBed() + 0.5);
n--; tTarget=int(degTargetBed() + 0.5);
}
lcd.print(':'); lcd.setCursor(0, 1);
while(n--) lcd.print(LCD_STR_BEDTEMP[0]);
lcd.print(' '); lcd.print(itostr3(tHotend));
lcd_printPGM(data); lcd.print('/');
} lcd.print(itostr3left(tTarget));
#define lcd_implementation_drawmenu_setting_edit_int3_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', itostr3(*(data))) lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
#define lcd_implementation_drawmenu_setting_edit_int3(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', itostr3(*(data))) if (tTarget < 10)
#define lcd_implementation_drawmenu_setting_edit_float3_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr3(*(data))) lcd.print(' ');
#define lcd_implementation_drawmenu_setting_edit_float3(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr3(*(data))) # else
#define lcd_implementation_drawmenu_setting_edit_float32_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr32(*(data))) lcd.setCursor(0,1);
#define lcd_implementation_drawmenu_setting_edit_float32(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr32(*(data))) lcd.print('X');
#define lcd_implementation_drawmenu_setting_edit_float5_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr5(*(data))) lcd.print(ftostr3(current_position[X_AXIS]));
#define lcd_implementation_drawmenu_setting_edit_float5(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data))) lcd_printPGM(PSTR(" Y"));
#define lcd_implementation_drawmenu_setting_edit_float52_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr52(*(data))) lcd.print(ftostr3(current_position[Y_AXIS]));
#define lcd_implementation_drawmenu_setting_edit_float52(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr52(*(data))) # endif//EXTRUDERS > 1 || TEMP_SENSOR_BED != 0
#define lcd_implementation_drawmenu_setting_edit_float51_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr51(*(data))) # endif//LCD_WIDTH > 19
#define lcd_implementation_drawmenu_setting_edit_float51(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr51(*(data))) lcd.setCursor(LCD_WIDTH - 8, 1);
#define lcd_implementation_drawmenu_setting_edit_long5_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr5(*(data))) lcd.print('Z');
#define lcd_implementation_drawmenu_setting_edit_long5(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data))) lcd.print(ftostr32(current_position[Z_AXIS]));
#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)) #endif//LCD_HEIGHT > 2
#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) #if LCD_HEIGHT > 3
{ lcd.setCursor(0, 2);
lcd.setCursor(1, 1); lcd.print(LCD_STR_FEEDRATE[0]);
lcd_printPGM(pstr); lcd.print(itostr3(feedmultiply));
lcd.print(':'); lcd.print('%');
#if LCD_WIDTH < 20 # if LCD_WIDTH > 19
lcd.setCursor(LCD_WIDTH - strlen(value), 1); # ifdef SDSUPPORT
#else lcd.setCursor(7, 2);
lcd.setCursor(LCD_WIDTH -1 - strlen(value), 1); lcd_printPGM(PSTR("SD"));
#endif if (IS_SD_PRINTING)
lcd.print(value); lcd.print(itostr3(card.percentDone()));
} else
static void lcd_implementation_drawmenu_sdfile_selected(uint8_t row, const char* pstr, const char* filename, char* longFilename) lcd_printPGM(PSTR("---"));
{ lcd.print('%');
char c; # endif//SDSUPPORT
uint8_t n = LCD_WIDTH - 1; # endif//LCD_WIDTH > 19
lcd.setCursor(0, row); lcd.setCursor(LCD_WIDTH - 6, 2);
lcd.print('>'); lcd.print(LCD_STR_CLOCK[0]);
if (longFilename[0] != '\0') if(starttime != 0)
{ {
filename = longFilename; uint16_t time = millis()/60000 - starttime/60000;
longFilename[LCD_WIDTH-1] = '\0'; lcd.print(itostr2(time/60));
} lcd.print(':');
while((c = *filename) != '\0') lcd.print(itostr2(time%60));
{ }else{
lcd.print(c); lcd_printPGM(PSTR("--:--"));
filename++; }
n--; #endif
}
while(n--) //Status message line on the last line
lcd.print(' '); lcd.setCursor(0, LCD_HEIGHT - 1);
} lcd.print(lcd_status_message);
static void lcd_implementation_drawmenu_sdfile(uint8_t row, const char* pstr, const char* filename, char* longFilename) #ifdef LCD_HAS_STATUS_INDICATORS
{ lcd_implementation_update_indicators();
char c; #endif
uint8_t n = LCD_WIDTH - 1; }
lcd.setCursor(0, row); static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, char pre_char, char post_char)
lcd.print(' '); {
if (longFilename[0] != '\0') char c;
{ //Use all characters in narrow LCDs
filename = longFilename; #if LCD_WIDTH < 20
longFilename[LCD_WIDTH-1] = '\0'; uint8_t n = LCD_WIDTH - 1 - 1;
} #else
while((c = *filename) != '\0') uint8_t n = LCD_WIDTH - 1 - 2;
{ #endif
lcd.print(c); lcd.setCursor(0, row);
filename++; lcd.print(pre_char);
n--; while((c = pgm_read_byte(pstr)) != '\0')
} {
while(n--) lcd.print(c);
lcd.print(' '); pstr++;
} n--;
static void lcd_implementation_drawmenu_sddirectory_selected(uint8_t row, const char* pstr, const char* filename, char* longFilename) }
{ while(n--)
char c; lcd.print(' ');
uint8_t n = LCD_WIDTH - 2; lcd.print(post_char);
lcd.setCursor(0, row); lcd.print(' ');
lcd.print('>'); }
lcd.print(LCD_STR_FOLDER[0]); static void lcd_implementation_drawmenu_setting_edit_generic(uint8_t row, const char* pstr, char pre_char, char* data)
if (longFilename[0] != '\0') {
{ char c;
filename = longFilename; //Use all characters in narrow LCDs
longFilename[LCD_WIDTH-2] = '\0'; #if LCD_WIDTH < 20
} uint8_t n = LCD_WIDTH - 1 - 1 - strlen(data);
while((c = *filename) != '\0') #else
{ uint8_t n = LCD_WIDTH - 1 - 2 - strlen(data);
lcd.print(c); #endif
filename++; lcd.setCursor(0, row);
n--; lcd.print(pre_char);
} while((c = pgm_read_byte(pstr)) != '\0')
while(n--) {
lcd.print(' '); lcd.print(c);
} pstr++;
static void lcd_implementation_drawmenu_sddirectory(uint8_t row, const char* pstr, const char* filename, char* longFilename) n--;
{ }
char c; lcd.print(':');
uint8_t n = LCD_WIDTH - 2; while(n--)
lcd.setCursor(0, row); lcd.print(' ');
lcd.print(' '); lcd.print(data);
lcd.print(LCD_STR_FOLDER[0]); }
if (longFilename[0] != '\0') static void lcd_implementation_drawmenu_setting_edit_generic_P(uint8_t row, const char* pstr, char pre_char, const char* data)
{ {
filename = longFilename; char c;
longFilename[LCD_WIDTH-2] = '\0'; //Use all characters in narrow LCDs
} #if LCD_WIDTH < 20
while((c = *filename) != '\0') uint8_t n = LCD_WIDTH - 1 - 1 - strlen_P(data);
{ #else
lcd.print(c); uint8_t n = LCD_WIDTH - 1 - 2 - strlen_P(data);
filename++; #endif
n--; lcd.setCursor(0, row);
} lcd.print(pre_char);
while(n--) while((c = pgm_read_byte(pstr)) != '\0')
lcd.print(' '); {
} lcd.print(c);
#define lcd_implementation_drawmenu_back_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0]) pstr++;
#define lcd_implementation_drawmenu_back(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', LCD_STR_UPLEVEL[0]) n--;
#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]) lcd.print(':');
#define lcd_implementation_drawmenu_gcode_selected(row, pstr, gcode) lcd_implementation_drawmenu_generic(row, pstr, '>', ' ') while(n--)
#define lcd_implementation_drawmenu_gcode(row, pstr, gcode) lcd_implementation_drawmenu_generic(row, pstr, ' ', ' ') lcd.print(' ');
#define lcd_implementation_drawmenu_function_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, '>', ' ') lcd_printPGM(data);
#define lcd_implementation_drawmenu_function(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', ' ') }
#define lcd_implementation_drawmenu_setting_edit_int3_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', itostr3(*(data)))
static void lcd_implementation_quick_feedback() #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)))
#if BEEPER > -1 #define lcd_implementation_drawmenu_setting_edit_float3(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr3(*(data)))
SET_OUTPUT(BEEPER); #define lcd_implementation_drawmenu_setting_edit_float32_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr32(*(data)))
for(int8_t i=0;i<10;i++) #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)))
WRITE(BEEPER,HIGH); #define lcd_implementation_drawmenu_setting_edit_float5(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data)))
delay(3); #define lcd_implementation_drawmenu_setting_edit_float52_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr52(*(data)))
WRITE(BEEPER,LOW); #define lcd_implementation_drawmenu_setting_edit_float52(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr52(*(data)))
delay(3); #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)))
#endif #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)))
#endif//ULTRA_LCD_IMPLEMENTATION_HITACHI_HD44780_H #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

Loading…
Cancel
Save