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