Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
LCD.cpp@4:2759062f4264, 2017-12-27 (annotated)
- Committer:
- chills
- Date:
- Wed Dec 27 18:26:50 2017 +0000
- Revision:
- 4:2759062f4264
2017_12_27 18:23; Working LCD Class!!!
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
chills | 4:2759062f4264 | 1 | #include "mbed.h" //Include the mbed libraries |
chills | 4:2759062f4264 | 2 | #include "LCD.hpp" //Include the header file, this acts like a series of forward declarations |
chills | 4:2759062f4264 | 3 | |
chills | 4:2759062f4264 | 4 | //Constructor |
chills | 4:2759062f4264 | 5 | LCD::LCD(PinName E,PinName RS,PinName RW,PinName DB0,PinName DB1,PinName DB2,PinName DB3,PinName DB4,PinName DB5,PinName DB6,PinName DB7) : _E(E),_RS(RS),_RW(RW),_DB0(DB0),_DB1(DB1),_DB2(DB2),_DB3(DB3),_DB4(DB4),_DB5(DB5),_DB6(DB6),_DB7(DB7) |
chills | 4:2759062f4264 | 6 | {} |
chills | 4:2759062f4264 | 7 | |
chills | 4:2759062f4264 | 8 | LCD::~LCD(){} //Destructor |
chills | 4:2759062f4264 | 9 | |
chills | 4:2759062f4264 | 10 | void LCD::clock_in(){_E = 1; wait(0.001); _E = 0; wait(0.001); _E = 1;} |
chills | 4:2759062f4264 | 11 | |
chills | 4:2759062f4264 | 12 | void LCD::Binary_Convert(int Integer){ |
chills | 4:2759062f4264 | 13 | |
chills | 4:2759062f4264 | 14 | } |
chills | 4:2759062f4264 | 15 | |
chills | 4:2759062f4264 | 16 | |
chills | 4:2759062f4264 | 17 | void LCD::Function_Set() {_RS = 0; _RW = 0; _DB7 = 0; _DB6 = 0; _DB5 = 1; _DB4 = 1; _DB3 = 1; _DB2 = 1; _DB1 = 0; _DB0 = 0; clock_in();} |
chills | 4:2759062f4264 | 18 | void LCD::Display_Off() {_RS = 0; _RW = 0; _DB7 = 0; _DB6 = 0; _DB5 = 0; _DB4 = 0; _DB3 = 1; _DB2 = 0; _DB1 = 0; _DB0 = 0; clock_in();} |
chills | 4:2759062f4264 | 19 | void LCD::Display_Clear() {_RS = 0; _RW = 0; _DB7 = 0; _DB6 = 0; _DB5 = 0; _DB4 = 0; _DB3 = 0; _DB2 = 0; _DB1 = 0; _DB0 = 1; clock_in();} |
chills | 4:2759062f4264 | 20 | void LCD::Entry_Mode_Set() {_RS = 0; _RW = 0; _DB7 = 0; _DB6 = 0; _DB5 = 0; _DB4 = 0; _DB3 = 0; _DB2 = 1; _DB1 = 1; _DB0 = 0; clock_in();} |
chills | 4:2759062f4264 | 21 | void LCD::Display_On() {_RS = 0; _RW = 0; _DB7 = 0; _DB6 = 0; _DB5 = 0; _DB4 = 0; _DB3 = 1; _DB2 = 1; _DB1 = 1; _DB0 = 1; clock_in();} |
chills | 4:2759062f4264 | 22 | |
chills | 4:2759062f4264 | 23 | void LCD::Initialise(){ |
chills | 4:2759062f4264 | 24 | Function_Set(); wait(0.020); |
chills | 4:2759062f4264 | 25 | Display_Off(); wait(0.020); |
chills | 4:2759062f4264 | 26 | Display_Clear(); wait(0.020); |
chills | 4:2759062f4264 | 27 | Entry_Mode_Set(); wait(0.020); |
chills | 4:2759062f4264 | 28 | Display_On(); wait(0.020); |
chills | 4:2759062f4264 | 29 | DDRAM_Address(0); wait(0.020); |
chills | 4:2759062f4264 | 30 | } |
chills | 4:2759062f4264 | 31 | |
chills | 4:2759062f4264 | 32 | void LCD::DDRAM_Address(int Address){ |
chills | 4:2759062f4264 | 33 | _RS = 0; |
chills | 4:2759062f4264 | 34 | _RW = 0; |
chills | 4:2759062f4264 | 35 | _DB7 = 1; |
chills | 4:2759062f4264 | 36 | _DB6 = (Address & 0b1000000) >> 6; _DB5 = (Address & 0b0100000) >> 5; _DB4 = (Address & 0b0010000) >> 4; |
chills | 4:2759062f4264 | 37 | _DB3 = (Address & 0b0001000) >> 3; _DB2 = (Address & 0b0000100) >> 2; _DB1 = (Address & 0b0000010) >> 1; _DB0 = (Address & 0b0000001) >> 0; |
chills | 4:2759062f4264 | 38 | clock_in(); |
chills | 4:2759062f4264 | 39 | } |
chills | 4:2759062f4264 | 40 | |
chills | 4:2759062f4264 | 41 | void LCD::Write_String(string Word){ |
chills | 4:2759062f4264 | 42 | int ASCII_Converted; |
chills | 4:2759062f4264 | 43 | for (int i = 0; i < Word.length(); i++) |
chills | 4:2759062f4264 | 44 | { |
chills | 4:2759062f4264 | 45 | ASCII_Converted = Word.at(i); |
chills | 4:2759062f4264 | 46 | _RS = 1; _RW = 0; |
chills | 4:2759062f4264 | 47 | _DB7 = (ASCII_Converted & 0b10000000) >> 7; _DB6 = (ASCII_Converted & 0b01000000) >> 6; _DB5 = (ASCII_Converted & 0b00100000) >> 5; _DB4 = (ASCII_Converted & 0b00010000) >> 4; |
chills | 4:2759062f4264 | 48 | _DB3 = (ASCII_Converted & 0b00001000) >> 3; _DB2 = (ASCII_Converted & 0b00000100) >> 2; _DB1 = (ASCII_Converted & 0b00000010) >> 1; _DB0 = (ASCII_Converted & 0b00000001) >> 0; |
chills | 4:2759062f4264 | 49 | clock_in(); |
chills | 4:2759062f4264 | 50 | } |
chills | 4:2759062f4264 | 51 | } |
chills | 4:2759062f4264 | 52 |