2015-02-19 05:05 PM
put
points
between the
string?
(for example:
00.00)
thanks
void Str_convert(unsigned long t, unsigned char *str, unsigned char n)
{
unsigned char a[7];
unsigned char i, j;
a[0]=(t/10000000)%10;
a[1]=(t/1000000)%10;
a[2]=(t/100000)%10;
a[3]=(t/10000)%10;
a[4]=(t/1000)%10;
a[5]=(t/100)%10;
a[6]=(t/10)%10;
a[7]=(t/1)%10;
for(i=0; i<8; i++)
a[i]=a[i]+'0';
for(i=0; a[i]=='0' && i<=-2; i++);
for(j=8-n; j<i; j++)
{
*str=' ';
str++;
}
for(; i<8; i++)
{
*str=a[i]; str++;
}
*str='\0';
}
int main(void)
{
unsigned long counter;
unsigned char Buffer[10];
Str_convert(counter,&Buffer[0],8);
Print(100,30,(unsigned char *)&Buffer[0],red,Green);
}
2015-02-19 06:37 PM
char *dec32dotdot(uint32_t i)
{
static char string[16]; // enough for 10 digits + NUL
int j = 0;
char *s = string + sizeof(string);
*--s = 0;
do
{
*--s = '0' + (char)(i % 10);
i = i / 10;
j++;
if ((j == 2) || (j == 4))
*--s = '.';
} while(i);
return(s);
}
[DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Discovery/usart%20stm32f0&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F¤tviews=21]https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2FSTM32Discovery%2Fusart%20stm32f0&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F¤tviews=21
2015-02-20 08:38 AM
short and sweet
cod
thanks