only:additional API

This commit is contained in:
rusefillc 2023-09-25 13:10:54 -04:00
parent 747d038fe4
commit 50f9fce660
2 changed files with 11 additions and 6 deletions

View File

@ -85,6 +85,14 @@ bool ButtonDebounce::readPinEvent() {
return readPinState();
}
bool ButtonDebounce::getPhysicalState() {
#if EFI_PROD_CODE || EFI_UNIT_TEST
return efiReadPin(active_pin);
#else
return false;
#endif
}
bool ButtonDebounce::readPinState() {
if (!isBrainPinValid(*m_pin)) {
return false;
@ -99,11 +107,7 @@ bool ButtonDebounce::readPinState() {
// We don't actually need it to be a class variable in this method,
// but when a method is implemented to actually get the pin's state,
// for example to implement long button presses, it will be needed.
#if EFI_PROD_CODE || EFI_UNIT_TEST
storedValue = efiReadPin(active_pin);
#else
storedValue = false;
#endif
storedValue = getPhysicalState();
// Invert
if (active_mode == PI_PULLUP) {
storedValue = !storedValue;
@ -119,7 +123,7 @@ void ButtonDebounce::debug() {
while (listItem != nullptr) {
#if EFI_PROD_CODE || EFI_UNIT_TEST
efiPrintf("%s timeLast %d", listItem->m_name, listItem->timeLast);
efiPrintf("physical state %d value %d", efiReadPin(listItem->active_pin), listItem->storedValue);
efiPrintf("physical state %d value %d", listItem->getPhysicalState(), listItem->storedValue);
#endif
listItem = listItem->nextDebounce;

View File

@ -23,6 +23,7 @@ public:
static void stopConfigurationList();
static void startConfigurationList();
static void debug();
bool getPhysicalState();
private:
const char* const m_name;
efitick_t m_threshold;