From 04f9cc79937a6939e800c646b4c8e9650898bd7e Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Wed, 4 Feb 2004 09:53:22 +0000 Subject: Added a debug option for the FM radio detection git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4293 a1c6a512-1295-4272-9138-f99709370657 --- apps/debug_menu.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ apps/recorder/radio.c | 5 ++++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/apps/debug_menu.c b/apps/debug_menu.c index 5f22776a4b..78442dcf9c 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c @@ -42,6 +42,7 @@ #include "settings.h" #include "ata.h" #include "fat.h" +#include "radio.h" #ifdef HAVE_LCD_BITMAP #include "widgets.h" #include "peakmeter.h" @@ -1377,6 +1378,46 @@ bool dbg_save_roms(void) return false; } +#ifdef HAVE_FMRADIO +extern int debug_fm_detection; + +bool dbg_fm_radio(void) +{ + char buf[32]; + int button; + bool fm_detected; + +#ifdef HAVE_LCD_BITMAP + lcd_setmargins(0, 0); +#endif + + while(1) + { + lcd_clear_display(); + fm_detected = radio_hardware_present(); + + snprintf(buf, sizeof buf, "HW detected: %s", fm_detected?"yes":"no"); + lcd_puts(0, 0, buf); + snprintf(buf, sizeof buf, "Result: %08x", debug_fm_detection); + lcd_puts(0, 1, buf); + lcd_update(); + + button = button_get(true); + + switch(button) + { +#ifdef HAVE_RECORDER_KEYPAD + case BUTTON_OFF: +#else + case BUTTON_STOP: +#endif + return false; + } + } + return false; +} +#endif + bool debug_menu(void) { int m; @@ -1411,6 +1452,9 @@ bool debug_menu(void) #endif /* PM_DEBUG */ #endif /* HAVE_LCD_BITMAP */ { "View runtime", view_runtime }, +#ifdef HAVE_FMRADIO + { "FM Radio", dbg_fm_radio }, +#endif }; m=menu_init( items, sizeof items / sizeof(struct menu_items) ); diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c index 65b8beb164..819d2a5d5b 100644 --- a/apps/recorder/radio.c +++ b/apps/recorder/radio.c @@ -64,6 +64,8 @@ static struct fmstation presets[MAX_PRESETS]; static char default_filename[] = "/.rockbox/fm-presets-default.fmr"; +int debug_fm_detection; + void radio_load_presets(void); bool radio_preset_select(void); bool radio_menu(void); @@ -81,6 +83,7 @@ bool radio_hardware_present(void) fmradio_set(2, 0x140885); /* 5kHz, 7.2MHz crystal, test mode 1 */ val = fmradio_read(0); + debug_fm_detection = val; if(val == 0x140885) return true; else @@ -554,7 +557,7 @@ void radio_load_presets(void) if(fd >= 0) { i = 0; - while(!done) + while(!done && num_presets < MAX_PRESETS) { rc = read_line(fd, buf, 128); if(rc > 0) -- cgit v1.2.3