float conversion

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
coco82
Posts: 9
Joined: 25 Sep 2017 22:25

float conversion

Post 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?
User avatar
PoltoS
Posts: 7565
Joined: 26 Jan 2011 19:36

Re: float conversion

Post 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
coco82
Posts: 9
Joined: 25 Sep 2017 22:25

Re: float conversion

Post 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.
User avatar
PoltoS
Posts: 7565
Joined: 26 Jan 2011 19:36

Re: float conversion

Post 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
petergebruers
Posts: 255
Joined: 26 Jul 2015 17:29

Re: float conversion

Post 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, ...).
User avatar
PoltoS
Posts: 7565
Joined: 26 Jan 2011 19:36

Re: float conversion

Post by PoltoS »

Soon. We will make a post on the forum
coco82
Posts: 9
Joined: 25 Sep 2017 22:25

Re: float conversion

Post 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.
petergebruers
Posts: 255
Joined: 26 Jul 2015 17:29

Re: float conversion

Post 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.
coco82
Posts: 9
Joined: 25 Sep 2017 22:25

Re: float conversion

Post 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.
petergebruers
Posts: 255
Joined: 26 Jul 2015 17:29

Re: float conversion

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