Merge pull request #1141 from filipmu/Filament-Sensor

Display filament sensor data on a 20x4 LCD or Graphical LCD
This commit is contained in:
Bo Herrmannsen
2014-12-17 20:38:30 +01:00
6 changed files with 75 additions and 3 deletions

View File

@ -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
**********************************************************************/
@ -791,6 +791,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

View File

@ -328,7 +328,21 @@ static void lcd_implementation_status_screen()
// Status line
u8g.setFont(FONT_STATUSMENU);
u8g.setPrintPos(0,61);
u8g.print(lcd_status_message);
#ifndef FILAMENT_LCD_DISPLAY
u8g.print(lcd_status_message);
#else
if(message_millis+5000>millis()){ //Display both Status message line and Filament display on the last line
u8g.print(lcd_status_message);
}
else
{
lcd_printPGM(PSTR("dia:"));
u8g.print(ftostr12ns(filament_width_meas));
lcd_printPGM(PSTR(" factor:"));
u8g.print(itostr3(extrudemultiply));
u8g.print('%');
}
#endif
}

View File

@ -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
@ -216,6 +222,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
@ -1355,6 +1364,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)
{
@ -1362,6 +1374,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)
{
@ -1549,6 +1564,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)?'+':'-';

View File

@ -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();
@ -111,6 +115,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);

View File

@ -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)
{