gavinlyonsrepo / TM1638plus

An Arduino library to drive TM1638 seven segment modules.
https://gavinlyonsrepo.github.io/
GNU General Public License v3.0
80 stars 25 forks source link

V1.6.0 - readButtons() not working #14

Closed FourOaks1 closed 3 years ago

FourOaks1 commented 3 years ago

Using "Model 1". When I update from V1.5.0 to 1.6.0 (or 1.7.0) the "readButtons()" method returns 0xff with no buttons pressed (previously worked fine). I have tried providing the additional constructor parameter (false) but that made no difference. Same code, same hardware. Change back to V1.5.0. and all is good again.

Seems odd in that if this is a real issue I would have thought it would have been noticed by now - so have I not spotted something in the upgrade path I should have done?

gavinlyonsrepo commented 3 years ago

Hi

I double check here now. I am on v1.7.0 (the latest version oct 2020) tested Model 1 on an Arduino UNO on the TM1638plus_TEST_Model1.ino example file , everything works. it returns 0x00. no buttons pressed.

What micro controller do you use? What code? You use arduino IDE?

I cannot think of a reason why or how this happened.

You could try deleting the library folder from your arduino libraries folder and then installing v1.7.0.

Regards

FourOaks1 commented 3 years ago

Hi Gavin,

Enclosed is some code stripped right down to just reading the buttons and was used for the following tests.

The processor is an Arduino Pro Mini, and I am using the Arduino IDE. The serial monitor output for V1.7.0 is below, and further down is 1.5.0.

I deleted the TM1638plus library folder and reinstalled V1.7.0 first and ran the test on that, then installed V1.5.0. and ran the test again.

V1.7.0… image

V1.5.0…

image

Button Test.zip

Regards, David.

gavinlyonsrepo commented 3 years ago

Hi

By using your code snippet i was able to replicate your problem on my bench and i think i figured it out Your code is missing the lk.displayBegin() method in the setup.

void initLED() { lk.displayBegin(); lk.reset(); lk.brightness(1); }

This method was added in version 1.4.0 (feb 2020 according to changelog) the reason was originally I was setting the pinmodes in the class constructor and this is bad practise. So I had to put these pinmode setup in a new begin method which now needed to be called in setup, this broke backwards compatibility with old example code but i had no other way to do it.

So any old (pre 1.4.0) example file or example code would be missing the begin method. I think that its anyway.

regards

FourOaks1 commented 3 years ago

Ah, terrific that fixes it. I did suspect it was probably something I'd missed and was indeed the case. I had previously been using V1.2.0 and went straight to 1.7.0 so I had a good chance of missing it :-).

Many thanks, David.