diff --git a/src/lgfx/v1/misc/colortype.hpp b/src/lgfx/v1/misc/colortype.hpp index 17e72b1c..94fdd143 100644 --- a/src/lgfx/v1/misc/colortype.hpp +++ b/src/lgfx/v1/misc/colortype.hpp @@ -29,6 +29,8 @@ namespace lgfx { inline namespace v1 { +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Warray-bounds" //---------------------------------------------------------------------------- #if defined ( _MSVC_LANG ) @@ -947,6 +949,7 @@ namespace lgfx //---------------------------------------------------------------------------- #undef LGFX_INLINE +# pragma GCC diagnostic pop } } diff --git a/src/lgfx/v1/platforms/esp32/Panel_CVBS.cpp b/src/lgfx/v1/platforms/esp32/Panel_CVBS.cpp index c66a26d5..5693f0e5 100644 --- a/src/lgfx/v1/platforms/esp32/Panel_CVBS.cpp +++ b/src/lgfx/v1/platforms/esp32/Panel_CVBS.cpp @@ -28,7 +28,6 @@ Inspiration Sources: #include #include #include -#include #include #include #include @@ -49,6 +48,16 @@ Inspiration Sources: #else #include #endif + +#if __has_include () + #include + #include + #include +#else + #include +#endif + + #if __has_include() // ESP-IDF v5 #include @@ -1921,6 +1930,14 @@ namespace lgfx deinit(); } + static dac_channel_t _get_dacchannel(int pin) { +#if defined ( LGFX_I2S_STD_ENABLED ) + return (pin == 25) ? DAC_CHAN_0 : DAC_CHAN_1; +#else + return (pin == 25) ? DAC_CHANNEL_1 : DAC_CHANNEL_2; +#endif + } + void Panel_CVBS::deinit(void) { if (_started) @@ -1946,25 +1963,21 @@ namespace lgfx I2S0.out_link.start = 0; I2S0.conf.tx_start = 0; +#if __has_include () + dac_ll_digi_enable_dma(false); + auto ch = _get_dacchannel(_config_detail.pin_dac); + dac_ll_power_down(ch); +#else dac_i2s_disable(); - switch (_config_detail.pin_dac) - { - default: - break; - case 25: - dac_output_disable(DAC_CHANNEL_1); // for GPIO 25 - break; - case 26: - dac_output_disable(DAC_CHANNEL_2); // for GPIO 26 - break; - } - + auto ch = _get_dacchannel(_config_detail.pin_dac); + dac_output_disable(ch); +#endif periph_module_disable(PERIPH_I2S0_MODULE); #if defined ( LGFX_I2S_STD_ENABLED ) - rtc_clk_apll_enable(false); + rtc_clk_apll_enable(false); #else - rtc_clk_apll_enable(false,0,0,0,1); + rtc_clk_apll_enable(false,0,0,0,1); #endif // printf("dmabuf: %08x free\n", internal.dma_desc[0].buf); @@ -1993,22 +2006,40 @@ namespace lgfx { return true; } - _started = true; - - dac_i2s_enable(); - switch (_config_detail.pin_dac) + if (_config_detail.pin_dac != GPIO_NUM_25 && _config_detail.pin_dac != GPIO_NUM_26) { - default: ESP_LOGE(TAG, "DAC output gpio error: G%d ... Select G25 or G26.", _config_detail.pin_dac); return false; - case 25: - dac_output_enable(DAC_CHANNEL_1); // for GPIO 25 - break; - case 26: - dac_output_enable(DAC_CHANNEL_2); // for GPIO 26 - break; } + _started = true; +#if __has_include () + { static constexpr const gpio_num_t gpio_table[2] = { GPIO_NUM_25, GPIO_NUM_26 }; // for ESP32 (not ESP32S2, s2=gpio17,gpio18) + for (int i = 0; i < 2; ++i) + { + if (_config_detail.pin_dac != gpio_table[i]) { continue; } + auto gpio_num = gpio_table[i]; + rtc_gpio_init(gpio_num); + rtc_gpio_set_direction(gpio_num, RTC_GPIO_MODE_DISABLED); + rtc_gpio_pullup_dis(gpio_num); + rtc_gpio_pulldown_dis(gpio_num); + + auto channel = _get_dacchannel(gpio_num); + dac_ll_power_on(channel); + } + dac_ll_rtc_sync_by_adc(false); + dac_ll_digi_enable_dma(true); + + I2S0.conf2.lcd_en = true; + I2S0.conf.tx_right_first = false; + I2S0.conf.tx_msb_shift = 0; + I2S0.conf.tx_short_sync = 0; + } +#else + dac_i2s_enable(); + auto ch = _get_dacchannel(_config_detail.pin_dac); + dac_output_enable(ch); +#endif if (_config_detail.signal_type >= config_detail_t::signal_type_t::signal_type_max) { _config_detail.signal_type = (config_detail_t::signal_type_t)0; diff --git a/src/lgfx/v1/platforms/esp32/common.cpp b/src/lgfx/v1/platforms/esp32/common.cpp index db705a77..7af6065c 100644 --- a/src/lgfx/v1/platforms/esp32/common.cpp +++ b/src/lgfx/v1/platforms/esp32/common.cpp @@ -35,16 +35,13 @@ Original Source: #include #include #include -#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)) - //#include - #if __has_include() - #include - #endif -#else - #if __has_include () - #include - #endif + +#if __has_include() + #include +#elif __has_include () + #include #endif + #include #include