General purpose character LCD library. I found the TextLCD library had too many constraints and it didn\\\\\\\'t supply acces to all functions in the HD44780 chipset, so i decided to write my own character lcd library.

Committer:
lktromp
Date:
Fri Mar 25 10:01:28 2011 +0000
Revision:
1:1349bedd5793
Child:
2:18f6402fd025
Improved

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lktromp 1:1349bedd5793 1 /***********************************************************************************
lktromp 1:1349bedd5793 2 Filename: CharacterLCD.h
lktromp 1:1349bedd5793 3
lktromp 1:1349bedd5793 4
lktromp 1:1349bedd5793 5 ***********************************************************************************/
lktromp 1:1349bedd5793 6 #ifndef CHARLCD_H
lktromp 1:1349bedd5793 7 #define CHARLCD_H
lktromp 1:1349bedd5793 8 #include "mbed.h"
lktromp 1:1349bedd5793 9
lktromp 1:1349bedd5793 10 //move this typedef to project specific datatype header file
lktromp 1:1349bedd5793 11 typedef unsigned char uint8;
lktromp 1:1349bedd5793 12
lktromp 1:1349bedd5793 13
lktromp 1:1349bedd5793 14
lktromp 1:1349bedd5793 15 class charLcd
lktromp 1:1349bedd5793 16 { public:
lktromp 1:1349bedd5793 17
lktromp 1:1349bedd5793 18 /** LCD panel format */
lktromp 1:1349bedd5793 19 enum LCDType {
lktromp 1:1349bedd5793 20 LCD16x2 /**< 16x2 LCD panel (default) */
lktromp 1:1349bedd5793 21 , LCD16x2B /**< 16x2 LCD panel alternate addressing */
lktromp 1:1349bedd5793 22 , LCD20x2 /**< 20x2 LCD panel */
lktromp 1:1349bedd5793 23 , LCD20x4 /**< 20x4 LCD panel */
lktromp 1:1349bedd5793 24 };
lktromp 1:1349bedd5793 25
lktromp 1:1349bedd5793 26 //constructor for 4-bit lcd control
lktromp 1:1349bedd5793 27 charLcd(PinName rs, PinName rw, PinName en, PinName d7, PinName d6, PinName d5, PinName d4, LCDType type = LCD16x2);
lktromp 1:1349bedd5793 28 //constructor for 8-bit lcd control
lktromp 1:1349bedd5793 29 charLcd(PinName rs, PinName rw, PinName en, PinName d7, PinName d6, PinName d5, PinName d4, PinName d3, PinName d2,
lktromp 1:1349bedd5793 30 PinName d1, PinName d0, LCDType type = LCD16x2);
lktromp 1:1349bedd5793 31
lktromp 1:1349bedd5793 32 void charLcdResetLCD(void);
lktromp 1:1349bedd5793 33 void charLcdClear (void);
lktromp 1:1349bedd5793 34 void charLcdReturnHome();
lktromp 1:1349bedd5793 35 void charLcdEntryMode(uint8 increment, uint8 shift);
lktromp 1:1349bedd5793 36 void charLcdDisplayOn(uint8 on);
lktromp 1:1349bedd5793 37 void charLcdCursor(uint8 cursor, uint8 blink);
lktromp 1:1349bedd5793 38 void charLcdShift(uint8 left, uint8 cursor);
lktromp 1:1349bedd5793 39 void charLcdFunctionSet(uint8 dots, uint8 lines, uint8 bits);
lktromp 1:1349bedd5793 40
lktromp 1:1349bedd5793 41 private:
lktromp 1:1349bedd5793 42 void charLcdSetCGRAMaddress(uint8 adr);
lktromp 1:1349bedd5793 43 void charLcdSetDDRAMaddress(uint8 address);
lktromp 1:1349bedd5793 44 uint8 charLcdReadBusyFlag();
lktromp 1:1349bedd5793 45 void charLcdWriteData(uint8 dat);
lktromp 1:1349bedd5793 46 uint8 charLcdReadData();
lktromp 1:1349bedd5793 47 void charLcdSendCommand(uint8 cmd);
lktromp 1:1349bedd5793 48 void charLcdWriteByte(uint8 byte);
lktromp 1:1349bedd5793 49
lktromp 1:1349bedd5793 50 uint8 LcdStatus;
lktromp 1:1349bedd5793 51 uint8 LcdCustomChar[8];
lktromp 1:1349bedd5793 52
lktromp 1:1349bedd5793 53 //LCD Control pins
lktromp 1:1349bedd5793 54 DigitalOut cl_rs;
lktromp 1:1349bedd5793 55 DigitalOut cl_rw;
lktromp 1:1349bedd5793 56 DigitalOut cl_en;
lktromp 1:1349bedd5793 57
lktromp 1:1349bedd5793 58 //LCD Data pins
lktromp 1:1349bedd5793 59 //DigitalInOut cl_d7;
lktromp 1:1349bedd5793 60 //DigitalInOut cl_d6;
lktromp 1:1349bedd5793 61 //DigitalInOut cl_d5;
lktromp 1:1349bedd5793 62 //DigitalInOut cl_d4;
lktromp 1:1349bedd5793 63 //DigitalInOut cl_d3;
lktromp 1:1349bedd5793 64 //DigitalInOut cl_d2;
lktromp 1:1349bedd5793 65 //DigitalInOut cl_d1;
lktromp 1:1349bedd5793 66 //DigitalInOut cl_d0;
lktromp 1:1349bedd5793 67
lktromp 1:1349bedd5793 68 //LCD Data port
lktromp 1:1349bedd5793 69 //PortInOut charLcdData;
lktromp 1:1349bedd5793 70
lktromp 1:1349bedd5793 71 //LCD Data bus
lktromp 1:1349bedd5793 72 BusInOut cl_charLcdData;
lktromp 1:1349bedd5793 73
lktromp 1:1349bedd5793 74 };
lktromp 1:1349bedd5793 75
lktromp 1:1349bedd5793 76
lktromp 1:1349bedd5793 77
lktromp 1:1349bedd5793 78 /**********************************************************************************/
lktromp 1:1349bedd5793 79 #endif //CHARLCD_H