Library for EarthLCD ezLCD3xx line of products
Diff: ezLCDLib.cpp
- Revision:
- 3:28e71ce23bfd
- Parent:
- 2:fc7d151593f1
- Child:
- 5:4a6254e2012f
--- a/ezLCDLib.cpp Sun Apr 28 19:33:18 2013 +0000 +++ b/ezLCDLib.cpp Mon Apr 29 03:04:13 2013 +0000 @@ -91,15 +91,14 @@ void ezLCD3::stripSpace(char* str) { - char* i = str; - char* j = str; - while(*j != 0) - { - *i = *j++; - if(*i != ' ') - i++; - } - *i = 0; + char* i = str; + char* j = str; + while(*j != 0) { + *i = *j++; + if(*i != ' ') + i++; + } + *i = 0; } int ezLCD3::getInt( char *str ) @@ -168,7 +167,6 @@ } void ezLCD3::color(int fColor) { - //pc.printf("color"); sendInt(Color); _ser.putc(' '); sendInt(fColor); @@ -176,11 +174,6 @@ waitForCR(); } -void ezLCD3::pos(int col, int row) -{ - //posXY(XSIZE*col, (YSIZE*row)); -} - void ezLCD3::xy(int x, int y) { sendInt(XY); @@ -250,7 +243,6 @@ void ezLCD3::light(int i) { - //pc.printf("light"); if (i >= 0 && i <= 100) { sendInt(Light); putc(' '); @@ -275,16 +267,21 @@ return getInt( buf ); } +void ezLCD3::sendString( char *str ) +{ + unsigned char c; + while( (c = *str++) ) + _ser.putc(c); +} + void ezLCD3::setStringID( int ID, char *str ) { - unsigned char c; sendInt(StringID); _ser.putc(' '); sendInt(ID); _ser.putc(' '); _ser.putc('\"'); - while( (c = *str++) ) - _ser.putc(c); + sendString(str); _ser.putc('\"'); _ser.putc('\r'); waitForCR(); @@ -299,34 +296,59 @@ getString(str); } -void ezLCD3::reverseMode() -{ - putc(0x7c); - putc(0x12); -} - -void ezLCD3::resolution(int type) -{ - -} - void ezLCD3::print( char *str ) { - unsigned char c; +// unsigned char c; sendInt(Print); _ser.putc(' '); _ser.putc('\"'); - while( (c = *str++) ) - _ser.putc(c); + sendString(str); +// while( (c = *str++) ) +// _ser.putc(c); + _ser.putc('\"'); + _ser.putc('\r'); + waitForCR(); +} +void ezLCD3::fontw( int ID, char *str) +{ + sendInt(Fontw); + _ser.putc(' '); + sendInt(ID); + _ser.putc(' '); + _ser.putc('\"'); + sendString(str); _ser.putc('\"'); _ser.putc('\r'); waitForCR(); } -void ezLCD3::resolution(int x, int y) +void ezLCD3::theme(int ID, int EmbossDkColor, int EmbossLtColor, int TextColor0, int TextColor1, int TextColorDisabled, int Color0, int Color1, int ColorDisabled, int CommonBkColor, int Fontw) { - _xMax = x; - _yMax = y; + sendInt(Widget_Theme); + _ser.putc(' '); + sendInt(ID); + _ser.putc(' '); + sendInt(EmbossDkColor); + _ser.putc(' '); + sendInt(EmbossLtColor); + _ser.putc(' '); + sendInt(TextColor0); + _ser.putc(' '); + sendInt(TextColor1); + _ser.putc(' '); + sendInt(TextColorDisabled); + _ser.putc(' '); + sendInt(Color0); + _ser.putc(' '); + sendInt(Color1); + _ser.putc(' '); + sendInt(ColorDisabled); + _ser.putc(' '); + sendInt(CommonBkColor); + _ser.putc(' '); + sendInt(Fontw); + _ser.putc('\r'); + waitForCR(); } //ameter [ID][x][y][width][height][options][value][min][max][theme][stringID][type] @@ -409,6 +431,80 @@ _ser.putc('\r'); waitForCR(); } +void ezLCD3::image( char *str ) +{ + sendInt(Picture); + _ser.putc(' '); + _ser.putc('\"'); + sendString(str); + _ser.putc('\"'); + _ser.putc('\r'); + waitForCR(); +} + +void ezLCD3::progressBar(int ID, int x, int y, int w, int h, int option, int value, int max, int theme, int stringID) +{ + sendInt(Set_Progress); + _ser.putc(' '); + sendInt(ID); + _ser.putc(' '); + sendInt(x); + _ser.putc(' '); + sendInt(y); + _ser.putc(' '); + sendInt(w); + _ser.putc(' '); + sendInt(h); + _ser.putc(' '); + sendInt(option); + _ser.putc(' '); + sendInt(value); + _ser.putc(' '); + sendInt(max); + _ser.putc(' '); + sendInt(theme); + _ser.putc(' '); + sendInt(stringID); + _ser.putc('\r'); + waitForCR(); +} + +void ezLCD3::image( int x, int y, char *str ) +{ + sendInt(Picture); + _ser.putc(' '); + sendInt(x); + _ser.putc(' '); + sendInt(y); + _ser.putc(' '); + _ser.putc('\"'); + sendString(str); + _ser.putc('\"'); + _ser.putc('\r'); + waitForCR(); +} +void ezLCD3::staticText( int ID, int x, int y, int w, int h, int option, int theme, int stringID) +{ + sendInt(Set_StaticText); + _ser.putc(' '); + sendInt(ID); + _ser.putc(' '); + sendInt(x); + _ser.putc(' '); + sendInt(y); + _ser.putc(' '); + sendInt(w); + _ser.putc(' '); + sendInt(h); + _ser.putc(' '); + sendInt(option); + _ser.putc(' '); + sendInt(theme); + _ser.putc(' '); + sendInt(stringID); + _ser.putc('\r'); + waitForCR(); +} unsigned int ezLCD3::wstack( int type ) { @@ -419,10 +515,37 @@ getString( buf ); return getInt( buf ); } +void ezLCD3::wvalue( int ID, int value) +{ + sendInt( Widget_Values ); + _ser.putc(' '); + sendInt( ID ); + _ser.putc(' '); + sendInt( value ); + _ser.putc('\r'); + waitForCR(); +} +void ezLCD3::wstate( int ID, int option ) +{ + sendInt( Widget_State ); + _ser.putc(' '); + sendInt( ID ); + _ser.putc(' '); + sendInt( option ); + _ser.putc('\r'); + waitForCR(); +} + +void ezLCD3::sendCommand(char *str) +{ + sendString(str); + _ser.putc('\r'); + waitForCR(); +} + int ezLCD3::_putc( int c) { - _ser.putc('2'); - _ser.putc('5'); + sendInt(Print); _ser.putc(' '); _ser.putc('\"'); _ser.putc(c); @@ -448,12 +571,5 @@ return(_ser.getc()); } -void ezLCD3::lcdbaud(int b) -{ - if (b > 0 && b < 7) { - putc(0x7c); - putc(0x07); - putc(b+'0'); - } -} +