summaryrefslogtreecommitdiff
path: root/apps/recorder
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2003-05-09 00:14:59 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2003-05-09 00:14:59 +0000
commitaf2b7adefe31839bebbc407083d980a112e7242c (patch)
treeaff0443d92408616e225bc68d6f3834aa7066bda /apps/recorder
parentb909fff38b29db410767a72a474ba4f7f9b8fadb (diff)
downloadrockbox-af2b7adefe31839bebbc407083d980a112e7242c.tar.gz
rockbox-af2b7adefe31839bebbc407083d980a112e7242c.zip
FM radio: ON leaves with radio on, OFF leaves with radio off
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3660 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/recorder')
-rw-r--r--apps/recorder/radio.c66
-rw-r--r--apps/recorder/radio.h1
2 files changed, 42 insertions, 25 deletions
diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c
index d45d1669b6..eba0afa92f 100644
--- a/apps/recorder/radio.c
+++ b/apps/recorder/radio.c
@@ -58,11 +58,18 @@ static struct fmstation presets[MAX_PRESETS];
58 58
59static char default_filename[] = "/.rockbox/fm-presets-default.fmr"; 59static char default_filename[] = "/.rockbox/fm-presets-default.fmr";
60 60
61void fm_load_presets(void); 61void radio_load_presets(void);
62bool fm_preset_select(void); 62bool radio_preset_select(void);
63bool fm_menu(void); 63bool radio_menu(void);
64 64
65void fm_set_frequency(int freq) 65void radio_stop(void)
66{
67 /* Mute the FM radio */
68 fmradio_set(1, 0x100003);
69
70}
71
72void radio_set_frequency(int freq)
66{ 73{
67 /* We add the standard Intermediate Frequency 10.7MHz before calculating 74 /* We add the standard Intermediate Frequency 10.7MHz before calculating
68 ** the divisor 75 ** the divisor
@@ -109,7 +116,7 @@ bool radio_screen(void)
109 fmradio_set_status(FMRADIO_PLAYING); 116 fmradio_set_status(FMRADIO_PLAYING);
110 lcd_getstringsize("A", &fw, &fh); 117 lcd_getstringsize("A", &fw, &fh);
111 118
112 fm_load_presets(); 119 radio_load_presets();
113 120
114 /* Enable the Left and right A/D Converter */ 121 /* Enable the Left and right A/D Converter */
115 mas_codec_writereg(0x0, 0xccc7); 122 mas_codec_writereg(0x0, 0xccc7);
@@ -117,7 +124,7 @@ bool radio_screen(void)
117 mas_codec_writereg(6, 0x4000); 124 mas_codec_writereg(6, 0x4000);
118 125
119 fmradio_set(2, 0x140884); /* 5kHz, 7.2MHz crystal */ 126 fmradio_set(2, 0x140884); /* 5kHz, 7.2MHz crystal */
120 fm_set_frequency(curr_freq); 127 radio_set_frequency(curr_freq);
121 curr_preset = find_preset(curr_freq); 128 curr_preset = find_preset(curr_freq);
122 129
123 while(!done) 130 while(!done)
@@ -131,7 +138,7 @@ bool radio_screen(void)
131 curr_freq = MIN_FREQ; 138 curr_freq = MIN_FREQ;
132 139
133 /* Tune in and delay */ 140 /* Tune in and delay */
134 fm_set_frequency(curr_freq); 141 radio_set_frequency(curr_freq);
135 sleep(10); 142 sleep(10);
136 143
137 /* Start IF measurement */ 144 /* Start IF measurement */
@@ -182,6 +189,15 @@ bool radio_screen(void)
182 switch(button) 189 switch(button)
183 { 190 {
184 case BUTTON_OFF: 191 case BUTTON_OFF:
192 radio_stop();
193
194 /* Turn off the ADC gain */
195 mas_codec_writereg(6, 0x0000);
196
197 done = true;
198 break;
199
200 case BUTTON_ON | BUTTON_REL:
185 done = true; 201 done = true;
186 break; 202 break;
187 203
@@ -190,7 +206,7 @@ bool radio_screen(void)
190 if(curr_freq < MIN_FREQ) 206 if(curr_freq < MIN_FREQ)
191 curr_freq = MIN_FREQ; 207 curr_freq = MIN_FREQ;
192 208
193 fm_set_frequency(curr_freq); 209 radio_set_frequency(curr_freq);
194 curr_preset = find_preset(curr_freq); 210 curr_preset = find_preset(curr_freq);
195 search_dir = 0; 211 search_dir = 0;
196 break; 212 break;
@@ -200,7 +216,7 @@ bool radio_screen(void)
200 if(curr_freq > MAX_FREQ) 216 if(curr_freq > MAX_FREQ)
201 curr_freq = MAX_FREQ; 217 curr_freq = MAX_FREQ;
202 218
203 fm_set_frequency(curr_freq); 219 radio_set_frequency(curr_freq);
204 curr_preset = find_preset(curr_freq); 220 curr_preset = find_preset(curr_freq);
205 search_dir = 0; 221 search_dir = 0;
206 break; 222 break;
@@ -234,7 +250,7 @@ bool radio_screen(void)
234 break; 250 break;
235 251
236 case BUTTON_F1: 252 case BUTTON_F1:
237 fm_menu(); 253 radio_menu();
238 curr_preset = find_preset(curr_freq); 254 curr_preset = find_preset(curr_freq);
239 lcd_clear_display(); 255 lcd_clear_display();
240 lcd_setmargins(0, 8); 256 lcd_setmargins(0, 8);
@@ -242,7 +258,7 @@ bool radio_screen(void)
242 break; 258 break;
243 259
244 case BUTTON_F2: 260 case BUTTON_F2:
245 fm_preset_select(); 261 radio_preset_select();
246 curr_preset = find_preset(curr_freq); 262 curr_preset = find_preset(curr_freq);
247 lcd_clear_display(); 263 lcd_clear_display();
248 lcd_setmargins(0, 8); 264 lcd_setmargins(0, 8);
@@ -287,7 +303,7 @@ static bool parseline(char* line, char** freq, char** name)
287 return true; 303 return true;
288} 304}
289 305
290void fm_save_presets(void) 306void radio_save_presets(void)
291{ 307{
292 int fd; 308 int fd;
293 int i; 309 int i;
@@ -307,7 +323,7 @@ void fm_save_presets(void)
307 } 323 }
308} 324}
309 325
310void fm_load_presets(void) 326void radio_load_presets(void)
311{ 327{
312 int fd; 328 int fd;
313 int rc; 329 int rc;
@@ -350,7 +366,7 @@ void fm_load_presets(void)
350 presets_loaded = true; 366 presets_loaded = true;
351} 367}
352 368
353bool fm_preset_select(void) 369bool radio_preset_select(void)
354{ 370{
355 struct menu_items menu[MAX_PRESETS]; 371 struct menu_items menu[MAX_PRESETS];
356 int m, result; 372 int m, result;
@@ -388,7 +404,7 @@ bool fm_preset_select(void)
388 { 404 {
389 i = (int)menu[result].function; 405 i = (int)menu[result].function;
390 curr_freq = presets[i].frequency; 406 curr_freq = presets[i].frequency;
391 fm_set_frequency(curr_freq); 407 radio_set_frequency(curr_freq);
392 } 408 }
393 } 409 }
394 else 410 else
@@ -400,7 +416,7 @@ bool fm_preset_select(void)
400 return reload_dir; 416 return reload_dir;
401} 417}
402 418
403static bool fm_add_preset(void) 419static bool radio_add_preset(void)
404{ 420{
405 char buf[27]; 421 char buf[27];
406 int i = find_preset(0); 422 int i = find_preset(0);
@@ -414,7 +430,7 @@ static bool fm_add_preset(void)
414 buf[27] = 0; 430 buf[27] = 0;
415 strcpy(presets[i].name, buf); 431 strcpy(presets[i].name, buf);
416 presets[i].frequency = curr_freq; 432 presets[i].frequency = curr_freq;
417 fm_save_presets(); 433 radio_save_presets();
418 } 434 }
419 } 435 }
420 else 436 else
@@ -424,7 +440,7 @@ static bool fm_add_preset(void)
424 return true; 440 return true;
425} 441}
426 442
427bool fm_delete_preset(void) 443bool radio_delete_preset(void)
428{ 444{
429 struct menu_items menu[MAX_PRESETS]; 445 struct menu_items menu[MAX_PRESETS];
430 int m, result; 446 int m, result;
@@ -460,25 +476,25 @@ bool fm_delete_preset(void)
460 { 476 {
461 i = (int)menu[result].function; 477 i = (int)menu[result].function;
462 presets[i].frequency = 0; 478 presets[i].frequency = 0;
463 fm_save_presets(); 479 radio_save_presets();
464 } 480 }
465 } 481 }
466 482
467 return reload_dir; 483 return reload_dir;
468} 484}
469 485
470static struct menu_items fm_menu_items[] = { 486static struct menu_items radio_menu_items[] = {
471 { "Add preset", fm_add_preset }, 487 { "Add preset", radio_add_preset },
472 { "Delete preset", fm_delete_preset } 488 { "Delete preset", radio_delete_preset }
473}; 489};
474 490
475bool fm_menu(void) 491bool radio_menu(void)
476{ 492{
477 int m; 493 int m;
478 bool result; 494 bool result;
479 495
480 m = menu_init( fm_menu_items, 496 m = menu_init( radio_menu_items,
481 sizeof fm_menu_items / sizeof(struct menu_items) ); 497 sizeof radio_menu_items / sizeof(struct menu_items) );
482 result = menu_run(m); 498 result = menu_run(m);
483 menu_exit(m); 499 menu_exit(m);
484 return result; 500 return result;
diff --git a/apps/recorder/radio.h b/apps/recorder/radio.h
index f6d7686ea9..45942a9990 100644
--- a/apps/recorder/radio.h
+++ b/apps/recorder/radio.h
@@ -21,6 +21,7 @@
21 21
22#ifdef HAVE_FMRADIO 22#ifdef HAVE_FMRADIO
23bool radio_screen(void); 23bool radio_screen(void);
24void radio_stop(void);
24 25
25struct fmstation 26struct fmstation
26{ 27{