hello~
In "telink_mesh_sdk", I want to output the float value to UART using the mini_printf function.
How do I modify the mini_printf function?
To use the "sprintf" function
I tried #include <stdio.h>
A compilation error occurs.
intmini_printf(constchar *format, ...){
charspan;
unsignedlongj;
char *s;
//char *msg;
va_listarg_ptr;
va_start(arg_ptr, format);
while((span = *(format++))){
if(span != % ){
uart_put_char(span);
}else{
span = *(format++);
if(span == c ){
j = va_arg(arg_ptr,int);//get value of char
uart_put_char(j);
}elseif(span == d ){
j = va_arg(arg_ptr,int);//get value of char
#if0
if(j<0){
uart_put_char( - );
j = -j;
}
#endif
puti(j,DECIMAL_OUTPUT);
}elseif(span == s ){
s = va_arg(arg_ptr,char *);//get string value
puts(s);
}elseif(span == o ){
j = va_arg(arg_ptr,unsignedint);//get octal value
puti(j,OCTAL_OUTPUT);
}elseif(span == x ){
j = va_arg(arg_ptr,unsignedint);//get hex value
puti(j,HEX_OUTPUT);
}elseif(span == 0){
break;
}else{
uart_put_char(span);
}
}
}
va_end(arg_ptr);
return0;
}
Hi,
mesh SDK support float print and float operations,please search this fuction (float_test()) to learn how to print float.
@Soyo
thank you reply.
I looked it up, but it's not there.
Hi,
mesh SDK support float print and float operations,please search this fuction (float_test()) to learn how to print float.
@Soyo
thank you reply.
I looked it up, but it's not there.
Oh! you are using Telink mesh SDK,can you download sig mesh SDK(http://wiki.telink-semi.cn/tools_and_sdk/BLE_Mesh/SIG_Mesh/sig_mesh_sdk.zip)?
and reference it's code,copy to Telink Mesh SDK.
@Soyo
thank you. soyo.
you are good man.