blob: 838d1f96da2be70ed0d294e248760114c59e147c [file] [log] [blame]
Jonathan Gordonb6867dc2010-05-17 15:03:59 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
Dave Chapman36e52602010-05-17 21:42:07 +00008 * $Id$
Jonathan Gordonb6867dc2010-05-17 15:03:59 +00009 *
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
35extern struct wps_state wps_state; /* from wps.c */
36static struct gui_wps fms_skin[NB_SCREENS] = {{ .data = NULL }};
37static struct wps_data fms_skin_data[NB_SCREENS] = {{ .wps_loaded = 0 }};
38static struct wps_sync_data fms_skin_sync_data = { .do_full_update = false };
39
40void 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 Arnold6ecb4d02010-05-26 05:58:46 +000048 const char default_fms[] = "%s%?Ti<%Ti. |>%?Tn<%Tn|%Tf>\n"
Jonathan Gordon5b0521c2010-06-07 03:44:11 +000049 "%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 Gordonb6867dc2010-05-17 15:03:59 +000052#if CONFIG_CODEC != SWCODEC && !defined(SIMULATOR)
Jonathan Gordon5b0521c2010-06-07 03:44:11 +000053 "%?Rr<%Sx(Time:) %Rh:%Rn:%Rs|%?St(prerecording time)<%pm|%Sx(Prerecord Time) %Rs>>\n"
Marianne Arnold6ecb4d02010-05-26 05:58:46 +000054#endif
55 "%pb\n"
Jonathan Gordonb6867dc2010-05-17 15:03:59 +000056#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}
64void 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
91void 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
109int 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
115struct gui_wps *fms_get(enum screen_type screen)
116{
117 return &fms_skin[screen];
118}