The example program for mbed pin-compatible platforms
Fork of mbed_blinky by
Diff: main.cpp
- Revision:
- 11:87bc5f44dcfa
- Parent:
- 9:9088b8a51286
- Child:
- 17:3dbf734d2731
--- a/main.cpp Sun Aug 24 02:24:07 2014 +0000 +++ b/main.cpp Sun Aug 24 02:27:17 2014 +0000 @@ -1,7 +1,5 @@ #include "mbed.h" #include "MorseCharacter.h" - -//#include <string> DigitalOut morseOut(LED1); int main() { @@ -9,13 +7,14 @@ char outputLength = strlen(output); char strpos = 0; float timeUnit = 0.092f; - while(strpos < outputLength) { + while(strpos < outputLength) { // for each character in string MorseCharacter morseChar(output[strpos]); - char size = morseChar.getNumberOfParts(); - if(size>0) { - for(int i=0;i<size;i++) { + char morseParts = morseChar.getNumberOfParts(); + if(morseParts > 0) { + for(int i=0; i < morseParts; i++) { morseOut = 1; - wait((morseChar.getPart(i)==morseChar.DIT?1:3) * timeUnit); + // wait 3 time units for a dah, 1 time unit for a dit + wait((morseChar.getPart(i) == morseChar.DIT ? 1 : 3) * timeUnit); morseOut = 0; wait(1*timeUnit); // time between dits/dahs is 1 time unit. } @@ -28,11 +27,9 @@ // character was sent. } strpos++; - if(strpos == outputLength) { + if(strpos == outputLength) { // if message is over, wait(5.0f); // wait 5 seconds strpos = 0; // start over; } } - - while(1) {} }