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.
interface.cpp
00001 #include "mbed.h" 00002 #include "Keepad.h" 00003 #include "LCDs.h" 00004 //#include "Decoder.h" 00005 #include "steps.h" 00006 #include "interface.h" 00007 00008 interface::interface(){} 00009 00010 void interface::startup() 00011 { 00012 LCDs lcd; 00013 lcd.lcdcmd(0x01); 00014 lcd.putString(" IRRIGATION SYSTEM STARTED"); 00015 wait_ms(2000); 00016 lcd.lcdcmd(0x01); 00017 } 00018 00019 char interface::scr1cnt() 00020 { 00021 int k1=0; 00022 char at = 'z'; 00023 screen1(); 00024 steps s; 00025 while(k1!=11 && k1!=21 && k1!=31) 00026 { 00027 k1 = keyInp(); 00028 } 00029 int r = s.step1(k1); 00030 k1=0; 00031 while(k1==0) 00032 { 00033 k1 = keyInp(); 00034 if( k1 == 33) 00035 screen1(); 00036 else if( k1 == 21 && r==1) 00037 screenManual(); 00038 else if( k1 == 11 && r==1) 00039 { 00040 at = screenAuto(); 00041 if(at=='s') 00042 scr1cnt(); 00043 } 00044 else 00045 k1=0; 00046 } 00047 return(at); 00048 } 00049 00050 void interface::screen1() 00051 { 00052 LCDs lcd2; 00053 lcd2.lcdcmd(0x01); 00054 lcd2.putString("PRESS: 1->MODES 2->TEMP 3->MOIST"); 00055 } 00056 00057 void interface::screenManual() 00058 { 00059 int k4=0; 00060 LCDs lcd3; 00061 lcd3.lcdcmd(0x01); 00062 lcd3.putString("Enter Irrigationtime (min): >>>"); 00063 while( k4 != 41) 00064 { 00065 k4 = keyInp(); 00066 if(k4==34) 00067 scr1cnt(); 00068 } 00069 lcd3.lcdcmd(0x01); 00070 string k3 = convNum(); 00071 lcd3.lcdcmd(0x01); 00072 lcd3.putString(k3); 00073 } 00074 00075 int interface::screenAuto() 00076 { 00077 int k3=0; 00078 LCDs lcd4; 00079 lcd4.lcdcmd(0x01); 00080 lcd4.putString("Enter crop :"); 00081 lcd4.lcdcmd(0xC0); 00082 lcd4.putString(">Press Right Key"); 00083 while( k3 != 41) 00084 { 00085 k3 = keyInp(); 00086 if(k3==34) 00087 scr1cnt(); 00088 } 00089 lcd4.lcdcmd(0x01); 00090 lcd4.putString("1.Wheat 2.Maize"); 00091 lcd4.lcdcmd(0xC0); 00092 lcd4.putString("3.Onion 4.Potato"); 00093 k3=0; 00094 while(k3==0) 00095 { 00096 k3 = keyInp(); 00097 if( k3 == 11) 00098 { 00099 //Wheat(); 00100 return('w'); 00101 } 00102 else if( k3 == 21) 00103 { 00104 //Maize(); 00105 return('m'); 00106 } 00107 else if( k3 == 31) 00108 { 00109 //Onion(); 00110 return('o'); 00111 } 00112 else if( k3 == 12) 00113 { 00114 //Potato(); 00115 return('p'); 00116 } 00117 else if( k3 == 34) 00118 return('s'); 00119 else 00120 k3=0; 00121 } 00122 return('z'); 00123 } 00124 00125 int interface::keyInp() 00126 { 00127 int kp=0; 00128 Keepad kpd; 00129 while(kp==0){ 00130 kp=0; 00131 kp=kpd.keypad(); 00132 } 00133 return(kp); 00134 } 00135 00136 string interface::convNum() 00137 { 00138 int cv[10]; 00139 int i = 0, j = 0, sum = 0; 00140 while(j != 34) 00141 { 00142 j = keyInp(); 00143 switch(j) 00144 { 00145 case 11: 00146 cv[i] = 1; 00147 break; 00148 case 21: 00149 cv[i] = 2; 00150 break; 00151 case 31: 00152 cv[i] = 3; 00153 break; 00154 case 12: 00155 cv[i] = 4; 00156 break; 00157 case 22: 00158 cv[i] = 5; 00159 break; 00160 case 32: 00161 cv[i] = 6; 00162 break; 00163 case 13: 00164 cv[i] = 7; 00165 break; 00166 case 23: 00167 cv[i] = 8; 00168 break; 00169 case 24: 00170 cv[i] = 9; 00171 break; 00172 case 14: 00173 cv[i] = 0; 00174 break; 00175 default: 00176 break; 00177 } 00178 i++; 00179 } 00180 j=1; 00181 i=i-2; 00182 sum = cv[i]; 00183 for(int t = 1; t <= i; t++) 00184 { 00185 j=j*10; 00186 } 00187 00188 for(int tv = 0; tv <i; tv++) 00189 { 00190 sum = sum + (cv[tv]*j); 00191 j=j/10; 00192 } 00193 00194 char dis[16]; 00195 sprintf(dis,"%d",sum); 00196 return(dis); 00197 }
Generated on Fri Jul 15 2022 03:01:38 by
1.7.2