SP1 vers 3
EADOG.h@1:03129e57a003, 2016-09-22 (annotated)
- Committer:
- sstaub
- Date:
- Thu Sep 22 11:28:11 2016 +0000
- Revision:
- 1:03129e57a003
new library for EADOG displays from electronic assembly, only tested for EADOG132M
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sstaub | 1:03129e57a003 | 1 | /* mbed library for the EA DOGM128 (128x64), DOGM132 (132x32), DOGL128 (128x64) pixel LCD |
sstaub | 1:03129e57a003 | 2 | * use ST7565R controller |
sstaub | 1:03129e57a003 | 3 | * Copyright (c) 2016 Stefan Staub |
sstaub | 1:03129e57a003 | 4 | * Released under the MIT License: http://mbed.org/license/mit |
sstaub | 1:03129e57a003 | 5 | * |
sstaub | 1:03129e57a003 | 6 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
sstaub | 1:03129e57a003 | 7 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
sstaub | 1:03129e57a003 | 8 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
sstaub | 1:03129e57a003 | 9 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
sstaub | 1:03129e57a003 | 10 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
sstaub | 1:03129e57a003 | 11 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
sstaub | 1:03129e57a003 | 12 | * THE SOFTWARE. |
sstaub | 1:03129e57a003 | 13 | */ |
sstaub | 1:03129e57a003 | 14 | |
sstaub | 1:03129e57a003 | 15 | #ifndef EADOG_H |
sstaub | 1:03129e57a003 | 16 | #define EADOG_H |
sstaub | 1:03129e57a003 | 17 | |
sstaub | 1:03129e57a003 | 18 | #include "mbed.h" |
sstaub | 1:03129e57a003 | 19 | |
sstaub | 1:03129e57a003 | 20 | /** display type |
sstaub | 1:03129e57a003 | 21 | * |
sstaub | 1:03129e57a003 | 22 | * @param DOGM128 128x64 2.3'' |
sstaub | 1:03129e57a003 | 23 | * @param DOGM132 132x32 2.1'' |
sstaub | 1:03129e57a003 | 24 | * @param DOGL128 128x64 2.8'' |
sstaub | 1:03129e57a003 | 25 | * |
sstaub | 1:03129e57a003 | 26 | */ |
sstaub | 1:03129e57a003 | 27 | enum {DOGM128, DOGM132, DOGL128}; |
sstaub | 1:03129e57a003 | 28 | |
sstaub | 1:03129e57a003 | 29 | /** update modes |
sstaub | 1:03129e57a003 | 30 | * |
sstaub | 1:03129e57a003 | 31 | * @param AUTO default |
sstaub | 1:03129e57a003 | 32 | * @param MANUELL |
sstaub | 1:03129e57a003 | 33 | * |
sstaub | 1:03129e57a003 | 34 | */ |
sstaub | 1:03129e57a003 | 35 | enum {MANUAL, AUTO}; |
sstaub | 1:03129e57a003 | 36 | |
sstaub | 1:03129e57a003 | 37 | /** display settings |
sstaub | 1:03129e57a003 | 38 | * |
sstaub | 1:03129e57a003 | 39 | * @param ON display on, default |
sstaub | 1:03129e57a003 | 40 | * @param OFF display off |
sstaub | 1:03129e57a003 | 41 | * @param SLEEP sets the display to sleep mode |
sstaub | 1:03129e57a003 | 42 | * @param DEFAULT default |
sstaub | 1:03129e57a003 | 43 | * @param INVERT inverts display |
sstaub | 1:03129e57a003 | 44 | * @param BOTTOM default 0° |
sstaub | 1:03129e57a003 | 45 | * @param TOPVIEW rotate the screento 180° |
sstaub | 1:03129e57a003 | 46 | * |
sstaub | 1:03129e57a003 | 47 | */ |
sstaub | 1:03129e57a003 | 48 | enum {ON, OFF, SLEEP, DEFAULT, INVERT, BOTTOM, TOPVIEW, CONTRAST, RST}; |
sstaub | 1:03129e57a003 | 49 | |
sstaub | 1:03129e57a003 | 50 | /** bitmap |
sstaub | 1:03129e57a003 | 51 | * |
sstaub | 1:03129e57a003 | 52 | */ |
sstaub | 1:03129e57a003 | 53 | struct Bitmap { |
sstaub | 1:03129e57a003 | 54 | int xSize; |
sstaub | 1:03129e57a003 | 55 | int ySize; |
sstaub | 1:03129e57a003 | 56 | int byte_in_Line; |
sstaub | 1:03129e57a003 | 57 | char *data; |
sstaub | 1:03129e57a003 | 58 | }; |
sstaub | 1:03129e57a003 | 59 | |
sstaub | 1:03129e57a003 | 60 | /** Library for the EADOG LCD displays from electronic assembly |
sstaub | 1:03129e57a003 | 61 | * |
sstaub | 1:03129e57a003 | 62 | * Example for EA DOGM132x-5 with STM32F401RE Nucleo |
sstaub | 1:03129e57a003 | 63 | * @code |
sstaub | 1:03129e57a003 | 64 | * // display test for EA DOGM132x-5 with STM32F401RE Nucleo |
sstaub | 1:03129e57a003 | 65 | * // sstaub(c)2016 |
sstaub | 1:03129e57a003 | 66 | * |
sstaub | 1:03129e57a003 | 67 | * #include "mbed.h" |
sstaub | 1:03129e57a003 | 68 | * #include "EADOG.h" |
sstaub | 1:03129e57a003 | 69 | * #include "Small_7.h" |
sstaub | 1:03129e57a003 | 70 | * #include "Fonts/ArialR12x14.h" |
sstaub | 1:03129e57a003 | 71 | * |
sstaub | 1:03129e57a003 | 72 | * // DOGM132x-5 Wide Range |
sstaub | 1:03129e57a003 | 73 | * // Pins for STM32F401RE Nucleo |
sstaub | 1:03129e57a003 | 74 | * |
sstaub | 1:03129e57a003 | 75 | * // DOG Pin Purpose ST Pin |
sstaub | 1:03129e57a003 | 76 | * // 40 CS PB_6(D10) |
sstaub | 1:03129e57a003 | 77 | * // 39 Reset PC_7(D9) |
sstaub | 1:03129e57a003 | 78 | * // 38 A0 PA_9(D8) |
sstaub | 1:03129e57a003 | 79 | * // 37 SCK PA_5(D13, SCK) |
sstaub | 1:03129e57a003 | 80 | * // 36 MOSI PA_7(D11, MOSI) |
sstaub | 1:03129e57a003 | 81 | * // 35 VDD 3.3V |
sstaub | 1:03129e57a003 | 82 | * // 34 VDD2 3.3V |
sstaub | 1:03129e57a003 | 83 | * // 33 VSS GND |
sstaub | 1:03129e57a003 | 84 | * // 32 VOUT 1uF -> GND |
sstaub | 1:03129e57a003 | 85 | * // 31 CAP3P 1uF -> CAP1N |
sstaub | 1:03129e57a003 | 86 | * // 30 CAP1N 1uF -> CAP1P |
sstaub | 1:03129e57a003 | 87 | * // 29 CAP1P |
sstaub | 1:03129e57a003 | 88 | * // 28 CAP2P 1uF -> CAP2N |
sstaub | 1:03129e57a003 | 89 | * // 27 CAP2N |
sstaub | 1:03129e57a003 | 90 | * // 26 VSS GND |
sstaub | 1:03129e57a003 | 91 | * // 25 V4 1uF -> GND |
sstaub | 1:03129e57a003 | 92 | * // 24 V3 1uF -> GND |
sstaub | 1:03129e57a003 | 93 | * // 23 V2 1uF -> GND |
sstaub | 1:03129e57a003 | 94 | * // 22 V1 1uF -> GND |
sstaub | 1:03129e57a003 | 95 | * // 21 V0 1uF -> GND |
sstaub | 1:03129e57a003 | 96 | * |
sstaub | 1:03129e57a003 | 97 | * |
sstaub | 1:03129e57a003 | 98 | * EADOG lcd(PA_7, PA_5, PC_7, PA_9, PB_6, DOGM132); // MOSI, SCK, Reset, A0, CS |
sstaub | 1:03129e57a003 | 99 | * |
sstaub | 1:03129e57a003 | 100 | * int main() { |
sstaub | 1:03129e57a003 | 101 | * // create logo |
sstaub | 1:03129e57a003 | 102 | * lcd.update(MANUAL); |
sstaub | 1:03129e57a003 | 103 | * lcd.rectangle(0, 0, 131, 31, 1); |
sstaub | 1:03129e57a003 | 104 | * lcd.fillrect(2, 2, 4, 4, 1); |
sstaub | 1:03129e57a003 | 105 | * lcd.fillrect(2, 27, 4, 29, 1); |
sstaub | 1:03129e57a003 | 106 | * lcd.fillrect(61, 2, 63, 4, 1); |
sstaub | 1:03129e57a003 | 107 | * lcd.fillrect(61, 27, 63, 29, 1); |
sstaub | 1:03129e57a003 | 108 | * lcd.line(65, 0, 65, 31, 1); |
sstaub | 1:03129e57a003 | 109 | * lcd.circle(33, 15, 10, 1); |
sstaub | 1:03129e57a003 | 110 | * lcd.circle(33, 15, 6, 1); |
sstaub | 1:03129e57a003 | 111 | * lcd.fillcircle(33, 15, 3, 1); |
sstaub | 1:03129e57a003 | 112 | * lcd.update(); |
sstaub | 1:03129e57a003 | 113 | * lcd.update(AUTO); |
sstaub | 1:03129e57a003 | 114 | * // create description text |
sstaub | 1:03129e57a003 | 115 | * lcd.locate(70, 1); |
sstaub | 1:03129e57a003 | 116 | * lcd.font((unsigned char*)ArialR12x14); |
sstaub | 1:03129e57a003 | 117 | * lcd.printf("mbed"); |
sstaub | 1:03129e57a003 | 118 | * lcd.locate(70, 13); |
sstaub | 1:03129e57a003 | 119 | * lcd.font((unsigned char*)Small_7); |
sstaub | 1:03129e57a003 | 120 | * lcd.printf("EA"); |
sstaub | 1:03129e57a003 | 121 | * lcd.locate(70, 22); |
sstaub | 1:03129e57a003 | 122 | * lcd.printf("DOGM132x-5"); |
sstaub | 1:03129e57a003 | 123 | * |
sstaub | 1:03129e57a003 | 124 | * wait(1); |
sstaub | 1:03129e57a003 | 125 | * lcd.display(CONTRAST, 16); // contrast low |
sstaub | 1:03129e57a003 | 126 | * wait(1); |
sstaub | 1:03129e57a003 | 127 | * lcd.display(CONTRAST, 40); // contrast high |
sstaub | 1:03129e57a003 | 128 | * wait(1); |
sstaub | 1:03129e57a003 | 129 | * lcd.display(CONTRAST); // contrast default |
sstaub | 1:03129e57a003 | 130 | * wait(1); |
sstaub | 1:03129e57a003 | 131 | * lcd.display(OFF); // display off |
sstaub | 1:03129e57a003 | 132 | * wait(1); |
sstaub | 1:03129e57a003 | 133 | * lcd.display(ON); // display on |
sstaub | 1:03129e57a003 | 134 | * wait(1); |
sstaub | 1:03129e57a003 | 135 | * lcd.display(SLEEP); // display sleep |
sstaub | 1:03129e57a003 | 136 | * wait(1); |
sstaub | 1:03129e57a003 | 137 | * lcd.display(ON); // display wake up |
sstaub | 1:03129e57a003 | 138 | * |
sstaub | 1:03129e57a003 | 139 | * while(1) { // main loop |
sstaub | 1:03129e57a003 | 140 | * lcd.display(INVERT); // display inverted |
sstaub | 1:03129e57a003 | 141 | * lcd.display(BOTTOM); // display normal orientation |
sstaub | 1:03129e57a003 | 142 | * wait(2); |
sstaub | 1:03129e57a003 | 143 | * lcd.display(DEFAULT); // display |
sstaub | 1:03129e57a003 | 144 | * lcd.display(TOPVIEW); // display rotated |
sstaub | 1:03129e57a003 | 145 | * wait(2); |
sstaub | 1:03129e57a003 | 146 | * } |
sstaub | 1:03129e57a003 | 147 | * } |
sstaub | 1:03129e57a003 | 148 | * @endcode |
sstaub | 1:03129e57a003 | 149 | */ |
sstaub | 1:03129e57a003 | 150 | class EADOG : public Stream { |
sstaub | 1:03129e57a003 | 151 | |
sstaub | 1:03129e57a003 | 152 | public: |
sstaub | 1:03129e57a003 | 153 | |
sstaub | 1:03129e57a003 | 154 | /** create a EADOG object connected to SPI |
sstaub | 1:03129e57a003 | 155 | * |
sstaub | 1:03129e57a003 | 156 | * @param mosi pinname |
sstaub | 1:03129e57a003 | 157 | * @param sck pinname |
sstaub | 1:03129e57a003 | 158 | * @param reset pinname |
sstaub | 1:03129e57a003 | 159 | * @param a0 pinname |
sstaub | 1:03129e57a003 | 160 | * @param cs pinname |
sstaub | 1:03129e57a003 | 161 | * |
sstaub | 1:03129e57a003 | 162 | */ |
sstaub | 1:03129e57a003 | 163 | EADOG(PinName mosi, PinName sck, PinName reset, PinName a0, PinName cs, uint8_t type); |
sstaub | 1:03129e57a003 | 164 | |
sstaub | 1:03129e57a003 | 165 | /** draw a pixel in buffer at x, y black or white |
sstaub | 1:03129e57a003 | 166 | * |
sstaub | 1:03129e57a003 | 167 | * @param x horizontal position |
sstaub | 1:03129e57a003 | 168 | * @param y vertical position |
sstaub | 1:03129e57a003 | 169 | * @param colour 1 set pixel, 0 erase pixel |
sstaub | 1:03129e57a003 | 170 | * there is no update, it writes the pixel only in the buffer |
sstaub | 1:03129e57a003 | 171 | */ |
sstaub | 1:03129e57a003 | 172 | void pixel(int x, int y, uint8_t colour); |
sstaub | 1:03129e57a003 | 173 | |
sstaub | 1:03129e57a003 | 174 | /** draw a single point |
sstaub | 1:03129e57a003 | 175 | * |
sstaub | 1:03129e57a003 | 176 | * @param x horizontal position |
sstaub | 1:03129e57a003 | 177 | * @param y vertical position |
sstaub | 1:03129e57a003 | 178 | * @param colour 1 set pixel, 0 erase pixel |
sstaub | 1:03129e57a003 | 179 | * |
sstaub | 1:03129e57a003 | 180 | */ |
sstaub | 1:03129e57a003 | 181 | void point(int x, int y, uint8_t colour); |
sstaub | 1:03129e57a003 | 182 | |
sstaub | 1:03129e57a003 | 183 | /** draw a 1 pixel line |
sstaub | 1:03129e57a003 | 184 | * |
sstaub | 1:03129e57a003 | 185 | * @param x0,y0 start point |
sstaub | 1:03129e57a003 | 186 | * @param x1,y1 end point |
sstaub | 1:03129e57a003 | 187 | * @param color 1 set pixel, 0 erase pixel |
sstaub | 1:03129e57a003 | 188 | * |
sstaub | 1:03129e57a003 | 189 | */ |
sstaub | 1:03129e57a003 | 190 | void line(int x0, int y0, int x1, int y1, uint8_t colour); |
sstaub | 1:03129e57a003 | 191 | |
sstaub | 1:03129e57a003 | 192 | /** draw a rect |
sstaub | 1:03129e57a003 | 193 | * |
sstaub | 1:03129e57a003 | 194 | * @param x0,y0 top left corner |
sstaub | 1:03129e57a003 | 195 | * @param x1,y1 down right corner |
sstaub | 1:03129e57a003 | 196 | * @param color 1 set pixel, 0 erase pixel |
sstaub | 1:03129e57a003 | 197 | * |
sstaub | 1:03129e57a003 | 198 | */ |
sstaub | 1:03129e57a003 | 199 | void rectangle(int x0, int y0, int x1, int y1, uint8_t colour); |
sstaub | 1:03129e57a003 | 200 | |
sstaub | 1:03129e57a003 | 201 | /** draw a filled rect |
sstaub | 1:03129e57a003 | 202 | * |
sstaub | 1:03129e57a003 | 203 | * @param x0,y0 top left corner |
sstaub | 1:03129e57a003 | 204 | * @param x1,y1 down right corner |
sstaub | 1:03129e57a003 | 205 | * @param color 1 set pixel, 0 erase pixel |
sstaub | 1:03129e57a003 | 206 | * |
sstaub | 1:03129e57a003 | 207 | */ |
sstaub | 1:03129e57a003 | 208 | void fillrect(int x0, int y0, int x1, int y1, uint8_t colour); |
sstaub | 1:03129e57a003 | 209 | |
sstaub | 1:03129e57a003 | 210 | /** draw a rounded rect |
sstaub | 1:03129e57a003 | 211 | * |
sstaub | 1:03129e57a003 | 212 | * @param x0,y0 top left corner |
sstaub | 1:03129e57a003 | 213 | * @param x1,y1 down right corner |
sstaub | 1:03129e57a003 | 214 | * @param rnd radius of the rounding |
sstaub | 1:03129e57a003 | 215 | * @param color 1 set pixel, 0 erase pixel |
sstaub | 1:03129e57a003 | 216 | * |
sstaub | 1:03129e57a003 | 217 | */ |
sstaub | 1:03129e57a003 | 218 | void roundrect(int x0, int y0, int x1, int y1, int rnd, uint8_t colour); |
sstaub | 1:03129e57a003 | 219 | |
sstaub | 1:03129e57a003 | 220 | /** draw a filled rounded rect |
sstaub | 1:03129e57a003 | 221 | * |
sstaub | 1:03129e57a003 | 222 | * @param x0,y0 top left corner |
sstaub | 1:03129e57a003 | 223 | * @param x1,y1 down right corner |
sstaub | 1:03129e57a003 | 224 | * @param rnd radius of the rounding |
sstaub | 1:03129e57a003 | 225 | * @param color 1 set pixel, 0 erase pixel |
sstaub | 1:03129e57a003 | 226 | * |
sstaub | 1:03129e57a003 | 227 | */ |
sstaub | 1:03129e57a003 | 228 | void fillrrect(int x0, int y0, int x1, int y1, int rnd, uint8_t colour); |
sstaub | 1:03129e57a003 | 229 | |
sstaub | 1:03129e57a003 | 230 | |
sstaub | 1:03129e57a003 | 231 | /** draw a circle |
sstaub | 1:03129e57a003 | 232 | * |
sstaub | 1:03129e57a003 | 233 | * @param x0,y0 center |
sstaub | 1:03129e57a003 | 234 | * @param r radius |
sstaub | 1:03129e57a003 | 235 | * @param colour 1 set pixel, 0 erase pixel |
sstaub | 1:03129e57a003 | 236 | * |
sstaub | 1:03129e57a003 | 237 | */ |
sstaub | 1:03129e57a003 | 238 | void circle(int x, int y, int r, uint8_t colour); |
sstaub | 1:03129e57a003 | 239 | |
sstaub | 1:03129e57a003 | 240 | /** draw a filled circle |
sstaub | 1:03129e57a003 | 241 | * |
sstaub | 1:03129e57a003 | 242 | * @param x0,y0 center |
sstaub | 1:03129e57a003 | 243 | * @param r radius |
sstaub | 1:03129e57a003 | 244 | * @param color 1 set pixel, 0 erase pixel |
sstaub | 1:03129e57a003 | 245 | * |
sstaub | 1:03129e57a003 | 246 | * use circle with different radius, |
sstaub | 1:03129e57a003 | 247 | * can miss some pixel |
sstaub | 1:03129e57a003 | 248 | * |
sstaub | 1:03129e57a003 | 249 | */ |
sstaub | 1:03129e57a003 | 250 | void fillcircle(int x, int y, int r, uint8_t colour); |
sstaub | 1:03129e57a003 | 251 | |
sstaub | 1:03129e57a003 | 252 | /** update copy display buffer to lcd |
sstaub | 1:03129e57a003 | 253 | * |
sstaub | 1:03129e57a003 | 254 | * @param AUTO set update mode to auto, default |
sstaub | 1:03129e57a003 | 255 | * @param MANUELL the update function must manually set |
sstaub | 1:03129e57a003 | 256 | * update() copy display buffer to lcd |
sstaub | 1:03129e57a003 | 257 | */ |
sstaub | 1:03129e57a003 | 258 | void update(); |
sstaub | 1:03129e57a003 | 259 | void update(uint8_t mode); |
sstaub | 1:03129e57a003 | 260 | |
sstaub | 1:03129e57a003 | 261 | /** display functions |
sstaub | 1:03129e57a003 | 262 | * |
sstaub | 1:03129e57a003 | 263 | * @param display ON switch display on, or wake up from sleep |
sstaub | 1:03129e57a003 | 264 | * @param display OFF set display off |
sstaub | 1:03129e57a003 | 265 | * @param display SLEEP set display off and to sleep mode |
sstaub | 1:03129e57a003 | 266 | * @param display BOTTOM (default) set display orientation 0° |
sstaub | 1:03129e57a003 | 267 | * @param display TOPVIEW draw display oriention to 180° |
sstaub | 1:03129e57a003 | 268 | * @param display INVERT invert the pixels |
sstaub | 1:03129e57a003 | 269 | * @param display DEFAULT normal pixel display |
sstaub | 1:03129e57a003 | 270 | * @param display CONTRAST set display contrast to default |
sstaub | 1:03129e57a003 | 271 | * |
sstaub | 1:03129e57a003 | 272 | */ |
sstaub | 1:03129e57a003 | 273 | void display(uint8_t display); |
sstaub | 1:03129e57a003 | 274 | |
sstaub | 1:03129e57a003 | 275 | /** display functions |
sstaub | 1:03129e57a003 | 276 | * |
sstaub | 1:03129e57a003 | 277 | * @param display CONTRAST set display contrast with value, |
sstaub | 1:03129e57a003 | 278 | * @param value sets display contrast 0 - 63, default 31 |
sstaub | 1:03129e57a003 | 279 | * |
sstaub | 1:03129e57a003 | 280 | */ |
sstaub | 1:03129e57a003 | 281 | void display(uint8_t display, uint8_t value); |
sstaub | 1:03129e57a003 | 282 | |
sstaub | 1:03129e57a003 | 283 | /** clear the screen |
sstaub | 1:03129e57a003 | 284 | * |
sstaub | 1:03129e57a003 | 285 | */ |
sstaub | 1:03129e57a003 | 286 | void cls(); |
sstaub | 1:03129e57a003 | 287 | |
sstaub | 1:03129e57a003 | 288 | /** draw a character on given position out of the active font to the LCD |
sstaub | 1:03129e57a003 | 289 | * |
sstaub | 1:03129e57a003 | 290 | * @param x x-position of char (top left) |
sstaub | 1:03129e57a003 | 291 | * @param y y-position |
sstaub | 1:03129e57a003 | 292 | * @param c char to print |
sstaub | 1:03129e57a003 | 293 | * |
sstaub | 1:03129e57a003 | 294 | */ |
sstaub | 1:03129e57a003 | 295 | void character(uint8_t x, uint8_t y, uint8_t c); |
sstaub | 1:03129e57a003 | 296 | |
sstaub | 1:03129e57a003 | 297 | /** set top left position of char/printf |
sstaub | 1:03129e57a003 | 298 | * |
sstaub | 1:03129e57a003 | 299 | * @param x x-position |
sstaub | 1:03129e57a003 | 300 | * @param y y-position |
sstaub | 1:03129e57a003 | 301 | * |
sstaub | 1:03129e57a003 | 302 | */ |
sstaub | 1:03129e57a003 | 303 | void locate(uint8_t x, uint8_t y); |
sstaub | 1:03129e57a003 | 304 | |
sstaub | 1:03129e57a003 | 305 | /** select the font to use |
sstaub | 1:03129e57a003 | 306 | * |
sstaub | 1:03129e57a003 | 307 | * @param f pointer to font array |
sstaub | 1:03129e57a003 | 308 | * |
sstaub | 1:03129e57a003 | 309 | * font array can created with GLCD Font Creator from http://www.mikroe.com |
sstaub | 1:03129e57a003 | 310 | * you have to add 4 parameter at the beginning of the font array to use: |
sstaub | 1:03129e57a003 | 311 | * - the number of byte / char |
sstaub | 1:03129e57a003 | 312 | * - the vertial size in pixel |
sstaub | 1:03129e57a003 | 313 | * - the horizontal size in pixel |
sstaub | 1:03129e57a003 | 314 | * - the number of byte per vertical line |
sstaub | 1:03129e57a003 | 315 | * you also have to change the array to char[] |
sstaub | 1:03129e57a003 | 316 | * @code |
sstaub | 1:03129e57a003 | 317 | * lcd.font((unsigned char*)Small_7); |
sstaub | 1:03129e57a003 | 318 | * @endcode |
sstaub | 1:03129e57a003 | 319 | */ |
sstaub | 1:03129e57a003 | 320 | void font(uint8_t *f); |
sstaub | 1:03129e57a003 | 321 | |
sstaub | 1:03129e57a003 | 322 | /** print bitmap to buffer |
sstaub | 1:03129e57a003 | 323 | * |
sstaub | 1:03129e57a003 | 324 | * @param bm Bitmap in flash |
sstaub | 1:03129e57a003 | 325 | * @param x x start |
sstaub | 1:03129e57a003 | 326 | * @param y y start |
sstaub | 1:03129e57a003 | 327 | * |
sstaub | 1:03129e57a003 | 328 | */ |
sstaub | 1:03129e57a003 | 329 | void bitmap(Bitmap bm, int x, int y); |
sstaub | 1:03129e57a003 | 330 | |
sstaub | 1:03129e57a003 | 331 | // declarations |
sstaub | 1:03129e57a003 | 332 | SPI _spi; |
sstaub | 1:03129e57a003 | 333 | DigitalOut _reset; |
sstaub | 1:03129e57a003 | 334 | DigitalOut _a0; |
sstaub | 1:03129e57a003 | 335 | DigitalOut _cs; |
sstaub | 1:03129e57a003 | 336 | |
sstaub | 1:03129e57a003 | 337 | protected: |
sstaub | 1:03129e57a003 | 338 | |
sstaub | 1:03129e57a003 | 339 | /** stream class, put a char on the screen |
sstaub | 1:03129e57a003 | 340 | * |
sstaub | 1:03129e57a003 | 341 | * @param value char to print |
sstaub | 1:03129e57a003 | 342 | * @returns printed char |
sstaub | 1:03129e57a003 | 343 | * |
sstaub | 1:03129e57a003 | 344 | */ |
sstaub | 1:03129e57a003 | 345 | virtual int _putc(int value); |
sstaub | 1:03129e57a003 | 346 | |
sstaub | 1:03129e57a003 | 347 | /** stream class, dummy |
sstaub | 1:03129e57a003 | 348 | * |
sstaub | 1:03129e57a003 | 349 | */ |
sstaub | 1:03129e57a003 | 350 | virtual int _getc(); |
sstaub | 1:03129e57a003 | 351 | |
sstaub | 1:03129e57a003 | 352 | /** init the DOGM132 LCD controller |
sstaub | 1:03129e57a003 | 353 | * |
sstaub | 1:03129e57a003 | 354 | */ |
sstaub | 1:03129e57a003 | 355 | void init(); //Init the ST7565R LCD controller |
sstaub | 1:03129e57a003 | 356 | |
sstaub | 1:03129e57a003 | 357 | /** write data to the LCD controller |
sstaub | 1:03129e57a003 | 358 | * |
sstaub | 1:03129e57a003 | 359 | * @param dat data written to LCD controller |
sstaub | 1:03129e57a003 | 360 | * |
sstaub | 1:03129e57a003 | 361 | */ |
sstaub | 1:03129e57a003 | 362 | void write_data(uint8_t data); // Write data to the LCD controller |
sstaub | 1:03129e57a003 | 363 | |
sstaub | 1:03129e57a003 | 364 | /** Write a command the LCD controller |
sstaub | 1:03129e57a003 | 365 | * |
sstaub | 1:03129e57a003 | 366 | * @param cmd command to be written |
sstaub | 1:03129e57a003 | 367 | * |
sstaub | 1:03129e57a003 | 368 | */ |
sstaub | 1:03129e57a003 | 369 | void write_command(uint8_t command); // Write a command the LCD controller |
sstaub | 1:03129e57a003 | 370 | |
sstaub | 1:03129e57a003 | 371 | // Variables |
sstaub | 1:03129e57a003 | 372 | uint8_t *font_buffer; |
sstaub | 1:03129e57a003 | 373 | uint8_t char_x; |
sstaub | 1:03129e57a003 | 374 | uint8_t char_y; |
sstaub | 1:03129e57a003 | 375 | uint8_t auto_update; |
sstaub | 1:03129e57a003 | 376 | uint8_t width; |
sstaub | 1:03129e57a003 | 377 | uint8_t height; |
sstaub | 1:03129e57a003 | 378 | uint8_t _type; |
sstaub | 1:03129e57a003 | 379 | uint8_t *graphic_buffer; |
sstaub | 1:03129e57a003 | 380 | uint32_t graphic_buffer_size; |
sstaub | 1:03129e57a003 | 381 | |
sstaub | 1:03129e57a003 | 382 | }; |
sstaub | 1:03129e57a003 | 383 | |
sstaub | 1:03129e57a003 | 384 | #endif |