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.
Fork of Final351CW_FINAL by
lglcd.cpp
00001 /* ELEC351 COURSEWORK 2018 00002 DESIGNED USING MBED ONLINE COMPILER IMPORTED TO KEIL 00003 LIAM GRAZIER // DOUG TILLEY // ALEX BARON 00004 */ 00005 #include "mbed.h" 00006 #include "lglcd.h" 00007 lglcd::lglcd(PinName RS, PinName E, PinName D4, PinName D5,PinName D6, PinName D7) : _lcdrs(RS),_lcde(E), _lcdinfo(D4, D5, D6, D7) 00008 { 00009 _lcde=1; //clear enable 00010 _lcdrs=0; // command 00011 writedata(_lcde,CMD); 00012 wait(0.000004); 00013 writedata(0x28,CMD); 00014 wait(0.000004); 00015 writedata(0x0C,CMD); //turnoncursor and blink 00016 wait(0.000004); 00017 writedata(0x10,CMD); 00018 wait(0.000004); 00019 LCD_CLR; //clearlcd 00020 wait(0.000004); 00021 writedata(0x06,CMD); //movecursor right 00022 wait(0.000004); 00023 LCD_HOME; //Return to the 0,0 00024 } 00025 void lglcd::clear(void)//lcd clear command with a tiny wait to ensure commadn finishes 00026 { 00027 LCD_CLR; //clearcommandwitha small wait 00028 wait(0.002); 00029 } 00030 void lglcd::setline(int row,int column) //set lu=ine and column function 00031 { 00032 if(row == 1) 00033 { 00034 writedata(LINE1|column,CMD); //line1 included 00035 wait(0.005); 00036 } 00037 if(row == 2) 00038 { 00039 writedata(LINE2|column,CMD); 00040 wait(0.005); 00041 } 00042 } 00043 void lglcd::writedata(unsigned char data, unsigned char type) //manual write data wherever the pointer is , requires the line to be set first . 00044 { 00045 if(type == CMD) 00046 { 00047 _lcdrs=0; //COMMAND MODE 00048 } 00049 else 00050 { 00051 _lcdrs=1; //CHARACTER/DATA MODE 00052 } 00053 _lcdinfo = data >> 4; 00054 wait(0.000050f); 00055 _lcde = 0; 00056 wait(0.000050f); 00057 _lcde = 1; 00058 _lcdinfo = data >> 0; 00059 wait(0.000050f); 00060 _lcde = 0; 00061 wait(0.000050f); 00062 _lcde = 1; 00063 } 00064 void lglcd::write(char charq[]) //write character, not used, used writedata mainly, this works well if need to write along string to 2 lines (FOR LOOP FOR CHANING LINE AUTO) 00065 { 00066 for (int n = 0; n < strlen(charq); n++) 00067 { 00068 int count = 0; 00069 count++; 00070 writedata(charq[n], TXT); 00071 if (n == 15) 00072 { 00073 writedata(LINE2 | 0, CMD); 00074 } 00075 if (n == 32) 00076 { 00077 clear(); 00078 writedata(LINE1, CMD); 00079 } 00080 } 00081 }
Generated on Mon Jul 18 2022 05:40:54 by
1.7.2
