Noiasca_ht16k33_hw_7 - Dot Point question

Greetings!
I discovered the NoiascaHt16k33 library.
I use Noiasca_ht16k33_hw_7 to control 8 Digit seven segment LED display.
It seems that this is one of the few lines or perhaps the only one (it's the only one I've discovered) that can control 8 digits connected to an HT16K33 backpack.

I'm using the eight digit display for a timecounter.
The timecounter counts rising edge pulses received from outside (I don't need any clock generator).
I would like the format shown in the display to be the following: 22.22.22.22
Obviously the numbers I wrote are random, but, instead, the dot points that serve as simple separators are very important.
Well, I can't print dot points,
I don't understand the syntax I have to use.
The dot points must be fixed and always lit, they are not floating commas, they are simple dots that act as a visual separator.

The main problem is that every single digit is the result of an independent calculation. therefore, even more so, I don't know how to do it because if I insert a "point" in the calculation, obviously I get an error from the Arduino IDE.

I'm not yet good at using Arrays (assuming they can be a help for this problem of mine).

It was also kindly suggested that I could use sprintf,
but I've read that it's a bit resource-intensive.
The pulses to read are around 40 per second and I don't know if sprintf can do it, also because the Loop of my code is quite long
...and in any case i have trouble to use sprintf
because I'm not yet very familiar with it and it's complicated for me to apply it without real code input. I'm sorry, I'm worse than a child. I'm still too used to CMOS logic gates and have a lot to learn in C++

This was suggested to me:

 print value A and print the dot
 print value B and print the dot
 print value C and print the dot
 print value D

but I don't know the syntax,

The calculations in my sketch are classic, of this type:
(I used easier to understand names for the example)

void Count() {
Digit1 = ((pulseNumber % pulseRate) % 10);
Digit2 = (((pulseNumber % pulseRate) / 10) % 10);

Digit3 = (((pulseNumber / pulseRate) % 60) % 10);
Digit4 = ((((pulseNumber / pulseRate) % 60) / 10) % 10);

Digit5 = ((((pulseNumber / pulseRate) / 60) % 60) % 10);
Digit6 = (((((pulseNumber / pulseRate) / 60) % 60) / 10) % 10);

Digit7 = (((((pulseNumber / pulseRate) / 60) / 60) % 10) % 10);
Digit8 = ((((((pulseNumber / pulseRate) / 60) / 60) / 10) % 10) % 10);

/*
to this we add that to exploit the Leading of the Zeros
and the shift of the minus sign (thanks Noiasca!)
I had to recompose the individual digits again with
a classic workaround, that is:
*/

   // Workaround for composing timeNumber digits
timeNumber = ((Digit8 * 10000000) + (Digit7 * 1000000) + (Digit6 * 100000) + (Digit5 * 10000) + (Digit4 * 1000) + (Digit3 * 100) + (Digit2 * 10) + Digit1);
} // close void Count

So, where and how do I insert dot points?

Thanks for the attention.
I hope for help that could be very interesting for anyone.

Can you provide a link to that library.

The library may allow you to control the decimal point LEDs separately from the numerical part of the display. Have you had a look at the documentation to see if that feature is available?

Yes, I had a look, but I don't understand.

The library is here:
https://werner.rothschopf.net/201909_arduino_ht16k33.htm

Thank you

I have never used this library, but from what I understand, it has a .print() function that works in a similar way to printing to serial monitor, for example. But when a "." is printed, this does not take up a whole digit, but instead, the dot of the previous digit is illuminated.

So you should be able to use it something like this:

char buffer[12];
sprintf(buffer, "%02d.%02d.%02d.%02d", days, hours, minutes, seconds);
display.print(buffer);

If you must use your individually calculated digits:

char buffer[] = "00.00.00.00";
buffer[10] += Digit1;
buffer[9] += Digit2;
buffer[7] += Digit3;
buffer[6] += Digit4;
buffer[4] += Digit5;
buffer[3] += Digit6;
buffer[1] += Digit7;
buffer[0] += Digit8;
display.print(buffer);
1 Like

one of the reasons why I told you to ask the question in the forum was to avoid splitted/hidden information.

that is what I have posted to you:

  int valueA, valueB, valueC, valueD;
  valueA = 1;
  valueB = 88;
  char s [8 + 8 + 1];
  sprintf (s, "%02d.%02d.%02d.%02d",  valueA, valueB, valueC, valueD);
  display.print(s);

PaulRB came to a very similar proposal as I have written you.

In general:
Just handle the display like you would write to Serial or any other "display" which inherits from Print.h.

uint32_t pulseNumber = 12345694;
uint32_t pulseRate = 42;

int Digit1, Digit2, Digit3, Digit4, Digit5, Digit6, Digit7, Digit8;

void testA() {
  Digit1 = ((pulseNumber % pulseRate) % 10);
  Digit2 = (((pulseNumber % pulseRate) / 10) % 10);

  Digit3 = (((pulseNumber / pulseRate) % 60) % 10);
  Digit4 = ((((pulseNumber / pulseRate) % 60) / 10) % 10);

  Digit5 = ((((pulseNumber / pulseRate) / 60) % 60) % 10);
  Digit6 = (((((pulseNumber / pulseRate) / 60) % 60) / 10) % 10);

  Digit7 = (((((pulseNumber / pulseRate) / 60) / 60) % 10) % 10);
  Digit8 = ((((((pulseNumber / pulseRate) / 60) / 60) / 10) % 10) % 10);

  Serial.println("test A");
  Serial.print(Digit1);
  Serial.print(Digit2);
  Serial.print('.');
  Serial.print(Digit3);
  Serial.print(Digit4);
  Serial.print('.');
  Serial.print(Digit5);
  Serial.print(Digit6);
  Serial.print('.');
  Serial.print(Digit7);
  Serial.print(Digit8);
  Serial.println(); // only for serial
}

void testB() {
  Serial.println("Test B");
  int valueA = ((pulseNumber % pulseRate) % 10) * 10 +  (((pulseNumber % pulseRate) / 10) % 10);
  int valueB = (((pulseNumber / pulseRate) % 60) % 10) * 10 + ((((pulseNumber / pulseRate) % 60) / 10) % 10);
  int valueC = ((((pulseNumber / pulseRate) / 60) % 60) % 10) * 10 + (((((pulseNumber / pulseRate) / 60) % 60) / 10) % 10);
  int valueD = (((((pulseNumber / pulseRate) / 60) / 60) % 10) % 10) * 10 + ((((((pulseNumber / pulseRate) / 60) / 60) / 10) % 10) % 10);
  
  if (valueA < 10) Serial.print('0');
  Serial.print(valueA);
  Serial.print('.');
   if (valueB < 10) Serial.print('0');
  Serial.print(valueB);
  Serial.print('.');
  if (valueC < 10) Serial.print('0');
  Serial.print(valueC);
  Serial.print('.');
  if (valueD < 10) Serial.print('0');
  Serial.print(valueD);
  Serial.println(); // only for serial
}

void testC() {
  Serial.println("Test C");
  char s [8 + 8 + 1];
  int valueA = ((pulseNumber % pulseRate) % 10) * 10 +  (((pulseNumber % pulseRate) / 10) % 10);
  int valueB = (((pulseNumber / pulseRate) % 60) % 10) * 10 + ((((pulseNumber / pulseRate) % 60) / 10) % 10);
  int valueC = ((((pulseNumber / pulseRate) / 60) % 60) % 10) * 10 + (((((pulseNumber / pulseRate) / 60) % 60) / 10) % 10);
  int valueD = (((((pulseNumber / pulseRate) / 60) / 60) % 10) % 10) * 10 + ((((((pulseNumber / pulseRate) / 60) / 60) / 10) % 10) % 10);
  sprintf (s, "%02d.%02d.%02d.%02d", valueA, valueB, valueC, valueD);
  Serial.print(s);
  Serial.println(); // only for serial
}

void setup() {
  Serial.begin(115200);
  testA();
  testB(); 
  testC();
}

void loop() {
  // put your main code here, to run repeatedly:
}

(* I know your calculations are bulky, but this is something you should take care of your own)

all three outputs will be the same:

test A
40.50.93.18
Test B
40.50.93.18
Test C
40.50.93.18
1 Like

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