From 39293c4130a708385eaab7a5a3bd4ecac1138383 Mon Sep 17 00:00:00 2001 From: Rob French Date: Fri, 28 Feb 2020 23:34:44 -0600 Subject: [PATCH] Updated GPIO keyer with enable/disable functionality. --- __init__.py | 2 +- gpiokeyer.c | 12 +++++++++--- quisk.c | 12 ++++++++++++ quisk.h | 5 ++++- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/__init__.py b/__init__.py index 91e915f..53ccd50 100755 --- a/__init__.py +++ b/__init__.py @@ -1 +1 @@ -#Quisk version 4.1.52-upr1 +#Quisk version 4.1.52 diff --git a/gpiokeyer.c b/gpiokeyer.c index 52bc846..a501fff 100644 --- a/gpiokeyer.c +++ b/gpiokeyer.c @@ -145,6 +145,7 @@ static sem_t cw_event; static int cw_hangtime_msec = 250; static int running, keyer_out = 0; +static int cw_keyer_enabled = 1; // Function prototypes @@ -217,10 +218,10 @@ void clear_memory() { static void set_keyer_out(int state) { if (state && tr_switch_gpio) { - digitalWrite(tr_switch_gpio, 1); + digitalWrite(tr_switch_gpio, 1 & cw_keyer_enabled); } keyer_out = state; - digitalWrite(keyer_out_gpio, keyer_out); + digitalWrite(keyer_out_gpio, keyer_out & cw_keyer_enabled); } static void* keyer_thread(void *arg) { @@ -502,7 +503,7 @@ void close_key_gpiokeyer(void) int is_key_down_gpiokeyer(void) { static int retval; - retval = keyer_out; + retval = keyer_out & cw_keyer_enabled; return retval; } @@ -542,4 +543,9 @@ void quisk_set_gpio_keyer_strict(int flag) cw_keyer_spacing = (flag == 0 ? 0 : 1); } +void quisk_set_gpio_keyer_enabled(int flag) +{ + cw_keyer_enabled = (flag == 0 ? 0 : 1); +} + #endif diff --git a/quisk.c b/quisk.c index cf9aa69..91705cc 100755 --- a/quisk.c +++ b/quisk.c @@ -5231,6 +5231,17 @@ static PyObject * set_gpio_keyer_strict(PyObject * self, PyObject * args) Py_INCREF (Py_None); return Py_None; } + +static PyObject * set_gpio_keyer_enabled(PyObject * self, PyObject * args) +{ + int enabled; + + if (!PyArg_ParseTuple (args, "i", &enabled)) + return NULL; + quisk_set_gpio_keyer_enabled(enabled); + Py_INCREF (Py_None); + return Py_None; +} #endif static PyMethodDef QuiskMethods[] = { @@ -5339,6 +5350,7 @@ static PyMethodDef QuiskMethods[] = { {"set_gpio_keyer_weight", set_gpio_keyer_weight, METH_VARARGS, "Change the CW keyer symbol weight."}, {"set_gpio_keyer_reversed", set_gpio_keyer_reversed, METH_VARARGS, "Enabled/disable reversed paddles."}, {"set_gpio_keyer_strict", set_gpio_keyer_strict, METH_VARARGS, "Enable/disable strict character spacing."}, + {"set_gpio_keyer_enabled", set_gpio_keyer_enabled, METH_VARARGS, "Enable/disable the CW keyer"}, #endif {NULL, NULL, 0, NULL} /* Sentinel */ }; diff --git a/quisk.h b/quisk.h index 972064c..fd16fab 100755 --- a/quisk.h +++ b/quisk.h @@ -288,6 +288,7 @@ void quisk_set_gpio_keyer_speed(int); void quisk_set_gpio_keyer_weight(int); void quisk_set_gpio_keyer_reversed(int); void quisk_set_gpio_keyer_strict(int); +void quisk_set_gpio_keyer_enabled(int); #endif // Functions supporting digital voice codecs @@ -347,6 +348,7 @@ int import_quisk_api(void); // used to initialize Quisk_API //#define quisk_set_gpio_keyer_weight (*( void (*) (int) )Quisk_API[13]) //#define quisk_set_gpio_keyer_reversed (*( void (*) (int) )Quisk_API[14]) //#define quisk_set_gpio_keyer_strict (*( void (*) (int) )Quisk_API[15]) +//#define quisk_set_gpio_keyer_enabled (*( void (*) (int) )Quisk_API[16]) //#endif #else @@ -368,6 +370,7 @@ void quisk_sample_source4(ty_sample_start, ty_sample_stop, ty_sample_read, ty_sa //void quisk_set_gpio_keyer_weight(int); //void quisk_set_gpio_keyer_reversed(int); //void quisk_set_gpio_keyer_strict(int); +//void quisk_set_gpio_keyer_enabled(int); //#endif //#if defined(ENABLE_GPIO_KEYER) @@ -375,7 +378,7 @@ void quisk_sample_source4(ty_sample_start, ty_sample_stop, ty_sample_read, ty_sa // &quisk_sound_state, &QuiskGetConfigInt, &QuiskGetConfigDouble, &QuiskGetConfigString, &QuiskTimeSec, \ // &QuiskSleepMicrosec, &QuiskPrintTime, &quisk_sample_source, &quisk_dvoice_freedv, &quisk_is_key_down, \ // &quisk_sample_source4, &quisk_set_gpio_keyer_mode, &quisk_set_gpio_keyer_speed, \ -// &quisk_set_gpio_keyer_weight, &quisk_set_gpio_keyer_reversed, &quisk_set_gpio_keyer_strict \ +// &quisk_set_gpio_keyer_weight, &quisk_set_gpio_keyer_reversed, &quisk_set_gpio_keyer_strict, &quisk_set_gpio_keyer_enabled \ // } //#else #define QUISK_API_INIT { \