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: main.cpp
- Revision:
- 4:2759062f4264
- Parent:
- 3:6ee7c8ce0b7a
--- a/main.cpp Wed Dec 27 16:12:38 2017 +0000 +++ b/main.cpp Wed Dec 27 18:26:50 2017 +0000 @@ -1,78 +1,23 @@ #include "mbed.h" #include <string> +#include "LCD.hpp" DigitalOut myled(LED1); -DigitalOut RS(D9); +/*DigitalOut RS(D9); DigitalOut RW(D4); DigitalOut E(D8); -BusInOut DB(A0, A1, A2, A3, D7, D6, D3, D1); //LSB First +BusInOut DB(A0, A1, A2, A3, D7, D6, D3, D1); //LSB First*/ -void clock_in(); -void Function_Set(); -void Display_Off(); -void Display_Clear(); -void Entry_Mode_Set(); -void Display_On(); -void DDRAM_Address(int Address); -void Write_Data(string Letter); -void Write_String(string Word); -void Initialise(); +LCD lcd(D8,D9,D4,A0,A1,A2,A3,D7,D6,D3,D1); int main() { - DB.output(); - Initialise(); + lcd.Initialise(); - DDRAM_Address(0x40); - Write_String("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); + lcd.DDRAM_Address(0x00); + lcd.Write_String("2017_12_27 18:22"); } -void clock_in(){E = 1; wait(0.001); E = 0; wait(0.001); E = 1;} -void Function_Set(){RS = 0; RW = 0; DB = 0x3C; clock_in();} - -void Display_Off(){RS = 0; RW = 0; DB = 0x08; clock_in();} - -void Display_Clear(){RS = 0; RW = 0; DB = 0x01; clock_in();} - -void Entry_Mode_Set(){RS = 0; RW = 0; DB = 0x06; clock_in();} - -void Display_On(){RS = 0; RW = 0; DB = 0x0F; clock_in();} - -void 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 DDRAM_Address(int Address){RS = 0; RW = 0; DB = 0x80 + Address; clock_in();} - -void Write_Data(string Letter){ - int ASCII_Converted[32]; - for (int i = 0; i < Letter.length(); i++) - { - ASCII_Converted[i] = Letter.at(i); - } - RS = 1; RW = 0; DB = ASCII_Converted[0]; clock_in(); -} - -void Write_String(string Word){ - - int ASCII_Converted; - for (int i = 0; i < Word.length(); i++) - { - ASCII_Converted = Word.at(i); - RS = 1; RW = 0; DB = ASCII_Converted; clock_in(); - } -}