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.
LCDs.cpp
00001 #include "mbed.h" 00002 #include "LCDs.h" 00003 #include <string> 00004 00005 DigitalOut rs(PA_6); 00006 DigitalOut en(PB_6); 00007 DigitalOut rw(PA_7); 00008 DigitalOut db0(PC_7); 00009 DigitalOut db1(PA_9); 00010 DigitalOut db2(PA_8); 00011 DigitalOut db3(PB_10); 00012 DigitalOut db4(PB_4); 00013 DigitalOut db5(PB_5); 00014 DigitalOut db6(PB_3); 00015 DigitalInOut db7(PA_10); 00016 00017 LCDs::LCDs() 00018 {} 00019 00020 void LCDs::lcdinit() 00021 { 00022 db7.output(); 00023 db7=0; 00024 en=0; 00025 wait_ms(250); 00026 } 00027 00028 void LCDs::putString(string disp) 00029 { 00030 for(int j = 0; j < disp.length(); j++) 00031 { 00032 if(j==16) 00033 lcdcmd(0xC0); 00034 putData((unsigned char)disp.at(j)); 00035 rs=1; 00036 rw=0; 00037 en=1; 00038 wait_ms(1); 00039 en=0; 00040 lcdReady(); 00041 } 00042 } 00043 00044 void LCDs::lcdReady() 00045 { 00046 db7.input(); 00047 rs=0; 00048 rw=1; 00049 do 00050 { 00051 en=1; 00052 wait_ms(1); 00053 en=0; 00054 }while(db7==1); 00055 db7.output(); 00056 } 00057 00058 void LCDs::putData(unsigned char value) 00059 { 00060 unsigned char newValue = value; 00061 for(int i = 0; i<=7; i++) 00062 { 00063 newValue = value>>i; 00064 newValue = newValue & 0x01; 00065 switch(i) 00066 { 00067 case 0: 00068 db0=(int)newValue; 00069 break; 00070 case 1: 00071 db1=(int)newValue; 00072 break; 00073 case 2: 00074 db2=(int)newValue; 00075 break; 00076 case 3: 00077 db3=(int)newValue; 00078 break; 00079 case 4: 00080 db4=(int)newValue; 00081 break; 00082 case 5: 00083 db5=(int)newValue; 00084 break; 00085 case 6: 00086 db6=(int)newValue; 00087 break; 00088 case 7: 00089 db7=(int)newValue; 00090 break; 00091 default: 00092 break; 00093 } 00094 } 00095 } 00096 00097 void LCDs::lcdcmd(unsigned char value) 00098 { 00099 putData(value); 00100 rs=0; 00101 rw=0; 00102 en=1; 00103 wait_ms(1); 00104 en=0; 00105 lcdReady(); 00106 }
Generated on Fri Jul 15 2022 03:01:38 by
1.7.2