5 #include <LiquidCrystal.h>
8 void lcd_status(const char* message);
12 #define LCD_UPDATE_INTERVAL 100
13 #define STATUSTIMEOUT 15000
14 extern LiquidCrystal lcd;
17 #define EN_C (1<<BLEN_C)
18 #define EN_B (1<<BLEN_B)
19 #define EN_A (1<<BLEN_A)
21 #define CLICKED (buttons&EN_C)
22 #define BLOCK {blocking=millis()+blocktime;}
23 #if (SDCARDDETECT > -1)
24 #ifdef SDCARDDETECTINVERTED
25 #define CARDINSERTED (READ(SDCARDDETECT)!=0)
27 #define CARDINSERTED (READ(SDCARDDETECT)==0)
29 #endif //SDCARDTETECTINVERTED
33 //atomatic, do not change
34 #define B_LE (1<<BL_LE)
35 #define B_UP (1<<BL_UP)
36 #define B_MI (1<<BL_MI)
37 #define B_DW (1<<BL_DW)
38 #define B_RI (1<<BL_RI)
39 #define B_ST (1<<BL_ST)
40 #define EN_B (1<<BLEN_B)
41 #define EN_A (1<<BLEN_A)
43 #define CLICKED ((buttons&B_MI)||(buttons&B_ST))
44 #define BLOCK {blocking[BL_MI]=millis()+blocktime;blocking[BL_ST]=millis()+blocktime;}
48 // blocking time for recognizing a new keypress of one key, ms
52 enum MainStatus{Main_Status, Main_Menu, Main_Prepare,Sub_PrepareMove, Main_Control, Main_SD,Sub_TempControl,Sub_MotionControl};
60 uint8_t displayStartingRow;
67 void showControlMotion();
68 void showControlTemp();
71 bool force_lcd_update;
74 int8_t lastlineoffset;
81 FORCE_INLINE void updateActiveLines(const uint8_t &maxlines,volatile int &encoderpos)
83 if(linechanging) return; // an item is changint its value, do not switch lines hence
84 lastlineoffset=lineoffset;
85 int curencoderpos=encoderpos;
86 force_lcd_update=false;
87 if( (abs(curencoderpos-lastencoderpos)<lcdslow) )
89 lcd.setCursor(0,activeline);lcd.print((activeline+lineoffset)?' ':' ');
93 if(lineoffset<0) lineoffset=0;
94 curencoderpos=lcdslow-1;
96 if(curencoderpos>(LCD_HEIGHT-1+1)*lcdslow)
99 curencoderpos=(LCD_HEIGHT-1)*lcdslow;
100 if(lineoffset>(maxlines+1-LCD_HEIGHT))
101 lineoffset=maxlines+1-LCD_HEIGHT;
102 if(curencoderpos>maxlines*lcdslow)
103 curencoderpos=maxlines*lcdslow;
105 lastencoderpos=encoderpos=curencoderpos;
106 activeline=curencoderpos/lcdslow;
107 if(activeline<0) activeline=0;
108 if(activeline>LCD_HEIGHT-1) activeline=LCD_HEIGHT-1;
109 if(activeline>maxlines)
112 curencoderpos=maxlines*lcdslow;
114 if(lastlineoffset!=lineoffset)
115 force_lcd_update=true;
116 lcd.setCursor(0,activeline);lcd.print((activeline+lineoffset)?'>':'\003');
120 FORCE_INLINE void clearIfNecessary()
122 if(lastlineoffset!=lineoffset ||force_lcd_update)
124 force_lcd_update=true;
130 //conversion routines, could need some overworking
131 char *ftostr51(const float &x);
132 char *ftostr52(const float &x);
133 char *ftostr31(const float &x);
134 char *ftostr3(const float &x);
138 #define LCD_MESSAGE(x) lcd_status(x);
139 #define LCD_MESSAGEPGM(x) lcd_statuspgm(MYPGM(x));
140 #define LCD_STATUS lcd_status()
143 #define LCD_MESSAGE(x)
144 #define LCD_MESSAGEPGM(x)
145 FORCE_INLINE void lcd_status() {};
147 #define CLICKED false
151 void lcd_statuspgm(const char* message);
153 char *ftostr3(const float &x);
154 char *itostr2(const uint8_t &x);
155 char *ftostr31(const float &x);
156 char *ftostr32(const float &x);
157 char *itostr31(const int &xx);
158 char *itostr3(const int &xx);
159 char *itostr4(const int &xx);
160 char *ftostr51(const float &x);