Last active
August 29, 2015 13:58
-
-
Save ibanezmatt13/10011523 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void loop(){ | |
// continuously updating individual telemetry fields | |
if (sentence_needed == true){ | |
sprintf(buffer, "%s, %d, %s .. ", callsign, sentence_id, latitude ..); // store all telemetry in buffer | |
*ptr = buffer; // set data at location being pointed to, to the buffer | |
} | |
} | |
ISR(Timer1_vect){ | |
switch (tx_status){ | |
case 0: // when the next byte needs to be gotten | |
if (ptr){ // if the pointer is valid | |
if (currentbyte){ // if there exists a byte at the pointer | |
tx_status = 1; | |
sentence_needed = False; | |
} | |
else { | |
sentence_needed = true; | |
break; | |
} | |
} | |
else { | |
sentence_needed = true; | |
break; | |
} | |
case 1: // first bit about to be sent | |
rtty_txbit(0); // send start bit | |
tx_status = 2; | |
currentbitcount = 1; // set bit count to 0 ready for incrementing to 7 for last bit of a ASCII-7 byte | |
break; | |
case 2: // normal status, transmitting bits of byte (including first and last) | |
rtty_txbit(currentbyte & 1); // transmit the bit, 1 or 0 appropriately | |
if (currentbitcount == 7){ // if we've just transmitted the final bit of the byte | |
tx_status = 3; | |
} | |
currentbyte = currentbyte >> 1; // shift all bits in byte 1 to right so next bit is LSB | |
currentbitcount++; | |
break; | |
case 3: // if all bits have been transmitted and we need to send the first of two stop bits | |
rtty_txbit(1); // send first stop bit | |
tx_status = 4; | |
break; | |
case 4: // ready to send the last of two stop bits | |
rtty_txbit(1); // send the final stop bit | |
ptr++; // increment the pointer for reading next byte in buffer | |
tx_status = 0; | |
break; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment