Oui, j'ai pensé aussi à cette solution, mais je ne me retrouve pas dans ce sous-programme "printfLCD" pour pouvoir afficher en décimal et non en hexa.
voici ce sous-programme, si vous trouver l'endroit où cela pose problème ca serait génial!
void printfLCD(unsigned char *ptr, ...)
{
unsigned char c1,c2;
unsigned int c3;
//unsigned char *var_ptr=&ptr+1;
unsigned char var;
unsigned char orig_buscon;
#ifdef __RC51__ //use ANSI stdarg
va_list var_ptr;
va_start(var_ptr,0);
#else
unsigned char *var_ptr=&ptr+1;
#endif
orig_buscon = BUSCON; // Save buscon value
BUSCON |= 0x3C; // Set Xdata Read/Write to max wait states
if(ulayer >3) //if page exceed the range 0 to 3,force it to 0.
ulayer = 0;
while (*ptr != NULL)
{
c1 = *ptr;
c2 = *(ptr+1);
c3 = c1;
c3 = (c3<<8)|c2;
if(c1 <= 128) // deal with asc code , if c1<=128 ,it will deal with asc code,otherwise Chinese word.
{
if ( *ptr == '\r')
{
ptr++;
ucol = 0;
}
else if( *ptr == '\n')
{
ptr++;
ucol = 0;
ulayer++;
}
else if( *ptr == '%')
{
ptr++;
if (*ptr == 'd')
{
ptr++;
#ifdef __RC51__ //use ANSI stdarg
var = *var_ptr--;
var_ptr--;
#else
var = *var_ptr++;
#endif
c1 = (var & 0x0F)+'0';
disp_one_asc(ucol,ulayer,c1,mode);
ucol+=7;
}
else if (*ptr == 'x')
{
#ifdef __RC51__ //use ANSI stdarg
var = *var_ptr--;
var_ptr--;
#else
var = *var_ptr++;
#endif
c1 = htoa_hi(var);
disp_one_asc(ucol,ulayer,c1,mode);
ucol+=7;
c1 = htoa_lo(var);
disp_one_asc(ucol,ulayer,c1,mode);
ucol+=7;
ptr++;
}
else if (*ptr == 'w')
{
ptr++;
#ifdef __RC51__ //use ANSI stdarg
var_ptr--;
var = *var_ptr;
#else
var = *var_ptr++;
#endif
c1 = htoa_hi(var);
disp_one_asc(ucol,ulayer,c1,mode);
ucol+=7;
c1 = htoa_lo(var);
disp_one_asc(ucol,ulayer,c1,mode);
ucol+=7;
#ifdef __RC51__ //use ANSI stdarg
var_ptr++;
var = *var_ptr;
var_ptr-=2;
#else
var = *var_ptr++;
#endif
c1 = htoa_hi(var);
disp_one_asc(ucol,ulayer,c1,mode);
ucol+=7;
c1 = htoa_lo(var);
disp_one_asc(ucol,ulayer,c1,mode);
ucol+=7;
}
else
{
c1 = *ptr;
disp_one_asc(ucol,ulayer,c1,mode);
ucol+=7;
ptr++;
}
}
else
{
disp_one_asc(ucol,ulayer,c1,mode);
ucol+=7;
ptr++; // one asc need one byte in computer system
}
}
#ifdef ENGLISH_CHINESE_FONT
else //deal with Chinese, if c1<=128 ,it will deal with asc code, otherwise Chinese word.
{
if(mode)
disp_one_ch(ucol,ulayer,c3,1);
else
disp_one_ch(ucol,ulayer,c3,0);
ucol+=16; //16*16 Chinese dot matrix
ptr += 2; //one Chinese word need two byte in computer system
}
#endif
}
BUSCON = orig_buscon; // Restore buscon value
}
c'est long je sais, et je vous en remercie si vous avez tout regardé.