Atsushi Hattori
/
20210627_Logger
hattori&ide
Embed:
(wiki syntax)
Show/hide line numbers
TextOLED.h
00001 /* mbed TextOLED Library, for a 4-bit LCD based on Winstar WEH000000 series 00002 * Originl: http://mbed.org/users/simon/libraries/TextLCD/latest 00003 * Modified by Suga 00004 */ 00005 /* mbed TextLCD Library, for a 4-bit LCD based on HD44780 00006 * Copyright (c) 2007-2010, sford, http://mbed.org 00007 * 00008 * Permission is hereby granted, free of charge, to any person obtaining a copy 00009 * of this software and associated documentation files (the "Software"), to deal 00010 * in the Software without restriction, including without limitation the rights 00011 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00012 * copies of the Software, and to permit persons to whom the Software is 00013 * furnished to do so, subject to the following conditions: 00014 * 00015 * The above copyright notice and this permission notice shall be included in 00016 * all copies or substantial portions of the Software. 00017 * 00018 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00019 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00020 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00021 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00022 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00023 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00024 * THE SOFTWARE. 00025 */ 00026 00027 #ifndef MBED_TEXTOLED_H 00028 #define MBED_TEXTOLED_H 00029 00030 #include "mbed.h" 00031 00032 /** A TextOLED interface for driving 4-bit HD44780-based LCDs 00033 * 00034 * Currently supports 16x2, 20x2 and 20x4 panels 00035 * 00036 * @code 00037 * #include "mbed.h" 00038 * #include "TextOLED.h" 00039 * 00040 * TextOLED lcd(p10, p12, p15, p16, p29, p30); // rs, e, d4-d7 00041 * 00042 * int main() { 00043 * lcd.printf("Hello World!\n"); 00044 * } 00045 * @endcode 00046 */ 00047 class TextOLED : public Stream { 00048 public: 00049 00050 /** LCD panel format */ 00051 enum LCDType { 00052 LCD16x2 /**< 16x2 LCD panel (default) */ 00053 , LCD16x2B /**< 16x2 LCD panel alternate addressing */ 00054 , LCD20x2 /**< 20x2 LCD panel */ 00055 , LCD20x4 /**< 20x4 LCD panel */ 00056 , LCD8x2 /**< 8x4 LCD panel */ 00057 }; 00058 00059 /** Create a TextOLED interface 00060 * 00061 * @param rs Instruction/data control line 00062 * @param e Enable line (clock) 00063 * @param d4-d7 Data lines for using as a 4-bit interface 00064 * @param type Sets the panel size/addressing mode (default = LCD16x2) 00065 */ 00066 TextOLED(PinName rs, PinName e, PinName d4, PinName d5, PinName d6, PinName d7, LCDType type = LCD16x2); 00067 00068 #if DOXYGEN_ONLY 00069 /** Write a character to the LCD 00070 * 00071 * @param c The character to write to the display 00072 */ 00073 int putc(int c); 00074 00075 /** Write a formated string to the LCD 00076 * 00077 * @param format A printf-style format string, followed by the 00078 * variables to use in formating the string. 00079 */ 00080 int printf(const char* format, ...); 00081 #endif 00082 00083 /** Locate to a screen column and row 00084 * 00085 * @param column The horizontal position from the left, indexed from 0 00086 * @param row The vertical position from the top, indexed from 0 00087 */ 00088 void locate(int column, int row); 00089 00090 /** Clear the screen and locate to 0,0 */ 00091 void cls(); 00092 00093 int rows(); 00094 int columns(); 00095 00096 void cursor (bool flg); 00097 00098 protected: 00099 00100 // Stream implementation functions 00101 virtual int _putc(int value); 00102 virtual int _getc(); 00103 00104 int address(int column, int row); 00105 void character(int column, int row, int c); 00106 void write4bit(int value); 00107 void writeByte(int value); 00108 void writeCommand(int command); 00109 void writeData(int data); 00110 00111 DigitalOut _rs, _e; 00112 BusOut _d; 00113 LCDType _type; 00114 00115 int _column; 00116 int _row; 00117 }; 00118 00119 #endif
Generated on Sun Dec 18 2022 08:16:47 by 1.7.2