aboutsummaryrefslogtreecommitdiffstats
path: root/lib/data/data_providers/hybrid_notifier.dart
diff options
context:
space:
mode:
authorLisandro Pérez Meyer <lpmeyer@ics.com>2023-12-14 13:24:42 -0300
committerLisandro Pérez Meyer <lpmeyer@ics.com>2023-12-14 13:46:12 -0300
commitdda6c8502a3fa1e50654c4cca934b4b846bbca98 (patch)
treefae219109b6fa5155ad8440354324d9522954498 /lib/data/data_providers/hybrid_notifier.dart
parent71d46d03850653c0229c678de197c6f94fceb477 (diff)
Hybrid animation from env variable
This commit changes central hybrid animation on dashboard screen. For now we can set from env randomHybridAnimation variable. If true animation should be switching randomly. If false just setting proper hybrid mode based on speed and RPM value. Also increase childLocks touch target Original from: Dominik Wawrzonek <dwawrzonek@ics.com> Bug-AGL: SPEC-4971 Change-Id: I71f09c63bd1bfeda174f92feafc58019c23d07cb Signed-off-by: Lisandro Pérez Meyer <lpmeyer@ics.com>
Diffstat (limited to 'lib/data/data_providers/hybrid_notifier.dart')
-rw-r--r--lib/data/data_providers/hybrid_notifier.dart45
1 files changed, 16 insertions, 29 deletions
diff --git a/lib/data/data_providers/hybrid_notifier.dart b/lib/data/data_providers/hybrid_notifier.dart
index fd16a68..3668f61 100644
--- a/lib/data/data_providers/hybrid_notifier.dart
+++ b/lib/data/data_providers/hybrid_notifier.dart
@@ -43,7 +43,7 @@ class HybridNotifier extends StateNotifier<Hybrid> {
state = state.copyWith(hybridState: hybridState);
}
- void updateHybridState() {
+ void updateHybridState(double speed, double engineSpeed, bool brake) {
// Variable to store the current state
HybridState currentState = state.hybridState;
@@ -56,38 +56,25 @@ class HybridNotifier extends StateNotifier<Hybrid> {
// Variable for storing the average value of RPM
double avgRpm = 0.0;
- // Variable to store the brake value state
- bool brake = false;
-
- // Collect 10 samples
- for (int i = 0; i < 10; i++) {
- // Get the current values for speed, engine rpm and brake status
-
- // speed = vehicleProvider();
- // rpm = _rpmFromServer();
- // brake = _brakeFromServer();
-
- // Calculate the average speed value
- // avgSpeed = (avgSpeed * (i + 1) + speed) / (i + 2);
-
- // Calculate the average engine rpm
- // avgRpm = (avgRpm * (i + 1) + rpm) / (i + 2);
+
+ if (speed == 0 && engineSpeed == 0) {
+ // Set idle state.
+ currentState = HybridState.idle;
+ } else if (engineSpeed > 0 && speed > 0) {
+ // Set stan na engine output state..
+ currentState = HybridState.engineOutput;
+ } else if (speed < 0 && brake) {
+ // Set regenerative breaking state
+ currentState = HybridState.regenerativeBreaking;
+ } else if (speed > 0 && engineSpeed <= 0) {
+ // Set battery output state
+ currentState = HybridState.baterryOutput;
}
- // define new state
- // if (avgSpeed == 0 && avgRpm == 0) {
- // currentState = HybridState.idle;
- // } else if (avgRpm > 0 && avgSpeed > 0) {
- // currentState = HybridState.engineOutput;
- // } else if (avgRpm == 0 && brake) {
- // currentState = HybridState.regenerativeBreaking;
- // } else if (avgSpeed > 0 && avgRpm <= avgSpeed) {
- // currentState = HybridState.baterryOutput;
- // }
-
// Update hybrid state
if (currentState != previousState) {
- state = state.copyWith(hybridState: currentState);
+ //state = state.copyWith(hybridState: currentState);
+ setHybridState(currentState);
}
}
}