Added custom fonts. Added triangle drawing function
Dependents: sc100016x4lcd REVO_Updated_Steering Driving_game Arkanoid_v1 ... more
Revision 1:a368f2688222, committed 2011-01-05
- Comitter:
- DimiterK
- Date:
- Wed Jan 05 00:01:45 2011 +0000
- Parent:
- 0:135b9a0a816e
- Child:
- 2:03d27b3fce6e
- Commit message:
- Improved documentation.
Changed in this revision
--- a/KS0108.cpp Tue Jan 04 18:35:28 2011 +0000 +++ b/KS0108.cpp Wed Jan 05 00:01:45 2011 +0000 @@ -1,11 +1,28 @@ -#include "KS0108.h" -#include <math.h> +/************************************************************************* +Copyright (c) 2010 Dimiter Kentri + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. -/*Constructor, initializes the lcd on the respective pins. - * - *@param pins - *@param databus - */ +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*******************************************************************************/ + +#include "KS0108.h" + + KS0108::KS0108 (PinName _RST,PinName _DI, PinName _RW, PinName _E, PinName _CS2, PinName _CS1, PinName DB0, PinName DB1, PinName DB2, PinName DB3, PinName DB4, PinName DB5, PinName DB6, PinName DB7) : DB(DB0,DB1,DB2,DB3,DB4,DB5,DB6,DB7),RST (_RST),DI(_DI), RW(_RW), E(_E), CS2(_CS2), CS1(_CS1) { @@ -20,13 +37,7 @@ } -/*Write instruction to the specific controller. - * - *@param Command command to send - *@param side controller side can be LEFT or RIGHT - *@return none - * - */ + void KS0108::WriteInstruction(unsigned int Command,unsigned int side){ E.write(0); DI.write(0); @@ -42,13 +53,7 @@ E.write(0); } -/*Write data to the controller. - * - *@param data data to send - *@param side controller side can be LEFT or RIGHT - * - *@return none - */ + void KS0108::WriteData(unsigned int data,unsigned char side){ E.write(0); DI.write(1); @@ -64,14 +69,7 @@ E = 0; } -/*Write data to the screen on specific page and column - * - *@param page page varies from0-7 for each side - *@param col col varies from 0-64 for each side - *@param data info to be written on given coordinates - *@return none - * - */ + void KS0108::WriteDataColPag(unsigned int page, unsigned int col, unsigned int data){ SelectSide(NONE); @@ -95,12 +93,7 @@ SelectSide(NONE); } -/*Read data from diplay - * - *@param none - *@return data - * - */ + unsigned int KS0108::ReadData(){ unsigned int data; DB.input(); @@ -118,12 +111,7 @@ return data; } -/*Read status of display , and check if it's busy - * - *@param none - *@return status status of display - * - */ + unsigned int KS0108::ReadStatus(){ unsigned int status; DB.input(); @@ -142,12 +130,7 @@ return status; } -/*Read status of display - * - *@param side controller side can be LEFT or RIGHT - *@return none - * - */ + void KS0108::SelectSide(unsigned char side){ if(side==LEFT) {CS1.write(1);CS2.write(0);} @@ -159,12 +142,7 @@ {CS1.write(0);CS2.write(0);} } -/*Clears display - * - *@param none - *@return none - * - */ + void KS0108::ClearScreen(){ for (int col=0;col<128;col++) { for (int page=0;page<8;page++) @@ -177,14 +155,7 @@ /*******************************************************************************************/ - -/*Set pixel to specific location on the screen. - *@param x page varies from 0-128 - *@param y col varies from 0-64 - *@param color color of pixel, can be BLACK or WHITE - *@return none - * - */ + void KS0108::SetPixel(unsigned int x, unsigned int y, unsigned int color){ unsigned int position; @@ -221,16 +192,7 @@ } -/*Draw a filled reactangle - * - *@param Xaxis1 - *@param Yaxis1 - *@param Xaxis2 - *@param Yaxis2 - *@param color can be BLACK or WHITE - *@return none - * - */ + void KS0108::FullRectangle(unsigned int Xaxis1, unsigned int Yaxis1, unsigned int Xaxis2 ,unsigned int Yaxis2,unsigned int color){ for(unsigned int i=Xaxis1;i<=Xaxis2;i++){ @@ -240,15 +202,7 @@ } } -/*Draw an empty rectangle - *@param Xaxis1 - *@param Yaxis1 - *@param Xaxis2 - *@param Yaxis2 - *@param color can be BLACK or WHITE - *@return none - * - */ + void KS0108::EmptyRectangle(unsigned int Xaxis1,unsigned int Yaxis1, unsigned int Xaxis2,unsigned int Yaxis2,unsigned int color){ unsigned int CurrentValue; @@ -267,15 +221,7 @@ } } -/*Draw a rectangle with round corners - *@param Xaxis1 - *@param Yaxis1 - *@param Xaxis2 - *@param Yaxis2 - *@param color can be BLACK or WHITE - *@return none - * - */ + void KS0108::RoundRectangle(unsigned int x, unsigned int y, unsigned int width, unsigned int height, unsigned int radius, unsigned int color) { int tSwitch, x1 = 0, y1 = radius; tSwitch = 3 - 2 * radius; @@ -308,66 +254,30 @@ VLineShort(x+width, y+radius,height-(2*radius), color); // right } -/*Draw a horizontal line - *@param Xaxis1 - *@param Xaxis2 - *@param Yaxis - *@param color can be BLACK or WHITE - *@return none - * - */ + void KS0108::HLine(unsigned int Xaxis1, unsigned int Xaxis2 ,unsigned int Yaxis,unsigned int color){ FullRectangle(Xaxis1,Yaxis,Xaxis2,Yaxis,color); } -/*Draw a horizontal line - *@param Xaxis1 - *@param Xaxis2 - *@param Yaxis - *@param color can be BLACK or WHITE - *@return none - * - */ + void KS0108::HLineShort(unsigned int Xaxis, unsigned int Yaxis,unsigned int width ,unsigned int color){ FullRectangle(Xaxis,Yaxis,Xaxis+width,Yaxis,color); } -/*Draw a horizontal line - *@param Xaxis1 - *@param Xaxis2 - *@param Yaxis - *@param color can be BLACK or WHITE - *@return none - * - */ + void KS0108::VLine(unsigned int Xaxis, unsigned int Yaxis1 ,unsigned int Yaxis2,unsigned int color){ FullRectangle(Xaxis,Yaxis1,Xaxis,Yaxis2,color); } -/*Draw a horizontal line - *@param Xaxis1 - *@param Xaxis2 - *@param Yaxis - *@param color can be BLACK or WHITE - *@return none - * - */ + void KS0108::VLineShort(unsigned int Xaxis,unsigned int Yaxis, unsigned int height ,unsigned int color){ FullRectangle(Xaxis,Yaxis,Xaxis,Yaxis+height,color); } -/* - *Draws a line from x,y at given degree from inner_radius to outer_radius. - *@param Xaxis1 - *@param Xaxis2 - *@param Yaxis - *@param color can be BLACK or WHITE - *@return none - * - */ + void KS0108::DegreeLine(unsigned int x, int y,unsigned int degree,unsigned int inner_radius,unsigned int outer_radius, unsigned int color){ int fx,fy,tx,ty; fx = x + dfloor(inner_radius * sin(degree * 3.14 / 180)); @@ -377,12 +287,7 @@ SlantyLine(fx,fy,tx,ty,color); } -/* - *Round a double - *@param double - *@return value - * - */ + double KS0108::dfloor( double value ) { if (value < 0.0) @@ -392,16 +297,7 @@ } -/* - *Draws a line from x,y at given degree from inner_radius to outer_radius. - *@param lX1 x coordinate of one side - *@param lY1 y coordinate of one side - *@param lX2 x coordinate of other side - *@param lY2 y coordinate of other side - *@param color can be BLACK or WHITE - *@return none - * - */ + void KS0108::SlantyLine(unsigned int lX1, unsigned int lY1, unsigned int lX2,unsigned int lY2,unsigned int color){ long lError, lDeltaX, lDeltaY, lYStep, bSteep; @@ -475,16 +371,7 @@ } -/* - *Draws a line from x1,y1 to x2,y2 - *@param lX1 x coordinate of one side - *@param lY1 y coordinate of one side - *@param lX2 x coordinate of other side - *@param lY2 y coordinate of other side - *@param color can be BLACK or WHITE - *@return none - * - */ + void KS0108::Line(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, unsigned int color){ unsigned int deltax, deltay, x,y, steep; int lerror, ystep; @@ -517,16 +404,7 @@ } } -/* - *Draws an empty circle centered a x,y with radius R and specific color. - *@param lX1 x coordinate of one side - *@param lY1 y coordinate of one side - *@param lX2 x coordinate of other side - *@param lY2 y coordinate of other side - *@param color can be BLACK or WHITE - *@return none - * - */ + void KS0108::EmptyCircle(unsigned int CenterX, unsigned int CenterY, unsigned int Radius,unsigned int color){ unsigned int y=0, x=0, d = 0; int part; @@ -554,18 +432,7 @@ } -/* - * Circle fill Code is merely a modification of the midpoint - * circle algorithem which is an adaption of Bresenham's line algorithm - * http://en.wikipedia.org/wiki/Midpoint_circle_algorithm - * http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm - * Adapted from arduino lib - * - *@param CenterX - *@param CenterY - *@param Radius - *@param color - */ + void KS0108::FullCircle(unsigned int CenterX, unsigned int CenterY, unsigned int Radius,unsigned int color){ int f = 1 - Radius; @@ -603,18 +470,7 @@ } -/* - *Draws a line from x,y at given degree from inner_radius to outer_radius. - *@param lX1 x coordinate of one side - *@param lY1 y coordinate of one side - *@param lX2 x coordinate of other side - *@param lY2 y coordinate of other side - *@param color can be BLACK or WHITE - *@return none - * - * Ported the algorithm found at http://homepage.smc.edu/kennedy_john/belipse.pdf - * - */ + void KS0108::PlotEllipse(long CX, long CY, long XRadius,long YRadius, int color) { @@ -673,18 +529,7 @@ } -/* - *Helper function for drawing an ellipse. - *@param CX x coordinate of one side - *@param CY y coordinate of one side - *@param X x coordinate of other side - *@param Y y coordinate of other side - *@param color can be BLACK or WHITE - *@return none - * - * Portted the algorithm found at http://homepage.smc.edu/kennedy_john/belipse.pdf - * - */ + void KS0108::Plot4EllipsePoints(long CX,long CY, long X, long Y, int color){ SetPixel(CX+X, CY+Y, color); //{point in quadrant 1} SetPixel(CX-X, CY+Y, color); //{point in quadrant 2} @@ -694,13 +539,7 @@ /***********************************************************************************/ -/* - *Draws an image on screen. - *@param PictureData 128x64 image array - *@return none - * - * - */ + void KS0108::FullScreenBMP (unsigned char *PictureData){ unsigned int Page=0; unsigned int Column=0; @@ -726,13 +565,7 @@ /******************************************************************************************/ -/* - *Moves cursor to x,y. - *@param x x coordinate - *@param y y coordinate - *@return none - * - */ + void KS0108::CursorXY(unsigned int x, unsigned int y){ if( (x > SCREEN_WIDTH-1) || (y > SCREEN_HEIGHT-1) ) // exit if coordinates are not legal return; @@ -748,15 +581,7 @@ } } -/* - *Print a char on the specified coordinates - *@param page row coordinate - *@param col y coordinate - *@param c character from systemfont - *@return none - * - * - */ + void KS0108::Putc (int page, int col,unsigned char c) { if (c>31 && c<127){ for(int i=0;i<5;i++){ @@ -766,15 +591,7 @@ } -/* - *Print a string on the specified coordinates. - *@param x row coordinate - *@param y y coordinate - *@param str character string - *@return none - * - * - */ + void KS0108::PutString(unsigned int x, unsigned int y,char* str){ while(*str != 0){ @@ -787,15 +604,6 @@ -/* - *Print a float on the specified coordiantes. - *@param val float number - *@param x row coordinate - *@param y y coordinate - *@return none - * - * - */ void KS0108::PrintFloat(float val, unsigned int x,unsigned int y){ char buf[20] = {}; // prints up to 20 digits sprintf(buf,"%f",val); @@ -803,20 +611,9 @@ } -/* - *Print an integer on th specified coordinates. - *@param val integer number - *@param x row coordinate - *@param y column coordinate - *@return none - * - */ + void KS0108::PrintInteger(int val,unsigned int x,unsigned int y){ char buf[20] = {}; // prints up to 20 digits sprintf(buf,"%d",val); PutString(x,y,buf); } - - - -
--- a/KS0108.h Tue Jan 04 18:35:28 2011 +0000 +++ b/KS0108.h Wed Jan 05 00:01:45 2011 +0000 @@ -1,32 +1,54 @@ +/************************************************************************* +Copyright (c) 2010 Dimiter Kentri + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*******************************************************************************/ + #ifndef KS0108_H #define KS0108_H #define VERSION 1 #include "mbed.h" -#include "SystemFont5x7.h" +#include "SystemFont5x7.h" /************************************************************************************/ // Commands -#define LCD_ON 0x3F -#define LCD_OFF 0x3E -#define LCD_SET_ADD 0x40 -#define LCD_SET_PAGE 0xB8 -#define LCD_DISP_START 0xC0 +#define LCD_ON 0x3F +#define LCD_OFF 0x3E +#define LCD_SET_ADD 0x40 +#define LCD_SET_PAGE 0xB8 +#define LCD_DISP_START 0xC0 //Controller directives -#define LEFT 1 -#define RIGHT 2 -#define BOTH 3 -#define NONE 4 +#define LEFT 1 +#define RIGHT 2 +#define BOTH 3 +#define NONE 4 // Colors -#define BLACK 0xFF -#define WHITE 0x00 +#define BLACK 0xFF +#define WHITE 0x00 //Screen dimensions -#define SCREEN_HEIGHT 64 -#define SCREEN_WIDTH 128 +#define SCREEN_HEIGHT 64 +#define SCREEN_WIDTH 128 /***********************************************************************************/ @@ -35,36 +57,27 @@ do\ {\ uint8_t t;\ - t=a;\ - a=b;\ - b=t;\ + t=a;\ + a=b;\ + b=t;\ } while(0) -/**************************************************************************************/ - -#define MAX_IMG_SIZE 128*64 - -typedef struct { - unsigned char imgarray[MAX_IMG_SIZE]; - unsigned int imgWidth; - unsigned int imgHeight; -}Image; /**************************************************************************************/ // Font Indices -#define FONT_LENGTH 0 -#define FONT_FIXED_WIDTH 2 -#define FONT_HEIGHT 3 -#define FONT_FIRST_CHAR 4 -#define FONT_CHAR_COUNT 5 -#define FONT_WIDTH_TABLE 6 +#define FONT_LENGTH 0 +#define FONT_FIXED_WIDTH 2 +#define FONT_HEIGHT 3 +#define FONT_FIRST_CHAR 4 +#define FONT_CHAR_COUNT 5 +#define FONT_WIDTH_TABLE 6 typedef struct { - unsigned int x; - unsigned int y; - unsigned int page; + unsigned int x; + unsigned int y; + unsigned int page; } LCDCoord; @@ -72,70 +85,340 @@ class KS0108 { - public: - // Constructor: - KS0108 (PinName _RST,PinName _DI, PinName _RW, PinName _E, PinName _CS1, PinName _CS2, PinName DB0, PinName DB1, PinName DB2, PinName DB3, PinName DB4, PinName DB5, PinName DB6, PinName DB7); - - void WriteInstruction(unsigned int Command,unsigned int side); - void WriteData(unsigned int data ,unsigned char side); - void WriteDataColPag(unsigned int page, unsigned int col, unsigned int data); - unsigned int ReadData(); - unsigned int ReadStatus(); - void SelectSide(unsigned char side); - void ClearScreen(); +public: + /*Constructor, initializes the lcd on the respective pins. + * + *@param pins + *@param databus + */ + + KS0108 (PinName _RST,PinName _DI, PinName _RW, PinName _E, PinName _CS1, PinName _CS2, PinName DB0, PinName DB1, PinName DB2, PinName DB3, PinName DB4, PinName DB5, PinName DB6, PinName DB7); + + /*Write instruction to the specific controller. + * + *@param Command command to send + *@param side controller side can be LEFT or RIGHT + *@return none + * + */ + void WriteInstruction(unsigned int Command,unsigned int side); + + /*Write data to the controller. + * + *@param data data to send + *@param side controller side can be LEFT or RIGHT + * + *@return none + */ + void WriteData(unsigned int data ,unsigned char side); + + /*Write data to the screen on specific page and column + * + *@param page page varies from0-7 for each side + *@param col col varies from 0-64 for each side + *@param data info to be written on given coordinates + *@return none + * + */ + void WriteDataColPag(unsigned int page, unsigned int col, unsigned int data); + + + /*Read data from diplay + * + *@param none + *@return data + * + */ + unsigned int ReadData(); + + /*Read status of display , and check if it's busy + * + *@param none + *@return status status of display + * + */ + unsigned int ReadStatus(); + + /*Select controller + * + *@param side controller side can be LEFT or RIGHT + *@return none + * + */ + void SelectSide(unsigned char side); - //Graphic functions - void SetPixel( unsigned int x, unsigned int y, unsigned int color); + /*Clears display + * + *@param none + *@return none + * + */ + void ClearScreen(); + + /*******************************Graphic functions************************************************/ + + /*Set pixel to specific location on the screen. + *@param x page varies from 0-128 + *@param y col varies from 0-64 + *@param color color of pixel, can be BLACK or WHITE + *@return none + * + */ + void SetPixel( unsigned int x, unsigned int y, unsigned int color); + + + /*Draw a horizontal line + *@param Xaxis1 + *@param Xaxis2 + *@param Yaxis + *@param color can be BLACK or WHITE + *@return none + * + */ + void HLine(unsigned int Xaxis1, unsigned int Xaxis2 ,unsigned int Yaxis,unsigned int color); - void HLine(unsigned int Xaxis1, unsigned int Xaxis2 ,unsigned int Yaxis,unsigned int color); - void HLineShort(unsigned int Xaxis, unsigned int Yaxis,unsigned int width ,unsigned int color); - void VLine(unsigned int Xaxis, unsigned int Yaxis1 ,unsigned int Yaxis2,unsigned int color); - void VLineShort(unsigned int Xaxis,unsigned int Yaxis, unsigned int height ,unsigned int color); - void Line(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2, unsigned int color); - void SlantyLine(unsigned int lX1, unsigned int lY1, unsigned int lX2,unsigned int lY2,unsigned int color); - void DegreeLine(unsigned int x, int y,unsigned int degree,unsigned int inner_radius,unsigned int outer_radius, unsigned int color); + /*Draw a horizontal line + *@param Xaxis1 + *@param Xaxis2 + *@param Yaxis + *@param color can be BLACK or WHITE + *@return none + * + */ + void HLineShort(unsigned int Xaxis, unsigned int Yaxis,unsigned int width ,unsigned int color); + + /*Draw a vertical line + *@param Xaxis1 + *@param Xaxis2 + *@param Yaxis + *@param color can be BLACK or WHITE + *@return none + * + */ + void VLine(unsigned int Xaxis, unsigned int Yaxis1 ,unsigned int Yaxis2,unsigned int color); + + /*Draw a vertical line + *@param Xaxis1 + *@param Xaxis2 + *@param Yaxis + *@param color can be BLACK or WHITE + *@return none + * + */ + void VLineShort(unsigned int Xaxis,unsigned int Yaxis, unsigned int height ,unsigned int color); + + + /* + *Draws a line from x1,y1 to x2,y2 + *@param lX1 x coordinate of one side + *@param lY1 y coordinate of one side + *@param lX2 x coordinate of other side + *@param lY2 y coordinate of other side + *@param color can be BLACK or WHITE + *@return none + * + */ + void Line(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2, unsigned int color); - void FullRectangle(unsigned int Xaxis1, unsigned int Yaxis1, unsigned int Xaxis2 ,unsigned int Yaxis2,unsigned int color); - void EmptyRectangle(unsigned int Xaxis1,unsigned int Yaxis1, unsigned int Xaxis2,unsigned int Yaxis2,unsigned int color); - void RoundRectangle(unsigned int x, unsigned int y, unsigned int width, unsigned int height, unsigned int radius, unsigned int color); - - - void EmptyCircle(unsigned int CenterX, unsigned int CenterY, unsigned int Radius,unsigned int color); - void FullCircle(unsigned int CenterX, unsigned int CenterY, unsigned int Radius,unsigned int color); - void PlotEllipse(long CX, long CY, long XRadius,long YRadius, int color); - void Plot4EllipsePoints(long CX,long CY, long X, long Y, int color); - - void FullScreenBMP (unsigned char *PictureData); - - double dfloor( double value ); - - - // Font Functions - void Putc (int page, int col,unsigned char c); - void PutString(unsigned int x, unsigned int y,char* str); - void PrintFloat(float val, unsigned int x,unsigned int y); - void PrintInteger(int val,unsigned int x,unsigned int y); + /* + *Draws a slanty line . + *@param lX1 x coordinate of one side + *@param lY1 y coordinate of one side + *@param lX2 x coordinate of other side + *@param lY2 y coordinate of other side + *@param color can be BLACK or WHITE + *@return none + * + */ + void SlantyLine(unsigned int lX1, unsigned int lY1, unsigned int lX2,unsigned int lY2,unsigned int color); + + /* + *Draws a line from x,y at given degree from inner_radius to outer_radius. + *@param Xaxis1 + *@param Xaxis2 + *@param Yaxis + *@param color can be BLACK or WHITE + *@return none + * + */ + void DegreeLine(unsigned int x, int y,unsigned int degree,unsigned int inner_radius,unsigned int outer_radius, unsigned int color); + + /*Draw a filled reactangle + * + *@param Xaxis1 + *@param Yaxis1 + *@param Xaxis2 + *@param Yaxis2 + *@param color can be BLACK or WHITE + *@return none + * + */ + void FullRectangle(unsigned int Xaxis1, unsigned int Yaxis1, unsigned int Xaxis2 ,unsigned int Yaxis2,unsigned int color); + + /*Draw an empty rectangle + *@param Xaxis1 + *@param Yaxis1 + *@param Xaxis2 + *@param Yaxis2 + *@param color can be BLACK or WHITE + *@return none + * + */ + void EmptyRectangle(unsigned int Xaxis1,unsigned int Yaxis1, unsigned int Xaxis2,unsigned int Yaxis2,unsigned int color); + + + /*Draw a rectangle with round corners + *@param Xaxis1 + *@param Yaxis1 + *@param Xaxis2 + *@param Yaxis2 + *@param color can be BLACK or WHITE + *@return none + * + */ + void RoundRectangle(unsigned int x, unsigned int y, unsigned int width, unsigned int height, unsigned int radius, unsigned int color); + + + /* + *Draws an empty circle centered a x,y with radius R and specific color. + *@param lX1 x coordinate of one side + *@param lY1 y coordinate of one side + *@param lX2 x coordinate of other side + *@param lY2 y coordinate of other side + *@param color can be BLACK or WHITE + *@return none + * + */ + void EmptyCircle(unsigned int CenterX, unsigned int CenterY, unsigned int Radius,unsigned int color); + + /* + * Circle fill Code is merely a modification of the midpoint + * circle algorithem which is an adaption of Bresenham's line algorithm + * http://en.wikipedia.org/wiki/Midpoint_circle_algorithm + * http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm + * Adapted from arduino lib + * + *@param CenterX + *@param CenterY + *@param Radius + *@param color + */ + void FullCircle(unsigned int CenterX, unsigned int CenterY, unsigned int Radius,unsigned int color); + + /* + *Draws an ellipse. + *@param lX1 x coordinate of one side + *@param lY1 y coordinate of one side + *@param lX2 x coordinate of other side + *@param lY2 y coordinate of other side + *@param color can be BLACK or WHITE + *@return none + * + * Ported the algorithm found at http://homepage.smc.edu/kennedy_john/belipse.pdf + * + */ + void PlotEllipse(long CX, long CY, long XRadius,long YRadius, int color); - void CursorXY( unsigned int x, unsigned int y); - - - - private: - BusInOut DB; - DigitalOut RST; - DigitalOut DI; - DigitalOut RW; - DigitalOut E; - DigitalInOut CS2; - DigitalInOut CS1; + /* + *Helper function for drawing an ellipse. + *@param CX x coordinate of one side + *@param CY y coordinate of one side + *@param X x coordinate of other side + *@param Y y coordinate of other side + *@param color can be BLACK or WHITE + *@return none + * + * Portted the algorithm found at http://homepage.smc.edu/kennedy_john/belipse.pdf + * + */ + void Plot4EllipsePoints(long CX,long CY, long X, long Y, int color); + + /* + *Draws an image on screen. + *@param PictureData 128x64 image array + *@return none + * + * + */ + void FullScreenBMP (unsigned char *PictureData); + + /* + *Round a double + *@param double + *@return value + * + */ + double dfloor( double value ); + + + /* + *Print a char on the specified coordinates + *@param page row coordinate + *@param col y coordinate + *@param c character from systemfont + *@return none + * + * + */ + void Putc (int page, int col,unsigned char c); - unsigned int color; - - unsigned int FontColor; - unsigned int* Font; - LCDCoord Coord; + /* + *Print a string on the specified coordinates. + *@param x row coordinate + *@param y y coordinate + *@param str character string + *@return none + * + * + */ + void PutString(unsigned int x, unsigned int y,char* str); + + /* + *Print a float on the specified coordiantes. + *@param val float number + *@param x row coordinate + *@param y y coordinate + *@return none + * + * + */ + void PrintFloat(float val, unsigned int x,unsigned int y); + + /* + *Print an integer on th specified coordinates. + *@param val integer number + *@param x row coordinate + *@param y column coordinate + *@return none + * + */ + void PrintInteger(int val,unsigned int x,unsigned int y); + + /* + *Moves cursor to x,y. + *@param x x coordinate + *@param y y coordinate + *@return none + * + */ + void CursorXY( unsigned int x, unsigned int y); + + + +private: + BusInOut DB; + DigitalOut RST; + DigitalOut DI; + DigitalOut RW; + DigitalOut E; + DigitalInOut CS2; + DigitalInOut CS1; + + unsigned int color; + unsigned int* Font; + LCDCoord Coord; }; - + #endif
--- a/SystemFont5x7.h Tue Jan 04 18:35:28 2011 +0000 +++ b/SystemFont5x7.h Wed Jan 05 00:01:45 2011 +0000 @@ -36,111 +36,111 @@ #define SYSTEM5x7_HEIGHT 7 static unsigned int System5x7[] = { - 0x0, 0x0, // size of zero indicates fixed width font, actual length is width * height - 0x05, // width - 0x07, // height - 0x20, // first char - 0x7f, // char count + 0x0, 0x0, // size of zero indicates fixed width font, actual length is width * height + 0x05, // width + 0x07, // height + 0x20, // first char + 0x7f, // char count // Fixed width; char width table not used !!!! // font data 0x00, 0x00, 0x00, 0x00, 0x00,// (space) - 0x00, 0x00, 0x5F, 0x00, 0x00,// ! - 0x00, 0x07, 0x00, 0x07, 0x00,// " - 0x14, 0x7F, 0x14, 0x7F, 0x14,// # - 0x24, 0x2A, 0x7F, 0x2A, 0x12,// $ - 0x23, 0x13, 0x08, 0x64, 0x62,// % - 0x36, 0x49, 0x55, 0x22, 0x50,// & - 0x00, 0x05, 0x03, 0x00, 0x00,// ' - 0x00, 0x1C, 0x22, 0x41, 0x00,// ( - 0x00, 0x41, 0x22, 0x1C, 0x00,// ) - 0x08, 0x2A, 0x1C, 0x2A, 0x08,// * - 0x08, 0x08, 0x3E, 0x08, 0x08,// + - 0x00, 0x50, 0x30, 0x00, 0x00,// , - 0x08, 0x08, 0x08, 0x08, 0x08,// - - 0x00, 0x60, 0x60, 0x00, 0x00,// . - 0x20, 0x10, 0x08, 0x04, 0x02,// / - 0x3E, 0x51, 0x49, 0x45, 0x3E,// 0 - 0x00, 0x42, 0x7F, 0x40, 0x00,// 1 - 0x42, 0x61, 0x51, 0x49, 0x46,// 2 - 0x21, 0x41, 0x45, 0x4B, 0x31,// 3 - 0x18, 0x14, 0x12, 0x7F, 0x10,// 4 - 0x27, 0x45, 0x45, 0x45, 0x39,// 5 - 0x3C, 0x4A, 0x49, 0x49, 0x30,// 6 - 0x01, 0x71, 0x09, 0x05, 0x03,// 7 - 0x36, 0x49, 0x49, 0x49, 0x36,// 8 - 0x06, 0x49, 0x49, 0x29, 0x1E,// 9 - 0x00, 0x36, 0x36, 0x00, 0x00,// : - 0x00, 0x56, 0x36, 0x00, 0x00,// ; - 0x00, 0x08, 0x14, 0x22, 0x41,// < - 0x14, 0x14, 0x14, 0x14, 0x14,// = - 0x41, 0x22, 0x14, 0x08, 0x00,// > - 0x02, 0x01, 0x51, 0x09, 0x06,// ? - 0x32, 0x49, 0x79, 0x41, 0x3E,// @ - 0x7E, 0x11, 0x11, 0x11, 0x7E,// A - 0x7F, 0x49, 0x49, 0x49, 0x36,// B - 0x3E, 0x41, 0x41, 0x41, 0x22,// C - 0x7F, 0x41, 0x41, 0x22, 0x1C,// D - 0x7F, 0x49, 0x49, 0x49, 0x41,// E - 0x7F, 0x09, 0x09, 0x01, 0x01,// F - 0x3E, 0x41, 0x41, 0x51, 0x32,// G - 0x7F, 0x08, 0x08, 0x08, 0x7F,// H - 0x00, 0x41, 0x7F, 0x41, 0x00,// I - 0x20, 0x40, 0x41, 0x3F, 0x01,// J - 0x7F, 0x08, 0x14, 0x22, 0x41,// K - 0x7F, 0x40, 0x40, 0x40, 0x40,// L - 0x7F, 0x02, 0x04, 0x02, 0x7F,// M - 0x7F, 0x04, 0x08, 0x10, 0x7F,// N - 0x3E, 0x41, 0x41, 0x41, 0x3E,// O - 0x7F, 0x09, 0x09, 0x09, 0x06,// P - 0x3E, 0x41, 0x51, 0x21, 0x5E,// Q - 0x7F, 0x09, 0x19, 0x29, 0x46,// R - 0x46, 0x49, 0x49, 0x49, 0x31,// S - 0x01, 0x01, 0x7F, 0x01, 0x01,// T - 0x3F, 0x40, 0x40, 0x40, 0x3F,// U - 0x1F, 0x20, 0x40, 0x20, 0x1F,// V - 0x7F, 0x20, 0x18, 0x20, 0x7F,// W - 0x63, 0x14, 0x08, 0x14, 0x63,// X - 0x03, 0x04, 0x78, 0x04, 0x03,// Y - 0x61, 0x51, 0x49, 0x45, 0x43,// Z - 0x00, 0x00, 0x7F, 0x41, 0x41,// [ - 0x02, 0x04, 0x08, 0x10, 0x20,// "\" - 0x41, 0x41, 0x7F, 0x00, 0x00,// ] - 0x04, 0x02, 0x01, 0x02, 0x04,// ^ - 0x40, 0x40, 0x40, 0x40, 0x40,// _ - 0x00, 0x01, 0x02, 0x04, 0x00,// ` - 0x20, 0x54, 0x54, 0x54, 0x78,// a - 0x7F, 0x48, 0x44, 0x44, 0x38,// b - 0x38, 0x44, 0x44, 0x44, 0x20,// c - 0x38, 0x44, 0x44, 0x48, 0x7F,// d - 0x38, 0x54, 0x54, 0x54, 0x18,// e - 0x08, 0x7E, 0x09, 0x01, 0x02,// f - 0x08, 0x14, 0x54, 0x54, 0x3C,// g - 0x7F, 0x08, 0x04, 0x04, 0x78,// h - 0x00, 0x44, 0x7D, 0x40, 0x00,// i - 0x20, 0x40, 0x44, 0x3D, 0x00,// j - 0x00, 0x7F, 0x10, 0x28, 0x44,// k - 0x00, 0x41, 0x7F, 0x40, 0x00,// l - 0x7C, 0x04, 0x18, 0x04, 0x78,// m - 0x7C, 0x08, 0x04, 0x04, 0x78,// n - 0x38, 0x44, 0x44, 0x44, 0x38,// o - 0x7C, 0x14, 0x14, 0x14, 0x08,// p - 0x08, 0x14, 0x14, 0x18, 0x7C,// q - 0x7C, 0x08, 0x04, 0x04, 0x08,// r - 0x48, 0x54, 0x54, 0x54, 0x20,// s - 0x04, 0x3F, 0x44, 0x40, 0x20,// t - 0x3C, 0x40, 0x40, 0x20, 0x7C,// u - 0x1C, 0x20, 0x40, 0x20, 0x1C,// v - 0x3C, 0x40, 0x30, 0x40, 0x3C,// w - 0x44, 0x28, 0x10, 0x28, 0x44,// x - 0x0C, 0x50, 0x50, 0x50, 0x3C,// y - 0x44, 0x64, 0x54, 0x4C, 0x44,// z - 0x00, 0x08, 0x36, 0x41, 0x00,// { - 0x00, 0x00, 0x7F, 0x00, 0x00,// | - 0x00, 0x41, 0x36, 0x08, 0x00,// } - 0x08, 0x08, 0x2A, 0x1C, 0x08,// -> - 0x08, 0x1C, 0x2A, 0x08, 0x08 // <- + 0x00, 0x00, 0x5F, 0x00, 0x00,// ! + 0x00, 0x07, 0x00, 0x07, 0x00,// " + 0x14, 0x7F, 0x14, 0x7F, 0x14,// # + 0x24, 0x2A, 0x7F, 0x2A, 0x12,// $ + 0x23, 0x13, 0x08, 0x64, 0x62,// % + 0x36, 0x49, 0x55, 0x22, 0x50,// & + 0x00, 0x05, 0x03, 0x00, 0x00,// ' + 0x00, 0x1C, 0x22, 0x41, 0x00,// ( + 0x00, 0x41, 0x22, 0x1C, 0x00,// ) + 0x08, 0x2A, 0x1C, 0x2A, 0x08,// * + 0x08, 0x08, 0x3E, 0x08, 0x08,// + + 0x00, 0x50, 0x30, 0x00, 0x00,// , + 0x08, 0x08, 0x08, 0x08, 0x08,// - + 0x00, 0x60, 0x60, 0x00, 0x00,// . + 0x20, 0x10, 0x08, 0x04, 0x02,// / + 0x3E, 0x51, 0x49, 0x45, 0x3E,// 0 + 0x00, 0x42, 0x7F, 0x40, 0x00,// 1 + 0x42, 0x61, 0x51, 0x49, 0x46,// 2 + 0x21, 0x41, 0x45, 0x4B, 0x31,// 3 + 0x18, 0x14, 0x12, 0x7F, 0x10,// 4 + 0x27, 0x45, 0x45, 0x45, 0x39,// 5 + 0x3C, 0x4A, 0x49, 0x49, 0x30,// 6 + 0x01, 0x71, 0x09, 0x05, 0x03,// 7 + 0x36, 0x49, 0x49, 0x49, 0x36,// 8 + 0x06, 0x49, 0x49, 0x29, 0x1E,// 9 + 0x00, 0x36, 0x36, 0x00, 0x00,// : + 0x00, 0x56, 0x36, 0x00, 0x00,// ; + 0x00, 0x08, 0x14, 0x22, 0x41,// < + 0x14, 0x14, 0x14, 0x14, 0x14,// = + 0x41, 0x22, 0x14, 0x08, 0x00,// > + 0x02, 0x01, 0x51, 0x09, 0x06,// ? + 0x32, 0x49, 0x79, 0x41, 0x3E,// @ + 0x7E, 0x11, 0x11, 0x11, 0x7E,// A + 0x7F, 0x49, 0x49, 0x49, 0x36,// B + 0x3E, 0x41, 0x41, 0x41, 0x22,// C + 0x7F, 0x41, 0x41, 0x22, 0x1C,// D + 0x7F, 0x49, 0x49, 0x49, 0x41,// E + 0x7F, 0x09, 0x09, 0x01, 0x01,// F + 0x3E, 0x41, 0x41, 0x51, 0x32,// G + 0x7F, 0x08, 0x08, 0x08, 0x7F,// H + 0x00, 0x41, 0x7F, 0x41, 0x00,// I + 0x20, 0x40, 0x41, 0x3F, 0x01,// J + 0x7F, 0x08, 0x14, 0x22, 0x41,// K + 0x7F, 0x40, 0x40, 0x40, 0x40,// L + 0x7F, 0x02, 0x04, 0x02, 0x7F,// M + 0x7F, 0x04, 0x08, 0x10, 0x7F,// N + 0x3E, 0x41, 0x41, 0x41, 0x3E,// O + 0x7F, 0x09, 0x09, 0x09, 0x06,// P + 0x3E, 0x41, 0x51, 0x21, 0x5E,// Q + 0x7F, 0x09, 0x19, 0x29, 0x46,// R + 0x46, 0x49, 0x49, 0x49, 0x31,// S + 0x01, 0x01, 0x7F, 0x01, 0x01,// T + 0x3F, 0x40, 0x40, 0x40, 0x3F,// U + 0x1F, 0x20, 0x40, 0x20, 0x1F,// V + 0x7F, 0x20, 0x18, 0x20, 0x7F,// W + 0x63, 0x14, 0x08, 0x14, 0x63,// X + 0x03, 0x04, 0x78, 0x04, 0x03,// Y + 0x61, 0x51, 0x49, 0x45, 0x43,// Z + 0x00, 0x00, 0x7F, 0x41, 0x41,// [ + 0x02, 0x04, 0x08, 0x10, 0x20,// "\" + 0x41, 0x41, 0x7F, 0x00, 0x00,// ] + 0x04, 0x02, 0x01, 0x02, 0x04,// ^ + 0x40, 0x40, 0x40, 0x40, 0x40,// _ + 0x00, 0x01, 0x02, 0x04, 0x00,// ` + 0x20, 0x54, 0x54, 0x54, 0x78,// a + 0x7F, 0x48, 0x44, 0x44, 0x38,// b + 0x38, 0x44, 0x44, 0x44, 0x20,// c + 0x38, 0x44, 0x44, 0x48, 0x7F,// d + 0x38, 0x54, 0x54, 0x54, 0x18,// e + 0x08, 0x7E, 0x09, 0x01, 0x02,// f + 0x08, 0x14, 0x54, 0x54, 0x3C,// g + 0x7F, 0x08, 0x04, 0x04, 0x78,// h + 0x00, 0x44, 0x7D, 0x40, 0x00,// i + 0x20, 0x40, 0x44, 0x3D, 0x00,// j + 0x00, 0x7F, 0x10, 0x28, 0x44,// k + 0x00, 0x41, 0x7F, 0x40, 0x00,// l + 0x7C, 0x04, 0x18, 0x04, 0x78,// m + 0x7C, 0x08, 0x04, 0x04, 0x78,// n + 0x38, 0x44, 0x44, 0x44, 0x38,// o + 0x7C, 0x14, 0x14, 0x14, 0x08,// p + 0x08, 0x14, 0x14, 0x18, 0x7C,// q + 0x7C, 0x08, 0x04, 0x04, 0x08,// r + 0x48, 0x54, 0x54, 0x54, 0x20,// s + 0x04, 0x3F, 0x44, 0x40, 0x20,// t + 0x3C, 0x40, 0x40, 0x20, 0x7C,// u + 0x1C, 0x20, 0x40, 0x20, 0x1C,// v + 0x3C, 0x40, 0x30, 0x40, 0x3C,// w + 0x44, 0x28, 0x10, 0x28, 0x44,// x + 0x0C, 0x50, 0x50, 0x50, 0x3C,// y + 0x44, 0x64, 0x54, 0x4C, 0x44,// z + 0x00, 0x08, 0x36, 0x41, 0x00,// { + 0x00, 0x00, 0x7F, 0x00, 0x00,// | + 0x00, 0x41, 0x36, 0x08, 0x00,// } + 0x08, 0x08, 0x2A, 0x1C, 0x08,// -> + 0x08, 0x1C, 0x2A, 0x08, 0x08 // <- };