Dependents: vmConfort_v6 Programski_zadatak_23 Projektni_zadatak_23 tempivolt
Diff: Display1602.h
- Revision:
- 0:6c0e68e0d876
- Child:
- 1:fc4c861451e1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Display1602.h Fri Apr 06 19:22:15 2012 +0000 @@ -0,0 +1,83 @@ + +#ifndef __DISPLAY1602_H__ +#define __DISPLAY1602_H__ + +#include "mbed.h" +#include <stdarg.h> + +/* +INITIALIZING BY INSTRUCTION +1) 8-bit interface mode (Condition: fosc = 270KHZ) + +Codes +N = 0 1-line mode , 1 2-line mode +D = 0 display off, 1 display on +C = 0 cursor off, 1 cursor on +B = 0 blink off, 1 blink on +I/D = 0 decrement mode, 1 increment mode +SH = 0 entire shift off, 1 entire shift on + + +*** Power on +Wait for more than 30 ms after VDD rises to 4.5 v + +*** Function set +RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 + 0 0 0 0 1 1 N D X X +Wait for more than 39 μs + +*** Display ON/OFF Control +RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 + 0 0 0 0 0 0 1 D C B +Wait for more than 39 μs + + +*** Display Clear +RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 + 0 0 0 0 0 0 0 0 0 1 +Wait for more than 1.53 ms + +*** Entry Mode Set +RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 + 0 0 0 0 0 0 0 1 I/D SH + +*** Initialization end *** + + +*/ + +/* + * Written by Richard e Collins. + * Basic bit of code for using a standard 1602 display in 8 bit mode. + * 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. + * + * Example use. + * Display1602 display(p10,p11,p12,p13,p14,p15,p16,p17,p18,p19,p20); + * display.SetXY(0,0); + * display.Print("Hello world"); + */ +struct Display1602 +{ + Display1602(PinName registerSelect,PinName readWriteSelect,PinName readWriteEnable,PinName d0,PinName d1,PinName d2,PinName d3,PinName d4,PinName d5,PinName d6,PinName d7) ; + + void Clear(); + + void Print(const char *text); + + void printf(const char *format,...); + + void SetXY(int x,int y); + +private: + DigitalOut rs; //Register select, high value in data is data char data, when low is a command. + DigitalOut rw; //Data direction, high read operation, low is write operation. + DigitalOut e; //When high the value in data is read from or written to the register selected. + DigitalOut bf; //Used by the hardware to say when busy, this is also data bit 7. I am assuming it is only valid to read when readWriteEnable is false. + BusOut data; //The data sent. + + void SendCommand(int cmd); + + void SendChar(char c); +}; + +#endif //#ifndef __DISPLAY1602_H__