Exemple #1
0
        bool read_straight_key(ref Keyer_state ks, bool keyed)
        {
            int i, j;
            debounce_buf[debounce_buf_i] = keyed;
            debounce_buf_i++;

            /* If the debounce buffer is full, determine the state of the key */
            if (debounce_buf_i >= ks.debounce)
            {
                debounce_buf_i = 0;

                j = 0;
                for (i = 0; i < ks.debounce; i++)
                    if (debounce_buf[i])
                        j++;

                keystate = (j > ks.debounce / 2) ? 1 : 0;
            }

            if (keystate == 1)
                return true;
            else
                return false;
        }
Exemple #2
0
 void KeyerInit(bool niambic, float wpm)
 {
     kl = new KeyerLogic();
     ks = new Keyer_state();
     ks.flag.iambic = niambic;
     ks.flag.autospace.khar = ks.flag.autospace.word = false;
     ks.flag.mdlmdB = true;
     ks.flag.memory.dah = true;
     ks.flag.memory.dit = true;
     ks.debounce = 2;		// could be more if sampled faster
     ks.mode = MODE_B;
     ks.weight = (int)MainForm.SetupForm.udCWWeight.Value;
     ks.wpm = wpm;
     iambic = niambic;
     TONE_SIZE = 192 * (int)(Audio.SampleRate / 48000.0);
 }
Exemple #3
0
        bool read_iambic_key(ref Keyer_state ks, bool dot, bool dash, ref KeyerLogic kl, float ticklen)
        {
            int i, j;
            int dah = 0, dit = 0;

            dah_debounce_buf[debounce_buf_i] = dash;
            dit_debounce_buf[debounce_buf_i] = dot;
            debounce_buf_i++;

            //***************************************************
            // back to business as usual
            //***************************************************

            /* If the debounce buffer is full, determine the state of the keys */
            if (debounce_buf_i >= ks.debounce)
            {
                debounce_buf_i = 0;

                j = 0;

                for (i = 0; i < ks.debounce; i++)
                {
                    if (dah_debounce_buf[i])
                        j++;
                }
                dah = (j > ks.debounce / 2) ? 1 : 0;

                j = 0;
                for (i = 0; i < ks.debounce; i++)
                {
                    if (dit_debounce_buf[i])
                        j++;
                }
                dit = (j > ks.debounce / 2) ? 1 : 0;
            }

            return klogic(ref kl,
                dit,
                dah,
                ks.wpm,
                ks.mode,
                ks.flag.mdlmdB,
                ks.flag.memory.dit,
                ks.flag.memory.dah,
                ks.flag.autospace.khar,
                ks.flag.autospace.word, ks.weight, ticklen);
        }