John Bunda
/
DigoleSerialDisp1
UART object
Fork of DigoleSerialDisp1 by
DigoleSerialDisp.h@5:7d3fd21b9ead, 2015-11-17 (annotated)
- Committer:
- jpnovak
- Date:
- Tue Nov 17 16:09:34 2015 +0000
- Revision:
- 5:7d3fd21b9ead
- Parent:
- 4:c4b2a8f0d056
- Child:
- 6:fc42c0dc7b7f
text commands working. not recognizing header files in command set. Only partial commands working. ;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shimniok | 0:3cf7c2683c3a | 1 | /** Digole Serial Display library, I2C |
shimniok | 0:3cf7c2683c3a | 2 | * |
shimniok | 4:c4b2a8f0d056 | 3 | * @Author: Digole Digital Solutions : www.digole.com ported from Arduino to mbed by Michael Shimniok www.bot-thoughts.com |
shimniok | 0:3cf7c2683c3a | 4 | */ |
shimniok | 0:3cf7c2683c3a | 5 | #ifndef DigoleSerialDisp_h |
shimniok | 0:3cf7c2683c3a | 6 | #define DigoleSerialDisp_h |
shimniok | 0:3cf7c2683c3a | 7 | |
shimniok | 0:3cf7c2683c3a | 8 | #include "mbed.h" |
shimniok | 0:3cf7c2683c3a | 9 | #include <inttypes.h> |
shimniok | 0:3cf7c2683c3a | 10 | |
shimniok | 0:3cf7c2683c3a | 11 | #define DEC 10 |
shimniok | 0:3cf7c2683c3a | 12 | #define HEX 16 |
shimniok | 0:3cf7c2683c3a | 13 | #define OCT 8 |
shimniok | 0:3cf7c2683c3a | 14 | #define BIN 2 |
shimniok | 0:3cf7c2683c3a | 15 | |
shimniok | 0:3cf7c2683c3a | 16 | #define delay(x) wait_ms(x) |
shimniok | 0:3cf7c2683c3a | 17 | |
shimniok | 0:3cf7c2683c3a | 18 | // Communication set up command |
shimniok | 0:3cf7c2683c3a | 19 | // Text function command |
shimniok | 0:3cf7c2683c3a | 20 | // Graph function command |
shimniok | 0:3cf7c2683c3a | 21 | |
shimniok | 0:3cf7c2683c3a | 22 | #define Serial_UART 0; |
shimniok | 0:3cf7c2683c3a | 23 | #define Serial_I2C 1; |
shimniok | 0:3cf7c2683c3a | 24 | #define Serial_SPI 2; |
shimniok | 0:3cf7c2683c3a | 25 | #define _TEXT_ 0 |
shimniok | 0:3cf7c2683c3a | 26 | #define _GRAPH_ 1 |
shimniok | 0:3cf7c2683c3a | 27 | |
shimniok | 0:3cf7c2683c3a | 28 | /** Digole Serial LCD/OLED Library |
shimniok | 4:c4b2a8f0d056 | 29 | * www.digole.com/index.php?productID=535 |
shimniok | 0:3cf7c2683c3a | 30 | * |
shimniok | 1:959715b1d042 | 31 | * Includes Arduino Print class member functions |
shimniok | 0:3cf7c2683c3a | 32 | */ |
shimniok | 0:3cf7c2683c3a | 33 | class DigoleSerialDisp { |
shimniok | 0:3cf7c2683c3a | 34 | public: |
shimniok | 0:3cf7c2683c3a | 35 | |
jpnovak | 5:7d3fd21b9ead | 36 | #if defined(_Digole_Serial_UART_) |
jpnovak | 5:7d3fd21b9ead | 37 | |
jpnovak | 5:7d3fd21b9ead | 38 | |
jpnovak | 5:7d3fd21b9ead | 39 | size_t write(uint8_t value) { |
jpnovak | 5:7d3fd21b9ead | 40 | _mySerial->write((uint8_t) value); |
jpnovak | 5:7d3fd21b9ead | 41 | return 1; // assume sucess |
jpnovak | 5:7d3fd21b9ead | 42 | } |
jpnovak | 5:7d3fd21b9ead | 43 | |
jpnovak | 5:7d3fd21b9ead | 44 | void begin(void) { |
jpnovak | 5:7d3fd21b9ead | 45 | _mySerial->begin(9600); |
jpnovak | 5:7d3fd21b9ead | 46 | _mySerial->print("SB"); |
jpnovak | 5:7d3fd21b9ead | 47 | _mySerial->println(_Baud); |
jpnovak | 5:7d3fd21b9ead | 48 | delay(100); |
jpnovak | 5:7d3fd21b9ead | 49 | _mySerial->begin(_Baud); |
jpnovak | 5:7d3fd21b9ead | 50 | } |
jpnovak | 5:7d3fd21b9ead | 51 | size_t read1(void) |
jpnovak | 5:7d3fd21b9ead | 52 | { |
jpnovak | 5:7d3fd21b9ead | 53 | int t; |
jpnovak | 5:7d3fd21b9ead | 54 | do { |
jpnovak | 5:7d3fd21b9ead | 55 | t = _mySerial->read(); |
jpnovak | 5:7d3fd21b9ead | 56 | } while (t == -1); |
jpnovak | 5:7d3fd21b9ead | 57 | return t; |
jpnovak | 5:7d3fd21b9ead | 58 | } |
jpnovak | 5:7d3fd21b9ead | 59 | #endif |
jpnovak | 5:7d3fd21b9ead | 60 | |
shimniok | 0:3cf7c2683c3a | 61 | /** Create a new Digole Serial Display interface |
shimniok | 0:3cf7c2683c3a | 62 | * |
shimniok | 1:959715b1d042 | 63 | * @param sda is the pin for I2C SDA |
shimniok | 1:959715b1d042 | 64 | * @param scl is the pin for I2C SCL |
shimniok | 1:959715b1d042 | 65 | * @param address is the 7-bit address (default is 0x27 for the device) |
shimniok | 0:3cf7c2683c3a | 66 | */ |
shimniok | 0:3cf7c2683c3a | 67 | DigoleSerialDisp(PinName sda, PinName scl, uint8_t address=0x27); |
shimniok | 0:3cf7c2683c3a | 68 | |
shimniok | 0:3cf7c2683c3a | 69 | |
shimniok | 0:3cf7c2683c3a | 70 | /** Carryover from Arduino library, not needed |
shimniok | 0:3cf7c2683c3a | 71 | */ |
shimniok | 0:3cf7c2683c3a | 72 | void begin(void) { } // nothing to do here |
shimniok | 0:3cf7c2683c3a | 73 | |
shimniok | 0:3cf7c2683c3a | 74 | |
shimniok | 0:3cf7c2683c3a | 75 | /** Write out a raw character |
shimniok | 1:959715b1d042 | 76 | * @param x is the character to write |
shimniok | 1:959715b1d042 | 77 | * @returns 1 |
shimniok | 0:3cf7c2683c3a | 78 | */ |
shimniok | 0:3cf7c2683c3a | 79 | size_t write(const char x); |
shimniok | 0:3cf7c2683c3a | 80 | |
shimniok | 0:3cf7c2683c3a | 81 | |
shimniok | 0:3cf7c2683c3a | 82 | /** Write out raw data from a buffer |
shimniok | 1:959715b1d042 | 83 | * @param buffer is the char array to write |
shimniok | 1:959715b1d042 | 84 | * @param size is the the number of bytes to write |
shimniok | 0:3cf7c2683c3a | 85 | * @returns size |
shimniok | 0:3cf7c2683c3a | 86 | */ |
shimniok | 0:3cf7c2683c3a | 87 | size_t write(const char *buffer, size_t size); |
shimniok | 0:3cf7c2683c3a | 88 | |
shimniok | 0:3cf7c2683c3a | 89 | |
shimniok | 0:3cf7c2683c3a | 90 | /** Write out raw string |
shimniok | 1:959715b1d042 | 91 | * @param str is the string to write |
shimniok | 0:3cf7c2683c3a | 92 | * @returns number of bytes written |
shimniok | 0:3cf7c2683c3a | 93 | */ |
shimniok | 0:3cf7c2683c3a | 94 | size_t write(const char *str); |
shimniok | 0:3cf7c2683c3a | 95 | |
shimniok | 0:3cf7c2683c3a | 96 | |
shimniok | 0:3cf7c2683c3a | 97 | /** Prints a char to the display in a single I2C transmission using "TTb\0" |
shimniok | 0:3cf7c2683c3a | 98 | * |
shimniok | 1:959715b1d042 | 99 | * @param c is the character to print |
shimniok | 0:3cf7c2683c3a | 100 | * @returns 1 |
shimniok | 0:3cf7c2683c3a | 101 | */ |
shimniok | 0:3cf7c2683c3a | 102 | size_t print(const char c); |
shimniok | 0:3cf7c2683c3a | 103 | |
shimniok | 0:3cf7c2683c3a | 104 | |
shimniok | 0:3cf7c2683c3a | 105 | /** Prints a string of data to the display in a single I2C transmission using "TTbbb...\0" |
shimniok | 0:3cf7c2683c3a | 106 | * |
shimniok | 1:959715b1d042 | 107 | * @param s is the null-terminated char array to print |
shimniok | 0:3cf7c2683c3a | 108 | * @returns length of s |
shimniok | 0:3cf7c2683c3a | 109 | */ |
shimniok | 0:3cf7c2683c3a | 110 | size_t print(const char s[]); |
shimniok | 0:3cf7c2683c3a | 111 | |
shimniok | 0:3cf7c2683c3a | 112 | |
shimniok | 0:3cf7c2683c3a | 113 | /** Print out an unsigned char as a number |
shimniok | 1:959715b1d042 | 114 | * @param u is the integer to print |
shimniok | 1:959715b1d042 | 115 | * @param base is the base to print, either DEC (default), HEX, BIN |
shimniok | 1:959715b1d042 | 116 | * @returns number of chars written |
shimniok | 0:3cf7c2683c3a | 117 | */ |
shimniok | 0:3cf7c2683c3a | 118 | size_t print(unsigned char u, int base = DEC); |
shimniok | 0:3cf7c2683c3a | 119 | |
shimniok | 0:3cf7c2683c3a | 120 | |
shimniok | 0:3cf7c2683c3a | 121 | /** Print out an integer |
shimniok | 1:959715b1d042 | 122 | * @param i is the integer to print |
shimniok | 1:959715b1d042 | 123 | * @param base is the base to print, either DEC (default), HEX, BIN |
shimniok | 1:959715b1d042 | 124 | * @returns number of chars written |
shimniok | 0:3cf7c2683c3a | 125 | */ |
shimniok | 0:3cf7c2683c3a | 126 | size_t print(int i, int base = DEC); |
shimniok | 0:3cf7c2683c3a | 127 | |
shimniok | 0:3cf7c2683c3a | 128 | |
shimniok | 0:3cf7c2683c3a | 129 | /** Print out an unsigned integer |
shimniok | 1:959715b1d042 | 130 | * @param u is the integer to print |
shimniok | 1:959715b1d042 | 131 | * @param base is the base to print, either DEC (default), HEX, BIN |
shimniok | 1:959715b1d042 | 132 | * @returns number of chars written |
shimniok | 0:3cf7c2683c3a | 133 | */ |
shimniok | 0:3cf7c2683c3a | 134 | size_t print(unsigned int u, int base = DEC); |
shimniok | 0:3cf7c2683c3a | 135 | |
shimniok | 0:3cf7c2683c3a | 136 | |
shimniok | 0:3cf7c2683c3a | 137 | /** Print out a long as a number |
shimniok | 1:959715b1d042 | 138 | * @param l is the integer to print |
shimniok | 1:959715b1d042 | 139 | * @param base is the base to print, either DEC (default), HEX, BIN |
shimniok | 1:959715b1d042 | 140 | * @returns number of chars written |
shimniok | 0:3cf7c2683c3a | 141 | */ |
shimniok | 0:3cf7c2683c3a | 142 | size_t print(long l, int base = DEC); |
shimniok | 0:3cf7c2683c3a | 143 | |
shimniok | 0:3cf7c2683c3a | 144 | |
shimniok | 0:3cf7c2683c3a | 145 | /** Print out an unsigned long |
shimniok | 1:959715b1d042 | 146 | * @param l is the integer to print |
shimniok | 1:959715b1d042 | 147 | * @param base is the base to print, either DEC (default), HEX, BIN |
shimniok | 1:959715b1d042 | 148 | * @returns number of chars written |
shimniok | 0:3cf7c2683c3a | 149 | */ |
shimniok | 0:3cf7c2683c3a | 150 | size_t print(unsigned long l, int base = DEC); |
shimniok | 0:3cf7c2683c3a | 151 | |
shimniok | 0:3cf7c2683c3a | 152 | |
shimniok | 0:3cf7c2683c3a | 153 | /** Print out a double |
shimniok | 1:959715b1d042 | 154 | * @param f is the integer to print |
shimniok | 1:959715b1d042 | 155 | * @param digits is the number of digits after the decimal |
shimniok | 0:3cf7c2683c3a | 156 | */ |
shimniok | 0:3cf7c2683c3a | 157 | size_t print(double f, int digits = 2); |
shimniok | 0:3cf7c2683c3a | 158 | |
shimniok | 0:3cf7c2683c3a | 159 | |
shimniok | 0:3cf7c2683c3a | 160 | /** Prints a string of data to the display in a single I2C transmission using "TTbbb...\0" |
shimniok | 0:3cf7c2683c3a | 161 | * |
shimniok | 1:959715b1d042 | 162 | * @param s is the null-terminated char array to print |
shimniok | 0:3cf7c2683c3a | 163 | * @returns length of s |
shimniok | 0:3cf7c2683c3a | 164 | */ |
shimniok | 0:3cf7c2683c3a | 165 | size_t println(const char s[]); |
shimniok | 0:3cf7c2683c3a | 166 | |
shimniok | 0:3cf7c2683c3a | 167 | |
shimniok | 0:3cf7c2683c3a | 168 | /** Prints a char the display in a single I2C transmission using "TTb\0" |
shimniok | 0:3cf7c2683c3a | 169 | * |
shimniok | 1:959715b1d042 | 170 | * @param c is the character to print |
shimniok | 0:3cf7c2683c3a | 171 | * @returns 1 |
shimniok | 0:3cf7c2683c3a | 172 | */ |
shimniok | 0:3cf7c2683c3a | 173 | size_t println(char c); |
shimniok | 0:3cf7c2683c3a | 174 | |
shimniok | 0:3cf7c2683c3a | 175 | |
shimniok | 0:3cf7c2683c3a | 176 | /** Prints an unsigned char as a number |
shimniok | 0:3cf7c2683c3a | 177 | * |
shimniok | 1:959715b1d042 | 178 | * @param u is the unsigned char number |
shimniok | 0:3cf7c2683c3a | 179 | * @returns 1 |
shimniok | 0:3cf7c2683c3a | 180 | */ |
shimniok | 0:3cf7c2683c3a | 181 | size_t println(unsigned char u, int base = DEC); |
shimniok | 0:3cf7c2683c3a | 182 | |
shimniok | 0:3cf7c2683c3a | 183 | |
shimniok | 0:3cf7c2683c3a | 184 | /** Print out an integer |
shimniok | 1:959715b1d042 | 185 | * @param i is the integer to print |
shimniok | 1:959715b1d042 | 186 | * @param base is the base to print, either DEC (default), HEX, BIN |
shimniok | 1:959715b1d042 | 187 | * @returns number of chars written |
shimniok | 0:3cf7c2683c3a | 188 | */ |
shimniok | 0:3cf7c2683c3a | 189 | size_t println(int i, int base = DEC); |
shimniok | 0:3cf7c2683c3a | 190 | |
shimniok | 0:3cf7c2683c3a | 191 | |
shimniok | 0:3cf7c2683c3a | 192 | /** Print out an unsigned char as a number |
shimniok | 1:959715b1d042 | 193 | * @param u is the integer to print |
shimniok | 1:959715b1d042 | 194 | * @param base is the base to print, either DEC (default), HEX, BIN |
shimniok | 1:959715b1d042 | 195 | * @returns number of chars written |
shimniok | 0:3cf7c2683c3a | 196 | */ |
shimniok | 0:3cf7c2683c3a | 197 | size_t println(unsigned int u, int base = DEC); |
shimniok | 0:3cf7c2683c3a | 198 | |
shimniok | 0:3cf7c2683c3a | 199 | |
shimniok | 0:3cf7c2683c3a | 200 | /** Print out a long as a number |
shimniok | 1:959715b1d042 | 201 | * @param l is the integer to print |
shimniok | 1:959715b1d042 | 202 | * @param base is the base to print, either DEC (default), HEX, BIN |
shimniok | 1:959715b1d042 | 203 | * @returns number of chars written |
shimniok | 0:3cf7c2683c3a | 204 | */ |
shimniok | 0:3cf7c2683c3a | 205 | size_t println(long l, int base = DEC); |
shimniok | 0:3cf7c2683c3a | 206 | |
shimniok | 0:3cf7c2683c3a | 207 | |
shimniok | 0:3cf7c2683c3a | 208 | /** Print out an unsigned long |
shimniok | 1:959715b1d042 | 209 | * @param l is the integer to print |
shimniok | 1:959715b1d042 | 210 | * @param base is the base to print, either DEC (default), HEX, BIN |
shimniok | 1:959715b1d042 | 211 | * @returns number of chars written |
shimniok | 0:3cf7c2683c3a | 212 | */ |
shimniok | 0:3cf7c2683c3a | 213 | size_t println(unsigned long l, int base = DEC); |
shimniok | 0:3cf7c2683c3a | 214 | |
shimniok | 0:3cf7c2683c3a | 215 | |
shimniok | 0:3cf7c2683c3a | 216 | /** Print out a double |
shimniok | 1:959715b1d042 | 217 | * @param f is the integer to print |
shimniok | 1:959715b1d042 | 218 | * @param digits is the number of digits after the decimal |
shimniok | 1:959715b1d042 | 219 | * @returns number of chars written |
shimniok | 0:3cf7c2683c3a | 220 | */ |
shimniok | 0:3cf7c2683c3a | 221 | size_t println(double f, int digits = 2); |
shimniok | 0:3cf7c2683c3a | 222 | |
shimniok | 0:3cf7c2683c3a | 223 | |
shimniok | 3:e5615f0cb6ee | 224 | /** prints, well, nothing in this case, but pretend we printed a newline |
shimniok | 0:3cf7c2683c3a | 225 | * @returns 1 |
shimniok | 0:3cf7c2683c3a | 226 | */ |
shimniok | 0:3cf7c2683c3a | 227 | size_t println(void); |
shimniok | 0:3cf7c2683c3a | 228 | |
shimniok | 0:3cf7c2683c3a | 229 | |
shimniok | 0:3cf7c2683c3a | 230 | /*---------functions for Text and Graphic LCD adapters---------*/ |
shimniok | 0:3cf7c2683c3a | 231 | |
shimniok | 0:3cf7c2683c3a | 232 | /** Turns off the cursor */ |
shimniok | 0:3cf7c2683c3a | 233 | void disableCursor(void); |
shimniok | 0:3cf7c2683c3a | 234 | |
shimniok | 0:3cf7c2683c3a | 235 | /** Turns on the cursor */ |
shimniok | 0:3cf7c2683c3a | 236 | void enableCursor(void); |
shimniok | 0:3cf7c2683c3a | 237 | |
shimniok | 0:3cf7c2683c3a | 238 | /** Displays a string at specified coordinates |
shimniok | 1:959715b1d042 | 239 | * @param x is the x coordinate to display the string |
shimniok | 1:959715b1d042 | 240 | * @param y is the y coordinate to display the string |
shimniok | 1:959715b1d042 | 241 | * @param s is the string to display |
shimniok | 0:3cf7c2683c3a | 242 | */ |
shimniok | 0:3cf7c2683c3a | 243 | void drawStr(uint8_t x, uint8_t y, const char *s); |
shimniok | 0:3cf7c2683c3a | 244 | |
shimniok | 0:3cf7c2683c3a | 245 | /** Sets the print position for graphics or text |
shimniok | 1:959715b1d042 | 246 | * @param x is the x coordinate to display the string |
shimniok | 1:959715b1d042 | 247 | * @param y is the y coordinate to display the string |
shimniok | 1:959715b1d042 | 248 | * @param graph if set to _TEXT_ affects subsequent text position, otherwise, affects graphics position |
shimniok | 0:3cf7c2683c3a | 249 | */ |
shimniok | 0:3cf7c2683c3a | 250 | void setPrintPos(uint8_t x, uint8_t y, uint8_t graph = _TEXT_); |
shimniok | 0:3cf7c2683c3a | 251 | |
shimniok | 0:3cf7c2683c3a | 252 | /** Clears the display screen */ |
shimniok | 0:3cf7c2683c3a | 253 | void clearScreen(void); |
shimniok | 0:3cf7c2683c3a | 254 | |
shimniok | 0:3cf7c2683c3a | 255 | /** Configure your LCD if other than 1602 and the chip is other than KS0066U/F / HD44780 |
shimniok | 1:959715b1d042 | 256 | * @param col is the number of columns |
shimniok | 1:959715b1d042 | 257 | * @param row is the number of rows |
shimniok | 0:3cf7c2683c3a | 258 | */ |
shimniok | 0:3cf7c2683c3a | 259 | void setLCDColRow(uint8_t col, uint8_t row); |
shimniok | 0:3cf7c2683c3a | 260 | |
shimniok | 0:3cf7c2683c3a | 261 | /** Sets a new I2C address for the display (default is 0x27), the adapter will store the new address in memory |
shimniok | 1:959715b1d042 | 262 | * @param address is the the new address |
shimniok | 0:3cf7c2683c3a | 263 | */ |
shimniok | 0:3cf7c2683c3a | 264 | void setI2CAddress(uint8_t add); |
shimniok | 0:3cf7c2683c3a | 265 | |
shimniok | 0:3cf7c2683c3a | 266 | /** Display Config on/off, the factory default set is on, |
shimniok | 0:3cf7c2683c3a | 267 | * so, when the module is powered up, it will display |
shimniok | 0:3cf7c2683c3a | 268 | * current communication mode on LCD, after you |
shimniok | 0:3cf7c2683c3a | 269 | * design finished, you can turn it off |
shimniok | 1:959715b1d042 | 270 | * @param v is the 1 is on, 0 is off |
shimniok | 0:3cf7c2683c3a | 271 | */ |
shimniok | 0:3cf7c2683c3a | 272 | void displayConfig(uint8_t v); |
shimniok | 0:3cf7c2683c3a | 273 | |
shimniok | 0:3cf7c2683c3a | 274 | /** Holdover from Arduino library; not needed */ |
shimniok | 0:3cf7c2683c3a | 275 | void preprint(void); |
shimniok | 0:3cf7c2683c3a | 276 | |
shimniok | 0:3cf7c2683c3a | 277 | /*----------Functions for Graphic LCD/OLED adapters only---------*/ |
shimniok | 0:3cf7c2683c3a | 278 | //the functions in this section compatible with u8glib |
shimniok | 0:3cf7c2683c3a | 279 | void drawBitmap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *bitmap); |
shimniok | 0:3cf7c2683c3a | 280 | void setRot90(void); |
shimniok | 0:3cf7c2683c3a | 281 | void setRot180(void); |
shimniok | 0:3cf7c2683c3a | 282 | void setRot270(void); |
shimniok | 0:3cf7c2683c3a | 283 | void undoRotation(void); |
shimniok | 0:3cf7c2683c3a | 284 | void setRotation(uint8_t); |
shimniok | 0:3cf7c2683c3a | 285 | void setContrast(uint8_t); |
shimniok | 0:3cf7c2683c3a | 286 | void drawBox(uint8_t x, uint8_t y, uint8_t w, uint8_t h); |
shimniok | 0:3cf7c2683c3a | 287 | void drawCircle(uint8_t x, uint8_t y, uint8_t r, uint8_t = 0); |
shimniok | 0:3cf7c2683c3a | 288 | void drawDisc(uint8_t x, uint8_t y, uint8_t r); |
shimniok | 0:3cf7c2683c3a | 289 | void drawFrame(uint8_t x, uint8_t y, uint8_t w, uint8_t h); |
shimniok | 0:3cf7c2683c3a | 290 | void drawPixel(uint8_t x, uint8_t y, uint8_t = 1); |
shimniok | 0:3cf7c2683c3a | 291 | void drawLine(uint8_t x, uint8_t y, uint8_t x1, uint8_t y1); |
shimniok | 0:3cf7c2683c3a | 292 | void drawLineTo(uint8_t x, uint8_t y); |
shimniok | 0:3cf7c2683c3a | 293 | void drawHLine(uint8_t x, uint8_t y, uint8_t w); |
shimniok | 0:3cf7c2683c3a | 294 | void drawVLine(uint8_t x, uint8_t y, uint8_t h); |
shimniok | 0:3cf7c2683c3a | 295 | //------------------------------- |
shimniok | 0:3cf7c2683c3a | 296 | //special functions for our adapters |
shimniok | 0:3cf7c2683c3a | 297 | |
shimniok | 0:3cf7c2683c3a | 298 | /** Sets the font |
shimniok | 0:3cf7c2683c3a | 299 | * |
shimniok | 0:3cf7c2683c3a | 300 | * @parameter font - available fonts: 6,10,18,51,120,123, user font 200-203 |
shimniok | 0:3cf7c2683c3a | 301 | */ |
shimniok | 0:3cf7c2683c3a | 302 | void setFont(uint8_t font); |
shimniok | 0:3cf7c2683c3a | 303 | |
shimniok | 0:3cf7c2683c3a | 304 | /** go to next text line, depending on the font size */ |
shimniok | 0:3cf7c2683c3a | 305 | void nextTextLine(void); |
shimniok | 0:3cf7c2683c3a | 306 | |
shimniok | 0:3cf7c2683c3a | 307 | /** set color for graphic function */ |
shimniok | 0:3cf7c2683c3a | 308 | void setColor(uint8_t); |
shimniok | 0:3cf7c2683c3a | 309 | |
shimniok | 0:3cf7c2683c3a | 310 | /** Turn on back light */ |
shimniok | 0:3cf7c2683c3a | 311 | void backLightOn(void); |
shimniok | 0:3cf7c2683c3a | 312 | |
shimniok | 0:3cf7c2683c3a | 313 | /** Turn off back light */ |
shimniok | 0:3cf7c2683c3a | 314 | void backLightOff(void); |
shimniok | 0:3cf7c2683c3a | 315 | |
shimniok | 0:3cf7c2683c3a | 316 | /** send command to LCD drectly |
shimniok | 0:3cf7c2683c3a | 317 | * @param d - command |
shimniok | 0:3cf7c2683c3a | 318 | */ |
shimniok | 0:3cf7c2683c3a | 319 | void directCommand(uint8_t d); |
shimniok | 0:3cf7c2683c3a | 320 | |
shimniok | 0:3cf7c2683c3a | 321 | /** send data to LCD drectly |
shimniok | 1:959715b1d042 | 322 | * @param d is the data |
shimniok | 0:3cf7c2683c3a | 323 | */ |
shimniok | 0:3cf7c2683c3a | 324 | void directData(uint8_t d); |
shimniok | 0:3cf7c2683c3a | 325 | |
shimniok | 0:3cf7c2683c3a | 326 | /** Move rectangle area on screen to another place |
shimniok | 1:959715b1d042 | 327 | * @param x0, y1 is the top left of the area to move |
shimniok | 1:959715b1d042 | 328 | * @param x1, y1 is the bottom right of the area to move |
shimniok | 1:959715b1d042 | 329 | * @param xoffset, yoffset is the the distance to move |
shimniok | 0:3cf7c2683c3a | 330 | */ |
shimniok | 0:3cf7c2683c3a | 331 | void moveArea(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, char xoffset, char yoffset); |
shimniok | 0:3cf7c2683c3a | 332 | |
shimniok | 0:3cf7c2683c3a | 333 | /** Display startup screen */ |
shimniok | 0:3cf7c2683c3a | 334 | void displayStartScreen(uint8_t m); |
shimniok | 0:3cf7c2683c3a | 335 | |
shimniok | 0:3cf7c2683c3a | 336 | /** Set display mode */ |
shimniok | 0:3cf7c2683c3a | 337 | void setMode(uint8_t m); |
shimniok | 0:3cf7c2683c3a | 338 | |
shimniok | 0:3cf7c2683c3a | 339 | /** set text position back to previous, only one back allowed */ |
shimniok | 0:3cf7c2683c3a | 340 | void setTextPosBack(void); |
shimniok | 0:3cf7c2683c3a | 341 | |
shimniok | 0:3cf7c2683c3a | 342 | void setTextPosOffset(char xoffset, char yoffset); |
shimniok | 0:3cf7c2683c3a | 343 | void setTextPosAbs(uint8_t x, uint8_t y); |
shimniok | 0:3cf7c2683c3a | 344 | void setLinePattern(uint8_t pattern); |
shimniok | 0:3cf7c2683c3a | 345 | /** Only for universal serial adapter */ |
shimniok | 0:3cf7c2683c3a | 346 | void setLCDChip(uint8_t chip); |
shimniok | 0:3cf7c2683c3a | 347 | |
shimniok | 0:3cf7c2683c3a | 348 | |
shimniok | 0:3cf7c2683c3a | 349 | /** Set Start Screen, 1st B is the lower byte of data length. |
shimniok | 0:3cf7c2683c3a | 350 | * Convert images to C array here: <a href="http://www.digole.com/tools/PicturetoC_Hex_converter.php">http://www.digole.com/tools/PicturetoC_Hex_converter.php</a> |
shimniok | 1:959715b1d042 | 351 | * @param lon is the length of data |
shimniok | 1:959715b1d042 | 352 | * @param data is the binary data |
shimniok | 0:3cf7c2683c3a | 353 | */ |
shimniok | 0:3cf7c2683c3a | 354 | void uploadStartScreen(int lon, const unsigned char *data); //upload start screen |
shimniok | 0:3cf7c2683c3a | 355 | |
shimniok | 0:3cf7c2683c3a | 356 | /** Upload a user font |
shimniok | 1:959715b1d042 | 357 | * @param lon is the length of data |
shimniok | 1:959715b1d042 | 358 | * @param data is the user font data |
shimniok | 1:959715b1d042 | 359 | * @param sect is the section of memory you want to upload to |
shimniok | 0:3cf7c2683c3a | 360 | */ |
shimniok | 0:3cf7c2683c3a | 361 | void uploadUserFont(int lon, const unsigned char *data, uint8_t sect); //upload user font |
shimniok | 0:3cf7c2683c3a | 362 | |
shimniok | 0:3cf7c2683c3a | 363 | /** Send a Byte to output head on board |
shimniok | 1:959715b1d042 | 364 | * @param x is the byte to output |
shimniok | 0:3cf7c2683c3a | 365 | */ |
shimniok | 0:3cf7c2683c3a | 366 | void digitalOutput(uint8_t x); |
shimniok | 0:3cf7c2683c3a | 367 | |
shimniok | 0:3cf7c2683c3a | 368 | private: |
shimniok | 0:3cf7c2683c3a | 369 | I2C _device; |
shimniok | 0:3cf7c2683c3a | 370 | uint8_t _address; |
shimniok | 0:3cf7c2683c3a | 371 | uint8_t _Comdelay; |
shimniok | 0:3cf7c2683c3a | 372 | |
shimniok | 0:3cf7c2683c3a | 373 | size_t printNumber(unsigned long n, uint8_t base); |
shimniok | 0:3cf7c2683c3a | 374 | size_t printFloat(double number, uint8_t digits); |
shimniok | 0:3cf7c2683c3a | 375 | }; |
shimniok | 0:3cf7c2683c3a | 376 | |
shimniok | 0:3cf7c2683c3a | 377 | #endif |