Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add configurable battery chemistry for repeaters
- Add per-repeater battery chemistry setting (NMC, LiFePO4, LiPo)
- Create shared battery_utils.dart for voltage-to-percentage calculation
- Support optional firmware-reported chemistry (protocol extension at byte 60)
- Show lock icon when chemistry is firmware-reported, dropdown when user-configurable
- Add l10n string for "Battery Type" label

Addresses #116
  • Loading branch information
rsp2k committed Feb 7, 2026
commit 9ef1c51d64c30a6e1a2ab30e315f885eb2b15e91
1 change: 1 addition & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,7 @@
},
"repeater_systemInformation": "System Information",
"repeater_battery": "Battery",
"repeater_batteryChemistry": "Battery Type",
"repeater_clockAtLogin": "Clock (at login)",
"repeater_uptime": "Uptime",
"repeater_queueLength": "Queue Length",
Expand Down
6 changes: 6 additions & 0 deletions lib/l10n/app_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3081,6 +3081,12 @@ abstract class AppLocalizations {
/// **'Battery'**
String get repeater_battery;

/// No description provided for @repeater_batteryChemistry.
///
/// In en, this message translates to:
/// **'Battery Type'**
String get repeater_batteryChemistry;

/// No description provided for @repeater_clockAtLogin.
///
/// In en, this message translates to:
Expand Down
3 changes: 3 additions & 0 deletions lib/l10n/app_localizations_bg.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1705,6 +1705,9 @@ class AppLocalizationsBg extends AppLocalizations {
@override
String get repeater_battery => 'Батерия';

@override
String get repeater_batteryChemistry => 'Battery Type';

@override
String get repeater_clockAtLogin => 'Часовник (при влизане)';

Expand Down
3 changes: 3 additions & 0 deletions lib/l10n/app_localizations_de.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1702,6 +1702,9 @@ class AppLocalizationsDe extends AppLocalizations {
@override
String get repeater_battery => 'Akku';

@override
String get repeater_batteryChemistry => 'Battery Type';

@override
String get repeater_clockAtLogin => 'Uhr (bei Anmeldung)';

Expand Down
3 changes: 3 additions & 0 deletions lib/l10n/app_localizations_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1675,6 +1675,9 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get repeater_battery => 'Battery';

@override
String get repeater_batteryChemistry => 'Battery Type';

@override
String get repeater_clockAtLogin => 'Clock (at login)';

Expand Down
3 changes: 3 additions & 0 deletions lib/l10n/app_localizations_es.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1699,6 +1699,9 @@ class AppLocalizationsEs extends AppLocalizations {
@override
String get repeater_battery => 'Batería';

@override
String get repeater_batteryChemistry => 'Battery Type';

@override
String get repeater_clockAtLogin => 'Reloj (al inicio de sesión)';

Expand Down
3 changes: 3 additions & 0 deletions lib/l10n/app_localizations_fr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1710,6 +1710,9 @@ class AppLocalizationsFr extends AppLocalizations {
@override
String get repeater_battery => 'Batterie';

@override
String get repeater_batteryChemistry => 'Battery Type';

@override
String get repeater_clockAtLogin => 'Horloge (au démarrage)';

Expand Down
3 changes: 3 additions & 0 deletions lib/l10n/app_localizations_it.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1699,6 +1699,9 @@ class AppLocalizationsIt extends AppLocalizations {
@override
String get repeater_battery => 'Batteria';

@override
String get repeater_batteryChemistry => 'Battery Type';

@override
String get repeater_clockAtLogin => 'Orologio (all\'accesso)';

Expand Down
3 changes: 3 additions & 0 deletions lib/l10n/app_localizations_nl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1693,6 +1693,9 @@ class AppLocalizationsNl extends AppLocalizations {
@override
String get repeater_battery => 'Batterij';

@override
String get repeater_batteryChemistry => 'Battery Type';

@override
String get repeater_clockAtLogin => 'Tijd (bij aanmelden)';

Expand Down
3 changes: 3 additions & 0 deletions lib/l10n/app_localizations_pl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1703,6 +1703,9 @@ class AppLocalizationsPl extends AppLocalizations {
@override
String get repeater_battery => 'Bateria';

@override
String get repeater_batteryChemistry => 'Battery Type';

@override
String get repeater_clockAtLogin => 'Godzina (przy logowaniu)';

Expand Down
3 changes: 3 additions & 0 deletions lib/l10n/app_localizations_pt.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1700,6 +1700,9 @@ class AppLocalizationsPt extends AppLocalizations {
@override
String get repeater_battery => 'Bateria';

@override
String get repeater_batteryChemistry => 'Battery Type';

@override
String get repeater_clockAtLogin => 'Relógio (no login)';

Expand Down
3 changes: 3 additions & 0 deletions lib/l10n/app_localizations_ru.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1702,6 +1702,9 @@ class AppLocalizationsRu extends AppLocalizations {
@override
String get repeater_battery => 'Батарея';

@override
String get repeater_batteryChemistry => 'Battery Type';

@override
String get repeater_clockAtLogin => 'Время (при входе)';

Expand Down
3 changes: 3 additions & 0 deletions lib/l10n/app_localizations_sk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1695,6 +1695,9 @@ class AppLocalizationsSk extends AppLocalizations {
@override
String get repeater_battery => 'Batéria';

@override
String get repeater_batteryChemistry => 'Battery Type';

@override
String get repeater_clockAtLogin => 'Čas (při přihlášení)';

Expand Down
3 changes: 3 additions & 0 deletions lib/l10n/app_localizations_sl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1694,6 +1694,9 @@ class AppLocalizationsSl extends AppLocalizations {
@override
String get repeater_battery => 'Baterija';

@override
String get repeater_batteryChemistry => 'Battery Type';

@override
String get repeater_clockAtLogin => 'Ure (pri prijavi)';

Expand Down
3 changes: 3 additions & 0 deletions lib/l10n/app_localizations_sv.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1684,6 +1684,9 @@ class AppLocalizationsSv extends AppLocalizations {
@override
String get repeater_battery => 'Batteri';

@override
String get repeater_batteryChemistry => 'Battery Type';

@override
String get repeater_clockAtLogin => 'Klocka (vid inloggning)';

Expand Down
3 changes: 3 additions & 0 deletions lib/l10n/app_localizations_uk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1703,6 +1703,9 @@ class AppLocalizationsUk extends AppLocalizations {
@override
String get repeater_battery => 'Батарея';

@override
String get repeater_batteryChemistry => 'Battery Type';

@override
String get repeater_clockAtLogin => 'Годинник (при вході)';

Expand Down
3 changes: 3 additions & 0 deletions lib/l10n/app_localizations_zh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1623,6 +1623,9 @@ class AppLocalizationsZh extends AppLocalizations {
@override
String get repeater_battery => '电池';

@override
String get repeater_batteryChemistry => 'Battery Type';

@override
String get repeater_clockAtLogin => '登录时的时间';

Expand Down
17 changes: 16 additions & 1 deletion lib/models/app_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class AppSettings {
final String? languageOverride; // null = system default
final bool appDebugLogEnabled;
final Map<String, String> batteryChemistryByDeviceId;
final Map<String, String> repeaterBatteryChemistryByPublicKey;

AppSettings({
this.clearPathOnMaxRetry = false,
Expand All @@ -43,7 +44,10 @@ class AppSettings {
this.languageOverride,
this.appDebugLogEnabled = false,
Map<String, String>? batteryChemistryByDeviceId,
}) : batteryChemistryByDeviceId = batteryChemistryByDeviceId ?? {};
Map<String, String>? repeaterBatteryChemistryByPublicKey,
}) : batteryChemistryByDeviceId = batteryChemistryByDeviceId ?? {},
repeaterBatteryChemistryByPublicKey =
repeaterBatteryChemistryByPublicKey ?? {};

Map<String, dynamic> toJson() {
return {
Expand All @@ -67,6 +71,8 @@ class AppSettings {
'language_override': languageOverride,
'app_debug_log_enabled': appDebugLogEnabled,
'battery_chemistry_by_device_id': batteryChemistryByDeviceId,
'repeater_battery_chemistry_by_public_key':
repeaterBatteryChemistryByPublicKey,
};
}

Expand Down Expand Up @@ -101,6 +107,11 @@ class AppSettings {
(key, value) => MapEntry(key.toString(), value.toString()),
) ??
{},
repeaterBatteryChemistryByPublicKey:
(json['repeater_battery_chemistry_by_public_key'] as Map?)?.map(
(key, value) => MapEntry(key.toString(), value.toString()),
) ??
{},
);
}

Expand All @@ -125,6 +136,7 @@ class AppSettings {
Object? languageOverride = _unset,
bool? appDebugLogEnabled,
Map<String, String>? batteryChemistryByDeviceId,
Map<String, String>? repeaterBatteryChemistryByPublicKey,
}) {
return AppSettings(
clearPathOnMaxRetry: clearPathOnMaxRetry ?? this.clearPathOnMaxRetry,
Expand Down Expand Up @@ -154,6 +166,9 @@ class AppSettings {
appDebugLogEnabled: appDebugLogEnabled ?? this.appDebugLogEnabled,
batteryChemistryByDeviceId:
batteryChemistryByDeviceId ?? this.batteryChemistryByDeviceId,
repeaterBatteryChemistryByPublicKey:
repeaterBatteryChemistryByPublicKey ??
this.repeaterBatteryChemistryByPublicKey,
);
}
}
Loading