The example program for mbed pin-compatible platforms
Fork of mbed_blinky by
Diff: main.cpp
- Revision:
- 8:ec3e22e9100e
- Parent:
- 7:b1e0b6f381ba
- Child:
- 9:9088b8a51286
--- a/main.cpp Sun Aug 24 01:47:19 2014 +0000 +++ b/main.cpp Sun Aug 24 02:12:15 2014 +0000 @@ -1,29 +1,36 @@ #include "mbed.h" #include "MorseCharacter.h" -#include <string> +//#include <string> DigitalOut morseOut(LED1); int main() { - std::string output = "Hello World"; + char* output = "HELLO WORLD"; + char strlen = 11; char strpos = 0; float timeUnit = 0.092f; - while(1) { + while(strpos < strlen) { MorseCharacter morseChar(output[strpos]); char size = morseChar.getNumberOfParts(); - for(int i=0;i<size;i++) { - morseOut = 1; - wait((morseChar.getPart(i)==morseChar.DIT?1:3) * timeUnit); - morseOut = 0; - wait(1*timeUnit); + if(size>0) { + for(int i=0;i<size;i++) { + morseOut = 1; + wait((morseChar.getPart(i)==morseChar.DIT?1:3) * timeUnit); + morseOut = 0; + wait(1*timeUnit); // time between dits/dahs is 1 time unit. + } + wait(timeUnit*2); // time between letters is 3 time units. + // there should already be 1 time unit after the + // last dit/dah. + } else { + wait(timeUnit * 4); // time between words is 7 time units. + // there should be 3 time units after the last + // character was sent. } - wait(timeUnit*3); - /*if(size==0) { - wait(timeUnit*3); - } else { - for( - }*/ - //wait(0.2); - //strpos = (strpos + 1) % (sizeof(output)-1); + strpos++; + //strpos = (strpos + 1) % strlen; + } + + while(1) {} }