TM16xx icon indicating copy to clipboard operation
TM16xx copied to clipboard

Example for setting dots in setDisplayToString?

Open tekadept opened this issue 3 years ago • 1 comments

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?

tekadept avatar Feb 06 '21 00:02 tekadept

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.

maxint-rd avatar Feb 14 '21 14:02 maxint-rd