Override or inhibit initVariant() at start up
Posted: Wed Sep 11, 2024 6:55 am
Hi!
I intend to use an Adafruit Feather ESP32-S2 due to, among other things, its capability to drive an OLED through its STEMMA QT connector, for which it uses the PIN_I2C_POWER pin to power I2C devices. This way the OLED will power off when the MCU is put in deep sleep (I hope). I have already tried to achieve this with other boards and an ordinary GPIO pin but that does not work with my SH1107 128x128 OLED. It apparently draws too much current, even if I increase the pin strength/capability to 3 (40 mA). So I hope the ESP32-S2 will do the trick.
As i can see on GitHub (https://github.com/espressif/arduino-es ... ariant.cpp)the ESP32-S2 initVariant() method is where that pin is set high, and this happens right before the call to setup().
This is all fine, but I would like to be able to delay PIN_I2C_POWER going high to a later stage, own my own choice. This due to the way I want the thing to behave after wakeup from deep sleep.
I could of course just set PIN_I2C_POWER low first thing in setup, thus neutralizing initVaraint(). But I do not want the OLED to flicker at startup, and perhaps it will not, but I still would like to do this in a controlled way. And I am generally interested in educating myself.
So finally, here is my question; Is there a way to either override initVariant() or make it not be called?
Cheers!
I intend to use an Adafruit Feather ESP32-S2 due to, among other things, its capability to drive an OLED through its STEMMA QT connector, for which it uses the PIN_I2C_POWER pin to power I2C devices. This way the OLED will power off when the MCU is put in deep sleep (I hope). I have already tried to achieve this with other boards and an ordinary GPIO pin but that does not work with my SH1107 128x128 OLED. It apparently draws too much current, even if I increase the pin strength/capability to 3 (40 mA). So I hope the ESP32-S2 will do the trick.
As i can see on GitHub (https://github.com/espressif/arduino-es ... ariant.cpp)the ESP32-S2 initVariant() method is where that pin is set high, and this happens right before the call to setup().
This is all fine, but I would like to be able to delay PIN_I2C_POWER going high to a later stage, own my own choice. This due to the way I want the thing to behave after wakeup from deep sleep.
I could of course just set PIN_I2C_POWER low first thing in setup, thus neutralizing initVaraint(). But I do not want the OLED to flicker at startup, and perhaps it will not, but I still would like to do this in a controlled way. And I am generally interested in educating myself.
So finally, here is my question; Is there a way to either override initVariant() or make it not be called?
Cheers!