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:
Sun Dec 26 18:49:00 2010 +0000
Revision:
21:87a2227c1ad2
Parent:
20:a07d700164c8
Child:
22:66401b612b1b

        

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 1:476dcc382de3 50 */
Nakor 0:4f009971ac11 51 uOLED(PinName serialTX, PinName serialRX, PinName reset);
Nakor 1:476dcc382de3 52
Nakor 17:cee1c66b3133 53 /** Convert RGB value into the type of value that the uOLED wants.
Nakor 17:cee1c66b3133 54 *
Nakor 17:cee1c66b3133 55 * @param red Red value.
Nakor 17:cee1c66b3133 56 * @param green Green value.
Nakor 17:cee1c66b3133 57 * @param blue Blue value.
Nakor 1:476dcc382de3 58 */
Nakor 0:4f009971ac11 59 short getRGB(char red, char green, char blue);
Nakor 0:4f009971ac11 60
Nakor 17:cee1c66b3133 61 /** !!ToDo!!
Nakor 17:cee1c66b3133 62 *
Nakor 2:559b81f2bb1e 63 * @param returns something.
Nakor 1:476dcc382de3 64 */
Nakor 0:4f009971ac11 65 bool addBitmappedCharacter(char character, char data[8]);
Nakor 17:cee1c66b3133 66
Nakor 17:cee1c66b3133 67 /** !!ToDO!!
Nakor 19:cc4f5d01f080 68 *
Nakor 2:559b81f2bb1e 69 * @param returns something.
Nakor 1:476dcc382de3 70 */
Nakor 0:4f009971ac11 71 bool blockCopyPaste(char sourceX, char sourceY, char destinationX, char destinationY, char width, char height);
Nakor 17:cee1c66b3133 72
Nakor 17:cee1c66b3133 73 /** Display control.
Nakor 17:cee1c66b3133 74 *
Nakor 19:cc4f5d01f080 75 * Display ON/OFF, set contrast, and PowerUp/Shutdown.
Nakor 17:cee1c66b3133 76 *
Nakor 17:cee1c66b3133 77 * @param mode Sets specified mode.
Nakor 17:cee1c66b3133 78 * @param value Value option for mode.
Nakor 17:cee1c66b3133 79 *
Nakor 18:77ec40174c31 80 * - Mode: 01 Display ON/OFF
Nakor 18:77ec40174c31 81 * - Value: 00 OFF
Nakor 18:77ec40174c31 82 * - Value: 01 ON
Nakor 18:77ec40174c31 83 * - Mode: 02 Contrast Adjust
Nakor 18:77ec40174c31 84 * - Value range: 0x00 to 0x0F
Nakor 18:77ec40174c31 85 * - Mode: 03 Display PowerUp/Shutdown (low power mode)
Nakor 18:77ec40174c31 86 * - Value 00 Shutdown
Nakor 18:77ec40174c31 87 * - Value 01 Powerup
Nakor 1:476dcc382de3 88 */
Nakor 17:cee1c66b3133 89 bool displayControl(char mode, char value);
Nakor 17:cee1c66b3133 90
Nakor 19:cc4f5d01f080 91 /** !!ToDo!!
Nakor 19:cc4f5d01f080 92 *
Nakor 2:559b81f2bb1e 93 * @param returns something.
Nakor 1:476dcc382de3 94 */
Nakor 0:4f009971ac11 95 bool displayUserBitmappedCharacter(char character, char x, char y, short color);
Nakor 19:cc4f5d01f080 96
Nakor 19:cc4f5d01f080 97 /** Draw a circle.
Nakor 19:cc4f5d01f080 98 *
Nakor 19:cc4f5d01f080 99 * @param x X position of circle center.
Nakor 19:cc4f5d01f080 100 * @param y Y position of circle center.
Nakor 19:cc4f5d01f080 101 * @param radius Radius of the circle.
Nakor 19:cc4f5d01f080 102 * @param red Amount of red.
Nakor 19:cc4f5d01f080 103 * @param green Amount of green.
Nakor 19:cc4f5d01f080 104 * @param blue Amount of blue.
Nakor 1:476dcc382de3 105 */
Nakor 19:cc4f5d01f080 106 bool drawCircle(char x, char y, char radius, short red, short green, short blue);
Nakor 19:cc4f5d01f080 107
Nakor 19:cc4f5d01f080 108 /** !!ToDo!!
Nakor 19:cc4f5d01f080 109 *
Nakor 2:559b81f2bb1e 110 * @param returns something.
Nakor 1:476dcc382de3 111 */
Nakor 0:4f009971ac11 112 bool drawCharacter(char character, char column, char row, short color);
Nakor 19:cc4f5d01f080 113
Nakor 19:cc4f5d01f080 114 /** !!ToDo!!
Nakor 19:cc4f5d01f080 115 *
Nakor 2:559b81f2bb1e 116 * @param returns something.
Nakor 1:476dcc382de3 117 */
Nakor 0:4f009971ac11 118 bool drawImage(char x, char y, char width, char height, char colorMode, char *pixels);
Nakor 19:cc4f5d01f080 119
Nakor 19:cc4f5d01f080 120 /** Draw a line.
Nakor 19:cc4f5d01f080 121 *
Nakor 19:cc4f5d01f080 122 * @param x1 Top left horizontal start position.
Nakor 19:cc4f5d01f080 123 * @param y1 Top left vertical start position.
Nakor 19:cc4f5d01f080 124 * @param x2 Bottom right horizontal start position.
Nakor 19:cc4f5d01f080 125 * @param y2 Bottom right vertical end position.
Nakor 19:cc4f5d01f080 126 * @param red Amount of red.
Nakor 19:cc4f5d01f080 127 * @param green Amount of green.
Nakor 19:cc4f5d01f080 128 * @param blue Amount of blue.
Nakor 1:476dcc382de3 129 */
Nakor 19:cc4f5d01f080 130 bool drawLine(char x1, char y1, char x2, char y2, short red, short green, short blue);
Nakor 19:cc4f5d01f080 131
Nakor 21:87a2227c1ad2 132 /** !!ToDo!!
Nakor 21:87a2227c1ad2 133 *
Nakor 2:559b81f2bb1e 134 * @param returns something.
Nakor 1:476dcc382de3 135 */
Nakor 0:4f009971ac11 136 bool drawPolygon(char vertices, char *x, char *y, short color);
Nakor 21:87a2227c1ad2 137
Nakor 21:87a2227c1ad2 138 /** Draw a rectangle.
Nakor 21:87a2227c1ad2 139 *
Nakor 21:87a2227c1ad2 140 * @param x Top left horizontal start position.
Nakor 21:87a2227c1ad2 141 * @param y Top left vertical start position.
Nakor 21:87a2227c1ad2 142 * @param width Bottom right horizontal end position.
Nakor 21:87a2227c1ad2 143 * @param height Bottom right vertical end position.
Nakor 21:87a2227c1ad2 144 * @param red Amount of red.
Nakor 21:87a2227c1ad2 145 * @param green Amount of green.
Nakor 21:87a2227c1ad2 146 * @param blue Amount of blue.
Nakor 1:476dcc382de3 147 */
Nakor 21:87a2227c1ad2 148 bool drawRectangle(char x, char y, char width, char height, short red, short green, short blue);
Nakor 21:87a2227c1ad2 149
Nakor 5:93ea03e2a688 150 /** Draw text to the screen.
Nakor 5:93ea03e2a688 151 *
Nakor 5:93ea03e2a688 152 * @param column X coordinate for text placement.
Nakor 5:93ea03e2a688 153 * @param row Y coordinate for text placement.
Nakor 5:93ea03e2a688 154 * @param font Which font to use (Uses 0, 1, or 2). More fonts can be added.
Nakor 5:93ea03e2a688 155 * @param color Font colour to use.
Nakor 5:93ea03e2a688 156 * @param *text Character array (string) to be displayed.
Nakor 5:93ea03e2a688 157 *
Nakor 5:93ea03e2a688 158 * Example:
Nakor 5:93ea03e2a688 159 * @code
Nakor 5:93ea03e2a688 160 * SGC.drawText(0, 0, 0, FF, "This is text");
Nakor 5:93ea03e2a688 161 * @endcode
Nakor 1:476dcc382de3 162 */
Nakor 21:87a2227c1ad2 163 bool drawText(char column, char row, char font, short red, short green, short blue, char *text);
Nakor 21:87a2227c1ad2 164
Nakor 14:3d90211095d4 165 /** Draw unformated text to the screen.
Nakor 14:3d90211095d4 166 * The manual describes this as "graphics format".
Nakor 14:3d90211095d4 167 *
Nakor 14:3d90211095d4 168 * @param x X coordinate for text placement.
Nakor 14:3d90211095d4 169 * @param y Y coordinate for text placement.
Nakor 14:3d90211095d4 170 * @param font Which font to use (Uses 0, 1, or 2). More fonts can be added.
Nakor 14:3d90211095d4 171 * @param red Amount of red in text colour RGB value.
Nakor 14:3d90211095d4 172 * @param green Amount of green in text colour RGB value.
Nakor 14:3d90211095d4 173 * @param blue Amount of blue in text colour RGB value.
Nakor 14:3d90211095d4 174 * @param width Text width.
Nakor 14:3d90211095d4 175 * @param height Text height.
Nakor 14:3d90211095d4 176 * @param *text Character array (string) to be displayed.
Nakor 14:3d90211095d4 177 *
Nakor 14:3d90211095d4 178 * Example:
Nakor 14:3d90211095d4 179 * @code
Nakor 16:6f5d07cfff03 180 * SGC.drawTextUF(0, 0, 0, 20, 20, 255, 1, 1, "This is text");
Nakor 14:3d90211095d4 181 * @endcode
Nakor 14:3d90211095d4 182 */
Nakor 15:06ef508fef4b 183 bool drawTextUF(char x, char y, char font, short red, short green, short blue, char width, char height, char *text);
Nakor 21:87a2227c1ad2 184
Nakor 21:87a2227c1ad2 185 /** Draw a triangle.
Nakor 21:87a2227c1ad2 186 *
Nakor 21:87a2227c1ad2 187 * Vertices must be defined counter clockwise.
Nakor 21:87a2227c1ad2 188 *
Nakor 21:87a2227c1ad2 189 * @param x1 Vertice 1 X coordinate.
Nakor 21:87a2227c1ad2 190 * @param y1 Vertice 1 Y coordinate.
Nakor 21:87a2227c1ad2 191 * @param x2 Vertice 2 X coordinate.
Nakor 21:87a2227c1ad2 192 * @param y2 Vertice 2 Y coordinate.
Nakor 21:87a2227c1ad2 193 * @param x3 Vertice 3 X coordinate.
Nakor 21:87a2227c1ad2 194 * @param y3 Vertice 3 Y coordinate.
Nakor 21:87a2227c1ad2 195 * @param red Amount of red.
Nakor 21:87a2227c1ad2 196 * @param blue Amount of blue.
Nakor 21:87a2227c1ad2 197 * @param green Amount of green.
Nakor 6:080d52539972 198 */
Nakor 21:87a2227c1ad2 199 bool drawTriangle(char x1, char y1, char x2, char y2, char x3, char y3, short red, short green, short blue);
Nakor 21:87a2227c1ad2 200
Nakor 21:87a2227c1ad2 201 /** Clear the screen.
Nakor 21:87a2227c1ad2 202 *
Nakor 21:87a2227c1ad2 203 * Remove everything except the background colour.
Nakor 21:87a2227c1ad2 204 *
Nakor 21:87a2227c1ad2 205 * @param returns success or failure.
Nakor 1:476dcc382de3 206 */
Nakor 0:4f009971ac11 207 bool eraseScreen();
Nakor 21:87a2227c1ad2 208
Nakor 0:4f009971ac11 209 /** Initialize the screen. This must be completed before any other communication with the device.
Nakor 21:87a2227c1ad2 210 *
Nakor 0:4f009971ac11 211 * Timing allows for at least 500ms delay for initialization.
Nakor 21:87a2227c1ad2 212 *
Nakor 2:559b81f2bb1e 213 * @param returns bool indicating success or failure of initialization.
Nakor 0:4f009971ac11 214 */
Nakor 0:4f009971ac11 215 bool init();
Nakor 21:87a2227c1ad2 216
Nakor 21:87a2227c1ad2 217 /** Set pen size.
Nakor 21:87a2227c1ad2 218 *
Nakor 21:87a2227c1ad2 219 * Sets if objects should be drawn solid or wire frame.
Nakor 21:87a2227c1ad2 220 * Does not apply to polygon function.
Nakor 21:87a2227c1ad2 221 *
Nakor 21:87a2227c1ad2 222 * @param size Sets solid or wire frame.
Nakor 21:87a2227c1ad2 223 * - 0x00 = Solid
Nakor 21:87a2227c1ad2 224 * - 0x01 = Wire frame.
Nakor 1:476dcc382de3 225 */
Nakor 0:4f009971ac11 226 bool penSize(char size);
Nakor 21:87a2227c1ad2 227
Nakor 1:476dcc382de3 228 /** Dunno17
Nakor 1:476dcc382de3 229 * Dunno
Nakor 2:559b81f2bb1e 230 * @param returns something.
Nakor 1:476dcc382de3 231 */
Nakor 0:4f009971ac11 232 bool putPixel(char x, char y, short color);
Nakor 1:476dcc382de3 233 /** Dunno18
Nakor 1:476dcc382de3 234 * Dunno
Nakor 2:559b81f2bb1e 235 * @param returns something.
Nakor 1:476dcc382de3 236 */
Nakor 0:4f009971ac11 237 short readPixel(char x, char y);
Nakor 7:c2fa784eb477 238 /** Replaces the background colour with a new colour.
Nakor 7:c2fa784eb477 239 *
Nakor 13:f2b9f249bcff 240 * @param red Red value (0 to 255).
Nakor 13:f2b9f249bcff 241 * @param green Green value (0 to 255).
Nakor 13:f2b9f249bcff 242 * @param blue Blue value (0 to 255).
Nakor 7:c2fa784eb477 243 */
Nakor 13:f2b9f249bcff 244 bool setBackgroundColour(char red, char green, char blue);
Nakor 1:476dcc382de3 245 /** Dunno19
Nakor 1:476dcc382de3 246 * Dunno
Nakor 2:559b81f2bb1e 247 * @param returns something.
Nakor 7:c2fa784eb477 248 */
Nakor 0:4f009971ac11 249 bool setFontSize(char fontType);
Nakor 1:476dcc382de3 250 /** Dunno21
Nakor 1:476dcc382de3 251 * Dunno
Nakor 2:559b81f2bb1e 252 * @param returns something.
Nakor 1:476dcc382de3 253 */
Nakor 0:4f009971ac11 254 bool textButton(char state, char x, char y, short buttonColor, char font, short textColor, char textWidth, char textHeight, char *text);
Nakor 1:476dcc382de3 255 /** Dunno22
Nakor 1:476dcc382de3 256 * Dunno
Nakor 2:559b81f2bb1e 257 * @param returns something.
Nakor 1:476dcc382de3 258 */
Nakor 0:4f009971ac11 259 bool textMode(char mode);
Nakor 1:476dcc382de3 260 /** Dunno23
Nakor 1:476dcc382de3 261 * Dunno
Nakor 2:559b81f2bb1e 262 * @param returns something.
Nakor 1:476dcc382de3 263 */
Nakor 0:4f009971ac11 264 bool versionInfo(bool onScreen, char *info);
Nakor 0:4f009971ac11 265
Nakor 0:4f009971ac11 266
Nakor 0:4f009971ac11 267 protected:
Nakor 0:4f009971ac11 268 Serial _oled;
Nakor 0:4f009971ac11 269 DigitalOut _reset;
Nakor 0:4f009971ac11 270
Nakor 0:4f009971ac11 271 void resetDisplay();
Nakor 8:0a92ceb34cd0 272 };
Nakor 8:0a92ceb34cd0 273
Nakor 8:0a92ceb34cd0 274 #endif