Index: apps/debug_menu.c
===================================================================
RCS file: /cvsroot/rockbox/apps/debug_menu.c,v
retrieving revision 1.43
diff -u -r1.43 debug_menu.c
--- apps/debug_menu.c	17 Mar 2003 19:27:45 -0000	1.43
+++ apps/debug_menu.c	26 Mar 2003 22:38:37 -0000
@@ -756,9 +756,9 @@
                 snprintf(buf, 30, "Charger: %s", 
                          charger_inserted() ? "present" : "absent");
                 lcd_puts(0, 3, buf);
-#ifdef HAVE_CHARGE_CTRL
+#ifdef HAVE_CHARGE_DETECT
                 snprintf(buf, 30, "Charging: %s", 
-                         charger_enabled ? "yes" : "no");
+                         charger_status() ? "yes" : "no");
                 lcd_puts(0, 4, buf);
 #endif                
                 y = ( power_history[POWER_HISTORY_LEN-1] * 100
@@ -802,7 +802,7 @@
                 lcd_clear_display();
 
 #ifdef HAVE_CHARGE_CTRL
-                snprintf(buf, 30, "charge_state: %d", charge_state);
+                snprintf(buf, 30, "charge_state: %d", charger_status());
                 lcd_puts(0, 0, buf);
 
                 snprintf(buf, 30, "Cycle time: %d m", powermgmt_last_cycle_startstop_min);
Index: apps/main_menu.c
===================================================================
RCS file: /cvsroot/rockbox/apps/main_menu.c,v
retrieving revision 1.78
diff -u -r1.78 main_menu.c
--- apps/main_menu.c	11 Feb 2003 15:03:24 -0000	1.78
+++ apps/main_menu.c	26 Mar 2003 22:38:38 -0000
@@ -191,11 +191,11 @@
             lcd_puts(0, y++, s);
             
 #ifdef HAVE_CHARGE_CTRL
-            if (charge_state == 1)
+            if (charger_status() == 1)
                 snprintf(s, sizeof(s), str(LANG_BATTERY_CHARGE));
-            else if (charge_state == 2)
+            else if (charger_status() == 2)
                 snprintf(s, sizeof(s), str(LANG_BATTERY_TOPOFF_CHARGE));
-            else if (charge_state == 3)
+            else if (charger_status() == 3)
                 snprintf(s, sizeof(s), str(LANG_BATTERY_TRICKLE_CHARGE));
             else
 #endif
Index: apps/status.c
===================================================================
RCS file: /cvsroot/rockbox/apps/status.c,v
retrieving revision 1.39
diff -u -r1.39 status.c
--- apps/status.c	13 Feb 2003 21:45:18 -0000	1.39
+++ apps/status.c	26 Mar 2003 22:38:39 -0000
@@ -35,10 +35,10 @@
 
 static enum playmode current_mode = STATUS_STOP;
 
-#if defined(HAVE_LCD_CHARCELLS) || defined(HAVE_CHARGE_CTRL)
+#if defined(HAVE_LCD_CHARCELLS) || defined(HAVE_CHARGE_DETECT)
 static long switch_tick;
 static int  battery_charge_step = 0;
-#ifdef HAVE_CHARGE_CTRL
+#ifdef HAVE_CHARGE_DETECT
 static bool plug_state;
 static bool battery_state;
 #endif
@@ -200,13 +200,13 @@
 #ifdef HAVE_LCD_BITMAP
     if (global_settings.statusbar) {
         statusbar_wipe();
-#ifdef HAVE_CHARGE_CTRL /* Recorder */
+#ifdef HAVE_CHARGE_DETECT /* Recorder and FM */
         if(charger_inserted()) {
             battery_state = true;
             plug_state = true;
-            if (charge_state > 0) /* charge || top off || trickle */
+            if (charger_status() > 0) /* charge || top off || trickle */
                 global_settings.runtime = 0;
-            if (charge_state == 1) { /* animate battery if charging */
+            if (charger_status() == 1) { /* animate battery if charging */
                 battlevel = battery_charge_step * 34; /* 34 for a better look */
                 battlevel = battlevel > 100 ? 100 : battlevel;
                 if(TIME_AFTER(current_tick, switch_tick)) {
Index: apps/recorder/icons.c
===================================================================
RCS file: /cvsroot/rockbox/apps/recorder/icons.c,v
retrieving revision 1.38
diff -u -r1.38 icons.c
--- apps/recorder/icons.c	4 Mar 2003 15:20:51 -0000	1.38
+++ apps/recorder/icons.c	26 Mar 2003 22:38:42 -0000
@@ -166,12 +166,12 @@
 #ifdef SIMULATOR
     if (global_settings.battery_type) {
 #else
-#ifdef HAVE_CHARGE_CTRL /* Recorder */
+#ifdef HAVE_CHARGE_DETECT /* Recorder & FM */
     /* show graphical animation when charging instead of numbers */
-    if ((global_settings.battery_type) && (charge_state != 1)) {
-#else /* FM */
+    if ((global_settings.battery_type) && (charger_status() != 1)) {
+#else
     if (global_settings.battery_type) {
-#endif /* HAVE_CHARGE_CTRL */
+#endif /* HAVE_CHARGE_DETECT */
 #endif
         /* Numeric display */
         snprintf(buffer, sizeof(buffer), "%3d", percent);
Index: firmware/powermgmt.c
===================================================================
RCS file: /cvsroot/rockbox/firmware/powermgmt.c,v
retrieving revision 1.34
diff -u -r1.34 powermgmt.c
--- firmware/powermgmt.c	7 Mar 2003 14:13:58 -0000	1.34
+++ firmware/powermgmt.c	26 Mar 2003 22:38:46 -0000
@@ -37,6 +37,11 @@
 
 #ifdef SIMULATOR
 
+int charger_status(void)
+{
+    return 0;
+}
+
 int battery_level(void)
 {
     return 100;
@@ -142,6 +147,22 @@
 static unsigned long sleeptimer_endtick;
 
 unsigned short power_history[POWER_HISTORY_LEN];
+
+int charger_status(void)
+{
+#ifdef HAVE_CHARGE_CTRL
+    /* Recorder */
+    return charge_state;
+#else
+#ifdef HAVE_FMADC
+    /* FM */
+    return adc_read(ADC_EXT_POWER) > 0x0C0;
+#else
+    /* Player */
+    return 0;
+#endif /* HAVE_FMADC */
+#endif /* HAVE_CHARGE_CTRL */
+}
 
 int battery_time(void)
 {
Index: firmware/export/config-fmrecorder.h
===================================================================
RCS file: /cvsroot/rockbox/firmware/export/config-fmrecorder.h,v
retrieving revision 1.5
diff -u -r1.5 config-fmrecorder.h
--- firmware/export/config-fmrecorder.h	14 Mar 2003 16:26:51 -0000	1.5
+++ firmware/export/config-fmrecorder.h	26 Mar 2003 22:38:47 -0000
@@ -16,6 +16,9 @@
 /* Define this if you have a FM Recorder key system */
 #define HAVE_FMADC 1
 
+/* Define this if you have charging detection */
+#define HAVE_CHARGE_DETECT
+
 /* Define this if you have a LiIon battery */
 #define HAVE_LIION
 
Index: firmware/export/config-recorder.h
===================================================================
RCS file: /cvsroot/rockbox/firmware/export/config-recorder.h,v
retrieving revision 1.1
diff -u -r1.1 config-recorder.h
--- firmware/export/config-recorder.h	7 Feb 2003 09:41:57 -0000	1.1
+++ firmware/export/config-recorder.h	26 Mar 2003 22:38:47 -0000
@@ -16,6 +16,9 @@
 /* Define this if you have charging control */
 #define HAVE_CHARGE_CTRL
 
+/* Define this if you have charging detection */
+#define HAVE_CHARGE_DETECT
+
 /* Define this if you have ATA power-off control */
 #define HAVE_ATA_POWER_OFF
 
Index: firmware/export/powermgmt.h
===================================================================
RCS file: /cvsroot/rockbox/firmware/export/powermgmt.h,v
retrieving revision 1.2
diff -u -r1.2 powermgmt.h
--- firmware/export/powermgmt.h	14 Feb 2003 15:09:12 -0000	1.2
+++ firmware/export/powermgmt.h	26 Mar 2003 22:38:48 -0000
@@ -68,7 +68,6 @@
 extern int battery_lazyness[20]; /* how does the battery react when plugging in/out the charger */
 void enable_trickle_charge(bool on);
 extern int trickle_sec;          /* trickle charge: How many seconds per minute are we charging actually? */
-extern int charge_state;         /* tells what the charger is doing (for info display): 0: decharging/charger off, 1: charge, 2: top-off, 3: trickle */
 
 #endif /* HAVE_CHARGE_CTRL */
 
@@ -83,6 +82,8 @@
 void power_init(void);
 
 #endif /* SIMULATOR */
+
+int charger_status(void);
 
 /* Returns battery level in percent */
 int battery_level(void);


