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.
Diff: main.cpp
- Revision:
- 79:9d46b0d532e1
- Parent:
- 78:0d905b656132
- Parent:
- 12:6fe33785b0f4
- Child:
- 80:dd2134edd58b
--- a/main.cpp Tue Oct 25 09:11:48 2022 +0000 +++ b/main.cpp Tue Oct 25 09:22:42 2022 +0000 @@ -45,7 +45,9 @@ void TE_LogVoltage(int count); // test funktion that write the woltage each time the battry is checked - +int PitTest(void); // Test if to robot needs to goto pit +void InitialMessages (void); // Prints initial message to the LCD +int PitTest(int gotoPit); int main() { LocalFileSystem local("local"); @@ -63,10 +65,12 @@ float speed = MAX; /*Team 7 Variabels*/ + int gotoPit = 0; // wether or not the robot is heading to pit. Initialstate false. int ccount = 0; //used to count cycles /*Printing secret cat mission*/ + LCD_InitialMessages(); m3pi.sensor_auto_calibrate(); @@ -76,6 +80,7 @@ TE_CreateVoltageLog(); while (1) { + /* If cycle count divided by a constant does not have a rest. test if pit */ if (ccount % CYCLEBEFORETEST == 0 && gotoPit == 0) { @@ -191,14 +196,32 @@ } } + +void InitialMessage(void){ + /*Prints iniatl secret mission*/ + + m3pi.cls(); + m3pi.locate(0,0); + m3pi.printf("eliminate"); + m3pi.locate(0,1); + m3pi.printf("all cats"); + wait(200.0); + + m3pi.cls(); + m3pi.locate(0,0); + m3pi.printf("%f.3 ",m3pi.battery()); + m3pi.locate(0,1); + m3pi.printf("%f.3 ",m3pi.pot_voltage()); + wait(200.0); + m3pi.cls(); +} + /** * PS_BatteryTest - Test the batteri voltage if the robot is not headed for pi * *return: 0 if the battery is above the threshold- Return 1 if the robot needs to goto pit */ - int PS_BatteryTest(void){ -/* Test the batteri voltage if the robot is not headed for pit */ const float BATVOLTTRESHOLD = 0.5; // Treshold i volt int result = 0; @@ -207,6 +230,7 @@ if (m3pi.battery() <= BATVOLTTRESHOLD ){ result = 1; // Set goto pit condition LED_Control(1, 1); + m3pi.cls(); m3pi.locate(0,0); m3pi.printf("Going to"); @@ -350,4 +374,22 @@ fprintf(fptr,"%8d,%8d,%4.4f,%4.4f\n" , timer.read()-startTime, count, m3pi.battery(),m3pi.pot_voltage() ); fclose(fptr); + return result; + +} + +void LED_Control(int ledNumber, int state){ + //LED1 on if robot is looking for pit + if ledNumber == 1{ + DigitalOut led1(state); + } + if ledNumber == 2{ + DigitalOut led1(state); + } + if ledNumber == 3{ + DigitalOut led1(state); + } + if ledNumber == 4{ + DigitalOut led1(state); + } } \ No newline at end of file