From a49c09a776ba2eec345cd00b3d66086a2c7361c7 Mon Sep 17 00:00:00 2001 From: Dirk Eichel Date: Tue, 19 Mar 2013 20:13:23 +0100 Subject: [PATCH] Add variable for animated fan, add float conversion w/o sign A new variable was introduced to allow fan animation on the GLCD. Add additional float to string conversion routine without sign character. This is used for the coordinates visualisation on the GLCD. --- Marlin/ultralcd.cpp | 15 +++++++++++++++ Marlin/ultralcd.h | 3 +++ 2 files changed, 18 insertions(+) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index db2d2766ca..74dc20b91d 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -893,6 +893,21 @@ char *ftostr31(const float &x) return conv; } +// convert float to string with 123.4 format +char *ftostr31ns(const float &x) +{ + int xx=x*10; + //conv[0]=(xx>=0)?'+':'-'; + xx=abs(xx); + conv[0]=(xx/1000)%10+'0'; + conv[1]=(xx/100)%10+'0'; + conv[2]=(xx/10)%10+'0'; + conv[3]='.'; + conv[4]=(xx)%10+'0'; + conv[5]=0; + return conv; +} + char *ftostr32(const float &x) { long xx=x*100; diff --git a/Marlin/ultralcd.h b/Marlin/ultralcd.h index df7746a1ab..28de229726 100644 --- a/Marlin/ultralcd.h +++ b/Marlin/ultralcd.h @@ -11,6 +11,8 @@ void lcd_setstatuspgm(const char* message); void lcd_setalertstatuspgm(const char* message); void lcd_reset_alert_level(); + + static unsigned char blink = 0; // Variable for visualisation of fan rotation in GLCD #define LCD_MESSAGEPGM(x) lcd_setstatuspgm(PSTR(x)) #define LCD_ALERTMESSAGEPGM(x) lcd_setalertstatuspgm(PSTR(x)) @@ -71,6 +73,7 @@ char *itostr3left(const int &xx); char *itostr4(const int &xx); 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 *ftostr5(const float &x);