cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert integer to string?

antonius
Senior
Posted on January 02, 2014 at 11:47

struct tm time;

   char year[50];

Guys,

I want to display year into LCD screen but I got 00 on LCD, any clues on how to do it ?

thanks

 printf(''Time: %d-%d-%d   %02d:%02d:%02d \r\n'', time.tm_year, \

                   time.tm_mon+1, time.tm_mday,\

                   time.tm_hour, time.tm_min, time.tm_sec);

    sprintf(year,''%.2f'',time.tm_year);

 

    lcd_string(year);

#!complicated
31 REPLIES 31
aa_talaat
Associate II
Posted on January 06, 2014 at 17:56

Yes, that is the LCD.

Here is the initialization code. It is based on another code from the internet, and uses the SPI peripheral to communicate. I include the SPI init as well.

________________

Attachments :

nokia-5110.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I19V&d=%2Fa%2F0X0000000bj5%2FVKpehYu93Kvi94xa4FUCBofrCMc1QLpKsRYbIzrecRw&asPdf=false

spieeprom.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I18s&d=%2Fa%2F0X0000000bj6%2F43wWFSUogljMuXVofE5U.Hgy5E.QC7TQ.lHmtL_pfuM&asPdf=false
trevor23
Associate III
Posted on January 07, 2014 at 10:22

But the problem seems to be that the time structure is not being setup properly so using a new LCD method to display what is already wrong is of no use and further adds to the number of variables to solve (further confusion if any was needed). The original poster needs to cut this down to one problem at a time e.g. loose the LCD for now (UART works so just use that) until the time string is formatted correctly would be a good starting point.

@h.rick you really need to read this carefully: 

http://www.catb.org/~esr/faqs/smart-questions.html

Especially the section entitled ''When asking about code''. Also this issue is cross posted here so you should always at least link to it: http://goo.gl/w27Y72