Page 1 of 2

float conversion

Posted: 25 Sep 2017 22:31
by coco82
Hi,

I tried to find a function which convert float to string, but all the know functions (sprintf, ...) are not supported by Z-Uno. Any idea?

Re: float conversion

Posted: 25 Sep 2017 23:37
by PoltoS
If you anyway output that string to UART, do Serial.print.

If you still want to compile the string in memory, use Stream class or make yours on top of Print by overriding write method.

https://github.com/Z-Wave-Me/Z-Uno-Core ... no/Print.h

Re: float conversion

Posted: 26 Sep 2017 22:36
by coco82
I want to output the string to a I2C LCD screen. The print method with float argument doesn't work: after few call, the screen starts to disp special symbols instead of float value.

If I use the print method with string argument, it always works.

Finally, I wrote a function which works fine. I hope that the main arduino functions will be available for Z-Uno, in the next release.

Re: float conversion

Posted: 26 Sep 2017 22:45
by PoltoS
Please let us know more about the problem with i2c.print(float) working not as expected - may be there is a bug to fix on our side.

We will soon release 2.1.1 with many internal changes

Re: float conversion

Posted: 27 Sep 2017 17:58
by petergebruers
PoltoS wrote:
26 Sep 2017 22:45
(...)We will soon release 2.1.1 with many internal changes
Thanks! That is good news. If you have a pre-release, I'll be happy to test it (BH1750 enhanced sketch, Neopixel 21-25 LED issue, FLIRS test, ...).

Re: float conversion

Posted: 27 Sep 2017 18:32
by PoltoS
Soon. We will make a post on the forum

Re: float conversion

Posted: 30 Sep 2017 18:09
by coco82
First, I took the Arduino LiquidCrystal_I2C library, and I made few changes to make it works with Z-Uno. It's small changes, and I don't remember all I did, but :

- the array declaration with default values don't work:
uint8_t row_offsets[4] = {0x00, 0x40, 0x14, 0x54); // default values are ignored
- in the header, the binary constants (En, Rs, Rw) make a compilator error. I converse it to hex constant.

In my program, I receive a temperature from a DS18B20 sensor, and I try to print it on a I2C LCD print. Sometimes, it works once or twice but after it starts to print special symbols et fills the screen. It seems that the Serial always works.

Maybe, it comes from the library... I can send you the files if you want.

Re: float conversion

Posted: 30 Sep 2017 18:28
by petergebruers
Did you rule out a hardware issue? I do not want to underestimate you, because we do not know eachother (yet) I might be asking silly questions. I was thinking maybe you do not have sufficiently low pullup resistors. Or a 5 V - 3.3 V conversion issue. Does your library check the I2C ACK? If it does not, you might not notice an error occured on the bus.

Re: float conversion

Posted: 30 Sep 2017 21:08
by coco82
It works if I convert the float to a string and I print it. No Crash. So it's definitely a soft problem.

Re: float conversion

Posted: 30 Sep 2017 21:48
by petergebruers
I see, I am sorry that I did not understand that right away, but when I reread this topic it is clear to me! If you get corruption, then I would guess something is writing to the wrong memory address. Maybe something to do with size of variables. I am sorry, I am talking out loud. Probably not very helpful right now. I am not at home, but on monday I can have a look at your code and the library. If that is ok with you then please send me the files...