3 //========================================================================
5 /* Read a straight key connected to a serial port, do debouncing, then
6 return the key state */
9 read_straight_key(KeyerState ks, BOOLEAN keyed) {
11 static BOOLEAN keystate = 0;
12 static int debounce_buf_i = 0,
13 debounce_buf[DEBOUNCE_BUF_MAX_SIZE];
14 debounce_buf[debounce_buf_i] = keyed;
18 //***************************************************
19 // back to business as usual
20 //***************************************************
22 /* If the debounce buffer is full, determine the state of the key */
23 if (debounce_buf_i >= ks->debounce) {
27 for (i = 0; i < ks->debounce; i++)
30 keystate = (j > ks->debounce / 2) ? 1 : 0;
36 //------------------------------------------------------------------------
38 /* Read an iambic key connected to a serial port, do debouncing, emulate a
39 straight key, then return the emulated key state */
42 read_iambic_key(KeyerState ks, BOOLEAN dash, BOOLEAN dot, KeyerLogic kl, double ticklen) {
44 static BOOLEAN dah_debounce_buf[DEBOUNCE_BUF_MAX_SIZE],
45 dit_debounce_buf[DEBOUNCE_BUF_MAX_SIZE];
46 static int dah = 0, debounce_buf_i = 0, dit = 0;
48 if (ks->flag.revpdl) {
49 dah_debounce_buf[debounce_buf_i] = dot;
50 dit_debounce_buf[debounce_buf_i] = dash;
52 dah_debounce_buf[debounce_buf_i] = dash;
53 dit_debounce_buf[debounce_buf_i] = dot;
58 //***************************************************
59 // back to business as usual
60 //***************************************************
62 /* If the debounce buffer is full, determine the state of the keys */
63 if (debounce_buf_i >= ks->debounce) {
67 for (i = 0; i < ks->debounce; i++)
68 if (dah_debounce_buf[i]) j++;
69 dah = (j > ks->debounce / 2) ? 1 : 0;
72 for (i = 0; i < ks->debounce; i++)
73 if (dit_debounce_buf[i]) j++;
74 dit = (j > ks->debounce / 2) ? 1 : 0;
85 ks->flag.autospace.khar,
86 ks->flag.autospace.word,
91 //========================================================================