Updated with some of the changes I made on travel. Will probably break everything...
This commit is contained in:
+45
-42
@@ -61,7 +61,7 @@ speed(wpm), symWeight(weight)
|
||||
// Calculate the length of dot, dash and silence
|
||||
void UBitxKeyer::calcRatio()
|
||||
{
|
||||
float w = (1 + symWeight) / (symWeight -1);
|
||||
float w = (1.0 + symWeight) / (symWeight - 1.0);
|
||||
spaceLen = (1200 / speed);
|
||||
dotLen = spaceLen * (w - 1);
|
||||
dashLen = (1 + w) * spaceLen;
|
||||
@@ -73,6 +73,12 @@ void UBitxKeyer::setWPM(int wpm)
|
||||
calcRatio();
|
||||
}
|
||||
|
||||
void UBitxKeyer::setWeight(float weight)
|
||||
{
|
||||
symWeight = weight;
|
||||
calcRatio();
|
||||
}
|
||||
|
||||
//======================================================================
|
||||
// Latch paddle press
|
||||
//======================================================================
|
||||
@@ -107,11 +113,10 @@ bool UBitxKeyer::doPaddles()
|
||||
if ((digitalRead(LP_in) == LOW) || (digitalRead(RP_in) == LOW) || (keyerControl & 0x03)) {
|
||||
updatePaddleLatch();
|
||||
keyerState = CHK_DIT;
|
||||
// letting this fall through // return true;
|
||||
} else {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
// break;
|
||||
return false;
|
||||
//break;
|
||||
|
||||
case CHK_DIT: // See if the dit paddle was pressed
|
||||
if (keyerControl & DIT_L) {
|
||||
@@ -119,59 +124,57 @@ bool UBitxKeyer::doPaddles()
|
||||
ktimer = dotLen;
|
||||
keyerState = KEYED_PREP;
|
||||
return true;
|
||||
} else { // fall through
|
||||
keyerState = CHK_DAH;
|
||||
}
|
||||
// fall through
|
||||
keyerState = CHK_DAH;
|
||||
|
||||
case CHK_DAH: // See if dah paddle was pressed
|
||||
if (keyerControl & DAH_L) {
|
||||
ktimer = dashLen;
|
||||
keyerState = KEYED_PREP;
|
||||
// letting this fall through // return true;
|
||||
return true;
|
||||
} else {
|
||||
keyerState = IDLE;
|
||||
return false;
|
||||
}
|
||||
// break;
|
||||
//break;
|
||||
|
||||
case KEYED_PREP: // Assert key down, start timing
|
||||
// state shared for dit or dah
|
||||
keyDown = true;
|
||||
ktimer += millis(); // set ktimer to interval end time
|
||||
keyerControl &= ~(DIT_L + DAH_L); // clear both paddle latch bits
|
||||
keyerState = KEYED; // next state
|
||||
// letting this fall through // return true;
|
||||
// break;
|
||||
case KEYED_PREP: // Assert key down, start timing
|
||||
// state shared for dit or dah
|
||||
keyDown = true;
|
||||
ktimer += millis(); // set ktimer to interval end time
|
||||
keyerControl &= ~(DIT_L + DAH_L); // clear both paddle latch bits
|
||||
keyerState = KEYED; // next state
|
||||
return true;
|
||||
//break;
|
||||
|
||||
case KEYED: // Wait for timer to expire
|
||||
if (millis() > ktimer) { // are we at end of key down ?
|
||||
keyDown = false;
|
||||
ktimer = millis() + spaceLen; // inter-element time
|
||||
keyerState = INTER_ELEMENT; // next state
|
||||
// letting this fall through // return true;
|
||||
} else if (keyMode == IAMBICB) { // Iambic B Mode ?
|
||||
updatePaddleLatch(); // yes, early paddle latch in Iambic B mode
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
// break;
|
||||
case KEYED: // Wait for timer to expire
|
||||
if (millis() > ktimer) { // are we at end of key down ?
|
||||
keyDown = false;
|
||||
ktimer = millis() + spaceLen; // inter-element time
|
||||
keyerState = INTER_ELEMENT; // next state
|
||||
return true;
|
||||
} else if (keyMode == IAMBICB) { // Iambic B Mode ?
|
||||
updatePaddleLatch(); // yes, early paddle latch in Iambic B mode
|
||||
}
|
||||
return true;
|
||||
// break;
|
||||
|
||||
case INTER_ELEMENT: // Insert time between dits/dahs
|
||||
updatePaddleLatch(); // latch paddle state
|
||||
if (millis() > ktimer) { // are we at end of inter-space ?
|
||||
if (keyerControl & DIT_PROC) { // was it a dit or dah ?
|
||||
keyerControl &= ~(DIT_L + DIT_PROC); // clear two bits
|
||||
keyerState = CHK_DAH; // dit done, check for dah
|
||||
return true;
|
||||
} else {
|
||||
keyerControl &= ~(DAH_L); // clear dah latch
|
||||
keyerState = IDLE; // go idle
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
updatePaddleLatch(); // latch paddle state
|
||||
if (millis() > ktimer) { // are we at end of inter-space ?
|
||||
if (keyerControl & DIT_PROC) { // was it a dit or dah ?
|
||||
keyerControl &= ~(DIT_L + DIT_PROC); // clear two bits
|
||||
keyerState = CHK_DAH; // dit done, check for dah
|
||||
return true;
|
||||
} else {
|
||||
keyerControl &= ~(DAH_L); // clear dah latch
|
||||
keyerState = IDLE; // go idle
|
||||
return false;
|
||||
}
|
||||
// break;
|
||||
}
|
||||
return true;
|
||||
//break;
|
||||
}
|
||||
|
||||
return false; // resolve compiler warning; do we ever get here?
|
||||
|
||||
Reference in New Issue
Block a user