Skip to content

Only one device works at a time #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
akastormseeker opened this issue Mar 25, 2025 · 4 comments
Closed

Only one device works at a time #61

akastormseeker opened this issue Mar 25, 2025 · 4 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@akastormseeker
Copy link

When using multiple devices (TM1650 in my case), only the first device used works.

My setup:
ESP32C3 micro
4x TM1650 + 4-digit 7-seg displays
Pin D6 connects to all TM1650 data pins
Pins D7-D10 connected to individual clock pins

Code:

TM1650 disp1(D6, D7);
TM1650 disp2(D6, D8);
TM1650 disp3(D6, D9);
TM1650 disp4(D6, D10);

void setup() {
  disp1.begin();
  disp2.begin();
  disp3.begin();
  disp4.begin();
  
  for(int digit = 0; digit < 4; digit++) {
    disp1.setSegments(0xff, digit);
    disp2.setSegments(0xff, digit);
    disp3.setSegments(0xff, digit);
    disp4.setSegments(0xff, digit);
  }
}

void loop() {
}

Expected behavior:
All displays light up

Actual behavior:
Only disp1 lights up

If I comment out disp1.begin();, then only disp2 lights up

@maxint-rd
Copy link
Owner

Hello @akastormseeker , thank you for reporting this. I encountered the very same issue myself when testin two TM1637 displays in Wokwi. I think I found the cause and intend to publish a new release. I wanted to do some physical testing first. Would you perhaps want to assist and test the new code on your TM1650 project? I will publish new code in the master branch shortly and let you know here...

@maxint-rd maxint-rd self-assigned this Mar 25, 2025
@maxint-rd
Copy link
Owner

Okay, reproducing this on hardware was a bit finicky. I used a CH32V003 and two TM1650 displays that shared their DIO pin but have individual CLK pins. When testing your example (modified for two modules) after first testing each display separately, your example worked just fine. But then after power off and on, your example did show that erroneous behavior.

As said I've encountered it myself sometime ago in the Wokwi simulation tool. Through debugging I found how that bug was introduced in the last release. I've made a fix and tested it locally in your example and another. Just now I published that fix.
Next step is to publish a new release to allow testing it in this Wokwi example.

@maxint-rd maxint-rd added bug Something isn't working good first issue Good for newcomers labels Mar 25, 2025
maxint-rd referenced this issue Mar 25, 2025
…to spaces)

Failure was introduced when implementing [implicit begin](952e586)
@akastormseeker
Copy link
Author

akastormseeker commented Mar 25, 2025

I actually think I figured out the problem. When testing, if you just recompile after commenting out the first one, then they both will work because the first is already initialized/turned on. The problem is the static "fBeginDone" variable in TM16xx:begin(), which applies to ALL instances of the class. I did a test and made it an instance variable and it works perfectly. I can do a pull request this morning if you'd like.

@maxint-rd
Copy link
Owner

maxint-rd commented Mar 25, 2025

Hello @akastormseeker, you're absolutely correct. When I encountered the issue, I first thought it was Wokwi specific, After debugging I found that the static variable was indeed the issue.

No need for a PR. I already published the fix and published it as a new release (v0.7.2503). It may take a day or so before the new release is picked up by the Arduino IDE, but then you should be notified of the updated release. Assuming this fixes the issue for you as well, I will close this issue as soon as I can confirm it to work in the Wokwi live demo.

Thanks again for submitting this issue with such a clear description. It raised my awareness and made me reconsider the importance of fixing this on short notice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants