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

High speed buttons error #16

Closed IntrCol closed 3 years ago

IntrCol commented 3 years ago

The first button press cannot be detected when using high speed devices. Fixed by moving last delayMicroseconds(1); to start of for loop in TM1638plus_common::HighFreqshiftin

PS: the TM1638 works fine on 3.3V no need for voltage level shift

gavinlyonsrepo commented 3 years ago

Hi

thanks for feedback.

Ya, i mentioned that in the readme in Note B : High frequency micro-controllers. Someone mentioned that before in a email IIRC although I have never seen it. Which device are you using and at what frequency is the anomaly ?

regards

IntrCol commented 3 years ago

Hello I am using an ESP32 running at 240MHz, the buttons are read correctly in the setup part of the program but not in the loop when lots of updates are written even after a delay. I changed the method to the following and everything reads fine now. All display functions work fine

uint8_t TM1638plus_common::HighFreqshiftin(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder) { uint8_t value = 0; uint8_t i = 0;

for(i = 0; i < 8; ++i) {
    delayMicroseconds(1);
    if(bitOrder == LSBFIRST)
        value |= digitalRead(dataPin) << i;
    else
        value |= digitalRead(dataPin) << (7 - i);

    digitalWrite(clockPin, HIGH);
    delayMicroseconds(1);
    digitalWrite(clockPin, LOW);
}
return value;

}

On Wed, 17 Nov 2021 at 16:25, Gavin Lyons @.***> wrote:

Hi

thanks for feedback.

Ya, i mentioned that in the readme in Note B : High frequency micro-controllers. Someone mentioned that before in a email IIRC although I have never seen it. Which device are you using and at what frequency is the anomaly ?

regards

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/gavinlyonsrepo/TM1638plus/issues/16#issuecomment-971631092, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWRJGHP2DBVJN6PFIG3MY2TUMO3NDANCNFSM5IG5RIRQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

gavinlyonsrepo commented 3 years ago

Hi

I created a new version "1.8.0" minor update. To make the function more like arduino core one in wiring_shift.c https://github.com/arduino/ArduinoCore-avr/blob/master/cores/arduino/wiring_shift.c

You can test it if you want and report back please see if it works, it should.

regards

IntrCol commented 3 years ago

Thank you, I will test over the weekend and get back to you with the results.

On Thu, 18 Nov 2021 at 00:45, Gavin Lyons @.***> wrote:

Hi

I created a new version "1.8.0" minor update. To make the function more like arduino core one in wiring_shift.c

https://github.com/arduino/ArduinoCore-avr/blob/master/cores/arduino/wiring_shift.c

You can test it if you want and report back please see if it works, it should.

regards

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/gavinlyonsrepo/TM1638plus/issues/16#issuecomment-972188748, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWRJGHOA7GJXDVKW7MS3QO3UMQWAJANCNFSM5IG5RIRQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

IntrCol commented 3 years ago

Good day

I tested the version 1.8.0 and it is working perfectly, thank you very much for your help.

On Thu, 18 Nov 2021 at 00:45, Gavin Lyons @.***> wrote:

Hi

I created a new version "1.8.0" minor update. To make the function more like arduino core one in wiring_shift.c

https://github.com/arduino/ArduinoCore-avr/blob/master/cores/arduino/wiring_shift.c

You can test it if you want and report back please see if it works, it should.

regards

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/gavinlyonsrepo/TM1638plus/issues/16#issuecomment-972188748, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWRJGHOA7GJXDVKW7MS3QO3UMQWAJANCNFSM5IG5RIRQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.