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: mbed DRV88255 TextLCD Ping mbed-rtos
Diff: main.cpp
- Revision:
- 8:24b057cbcb53
- Parent:
- 6:067e999b9c6e
--- a/main.cpp Fri Jun 10 10:53:56 2016 +0000 +++ b/main.cpp Fri Jun 10 12:38:54 2016 +0000 @@ -2,16 +2,49 @@ #include "TemperatureController.h" #include "MotorController.h" #include "LCDController.h" +#include "ProximityController.h" #include "mbed.h" +#include "rtos.h" + +typedef struct Controllers { + TemperatureController *temperature; + SalinityController *salinity; + ProximityController *proximity; + LCDController *lcd; + +} Controllers; + + + +/* + Continuously update controller every 100 ms +*/ +void controller_thread(void const *args) { + Controller *controller = (Controller*)args; + + while(1) { + controller->update(); + Thread::wait(100); + } + +} + int main() { int count; - SalinityController salt; TemperatureController temperature; + Thread t1(controller_thread, (Controller*)&temperature); + + //SalinityController salt; + //Thread t2(controller_thread, (Controller*)&salt); + + + MotorController motor; + // Keep LCD controller outside thread LCDController lcd; // for(int i = 0; i < 20; i++) @@ -19,8 +52,8 @@ // motor.test(); // motor.test2(); // } - lcd.splash(); - while(1) { + //lcd.splash(); + //while(1) { // printf("%d> ", count); // salt.displayPPT(); @@ -29,9 +62,27 @@ // temperature.controlHeater(); - lcd.updateScreen(temperature.getTemperature(),salt.getVoltage()); - count++; + // lcd.updateScreen(temperature.getTemperature(),salt.getVoltage()); + // count++; - wait(0.5); + // wait(0.5); + //} + + float s = 0.0; + float t = 0.0; + + while(1) { + lcd.splash(); + Thread::wait(1000); + + t = temperature.getValue(); + // s=... + + printf("Grabbing temperature value from main thread: %f\r\n", t); + //printf("Grabbing salinity value from main thread: %f\n", salt.getValue()); + + lcd.updateScreen(t, s); + + motor.test(); } } \ No newline at end of file