#if 0
stdio.h中,v开头的print函数和scan函数,都是支持__va_list 参数的,也就是...转换后的参数列表结构;
可以用来封装自己的格式化打印函数
extern _ARMABI int vsprintf(char * __restrict /*s*/,
const char * __restrict /*format*/, __va_list /*arg*/) __attribute__((__nonnull__(1,2)));
/*
* is equivalent to sprintf, with the variable argument list replaced by
* arg, which has been initialised by the va_start macro (and possibly
* subsequent va_arg calls). The vsprintf function does not invoke the
* va_end function.
* Returns: the number of characters written in the array, not counting the
* terminating null character.
*/
extern _ARMABI int vsnprintf(char * __restrict /*s*/, size_t /*n*/,
const char * __restrict /*format*/, __va_list /*arg*/) __attribute__((__nonnull__(3)));
/*
* is equivalent to snprintf, with the variable argument list replaced by
* arg, which has been initialised by the va_start macro (and possibly
* subsequent va_arg calls). The vsprintf function does not invoke the
* va_end function.
* Returns: the number of characters that would have been written in the
* array, not counting the terminating null character. As
* snprintf.
*/
#endif
int LCD_LinePrint(int rows,const char *format, ... )
{
char buff[65]={0};
uint8_t columns=0;
va_list arg;
int done;
//LCD_WriteInstructions(CMD_RETURN_HOME);
va_start (arg, format);
done = vsnprintf(buff,sizeof(buff),format,arg);
va_end (arg);
done = done>LCD_CHAR_BUFFER_MAX?LCD_CHAR_BUFFER_MAX:done;
rows = rows%LCD_LINE_MAX;
for (columns=0;columns<done;columns++){
LCD_PutChar(rows,columns,buff[columns]);
}
return done;
}
12-30
8953
