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: LCDTFT_ssd0139 mbed
main.cpp
00001 #include "mbed.h" 00002 #include "LCDTFT.h" 00003 00004 BusOut MyBus(PTA13,PTD5,PTD4,PTA12,PTA4,PTA5,PTC8,PTC9); // 8 bit bus on these dvices 00005 LCDTFT MyLCD(PTB0,PTB1,PTB2,PTB3,PTC2,&MyBus); //LCDTFT(PinName PIN_RD,PinName PIN_WR,PinName PIN_RS,PinName PIN_CS,PinName PIN_RESET, BusOut *BUSLCD); 00006 00007 DigitalOut myled(LED1); // define status LED 00008 Serial infoin(PTE0,PTE1); // define serial 00009 Serial pc(USBTX,USBRX); // for use with pc terminal 00010 DigitalOut unlock(PTB8); // flag pin to output to locker 00011 DigitalIn doorOpen(PTB9); // flag pin for input from locker 00012 00013 int Rawl = 22319109; //define two integers to associate the tagnumbers with people 00014 int Fish = 22312052; 00015 int tagNumber; 00016 00017 char c; 00018 int i; 00019 00020 //define required flags and initialize floats for te weather data. 00021 00022 float temperature = 45; 00023 float light = 100; 00024 float pressure; 00025 float humidity; 00026 char message[20]; 00027 00028 00029 int main() { 00030 unlock =1; // send a high level to the locker 00031 MyLCD.vLCDTFTInit(1); // sets LCD to landscape mode 00032 MyLCD.vLCDTFTFillScreen(Cyan); 00033 00034 MyLCD.vLCDTFTLine(0,120,320,120,Black); // separates weather data from RFID info 00035 00036 MyLCD.vLCDTFTSetParametersPrintf(5,130,0,320,2,Black,Cyan); // display labels for all time FOREVER 00037 MyLCD.printf("Temperature:"); 00038 00039 MyLCD.vLCDTFTSetParametersPrintf(5,160,0,320,2,Black,Cyan); 00040 MyLCD.printf("Humidity:"); 00041 00042 MyLCD.vLCDTFTSetParametersPrintf(5,190,0,320,2,Black,Cyan); 00043 MyLCD.printf("Light:"); 00044 00045 MyLCD.vLCDTFTSetParametersPrintf(5,220,0,320,2,Black,Cyan); 00046 MyLCD.printf("Pressure:"); 00047 00048 00049 00050 00051 00052 while(1) { 00053 00054 if(doorOpen == 1){ // prints to terminal when door is open - for use later 00055 pc.printf("Door is Open"); 00056 } 00057 00058 if(infoin.readable()) { // if serial bus has data, read it character by character 00059 c=infoin.getc(); 00060 message[i] = c; // store in character array 'message' 00061 i++; 00062 00063 if(c=='a'){ //if the first letter is a, we're getting an RFID 00064 i=0; 00065 } 00066 00067 if(c=='A'){ //if we get 'A', we reach the end of the RFID 00068 MyLCD.vLCDTFTSetParametersPrintf(5,5,0,320,3,Fuchsia,Cyan); 00069 MyLCD.printf("Welcome, "); 00070 sscanf(message,"%d",&tagNumber); // save tagNumber as integer 00071 if(tagNumber == Fish) MyLCD.printf("Lew"); // match tagNumber to Name 00072 if(tagNumber == Rawl) MyLCD.printf("Tom"); 00073 00074 i=0; 00075 00076 unlock = 0; // send pulse to locker 00077 wait(0.2); 00078 unlock = 1; 00079 } 00080 00081 00082 00083 //Here begin the if statements for weather data 00084 00085 if ( c == 'l') { // start of light data 00086 i = 0; 00087 } 00088 00089 if ( c == 'L') { // end of light data 00090 00091 MyLCD.vLCDTFTSetParametersPrintf(5,190,0,320,2,Black,Cyan); 00092 00093 sscanf(message,"%f",&light); // convert string to float 00094 MyLCD.printf("Light: %5.2f",light); 00095 00096 MyLCD.vLCDTFTRectangle(260,190,315,200,1,Cyan); // needed to clear the visuals 00097 00098 if(light>0) MyLCD.vLCDTFTCircle(265,195,5,1,Yellow); // if statements for number of suns 00099 00100 if(light>25) MyLCD.vLCDTFTCircle(280,195,5,1,Yellow); 00101 00102 if(light>50) MyLCD.vLCDTFTCircle(295,195,5,1,Yellow); 00103 00104 if(light>75) MyLCD.vLCDTFTCircle(310,195,5,1,Yellow); 00105 00106 00107 i=0; 00108 wait(1); 00109 } 00110 00111 if ( c == 't') { // start of temperature data 00112 i = 0; 00113 } 00114 00115 if ( c == 'T') { // end of temperature data 00116 00117 MyLCD.vLCDTFTSetParametersPrintf(5,130,0,320,2,Black,Cyan); 00118 00119 sscanf(message,"%f",&temperature); // convert string to float 00120 MyLCD.printf("Temperature: %5.2f",temperature); 00121 00122 MyLCD.vLCDTFTRectangle(260,130,315,140,1,Cyan); // needed to clear visuals 00123 00124 if(temperature>0) MyLCD.vLCDTFTRectangle(260,130,270,140,1,Lime); // if statements for temperature bar 00125 00126 if(temperature>10) MyLCD.vLCDTFTRectangle(275,130,285,140,1,Yellow); 00127 00128 if(temperature>20) MyLCD.vLCDTFTRectangle(290,130,300,140,1,Orange); 00129 00130 if(temperature>30) MyLCD.vLCDTFTRectangle(305,130,315,140,1,Red); 00131 00132 i=0; 00133 wait(1); 00134 } 00135 00136 if ( c == 'p') { // start of pressure data 00137 i = 0; 00138 } 00139 00140 if ( c == 'P') { // end of pressure data 00141 00142 MyLCD.vLCDTFTSetParametersPrintf(5,220,0,320,2,Black,Cyan); 00143 00144 sscanf(message,"%f",&pressure); // convert string to float 00145 MyLCD.printf("Pressure: %5.2f",pressure); 00146 00147 00148 i=0; 00149 wait(1); 00150 } 00151 00152 if ( c == 'h') { // start of humidity data 00153 i = 0; 00154 } 00155 00156 if ( c == 'H') { // end of humidity data 00157 00158 MyLCD.vLCDTFTSetParametersPrintf(5,160,0,320,2,Black,Cyan); 00159 00160 sscanf(message,"%f",&humidity); // convert string to float 00161 MyLCD.printf("Humidity: %5.2f",humidity); 00162 00163 //MyLCD.printf("\n\r"); 00164 i=0; 00165 wait(1); 00166 } 00167 00168 } 00169 00170 } 00171 }
Generated on Fri Jul 15 2022 15:28:29 by
1.7.2