broadcast button toggle counter #5514

only:fancy boolen with counter
This commit is contained in:
rusefillc 2023-08-22 14:49:28 -04:00
parent 3c8cd08c61
commit a041eb55f3
4 changed files with 14 additions and 4 deletions

View File

@ -255,12 +255,11 @@ extern bool kAcRequestState;
currentState = engine->engineState.lua.acRequestState;
}
AcController & acController = engine->module<AcController>().unmock();
if (acController.acButtonState != currentState) {
acController.acButtonState = currentState;
if (engine->acButtonSwitchedState.update(currentState)) {
acController.acSwitchLastChangeTimeMs = US2MS(getTimeNowUs());
}
}
engine->engineState.clutchUpState = getClutchUpState();
engine->clutchUpSwitchedState.update(getClutchUpState());
#if EFI_IDLE_CONTROL
if (isBrainPinValid(engineConfiguration->throttlePedalUpPin)) {
@ -268,7 +267,7 @@ extern bool kAcRequestState;
}
#endif // EFI_IDLE_CONTROL
engine->engineState.brakePedalState = getBrakePedalState();
engine->brakePedalSwitchedState.update(getBrakePedalState());
#endif // EFI_GPIO_HARDWARE
}

View File

@ -54,6 +54,15 @@ void sendEventCounters() {
#endif // EFI_SHAFT_POSITION_INPUT
}
void sendButtonCounters() {
CanTxMessage msg(CanCategory::BENCH_TEST, BENCH_TEST_BUTTON_COUNTERS, 8);
msg[0] = TRUNCATE_TO_BYTE(engine->engineState.brakePedalState.getCounter());
msg[1] = TRUNCATE_TO_BYTE(engine->engineState.clutchUpState.getCounter());
AcController &acController = engine->module<AcController>().unmock();
msg[2] = TRUNCATE_TO_BYTE(acController.acButtonState.getCounter());
}
void sendRawAnalogValues() {
const float values[RAW_ANALOG_VALUES_COUNT] = {
Sensor::getRaw(SensorType::Tps1Primary),

View File

@ -7,5 +7,6 @@
void processCanBenchTest(const CANRxFrame& frame);
void sendEventCounters();
void sendButtonCounters();
void sendRawAnalogValues();
void sendBoardStatus();

View File

@ -62,6 +62,7 @@ void CanWrite::PeriodicTask(efitick_t nowNt) {
if (cycle.isInterval(CI::_250ms)) {
sendBoardStatus();
sendButtonCounters();
}
#if EFI_WIDEBAND_FIRMWARE_UPDATE