jasonacox / TM1637TinyDisplay

Arduino library to display numbers and text on a 4 and 6 digit 7-segment TM1637 display modules.
GNU Lesser General Public License v3.0
69 stars 19 forks source link

Using 4 and 6 digit displays at the same time #23

Open jasonacox opened 1 year ago

jasonacox commented 1 year ago

Question from @Kravatox

I have another question, in my code I use two display, one with 4 digits and another with 6 digits, and when I include TM1637TinyDisplay.h library and TM1637TinyDisplay6.h I have this error : "warning: "MAXDIGITS" redefined" and "warning: "FRAMES" redefined". Is there any solution to use both library the same time ?

jasonacox commented 1 year ago

Hi @Kravatox

I am moving this into a new issue to address your question. Yes, you can use both. Here is a code snip from my Powerwall-Display project that uses two 4-digit displays and one 6-digit display.

#include <TM1637TinyDisplay6.h>
#include <TM1637TinyDisplay.h>

TM1637TinyDisplay display1(CLK1, DIO1);   // Solar
TM1637TinyDisplay6 display3(CLK2, DIO2);  // Power for Grid, House, Bat
TM1637TinyDisplay display2(CLK3, DIO3);   // Battery Level
CaptainSMan commented 8 months ago

Is it possible to share the one CLK pin for say two 6digit displays?

jasonacox commented 8 months ago

That is possible. However, as you update one display, it is unknown what will happen to the the other display. It is possible that it will zero out even with no DIO toggles. Let us know if you try it out.

Alternatively, you could create a new class that manages two displays and update both displays at the same time using a shared CLK.

I don't think it would be too difficult. If you or anyone else wants to attempt adding this new class, I would be happy to accept a PR to add it to the library.

CaptainSMan commented 8 months ago

Thanks Jason. I have kept them separate for now in the interest of getting my project up and running, might revisit this in the next iteration.