|
|
@ -15,19 +15,19 @@ uint8_t ee_WpMBpM EEMEM = 0; // WpM oder BpM Anzeige
|
|
|
|
uint8_t ee_Reverse EEMEM = 0; // linkes/rechtes Paddle vertauschen
|
|
|
|
uint8_t ee_Reverse EEMEM = 0; // linkes/rechtes Paddle vertauschen
|
|
|
|
uint8_t ee_SpeedRatioEnabled EEMEM = 0; // Ratio von der Geschwindigkeit abhängig
|
|
|
|
uint8_t ee_SpeedRatioEnabled EEMEM = 0; // Ratio von der Geschwindigkeit abhängig
|
|
|
|
uint8_t ee_Ratio EEMEM = 30; // Punkt/Strich Verhältnis 1:3
|
|
|
|
uint8_t ee_Ratio EEMEM = 30; // Punkt/Strich Verhältnis 1:3
|
|
|
|
|
|
|
|
uint8_t ee_Weight EEMEM = 50; // Punkt/Strich Gewichtung
|
|
|
|
uint8_t ee_Memory EEMEM = 0; // Punkt/Strich Speicher
|
|
|
|
uint8_t ee_Memory EEMEM = 0; // Punkt/Strich Speicher
|
|
|
|
uint16_t ee_SidetoneFreq EEMEM = 600; // Frequenz des Mithörtons
|
|
|
|
uint16_t ee_SidetoneFreq EEMEM = 600; // Frequenz des Mithörtons
|
|
|
|
uint8_t ee_WpM EEMEM = 12; // Geschwindigkeit WpM
|
|
|
|
uint8_t ee_WpM EEMEM = 12; // Geschwindigkeit WpM
|
|
|
|
uint8_t ee_RiseTime EEMEM = 5; // Anstiegszeit Sinuston
|
|
|
|
uint8_t ee_RiseTime EEMEM = 5; // Anstiegszeit Sinuston
|
|
|
|
uint8_t ee_RiseTimeCounter EEMEM = 5; // Anzahl Sinusschwingungen für den Anstieg
|
|
|
|
uint8_t ee_RiseTimeCounter EEMEM = 5; // Anzahl Sinusschwingungen für den Anstieg
|
|
|
|
uint8_t ee_DebounceTime EEMEM = 6; // Entprellzeit für Straight Key Eingang
|
|
|
|
uint8_t ee_DebounceTime EEMEM = 6; // Entprellzeit für Straight Key Eingang
|
|
|
|
// Stringkonstanten für VT100 Terminals
|
|
|
|
//
|
|
|
|
const char CLRSCR[] = "\033[2J";
|
|
|
|
//
|
|
|
|
|
|
|
|
/** @fn void DelayMilliSeconds(uint16_t ms)
|
|
|
|
/** @brief Ein paar Millisekunden warten
|
|
|
|
* @brief Zeitschleife von 1-65535 Millisekunden
|
|
|
|
*
|
|
|
|
* @param Anzahl Millisekunden
|
|
|
|
* @param Zeit in Millisekunden, die gewartet werden soll
|
|
|
|
* @return none
|
|
|
|
* @return void
|
|
|
|
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
void DelayMilliSeconds(uint16_t ms)
|
|
|
|
void DelayMilliSeconds(uint16_t ms)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -39,12 +39,13 @@ void DelayMilliSeconds(uint16_t ms)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ctr = t_delayms;
|
|
|
|
ctr = t_delayms;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CheckPaddles();
|
|
|
|
} while (ctr < ms);
|
|
|
|
} while (ctr < ms);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/** @brief Wert des Zählers für Millisekunden lesen
|
|
|
|
/** @fn uint16_t GetMilliSeconds(void)
|
|
|
|
*
|
|
|
|
* @brief Zäherwert für Zeitschleifen auslesen
|
|
|
|
* @param none
|
|
|
|
* @param none
|
|
|
|
* @return milliseconds
|
|
|
|
* @return Millisekunden
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
uint16_t GetMilliSeconds(void)
|
|
|
|
uint16_t GetMilliSeconds(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -55,8 +56,8 @@ uint16_t GetMilliSeconds(void)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ctr;
|
|
|
|
return ctr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/** @brief Setzt den Zähler für Millisekunden auf 0
|
|
|
|
/** @fn void ResetMilliSeconds(void)
|
|
|
|
*
|
|
|
|
* @brief Setzt den Millisekundenzähler für Zeitschleifen auf 0
|
|
|
|
* @param none
|
|
|
|
* @param none
|
|
|
|
* @return none
|
|
|
|
* @return none
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -67,7 +68,8 @@ void ResetMilliSeconds(void)
|
|
|
|
t_delayms = 0;
|
|
|
|
t_delayms = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/** @brief SREG wieder herstellen und Interrupts erlauben
|
|
|
|
/** @fn void IntEnable(void)
|
|
|
|
|
|
|
|
* @brief Register wieder herstellen und Interrupts erlauben
|
|
|
|
* @param none
|
|
|
|
* @param none
|
|
|
|
* @return none
|
|
|
|
* @return none
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -76,7 +78,8 @@ void IntEnable(void)
|
|
|
|
SREG = sreg_tmp;
|
|
|
|
SREG = sreg_tmp;
|
|
|
|
sei();
|
|
|
|
sei();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/** @brief SREG sichern und Interrupts verbieten
|
|
|
|
/** @fn void IntDisable(void)
|
|
|
|
|
|
|
|
* @brief Register sichern und Interrupts verbieten
|
|
|
|
* @param none
|
|
|
|
* @param none
|
|
|
|
* @return none
|
|
|
|
* @return none
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -85,23 +88,8 @@ void IntDisable(void)
|
|
|
|
sreg_tmp = SREG;
|
|
|
|
sreg_tmp = SREG;
|
|
|
|
cli();
|
|
|
|
cli();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/** @brief Pin Change Interrupt abschalten
|
|
|
|
/** @fn void WriteEEprom(void)
|
|
|
|
* @param none
|
|
|
|
* @brief Akt. Einstellungen in EEPROM schreiben
|
|
|
|
* @return none
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
void DisablePinChangeIRQ(void)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
cbi(PCICR,PCIE2);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @brief Pin Change Interrupt einschalten
|
|
|
|
|
|
|
|
* @param none
|
|
|
|
|
|
|
|
* @return none
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
void EnablePinChangeIRQ(void)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
sbi(PCICR,PCIE2);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @brief EEPROM schreiben
|
|
|
|
|
|
|
|
* @param none
|
|
|
|
* @param none
|
|
|
|
* @return none
|
|
|
|
* @return none
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -117,6 +105,7 @@ void WriteEEprom(void)
|
|
|
|
eeprom_write_byte(&ee_WpMBpM, bConfig.WpMBpM);
|
|
|
|
eeprom_write_byte(&ee_WpMBpM, bConfig.WpMBpM);
|
|
|
|
eeprom_write_byte(&ee_Reverse, bConfig.Reverse);
|
|
|
|
eeprom_write_byte(&ee_Reverse, bConfig.Reverse);
|
|
|
|
eeprom_write_byte(&ee_SpeedRatioEnabled, bConfig.SpeedRatioEnabled);
|
|
|
|
eeprom_write_byte(&ee_SpeedRatioEnabled, bConfig.SpeedRatioEnabled);
|
|
|
|
|
|
|
|
eeprom_write_byte(&ee_Weight, bConfig.Weight);
|
|
|
|
eeprom_write_byte(&ee_Ratio, bConfig.Ratio);
|
|
|
|
eeprom_write_byte(&ee_Ratio, bConfig.Ratio);
|
|
|
|
eeprom_write_byte(&ee_Memory, bConfig.Memory);
|
|
|
|
eeprom_write_byte(&ee_Memory, bConfig.Memory);
|
|
|
|
eeprom_write_byte(&ee_RiseTime, bConfig.RiseTime);
|
|
|
|
eeprom_write_byte(&ee_RiseTime, bConfig.RiseTime);
|
|
|
@ -124,21 +113,35 @@ void WriteEEprom(void)
|
|
|
|
eeprom_write_byte(&ee_DebounceTime, bConfig.DebounceTime);
|
|
|
|
eeprom_write_byte(&ee_DebounceTime, bConfig.DebounceTime);
|
|
|
|
IntEnable();
|
|
|
|
IntEnable();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @fn void ReadEEpromWpM(void)
|
|
|
|
|
|
|
|
* @brief Gespeicherte Einstellung für die Geschwindigkeit aus EEprom lesen
|
|
|
|
|
|
|
|
* @param none
|
|
|
|
|
|
|
|
* @return none
|
|
|
|
|
|
|
|
*/
|
|
|
|
void ReadEEpromWpM(void)
|
|
|
|
void ReadEEpromWpM(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
IntDisable();
|
|
|
|
IntDisable();
|
|
|
|
bConfig.WpM = eeprom_read_byte(&ee_WpM);
|
|
|
|
bConfig.WpM = eeprom_read_byte(&ee_WpM);
|
|
|
|
IntEnable();
|
|
|
|
IntEnable();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @fn void WriteEEpromWpM(void)
|
|
|
|
|
|
|
|
* @brief Akt. Einstellung für die Geschwindigkeit in EEprom schreiben
|
|
|
|
|
|
|
|
* @param none
|
|
|
|
|
|
|
|
* @return none
|
|
|
|
|
|
|
|
*/
|
|
|
|
void WriteEEpromWpM(void)
|
|
|
|
void WriteEEpromWpM(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
IntDisable();
|
|
|
|
IntDisable();
|
|
|
|
eeprom_write_byte(&ee_WpM, bConfig.WpM);
|
|
|
|
eeprom_write_byte(&ee_WpM, bConfig.WpM);
|
|
|
|
IntEnable();
|
|
|
|
IntEnable();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @fn void SetEEprom(void)
|
|
|
|
/** @brief Standardeinstellungen (bei neuem Controller)
|
|
|
|
/** @brief Standardeinstellungen (bei neuem Controller)
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* Wird ein neuer Controller verwendet, gibt es keine
|
|
|
|
|
|
|
|
* Einstellungswerte im EEprom. Diese Funktion schreibt
|
|
|
|
|
|
|
|
* die initialen Werte in das EEprom. Wird sehr selten
|
|
|
|
|
|
|
|
* benötigt ;-)
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param none
|
|
|
|
* @param none
|
|
|
|
* @return none
|
|
|
|
* @return none
|
|
|
@ -154,6 +157,7 @@ void SetEEprom(void)
|
|
|
|
bConfig.WpMBpM = 1;
|
|
|
|
bConfig.WpMBpM = 1;
|
|
|
|
bConfig.Reverse = 0;
|
|
|
|
bConfig.Reverse = 0;
|
|
|
|
bConfig.SpeedRatioEnabled = 0;
|
|
|
|
bConfig.SpeedRatioEnabled = 0;
|
|
|
|
|
|
|
|
bConfig.Weight = 50;
|
|
|
|
bConfig.Ratio = 30;
|
|
|
|
bConfig.Ratio = 30;
|
|
|
|
bConfig.Memory = 0;
|
|
|
|
bConfig.Memory = 0;
|
|
|
|
bConfig.RiseTime = 5;
|
|
|
|
bConfig.RiseTime = 5;
|
|
|
@ -161,7 +165,8 @@ void SetEEprom(void)
|
|
|
|
bConfig.DebounceTime = 5;
|
|
|
|
bConfig.DebounceTime = 5;
|
|
|
|
WriteEEprom();
|
|
|
|
WriteEEprom();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/** @brief EEprom lesen
|
|
|
|
/** @fn void ReadEEprom(void)
|
|
|
|
|
|
|
|
* @brief Einstellungen aus dem EEprom lesen
|
|
|
|
* @param none
|
|
|
|
* @param none
|
|
|
|
* @return none
|
|
|
|
* @return none
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -184,57 +189,15 @@ void ReadEEprom(void)
|
|
|
|
bConfig.Reverse = eeprom_read_byte(&ee_Reverse);
|
|
|
|
bConfig.Reverse = eeprom_read_byte(&ee_Reverse);
|
|
|
|
bConfig.SpeedRatioEnabled = eeprom_read_byte(&ee_SpeedRatioEnabled);
|
|
|
|
bConfig.SpeedRatioEnabled = eeprom_read_byte(&ee_SpeedRatioEnabled);
|
|
|
|
bConfig.Ratio = eeprom_read_byte(&ee_Ratio);
|
|
|
|
bConfig.Ratio = eeprom_read_byte(&ee_Ratio);
|
|
|
|
|
|
|
|
bConfig.Weight = eeprom_read_byte(&ee_Weight);
|
|
|
|
bConfig.Memory = eeprom_read_byte(&ee_Memory);
|
|
|
|
bConfig.Memory = eeprom_read_byte(&ee_Memory);
|
|
|
|
bConfig.RiseTime = eeprom_read_byte(&ee_RiseTime);
|
|
|
|
bConfig.RiseTime = eeprom_read_byte(&ee_RiseTime);
|
|
|
|
bConfig.RiseTimeCounter = eeprom_read_byte(&ee_RiseTimeCounter);
|
|
|
|
bConfig.RiseTimeCounter = eeprom_read_byte(&ee_RiseTimeCounter);
|
|
|
|
bConfig.DebounceTime = eeprom_read_byte(&ee_DebounceTime);
|
|
|
|
bConfig.DebounceTime = eeprom_read_byte(&ee_DebounceTime);
|
|
|
|
IntEnable();
|
|
|
|
IntEnable();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/** @brief Aktuelle Einstellungen über serielle Schnittstelle ausgeben
|
|
|
|
/** @fn void SerialWriteChar(unsigned char data)
|
|
|
|
* @param none
|
|
|
|
* @brief Ein Zeichen über serielle Schnittstelle ausgeben
|
|
|
|
* @return none
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
void SerialInfo(void)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
sprintf(sdebug,"WpM : %i\r\n", bConfig.WpM);
|
|
|
|
|
|
|
|
SerialWriteString(sdebug);
|
|
|
|
|
|
|
|
sprintf(sdebug,"KeyerMode : %i\r\n", bConfig.KeyerMode);
|
|
|
|
|
|
|
|
SerialWriteString(sdebug);
|
|
|
|
|
|
|
|
sprintf(sdebug,"SidetoneFreq : %u\r\n", bConfig.SidetoneFreq);
|
|
|
|
|
|
|
|
SerialWriteString(sdebug);
|
|
|
|
|
|
|
|
sprintf(sdebug,"TRX : %i\r\n", bConfig.TRX);
|
|
|
|
|
|
|
|
SerialWriteString(sdebug);
|
|
|
|
|
|
|
|
sprintf(sdebug,"SidetoneEnabled : %i\r\n", bConfig.SidetoneEnabled);
|
|
|
|
|
|
|
|
SerialWriteString(sdebug);
|
|
|
|
|
|
|
|
sprintf(sdebug,"Ratio : %i\r\n", bConfig.Ratio);
|
|
|
|
|
|
|
|
SerialWriteString(sdebug);
|
|
|
|
|
|
|
|
sprintf(sdebug,"WpMBpM : %i\r\n", bConfig.WpMBpM);
|
|
|
|
|
|
|
|
SerialWriteString(sdebug);
|
|
|
|
|
|
|
|
sprintf(sdebug,"Reverse : %i\r\n", bConfig.Reverse);
|
|
|
|
|
|
|
|
SerialWriteString(sdebug);
|
|
|
|
|
|
|
|
sprintf(sdebug,"Memory : %i\r\n", bConfig.Memory);
|
|
|
|
|
|
|
|
SerialWriteString(sdebug);
|
|
|
|
|
|
|
|
sprintf(sdebug,"SpeedRatio : %i\r\n", bConfig.SpeedRatioEnabled);
|
|
|
|
|
|
|
|
SerialWriteString(sdebug);
|
|
|
|
|
|
|
|
sprintf(sdebug,"RiseTime : %i\r\n", bConfig.RiseTime);
|
|
|
|
|
|
|
|
SerialWriteString(sdebug);
|
|
|
|
|
|
|
|
sprintf(sdebug,"RiseTimeCounter : %i\r\n", bConfig.RiseTimeCounter);
|
|
|
|
|
|
|
|
SerialWriteString(sdebug);
|
|
|
|
|
|
|
|
sprintf(sdebug,"DebounceTime : %i\r\n", bConfig.DebounceTime);
|
|
|
|
|
|
|
|
SerialWriteString(sdebug);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @brief Versionsinformation über serielle Schnittstelle ausgeben
|
|
|
|
|
|
|
|
* @param none
|
|
|
|
|
|
|
|
* @return none
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
void SerialAbout(void)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
sprintf(sdebug,"%s", CLRSCR);
|
|
|
|
|
|
|
|
SerialWriteString(sdebug);
|
|
|
|
|
|
|
|
sprintf(sdebug,"%s %s %s\r\n\r\n", PRG,VER,CALL);
|
|
|
|
|
|
|
|
SerialWriteString(sdebug);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @brief Ein Zeichen über serielle Schnittstelle ausgeben
|
|
|
|
|
|
|
|
* @param Zeichen
|
|
|
|
* @param Zeichen
|
|
|
|
* @return none
|
|
|
|
* @return none
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -243,7 +206,8 @@ void SerialWriteChar(unsigned char data)
|
|
|
|
while(!(UCSR0A & (1<<UDRE0)));
|
|
|
|
while(!(UCSR0A & (1<<UDRE0)));
|
|
|
|
UDR0 = data;
|
|
|
|
UDR0 = data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/** @brief Eine Zeichenkette über serielle Schnittstelle ausgeben
|
|
|
|
/** @fn void SerialWriteString(unsigned char *s)
|
|
|
|
|
|
|
|
* @brief Eine Zeichenkette über serielle Schnittstelle ausgeben
|
|
|
|
* @param Zeiger auf Zeichenkette, die mit 0x00 abgeschlossen sein muss
|
|
|
|
* @param Zeiger auf Zeichenkette, die mit 0x00 abgeschlossen sein muss
|
|
|
|
* @return none
|
|
|
|
* @return none
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -252,19 +216,8 @@ void SerialWriteString(char *s)
|
|
|
|
while(*s != 0x00)
|
|
|
|
while(*s != 0x00)
|
|
|
|
SerialWriteChar(*s++);
|
|
|
|
SerialWriteChar(*s++);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @fn void SidetoneOn(void)
|
|
|
|
/** @brief Read port pin of morse keys
|
|
|
|
* @brief Mithörton einschalten
|
|
|
|
*
|
|
|
|
|
|
|
|
* This function reads the input of
|
|
|
|
|
|
|
|
* the Paddle or Straight key.
|
|
|
|
|
|
|
|
* @params: Pin to read
|
|
|
|
|
|
|
|
* @return: State of pin
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
uint8_t ReadKeyPin(uint8_t pin)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return(PIND & (1<<pin));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @brief Tonausgabe einschalten
|
|
|
|
|
|
|
|
* @param none
|
|
|
|
* @param none
|
|
|
|
* @return none
|
|
|
|
* @return none
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -276,7 +229,8 @@ void SidetoneOn(void)
|
|
|
|
icnt = 0;
|
|
|
|
icnt = 0;
|
|
|
|
sbi(TIMSK1,OCIE1A);
|
|
|
|
sbi(TIMSK1,OCIE1A);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/** @brief Tonausgabe abschalten
|
|
|
|
/** @fn void SidetoneOff(void)
|
|
|
|
|
|
|
|
* @brief Mithörtone ausschalten
|
|
|
|
* @param none
|
|
|
|
* @param none
|
|
|
|
* @return none
|
|
|
|
* @return none
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -286,7 +240,8 @@ void SidetoneOff(void)
|
|
|
|
StateRiseTime = 0;
|
|
|
|
StateRiseTime = 0;
|
|
|
|
StateRiseTimeCounter = 0;
|
|
|
|
StateRiseTimeCounter = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/** @brief Audioverstärker abschalten
|
|
|
|
/** @fn void SidetoneDisable(void)
|
|
|
|
|
|
|
|
/* @brief Audioverstärker abschalten
|
|
|
|
* @param none
|
|
|
|
* @param none
|
|
|
|
* @return none
|
|
|
|
* @return none
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -295,7 +250,8 @@ void SidetoneDisable(void)
|
|
|
|
bConfig.SidetoneEnabled = 0;
|
|
|
|
bConfig.SidetoneEnabled = 0;
|
|
|
|
cbi(PORTB,AUDIO_EN);
|
|
|
|
cbi(PORTB,AUDIO_EN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/** @brief Audioverstärker einschalten
|
|
|
|
/** @fn void SidetoneEnable(void)
|
|
|
|
|
|
|
|
* @brief Audioverstärker einschalten
|
|
|
|
* @param none
|
|
|
|
* @param none
|
|
|
|
* @return none
|
|
|
|
* @return none
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -304,11 +260,14 @@ void SidetoneEnable(void)
|
|
|
|
bConfig.SidetoneEnabled = 1;
|
|
|
|
bConfig.SidetoneEnabled = 1;
|
|
|
|
sbi(PORTB,AUDIO_EN);
|
|
|
|
sbi(PORTB,AUDIO_EN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @fn void TXKey(uint8_t State)
|
|
|
|
/*
|
|
|
|
* @brief Gibt ein Symbol aus
|
|
|
|
** TXKey
|
|
|
|
*
|
|
|
|
**
|
|
|
|
* Je nach Einstellung wird ein oder beide Transceiver
|
|
|
|
** Tastung TRX1, TRX2 oder beide
|
|
|
|
* getastet oder nur der Mithörton ausgegeben.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param State - Bitfeld für Transceiver und Tonausgabe
|
|
|
|
|
|
|
|
* @return none
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
void TXKey(uint8_t State)
|
|
|
|
void TXKey(uint8_t State)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -334,17 +293,19 @@ void TXKey(uint8_t State)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @fn void CheckStraightKey(void)
|
|
|
|
/** \brief StraigtKey
|
|
|
|
* @brief Fragt die Handtasteneingänge ab und gibt das
|
|
|
|
*
|
|
|
|
* entsprechende Symbol aus. Bei der Handtaste
|
|
|
|
* Check Straightkey
|
|
|
|
* findet über einen Timer noch eine Software
|
|
|
|
*
|
|
|
|
* Entprellung statt
|
|
|
|
*/
|
|
|
|
* @param none
|
|
|
|
|
|
|
|
* @return none
|
|
|
|
|
|
|
|
*/
|
|
|
|
void CheckStraightKey(void)
|
|
|
|
void CheckStraightKey(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(PIND & (1<<STRAIGHT_KEY))
|
|
|
|
if(PIND & (1<<STRAIGHT_KEY))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(bState.SendStatus == NOTHING)
|
|
|
|
if(bState.SendStatus == SENDING_NOTHING)
|
|
|
|
TXKey(0);
|
|
|
|
TXKey(0);
|
|
|
|
StateStraightKeyPressed = NO_KEY_PRESSED;
|
|
|
|
StateStraightKeyPressed = NO_KEY_PRESSED;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -355,40 +316,78 @@ void CheckStraightKey(void)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(StateStraightKeyPressed == KEY_PRESSED)
|
|
|
|
if(StateStraightKeyPressed == KEY_PRESSED)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(bState.SendStatus == NOTHING)
|
|
|
|
if(bState.SendStatus == SENDING_NOTHING)
|
|
|
|
TXKey(1);
|
|
|
|
TXKey(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/** \brief CheckPaddles
|
|
|
|
/** @fn void CheckPaddles(void)
|
|
|
|
**
|
|
|
|
** @brief Diese Funktion prüft, ob ein Paddle betätigt wurde.
|
|
|
|
|
|
|
|
**
|
|
|
|
|
|
|
|
** Wenn dies der Fall war, ist das jeweilige Statusbit gesetzt
|
|
|
|
|
|
|
|
** und die Funktion für die Ausgabe des entsprechendem Symbol
|
|
|
|
|
|
|
|
** wird aufgerufen.
|
|
|
|
|
|
|
|
**
|
|
|
|
|
|
|
|
** @param none
|
|
|
|
|
|
|
|
** @return none
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
void CheckPaddles(void)
|
|
|
|
void CheckPaddles(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CheckDitPaddle();
|
|
|
|
CheckDitPaddle();
|
|
|
|
CheckDahPaddle();
|
|
|
|
CheckDahPaddle();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Wenn Paddle betätigt wurde,
|
|
|
|
|
|
|
|
if(bState.SendStatus == SENDING_NOTHING)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(bState.DitPressed || bState.DahPressed)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(bState.DitPressed && !bState.DahPressed)
|
|
|
|
|
|
|
|
SendDit();
|
|
|
|
|
|
|
|
else if(bState.DahPressed && !bState.DitPressed)
|
|
|
|
|
|
|
|
SendDah();
|
|
|
|
|
|
|
|
else if(bState.DahPressed && bState.DitPressed)
|
|
|
|
|
|
|
|
SendIambic();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/** \brief CheckDitPaddle
|
|
|
|
/** @fn void CheckDitPaddle(void)
|
|
|
|
|
|
|
|
* @brief Prüfen, ob das Punkt Paddle betätigt wurde.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
|
|
|
|
* Ist dies der Fall, wird das Statusbit gesetzt.Wurde in den
|
|
|
|
|
|
|
|
* Einstellungen der Reverse Mode aktiviert, werden in der
|
|
|
|
|
|
|
|
* Abfrage die Paddle vertauscht.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param none
|
|
|
|
|
|
|
|
* @return none
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
void CheckDitPaddle(void)
|
|
|
|
void CheckDitPaddle(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
uint8_t pinvalue = 0;
|
|
|
|
uint8_t pinvalue = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if(PaddleMode == PADDLE_NORMAL) // no reverse paddle
|
|
|
|
if(PaddleMode == PADDLE_NORMAL)
|
|
|
|
pinvalue = PIND & (1<<LEFT_PADDLE);
|
|
|
|
pinvalue = PIND & (1<<LEFT_PADDLE);
|
|
|
|
else
|
|
|
|
else
|
|
|
|
pinvalue = PIND & (1<<RIGHT_PADDLE); // reverse paddle
|
|
|
|
pinvalue = PIND & (1<<RIGHT_PADDLE);
|
|
|
|
|
|
|
|
|
|
|
|
if(pinvalue == 0) // DitPaddle betätigt
|
|
|
|
if((pinvalue == 0) && ((!(bState.SendStatus == SENDING_DIT)) || (bState.SendStatus == SENDING_NOTHING)))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bState.DitPressed = 1;
|
|
|
|
bState.DitPressed = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Wenn Punkt/Strich Speicher aktiviert ist, das Symbol merken, wenn es nicht identisch ist
|
|
|
|
|
|
|
|
if((pinvalue == 0) && (!(bState.SendStatus == SENDING_DIT)) && (bConfig.Memory == 1))
|
|
|
|
|
|
|
|
bState.DitPressed = 1;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
/** @fn void CheckDahPaddle(void)
|
|
|
|
** CheckDahPaddle
|
|
|
|
* @brief Prüfen, ob das Strich Paddle betätigt wurde.
|
|
|
|
*/
|
|
|
|
*
|
|
|
|
|
|
|
|
* Ist dies der Fall, wird das Statusbit gesetzt. Wurde in den
|
|
|
|
|
|
|
|
* Einstellungen der Reverse Mode aktiviert, werden in der
|
|
|
|
|
|
|
|
* Abfrage die Paddle vertauscht.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param none
|
|
|
|
|
|
|
|
* @return none
|
|
|
|
|
|
|
|
*/
|
|
|
|
void CheckDahPaddle(void)
|
|
|
|
void CheckDahPaddle(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
uint8_t pinvalue = 0;
|
|
|
|
uint8_t pinvalue = 0;
|
|
|
@ -398,54 +397,130 @@ void CheckDahPaddle(void)
|
|
|
|
else
|
|
|
|
else
|
|
|
|
pinvalue = PIND & (1<<LEFT_PADDLE); // reverse paddle
|
|
|
|
pinvalue = PIND & (1<<LEFT_PADDLE); // reverse paddle
|
|
|
|
|
|
|
|
|
|
|
|
if(pinvalue == 0)
|
|
|
|
// Das Symbol nur merken, wenn nicht gerade eines ausgegeben wird oder gar nichts ausgegeben wird
|
|
|
|
|
|
|
|
if((pinvalue == 0) && ((!(bState.SendStatus == SENDING_DAH)) || (bState.SendStatus == SENDING_NOTHING)))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bState.DahPressed = 1;
|
|
|
|
bState.DahPressed = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Wenn Punkt/Strich Speicher aktiviert ist, das Symbol merken, wenn es nicht identisch ist
|
|
|
|
|
|
|
|
if((pinvalue == 0) && (!(bState.SendStatus == SENDING_DAH)) && (bConfig.Memory == 1))
|
|
|
|
|
|
|
|
bState.DahPressed = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void SetRatio(uint8_t WPMCorrectFactor)
|
|
|
|
/** @fn void SetRatio(void)
|
|
|
|
|
|
|
|
* @brief Berechnung der Zeitdauer für Punkt und Strich
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* Die Länge eines Symbols ist abhängig von der
|
|
|
|
|
|
|
|
* eingestellten Geschwindigkeit. Intern wird immer
|
|
|
|
|
|
|
|
* mit Wörtern pro Minute gerechnet. Das normale
|
|
|
|
|
|
|
|
* Punkt/Strich Verhältnis ist 1:3. Dies kann durch
|
|
|
|
|
|
|
|
* den Parameter Ratio in den Einstellungen verändert
|
|
|
|
|
|
|
|
* werden. Wird ein Korrekturfaktor angegeben, kann
|
|
|
|
|
|
|
|
* das Ratio über eine Tabelle in Abhängigkeit der
|
|
|
|
|
|
|
|
* Geschwindigkeit bis zu 1:2.0 verändert werden.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param none
|
|
|
|
|
|
|
|
* @return none
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
void SetRatio(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DitMillis = 1200 / WpM;
|
|
|
|
DitMillis = 1200 / WpM;
|
|
|
|
DahMillis = DitMillis * (float)(bConfig.Ratio/10);
|
|
|
|
if(bConfig.SpeedRatioEnabled)
|
|
|
|
|
|
|
|
DahMillis = DitMillis * (float)(bState.WpMCorrectFactor / 10);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
DahMillis = DitMillis * (float)(bConfig.Ratio/10);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @fn void GetWpMCorrectFactor(void)
|
|
|
|
|
|
|
|
* @brief Ermittelt den Korrekturfaktor für das Ratio
|
|
|
|
|
|
|
|
* param none
|
|
|
|
|
|
|
|
* return none
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
void GetWpMCorrectFactor(void)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bState.WpMCorrectFactor = 30;
|
|
|
|
|
|
|
|
if(WpM > 20)
|
|
|
|
|
|
|
|
bState.WpMCorrectFactor = 28;
|
|
|
|
|
|
|
|
|
|
|
|
/** @brief Symbol senden
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetWeight(void)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
DitMillis = 1200/WpM;
|
|
|
|
|
|
|
|
DahMillis = 3 * DitMillis;
|
|
|
|
|
|
|
|
SpcMillis = 1200/WpM;
|
|
|
|
|
|
|
|
DitMillis = (bConfig.Weight/50.0) * DitMillis;
|
|
|
|
|
|
|
|
DahMillis = (bConfig.Weight/50.0) * DahMillis;
|
|
|
|
|
|
|
|
if(bConfig.Weight < 50)
|
|
|
|
|
|
|
|
SpcMillis = SpcMillis + (SpcMillis - DitMillis);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
SpcMillis = SpcMillis - (DitMillis - SpcMillis);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @fn void SendSymbol(uint8_t Dit)
|
|
|
|
|
|
|
|
* @brief Symbol senden
|
|
|
|
* @param Dit = 1, wenn Symbol ein Punkt ist
|
|
|
|
* @param Dit = 1, wenn Symbol ein Punkt ist
|
|
|
|
* @return none
|
|
|
|
* @return none
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
void SendSymbol(uint8_t Dit)
|
|
|
|
void SendSymbol(uint8_t Dit)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
volatile static uint16_t ticks; // Länge des Symbols
|
|
|
|
static uint16_t ticks; // Länge des Symbols
|
|
|
|
if(Dit)
|
|
|
|
if(Dit)
|
|
|
|
ticks = DitMillis;
|
|
|
|
ticks = DitMillis;
|
|
|
|
else
|
|
|
|
else
|
|
|
|
ticks = DahMillis;
|
|
|
|
ticks = DahMillis;
|
|
|
|
t_elementlength = 0;
|
|
|
|
t_elementlength = 0;
|
|
|
|
|
|
|
|
|
|
|
|
TXKey(1);
|
|
|
|
TXKey(1);
|
|
|
|
DelayMilliSeconds(ticks);
|
|
|
|
DelayMilliSeconds(ticks);
|
|
|
|
|
|
|
|
bState.SendStatus = SENDING_SPC;
|
|
|
|
TXKey(0);
|
|
|
|
TXKey(0);
|
|
|
|
DelayMilliSeconds(DitMillis);
|
|
|
|
DelayMilliSeconds(SpcMillis);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/** @fn void SendDit(void)
|
|
|
|
** void SendDit(uint8_t SendingType)
|
|
|
|
* @brief Gibt einen Punkt aus
|
|
|
|
*/
|
|
|
|
* @param none
|
|
|
|
|
|
|
|
* @return none
|
|
|
|
|
|
|
|
*/
|
|
|
|
void SendDit(void)
|
|
|
|
void SendDit(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bState.DitPressed = 0;
|
|
|
|
if((bState.SendStatus == NOTHING) || (bState.SendStatus == SENDING_DAH))
|
|
|
|
SendSymbol(DIT);
|
|
|
|
{
|
|
|
|
bState.LastSymbolWasDit = 1;
|
|
|
|
bState.DitPressed = 0;
|
|
|
|
|
|
|
|
bState.SendStatus = SENDING_DIT;
|
|
|
|
|
|
|
|
SendSymbol(DIT);
|
|
|
|
|
|
|
|
bState.SendStatus = SENDING_NOTHING;
|
|
|
|
|
|
|
|
bState.LastSymbolWasDit = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(bConfig.Memory == 0)
|
|
|
|
|
|
|
|
bState.DitPressed = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/** \brief Send a dah
|
|
|
|
/** @fn void SendDah(void)
|
|
|
|
** A Dah with weight = 50 has the length of 3 Dits.
|
|
|
|
* @brief Gibt einen Strich aus
|
|
|
|
|
|
|
|
* @param none
|
|
|
|
|
|
|
|
* @return none
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
void SendDah(void)
|
|
|
|
void SendDah(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bState.DahPressed = 0;
|
|
|
|
if((bState.SendStatus == NOTHING) || (bState.SendStatus == SENDING_DIT))
|
|
|
|
SendSymbol(DAH);
|
|
|
|
{
|
|
|
|
bState.LastSymbolWasDit = 0;
|
|
|
|
bState.DahPressed = 0;
|
|
|
|
|
|
|
|
bState.SendStatus = SENDING_DAH;
|
|
|
|
|
|
|
|
SendSymbol(DAH);
|
|
|
|
|
|
|
|
bState.SendStatus = SENDING_NOTHING;
|
|
|
|
|
|
|
|
bState.LastSymbolWasDit = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(bConfig.Memory == 0)
|
|
|
|
|
|
|
|
bState.DahPressed = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @fn void SendIambic(void)
|
|
|
|
|
|
|
|
* @brief Wenn beide Paddle betätigt sind, wird alternierend
|
|
|
|
|
|
|
|
* ein Punkt und Strich ausgegeben.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* Beim Iambic B Mode und Ultimatic Mode wird gegebenenfalls
|
|
|
|
|
|
|
|
* noch ein gegensätzliches Zeichen des zuletzt betätigten Paddle
|
|
|
|
|
|
|
|
* angefügt. Erläuterung und Timing siehe Dokumentation.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param none
|
|
|
|
|
|
|
|
* @return none
|
|
|
|
|
|
|
|
*/
|
|
|
|
void SendIambic(void)
|
|
|
|
void SendIambic(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bState.DahPressed = 0;
|
|
|
|
bState.DahPressed = 0;
|
|
|
@ -485,19 +560,27 @@ void SendIambic(void)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
/** @fn void SetFrequency(uint16_t f)
|
|
|
|
** Set sidetone frequency
|
|
|
|
* @brief Verändert die Frequenz des Mithörtons
|
|
|
|
*/
|
|
|
|
*
|
|
|
|
|
|
|
|
* Durch die Anpassung des Timers 1 für das
|
|
|
|
|
|
|
|
* Laden der Werte der Sinuskurve wird die
|
|
|
|
|
|
|
|
* Tonhöhe des Mithörtons verändert.
|
|
|
|
|
|
|
|
* @param Frequenz des Mithörtons in Hz
|
|
|
|
|
|
|
|
* @return none
|
|
|
|
|
|
|
|
*/
|
|
|
|
void SetFrequency(uint16_t f)
|
|
|
|
void SetFrequency(uint16_t f)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
IntDisable();
|
|
|
|
IntDisable();
|
|
|
|
OCR1A = (F_CPUPRESIN / f) - 1;
|
|
|
|
OCR1A = (F_CPUPRESIN / f) - 1;
|
|
|
|
IntEnable();
|
|
|
|
IntEnable();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
/** @fn void Tone(uint16_t f, uint8_t duration)
|
|
|
|
** Output a tone width frequency f and duration duration
|
|
|
|
* @brief Ausgabe eines Tons mit Dauer und Frequenz
|
|
|
|
**
|
|
|
|
* @param f - Frequenz des Tons
|
|
|
|
*/
|
|
|
|
* duration - Dauer des Tons
|
|
|
|
|
|
|
|
* @return none
|
|
|
|
|
|
|
|
*/
|
|
|
|
void Tone(uint16_t f, uint8_t duration)
|
|
|
|
void Tone(uint16_t f, uint8_t duration)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SetFrequency(f);
|
|
|
|
SetFrequency(f);
|
|
|
@ -506,14 +589,29 @@ void Tone(uint16_t f, uint8_t duration)
|
|
|
|
SidetoneOff();
|
|
|
|
SidetoneOff();
|
|
|
|
SetFrequency(bConfig.SidetoneFreq);
|
|
|
|
SetFrequency(bConfig.SidetoneFreq);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @fn void Boop(void)
|
|
|
|
|
|
|
|
* @brief Boop Ton ausgeben
|
|
|
|
|
|
|
|
* @param none
|
|
|
|
|
|
|
|
* @return none
|
|
|
|
|
|
|
|
*/
|
|
|
|
void Boop(void)
|
|
|
|
void Boop(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Tone(600,100);
|
|
|
|
Tone(600,100);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @fn void Beep(void)
|
|
|
|
|
|
|
|
* @brief Beep Ton ausgeben
|
|
|
|
|
|
|
|
* @param none
|
|
|
|
|
|
|
|
* @return none
|
|
|
|
|
|
|
|
*/
|
|
|
|
void Beep(void)
|
|
|
|
void Beep(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Tone(1200,100);
|
|
|
|
Tone(1200,100);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @fn void BeepBoop(void)
|
|
|
|
|
|
|
|
* @brief BeepBoop Doppelton ausgeben
|
|
|
|
|
|
|
|
* @param none
|
|
|
|
|
|
|
|
* @return none
|
|
|
|
|
|
|
|
*/
|
|
|
|
void BeepBoop(void)
|
|
|
|
void BeepBoop(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DelayMilliSeconds(10);
|
|
|
|
DelayMilliSeconds(10);
|
|
|
|