mirror of https://github.com/FOME-Tech/fome-fw.git
Simple transmission 2 (#1870)
* simple trans controller * don't need check * we can loop! * use efi::size * pin mode configuration * set pin mode * switch to RegisteredOutputPin * size * add to makefile * fixes * fixes * wat * output pin, and ts stuff * use SimpleTransmissionController * include * grrr * grrr * move to separate file * fix includes * try * semicolon stupid * try pointers * try * add to makefile * wat * try * try * try * try * try * try * try * try * try * try * try * try * try * try * undo * more idiomatic maybe * remove logger * try init func * try * try * try init fn * try * switch * try * try * ifndef * try * try * ifndef * use def dug * INJECT FIRST * try * try * duh
This commit is contained in:
parent
c646fe2be7
commit
a6a0e8ba77
|
@ -17,7 +17,7 @@
|
||||||
#include "trigger_central.h"
|
#include "trigger_central.h"
|
||||||
#include "local_version_holder.h"
|
#include "local_version_holder.h"
|
||||||
#include "buttonshift.h"
|
#include "buttonshift.h"
|
||||||
#include "tcu.h"
|
#include "gear_controller.h"
|
||||||
|
|
||||||
#if EFI_SIGNAL_EXECUTOR_ONE_TIMER
|
#if EFI_SIGNAL_EXECUTOR_ONE_TIMER
|
||||||
// PROD real firmware uses this implementation
|
// PROD real firmware uses this implementation
|
||||||
|
|
|
@ -100,7 +100,7 @@ typedef uint8_t iac_pid_mult_t[IAC_PID_MULT_SIZE][IAC_PID_MULT_SIZE];
|
||||||
|
|
||||||
typedef float baro_corr_table_t[BARO_CORR_SIZE][BARO_CORR_SIZE];
|
typedef float baro_corr_table_t[BARO_CORR_SIZE][BARO_CORR_SIZE];
|
||||||
|
|
||||||
typedef bool tcubinary_table_t[TCU_SOLENOID_COUNT][TCU_GEAR_COUNT];
|
typedef bool tcubinary_table_t[TCU_GEAR_COUNT][TCU_SOLENOID_COUNT];
|
||||||
|
|
||||||
typedef float fsio_table_8x8_f32t[FSIO_TABLE_8][FSIO_TABLE_8];
|
typedef float fsio_table_8x8_f32t[FSIO_TABLE_8][FSIO_TABLE_8];
|
||||||
typedef float tps_tps_table_t[TPS_TPS_ACCEL_TABLE][TPS_TPS_ACCEL_TABLE];
|
typedef float tps_tps_table_t[TPS_TPS_ACCEL_TABLE][TPS_TPS_ACCEL_TABLE];
|
||||||
|
|
|
@ -16,6 +16,8 @@ void ButtonShiftController::init (DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
// 500 millisecond is maybe a little long?
|
// 500 millisecond is maybe a little long?
|
||||||
debounceUp.init(500, CONFIG(tcuUpshiftButtonPin), CONFIG(tcuUpshiftButtonPinMode));
|
debounceUp.init(500, CONFIG(tcuUpshiftButtonPin), CONFIG(tcuUpshiftButtonPinMode));
|
||||||
debounceDown.init(500, CONFIG(tcuDownshiftButtonPin), CONFIG(tcuDownshiftButtonPinMode));
|
debounceDown.init(500, CONFIG(tcuDownshiftButtonPin), CONFIG(tcuDownshiftButtonPinMode));
|
||||||
|
INJECT_ENGINE_REFERENCE(&transmissionController);
|
||||||
|
transmissionController.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ButtonShiftController::update() {
|
void ButtonShiftController::update() {
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "tcu.h"
|
#include "gear_controller.h"
|
||||||
#include "globalaccess.h"
|
#include "globalaccess.h"
|
||||||
#include "debounce.h"
|
#include "debounce.h"
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,9 @@ CONTROLLERS_SRC_CPP = \
|
||||||
$(CONTROLLERS_DIR)/serial/serial_sensor.cpp \
|
$(CONTROLLERS_DIR)/serial/serial_sensor.cpp \
|
||||||
$(CONTROLLERS_DIR)/buttonshift.cpp \
|
$(CONTROLLERS_DIR)/buttonshift.cpp \
|
||||||
$(CONTROLLERS_DIR)/tcu.cpp \
|
$(CONTROLLERS_DIR)/tcu.cpp \
|
||||||
|
$(CONTROLLERS_DIR)/gear_controller.cpp \
|
||||||
$(CONTROLLERS_DIR)/start_stop.cpp \
|
$(CONTROLLERS_DIR)/start_stop.cpp \
|
||||||
|
$(CONTROLLERS_DIR)/simple_tcu.cpp \
|
||||||
|
|
||||||
CONTROLLERS_INC=\
|
CONTROLLERS_INC=\
|
||||||
$(CONTROLLERS_DIR) \
|
$(CONTROLLERS_DIR) \
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
#include "gear_controller.h"
|
||||||
|
#include "tunerstudio_outputs.h"
|
||||||
|
|
||||||
|
void GearControllerBase::init() {
|
||||||
|
INJECT_ENGINE_REFERENCE(&transmissionController);
|
||||||
|
transmissionController.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GearControllerBase::update() {
|
||||||
|
transmissionController.update(getDesiredGear());
|
||||||
|
postState();
|
||||||
|
}
|
||||||
|
|
||||||
|
gear_e GearControllerBase::getDesiredGear() const {
|
||||||
|
return desiredGear;
|
||||||
|
}
|
||||||
|
|
||||||
|
gear_e GearControllerBase::setDesiredGear(gear_e gear) {
|
||||||
|
desiredGear = gear;
|
||||||
|
return getDesiredGear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GearControllerBase::postState() {
|
||||||
|
#if EFI_TUNER_STUDIO
|
||||||
|
tsOutputChannels.tcuDesiredGear = getDesiredGear();
|
||||||
|
#endif
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "global.h"
|
||||||
|
#include "io_pins.h"
|
||||||
|
#include "persistent_configuration.h"
|
||||||
|
#include "engine_configuration_generated_structures.h"
|
||||||
|
#include "globalaccess.h"
|
||||||
|
#include "simple_tcu.h"
|
||||||
|
|
||||||
|
class GearControllerBase {
|
||||||
|
public:
|
||||||
|
DECLARE_ENGINE_PTR;
|
||||||
|
|
||||||
|
virtual void update();
|
||||||
|
gear_e getDesiredGear() const;
|
||||||
|
virtual void init();
|
||||||
|
private:
|
||||||
|
gear_e desiredGear = NEUTRAL;
|
||||||
|
protected:
|
||||||
|
gear_e setDesiredGear(gear_e);
|
||||||
|
void postState();
|
||||||
|
SimpleTransmissionController transmissionController;
|
||||||
|
};
|
|
@ -1,16 +1,22 @@
|
||||||
#include "simple_tcu.h"
|
#include "simple_tcu.h"
|
||||||
|
#include "efi_gpio.h"
|
||||||
|
#include "engine_configuration.h"
|
||||||
|
|
||||||
RegisteredOutputPin tcuSolenoids[efi::size(tcu_solenoid)];
|
EXTERN_CONFIG;
|
||||||
|
|
||||||
void SimpleTransmissionController::SimpleTransmissionController() {
|
OutputPin tcuSolenoids[TCU_SOLENOID_COUNT];
|
||||||
for (int i = 0; i < efi::size(tcu_solenoid); i++) {
|
|
||||||
tcuSolenoids[i].initPin("Transmission Solenoid", CONFIG(tcu_solenoid[i]), CONFIG{tcu_solenoid_mode[i]});
|
void SimpleTransmissionController::init() {
|
||||||
|
for (int i = 0; i < efi::size(CONFIG(tcu_solenoid)); i++) {
|
||||||
|
tcuSolenoids[i].initPin("Transmission Solenoid", CONFIG(tcu_solenoid)[i], &CONFIG(tcu_solenoid_mode)[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleTransmissionController::update(gear_e gear) {
|
void SimpleTransmissionController::update(gear_e gear) {
|
||||||
for (int i = 0; i < efi::size(tcu_solenoid); i++) {
|
for (int i = 0; i < efi::size(CONFIG(tcu_solenoid)); i++) {
|
||||||
tcuSolenoids[i].setValue(CONFIG(tcuSolenoidTable)[i][static_cast<int>(gear)])
|
#ifndef EFI_UNIT_TEST
|
||||||
|
tcuSolenoids[i].setValue(config->tcuSolenoidTable[static_cast<int>(gear) + 1][i]);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
setCurrentGear(gear);
|
setCurrentGear(gear);
|
||||||
postState();
|
postState();
|
||||||
|
|
|
@ -2,8 +2,10 @@
|
||||||
|
|
||||||
#include "tcu.h"
|
#include "tcu.h"
|
||||||
|
|
||||||
class SimpleTransmissionController {
|
class SimpleTransmissionController: public TransmissionControllerBase {
|
||||||
public:
|
public:
|
||||||
|
DECLARE_ENGINE_PTR;
|
||||||
|
|
||||||
void update(gear_e);
|
void update(gear_e);
|
||||||
SimpleTransmissionController();
|
void init();
|
||||||
}
|
};
|
||||||
|
|
|
@ -28,23 +28,3 @@ void TransmissionControllerBase::postState() {
|
||||||
tsOutputChannels.tcuCurrentGear = getCurrentGear();
|
tsOutputChannels.tcuCurrentGear = getCurrentGear();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void GearControllerBase::update() {
|
|
||||||
transmissionController.update(getDesiredGear());
|
|
||||||
postState();
|
|
||||||
}
|
|
||||||
|
|
||||||
gear_e GearControllerBase::getDesiredGear() const {
|
|
||||||
return desiredGear;
|
|
||||||
}
|
|
||||||
|
|
||||||
gear_e GearControllerBase::setDesiredGear(gear_e gear) {
|
|
||||||
desiredGear = gear;
|
|
||||||
return getDesiredGear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GearControllerBase::postState() {
|
|
||||||
#if EFI_TUNER_STUDIO
|
|
||||||
tsOutputChannels.tcuDesiredGear = getDesiredGear();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
class TransmissionControllerBase {
|
class TransmissionControllerBase {
|
||||||
public:
|
public:
|
||||||
void update(gear_e);
|
void update(gear_e);
|
||||||
|
void init();
|
||||||
gear_e getCurrentGear() const;
|
gear_e getCurrentGear() const;
|
||||||
private:
|
private:
|
||||||
gear_e currentGear = NEUTRAL;
|
gear_e currentGear = NEUTRAL;
|
||||||
|
@ -23,15 +24,3 @@ protected:
|
||||||
gear_e setCurrentGear(gear_e);
|
gear_e setCurrentGear(gear_e);
|
||||||
void postState();
|
void postState();
|
||||||
};
|
};
|
||||||
|
|
||||||
class GearControllerBase {
|
|
||||||
public:
|
|
||||||
virtual void update();
|
|
||||||
gear_e getDesiredGear() const;
|
|
||||||
private:
|
|
||||||
gear_e desiredGear = NEUTRAL;
|
|
||||||
protected:
|
|
||||||
gear_e setDesiredGear(gear_e);
|
|
||||||
void postState();
|
|
||||||
TransmissionControllerBase transmissionController;
|
|
||||||
};
|
|
||||||
|
|
|
@ -205,7 +205,7 @@ custom fuel_table_t 4*@@FUEL_RPM_COUNT@@x@@FUEL_LOAD_COUNT@@ array, F32, @OF
|
||||||
custom ve_table_t 4*@@FUEL_RPM_COUNT@@x@@FUEL_LOAD_COUNT@@ array, F32, @OFFSET@, [@@FUEL_RPM_COUNT@@x@@FUEL_LOAD_COUNT@@],"%", 1, 0, 0, 999.0, 2
|
custom ve_table_t 4*@@FUEL_RPM_COUNT@@x@@FUEL_LOAD_COUNT@@ array, F32, @OFFSET@, [@@FUEL_RPM_COUNT@@x@@FUEL_LOAD_COUNT@@],"%", 1, 0, 0, 999.0, 2
|
||||||
custom afr_table_t @@FUEL_RPM_COUNT@@x@@FUEL_LOAD_COUNT@@ array, U08, @OFFSET@, [@@FUEL_RPM_COUNT@@x@@FUEL_LOAD_COUNT@@],"deg", {1/@@PACK_MULT_AFR_CFG@@}, 0, 0, 25.0, 1
|
custom afr_table_t @@FUEL_RPM_COUNT@@x@@FUEL_LOAD_COUNT@@ array, U08, @OFFSET@, [@@FUEL_RPM_COUNT@@x@@FUEL_LOAD_COUNT@@],"deg", {1/@@PACK_MULT_AFR_CFG@@}, 0, 0, 25.0, 1
|
||||||
|
|
||||||
custom tcubinary_table_t @@TCU_SOLENOID_COUNT@@x@@TCU_GEAR_COUNT@@ array, U08, @OFFSET@, [@@TCU_SOLENOID_COUNT@@x@@TCU_GEAR_COUNT@@],"onoff", 1, 0, 0, 1, 0
|
custom tcubinary_table_t @@TCU_GEAR_COUNT@@x@@TCU_SOLENOID_COUNT@@ array, U08, @OFFSET@, [@@TCU_GEAR_COUNT@@x@@TCU_SOLENOID_COUNT@@],"onoff", 1, 0, 0, 1, 0
|
||||||
|
|
||||||
custom fsio_table_8x8_u8t @@FSIO_TABLE_8@@x@@FSIO_TABLE_8@@ array, U08, @OFFSET@, [@@FSIO_TABLE_8@@x@@FSIO_TABLE_8@@],"value", 1, 0, 0.0, 255.0, 0
|
custom fsio_table_8x8_u8t @@FSIO_TABLE_8@@x@@FSIO_TABLE_8@@ array, U08, @OFFSET@, [@@FSIO_TABLE_8@@x@@FSIO_TABLE_8@@],"value", 1, 0, 0.0, 255.0, 0
|
||||||
custom fsio_table_8x8_f32t 4*@@FSIO_TABLE_8@@x@@FSIO_TABLE_8@@ array, F32, @OFFSET@, [@@FSIO_TABLE_8@@x@@FSIO_TABLE_8@@],"value", 1, 0, 0.0, 30000.0, 2
|
custom fsio_table_8x8_f32t 4*@@FSIO_TABLE_8@@x@@FSIO_TABLE_8@@ array, F32, @OFFSET@, [@@FSIO_TABLE_8@@x@@FSIO_TABLE_8@@],"value", 1, 0, 0.0, 30000.0, 2
|
||||||
|
|
|
@ -2957,7 +2957,7 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
|
||||||
field = "Solenoid 5 Pin Mode" tcu_solenoid_mode5, { tcuEnabled }
|
field = "Solenoid 5 Pin Mode" tcu_solenoid_mode5, { tcuEnabled }
|
||||||
field = "Solenoid 6 Pin Mode" tcu_solenoid_mode6, { tcuEnabled }
|
field = "Solenoid 6 Pin Mode" tcu_solenoid_mode6, { tcuEnabled }
|
||||||
|
|
||||||
dialog = buttonShiftInputPanel
|
dialog = buttonShiftInputPanel, "Switch/Button Shift"
|
||||||
field = "Upshift Pin" tcuUpshiftButtonPin, { tcuEnabled }
|
field = "Upshift Pin" tcuUpshiftButtonPin, { tcuEnabled }
|
||||||
field = "Upshift Pin Mode" tcuUpshiftButtonPinMode, { tcuEnabled }
|
field = "Upshift Pin Mode" tcuUpshiftButtonPinMode, { tcuEnabled }
|
||||||
field = "Downshift Pin" tcuDownshiftButtonPin, { tcuEnabled }
|
field = "Downshift Pin" tcuDownshiftButtonPin, { tcuEnabled }
|
||||||
|
|
Loading…
Reference in New Issue