Esta versión v6 pasa a ser el nuevo master. Funciona correctamente

Dependencies:   ADXL345 Display1602 MSCFileSystem SDFileSystem mbed FATFileSystem

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Display1602.h Source File

Display1602.h

00001 
00002 #ifndef __DISPLAY1602_H__
00003 #define __DISPLAY1602_H__
00004 
00005 #include "mbed.h"
00006 #include <stdarg.h>
00007 
00008 /*
00009 INITIALIZING BY INSTRUCTION
00010 1) 8-bit interface mode (Condition: fosc = 270KHZ)
00011 
00012 Codes
00013 N = 0 1-line mode , 1 2-line mode
00014 D = 0 display off, 1 display on
00015 C = 0 cursor off, 1 cursor on
00016 B = 0 blink off, 1 blink on
00017 I/D = 0 decrement mode, 1 increment mode
00018 SH = 0 entire shift off, 1 entire shift on
00019 
00020 
00021 ***        Power on
00022 Wait for more than 30 ms after VDD rises to 4.5 v
00023 
00024 ***        Function set
00025 RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0
00026  0  0   0   0   1   1   N   D   X   X
00027 Wait for more than 39 &#956;s
00028 
00029 ***        Display ON/OFF Control
00030 RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0
00031  0  0   0   0   0   0   1   D   C   B
00032 Wait for more than 39 &#956;s
00033 
00034 
00035 ***        Display Clear
00036 RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0
00037  0  0   0   0   0   0   0   0   0   1
00038 Wait for more than 1.53 ms
00039 
00040 ***        Entry Mode Set
00041 RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0
00042  0   0  0   0   0   0   0   1  I/D SH
00043 
00044 ***        Initialization end     ***
00045 
00046 
00047 */
00048 
00049 /** Basic bit of code for using a standard 1602 display in 8 bit mode.
00050  * Written by Richard e Collins.
00051  * Basic bit of code for using a standard 1602 display in 8 bit mode.
00052  * When wiring one of these displays up make sure the power to the LCD on pin 3 is correct, too high and it will not display anything. About 0.2v is good, I use a POT to set it.
00053  *
00054  * Example use.
00055  *   Display1602 display(p10,p11,p12,p13,p14,p15,p16,p17,p18,p19,p20);
00056  *   display.SetXY(0,0);
00057  *   display.Print("Hello world");
00058  */
00059 struct Display1602
00060 {
00061     /**
00062      * Constructor, here you state the oins used to read and write data on and the control pins.
00063      * @param registerSelect This is the pin used to select if you are sending data or setting a control register.
00064      * @param readWriteSelect The pin to state if you are reading or writing data / register.
00065      * @param d0 -> d7. The eight pins for the data to be either written to the display or a register.
00066      */
00067     Display1602(PinName registerSelect,PinName readWriteSelect,PinName readWriteEnable,PinName d0,PinName d1,PinName d2,PinName d3,PinName d4,PinName d5,PinName d6,PinName d7) ;
00068 
00069     /**
00070      * Clears the display.
00071      */    
00072     void Clear();
00073     
00074     /**
00075      * Prints the text to the display, will limit the chars read by 16 chars or hitting a null terminator, which ever comes first.
00076      * Advances the cursor pos.
00077      */
00078     void Print(const char *text);
00079     
00080     /**
00081      * handy printf funtion for displaying text.
00082      * Advances the cursor pos.
00083      */
00084     void printf(const char *format,...);
00085 
00086     /**
00087      *Sets the cusor X Y pos.
00088      */
00089     void SetXY(int x,int y);
00090     
00091 private:
00092     DigitalOut rs;     //Register select, high value in data is data char data, when low is a command.
00093     DigitalOut rw;    //Data direction, high read operation, low is write operation.
00094     DigitalOut e;    //When high the value in data is read from or written to the register selected. 
00095     BusOut data;    //The data sent.
00096     
00097     void SendCommand(int cmd);
00098     
00099     void SendChar(char c);
00100 };
00101 
00102 #endif //#ifndef __DISPLAY1602_H__