Browse Source

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.
Filip Mulier 9 years ago
parent
commit
d84934d8c5

+ 3
- 1
Marlin/Configuration.h View File

@@ -773,7 +773,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
773 773
  * 
774 774
  * Motherboards
775 775
  * 34 - RAMPS1.4 - uses Analog input 5 on the AUX2 connector 
776
- * 81 - Printrboard - Uses Analog input 2 on the Aux 2 connector
776
+ * 81 - Printrboard - Uses Analog input 2 on the Exp1 connector (version B,C,D,E)
777 777
  * 301 - Rambo  - uses Analog input 3
778 778
  * Note may require analog pins to be defined for different motherboards
779 779
  **********************************************************************/
@@ -789,6 +789,8 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
789 789
 //defines used in the code
790 790
 #define DEFAULT_MEASURED_FILAMENT_DIA  DEFAULT_NOMINAL_FILAMENT_DIA  //set measured to nominal initially 
791 791
 
792
+//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.
793
+//#define FILAMENT_LCD_DISPLAY
792 794
 
793 795
 
794 796
 

+ 29
- 0
Marlin/ultralcd.cpp View File

@@ -20,6 +20,12 @@ int absPreheatHPBTemp;
20 20
 int absPreheatFanSpeed;
21 21
 
22 22
 
23
+#ifdef FILAMENT_LCD_DISPLAY
24
+unsigned long message_millis=0;
25
+#endif
26
+
27
+
28
+
23 29
 #ifdef ULTIPANEL
24 30
 static float manual_feedrate[] = MANUAL_FEEDRATE;
25 31
 #endif // ULTIPANEL
@@ -195,6 +201,9 @@ static void lcd_status_screen()
195 201
         encoderPosition = 0;
196 202
         lcd_quick_feedback();
197 203
         lcd_implementation_init(); // to maybe revive the LCD if static electricity killed it.
204
+#ifdef FILAMENT_LCD_DISPLAY
205
+        message_millis=millis();  //get status message to show up for a while
206
+#endif
198 207
     }
199 208
 
200 209
 #ifdef ULTIPANEL_FEEDMULTIPLY
@@ -1321,6 +1330,9 @@ void lcd_setstatus(const char* message)
1321 1330
         return;
1322 1331
     strncpy(lcd_status_message, message, LCD_WIDTH);
1323 1332
     lcdDrawUpdate = 2;
1333
+#ifdef FILAMENT_LCD_DISPLAY
1334
+        message_millis=millis();  //get status message to show up for a while
1335
+#endif
1324 1336
 }
1325 1337
 void lcd_setstatuspgm(const char* message)
1326 1338
 {
@@ -1328,6 +1340,9 @@ void lcd_setstatuspgm(const char* message)
1328 1340
         return;
1329 1341
     strncpy_P(lcd_status_message, message, LCD_WIDTH);
1330 1342
     lcdDrawUpdate = 2;
1343
+#ifdef FILAMENT_LCD_DISPLAY
1344
+        message_millis=millis();  //get status message to show up for a while
1345
+#endif
1331 1346
 }
1332 1347
 void lcd_setalertstatuspgm(const char* message)
1333 1348
 {
@@ -1515,6 +1530,20 @@ char *ftostr32(const float &x)
1515 1530
   return conv;
1516 1531
 }
1517 1532
 
1533
+//Float to string with 1.23 format
1534
+char *ftostr12ns(const float &x)
1535
+{
1536
+  long xx=x*100;
1537
+  
1538
+  xx=abs(xx);
1539
+  conv[0]=(xx/100)%10+'0';
1540
+  conv[1]='.';
1541
+  conv[2]=(xx/10)%10+'0';
1542
+  conv[3]=(xx)%10+'0';
1543
+  conv[4]=0;
1544
+  return conv;
1545
+}
1546
+
1518 1547
 char *itostr31(const int &xx)
1519 1548
 {
1520 1549
   conv[0]=(xx>=0)?'+':'-';

+ 5
- 0
Marlin/ultralcd.h View File

@@ -44,6 +44,10 @@
44 44
   extern int absPreheatFanSpeed;
45 45
   
46 46
   extern bool cancel_heatup;
47
+  
48
+  #ifdef FILAMENT_LCD_DISPLAY
49
+        extern unsigned long message_millis;
50
+  #endif
47 51
     
48 52
   void lcd_buzz(long duration,uint16_t freq);
49 53
   bool lcd_clicked();
@@ -109,6 +113,7 @@ char *ftostr3(const float &x);
109 113
 char *ftostr31ns(const float &x); // float to string without sign character
110 114
 char *ftostr31(const float &x);
111 115
 char *ftostr32(const float &x);
116
+char *ftostr12ns(const float &x); 
112 117
 char *ftostr5(const float &x);
113 118
 char *ftostr51(const float &x);
114 119
 char *ftostr52(const float &x);

+ 15
- 1
Marlin/ultralcd_implementation_hitachi_HD44780.h View File

@@ -499,9 +499,23 @@ static void lcd_implementation_status_screen()
499 499
     }
500 500
 #endif
501 501
 
502
-    //Status message line on the last line
502
+    //Display both Status message line and Filament display on the last line
503
+    #ifdef FILAMENT_LCD_DISPLAY
504
+      if(message_millis+5000>millis()){  //display any status for the first 5 sec after screen is initiated
505
+         	 lcd.setCursor(0, LCD_HEIGHT - 1);
506
+        	 lcd.print(lcd_status_message);
507
+        } else {
508
+		     lcd.setCursor(0,LCD_HEIGHT - 1);
509
+		     lcd_printPGM(PSTR("Dia "));
510
+		     lcd.print(ftostr12ns(filament_width_meas));
511
+		     lcd_printPGM(PSTR(" V"));
512
+		     lcd.print(itostr3(100.0*volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]));
513
+    		 lcd.print('%');
514
+        }
515
+    #else
503 516
     lcd.setCursor(0, LCD_HEIGHT - 1);
504 517
     lcd.print(lcd_status_message);
518
+    #endif
505 519
 }
506 520
 static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, char pre_char, char post_char)
507 521
 {

Loading…
Cancel
Save