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