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:
parent
0fd9424d79
commit
56c09c44aa
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue