#ifdef LOCALCW
+// Note we cannot use debouncing, as after the first interrupt,
+// we might read the wrong level. So we forward all CW interrupts
+// to the keyer.
+
static void setup_cw_pin(int pin, void(*pAlert)(void)) {
-fprintf(stderr,"setup_cw_pin: pin=%d \n",pin);
+ fprintf(stderr,"setup_cw_pin: pin=%d \n",pin);
pinMode(pin,INPUT);
pullUpDnControl(pin,PUD_UP);
usleep(10000);
}
static void cwAlert_left() {
- int level=digitalRead(CWL_BUTTON);
- //fprintf(stderr,"cwl button : level=%d \n",level);
- if (cw_keyer_internal == 0 ){
- keyer_event(CWL_BUTTON, cw_active_level == 0 ? level : (level==0));
- }
+ int level;
+ if (cw_keyer_internal != 0) return; // as quickly as possible
+ level=digitalRead(CWL_BUTTON);
+ //fprintf(stderr,"cwl button : level=%d \n",level);
+ keyer_event(CWL_BUTTON, cw_active_level == 0 ? level : (level==0));
}
static void cwAlert_right() {
- int level=digitalRead(CWR_BUTTON);
- //fprintf(stderr,"cwr button : level=%d \n",level);
- if (cw_keyer_internal == 0 ){
- keyer_event(CWR_BUTTON, cw_active_level == 0 ? level : (level==0));
- }
+ int level;
+ if (cw_keyer_internal != 0) return; // as quickly as possible
+ level=digitalRead(CWR_BUTTON);
+ //fprintf(stderr,"cwr button : level=%d \n",level);
+ keyer_event(CWR_BUTTON, cw_active_level == 0 ? level : (level==0));
}
#endif
#include "new_protocol.h"
#include "iambic.h"
#include "transmitter.h"
+#include "ext.h"
static void* keyer_thread(void *arg);
static pthread_t keyer_thread_id;
static sem_t cw_event;
#endif
+static int cwvox = 0;
+
int keyer_out = 0;
// using clock_nanosleep of librt
void keyer_event(int gpio, int level) {
int state = (level == 0);
- // This is for aborting CAT CW messages if the key is hit.
if (state) {
+ // This is for aborting CAT CW messages if the key is hit.
cw_key_hit = 1;
+ // we do PTT as soon as possible ...
+ if (running && !cwvox) {
+ g_idle_add(ext_mox_update, (gpointer)(long) 1);
+ cwvox=(int) vox_hang;
+ }
}
- if (gpio == CWL_BUTTON)
+ if (gpio == CWL_BUTTON) {
kcwl = state;
- else // CWR_BUTTON
+ //fprintf(stderr,"L=%d\n",state);
+ } else { // CWR_BUTTON
kcwr = state;
+ //fprintf(stderr,"R=%d\n",state);
+ }
if (state || cw_keyer_mode == KEYER_STRAIGHT) {
#ifdef __APPLE__
// MOX before starting local CW.
keyer_out = state;
if(protocol==NEW_PROTOCOL) schedule_high_priority(9);
- fprintf(stderr,"set_keyer_out keyer_out= %d\n", keyer_out);
+ //fprintf(stderr,"set_keyer_out keyer_out= %d\n", keyer_out);
if (state) {
// DL1YCF: we must call cw_hold_key in *any* case, else no
// CW signal will be produced. We certainly do not
key_state = CHECK;
- while (key_state != EXITLOOP) {
- switch(key_state) {
+ // If MOX still hanging, continue spinnning/checking and decrement cwvox
+
+ while (key_state != EXITLOOP || cwvox > 0) {
+ if (cwvox > 0 && key_state != EXITLOOP && key_state != CHECK) cwvox=(int) vox_hang;
+ switch (key_state) {
+ case EXITLOOP:
+ if (cwvox >0) cwvox--;
+ if (cwvox == 0) {
+ g_idle_add(ext_mox_update,(gpointer)(long) 0);
+ } else {
+ key_state=CHECK;
+ }
+ break;
case CHECK: // check for key press
+ if (cwvox > 1) cwvox--;
if (cw_keyer_mode == KEYER_STRAIGHT) { // Straight/External key or bug
if (*kdash) { // send manual dashes
set_keyer_out(1);