-
-
Notifications
You must be signed in to change notification settings - Fork 224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for ESP32-S3-Box v3 #569
Comments
hi, thanks for your feedback 👍 indeed the autodetect sequence will need a new entry, but first let's validate the display and touch configuration does it work if you edit manually the struct detector to set the correct pin number for the backlight and change MISO value to |
thankyou - unfortunately after I manually edit the detector and recompile, the display is still black. I've never used ESP32-S3-BOX-3 before, so I'm not sure if there's some other initialisation that needs to be done, for example some kind of power supply enable or similar. I turned on verbose logging and saw:
#include <Arduino.h>
#define LGFX_ESP32_S3_BOX // Espressif ESP32-S3-BOX
// #define LGFX_AUTODETECT
#include <LGFX_AUTODETECT.hpp>
#include <LovyanGFX.hpp>
static LGFX lcd;
#include "FastLED.h"
#include "TickTwo.h"
// lots of variable declarations and #define constants
void setup(void) {
Serial.begin(115200);
delay(5000); // Wait for serial port to begin
lcd.init();
lcd.setBrightness(255);
lcd.clear(TFT_GREEN);
delay(1000);
lcd.clear();
lcd.setFont(&fonts::FreeSans12pt7b);
lcd.setTextColor(TFT_GREEN, TFT_BLACK);
lcd.setTextDatum(top_center);
int x = lcd.width() / 2;
int y = lcd.height() / 2;
lcd.drawString("Hello World", x, y);
while (true);
} PlatformIO.ini [env:S3-Box-AD8318]
platform = espressif32
board = esp32s3box
framework = arduino
monitor_speed = 115200
build_flags =
; -DCORE_DEBUG_LEVEL=0 ; None
; -DCORE_DEBUG_LEVEL=1 ; Error *
; -DCORE_DEBUG_LEVEL=2 ; Warn
; -DCORE_DEBUG_LEVEL=3 ; Info
; -DCORE_DEBUG_LEVEL=4 ; Debug *
-DCORE_DEBUG_LEVEL=5 ; Verbose
lib_deps =
lovyan03/LovyanGFX
fastled/FastLED
sstaub/TickTwo |
can't find much difference either maybe disable the id checker since miso is disabled, e.g. replace |
I don't know what those numbers do, but there is progress. The backlight is now on, and the screen is white. But the brightness level is changing, i.e. if I set brightness to 50%, it is definitely not as bright. But still no graphics displayed, now just a white screen. Log output slightly different:
|
last thing to try: manually set the reset pin as input_pullup after this I can't think of anything else without ordering a unit and start poking around, but this will take weeks before it gets delivered |
success! It was the reset pin that fixed it. Now for the touchscreen? Thanks for your help. By the way, on this ESP32-S3 chip, I have to press the reset button to run code after an upload, it doesn't auto run for some reason. |
🥳
remove the while(1) from you setup and use this loop() test function: void loop() {
std::int32_t x, y, number = 0;
while (display.getTouch(&x, &y, number))
{
display.fillCircle(x, y, 5, (std::uint32_t)(number * 0x333333u));
++number;
}
}
I have this too when I select OTG as USB mode ( |
here we go again, no circles displayed on the screen. Any suggestions what to try this time? As far as I can tell, the touchscreen is the same as the previous ESP32-BOX, i.e. I2C lines SDA=GPIO8, SCL=GPIO18 and interrupt CTP_INT=GPIO3 |
Touch_TT21xxx class doesn't seem to make much of you can first try to set this: eventually perform an I2C scan to see if I2C0 is shared with other I2C devices, if so you can also try to set this: |
OK I've set
I've substituted each of those addresses in |
|
Yes because when I scan I2C0 I get
|
whoops maybe update |
no good unfortunately, this is what I have struct _detector_ESP32_S3_BOX_t : public _detector_spi_t
{
constexpr _detector_ESP32_S3_BOX_t(void) :
_detector_spi_t
{ board_t::board_ESP32_S3_BOX
, 0, 0, 0 // ILI9342C
, 40000000, 16000000
, GPIO_NUM_6 // MOSI
, (gpio_num_t)-1 // MISO
, GPIO_NUM_7 // SCLK
, GPIO_NUM_4 // DC
, GPIO_NUM_5 // CS
, (gpio_num_t)-1 // RST
, (gpio_num_t)-1 // TF CARD CS
, 0 // SPI MODE
, true // SPI 3wire
, SPI2_HOST // SPI HOST
} {}
void setup(_detector_result_t* result) const override
{
ESP_LOGI(LIBRARY_NAME, "[Autodetect] ESP32_S3_BOX");
auto p = new Panel_ILI9342();
result->panel = p;
{
auto cfg = p->config();
// cfg.pin_cs = GPIO_NUM_5;
// cfg.pin_rst = GPIO_NUM_48;
cfg.offset_rotation = 1;
p->config(cfg); // config設定;
p->setRotation(1); // config設定後に向きを設定;
p->light(_create_pwm_backlight(GPIO_NUM_47, 0, 12000));
}
{
auto t = new lgfx::Touch_GT911();
auto cfg = t->config();
// cfg.pin_int = GPIO_NUM_3;
cfg.pin_int = -1;
cfg.pin_sda = GPIO_NUM_8;
cfg.pin_scl = GPIO_NUM_18;
// cfg.i2c_addr = 0x24;
cfg.i2c_addr = 0x5D;
// I2C device found at address 0x18
// I2C device found at address 0x40
// I2C device found at address 0x5D
// I2C device found at address 0x68
cfg.i2c_port = I2C_NUM_0;
cfg.freq = 400000;
cfg.x_min = 0;
cfg.x_max = 319;
cfg.y_min = 0;
cfg.y_max = 239;
cfg.bus_shared = true;
t->config(cfg);
p->touch(t);
float affine[6] = { 1, 0, 0, 0, -1, 240 };
p->setCalibrateAffine(affine);
}
}
}; |
moreover, the only device using GT911 in the autodetect (M5Paper) seems to try a secondary I2C address between cfg.i2c_addr = 0x14;
// (...)
t->config(cfg);
if (!t->init())
{
cfg.i2c_addr = 0x5D; // addr change (0x14 or 0x5D)
t->config(cfg);
}
p->touch(t); |
still no good. I tried I2C freq of 10000 too, and various combinations of I2C0 and I2C1. When I get time later today, I'll dig into Espressif's hardware docs and driver code and see if I can work out exactly which touch chip they're using. From a quick look, they don't reveal this on schematic or the hardware overview etc. |
@tobozo there is some discussion on the touch driver here, I've not had time to read it all |
yup the rust project is where I found the idea for the input pullup on the panel RST pin GT911 does support interrupts (LGFX uses it for touch wakeup) and more insight on the dual i2c_address: https://github.com/espressif/esp-bsp/blob/master/components/lcd_touch/esp_lcd_touch_gt911/include/esp_lcd_touch_gt911.h#L35
|
success!!! The problem was the colour of the circles drawn on touch points. With one finger, it must be black. If I use two fingers, then very dark grey dots show up. If I use three fingers (difficult on small display), the colour is light grey. I realised I can drag my finger and it draws a dotted line. For now instead of I changed a few other auto detect settings too, so I'll wind those back and see what really made it work. I will report back soon. |
Here is the latest autodetect code. The last 2 lines in the touch config for calibration need to be commented out. Although it still needs calibration because the max-y I'm seeting is about 200. I haven't looked into user calibration yet, just happy its working! struct _detector_ESP32_S3_BOX_t : public _detector_spi_t
{
constexpr _detector_ESP32_S3_BOX_t(void) :
_detector_spi_t
{ board_t::board_ESP32_S3_BOX
, 0, 0, 0 // ILI9342C
, 40000000, 16000000
, GPIO_NUM_6 // MOSI
, (gpio_num_t)-1 // MISO
, GPIO_NUM_7 // SCLK
, GPIO_NUM_4 // DC
, GPIO_NUM_5 // CS
, (gpio_num_t)-1 // RST
, (gpio_num_t)-1 // TF CARD CS
, 0 // SPI MODE
, true // SPI 3wire
, SPI2_HOST // SPI HOST
} {}
void setup(_detector_result_t* result) const override
{
ESP_LOGI(LIBRARY_NAME, "[Autodetect] ESP32_S3_BOX");
auto p = new Panel_ILI9342();
result->panel = p;
{
auto cfg = p->config();
// cfg.pin_cs = GPIO_NUM_5;
// cfg.pin_rst = GPIO_NUM_48;
cfg.offset_rotation = 1;
p->config(cfg); // config設定;
p->setRotation(1); // config設定後に向きを設定;
p->light(_create_pwm_backlight(GPIO_NUM_47, 0, 12000));
}
{
auto t = new lgfx::Touch_GT911();
auto cfg = t->config();
cfg.pin_int = -1;
cfg.pin_sda = GPIO_NUM_8;
cfg.pin_scl = GPIO_NUM_18;
cfg.i2c_addr = 0x14;
cfg.i2c_port = I2C_NUM_0;
// cfg.freq = 400000;
cfg.x_min = 0;
cfg.x_max = 319;
cfg.y_min = 0;
// cfg.y_max = 239;
// Max-y = 239 + 40 pixels for "red" touch point below LCD active area
cfg.y_max = 279;
cfg.offset_rotation = 2;
cfg.bus_shared = false;
t->config(cfg);
if (!t->init())
{
cfg.i2c_addr = 0x5D; // addr change (0x14 or 0x5D)
t->config(cfg);
}
p->touch(t);
// float affine[6] = { 1, 0, 0, 0, -1, 240 };
// p->setCalibrateAffine(affine);
}
}
}; setup() is pinMode(GPIO_NUM_48, INPUT_PULLUP); // LCD Reset pin
lcd.init(); using this loop code void loop(void) {
static bool touched = false;
std::int32_t x, y, number = 0;
while (lcd.getTouch(&x, &y)) {
touched = true;
// lcd.fillCircle(x, y, 5, (std::uint32_t)(number * 0x333333u));
lcd.fillCircle(x, y, 5, TFT_GREEN);
}
if (touched) {
touched = false;
lcd.setTextColor(TFT_CYAN, TFT_BACKGND);
sprintf(txt, "(%d, %d)", x, y);
lcd.drawString(txt, x + 5, y);
lcd.getTouchRaw(&x, &y);
Serial.printf("Touch raw x=%d, y=%d\n", x, y);
if (y > 200)
lcd.clear();
}
lcd.setTextColor(TFT_ORANGE, TFT_BACKGND);
lcd.drawNumber(num++, 10, 10);
} |
thanks for testing this 👍 I've added your changes to a new block in the autodetect sequence (see you can test it by checking out the develop branch of this repository. the the touch interrupt pin was added back to the touch config as some wake/sleep scenarios may need it, please confirm it didn't break anything :-) now there's still room for improvement but it can be kept as a tech debt; so you can eventually ignore what follows: according to the ilitek documentation the display is readable, and if you feel like playing with that part, you can re-enable the what the
thanks again for testing all this 👍 |
ok that's working perfectly with the develop branch. Regarding autodetect, with #define LGFX_ESP32_S3_BOX_V3 // Espressif ESP32-S3-BOX-V3
// #define LGFX_AUTODETECT I'm seeing:
So does that response of 000000e3 mean it's working? BTW I see no difference between freq of 16000000 or 15000000. I would need more ideas how to play with the DC signal, would that be in the autodetect code, and what would I set it to? Then I went ahead with: // #define LGFX_ESP32_S3_BOX_V3 // Espressif ESP32-S3-BOX
#define LGFX_AUTODETECT and its still working ok, I saw a couple of extra lines in the logs, not sure why it tries to initialise I2C with SDA=12, SCL=11.
A couple of comments: I hear you about technical debt, but what about the red touch button below the screen? It would be similar to the M5Unified Core2 three red buttons below the display area. I haven't had a chance to calibrate the screen, so I can't confirm if this number actually works. Might be best to revert that y_max=239.
|
yes ^^ I'll update the develop branch with the original
switching from 16MHz to 15MHz made a difference on M5StickCPlus, the M5StickC even needs to go down to 14MHz, but since it works with the S3box at 16MHz there's no need to change that
since the
that's 7/6th of the panel height, if you believe it should be more you can still set a higher value, but the finger/panel proportion is valid with the M5Core2 and the panel size seems to match the s3box wether it should be enabled or not has been subject to many discussions (e.g. lvgl wants absolute data but users may want to implement 3 buttons instead of 1), and the conclusion is that it doesn't hurt to enable it since there's still access to the raw data and the calibration can be changed after init thanks for your suggestions 👍 |
Thanks for all your help here @tobozo. Do you need anything more from me? I'll probably investigate getting the red touch button to work this week, but I guess you can do a PR before that. |
I'm not sure when the next release will be published, some other unrelated tasks may need to be achieved before the develop branch is merged with the master but I've ordered a esp32-s3box-3b so hopefully in a few weeks I'll be able to investigate that red button too 🤞 |
Hi again, I ran the user calibration routine I found in the example lcd.init();
// タッチが使用可能な場合のキャリブレーションを行います。(省略可)
if (lcd.touch()) {
if (lcd.width() < lcd.height()) lcd.setRotation(lcd.getRotation() ^ 1);
// 画面に案内文章を描画します。
lcd.setTextDatum(textdatum_t::middle_center);
lcd.drawString("touch the arrow marker.", lcd.width() >> 1, lcd.height() >> 1);
lcd.setTextDatum(textdatum_t::top_left);
// タッチを使用する場合、キャリブレーションを行います。画面の四隅に表示される矢印の先端を順にタッチしてください。
std::uint16_t fg = TFT_WHITE;
std::uint16_t bg = TFT_BLACK;
if (lcd.isEPD()) std::swap(fg, bg);
uint16_t calibrationData[8];
lcd.calibrateTouch(calibrationData, fg, bg, std::max(lcd.width(), lcd.height()) >> 3);
for (int i = 0; i < 8; i++) {
Serial.print(calibrationData[i]);
Serial.print(", ");
}
} This code returns these numbers:
I'm not quite sure what's happening under the hood with calibration. Is it run once, and these numbers get saved to EEPROM and read back at startup? Or am I expecting too much, and I should write them to EEPROM and then read them back at startup and somehow set the calibration? In any case, now when I tap the very top edge of the LCD I see y=-9, and the very bottom of the LCD (not as low down as red button) I see 240. I get no response when I tap the red button. Left and right seem a bit out too, left=-20, right=326. There is no difference between I know this is probably beyond the scope of this issue, so maybe we leave it here, and you can look into it when your unit arrives. |
those numbers look normal, the values offsets are caused by the finger not touching the exact corner maybe?
if I round up the values to the closest corner, the calibration data is:
the gt911 will pretend multitouch is happening whenever one of the (up to) 4 buttons outside the panel area is touched void loop()
{
std::int32_t x, y, number = 0;
while (display.getTouch(&x, &y, number))
{
Serial.printf("index=%d, x=%d, y=%d", number, x, y); Serial.println();
++number;
}
} according to the esphome gt911 documentation (which is a different driver) the index value for the red button should be 0 you can confirm the behaviour of LGFX's gt911 driver is the same by comparing the index when you touch the middle of the screen, and the index when you touch the red button [edit] Touch_GT911 has an extra method, could you try this in the autodetect block, before t->setTouchNums(2); the argument value can be 1, 2, 3, 4 or 5, my guess is it's defaulting to 1 |
ok I tried the above, index is only > 0 on multi-touch, e.g. two fingers and index == 1. Pressing the red button still results in nothing unfortunately. |
I've been searching through espressif labyrinthic codebase and got lost 🤣 the GT911 supports custom configs, so that's probably the angle to consider when comparing with working examples I'm out of ideas so I'll wait for my s3box unit to be delivered before investigating further btw the develop branch has been merged with the master branch, incoming new release :-) |
thanks for trying. I tried that too, labyrinthic is the word. Shall we close this issue now? I can keep an eye on the release notes to see if you ever solve the red button! |
if it works with M5Core2, it's legitimate to expect support for S3Box; let's keep the issue open until this red button mystery is solved |
hi, I received the S3Box v3 and already found a few design defects, it seems that espressif was well inspired to acquire M5Stack as they have a lot to learn from them :-)
a more in-depth analysis of |
progress: managed to get 0x8093 reg data to be processed when available but I broke multitouch support I created a dedicated branch and pushed the changes. Whenever the red button is pushed, the using lgfx::touch_point_t tp;
auto tpPtr = &tp;
auto number = lcd.getTouchRaw(tpPtr, 5);
if (number > 0)
{
for( int i=0;i<number;i++)
{
Serial.printf("[%d] x=%d, y=%d\n", i, tpPtr[i].x, tpPtr[i].y);
if( tpPtr[i].y<0 || tpPtr[i].y>lcd.height() )
lcd.clear();
else
lcd.fillCircle(tpPtr[i].x, tpPtr[i].y, 5, TFT_RED );
}
} using std::int32_t x, y, number = 0;
while (lcd.getTouch(&x, &y, number))
{
Serial.printf("index=%d, x=%d, y=%d\n", number, x, y);
if( y<0 || y>lcd.height() )
lcd.clear();
else
lcd.fillCircle(x, y, 5, TFT_RED );
++number;
} |
I have not tried this, but is disappointing
Agree, I should have mentioned this, I thought the buttons were broken when I first pressed them
I used my own for this reason
Agree again, M5 Stack do design better. |
I have moved on and decided to use a different ESP32-S3 for my current project (Xiao, no LCD 😲), and am in the thick of coding for it, but when I get a chance, I will try your branch re red button touch - thanks |
Hi there,
I see the library has support for ESP32-S3-BOX, however this is no longer in production and has been superseded by the ESP32-BOX-S3-3 (an overly long model number, note the "-3" suffix).
Please see here https://github.com/espressif/esp-box/tree/master

The device currently supported by your library has, I think, the same SPI pinout, but LCD backlight is on GPIO47 vs GPIO45 for the S3-BOX, hence selecting AUTODETECT or specifying
Compiles ok, but nothing is displayed on the LCD.

The pinout is on the schematic here https://github.com/espressif/esp-box/blob/master/hardware/SCH_ESP32-S3-BOX-3_V1.0/SCH_ESP32-S3-BOX-3-MB_V1.1_20230808.pdf
The LCD backlight control is on GPIO47.


Thanks for your assistance.
The text was updated successfully, but these errors were encountered: