A basic basic basic driver for 2x16 HD44780 based displays using the four wire interface.

Dependents:   lcdLibraryTest generado_final

Committer:
mattegan
Date:
Fri Nov 08 07:03:35 2013 +0000
Revision:
0:0db835052212
[ADMIN] initial commit - everything should be working

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mattegan 0:0db835052212 1 #ifndef LCD
mattegan 0:0db835052212 2 #define LCD
mattegan 0:0db835052212 3
mattegan 0:0db835052212 4 #include "mbed.h"
mattegan 0:0db835052212 5
mattegan 0:0db835052212 6 #define klcdWriteMode 0
mattegan 0:0db835052212 7 #define klcdReadMode 1
mattegan 0:0db835052212 8 #define klcdInstructionRegister 0
mattegan 0:0db835052212 9 #define klcdDataRegister 1
mattegan 0:0db835052212 10 #define klcdEnableHigh 1
mattegan 0:0db835052212 11 #define klcdEnableLow 0
mattegan 0:0db835052212 12
mattegan 0:0db835052212 13 class lcd : public Stream{
mattegan 0:0db835052212 14 public:
mattegan 0:0db835052212 15 //uses the four bit interface with a read/write pin in order to read the busy flag
mattegan 0:0db835052212 16 lcd(PinName _rs, PinName _rw, PinName _e, PinName _db4, PinName _db5, PinName _db6, PinName _db7);
mattegan 0:0db835052212 17
mattegan 0:0db835052212 18 //clear the screen
mattegan 0:0db835052212 19 void clear();
mattegan 0:0db835052212 20
mattegan 0:0db835052212 21 //move to a location on the screen, the next printf or putc call
mattegan 0:0db835052212 22 // will locate the character at the location
mattegan 0:0db835052212 23 void locate(int _row, int _column);
mattegan 0:0db835052212 24
mattegan 0:0db835052212 25 //place a character at a location
mattegan 0:0db835052212 26 void locateCharacter(int _row, int _column, int _char);
mattegan 0:0db835052212 27
mattegan 0:0db835052212 28 //define a character with a 8 element array of 5 bit wide pixel
mattegan 0:0db835052212 29 // definitions, from top to bottom
mattegan 0:0db835052212 30 void defineCharacter(int _char, int _charData[8]);
mattegan 0:0db835052212 31
mattegan 0:0db835052212 32 protected:
mattegan 0:0db835052212 33 void setMode(int _mode);
mattegan 0:0db835052212 34 void waitUntilNotBusy();
mattegan 0:0db835052212 35 int readByte(int _reg);
mattegan 0:0db835052212 36 void writeByte(int _reg, int _byte, bool _wait = true);
mattegan 0:0db835052212 37 int readNibble(int _reg);
mattegan 0:0db835052212 38 void writeNibble(int _reg, int _nibble);
mattegan 0:0db835052212 39
mattegan 0:0db835052212 40 //stream implementation
mattegan 0:0db835052212 41 virtual int _putc(int _value);
mattegan 0:0db835052212 42 virtual int _getc();
mattegan 0:0db835052212 43
mattegan 0:0db835052212 44 BusInOut dataBus;
mattegan 0:0db835052212 45 DigitalOut registerSelect;
mattegan 0:0db835052212 46 DigitalOut readWrite;
mattegan 0:0db835052212 47 DigitalOut enable;
mattegan 0:0db835052212 48
mattegan 0:0db835052212 49 int currentMode;
mattegan 0:0db835052212 50 int column;
mattegan 0:0db835052212 51 int row;
mattegan 0:0db835052212 52 };
mattegan 0:0db835052212 53
mattegan 0:0db835052212 54 #endif