maxint-rd / TM16xx

Arduino TM16xx library for LED & KEY and LED Matrix modules based on TM1638, TM1637, TM1640 and similar chips. Simply use print() on 7-segment and use Adafruit GFX on matrix.
164 stars 34 forks source link

Example for setting dots in setDisplayToString? #13

Open tekadept opened 3 years ago

tekadept commented 3 years ago

Hi is it possible you can provide an example for setting dots in setdisplay to string? I see it takes a word for setting dots as second parameter, but I'm not sure how to work that. Ie what do I send to make dot 3 and 5 on?

maxint-rd commented 3 years ago

Hello @tekadept , I will add a more descriptive example as soon as I can find the time. The method setDisplayToString() accepts a second parameter to set the dots, just like the method setDisplayToDecNumber(),

The example TM16xx_setSegments shows on line #47 how the first four dots of the display are switched on, and the last four are switched off: module.setDisplayToString("HALO1234", 0xF0); That line probably should have some comment added. The secondary parameter is a composite of a binary values, used to indicate for each digit if the dot should be on or off.

To compose such value you can use the hexadecimal notation as used above. You can also use binary notation: module.setDisplayToString("HALO1234", B11110000); Another alternative is to combine bit values using | and _BV(), (or use bit() in case your display has more than 8 digits): module.setDisplayToString("HALO1234", _BV(7) | _BV(6) | _BV(5) | _BV(4));

So to conclude, for your example setting you could try this: module.setDisplayToString("HALO1234", _BV(5) | _BV(3)); If the wrong dots light up, you may want to reverse the order.

BTW. the example TM1638_TM1637ex_two_modules uses various other methods to show some things, including the class TM16xxDisplay, which supports the familiar and easy to use Arduino print() function.