summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/settings.c8
-rw-r--r--apps/settings.h9
-rw-r--r--apps/settings_menu.c25
-rw-r--r--firmware/powermgmt.c6
-rw-r--r--firmware/powermgmt.h1
5 files changed, 20 insertions, 29 deletions
diff --git a/apps/settings.c b/apps/settings.c
index 64a1a8c0a2..9d0a9f62b3 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -126,6 +126,7 @@ modified unless the header & checksum test fails.
126 126
127Rest of config block, only saved to disk: 127Rest of config block, only saved to disk:
128 128
1290xB1 (int) battery capacity
1290xB5 scroll step in pixels 1300xB5 scroll step in pixels
1300xB6 scroll start and endpoint delay 1310xB6 scroll start and endpoint delay
1310xB7 bidir scroll setting (bidi if 0-200% longer than screen width) 1320xB7 bidir scroll setting (bidi if 0-200% longer than screen width)
@@ -368,6 +369,7 @@ int settings_save( void )
368 config_block[0x29]=(unsigned char)(global_settings.topruntime >> 8); 369 config_block[0x29]=(unsigned char)(global_settings.topruntime >> 8);
369 } 370 }
370 371
372 memcpy(&config_block[0xb1], &global_settings.battery_capacity, 4);
371 config_block[0xb5]=(unsigned char)global_settings.scroll_step; 373 config_block[0xb5]=(unsigned char)global_settings.scroll_step;
372 config_block[0xb6]=(unsigned char)global_settings.scroll_delay; 374 config_block[0xb6]=(unsigned char)global_settings.scroll_delay;
373 config_block[0xb7]=(unsigned char)global_settings.bidir_limit; 375 config_block[0xb7]=(unsigned char)global_settings.bidir_limit;
@@ -466,6 +468,8 @@ void settings_apply(void)
466 enable_trickle_charge(global_settings.trickle_charge); 468 enable_trickle_charge(global_settings.trickle_charge);
467#endif 469#endif
468 470
471 set_battery_capacity(global_settings.battery_capacity);
472
469#ifdef HAVE_LCD_BITMAP 473#ifdef HAVE_LCD_BITMAP
470 settings_apply_pm_range(); 474 settings_apply_pm_range();
471 peak_meter_init_times( 475 peak_meter_init_times(
@@ -648,6 +652,8 @@ void settings_load(void)
648 global_settings.topruntime = 652 global_settings.topruntime =
649 config_block[0x28] | (config_block[0x29] << 8); 653 config_block[0x28] | (config_block[0x29] << 8);
650 654
655 memcpy(&global_settings.battery_capacity, &config_block[0xb1], 4);
656
651 if (config_block[0xb5] != 0xff) 657 if (config_block[0xb5] != 0xff)
652 global_settings.scroll_step = config_block[0xb5]; 658 global_settings.scroll_step = config_block[0xb5];
653 659
@@ -831,7 +837,7 @@ void settings_reset(void) {
831 global_settings.backlight_timeout = DEFAULT_BACKLIGHT_TIMEOUT_SETTING; 837 global_settings.backlight_timeout = DEFAULT_BACKLIGHT_TIMEOUT_SETTING;
832 global_settings.backlight_on_when_charging = 838 global_settings.backlight_on_when_charging =
833 DEFAULT_BACKLIGHT_ON_WHEN_CHARGING_SETTING; 839 DEFAULT_BACKLIGHT_ON_WHEN_CHARGING_SETTING;
834 global_settings.battery_capacity = 0; /* 1500 mAh */ 840 global_settings.battery_capacity = 1500; /* mAh */
835 global_settings.trickle_charge = true; 841 global_settings.trickle_charge = true;
836 global_settings.dirfilter = SHOW_MUSIC; 842 global_settings.dirfilter = SHOW_MUSIC;
837 global_settings.sort_case = false; 843 global_settings.sort_case = false;
diff --git a/apps/settings.h b/apps/settings.h
index a2f7692d88..41f9b803c1 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -85,14 +85,7 @@ struct user_settings
85 bool backlight_on_when_charging; 85 bool backlight_on_when_charging;
86 bool discharge; /* maintain charge of at least: false = 85%, true = 10% */ 86 bool discharge; /* maintain charge of at least: false = 85%, true = 10% */
87 bool trickle_charge; /* do trickle charging: 0=off, 1=on */ 87 bool trickle_charge; /* do trickle charging: 0=off, 1=on */
88 int battery_capacity; /* 0 = 1500 mAh 88 int battery_capacity; /* in mAh */
89 1 = 1600 mAh
90 2 = 1700 mAh
91 3 = 1800 mAh
92 4 = 1900 mAh
93 5 = 2000 mAh
94 6 = 2100 mAh
95 7 = 2200 mAh */
96 89
97 /* resume settings */ 90 /* resume settings */
98 91
diff --git a/apps/settings_menu.c b/apps/settings_menu.c
index 9e7320eef6..94f6cc74ea 100644
--- a/apps/settings_menu.c
+++ b/apps/settings_menu.c
@@ -428,27 +428,16 @@ static bool bidir_limit(void)
428} 428}
429#endif 429#endif
430 430
431#ifndef SIMULATOR
431/** 432/**
432 * Menu to set the battery capacity 433 * Menu to set the battery capacity
433 */ 434 */
434static bool battery_capacity(void) { 435static bool battery_capacity(void)
435 bool retval = false; 436{
436 437 return set_int(str(LANG_BATTERY_CAPACITY), " mAh", &global_settings.battery_capacity,
437 char* names[] = { "1500 mAh ", "1600 mAh ", 438 &set_battery_capacity, 50, 1500, BATTERY_CAPACITY_MAX );
438 "1700 mAh ", "1800 mAh ",
439 "1900 mAh ", "2000 mAh ",
440 "2100 mAh ", "2200 mAh "
441 };
442
443 retval = set_option( str(LANG_BATTERY_CAPACITY),
444 &global_settings.battery_capacity, names, 8, NULL);
445
446#ifndef SIMULATOR
447 set_battery_capacity(global_settings.battery_capacity);
448#endif /* SIMULATOR */
449
450 return retval;
451} 439}
440#endif
452 441
453#ifdef HAVE_CHARGE_CTRL 442#ifdef HAVE_CHARGE_CTRL
454static bool deep_discharge(void) 443static bool deep_discharge(void)
@@ -742,7 +731,9 @@ static bool system_settings_menu(void)
742#ifdef HAVE_ATA_POWER_OFF 731#ifdef HAVE_ATA_POWER_OFF
743 { str(LANG_POWEROFF), poweroff }, 732 { str(LANG_POWEROFF), poweroff },
744#endif 733#endif
734#ifndef SIMULATOR
745 { str(LANG_BATTERY_CAPACITY), battery_capacity }, 735 { str(LANG_BATTERY_CAPACITY), battery_capacity },
736#endif
746#ifdef HAVE_CHARGE_CTRL 737#ifdef HAVE_CHARGE_CTRL
747 { str(LANG_DISCHARGE), deep_discharge }, 738 { str(LANG_DISCHARGE), deep_discharge },
748 { str(LANG_TRICKLE_CHARGE), trickle_charge }, 739 { str(LANG_TRICKLE_CHARGE), trickle_charge },
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c
index 7dcecb1e68..febcb78a5a 100644
--- a/firmware/powermgmt.c
+++ b/firmware/powermgmt.c
@@ -73,9 +73,9 @@ int battery_capacity = 1500; /* only a default value */
73 73
74void set_battery_capacity(int capacity) 74void set_battery_capacity(int capacity)
75{ 75{
76 int values[8] = {1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200}; 76 battery_capacity = capacity;
77 77 if ((battery_capacity > BATTERY_CAPACITY_MAX) || (battery_capacity < 1500))
78 battery_capacity = values[capacity]; 78 battery_capacity = 1500;
79} 79}
80 80
81#ifdef HAVE_CHARGE_CTRL 81#ifdef HAVE_CHARGE_CTRL
diff --git a/firmware/powermgmt.h b/firmware/powermgmt.h
index b7f8b01978..ea6319c02e 100644
--- a/firmware/powermgmt.h
+++ b/firmware/powermgmt.h
@@ -27,6 +27,7 @@
27#define BATTERY_LEVEL_FULL 585 /* 5.85V */ 27#define BATTERY_LEVEL_FULL 585 /* 5.85V */
28 28
29#define BATTERY_RANGE (BATTERY_LEVEL_FULL - BATTERY_LEVEL_EMPTY) 29#define BATTERY_RANGE (BATTERY_LEVEL_FULL - BATTERY_LEVEL_EMPTY)
30#define BATTERY_CAPACITY_MAX 2400 /* max. capacity that can be selected in settings menu, min. is always 1500 */
30 31
31#define POWER_HISTORY_LEN 2*60 /* 2 hours of samples, one per minute */ 32#define POWER_HISTORY_LEN 2*60 /* 2 hours of samples, one per minute */
32#define POWER_AVG_N 4 /* how many samples to take for each measurement */ 33#define POWER_AVG_N 4 /* how many samples to take for each measurement */