Signal strength meter for FM radio - FS#8151 by Przemysław Hołubowski
[maemo-rb.git] / apps / radio / radio_skin.c
blob68314d62b5c8eede2963c25b1b78dd526127124c
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2010 Jonathan Gordon
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
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 "tuner.h"
31 #include "action.h"
32 #include "appevents.h"
33 #include "statusbar-skinned.h"
34 #include "option_select.h"
37 char* default_radio_skin(enum screen_type screen)
39 (void)screen;
40 static char default_fms[] =
41 "%s%?Ti<%Ti. |>%?Tn<%Tn|%Tf>\n"
42 "%Sx(Station:) %tf MHz\n"
43 "%?St(force fm mono)<%Sx(Force Mono)|%?ts<%Sx(Stereo)|%Sx(Mono)>>\n"
44 "%Sx(Mode:) %?tm<%Sx(Scan)|%Sx(Preset)>\n"
45 #ifdef HAVE_RADIO_RSSI
46 "%Sx(Signal strength:) %tr dBuV\n"
47 #endif
48 #if CONFIG_CODEC != SWCODEC && !defined(SIMULATOR)
49 "%?Rr<%Sx(Time:) %Rh:%Rn:%Rs|%?St(prerecording time)<%pm|%Sx(Prerecord Time) %Rs>>\n"
50 #endif
51 "%pb\n"
52 #ifdef HAVE_RDS_CAP
53 "\n%s%ty\n"
54 "%s%tz\n"
55 #endif
57 return default_fms;
60 void fms_fix_displays(enum fms_exiting toggle_state)
62 int i;
63 FOR_NB_SCREENS(i)
65 struct wps_data *data = skin_get_gwps(FM_SCREEN, i)->data;
66 if (toggle_state == FMS_ENTER)
68 viewportmanager_theme_enable(i, skin_has_sbs(i, data), NULL);
69 #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
70 skin_backdrop_show(data->backdrop_id);
71 #endif
72 screens[i].clear_display();
73 /* force statusbar/skin update since we just cleared the whole screen */
74 send_event(GUI_EVENT_ACTIONUPDATE, (void*)1);
76 else
78 screens[i].stop_scroll();
79 #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
80 skin_backdrop_show(sb_get_backdrop(i));
81 #endif
82 viewportmanager_theme_undo(i, skin_has_sbs(i, data));
84 #ifdef HAVE_TOUCHSCREEN
85 if (i==SCREEN_MAIN && !data->touchregions)
86 touchscreen_set_mode(toggle_state == FMS_ENTER ?
87 TOUCHSCREEN_BUTTON : global_settings.touch_mode);
88 #endif
93 int fms_do_button_loop(bool update_screen)
95 int button = skin_wait_for_action(FM_SCREEN, CONTEXT_FM,
96 update_screen ? TIMEOUT_NOBLOCK : HZ/5);
97 #ifdef HAVE_TOUCHSCREEN
98 struct touchregion *region;
99 int offset;
100 if (button == ACTION_TOUCHSCREEN)
101 button = skin_get_touchaction(skin_get_gwps(FM_SCREEN, SCREEN_MAIN)->data,
102 &offset, &region);
103 switch (button)
105 case ACTION_WPS_STOP:
106 return ACTION_FM_STOP;
107 case ACTION_STD_CANCEL:
108 return ACTION_FM_EXIT;
109 case ACTION_WPS_VOLUP:
110 return ACTION_SETTINGS_INC;
111 case ACTION_WPS_VOLDOWN:
112 return ACTION_SETTINGS_DEC;
113 case ACTION_WPS_PLAY:
114 return ACTION_FM_PLAY;
115 case ACTION_STD_MENU:
116 return ACTION_FM_MENU;
117 case WPS_TOUCHREGION_SCROLLBAR:
118 /* TODO */
119 break;
120 case ACTION_SETTINGS_INC:
121 case ACTION_SETTINGS_DEC:
123 const struct settings_list *setting = region->extradata;
124 option_select_next_val(setting, button == ACTION_SETTINGS_DEC, true);
126 return ACTION_REDRAW;
128 #endif
129 return button;
132 struct gui_wps *fms_get(enum screen_type screen)
134 return skin_get_gwps(FM_SCREEN, screen);