|
|
|
@ -85,8 +85,25 @@ void IntDisable(void)
|
|
|
|
|
sreg_tmp = SREG;
|
|
|
|
|
cli();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** \brief EEPROM schreiben
|
|
|
|
|
/** @brief Pin Change Interrupt abschalten
|
|
|
|
|
* @param none
|
|
|
|
|
* @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
|
|
|
|
|
* @return none
|
|
|
|
|
*/
|
|
|
|
|
void WriteEEprom(void)
|
|
|
|
|
{
|
|
|
|
@ -365,85 +382,8 @@ void CheckStraightKey(void)
|
|
|
|
|
*/
|
|
|
|
|
void CheckPaddles(void)
|
|
|
|
|
{
|
|
|
|
|
static uint8_t LastAction = NOTHING;
|
|
|
|
|
|
|
|
|
|
CheckDitPaddle();
|
|
|
|
|
CheckDahPaddle();
|
|
|
|
|
|
|
|
|
|
if(bConfig.KeyerMode == ULTIMATIC)
|
|
|
|
|
{
|
|
|
|
|
switch(LastAction)
|
|
|
|
|
{
|
|
|
|
|
case DAH_DIT_ON:
|
|
|
|
|
if(DahBuffer) {
|
|
|
|
|
if(DitBuffer)
|
|
|
|
|
DitBuffer = 0;
|
|
|
|
|
else
|
|
|
|
|
LastAction = DAH_DIT_OFF;
|
|
|
|
|
} else {
|
|
|
|
|
if(DitBuffer)
|
|
|
|
|
LastAction = DIT_DAH_OFF;
|
|
|
|
|
else
|
|
|
|
|
LastAction = NOTHING;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case DIT_DAH_ON:
|
|
|
|
|
if(DitBuffer) {
|
|
|
|
|
if(DahBuffer)
|
|
|
|
|
DahBuffer = 0;
|
|
|
|
|
else
|
|
|
|
|
LastAction = DIT_DAH_OFF;
|
|
|
|
|
} else {
|
|
|
|
|
if(DahBuffer)
|
|
|
|
|
LastAction = DAH_DIT_OFF;
|
|
|
|
|
else
|
|
|
|
|
LastAction = NOTHING;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case DAH_DIT_OFF:
|
|
|
|
|
if(DitBuffer) {
|
|
|
|
|
if(DahBuffer)
|
|
|
|
|
{
|
|
|
|
|
LastAction = DIT_DAH_ON;
|
|
|
|
|
DahBuffer = 0;
|
|
|
|
|
} else {
|
|
|
|
|
LastAction = DIT_DAH_OFF;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if(!DahBuffer)
|
|
|
|
|
LastAction = NOTHING;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case DIT_DAH_OFF:
|
|
|
|
|
if(DahBuffer) {
|
|
|
|
|
if(DitBuffer)
|
|
|
|
|
{
|
|
|
|
|
LastAction = DAH_DIT_ON;
|
|
|
|
|
DitBuffer = 0;
|
|
|
|
|
} else {
|
|
|
|
|
LastAction = DAH_DIT_OFF;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if(!DitBuffer)
|
|
|
|
|
LastAction = NOTHING;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case NOTHING:
|
|
|
|
|
if((DitBuffer) && (!DahBuffer)) {
|
|
|
|
|
LastAction = NOTHING;
|
|
|
|
|
} else {
|
|
|
|
|
if((DahBuffer) && (!DitBuffer)) {
|
|
|
|
|
LastAction = DAH_DIT_OFF;
|
|
|
|
|
} else {
|
|
|
|
|
if((DitBuffer) && (DahBuffer)) {
|
|
|
|
|
LastAction = DIT_DAH_ON;
|
|
|
|
|
DahBuffer = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/** \brief CheckDitPaddle
|
|
|
|
|
*
|
|
|
|
@ -460,7 +400,7 @@ void CheckDitPaddle(void)
|
|
|
|
|
|
|
|
|
|
if(pinvalue == 0) // DitPaddle betätigt
|
|
|
|
|
{
|
|
|
|
|
DitBuffer = 1;
|
|
|
|
|
bState.DitPressed = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
@ -477,146 +417,91 @@ void CheckDahPaddle(void)
|
|
|
|
|
|
|
|
|
|
if(pinvalue == 0)
|
|
|
|
|
{
|
|
|
|
|
DahBuffer = 1;
|
|
|
|
|
bState.DahPressed = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetRatio(uint8_t WPMCorrectFactor)
|
|
|
|
|
{
|
|
|
|
|
DitMillis = 1200 / WpM;
|
|
|
|
|
DahMillis = DitMillis * (float)(bConfig.Ratio/10);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** @brief Schleife für die Dauer eines Zeichenelements Dit oder Dah
|
|
|
|
|
*
|
|
|
|
|
* @param Len Anzahl der Symbole (in Dits)
|
|
|
|
|
/** @brief Symbol senden
|
|
|
|
|
* @param Dit = 1, wenn Symbol ein Punkt ist
|
|
|
|
|
* @return none
|
|
|
|
|
*/
|
|
|
|
|
void SymbolLoop(uint8_t Len)
|
|
|
|
|
{
|
|
|
|
|
volatile static uint16_t ticks; // lengths of elements + AddMilliSeconds in ms
|
|
|
|
|
|
|
|
|
|
ticks = DitMillis * Len; //
|
|
|
|
|
t_elementlength = 0; // Reset Timer 0 variable
|
|
|
|
|
while(t_elementlength < ticks)
|
|
|
|
|
{
|
|
|
|
|
if(KeyerMode != ULTIMATIC)
|
|
|
|
|
{
|
|
|
|
|
if((KeyerMode == IAMBIC_A) && (!(PIND & (1<<LEFT_PADDLE))) && (!(PIND & (1<<RIGHT_PADDLE))))
|
|
|
|
|
{
|
|
|
|
|
IambicFlag = 1;
|
|
|
|
|
SerialWriteString("526:IambicFlag == 1\r\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(bState.SendStatus == SENDING_DIT)
|
|
|
|
|
{
|
|
|
|
|
CheckDahPaddle();
|
|
|
|
|
} else {
|
|
|
|
|
if(bState.SendStatus == SENDING_DAH)
|
|
|
|
|
{
|
|
|
|
|
CheckDitPaddle();
|
|
|
|
|
} else {
|
|
|
|
|
CheckDahPaddle();
|
|
|
|
|
CheckDitPaddle();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if(bState.SendStatus == SENDING_DIT)
|
|
|
|
|
{
|
|
|
|
|
CheckDahPaddle();
|
|
|
|
|
} else {
|
|
|
|
|
if(bState.SendStatus == SENDING_DAH)
|
|
|
|
|
{
|
|
|
|
|
CheckDitPaddle();
|
|
|
|
|
} else {
|
|
|
|
|
CheckDahPaddle();
|
|
|
|
|
CheckDitPaddle();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Wenn Taste losgelassen, dann im KeyerMode IAMBIC_A das IambicFlag löschen
|
|
|
|
|
if((KeyerMode == IAMBIC_A) && (IambicFlag) && (PIND & (1<<LEFT_PADDLE)) && (PIND & (1<<RIGHT_PADDLE)))
|
|
|
|
|
{
|
|
|
|
|
IambicFlag = 0;
|
|
|
|
|
DitBuffer = 0;
|
|
|
|
|
DahBuffer = 0;
|
|
|
|
|
SerialWriteString("562:IambicFlag == 0\r\n");
|
|
|
|
|
}
|
|
|
|
|
if((bState.SendStatus == SENDING_DIT) || (bState.SendStatus == SENDING_DAH))
|
|
|
|
|
{
|
|
|
|
|
if(bConfig.Memory == 0)
|
|
|
|
|
{
|
|
|
|
|
DitBuffer = 0;
|
|
|
|
|
DahBuffer = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
void SendSymbol(uint8_t Dit)
|
|
|
|
|
{
|
|
|
|
|
volatile static uint16_t ticks; // Länge des Symbols
|
|
|
|
|
if(Dit)
|
|
|
|
|
ticks = DitMillis;
|
|
|
|
|
else
|
|
|
|
|
ticks = DahMillis;
|
|
|
|
|
t_elementlength = 0;
|
|
|
|
|
TXKey(1);
|
|
|
|
|
DelayMilliSeconds(ticks);
|
|
|
|
|
TXKey(0);
|
|
|
|
|
DelayMilliSeconds(DitMillis);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
** void SendDit(uint8_t SendingType)
|
|
|
|
|
*/
|
|
|
|
|
void SendDit(uint8_t SendingType)
|
|
|
|
|
void SendDit(void)
|
|
|
|
|
{
|
|
|
|
|
bState.SendStatus = SENDING_DIT;
|
|
|
|
|
TXKey(1);
|
|
|
|
|
SymbolLoop(1);
|
|
|
|
|
TXKey(0);
|
|
|
|
|
SymbolLoop(1);
|
|
|
|
|
bState.SendStatus = NOTHING;
|
|
|
|
|
CheckPaddles();
|
|
|
|
|
bState.DitPressed = 0;
|
|
|
|
|
SendSymbol(DIT);
|
|
|
|
|
bState.LastSymbolWasDit = 1;
|
|
|
|
|
}
|
|
|
|
|
/** \brief Send a dah
|
|
|
|
|
** A Dah with weight = 50 has the length of 3 Dits.
|
|
|
|
|
*/
|
|
|
|
|
void SendDah(uint8_t SendingType)
|
|
|
|
|
void SendDah(void)
|
|
|
|
|
{
|
|
|
|
|
bState.SendStatus = SENDING_DAH;
|
|
|
|
|
TXKey(1);
|
|
|
|
|
SymbolLoop(3);
|
|
|
|
|
TXKey(0);
|
|
|
|
|
SymbolLoop(1);
|
|
|
|
|
bState.SendStatus = NOTHING;
|
|
|
|
|
CheckPaddles();
|
|
|
|
|
bState.DahPressed = 0;
|
|
|
|
|
SendSymbol(DAH);
|
|
|
|
|
bState.LastSymbolWasDit = 0;
|
|
|
|
|
}
|
|
|
|
|
/** @brief Bearbeiten der Punkt- und Strichbuffer für Iambic Modes
|
|
|
|
|
*
|
|
|
|
|
* Bei Iambic A wird der Buffer gelöscht, bei Iambic B voher das
|
|
|
|
|
* gegensätzliche Zeichen ausgegeben.
|
|
|
|
|
* @param none
|
|
|
|
|
* @return none
|
|
|
|
|
*/
|
|
|
|
|
void DitDahBuffers(void)
|
|
|
|
|
|
|
|
|
|
void SendIambic(void)
|
|
|
|
|
{
|
|
|
|
|
if((bConfig.KeyerMode == IAMBIC_A) || (bConfig.KeyerMode == IAMBIC_B))
|
|
|
|
|
bState.DahPressed = 0;
|
|
|
|
|
bState.DitPressed = 0;
|
|
|
|
|
if(bState.LastSymbolWasDit)
|
|
|
|
|
{
|
|
|
|
|
// IAMBIC_A
|
|
|
|
|
if((bConfig.KeyerMode == IAMBIC_A) && (IambicFlag) && (PIND & (1<<LEFT_PADDLE)) && (PIND & (1<<RIGHT_PADDLE)))
|
|
|
|
|
SendDah();
|
|
|
|
|
if(bConfig.KeyerMode == IAMBIC_B && !bState.DahPressed && !bState.DitPressed)
|
|
|
|
|
{
|
|
|
|
|
IambicFlag = 0;
|
|
|
|
|
DitBuffer = 0;
|
|
|
|
|
DahBuffer = 0;
|
|
|
|
|
SerialWriteString("616:IambicFlag == 0\r\n");
|
|
|
|
|
SendDit();
|
|
|
|
|
} else {
|
|
|
|
|
// IAMBIC_B
|
|
|
|
|
if(DitBuffer)
|
|
|
|
|
if(bConfig.KeyerMode == ULTIMATIC)
|
|
|
|
|
{
|
|
|
|
|
DitBuffer = 0;
|
|
|
|
|
SendDit(MAN);
|
|
|
|
|
while(bState.DahPressed)
|
|
|
|
|
{
|
|
|
|
|
bState.DitPressed = 0;
|
|
|
|
|
bState.DahPressed = 0;
|
|
|
|
|
SendDah();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(DahBuffer)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
SendDit();
|
|
|
|
|
if(bConfig.KeyerMode == IAMBIC_B && !bState.DitPressed && !bState.DahPressed)
|
|
|
|
|
{
|
|
|
|
|
SendDah();
|
|
|
|
|
} else {
|
|
|
|
|
if(bConfig.KeyerMode == ULTIMATIC)
|
|
|
|
|
{
|
|
|
|
|
DahBuffer = 0;
|
|
|
|
|
SendDah(MAN);
|
|
|
|
|
while(bState.DitPressed)
|
|
|
|
|
{
|
|
|
|
|
bState.DitPressed = 0;
|
|
|
|
|
bState.DahPressed = 0;
|
|
|
|
|
SendDit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(bConfig.KeyerMode == ULTIMATIC)
|
|
|
|
|
{
|
|
|
|
|
SerialWriteString("Ultimatic\r\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
** Set sidetone frequency
|
|
|
|
|
*/
|
|
|
|
@ -659,6 +544,7 @@ void SendChar(unsigned char c)
|
|
|
|
|
switch(c)
|
|
|
|
|
{
|
|
|
|
|
// Buchstaben
|
|
|
|
|
/*
|
|
|
|
|
case 'A': SendDit(AUTO); SendDah(AUTO); break;
|
|
|
|
|
case 'B': SendDah(AUTO); SendDit(AUTO); SendDit(AUTO); SendDit(AUTO); break;
|
|
|
|
|
case 'C': SendDit(AUTO); SendDah(AUTO); SendDit(AUTO); SendDah(AUTO); break;
|
|
|
|
@ -703,6 +589,7 @@ void SendChar(unsigned char c)
|
|
|
|
|
case ',': SendDah(AUTO); SendDah(AUTO); SendDit(AUTO); SendDit(AUTO); SendDah(AUTO); SendDah(AUTO); break;
|
|
|
|
|
case '?': SendDit(AUTO); SendDit(AUTO); SendDah(AUTO); SendDah(AUTO); SendDit(AUTO); SendDit(AUTO); break;
|
|
|
|
|
case '@': SendDit(AUTO); SendDah(AUTO); SendDah(AUTO); SendDit(AUTO); SendDah(AUTO); SendDit(AUTO); break;
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|