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