Graphic OLED 100x16 pixels interface

Dependents:   mbed_nicovideo_search_api mbed_recent_nicovideo_display_pub

/media/uploads/va009039/graphicoled_1.jpg

Committer:
va009039
Date:
Tue Aug 12 01:47:43 2014 +0000
Revision:
3:a6650dd2dbc8
Parent:
2:337a2655f815
change from shift-jis to utf-8.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
va009039 0:67d983a1ed3e 1 // GraphicOLED.h
va009039 2:337a2655f815 2 #pragma once
va009039 2:337a2655f815 3 #include "mbed.h"
va009039 0:67d983a1ed3e 4
va009039 1:a104653979bf 5 /** GraphicOLED interface for WS0010
va009039 1:a104653979bf 6 *
va009039 2:337a2655f815 7 * Currently support UTF-8 KANJI(misaki font)
va009039 1:a104653979bf 8 *
va009039 1:a104653979bf 9 * @code
va009039 1:a104653979bf 10 * #include "mbed.h"
va009039 1:a104653979bf 11 * #include "GraphicOLED.h"
va009039 1:a104653979bf 12 *
va009039 1:a104653979bf 13 * GraphicOLED oled(p24, p26, p27, p28, p29, p30); // rs, e, d4-d7
va009039 1:a104653979bf 14 *
va009039 1:a104653979bf 15 * int main() {
va009039 1:a104653979bf 16 * oled.printf("Hello World!\n");
va009039 1:a104653979bf 17 * }
va009039 1:a104653979bf 18 * @endcode
va009039 1:a104653979bf 19 */
va009039 2:337a2655f815 20 class GraphicOLED : public Stream {
va009039 0:67d983a1ed3e 21 public:
va009039 1:a104653979bf 22 /** Create a GraphicOLED interface
va009039 1:a104653979bf 23 *
va009039 1:a104653979bf 24 * @param rs Instruction/data control line
va009039 1:a104653979bf 25 * @param e Enable line (clock)
va009039 1:a104653979bf 26 * @param d4-d7 Data lines for using as a 4-bit interface
va009039 1:a104653979bf 27 */
va009039 1:a104653979bf 28 GraphicOLED(PinName rs, PinName e, PinName d4, PinName d5, PinName d6, PinName d7);
va009039 2:337a2655f815 29
va009039 2:337a2655f815 30 #if DOXYGEN_ONLY
va009039 3:a6650dd2dbc8 31 /** Write a character to the OLED
va009039 2:337a2655f815 32 *
va009039 2:337a2655f815 33 * @param c The character to write to the display
va009039 2:337a2655f815 34 */
va009039 2:337a2655f815 35 int putc(int c);
va009039 2:337a2655f815 36
va009039 3:a6650dd2dbc8 37 /** Write a formated string to the OLED
va009039 2:337a2655f815 38 *
va009039 2:337a2655f815 39 * @param format A printf-style format string, followed by the
va009039 2:337a2655f815 40 * variables to use in formating the string.
va009039 2:337a2655f815 41 */
va009039 2:337a2655f815 42 int printf(const char* format, ...);
va009039 2:337a2655f815 43 #endif
va009039 2:337a2655f815 44
va009039 2:337a2655f815 45 /** Locate to a screen column and row
va009039 2:337a2655f815 46 *
va009039 2:337a2655f815 47 * @param column The horizontal position from the left, indexed from 0
va009039 2:337a2655f815 48 * @param row The vertical position from the top, indexed from 0
va009039 2:337a2655f815 49 */
va009039 2:337a2655f815 50 void locate(int column, int row);
va009039 2:337a2655f815 51
va009039 2:337a2655f815 52 /** Clear the screen and locate to 0,0 */
va009039 0:67d983a1ed3e 53 void cls();
va009039 2:337a2655f815 54
va009039 2:337a2655f815 55 int rows();
va009039 0:67d983a1ed3e 56 int columns();
va009039 2:337a2655f815 57
va009039 2:337a2655f815 58 void g_write(uint8_t pat, int x, int y);
va009039 2:337a2655f815 59 void g_write(uint8_t *buf, int len, int x, int y);
va009039 2:337a2655f815 60
va009039 2:337a2655f815 61 private:
va009039 3:a6650dd2dbc8 62 int _uni_len;
va009039 3:a6650dd2dbc8 63 uint32_t _unicode;
va009039 2:337a2655f815 64
va009039 2:337a2655f815 65 // Stream implementation functions
va009039 2:337a2655f815 66 virtual int _putc(int value);
va009039 2:337a2655f815 67 virtual int _getc();
va009039 2:337a2655f815 68
va009039 3:a6650dd2dbc8 69 int character(int column, int row, int c);
va009039 2:337a2655f815 70 void writeByte(uint8_t value);
va009039 2:337a2655f815 71 void writeCommand(uint8_t command);
va009039 2:337a2655f815 72 void writeData(uint8_t data);
va009039 2:337a2655f815 73
va009039 2:337a2655f815 74 DigitalOut _rs, _e;
va009039 2:337a2655f815 75 BusOut _d;
va009039 2:337a2655f815 76
va009039 2:337a2655f815 77 int _column;
va009039 2:337a2655f815 78 int _row;
va009039 0:67d983a1ed3e 79 };
va009039 2:337a2655f815 80