A little controller that links to a radio to send commands to sailboat.
Dependencies: SLCD- mbed tsi_sensor
Revision 0:dcad18121333, committed 2014-11-19
- Comitter:
- bclaus
- Date:
- Wed Nov 19 18:20:28 2014 +0000
- Commit message:
- Initial;
Changed in this revision
diff -r 000000000000 -r dcad18121333 SLCD-.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SLCD-.lib Wed Nov 19 18:20:28 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/liborgecnuk/code/SLCD-/#f5cc1eb350cf
diff -r 000000000000 -r dcad18121333 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Nov 19 18:20:28 2014 +0000 @@ -0,0 +1,60 @@ +#include "mbed.h" +#include "tsi_sensor.h" +#include "SLCD.h" + +/* This defines will be replaced by PinNames soon */ +#if defined (TARGET_KL25Z) || defined (TARGET_KL46Z) + #define ELEC0 9 + #define ELEC1 10 +#elif defined (TARGET_KL05Z) + #define ELEC0 9 + #define ELEC1 8 +#else + #error TARGET NOT DEFINED +#endif + +DigitalIn s1(PTC3); +DigitalIn s3(PTC12); + +Serial radio(PTE0, PTE1); + +SLCD slcd; + +int main(void) { + PwmOut led(LED_GREEN); + TSIAnalogSlider tsi(ELEC0, ELEC1, 40); + radio.baud(9600); + float controlSail=0; + float controlRudder=0; + + while (true) { + if(!s1){ + slcd.clear(); // All segments off + slcd.Home(); // sets next charater to posistion 0 (start) + controlSail=tsi.readPercentage(); + led = 1.0 - controlSail; + slcd.printf("S%2.2f",controlSail); // standard printf function, only charaters in ASCII_TO_WF_CODIFICATION_TABLE will display + radio.putc('s'); + radio.putc((char)(controlSail*255)); + } + else if(!s3){ + slcd.clear(); // All segments off + slcd.Home(); // sets next charater to posistion 0 (start) + controlRudder=tsi.readPercentage(); + led = 1.0 - controlRudder; + slcd.printf("R%2.2f",controlRudder); // standard printf function, only charaters in ASCII_TO_WF_CODIFICATION_TABLE will display + radio.putc('r'); + radio.putc((char)(controlRudder*255)); + + } + else{ + slcd.clear(); // All segments off + slcd.Home(); // sets next charater to posistion 0 (start) + slcd.putc('R'); // standard printf function, only charaters in ASCII_TO_WF_CODIFICATION_TABLE will display + slcd.CharPosition=3; // x=0 to 3, 0 is start position + slcd.putc('S'); // standard printf function, only charaters in ASCII_TO_WF_CODIFICATION_TABLE will display + + } + wait(0.1); + } +}
diff -r 000000000000 -r dcad18121333 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Nov 19 18:20:28 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/6213f644d804 \ No newline at end of file
diff -r 000000000000 -r dcad18121333 tsi_sensor.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tsi_sensor.lib Wed Nov 19 18:20:28 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/Kojto/code/tsi_sensor/#20ffa9b18488