hi-tech te printf ve lcd nin beraber kullanımı?

Başlatan piedos, 05 Ağustos 2006, 01:55:37

piedos

CCS te  

printf(lcd_putc,"\fyil: %d\n",2006);


koduyla

yil: 2006

yazısını lcdye yazdırabiliyorum.

Aynı olayı hi-tech te nasıl yapabilirim?

Teşekkürler
Einstein: "Only two things are infinite, the universe and human stupidity, and I'm not sure about the former."

piedos

char  message[20]=""; 

 
lcd_init();
lcd_goto(0);	// select first line
	 

DelayMs(1000);
sprintf(message,"int:%d float:%6.3f ",100,3.14);
lcd_puts(message);




%d tamam ama %f sorunlu

lcd de

int:100 float: f

yazısı var.

Herhangi bir fikri olan var mı?
Einstein: "Only two things are infinite, the universe and human stupidity, and I'm not sure about the former."

aykuto

void putch(unsigned char byte) 
{
   lcd_putchar(byte);
}


Üstteki şekilde bir fonksiyon tanımlarsanız. Direk printf ile de lcd'ye çıkış sağlayabilirsiniz. Buradaki lcd_putchar yerine lcd'ye karakter gönderen rutininiz neyse onu kullanabilirsiniz.

Float sayıları bastırmakta ise yine probleminiz olacaktır. Bunu aşmak için 'Options' bölümünde 'Float formats in printf()' seçeneği aktif olmalıdır.

Erol YILMAZ

HITECH PIC18 derleyicisinin manualinde soyle demiş...

Alıntı Yap4.4.26.1 Printf with Additional Support for Longs and Floats
By default, printf() and related functions contained in the standard libraries support the printing of
integers only. If additional support for longs and floats is required different libraries must be used
during the link stage. For complete information on printf(), see page 276.
To use the version of printf() which has additional support for longs, you must include a
supplementary library by using the following option when linking (or when you are compiling and
linking in one step):
-Ll
To use the version of printf() which has additional support for longs and floats, use the option:
-Lf
In the above options, l and f are merely specifying the library type as described in the section Standard
Libraries on page 75. In addition to these options, no modification of your source code is required to
print longs or floats. If these options are not specified, printf() will not know about the long and
float placeholders and any attempt to use them will print the placeholder character(s) as text with no
substitution.

An alternative version of printf() with additional flags and functionality can be selected by using the
command line option:
-Lw
This version of printf() can print long and float variables by default, and is larger than the standard
version of printf().


piedos

Teşekkürler Erol

Ancak bu yöntemle çok fazla ROM kullanılıyor. Bu yüzden kendim bir fonksiyon yazacağım.
Einstein: "Only two things are infinite, the universe and human stupidity, and I'm not sure about the former."