Page 1 of 1

Print Formatted Number - I2C LCD - Not working

Posted: Tue Jan 31, 2017 9:49 pm
by Jay Dee
Hi guys,
I'm pretty sure this is a bug, not me being a clunk.... maybe!
I am using the i2C LCD component and cant print ULong values, Im using the PrintFormattedNumber function.
Both simulate OK.

I also could not get a good result using a conventional 2x20 LCD, it output a value but is not what I expected.
Example FC attached.
Display_ULong.fcfx
example
(13.24 KiB) Downloaded 311 times
Any thoughts?
thanks, J.

Re: Print Formatted Number - I2C LCD - Not working

Posted: Wed Feb 01, 2017 11:11 am
by Benj
Hello,

The problem is not the print routine, it seems to be the calculation that is causing it.

If you change your calculation from

Code: Select all

Ans_ULong = Arg1_U16 * Arg2_U16
To

Code: Select all

Ans_ULong = Arg1_U16
Ans_ULong = Ans_ULong * Arg2_U16
Then it should work as expected.

The first is cast as a 16-bit value when performing the calculation and then assigned to the 32-bit value.

The second uses a 32-bit value in the calculation and so forces the result to also be 32-bit.

Re: Print Formatted Number - I2C LCD - Not working

Posted: Wed Feb 01, 2017 9:06 pm
by Jay Dee
Hi Ben,
Thanks for the quick response. I made the change as advised.
Display_ULong2.fcfx
(12.5 KiB) Downloaded 348 times
This now work for the conventional 2x20 LCD,
but still nothing being displayed on the i2C LCD display.
regards, J.

Re: Print Formatted Number - I2C LCD - Not working

Posted: Thu Feb 02, 2017 6:24 pm
by Benj
Thanks for letting us know.

I believe I have now found and fixed the problem but have a go and see how you get on.
lcd_I2C.fcpx
(26.12 KiB) Downloaded 341 times

Re: Print Formatted Number - I2C LCD - Not working

Posted: Thu Feb 02, 2017 6:59 pm
by Jay Dee
Thanks Ben,
Excellent, that all works with my Hardware.
Promptly resolved and its much appreciated.
J.