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.
This commit is contained in:
Gregg 2021-10-05 06:32:19 -05:00
parent 0fd9424d79
commit 56c09c44aa
1 changed files with 2 additions and 1 deletions

View File

@ -227,7 +227,6 @@ Blinker::Blinker(int pin, int timerNum){
void Blinker::init(int pin, int timerNum){ void Blinker::init(int pin, int timerNum){
this->pin=pin; this->pin=pin;
pinMode(pin,OUTPUT); 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); digitalWrite(pin,0);
#if SOC_TIMER_GROUP_TIMERS_PER_GROUP>1 // ESP32 and ESP32-S2 contains two timers per timer group #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){ 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; period*=10;
onTime=dutyCycle*period; onTime=dutyCycle*period;
offTime=period-onTime; offTime=period-onTime;