The big LCD code update. This splits the display and menu implementation. Paving the way for future different displays. It also makes it easier to modify the menu structures while keeping everything consistant. Note that this most likely breaks the translations, which need to be updated.

2.0.x
daid303 12 years ago
parent 6731c094ee
commit 1a8f54cea1

@ -182,7 +182,6 @@ void setPwmFrequency(uint8_t pin, int val);
extern float homing_feedrate[]; extern float homing_feedrate[];
extern bool axis_relative_modes[]; extern bool axis_relative_modes[];
extern int feedmultiply; extern int feedmultiply;
extern bool feedmultiplychanged;
extern int extrudemultiply; // Sets extrude multiply factor (in percent) extern int extrudemultiply; // Sets extrude multiply factor (in percent)
extern float current_position[NUM_AXIS] ; extern float current_position[NUM_AXIS] ;
extern float add_homeing[3]; extern float add_homeing[3];

@ -147,7 +147,6 @@ CardReader card;
float homing_feedrate[] = HOMING_FEEDRATE; float homing_feedrate[] = HOMING_FEEDRATE;
bool axis_relative_modes[] = AXIS_RELATIVE_MODES; bool axis_relative_modes[] = AXIS_RELATIVE_MODES;
int feedmultiply=100; //100->1 200->2 int feedmultiply=100; //100->1 200->2
bool feedmultiplychanged;
int saved_feedmultiply; int saved_feedmultiply;
int extrudemultiply=100; //100->1 200->2 int extrudemultiply=100; //100->1 200->2
float current_position[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0 }; float current_position[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0 };
@ -1372,7 +1371,6 @@ void process_commands()
if(code_seen('S')) if(code_seen('S'))
{ {
feedmultiply = code_value() ; feedmultiply = code_value() ;
feedmultiplychanged = true;
} }
} }
break; break;
@ -1543,6 +1541,7 @@ void process_commands()
break; break;
case 999: // M999: Restart after being stopped case 999: // M999: Restart after being stopped
Stopped = false; Stopped = false;
lcd_reset_alert_level();
gcode_LastN = Stopped_gcode_LastN; gcode_LastN = Stopped_gcode_LastN;
FlushSerialRequestResend(); FlushSerialRequestResend();
break; break;

@ -529,6 +529,7 @@ void CardReader::printingHasFinished()
{ {
st_synchronize(); st_synchronize();
quickStop(); quickStop();
file.close();
sdprinting = false; sdprinting = false;
if(SD_FINISHED_STEPPERRELEASE) if(SD_FINISHED_STEPPERRELEASE)
{ {

@ -35,10 +35,11 @@ public:
void setroot(); void setroot();
FORCE_INLINE bool isFileOpen() { return file.isOpen(); }
FORCE_INLINE bool eof() { return sdpos>=filesize ;}; FORCE_INLINE bool eof() { return sdpos>=filesize ;};
FORCE_INLINE int16_t get() { sdpos = file.curPosition();return (int16_t)file.read();}; FORCE_INLINE int16_t get() { sdpos = file.curPosition();return (int16_t)file.read();};
FORCE_INLINE void setIndex(long index) {sdpos = index;file.seekSet(index);}; FORCE_INLINE void setIndex(long index) {sdpos = index;file.seekSet(index);};
FORCE_INLINE uint8_t percentDone(){if(!sdprinting) return 0; if(filesize) return sdpos/((filesize+99)/100); else return 0;}; FORCE_INLINE uint8_t percentDone(){if(!isFileOpen()) return 0; if(filesize) return sdpos/((filesize+99)/100); else return 0;};
FORCE_INLINE char* getWorkDirName(){workDir.getFilename(filename);return filename;}; FORCE_INLINE char* getWorkDirName(){workDir.getFilename(filename);return filename;};
public: public:

@ -39,88 +39,80 @@
#define WELCOME_MSG MACHINE_NAME " Ready." #define WELCOME_MSG MACHINE_NAME " Ready."
#define MSG_SD_INSERTED "Card inserted" #define MSG_SD_INSERTED "Card inserted"
#define MSG_SD_REMOVED "Card removed" #define MSG_SD_REMOVED "Card removed"
#define MSG_MAIN " Main \003" #define MSG_MAIN "Main"
#define MSG_AUTOSTART "Autostart" #define MSG_AUTOSTART "Autostart"
#define MSG_DISABLE_STEPPERS "Disable Steppers" #define MSG_DISABLE_STEPPERS "Disable Steppers"
#define MSG_AUTO_HOME "Auto Home" #define MSG_AUTO_HOME "Auto Home"
#define MSG_SET_ORIGIN "Set Origin" #define MSG_SET_ORIGIN "Set Origin"
#define MSG_PREHEAT_PLA "Preheat PLA" #define MSG_PREHEAT_PLA "Preheat PLA"
#define MSG_PREHEAT_PLA_SETTINGS " Preheat PLA Setting" #define MSG_PREHEAT_PLA_SETTINGS "Preheat PLA Conf"
#define MSG_PREHEAT_ABS "Preheat ABS" #define MSG_PREHEAT_ABS "Preheat ABS"
#define MSG_PREHEAT_ABS_SETTINGS " Preheat ABS Setting" #define MSG_PREHEAT_ABS_SETTINGS "Preheat ABS Conf"
#define MSG_COOLDOWN "Cooldown" #define MSG_COOLDOWN "Cooldown"
#define MSG_EXTRUDE "Extrude" #define MSG_EXTRUDE "Extrude"
#define MSG_RETRACT "Retract" #define MSG_RETRACT "Retract"
#define MSG_PREHEAT_PLA "Preheat PLA" #define MSG_PREHEAT_PLA "Preheat PLA"
#define MSG_PREHEAT_ABS "Preheat ABS" #define MSG_PREHEAT_ABS "Preheat ABS"
#define MSG_MOVE_AXIS " Move Axis \x7E" #define MSG_MOVE_AXIS "Move Axis"
#define MSG_SPEED " Speed:" #define MSG_SPEED "Speed"
#define MSG_NOZZLE " \002Nozzle:" #define MSG_NOZZLE "Nozzle"
#define MSG_NOZZLE1 " \002Nozzle2:" #define MSG_NOZZLE1 "Nozzle2"
#define MSG_NOZZLE2 " \002Nozzle3:" #define MSG_NOZZLE2 "Nozzle3"
#define MSG_BED " \002Bed:" #define MSG_BED "Bed"
#define MSG_FAN_SPEED " Fan speed:" #define MSG_FAN_SPEED "Fan speed"
#define MSG_FLOW " Flow:" #define MSG_FLOW "Flow"
#define MSG_CONTROL " Control \003" #define MSG_CONTROL "Control"
#define MSG_MIN " \002 Min:" #define MSG_MIN " \002 Min"
#define MSG_MAX " \002 Max:" #define MSG_MAX " \002 Max"
#define MSG_FACTOR " \002 Fact:" #define MSG_FACTOR " \002 Fact"
#define MSG_AUTOTEMP " Autotemp:" #define MSG_AUTOTEMP "Autotemp"
#define MSG_ON "On " #define MSG_ON "On "
#define MSG_OFF "Off" #define MSG_OFF "Off"
#define MSG_PID_P " PID-P: " #define MSG_PID_P "PID-P"
#define MSG_PID_I " PID-I: " #define MSG_PID_I "PID-I"
#define MSG_PID_D " PID-D: " #define MSG_PID_D "PID-D"
#define MSG_PID_C " PID-C: " #define MSG_PID_C "PID-C"
#define MSG_ACC " Acc:" #define MSG_ACC "Accel"
#define MSG_VXY_JERK " Vxy-jerk: " #define MSG_VXY_JERK "Vxy-jerk"
#define MSG_VMAX "Vmax " #define MSG_VMAX "Vmax "
#define MSG_X "x:" #define MSG_X "x"
#define MSG_Y "y:" #define MSG_Y "y"
#define MSG_Z "z:" #define MSG_Z "z"
#define MSG_E "e:" #define MSG_E "e"
#define MSG_VMIN " Vmin:" #define MSG_VMIN "Vmin"
#define MSG_VTRAV_MIN " VTrav min:" #define MSG_VTRAV_MIN "VTrav min"
#define MSG_AMAX "Amax " #define MSG_AMAX "Amax "
#define MSG_A_RETRACT " A-retract:" #define MSG_A_RETRACT "A-retract"
#define MSG_XSTEPS " Xsteps/mm:" #define MSG_XSTEPS "Xsteps/mm"
#define MSG_YSTEPS " Ysteps/mm:" #define MSG_YSTEPS "Ysteps/mm"
#define MSG_ZSTEPS " Zsteps/mm:" #define MSG_ZSTEPS "Zsteps/mm"
#define MSG_ESTEPS " Esteps/mm:" #define MSG_ESTEPS "Esteps/mm"
#define MSG_MAIN_WIDE " Main \003" #define MSG_RECTRACT "Rectract"
#define MSG_RECTRACT_WIDE " Rectract \x7E" #define MSG_TEMPERATURE "Temperature"
#define MSG_TEMPERATURE_WIDE " Temperature \x7E" #define MSG_MOTION "Motion"
#define MSG_TEMPERATURE_RTN " Temperature \003"
#define MSG_MOTION_WIDE " Motion \x7E"
#define MSG_STORE_EPROM "Store memory" #define MSG_STORE_EPROM "Store memory"
#define MSG_LOAD_EPROM "Load memory" #define MSG_LOAD_EPROM "Load memory"
#define MSG_RESTORE_FAILSAFE "Restore Failsafe" #define MSG_RESTORE_FAILSAFE "Restore Failsafe"
#define MSG_REFRESH "\004Refresh" #define MSG_REFRESH "Refresh"
#define MSG_WATCH " Watch \003" #define MSG_WATCH "Watch"
#define MSG_PREPARE " Prepare \x7E" #define MSG_PREPARE "Prepare"
#define MSG_PREPARE_ALT " Prepare \003" #define MSG_TUNE "Tune"
#define MSG_CONTROL_ARROW " Control \x7E" #define MSG_PAUSE_PRINT "Pause Print"
#define MSG_RETRACT_ARROW " Retract \x7E" #define MSG_RESUME_PRINT "Resume Print"
#define MSG_TUNE " Tune \x7E" #define MSG_STOP_PRINT "Stop Print"
#define MSG_PAUSE_PRINT " Pause Print \x7E" #define MSG_CARD_MENU "Card Menu"
#define MSG_RESUME_PRINT " Resume Print \x7E"
#define MSG_STOP_PRINT " Stop Print \x7E"
#define MSG_CARD_MENU " Card Menu \x7E"
#define MSG_NO_CARD "No Card" #define MSG_NO_CARD "No Card"
#define MSG_DWELL "Sleep..." #define MSG_DWELL "Sleep..."
#define MSG_USERWAIT "Wait for user..." #define MSG_USERWAIT "Wait for user..."
#define MSG_NO_MOVE "No move." #define MSG_NO_MOVE "No move."
#define MSG_PART_RELEASE "Partial Release"
#define MSG_KILLED "KILLED. " #define MSG_KILLED "KILLED. "
#define MSG_STOPPED "STOPPED. " #define MSG_STOPPED "STOPPED. "
#define MSG_STEPPER_RELEASED "Released." #define MSG_CONTROL_RETRACT "Retract mm"
#define MSG_CONTROL_RETRACT " Retract mm:" #define MSG_CONTROL_RETRACTF "Retract F"
#define MSG_CONTROL_RETRACTF " Retract F:" #define MSG_CONTROL_RETRACT_ZLIFT "Hop mm"
#define MSG_CONTROL_RETRACT_ZLIFT " Hop mm:" #define MSG_CONTROL_RETRACT_RECOVER "UnRet +mm"
#define MSG_CONTROL_RETRACT_RECOVER " UnRet +mm:" #define MSG_CONTROL_RETRACT_RECOVERF "UnRet F"
#define MSG_CONTROL_RETRACT_RECOVERF " UnRet F:" #define MSG_AUTORETRACT "AutoRetr."
#define MSG_AUTORETRACT " AutoRetr.:"
#define MSG_SERIAL_ERROR_MENU_STRUCTURE "Something is wrong in the MenuStructure."
// Serial Console Messages // Serial Console Messages
@ -200,7 +192,7 @@
#define WELCOME_MSG MACHINE_NAME " Gotowe." #define WELCOME_MSG MACHINE_NAME " Gotowe."
#define MSG_SD_INSERTED "Karta wlozona" #define MSG_SD_INSERTED "Karta wlozona"
#define MSG_SD_REMOVED "Karta usunieta" #define MSG_SD_REMOVED "Karta usunieta"
#define MSG_MAIN " Menu \003" #define MSG_MAIN "Main"
#define MSG_AUTOSTART "Autostart" #define MSG_AUTOSTART "Autostart"
#define MSG_DISABLE_STEPPERS "Wylacz silniki" #define MSG_DISABLE_STEPPERS "Wylacz silniki"
#define MSG_AUTO_HOME "Auto. poz. zerowa" #define MSG_AUTO_HOME "Auto. poz. zerowa"
@ -212,59 +204,55 @@
#define MSG_COOLDOWN "Chlodzenie" #define MSG_COOLDOWN "Chlodzenie"
#define MSG_EXTRUDE "Ekstruzja" #define MSG_EXTRUDE "Ekstruzja"
#define MSG_RETRACT "Cofanie" #define MSG_RETRACT "Cofanie"
#define MSG_MOVE_AXIS " Ruch osi \x7E" #define MSG_MOVE_AXIS "Ruch osi"
#define MSG_SPEED " Predkosc:" #define MSG_SPEED "Predkosc"
#define MSG_NOZZLE " \002Dysza:" #define MSG_NOZZLE "Dysza"
#define MSG_NOZZLE1 " \002Dysza2:" #define MSG_NOZZLE1 "Dysza2"
#define MSG_NOZZLE2 " \002Dysza3:" #define MSG_NOZZLE2 "Dysza3"
#define MSG_BED " \002Loze:" #define MSG_BED "Loze"
#define MSG_FAN_SPEED " Obroty wiatraka:" #define MSG_FAN_SPEED "Obroty wiatraka"
#define MSG_FLOW " Przeplyw:" #define MSG_FLOW "Przeplyw"
#define MSG_CONTROL " Kontrola \003" #define MSG_CONTROL "Kontrola"
#define MSG_MIN " \002 Min:" #define MSG_MIN " \002 Min"
#define MSG_MAX " \002 Max:" #define MSG_MAX " \002 Max"
#define MSG_FACTOR " \002 Mnoznik:" #define MSG_FACTOR " \002 Mnoznik"
#define MSG_AUTOTEMP " Auto. temp.:" #define MSG_AUTOTEMP "Auto. temp."
#define MSG_ON "Wl. " #define MSG_ON "Wl. "
#define MSG_OFF "Wyl." #define MSG_OFF "Wyl."
#define MSG_PID_P " PID-P: " #define MSG_PID_P "PID-P"
#define MSG_PID_I " PID-I: " #define MSG_PID_I "PID-I"
#define MSG_PID_D " PID-D: " #define MSG_PID_D "PID-D"
#define MSG_PID_C " PID-C: " #define MSG_PID_C "PID-C"
#define MSG_ACC " Acc:" #define MSG_ACC "Acc"
#define MSG_VXY_JERK " Zryw Vxy: " #define MSG_VXY_JERK "Zryw Vxy"
#define MSG_VMAX "Vmax" #define MSG_VMAX "Vmax"
#define MSG_X "x:" #define MSG_X "x"
#define MSG_Y "y:" #define MSG_Y "y"
#define MSG_Z "z:" #define MSG_Z "z"
#define MSG_E "e:" #define MSG_E "e"
#define MSG_VMIN " Vmin:" #define MSG_VMIN "Vmin"
#define MSG_VTRAV_MIN " Vskok min:" #define MSG_VTRAV_MIN "Vskok min"
#define MSG_AMAX "Amax" #define MSG_AMAX "Amax"
#define MSG_A_RETRACT " A-wycofanie:" #define MSG_A_RETRACT "A-wycofanie"
#define MSG_XSTEPS " krokiX/mm:" #define MSG_XSTEPS "krokiX/mm"
#define MSG_YSTEPS " krokiY/mm:" #define MSG_YSTEPS "krokiY/mm"
#define MSG_ZSTEPS " krokiZ/mm:" #define MSG_ZSTEPS "krokiZ/mm"
#define MSG_ESTEPS " krokiE/mm:" #define MSG_ESTEPS "krokiE/mm"
#define MSG_MAIN_WIDE " Menu \003" #define MSG_RECTRACT "Wycofanie"
#define MSG_RECTRACT_WIDE " Wycofanie \x7E" #define MSG_TEMPERATURE "Temperatura"
#define MSG_TEMPERATURE_WIDE " Temperatura \x7E" #define MSG_MOTION "Ruch"
#define MSG_TEMPERATURE_RTN " Temperatura \003"
#define MSG_MOTION_WIDE " Ruch \x7E"
#define MSG_STORE_EPROM "Zapisz w pamieci" #define MSG_STORE_EPROM "Zapisz w pamieci"
#define MSG_LOAD_EPROM "Wczytaj z pamieci" #define MSG_LOAD_EPROM "Wczytaj z pamieci"
#define MSG_RESTORE_FAILSAFE " Ustawienia fabryczne" #define MSG_RESTORE_FAILSAFE " Ustawienia fabryczne"
#define MSG_REFRESH "\004Odswiez" #define MSG_REFRESH "\004Odswiez"
#define MSG_WATCH " Obserwuj \003" #define MSG_WATCH "Obserwuj"
#define MSG_PREPARE " Przygotuj \x7E" #define MSG_PREPARE "Przygotuj"
#define MSG_PREPARE_ALT " Przygotuj \003" #define MSG_CONTROL "Kontroluj"
#define MSG_CONTROL_ARROW " Kontroluj \x7E" #define MSG_TUNE "Strojenie"
#define MSG_RETRACT_ARROW " Wycofaj \x7E" #define MSG_PAUSE_PRINT "Pauza"
#define MSG_TUNE "Strojenie\x7E" #define MSG_RESUME_PRINT "Wznowienie"
#define MSG_PAUSE_PRINT " Pauza \x7E" #define MSG_STOP_PRINT "Stop"
#define MSG_RESUME_PRINT " Wznowienie \x7E" #define MSG_CARD_MENU "Menu SDCard"
#define MSG_STOP_PRINT " Stop \x7E"
#define MSG_CARD_MENU " Menu SDCard \x7E"
#define MSG_NO_CARD "Brak karty" #define MSG_NO_CARD "Brak karty"
#define MSG_DWELL "Uspij..." #define MSG_DWELL "Uspij..."
#define MSG_USERWAIT "Czekaj na uzytkownika..." #define MSG_USERWAIT "Czekaj na uzytkownika..."
@ -273,13 +261,12 @@
#define MSG_KILLED "Ubity. " #define MSG_KILLED "Ubity. "
#define MSG_STOPPED "Zatrzymany. " #define MSG_STOPPED "Zatrzymany. "
#define MSG_STEPPER_RELEASED "Zwolniony." #define MSG_STEPPER_RELEASED "Zwolniony."
#define MSG_CONTROL_RETRACT " Wycofaj mm:" #define MSG_CONTROL_RETRACT "Wycofaj mm"
#define MSG_CONTROL_RETRACTF " Wycofaj F:" #define MSG_CONTROL_RETRACTF "Wycofaj F"
#define MSG_CONTROL_RETRACT_ZLIFT "Skok Z mm:" #define MSG_CONTROL_RETRACT_ZLIFT "Skok Z mm:"
#define MSG_CONTROL_RETRACT_RECOVER " Cof. wycof. +mm:" #define MSG_CONTROL_RETRACT_RECOVER "Cof. wycof. +mm"
#define MSG_CONTROL_RETRACT_RECOVERF " Cof. wycof. F:" #define MSG_CONTROL_RETRACT_RECOVERF "Cof. wycof. F"
#define MSG_AUTORETRACT " Auto. wycofanie:" #define MSG_AUTORETRACT "Auto. wycofanie"
#define MSG_SERIAL_ERROR_MENU_STRUCTURE "Cos jest nie tak ze struktura menu."
// Serial Console Messages // Serial Console Messages
@ -439,7 +426,6 @@
#define MSG_CONTROL_RETRACT_RECOVER " UnRet +mm:" #define MSG_CONTROL_RETRACT_RECOVER " UnRet +mm:"
#define MSG_CONTROL_RETRACT_RECOVERF " UnRet F:" #define MSG_CONTROL_RETRACT_RECOVERF " UnRet F:"
#define MSG_AUTORETRACT " Retract. Auto.:" #define MSG_AUTORETRACT " Retract. Auto.:"
#define MSG_SERIAL_ERROR_MENU_STRUCTURE "Erreur avec MenuStructure."
// Serial Console Messages // Serial Console Messages
@ -599,7 +585,6 @@
#define MSG_CONTROL_RETRACT_RECOVER " UnRet +mm:" #define MSG_CONTROL_RETRACT_RECOVER " UnRet +mm:"
#define MSG_CONTROL_RETRACT_RECOVERF " UnRet F:" #define MSG_CONTROL_RETRACT_RECOVERF " UnRet F:"
#define MSG_AUTORETRACT " AutoRetr.:" #define MSG_AUTORETRACT " AutoRetr.:"
#define MSG_SERIAL_ERROR_MENU_STRUCTURE "Fehler in Menüstruktur."
// Serial Console Messages // Serial Console Messages
@ -758,7 +743,6 @@
#define MSG_CONTROL_RETRACT_RECOVER " DesRet +mm:" #define MSG_CONTROL_RETRACT_RECOVER " DesRet +mm:"
#define MSG_CONTROL_RETRACT_RECOVERF " DesRet F:" #define MSG_CONTROL_RETRACT_RECOVERF " DesRet F:"
#define MSG_AUTORETRACT " AutoRetr.:" #define MSG_AUTORETRACT " AutoRetr.:"
#define MSG_SERIAL_ERROR_MENU_STRUCTURE "Hay un error en la estructura del menu"
// Serial Console Messages // Serial Console Messages
@ -915,7 +899,6 @@
#define MSG_CONTROL_RETRACT_RECOVER " Возврат +mm:" #define MSG_CONTROL_RETRACT_RECOVER " Возврат +mm:"
#define MSG_CONTROL_RETRACT_RECOVERF " Возврат F:" #define MSG_CONTROL_RETRACT_RECOVERF " Возврат F:"
#define MSG_AUTORETRACT " АвтоОткат:" #define MSG_AUTORETRACT " АвтоОткат:"
#define MSG_SERIAL_ERROR_MENU_STRUCTURE "Ошибка в структуре меню."
// Serial Console Messages // Serial Console Messages

File diff suppressed because it is too large Load Diff

@ -5,21 +5,12 @@
#ifdef ULTRA_LCD #ifdef ULTRA_LCD
#if LANGUAGE_CHOICE == 6
#include "LiquidCrystalRus.h"
#define LCD_CLASS LiquidCrystalRus
#else
#include <LiquidCrystal.h>
#define LCD_CLASS LiquidCrystal
#endif
void lcd_update(); void lcd_update();
void lcd_init(); void lcd_init();
void lcd_setstatus(const char* message); void lcd_setstatus(const char* message);
void lcd_setstatuspgm(const char* message); void lcd_setstatuspgm(const char* message);
void lcd_setalertstatuspgm(const char* message); void lcd_setalertstatuspgm(const char* message);
void lcd_buttons_update(); void lcd_reset_alert_level();
void lcd_buttons_init();
#define LCD_MESSAGEPGM(x) lcd_setstatuspgm(PSTR(x)) #define LCD_MESSAGEPGM(x) lcd_setstatuspgm(PSTR(x))
#define LCD_ALERTMESSAGEPGM(x) lcd_setalertstatuspgm(PSTR(x)) #define LCD_ALERTMESSAGEPGM(x) lcd_setalertstatuspgm(PSTR(x))
@ -27,7 +18,12 @@
#define LCD_UPDATE_INTERVAL 100 #define LCD_UPDATE_INTERVAL 100
#define LCD_TIMEOUT_TO_STATUS 15000 #define LCD_TIMEOUT_TO_STATUS 15000
#ifdef ULTIPANEL
void lcd_buttons_update();
extern volatile uint8_t buttons; //the last checked buttons in a bit array. extern volatile uint8_t buttons; //the last checked buttons in a bit array.
#else
FORCE_INLINE void lcd_buttons_update() {}
#endif
extern int plaPreheatHotendTemp; extern int plaPreheatHotendTemp;
extern int plaPreheatHPBTemp; extern int plaPreheatHPBTemp;
@ -43,7 +39,6 @@
#define EN_A (1<<BLEN_A) #define EN_A (1<<BLEN_A)
#define LCD_CLICKED (buttons&EN_C) #define LCD_CLICKED (buttons&EN_C)
#define LCD_BLOCK {blocking=millis()+blocktime;}
#else #else
//atomatic, do not change //atomatic, do not change
#define B_LE (1<<BL_LE) #define B_LE (1<<BL_LE)
@ -56,101 +51,14 @@
#define EN_A (1<<BLEN_A) #define EN_A (1<<BLEN_A)
#define LCD_CLICKED ((buttons&B_MI)||(buttons&B_ST)) #define LCD_CLICKED ((buttons&B_MI)||(buttons&B_ST))
#define LCD_BLOCK {blocking[BL_MI]=millis()+blocktime;blocking[BL_ST]=millis()+blocktime;} #endif//NEWPANEL
#endif
// blocking time for recognizing a new keypress of one key, ms
#define blocktime 500
#define lcdslow 5
enum MainStatus{Main_Status, Main_Menu, Main_Prepare,Sub_PrepareMove, Main_Control, Main_SD,Sub_TempControl,Sub_MotionControl,Sub_RetractControl, Sub_PreheatPLASettings, Sub_PreheatABSSettings};
extern LCD_CLASS lcd;
class MainMenu{
public:
MainMenu();
void update();
int8_t activeline;
MainStatus status;
uint8_t displayStartingRow;
void showStatus();
void showMainMenu();
void showPrepare();
void showTune();
void showControl();
void showControlMotion();
void showControlTemp();
void showControlRetract();
void showAxisMove();
void showSD();
void showPLAsettings();
void showABSsettings();
bool force_lcd_update;
long lastencoderpos;
int8_t lineoffset;
int8_t lastlineoffset;
bool linechanging;
bool tune;
private:
FORCE_INLINE void updateActiveLines(const uint8_t &maxlines,volatile long &encoderpos)
{
if(linechanging) return; // an item is changint its value, do not switch lines hence
lastlineoffset=lineoffset;
long curencoderpos=encoderpos;
force_lcd_update=false;
if( (abs(curencoderpos-lastencoderpos)<lcdslow) )
{
lcd.setCursor(0,activeline);lcd.print((activeline+lineoffset)?' ':' ');
if(curencoderpos<0)
{
lineoffset--;
if(lineoffset<0) lineoffset=0;
curencoderpos=lcdslow-1;
}
if(curencoderpos>(LCD_HEIGHT-1+1)*lcdslow)
{
lineoffset++;
curencoderpos=(LCD_HEIGHT-1)*lcdslow;
if(lineoffset>(maxlines+1-LCD_HEIGHT))
lineoffset=maxlines+1-LCD_HEIGHT;
if(curencoderpos>maxlines*lcdslow)
curencoderpos=maxlines*lcdslow;
}
lastencoderpos=encoderpos=curencoderpos;
activeline=curencoderpos/lcdslow;
if(activeline<0) activeline=0;
if(activeline>LCD_HEIGHT-1) activeline=LCD_HEIGHT-1;
if(activeline>maxlines)
{
activeline=maxlines;
curencoderpos=maxlines*lcdslow;
}
if(lastlineoffset!=lineoffset)
force_lcd_update=true;
lcd.setCursor(0,activeline);lcd.print((activeline+lineoffset)?'>':'\003');
}
}
FORCE_INLINE void clearIfNecessary()
{
if(lastlineoffset!=lineoffset ||force_lcd_update)
{
force_lcd_update=true;
lcd.clear();
}
}
};
#else //no lcd #else //no lcd
FORCE_INLINE void lcd_update() {} FORCE_INLINE void lcd_update() {}
FORCE_INLINE void lcd_init() {} FORCE_INLINE void lcd_init() {}
FORCE_INLINE void lcd_setstatus(const char* message) {} FORCE_INLINE void lcd_setstatus(const char* message) {}
FORCE_INLINE void lcd_buttons_init() {}
FORCE_INLINE void lcd_buttons_update() {} FORCE_INLINE void lcd_buttons_update() {}
FORCE_INLINE void lcd_reset_alert_level() {}
#define LCD_MESSAGEPGM(x) #define LCD_MESSAGEPGM(x)
#define LCD_ALERTMESSAGEPGM(x) #define LCD_ALERTMESSAGEPGM(x)
@ -162,11 +70,13 @@
char *itostr2(const uint8_t &x); char *itostr2(const uint8_t &x);
char *itostr31(const int &xx); char *itostr31(const int &xx);
char *itostr3(const int &xx); char *itostr3(const int &xx);
char *itostr3left(const int &xx);
char *itostr4(const int &xx); char *itostr4(const int &xx);
char *ftostr3(const float &x); char *ftostr3(const float &x);
char *ftostr31(const float &x); char *ftostr31(const float &x);
char *ftostr32(const float &x); char *ftostr32(const float &x);
char *ftostr5(const float &x);
char *ftostr51(const float &x); char *ftostr51(const float &x);
char *ftostr52(const float &x); char *ftostr52(const float &x);

@ -0,0 +1,461 @@
#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.
**/
#if LANGUAGE_CHOICE == 6
#include "LiquidCrystalRus.h"
#define LCD_CLASS LiquidCrystalRus
#else
#include <LiquidCrystal.h>
#define LCD_CLASS LiquidCrystal
#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 */
LiquidCrystal 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
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
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();
}
/*
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.print(F(LCD_STR_DEGREE " "));
# 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.print(F(LCD_STR_DEGREE " "));
# 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.print(F("SD"));
if (IS_SD_PRINTING)
lcd.print(itostr3(card.percentDone()));
else
lcd.print(F("---"));
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.print(F(LCD_STR_DEGREE " "));
# else
lcd.setCursor(0,1);
lcd.print('X');
lcd.print(ftostr3(current_position[X_AXIS]));
lcd.print(F(" Y"));
lcd.print(ftostr3(current_position[Y_AXIS]));
# endif//EXTRUDERS > 1 || TEMP_SENSOR_BED != 0
# endif//LCD_WIDTH > 19
lcd.setCursor(LCD_WIDTH - 7, 1);
lcd.print('Z');
lcd.print(ftostr31(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(F("%"));
# if LCD_WIDTH > 19
# ifdef SDSUPPORT
lcd.setCursor(7, 2);
lcd.print(F("SD"));
if (IS_SD_PRINTING)
lcd.print(itostr3(card.percentDone()));
else
lcd.print(F("---"));
lcd.print(F("%"));
# 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(F(":"));
lcd.print(itostr2(time%60));
}else{
lcd.print(F("--:--"));
}
#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;
uint8_t n = LCD_WIDTH - 1 - 2;
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;
uint8_t n = LCD_WIDTH - 1 - 2 - strlen(data);
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;
uint8_t n = LCD_WIDTH - 1 - 2 - strlen_P(data);
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(reinterpret_cast<const __FlashStringHelper *>(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(0, 1);
lcd.print(reinterpret_cast<const __FlashStringHelper *>(pstr));
lcd.print(':');
lcd.setCursor(19 - strlen(value), 1);
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
Loading…
Cancel
Save