Button18 on FezHat

I use FezHAT 1.1 with Windows IoT Anniversary edition.


        private async void Setup()
        {
            _fezHat = await FEZHAT.CreateAsync();
            _timer = new DispatcherTimer();
            _timer.Interval = TimeSpan.FromMilliseconds(100);
            _timer.Tick += _timer_Tick;
            _timer.Start();

            _fezHat.D2.Color=FEZHAT.Color.Green;
            _fezHat.D3.Color = FEZHAT.Color.Yellow;
        }

        private void _timer_Tick(object sender, object e)
        {
            if (_fezHat.IsDIO18Pressed())
                Button18Pressed();
            if (_fezHat.IsDIO22Pressed())
                Button22Pressed();
        }

        private void Button22Pressed()
        {
            _fezHat.D3.Color = FEZHAT.Color.Blue;
        }

        private void Button18Pressed()
        {
            _fezHat.D3.Color = FEZHAT.Color.Cyan;
        }


Code for Button18Pressed is never reached ! IsDIO18Pressed() is always returning false. Have I missed some setup or Hat is faulty ? Button22 is perfectly working.

@ Bauland - Can you try the below code? Hold the buttons for a second or two multiple times to be sure the events aren’t getting missed.


using System.Diagnostics;

private async void Setup()
{
	_fezHat = await FEZHAT.CreateAsync();
	_timer = new DispatcherTimer();
	_timer.Interval = TimeSpan.FromMilliseconds(25);
	_timer.Tick += (s, e) => Debug.WriteLine(_fezHat.IsDIO18Pressed() + " " + _fezHat.IsDIO22Pressed());
	_timer.Start();
}

@ John: You’re right !!!
No chance of press button always during space time between Tick calls, but it was that !!! :clap:

So with decrease of interval, all is perfectly running.
Another thing to say: in FezHat code, color magenta was misspelled, it was called “Magneta”. Where must I declare that: bitbucket or task tracker ?

@ Bauland - The misspelling is in our internal issue tracker, it’ll be corrected for the next release.