Ejemplo n.º 1
0
 public static void Main()
 {
     // Initializes a new rotary encoder object
     RotaryEncoder Knob = new RotaryEncoder(Pins.GPIO_PIN_D0, Pins.GPIO_PIN_D1);
     // Bounds the event to the rotary encoder
     Knob.Rotated += new NativeEventHandler(Knob_Rotated);
     // Wait infinitely
     Thread.Sleep(Timeout.Infinite);
 }
Ejemplo n.º 2
0
        public static void Main()
        {
            // Defines all 16 LEDs linked to two 74HC595 ICs in a chain
            Ic74hc595 IcChain = new Ic74hc595(SPI_Devices.SPI1, Pins.GPIO_PIN_D10, 2);
            Led = IcChain.Pins;

            // Defines the rotary encoder
            RotaryEncoder Knob = new RotaryEncoder(Pins.GPIO_PIN_D0, Pins.GPIO_PIN_D1);
            Knob.Rotated += new NativeEventHandler(Knob_Rotated);

            // Links the event to the button
            Button.StateChanged += new AutoRepeatEventHandler(Button_StateChanged);

            // Wait infinitely
            Thread.Sleep(Timeout.Infinite);
        }
Ejemplo n.º 3
0
        public static void Main()
        {
            //dynamo
            var dynamo = new DynamoEncoder(Pins.GPIO_PIN_A2);

            dynamo.StatusChanged += (s_, e_) =>
            {
                //display the current value
                Debug.Print("Dynamo=" + dynamo.Value.ToString());
            };

            //rotary
            var rotary = new RotaryEncoder(
                Pins.GPIO_PIN_D6,
                Pins.GPIO_PIN_D7
                );

            rotary.StatusChanged += (s_, e_) =>
            {
                //display the current value
                Debug.Print("Rotary=" + rotary.Value.ToString());
            };

            //button
            var button = new PushButtonInputPort(
                Pins.GPIO_PIN_D0,
                Port.ResistorMode.PullUp,
                activeLevel: false
                );

            button.StatusChanged += (s_, e_) =>
            {
                //display the current value
                Debug.Print("Button=" + button.Read().ToString());
            };

            Thread.Sleep(Timeout.Infinite);
        }