TM1637 colon problem

Hi all,

I have a TM1637 module and try to display the colon but without succes.
An ATtiny85 reads out two different NTC thermistors.
I would like the display to show 0 or 1 ( to know which temp is shown), then an empty space or an H when a temp goes over an upper limit, then the temperature as an int.
When the temp is too high I would like the display to show the number of the thermistor, the H and the colon and the temperature ie.
0__32 for temp 0, _ = a space character
1H:60 for temp 1
The library I use is the TM1637Display library which can be downloaded from the IDE of Arduino.
The temp number and temperature are not the problem, that works. The H when a temp is too high works as well. But it seems impossible to add the colon with the H.

      display.showNumberDec( activePin, false, 1, 0),
      display.setSegments( charH, 1, 1),
      display.showNumberDecEx( 49+activePin, 224, false, 2, 2); // test code

What data types are the parameters to the showNumberDecEx() function ?

You need to set the MSB (most significant bit) of the character pattern to 1 to display the colon (this will only work when the character is on the 2nd LED digit from the left).

void loop()
{
  display.setBrightness(0x0f);
  byte activePin = 1;
  byte charH[] = {SEG_B | SEG_C | SEG_E | SEG_F | SEG_G | 0b10000000};
  display.showNumberDec( activePin, false, 1, 0);
  display.setSegments( charH, 1, 1);
  display.showNumberDecEx( 49 + activePin, 224, false, 2, 2); // test code
  while (true);
}

@david_2018 Yep that did the trick. I had the character H defined as

const uint8_t charH[] = { 0b1110110};                   // H

Just by adding a 1 after the b like

const uint8_t charH[] = { 0b11110110};                   // H:

works like a charm.
Thanks

@UKHeliBob the data type is an INT.

There are two common version of this display. One has a colon display, one has four individual decimals. It is one or the other

Which one is yours? What actually happens when you code to show all four decimals?

// "ricc" with dots display on TM1637
//  By Paul__B on Arduino forum
#include <Arduino.h>
#include <TM1637Display.h>

// Module connection pins (Digital Pins)
#define CLK 2
#define DIO 3

// The amount of time (in milliseconds) between tests
#define TEST_DELAY   1000

const uint8_t SEG_DONE[] = {
  SEG_B | SEG_C | SEG_D | SEG_E | SEG_G,           // d
  SEG_C | SEG_D | SEG_E | SEG_G,                   // o
  SEG_C | SEG_E | SEG_G,                           // n
  SEG_A | SEG_D | SEG_E | SEG_F | SEG_G            // E
};

TM1637Display display(CLK, DIO);

int k;
uint8_t data[] = { 0xff, 0xff, 0xff, 0xff };
uint8_t blank[] = { 0x00, 0x00, 0x00, 0x00 };

void wipe() {
  display.clear();
  for (k = 0; k < 4; k++)
    data[k] = 0x00;
  display.setSegments(data);
}

void barr() {
  display.clear();
  for (k = 0; k < 4; k++)
    data[k] = 0x49;
  display.setSegments(data);
  delay(4000);
}

void cshow (uint8_t ix, uint8_t pattern)
{
  data[ix] = pattern;
  display.setSegments(data);
  delay(TEST_DELAY);
}

void setup()
{
  barr();
}

void loop()
{
  display.setBrightness(0x0f);

  wipe();
  delay(TEST_DELAY);
  cshow (0, 0xd0);
  cshow (0, 0x50);
  cshow (1, 0x90);
  cshow (1, 0x10);
  cshow (2, 0xd8);
  cshow (2, 0x58);
  cshow (3, 0xd8);
  cshow (3, 0x58);
}

The display I have is the one with the colon between 2nd and 3rd LED digit.
Using your code gives r i colon on colon off c c on the display.
As david said that is what the MSB does, 1 shows colon, 0 hides it, it is the difference between 0b10000000 and 0b0000000 on the 2nd digit in my case.
Now it is showing for example 1H:73 as of temp sensor 1 senses a temperature that is higher as the set max temp and adds H: to the display.

It is not impossible to control the dots and colon with this library. Look:

void showNumberDecEx(int num, uint8_t dots = 0, bool leading_zero = false, uint8_t length = 4, uint8_t pos = 0);

  //! Display a hexadecimal number, with dot control
  //!
  //! Display the given argument as a hexadecimal number. The dots between the digits (or colon)
  //! can be individually controlled.
  //!
  //! @param num The number to be shown
  //! @param dots Dot/Colon enable. The argument is a bitmask, with each bit corresponding to a dot
  //!        between the digits (or colon mark, as implemented by each module). i.e.
  //!        For displays with dots between each digit:
  //!        * 0.000 (0b10000000)
  //!        * 00.00 (0b01000000)
  //!        * 000.0 (0b00100000)
  //!        * 0.0.0.0 (0b11100000)
  //!        For displays with just a colon:
  //!        * 00:00 (0b01000000)
  //!        For displays with dots and colons colon:
  //!        * 0.0:0.0 (0b11100000)

There just is not a lot of documentation for setting the dots or colon when using a user-defined character. The library has definitions for the LED segments, SEG_A through SEG_G, but nothing is pre-defined for the dot or colon, and the availability of the dot and/or colon is dependent on the specific display.

I know. But at least there is a mechanism to do it. Other libraries for the TM1637 also don't support specific display implementations. Not at that level of detail, at least.

It's better to use the mechanism so you don't have to mingle character and dot operations.

OK, I have not been in a position to find and assemble such a display here just today as I am busy with other things but apparently from your description, the "clock" version of the display has only the colon and no decimal points.

Correct @Paul_B , I guess that I have not been precise enough in my first post.

I suggest looking more closely at the module to see if there are decimal points as well as a colon. Every TM1637 display I've ever seen, had both.

My display has the locations for both, but only the colon has the actual LEDs present.

Oh, right, actually I doubt that there enough intersections in the matrix to support both.

No decimal points just a colon, like a "retro" clock display.

Some versions I've seen with these modules

Yes, the DiyMore modules which I suspect are clones of the Robodyne displays.

Actually, there are, but it might require an extra pin on the actual LED assembly.

The forum has an annoying behaviour of randomly removing things you write, :astonished:

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