Added custom fonts. Added triangle drawing function
Dependents: sc100016x4lcd REVO_Updated_Steering Driving_game Arkanoid_v1 ... more
KS0108.h@2:03d27b3fce6e, 2011-01-28 (annotated)
- Committer:
- DimiterK
- Date:
- Fri Jan 28 01:08:45 2011 +0000
- Revision:
- 2:03d27b3fce6e
- Parent:
- 1:a368f2688222
- Child:
- 4:bdc04bb2ffc1
Added support for drawing a custom size image array.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
DimiterK | 1:a368f2688222 | 1 | /************************************************************************* |
DimiterK | 1:a368f2688222 | 2 | Copyright (c) 2010 Dimiter Kentri |
DimiterK | 1:a368f2688222 | 3 | |
DimiterK | 1:a368f2688222 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy |
DimiterK | 1:a368f2688222 | 5 | of this software and associated documentation files (the "Software"), to deal |
DimiterK | 1:a368f2688222 | 6 | in the Software without restriction, including without limitation the rights |
DimiterK | 1:a368f2688222 | 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
DimiterK | 1:a368f2688222 | 8 | copies of the Software, and to permit persons to whom the Software is |
DimiterK | 1:a368f2688222 | 9 | furnished to do so, subject to the following conditions: |
DimiterK | 1:a368f2688222 | 10 | |
DimiterK | 1:a368f2688222 | 11 | The above copyright notice and this permission notice shall be included in |
DimiterK | 1:a368f2688222 | 12 | all copies or substantial portions of the Software. |
DimiterK | 1:a368f2688222 | 13 | |
DimiterK | 1:a368f2688222 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
DimiterK | 1:a368f2688222 | 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
DimiterK | 1:a368f2688222 | 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
DimiterK | 1:a368f2688222 | 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
DimiterK | 1:a368f2688222 | 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
DimiterK | 1:a368f2688222 | 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
DimiterK | 1:a368f2688222 | 20 | THE SOFTWARE. |
DimiterK | 1:a368f2688222 | 21 | *******************************************************************************/ |
DimiterK | 1:a368f2688222 | 22 | |
DimiterK | 0:135b9a0a816e | 23 | #ifndef KS0108_H |
DimiterK | 0:135b9a0a816e | 24 | #define KS0108_H |
DimiterK | 0:135b9a0a816e | 25 | |
DimiterK | 2:03d27b3fce6e | 26 | #define VERSION 1.1 |
DimiterK | 0:135b9a0a816e | 27 | |
DimiterK | 0:135b9a0a816e | 28 | #include "mbed.h" |
DimiterK | 1:a368f2688222 | 29 | #include "SystemFont5x7.h" |
DimiterK | 0:135b9a0a816e | 30 | |
DimiterK | 0:135b9a0a816e | 31 | /************************************************************************************/ |
DimiterK | 0:135b9a0a816e | 32 | // Commands |
DimiterK | 2:03d27b3fce6e | 33 | #define LCD_ON 0x3F |
DimiterK | 2:03d27b3fce6e | 34 | #define LCD_OFF 0x3E |
DimiterK | 2:03d27b3fce6e | 35 | #define LCD_SET_ADD 0x40 |
DimiterK | 1:a368f2688222 | 36 | #define LCD_SET_PAGE 0xB8 |
DimiterK | 2:03d27b3fce6e | 37 | #define LCD_DISP_START 0xC0 |
DimiterK | 0:135b9a0a816e | 38 | |
DimiterK | 0:135b9a0a816e | 39 | //Controller directives |
DimiterK | 1:a368f2688222 | 40 | #define LEFT 1 |
DimiterK | 1:a368f2688222 | 41 | #define RIGHT 2 |
DimiterK | 1:a368f2688222 | 42 | #define BOTH 3 |
DimiterK | 1:a368f2688222 | 43 | #define NONE 4 |
DimiterK | 0:135b9a0a816e | 44 | |
DimiterK | 0:135b9a0a816e | 45 | // Colors |
DimiterK | 2:03d27b3fce6e | 46 | #define BLACK 0xFF |
DimiterK | 2:03d27b3fce6e | 47 | #define WHITE 0x00 |
DimiterK | 0:135b9a0a816e | 48 | |
DimiterK | 0:135b9a0a816e | 49 | //Screen dimensions |
DimiterK | 1:a368f2688222 | 50 | #define SCREEN_HEIGHT 64 |
DimiterK | 1:a368f2688222 | 51 | #define SCREEN_WIDTH 128 |
DimiterK | 0:135b9a0a816e | 52 | |
DimiterK | 0:135b9a0a816e | 53 | /***********************************************************************************/ |
DimiterK | 0:135b9a0a816e | 54 | |
DimiterK | 0:135b9a0a816e | 55 | #define absDiff(x,y) ((x>y) ? (x-y) : (y-x)) |
DimiterK | 0:135b9a0a816e | 56 | #define swap(a,b) \ |
DimiterK | 0:135b9a0a816e | 57 | do\ |
DimiterK | 0:135b9a0a816e | 58 | {\ |
DimiterK | 0:135b9a0a816e | 59 | uint8_t t;\ |
DimiterK | 1:a368f2688222 | 60 | t=a;\ |
DimiterK | 1:a368f2688222 | 61 | a=b;\ |
DimiterK | 1:a368f2688222 | 62 | b=t;\ |
DimiterK | 0:135b9a0a816e | 63 | } while(0) |
DimiterK | 0:135b9a0a816e | 64 | |
DimiterK | 0:135b9a0a816e | 65 | |
DimiterK | 0:135b9a0a816e | 66 | /**************************************************************************************/ |
DimiterK | 0:135b9a0a816e | 67 | |
DimiterK | 0:135b9a0a816e | 68 | // Font Indices |
DimiterK | 2:03d27b3fce6e | 69 | #define FONT_LENGTH 0 |
DimiterK | 1:a368f2688222 | 70 | #define FONT_FIXED_WIDTH 2 |
DimiterK | 2:03d27b3fce6e | 71 | #define FONT_HEIGHT 3 |
DimiterK | 2:03d27b3fce6e | 72 | #define FONT_FIRST_CHAR 4 |
DimiterK | 2:03d27b3fce6e | 73 | #define FONT_CHAR_COUNT 5 |
DimiterK | 1:a368f2688222 | 74 | #define FONT_WIDTH_TABLE 6 |
DimiterK | 0:135b9a0a816e | 75 | |
DimiterK | 2:03d27b3fce6e | 76 | /*************************************************************************************/ |
DimiterK | 2:03d27b3fce6e | 77 | #define MAX_IMG_SIZE 127*64 |
DimiterK | 2:03d27b3fce6e | 78 | |
DimiterK | 2:03d27b3fce6e | 79 | typedef struct { |
DimiterK | 2:03d27b3fce6e | 80 | unsigned int imgWidth; |
DimiterK | 2:03d27b3fce6e | 81 | unsigned int imgHeight; |
DimiterK | 2:03d27b3fce6e | 82 | unsigned char imgarray[MAX_IMG_SIZE]; |
DimiterK | 2:03d27b3fce6e | 83 | }Image; |
DimiterK | 2:03d27b3fce6e | 84 | |
DimiterK | 2:03d27b3fce6e | 85 | /**************************************************************************************/ |
DimiterK | 0:135b9a0a816e | 86 | |
DimiterK | 0:135b9a0a816e | 87 | typedef struct { |
DimiterK | 1:a368f2688222 | 88 | unsigned int x; |
DimiterK | 1:a368f2688222 | 89 | unsigned int y; |
DimiterK | 1:a368f2688222 | 90 | unsigned int page; |
DimiterK | 0:135b9a0a816e | 91 | } LCDCoord; |
DimiterK | 0:135b9a0a816e | 92 | |
DimiterK | 0:135b9a0a816e | 93 | |
DimiterK | 0:135b9a0a816e | 94 | /****************************************************************************************/ |
DimiterK | 0:135b9a0a816e | 95 | |
DimiterK | 0:135b9a0a816e | 96 | |
DimiterK | 0:135b9a0a816e | 97 | class KS0108 { |
DimiterK | 1:a368f2688222 | 98 | public: |
DimiterK | 2:03d27b3fce6e | 99 | |
DimiterK | 2:03d27b3fce6e | 100 | /** |
DimiterK | 2:03d27b3fce6e | 101 | *@brief Constructor, initializes the lcd on the respective pins. |
DimiterK | 2:03d27b3fce6e | 102 | *@param control pins RST,DI,RW,E,CS2,CS1 |
DimiterK | 2:03d27b3fce6e | 103 | *@param databus DB0-DB7 data pins |
DimiterK | 2:03d27b3fce6e | 104 | *@return none |
DimiterK | 2:03d27b3fce6e | 105 | */ |
DimiterK | 1:a368f2688222 | 106 | |
DimiterK | 1:a368f2688222 | 107 | 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); |
DimiterK | 1:a368f2688222 | 108 | |
DimiterK | 2:03d27b3fce6e | 109 | /** |
DimiterK | 2:03d27b3fce6e | 110 | *@brief Write instruction to the specific controller. |
DimiterK | 2:03d27b3fce6e | 111 | *@param Command command to send to the controller |
DimiterK | 2:03d27b3fce6e | 112 | *@param side controller side can be LEFT or RIGHT |
DimiterK | 1:a368f2688222 | 113 | *@return none |
DimiterK | 1:a368f2688222 | 114 | * |
DimiterK | 1:a368f2688222 | 115 | */ |
DimiterK | 1:a368f2688222 | 116 | void WriteInstruction(unsigned int Command,unsigned int side); |
DimiterK | 1:a368f2688222 | 117 | |
DimiterK | 2:03d27b3fce6e | 118 | /** |
DimiterK | 2:03d27b3fce6e | 119 | *@brief Write data byte to the controller. |
DimiterK | 2:03d27b3fce6e | 120 | *@param data data send to the controller chip |
DimiterK | 2:03d27b3fce6e | 121 | *@param side selected controller can be LEFT or RIGHT |
DimiterK | 2:03d27b3fce6e | 122 | *@return none |
DimiterK | 1:a368f2688222 | 123 | * |
DimiterK | 1:a368f2688222 | 124 | */ |
DimiterK | 1:a368f2688222 | 125 | void WriteData(unsigned int data ,unsigned char side); |
DimiterK | 1:a368f2688222 | 126 | |
DimiterK | 2:03d27b3fce6e | 127 | /** |
DimiterK | 2:03d27b3fce6e | 128 | *@brief Write data byte to the screen on specific page and column |
DimiterK | 2:03d27b3fce6e | 129 | *@param page page varies from 0-7 for each side |
DimiterK | 2:03d27b3fce6e | 130 | *@param col col varies from 0-64 for each side |
DimiterK | 2:03d27b3fce6e | 131 | *@param data info to be written on given coordinates |
DimiterK | 2:03d27b3fce6e | 132 | *@return none |
DimiterK | 2:03d27b3fce6e | 133 | * |
DimiterK | 2:03d27b3fce6e | 134 | */ |
DimiterK | 1:a368f2688222 | 135 | void WriteDataColPag(unsigned int page, unsigned int col, unsigned int data); |
DimiterK | 1:a368f2688222 | 136 | |
DimiterK | 2:03d27b3fce6e | 137 | /** |
DimiterK | 2:03d27b3fce6e | 138 | *@brief Read data from display |
DimiterK | 1:a368f2688222 | 139 | *@param none |
DimiterK | 2:03d27b3fce6e | 140 | *@return none |
DimiterK | 1:a368f2688222 | 141 | * |
DimiterK | 1:a368f2688222 | 142 | */ |
DimiterK | 1:a368f2688222 | 143 | unsigned int ReadData(); |
DimiterK | 1:a368f2688222 | 144 | |
DimiterK | 2:03d27b3fce6e | 145 | /** |
DimiterK | 2:03d27b3fce6e | 146 | *@brief Read status of display , and check if it's busy |
DimiterK | 1:a368f2688222 | 147 | *@param none |
DimiterK | 2:03d27b3fce6e | 148 | *@return status status of display |
DimiterK | 1:a368f2688222 | 149 | * |
DimiterK | 1:a368f2688222 | 150 | */ |
DimiterK | 1:a368f2688222 | 151 | unsigned int ReadStatus(); |
DimiterK | 1:a368f2688222 | 152 | |
DimiterK | 2:03d27b3fce6e | 153 | /** |
DimiterK | 2:03d27b3fce6e | 154 | *@brief Select controller chip |
DimiterK | 1:a368f2688222 | 155 | * |
DimiterK | 2:03d27b3fce6e | 156 | *@param side controller side can be LEFT or RIGHT |
DimiterK | 1:a368f2688222 | 157 | *@return none |
DimiterK | 1:a368f2688222 | 158 | * |
DimiterK | 1:a368f2688222 | 159 | */ |
DimiterK | 1:a368f2688222 | 160 | void SelectSide(unsigned char side); |
DimiterK | 0:135b9a0a816e | 161 | |
DimiterK | 2:03d27b3fce6e | 162 | /** |
DimiterK | 2:03d27b3fce6e | 163 | *@brief Clears display |
DimiterK | 1:a368f2688222 | 164 | * |
DimiterK | 1:a368f2688222 | 165 | *@param none |
DimiterK | 1:a368f2688222 | 166 | *@return none |
DimiterK | 1:a368f2688222 | 167 | * |
DimiterK | 1:a368f2688222 | 168 | */ |
DimiterK | 1:a368f2688222 | 169 | void ClearScreen(); |
DimiterK | 1:a368f2688222 | 170 | |
DimiterK | 1:a368f2688222 | 171 | /*******************************Graphic functions************************************************/ |
DimiterK | 1:a368f2688222 | 172 | |
DimiterK | 2:03d27b3fce6e | 173 | /** |
DimiterK | 2:03d27b3fce6e | 174 | *@brief Set pixel to specific location on the screen. |
DimiterK | 2:03d27b3fce6e | 175 | *@param x coordinate varies from 0-128 |
DimiterK | 2:03d27b3fce6e | 176 | *@param y col varies from 0-64 |
DimiterK | 2:03d27b3fce6e | 177 | *@param color color of pixel, can be BLACK or WHITE |
DimiterK | 2:03d27b3fce6e | 178 | *@return none |
DimiterK | 2:03d27b3fce6e | 179 | * |
DimiterK | 2:03d27b3fce6e | 180 | */ |
DimiterK | 1:a368f2688222 | 181 | void SetPixel( unsigned int x, unsigned int y, unsigned int color); |
DimiterK | 1:a368f2688222 | 182 | |
DimiterK | 1:a368f2688222 | 183 | |
DimiterK | 2:03d27b3fce6e | 184 | /** |
DimiterK | 2:03d27b3fce6e | 185 | *@brief Draws a line from x1,y1 to x2,y1 |
DimiterK | 2:03d27b3fce6e | 186 | *@param Xaxis1 x coordinate of one side |
DimiterK | 2:03d27b3fce6e | 187 | *@param Xaxis2 x coordinate of one side |
DimiterK | 2:03d27b3fce6e | 188 | *@param Yaxis y coordinate both points |
DimiterK | 1:a368f2688222 | 189 | *@param color can be BLACK or WHITE |
DimiterK | 1:a368f2688222 | 190 | *@return none |
DimiterK | 1:a368f2688222 | 191 | * |
DimiterK | 1:a368f2688222 | 192 | */ |
DimiterK | 2:03d27b3fce6e | 193 | void HLine(unsigned int Xaxis1, unsigned int Xaxis2 ,unsigned int Yaxis,unsigned int color); |
DimiterK | 0:135b9a0a816e | 194 | |
DimiterK | 2:03d27b3fce6e | 195 | /** |
DimiterK | 2:03d27b3fce6e | 196 | *@brief Draw a horizontal line |
DimiterK | 1:a368f2688222 | 197 | *@param Xaxis1 |
DimiterK | 1:a368f2688222 | 198 | *@param Xaxis2 |
DimiterK | 2:03d27b3fce6e | 199 | *@param width |
DimiterK | 1:a368f2688222 | 200 | *@param color can be BLACK or WHITE |
DimiterK | 1:a368f2688222 | 201 | *@return none |
DimiterK | 1:a368f2688222 | 202 | * |
DimiterK | 1:a368f2688222 | 203 | */ |
DimiterK | 1:a368f2688222 | 204 | void HLineShort(unsigned int Xaxis, unsigned int Yaxis,unsigned int width ,unsigned int color); |
DimiterK | 1:a368f2688222 | 205 | |
DimiterK | 2:03d27b3fce6e | 206 | /** |
DimiterK | 2:03d27b3fce6e | 207 | *@brief Draws a vertical line |
DimiterK | 2:03d27b3fce6e | 208 | *@param Xaxis |
DimiterK | 2:03d27b3fce6e | 209 | *@param Yaxis1 |
DimiterK | 2:03d27b3fce6e | 210 | *@param Yaxis2 |
DimiterK | 1:a368f2688222 | 211 | *@param color can be BLACK or WHITE |
DimiterK | 1:a368f2688222 | 212 | *@return none |
DimiterK | 1:a368f2688222 | 213 | * |
DimiterK | 1:a368f2688222 | 214 | */ |
DimiterK | 1:a368f2688222 | 215 | void VLine(unsigned int Xaxis, unsigned int Yaxis1 ,unsigned int Yaxis2,unsigned int color); |
DimiterK | 1:a368f2688222 | 216 | |
DimiterK | 2:03d27b3fce6e | 217 | /** |
DimiterK | 2:03d27b3fce6e | 218 | *@brief Draw a vertical line of a given width starting from X, Y |
DimiterK | 2:03d27b3fce6e | 219 | *@param Xaxis |
DimiterK | 1:a368f2688222 | 220 | *@param Yaxis |
DimiterK | 2:03d27b3fce6e | 221 | *@param height Height of line |
DimiterK | 1:a368f2688222 | 222 | *@param color can be BLACK or WHITE |
DimiterK | 1:a368f2688222 | 223 | *@return none |
DimiterK | 1:a368f2688222 | 224 | * |
DimiterK | 1:a368f2688222 | 225 | */ |
DimiterK | 1:a368f2688222 | 226 | void VLineShort(unsigned int Xaxis,unsigned int Yaxis, unsigned int height ,unsigned int color); |
DimiterK | 1:a368f2688222 | 227 | |
DimiterK | 1:a368f2688222 | 228 | |
DimiterK | 2:03d27b3fce6e | 229 | /** |
DimiterK | 2:03d27b3fce6e | 230 | *@brief Draws a line from x1,y1 to x2,y2. |
DimiterK | 2:03d27b3fce6e | 231 | *@param x1 x coordinate of one side |
DimiterK | 2:03d27b3fce6e | 232 | *@param y1 y coordinate of one side |
DimiterK | 2:03d27b3fce6e | 233 | *@param x2 x coordinate of other side |
DimiterK | 2:03d27b3fce6e | 234 | *@param y2 y coordinate of other side |
DimiterK | 1:a368f2688222 | 235 | *@param color can be BLACK or WHITE |
DimiterK | 1:a368f2688222 | 236 | *@return none |
DimiterK | 1:a368f2688222 | 237 | * |
DimiterK | 1:a368f2688222 | 238 | */ |
DimiterK | 1:a368f2688222 | 239 | void Line(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2, unsigned int color); |
DimiterK | 0:135b9a0a816e | 240 | |
DimiterK | 0:135b9a0a816e | 241 | |
DimiterK | 2:03d27b3fce6e | 242 | /** |
DimiterK | 2:03d27b3fce6e | 243 | *@brief Draws a slanty line from x1,y1 to x2,y2 |
DimiterK | 1:a368f2688222 | 244 | *@param lX1 x coordinate of one side |
DimiterK | 1:a368f2688222 | 245 | *@param lY1 y coordinate of one side |
DimiterK | 1:a368f2688222 | 246 | *@param lX2 x coordinate of other side |
DimiterK | 1:a368f2688222 | 247 | *@param lY2 y coordinate of other side |
DimiterK | 1:a368f2688222 | 248 | *@param color can be BLACK or WHITE |
DimiterK | 1:a368f2688222 | 249 | *@return none |
DimiterK | 1:a368f2688222 | 250 | * |
DimiterK | 1:a368f2688222 | 251 | */ |
DimiterK | 1:a368f2688222 | 252 | void SlantyLine(unsigned int lX1, unsigned int lY1, unsigned int lX2,unsigned int lY2,unsigned int color); |
DimiterK | 1:a368f2688222 | 253 | |
DimiterK | 2:03d27b3fce6e | 254 | /** |
DimiterK | 2:03d27b3fce6e | 255 | *@brief Draws a line from x,y at given degree from inner_radius to outer_radius. |
DimiterK | 2:03d27b3fce6e | 256 | *@param x |
DimiterK | 2:03d27b3fce6e | 257 | *@param y |
DimiterK | 2:03d27b3fce6e | 258 | *@param inner_radius |
DimiterK | 2:03d27b3fce6e | 259 | *@param outer_radius |
DimiterK | 1:a368f2688222 | 260 | *@param color can be BLACK or WHITE |
DimiterK | 1:a368f2688222 | 261 | *@return none |
DimiterK | 1:a368f2688222 | 262 | * |
DimiterK | 1:a368f2688222 | 263 | */ |
DimiterK | 1:a368f2688222 | 264 | void DegreeLine(unsigned int x, int y,unsigned int degree,unsigned int inner_radius,unsigned int outer_radius, unsigned int color); |
DimiterK | 1:a368f2688222 | 265 | |
DimiterK | 2:03d27b3fce6e | 266 | /** |
DimiterK | 2:03d27b3fce6e | 267 | *@brief Draw a filled reactangle |
DimiterK | 1:a368f2688222 | 268 | * |
DimiterK | 1:a368f2688222 | 269 | *@param Xaxis1 |
DimiterK | 1:a368f2688222 | 270 | *@param Yaxis1 |
DimiterK | 1:a368f2688222 | 271 | *@param Xaxis2 |
DimiterK | 1:a368f2688222 | 272 | *@param Yaxis2 |
DimiterK | 1:a368f2688222 | 273 | *@param color can be BLACK or WHITE |
DimiterK | 1:a368f2688222 | 274 | *@return none |
DimiterK | 1:a368f2688222 | 275 | * |
DimiterK | 1:a368f2688222 | 276 | */ |
DimiterK | 1:a368f2688222 | 277 | void FullRectangle(unsigned int Xaxis1, unsigned int Yaxis1, unsigned int Xaxis2 ,unsigned int Yaxis2,unsigned int color); |
DimiterK | 1:a368f2688222 | 278 | |
DimiterK | 2:03d27b3fce6e | 279 | /** |
DimiterK | 2:03d27b3fce6e | 280 | *@brief Draw an empty rectangle |
DimiterK | 1:a368f2688222 | 281 | *@param Xaxis1 |
DimiterK | 1:a368f2688222 | 282 | *@param Yaxis1 |
DimiterK | 1:a368f2688222 | 283 | *@param Xaxis2 |
DimiterK | 1:a368f2688222 | 284 | *@param Yaxis2 |
DimiterK | 1:a368f2688222 | 285 | *@param color can be BLACK or WHITE |
DimiterK | 1:a368f2688222 | 286 | *@return none |
DimiterK | 1:a368f2688222 | 287 | * |
DimiterK | 1:a368f2688222 | 288 | */ |
DimiterK | 1:a368f2688222 | 289 | void EmptyRectangle(unsigned int Xaxis1,unsigned int Yaxis1, unsigned int Xaxis2,unsigned int Yaxis2,unsigned int color); |
DimiterK | 1:a368f2688222 | 290 | |
DimiterK | 1:a368f2688222 | 291 | |
DimiterK | 2:03d27b3fce6e | 292 | /** |
DimiterK | 2:03d27b3fce6e | 293 | *@brief Draw a rectangle with round corners |
DimiterK | 2:03d27b3fce6e | 294 | *@param Xaxis1 x-coordinate of the top left point |
DimiterK | 2:03d27b3fce6e | 295 | *@param Yaxis1 y-coordinate of the top left point |
DimiterK | 2:03d27b3fce6e | 296 | *@param width rectangle width |
DimiterK | 2:03d27b3fce6e | 297 | *@param height rectangle height |
DimiterK | 2:03d27b3fce6e | 298 | *@param radius radius of the edges |
DimiterK | 1:a368f2688222 | 299 | *@param color can be BLACK or WHITE |
DimiterK | 1:a368f2688222 | 300 | *@return none |
DimiterK | 1:a368f2688222 | 301 | * |
DimiterK | 1:a368f2688222 | 302 | */ |
DimiterK | 1:a368f2688222 | 303 | void RoundRectangle(unsigned int x, unsigned int y, unsigned int width, unsigned int height, unsigned int radius, unsigned int color); |
DimiterK | 1:a368f2688222 | 304 | |
DimiterK | 1:a368f2688222 | 305 | |
DimiterK | 1:a368f2688222 | 306 | /* |
DimiterK | 1:a368f2688222 | 307 | *Draws an empty circle centered a x,y with radius R and specific color. |
DimiterK | 2:03d27b3fce6e | 308 | *@param CenterX center x coordinate |
DimiterK | 2:03d27b3fce6e | 309 | *@param CenterY center y coordinate |
DimiterK | 2:03d27b3fce6e | 310 | *@param Radius circle radius |
DimiterK | 2:03d27b3fce6e | 311 | *@param color Color can be BLACK or WHITE |
DimiterK | 1:a368f2688222 | 312 | *@return none |
DimiterK | 1:a368f2688222 | 313 | * |
DimiterK | 1:a368f2688222 | 314 | */ |
DimiterK | 1:a368f2688222 | 315 | void EmptyCircle(unsigned int CenterX, unsigned int CenterY, unsigned int Radius,unsigned int color); |
DimiterK | 1:a368f2688222 | 316 | |
DimiterK | 1:a368f2688222 | 317 | /* |
DimiterK | 1:a368f2688222 | 318 | * Circle fill Code is merely a modification of the midpoint |
DimiterK | 1:a368f2688222 | 319 | * circle algorithem which is an adaption of Bresenham's line algorithm |
DimiterK | 1:a368f2688222 | 320 | * http://en.wikipedia.org/wiki/Midpoint_circle_algorithm |
DimiterK | 1:a368f2688222 | 321 | * http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm |
DimiterK | 1:a368f2688222 | 322 | * Adapted from arduino lib |
DimiterK | 1:a368f2688222 | 323 | * |
DimiterK | 2:03d27b3fce6e | 324 | *@param CenterX center x coordinate |
DimiterK | 2:03d27b3fce6e | 325 | *@param CenterY center y coordinate |
DimiterK | 2:03d27b3fce6e | 326 | *@param Radius circle radius |
DimiterK | 2:03d27b3fce6e | 327 | *@param color Color can be BLACK or WHITE |
DimiterK | 1:a368f2688222 | 328 | */ |
DimiterK | 1:a368f2688222 | 329 | void FullCircle(unsigned int CenterX, unsigned int CenterY, unsigned int Radius,unsigned int color); |
DimiterK | 1:a368f2688222 | 330 | |
DimiterK | 1:a368f2688222 | 331 | /* |
DimiterK | 1:a368f2688222 | 332 | *Draws an ellipse. |
DimiterK | 2:03d27b3fce6e | 333 | *@param CX x coordinate of one side |
DimiterK | 2:03d27b3fce6e | 334 | *@param CY y coordinate of one side |
DimiterK | 2:03d27b3fce6e | 335 | *@param XRadius x coordinate of other side |
DimiterK | 2:03d27b3fce6e | 336 | *@param YRadius y coordinate of other side |
DimiterK | 1:a368f2688222 | 337 | *@param color can be BLACK or WHITE |
DimiterK | 1:a368f2688222 | 338 | *@return none |
DimiterK | 1:a368f2688222 | 339 | * |
DimiterK | 1:a368f2688222 | 340 | * Ported the algorithm found at http://homepage.smc.edu/kennedy_john/belipse.pdf |
DimiterK | 1:a368f2688222 | 341 | * |
DimiterK | 1:a368f2688222 | 342 | */ |
DimiterK | 1:a368f2688222 | 343 | void PlotEllipse(long CX, long CY, long XRadius,long YRadius, int color); |
DimiterK | 1:a368f2688222 | 344 | void Plot4EllipsePoints(long CX,long CY, long X, long Y, int color); |
DimiterK | 1:a368f2688222 | 345 | |
DimiterK | 2:03d27b3fce6e | 346 | /** |
DimiterK | 2:03d27b3fce6e | 347 | *@brief Draws an image on screen. |
DimiterK | 1:a368f2688222 | 348 | *@param PictureData 128x64 image array |
DimiterK | 1:a368f2688222 | 349 | *@return none |
DimiterK | 1:a368f2688222 | 350 | * |
DimiterK | 1:a368f2688222 | 351 | * |
DimiterK | 1:a368f2688222 | 352 | */ |
DimiterK | 1:a368f2688222 | 353 | void FullScreenBMP (unsigned char *PictureData); |
DimiterK | 1:a368f2688222 | 354 | |
DimiterK | 2:03d27b3fce6e | 355 | |
DimiterK | 2:03d27b3fce6e | 356 | /** |
DimiterK | 2:03d27b3fce6e | 357 | *@brief Draw a 1 bit bmp image at specified coordinates |
DimiterK | 2:03d27b3fce6e | 358 | * |
DimiterK | 2:03d27b3fce6e | 359 | *@param image struct containing img size and array |
DimiterK | 2:03d27b3fce6e | 360 | *@param x x-coordinate |
DimiterK | 2:03d27b3fce6e | 361 | *@param y y-coordinate |
DimiterK | 2:03d27b3fce6e | 362 | *@param color can be BLACK or WHITE |
DimiterK | 2:03d27b3fce6e | 363 | *@return none |
DimiterK | 2:03d27b3fce6e | 364 | */ |
DimiterK | 2:03d27b3fce6e | 365 | void CustomImage(Image* image,unsigned int x, unsigned int y, unsigned int color); |
DimiterK | 2:03d27b3fce6e | 366 | |
DimiterK | 2:03d27b3fce6e | 367 | /** |
DimiterK | 2:03d27b3fce6e | 368 | *@brief Round a double |
DimiterK | 1:a368f2688222 | 369 | *@param double |
DimiterK | 1:a368f2688222 | 370 | *@return value |
DimiterK | 1:a368f2688222 | 371 | * |
DimiterK | 1:a368f2688222 | 372 | */ |
DimiterK | 1:a368f2688222 | 373 | double dfloor( double value ); |
DimiterK | 1:a368f2688222 | 374 | |
DimiterK | 1:a368f2688222 | 375 | |
DimiterK | 2:03d27b3fce6e | 376 | /** |
DimiterK | 2:03d27b3fce6e | 377 | *@brief Print a character on specified coordinates |
DimiterK | 2:03d27b3fce6e | 378 | * |
DimiterK | 2:03d27b3fce6e | 379 | *@param page row |
DimiterK | 2:03d27b3fce6e | 380 | *@param col column |
DimiterK | 2:03d27b3fce6e | 381 | *@param c integer value |
DimiterK | 2:03d27b3fce6e | 382 | *@return none |
DimiterK | 2:03d27b3fce6e | 383 | */ |
DimiterK | 1:a368f2688222 | 384 | void Putc (int page, int col,unsigned char c); |
DimiterK | 0:135b9a0a816e | 385 | |
DimiterK | 2:03d27b3fce6e | 386 | /** |
DimiterK | 2:03d27b3fce6e | 387 | *@brief Print a string on specified coordinates |
DimiterK | 2:03d27b3fce6e | 388 | * |
DimiterK | 2:03d27b3fce6e | 389 | *@param str char array |
DimiterK | 2:03d27b3fce6e | 390 | *@param x row |
DimiterK | 2:03d27b3fce6e | 391 | *@param y column |
DimiterK | 2:03d27b3fce6e | 392 | *@return none |
DimiterK | 2:03d27b3fce6e | 393 | */ |
DimiterK | 1:a368f2688222 | 394 | void PutString(unsigned int x, unsigned int y,char* str); |
DimiterK | 1:a368f2688222 | 395 | |
DimiterK | 2:03d27b3fce6e | 396 | /** |
DimiterK | 2:03d27b3fce6e | 397 | *@brief Print a float on specified coordinates |
DimiterK | 2:03d27b3fce6e | 398 | * |
DimiterK | 2:03d27b3fce6e | 399 | *@param val float value |
DimiterK | 2:03d27b3fce6e | 400 | *@param x row |
DimiterK | 2:03d27b3fce6e | 401 | *@param y column |
DimiterK | 2:03d27b3fce6e | 402 | *@return none |
DimiterK | 2:03d27b3fce6e | 403 | */ |
DimiterK | 1:a368f2688222 | 404 | void PrintFloat(float val, unsigned int x,unsigned int y); |
DimiterK | 1:a368f2688222 | 405 | |
DimiterK | 2:03d27b3fce6e | 406 | /** |
DimiterK | 2:03d27b3fce6e | 407 | *@brief Print an integer on specified coordinates |
DimiterK | 2:03d27b3fce6e | 408 | * |
DimiterK | 2:03d27b3fce6e | 409 | *@param val integer value |
DimiterK | 2:03d27b3fce6e | 410 | *@param x row |
DimiterK | 2:03d27b3fce6e | 411 | *@param y column |
DimiterK | 2:03d27b3fce6e | 412 | *@return none |
DimiterK | 2:03d27b3fce6e | 413 | */ |
DimiterK | 1:a368f2688222 | 414 | void PrintInteger(int val,unsigned int x,unsigned int y); |
DimiterK | 1:a368f2688222 | 415 | |
DimiterK | 2:03d27b3fce6e | 416 | /** |
DimiterK | 2:03d27b3fce6e | 417 | *@brief Set cursor to specified coordinates |
DimiterK | 2:03d27b3fce6e | 418 | * |
DimiterK | 2:03d27b3fce6e | 419 | *@param x row |
DimiterK | 2:03d27b3fce6e | 420 | *@param y column |
DimiterK | 1:a368f2688222 | 421 | *@return none |
DimiterK | 1:a368f2688222 | 422 | */ |
DimiterK | 1:a368f2688222 | 423 | void CursorXY( unsigned int x, unsigned int y); |
DimiterK | 1:a368f2688222 | 424 | |
DimiterK | 1:a368f2688222 | 425 | |
DimiterK | 1:a368f2688222 | 426 | |
DimiterK | 1:a368f2688222 | 427 | private: |
DimiterK | 1:a368f2688222 | 428 | BusInOut DB; |
DimiterK | 1:a368f2688222 | 429 | DigitalOut RST; |
DimiterK | 1:a368f2688222 | 430 | DigitalOut DI; |
DimiterK | 1:a368f2688222 | 431 | DigitalOut RW; |
DimiterK | 1:a368f2688222 | 432 | DigitalOut E; |
DimiterK | 1:a368f2688222 | 433 | DigitalInOut CS2; |
DimiterK | 1:a368f2688222 | 434 | DigitalInOut CS1; |
DimiterK | 1:a368f2688222 | 435 | |
DimiterK | 1:a368f2688222 | 436 | unsigned int color; |
DimiterK | 1:a368f2688222 | 437 | unsigned int* Font; |
DimiterK | 1:a368f2688222 | 438 | LCDCoord Coord; |
DimiterK | 0:135b9a0a816e | 439 | }; |
DimiterK | 1:a368f2688222 | 440 | |
DimiterK | 0:135b9a0a816e | 441 | |
DimiterK | 0:135b9a0a816e | 442 | #endif |