TM1650 7-Segment Display. How to suppress leading zeros?

I am using maxin-rd/TM16xx library.

This is my test-code:

#include <TM1650.h>
#include <TM16xxDisplay.h>
//              [data Pin]
//              |  [clock Pin]
//              |  |  [num Digits]
//              |  |  |  [activate Display]
//              |  |  |  |     [intensity]
//              |  |  |  |     |  [display mode]
//              ↓  ↓  ↓  ↓     ↓  ↓
TM1650 display1(4, 5, 4, true, 0);
int n;

void setup() {
  display1.clearDisplay();
}

void loop() {
  for (n = 0; n < 9999; n++) {
    display1.setDisplayToDecNumber(n, 0);
    delay(300);
  }
}

setDisplayToDecNumber() doesn't suppress leading zeros.

I have seen an example at this video that is using setDisplayToSignedDecNumber ().

   display1.setDisplayToSignedDecNumber( n,       // signed long number
                                         B0000,   // byte dots
                                         false    // boolean leadingZeros = true
                                               ); // const byte numberFont[] = TM16XX_NUMBER_FONT);

It seems like that instruction can suppress the leading zeros, but I get an error when I introduce that line.

Compilation error: 'class TM1650' has no member named 'setDisplayToSignedDecNumber'; did you mean 'setDisplayToDecNumber'?

That library does not contain that keyword. Is there other library that can suppress leading zeros?

If you take a look in TM16xx/src/TM16xxDisplay.h you'll find the following in the TM16xxDisplay class:

  // Set the display to a unsigned hexadecimal number (with or without leading zeros)
  void setDisplayToHexNumber(unsigned long number, byte dots, boolean leadingZeros = true, const byte numberFont[] = TM16XX_NUMBER_FONT);
  // Set the display to a unsigned decimal number (with or without leading zeros)
  void setDisplayToDecNumber(unsigned long number, byte dots, boolean leadingZeros = true, const byte numberFont[] = TM16XX_NUMBER_FONT);
  // Set the display to a signed decimal number (with or without leading zeros)
  void setDisplayToSignedDecNumber(signed long number, byte dots, boolean leadingZeros = true, const byte numberFont[] = TM16XX_NUMBER_FONT);

and if you take a look in the some of the examples you'll find code similar to:

TM1650 module(4, 5, 4, true, 0);
TM16xxDisplay display(&module, 4);
.
.
.
display.setDisplayToSignedDecNumber(n, 0b0000, false);
1 Like

Thank you for your reply.

Yes, I have already tried

display.setDisplayToSignedDecNumber(n, 0b0000, false);

But as I have stated above, I get the error:

Compilation error: 'class TM1650' has no member named 'setDisplayToSignedDecNumber'; did you mean 'setDisplayToDecNumber'?

Your code:

TM1650 display1(4, 5, 4, true, 0);

Code from examples. Notice the difference?

TM1650 module(4, 5, 4, true, 0);
TM16xxDisplay display(&module, 4);
1 Like

My mistake! :sweat_smile:
Working now
Thank you very much for your kind support.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.