Closed lefty01 closed 1 year ago
hi, thanks for your contribution :+1:
can you edit your PR and target the develop branch instead of the master branch?
hi, thanks for your contribution +1
can you edit your PR and target the develop branch instead of the master branch? sure, changed it
If readout from the panel is not available, it must be handled with care.
If it is confirmed that reading from the panel is not possible, the board should be excluded from LGFX_AUTODETECT. This is because auto-configuration of a board whose ID cannot be confirmed may interfere with the operation of other boards.
aha thanks ... I'll retry. I did try spi_3wire with true / false values. but need then to check again (as you note) to get something meaningful back from the board.
after looking around I had seen that the _detector_Feather_ESP32_S3_TFT_t detector used the same values (0,0,0) indicating Id checker disabled ... I think that was what made me believe it would be ok ;)
so would you think it then requires to add "custom" detect function within the t4 detector?
I switched back to , 0x04, 0xFF, 0x00 // ili9341
struct _detector_TTGO_T4_Display_t : public _detector_spi_t
{
constexpr _detector_TTGO_T4_Display_t(void)
: _detector_spi_t
{ board_t::board_TTGO_T4_Display
, 0x04, 0xFF, 0x00 // ili9341
//, 0, 0, 0 // cannot get id
, 40000000, 16000000
, GPIO_NUM_23 // MOSI
, GPIO_NUM_12 // MISO
, GPIO_NUM_18 // SCLK
, GPIO_NUM_32 // DC
, GPIO_NUM_27 // CS
, GPIO_NUM_5 // RST
, GPIO_NUM_13 // TF CARD CS
, 0 // SPI MODE
, true // SPI 3wire
, VSPI_HOST // SPI HOST
} {}
bool detect(_detector_result_t* result, bool use_reset) const override
{
ESP_LOGI(LIBRARY_NAME, "[Autodetect] TTGO_T4_Display detect function ...");
//_pin_backup_t backup = { GPIO_NUM_2 };
//_pin_level(GPIO_NUM_2, true);
bool res = _detector_spi_t::detect(result, use_reset);
//backup.restore();
return res;
}
void setup(_detector_result_t* result) const override
{
ESP_LOGI(LIBRARY_NAME, "[Autodetect] TTGO_T4_Display");
auto p = new Panel_ILI9341();
result->panel = p;
{
auto cfg = p->config();
cfg.pin_cs = GPIO_NUM_27;
cfg.pin_rst = GPIO_NUM_5;
cfg.pin_busy = -1;
cfg.panel_width = 240;
cfg.panel_height = 320;
cfg.offset_x = 0;
cfg.offset_y = 0;
cfg.offset_rotation = 0;
cfg.dummy_read_pixel = 8;
cfg.dummy_read_bits = 1;
cfg.readable = true;
cfg.invert = false;
cfg.rgb_order = false;
cfg.dlen_16bit = false;
cfg.bus_shared = true;
p->config(cfg);
p->light(_create_pwm_backlight(GPIO_NUM_4, 7, 44100));
}
}
};
with debug enabled this gives me this output ... I can see now it is not all zeros ...
Init display
[ 3041][I][LGFX_AutoDetect_ESP32_all.hpp:981] init_impl(): [LovyanGFX] [Autodetect] load from NVS : board:10
[ 3042][V][LGFX_AutoDetect_ESP32_all.hpp:3289] autodetect(): [LGFX] pkg: 0
[ 3049][I][esp32-hal-i2c.c:75] i2cInit(): Initialising I2C Master: sda=21 scl=22 freq=100000
[ 3058][I][LGFX_AutoDetect_ESP32_all.hpp:2322] detect(): [LovyanGFX] [Autodetect] TTGO_T4_Display detect function ...
[ 3083][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:04 = 00000000
[ 3084][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:09 = 00000000
[ 3093][V][LGFX_AutoDetect_ESP32_all.hpp:3289] autodetect(): [LGFX] pkg: 0
[ 3099][I][esp32-hal-i2c.c:75] i2cInit(): Initialising I2C Master: sda=21 scl=22 freq=100000
[ 3108][I][esp32-hal-i2c.c:75] i2cInit(): Initialising I2C Master: sda=21 scl=22 freq=100000
[ 3130][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:04 = 00000000
[ 3144][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:04 = 00000000
[ 3144][I][LGFX_AutoDetect_ESP32_all.hpp:2322] detect(): [LovyanGFX] [Autodetect] TTGO_T4_Display detect function ...
[ 3168][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:04 = 00000000
[ 3168][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:09 = 00000000
[ 3178][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:04 = ffffffff
[ 3188][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:04 = ffffffff
[ 3211][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:04 = ffffffff
[ 3225][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:04 = 00000000
[ 3241][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:04 = 00000000
[ 3241][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:09 = 00000000
[ 3250][V][LGFX_AutoDetect_ESP32_all.hpp:3289] autodetect(): [LGFX] pkg: 0
[ 3256][I][esp32-hal-i2c.c:75] i2cInit(): Initialising I2C Master: sda=21 scl=22 freq=100000
[ 3266][I][esp32-hal-i2c.c:75] i2cInit(): Initialising I2C Master: sda=21 scl=22 freq=100000
[ 3287][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:04 = 00000000
[ 3301][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:04 = 00000000
[ 3301][I][LGFX_AutoDetect_ESP32_all.hpp:2322] detect(): [LovyanGFX] [Autodetect] TTGO_T4_Display detect function ...
[ 3325][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:04 = 00000000
[ 3325][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:09 = 00000000
[ 3335][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:04 = ffffffff
[ 3345][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:04 = ffffffff
[ 3368][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:04 = ffffffff
[ 3382][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:04 = 00000000
[ 3398][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:04 = 00000000
[ 3398][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:09 = 00000000
[ 3407][V][LGFX_AutoDetect_ESP32_all.hpp:3289] autodetect(): [LGFX] pkg: 0
[ 3413][I][esp32-hal-i2c.c:75] i2cInit(): Initialising I2C Master: sda=21 scl=22 freq=100000
[ 3423][I][esp32-hal-i2c.c:75] i2cInit(): Initialising I2C Master: sda=21 scl=22 freq=100000
[ 3444][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:04 = 00000000
[ 3458][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:04 = 00000000
[ 3458][I][LGFX_AutoDetect_ESP32_all.hpp:2322] detect(): [LovyanGFX] [Autodetect] TTGO_T4_Display detect function ...
[ 3482][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:04 = 00000000
[ 3482][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:09 = 00000000
[ 3492][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:04 = ffffffff
[ 3502][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:04 = ffffffff
[ 3525][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:04 = ffffffff
[ 3540][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:04 = 00000000
[ 3556][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:04 = 00000000
[ 3556][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:09 = 00000000
[ 3565][V][LGFX_AutoDetect_ESP32_all.hpp:3289] autodetect(): [LGFX] pkg: 0
[ 3571][I][esp32-hal-i2c.c:75] i2cInit(): Initialising I2C Master: sda=21 scl=22 freq=100000
[ 3581][I][esp32-hal-i2c.c:75] i2cInit(): Initialising I2C Master: sda=21 scl=22 freq=100000
[ 3602][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:04 = 00000000
[ 3616][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:04 = 00000000
[ 3616][I][LGFX_AutoDetect_ESP32_all.hpp:2322] detect(): [LovyanGFX] [Autodetect] TTGO_T4_Display detect function ...
[ 3640][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:04 = 00000000
[ 3640][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:09 = 00000000
[ 3650][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:04 = ffffffff
[ 3660][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:04 = ffffffff
[ 3683][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:04 = ffffffff
[ 3697][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:04 = 00000000
[ 3713][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:04 = 00000000
[ 3713][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:09 = 00000000
[ 3722][I][LGFX_AutoDetect_ESP32_all.hpp:1006] init_impl(): [LovyanGFX] [Autodetect] save to NVS : board:0
Init LVGL display
Setup started:
Init Wifi...*WM:
Ooooh .... wait ... ok now I set 3wire to false
Init display
[ 3042][I][LGFX_AutoDetect_ESP32_all.hpp:981] init_impl(): [LovyanGFX] [Autodetect] load from NVS : board:0
[ 3043][V][LGFX_AutoDetect_ESP32_all.hpp:3290] autodetect(): [LGFX] pkg: 0
[ 3050][I][esp32-hal-i2c.c:75] i2cInit(): Initialising I2C Master: sda=21 scl=22 freq=100000
[ 3059][I][esp32-hal-i2c.c:75] i2cInit(): Initialising I2C Master: sda=21 scl=22 freq=100000
[ 3081][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:04 = 00000000
[ 3095][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:04 = 00000000
[ 3095][I][LGFX_AutoDetect_ESP32_all.hpp:2323] detect(): [LovyanGFX] [Autodetect] TTGO_T4_Display detect function ...
[ 3119][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:04 = 00000000
[ 3119][V][LGFX_AutoDetect_ESP32_all.hpp:687] _read_panel_id(): [LovyanGFX] [Autodetect] read cmd:09 = 00006100
[ 3128][I][LGFX_AutoDetect_ESP32_all.hpp:2334] setup(): [LovyanGFX] [Autodetect] TTGO_T4_Display
[ 3388][I][LGFX_AutoDetect_ESP32_all.hpp:1006] init_impl(): [LovyanGFX] [Autodetect] save to NVS : board:10
Init LVGL display
... so this is working!
@lefty01 Thanks for checking !
If possible, please run examples/Test/test_readpixel to verify that the pixel data reading is functioning properly.
If it works correctly, it will transform as shown in the following picture. If there is a discrepancy in the settings, the color will change or the brightness will change.
If this test is successful, I will gladly merge this PR.
hrmmm ok I tried this, I added the #define LGFX_AUTODETECT before the include of LovyanGFX.hpp ... this however does not work at all :( the display is blinking like one every second turns on (looks like full white) and then stays off again. any idea which config setting I could try tweaking?
oh it is constantly rebooting ... TG1WDT_SYS_RESET ....hrmm.
constantly rebooting ... TG1WDT_SYS_RESET
@lefty01 lgfx saves the "last known good" display device in NVS using an index number, if the order in autodetect is changed, you may end up with the wrong panel selected
solution: erase all flash
some thoughts:
the idea of using autodetect is compatible with "one binary fits all devices" philosophy
but in some situations "one sketch fits all devices" is enough and autodetection doesn't need to be that much exhaustive
e.g. if TTGO-T4 existed in the boards list, it would probably create this definition upon compilation:
#define ARDUINO_TTGO_T4
which could be reflected in lgfx, and propagated:
#if defined ARDUINO_TTGO_T4
#define LGFX_TTGO_T4
#endif
then in the autodetect block:
#if defined LGFX_TTGO_T4
// your autodetect code
#endif
there's an example of such implementation with the S3Pro, using a define that only exists inside LGFX, until this board model eventually gets an official name LGFX_LOLIN_S3_PRO
perhaps.. need this line ?
# define LGFX_USE_V1
... back to work, less time ;) I actually did add the LGFX_USE_V1 define already.
so I now have added the test_readpixel code to a platformio project pointing to my github fork.
at the very top is:
// v1.0.0 を有効にします(v0からの移行期間の特別措置です。これを書かない場合は旧v0系で動作します。)
#define LGFX_USE_V1
#define LGFX_AUTODETECT
#include <LovyanGFX.hpp>
...
I did some pio run -t erase and then uploaded that code. so to some degree it looks better now since I can see the pattern shortly then its almost black except for some red faded line that changes the side based on rotation (which is seen in the printed text) ... I can upload a video if you want.
but it does not have any transformation effect yet!
(I can see this effect if I flash the same on the ESP TTGO T-Display ...)
so I might take a look on what you mentioned about the define that shall be created if I would only add the new board.
oh ok .. wait ... I changed back to define the LGFX class and not using the autodetect ... at first the same bahaviour again.
then I started to "play" again with the spi instance config .. eventually setting cfg.spi_3wire back to false. et voila ... that gives the expected result the test pattern morphing in kind of triangle shape to the bottom of the screen (depending on rotation)....
only added or changed the rotation offset now.
p/s: the width and height you might see in the image is what I added (just to be sure it receives the correct values)
@lefty01 Thanks for taking the time to check it out ! Perhaps the problem has been cleared up, so I will merge this in. Thanks again for your contribution !
hi, I have this ttgo t4 board and we are using your great library. so I added this to the esp32 autodetect file, does it make sense? would you like to add the change to main?