ESP8266 Developer Zone The Official ESP8266 Forum 2014-11-17T19:46:09+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=44 2014-11-17T19:46:09+08:00 2014-11-17T19:46:09+08:00 https://bbs.espressif.com:443/viewtopic.php?t=44&p=168#p168 <![CDATA[Re: Q: os_sprintf.. : Float / Double]]>
vishnu046 wrote:
Hi rudy,

OS_SPRINTF doesnt supprot %f ...
i am using like this...


hi vishnu ;-)


thank you so much for your effort and help.
i will test asap ;-) i search in
http://www.cs.fsu.edu/~baker/devices/lx ... t/printf.c
for making a function .. without boot.h ..
so you have save me the work
thank you!!
^^^^^^^^^^

best wishes rudi ;-)


btw: i help me in past like this way, this is a simple way in first step to get decimals..

Code:


char temp[100];
char arraystring[5];
float adjustvalue = 1.5;   // my LM35 was difference 1.5 kelvin to the mechanical thermometer to much .. so i substrakt this from measuring value later..
float adc_value;
int decimal, whole;
...
...

adc_value = adc_read();
adc_value = ((adc_value * 1000 / 1024 / 9.31 ) - adjustvalue );
whole    = adc_value;
decimal = ( adc_value - whole ) * 10 ; // only deci ..

..
..

os_sprintf(arraystr, "%2d.%i", whole, decimal );  // look like 17.5
os_sprintf(temp,"Temp measuring was: %s °C", arraystr);
uart0_sendStr(temp);
..



or simple without the arraystr..

Code:

os_sprintf(temp,"Temp measuring was: %2d.%i °C", whole, decimal);
uart0_sendStr(temp);


btw with esp-01 the adc measuring will be fine too, i attached the mod at a esp-01
add a LM35 to the adc pin and get the measuring too ;-)
i love espressif!!!
^^^^^

rudi ;-)

info for negative celsius..
my measuring is allways in + Celsius so i can work this in paste way.. but
if measuring value goes - Celsius, the formated value is

Code:

-10.-3 °C

so must change the negative decimal .. i will test yours ;-) thank you!!!

edit'S: misspelling ..name
templm35.JPG

IMG_3101.JPG

Statistics: Posted by rudi — Mon Nov 17, 2014 7:46 pm


]]>
2014-11-17T18:39:01+08:00 2014-11-17T18:39:01+08:00 https://bbs.espressif.com:443/viewtopic.php?t=44&p=167#p167 <![CDATA[Re: Q: os_sprintf.. : Float / Double]]>
OS_SPRINTF doesnt supprot %f ...
i am using like this...
iftoa.rar

Statistics: Posted by vishnu046 — Mon Nov 17, 2014 6:39 pm


]]>
2014-11-14T03:33:06+08:00 2014-11-14T03:33:06+08:00 https://bbs.espressif.com:443/viewtopic.php?t=44&p=152#p152 <![CDATA[Q: os_sprintf.. : Float / Double]]>
i play with float and double

Code:


char temp[100];

os_sprintf(temp, " Where is my Float : %f \r", 12.34);
os_sprintf(temp, " Where is my Float : %2.2f \r", 12.34);
os_sprintf(temp, " Where is my Float : %.2f \r", 12.34);


get not the right formated string.

a try with %e and %E

Code:

os_sprintf(temp, " Where is my Float : %e \r", 12.34);
os_sprintf(temp, " Where is my Float : %E \r", 12.34);


same.

how you format floats ;-) 12.34 ?

thank you!
best wishes
rudi ;-)

Statistics: Posted by rudi — Fri Nov 14, 2014 3:33 am


]]>