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: N5110WN PowerControl SRF02 mbed
Diff: main.cpp
- Revision:
- 2:a1eaa4d74b63
- Parent:
- 1:7f151ab172cb
- Child:
- 3:00933efbe463
--- a/main.cpp Fri Mar 20 11:46:08 2015 +0000
+++ b/main.cpp Fri Mar 20 17:25:39 2015 +0000
@@ -17,7 +17,21 @@
char buffer[30]; // buffer used to store time string
set_time(1427846400); // initialise time to 1st April 2015 00:00:00
-
+
+ BLED.period(0.02); //sets the frequency of the Backlight at 50Hz
+ lcd.init(); //to initilize the display
+ checkerBoard();
+ wait(0.2);
+ lcd.clear();
+
+ introTune(); // plays the intro tune
+ lcd.printString("Parking",20,0);
+ lcd.printString("Sensor",6,1);
+ lcd.printString("by",35,2);
+ lcd.printString("Jakobi",24,3);
+ lcd.printString("Blackburn",16,4);
+ wait(0.2);
+ lcd.clear();
while(1) {
if(timerFlag){
@@ -25,11 +39,11 @@
time_t seconds = time(NULL); // get current time
// format time into a string (time and date)
strftime(buffer, 30 , "%d/%m/%y %R", localtime(&seconds));
- float dist = getDistance(); //reads the temperature and sets it to a float value.
+ float dist = getDistance(); //reads the distance and sets it to a float value.
//prints the value to the serial port.
- if(unitX==0.01){pc.printf("@ %s , Distance = %.2f m \n",buffer,dist*unitX);}//prints the value to the serial port.
- else if(unitX==1){pc.printf("@ %s , Distance = %.0f cm \n",buffer,dist*unitX);}//prints the value to the serial port.
- else if(unitX==10){pc.printf("@ %s , Distance = %.0f mm \n",buffer,dist*unitX);}//prints the value to the serial port.
+ if(state==1){pc.printf("%s , Distance = %.2f %s \n",buffer,dist*unitX,units);}//prints the value to the serial port.
+ else if(state !=1){pc.printf("%s , Distance = %.0f %s \n",buffer,dist*unitX,units);}//prints the value to the serial port.
+
leds=15;
logging(buffer,dist);
leds=0;
@@ -38,6 +52,7 @@
setTimeFlag = 0; // clear flag
setTime(); // update time
}
+ Sleep();
}
}
@@ -81,10 +96,10 @@
void unitToggle(){
state = fsm[state].nextState[UnitTog]; // read input and update current state
unitX = fsm[state].unitMultiple; // set output depending on current state
-// units= fsm[state].Unit; //
+ units= fsm[state].Unit; //
wait(0.2);
pc.printf("unit multiple = %.2f \n",unitX);
- // pc.printf("Units = %s \n",units);
+ pc.printf("Units = %s \n",units);
}
@@ -155,4 +170,31 @@
pc.gets(rxString,16);
// set flag
setTimeFlag = 1;
+}
+
+void introTune()
+{
+ Buzzer.PlayNote(1319.0,0.084,1.0);
+ wait(0.01);
+ Buzzer.PlayNote(1319.0,0.084,1.0);
+ wait(0.094);
+ Buzzer.PlayNote(1319.0,0.084,1.0);
+ wait(0.094);
+ Buzzer.PlayNote(1047.0,0.084,1.0);
+ wait(0.01);
+ Buzzer.PlayNote(1319.0,0.084,1.0);
+ wait(0.094);
+ Buzzer.PlayNote(1568.0,0.084,1.0);
+ wait(0.26);
+ Buzzer.PlayNote(784.0,0.084,1.0);
+}
+
+void checkerBoard() // creates a checked pattern on the lcd
+{
+ for(int i=0; i<84; i+=2) {
+ for(int j=0; j<48; j+=2) {
+ lcd.setPixel(i,j);
+ }
+ }
+ lcd.refresh();
}
\ No newline at end of file