The example program for mbed pin-compatible platforms

Dependencies:   mbed

Fork of mbed_blinky by Mbed

MorseCharacter.h

Committer:
vartan
Date:
2014-08-24
Revision:
19:56d79e19eb8d
Parent:
17:3dbf734d2731

File content as of revision 19:56d79e19eb8d:

/**
 * Packed Morse Character
 *
 * Morse Code Sequences have been packed into one byte.
 *
 * Bits 7-5: Octal containing the number of parts (dits or dahs)
 *           If the octal is zero, the morse character is a space.
 *
 * Bits 4:0  Each morse part: 0: DIT
 *                            1: DAH
 * @author  Michael Vartan
 */
class MorseCharacter {
    char mSequence;
    
    const static char numbers[];
    const static char letters[];
    
    public:
        const static char DIT = 0;
        const static char DAH = 1;
        
        MorseCharacter(char character);
        char getPart(int partNumber) const;
        
         /**
         * Get Number of Morse Parts. 
         * 
         * Get bits 7-5 for the number of dits/dahs in the morse sequence.
         */
        inline char getNumberOfParts() const {
            return this->mSequence >> 5;
        }
};