Xinyuan-LilyGO / TTGO_TWatch_Library

MIT License
855 stars 282 forks source link

Need help with T-Watch 2020 V1 TFT_ESPI PLATFORM IO #215

Open 2ant opened 7 months ago

2ant commented 7 months ago

Hi, i desperately need help, I'm trying to use the last version of tft_espi library with my watch.

I'm using Platform IO, I installed the ttgo library but the version of tft_espi in it is too old si I installed it separately but I'm having trouble finding how to make it work.

After a while i found this :

#if !defined(EXTERNAL_TFT_ESPI_LIBRARY)
    #if defined(LILYGO_WATCH_HAS_DISPLAY) || defined(LILYGO_EINK_TOUCHSCREEN) || defined(LILYGO_WATCH_HAS_EINK)
        #include "libraries/TFT_eSPI/TFT_eSPI.h"
        #include "libraries/U8g2_for_Adafruit_GFX/src/U8g2_for_Adafruit_GFX.h"
    #endif
    #else // EXTERNAL_TFT_ESPI_LIBRARY
        #include <TFT_eSPI.h>
#endif /*EXTERNAL_TFT_ESPI_LIBRARY*/

I added the flag in my config.h file :

#define LILYGO_WATCH_2020_V1              // Use T-Watch2020

#define LILYGO_WATCH_LVGL

#define EXTERNAL_TFT_ESPI_LIBRARY

#include <LilyGoWatch.h>

#include "icones.h" 

#include "esp_sleep.h"

I chose the right user setup in the newer tft_espi library and then tested a simple code that works :

#include <Arduino.h>

#include "config.h"     

#include <TFT_eSPI.h> 
#include <SPI.h>

TFT_eSPI tft = TFT_eSPI();
TFT_eSprite spr(&tft), spr1(&tft);

TTGOClass *ttgo; 

void setup() 
{

  Serial.begin(115200);

  Serial.println("start");

  ttgo = TTGOClass::getWatch();
  ttgo->begin();     
  ttgo->openBL();
  ttgo->bl->adjust(255);

  tft.init();

  tft.setRotation(2);

  tft.fillScreen(TFT_BLUE);

}

void loop()
{

}

I then tried a simple code to test screen + touch :

#include <Arduino.h>

#include "config.h"     

#include <TFT_eSPI.h> 
#include <SPI.h>

TFT_eSPI tft = TFT_eSPI();
TFT_eSprite spr(&tft), spr1(&tft);

TTGOClass *ttgo; 

char buf[128];

void setup() {

  Serial.begin(115200);

  Serial.println("start");

  ttgo = TTGOClass::getWatch();
  ttgo->begin();     
  ttgo->openBL();
  ttgo->bl->adjust(255);

  tft.init();

  tft.setRotation(2);

  tft.fillScreen(TFT_RED);

  tft.setTextFont(2);
  tft.setTextColor(TFT_WHITE, TFT_BLACK);
  tft.drawString("T-Watch Touch Test", 62, 90);

}

void loop()
{
  int16_t x, y;
    if (ttgo->getTouch(x, y)) {
        tft.drawString("Touch detected", 62, 90);
        sprintf(buf, "x:%03d  y:%03d", x, y);
        tft.drawString(buf, 80, 118);
    }
    delay(5);

}

I get a red screen with text but when I touch it the watch reboots.

I get this in my VS Code terminal :

Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.

Core  1 register dump:
PC      : 0x400ff1a7  PS      : 0x00060830  A0      : 0x800d1f9c  A1      : 0x3ffc5eb0
A2      : 0x00000000  A3      : 0x3ffc5edc  A4      : 0x3ffc5ede  A5      : 0x0000005a
A6      : 0x3f400268  A7      : 0x00000001  A8      : 0x00000060  A9      : 0x00000060
A10     : 0x00000001  A11     : 0x00000005  A12     : 0x3ffc5eab  A13     : 0x00000001
A14     : 0x400fe988  A15     : 0x3ffc2034  SAR     : 0x00000005  EXCCAUSE: 0x0000001c  
EXCVADDR: 0x0000001f  LBEG    : 0x40087780  LEND    : 0x40087796  LCOUNT  : 0xffffffff

Backtrace: 0x400ff1a4:0x3ffc5eb0 0x400d1f99:0x3ffc5ed0 0x400db391:0x3ffc5f00

ELF file SHA256: 9eb3bcf6dab25a87

Rebooting...
ets Jul 29 2019 12:21:46

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1184
load:0x40078000,len:13232
load:0x40080400,len:3028
entry 0x400805e4
start
[   489][E][TTGO.h:1213] initTFT(): TFT Handler is NULL!!!
[   489][E][TTGO.h:1341] initTouch(): Begin touch ok

Any help is welcome.