/*
**********************************************************************************************************************
*                                               debug_display_putstr
*
* Description:
*
* Arguments  :
*
* Returns    :
*
* Notes      :
*
**********************************************************************************************************************
*/
static int uichar_putstr(const char * str, int length)
{
	int count = 0;

	while( *str != '\0' )
	{
		if(*str == '\n')
		{
            //需要换行的时候,自动切换到下一行开始进行显示
            //调用换行函数
            if(uichar_change_newline( ))
	        {
	        	return -1;
	        }
		}
		else
		{
			if(uichar_putchar(*str))
			{
				return -1;
			}
		}
		str++;
		count ++;
		if(count >= length)
		{
			if(uichar_change_newline( ))
	        {
	        	return -1;
	        }
		}
	}

	return 0;
}
Ejemplo n.º 2
0
/*
**********************************************************************************************************************
*                                               _debug_display_putchar
*
* Description:
*
* Arguments  :  ch         :  需要打印的字符
*               rest_width :  当前行剩余的宽度
*
* Returns    :
*
* Notes      :
*
**********************************************************************************************************************
*/
static int uichar_putchar(__u8 ch)
{
    __s32 ret, width;

    ret = check_change_line(ui_char_info.x, ch);
    if(ret == -1)             //访问失败,当前字符不处理
    {
        return 0;
    }
    else if(ret == 0)        //访问成功,当前字符处理,但是不需要换行
    {
        ;
    }
    else if(ret == 1)        //访问成功,当前字符处理,需要换行
    {
        if(uichar_change_newline( ))
        {
        	ret = -1;
        }
    }

    width = draw_bmp_ulc(ui_char_info.x, ui_char_info.y, ui_source.color);    //显示字符,返回当前显示字符的宽度,像素单位
    ui_char_info.x += width;
    ui_char_info.rest_screen_width -= width;                        //记录当前行剩余的像素
    //调用打印函数

	return ret;
}
void boot_ui_printf( const char * str, ...)
{
	int  base_color;
	char string[32];
	char *p;
	__s32 hex_flag ;
	va_list argp;

	va_start( argp, str );

	base_color = boot_ui_get_color();
	base_color &= 0xffffff;
	boot_ui_set_color(base_color);
    if(change_line == 1)
    {
        if(uichar_change_newline())
        {
        	__inf("boot ui char: unable to change to one new line\n");

        	goto boot_ui_print_err;
        }
        wBoot_timer_delay(10);
        change_line = 0;
    }

	while( *str )
	{
		if( *str == '%' )
		{
			++str;
			p = string;
			hex_flag = 'X';
			switch( *str )
			{
			    case 'u':
				case 'd':
				{
					int_to_string_dec( va_arg( argp,  __s32 ), string );
                    if(uichar_putstr( p, 32 ))
                    {
                      	goto boot_ui_print_err;
                    }
					++str;
					break;
				}
				case 'x': hex_flag = 'x';	         // jump to " case 'X' "
				case 'p':
				case 'X':
				{
					int_to_string_hex( va_arg( argp,  __s32 ), string, hex_flag );
					if(uichar_putstr( p , 32))
					{
						goto boot_ui_print_err;
					}
                    ++str;
					break;
				}
				case 'c':
				{
					if(uichar_putchar( va_arg( argp,  __s32 ) ))
					{
						goto boot_ui_print_err;
					}
					++str;
					break;
				}
				case 's':
				{
					if(uichar_putstr( va_arg( argp, char * ), 32 ))
					{
						goto boot_ui_print_err;
					}
					++str;
					break;
				}
				default :
				{
					if(uichar_putchar( '%' ))          // if current character is not Conversion Specifiers 'dxpXucs',
					{
						goto boot_ui_print_err;
					}
					if(uichar_putchar( *str ))         // output directly '%' and current character, and then
					{
						goto boot_ui_print_err;
					}
					++str;                        // let 'str' point to next character.
				}
			}
		}
		else
		{
			if( *str == '\n' )                      // if current character is '\n', insert and output '\r'