Library for EarthLCD ezLCD3xx line of products
ezLCDLib.h
- Committer:
- codeman
- Date:
- 2013-04-28
- Revision:
- 1:c7659c8af0d3
- Parent:
- 0:65606abcae36
- Child:
- 3:28e71ce23bfd
File content as of revision 1:c7659c8af0d3:
/* * * * @author Ken Segler * */ /** Interface to the Sparkfun Serial Graphic LCD, LCD-09351; and Graphic * LCD Serial Backpack, LCD-09352. Derived class from Serial so that you * can conveniently printf(), putc(), etc to the display. * * Example: * @code * #include "mbed.h" * #include "ezLCDLib.h" * * SerialGraphicLCD lcd(p26, p25); * * int main() { * lcd.baud(115200); // default baud rate * while (1) { * lcd.clear(); * lcd.rect(3, 3, 20, 20); * lcd.printf("Hello World!"); * lcd.pixel(14, 35, true); * lcd.pixel(16, 36, true); * lcd.pixel(18, 37, true); * lcd.pos(5, 30); * lcd.printf("Hi"); * lcd.circle(50, 20, 20, true); * lcd.pos(50, 20); * lcd.printf("Howdy"); * lcd.line(0, 0, 25, 25, true); * wait(2); * } * } * @endcode */ #ifndef _EZLCDLIB_H #define _EZLCDLIB_H #include "mbed.h" #define FIFO 0 #define LIFO 1 #define CLEAR 2 class ezLCD3: public Stream { public: /** Create a new interface to a Serial Graphic LCD * Note that the display lower left corner is coordinates 0, 0. * Rows start at the top at 0, columns start at the left at 0. * @param tx -- mbed transmit pin * @param rx -- mbed receive pin */ ezLCD3(PinName tx, PinName rx); /** * * */ void Rx_interrupt( void ); void itoa(int value, char *sp, int radix); void stripSpace(char *str); bool sync( void ); /** * * */ void sendInt( int i ); /** * * */ int getInt( char *str ); /** * * */ void getString( char *str ); /** * * */ bool waitForCR( void ); /** clear the screen */ void cls(void); /** clear the screen with background color */ void cls(int bColor); /** clear the screen with background color and forground color */ void cls(int bColor, int fColor); /** * */ void color( int color ); /** set text position in rows, columns * * @param col is the col coordinate * @param row is the row coordinate */ void pos(int col, int row); /** set text position in x, y coordinates * * @param x is the x coordinate * @param y is the y coordinate */ void xy(int x, int y); /** set or erase a pixel * * @param x is the x coordinate * @param y is the y coordinate */ void plot(void); /** set or erase a pixel * * @param x is the x coordinate * @param y is the y coordinate */ void plot(int x, int y); /** draw or erase a line * * @param x1 is the x coordinate of the start of the line * @param y1 is the y coordinate of the start of the line */ void line(int x1, int y1); /** set or reset a circle * * @param x is the x coordinate of the circle center * @param y is the y coordinate of the circle center * @param r is the radius of the circle * @param set if true sets the pixel, if false, clears it */ void circle(int radius, bool filled); /** draw a box * * @param x1 is the x coordinate of the upper left of the rectangle * @param y1 is the y coordinate of the upper left of the rectangle * @param Fill for filled box */ void box(int x1, int y1, bool filled); /** set backlight brightness * * @param i is the duty cycle from 0 to 100; 0 is off, 100 is full power */ void light(int i); /** clear screen and put in reverse mode */ void reverseMode(void); /** configure the lcd baud rate so you have to call this along with baud() to change * communication speeds * * @param b is the baud rate, LCD_4800, LCD_9600, LCD_19200, LCD_38400, LCD_57600 or LCD_115200 */ void lcdbaud(int b); /** sets the resolution of the LCD so that the pos() call works properly * defaults to LCD_128x64. * * @param type is the type of LCD, either LCD_128x64 or LCD_160x128 */ void resolution(int type); /** sets the resolution of the LCD in x and y coordinates which determines * how rows and columns are calculated in the pos() call. Defaults to * x=128, y=64 * * @param x is the number of horizontal pixels * @param y is the number of vertical pixels */ void resolution(int x, int y); /** * * */ int getXmax( void ); /** * * */ int getYmax( void ); void setStringID( int ID, char *str ); void getStringID( int ID, char *str ); /** print string at current x y * @param string * * */ void print( char *str); /** * * */ //ameter [ID][x][y][width][height][options][value][min][max][theme][stringID][type] void ameter( int ID, int x, int y, int w, int h, int options, int value, int min, int max, int theme, int stringID, int type); /** * * */ void touchZone( int ID, int x, int y, int w, int h, bool option); /** * * */ void button( int ID, int x, int y, int w, int h, int option, int align, int radius, int theme, int stringID ); /** * * */ unsigned int wstack( int type ); /** Send a character directly to the serial interface * @param c The character to send to the */ int putc(int c); /** Receive a character directly to the serial interface * @returns c The character received from the */ int getc(); /** * Numerical values for the EarthSEMPL commands. Provided here for * users who wish to compose EarthSEMPL commands manually. (This is a low- * level asset that is not required for the common uses of the device) */ enum Commands { Command= 0, /**< Direct command. */ Status= 1, Clr_Screen= 2, /**< Clear to provided color. */ Ping= 3, /**< Return Pong */ zBeep= 4, /**< Beep provided duration *(frequency fixed) */ Light= 5, /**< \c 0 (off) to \c 100 (on) */ Color= 6, eColor_ID= 7, Font= 10, /**< Font number. */ Fontw= 11, /**< Font number widget. */ Font_Orient= 12, /**< Horizontal or vertical. */ Line_Width= 13, /**< 1 or 3. */ Line_Type= 14, /**< 1=dot dot 2=dash dash. */ XY= 15, /**< X and Y. */ StringID= 16, /**< SID ASCII String or File Name that * ends with 0. */ Plot= 17, /**< Place Pixel at X and Y. */ Line= 18, /**< Draw a line to X and Y. */ Box= 19, /**< Draws a Box to X and Y optional * fill. */ Circle= 20, /**< Draws a Circle with Radius optional * fill */ Arc= 21, /**< Draws an Arc with Radius and Begin * Angle to End Angle. */ Pie= 22, /**< Draws a Pie figure with Radius and * Begin Angle to End Angle and fills * it. */ Picture= 24, /**< Places a Picture on display. */ Print= 25, /**< Places the string on display which * ends with 0. */ Beep_Freq= 26, /**< Set the beeper frequency. */ Calibrate= 28, /**< Calibrate touch screen. */ zReset= 29, /**< Reset. */ Rec_Macro= 30, /**< Record Macro to flash drive. */ Play_Macro= 31, /**< Play Macro. */ Stop_Macro= 32, /**< Stop Macro. */ Pause_Macro= 33, /**< Pause n msec. */ Loop_Macro= 34, /**< Loop on Macro. */ Speed_Macro= 35, /**< Set the macro speed. */ Peri= 36, ConfigIO= 37, IO= 38, IOG= 39, Security= 40, /**< Set drive security string. */ Location= 41, /**< LID Location Vlaue. */ Upgrade= 43, Parameters= 45, ClipEnable= 46, /**< Set clip Enable. */ ClipArea= 47, /**< Set clip area. */ /* Filesystem operations */ Comment= 50, Fsgetcwd= 51, Fschdir= 52, Fsmkdir= 53, Fsrmdir= 54, Fsdir= 55, Fscopy= 56, Fsrename= 57, Fsremove= 58, Fsmore= 59, Format= 60, /**< Format Flash Drive if string1 = * "ezLCD" */ If= 61, Cmd= 62, /* Widget commands */ Set_Button= 70, /**< Widget Button. */ Set_CheckBox= 71, /**< Widget Checkbox. */ Set_Gbox= 72, /**< Widget Group Box. */ Set_RadioButton= 73, /**< Widget Radio Button. */ Set_DMeter= 74, /**< Widget Digital Meter. */ DMeter_Value= 75, /**< Set DMeter value. */ Set_AMeter= 76, /**< Widget Analog Meter. */ AMeter_Value= 77, /**< Set AMeter value. */ AMeter_Color= 78, /**< Set AMeter color */ Set_TouchZone= 79, /**< touch zone */ Set_Dial= 80, /**< Widget RoundDial. */ Set_Slider= 82, /**< Widget Slider. */ Set_Progress= 85, /**< Widget Progress bar. */ Progress_Value= 86, /**< Progress value. */ Set_StaticText= 87, /**< Widget Static text. */ StaticText_Value= 88, /**< Static text Value. */ Choice= 89, /**< Widget get choice. */ Widget_Theme= 90, /**< Widget Scheme. */ Widget_Values= 91, /**<Widget Values (Slider and Dial in this version).*/ Widget_State= 92, /**<Widget State (Button, checkbox, radiobutton in this version).*/ // no id returns the id of the last touched Mode= 98, Comport= 99, Xmax= 100, /**< Return Xmax width. */ Ymax= 101, /**< Return Ymax height. */ Wait= 102, /**< Wait for touch. */ Waitn= 103, /**< Wait for no touch. */ Waitt= 104, /**< Wait for touch. */ Threshold= 105, /**< Touch threshold. */ Verbose= 106, /**< Controls the verbose mode. */ Lecho= 107, /**< Controls the echo mode. */ Xtouch= 110, /**< return touchX. */ Ytouch= 111, /**< return touchY. */ Stouch= 112, /**< return touchS. */ Wquiet= 113, Wstack= 114, }; private: Serial _ser; virtual int _putc(int c); virtual int _getc(); int _xMax; int _yMax; int _firmware; }; #endif