From 5588d1d26f1be968af6809e43507d7be0fadf434 Mon Sep 17 00:00:00 2001 From: Scott Murray Date: Thu, 4 Jan 2024 20:05:15 -0500 Subject: Tweak idle speed in hybrid animation logic To improve the behavior with our simple CAN simulator script and agl-demo-control-panel, tweak the hybrid animation logic to treat 600 rpm as the threshold for idling, instead of using 0. This should trigger the battery charging animation more often in the demo scenarios. Bug-AGL: SPEC-5027 Change-Id: I1578c39e220c5d2943959194640ade4219bc2b1b Signed-off-by: Scott Murray --- lib/data/data_providers/hybrid_notifier.dart | 32 +++++++++++++--------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'lib/data/data_providers/hybrid_notifier.dart') diff --git a/lib/data/data_providers/hybrid_notifier.dart b/lib/data/data_providers/hybrid_notifier.dart index 7381f5c..51a65fe 100644 --- a/lib/data/data_providers/hybrid_notifier.dart +++ b/lib/data/data_providers/hybrid_notifier.dart @@ -9,20 +9,20 @@ class HybridNotifier extends StateNotifier { switch (hybridState) { case HybridState.idle: state = state.copyWith( - hybridState: hybridState, - topArrowState: ArrowState.blue, - leftArrowState: ArrowState.blue, - rightArrowState: ArrowState.blue, - batteryState: BatteryState.white, + hybridState: hybridState, + topArrowState: ArrowState.blue, + leftArrowState: ArrowState.blue, + rightArrowState: ArrowState.blue, + batteryState: BatteryState.white, ); break; case HybridState.engineOutput: state = state.copyWith( - hybridState: hybridState, - topArrowState: ArrowState.red, - leftArrowState: ArrowState.red, - rightArrowState: ArrowState.blue, - batteryState: BatteryState.red, + hybridState: hybridState, + topArrowState: ArrowState.red, + leftArrowState: ArrowState.red, + rightArrowState: ArrowState.blue, + batteryState: BatteryState.red, ); break; case HybridState.regenerativeBreaking: @@ -31,8 +31,7 @@ class HybridNotifier extends StateNotifier { topArrowState: ArrowState.blue, leftArrowState: ArrowState.blue, rightArrowState: ArrowState.green, - batteryState: BatteryState.green - ); + batteryState: BatteryState.green); break; case HybridState.batteryOutput: state = state.copyWith( @@ -40,8 +39,7 @@ class HybridNotifier extends StateNotifier { topArrowState: ArrowState.blue, leftArrowState: ArrowState.blue, rightArrowState: ArrowState.yellow, - batteryState: BatteryState.yellow - ); + batteryState: BatteryState.yellow); break; default: state = state.copyWith(hybridState: hybridState); @@ -61,11 +59,11 @@ class HybridNotifier extends StateNotifier { // Variable for storing the average value of RPM double avgRpm = 0.0; - - if (speed == 0 && engineSpeed == 0) { + + if (speed == 0 && engineSpeed <= 600) { // Set idle state. currentState = HybridState.idle; - } else if (engineSpeed > 0 && speed > 0) { + } else if (engineSpeed > 600 && speed > 0) { // Set engine output state.. currentState = HybridState.engineOutput; } else if (speed < 0 && brake) { -- cgit 1.2.3-korg