From d84934d8c5bdb7f8298760ce487da4c9c33bc438 Mon Sep 17 00:00:00 2001 From: Filip Mulier Date: Mon, 10 Nov 2014 21:43:58 -0600 Subject: [PATCH] Display Filament Sensor data on 20x4 LCD Changes to support displaying the real-time filament width and the volume factor on a 20x4 LCD. The data is displayed on the 4th line. First the status message is displayed for 5 seconds, and then the filament data is displayed. The status message can be seen by re-selecting the info screen in the menu. --- Marlin/Configuration.h | 4 ++- Marlin/ultralcd.cpp | 29 +++++++++++++++++++ Marlin/ultralcd.h | 5 ++++ .../ultralcd_implementation_hitachi_HD44780.h | 16 +++++++++- 4 files changed, 52 insertions(+), 2 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index d2aba196d9..e2cadaa17f 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -773,7 +773,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of * * Motherboards * 34 - RAMPS1.4 - uses Analog input 5 on the AUX2 connector - * 81 - Printrboard - Uses Analog input 2 on the Aux 2 connector + * 81 - Printrboard - Uses Analog input 2 on the Exp1 connector (version B,C,D,E) * 301 - Rambo - uses Analog input 3 * Note may require analog pins to be defined for different motherboards **********************************************************************/ @@ -789,6 +789,8 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of //defines used in the code #define DEFAULT_MEASURED_FILAMENT_DIA DEFAULT_NOMINAL_FILAMENT_DIA //set measured to nominal initially +//When using an LCD, uncomment the line below to display the Filament sensor data on the last line instead of status. Status will appear for 5 sec. +//#define FILAMENT_LCD_DISPLAY diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 734c859d02..5873cc7146 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -20,6 +20,12 @@ int absPreheatHPBTemp; int absPreheatFanSpeed; +#ifdef FILAMENT_LCD_DISPLAY +unsigned long message_millis=0; +#endif + + + #ifdef ULTIPANEL static float manual_feedrate[] = MANUAL_FEEDRATE; #endif // ULTIPANEL @@ -195,6 +201,9 @@ static void lcd_status_screen() encoderPosition = 0; lcd_quick_feedback(); lcd_implementation_init(); // to maybe revive the LCD if static electricity killed it. +#ifdef FILAMENT_LCD_DISPLAY + message_millis=millis(); //get status message to show up for a while +#endif } #ifdef ULTIPANEL_FEEDMULTIPLY @@ -1321,6 +1330,9 @@ void lcd_setstatus(const char* message) return; strncpy(lcd_status_message, message, LCD_WIDTH); lcdDrawUpdate = 2; +#ifdef FILAMENT_LCD_DISPLAY + message_millis=millis(); //get status message to show up for a while +#endif } void lcd_setstatuspgm(const char* message) { @@ -1328,6 +1340,9 @@ void lcd_setstatuspgm(const char* message) return; strncpy_P(lcd_status_message, message, LCD_WIDTH); lcdDrawUpdate = 2; +#ifdef FILAMENT_LCD_DISPLAY + message_millis=millis(); //get status message to show up for a while +#endif } void lcd_setalertstatuspgm(const char* message) { @@ -1515,6 +1530,20 @@ char *ftostr32(const float &x) return conv; } +//Float to string with 1.23 format +char *ftostr12ns(const float &x) +{ + long xx=x*100; + + xx=abs(xx); + conv[0]=(xx/100)%10+'0'; + conv[1]='.'; + conv[2]=(xx/10)%10+'0'; + conv[3]=(xx)%10+'0'; + conv[4]=0; + return conv; +} + char *itostr31(const int &xx) { conv[0]=(xx>=0)?'+':'-'; diff --git a/Marlin/ultralcd.h b/Marlin/ultralcd.h index 9bf685805d..ca342c144e 100644 --- a/Marlin/ultralcd.h +++ b/Marlin/ultralcd.h @@ -44,6 +44,10 @@ extern int absPreheatFanSpeed; extern bool cancel_heatup; + + #ifdef FILAMENT_LCD_DISPLAY + extern unsigned long message_millis; + #endif void lcd_buzz(long duration,uint16_t freq); bool lcd_clicked(); @@ -109,6 +113,7 @@ char *ftostr3(const float &x); char *ftostr31ns(const float &x); // float to string without sign character char *ftostr31(const float &x); char *ftostr32(const float &x); +char *ftostr12ns(const float &x); char *ftostr5(const float &x); char *ftostr51(const float &x); char *ftostr52(const float &x); diff --git a/Marlin/ultralcd_implementation_hitachi_HD44780.h b/Marlin/ultralcd_implementation_hitachi_HD44780.h index befb25bfdb..d5f62e8697 100644 --- a/Marlin/ultralcd_implementation_hitachi_HD44780.h +++ b/Marlin/ultralcd_implementation_hitachi_HD44780.h @@ -499,9 +499,23 @@ static void lcd_implementation_status_screen() } #endif - //Status message line on the last line + //Display both Status message line and Filament display on the last line + #ifdef FILAMENT_LCD_DISPLAY + if(message_millis+5000>millis()){ //display any status for the first 5 sec after screen is initiated + lcd.setCursor(0, LCD_HEIGHT - 1); + lcd.print(lcd_status_message); + } else { + lcd.setCursor(0,LCD_HEIGHT - 1); + lcd_printPGM(PSTR("Dia ")); + lcd.print(ftostr12ns(filament_width_meas)); + lcd_printPGM(PSTR(" V")); + lcd.print(itostr3(100.0*volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM])); + lcd.print('%'); + } + #else lcd.setCursor(0, LCD_HEIGHT - 1); lcd.print(lcd_status_message); + #endif } static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, char pre_char, char post_char) {