📄 screens.c
字号:
break; case SYS_USB_CONNECTED: usb_screen(); return 2; } } lcd_setfont(FONT_UI); if ( used ) return 1; else return 0;}bool f2_screen(void){ bool exit = false; bool used = false; int w, h; char buf[32]; int oldrepeat = global_settings.repeat_mode; lcd_setfont(FONT_SYSFIXED); lcd_getstringsize("A",&w,&h); while (!exit) { char* ptr=NULL; lcd_clear_display(); /* Shuffle mode */ lcd_putsxy(0, LCD_HEIGHT/2 - h*2, str(LANG_SHUFFLE)); lcd_putsxy(0, LCD_HEIGHT/2 - h, str(LANG_F2_MODE)); lcd_putsxy(0, LCD_HEIGHT/2, global_settings.playlist_shuffle ? str(LANG_ON) : str(LANG_OFF)); lcd_bitmap(bitmap_icons_7x8[Icon_FastBackward], LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8, true); /* Directory Filter */ switch ( global_settings.dirfilter ) { case SHOW_ALL: ptr = str(LANG_FILTER_ALL); break; case SHOW_SUPPORTED: ptr = str(LANG_FILTER_SUPPORTED); break; case SHOW_MUSIC: ptr = str(LANG_FILTER_MUSIC); break; case SHOW_PLAYLIST: ptr = str(LANG_FILTER_PLAYLIST); break; } snprintf(buf, sizeof buf, "%s:", str(LANG_FILTER)); lcd_getstringsize(buf,&w,&h); lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h*2, buf); lcd_getstringsize(ptr,&w,&h); lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, ptr); lcd_bitmap(bitmap_icons_7x8[Icon_DownArrow], LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8, true); /* Repeat Mode */ switch ( global_settings.repeat_mode ) { case REPEAT_OFF: ptr = str(LANG_OFF); break; case REPEAT_ALL: ptr = str(LANG_REPEAT_ALL); break; case REPEAT_ONE: ptr = str(LANG_REPEAT_ONE); break; } lcd_getstringsize(str(LANG_REPEAT),&w,&h); lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h*2, str(LANG_REPEAT)); lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h, str(LANG_F2_MODE)); lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2, ptr); lcd_bitmap(bitmap_icons_7x8[Icon_FastForward], LCD_WIDTH/2 + 8, LCD_HEIGHT/2 - 4, 7, 8, true); lcd_update(); switch (button_get(true)) { case BUTTON_LEFT: case BUTTON_F2 | BUTTON_LEFT: global_settings.playlist_shuffle = !global_settings.playlist_shuffle; if(mpeg_status() & MPEG_STATUS_PLAY) { if (global_settings.playlist_shuffle) playlist_randomise(NULL, current_tick, true); else playlist_sort(NULL, true); } used = true; break; case BUTTON_DOWN: case BUTTON_F2 | BUTTON_DOWN: global_settings.dirfilter++; if ( global_settings.dirfilter >= NUM_FILTER_MODES ) global_settings.dirfilter = 0; used = true; break; case BUTTON_RIGHT: case BUTTON_F2 | BUTTON_RIGHT: global_settings.repeat_mode++; if ( global_settings.repeat_mode >= NUM_REPEAT_MODES ) global_settings.repeat_mode = 0; used = true; break; case BUTTON_F2 | BUTTON_REL: if ( used ) exit = true; used = true; break; case BUTTON_F2 | BUTTON_REPEAT: used = true; break; case BUTTON_OFF | BUTTON_REPEAT: return false; case SYS_USB_CONNECTED: usb_screen(); return true; } } settings_save(); lcd_setfont(FONT_UI); if ( oldrepeat != global_settings.repeat_mode ) mpeg_flush_and_reload_tracks(); return false;}bool f3_screen(void){ bool exit = false; bool used = false; lcd_setfont(FONT_SYSFIXED); while (!exit) { int w,h; char* ptr; lcd_clear_display(); /* Scrollbar */ lcd_putsxy(0, LCD_HEIGHT/2 - h*2, str(LANG_F3_SCROLL)); lcd_putsxy(0, LCD_HEIGHT/2 - h, str(LANG_F3_BAR)); lcd_putsxy(0, LCD_HEIGHT/2, global_settings.scrollbar ? str(LANG_ON) : str(LANG_OFF)); lcd_bitmap(bitmap_icons_7x8[Icon_FastBackward], LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8, true); /* Status bar */ ptr = str(LANG_F3_STATUS); lcd_getstringsize(ptr,&w,&h); lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h*2, ptr); lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h, str(LANG_F3_BAR)); lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2, global_settings.statusbar ? str(LANG_ON) : str(LANG_OFF)); lcd_bitmap(bitmap_icons_7x8[Icon_FastForward], LCD_WIDTH/2 + 8, LCD_HEIGHT/2 - 4, 7, 8, true); /* Flip */ ptr = str(LANG_FLIP_DISPLAY); lcd_getstringsize(ptr,&w,&h); lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h*2, str(LANG_FLIP_DISPLAY)); ptr = global_settings.flip_display ? str(LANG_SET_BOOL_YES) : str(LANG_SET_BOOL_NO); lcd_getstringsize(ptr,&w,&h); lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, ptr); lcd_bitmap(bitmap_icons_7x8[Icon_DownArrow], LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8, true); lcd_update(); switch (button_get(true)) { case BUTTON_LEFT: case BUTTON_F3 | BUTTON_LEFT: global_settings.scrollbar = !global_settings.scrollbar; used = true; break; case BUTTON_RIGHT: case BUTTON_F3 | BUTTON_RIGHT: global_settings.statusbar = !global_settings.statusbar; used = true; break; case BUTTON_DOWN: case BUTTON_F3 | BUTTON_DOWN: case BUTTON_UP: /* allow "up" as well, more tolerant if tilted */ case BUTTON_F3 | BUTTON_UP: global_settings.flip_display = !global_settings.flip_display; button_set_flip(global_settings.flip_display); lcd_set_flip(global_settings.flip_display); used = true; break; case BUTTON_F3 | BUTTON_REL: if ( used ) exit = true; used = true; break; case BUTTON_F3 | BUTTON_REPEAT: used = true; break; case BUTTON_OFF | BUTTON_REPEAT: return false; case SYS_USB_CONNECTED: usb_screen(); return true; } } settings_save(); if (global_settings.statusbar) lcd_setmargins(0, STATUSBAR_HEIGHT); else lcd_setmargins(0, 0); lcd_setfont(FONT_UI); return false;}#endif#ifdef HAVE_LCD_BITMAP#define SPACE 3 /* pixels between words */#define MAXLETTERS 128 /* 16*8 */#define MAXLINES 10#else#define SPACE 1 /* one letter space */#undef LCD_WIDTH#define LCD_WIDTH 11#undef LCD_HEIGHT#define LCD_HEIGHT 2#define MAXLETTERS 22 /* 11 * 2 */#define MAXLINES 2#endifvoid splash(int ticks, /* how long the splash is displayed */ bool center, /* FALSE means left-justified, TRUE means horizontal and vertical center */ char *fmt, /* what to say *printf style */ ...){ char *next; char *store=NULL; int x=0; int y=0; int w, h; unsigned char splash_buf[MAXLETTERS]; va_list ap; unsigned char widths[MAXLINES]; int line=0; bool first=true;#ifdef HAVE_LCD_BITMAP int maxw=0;#endif va_start( ap, fmt ); vsnprintf( splash_buf, sizeof(splash_buf), fmt, ap ); if(center) { /* first a pass to measure sizes */ next = strtok_r(splash_buf, " ", &store); while (next) {#ifdef HAVE_LCD_BITMAP lcd_getstringsize(next, &w, &h);#else w = strlen(next); h = 1; /* store height in characters */#endif if(!first) { if(x+w> LCD_WIDTH) { /* Too wide, wrap */ y+=h; line++; if((y > (LCD_HEIGHT-h)) || (line > MAXLINES)) /* STOP */ break; x=0; first=true; } } else first = false; /* think of it as if the text was written here at position x,y being w pixels/chars wide and h high */ x += w+SPACE; widths[line]=x-SPACE; /* don't count the trailing space */#ifdef HAVE_LCD_BITMAP /* store the widest line */ if(widths[line]>maxw) maxw = widths[line];#endif next = strtok_r(NULL, " ", &store); }#ifdef HAVE_LCD_BITMAP /* Start displaying the message at position y. The reason for the added h here is that it isn't added until the end of lines in the loop above and we always break the loop in the middle of a line. */ y = (LCD_HEIGHT - (y+h) )/2;#else y = 0; /* vertical center on 2 lines would be silly */#endif first=true; /* Now recreate the string again since the strtok_r() above has ruined the one we already have! Here's room for improvements! */ vsnprintf( splash_buf, sizeof(splash_buf), fmt, ap ); } va_end( ap ); if(center) { x = (LCD_WIDTH-widths[0])/2; if(x < 0) x = 0; }#ifdef HAVE_LCD_BITMAP /* If we center the display and it wouldn't cover the full screen, then just clear the box we need and put a nice little frame and put the text in there! */ if(center && (y > 2)) { if(maxw < (LCD_WIDTH -4)) { int xx = (LCD_WIDTH-maxw)/2 - 2; lcd_clearrect(xx, y-2, maxw+4, LCD_HEIGHT-y*2+4); lcd_drawrect(xx, y-2, maxw+4, LCD_HEIGHT-y*2+4); } else { lcd_clearrect(0, y-2, LCD_WIDTH, LCD_HEIGHT-y*2+4); lcd_drawline(0, y-2, LCD_WIDTH-1, y-2); lcd_drawline(0, LCD_HEIGHT-y+2, LCD_WIDTH-1, LCD_HEIGHT-y+2); } } else#endif lcd_clear_display(); line=0; next = strtok_r(splash_buf, " ", &store); while (next) {#ifdef HAVE_LCD_BITMAP lcd_getstringsize(next, &w, &h);#else w = strlen(next); h = 1;#endif if(!first) { if(x+w> LCD_WIDTH) { /* too wide */ y+=h; line++; /* goto next line */ first=true; if(y > (LCD_HEIGHT-h)) /* STOP */ break; if(center) x = (LCD_WIDTH-widths[line])/2; else x=0; } } else first=false;#ifdef HAVE_LCD_BITMAP lcd_putsxy(x, y, next);#else lcd_puts(x, y, next);#endif x += w+SPACE; /* pixels space! */ next = strtok_r(NULL, " ", &store); } lcd_update(); if(ticks) /* unbreakable! */ sleep(ticks);}void charging_splash(void){ splash(2*HZ, true, str(LANG_BATTERY_CHARGE)); while (button_get(false));}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -