Knock inputs to be bore diameter and checkbox #6767

only: only bore logic
This commit is contained in:
rusefi 2024-08-04 13:30:15 -04:00
parent b541167fcd
commit ffea0a23a0
4 changed files with 12 additions and 21 deletions

View File

@ -666,11 +666,6 @@ static void setPrescalerAndSDO(int value) {
engineConfiguration->hip9011PrescalerAndSDO = value;
}
static void setHipBand(float value) {
engineConfiguration->knockBandCustom = value;
showHipInfo();
}
static void setHipGain(float value) {
engineConfiguration->hip9011Gain = value;
showHipInfo();
@ -679,7 +674,6 @@ static void setHipGain(float value) {
static void hip_addconsoleActions() {
addConsoleAction("hipinfo", showHipInfo);
addConsoleActionF("set_gain", setHipGain);
addConsoleActionF("set_band", setHipBand);
addConsoleActionI("set_hip_prescalerandsdo", setPrescalerAndSDO);
}

View File

@ -75,9 +75,7 @@ int HIP9011::sendCommandGetReply(uint8_t cmd, uint8_t *reply) {
* @return frequency band we are interested in
*/
float HIP9011::getBand(DEFINE_HIP_PARAMS) {
return GET_CONFIG_VALUE(knockBandCustom) == 0 ?
bore2frequency(GET_CONFIG_VALUE(cylinderBore)) :
GET_CONFIG_VALUE(knockBandCustom);
return bore2frequency(GET_CONFIG_VALUE(cylinderBore));
}
int HIP9011::getBandIndex(DEFINE_HIP_PARAMS) {

View File

@ -51,21 +51,21 @@ public:
#define DEFINE_PARAM_SUFFIX(x)
#else
#define PASS_HIP_PARAMS engineConfiguration->knockBandCustom, \
#define PASS_HIP_PARAMS \
engineConfiguration->cylinderBore, \
engineConfiguration->hip9011Gain, \
engineConfiguration->hip9011PrescalerAndSDO, \
engineConfiguration->knockDetectionWindowStart, \
engineConfiguration->knockDetectionWindowEnd
#define FORWARD_HIP_PARAMS knockBandCustom, \
#define FORWARD_HIP_PARAMS \
cylinderBore, \
hip9011Gain, \
hip9011PrescalerAndSDO, \
knockDetectionWindowStart, \
knockDetectionWindowEnd
#define DEFINE_HIP_PARAMS float knockBandCustom,\
#define DEFINE_HIP_PARAMS \
float cylinderBore, \
float hip9011Gain, \
int hip9011PrescalerAndSDO, \

View File

@ -19,11 +19,11 @@ TEST(hip9011, lookup) {
assertEqualsM2("240us 50 degree", 1105.2435, instance.getRpmByAngleWindowAndTimeUs(240, 50), 0.1);
assertEqualsM2("240us 50 degree", 6631.4619, instance.getRpmByAngleWindowAndTimeUs(40, 50), 0.1);
EXPECT_EQ(0, instance.getGainIndex(/* knockBandCustom*/NAN, /*cylinderBore*/NAN, /*hip9011Gain*/3, 0, NAN, NAN));
EXPECT_EQ(0, instance.getGainIndex(/* knockBandCustom*/NAN, /*cylinderBore*/NAN, /*hip9011Gain*/2, 0, NAN, NAN));
EXPECT_EQ(47, instance.getGainIndex(/* knockBandCustom*/NAN, /*cylinderBore*/NAN, /*hip9011Gain*/0.234, 0, NAN, NAN));
EXPECT_EQ(63, instance.getGainIndex(/* knockBandCustom*/NAN, /*cylinderBore*/NAN, /*hip9011Gain*/0.000001, 0, NAN, NAN));
EXPECT_EQ(63, instance.getGainIndex(/* knockBandCustom*/NAN, /*cylinderBore*/NAN, /*hip9011Gain*/-1.0, 0, NAN, NAN));
EXPECT_EQ(0, instance.getGainIndex(/*cylinderBore*/NAN, /*hip9011Gain*/3, 0, NAN, NAN));
EXPECT_EQ(0, instance.getGainIndex(/*cylinderBore*/NAN, /*hip9011Gain*/2, 0, NAN, NAN));
EXPECT_EQ(47, instance.getGainIndex(/*cylinderBore*/NAN, /*hip9011Gain*/0.234, 0, NAN, NAN));
EXPECT_EQ(63, instance.getGainIndex(/*cylinderBore*/NAN, /*hip9011Gain*/0.000001, 0, NAN, NAN));
EXPECT_EQ(63, instance.getGainIndex(/*cylinderBore*/NAN, /*hip9011Gain*/-1.0, 0, NAN, NAN));
}
@ -42,10 +42,9 @@ TEST(hip9011, rpmLookup) {
TEST(hip9011, band) {
HIP9011 instance(NULL);
EXPECT_FLOAT_EQ(3, instance.getBand(/* knockBandCustom*/3, /*cylinderBore*/76, /*hip9011Gain*/NAN, 0, NAN, NAN));
EXPECT_NEAR_M4(7.5389242, instance.getBand(/* knockBandCustom*/0, /*cylinderBore*/76, /*hip9011Gain*/NAN, 0, NAN, NAN));
EXPECT_NEAR_M4(7.5389242, instance.getBand(/*cylinderBore*/76, /*hip9011Gain*/NAN, 0, NAN, NAN));
EXPECT_EQ(42, instance.getBandIndex(/* knockBandCustom*/0, /*cylinderBore*/76, /*hip9011Gain*/NAN, 0, NAN, NAN));
EXPECT_EQ(42, instance.getBandIndex(/*cylinderBore*/76, /*hip9011Gain*/NAN, 0, NAN, NAN));
}
@ -64,7 +63,7 @@ TEST(hip9011, configurationCommands) {
HIP9011 instance(&mock);
// want to invoke method with same parameters a few times
#define PARAMETERS 600, /* knockBandCustom*/0, /*cylinderBore*/76, /*hip9011Gain*/1, HIP_8MHZ_PRESCALER, 0.0, 50.0
#define PARAMETERS 600, /*cylinderBore*/76, /*hip9011Gain*/1, HIP_8MHZ_PRESCALER, 0.0, 50.0
// Not making assumptions on the message send ...
EXPECT_CALL(mock, sendSyncCommand(SET_GAIN_CMD(0xE), 0)).Times(1);