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