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
Diff: LCD.cpp
- Revision:
- 4:2759062f4264
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LCD.cpp Wed Dec 27 18:26:50 2017 +0000 @@ -0,0 +1,52 @@ +#include "mbed.h" //Include the mbed libraries +#include "LCD.hpp" //Include the header file, this acts like a series of forward declarations + +//Constructor +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) +{} + +LCD::~LCD(){} //Destructor + +void LCD::clock_in(){_E = 1; wait(0.001); _E = 0; wait(0.001); _E = 1;} + +void LCD::Binary_Convert(int Integer){ + +} + + +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();} +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();} +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();} +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();} +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();} + +void LCD::Initialise(){ + Function_Set(); wait(0.020); + Display_Off(); wait(0.020); + Display_Clear(); wait(0.020); + Entry_Mode_Set(); wait(0.020); + Display_On(); wait(0.020); + DDRAM_Address(0); wait(0.020); +} + +void LCD::DDRAM_Address(int Address){ + _RS = 0; + _RW = 0; + _DB7 = 1; + _DB6 = (Address & 0b1000000) >> 6; _DB5 = (Address & 0b0100000) >> 5; _DB4 = (Address & 0b0010000) >> 4; + _DB3 = (Address & 0b0001000) >> 3; _DB2 = (Address & 0b0000100) >> 2; _DB1 = (Address & 0b0000010) >> 1; _DB0 = (Address & 0b0000001) >> 0; + clock_in(); + } + +void LCD::Write_String(string Word){ + int ASCII_Converted; + for (int i = 0; i < Word.length(); i++) + { + ASCII_Converted = Word.at(i); + _RS = 1; _RW = 0; + _DB7 = (ASCII_Converted & 0b10000000) >> 7; _DB6 = (ASCII_Converted & 0b01000000) >> 6; _DB5 = (ASCII_Converted & 0b00100000) >> 5; _DB4 = (ASCII_Converted & 0b00010000) >> 4; + _DB3 = (ASCII_Converted & 0b00001000) >> 3; _DB2 = (ASCII_Converted & 0b00000100) >> 2; _DB1 = (ASCII_Converted & 0b00000010) >> 1; _DB0 = (ASCII_Converted & 0b00000001) >> 0; + clock_in(); + } +} + \ No newline at end of file