From 0558524899bceba3005ce7467fcd716c1564ecab Mon Sep 17 00:00:00 2001 From: steadramon <866195+steadramon@users.noreply.github.com> Date: Sat, 17 Aug 2024 09:15:32 +0100 Subject: [PATCH] Added adjustable pin mode for pcnt --- ESPGeiger/src/GeigerInput/Type/Pulse.cpp | 2 +- ESPGeiger/src/GeigerInput/Type/Pulse.h | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ESPGeiger/src/GeigerInput/Type/Pulse.cpp b/ESPGeiger/src/GeigerInput/Type/Pulse.cpp index 5125770..1fd0eff 100644 --- a/ESPGeiger/src/GeigerInput/Type/Pulse.cpp +++ b/ESPGeiger/src/GeigerInput/Type/Pulse.cpp @@ -42,7 +42,7 @@ void GeigerPulse::begin() { pcnt_set_filter_value(PCNT_UNIT, PCNT_FILTER); pcnt_filter_enable(PCNT_UNIT); #endif - gpio_set_pull_mode((gpio_num_t)_rx_pin, GPIO_PULLDOWN_ONLY); + gpio_set_pull_mode((gpio_num_t)_rx_pin, PCNT_PIN_PULL_MODE); pcnt_counter_clear(PCNT_UNIT); pcnt_counter_resume(PCNT_UNIT); #else diff --git a/ESPGeiger/src/GeigerInput/Type/Pulse.h b/ESPGeiger/src/GeigerInput/Type/Pulse.h index 5f3b566..115aa44 100644 --- a/ESPGeiger/src/GeigerInput/Type/Pulse.h +++ b/ESPGeiger/src/GeigerInput/Type/Pulse.h @@ -37,6 +37,11 @@ extern "C" { #define PCNT_UNIT PCNT_UNIT_0 #define PCNT_CHANNEL PCNT_CHANNEL_0 +#ifdef PCNT_FLOATING_PIN +#define PCNT_PIN_PULL_MODE GPIO_FLOATING +#else +#define PCNT_PIN_PULL_MODE GPIO_PULLDOWN_ONLY +#endif #endif #include "../GeigerInput.h" @@ -54,4 +59,4 @@ class GeigerPulse : public GeigerInput int collect(); #endif }; -#endif \ No newline at end of file +#endif