diff --git a/ubitx_20/ubitx.h b/ubitx_20/ubitx.h index 5d22b4a..28c8ab0 100644 --- a/ubitx_20/ubitx.h +++ b/ubitx_20/ubitx.h @@ -41,6 +41,9 @@ //Select betwen Analog S-Meter and DSP (I2C) Meter //#define USE_I2CSMETER +// Use alternate keyer? +#define USE_ALTKEYER + //#define EXTEND_KEY_GROUP1 //MODE, BAND(-), BAND(+), STEP //#define EXTEND_KEY_GROUP2 //Numeric (0~9), Point(.), Enter //Not supported in Version 1.0x @@ -219,8 +222,10 @@ extern byte I2C_LCD_SECOND_ADDRESS; //only using Dual LCD Mode #define ANALOG_SPARE (A7) #define ANALOG_SMETER (A7) //by KD8CEC -#define KEYER_DOT (D11) -#define KEYER_DASH (D12) +#ifdef USE_ALTKEYER + #define DIGITAL_DOT (11) + #define DIGITAL_DASH (12) +#endif /** * The second set of 16 pins on the Raduino's bottom connector are have the three clock outputs and the digital lines to control the rig. diff --git a/ubitx_20/ubitx_20.ino b/ubitx_20/ubitx_20.ino index 2066939..d002b5f 100644 --- a/ubitx_20/ubitx_20.ino +++ b/ubitx_20/ubitx_20.ino @@ -1292,6 +1292,11 @@ void initPorts(){ pinMode(ANALOG_KEYER, INPUT_PULLUP); pinMode(ANALOG_SMETER, INPUT); //by KD8CEC +#ifdef USE_ALTKEYER + pinMode(DIGITAL_DOT, INPUT_PULLUP); + pinMode(DIGITAL_DASH, INPUT_PULLUP); +#endif + #ifdef USE_CUSTOM_LPF_FILTER if (isCustomFilter_A7) { diff --git a/ubitx_20/ubitx_keyer.ino b/ubitx_20/ubitx_keyer.ino index 1ac1c2f..3ddfbfd 100644 --- a/ubitx_20/ubitx_keyer.ino +++ b/ubitx_20/ubitx_keyer.ino @@ -39,6 +39,21 @@ char lastPaddle = 0; //reads the analog keyer pin and reports the paddle byte getPaddle(){ +#ifdef USE_ALTKEYER + // Alternate keyer... but it looks like getPaddle() ever actually gets used, so... + if (cwMode > 0) { + // PTT functions as straight key, but only if we're in CW mode + if (digitalRead(PTT) == LOW) { + return PADDLE_STRAIGHT; + } + } else { + // paddles work whether or not CW mode is actually selected + int rv = 0; + rv |= digitalRead(DIGITAL_DOT) == LOW ? 1 : 0; + rv |= digitalRead(DIGITAL_DASH) == LOW ? 2 : 0; + return rv; + } +#else int paddle = analogRead(ANALOG_KEYER); if (paddle > 800) // above 4v is up @@ -52,6 +67,7 @@ byte getPaddle(){ return PADDLE_BOTH; //both are between 1 and 2v else return PADDLE_STRAIGHT; //less than 1v is the straight key +#endif } /** @@ -96,9 +112,20 @@ unsigned char keyerState = IDLE; //Below is a test to reduce the keying error. do not delete lines //create by KD8CEC for compatible with new CW Logic char update_PaddleLatch(byte isUpdateKeyState) { - unsigned char tmpKeyerControl = 0; - int paddle = analogRead(ANALOG_KEYER); + unsigned char tmpKeyerControl = 0; +#ifdef USE_ALTKEYER + // One big note... I have no idea how debounce does or doesn't affect this... but there is no debounce right now. It's conceivable + // that the normal uBITX use of an analog input for this masks bouncing... + if (digitalRead(DIGITAL_DOT) == LOW) tmpKeyerControl |= DIT_L; + if (Iambic_Key) { + if ((digitalRead(DIGITAL_DASH) == LOW)) tmpKeyerControl |= DAH_L; + } else { + // I really would like to have the PTT (during CW mode) just result in key down regardless of Iambic, but this doesn't do that yet... + if ((cwMode > 0) && (digitalRead(PTT) == LOW)) tmpKeyerControl |= DIT_L; + } +#else + int paddle = analogRead(ANALOG_KEYER); if (paddle >= cwAdcDashFrom && paddle <= cwAdcDashTo) tmpKeyerControl |= DAH_L; else if (paddle >= cwAdcDotFrom && paddle <= cwAdcDotTo) @@ -111,9 +138,10 @@ char update_PaddleLatch(byte isUpdateKeyState) { tmpKeyerControl = 0 ; else if (paddle >= cwAdcSTFrom && paddle <= cwAdcSTTo) tmpKeyerControl = DIT_L ; - else - tmpKeyerControl = 0 ; + else + tmpKeyerControl = 0 ; } +#endif if (isUpdateKeyState == 1) keyerControl |= tmpKeyerControl; @@ -365,5 +393,3 @@ void cwKeyer(){ } } */ - -