mbed TextOLED Library, for a 4-bit LCD based on Winstar WEH000000 series Originl: http://mbed.org/users/simon/libraries/TextLCD/latest 共立電子 デジット の OLEDモジュール 4bitモード用 adapted 12/3/2013 by CJS to make custom character defintions possible

Fork of TextOLED by Suga koubou

Committer:
pegcjs
Date:
Tue Mar 12 15:34:51 2013 +0000
Revision:
3:f67d4fc4e388
Parent:
1:df8722660f48
moved writeComand, writeData and character into pulich classes to alow definition of custom characters on the fly

Who changed what in which revision?

UserRevisionLine numberNew contents of line
okini3939 0:4467cf9395fd 1 /* mbed TextOLED Library, for a 4-bit LCD based on Winstar WEH000000 series
okini3939 0:4467cf9395fd 2 * Originl: http://mbed.org/users/simon/libraries/TextLCD/latest
okini3939 0:4467cf9395fd 3 * Modified by Suga
okini3939 0:4467cf9395fd 4 */
okini3939 0:4467cf9395fd 5 /* mbed TextLCD Library, for a 4-bit LCD based on HD44780
okini3939 0:4467cf9395fd 6 * Copyright (c) 2007-2010, sford, http://mbed.org
okini3939 0:4467cf9395fd 7 *
okini3939 0:4467cf9395fd 8 * Permission is hereby granted, free of charge, to any person obtaining a copy
okini3939 0:4467cf9395fd 9 * of this software and associated documentation files (the "Software"), to deal
okini3939 0:4467cf9395fd 10 * in the Software without restriction, including without limitation the rights
okini3939 0:4467cf9395fd 11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
okini3939 0:4467cf9395fd 12 * copies of the Software, and to permit persons to whom the Software is
okini3939 0:4467cf9395fd 13 * furnished to do so, subject to the following conditions:
okini3939 0:4467cf9395fd 14 *
okini3939 0:4467cf9395fd 15 * The above copyright notice and this permission notice shall be included in
okini3939 0:4467cf9395fd 16 * all copies or substantial portions of the Software.
okini3939 0:4467cf9395fd 17 *
okini3939 0:4467cf9395fd 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
okini3939 0:4467cf9395fd 19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
okini3939 0:4467cf9395fd 20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
okini3939 0:4467cf9395fd 21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
okini3939 0:4467cf9395fd 22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
okini3939 0:4467cf9395fd 23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
okini3939 0:4467cf9395fd 24 * THE SOFTWARE.
okini3939 0:4467cf9395fd 25 */
okini3939 0:4467cf9395fd 26
okini3939 0:4467cf9395fd 27 #ifndef MBED_TEXTOLED_H
okini3939 0:4467cf9395fd 28 #define MBED_TEXTOLED_H
okini3939 0:4467cf9395fd 29
okini3939 0:4467cf9395fd 30 #include "mbed.h"
okini3939 0:4467cf9395fd 31
okini3939 0:4467cf9395fd 32 /** A TextOLED interface for driving 4-bit HD44780-based LCDs
okini3939 0:4467cf9395fd 33 *
okini3939 0:4467cf9395fd 34 * Currently supports 16x2, 20x2 and 20x4 panels
okini3939 0:4467cf9395fd 35 *
okini3939 0:4467cf9395fd 36 * @code
okini3939 0:4467cf9395fd 37 * #include "mbed.h"
okini3939 0:4467cf9395fd 38 * #include "TextOLED.h"
okini3939 0:4467cf9395fd 39 *
okini3939 0:4467cf9395fd 40 * TextOLED lcd(p10, p12, p15, p16, p29, p30); // rs, e, d4-d7
okini3939 0:4467cf9395fd 41 *
okini3939 0:4467cf9395fd 42 * int main() {
okini3939 0:4467cf9395fd 43 * lcd.printf("Hello World!\n");
okini3939 0:4467cf9395fd 44 * }
okini3939 0:4467cf9395fd 45 * @endcode
okini3939 0:4467cf9395fd 46 */
okini3939 0:4467cf9395fd 47 class TextOLED : public Stream {
okini3939 0:4467cf9395fd 48 public:
pegcjs 3:f67d4fc4e388 49 void writeCommand(int command);
pegcjs 3:f67d4fc4e388 50 void writeData(int data);
pegcjs 3:f67d4fc4e388 51 void character(int column, int row, int c);
okini3939 0:4467cf9395fd 52 /** LCD panel format */
okini3939 0:4467cf9395fd 53 enum LCDType {
okini3939 0:4467cf9395fd 54 LCD16x2 /**< 16x2 LCD panel (default) */
okini3939 0:4467cf9395fd 55 , LCD16x2B /**< 16x2 LCD panel alternate addressing */
okini3939 0:4467cf9395fd 56 , LCD20x2 /**< 20x2 LCD panel */
okini3939 0:4467cf9395fd 57 , LCD20x4 /**< 20x4 LCD panel */
okini3939 0:4467cf9395fd 58 , LCD8x2 /**< 8x4 LCD panel */
okini3939 0:4467cf9395fd 59 };
okini3939 0:4467cf9395fd 60
okini3939 0:4467cf9395fd 61 /** Create a TextOLED interface
okini3939 0:4467cf9395fd 62 *
okini3939 0:4467cf9395fd 63 * @param rs Instruction/data control line
okini3939 0:4467cf9395fd 64 * @param e Enable line (clock)
okini3939 0:4467cf9395fd 65 * @param d4-d7 Data lines for using as a 4-bit interface
okini3939 0:4467cf9395fd 66 * @param type Sets the panel size/addressing mode (default = LCD16x2)
okini3939 0:4467cf9395fd 67 */
okini3939 0:4467cf9395fd 68 TextOLED(PinName rs, PinName e, PinName d4, PinName d5, PinName d6, PinName d7, LCDType type = LCD16x2);
okini3939 0:4467cf9395fd 69
okini3939 0:4467cf9395fd 70 #if DOXYGEN_ONLY
okini3939 0:4467cf9395fd 71 /** Write a character to the LCD
okini3939 0:4467cf9395fd 72 *
okini3939 0:4467cf9395fd 73 * @param c The character to write to the display
okini3939 0:4467cf9395fd 74 */
okini3939 0:4467cf9395fd 75 int putc(int c);
okini3939 0:4467cf9395fd 76
okini3939 0:4467cf9395fd 77 /** Write a formated string to the LCD
okini3939 0:4467cf9395fd 78 *
okini3939 0:4467cf9395fd 79 * @param format A printf-style format string, followed by the
okini3939 0:4467cf9395fd 80 * variables to use in formating the string.
okini3939 0:4467cf9395fd 81 */
okini3939 0:4467cf9395fd 82 int printf(const char* format, ...);
okini3939 0:4467cf9395fd 83 #endif
okini3939 0:4467cf9395fd 84
okini3939 0:4467cf9395fd 85 /** Locate to a screen column and row
okini3939 0:4467cf9395fd 86 *
okini3939 0:4467cf9395fd 87 * @param column The horizontal position from the left, indexed from 0
okini3939 0:4467cf9395fd 88 * @param row The vertical position from the top, indexed from 0
okini3939 0:4467cf9395fd 89 */
okini3939 0:4467cf9395fd 90 void locate(int column, int row);
okini3939 0:4467cf9395fd 91
okini3939 0:4467cf9395fd 92 /** Clear the screen and locate to 0,0 */
okini3939 0:4467cf9395fd 93 void cls();
okini3939 0:4467cf9395fd 94
okini3939 0:4467cf9395fd 95 int rows();
okini3939 0:4467cf9395fd 96 int columns();
okini3939 0:4467cf9395fd 97
okini3939 1:df8722660f48 98 void cursor (bool flg);
okini3939 1:df8722660f48 99
okini3939 0:4467cf9395fd 100 protected:
okini3939 0:4467cf9395fd 101
okini3939 0:4467cf9395fd 102 // Stream implementation functions
okini3939 0:4467cf9395fd 103 virtual int _putc(int value);
okini3939 0:4467cf9395fd 104 virtual int _getc();
okini3939 0:4467cf9395fd 105
okini3939 0:4467cf9395fd 106 int address(int column, int row);
pegcjs 3:f67d4fc4e388 107 //void character(int column, int row, int c);
okini3939 0:4467cf9395fd 108 void write4bit(int value);
okini3939 0:4467cf9395fd 109 void writeByte(int value);
pegcjs 3:f67d4fc4e388 110 //void writeCommand(int command);
pegcjs 3:f67d4fc4e388 111 //void writeData(int data);
okini3939 0:4467cf9395fd 112
okini3939 0:4467cf9395fd 113 DigitalOut _rs, _e;
okini3939 0:4467cf9395fd 114 BusOut _d;
okini3939 0:4467cf9395fd 115 LCDType _type;
okini3939 0:4467cf9395fd 116
okini3939 0:4467cf9395fd 117 int _column;
okini3939 0:4467cf9395fd 118 int _row;
okini3939 0:4467cf9395fd 119 };
okini3939 0:4467cf9395fd 120
okini3939 0:4467cf9395fd 121 #endif