FEZ Spider II (G120E) with TinyClr event

I’ve connect a Button (V1.4) on socket 4 on FEZ Spider II and same button on FEZ Panda III (pin3 -> D3, pin4 -> D2).
Value of reading is always correct, but event is only raised on FEZ Panda III.

Here is code (I change mb value when changing mainboard):


using System;
using System.Threading;
using GHIElectronics.TinyCLR.Devices.Gpio;
using GHIElectronics.TinyCLR.Pins;

namespace testButton
{
    enum Mainboard
    {
        FEZSpiderII,
        FEZPandaIII
    };

    public class Program
    {
        private static GpioPin _led;
        private static GpioPin _btn;
        public static void Main()
        {
            Mainboard mb=Mainboard.FEZSpiderII;

            GpioController gpio = GpioController.GetDefault();

            if (mb == Mainboard.FEZSpiderII)
            {
                _led = gpio.OpenPin(G120E.GpioPin.P2_0);
                _btn = gpio.OpenPin(G120E.GpioPin.P2_31);
            }
            else
            {
                _led = gpio.OpenPin(FEZPandaIII.GpioPin.D2);
                _btn = gpio.OpenPin(FEZPandaIII.GpioPin.D3);
            }
            _led.SetDriveMode(GpioPinDriveMode.Output);
            _btn.SetDriveMode(GpioPinDriveMode.InputPullUp);

            _btn.ValueChanged += Btn_ValueChanged;

            for (int i = 0; i < 4; i++)
            {
                _led.Write(GpioPinValue.High);
                Thread.Sleep(200);
                _led.Write(GpioPinValue.Low);
                Thread.Sleep(200);
            }
            while (true)
            {
                _led.Write(_btn.Read()==GpioPinValue.Low?GpioPinValue.High : GpioPinValue.Low);
                Thread.Sleep(20);
            }
        }

        private static void Btn_ValueChanged(object sender, GpioPinValueChangedEventArgs e)
        {
        }
    }
}

@ Bauland -

It is a bug in G120E, they worked fine in G120.
Thanks for showing us the issue.

@ Bauland -

Used your code on my Spider II and I also tried different sockets. All had the same fault.

Good observation on your part!

I hope it will be corrected soon … I can’t complete some classes for some modules. I know I can use a thread to read, as read function works but it not really a clean solution.

I can only see that as I have a FEZ Panda to compare. At the beginning, I believe I don’t understand how event works !!!

@ Dat - Could it be corrected for next realse of TinyClr or it is from G120E and cannot be corrected ?

@ Bauland - It is still on our list to look into.

@ John - Thanks for the information.

It is working with new version of TinyClr 0.3.0 ! Thanks for work. :clap: :clap: :clap: