Floats as "number font" on display

Post here to discuss any new features, components, chips, etc, that you would like to see in Flowcode.
Post Reply
MJU20
Posts: 367
http://meble-kuchenne.info.pl
Joined: Tue Dec 08, 2020 5:11 pm
Has thanked: 105 times
Been thanked: 76 times

Floats as "number font" on display

Post 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 7568 times
Is it possible to add a comma or a point to these "number fonts" so they could show a float-like number?

Thanks..

BenR
Matrix Staff
Posts: 2305
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 637 times
Been thanked: 847 times

Re: Floats as "number font" on display

Post 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 7548 times

I'll have a look and see how easy it would be to add the extra characters
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel

BenR
Matrix Staff
Posts: 2305
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 637 times
Been thanked: 847 times

Re: Floats as "number font" on display

Post 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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel

MJU20
Posts: 367
Joined: Tue Dec 08, 2020 5:11 pm
Has thanked: 105 times
Been thanked: 76 times

Re: Floats as "number font" on display

Post 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.

BenR
Matrix Staff
Posts: 2305
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 637 times
Been thanked: 847 times

Re: Floats as "number font" on display

Post 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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel

MJU20
Posts: 367
Joined: Tue Dec 08, 2020 5:11 pm
Has thanked: 105 times
Been thanked: 76 times

Re: Floats as "number font" on display

Post 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.

BenR
Matrix Staff
Posts: 2305
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 637 times
Been thanked: 847 times

Re: Floats as "number font" on display

Post 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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel

Post Reply