Adding ascii % symbol to LCD display

Use this section to discuss your embedded Flowcode projects.
Post Reply
canary_wharfe
Posts: 78
http://meble-kuchenne.info.pl
Joined: Thu Dec 10, 2020 3:54 pm
Has thanked: 6 times
Been thanked: 11 times

Adding ascii % symbol to LCD display

Post by canary_wharfe »

I am displaying a number that can vary from 1 to 3 digits on a 16 x 2 LCD module. The number is always placed at char position 12 and therefore takes up either the 12th position, the 12 and 13th position or the 12th, 13th and 14th position. Can someone please show me the command to write into the LCD macro line that will add the % character immediately after the last digit to the right of the number? I think the number has to be inserted into a string denoted by " " but I can't for the life of me remember how to do it.

medelec35
Matrix Staff
Posts: 1432
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 506 times
Been thanked: 469 times

Re: Adding ascii % symbol to LCD display

Post by medelec35 »

Hello.
The easiest way is to use

Code: Select all

PrintString "%  "

If the number goes from 255 to 3 for example, the two spaces between % and "ensure the unwanted 55 digits are erased.
You won't require a cursor command prior to the PrintString function.
Martin

canary_wharfe
Posts: 78
Joined: Thu Dec 10, 2020 3:54 pm
Has thanked: 6 times
Been thanked: 11 times

Re: Adding ascii % symbol to LCD display

Post by canary_wharfe »

Thanks Martin. That should work nicely.
So you're saying the solution is to add the PrintString function after I have done the PrintNumber.
FYI I thought there was a way to insert the number with the PtintString % as one function but my memory is fuzzy and I may be thinking back to earlier code development before I switched to using Flowcode.

canary_wharfe
Posts: 78
Joined: Thu Dec 10, 2020 3:54 pm
Has thanked: 6 times
Been thanked: 11 times

Re: Adding ascii % symbol to LCD display

Post by canary_wharfe »

Martin
Just to confirm, it does all work as expected and as you pointed out it has also eliminated a few cursor command functions in the flowcode.
:-)

medelec35
Matrix Staff
Posts: 1432
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 506 times
Been thanked: 469 times

Re: Adding ascii % symbol to LCD display

Post by medelec35 »

Sorry yes, I should have said to add the PrintString directly after the PrintNumber function.
Thank you for confirming it's working for you. :)
Martin

Post Reply