The example program for mbed pin-compatible platforms

Dependencies:   mbed

Fork of mbed_blinky by Mbed

main.cpp

Committer:
vartan
Date:
2014-08-24
Revision:
9:9088b8a51286
Parent:
8:ec3e22e9100e
Child:
11:87bc5f44dcfa

File content as of revision 9:9088b8a51286:

#include "mbed.h"
#include "MorseCharacter.h"

//#include <string>
DigitalOut morseOut(LED1);

int main() {
    char* output = "Hello World";
    char outputLength = strlen(output);
    char strpos = 0;
    float timeUnit = 0.092f;
    while(strpos < outputLength) {
        MorseCharacter morseChar(output[strpos]);
        char size = morseChar.getNumberOfParts();
        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.
        }
        strpos++;
        if(strpos == outputLength) {
            wait(5.0f); // wait 5 seconds
            strpos = 0; // start over;
        }
    }
    
    while(1) {}
}