int get_radio(int unit, int subunit) { char tmp[100], prefix[] = "wlXXXXXXXXXXXXXX"; if (subunit > 0) snprintf(prefix, sizeof(prefix), "wl%d.%d_", unit, subunit); else snprintf(prefix, sizeof(prefix), "wl%d_", unit); if (subunit > 0) return nvram_match(strcat_r(prefix, "radio", tmp), "1"); else return get_radio_status(nvram_safe_get(strcat_r(prefix, "ifname", tmp))); }
int current_playmode(void) { int audio_stat = audio_status(); /* ff_mode can be either STATUS_FASTFORWARD or STATUS_FASTBACKWARD and that supercedes the other modes */ if(ff_mode) return ff_mode; if(audio_stat & AUDIO_STATUS_PLAY) { if(audio_stat & AUDIO_STATUS_PAUSE) return STATUS_PAUSE; else return STATUS_PLAY; } #ifdef HAVE_RECORDING if(audio_stat & AUDIO_STATUS_RECORD) { if(audio_stat & AUDIO_STATUS_PAUSE) return STATUS_RECORD_PAUSE; else return STATUS_RECORD; } #endif #if CONFIG_TUNER audio_stat = get_radio_status(); if(audio_stat & FMRADIO_PLAYING) return STATUS_RADIO; if(audio_stat & FMRADIO_PAUSED) return STATUS_RADIO_PAUSE; #endif return STATUS_STOP; }
static bool do_non_text_tags(struct gui_wps *gwps, struct skin_draw_info *info, struct skin_element *element, struct viewport* vp) { #ifndef HAVE_LCD_BITMAP (void)vp; /* silence warnings */ (void)info; #endif struct wps_token *token = (struct wps_token *)element->data; #ifdef HAVE_LCD_BITMAP struct wps_data *data = gwps->data; bool do_refresh = (element->tag->flags & info->refresh_type) > 0; #endif switch (token->type) { #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)) case SKIN_TOKEN_VIEWPORT_FGCOLOUR: { struct viewport_colour *col = token->value.data; col->vp->fg_pattern = col->colour; } break; case SKIN_TOKEN_VIEWPORT_BGCOLOUR: { struct viewport_colour *col = token->value.data; col->vp->bg_pattern = col->colour; } break; #endif case SKIN_TOKEN_VIEWPORT_ENABLE: { char *label = token->value.data; char temp = VP_DRAW_HIDEABLE; struct skin_element *viewport = gwps->data->tree; while (viewport) { struct skin_viewport *skinvp = (struct skin_viewport*)viewport->data; if (skinvp->label && !skinvp->is_infovp && !strcmp(skinvp->label, label)) { if (skinvp->hidden_flags&VP_DRAW_HIDDEN) { temp |= VP_DRAW_WASHIDDEN; } skinvp->hidden_flags = temp; } viewport = viewport->next; } } break; #ifdef HAVE_LCD_BITMAP case SKIN_TOKEN_UIVIEWPORT_ENABLE: sb_set_info_vp(gwps->display->screen_type, token->value.data); break; case SKIN_TOKEN_PEAKMETER: data->peak_meter_enabled = true; if (do_refresh) draw_peakmeters(gwps, info->line_number, vp); break; #endif #ifdef HAVE_LCD_BITMAP case SKIN_TOKEN_PEAKMETER_LEFTBAR: case SKIN_TOKEN_PEAKMETER_RIGHTBAR: data->peak_meter_enabled = true; /* fall through to the progressbar code */ #endif case SKIN_TOKEN_VOLUMEBAR: case SKIN_TOKEN_BATTERY_PERCENTBAR: #ifdef HAVE_LCD_BITMAP case SKIN_TOKEN_PROGRESSBAR: case SKIN_TOKEN_TUNER_RSSI_BAR: { struct progressbar *bar = (struct progressbar*)token->value.data; if (do_refresh) draw_progressbar(gwps, info->line_number, bar); } #endif break; #ifdef HAVE_LCD_BITMAP case SKIN_TOKEN_IMAGE_DISPLAY_LISTICON: case SKIN_TOKEN_IMAGE_PRELOAD_DISPLAY: { struct image_display *id = token->value.data; const char* label = id->label; struct gui_img *img = skin_find_item(label,SKIN_FIND_IMAGE, data); if (img && img->loaded) { if (id->token == NULL) { img->display = id->subimage; } else { char buf[16]; const char *out; int a = img->num_subimages; out = get_token_value(gwps, id->token, info->offset, buf, sizeof(buf), &a); /* NOTE: get_token_value() returns values starting at 1! */ if (a == -1) a = (out && *out) ? 1 : 2; if (token->type == SKIN_TOKEN_IMAGE_DISPLAY_LISTICON) a -= 2; /* 2 is added in statusbar-skinned.c! */ else a--; a += id->offset; /* Clear the image, as in conditionals */ clear_image_pos(gwps, img); /* If the token returned a value which is higher than * the amount of subimages, don't draw it. */ if (a >= 0 && a < img->num_subimages) { img->display = a; } } } break; } #ifdef HAVE_ALBUMART case SKIN_TOKEN_ALBUMART_DISPLAY: /* now draw the AA */ if (do_refresh && data->albumart) { int handle = playback_current_aa_hid(data->playback_aa_slot); #if CONFIG_TUNER if (in_radio_screen() || (get_radio_status() != FMRADIO_OFF)) { struct dim dim = {data->albumart->width, data->albumart->height}; handle = radio_get_art_hid(&dim); } #endif data->albumart->draw_handle = handle; } break; #endif case SKIN_TOKEN_DRAW_INBUILTBAR: gui_statusbar_draw(&(statusbars.statusbars[gwps->display->screen_type]), info->refresh_type == SKIN_REFRESH_ALL, token->value.data); break; case SKIN_TOKEN_VIEWPORT_CUSTOMLIST: if (do_refresh) skin_render_playlistviewer(token->value.data, gwps, info->skin_vp, info->refresh_type); break; #endif /* HAVE_LCD_BITMAP */ #ifdef HAVE_SKIN_VARIABLES case SKIN_TOKEN_VAR_SET: if (do_refresh) { struct skin_var_changer *data = token->value.data; if (data->direct) data->var->value = data->newval; else { data->var->value += data->newval; if (data->max) { if (data->var->value > data->max) data->var->value = 1; else if (data->var->value < 1) data->var->value = data->max; } } if (data->var->value < 1) data->var->value = 1; data->var->last_changed = current_tick; } break; #endif default: return false; } return true; }
void draw_progressbar(struct gui_wps *gwps, int line, struct progressbar *pb) { struct screen *display = gwps->display; struct viewport *vp = pb->vp; struct wps_state *state = skin_get_global_state(); struct mp3entry *id3 = state->id3; int x = pb->x, y = pb->y, width = pb->width, height = pb->height; unsigned long length, end; int flags = HORIZONTAL; if (height < 0) height = font_get(vp->font)->height; if (y < 0) { int line_height = font_get(vp->font)->height; /* center the pb in the line, but only if the line is higher than the pb */ int center = (line_height-height)/2; /* if Y was not set calculate by font height,Y is -line_number-1 */ y = line*line_height + (0 > center ? 0 : center); } if (pb->type == SKIN_TOKEN_VOLUMEBAR) { int minvol = sound_min(SOUND_VOLUME); int maxvol = sound_max(SOUND_VOLUME); length = maxvol-minvol; end = global_settings.volume-minvol; } else if (pb->type == SKIN_TOKEN_BATTERY_PERCENTBAR) { length = 100; end = battery_level(); } else if (pb->type == SKIN_TOKEN_PEAKMETER_LEFTBAR || pb->type == SKIN_TOKEN_PEAKMETER_RIGHTBAR) { int left, right, val; peak_meter_current_vals(&left, &right); val = pb->type == SKIN_TOKEN_PEAKMETER_LEFTBAR ? left : right; length = MAX_PEAK; end = peak_meter_scale_value(val, length); } #if CONFIG_TUNER else if (in_radio_screen() || (get_radio_status() != FMRADIO_OFF)) { #ifdef HAVE_RADIO_RSSI if (pb->type == SKIN_TOKEN_TUNER_RSSI_BAR) { int val = tuner_get(RADIO_RSSI); int min = tuner_get(RADIO_RSSI_MIN); int max = tuner_get(RADIO_RSSI_MAX); end = val - min; length = max - min; } else #endif { int min = fm_region_data[global_settings.fm_region].freq_min; end = radio_current_frequency() - min; length = fm_region_data[global_settings.fm_region].freq_max - min; } } #endif else if (id3 && id3->length) { length = id3->length; end = id3->elapsed + state->ff_rewind_count; } else { length = 1; end = 0; } if (!pb->horizontal) { /* we want to fill upwards which is technically inverted. */ flags = INVERTFILL; } if (pb->invert_fill_direction) { flags ^= INVERTFILL; } if (pb->nofill) { flags |= INNER_NOFILL; } if (pb->slider) { struct gui_img *img = pb->slider; /* clear the slider */ screen_clear_area(display, x, y, width, height); /* shrink the bar so the slider is inside bounds */ if (flags&HORIZONTAL) { width -= img->bm.width; x += img->bm.width / 2; } else { height -= img->bm.height; y += img->bm.height / 2; } } if (pb->backdrop) { struct gui_img *img = pb->backdrop; #if LCD_DEPTH > 1 if(img->bm.format == FORMAT_MONO) { #endif display->mono_bitmap_part(img->bm.data, 0, 0, img->bm.width, x, y, width, height); #if LCD_DEPTH > 1 } else { display->transparent_bitmap_part((fb_data *)img->bm.data, 0, 0, STRIDE(display->screen_type, img->bm.width, img->bm.height), x, y, width, height); } #endif flags |= DONT_CLEAR_EXCESS; } if (!pb->nobar) { if (pb->image) gui_bitmap_scrollbar_draw(display, &pb->image->bm, x, y, width, height, length, 0, end, flags); else gui_scrollbar_draw(display, x, y, width, height, length, 0, end, flags); } if (pb->slider) { int xoff = 0, yoff = 0; int w = width, h = height; struct gui_img *img = pb->slider; if (flags&HORIZONTAL) { w = img->bm.width; xoff = width * end / length; if (flags&INVERTFILL) xoff = width - xoff; xoff -= w / 2; } else { h = img->bm.height; yoff = height * end / length; if (flags&INVERTFILL) yoff = height - yoff; yoff -= h / 2; } #if LCD_DEPTH > 1 if(img->bm.format == FORMAT_MONO) { #endif display->mono_bitmap_part(img->bm.data, 0, 0, img->bm.width, x + xoff, y + yoff, w, h); #if LCD_DEPTH > 1 } else { display->transparent_bitmap_part((fb_data *)img->bm.data, 0, 0, STRIDE(display->screen_type, img->bm.width, img->bm.height), x + xoff, y + yoff, w, h); } #endif } if (pb->type == SKIN_TOKEN_PROGRESSBAR) { if (id3 && id3->length) { #ifdef AB_REPEAT_ENABLE if (ab_repeat_mode_enabled()) ab_draw_markers(display, id3->length, x, y, width, height); #endif if (id3->cuesheet) cue_draw_markers(display, id3->cuesheet, id3->length, x, y+1, width, height-2); } #if 0 /* disable for now CONFIG_TUNER */ else if (in_radio_screen() || (get_radio_status() != FMRADIO_OFF)) { presets_draw_markers(display, x, y, width, height); } #endif } }
void draw_progressbar(struct gui_wps *gwps, int line, struct progressbar *pb) { struct screen *display = gwps->display; struct viewport *vp = SKINOFFSETTOPTR(get_skin_buffer(gwps->data), pb->vp); struct wps_state *state = skin_get_global_state(); struct mp3entry *id3 = state->id3; int x = pb->x, y = pb->y, width = pb->width, height = pb->height; unsigned long length, end; int flags = HORIZONTAL; if (height < 0) height = font_get(vp->font)->height; if (y < 0) { int line_height = font_get(vp->font)->height; /* center the pb in the line, but only if the line is higher than the pb */ int center = (line_height-height)/2; /* if Y was not set calculate by font height,Y is -line_number-1 */ y = line*line_height + (0 > center ? 0 : center); } if (pb->type == SKIN_TOKEN_VOLUMEBAR) { int minvol = sound_min(SOUND_VOLUME); int maxvol = sound_max(SOUND_VOLUME); length = maxvol-minvol; end = global_settings.volume-minvol; } else if (pb->type == SKIN_TOKEN_BATTERY_PERCENTBAR) { length = 100; end = battery_level(); } else if (pb->type == SKIN_TOKEN_PEAKMETER_LEFTBAR || pb->type == SKIN_TOKEN_PEAKMETER_RIGHTBAR) { int left, right, val; peak_meter_current_vals(&left, &right); val = pb->type == SKIN_TOKEN_PEAKMETER_LEFTBAR ? left : right; length = MAX_PEAK; end = peak_meter_scale_value(val, length); } else if (pb->type == SKIN_TOKEN_LIST_SCROLLBAR) { int val, min, max; skinlist_get_scrollbar(&val, &min, &max); end = val - min; length = max - min; } else if (pb->type == SKIN_TOKEN_SETTINGBAR) { int val, count; get_setting_info_for_bar(pb->setting_id, &count, &val); length = count - 1; end = val; } #if CONFIG_TUNER else if (in_radio_screen() || (get_radio_status() != FMRADIO_OFF)) { #ifdef HAVE_RADIO_RSSI if (pb->type == SKIN_TOKEN_TUNER_RSSI_BAR) { int val = tuner_get(RADIO_RSSI); int min = tuner_get(RADIO_RSSI_MIN); int max = tuner_get(RADIO_RSSI_MAX); end = val - min; length = max - min; } else #endif { int min = fm_region_data[global_settings.fm_region].freq_min; end = radio_current_frequency() - min; length = fm_region_data[global_settings.fm_region].freq_max - min; } } #endif else if (id3 && id3->length) { length = id3->length; end = id3->elapsed + state->ff_rewind_count; } else { length = 1; end = 0; } if (!pb->horizontal) { /* we want to fill upwards which is technically inverted. */ flags = INVERTFILL; } if (pb->invert_fill_direction) { flags ^= INVERTFILL; } if (pb->nofill) { flags |= INNER_NOFILL; } if (SKINOFFSETTOPTR(get_skin_buffer(gwps->data), pb->slider)) { struct gui_img *img = SKINOFFSETTOPTR(get_skin_buffer(gwps->data), pb->slider); /* clear the slider */ screen_clear_area(display, x, y, width, height); /* account for the sliders width in the progressbar */ if (flags&HORIZONTAL) { width -= img->bm.width; } else { height -= img->bm.height; } } if (SKINOFFSETTOPTR(get_skin_buffer(gwps->data), pb->backdrop)) { struct gui_img *img = SKINOFFSETTOPTR(get_skin_buffer(gwps->data), pb->backdrop); img->bm.data = core_get_data(img->buflib_handle); display->bmp_part(&img->bm, 0, 0, x, y, pb->width, height); flags |= DONT_CLEAR_EXCESS; } if (!pb->nobar) { struct gui_img *img = SKINOFFSETTOPTR(get_skin_buffer(gwps->data), pb->image); if (img) { char *img_data = core_get_data(img->buflib_handle); img->bm.data = img_data; gui_bitmap_scrollbar_draw(display, &img->bm, x, y, width, height, length, 0, end, flags); } else gui_scrollbar_draw(display, x, y, width, height, length, 0, end, flags); } if (SKINOFFSETTOPTR(get_skin_buffer(gwps->data), pb->slider)) { int xoff = 0, yoff = 0; int w = width, h = height; struct gui_img *img = SKINOFFSETTOPTR(get_skin_buffer(gwps->data), pb->slider); img->bm.data = core_get_data(img->buflib_handle); if (flags&HORIZONTAL) { w = img->bm.width; xoff = width * end / length; if (flags&INVERTFILL) xoff = width - xoff; } else { h = img->bm.height; yoff = height * end / length; if (flags&INVERTFILL) yoff = height - yoff; } display->bmp_part(&img->bm, 0, 0, x + xoff, y + yoff, w, h); } if (pb->type == SKIN_TOKEN_PROGRESSBAR) { if (id3 && id3->length) { #ifdef AB_REPEAT_ENABLE if (ab_repeat_mode_enabled()) ab_draw_markers(display, id3->length, x, y, width, height); #endif if (id3->cuesheet) cue_draw_markers(display, id3->cuesheet, id3->length, x, y+1, width, height-2); } #if 0 /* disable for now CONFIG_TUNER */ else if (in_radio_screen() || (get_radio_status() != FMRADIO_OFF)) { presets_draw_markers(display, x, y, width, height); } #endif } }