コード例 #1
0
        private void tmrPOLL_Tick(object sender, EventArgs e)
        {
            if (gpio.GetBit(IN1))
            {
                // Button Unpushed
                rbIN1.Checked = false;
                tUnpushed    += 100; //ms

                if (tPushed != 0)
                {
                    if (tPushed < 400)
                    {
                        this.morseCodeBox.Text += ".";
                        morseChar = (byte)(morseChar << 1);
                    }
                    else
                    {
                        this.morseCodeBox.Text += "-";
                        morseChar = (byte)((morseChar << 1) + 1);
                    }
                    tPushed = 0;
                }


                if (tUnpushed == 800)
                {
                    if (morseChar != 1)
                    {
                        this.morseCodeBox.Text += "/";

                        byte codeIndex = 27;
                        byte i;
                        for (i = 0; i < 27; i++)
                        {
                            if (codeMorse[i] == morseChar)
                            {
                                codeIndex = i;
                                break;
                            }
                        }
                        this.textCodeBox.Text += codeText[codeIndex];
                        morseChar              = 1;
                    }
                }
                else if (tUnpushed == 2000)
                {
                    this.morseCodeBox.Text += "  /";
                    this.textCodeBox.Text  += " ";
                }
            }
            else
            {
                // Button Pushed
                rbIN1.Checked = true;
                tPushed      += 100; //ms

                if (tUnpushed != 0)
                {
                    tUnpushed = 0;
                }
            }
        }