m5stack / M5Core2

M5Core2 Arduino Library
MIT License
263 stars 115 forks source link

TFT_BL appears set incorrectly #92

Closed belm0 closed 2 years ago

belm0 commented 2 years ago

TFT_BL is defined as -1

So when the Display init code tries to set up the TFT backlight, there is an error from the esp32 library.

E (1375) ledc: ledc_channel_config(369): gpio_num argument is invalid

https://github.com/m5stack/M5Core2/blob/9ef6a81070022d566c07a9c01718c02c1a29d7f3/src/utility/In_eSPI_Setup.h#L187

https://github.com/m5stack/M5Core2/blob/9ef6a81070022d566c07a9c01718c02c1a29d7f3/src/M5Display.cpp#L21-L24

OekoSolveMG commented 2 years ago

Defines in the M5Stack library:

#define TFT_MISO 19
#define TFT_MOSI 23
#define TFT_SCLK 18
#define TFT_CS   14  // Chip select control pin
#define TFT_DC   27  // Data Command control pin
#define TFT_RST  33  // Reset pin (could connect to Arduino RESET pin)
#define TFT_BL   32  // LED back-light (required for M5Stack)

I am assuming that the backlight is not accesed in the same way with the Core2, because you have to set the backligth via. AXP as well.

Nevertheless attaching a pin, that is not even needed and set to -1, does not make any sense whatsoever. The only thing it does it produce error messages.

belm0 commented 2 years ago

Yes, the offending code is left over from the Core Basic library and should be removed.

The maintainers don't seem to care-- perhaps focus is now on the M5Unified library.

Sarah-C commented 2 years ago

I asked the devs of tft_eSPI about the backlight issue, because awhile ago it was overdriving it on the M5Stack.

It would appear issues are still effecting the M5Stack repositories that use the graphical framework.

Below is more details about it, and a very short and simple Core 2 brightness function that handles it as it should -safely, below 2.8v but lets you overdrive the LED to 3.3 if you want. The engineers of the Core 2 don't recommend it for more than an hour at a time though.

My thoughts for a quick fix are get it to compile and use my brightness function in your sketch. It avoids needing to include libraries you may not want?

https://github.com/Sarah-C/M5Stack_Core2_ScreenBrightness

https://www.reddit.com/r/esp32/comments/pnwdfj/warning_for_people_using_tft_espi_as_a_stand/

https://github.com/Bodmer/TFT_eSPI/issues/226

Tinyu-Zhao commented 2 years ago

The Core2 backlight is controlled directly via the DCDC3 channel of the AXP192, setting -1 in TFT_BL means that it is not directly connected to a pin.

belm0 commented 2 years ago

The Core2 backlight is controlled directly via the DCDC3 channel of the AXP193, setting -1 in TFT_BL means that it is not directly connected to a pin.

Maybe the TFT_BL value is sent to multiple places. It should not be passed to ledcAttachPin() when it is -1, because this causes an error message.

Tinyu-Zhao commented 2 years ago

So far everything looks fine, thanks for your feedback