making more code testable

This commit is contained in:
rusefi 2019-11-20 02:18:17 -05:00
parent b8ce0daf85
commit a7b7fd1005
4 changed files with 30 additions and 19 deletions

View File

@ -8,6 +8,11 @@
*/ */
#include "global.h" #include "global.h"
#if EFI_TUNER_STUDIO
#include "tunerstudio_configuration.h"
#endif /* EFI_TUNER_STUDIO */
#if EFI_ALTERNATOR_CONTROL #if EFI_ALTERNATOR_CONTROL
#include "engine.h" #include "engine.h"
#include "rpm_calculator.h" #include "rpm_calculator.h"
@ -19,11 +24,11 @@
#include "pwm_generator.h" #include "pwm_generator.h"
#include "pin_repository.h" #include "pin_repository.h"
#include "tunerstudio_configuration.h"
#if defined(HAS_OS_ACCESS) #if defined(HAS_OS_ACCESS)
#error "Unexpected OS ACCESS HERE" #error "Unexpected OS ACCESS HERE"
#endif #endif /* HAS_OS_ACCESS */
EXTERN_ENGINE EXTERN_ENGINE
; ;

View File

@ -343,8 +343,8 @@ void setThrottleDutyCycle(percent_t level) {
scheduleMsg(&logger, "duty ETB duty=%f", dc); scheduleMsg(&logger, "duty ETB duty=%f", dc);
} }
#if EFI_PROD_CODE
static void showEthInfo(void) { static void showEthInfo(void) {
#if EFI_PROD_CODE
static char pinNameBuffer[16]; static char pinNameBuffer[16];
scheduleMsg(&logger, "etbAutoTune=%d", scheduleMsg(&logger, "etbAutoTune=%d",
@ -366,16 +366,10 @@ static void showEthInfo(void) {
scheduleMsg(&logger, "dir1=%s", hwPortname(CONFIGB(etb1.directionPin1))); scheduleMsg(&logger, "dir1=%s", hwPortname(CONFIGB(etb1.directionPin1)));
scheduleMsg(&logger, "dir2=%s", hwPortname(CONFIGB(etb1.directionPin2))); scheduleMsg(&logger, "dir2=%s", hwPortname(CONFIGB(etb1.directionPin2)));
etbPid.showPidStatus(&logger, "ETB"); etbPid.showPidStatus(&logger, "ETB");
#endif /* EFI_PROD_CODE */
} }
/** #if EFI_PROD_CODE
* set etb_p X
*/
void setEtbPFactor(float value) {
engineConfiguration->etb.pFactor = value;
etbPid.reset();
showEthInfo();
}
static void setEtbFrequency(int frequency) { static void setEtbFrequency(int frequency) {
engineConfiguration->etbFreq = frequency; engineConfiguration->etbFreq = frequency;
@ -391,6 +385,16 @@ static void etbReset() {
mockPedalPosition = MOCK_UNDEFINED; mockPedalPosition = MOCK_UNDEFINED;
} }
#endif /* EFI_PROD_CODE */
/**
* set etb_p X
*/
void setEtbPFactor(float value) {
engineConfiguration->etb.pFactor = value;
etbPid.reset();
showEthInfo();
}
/** /**
* set etb_i X * set etb_i X
@ -418,7 +422,6 @@ void setEtbOffset(int value) {
etbPid.reset(); etbPid.reset();
showEthInfo(); showEthInfo();
} }
#endif /* EFI_PROD_CODE */
void setBoschVNH2SP30Curve(DECLARE_CONFIG_PARAMETER_SIGNATURE) { void setBoschVNH2SP30Curve(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
engineConfiguration->etbBiasBins[0] = 0; engineConfiguration->etbBiasBins[0] = 0;
@ -539,7 +542,7 @@ static void setAutoOffset(int offset) {
tuneWorkingPidSettings.offset = offset; tuneWorkingPidSettings.offset = offset;
autoTune.reset(); autoTune.reset();
} }
#endif #endif /* EFI_PROD_CODE */
void setDefaultEtbBiasCurve(DECLARE_CONFIG_PARAMETER_SIGNATURE) { void setDefaultEtbBiasCurve(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
engineConfiguration->etbBiasBins[0] = 0; engineConfiguration->etbBiasBins[0] = 0;
@ -625,7 +628,7 @@ void initElectronicThrottle(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
// manual duty cycle control without PID. Percent value from 0 to 100 // manual duty cycle control without PID. Percent value from 0 to 100
addConsoleActionNANF(CMD_ETB_DUTY, setThrottleDutyCycle); addConsoleActionNANF(CMD_ETB_DUTY, setThrottleDutyCycle);
#endif #endif /* EFI_PROD_CODE */
#if EFI_PROD_CODE && 0 #if EFI_PROD_CODE && 0
tuneWorkingPidSettings.pFactor = 1; tuneWorkingPidSettings.pFactor = 1;

View File

@ -30,7 +30,6 @@
#if EFI_PROD_CODE #if EFI_PROD_CODE
#include "vehicle_speed.h" #include "vehicle_speed.h"
#include "electronic_throttle.h"
#include "rtc_helper.h" #include "rtc_helper.h"
#include "can_hw.h" #include "can_hw.h"
#include "rusefi.h" #include "rusefi.h"
@ -38,6 +37,10 @@
#include "hardware.h" #include "hardware.h"
#endif /* EFI_PROD_CODE */ #endif /* EFI_PROD_CODE */
#if EFI_ELECTRONIC_THROTTLE_BODY
#include "electronic_throttle.h"
#endif /* EFI_ELECTRONIC_THROTTLE_BODY */
#if EFI_INTERNAL_FLASH #if EFI_INTERNAL_FLASH
#include "flash_main.h" #include "flash_main.h"
#endif /* EFI_INTERNAL_FLASH */ #endif /* EFI_INTERNAL_FLASH */

View File

@ -2,7 +2,7 @@
* efifeatures.h * efifeatures.h
* *
* @date Mar 7, 2014 * @date Mar 7, 2014
* @author Andrey Belomutskiy, (c) 2012-2016 * @author Andrey Belomutskiy, (c) 2012-2019
*/ */
#ifndef EFIFEATURES_H_ #ifndef EFIFEATURES_H_
@ -61,7 +61,7 @@
#define TS_UART_DMA_MODE FALSE #define TS_UART_DMA_MODE FALSE
#define EFI_MAP_AVERAGING TRUE #define EFI_MAP_AVERAGING TRUE
#define EFI_ALTERNATOR_CONTROL FALSE #define EFI_ALTERNATOR_CONTROL TRUE
#define EFI_SUPPORT_DODGE_NEON TRUE #define EFI_SUPPORT_DODGE_NEON TRUE
#define EFI_SUPPORT_FORD_ASPIRE TRUE #define EFI_SUPPORT_FORD_ASPIRE TRUE
@ -98,8 +98,8 @@
#define BOARD_MC33972_COUNT 0 #define BOARD_MC33972_COUNT 0
#define BOARD_TLE8888_COUNT 0 #define BOARD_TLE8888_COUNT 0
#define EFI_ELECTRONIC_THROTTLE_BODY FALSE #define EFI_ELECTRONIC_THROTTLE_BODY TRUE
#define EFI_AUX_PID FALSE #define EFI_AUX_PID TRUE
#define EFI_ICU_INPUTS FALSE #define EFI_ICU_INPUTS FALSE
#ifndef HAL_TRIGGER_USE_PAL #ifndef HAL_TRIGGER_USE_PAL