ok but I needed Morse Code transmitter for my flight simulator it takes input from a database and it chucks it out… easy
so here it is::: 8)
The following function gets the next callsign segment from CallSign and sets it up as a string of Morse Code timer durations in Morse:
// t = ptr to Tx Data structure of stn currently being keyed
SetUpCallSign(struct TxData t){
/ Array letters of the Morse Code alphabet where
the code for each letter is expressed as timer
durations: dot=1, dash = 3 */
char *MorseCode = {
“\3\1”, “\3\1\1\3”, “\3\1\3\1”, “\3\1\1”,
“\1”, “\1\1\3\1”, “\3\3\1”, “\1\1\1\1”,
“\1\1”, “\1\3\3\3”, “\3\1\3”, “\1\3\1\1”,
“\3\3”, “\3\1”, “\3\3\3”, “\1\3\3\1”, “\3\3\1\3”,
“\1\3\1”, “\1\1\1”, “\3”, “\1\1\3”, “\1\1\1\3”,
“\1\3\3”, “\3\1\1\3”, “\3\1\3\3”, “\3\3\1\1”};
char MC, //Morse Code element (dot/dash/gap)
*pMC, //ptr to Morse element in MorseCode
*pC = t->pCallSign, //ptr to start of next callsign segment
*pM = t->pMorse; //ptr to start of stn’s Morse string
if(*pC == ‘\0’) //if we’ve reached end of callsign data
pC = t->CallSign; //reset ptr to start of callsign data
t->Pitch = (int)*pC++; //audio frequency of keying tone
t->Repeat = (int)*pC++; //Nº of times it is to be repeated
if((int delay = (int)*pC++) < 0) //if the delay is negative{
t->Key = TRUE; //set morse key to the on state
delay = -delay; //reverse its sign (make it positive)}
else //if delay is zero or positive
t->Key = FALSE; //set morse key to the off state
/While the next call sign character is not a semicolon
get pointer to next character’s Morse sequence string/
while((char Letter = *pC) != ‘;’) {
pMC = MorseCode + Letter - 65;
//For each Morse element (dot or dash) of the character
while((MC = *pMC++) > ‘\0’) {
*pM++ = MC; //store duration of this Morse element
*pM++ = ‘\1’; //store duration of inter-element pause
}
*–pM = ‘\3’; //overwrite with an inter-letter pause
pC++; //advance to next letter to be translated
}
*pM++ = delay; //overwrite with delay at end of callsign
*pM = ‘\0’; //terminating null for Morse Buffer
t->pCallSign = ++pC; //start of next segment of callsign
}