Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: uOLED-128-G1-CLASS-DEMO
uOLED.h
- Committer:
- Nakor
- Date:
- 2010-12-21
- Revision:
- 19:cc4f5d01f080
- Parent:
- 18:77ec40174c31
- Child:
- 20:a07d700164c8
File content as of revision 19:cc4f5d01f080:
/* mbed 4D uOLED Library
* Originally designed for use with uOLED-96-G1 (SGC)
* serially controlled .96" screen.
*
* This is a modified library originally obtained from
* Erik van Wijk's library code at:
* http://mbed.org/users/evwijk/libraries/microOLED/li4nzn
*
* This library (uOLED) by Aaron Goselin.
* 2010
*/
#ifndef _MBED_UOLED_
#define _MBED_UOLED_
#include "mbed.h"
#define OLED_FONT5X7 0x01
#define OLED_FONT8X8 0x02
#define OLED_FONT8X12 0x03
#define OLED_DISPLAYCONTROL_DISPLAY 0x01
#define OLED_DISPLAYCONTROL_CONTRAST 0x02
#define OLED_DISPLAYCONTROL_POWER 0x03
/** uOLED control class using Serial
*
* Example:
* @code
* // Draw text on the screen.
* #include "mbed.h"
* #include "uOLED.h"
*
* uOLED SGC(p9, p10, p11);
*
* int main()
* {
* SGC.drawText(0, 0, 0, FF, "This is text");
* }
* @endcode
*/
class uOLED {
public:
/** Create an instance of the uOLED class.
*
* @param serialTX - mbed TX pin to be used
* @param serialRX - mbed RX pin to be used
* @param reset - mbed pin to control reset of the uOLED
*/
uOLED(PinName serialTX, PinName serialRX, PinName reset);
/** Convert RGB value into the type of value that the uOLED wants.
*
* @param red Red value.
* @param green Green value.
* @param blue Blue value.
*/
short getRGB(char red, char green, char blue);
/** !!ToDo!!
*
* @param returns something.
*/
bool addBitmappedCharacter(char character, char data[8]);
/** !!ToDO!!
*
* @param returns something.
*/
bool blockCopyPaste(char sourceX, char sourceY, char destinationX, char destinationY, char width, char height);
/** Display control.
*
* Display ON/OFF, set contrast, and PowerUp/Shutdown.
*
* @param mode Sets specified mode.
* @param value Value option for mode.
*
* - Mode: 01 Display ON/OFF
* - Value: 00 OFF
* - Value: 01 ON
* - Mode: 02 Contrast Adjust
* - Value range: 0x00 to 0x0F
* - Mode: 03 Display PowerUp/Shutdown (low power mode)
* - Value 00 Shutdown
* - Value 01 Powerup
*/
bool displayControl(char mode, char value);
/** !!ToDo!!
*
* @param returns something.
*/
bool displayUserBitmappedCharacter(char character, char x, char y, short color);
/** Draw a circle.
*
* @param x X position of circle center.
* @param y Y position of circle center.
* @param radius Radius of the circle.
* @param red Amount of red.
* @param green Amount of green.
* @param blue Amount of blue.
*/
bool drawCircle(char x, char y, char radius, short red, short green, short blue);
/** !!ToDo!!
*
* @param returns something.
*/
bool drawCharacter(char character, char column, char row, short color);
/** !!ToDo!!
*
* @param returns something.
*/
bool drawImage(char x, char y, char width, char height, char colorMode, char *pixels);
/** Draw a line.
*
* Draws a line to the screen.
* @param x1 Top left horizontal start position.
* @param y1 Top left vertical start position.
* @param x2 Bottom right horizontal start position.
* @param y2 Bottom right vertical end position.
* @param red Amount of red.
* @param green Amount of green.
* @param blue Amount of blue.
*/
bool drawLine(char x1, char y1, char x2, char y2, short red, short green, short blue);
/** Dunno11
* Dunno
* @param returns something.
*/
bool drawPolygon(char vertices, char *x, char *y, short color);
/** Dunno12
* Dunno
* @param returns something.
*/
bool drawRectangle(char x, char y, char width, char height, short color);
/** Draw text to the screen.
*
* @param column X coordinate for text placement.
* @param row Y coordinate for text placement.
* @param font Which font to use (Uses 0, 1, or 2). More fonts can be added.
* @param color Font colour to use.
* @param *text Character array (string) to be displayed.
*
* Example:
* @code
* SGC.drawText(0, 0, 0, FF, "This is text");
* @endcode
*/
bool drawText(char column, char row, char font, short color, char *text);
/** Draw unformated text to the screen.
* The manual describes this as "graphics format".
*
* @param x X coordinate for text placement.
* @param y Y coordinate for text placement.
* @param font Which font to use (Uses 0, 1, or 2). More fonts can be added.
* @param red Amount of red in text colour RGB value.
* @param green Amount of green in text colour RGB value.
* @param blue Amount of blue in text colour RGB value.
* @param width Text width.
* @param height Text height.
* @param *text Character array (string) to be displayed.
*
* Example:
* @code
* SGC.drawTextUF(0, 0, 0, 20, 20, 255, 1, 1, "This is text");
* @endcode
*/
bool drawTextUF(char x, char y, char font, short red, short green, short blue, char width, char height, char *text);
/** Dunno13
* Dunno
* @param returns something.
*/
bool drawTriangle(char x1, char y1, char x2, char y2, char x3, char y3, short color);
/** Dunno15
* Dunno
* @param returns something.
*/
bool eraseScreen();
/** Initialize the screen. This must be completed before any other communication with the device.
* Timing allows for at least 500ms delay for initialization.
* @param returns bool indicating success or failure of initialization.
*/
bool init();
/** Dunno16
* Dunno
* @param returns something.
*/
bool penSize(char size);
/** Dunno17
* Dunno
* @param returns something.
*/
bool putPixel(char x, char y, short color);
/** Dunno18
* Dunno
* @param returns something.
*/
short readPixel(char x, char y);
/** Replaces the background colour with a new colour.
*
* @param red Red value (0 to 255).
* @param green Green value (0 to 255).
* @param blue Blue value (0 to 255).
*/
bool setBackgroundColour(char red, char green, char blue);
/** Dunno19
* Dunno
* @param returns something.
*/
bool setFontSize(char fontType);
/** Dunno21
* Dunno
* @param returns something.
*/
bool textButton(char state, char x, char y, short buttonColor, char font, short textColor, char textWidth, char textHeight, char *text);
/** Dunno22
* Dunno
* @param returns something.
*/
bool textMode(char mode);
/** Dunno23
* Dunno
* @param returns something.
*/
bool versionInfo(bool onScreen, char *info);
protected:
Serial _oled;
DigitalOut _reset;
void resetDisplay();
};
#endif