コード例 #1
0
ファイル: menu.c プロジェクト: BackupTheBerlios/bimmerbox
void menu_draw(int m)
{
    int i = 0;
#ifdef HAVE_LCD_BITMAP
    int fw, fh;
    int menu_lines;
    int height = LCD_HEIGHT;
    
    lcd_setfont(FONT_UI);
    lcd_getstringsize("A", &fw, &fh);
    if (global_settings.statusbar)
        height -= STATUSBAR_HEIGHT;

#if CONFIG_KEYPAD == RECORDER_PAD
    if(global_settings.buttonbar && menus[m].use_buttonbar) {
        buttonbar_set(menus[m].buttonbar[0],
                      menus[m].buttonbar[1],
                      menus[m].buttonbar[2]);
        height -= BUTTONBAR_HEIGHT;
    }
#endif

    menu_lines = height / fh;
    
#else
    int menu_lines = MENU_LINES;
#endif

    lcd_clear_display();
#ifdef HAVE_LCD_BITMAP
    lcd_setmargins(MARGIN_X,MARGIN_Y); /* leave room for cursor and icon */
#endif
    /* Adjust cursor pos if it's below the screen */
    if (menus[m].cursor - menus[m].top >= menu_lines)
        menus[m].top = menus[m].cursor - (menu_lines - 1);

    /* Adjust cursor pos if it's above the screen */
    if(menus[m].cursor < menus[m].top)
        menus[m].top = menus[m].cursor;

    for (i = menus[m].top; 
         (i < menus[m].itemcount) && (i<menus[m].top+menu_lines);
         i++) {

        /* We want to scroll the line where the cursor is */
        if((menus[m].cursor - menus[m].top)==(i-menus[m].top))
#ifdef HAVE_LCD_BITMAP
            if (global_settings.invert_cursor)
                lcd_puts_scroll_style(LINE_X, i-menus[m].top,
                                       P2STR(menus[m].items[i].desc), STYLE_INVERT);
            else
#endif
                lcd_puts_scroll(LINE_X, i-menus[m].top, P2STR(menus[m].items[i].desc));
        else
            lcd_puts(LINE_X, i-menus[m].top, P2STR(menus[m].items[i].desc));
    }

    /* place the cursor */
    put_cursorxy(CURSOR_X, menus[m].cursor - menus[m].top, true);
    
#ifdef HAVE_LCD_BITMAP
    if (global_settings.scrollbar && menus[m].itemcount > menu_lines) 
        scrollbar(SCROLLBAR_X, SCROLLBAR_Y, SCROLLBAR_WIDTH - 1,
                  height, menus[m].itemcount, menus[m].top,
                  menus[m].top + menu_lines, VERTICAL);

#if CONFIG_KEYPAD == RECORDER_PAD
    if(global_settings.buttonbar && menus[m].use_buttonbar)
        buttonbar_draw();
#endif /* CONFIG_KEYPAD == RECORDER_PAD */
#endif /* HAVE_LCD_BITMAP */
    status_draw(true);

    lcd_update();
}
コード例 #2
0
ファイル: telechips.c プロジェクト: Cortexelus/rockbox
/* The following function is just test/development code */
void show_debug_screen(void)
{
    int button;
    int power_count = 0;
    int count = 0;
    bool do_power_off = false;
    
    lcd_puts_scroll(0,0,"+++ this is a very very long line to test scrolling. ---");
    while (!do_power_off) {
        line = 1;
        button = button_get(false);
        
        /* Power-off if POWER button has been held for a time
           This loop is currently running at about 100 iterations/second
         */
        if (button & POWEROFF_BUTTON) {
            power_count++;
            if (power_count > 100)
               do_power_off = true;
        } else {
            power_count = 0;
        }
#if 0
        if (button & BUTTON_SELECT){
            _backlight_off();
        }
        else{
            _backlight_on();
        }
#endif
        printf("Btn: 0x%08x",button);
#if 0
        printf("Tick: %d",current_tick);
        printf("GPIOA: 0x%08x",GPIOA);
        printf("GPIOB: 0x%08x",GPIOB);
        printf("GPIOC: 0x%08x",GPIOC);
        printf("GPIOD: 0x%08x",GPIOD);
        printf("GPIOE: 0x%08x",GPIOE);
#endif

#if 0
        int i;
        for (i = 0; i<4; i++)
        {
            printf("ADC%d: 0x%04x",i,adc_read(i));
        }
#endif
        count++;
        printf("Count: %d",count);
        lcd_update();
        sleep(HZ/10);

    }

    lcd_clear_display();
    line = 0;
    printf("POWER-OFF");

    /* Power-off */
    power_off();

    printf("(NOT) POWERED OFF");
    while (true);
}
コード例 #3
0
bool set_sound(const char* string,
               int* variable,
               int setting)
{
    bool done = false;
    bool changed = true;
    int min, max;
    int val;
    int numdec;
    int integer;
    int dec;
    const char* unit;
    char str[32];
    int talkunit = UNIT_INT;
    int steps;
    int button;

    unit = sound_unit(setting);
    numdec = sound_numdecimals(setting);
    steps = sound_steps(setting);
    min = sound_min(setting);
    max = sound_max(setting);
    if (*unit == 'd') /* crude reconstruction */
        talkunit = UNIT_DB;
    else if (*unit == '%')
        talkunit = UNIT_PERCENT;
    else if (*unit == 'H')
         talkunit = UNIT_HERTZ;
    
#ifdef HAVE_LCD_BITMAP
    if(global_settings.statusbar)
        lcd_setmargins(0, STATUSBAR_HEIGHT);
    else
        lcd_setmargins(0, 0);
#endif
    lcd_clear_display();
    lcd_puts_scroll(0,0,string);

    while (!done) {
        if (changed) {
            val = sound_val2phys(setting, *variable);
            if(numdec)
            {
                integer = val / (10 * numdec);
                dec = val % (10 * numdec);
                snprintf(str,sizeof str, fmt[numdec], integer, dec, unit);
            }
            else
            {
                snprintf(str,sizeof str,"%d %s  ", val, unit);
            }
            if (global_settings.talk_menu)
                talk_value(val, talkunit, false); /* speak it */
        }
        lcd_puts(0,1,str);
        status_draw(true);
        lcd_update();

        changed = false;
        button = button_get_w_tmo(HZ/2);
        switch( button ) {
            case SETTINGS_INC:
            case SETTINGS_INC | BUTTON_REPEAT:
                (*variable)+=steps;
                if(*variable > max )
                    *variable = max;
                changed = true;
                break;

            case SETTINGS_DEC:
            case SETTINGS_DEC | BUTTON_REPEAT:
                (*variable)-=steps;
                if(*variable < min )
                    *variable = min;
                changed = true;
                break;

            case SETTINGS_OK:
            case SETTINGS_CANCEL:
#ifdef SETTINGS_OK2
            case SETTINGS_OK2:
#endif
#ifdef SETTINGS_CANCEL2
            case SETTINGS_CANCEL2:
#endif
                done = true;
                break;

            default:
                if(default_event_handler(button) == SYS_USB_CONNECTED)
                    return true;
                break;
        }
        if (changed)
            sound_set(setting, *variable);
    }
    lcd_stop_scroll();
    return false;
}