Added custom fonts. Added triangle drawing function
Dependents: sc100016x4lcd REVO_Updated_Steering Driving_game Arkanoid_v1 ... more
KS0108.h@4:bdc04bb2ffc1, 2011-02-10 (annotated)
- Committer:
- DimiterK
- Date:
- Thu Feb 10 03:06:19 2011 +0000
- Revision:
- 4:bdc04bb2ffc1
- Parent:
- 2:03d27b3fce6e
- Child:
- 5:e4b50f4c13a8
Added two helper functions. Ver1.11
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 | 4:bdc04bb2ffc1 | 26 | #define VERSION 1.11 |
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 | 4:bdc04bb2ffc1 | 77 | #define MAX_IMG_SIZE 128*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 | class KS0108 { |
DimiterK | 1:a368f2688222 | 88 | public: |
DimiterK | 2:03d27b3fce6e | 89 | |
DimiterK | 2:03d27b3fce6e | 90 | /** |
DimiterK | 2:03d27b3fce6e | 91 | *@brief Constructor, initializes the lcd on the respective pins. |
DimiterK | 2:03d27b3fce6e | 92 | *@param control pins RST,DI,RW,E,CS2,CS1 |
DimiterK | 2:03d27b3fce6e | 93 | *@param databus DB0-DB7 data pins |
DimiterK | 2:03d27b3fce6e | 94 | *@return none |
DimiterK | 2:03d27b3fce6e | 95 | */ |
DimiterK | 1:a368f2688222 | 96 | |
DimiterK | 1:a368f2688222 | 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); |
DimiterK | 1:a368f2688222 | 98 | |
DimiterK | 2:03d27b3fce6e | 99 | /** |
DimiterK | 2:03d27b3fce6e | 100 | *@brief Write instruction to the specific controller. |
DimiterK | 2:03d27b3fce6e | 101 | *@param Command command to send to the controller |
DimiterK | 2:03d27b3fce6e | 102 | *@param side controller side can be LEFT or RIGHT |
DimiterK | 1:a368f2688222 | 103 | *@return none |
DimiterK | 1:a368f2688222 | 104 | * |
DimiterK | 1:a368f2688222 | 105 | */ |
DimiterK | 1:a368f2688222 | 106 | void WriteInstruction(unsigned int Command,unsigned int side); |
DimiterK | 1:a368f2688222 | 107 | |
DimiterK | 2:03d27b3fce6e | 108 | /** |
DimiterK | 2:03d27b3fce6e | 109 | *@brief Write data byte to the controller. |
DimiterK | 2:03d27b3fce6e | 110 | *@param data data send to the controller chip |
DimiterK | 2:03d27b3fce6e | 111 | *@param side selected controller can be LEFT or RIGHT |
DimiterK | 2:03d27b3fce6e | 112 | *@return none |
DimiterK | 1:a368f2688222 | 113 | * |
DimiterK | 1:a368f2688222 | 114 | */ |
DimiterK | 1:a368f2688222 | 115 | void WriteData(unsigned int data ,unsigned char side); |
DimiterK | 1:a368f2688222 | 116 | |
DimiterK | 2:03d27b3fce6e | 117 | /** |
DimiterK | 2:03d27b3fce6e | 118 | *@brief Write data byte to the screen on specific page and column |
DimiterK | 2:03d27b3fce6e | 119 | *@param page page varies from 0-7 for each side |
DimiterK | 2:03d27b3fce6e | 120 | *@param col col varies from 0-64 for each side |
DimiterK | 2:03d27b3fce6e | 121 | *@param data info to be written on given coordinates |
DimiterK | 2:03d27b3fce6e | 122 | *@return none |
DimiterK | 2:03d27b3fce6e | 123 | * |
DimiterK | 2:03d27b3fce6e | 124 | */ |
DimiterK | 1:a368f2688222 | 125 | void WriteDataColPag(unsigned int page, unsigned int col, unsigned int data); |
DimiterK | 1:a368f2688222 | 126 | |
DimiterK | 2:03d27b3fce6e | 127 | /** |
DimiterK | 2:03d27b3fce6e | 128 | *@brief Read data from display |
DimiterK | 1:a368f2688222 | 129 | *@param none |
DimiterK | 2:03d27b3fce6e | 130 | *@return none |
DimiterK | 1:a368f2688222 | 131 | * |
DimiterK | 1:a368f2688222 | 132 | */ |
DimiterK | 1:a368f2688222 | 133 | unsigned int ReadData(); |
DimiterK | 1:a368f2688222 | 134 | |
DimiterK | 2:03d27b3fce6e | 135 | /** |
DimiterK | 2:03d27b3fce6e | 136 | *@brief Read status of display , and check if it's busy |
DimiterK | 1:a368f2688222 | 137 | *@param none |
DimiterK | 2:03d27b3fce6e | 138 | *@return status status of display |
DimiterK | 1:a368f2688222 | 139 | * |
DimiterK | 1:a368f2688222 | 140 | */ |
DimiterK | 1:a368f2688222 | 141 | unsigned int ReadStatus(); |
DimiterK | 1:a368f2688222 | 142 | |
DimiterK | 2:03d27b3fce6e | 143 | /** |
DimiterK | 2:03d27b3fce6e | 144 | *@brief Select controller chip |
DimiterK | 1:a368f2688222 | 145 | * |
DimiterK | 2:03d27b3fce6e | 146 | *@param side controller side can be LEFT or RIGHT |
DimiterK | 1:a368f2688222 | 147 | *@return none |
DimiterK | 1:a368f2688222 | 148 | * |
DimiterK | 1:a368f2688222 | 149 | */ |
DimiterK | 1:a368f2688222 | 150 | void SelectSide(unsigned char side); |
DimiterK | 0:135b9a0a816e | 151 | |
DimiterK | 2:03d27b3fce6e | 152 | /** |
DimiterK | 2:03d27b3fce6e | 153 | *@brief Clears display |
DimiterK | 1:a368f2688222 | 154 | * |
DimiterK | 1:a368f2688222 | 155 | *@param none |
DimiterK | 1:a368f2688222 | 156 | *@return none |
DimiterK | 1:a368f2688222 | 157 | * |
DimiterK | 1:a368f2688222 | 158 | */ |
DimiterK | 1:a368f2688222 | 159 | void ClearScreen(); |
DimiterK | 4:bdc04bb2ffc1 | 160 | |
DimiterK | 4:bdc04bb2ffc1 | 161 | |
DimiterK | 4:bdc04bb2ffc1 | 162 | /** |
DimiterK | 4:bdc04bb2ffc1 | 163 | *@brief Turn on display |
DimiterK | 4:bdc04bb2ffc1 | 164 | * |
DimiterK | 4:bdc04bb2ffc1 | 165 | *@param none |
DimiterK | 4:bdc04bb2ffc1 | 166 | *@return none |
DimiterK | 4:bdc04bb2ffc1 | 167 | * |
DimiterK | 4:bdc04bb2ffc1 | 168 | */ |
DimiterK | 4:bdc04bb2ffc1 | 169 | void TurnOn(); |
DimiterK | 4:bdc04bb2ffc1 | 170 | |
DimiterK | 4:bdc04bb2ffc1 | 171 | |
DimiterK | 4:bdc04bb2ffc1 | 172 | /** |
DimiterK | 4:bdc04bb2ffc1 | 173 | *@brief Turn Off display |
DimiterK | 4:bdc04bb2ffc1 | 174 | * |
DimiterK | 4:bdc04bb2ffc1 | 175 | *@param none |
DimiterK | 4:bdc04bb2ffc1 | 176 | *@return none |
DimiterK | 4:bdc04bb2ffc1 | 177 | * |
DimiterK | 4:bdc04bb2ffc1 | 178 | */ |
DimiterK | 4:bdc04bb2ffc1 | 179 | void TurnOff(); |
DimiterK | 1:a368f2688222 | 180 | |
DimiterK | 1:a368f2688222 | 181 | /*******************************Graphic functions************************************************/ |
DimiterK | 1:a368f2688222 | 182 | |
DimiterK | 2:03d27b3fce6e | 183 | /** |
DimiterK | 2:03d27b3fce6e | 184 | *@brief Set pixel to specific location on the screen. |
DimiterK | 2:03d27b3fce6e | 185 | *@param x coordinate varies from 0-128 |
DimiterK | 2:03d27b3fce6e | 186 | *@param y col varies from 0-64 |
DimiterK | 2:03d27b3fce6e | 187 | *@param color color of pixel, can be BLACK or WHITE |
DimiterK | 2:03d27b3fce6e | 188 | *@return none |
DimiterK | 2:03d27b3fce6e | 189 | * |
DimiterK | 2:03d27b3fce6e | 190 | */ |
DimiterK | 1:a368f2688222 | 191 | void SetPixel( unsigned int x, unsigned int y, unsigned int color); |
DimiterK | 1:a368f2688222 | 192 | |
DimiterK | 1:a368f2688222 | 193 | |
DimiterK | 2:03d27b3fce6e | 194 | /** |
DimiterK | 2:03d27b3fce6e | 195 | *@brief Draws a line from x1,y1 to x2,y1 |
DimiterK | 2:03d27b3fce6e | 196 | *@param Xaxis1 x coordinate of one side |
DimiterK | 2:03d27b3fce6e | 197 | *@param Xaxis2 x coordinate of one side |
DimiterK | 2:03d27b3fce6e | 198 | *@param Yaxis y coordinate both points |
DimiterK | 1:a368f2688222 | 199 | *@param color can be BLACK or WHITE |
DimiterK | 1:a368f2688222 | 200 | *@return none |
DimiterK | 1:a368f2688222 | 201 | * |
DimiterK | 1:a368f2688222 | 202 | */ |
DimiterK | 2:03d27b3fce6e | 203 | void HLine(unsigned int Xaxis1, unsigned int Xaxis2 ,unsigned int Yaxis,unsigned int color); |
DimiterK | 0:135b9a0a816e | 204 | |
DimiterK | 2:03d27b3fce6e | 205 | /** |
DimiterK | 2:03d27b3fce6e | 206 | *@brief Draw a horizontal line |
DimiterK | 1:a368f2688222 | 207 | *@param Xaxis1 |
DimiterK | 1:a368f2688222 | 208 | *@param Xaxis2 |
DimiterK | 2:03d27b3fce6e | 209 | *@param width |
DimiterK | 1:a368f2688222 | 210 | *@param color can be BLACK or WHITE |
DimiterK | 1:a368f2688222 | 211 | *@return none |
DimiterK | 1:a368f2688222 | 212 | * |
DimiterK | 1:a368f2688222 | 213 | */ |
DimiterK | 1:a368f2688222 | 214 | void HLineShort(unsigned int Xaxis, unsigned int Yaxis,unsigned int width ,unsigned int color); |
DimiterK | 1:a368f2688222 | 215 | |
DimiterK | 2:03d27b3fce6e | 216 | /** |
DimiterK | 2:03d27b3fce6e | 217 | *@brief Draws a vertical line |
DimiterK | 2:03d27b3fce6e | 218 | *@param Xaxis |
DimiterK | 2:03d27b3fce6e | 219 | *@param Yaxis1 |
DimiterK | 2:03d27b3fce6e | 220 | *@param Yaxis2 |
DimiterK | 1:a368f2688222 | 221 | *@param color can be BLACK or WHITE |
DimiterK | 1:a368f2688222 | 222 | *@return none |
DimiterK | 1:a368f2688222 | 223 | * |
DimiterK | 1:a368f2688222 | 224 | */ |
DimiterK | 1:a368f2688222 | 225 | void VLine(unsigned int Xaxis, unsigned int Yaxis1 ,unsigned int Yaxis2,unsigned int color); |
DimiterK | 1:a368f2688222 | 226 | |
DimiterK | 2:03d27b3fce6e | 227 | /** |
DimiterK | 2:03d27b3fce6e | 228 | *@brief Draw a vertical line of a given width starting from X, Y |
DimiterK | 2:03d27b3fce6e | 229 | *@param Xaxis |
DimiterK | 1:a368f2688222 | 230 | *@param Yaxis |
DimiterK | 2:03d27b3fce6e | 231 | *@param height Height of line |
DimiterK | 1:a368f2688222 | 232 | *@param color can be BLACK or WHITE |
DimiterK | 1:a368f2688222 | 233 | *@return none |
DimiterK | 1:a368f2688222 | 234 | * |
DimiterK | 1:a368f2688222 | 235 | */ |
DimiterK | 1:a368f2688222 | 236 | void VLineShort(unsigned int Xaxis,unsigned int Yaxis, unsigned int height ,unsigned int color); |
DimiterK | 1:a368f2688222 | 237 | |
DimiterK | 1:a368f2688222 | 238 | |
DimiterK | 2:03d27b3fce6e | 239 | /** |
DimiterK | 2:03d27b3fce6e | 240 | *@brief Draws a line from x1,y1 to x2,y2. |
DimiterK | 2:03d27b3fce6e | 241 | *@param x1 x coordinate of one side |
DimiterK | 2:03d27b3fce6e | 242 | *@param y1 y coordinate of one side |
DimiterK | 2:03d27b3fce6e | 243 | *@param x2 x coordinate of other side |
DimiterK | 2:03d27b3fce6e | 244 | *@param y2 y coordinate of other side |
DimiterK | 1:a368f2688222 | 245 | *@param color can be BLACK or WHITE |
DimiterK | 1:a368f2688222 | 246 | *@return none |
DimiterK | 1:a368f2688222 | 247 | * |
DimiterK | 1:a368f2688222 | 248 | */ |
DimiterK | 1:a368f2688222 | 249 | void Line(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2, unsigned int color); |
DimiterK | 0:135b9a0a816e | 250 | |
DimiterK | 0:135b9a0a816e | 251 | |
DimiterK | 2:03d27b3fce6e | 252 | /** |
DimiterK | 2:03d27b3fce6e | 253 | *@brief Draws a slanty line from x1,y1 to x2,y2 |
DimiterK | 1:a368f2688222 | 254 | *@param lX1 x coordinate of one side |
DimiterK | 1:a368f2688222 | 255 | *@param lY1 y coordinate of one side |
DimiterK | 1:a368f2688222 | 256 | *@param lX2 x coordinate of other side |
DimiterK | 1:a368f2688222 | 257 | *@param lY2 y coordinate of other side |
DimiterK | 1:a368f2688222 | 258 | *@param color can be BLACK or WHITE |
DimiterK | 1:a368f2688222 | 259 | *@return none |
DimiterK | 1:a368f2688222 | 260 | * |
DimiterK | 1:a368f2688222 | 261 | */ |
DimiterK | 1:a368f2688222 | 262 | void SlantyLine(unsigned int lX1, unsigned int lY1, unsigned int lX2,unsigned int lY2,unsigned int color); |
DimiterK | 1:a368f2688222 | 263 | |
DimiterK | 2:03d27b3fce6e | 264 | /** |
DimiterK | 2:03d27b3fce6e | 265 | *@brief Draws a line from x,y at given degree from inner_radius to outer_radius. |
DimiterK | 2:03d27b3fce6e | 266 | *@param x |
DimiterK | 2:03d27b3fce6e | 267 | *@param y |
DimiterK | 2:03d27b3fce6e | 268 | *@param inner_radius |
DimiterK | 2:03d27b3fce6e | 269 | *@param outer_radius |
DimiterK | 1:a368f2688222 | 270 | *@param color can be BLACK or WHITE |
DimiterK | 1:a368f2688222 | 271 | *@return none |
DimiterK | 1:a368f2688222 | 272 | * |
DimiterK | 1:a368f2688222 | 273 | */ |
DimiterK | 1:a368f2688222 | 274 | void DegreeLine(unsigned int x, int y,unsigned int degree,unsigned int inner_radius,unsigned int outer_radius, unsigned int color); |
DimiterK | 1:a368f2688222 | 275 | |
DimiterK | 2:03d27b3fce6e | 276 | /** |
DimiterK | 2:03d27b3fce6e | 277 | *@brief Draw a filled reactangle |
DimiterK | 1:a368f2688222 | 278 | * |
DimiterK | 1:a368f2688222 | 279 | *@param Xaxis1 |
DimiterK | 1:a368f2688222 | 280 | *@param Yaxis1 |
DimiterK | 1:a368f2688222 | 281 | *@param Xaxis2 |
DimiterK | 1:a368f2688222 | 282 | *@param Yaxis2 |
DimiterK | 1:a368f2688222 | 283 | *@param color can be BLACK or WHITE |
DimiterK | 1:a368f2688222 | 284 | *@return none |
DimiterK | 1:a368f2688222 | 285 | * |
DimiterK | 1:a368f2688222 | 286 | */ |
DimiterK | 1:a368f2688222 | 287 | void FullRectangle(unsigned int Xaxis1, unsigned int Yaxis1, unsigned int Xaxis2 ,unsigned int Yaxis2,unsigned int color); |
DimiterK | 1:a368f2688222 | 288 | |
DimiterK | 2:03d27b3fce6e | 289 | /** |
DimiterK | 2:03d27b3fce6e | 290 | *@brief Draw an empty rectangle |
DimiterK | 1:a368f2688222 | 291 | *@param Xaxis1 |
DimiterK | 1:a368f2688222 | 292 | *@param Yaxis1 |
DimiterK | 1:a368f2688222 | 293 | *@param Xaxis2 |
DimiterK | 1:a368f2688222 | 294 | *@param Yaxis2 |
DimiterK | 1:a368f2688222 | 295 | *@param color can be BLACK or WHITE |
DimiterK | 1:a368f2688222 | 296 | *@return none |
DimiterK | 1:a368f2688222 | 297 | * |
DimiterK | 1:a368f2688222 | 298 | */ |
DimiterK | 1:a368f2688222 | 299 | void EmptyRectangle(unsigned int Xaxis1,unsigned int Yaxis1, unsigned int Xaxis2,unsigned int Yaxis2,unsigned int color); |
DimiterK | 1:a368f2688222 | 300 | |
DimiterK | 1:a368f2688222 | 301 | |
DimiterK | 2:03d27b3fce6e | 302 | /** |
DimiterK | 2:03d27b3fce6e | 303 | *@brief Draw a rectangle with round corners |
DimiterK | 2:03d27b3fce6e | 304 | *@param Xaxis1 x-coordinate of the top left point |
DimiterK | 2:03d27b3fce6e | 305 | *@param Yaxis1 y-coordinate of the top left point |
DimiterK | 2:03d27b3fce6e | 306 | *@param width rectangle width |
DimiterK | 2:03d27b3fce6e | 307 | *@param height rectangle height |
DimiterK | 2:03d27b3fce6e | 308 | *@param radius radius of the edges |
DimiterK | 1:a368f2688222 | 309 | *@param color can be BLACK or WHITE |
DimiterK | 1:a368f2688222 | 310 | *@return none |
DimiterK | 1:a368f2688222 | 311 | * |
DimiterK | 1:a368f2688222 | 312 | */ |
DimiterK | 1:a368f2688222 | 313 | void RoundRectangle(unsigned int x, unsigned int y, unsigned int width, unsigned int height, unsigned int radius, unsigned int color); |
DimiterK | 1:a368f2688222 | 314 | |
DimiterK | 1:a368f2688222 | 315 | |
DimiterK | 1:a368f2688222 | 316 | /* |
DimiterK | 1:a368f2688222 | 317 | *Draws an empty circle centered a x,y with radius R and specific color. |
DimiterK | 2:03d27b3fce6e | 318 | *@param CenterX center x coordinate |
DimiterK | 2:03d27b3fce6e | 319 | *@param CenterY center y coordinate |
DimiterK | 2:03d27b3fce6e | 320 | *@param Radius circle radius |
DimiterK | 2:03d27b3fce6e | 321 | *@param color Color can be BLACK or WHITE |
DimiterK | 1:a368f2688222 | 322 | *@return none |
DimiterK | 1:a368f2688222 | 323 | * |
DimiterK | 1:a368f2688222 | 324 | */ |
DimiterK | 1:a368f2688222 | 325 | void EmptyCircle(unsigned int CenterX, unsigned int CenterY, unsigned int Radius,unsigned int color); |
DimiterK | 1:a368f2688222 | 326 | |
DimiterK | 1:a368f2688222 | 327 | /* |
DimiterK | 1:a368f2688222 | 328 | * Circle fill Code is merely a modification of the midpoint |
DimiterK | 1:a368f2688222 | 329 | * circle algorithem which is an adaption of Bresenham's line algorithm |
DimiterK | 1:a368f2688222 | 330 | * http://en.wikipedia.org/wiki/Midpoint_circle_algorithm |
DimiterK | 1:a368f2688222 | 331 | * http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm |
DimiterK | 1:a368f2688222 | 332 | * Adapted from arduino lib |
DimiterK | 1:a368f2688222 | 333 | * |
DimiterK | 2:03d27b3fce6e | 334 | *@param CenterX center x coordinate |
DimiterK | 2:03d27b3fce6e | 335 | *@param CenterY center y coordinate |
DimiterK | 2:03d27b3fce6e | 336 | *@param Radius circle radius |
DimiterK | 2:03d27b3fce6e | 337 | *@param color Color can be BLACK or WHITE |
DimiterK | 1:a368f2688222 | 338 | */ |
DimiterK | 1:a368f2688222 | 339 | void FullCircle(unsigned int CenterX, unsigned int CenterY, unsigned int Radius,unsigned int color); |
DimiterK | 1:a368f2688222 | 340 | |
DimiterK | 1:a368f2688222 | 341 | /* |
DimiterK | 1:a368f2688222 | 342 | *Draws an ellipse. |
DimiterK | 2:03d27b3fce6e | 343 | *@param CX x coordinate of one side |
DimiterK | 2:03d27b3fce6e | 344 | *@param CY y coordinate of one side |
DimiterK | 2:03d27b3fce6e | 345 | *@param XRadius x coordinate of other side |
DimiterK | 2:03d27b3fce6e | 346 | *@param YRadius y coordinate of other side |
DimiterK | 1:a368f2688222 | 347 | *@param color can be BLACK or WHITE |
DimiterK | 1:a368f2688222 | 348 | *@return none |
DimiterK | 1:a368f2688222 | 349 | * |
DimiterK | 1:a368f2688222 | 350 | * Ported the algorithm found at http://homepage.smc.edu/kennedy_john/belipse.pdf |
DimiterK | 1:a368f2688222 | 351 | * |
DimiterK | 1:a368f2688222 | 352 | */ |
DimiterK | 1:a368f2688222 | 353 | void PlotEllipse(long CX, long CY, long XRadius,long YRadius, int color); |
DimiterK | 1:a368f2688222 | 354 | void Plot4EllipsePoints(long CX,long CY, long X, long Y, int color); |
DimiterK | 1:a368f2688222 | 355 | |
DimiterK | 2:03d27b3fce6e | 356 | /** |
DimiterK | 2:03d27b3fce6e | 357 | *@brief Draws an image on screen. |
DimiterK | 4:bdc04bb2ffc1 | 358 | *@param IamgeData 128x64 image array |
DimiterK | 1:a368f2688222 | 359 | *@return none |
DimiterK | 1:a368f2688222 | 360 | * |
DimiterK | 1:a368f2688222 | 361 | * |
DimiterK | 1:a368f2688222 | 362 | */ |
DimiterK | 4:bdc04bb2ffc1 | 363 | void FullScreenBMP (unsigned char *ImageData); |
DimiterK | 1:a368f2688222 | 364 | |
DimiterK | 2:03d27b3fce6e | 365 | |
DimiterK | 2:03d27b3fce6e | 366 | /** |
DimiterK | 2:03d27b3fce6e | 367 | *@brief Draw a 1 bit bmp image at specified coordinates |
DimiterK | 2:03d27b3fce6e | 368 | * |
DimiterK | 2:03d27b3fce6e | 369 | *@param image struct containing img size and array |
DimiterK | 2:03d27b3fce6e | 370 | *@param x x-coordinate |
DimiterK | 2:03d27b3fce6e | 371 | *@param y y-coordinate |
DimiterK | 2:03d27b3fce6e | 372 | *@param color can be BLACK or WHITE |
DimiterK | 2:03d27b3fce6e | 373 | *@return none |
DimiterK | 2:03d27b3fce6e | 374 | */ |
DimiterK | 2:03d27b3fce6e | 375 | void CustomImage(Image* image,unsigned int x, unsigned int y, unsigned int color); |
DimiterK | 2:03d27b3fce6e | 376 | |
DimiterK | 2:03d27b3fce6e | 377 | /** |
DimiterK | 2:03d27b3fce6e | 378 | *@brief Round a double |
DimiterK | 1:a368f2688222 | 379 | *@param double |
DimiterK | 1:a368f2688222 | 380 | *@return value |
DimiterK | 1:a368f2688222 | 381 | * |
DimiterK | 1:a368f2688222 | 382 | */ |
DimiterK | 1:a368f2688222 | 383 | double dfloor( double value ); |
DimiterK | 1:a368f2688222 | 384 | |
DimiterK | 1:a368f2688222 | 385 | |
DimiterK | 2:03d27b3fce6e | 386 | /** |
DimiterK | 2:03d27b3fce6e | 387 | *@brief Print a character on specified coordinates |
DimiterK | 2:03d27b3fce6e | 388 | * |
DimiterK | 2:03d27b3fce6e | 389 | *@param page row |
DimiterK | 2:03d27b3fce6e | 390 | *@param col column |
DimiterK | 2:03d27b3fce6e | 391 | *@param c integer value |
DimiterK | 2:03d27b3fce6e | 392 | *@return none |
DimiterK | 2:03d27b3fce6e | 393 | */ |
DimiterK | 1:a368f2688222 | 394 | void Putc (int page, int col,unsigned char c); |
DimiterK | 0:135b9a0a816e | 395 | |
DimiterK | 2:03d27b3fce6e | 396 | /** |
DimiterK | 2:03d27b3fce6e | 397 | *@brief Print a string on specified coordinates |
DimiterK | 2:03d27b3fce6e | 398 | * |
DimiterK | 2:03d27b3fce6e | 399 | *@param str char array |
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 PutString(unsigned int x, unsigned int y,char* str); |
DimiterK | 1:a368f2688222 | 405 | |
DimiterK | 2:03d27b3fce6e | 406 | /** |
DimiterK | 2:03d27b3fce6e | 407 | *@brief Print a float on specified coordinates |
DimiterK | 2:03d27b3fce6e | 408 | * |
DimiterK | 2:03d27b3fce6e | 409 | *@param val float 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 PrintFloat(float val, unsigned int x,unsigned int y); |
DimiterK | 1:a368f2688222 | 415 | |
DimiterK | 2:03d27b3fce6e | 416 | /** |
DimiterK | 2:03d27b3fce6e | 417 | *@brief Print an integer on specified coordinates |
DimiterK | 2:03d27b3fce6e | 418 | * |
DimiterK | 2:03d27b3fce6e | 419 | *@param val integer value |
DimiterK | 2:03d27b3fce6e | 420 | *@param x row |
DimiterK | 2:03d27b3fce6e | 421 | *@param y column |
DimiterK | 2:03d27b3fce6e | 422 | *@return none |
DimiterK | 2:03d27b3fce6e | 423 | */ |
DimiterK | 1:a368f2688222 | 424 | void PrintInteger(int val,unsigned int x,unsigned int y); |
DimiterK | 1:a368f2688222 | 425 | |
DimiterK | 2:03d27b3fce6e | 426 | /** |
DimiterK | 2:03d27b3fce6e | 427 | *@brief Set cursor to specified coordinates |
DimiterK | 2:03d27b3fce6e | 428 | * |
DimiterK | 2:03d27b3fce6e | 429 | *@param x row |
DimiterK | 2:03d27b3fce6e | 430 | *@param y column |
DimiterK | 1:a368f2688222 | 431 | *@return none |
DimiterK | 1:a368f2688222 | 432 | */ |
DimiterK | 1:a368f2688222 | 433 | void CursorXY( unsigned int x, unsigned int y); |
DimiterK | 1:a368f2688222 | 434 | |
DimiterK | 1:a368f2688222 | 435 | |
DimiterK | 1:a368f2688222 | 436 | |
DimiterK | 1:a368f2688222 | 437 | private: |
DimiterK | 1:a368f2688222 | 438 | BusInOut DB; |
DimiterK | 1:a368f2688222 | 439 | DigitalOut RST; |
DimiterK | 1:a368f2688222 | 440 | DigitalOut DI; |
DimiterK | 1:a368f2688222 | 441 | DigitalOut RW; |
DimiterK | 1:a368f2688222 | 442 | DigitalOut E; |
DimiterK | 1:a368f2688222 | 443 | DigitalInOut CS2; |
DimiterK | 1:a368f2688222 | 444 | DigitalInOut CS1; |
DimiterK | 1:a368f2688222 | 445 | |
DimiterK | 1:a368f2688222 | 446 | unsigned int color; |
DimiterK | 4:bdc04bb2ffc1 | 447 | unsigned int* Font; |
DimiterK | 0:135b9a0a816e | 448 | }; |
DimiterK | 1:a368f2688222 | 449 | |
DimiterK | 0:135b9a0a816e | 450 | |
DimiterK | 0:135b9a0a816e | 451 | #endif |