rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
gc_auto.cpp
Go to the documentation of this file.
1#include "pch.h"
2
3#include "gc_auto.h"
4
5#if EFI_TCU
7
10
14
15 if (getDesiredGear() == NEUTRAL) {
17 }
18
19 if (tps.Valid && vss.Valid) {
20 switch (getDesiredGear()) {
21 case GEAR_1 :
22 shift(vss.Value, tps.Value, &config->tcu_shiftSpeed12, GEAR_2);
23 break;
24 case GEAR_2 :
25 shift(vss.Value, tps.Value, &config->tcu_shiftSpeed21, GEAR_1, true);
26 shift(vss.Value, tps.Value, &config->tcu_shiftSpeed23, GEAR_3);
27 break;
28 case GEAR_3 :
29 shift(vss.Value, tps.Value, &config->tcu_shiftSpeed32, GEAR_2, true);
30 shift(vss.Value, tps.Value, &config->tcu_shiftSpeed34, GEAR_4);
31 break;
32 case GEAR_4 :
33 shift(vss.Value, tps.Value, &config->tcu_shiftSpeed43, GEAR_3, true);
34 break;
35 default :
36 break;
37 }
38 }
39
41}
42
43void AutomaticGearController::shift(float speed, float throttle, uint8_t (*curve)[TCU_TABLE_WIDTH], gear_e gear) {
44 shift(speed, throttle, curve, gear, false);
45}
46
47void AutomaticGearController::shift(float speed, float throttle, uint8_t (*curve)[TCU_TABLE_WIDTH], gear_e gear, bool down) {
48 int curveSpeed = interpolate2d(throttle, config->tcu_shiftTpsBins, *curve);
49
50 if ((down && speed < curveSpeed) || (!down && speed > curveSpeed)) {
51 setDesiredGear(gear);
52 }
53}
54
58#endif // EFI_TCU
void shift(float speed, float throttle, uint8_t(*curve)[TCU_TABLE_WIDTH], gear_e gear)
Definition gc_auto.cpp:43
virtual void update()
virtual gear_e getDesiredGear() const
virtual gear_e setDesiredGear(gear_e)
virtual SensorResult get() const =0
static constexpr persistent_config_s * config
AutomaticGearController * getAutomaticGearController()
Definition gc_auto.cpp:55
AutomaticGearController automaticGearController
Definition gc_auto.cpp:6
gear_e
@ GEAR_2
@ GEAR_1
@ GEAR_4
@ NEUTRAL
@ GEAR_3
@ DriverThrottleIntent
scaled_channel< uint8_t, 1, 1 > tcu_shiftTpsBins[TCU_TABLE_WIDTH]