Page 1 of 1

Floats as "number font" on display

Posted: Mon Jun 27, 2022 11:16 pm
by MJU20
The display fonts in the display components have a few fonts that only show numbers.
Nieuw-1.jpg
Nieuw-1.jpg (12.09 KiB) Viewed 2177 times
Is it possible to add a comma or a point to these "number fonts" so they could show a float-like number?

Thanks..

Re: Floats as "number font" on display

Posted: Wed Jun 29, 2022 11:45 am
by BenR
Hello,

The Calibri Black Number and Fixed Number fonts include ASCII 43 to ASCII 58 and so should allow you , and . characters, looks like it's just the Verdana Number font that's more limited at ASCII 48 to ASCII 58.

FontAsciiNumber.jpg
FontAsciiNumber.jpg (24.57 KiB) Viewed 2157 times

I'll have a look and see how easy it would be to add the extra characters

Re: Floats as "number font" on display

Posted: Wed Jun 29, 2022 12:20 pm
by BenR
I've had a go and pushed a new version of the font component to the library update system, hopefully Verdana Number should now have all the characters shown above to match the other Number fonts.

Re: Floats as "number font" on display

Posted: Wed Jun 29, 2022 5:34 pm
by MJU20
Thanks BenR!

How can I print a number like 20.4 to the display?
Do I need to cut the 20 and the 4 and add a comma between them?

Then I need to calculate the position for the comma?
Or is there a better trick?

Now I use the printnumber macro for the SSD1306 OLED. But I I use a number like 20.4 it isn't displayed.

Re: Floats as "number font" on display

Posted: Wed Jun 29, 2022 8:20 pm
by BenR
Hello

You should be able to use the float to string function in the calculation icon. The parameters are the floating point number , the number of decimal places.

E.g.

Str = floattostring$(float, 1)

Then print out the str as you would normally print out a string.

Let us know how you get on.

Re: Floats as "number font" on display

Posted: Thu Jun 30, 2022 5:37 pm
by MJU20
Great BenR :D
This works!

But for me this is very confusing..
If you don't know this trick I wouldn't be able to figure this out.

A font, special for numbers, that uses a string to show a few characters...
Why not build this feature in the print number feature of the component?

But, thanks again for pointing me to this workaround.

Re: Floats as "number font" on display

Posted: Thu Jun 30, 2022 7:14 pm
by BenR
Hello,

Print number should also work fine but only works with integer numbers. I could maybe look at adding a print float macro to the graphical displays like we have for the alphanumeric displays.