| 
	
	|  |  |  
	
		| View previous topic :: View next topic |  
		| Author | Message |  
		| .C 
 
 
 Joined: 06 May 2004
 Posts: 19
 Location: Italy
 
 
			    
 
 | 
			
				| lcd_putc and printf(lcd_putc,... |  
				|  Posted: Tue May 11, 2004 9:04 am |   |  
				| 
 |  
				| 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
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Tue May 11, 2004 1:36 pm |   |  
				| 
 |  
				|  	  | 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
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Wed May 12, 2004 2:40 am |   |  
				| 
 |  
				| 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
 |  |  
		|  |  
		|  |  
  
	| 
 
 | 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
 
 |