コード例 #1
0
 public static void Main()
 {
     // Initializes the button
     AutoRepeatInputPort Button = new AutoRepeatInputPort(Pins.ONBOARD_SW1, Port.ResistorMode.PullUp, true);
     // Attaches the event
     Button.StateChanged += new AutoRepeatEventHandler(Button_StateChanged);
     // Tells you what to do :-)
     Debug.Print("Press the onboard switch for a while");
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: wangzhefeng2000/cetdevelop
        public static void Main()
        {
            int duty = 0;

            //define the PWM out
            var pwm = new PWM(Pins.GPIO_PIN_D5);

            pwm.SetDutyCycle((uint)duty);

            //define the input port for the "decrement" button
            var btnDec = new AutoRepeatInputPort(
                port: Pins.GPIO_PIN_D8,
                resistor: Port.ResistorMode.PullUp,
                activeLevel: false);

            btnDec.InitialDelay  = 1000;
            btnDec.StateChanged += (s, e) =>
            {
                if (e.State != AutoRepeatInputPort.AutoRepeatState.Release)
                {
                    duty--;
                    if (duty < 0)
                    {
                        duty = 0;
                    }

                    pwm.SetDutyCycle((uint)duty);
                }
            };

            //define the input port for the "increment" button
            var btnInc = new AutoRepeatInputPort(
                port: Pins.GPIO_PIN_D9,
                resistor: Port.ResistorMode.PullUp,
                activeLevel: false);

            btnInc.InitialDelay  = 1000;
            btnInc.StateChanged += (s, e) =>
            {
                if (e.State != AutoRepeatInputPort.AutoRepeatState.Release)
                {
                    duty++;
                    if (duty > 100)
                    {
                        duty = 100;
                    }

                    pwm.SetDutyCycle((uint)duty);
                }
            };

            //do nothing
            Thread.Sleep(Timeout.Infinite);
        }
コード例 #3
0
 /// <summary>
 /// Extension wrapper to the standard <see cref="Microsoft.SPOT.EventArgs"/> object, thus the state of the auto-repeat may be carried out to the host
 /// </summary>
 /// <param name="state"></param>
 public AutoRepeatEventArgs(AutoRepeatInputPort.AutoRepeatState state)
 {
     this.State = state;
 }