mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-06-19 17:05:33 +10:00
Fix repeater battery % inconsistency and add configurable repeater battery chemistry (#199)
* fix(repeater): unify battery percentage math and add repeater chemistry setting - Add shared battery percent utility used by connector, repeater status, and telemetry - Add repeater-specific battery chemistry persistence and service accessors - Add repeater chemistry selector in Repeater Hub - Ensure telemetry and status compute percentages consistently from same chemistry - Add focused battery utility tests Refs #116 Refs #174 * fix: Flutter Analyzer Errors fixed Recent Merge Compatible * Unify repeater battery source across status and telemetry
This commit is contained in:
@@ -17,6 +17,12 @@ class AppSettingsService extends ChangeNotifier {
|
||||
return stored ?? 'nmc';
|
||||
}
|
||||
|
||||
String batteryChemistryForRepeater(String repeaterPubKeyHex) {
|
||||
final stored = _settings.batteryChemistryByRepeaterId[repeaterPubKeyHex];
|
||||
if (stored == 'liion') return 'nmc';
|
||||
return stored ?? 'nmc';
|
||||
}
|
||||
|
||||
Future<void> loadSettings() async {
|
||||
final prefs = PrefsManager.instance;
|
||||
final jsonStr = prefs.getString(_settingsKey);
|
||||
@@ -133,13 +139,20 @@ class AppSettingsService extends ChangeNotifier {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> setBatteryChemistryForRepeater(
|
||||
String repeaterPubKeyHex,
|
||||
String chemistry,
|
||||
) async {
|
||||
final updated = Map<String, String>.from(
|
||||
_settings.batteryChemistryByRepeaterId,
|
||||
);
|
||||
updated[repeaterPubKeyHex] = chemistry;
|
||||
await updateSettings(
|
||||
_settings.copyWith(batteryChemistryByRepeaterId: updated),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> setUnitSystem(UnitSystem value) async {
|
||||
await updateSettings(_settings.copyWith(unitSystem: value));
|
||||
}
|
||||
|
||||
Future<void> setLosUnitSystem(String value) async {
|
||||
await setUnitSystem(
|
||||
value == 'imperial' ? UnitSystem.imperial : UnitSystem.metric,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user