KS0108 LCD LIB with I2C I/O expander PCF8574 for Databus
KS0108.h@0:f2f71eab6aef, 2012-04-21 (annotated)
- Committer:
- GuiTwo
- Date:
- Sat Apr 21 20:52:05 2012 +0000
- Revision:
- 0:f2f71eab6aef
- Child:
- 2:6a8fbb08d519
First version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
GuiTwo | 0:f2f71eab6aef | 1 | #ifndef KS0108_H |
GuiTwo | 0:f2f71eab6aef | 2 | #define KS0108_H |
GuiTwo | 0:f2f71eab6aef | 3 | |
GuiTwo | 0:f2f71eab6aef | 4 | #define VERSION 2.0 |
GuiTwo | 0:f2f71eab6aef | 5 | |
GuiTwo | 0:f2f71eab6aef | 6 | #include <mbed.h> |
GuiTwo | 0:f2f71eab6aef | 7 | #include "SystemFont5x7.h" |
GuiTwo | 0:f2f71eab6aef | 8 | #include "PCF8574_DataBus.h" |
GuiTwo | 0:f2f71eab6aef | 9 | |
GuiTwo | 0:f2f71eab6aef | 10 | /************************************************************************************/ |
GuiTwo | 0:f2f71eab6aef | 11 | // Commands |
GuiTwo | 0:f2f71eab6aef | 12 | #define LCD_ON 0x3F |
GuiTwo | 0:f2f71eab6aef | 13 | #define LCD_OFF 0x3E |
GuiTwo | 0:f2f71eab6aef | 14 | #define LCD_SET_ADD 0x40 // Y adresse 0-63 |
GuiTwo | 0:f2f71eab6aef | 15 | #define LCD_SET_PAGE 0xB8 //X adresse 0-7 |
GuiTwo | 0:f2f71eab6aef | 16 | #define LCD_DISP_START 0xC0 |
GuiTwo | 0:f2f71eab6aef | 17 | |
GuiTwo | 0:f2f71eab6aef | 18 | //Controller directives |
GuiTwo | 0:f2f71eab6aef | 19 | #define LEFT 0 |
GuiTwo | 0:f2f71eab6aef | 20 | #define RIGHT 1 |
GuiTwo | 0:f2f71eab6aef | 21 | #define BOTH 3 |
GuiTwo | 0:f2f71eab6aef | 22 | #define NONE 4 |
GuiTwo | 0:f2f71eab6aef | 23 | |
GuiTwo | 0:f2f71eab6aef | 24 | // Colors |
GuiTwo | 0:f2f71eab6aef | 25 | #define BLACK 0xFF |
GuiTwo | 0:f2f71eab6aef | 26 | #define WHITE 0x00 |
GuiTwo | 0:f2f71eab6aef | 27 | |
GuiTwo | 0:f2f71eab6aef | 28 | //Screen dimensions |
GuiTwo | 0:f2f71eab6aef | 29 | #define SCREEN_HEIGHT 64 |
GuiTwo | 0:f2f71eab6aef | 30 | #define SCREEN_WIDTH 128 |
GuiTwo | 0:f2f71eab6aef | 31 | #define CHIP_WIDTH 64 |
GuiTwo | 0:f2f71eab6aef | 32 | |
GuiTwo | 0:f2f71eab6aef | 33 | /***********************************************************************************/ |
GuiTwo | 0:f2f71eab6aef | 34 | //helper functions |
GuiTwo | 0:f2f71eab6aef | 35 | |
GuiTwo | 0:f2f71eab6aef | 36 | #define absDiff(x,y) ((x>y) ? (x-y) : (y-x)) |
GuiTwo | 0:f2f71eab6aef | 37 | #define swap(a,b) \ |
GuiTwo | 0:f2f71eab6aef | 38 | do\ |
GuiTwo | 0:f2f71eab6aef | 39 | {\ |
GuiTwo | 0:f2f71eab6aef | 40 | uint8_t t;\ |
GuiTwo | 0:f2f71eab6aef | 41 | t=a;\ |
GuiTwo | 0:f2f71eab6aef | 42 | a=b;\ |
GuiTwo | 0:f2f71eab6aef | 43 | b=t;\ |
GuiTwo | 0:f2f71eab6aef | 44 | } while(0) |
GuiTwo | 0:f2f71eab6aef | 45 | |
GuiTwo | 0:f2f71eab6aef | 46 | /**************************************************************************************/ |
GuiTwo | 0:f2f71eab6aef | 47 | |
GuiTwo | 0:f2f71eab6aef | 48 | // Font Indices |
GuiTwo | 0:f2f71eab6aef | 49 | #define FONT_LENGTH 0 |
GuiTwo | 0:f2f71eab6aef | 50 | #define FONT_FIXED_WIDTH 2 |
GuiTwo | 0:f2f71eab6aef | 51 | #define FONT_HEIGHT 3 |
GuiTwo | 0:f2f71eab6aef | 52 | #define FONT_FIRST_CHAR 4 |
GuiTwo | 0:f2f71eab6aef | 53 | #define FONT_CHAR_COUNT 5 |
GuiTwo | 0:f2f71eab6aef | 54 | #define FONT_WIDTH_TABLE 6 |
GuiTwo | 0:f2f71eab6aef | 55 | |
GuiTwo | 0:f2f71eab6aef | 56 | |
GuiTwo | 0:f2f71eab6aef | 57 | /*************************Callback function definietion for fonts *********************/ |
GuiTwo | 0:f2f71eab6aef | 58 | typedef unsigned int (*FontCallback)(unsigned int*); |
GuiTwo | 0:f2f71eab6aef | 59 | |
GuiTwo | 0:f2f71eab6aef | 60 | /*************************Callback function for reading font array*********************/ |
GuiTwo | 0:f2f71eab6aef | 61 | static unsigned int ReadData(unsigned int* ptr) { |
GuiTwo | 0:f2f71eab6aef | 62 | return *ptr; |
GuiTwo | 0:f2f71eab6aef | 63 | } |
GuiTwo | 0:f2f71eab6aef | 64 | |
GuiTwo | 0:f2f71eab6aef | 65 | /*************************************************************************************/ |
GuiTwo | 0:f2f71eab6aef | 66 | #define MAX_IMG_SIZE 128*64 |
GuiTwo | 0:f2f71eab6aef | 67 | |
GuiTwo | 0:f2f71eab6aef | 68 | typedef struct { |
GuiTwo | 0:f2f71eab6aef | 69 | unsigned int imgWidth; |
GuiTwo | 0:f2f71eab6aef | 70 | unsigned int imgHeight; |
GuiTwo | 0:f2f71eab6aef | 71 | unsigned char imgarray[MAX_IMG_SIZE]; |
GuiTwo | 0:f2f71eab6aef | 72 | }Image; |
GuiTwo | 0:f2f71eab6aef | 73 | |
GuiTwo | 0:f2f71eab6aef | 74 | |
GuiTwo | 0:f2f71eab6aef | 75 | typedef struct { |
GuiTwo | 0:f2f71eab6aef | 76 | unsigned int x; |
GuiTwo | 0:f2f71eab6aef | 77 | unsigned int y; |
GuiTwo | 0:f2f71eab6aef | 78 | unsigned int page; |
GuiTwo | 0:f2f71eab6aef | 79 | } LCDCoord; |
GuiTwo | 0:f2f71eab6aef | 80 | |
GuiTwo | 0:f2f71eab6aef | 81 | |
GuiTwo | 0:f2f71eab6aef | 82 | /****************************************************************************************/ |
GuiTwo | 0:f2f71eab6aef | 83 | |
GuiTwo | 0:f2f71eab6aef | 84 | |
GuiTwo | 0:f2f71eab6aef | 85 | |
GuiTwo | 0:f2f71eab6aef | 86 | class KS0108 { |
GuiTwo | 0:f2f71eab6aef | 87 | public: |
GuiTwo | 0:f2f71eab6aef | 88 | |
GuiTwo | 0:f2f71eab6aef | 89 | /** |
GuiTwo | 0:f2f71eab6aef | 90 | *@brief Constructor, initializes the lcd on the respective pins. |
GuiTwo | 0:f2f71eab6aef | 91 | *@param control pins RST,DI,RW,E,CS2,CS1 |
GuiTwo | 0:f2f71eab6aef | 92 | *@param databus DB0-DB7 data pins |
GuiTwo | 0:f2f71eab6aef | 93 | *@return none |
GuiTwo | 0:f2f71eab6aef | 94 | */ |
GuiTwo | 0:f2f71eab6aef | 95 | |
GuiTwo | 0:f2f71eab6aef | 96 | // 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); |
GuiTwo | 0:f2f71eab6aef | 97 | //KS0108 (PinName _DI, PinName _RW, PinName _E, PinName _CS2, PinName _CS1,PCF8574 _DB);// |
GuiTwo | 0:f2f71eab6aef | 98 | KS0108 (PinName _RST,PinName _DI, PinName _RW, PinName _E, PinName _CS2, PinName _CS1,PCF8574_DataBus &_DB); |
GuiTwo | 0:f2f71eab6aef | 99 | /** |
GuiTwo | 0:f2f71eab6aef | 100 | *@brief Write instruction to the specific controller. |
GuiTwo | 0:f2f71eab6aef | 101 | *@param Command command to send to the controller |
GuiTwo | 0:f2f71eab6aef | 102 | *@param side controller side can be LEFT or RIGHT |
GuiTwo | 0:f2f71eab6aef | 103 | *@return none |
GuiTwo | 0:f2f71eab6aef | 104 | * |
GuiTwo | 0:f2f71eab6aef | 105 | */ |
GuiTwo | 0:f2f71eab6aef | 106 | void WriteInstruction(unsigned int Command,unsigned int side); |
GuiTwo | 0:f2f71eab6aef | 107 | |
GuiTwo | 0:f2f71eab6aef | 108 | /** |
GuiTwo | 0:f2f71eab6aef | 109 | *@brief Write data byte to the controller. |
GuiTwo | 0:f2f71eab6aef | 110 | *@param data data send to the controller chip |
GuiTwo | 0:f2f71eab6aef | 111 | *@param side selected controller can be LEFT or RIGHT |
GuiTwo | 0:f2f71eab6aef | 112 | *@return none |
GuiTwo | 0:f2f71eab6aef | 113 | * |
GuiTwo | 0:f2f71eab6aef | 114 | */ |
GuiTwo | 0:f2f71eab6aef | 115 | void WriteData(unsigned int data ,unsigned char side); |
GuiTwo | 0:f2f71eab6aef | 116 | |
GuiTwo | 0:f2f71eab6aef | 117 | |
GuiTwo | 0:f2f71eab6aef | 118 | /** |
GuiTwo | 0:f2f71eab6aef | 119 | *@brief Write data byte to the controller (overloaded function). |
GuiTwo | 0:f2f71eab6aef | 120 | * |
GuiTwo | 0:f2f71eab6aef | 121 | *@param data data send to the controller chip |
GuiTwo | 0:f2f71eab6aef | 122 | *@return none |
GuiTwo | 0:f2f71eab6aef | 123 | */ |
GuiTwo | 0:f2f71eab6aef | 124 | void WriteData(unsigned int data); |
GuiTwo | 0:f2f71eab6aef | 125 | |
GuiTwo | 0:f2f71eab6aef | 126 | /** |
GuiTwo | 0:f2f71eab6aef | 127 | *@brief Write data byte to the screen on specific page and column |
GuiTwo | 0:f2f71eab6aef | 128 | *@param page page varies from 0-7 for each side |
GuiTwo | 0:f2f71eab6aef | 129 | *@param col col varies from 0-64 for each side |
GuiTwo | 0:f2f71eab6aef | 130 | *@param data info to be written on given coordinates |
GuiTwo | 0:f2f71eab6aef | 131 | *@return none |
GuiTwo | 0:f2f71eab6aef | 132 | * |
GuiTwo | 0:f2f71eab6aef | 133 | */ |
GuiTwo | 0:f2f71eab6aef | 134 | void WriteDataColPag(unsigned int page, unsigned int col, unsigned int data); |
GuiTwo | 0:f2f71eab6aef | 135 | |
GuiTwo | 0:f2f71eab6aef | 136 | /** |
GuiTwo | 0:f2f71eab6aef | 137 | *@brief Read data from display |
GuiTwo | 0:f2f71eab6aef | 138 | *@param none |
GuiTwo | 0:f2f71eab6aef | 139 | *@return none |
GuiTwo | 0:f2f71eab6aef | 140 | * |
GuiTwo | 0:f2f71eab6aef | 141 | */ |
GuiTwo | 0:f2f71eab6aef | 142 | unsigned int ReadData(); |
GuiTwo | 0:f2f71eab6aef | 143 | |
GuiTwo | 0:f2f71eab6aef | 144 | /** |
GuiTwo | 0:f2f71eab6aef | 145 | *@brief Read status of display , and check if it's busy |
GuiTwo | 0:f2f71eab6aef | 146 | *@param none |
GuiTwo | 0:f2f71eab6aef | 147 | *@return status status of display |
GuiTwo | 0:f2f71eab6aef | 148 | * |
GuiTwo | 0:f2f71eab6aef | 149 | */ |
GuiTwo | 0:f2f71eab6aef | 150 | unsigned int ReadStatus(); |
GuiTwo | 0:f2f71eab6aef | 151 | |
GuiTwo | 0:f2f71eab6aef | 152 | /** |
GuiTwo | 0:f2f71eab6aef | 153 | *@brief Select controller chip |
GuiTwo | 0:f2f71eab6aef | 154 | * |
GuiTwo | 0:f2f71eab6aef | 155 | *@param side controller side can be LEFT or RIGHT |
GuiTwo | 0:f2f71eab6aef | 156 | *@return none |
GuiTwo | 0:f2f71eab6aef | 157 | * |
GuiTwo | 0:f2f71eab6aef | 158 | */ |
GuiTwo | 0:f2f71eab6aef | 159 | void SelectSide(unsigned char side); |
GuiTwo | 0:f2f71eab6aef | 160 | |
GuiTwo | 0:f2f71eab6aef | 161 | |
GuiTwo | 0:f2f71eab6aef | 162 | /** |
GuiTwo | 0:f2f71eab6aef | 163 | *@brief Set cursor to specified coordinates |
GuiTwo | 0:f2f71eab6aef | 164 | * |
GuiTwo | 0:f2f71eab6aef | 165 | *@param x row |
GuiTwo | 0:f2f71eab6aef | 166 | *@param y column |
GuiTwo | 0:f2f71eab6aef | 167 | *@return none |
GuiTwo | 0:f2f71eab6aef | 168 | */ |
GuiTwo | 0:f2f71eab6aef | 169 | void GotoXY(unsigned int x, unsigned int y); |
GuiTwo | 0:f2f71eab6aef | 170 | |
GuiTwo | 0:f2f71eab6aef | 171 | |
GuiTwo | 0:f2f71eab6aef | 172 | /** |
GuiTwo | 0:f2f71eab6aef | 173 | *@brief Clears display |
GuiTwo | 0:f2f71eab6aef | 174 | * |
GuiTwo | 0:f2f71eab6aef | 175 | *@param none |
GuiTwo | 0:f2f71eab6aef | 176 | *@return none |
GuiTwo | 0:f2f71eab6aef | 177 | * |
GuiTwo | 0:f2f71eab6aef | 178 | */ |
GuiTwo | 0:f2f71eab6aef | 179 | void ClearScreen(); |
GuiTwo | 0:f2f71eab6aef | 180 | |
GuiTwo | 0:f2f71eab6aef | 181 | |
GuiTwo | 0:f2f71eab6aef | 182 | /** |
GuiTwo | 0:f2f71eab6aef | 183 | *@brief Turn on display |
GuiTwo | 0:f2f71eab6aef | 184 | * |
GuiTwo | 0:f2f71eab6aef | 185 | *@param none |
GuiTwo | 0:f2f71eab6aef | 186 | *@return none |
GuiTwo | 0:f2f71eab6aef | 187 | * |
GuiTwo | 0:f2f71eab6aef | 188 | */ |
GuiTwo | 0:f2f71eab6aef | 189 | void TurnOn(); |
GuiTwo | 0:f2f71eab6aef | 190 | |
GuiTwo | 0:f2f71eab6aef | 191 | |
GuiTwo | 0:f2f71eab6aef | 192 | /** |
GuiTwo | 0:f2f71eab6aef | 193 | *@brief Turn Off display |
GuiTwo | 0:f2f71eab6aef | 194 | * |
GuiTwo | 0:f2f71eab6aef | 195 | *@param none |
GuiTwo | 0:f2f71eab6aef | 196 | *@return none |
GuiTwo | 0:f2f71eab6aef | 197 | * |
GuiTwo | 0:f2f71eab6aef | 198 | */ |
GuiTwo | 0:f2f71eab6aef | 199 | void TurnOff(); |
GuiTwo | 0:f2f71eab6aef | 200 | |
GuiTwo | 0:f2f71eab6aef | 201 | /*******************************Graphic functions************************************************/ |
GuiTwo | 0:f2f71eab6aef | 202 | |
GuiTwo | 0:f2f71eab6aef | 203 | /** |
GuiTwo | 0:f2f71eab6aef | 204 | *@brief Set pixel to specific location on the screen. |
GuiTwo | 0:f2f71eab6aef | 205 | *@param x coordinate varies from 0-128 |
GuiTwo | 0:f2f71eab6aef | 206 | *@param y col varies from 0-64 |
GuiTwo | 0:f2f71eab6aef | 207 | *@param color color of pixel, can be BLACK or WHITE |
GuiTwo | 0:f2f71eab6aef | 208 | *@return none |
GuiTwo | 0:f2f71eab6aef | 209 | * |
GuiTwo | 0:f2f71eab6aef | 210 | */ |
GuiTwo | 0:f2f71eab6aef | 211 | void SetPixel( unsigned int x, unsigned int y, unsigned int color); |
GuiTwo | 0:f2f71eab6aef | 212 | |
GuiTwo | 0:f2f71eab6aef | 213 | |
GuiTwo | 0:f2f71eab6aef | 214 | /** |
GuiTwo | 0:f2f71eab6aef | 215 | *@brief Draws a line from x1,y1 to x2,y1 |
GuiTwo | 0:f2f71eab6aef | 216 | *@param Xaxis1 x coordinate of one side |
GuiTwo | 0:f2f71eab6aef | 217 | *@param Xaxis2 x coordinate of one side |
GuiTwo | 0:f2f71eab6aef | 218 | *@param Yaxis y coordinate both points |
GuiTwo | 0:f2f71eab6aef | 219 | *@param color can be BLACK or WHITE |
GuiTwo | 0:f2f71eab6aef | 220 | *@return none |
GuiTwo | 0:f2f71eab6aef | 221 | * |
GuiTwo | 0:f2f71eab6aef | 222 | */ |
GuiTwo | 0:f2f71eab6aef | 223 | void HLine(unsigned int Xaxis1, unsigned int Xaxis2 ,unsigned int Yaxis,unsigned int color); |
GuiTwo | 0:f2f71eab6aef | 224 | |
GuiTwo | 0:f2f71eab6aef | 225 | /** |
GuiTwo | 0:f2f71eab6aef | 226 | *@brief Draw a horizontal line |
GuiTwo | 0:f2f71eab6aef | 227 | *@param Xaxis1 |
GuiTwo | 0:f2f71eab6aef | 228 | *@param Xaxis2 |
GuiTwo | 0:f2f71eab6aef | 229 | *@param width |
GuiTwo | 0:f2f71eab6aef | 230 | *@param color can be BLACK or WHITE |
GuiTwo | 0:f2f71eab6aef | 231 | *@return none |
GuiTwo | 0:f2f71eab6aef | 232 | * |
GuiTwo | 0:f2f71eab6aef | 233 | */ |
GuiTwo | 0:f2f71eab6aef | 234 | void HLineShort(unsigned int Xaxis, unsigned int Yaxis,unsigned int width ,unsigned int color); |
GuiTwo | 0:f2f71eab6aef | 235 | |
GuiTwo | 0:f2f71eab6aef | 236 | /** |
GuiTwo | 0:f2f71eab6aef | 237 | *@brief Draws a vertical line |
GuiTwo | 0:f2f71eab6aef | 238 | *@param Xaxis |
GuiTwo | 0:f2f71eab6aef | 239 | *@param Yaxis1 |
GuiTwo | 0:f2f71eab6aef | 240 | *@param Yaxis2 |
GuiTwo | 0:f2f71eab6aef | 241 | *@param color can be BLACK or WHITE |
GuiTwo | 0:f2f71eab6aef | 242 | *@return none |
GuiTwo | 0:f2f71eab6aef | 243 | * |
GuiTwo | 0:f2f71eab6aef | 244 | */ |
GuiTwo | 0:f2f71eab6aef | 245 | void VLine(unsigned int Xaxis, unsigned int Yaxis1 ,unsigned int Yaxis2,unsigned int color); |
GuiTwo | 0:f2f71eab6aef | 246 | |
GuiTwo | 0:f2f71eab6aef | 247 | /** |
GuiTwo | 0:f2f71eab6aef | 248 | *@brief Draw a vertical line of a given width starting from X, Y |
GuiTwo | 0:f2f71eab6aef | 249 | *@param Xaxis |
GuiTwo | 0:f2f71eab6aef | 250 | *@param Yaxis |
GuiTwo | 0:f2f71eab6aef | 251 | *@param height Height of line |
GuiTwo | 0:f2f71eab6aef | 252 | *@param color can be BLACK or WHITE |
GuiTwo | 0:f2f71eab6aef | 253 | *@return none |
GuiTwo | 0:f2f71eab6aef | 254 | * |
GuiTwo | 0:f2f71eab6aef | 255 | */ |
GuiTwo | 0:f2f71eab6aef | 256 | void VLineShort(unsigned int Xaxis,unsigned int Yaxis, unsigned int height ,unsigned int color); |
GuiTwo | 0:f2f71eab6aef | 257 | |
GuiTwo | 0:f2f71eab6aef | 258 | |
GuiTwo | 0:f2f71eab6aef | 259 | /** |
GuiTwo | 0:f2f71eab6aef | 260 | *@brief Draws a line from x1,y1 to x2,y2. |
GuiTwo | 0:f2f71eab6aef | 261 | *@param x1 x coordinate of one side |
GuiTwo | 0:f2f71eab6aef | 262 | *@param y1 y coordinate of one side |
GuiTwo | 0:f2f71eab6aef | 263 | *@param x2 x coordinate of other side |
GuiTwo | 0:f2f71eab6aef | 264 | *@param y2 y coordinate of other side |
GuiTwo | 0:f2f71eab6aef | 265 | *@param color can be BLACK or WHITE |
GuiTwo | 0:f2f71eab6aef | 266 | *@return none |
GuiTwo | 0:f2f71eab6aef | 267 | * |
GuiTwo | 0:f2f71eab6aef | 268 | */ |
GuiTwo | 0:f2f71eab6aef | 269 | void Line(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2, unsigned int color); |
GuiTwo | 0:f2f71eab6aef | 270 | |
GuiTwo | 0:f2f71eab6aef | 271 | |
GuiTwo | 0:f2f71eab6aef | 272 | /** |
GuiTwo | 0:f2f71eab6aef | 273 | *@brief Draws a slanty line from x1,y1 to x2,y2 |
GuiTwo | 0:f2f71eab6aef | 274 | *@param lX1 x coordinate of one side |
GuiTwo | 0:f2f71eab6aef | 275 | *@param lY1 y coordinate of one side |
GuiTwo | 0:f2f71eab6aef | 276 | *@param lX2 x coordinate of other side |
GuiTwo | 0:f2f71eab6aef | 277 | *@param lY2 y coordinate of other side |
GuiTwo | 0:f2f71eab6aef | 278 | *@param color can be BLACK or WHITE |
GuiTwo | 0:f2f71eab6aef | 279 | *@return none |
GuiTwo | 0:f2f71eab6aef | 280 | * |
GuiTwo | 0:f2f71eab6aef | 281 | */ |
GuiTwo | 0:f2f71eab6aef | 282 | void SlantyLine(unsigned int lX1, unsigned int lY1, unsigned int lX2,unsigned int lY2,unsigned int color); |
GuiTwo | 0:f2f71eab6aef | 283 | |
GuiTwo | 0:f2f71eab6aef | 284 | /** |
GuiTwo | 0:f2f71eab6aef | 285 | *@brief Draws a line from x,y at given degree from inner_radius to outer_radius. |
GuiTwo | 0:f2f71eab6aef | 286 | *@param x |
GuiTwo | 0:f2f71eab6aef | 287 | *@param y |
GuiTwo | 0:f2f71eab6aef | 288 | *@param inner_radius |
GuiTwo | 0:f2f71eab6aef | 289 | *@param outer_radius |
GuiTwo | 0:f2f71eab6aef | 290 | *@param color can be BLACK or WHITE |
GuiTwo | 0:f2f71eab6aef | 291 | *@return none |
GuiTwo | 0:f2f71eab6aef | 292 | * |
GuiTwo | 0:f2f71eab6aef | 293 | */ |
GuiTwo | 0:f2f71eab6aef | 294 | void DegreeLine(unsigned int x, int y,unsigned int degree,unsigned int inner_radius,unsigned int outer_radius, unsigned int color); |
GuiTwo | 0:f2f71eab6aef | 295 | |
GuiTwo | 0:f2f71eab6aef | 296 | /** |
GuiTwo | 0:f2f71eab6aef | 297 | *@brief Draw a filled reactangle |
GuiTwo | 0:f2f71eab6aef | 298 | * |
GuiTwo | 0:f2f71eab6aef | 299 | *@param Xaxis1 |
GuiTwo | 0:f2f71eab6aef | 300 | *@param Yaxis1 |
GuiTwo | 0:f2f71eab6aef | 301 | *@param Xaxis2 |
GuiTwo | 0:f2f71eab6aef | 302 | *@param Yaxis2 |
GuiTwo | 0:f2f71eab6aef | 303 | *@param color can be BLACK or WHITE |
GuiTwo | 0:f2f71eab6aef | 304 | *@return none |
GuiTwo | 0:f2f71eab6aef | 305 | * |
GuiTwo | 0:f2f71eab6aef | 306 | */ |
GuiTwo | 0:f2f71eab6aef | 307 | void FullRectangle(unsigned int Xaxis1, unsigned int Yaxis1, unsigned int Xaxis2 ,unsigned int Yaxis2,unsigned int color); |
GuiTwo | 0:f2f71eab6aef | 308 | |
GuiTwo | 0:f2f71eab6aef | 309 | /** |
GuiTwo | 0:f2f71eab6aef | 310 | *@brief Draw an empty rectangle |
GuiTwo | 0:f2f71eab6aef | 311 | *@param Xaxis1 |
GuiTwo | 0:f2f71eab6aef | 312 | *@param Yaxis1 |
GuiTwo | 0:f2f71eab6aef | 313 | *@param Xaxis2 |
GuiTwo | 0:f2f71eab6aef | 314 | *@param Yaxis2 |
GuiTwo | 0:f2f71eab6aef | 315 | *@param color can be BLACK or WHITE |
GuiTwo | 0:f2f71eab6aef | 316 | *@return none |
GuiTwo | 0:f2f71eab6aef | 317 | * |
GuiTwo | 0:f2f71eab6aef | 318 | */ |
GuiTwo | 0:f2f71eab6aef | 319 | void EmptyRectangle(unsigned int Xaxis1,unsigned int Yaxis1, unsigned int Xaxis2,unsigned int Yaxis2,unsigned int color); |
GuiTwo | 0:f2f71eab6aef | 320 | |
GuiTwo | 0:f2f71eab6aef | 321 | |
GuiTwo | 0:f2f71eab6aef | 322 | /** |
GuiTwo | 0:f2f71eab6aef | 323 | *@brief Draw a rectangle with round corners |
GuiTwo | 0:f2f71eab6aef | 324 | *@param Xaxis1 x-coordinate of the top left point |
GuiTwo | 0:f2f71eab6aef | 325 | *@param Yaxis1 y-coordinate of the top left point |
GuiTwo | 0:f2f71eab6aef | 326 | *@param width rectangle width |
GuiTwo | 0:f2f71eab6aef | 327 | *@param height rectangle height |
GuiTwo | 0:f2f71eab6aef | 328 | *@param radius radius of the edges |
GuiTwo | 0:f2f71eab6aef | 329 | *@param color can be BLACK or WHITE |
GuiTwo | 0:f2f71eab6aef | 330 | *@return none |
GuiTwo | 0:f2f71eab6aef | 331 | * |
GuiTwo | 0:f2f71eab6aef | 332 | */ |
GuiTwo | 0:f2f71eab6aef | 333 | void RoundRectangle(unsigned int x, unsigned int y, unsigned int width, unsigned int height, unsigned int radius, unsigned int color); |
GuiTwo | 0:f2f71eab6aef | 334 | |
GuiTwo | 0:f2f71eab6aef | 335 | |
GuiTwo | 0:f2f71eab6aef | 336 | /** |
GuiTwo | 0:f2f71eab6aef | 337 | *Draws a triangle . |
GuiTwo | 0:f2f71eab6aef | 338 | *@param |
GuiTwo | 0:f2f71eab6aef | 339 | *@param |
GuiTwo | 0:f2f71eab6aef | 340 | *@param |
GuiTwo | 0:f2f71eab6aef | 341 | *@param |
GuiTwo | 0:f2f71eab6aef | 342 | *@return none |
GuiTwo | 0:f2f71eab6aef | 343 | * |
GuiTwo | 0:f2f71eab6aef | 344 | */ |
GuiTwo | 0:f2f71eab6aef | 345 | |
GuiTwo | 0:f2f71eab6aef | 346 | void Triangle ( int topx, int topy, int rightx, int righty); |
GuiTwo | 0:f2f71eab6aef | 347 | |
GuiTwo | 0:f2f71eab6aef | 348 | |
GuiTwo | 0:f2f71eab6aef | 349 | /** |
GuiTwo | 0:f2f71eab6aef | 350 | *Draws a right angle triangle . |
GuiTwo | 0:f2f71eab6aef | 351 | *@param |
GuiTwo | 0:f2f71eab6aef | 352 | *@param |
GuiTwo | 0:f2f71eab6aef | 353 | *@param |
GuiTwo | 0:f2f71eab6aef | 354 | *@param |
GuiTwo | 0:f2f71eab6aef | 355 | *@return none |
GuiTwo | 0:f2f71eab6aef | 356 | * |
GuiTwo | 0:f2f71eab6aef | 357 | */ |
GuiTwo | 0:f2f71eab6aef | 358 | void RightTriangle ( int topx, int topy, int rightx, int righty); |
GuiTwo | 0:f2f71eab6aef | 359 | |
GuiTwo | 0:f2f71eab6aef | 360 | |
GuiTwo | 0:f2f71eab6aef | 361 | /** |
GuiTwo | 0:f2f71eab6aef | 362 | *Draws an empty circle centered a x,y with radius R and specific color. |
GuiTwo | 0:f2f71eab6aef | 363 | *@param CenterX center x coordinate |
GuiTwo | 0:f2f71eab6aef | 364 | *@param CenterY center y coordinate |
GuiTwo | 0:f2f71eab6aef | 365 | *@param Radius circle radius |
GuiTwo | 0:f2f71eab6aef | 366 | *@param color Color can be BLACK or WHITE |
GuiTwo | 0:f2f71eab6aef | 367 | *@return none |
GuiTwo | 0:f2f71eab6aef | 368 | * |
GuiTwo | 0:f2f71eab6aef | 369 | */ |
GuiTwo | 0:f2f71eab6aef | 370 | void EmptyCircle(unsigned int CenterX, unsigned int CenterY, unsigned int Radius,unsigned int color); |
GuiTwo | 0:f2f71eab6aef | 371 | |
GuiTwo | 0:f2f71eab6aef | 372 | /** |
GuiTwo | 0:f2f71eab6aef | 373 | * Circle fill Code is merely a modification of the midpoint |
GuiTwo | 0:f2f71eab6aef | 374 | * circle algorithem which is an adaption of Bresenham's line algorithm |
GuiTwo | 0:f2f71eab6aef | 375 | * http://en.wikipedia.org/wiki/Midpoint_circle_algorithm |
GuiTwo | 0:f2f71eab6aef | 376 | * http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm |
GuiTwo | 0:f2f71eab6aef | 377 | * Adapted from arduino lib |
GuiTwo | 0:f2f71eab6aef | 378 | * |
GuiTwo | 0:f2f71eab6aef | 379 | *@param CenterX center x coordinate |
GuiTwo | 0:f2f71eab6aef | 380 | *@param CenterY center y coordinate |
GuiTwo | 0:f2f71eab6aef | 381 | *@param Radius circle radius |
GuiTwo | 0:f2f71eab6aef | 382 | *@param color Color can be BLACK or WHITE |
GuiTwo | 0:f2f71eab6aef | 383 | */ |
GuiTwo | 0:f2f71eab6aef | 384 | void FullCircle(unsigned int CenterX, unsigned int CenterY, unsigned int Radius,unsigned int color); |
GuiTwo | 0:f2f71eab6aef | 385 | |
GuiTwo | 0:f2f71eab6aef | 386 | /** |
GuiTwo | 0:f2f71eab6aef | 387 | *Draws an ellipse. |
GuiTwo | 0:f2f71eab6aef | 388 | *@param CX x coordinate of one side |
GuiTwo | 0:f2f71eab6aef | 389 | *@param CY y coordinate of one side |
GuiTwo | 0:f2f71eab6aef | 390 | *@param XRadius x coordinate of other side |
GuiTwo | 0:f2f71eab6aef | 391 | *@param YRadius y coordinate of other side |
GuiTwo | 0:f2f71eab6aef | 392 | *@param color can be BLACK or WHITE |
GuiTwo | 0:f2f71eab6aef | 393 | *@return none |
GuiTwo | 0:f2f71eab6aef | 394 | * |
GuiTwo | 0:f2f71eab6aef | 395 | * Ported the algorithm found at http://homepage.smc.edu/kennedy_john/belipse.pdf |
GuiTwo | 0:f2f71eab6aef | 396 | * |
GuiTwo | 0:f2f71eab6aef | 397 | */ |
GuiTwo | 0:f2f71eab6aef | 398 | void PlotEllipse(long CX, long CY, long XRadius,long YRadius, int color); |
GuiTwo | 0:f2f71eab6aef | 399 | void Plot4EllipsePoints(long CX,long CY, long X, long Y, int color); |
GuiTwo | 0:f2f71eab6aef | 400 | |
GuiTwo | 0:f2f71eab6aef | 401 | |
GuiTwo | 0:f2f71eab6aef | 402 | /** |
GuiTwo | 0:f2f71eab6aef | 403 | *@brief Round a double |
GuiTwo | 0:f2f71eab6aef | 404 | *@param double |
GuiTwo | 0:f2f71eab6aef | 405 | *@return value |
GuiTwo | 0:f2f71eab6aef | 406 | * |
GuiTwo | 0:f2f71eab6aef | 407 | */ |
GuiTwo | 0:f2f71eab6aef | 408 | double dfloor( double value ); |
GuiTwo | 0:f2f71eab6aef | 409 | |
GuiTwo | 0:f2f71eab6aef | 410 | |
GuiTwo | 0:f2f71eab6aef | 411 | /*****************************Bitmaps *****************************************************************/ |
GuiTwo | 0:f2f71eab6aef | 412 | |
GuiTwo | 0:f2f71eab6aef | 413 | /** |
GuiTwo | 0:f2f71eab6aef | 414 | *@brief Draws an image on screen. |
GuiTwo | 0:f2f71eab6aef | 415 | *@param PictureData 128x64 image array |
GuiTwo | 0:f2f71eab6aef | 416 | *@return none |
GuiTwo | 0:f2f71eab6aef | 417 | * |
GuiTwo | 0:f2f71eab6aef | 418 | * |
GuiTwo | 0:f2f71eab6aef | 419 | */ |
GuiTwo | 0:f2f71eab6aef | 420 | void FullScreenBMP (unsigned char *ImageData); |
GuiTwo | 0:f2f71eab6aef | 421 | |
GuiTwo | 0:f2f71eab6aef | 422 | /** |
GuiTwo | 0:f2f71eab6aef | 423 | *@brief Draw a 1-bit bitmap |
GuiTwo | 0:f2f71eab6aef | 424 | * |
GuiTwo | 0:f2f71eab6aef | 425 | *@param image struct containing img size and array |
GuiTwo | 0:f2f71eab6aef | 426 | *@param x x-coordinate |
GuiTwo | 0:f2f71eab6aef | 427 | *@param y y-coordinate |
GuiTwo | 0:f2f71eab6aef | 428 | *@param color can be BLACK or WHITE |
GuiTwo | 0:f2f71eab6aef | 429 | *@return none |
GuiTwo | 0:f2f71eab6aef | 430 | */ |
GuiTwo | 0:f2f71eab6aef | 431 | void DrawBitmap(const unsigned int * bitmap, unsigned int x, unsigned int y, unsigned int color); |
GuiTwo | 0:f2f71eab6aef | 432 | |
GuiTwo | 0:f2f71eab6aef | 433 | /** |
GuiTwo | 0:f2f71eab6aef | 434 | *@brief Static function , mplemented to read an array |
GuiTwo | 0:f2f71eab6aef | 435 | *@param ptr data array |
GuiTwo | 0:f2f71eab6aef | 436 | *@return none |
GuiTwo | 0:f2f71eab6aef | 437 | */ |
GuiTwo | 0:f2f71eab6aef | 438 | unsigned int ReadArrayData(const unsigned int* ptr); |
GuiTwo | 0:f2f71eab6aef | 439 | |
GuiTwo | 0:f2f71eab6aef | 440 | |
GuiTwo | 0:f2f71eab6aef | 441 | /*************************************Font functions **************************************/ |
GuiTwo | 0:f2f71eab6aef | 442 | |
GuiTwo | 0:f2f71eab6aef | 443 | /** |
GuiTwo | 0:f2f71eab6aef | 444 | *@brief Print a character on specified coordinates |
GuiTwo | 0:f2f71eab6aef | 445 | * |
GuiTwo | 0:f2f71eab6aef | 446 | *@param page row |
GuiTwo | 0:f2f71eab6aef | 447 | *@param col column |
GuiTwo | 0:f2f71eab6aef | 448 | *@param c integer value |
GuiTwo | 0:f2f71eab6aef | 449 | *@return none |
GuiTwo | 0:f2f71eab6aef | 450 | */ |
GuiTwo | 0:f2f71eab6aef | 451 | void Putchar (int page, int col,unsigned char c); |
GuiTwo | 0:f2f71eab6aef | 452 | |
GuiTwo | 0:f2f71eab6aef | 453 | /** |
GuiTwo | 0:f2f71eab6aef | 454 | *@brief Print a string on specified coordinates |
GuiTwo | 0:f2f71eab6aef | 455 | * |
GuiTwo | 0:f2f71eab6aef | 456 | *@param str char array |
GuiTwo | 0:f2f71eab6aef | 457 | *@param x row |
GuiTwo | 0:f2f71eab6aef | 458 | *@param y column |
GuiTwo | 0:f2f71eab6aef | 459 | *@return none |
GuiTwo | 0:f2f71eab6aef | 460 | */ |
GuiTwo | 0:f2f71eab6aef | 461 | void PutString(unsigned int x, unsigned int y,char* str); |
GuiTwo | 0:f2f71eab6aef | 462 | |
GuiTwo | 0:f2f71eab6aef | 463 | /** |
GuiTwo | 0:f2f71eab6aef | 464 | *@brief Print a float on specified coordinates |
GuiTwo | 0:f2f71eab6aef | 465 | * |
GuiTwo | 0:f2f71eab6aef | 466 | *@param val float value |
GuiTwo | 0:f2f71eab6aef | 467 | *@param x row |
GuiTwo | 0:f2f71eab6aef | 468 | *@param y column |
GuiTwo | 0:f2f71eab6aef | 469 | *@return none |
GuiTwo | 0:f2f71eab6aef | 470 | */ |
GuiTwo | 0:f2f71eab6aef | 471 | void PrintFloat(float val, unsigned int x,unsigned int y); |
GuiTwo | 0:f2f71eab6aef | 472 | |
GuiTwo | 0:f2f71eab6aef | 473 | /** |
GuiTwo | 0:f2f71eab6aef | 474 | *@brief Print an integer on specified coordinates |
GuiTwo | 0:f2f71eab6aef | 475 | * |
GuiTwo | 0:f2f71eab6aef | 476 | *@param val integer value |
GuiTwo | 0:f2f71eab6aef | 477 | *@param x row |
GuiTwo | 0:f2f71eab6aef | 478 | *@param y column |
GuiTwo | 0:f2f71eab6aef | 479 | *@return none |
GuiTwo | 0:f2f71eab6aef | 480 | */ |
GuiTwo | 0:f2f71eab6aef | 481 | void PrintInteger(int val,unsigned int x,unsigned int y); |
GuiTwo | 0:f2f71eab6aef | 482 | |
GuiTwo | 0:f2f71eab6aef | 483 | |
GuiTwo | 0:f2f71eab6aef | 484 | /** |
GuiTwo | 0:f2f71eab6aef | 485 | *@brief Select a specific font |
GuiTwo | 0:f2f71eab6aef | 486 | * |
GuiTwo | 0:f2f71eab6aef | 487 | *@param font font array |
GuiTwo | 0:f2f71eab6aef | 488 | *@param color font color , can be BLACK or WHITE |
GuiTwo | 0:f2f71eab6aef | 489 | *@param callback function pointer to load font |
GuiTwo | 0:f2f71eab6aef | 490 | *@return none |
GuiTwo | 0:f2f71eab6aef | 491 | */ |
GuiTwo | 0:f2f71eab6aef | 492 | void SelectFont(unsigned int* font,unsigned int color, FontCallback callback); |
GuiTwo | 0:f2f71eab6aef | 493 | |
GuiTwo | 0:f2f71eab6aef | 494 | |
GuiTwo | 0:f2f71eab6aef | 495 | /** |
GuiTwo | 0:f2f71eab6aef | 496 | *@brief Print a character |
GuiTwo | 0:f2f71eab6aef | 497 | * |
GuiTwo | 0:f2f71eab6aef | 498 | *@param c char |
GuiTwo | 0:f2f71eab6aef | 499 | *@return none |
GuiTwo | 0:f2f71eab6aef | 500 | */ |
GuiTwo | 0:f2f71eab6aef | 501 | int PrintChar(char c); |
GuiTwo | 0:f2f71eab6aef | 502 | |
GuiTwo | 0:f2f71eab6aef | 503 | |
GuiTwo | 0:f2f71eab6aef | 504 | /** |
GuiTwo | 0:f2f71eab6aef | 505 | *@brief Print a character string |
GuiTwo | 0:f2f71eab6aef | 506 | * |
GuiTwo | 0:f2f71eab6aef | 507 | *@param str char string |
GuiTwo | 0:f2f71eab6aef | 508 | *@return none |
GuiTwo | 0:f2f71eab6aef | 509 | */ |
GuiTwo | 0:f2f71eab6aef | 510 | void PrintString(char* str); |
GuiTwo | 0:f2f71eab6aef | 511 | |
GuiTwo | 0:f2f71eab6aef | 512 | |
GuiTwo | 0:f2f71eab6aef | 513 | /** |
GuiTwo | 0:f2f71eab6aef | 514 | *@brief Print a number |
GuiTwo | 0:f2f71eab6aef | 515 | * |
GuiTwo | 0:f2f71eab6aef | 516 | *@param n number |
GuiTwo | 0:f2f71eab6aef | 517 | *@return none |
GuiTwo | 0:f2f71eab6aef | 518 | */ |
GuiTwo | 0:f2f71eab6aef | 519 | void PrintNumber(long n); |
GuiTwo | 0:f2f71eab6aef | 520 | |
GuiTwo | 0:f2f71eab6aef | 521 | |
GuiTwo | 0:f2f71eab6aef | 522 | private: |
GuiTwo | 0:f2f71eab6aef | 523 | //BusInOut DB; |
GuiTwo | 0:f2f71eab6aef | 524 | PCF8574_DataBus &DB; |
GuiTwo | 0:f2f71eab6aef | 525 | DigitalInOut RST; // hardware reset |
GuiTwo | 0:f2f71eab6aef | 526 | PinName SDA; |
GuiTwo | 0:f2f71eab6aef | 527 | PinName SCL; |
GuiTwo | 0:f2f71eab6aef | 528 | |
GuiTwo | 0:f2f71eab6aef | 529 | DigitalInOut DI; |
GuiTwo | 0:f2f71eab6aef | 530 | DigitalInOut RW; |
GuiTwo | 0:f2f71eab6aef | 531 | DigitalInOut E; |
GuiTwo | 0:f2f71eab6aef | 532 | DigitalInOut CS2; |
GuiTwo | 0:f2f71eab6aef | 533 | DigitalInOut CS1; |
GuiTwo | 0:f2f71eab6aef | 534 | |
GuiTwo | 0:f2f71eab6aef | 535 | |
GuiTwo | 0:f2f71eab6aef | 536 | bool Inverted; |
GuiTwo | 0:f2f71eab6aef | 537 | |
GuiTwo | 0:f2f71eab6aef | 538 | LCDCoord Coord; |
GuiTwo | 0:f2f71eab6aef | 539 | FontCallback FontRead ; |
GuiTwo | 0:f2f71eab6aef | 540 | unsigned int FontColor; |
GuiTwo | 0:f2f71eab6aef | 541 | unsigned int* Font; |
GuiTwo | 0:f2f71eab6aef | 542 | unsigned int color; |
GuiTwo | 0:f2f71eab6aef | 543 | |
GuiTwo | 0:f2f71eab6aef | 544 | |
GuiTwo | 0:f2f71eab6aef | 545 | }; |
GuiTwo | 0:f2f71eab6aef | 546 | |
GuiTwo | 0:f2f71eab6aef | 547 | |
GuiTwo | 0:f2f71eab6aef | 548 | #endif |