mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-06-14 22:55:12 +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:
@@ -0,0 +1,23 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:meshcore_open/utils/battery_utils.dart';
|
||||
|
||||
void main() {
|
||||
group('battery utils', () {
|
||||
test('nmc range maps 3.0V to 0% and 4.2V to 100%', () {
|
||||
expect(estimateBatteryPercentFromVolts(3.0, 'nmc'), 0);
|
||||
expect(estimateBatteryPercentFromVolts(4.2, 'nmc'), 100);
|
||||
});
|
||||
|
||||
test('lifepo4 range maps 2.6V to 0% and 3.65V to 100%', () {
|
||||
expect(estimateBatteryPercentFromVolts(2.6, 'lifepo4'), 0);
|
||||
expect(estimateBatteryPercentFromVolts(3.65, 'lifepo4'), 100);
|
||||
});
|
||||
|
||||
test('unknown chemistry falls back to nmc mapping', () {
|
||||
expect(
|
||||
estimateBatteryPercentFromMillivolts(3600, 'unknown'),
|
||||
estimateBatteryPercentFromMillivolts(3600, 'nmc'),
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user