5 #include <LiquidCrystal.h>
8 void lcd_status(const char* message);
13 #define LCD_UPDATE_INTERVAL 100
14 #define STATUSTIMEOUT 15000
15 extern LiquidCrystal lcd;
16 extern volatile char buttons; //the last checked buttons in a bit array.
19 #define EN_C (1<<BLEN_C)
20 #define EN_B (1<<BLEN_B)
21 #define EN_A (1<<BLEN_A)
23 #define CLICKED (buttons&EN_C)
24 #define BLOCK {blocking=millis()+blocktime;}
25 #if (SDCARDDETECT > -1)
26 #ifdef SDCARDDETECTINVERTED
27 #define CARDINSERTED (READ(SDCARDDETECT)!=0)
29 #define CARDINSERTED (READ(SDCARDDETECT)==0)
31 #endif //SDCARDTETECTINVERTED
35 //atomatic, do not change
36 #define B_LE (1<<BL_LE)
37 #define B_UP (1<<BL_UP)
38 #define B_MI (1<<BL_MI)
39 #define B_DW (1<<BL_DW)
40 #define B_RI (1<<BL_RI)
41 #define B_ST (1<<BL_ST)
42 #define EN_B (1<<BLEN_B)
43 #define EN_A (1<<BLEN_A)
45 #define CLICKED ((buttons&B_MI)||(buttons&B_ST))
46 #define BLOCK {blocking[BL_MI]=millis()+blocktime;blocking[BL_ST]=millis()+blocktime;}
50 // blocking time for recognizing a new keypress of one key, ms
54 enum MainStatus{Main_Status, Main_Menu, Main_Prepare,Sub_PrepareMove, Main_Control, Main_SD,Sub_TempControl,Sub_MotionControl};
62 uint8_t displayStartingRow;
69 void showControlMotion();
70 void showControlTemp();
73 bool force_lcd_update;
76 int8_t lastlineoffset;
83 FORCE_INLINE void updateActiveLines(const uint8_t &maxlines,volatile long &encoderpos)
85 if(linechanging) return; // an item is changint its value, do not switch lines hence
86 lastlineoffset=lineoffset;
87 long curencoderpos=encoderpos;
88 force_lcd_update=false;
89 if( (abs(curencoderpos-lastencoderpos)<lcdslow) )
91 lcd.setCursor(0,activeline);lcd.print((activeline+lineoffset)?' ':' ');
95 if(lineoffset<0) lineoffset=0;
96 curencoderpos=lcdslow-1;
98 if(curencoderpos>(LCD_HEIGHT-1+1)*lcdslow)
101 curencoderpos=(LCD_HEIGHT-1)*lcdslow;
102 if(lineoffset>(maxlines+1-LCD_HEIGHT))
103 lineoffset=maxlines+1-LCD_HEIGHT;
104 if(curencoderpos>maxlines*lcdslow)
105 curencoderpos=maxlines*lcdslow;
107 lastencoderpos=encoderpos=curencoderpos;
108 activeline=curencoderpos/lcdslow;
109 if(activeline<0) activeline=0;
110 if(activeline>LCD_HEIGHT-1) activeline=LCD_HEIGHT-1;
111 if(activeline>maxlines)
114 curencoderpos=maxlines*lcdslow;
116 if(lastlineoffset!=lineoffset)
117 force_lcd_update=true;
118 lcd.setCursor(0,activeline);lcd.print((activeline+lineoffset)?'>':'\003');
122 FORCE_INLINE void clearIfNecessary()
124 if(lastlineoffset!=lineoffset ||force_lcd_update)
126 force_lcd_update=true;
132 //conversion routines, could need some overworking
133 char *ftostr51(const float &x);
134 char *ftostr52(const float &x);
135 char *ftostr31(const float &x);
136 char *ftostr3(const float &x);
139 #define LCD_INIT lcd_init();
140 #define LCD_MESSAGE(x) lcd_status(x);
141 #define LCD_MESSAGEPGM(x) lcd_statuspgm(MYPGM(x));
142 #define LCD_STATUS lcd_status()
146 #define LCD_MESSAGE(x)
147 #define LCD_MESSAGEPGM(x)
148 FORCE_INLINE void lcd_status() {};
150 #define CLICKED false
154 void lcd_statuspgm(const char* message);
156 char *ftostr3(const float &x);
157 char *itostr2(const uint8_t &x);
158 char *ftostr31(const float &x);
159 char *ftostr32(const float &x);
160 char *itostr31(const int &xx);
161 char *itostr3(const int &xx);
162 char *itostr4(const int &xx);
163 char *ftostr51(const float &x);