From 56c09c44aadeab1fa5e82499cebe3965c42c44c5 Mon Sep 17 00:00:00 2001 From: Gregg Date: Tue, 5 Oct 2021 06:32:19 -0500 Subject: [PATCH] Updated Blinker again to ensure C3 compatibility moved gpio_set_direction to start() method so that it is called every time needed in case another part of the program (i.e. DEV_Identify) calls pinMode() and resets the pin to a strict OUTPUT. --- src/Utils.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Utils.cpp b/src/Utils.cpp index dbeeaab..dd97b63 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -227,7 +227,6 @@ Blinker::Blinker(int pin, int timerNum){ void Blinker::init(int pin, int timerNum){ this->pin=pin; pinMode(pin,OUTPUT); - gpio_set_direction((gpio_num_t)pin, GPIO_MODE_INPUT_OUTPUT); // needed to ensure digitalRead() functions correctly on ESP32-C3 digitalWrite(pin,0); #if SOC_TIMER_GROUP_TIMERS_PER_GROUP>1 // ESP32 and ESP32-S2 contains two timers per timer group @@ -323,6 +322,8 @@ void Blinker::start(int period, float dutyCycle){ void Blinker::start(int period, float dutyCycle, int nBlinks, int delayTime){ + gpio_set_direction((gpio_num_t)pin, GPIO_MODE_INPUT_OUTPUT); // needed to ensure digitalRead() functions correctly on ESP32-C3 + period*=10; onTime=dutyCycle*period; offTime=period-onTime;