Heavily documented control library for the uOLED-96-G1 (SGC) by 4D Systems. Will likely work with any of the 4D Systems serial controlled screens. <<info>> All examples in the documentation have been tested to the best of my current abilities, but there are a few functions that I simply do not use. I have created a Lighthouse page for this library. You may submit bug reports or feature requests to [[http://mbed-uoled.lighthouseapp.com|this page]]. If you really do not wish to sign up for a Lighthouse account you may also post any bugs or requests [[/users/Nakor/notebook/uoled-bug-reports/|here]]. <</info>>

Dependents:   DS18B20 DS18B20GSM Astromed Astromed_build20121123

Committer:
Nakor
Date:
Mon Dec 27 03:21:23 2010 +0000
Revision:
25:caf134ebfc34
Parent:
24:22c2d08f111d
Child:
26:5a2128799f60

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Nakor 0:4f009971ac11 1 /* mbed 4D uOLED Library
Nakor 0:4f009971ac11 2 * Originally designed for use with uOLED-96-G1 (SGC)
Nakor 0:4f009971ac11 3 * serially controlled .96" screen.
Nakor 0:4f009971ac11 4 *
Nakor 0:4f009971ac11 5 * This is a modified library originally obtained from
Nakor 0:4f009971ac11 6 * Erik van Wijk's library code at:
Nakor 0:4f009971ac11 7 * http://mbed.org/users/evwijk/libraries/microOLED/li4nzn
Nakor 5:93ea03e2a688 8 *
Nakor 5:93ea03e2a688 9 * This library (uOLED) by Aaron Goselin.
Nakor 5:93ea03e2a688 10 * 2010
Nakor 0:4f009971ac11 11 */
Nakor 0:4f009971ac11 12
Nakor 0:4f009971ac11 13 #ifndef _MBED_UOLED_
Nakor 0:4f009971ac11 14 #define _MBED_UOLED_
Nakor 0:4f009971ac11 15
Nakor 0:4f009971ac11 16 #include "mbed.h"
Nakor 0:4f009971ac11 17
Nakor 0:4f009971ac11 18 #define OLED_FONT5X7 0x01
Nakor 0:4f009971ac11 19 #define OLED_FONT8X8 0x02
Nakor 0:4f009971ac11 20 #define OLED_FONT8X12 0x03
Nakor 0:4f009971ac11 21
Nakor 0:4f009971ac11 22 #define OLED_DISPLAYCONTROL_DISPLAY 0x01
Nakor 0:4f009971ac11 23 #define OLED_DISPLAYCONTROL_CONTRAST 0x02
Nakor 0:4f009971ac11 24 #define OLED_DISPLAYCONTROL_POWER 0x03
Nakor 0:4f009971ac11 25
Nakor 0:4f009971ac11 26 /** uOLED control class using Serial
Nakor 0:4f009971ac11 27 *
Nakor 0:4f009971ac11 28 * Example:
Nakor 0:4f009971ac11 29 * @code
Nakor 0:4f009971ac11 30 * // Draw text on the screen.
Nakor 0:4f009971ac11 31 * #include "mbed.h"
Nakor 0:4f009971ac11 32 * #include "uOLED.h"
Nakor 0:4f009971ac11 33 *
Nakor 0:4f009971ac11 34 * uOLED SGC(p9, p10, p11);
Nakor 0:4f009971ac11 35 *
Nakor 5:93ea03e2a688 36 * int main()
Nakor 0:4f009971ac11 37 * {
Nakor 0:4f009971ac11 38 * SGC.drawText(0, 0, 0, FF, "This is text");
Nakor 0:4f009971ac11 39 * }
Nakor 3:949c5ac54e9c 40 * @endcode
Nakor 0:4f009971ac11 41 */
Nakor 0:4f009971ac11 42 class uOLED {
Nakor 0:4f009971ac11 43 public:
Nakor 0:4f009971ac11 44
Nakor 4:51f274633e70 45 /** Create an instance of the uOLED class.
Nakor 4:51f274633e70 46 *
Nakor 2:559b81f2bb1e 47 * @param serialTX - mbed TX pin to be used
Nakor 2:559b81f2bb1e 48 * @param serialRX - mbed RX pin to be used
Nakor 2:559b81f2bb1e 49 * @param reset - mbed pin to control reset of the uOLED
Nakor 25:caf134ebfc34 50 *
Nakor 25:caf134ebfc34 51 * Example:
Nakor 25:caf134ebfc34 52 * @code
Nakor 25:caf134ebfc34 53 * // (serialTX, serialRX, reset)
Nakor 25:caf134ebfc34 54 * uOLED SGC(p9, p10, p11);
Nakor 25:caf134ebfc34 55 * @endcode
Nakor 1:476dcc382de3 56 */
Nakor 0:4f009971ac11 57 uOLED(PinName serialTX, PinName serialRX, PinName reset);
Nakor 1:476dcc382de3 58
Nakor 17:cee1c66b3133 59 /** Convert RGB value into the type of value that the uOLED wants.
Nakor 17:cee1c66b3133 60 *
Nakor 17:cee1c66b3133 61 * @param red Red value.
Nakor 17:cee1c66b3133 62 * @param green Green value.
Nakor 17:cee1c66b3133 63 * @param blue Blue value.
Nakor 25:caf134ebfc34 64 *
Nakor 25:caf134ebfc34 65 * Example:
Nakor 25:caf134ebfc34 66 * @code
Nakor 25:caf134ebfc34 67 * // (red, green, blue)
Nakor 25:caf134ebfc34 68 * SGC.getRGB(120, 255, 50);
Nakor 25:caf134ebfc34 69 * @endcode
Nakor 1:476dcc382de3 70 */
Nakor 0:4f009971ac11 71 short getRGB(char red, char green, char blue);
Nakor 0:4f009971ac11 72
Nakor 25:caf134ebfc34 73 /** Add user defined bitmap character into internal memory.
Nakor 17:cee1c66b3133 74 *
Nakor 25:caf134ebfc34 75 * @param character Character index to add to memory. Range is 0-31 (0x00 to 0x1F). 32 8x8 characters.
Nakor 25:caf134ebfc34 76 * @param data[8] 8 data bytes that make up the composition of the bitmap character. 8x8 composition is 1 byte wide (8 bits) by 8 bytes deep.
Nakor 25:caf134ebfc34 77 *
Nakor 25:caf134ebfc34 78 * Example:
Nakor 25:caf134ebfc34 79 * @code
Nakor 25:caf134ebfc34 80 * // Array containing data for 8x8 "O" character.
Nakor 25:caf134ebfc34 81 * char data[8] = {0x18, 0x24, 0x42, 0x81, 0x81, 0x42, 0x24, 0x18};
Nakor 25:caf134ebfc34 82 * // (characterIndex, characterData)
Nakor 25:caf134ebfc34 83 * SGC.addBitmappedCharacter(0x01, data);
Nakor 25:caf134ebfc34 84 * @endcode
Nakor 1:476dcc382de3 85 */
Nakor 0:4f009971ac11 86 bool addBitmappedCharacter(char character, char data[8]);
Nakor 17:cee1c66b3133 87
Nakor 25:caf134ebfc34 88 /** Copy and paste a specified block of the screen.
Nakor 19:cc4f5d01f080 89 *
Nakor 25:caf134ebfc34 90 * @param sourceX Top left horizontal start position of screen area to be copied.
Nakor 25:caf134ebfc34 91 * @param sourceY Top left vertical start position of screen area to be copied.
Nakor 25:caf134ebfc34 92 * @param destinationX Top left horizontal start position of where copied area is to be pasted.
Nakor 25:caf134ebfc34 93 * @param destinationY Top left vertical start position of where copied area is to be pasted.
Nakor 25:caf134ebfc34 94 * @param width Width of screen area to be copied.
Nakor 25:caf134ebfc34 95 * @param height Height of screen area to be copied.
Nakor 25:caf134ebfc34 96 *
Nakor 25:caf134ebfc34 97 * Example:
Nakor 25:caf134ebfc34 98 * @code
Nakor 25:caf134ebfc34 99 * // (sourceX, sourceY, destinationX, destinationY, width, height)
Nakor 25:caf134ebfc34 100 * SGC.blockCopyPaste(0, 0, 25, 5, 10, 10);
Nakor 25:caf134ebfc34 101 * @endcode
Nakor 1:476dcc382de3 102 */
Nakor 0:4f009971ac11 103 bool blockCopyPaste(char sourceX, char sourceY, char destinationX, char destinationY, char width, char height);
Nakor 17:cee1c66b3133 104
Nakor 17:cee1c66b3133 105 /** Display control.
Nakor 17:cee1c66b3133 106 *
Nakor 19:cc4f5d01f080 107 * Display ON/OFF, set contrast, and PowerUp/Shutdown.
Nakor 17:cee1c66b3133 108 *
Nakor 17:cee1c66b3133 109 * @param mode Sets specified mode.
Nakor 17:cee1c66b3133 110 * @param value Value option for mode.
Nakor 17:cee1c66b3133 111 *
Nakor 18:77ec40174c31 112 * - Mode: 01 Display ON/OFF
Nakor 18:77ec40174c31 113 * - Value: 00 OFF
Nakor 18:77ec40174c31 114 * - Value: 01 ON
Nakor 18:77ec40174c31 115 * - Mode: 02 Contrast Adjust
Nakor 18:77ec40174c31 116 * - Value range: 0x00 to 0x0F
Nakor 18:77ec40174c31 117 * - Mode: 03 Display PowerUp/Shutdown (low power mode)
Nakor 18:77ec40174c31 118 * - Value 00 Shutdown
Nakor 18:77ec40174c31 119 * - Value 01 Powerup
Nakor 25:caf134ebfc34 120 *
Nakor 25:caf134ebfc34 121 * Example:
Nakor 25:caf134ebfc34 122 * @code
Nakor 25:caf134ebfc34 123 * // Turn display ON.
Nakor 25:caf134ebfc34 124 * SGC.displayControl(0x01, 0x01)
Nakor 25:caf134ebfc34 125 * // Set contrast to medium.
Nakor 25:caf134ebfc34 126 * SGC.displayControl(0x02, 0x08);
Nakor 25:caf134ebfc34 127 * // Shutdown display.
Nakor 25:caf134ebfc34 128 * SGC.displayControl(0x03, 0x00);
Nakor 25:caf134ebfc34 129 * @endcode
Nakor 1:476dcc382de3 130 */
Nakor 17:cee1c66b3133 131 bool displayControl(char mode, char value);
Nakor 17:cee1c66b3133 132
Nakor 25:caf134ebfc34 133 /** Draw previously defined user bitmap character at specified location (and colour).
Nakor 19:cc4f5d01f080 134 *
Nakor 25:caf134ebfc34 135 * @param character Character index of previously defined bitmap character. Range is 0 to 31 (0x00 to 0x1F). 32 8x8 characters.
Nakor 25:caf134ebfc34 136 * @param x Horizontal display position of character.
Nakor 25:caf134ebfc34 137 * @param y Vertical display position of character.
Nakor 25:caf134ebfc34 138 * @param red Amount of red.
Nakor 25:caf134ebfc34 139 * @param green Amount of green.
Nakor 25:caf134ebfc34 140 * @param blue Amount of blue.
Nakor 1:476dcc382de3 141 */
Nakor 25:caf134ebfc34 142 bool displayUserBitmappedCharacter(char character, char x, char y, short red, short green, short blue);
Nakor 19:cc4f5d01f080 143
Nakor 19:cc4f5d01f080 144 /** Draw a circle.
Nakor 19:cc4f5d01f080 145 *
Nakor 19:cc4f5d01f080 146 * @param x X position of circle center.
Nakor 19:cc4f5d01f080 147 * @param y Y position of circle center.
Nakor 19:cc4f5d01f080 148 * @param radius Radius of the circle.
Nakor 19:cc4f5d01f080 149 * @param red Amount of red.
Nakor 19:cc4f5d01f080 150 * @param green Amount of green.
Nakor 19:cc4f5d01f080 151 * @param blue Amount of blue.
Nakor 1:476dcc382de3 152 */
Nakor 19:cc4f5d01f080 153 bool drawCircle(char x, char y, char radius, short red, short green, short blue);
Nakor 19:cc4f5d01f080 154
Nakor 25:caf134ebfc34 155 /** Draw ASCII character (text format)
Nakor 19:cc4f5d01f080 156 *
Nakor 25:caf134ebfc34 157 * @param character Inbuilt standard ASCII character. Range 32 to 127 (0x20 to 0x7F).
Nakor 25:caf134ebfc34 158 * @param column Horizontal position of character.
Nakor 25:caf134ebfc34 159 * - range: 0-20 for 5x7 font.
Nakor 25:caf134ebfc34 160 * - range: 0-15 for 8x8 and 8x12 fonts.
Nakor 25:caf134ebfc34 161 * @param row Vertical position of character.
Nakor 25:caf134ebfc34 162 * @param red Amount of red.
Nakor 25:caf134ebfc34 163 * @param green Amount of green.
Nakor 25:caf134ebfc34 164 * @param blue Amount of blue.
Nakor 1:476dcc382de3 165 */
Nakor 25:caf134ebfc34 166 bool drawCharacter(char character, char column, char row, short red, short green, short blue);
Nakor 19:cc4f5d01f080 167
Nakor 25:caf134ebfc34 168 /** Display a bitmap image on the screen at specified location and size.
Nakor 19:cc4f5d01f080 169 *
Nakor 25:caf134ebfc34 170 * @param x Image horizontal start position (top left).
Nakor 25:caf134ebfc34 171 * @param y Image vertical start position (top left).
Nakor 25:caf134ebfc34 172 * @param width Horizontal size of the image.
Nakor 25:caf134ebfc34 173 * @param height Vertical size of the image.
Nakor 25:caf134ebfc34 174 * @param colorMode Colour mode to use for the image.
Nakor 25:caf134ebfc34 175 * - 0x08 = 256 colour mode (8bits/1byte per pixel)
Nakor 25:caf134ebfc34 176 * - 0x10 = 65K colour mode (16bits/2bytes per pixel)
Nakor 25:caf134ebfc34 177 * @param *pixels Image pixel data.
Nakor 25:caf134ebfc34 178 * - Colour Mode 0x08 (256 colour mode): Number of pixels = width x height
Nakor 25:caf134ebfc34 179 * - Colour Mode 0x10 (65K colour mode): Number of pixels = 2 x width x height
Nakor 1:476dcc382de3 180 */
Nakor 0:4f009971ac11 181 bool drawImage(char x, char y, char width, char height, char colorMode, char *pixels);
Nakor 19:cc4f5d01f080 182
Nakor 19:cc4f5d01f080 183 /** Draw a line.
Nakor 19:cc4f5d01f080 184 *
Nakor 19:cc4f5d01f080 185 * @param x1 Top left horizontal start position.
Nakor 19:cc4f5d01f080 186 * @param y1 Top left vertical start position.
Nakor 19:cc4f5d01f080 187 * @param x2 Bottom right horizontal start position.
Nakor 19:cc4f5d01f080 188 * @param y2 Bottom right vertical end position.
Nakor 19:cc4f5d01f080 189 * @param red Amount of red.
Nakor 19:cc4f5d01f080 190 * @param green Amount of green.
Nakor 19:cc4f5d01f080 191 * @param blue Amount of blue.
Nakor 1:476dcc382de3 192 */
Nakor 19:cc4f5d01f080 193 bool drawLine(char x1, char y1, char x2, char y2, short red, short green, short blue);
Nakor 19:cc4f5d01f080 194
Nakor 25:caf134ebfc34 195 /** Draw a polygon (user defined shape) to the screen.
Nakor 21:87a2227c1ad2 196 *
Nakor 25:caf134ebfc34 197 * @param vertices Number of vertices from 3 to 7.
Nakor 25:caf134ebfc34 198 * @param *x Array of vertices' X coordinates.
Nakor 25:caf134ebfc34 199 * @param *y Array of vertices' Y coordinates.
Nakor 25:caf134ebfc34 200 * @param red Amount of red.
Nakor 25:caf134ebfc34 201 * @param green Amount of green.
Nakor 25:caf134ebfc34 202 * @param blue Amount of blue.
Nakor 1:476dcc382de3 203 */
Nakor 25:caf134ebfc34 204 bool drawPolygon(char vertices, char *x, char *y, short red, short green, short blue);
Nakor 21:87a2227c1ad2 205
Nakor 21:87a2227c1ad2 206 /** Draw a rectangle.
Nakor 21:87a2227c1ad2 207 *
Nakor 21:87a2227c1ad2 208 * @param x Top left horizontal start position.
Nakor 21:87a2227c1ad2 209 * @param y Top left vertical start position.
Nakor 21:87a2227c1ad2 210 * @param width Bottom right horizontal end position.
Nakor 21:87a2227c1ad2 211 * @param height Bottom right vertical end position.
Nakor 21:87a2227c1ad2 212 * @param red Amount of red.
Nakor 21:87a2227c1ad2 213 * @param green Amount of green.
Nakor 21:87a2227c1ad2 214 * @param blue Amount of blue.
Nakor 1:476dcc382de3 215 */
Nakor 21:87a2227c1ad2 216 bool drawRectangle(char x, char y, char width, char height, short red, short green, short blue);
Nakor 21:87a2227c1ad2 217
Nakor 5:93ea03e2a688 218 /** Draw text to the screen.
Nakor 5:93ea03e2a688 219 *
Nakor 5:93ea03e2a688 220 * @param column X coordinate for text placement.
Nakor 5:93ea03e2a688 221 * @param row Y coordinate for text placement.
Nakor 5:93ea03e2a688 222 * @param font Which font to use (Uses 0, 1, or 2). More fonts can be added.
Nakor 5:93ea03e2a688 223 * @param color Font colour to use.
Nakor 5:93ea03e2a688 224 * @param *text Character array (string) to be displayed.
Nakor 5:93ea03e2a688 225 *
Nakor 5:93ea03e2a688 226 * Example:
Nakor 5:93ea03e2a688 227 * @code
Nakor 5:93ea03e2a688 228 * SGC.drawText(0, 0, 0, FF, "This is text");
Nakor 5:93ea03e2a688 229 * @endcode
Nakor 1:476dcc382de3 230 */
Nakor 21:87a2227c1ad2 231 bool drawText(char column, char row, char font, short red, short green, short blue, char *text);
Nakor 21:87a2227c1ad2 232
Nakor 14:3d90211095d4 233 /** Draw unformated text to the screen.
Nakor 14:3d90211095d4 234 * The manual describes this as "graphics format".
Nakor 14:3d90211095d4 235 *
Nakor 14:3d90211095d4 236 * @param x X coordinate for text placement.
Nakor 14:3d90211095d4 237 * @param y Y coordinate for text placement.
Nakor 14:3d90211095d4 238 * @param font Which font to use (Uses 0, 1, or 2). More fonts can be added.
Nakor 14:3d90211095d4 239 * @param red Amount of red in text colour RGB value.
Nakor 14:3d90211095d4 240 * @param green Amount of green in text colour RGB value.
Nakor 14:3d90211095d4 241 * @param blue Amount of blue in text colour RGB value.
Nakor 14:3d90211095d4 242 * @param width Text width.
Nakor 14:3d90211095d4 243 * @param height Text height.
Nakor 14:3d90211095d4 244 * @param *text Character array (string) to be displayed.
Nakor 14:3d90211095d4 245 *
Nakor 14:3d90211095d4 246 * Example:
Nakor 14:3d90211095d4 247 * @code
Nakor 16:6f5d07cfff03 248 * SGC.drawTextUF(0, 0, 0, 20, 20, 255, 1, 1, "This is text");
Nakor 14:3d90211095d4 249 * @endcode
Nakor 14:3d90211095d4 250 */
Nakor 15:06ef508fef4b 251 bool drawTextUF(char x, char y, char font, short red, short green, short blue, char width, char height, char *text);
Nakor 21:87a2227c1ad2 252
Nakor 21:87a2227c1ad2 253 /** Draw a triangle.
Nakor 21:87a2227c1ad2 254 *
Nakor 21:87a2227c1ad2 255 * Vertices must be defined counter clockwise.
Nakor 21:87a2227c1ad2 256 *
Nakor 21:87a2227c1ad2 257 * @param x1 Vertice 1 X coordinate.
Nakor 21:87a2227c1ad2 258 * @param y1 Vertice 1 Y coordinate.
Nakor 21:87a2227c1ad2 259 * @param x2 Vertice 2 X coordinate.
Nakor 21:87a2227c1ad2 260 * @param y2 Vertice 2 Y coordinate.
Nakor 21:87a2227c1ad2 261 * @param x3 Vertice 3 X coordinate.
Nakor 21:87a2227c1ad2 262 * @param y3 Vertice 3 Y coordinate.
Nakor 21:87a2227c1ad2 263 * @param red Amount of red.
Nakor 21:87a2227c1ad2 264 * @param blue Amount of blue.
Nakor 21:87a2227c1ad2 265 * @param green Amount of green.
Nakor 6:080d52539972 266 */
Nakor 21:87a2227c1ad2 267 bool drawTriangle(char x1, char y1, char x2, char y2, char x3, char y3, short red, short green, short blue);
Nakor 21:87a2227c1ad2 268
Nakor 21:87a2227c1ad2 269 /** Clear the screen.
Nakor 21:87a2227c1ad2 270 *
Nakor 21:87a2227c1ad2 271 * Remove everything except the background colour.
Nakor 21:87a2227c1ad2 272 *
Nakor 21:87a2227c1ad2 273 * @param returns success or failure.
Nakor 1:476dcc382de3 274 */
Nakor 0:4f009971ac11 275 bool eraseScreen();
Nakor 21:87a2227c1ad2 276
Nakor 0:4f009971ac11 277 /** Initialize the screen. This must be completed before any other communication with the device.
Nakor 21:87a2227c1ad2 278 *
Nakor 0:4f009971ac11 279 * Timing allows for at least 500ms delay for initialization.
Nakor 21:87a2227c1ad2 280 *
Nakor 2:559b81f2bb1e 281 * @param returns bool indicating success or failure of initialization.
Nakor 0:4f009971ac11 282 */
Nakor 0:4f009971ac11 283 bool init();
Nakor 21:87a2227c1ad2 284
Nakor 21:87a2227c1ad2 285 /** Set pen size.
Nakor 21:87a2227c1ad2 286 *
Nakor 21:87a2227c1ad2 287 * Sets if objects should be drawn solid or wire frame.
Nakor 21:87a2227c1ad2 288 * Does not apply to polygon function.
Nakor 21:87a2227c1ad2 289 *
Nakor 21:87a2227c1ad2 290 * @param size Sets solid or wire frame.
Nakor 21:87a2227c1ad2 291 * - 0x00 = Solid
Nakor 21:87a2227c1ad2 292 * - 0x01 = Wire frame.
Nakor 1:476dcc382de3 293 */
Nakor 0:4f009971ac11 294 bool penSize(char size);
Nakor 21:87a2227c1ad2 295
Nakor 22:66401b612b1b 296 /** Draw a coloured pixel at designated position.
Nakor 22:66401b612b1b 297 *
Nakor 22:66401b612b1b 298 * @param x Horizontal position of pixel.
Nakor 22:66401b612b1b 299 * @param y Vertical position of pixel.
Nakor 22:66401b612b1b 300 * @param red Amount of red.
Nakor 22:66401b612b1b 301 * @param green Amount of green.
Nakor 22:66401b612b1b 302 * @param blue Amount of blue.
Nakor 1:476dcc382de3 303 */
Nakor 22:66401b612b1b 304 bool putPixel(char x, char y, short red, short green, short blue);
Nakor 22:66401b612b1b 305
Nakor 22:66401b612b1b 306 /** Read the colour of a specified pixel.
Nakor 22:66401b612b1b 307 *
Nakor 22:66401b612b1b 308 * @param x X coordinate.
Nakor 22:66401b612b1b 309 * @param y Y coordinate.
Nakor 22:66401b612b1b 310 * @param returns 2 byte pixel colour in RGB format.
Nakor 22:66401b612b1b 311 * - MSB: R4R3R2R1R0G5G4G3
Nakor 22:66401b612b1b 312 * - LSB: G2G1G0B4B3B2B1B0
Nakor 1:476dcc382de3 313 */
Nakor 0:4f009971ac11 314 short readPixel(char x, char y);
Nakor 22:66401b612b1b 315
Nakor 7:c2fa784eb477 316 /** Replaces the background colour with a new colour.
Nakor 7:c2fa784eb477 317 *
Nakor 13:f2b9f249bcff 318 * @param red Red value (0 to 255).
Nakor 13:f2b9f249bcff 319 * @param green Green value (0 to 255).
Nakor 13:f2b9f249bcff 320 * @param blue Blue value (0 to 255).
Nakor 7:c2fa784eb477 321 */
Nakor 13:f2b9f249bcff 322 bool setBackgroundColour(char red, char green, char blue);
Nakor 22:66401b612b1b 323
Nakor 22:66401b612b1b 324 /** Set font (for future text).
Nakor 22:66401b612b1b 325 *
Nakor 22:66401b612b1b 326 * 3 default fonts are supplied. Further font sets can be added.
Nakor 22:66401b612b1b 327 *
Nakor 22:66401b612b1b 328 * @param font Font selection. Either a default or otherwise.
Nakor 22:66401b612b1b 329 * - DEFAULT: 0x00 = 5x7 small size font set
Nakor 22:66401b612b1b 330 * - DEFAULT: 0x01 = 8x8 medium size font set
Nakor 22:66401b612b1b 331 * - DEFAULT: 0x02 = 8x12 large size font set
Nakor 7:c2fa784eb477 332 */
Nakor 22:66401b612b1b 333 bool setFont(char font);
Nakor 22:66401b612b1b 334
Nakor 22:66401b612b1b 335 /** Draw a text button to the screen.
Nakor 22:66401b612b1b 336 *
Nakor 22:66401b612b1b 337 * @param state Button down (0x00) or button up (0x01).
Nakor 22:66401b612b1b 338 * @param x Top left horizontal start position.
Nakor 22:66401b612b1b 339 * @param y Top left vertical start position.
Nakor 22:66401b612b1b 340 * @param red Amount of red (for button not text).
Nakor 22:66401b612b1b 341 * @param green Amount of green (for button not text).
Nakor 22:66401b612b1b 342 * @param blue Amount of blue (for button not text).
Nakor 22:66401b612b1b 343 * @param font Set which font set to use for the button. 3 default font sets are supplied and more can be added.
Nakor 22:66401b612b1b 344 * - DEFAULT: 0x00 = 5x7 small size font set
Nakor 22:66401b612b1b 345 * - DEFAULT: 0x01 = 8x8 medium size font set
Nakor 22:66401b612b1b 346 * - DEFAULT: 0x02 = 8x12 large size font set
Nakor 22:66401b612b1b 347 * @param textRed Amount of red for text.
Nakor 22:66401b612b1b 348 * @param textGreen Amount of green for text.
Nakor 22:66401b612b1b 349 * @param textBlue Amount of blue for text.
Nakor 22:66401b612b1b 350 * @param textWidth Width of characters (text). Affect total width of string and button.
Nakor 22:66401b612b1b 351 * @param textHeight Height of characters (text). Affects total height of string and button.
Nakor 22:66401b612b1b 352 * @param *text Character array (string) to display in the button.
Nakor 1:476dcc382de3 353 */
Nakor 22:66401b612b1b 354 bool textButton(char state, char x, char y, short red, short green, short blue, char font, short textRed, short textGreen, short textBlue, char textWidth, char textHeight, char *text);
Nakor 22:66401b612b1b 355
Nakor 23:dd9a280c8be5 356 /** Set text mode (transparent or opaque).
Nakor 23:dd9a280c8be5 357 *
Nakor 23:dd9a280c8be5 358 * Opaque text has a rectangle drawn behind it (blocking out what is under it) and transparent text does not.
Nakor 23:dd9a280c8be5 359 *
Nakor 23:dd9a280c8be5 360 * @param mode Set text to transparent (0x00) or opaque (0x01).
Nakor 1:476dcc382de3 361 */
Nakor 0:4f009971ac11 362 bool textMode(char mode);
Nakor 23:dd9a280c8be5 363
Nakor 23:dd9a280c8be5 364 /** Retrieve current version info of the device.
Nakor 23:dd9a280c8be5 365 *
Nakor 23:dd9a280c8be5 366 * Response:
Nakor 23:dd9a280c8be5 367 *
Nakor 23:dd9a280c8be5 368 * device_type Indicates device type.
Nakor 23:dd9a280c8be5 369 * - 0x00 = micro-OLED
Nakor 23:dd9a280c8be5 370 * - 0x01 = micro-LCD
Nakor 23:dd9a280c8be5 371 * - 0x02 = micro-VGA
Nakor 24:22c2d08f111d 372 *
Nakor 23:dd9a280c8be5 373 * hardware_rev Indicates device hardware version.
Nakor 24:22c2d08f111d 374 *
Nakor 23:dd9a280c8be5 375 * firmware_rev Indicates device firmware version.
Nakor 24:22c2d08f111d 376 *
Nakor 23:dd9a280c8be5 377 * horizontal_res Indicates the horizontal resolution of the display.
Nakor 23:dd9a280c8be5 378 * - 0x22 = 220 pixels
Nakor 23:dd9a280c8be5 379 * - 0x28 = 128 pixels
Nakor 23:dd9a280c8be5 380 * - 0x32 = 320 pixels
Nakor 23:dd9a280c8be5 381 * - 0x60 = 160 pixels
Nakor 23:dd9a280c8be5 382 * - 0x64 = 64 pixels
Nakor 23:dd9a280c8be5 383 * - 0x76 = 176 pixels
Nakor 23:dd9a280c8be5 384 * - 0x96 = 96 pixels
Nakor 24:22c2d08f111d 385 *
Nakor 23:dd9a280c8be5 386 * vertical_res Indicates the vertical resolution of the display.
Nakor 23:dd9a280c8be5 387 * - See horizontal_res (identical).
Nakor 23:dd9a280c8be5 388 *
Nakor 23:dd9a280c8be5 389 * @param onScreen Set output option.
Nakor 23:dd9a280c8be5 390 * - 0x00 = Output to serial port only.
Nakor 23:dd9a280c8be5 391 * - 0x01 = Output to serial port and screen.
Nakor 23:dd9a280c8be5 392 * @param *info Character array to store results.
Nakor 1:476dcc382de3 393 */
Nakor 0:4f009971ac11 394 bool versionInfo(bool onScreen, char *info);
Nakor 0:4f009971ac11 395
Nakor 0:4f009971ac11 396
Nakor 0:4f009971ac11 397 protected:
Nakor 0:4f009971ac11 398 Serial _oled;
Nakor 0:4f009971ac11 399 DigitalOut _reset;
Nakor 0:4f009971ac11 400
Nakor 0:4f009971ac11 401 void resetDisplay();
Nakor 8:0a92ceb34cd0 402 };
Nakor 8:0a92ceb34cd0 403
Nakor 8:0a92ceb34cd0 404 #endif