code cleanup in ultralcd.
This commit is contained in:
@ -72,6 +72,55 @@
|
||||
int8_t lastlineoffset;
|
||||
|
||||
bool linechanging;
|
||||
|
||||
private:
|
||||
inline void updateActiveLines(const uint8_t &maxlines,volatile int &encoderpos)
|
||||
{
|
||||
if(linechanging) return; // an item is changint its value, do not switch lines hence
|
||||
lastlineoffset=lineoffset;
|
||||
int curencoderpos=encoderpos;
|
||||
force_lcd_update=false;
|
||||
if( (abs(curencoderpos-lastencoderpos)<lcdslow) )
|
||||
{
|
||||
lcd.setCursor(0,activeline);lcd.print((activeline+lineoffset)?' ':' ');
|
||||
if(curencoderpos<0)
|
||||
{
|
||||
lineoffset--;
|
||||
if(lineoffset<0) lineoffset=0;
|
||||
curencoderpos=lcdslow-1;
|
||||
force_lcd_update=true;
|
||||
}
|
||||
if(curencoderpos>(LCD_HEIGHT-1+1)*lcdslow)
|
||||
{
|
||||
lineoffset++;
|
||||
curencoderpos=(LCD_HEIGHT-1)*lcdslow;
|
||||
if(lineoffset>(maxlines+1-LCD_HEIGHT))
|
||||
lineoffset=maxlines+1-LCD_HEIGHT;
|
||||
if(curencoderpos>maxlines*lcdslow)
|
||||
curencoderpos=maxlines*lcdslow;
|
||||
force_lcd_update=true;
|
||||
}
|
||||
lastencoderpos=encoderpos=curencoderpos;
|
||||
activeline=curencoderpos/lcdslow;
|
||||
if(activeline<0) activeline=0;
|
||||
if(activeline>LCD_HEIGHT-1) activeline=LCD_HEIGHT-1;
|
||||
if(activeline>maxlines)
|
||||
{
|
||||
activeline=maxlines;
|
||||
curencoderpos=maxlines*lcdslow;
|
||||
}
|
||||
lcd.setCursor(0,activeline);lcd.print((activeline+lineoffset)?'>':'\003');
|
||||
}
|
||||
}
|
||||
|
||||
inline void clearIfNecessary()
|
||||
{
|
||||
if(lastlineoffset!=lineoffset ||force_lcd_update)
|
||||
{
|
||||
force_lcd_update=true;
|
||||
lcd.clear();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//conversion routines, could need some overworking
|
||||
|
Reference in New Issue
Block a user