cristian rodriguez
/
lcd
lcd
Embed:
(wiki syntax)
Show/hide line numbers
TextLCD_20X4.h
00001 /* mbed TextLCD Library 00002 * Copyright (c) 2007-2009 sford 00003 * Released under the MIT License: http://mbed.org/license/mit 00004 * 00005 * TODO: Needs serious rework/neatening up! 00006 */ 00007 00008 /* 00009 * 2010/05/14 modified for 20X4 LCD by ym1784 00010 */ 00011 00012 #ifndef MBED_TEXTLCD_20X4_H 00013 #define MBED_TEXTLCD_20X4_H 00014 00015 #include "Stream.h" 00016 #include "DigitalOut.h" 00017 #include "BusOut.h" 00018 00019 namespace mbed { 00020 00021 /* Class: TextLCD_20X4 00022 * A 20x4 Text LCD controller ... ym1784 00023 * 00024 * Allows you to print to a Text LCD screen, and locate/cls. Could be 00025 * turned in to a more generic libray. 00026 * 00027 * If you are connecting multiple displays, you can connect them all in 00028 * parallel except for the enable (e) pin, which must be unique for each 00029 * display. 00030 * 00031 * Example: 00032 * > #include "mbed.h" 00033 * > #include "TextLCD_20X4.h" 00034 * > 00035 * > TextLCD_20X4 lcd(p21, p22, p23, p24, p25, p26); // rs, e, d0, d1, d2, d3 00036 * > 00037 * > int main() { 00038 * > lcd.printf("Hello World!"); 00039 * > } 00040 */ 00041 class TextLCD_20X4 : public Stream { 00042 00043 public: 00044 /* Constructor: TextLCD_20X4 00045 * Create a TextLCD_20X4 object, connected to the specified pins 00046 * 00047 * All signals must be connected to DigitalIn compatible pins. 00048 * 00049 * Variables: 00050 * rs - Used to specify data or command 00051 * e - enable 00052 * d0..d3 - The data lines 00053 */ 00054 TextLCD_20X4(PinName rs, PinName e, PinName d0, PinName d1, 00055 PinName d2, PinName d3, int columns = 20, int rows = 4); 00056 00057 #if 0 // Inhereted from Stream, for documentation only 00058 /* Function: putc 00059 * Write a character 00060 * 00061 * Variables: 00062 * c - The character to write to the serial port 00063 */ 00064 int putc(int c); 00065 00066 /* Function: printf 00067 * Write a formated string 00068 * 00069 * Variables: 00070 * format - A printf-style format string, followed by the 00071 * variables to use in formating the string. 00072 */ 00073 int printf(const char* format, ...); 00074 #endif 00075 00076 /* Function: locate 00077 * Locate to a certian position 00078 * 00079 * Variables: 00080 * column - the column to locate to, from 0..19 00081 * row - the row to locate to, from 0..3 00082 */ 00083 virtual void locate(int column, int row); 00084 00085 /* Function: cls 00086 * Clear the screen 00087 */ 00088 virtual void cls(); 00089 00090 virtual void reset(); 00091 00092 //protected: 00093 00094 void clock(); 00095 void writeData(int data); 00096 void writeCommand(int command); 00097 void writeByte(int value); 00098 void writeNibble(int value); 00099 virtual int _putc(int c); 00100 virtual int _getc(); 00101 virtual void newline(); 00102 00103 int _row; 00104 int _column; 00105 DigitalOut _rs, _e; 00106 BusOut _d; 00107 int _columns; 00108 int _rows; 00109 int address; 00110 }; 00111 00112 } 00113 00114 #endif
Generated on Mon Jul 18 2022 20:28:04 by 1.7.2