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:
David Holdeman 2020-10-09 22:34:45 -05:00 committed by GitHub
parent b76afc46e4
commit 29c2d692ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 77 additions and 46 deletions

View File

@ -17,7 +17,7 @@
#include "trigger_central.h"
#include "local_version_holder.h"
#include "buttonshift.h"
#include "tcu.h"
#include "gear_controller.h"
#if EFI_SIGNAL_EXECUTOR_ONE_TIMER
// PROD real firmware uses this implementation

View File

@ -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 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 tps_tps_table_t[TPS_TPS_ACCEL_TABLE][TPS_TPS_ACCEL_TABLE];

View File

@ -16,6 +16,8 @@ void ButtonShiftController::init (DECLARE_ENGINE_PARAMETER_SIGNATURE) {
// 500 millisecond is maybe a little long?
debounceUp.init(500, CONFIG(tcuUpshiftButtonPin), CONFIG(tcuUpshiftButtonPinMode));
debounceDown.init(500, CONFIG(tcuDownshiftButtonPin), CONFIG(tcuDownshiftButtonPinMode));
INJECT_ENGINE_REFERENCE(&transmissionController);
transmissionController.init();
}
void ButtonShiftController::update() {

View File

@ -7,7 +7,7 @@
*/
#pragma once
#include "tcu.h"
#include "gear_controller.h"
#include "globalaccess.h"
#include "debounce.h"

View File

@ -50,7 +50,9 @@ CONTROLLERS_SRC_CPP = \
$(CONTROLLERS_DIR)/serial/serial_sensor.cpp \
$(CONTROLLERS_DIR)/buttonshift.cpp \
$(CONTROLLERS_DIR)/tcu.cpp \
$(CONTROLLERS_DIR)/gear_controller.cpp \
$(CONTROLLERS_DIR)/start_stop.cpp \
$(CONTROLLERS_DIR)/simple_tcu.cpp \
CONTROLLERS_INC=\
$(CONTROLLERS_DIR) \

View File

@ -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
}

View File

@ -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;
};

View File

@ -1,16 +1,22 @@
#include "simple_tcu.h"
#include "efi_gpio.h"
#include "engine_configuration.h"
RegisteredOutputPin tcuSolenoids[efi::size(tcu_solenoid)];
EXTERN_CONFIG;
void SimpleTransmissionController::SimpleTransmissionController() {
for (int i = 0; i < efi::size(tcu_solenoid); i++) {
tcuSolenoids[i].initPin("Transmission Solenoid", CONFIG(tcu_solenoid[i]), CONFIG{tcu_solenoid_mode[i]});
OutputPin tcuSolenoids[TCU_SOLENOID_COUNT];
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) {
for (int i = 0; i < efi::size(tcu_solenoid); i++) {
tcuSolenoids[i].setValue(CONFIG(tcuSolenoidTable)[i][static_cast<int>(gear)])
for (int i = 0; i < efi::size(CONFIG(tcu_solenoid)); i++) {
#ifndef EFI_UNIT_TEST
tcuSolenoids[i].setValue(config->tcuSolenoidTable[static_cast<int>(gear) + 1][i]);
#endif
}
setCurrentGear(gear);
postState();

View File

@ -2,8 +2,10 @@
#include "tcu.h"
class SimpleTransmissionController {
class SimpleTransmissionController: public TransmissionControllerBase {
public:
DECLARE_ENGINE_PTR;
void update(gear_e);
SimpleTransmissionController();
}
void init();
};

View File

@ -28,23 +28,3 @@ void TransmissionControllerBase::postState() {
tsOutputChannels.tcuCurrentGear = getCurrentGear();
#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
}

View File

@ -16,6 +16,7 @@
class TransmissionControllerBase {
public:
void update(gear_e);
void init();
gear_e getCurrentGear() const;
private:
gear_e currentGear = NEUTRAL;
@ -23,15 +24,3 @@ protected:
gear_e setCurrentGear(gear_e);
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;
};

View File

@ -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 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_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

View File

@ -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 6 Pin Mode" tcu_solenoid_mode6, { tcuEnabled }
dialog = buttonShiftInputPanel
dialog = buttonShiftInputPanel, "Switch/Button Shift"
field = "Upshift Pin" tcuUpshiftButtonPin, { tcuEnabled }
field = "Upshift Pin Mode" tcuUpshiftButtonPinMode, { tcuEnabled }
field = "Downshift Pin" tcuDownshiftButtonPin, { tcuEnabled }