void gpio_cw_sidetone_set(int level) {}
#endif
+void keyer_straight_key(state) {
+ //
+ // Interface for simple key-down action e.g. from a MIDI message
+ //
+ if (state != 0) {
+ cw_key_down=960000; // max. 20 sec to protect hardware
+ cw_key_up=0;
+ cw_key_active=1;
+ gpio_cw_sidetone_set(1);
+ } else {
+ cw_key_down=0;
+ cw_key_up=0;
+ gpio_cw_sidetone_set(0);
+ }
+}
+
void keyer_update() {
//
// This function will take notice of changes in the following variables
// If both paddles are pressed (should not happen), then
// the dash paddle wins.
if (*kdash) { // send manual dashes
- cw_key_down=960000; // 20 sec maximum
- cw_key_up=0;
- gpio_cw_sidetone_set(1);
+ keyer_straight_key(1); // do key down
key_state=STRAIGHT;
}
} else {
// Wait for dash paddle being released in "straight key" mode.
//
if (! *kdash) {
- cw_key_down=0;
- gpio_cw_sidetone_set(0);
+ keyer_straight_key(0); // key-up
key_state=CHECK;
}
break;
/////////////////////////////////////////////////////////// "CW"
case MIDI_ACTION_CWKEY: // only key
//
- // This is a CW key-up/down which works outside the keyer.
- // It is intended for the use of external keyers
- // and works if not compiled with LOCALCW
- // and/or using "CW handled in radio".
- // NO BREAK-IN! The keyer has to send a MIDI "PTT on" command and
- // wait a decent amount of time before doing key-down.
+ // This is a CW key-up/down which uses functions from the keyer
+ // that by-pass the interrupt-driven standard action.
+ // It is intended to
+ // be used with external keyers that send key-up/down messages via
+ // MIDI using this command.
+ //
+ // NO BREAK-IN! The keyer has to take care of sending MIDI PTT
+ // on/off messages at appropriate times.
//
+#ifdef LOCALCW
if (type == MIDI_TYPE_KEY) {
- if (val != 0) {
- cw_key_down=960000; // max. 20 sec to protect hardware
- cw_key_up=0;
- cw_key_hit=1; // abort any pending CAT CW messages
- } else {
- cw_key_down=0;
- cw_key_up=0;
- }
+ keyer_straight_key(val);
}
+#else
+ g_print("%s: CWKEY:%d\n",__FUNCTION__,val);
+
+#endif
break;
/////////////////////////////////////////////////////////// "CWL"
/////////////////////////////////////////////////////////// "CWR"