Exemple #1
0
static int screen_helper_getcharheight(void)
{
#ifdef HAVE_LCD_BITMAP
    return font_get(lcd_getfont())->height;
#else
    return 1;
#endif
}
Exemple #2
0
/* some helper functions to calculate metrics on the fly */
static int screen_helper_getcharwidth(void)
{
#ifdef HAVE_LCD_BITMAP
    return font_get(lcd_getfont())->maxwidth;
#else
    return 1;
#endif
}
Exemple #3
0
bool dbg_hw_info_pinctrl(void)
{
    lcd_setfont(FONT_SYSFIXED);

#ifdef IMX233_PINCTRL_DEBUG
    unsigned top_user = 0;
#endif
    while(1)
    {
        int button = get_action(CONTEXT_STD, HZ / 10);
        switch(button)
        {
            case ACTION_STD_NEXT:
#ifdef IMX233_PINCTRL_DEBUG
                top_user++;
                break;
#endif
            case ACTION_STD_PREV:
#ifdef IMX233_PINCTRL_DEBUG
                if(top_user > 0)
                    top_user--;
                break;
#endif
            case ACTION_STD_OK:
            case ACTION_STD_MENU:
                lcd_setfont(FONT_UI);
                return true;
            case ACTION_STD_CANCEL:
                lcd_setfont(FONT_UI);
                return false;
        }

        lcd_clear_display();
        for(int i = 0; i < 4; i++)
            lcd_putsf(0, i, "DIN%d = 0x%08x", i, imx233_get_gpio_input_mask(i, 0xffffffff));
#ifdef IMX233_PINCTRL_DEBUG
        unsigned cur_line = 6;
        unsigned last_line = lcd_getheight() / font_get(lcd_getfont())->height;
        unsigned cur_idx = 0;

        for(int bank = 0; bank < 4; bank++)
        for(int pin = 0; pin < 32; pin++)
        {
            const char *owner = imx233_pinctrl_get_pin_use(bank, pin);
            if(owner == NULL)
                continue;
            if(cur_idx++ >= top_user && cur_line < last_line)
                lcd_putsf(0, cur_line++, "B%dP%02d %s", bank, pin, owner);
        }
        if(cur_idx < top_user)
            top_user = cur_idx - 1;
#endif
        lcd_update();
        yield();
    }
}
Exemple #4
0
bool dbg_hw_info_ocotp(void)
{
    lcd_setfont(FONT_SYSFIXED);

    unsigned top_user = 0;

    while(1)
    {
        int button = get_action(CONTEXT_STD, HZ / 10);
        switch(button)
        {
            case ACTION_STD_NEXT:
                top_user++;
                break;
            case ACTION_STD_PREV:
                if(top_user > 0)
                    top_user--;
                break;
            case ACTION_STD_OK:
            case ACTION_STD_MENU:
                lcd_setfont(FONT_UI);
                return true;
            case ACTION_STD_CANCEL:
                lcd_setfont(FONT_UI);
                return false;
        }

        lcd_clear_display();
        unsigned cur_line = 0;
        unsigned last_line = lcd_getheight() / font_get(lcd_getfont())->height;
        unsigned i = 0;

        for(i = 0; i < ARRAYLEN(dbg_ocotp); i++)
        {
            if(i >= top_user && cur_line < last_line)
            {
                lcd_putsf(0, cur_line, "%s", dbg_ocotp[i].name);
                lcd_putsf(8, cur_line++, "%x", imx233_ocotp_read(dbg_ocotp[i].addr));
            }
        }
        if(i < top_user)
            top_user = i - 1;
        
        lcd_update();
        yield();
    }
}
Exemple #5
0
bool dbg_hw_info_icoll(void)
{
    lcd_setfont(FONT_SYSFIXED);

    int first_irq = 0;
    int dbg_irqs_count = sizeof(dbg_irqs) / sizeof(dbg_irqs[0]);
    int line_count = lcd_getheight() / font_get(lcd_getfont())->height;
    
    while(1)
    {
        int button = get_action(CONTEXT_STD, HZ / 10);
        switch(button)
        {
            case ACTION_STD_NEXT:
                first_irq++;
                if(first_irq >= dbg_irqs_count)
                    first_irq = dbg_irqs_count - 1;
                break;
            case ACTION_STD_PREV:
                first_irq--;
                if(first_irq < 0)
                    first_irq = 0;
                break;
            case ACTION_STD_OK:
            case ACTION_STD_MENU:
                lcd_setfont(FONT_UI);
                return true;
            case ACTION_STD_CANCEL:
                lcd_setfont(FONT_UI);
                return false;
        }

        lcd_clear_display();
        for(int i = first_irq, j = 0; i < dbg_irqs_count && j < line_count; i++, j++)
        {
            struct imx233_icoll_irq_info_t info = imx233_icoll_get_irq_info(dbg_irqs[i].src);
            lcd_putsf(0, j, "%s", dbg_irqs[i].name);
            if(info.enabled)
                lcd_putsf(10, j, "%d", info.freq);
        }
        lcd_update();
        yield();
    }
}
Exemple #6
0
bool dbg_hw_info_clkctrl(void)
{
    lcd_setfont(FONT_SYSFIXED);
    
    while(1)
    {
        int button = get_action(CONTEXT_STD, HZ / 10);
        switch(button)
        {
            case ACTION_STD_NEXT:
            case ACTION_STD_PREV:
            case ACTION_STD_OK:
            case ACTION_STD_MENU:
                lcd_setfont(FONT_UI);
                return true;
            case ACTION_STD_CANCEL:
                lcd_setfont(FONT_UI);
                return false;
        }
        
        lcd_clear_display();

        /*               012345678901234567890123456789 */
        lcd_putsf(0, 0, "name en by idiv fdiv frequency");
        for(unsigned i = 0; i < ARRAYLEN(dbg_clk); i++)
        {
            #define c dbg_clk[i]
            lcd_putsf(0, i + 1, "%4s", c.name);
            if(c.has_enable)
                lcd_putsf(5, i + 1, "%2d", imx233_clkctrl_is_clock_enabled(c.clk));
            if(c.has_bypass)
                lcd_putsf(8, i + 1, "%2d", imx233_clkctrl_get_bypass_pll(c.clk));
            if(c.has_idiv && imx233_clkctrl_get_clock_divisor(c.clk) != 0)
                lcd_putsf(10, i + 1, "%4d", imx233_clkctrl_get_clock_divisor(c.clk));
            if(c.has_fdiv && imx233_clkctrl_get_fractional_divisor(c.clk) != 0)
                lcd_putsf(16, i + 1, "%4d", imx233_clkctrl_get_fractional_divisor(c.clk));
            if(c.has_freq)
                lcd_putsf(21, i + 1, "%9d", imx233_clkctrl_get_clock_freq(c.clk));
            #undef c
        }
        int line = ARRAYLEN(dbg_clk) + 1;
        lcd_putsf(0, line, "as: %d/%d  emi sync: %d", imx233_clkctrl_is_auto_slow_enabled(),
            1 << imx233_clkctrl_get_auto_slow_divisor(), imx233_clkctrl_is_emi_sync_enabled());
        line++;
        lcd_putsf(0, line, "as monitor: ");
        int x_off = 12;
        bool first = true;
        unsigned line_w = lcd_getwidth() / font_get_width(font_get(lcd_getfont()), ' ');
        for(unsigned i = 0; i < ARRAYLEN(dbg_as_monitor); i++)
        {
            if(!imx233_clkctrl_is_auto_slow_monitor_enabled(dbg_as_monitor[i].monitor))
                continue;
            if(!first)
            {
                lcd_putsf(x_off, line, ", ");
                x_off += 2;
            }
            first = false;
            if((x_off + strlen(dbg_as_monitor[i].name)) > line_w)
            {
                x_off = 1;
                line++;
            }
            lcd_putsf(x_off, line, "%s", dbg_as_monitor[i].name);
            x_off += strlen(dbg_as_monitor[i].name);
        }
        line++;
        
        lcd_update();
        yield();
    }
}
Exemple #7
0
bool logfdisplay(void)
{
    int action;
    int w, h, i, index;
    int fontnr;
    int cur_x, cur_y, delta_y, delta_x;
    struct font* font;
    int user_index;/* user_index will be number of the first line to display (warning: line!=logf entry) */
    char buf[2];
    
    fontnr = lcd_getfont();
    font = font_get(fontnr);
    
    /* get the horizontal size of each line */
    font_getstringsize("A", NULL, &delta_y, fontnr);
    
    buf[1] = '\0';
    w = LCD_WIDTH;
    h = LCD_HEIGHT;
    /* start at the end of the log */
    user_index = compute_nb_lines(w, font) - h/delta_y -1; /* if negative, will be set 0 to zero later */

    do {
        lcd_clear_display();
        
        if(user_index < 0)
            user_index = 0;
        
        if(logfwrap)
            i = logfindex;
        else
            i = 0;
        
        index = 0;
        cur_x = 0;
        cur_y = 0;
        
        /* nothing to print ? */
        if(logfindex == 0 && !logfwrap)
            goto end_print;
        
        do {
            if(logfbuffer[i] == '\0')
            {
                /* should be display a newline ? */
                if(index >= user_index)
                    cur_y += delta_y;
                cur_x = 0;
                index++;
            }
            else
            {
                /* does character fit on this line ? */
                delta_x = font_get_width(font, logfbuffer[i]);
                
                if(cur_x + delta_x > w)
                {
                    /* should be display a newline ? */
                    if(index >= user_index)
                        cur_y += delta_y;
                    cur_x = 0;
                    index++;
                }
                
                /* should we print character ? */
                if(index >= user_index)
                {
                    buf[0] = logfbuffer[i];
                    lcd_putsxy(cur_x, cur_y, buf);
                }
                
                /* update pointer */
                cur_x += delta_x;
            }
            
            /* did we fill the screen ? */
            if(cur_y > h)
                break;
            
            i++;
            if(i >= MAX_LOGF_SIZE)
                i = 0;
        } while(i != logfindex);
        
        end_print:
        lcd_update();
        
        action = get_action(CONTEXT_STD, HZ);
        switch( action )
        {
            case ACTION_STD_NEXT:
            case ACTION_STD_NEXTREPEAT:
                user_index++;
                break;
            case ACTION_STD_PREV:
            case ACTION_STD_PREVREPEAT:
                user_index--;
                break;
            case ACTION_STD_OK:
                user_index = 0;
                break;
#ifdef HAVE_TOUCHSCREEN
            case ACTION_TOUCHSCREEN:
            {
                short x, y;
                static int prev_y;
                
                action = action_get_touchscreen_press(&x, &y);
                
                if(action & BUTTON_REL)
                    prev_y = 0;
                else
                {
                    if(prev_y != 0)
                        user_index += (prev_y - y) / delta_y;
                    
                    prev_y = y;
                }
            }
#endif
            default:
                break;
        }
    } while(action != ACTION_STD_CANCEL);

    return false;
}
Exemple #8
0
static void displayremote(void)
{
    /* TODO: we should have a debug option that enables/disables this! */
    int w, h, i;
    int fontnr;
    int cur_x, cur_y, delta_y, delta_x;
    struct font* font;
    int nb_lines;
    char buf[2];
    /* Memorize the pointer to the beginning of the last ... lines
       I assume delta_y >= 6 to avoid wasting memory and allocating memory dynamically
       I hope there is no font with height < 6 ! */
    const int NB_ENTRIES=LCD_REMOTE_HEIGHT / 6;
    int line_start_ptr[NB_ENTRIES];

    fontnr = lcd_getfont();
    font = font_get(fontnr);

    /* get the horizontal size of each line */
    font_getstringsize("A", NULL, &delta_y, fontnr);

    /* font too small ? */
    if(delta_y < 6)
        return;
    /* nothing to print ? */
    if(logfindex == 0 && !logfwrap)
        return;

    w = LCD_REMOTE_WIDTH;
    h = LCD_REMOTE_HEIGHT;
    nb_lines = 0;

    if(logfwrap)
        i = logfindex;
    else
        i = 0;

    cur_x = 0;

    line_start_ptr[0] = i;

    do
    {
        if(logfbuffer[i] == '\0')
        {
            line_start_ptr[++nb_lines % NB_ENTRIES] = i+1;
            cur_x = 0;
        }
        else
        {
            /* does character fit on this line ? */
            delta_x = font_get_width(font, logfbuffer[i]);

            if(cur_x + delta_x > w)
            {
                cur_x = 0;
                line_start_ptr[++nb_lines % NB_ENTRIES] = i;
            }
            /* update pointer */
            cur_x += delta_x;
        }
        i++;
        if(i >= MAX_LOGF_SIZE)
            i = 0;
    } while(i != logfindex);

    lcd_remote_clear_display();

    i = line_start_ptr[ MAX(nb_lines - h / delta_y, 0) % NB_ENTRIES];
    cur_x = 0;
    cur_y = 0;
    buf[1] = '\0';

    do {
        if(logfbuffer[i] == '\0')
        {
            cur_y += delta_y;
            cur_x = 0;
        }
        else
        {
            /* does character fit on this line ? */
            delta_x = font_get_width(font, logfbuffer[i]);

            if(cur_x + delta_x > w)
            {
                cur_y += delta_y;
                cur_x = 0;
            }

            buf[0] = logfbuffer[i];
            lcd_remote_putsxy(cur_x, cur_y, buf);
            cur_x += delta_x;
        }

        i++;
        if(i >= MAX_LOGF_SIZE)
            i = 0;
    } while(i != logfindex);

    lcd_remote_update();
}