1st Test new CW Keyer and add cat message processing

This commit is contained in:
phdlee 2018-01-27 18:05:08 +09:00
parent cc7dd752e6
commit 8d4c788e11
2 changed files with 121 additions and 106 deletions

View File

@ -597,8 +597,13 @@ applied Threshold for reduct errors, dial Lock, dynamic Step
byte threshold = 2; //noe action for count byte threshold = 2; //noe action for count
unsigned long lastEncInputtime = 0; unsigned long lastEncInputtime = 0;
int encodedSumValue = 0; int encodedSumValue = 0;
unsigned long lastTunetime = 0; //if continous moving, skip threshold processing
byte lastMovedirection = 0; //0 : stop, 1 : cw, 2 : ccw
#define skipThresholdTime 100
#define encodeTimeOut 1000 #define encodeTimeOut 1000
void doTuning(){
void doTuningWithThresHold(){
int s = 0; int s = 0;
unsigned long prev_freq; unsigned long prev_freq;
long incdecValue = 0; long incdecValue = 0;
@ -615,6 +620,8 @@ void doTuning(){
if (s == 0) { if (s == 0) {
if (encodedSumValue != 0 && (millis() - encodeTimeOut) > lastEncInputtime) if (encodedSumValue != 0 && (millis() - encodeTimeOut) > lastEncInputtime)
encodedSumValue = 0; encodedSumValue = 0;
lastMovedirection = 0;
return; return;
} }
lastEncInputtime = millis(); lastEncInputtime = millis();
@ -622,16 +629,18 @@ void doTuning(){
//for check moving direction //for check moving direction
encodedSumValue += (s > 0 ? 1 : -1); encodedSumValue += (s > 0 ? 1 : -1);
//check threshold //check threshold and operator actions (hold dial speed = continous moving, skip threshold check)
if ((encodedSumValue * encodedSumValue) <= (threshold * threshold)) if ((lastTunetime < millis() - skipThresholdTime) && ((encodedSumValue * encodedSumValue) <= (threshold * threshold)))
return; return;
lastTunetime = millis();
//Valid Action without noise //Valid Action without noise
encodedSumValue = 0; encodedSumValue = 0;
prev_freq = frequency; prev_freq = frequency;
//incdecValue = tuningStep * s; //incdecValue = tuningStep * s;
frequency += (arTuneStep[tuneStepIndex -1] * s); frequency += (arTuneStep[tuneStepIndex -1] * s * (s * s < 10 ? 1 : 3)); //appield weight (s is speed)
if (prev_freq < 10000000l && frequency > 10000000l) if (prev_freq < 10000000l && frequency > 10000000l)
isUSB = true; isUSB = true;
@ -1036,7 +1045,7 @@ void loop(){
if (ritOn) if (ritOn)
doRIT(); doRIT();
else else
doTuning(); doTuningWithThresHold();
} }
//we check CAT after the encoder as it might put the radio into TX //we check CAT after the encoder as it might put the radio into TX

View File

@ -133,9 +133,9 @@ void cwKeyer(void){
int dot,dash; int dot,dash;
bool continue_loop = true; bool continue_loop = true;
unsigned tmpKeyControl = 0; unsigned tmpKeyControl = 0;
if( Iambic_Key ){
while(continue_loop){ if( Iambic_Key ) {
while(continue_loop) {
switch (keyerState) { switch (keyerState) {
case IDLE: case IDLE:
tmpKeyControl = update_PaddleLatch(0); tmpKeyControl = update_PaddleLatch(0);
@ -207,11 +207,12 @@ while(continue_loop){
} }
break; break;
} }
} //end of while
}else{ Check_Cat(3);
} //end of while
}
else{
while(1){ while(1){
//if (analogRead(ANALOG_DOT) < 600){
if (update_PaddleLatch(0) == DIT_L) { if (update_PaddleLatch(0) == DIT_L) {
// if we are here, it is only because the key is pressed // if we are here, it is only because the key is pressed
if (!inTx){ if (!inTx){
@ -219,12 +220,14 @@ while(continue_loop){
cwTimeout = millis() + cwDelayTime * 10; //+ CW_TIMEOUT; cwTimeout = millis() + cwDelayTime * 10; //+ CW_TIMEOUT;
startTx(TX_CW, 1); startTx(TX_CW, 1);
} }
// start the transmission)
cwKeydown(); cwKeydown();
//while ( analogRead(ANALOG_DOT) < 600 ) delay(1);
while ( update_PaddleLatch(0) == DIT_L ) delay(1); while ( update_PaddleLatch(0) == DIT_L )
delay_background(1, 3);
cwKeyUp(); cwKeyUp();
}else{ }
else{
if (0 < cwTimeout && cwTimeout < millis()){ if (0 < cwTimeout && cwTimeout < millis()){
cwTimeout = 0; cwTimeout = 0;
keyDown = 0; keyDown = 0;
@ -234,11 +237,14 @@ while(continue_loop){
return; return;
// got back to the beginning of the loop, if no further activity happens on straight key // got back to the beginning of the loop, if no further activity happens on straight key
// we will time out, and return out of this routine // we will time out, and return out of this routine
delay(5); //delay(5);
delay_background(5, 3);
continue; continue;
} }
} //end of else
} Check_Cat(2);
} //end of while
} //end of elese
} }