diff --git a/apps/settings.c b/apps/settings.c index 10333b15c1..bd7ce4329e 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -213,10 +213,12 @@ static const struct bit_entry rtc_bits[] = {1, S_O(discharge), 0, "deep discharge", off_on }, {1, S_O(trickle_charge), true, "trickle charge", off_on }, #endif -#ifdef HAVE_LIION +#if CONFIG_BATTERY == BATT_LIION2200 {12, S_O(battery_capacity), 2200, "battery capacity", NULL }, /* 1500...3200 */ -#else +#elif CONFIG_BATTERY == BATT_4AA_NIMH {12, S_O(battery_capacity), 1500, "battery capacity", NULL }, /* 1500...3200 */ +#elif CONFIG_BATTERY == BATT_3AAA_ALKALINE + {12, S_O(battery_capacity), 1000, "battery capacity", NULL }, #endif {1, S_O(car_adapter_mode), false, "car adapter mode", off_on }, diff --git a/apps/status.c b/apps/status.c index 84a3f8d6c2..248f9b9e1f 100644 --- a/apps/status.c +++ b/apps/status.c @@ -172,7 +172,7 @@ void status_draw(bool force_redraw) if (info.inserted) { battery_state = true; plug_state = true; -#if defined(HAVE_CHARGE_CTRL) || defined(HAVE_LIION) +#if defined(HAVE_CHARGE_CTRL) || CONFIG_BATTERY == BATT_LIION2200 /* zero battery run time if charging */ if (charge_state > 0) { global_settings.runtime = 0; diff --git a/firmware/export/config-fmrecorder.h b/firmware/export/config-fmrecorder.h index af7ca91315..8d3f1a1051 100644 --- a/firmware/export/config-fmrecorder.h +++ b/firmware/export/config-fmrecorder.h @@ -25,9 +25,6 @@ /* Define this if you have a FM Recorder key system */ #define HAVE_FMADC 1 -/* Define this if you have a LiIon battery */ -#define HAVE_LIION - /* Define this if you need to power on ATA */ #define NEEDS_ATA_POWER_ON @@ -37,6 +34,9 @@ /* Define this to the CPU frequency */ #define CPU_FREQ 11059200 +/* Type of mobile power */ +#define CONFIG_BATTERY BATT_LIION2200 + /* Battery scale factor (guessed, seems to be 1,25 * value from recorder) */ #define BATTERY_SCALE_FACTOR 8081 @@ -61,7 +61,7 @@ /* How to detect USB */ #define USB_FMRECORDERSTYLE 1 -/* Define this if the platform has batteries */ +/* Define this if the platform can charge batteries */ #define HAVE_BATTERIES 1 /* The start address index for ROM builds */ diff --git a/firmware/export/config-h100.h b/firmware/export/config-h100.h index 343fc89b42..a3e982a062 100644 --- a/firmware/export/config-h100.h +++ b/firmware/export/config-h100.h @@ -16,7 +16,10 @@ /* Define this if you have a Motorola SCF5249 */ #define CONFIG_CPU MCF5249 -/* Define this if the platform has batteries */ +/* Type of mobile power, FIXME: probably different, make new type */ +#define CONFIG_BATTERY BATT_LIION2200 + +/* Define this if the platform can charge batteries */ #define HAVE_BATTERIES 1 /* The start address index for ROM builds */ diff --git a/firmware/export/config-ondiofm.h b/firmware/export/config-ondiofm.h index f7d9a8f33f..f7cff94f5e 100644 --- a/firmware/export/config-ondiofm.h +++ b/firmware/export/config-ondiofm.h @@ -22,6 +22,9 @@ /* Define this to the CPU frequency */ #define CPU_FREQ 12000000 +/* Type of mobile power */ +#define CONFIG_BATTERY BATT_3AAA_ALKALINE + /* Battery scale factor (measured from Jörg's FM) */ #define BATTERY_SCALE_FACTOR 4785 /* 4.890V read as 0x3FE */ diff --git a/firmware/export/config-ondiosp.h b/firmware/export/config-ondiosp.h index b4c9f0d572..111787ffc9 100644 --- a/firmware/export/config-ondiosp.h +++ b/firmware/export/config-ondiosp.h @@ -19,6 +19,9 @@ /* Define this to the CPU frequency */ #define CPU_FREQ 12000000 +/* Type of mobile power */ +#define CONFIG_BATTERY BATT_3AAA_ALKALINE + /* Battery scale factor (measured from Jörg's FM) */ #define BATTERY_SCALE_FACTOR 4785 /* 4.890V read as 0x3FE */ diff --git a/firmware/export/config-player.h b/firmware/export/config-player.h index 8bd63c42e6..d457ef40fd 100644 --- a/firmware/export/config-player.h +++ b/firmware/export/config-player.h @@ -22,6 +22,9 @@ /* Define this to the CPU frequency */ #define CPU_FREQ 12000000 /* cycle time ~83.3ns */ +/* Type of mobile power */ +#define CONFIG_BATTERY BATT_4AA_NIMH + /* Battery scale factor (?) */ #define BATTERY_SCALE_FACTOR 6546 @@ -44,7 +47,7 @@ /* How to detect USB */ #define USB_PLAYERSTYLE 1 -/* Define this if the platform has batteries */ +/* Define this if the platform can charge batteries */ #define HAVE_BATTERIES 1 /* Define this for programmable LED available */ diff --git a/firmware/export/config-recorder.h b/firmware/export/config-recorder.h index 89e19f32f6..1e90a05248 100644 --- a/firmware/export/config-recorder.h +++ b/firmware/export/config-recorder.h @@ -34,6 +34,9 @@ /* Define this to the CPU frequency */ #define CPU_FREQ 11059200 +/* Type of mobile power */ +#define CONFIG_BATTERY BATT_4AA_NIMH + /* Battery scale factor (?) */ #define BATTERY_SCALE_FACTOR 6465 @@ -52,7 +55,7 @@ /* How to detect USB */ #define USB_RECORDERSTYLE 1 -/* Define this if the platform has batteries */ +/* Define this if the platform can charge batteries */ #define HAVE_BATTERIES 1 /* The start address index for ROM builds */ diff --git a/firmware/export/config-recorderv2.h b/firmware/export/config-recorderv2.h index 56967cfa10..b676a180ed 100644 --- a/firmware/export/config-recorderv2.h +++ b/firmware/export/config-recorderv2.h @@ -25,9 +25,6 @@ /* Define this if you have a FM Recorder key system */ #define HAVE_FMADC 1 -/* Define this if you have a LiIon battery */ -#define HAVE_LIION - /* Define this if you need to power on ATA */ #define NEEDS_ATA_POWER_ON @@ -37,6 +34,9 @@ /* Define this to the CPU frequency */ #define CPU_FREQ 11059200 +/* Type of mobile power */ +#define CONFIG_BATTERY BATT_LIION2200 + /* Battery scale factor (guessed, seems to be 1,25 * value from recorder) */ #define BATTERY_SCALE_FACTOR 8081 @@ -61,7 +61,7 @@ /* How to detect USB */ #define USB_FMRECORDERSTYLE 1 -/* Define this if the platform has batteries */ +/* Define this if the platform can charge batteries */ #define HAVE_BATTERIES 1 /* The start address index for ROM builds */ diff --git a/firmware/export/config.h b/firmware/export/config.h index fd757b1ab1..76a2bd9316 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h @@ -40,6 +40,11 @@ #define RECORDER_PAD 1 #define ONDIO_PAD 2 +/* CONFIG_BATTERY */ +#define BATT_LIION2200 2200 /* FM/V2 recorder type */ +#define BATT_4AA_NIMH 1500 +#define BATT_3AAA_ALKALINE 1000 + /* now go and pick yours */ #if defined(ARCHOS_PLAYER) #include "config-player.h" diff --git a/firmware/export/powermgmt.h b/firmware/export/powermgmt.h index eb0ba29f28..1a54006a7d 100644 --- a/firmware/export/powermgmt.h +++ b/firmware/export/powermgmt.h @@ -19,7 +19,7 @@ #ifndef _POWERMGMT_H_ #define _POWERMGMT_H_ -#ifdef HAVE_LIION /* FM Recorder, LiIon */ +#if CONFIG_BATTERY == BATT_LIION2200 /* FM Recorder, LiIon */ #define BATTERY_LEVEL_SHUTDOWN 260 /* 2.60V */ #define BATTERY_LEVEL_EMPTY 265 /* 2.65V */ #define BATTERY_LEVEL_DANGEROUS 280 /* 2.80V */ @@ -71,7 +71,7 @@ extern int trickle_sec; /* trickle charge: How many seconds per minute #endif /* HAVE_CHARGE_CTRL */ -#if defined(HAVE_CHARGE_CTRL) || defined(HAVE_LIION) +#if defined(HAVE_CHARGE_CTRL) || CONFIG_BATTERY == BATT_LIION2200 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 diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c index 155d11e609..e7486635d0 100644 --- a/firmware/powermgmt.c +++ b/firmware/powermgmt.c @@ -92,7 +92,7 @@ static const int poweroff_idle_timeout_value[15] = static const int percent_to_volt_decharge[11] = /* voltages (centivolt) of 0%, 10%, ... 100% when charging disabled */ { -#ifdef HAVE_LIION +#if CONFIG_BATTERY == BATT_LIION2200 /* measured values */ 260, 285, 295, 303, 311, 320, 330, 345, 360, 380, 400 #else /* NiMH */ @@ -112,7 +112,7 @@ void set_battery_capacity(int capacity) battery_capacity = 1500; } -#if defined(HAVE_CHARGE_CTRL) || defined(HAVE_LIION) +#if defined(HAVE_CHARGE_CTRL) || CONFIG_BATTERY == BATT_LIION2200 int charge_state = 0; /* at the beginning, the charger does nothing */ #endif @@ -443,7 +443,7 @@ static void power_thread(void) int i; int avg, ok_samples, spin_samples; int current = 0; -#ifdef HAVE_LIION +#if CONFIG_BATTERY == BATT_LIION2200 int charging_current; #endif #ifdef HAVE_CHARGE_CTRL @@ -535,7 +535,7 @@ static void power_thread(void) #endif /* MEM == 8 */ #endif /* HAVE_CHARGE_CONTROL */ -#ifdef HAVE_LIION +#if CONFIG_BATTERY == BATT_LIION2200 /* We use the information from the ADC_EXT_POWER ADC channel, which tells us the charging current from the LTC1734. When DC is connected (either via the external adapter, or via USB), we try @@ -790,7 +790,7 @@ static void power_thread(void) powermgmt_last_cycle_startstop_min++; #endif /* HAVE_CHARGE_CTRL*/ -#endif /* HAVE_LIION */ +#endif /* # if CONFIG_BATTERY == BATT_LIION2200 */ /* sleep for roughly a minute */ #ifdef HAVE_CHARGE_CTRL