Driver for the Digole Serial universal LCD display adapter
DigoleSerialDisp.h@0:3cf7c2683c3a, 2013-02-25 (annotated)
- Committer:
- shimniok
- Date:
- Mon Feb 25 05:48:10 2013 +0000
- Revision:
- 0:3cf7c2683c3a
- Child:
- 1:959715b1d042
Things seem to be working now.
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 | 0:3cf7c2683c3a | 3 | * @Author: Digole Digital Solutions : www.digole.com ported 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 | 0:3cf7c2683c3a | 29 | * |
shimniok | 0:3cf7c2683c3a | 30 | * Inherits from the Print class for all the fancy print/println stuff |
shimniok | 0:3cf7c2683c3a | 31 | * |
shimniok | 0:3cf7c2683c3a | 32 | * Communication set up command |
shimniok | 0:3cf7c2683c3a | 33 | * "SB":Baud (ascII bytes end with 0x00/0x0A/0x0D) -- set UART Baud Rate |
shimniok | 0:3cf7c2683c3a | 34 | * "SI2CA":Address(1 byte <127) -- Set I2C address, default address is:0x27 |
shimniok | 0:3cf7c2683c3a | 35 | * "DC":1/0(1byte) -- set config display on/off, if set to 1, displayer will display current commucation setting when power on |
shimniok | 0:3cf7c2683c3a | 36 | * Text Function command |
shimniok | 0:3cf7c2683c3a | 37 | * "CL": -- Clear screen--OK |
shimniok | 0:3cf7c2683c3a | 38 | * "CS":1/0 (1 byte)-- Cursor on/off |
shimniok | 0:3cf7c2683c3a | 39 | * "TP":x(1 byte) y(1 byte) -- set text position |
shimniok | 0:3cf7c2683c3a | 40 | * "TT":string(bytes) end with 0x00/0x0A/0x0D -- display string under regular mode |
shimniok | 0:3cf7c2683c3a | 41 | * Graphic function command |
shimniok | 0:3cf7c2683c3a | 42 | * "GP":x(1byte) y(1byte) -- set current graphic position |
shimniok | 0:3cf7c2683c3a | 43 | * "DM":"C/!/~/&/|/^"(ASCII 1byte) -- set drawing mode--C="Copy",! and ~ = "Not", & = "And", | = "Or", ^ = "Xor" |
shimniok | 0:3cf7c2683c3a | 44 | * "SC":1/0 (1byte) -- set draw color--only 1 and 0 |
shimniok | 0:3cf7c2683c3a | 45 | * "LN":x0(1byte) y0(1byte) x1(1byte) y2(1byte)--draw line from x0,y0 to x1,y1,set new pot to x1,y1 |
shimniok | 0:3cf7c2683c3a | 46 | * "LT":x(1byte) y(1byte) -- draw line from current pos to x,y |
shimniok | 0:3cf7c2683c3a | 47 | * "CC":x(1byte) y(1byte) ratio(byte) -- draw circle at x,y with ratio |
shimniok | 0:3cf7c2683c3a | 48 | * "DP":x(1byte) y(1byte) Color(1byte) -- draw a pixel--OK |
shimniok | 0:3cf7c2683c3a | 49 | * "DR":x0(1byte) y0(1byte) x1(1byte) y2(1byte)--draw rectangle, top-left:x0,y0; right-bottom:x1,y1 |
shimniok | 0:3cf7c2683c3a | 50 | * "FR":x0(1byte) y0(1byte) x1(1byte) y2(1byte)--draw filled rectangle, top-left:x0,y0; right-bottom:x1,y1 |
shimniok | 0:3cf7c2683c3a | 51 | */ |
shimniok | 0:3cf7c2683c3a | 52 | class DigoleSerialDisp { |
shimniok | 0:3cf7c2683c3a | 53 | public: |
shimniok | 0:3cf7c2683c3a | 54 | |
shimniok | 0:3cf7c2683c3a | 55 | /** Create a new Digole Serial Display interface |
shimniok | 0:3cf7c2683c3a | 56 | * |
shimniok | 0:3cf7c2683c3a | 57 | * @param sda - pin for I2C SDA |
shimniok | 0:3cf7c2683c3a | 58 | * @param scl - pin for I2C SCL |
shimniok | 0:3cf7c2683c3a | 59 | * @param address - 7-bit address (default is 0x27 for the device) |
shimniok | 0:3cf7c2683c3a | 60 | */ |
shimniok | 0:3cf7c2683c3a | 61 | DigoleSerialDisp(PinName sda, PinName scl, uint8_t address=0x27); |
shimniok | 0:3cf7c2683c3a | 62 | |
shimniok | 0:3cf7c2683c3a | 63 | |
shimniok | 0:3cf7c2683c3a | 64 | /** Carryover from Arduino library, not needed |
shimniok | 0:3cf7c2683c3a | 65 | */ |
shimniok | 0:3cf7c2683c3a | 66 | void begin(void) { } // nothing to do here |
shimniok | 0:3cf7c2683c3a | 67 | |
shimniok | 0:3cf7c2683c3a | 68 | |
shimniok | 0:3cf7c2683c3a | 69 | /** Write out a raw character |
shimniok | 0:3cf7c2683c3a | 70 | * @param x - character |
shimniok | 0:3cf7c2683c3a | 71 | * @returns - 1 |
shimniok | 0:3cf7c2683c3a | 72 | */ |
shimniok | 0:3cf7c2683c3a | 73 | size_t write(const char x); |
shimniok | 0:3cf7c2683c3a | 74 | |
shimniok | 0:3cf7c2683c3a | 75 | |
shimniok | 0:3cf7c2683c3a | 76 | /** Write out raw data from a buffer |
shimniok | 0:3cf7c2683c3a | 77 | * @param buffer -- buffer to write |
shimniok | 0:3cf7c2683c3a | 78 | * @param size -- the number of bytes to write |
shimniok | 0:3cf7c2683c3a | 79 | * @returns size |
shimniok | 0:3cf7c2683c3a | 80 | */ |
shimniok | 0:3cf7c2683c3a | 81 | size_t write(const char *buffer, size_t size); |
shimniok | 0:3cf7c2683c3a | 82 | |
shimniok | 0:3cf7c2683c3a | 83 | |
shimniok | 0:3cf7c2683c3a | 84 | /** Write out raw string |
shimniok | 0:3cf7c2683c3a | 85 | * @param str -- string to write |
shimniok | 0:3cf7c2683c3a | 86 | * @returns number of bytes written |
shimniok | 0:3cf7c2683c3a | 87 | */ |
shimniok | 0:3cf7c2683c3a | 88 | size_t write(const char *str); |
shimniok | 0:3cf7c2683c3a | 89 | |
shimniok | 0:3cf7c2683c3a | 90 | |
shimniok | 0:3cf7c2683c3a | 91 | /** Prints a char to the display in a single I2C transmission using "TTb\0" |
shimniok | 0:3cf7c2683c3a | 92 | * |
shimniok | 0:3cf7c2683c3a | 93 | * @param c - character to print |
shimniok | 0:3cf7c2683c3a | 94 | * @returns 1 |
shimniok | 0:3cf7c2683c3a | 95 | */ |
shimniok | 0:3cf7c2683c3a | 96 | size_t print(const char c); |
shimniok | 0:3cf7c2683c3a | 97 | |
shimniok | 0:3cf7c2683c3a | 98 | |
shimniok | 0:3cf7c2683c3a | 99 | /** Prints a string of data to the display in a single I2C transmission using "TTbbb...\0" |
shimniok | 0:3cf7c2683c3a | 100 | * |
shimniok | 0:3cf7c2683c3a | 101 | * @param s -- array of data, null terminated |
shimniok | 0:3cf7c2683c3a | 102 | * @returns length of s |
shimniok | 0:3cf7c2683c3a | 103 | */ |
shimniok | 0:3cf7c2683c3a | 104 | size_t print(const char s[]); |
shimniok | 0:3cf7c2683c3a | 105 | |
shimniok | 0:3cf7c2683c3a | 106 | |
shimniok | 0:3cf7c2683c3a | 107 | /** Print out an unsigned char as a number |
shimniok | 0:3cf7c2683c3a | 108 | * @param u -- integer to print |
shimniok | 0:3cf7c2683c3a | 109 | * @param base -- base is DEC (default), HEX, BIN |
shimniok | 0:3cf7c2683c3a | 110 | */ |
shimniok | 0:3cf7c2683c3a | 111 | size_t print(unsigned char u, int base = DEC); |
shimniok | 0:3cf7c2683c3a | 112 | |
shimniok | 0:3cf7c2683c3a | 113 | |
shimniok | 0:3cf7c2683c3a | 114 | /** Print out an integer |
shimniok | 0:3cf7c2683c3a | 115 | * @param i -- integer to print |
shimniok | 0:3cf7c2683c3a | 116 | * @param base -- base is DEC (default), HEX, BIN |
shimniok | 0:3cf7c2683c3a | 117 | */ |
shimniok | 0:3cf7c2683c3a | 118 | size_t print(int i, int base = DEC); |
shimniok | 0:3cf7c2683c3a | 119 | |
shimniok | 0:3cf7c2683c3a | 120 | |
shimniok | 0:3cf7c2683c3a | 121 | /** Print out an unsigned integer |
shimniok | 0:3cf7c2683c3a | 122 | * @param u -- integer to print |
shimniok | 0:3cf7c2683c3a | 123 | * @param base -- base is DEC (default), HEX, BIN |
shimniok | 0:3cf7c2683c3a | 124 | */ |
shimniok | 0:3cf7c2683c3a | 125 | size_t print(unsigned int u, int base = DEC); |
shimniok | 0:3cf7c2683c3a | 126 | |
shimniok | 0:3cf7c2683c3a | 127 | |
shimniok | 0:3cf7c2683c3a | 128 | /** Print out a long as a number |
shimniok | 0:3cf7c2683c3a | 129 | * @param l -- integer to print |
shimniok | 0:3cf7c2683c3a | 130 | * @param base -- base is DEC (default), HEX, BIN |
shimniok | 0:3cf7c2683c3a | 131 | */ |
shimniok | 0:3cf7c2683c3a | 132 | size_t print(long l, int base = DEC); |
shimniok | 0:3cf7c2683c3a | 133 | |
shimniok | 0:3cf7c2683c3a | 134 | |
shimniok | 0:3cf7c2683c3a | 135 | /** Print out an unsigned long |
shimniok | 0:3cf7c2683c3a | 136 | * @param l -- integer to print |
shimniok | 0:3cf7c2683c3a | 137 | * @param base -- base is DEC (default), HEX, BIN |
shimniok | 0:3cf7c2683c3a | 138 | */ |
shimniok | 0:3cf7c2683c3a | 139 | size_t print(unsigned long l, int base = DEC); |
shimniok | 0:3cf7c2683c3a | 140 | |
shimniok | 0:3cf7c2683c3a | 141 | |
shimniok | 0:3cf7c2683c3a | 142 | /** Print out a double |
shimniok | 0:3cf7c2683c3a | 143 | * @param f -- integer to print |
shimniok | 0:3cf7c2683c3a | 144 | * @param digits -- number of digits after the decimal |
shimniok | 0:3cf7c2683c3a | 145 | */ |
shimniok | 0:3cf7c2683c3a | 146 | size_t print(double f, int digits = 2); |
shimniok | 0:3cf7c2683c3a | 147 | |
shimniok | 0:3cf7c2683c3a | 148 | |
shimniok | 0:3cf7c2683c3a | 149 | /** Prints a string of data to the display in a single I2C transmission using "TTbbb...\0" |
shimniok | 0:3cf7c2683c3a | 150 | * |
shimniok | 0:3cf7c2683c3a | 151 | * @param s -- array of data, null terminated |
shimniok | 0:3cf7c2683c3a | 152 | * @returns length of s |
shimniok | 0:3cf7c2683c3a | 153 | */ |
shimniok | 0:3cf7c2683c3a | 154 | size_t println(const char s[]); |
shimniok | 0:3cf7c2683c3a | 155 | |
shimniok | 0:3cf7c2683c3a | 156 | |
shimniok | 0:3cf7c2683c3a | 157 | /** Prints a char the display in a single I2C transmission using "TTb\0" |
shimniok | 0:3cf7c2683c3a | 158 | * |
shimniok | 0:3cf7c2683c3a | 159 | * @param c -- character to print |
shimniok | 0:3cf7c2683c3a | 160 | * @returns 1 |
shimniok | 0:3cf7c2683c3a | 161 | */ |
shimniok | 0:3cf7c2683c3a | 162 | size_t println(char c); |
shimniok | 0:3cf7c2683c3a | 163 | |
shimniok | 0:3cf7c2683c3a | 164 | |
shimniok | 0:3cf7c2683c3a | 165 | /** Prints an unsigned char as a number |
shimniok | 0:3cf7c2683c3a | 166 | * |
shimniok | 0:3cf7c2683c3a | 167 | * @param u -- unsigned char number |
shimniok | 0:3cf7c2683c3a | 168 | * @returns 1 |
shimniok | 0:3cf7c2683c3a | 169 | */ |
shimniok | 0:3cf7c2683c3a | 170 | size_t println(unsigned char u, int base = DEC); |
shimniok | 0:3cf7c2683c3a | 171 | |
shimniok | 0:3cf7c2683c3a | 172 | |
shimniok | 0:3cf7c2683c3a | 173 | /** Print out an integer |
shimniok | 0:3cf7c2683c3a | 174 | * @param i -- integer to print |
shimniok | 0:3cf7c2683c3a | 175 | * @param base -- base is DEC (default), HEX, BIN |
shimniok | 0:3cf7c2683c3a | 176 | */ |
shimniok | 0:3cf7c2683c3a | 177 | size_t println(int i, int base = DEC); |
shimniok | 0:3cf7c2683c3a | 178 | |
shimniok | 0:3cf7c2683c3a | 179 | |
shimniok | 0:3cf7c2683c3a | 180 | /** Print out an unsigned char as a number |
shimniok | 0:3cf7c2683c3a | 181 | * @param u -- integer to print |
shimniok | 0:3cf7c2683c3a | 182 | * @param base -- base is DEC (default), HEX, BIN |
shimniok | 0:3cf7c2683c3a | 183 | */ |
shimniok | 0:3cf7c2683c3a | 184 | size_t println(unsigned int u, int base = DEC); |
shimniok | 0:3cf7c2683c3a | 185 | |
shimniok | 0:3cf7c2683c3a | 186 | |
shimniok | 0:3cf7c2683c3a | 187 | /** Print out a long as a number |
shimniok | 0:3cf7c2683c3a | 188 | * @param l -- integer to print |
shimniok | 0:3cf7c2683c3a | 189 | * @param base -- base is DEC (default), HEX, BIN |
shimniok | 0:3cf7c2683c3a | 190 | */ |
shimniok | 0:3cf7c2683c3a | 191 | size_t println(long l, int base = DEC); |
shimniok | 0:3cf7c2683c3a | 192 | |
shimniok | 0:3cf7c2683c3a | 193 | |
shimniok | 0:3cf7c2683c3a | 194 | /** Print out an unsigned long |
shimniok | 0:3cf7c2683c3a | 195 | * @param l -- integer to print |
shimniok | 0:3cf7c2683c3a | 196 | * @param base -- base is DEC (default), HEX, BIN |
shimniok | 0:3cf7c2683c3a | 197 | */ |
shimniok | 0:3cf7c2683c3a | 198 | size_t println(unsigned long l, int base = DEC); |
shimniok | 0:3cf7c2683c3a | 199 | |
shimniok | 0:3cf7c2683c3a | 200 | |
shimniok | 0:3cf7c2683c3a | 201 | /** Print out a double |
shimniok | 0:3cf7c2683c3a | 202 | * @param f -- integer to print |
shimniok | 0:3cf7c2683c3a | 203 | * @param digits -- number of digits after the decimal |
shimniok | 0:3cf7c2683c3a | 204 | */ |
shimniok | 0:3cf7c2683c3a | 205 | size_t println(double f, int digits = 2); |
shimniok | 0:3cf7c2683c3a | 206 | |
shimniok | 0:3cf7c2683c3a | 207 | |
shimniok | 0:3cf7c2683c3a | 208 | /** prints -- well, nothing in this case, but let's pretend we printed a \n |
shimniok | 0:3cf7c2683c3a | 209 | * @returns 1 |
shimniok | 0:3cf7c2683c3a | 210 | */ |
shimniok | 0:3cf7c2683c3a | 211 | size_t println(void); |
shimniok | 0:3cf7c2683c3a | 212 | |
shimniok | 0:3cf7c2683c3a | 213 | |
shimniok | 0:3cf7c2683c3a | 214 | /*---------functions for Text and Graphic LCD adapters---------*/ |
shimniok | 0:3cf7c2683c3a | 215 | |
shimniok | 0:3cf7c2683c3a | 216 | /** Turns off the cursor */ |
shimniok | 0:3cf7c2683c3a | 217 | void disableCursor(void); |
shimniok | 0:3cf7c2683c3a | 218 | |
shimniok | 0:3cf7c2683c3a | 219 | /** Turns on the cursor */ |
shimniok | 0:3cf7c2683c3a | 220 | void enableCursor(void); |
shimniok | 0:3cf7c2683c3a | 221 | |
shimniok | 0:3cf7c2683c3a | 222 | /** Displays a string at specified coordinates |
shimniok | 0:3cf7c2683c3a | 223 | * @param x -- x coordinate to display string |
shimniok | 0:3cf7c2683c3a | 224 | * @param y -- y coordinate to display string |
shimniok | 0:3cf7c2683c3a | 225 | * @param s -- string to display |
shimniok | 0:3cf7c2683c3a | 226 | */ |
shimniok | 0:3cf7c2683c3a | 227 | void drawStr(uint8_t x, uint8_t y, const char *s); |
shimniok | 0:3cf7c2683c3a | 228 | |
shimniok | 0:3cf7c2683c3a | 229 | /** Sets the print position for graphics or text |
shimniok | 0:3cf7c2683c3a | 230 | * @param x -- x coordinate to display string |
shimniok | 0:3cf7c2683c3a | 231 | * @param y -- y coordinate to display string |
shimniok | 0:3cf7c2683c3a | 232 | * @param graph -- if _TEXT_ affects subsequent text position, otherwise, affects graphics position |
shimniok | 0:3cf7c2683c3a | 233 | */ |
shimniok | 0:3cf7c2683c3a | 234 | void setPrintPos(uint8_t x, uint8_t y, uint8_t graph = _TEXT_); |
shimniok | 0:3cf7c2683c3a | 235 | |
shimniok | 0:3cf7c2683c3a | 236 | /** Clears the display screen */ |
shimniok | 0:3cf7c2683c3a | 237 | void clearScreen(void); |
shimniok | 0:3cf7c2683c3a | 238 | |
shimniok | 0:3cf7c2683c3a | 239 | /** Configure your LCD if other than 1602 and the chip is other than KS0066U/F / HD44780 |
shimniok | 0:3cf7c2683c3a | 240 | * @param col -- number of columns |
shimniok | 0:3cf7c2683c3a | 241 | * @param row -- number of rows |
shimniok | 0:3cf7c2683c3a | 242 | */ |
shimniok | 0:3cf7c2683c3a | 243 | void setLCDColRow(uint8_t col, uint8_t row); |
shimniok | 0:3cf7c2683c3a | 244 | |
shimniok | 0:3cf7c2683c3a | 245 | /** Sets a new I2C address for the display (default is 0x27), the adapter will store the new address in memory |
shimniok | 0:3cf7c2683c3a | 246 | * @param address -- the new address |
shimniok | 0:3cf7c2683c3a | 247 | */ |
shimniok | 0:3cf7c2683c3a | 248 | void setI2CAddress(uint8_t add); |
shimniok | 0:3cf7c2683c3a | 249 | |
shimniok | 0:3cf7c2683c3a | 250 | /** Display Config on/off, the factory default set is on, |
shimniok | 0:3cf7c2683c3a | 251 | * so, when the module is powered up, it will display |
shimniok | 0:3cf7c2683c3a | 252 | * current communication mode on LCD, after you |
shimniok | 0:3cf7c2683c3a | 253 | * design finished, you can turn it off |
shimniok | 0:3cf7c2683c3a | 254 | * @param v -- 1 is on, 0 is off |
shimniok | 0:3cf7c2683c3a | 255 | */ |
shimniok | 0:3cf7c2683c3a | 256 | void displayConfig(uint8_t v); |
shimniok | 0:3cf7c2683c3a | 257 | |
shimniok | 0:3cf7c2683c3a | 258 | /** Holdover from Arduino library; not needed */ |
shimniok | 0:3cf7c2683c3a | 259 | void preprint(void); |
shimniok | 0:3cf7c2683c3a | 260 | |
shimniok | 0:3cf7c2683c3a | 261 | /*----------Functions for Graphic LCD/OLED adapters only---------*/ |
shimniok | 0:3cf7c2683c3a | 262 | //the functions in this section compatible with u8glib |
shimniok | 0:3cf7c2683c3a | 263 | void drawBitmap(uint8_t x, uint8_t y, uint8_t w, uint8_t h, const uint8_t *bitmap); |
shimniok | 0:3cf7c2683c3a | 264 | void setRot90(void); |
shimniok | 0:3cf7c2683c3a | 265 | void setRot180(void); |
shimniok | 0:3cf7c2683c3a | 266 | void setRot270(void); |
shimniok | 0:3cf7c2683c3a | 267 | void undoRotation(void); |
shimniok | 0:3cf7c2683c3a | 268 | void setRotation(uint8_t); |
shimniok | 0:3cf7c2683c3a | 269 | void setContrast(uint8_t); |
shimniok | 0:3cf7c2683c3a | 270 | void drawBox(uint8_t x, uint8_t y, uint8_t w, uint8_t h); |
shimniok | 0:3cf7c2683c3a | 271 | void drawCircle(uint8_t x, uint8_t y, uint8_t r, uint8_t = 0); |
shimniok | 0:3cf7c2683c3a | 272 | void drawDisc(uint8_t x, uint8_t y, uint8_t r); |
shimniok | 0:3cf7c2683c3a | 273 | void drawFrame(uint8_t x, uint8_t y, uint8_t w, uint8_t h); |
shimniok | 0:3cf7c2683c3a | 274 | void drawPixel(uint8_t x, uint8_t y, uint8_t = 1); |
shimniok | 0:3cf7c2683c3a | 275 | void drawLine(uint8_t x, uint8_t y, uint8_t x1, uint8_t y1); |
shimniok | 0:3cf7c2683c3a | 276 | void drawLineTo(uint8_t x, uint8_t y); |
shimniok | 0:3cf7c2683c3a | 277 | void drawHLine(uint8_t x, uint8_t y, uint8_t w); |
shimniok | 0:3cf7c2683c3a | 278 | void drawVLine(uint8_t x, uint8_t y, uint8_t h); |
shimniok | 0:3cf7c2683c3a | 279 | //------------------------------- |
shimniok | 0:3cf7c2683c3a | 280 | //special functions for our adapters |
shimniok | 0:3cf7c2683c3a | 281 | |
shimniok | 0:3cf7c2683c3a | 282 | /** Sets the font |
shimniok | 0:3cf7c2683c3a | 283 | * |
shimniok | 0:3cf7c2683c3a | 284 | * @parameter font - available fonts: 6,10,18,51,120,123, user font 200-203 |
shimniok | 0:3cf7c2683c3a | 285 | */ |
shimniok | 0:3cf7c2683c3a | 286 | void setFont(uint8_t font); |
shimniok | 0:3cf7c2683c3a | 287 | |
shimniok | 0:3cf7c2683c3a | 288 | /** go to next text line, depending on the font size */ |
shimniok | 0:3cf7c2683c3a | 289 | void nextTextLine(void); |
shimniok | 0:3cf7c2683c3a | 290 | |
shimniok | 0:3cf7c2683c3a | 291 | /** set color for graphic function */ |
shimniok | 0:3cf7c2683c3a | 292 | void setColor(uint8_t); |
shimniok | 0:3cf7c2683c3a | 293 | |
shimniok | 0:3cf7c2683c3a | 294 | /** Turn on back light */ |
shimniok | 0:3cf7c2683c3a | 295 | void backLightOn(void); |
shimniok | 0:3cf7c2683c3a | 296 | |
shimniok | 0:3cf7c2683c3a | 297 | /** Turn off back light */ |
shimniok | 0:3cf7c2683c3a | 298 | void backLightOff(void); |
shimniok | 0:3cf7c2683c3a | 299 | |
shimniok | 0:3cf7c2683c3a | 300 | /** send command to LCD drectly |
shimniok | 0:3cf7c2683c3a | 301 | * @param d - command |
shimniok | 0:3cf7c2683c3a | 302 | */ |
shimniok | 0:3cf7c2683c3a | 303 | void directCommand(uint8_t d); |
shimniok | 0:3cf7c2683c3a | 304 | |
shimniok | 0:3cf7c2683c3a | 305 | /** send data to LCD drectly |
shimniok | 0:3cf7c2683c3a | 306 | * @param d -- data |
shimniok | 0:3cf7c2683c3a | 307 | */ |
shimniok | 0:3cf7c2683c3a | 308 | void directData(uint8_t d); |
shimniok | 0:3cf7c2683c3a | 309 | |
shimniok | 0:3cf7c2683c3a | 310 | /** Move rectangle area on screen to another place |
shimniok | 0:3cf7c2683c3a | 311 | * @param x0, y1 -- top left of the area to move |
shimniok | 0:3cf7c2683c3a | 312 | * @param x1, y1 -- bottom right of the area to move |
shimniok | 0:3cf7c2683c3a | 313 | * @param xoffset, yoffset -- the distance to move |
shimniok | 0:3cf7c2683c3a | 314 | */ |
shimniok | 0:3cf7c2683c3a | 315 | void moveArea(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, char xoffset, char yoffset); |
shimniok | 0:3cf7c2683c3a | 316 | |
shimniok | 0:3cf7c2683c3a | 317 | /** Display startup screen */ |
shimniok | 0:3cf7c2683c3a | 318 | void displayStartScreen(uint8_t m); |
shimniok | 0:3cf7c2683c3a | 319 | |
shimniok | 0:3cf7c2683c3a | 320 | /** Set display mode */ |
shimniok | 0:3cf7c2683c3a | 321 | void setMode(uint8_t m); |
shimniok | 0:3cf7c2683c3a | 322 | |
shimniok | 0:3cf7c2683c3a | 323 | /** set text position back to previous, only one back allowed */ |
shimniok | 0:3cf7c2683c3a | 324 | void setTextPosBack(void); |
shimniok | 0:3cf7c2683c3a | 325 | |
shimniok | 0:3cf7c2683c3a | 326 | void setTextPosOffset(char xoffset, char yoffset); |
shimniok | 0:3cf7c2683c3a | 327 | void setTextPosAbs(uint8_t x, uint8_t y); |
shimniok | 0:3cf7c2683c3a | 328 | void setLinePattern(uint8_t pattern); |
shimniok | 0:3cf7c2683c3a | 329 | /** Only for universal serial adapter */ |
shimniok | 0:3cf7c2683c3a | 330 | void setLCDChip(uint8_t chip); |
shimniok | 0:3cf7c2683c3a | 331 | |
shimniok | 0:3cf7c2683c3a | 332 | |
shimniok | 0:3cf7c2683c3a | 333 | /** Set Start Screen, 1st B is the lower byte of data length. |
shimniok | 0:3cf7c2683c3a | 334 | * 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 | 0:3cf7c2683c3a | 335 | * @param lon -- length of data |
shimniok | 0:3cf7c2683c3a | 336 | * @param data -- binary data |
shimniok | 0:3cf7c2683c3a | 337 | */ |
shimniok | 0:3cf7c2683c3a | 338 | void uploadStartScreen(int lon, const unsigned char *data); //upload start screen |
shimniok | 0:3cf7c2683c3a | 339 | |
shimniok | 0:3cf7c2683c3a | 340 | /** Upload a user font |
shimniok | 0:3cf7c2683c3a | 341 | * @param lon -- length of data |
shimniok | 0:3cf7c2683c3a | 342 | * @param data -- user font data |
shimniok | 0:3cf7c2683c3a | 343 | * @param sect -- section of memory you want to upload to |
shimniok | 0:3cf7c2683c3a | 344 | */ |
shimniok | 0:3cf7c2683c3a | 345 | void uploadUserFont(int lon, const unsigned char *data, uint8_t sect); //upload user font |
shimniok | 0:3cf7c2683c3a | 346 | |
shimniok | 0:3cf7c2683c3a | 347 | /** Send a Byte to output head on board |
shimniok | 0:3cf7c2683c3a | 348 | * @param x -- byte to output |
shimniok | 0:3cf7c2683c3a | 349 | */ |
shimniok | 0:3cf7c2683c3a | 350 | void digitalOutput(uint8_t x); |
shimniok | 0:3cf7c2683c3a | 351 | |
shimniok | 0:3cf7c2683c3a | 352 | private: |
shimniok | 0:3cf7c2683c3a | 353 | I2C _device; |
shimniok | 0:3cf7c2683c3a | 354 | uint8_t _address; |
shimniok | 0:3cf7c2683c3a | 355 | uint8_t _Comdelay; |
shimniok | 0:3cf7c2683c3a | 356 | |
shimniok | 0:3cf7c2683c3a | 357 | size_t printNumber(unsigned long n, uint8_t base); |
shimniok | 0:3cf7c2683c3a | 358 | size_t printFloat(double number, uint8_t digits); |
shimniok | 0:3cf7c2683c3a | 359 | }; |
shimniok | 0:3cf7c2683c3a | 360 | |
shimniok | 0:3cf7c2683c3a | 361 | #endif |