Jonathan Gordon | b6867dc | 2010-05-17 15:03:59 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
Dave Chapman | 36e5260 | 2010-05-17 21:42:07 +0000 | [diff] [blame] | 8 | * $Id$ |
Jonathan Gordon | b6867dc | 2010-05-17 15:03:59 +0000 | [diff] [blame] | 9 | * |
| 10 | * Copyright (C) 2010 Jonathan Gordon |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or |
| 13 | * modify it under the terms of the GNU General Public License |
| 14 | * as published by the Free Software Foundation; either version 2 |
| 15 | * of the License, or (at your option) any later version. |
| 16 | * |
| 17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 18 | * KIND, either express or implied. |
| 19 | * |
| 20 | ****************************************************************************/ |
| 21 | |
| 22 | |
| 23 | #include "config.h" |
| 24 | #include <stdio.h> |
| 25 | #include <stdbool.h> |
| 26 | #include <stdlib.h> |
| 27 | #include "skin_engine/skin_engine.h" |
| 28 | #include "settings.h" |
| 29 | #include "radio.h" |
| 30 | #include "action.h" |
| 31 | #include "appevents.h" |
| 32 | #include "statusbar-skinned.h" |
| 33 | |
| 34 | |
| 35 | extern struct wps_state wps_state; /* from wps.c */ |
| 36 | static struct gui_wps fms_skin[NB_SCREENS] = {{ .data = NULL }}; |
| 37 | static struct wps_data fms_skin_data[NB_SCREENS] = {{ .wps_loaded = 0 }}; |
| 38 | static struct wps_sync_data fms_skin_sync_data = { .do_full_update = false }; |
| 39 | |
| 40 | void fms_data_load(enum screen_type screen, const char *buf, bool isfile) |
| 41 | { |
| 42 | struct wps_data *data = fms_skin[screen].data; |
| 43 | int success; |
| 44 | success = buf && skin_data_load(screen, data, buf, isfile); |
| 45 | |
| 46 | if (!success ) /* load the default */ |
| 47 | { |
Marianne Arnold | 6ecb4d0 | 2010-05-26 05:58:46 +0000 | [diff] [blame] | 48 | const char default_fms[] = "%s%?Ti<%Ti. |>%?Tn<%Tn|%Tf>\n" |
Jonathan Gordon | 5b0521c | 2010-06-07 03:44:11 +0000 | [diff] [blame^] | 49 | "%Sx(Station:) %tf MHz\n" |
| 50 | "%?St(force fm mono)<%Sx(Force Mono)|%?ts<%Sx(Stereo)|%Sx(Mono)>>\n" |
| 51 | "%Sx(Mode:) %?tm<%Sx(Scan)|%Sx(Preset)>\n" |
Jonathan Gordon | b6867dc | 2010-05-17 15:03:59 +0000 | [diff] [blame] | 52 | #if CONFIG_CODEC != SWCODEC && !defined(SIMULATOR) |
Jonathan Gordon | 5b0521c | 2010-06-07 03:44:11 +0000 | [diff] [blame^] | 53 | "%?Rr<%Sx(Time:) %Rh:%Rn:%Rs|%?St(prerecording time)<%pm|%Sx(Prerecord Time) %Rs>>\n" |
Marianne Arnold | 6ecb4d0 | 2010-05-26 05:58:46 +0000 | [diff] [blame] | 54 | #endif |
| 55 | "%pb\n" |
Jonathan Gordon | b6867dc | 2010-05-17 15:03:59 +0000 | [diff] [blame] | 56 | #ifdef HAVE_RDS_CAP |
| 57 | "\n%s%ty\n" |
| 58 | "%s%tz\n" |
| 59 | #endif |
| 60 | ; |
| 61 | skin_data_load(screen, data, default_fms, false); |
| 62 | } |
| 63 | } |
| 64 | void fms_fix_displays(enum fms_exiting toggle_state) |
| 65 | { |
| 66 | int i; |
| 67 | FOR_NB_SCREENS(i) |
| 68 | { |
| 69 | if (toggle_state == FMS_ENTER) |
| 70 | { |
| 71 | viewportmanager_theme_enable(i, skin_has_sbs(i, fms_skin[i].data), NULL); |
| 72 | #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 |
| 73 | screens[i].backdrop_show(fms_skin[i].data->backdrop); |
| 74 | #endif |
| 75 | screens[i].clear_display(); |
| 76 | /* force statusbar/skin update since we just cleared the whole screen */ |
| 77 | send_event(GUI_EVENT_ACTIONUPDATE, (void*)1); |
| 78 | } |
| 79 | else |
| 80 | { |
| 81 | screens[i].stop_scroll(); |
| 82 | #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 |
| 83 | screens[i].backdrop_show(sb_get_backdrop(i)); |
| 84 | #endif |
| 85 | viewportmanager_theme_undo(i, skin_has_sbs(i, fms_skin[i].data)); |
| 86 | } |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | |
| 91 | void fms_skin_init(void) |
| 92 | { |
| 93 | int i; |
| 94 | FOR_NB_SCREENS(i) |
| 95 | { |
| 96 | #ifdef HAVE_ALBUMART |
| 97 | fms_skin_data[i].albumart = NULL; |
| 98 | fms_skin_data[i].playback_aa_slot = -1; |
| 99 | #endif |
| 100 | fms_skin[i].data = &fms_skin_data[i]; |
| 101 | fms_skin[i].display = &screens[i]; |
| 102 | /* Currently no seperate wps_state needed/possible |
| 103 | so use the only available ( "global" ) one */ |
| 104 | fms_skin[i].state = &wps_state; |
| 105 | fms_skin[i].sync_data = &fms_skin_sync_data; |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | int fms_do_button_loop(bool update_screen) |
| 110 | { |
| 111 | return skin_wait_for_action(fms_skin, CONTEXT_FM, |
| 112 | update_screen ? TIMEOUT_NOBLOCK : HZ); |
| 113 | } |
| 114 | |
| 115 | struct gui_wps *fms_get(enum screen_type screen) |
| 116 | { |
| 117 | return &fms_skin[screen]; |
| 118 | } |