CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

lcd_putc and printf(lcd_putc,...

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
.C



Joined: 06 May 2004
Posts: 19
Location: Italy

View user's profile Send private message

lcd_putc and printf(lcd_putc,...
PostPosted: Tue May 11, 2004 9:04 am     Reply with quote

Hi,

I'am using this routine to print on the lcd my digits.
Printf(LCD_PUTC...) is more expensive..

void PrintDigit(unsigned int inp)
{

outp[0] = outp[1] = outp[2] = outp[3] = outp[4] = 0;// clear the string


while (inp > 99) {
inp -= 100;
outp[2]++;
}
while (inp > 9) {
inp -= 10;
outp[3]++;
}


outp[4] = inp + 0x30; // add '0' to the results
outp[0] += 0x30;
outp[1] += 0x30;
outp[2] += 0x30;
outp[3] += 0x30;

}

void LCD (int N) {
outp[0] = outp[1] = outp[2] = outp[3] = outp[4] = 0;// clear the string
PrintDigit(N);

if (n>99) { lcd_GOTOXY(9,1); LCD_PUTC(OUTP[2]); }
if (n>9) { lcd_GOTOXY(10,1); LCD_PUTC(OUTP[3]); }
lcd_GOTOXY(11,1); LCD_PUTC(OUTP[4]);

if (n<100) {lcd_GOTOXY(9,1); LCD_PUTC(' '); }
if (n<9) {lcd_GOTOXY(10,1); LCD_PUTC(' '); }



}

/***********/

lcd(200); //example


But I don't know how to print string characters

void Print(int msgIndex) {
int scanMSGLCD;

char const msgLCD[7][17] = { " Hello "," GO ",
" DOWN "," UP ",
etc..

}


IF (MSGINDEX>6) MSGINDEX=0;
lcd_gotoxy(1,2);

for (scanMSGLCD=0;scanMSGLCD<17;scanmsgLCD++) {

>> printf(lcd_putc,"%c",msgLCD[msgIndex][scanmsgLCD]);

}

}

Can you help me to write code for lcd character without printf ?
Thank in advance
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue May 11, 2004 1:36 pm     Reply with quote

Quote:
printf(lcd_putc,"%c",msgLCD[msgIndex][scanmsgLCD]);
Can you help me to write code for lcd character without printf ?


Can't you just do this with a loop ? Read characters from the
string and send them to the lcd driver, one at a time, until you
read an "end of string" character (ie., 0). Then break out of
the loop.

Code:
for(scanMSGLCD=0; scanMSGLCD < 17; scanmsgLCD++)
   {
    c = msgLCD[msgIndex][scanmsgLCD];
    if(c == 0)
       break;
    else
      lcd_putc(c);
   }
.C



Joined: 06 May 2004
Posts: 19
Location: Italy

View user's profile Send private message

PostPosted: Wed May 12, 2004 2:40 am     Reply with quote

yes I think that it is the best way or

do {

ScanMSGLCD++;
c = msgLCD[msgIndex][scanmsgLCD];

lcd_putc(C);
} while (C!=0);


In this case 'Do' is the best
Thanks
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group