Xinyuan-LilyGO / T-Watch-2021

MIT License
84 stars 18 forks source link

WakeFromMotionSensor not working #10

Closed Dj-EKI closed 1 year ago

Dj-EKI commented 1 year ago

T-Watch 2021 v1.0 Arduino 2.1.0

On the display I only see the text up to "Singel / Do". Sometimes the "o" has an odd character. After that it just shuts down and restarts.

#include <Arduino.h>
#include <TWatch_hal.h>
//"TWatch_config.h" needs to be configured in the library for the first time
// This routine needs to annotate the LVGL GUI

/*
T-Watch-2021-V1.0:  This version of the alarm clock and motion sensor use independent GPIO, no alarm interrupt pin
*/

/*
T-Watch-2021-V1.2:  Since the ESP32 pins are not enough, the interrupts of the alarm clock,
                    touch, and motion sensor are concentrated in the "TWATCH_AIO_INT" pin,
                    so the reason for the wake-up is all the external trigger "TWATCH_AIO_INT" to wake up.
*/

TWatchClass *twatch = nullptr;
TFT_eSPI *tft = nullptr;

char buf[128];

void print_wakeup_reason() {
  esp_sleep_wakeup_cause_t wakeup_reason;

  wakeup_reason = esp_sleep_get_wakeup_cause();
  tft->setTextColor(TFT_GREEN, TFT_BLACK);
  switch (wakeup_reason) {
  case ESP_SLEEP_WAKEUP_EXT0:
    Serial.println("Wakeup caused by external signal using RTC_IO");
    tft->drawString("Wakeup caused by", 20, 144);
    tft->drawString("external signal using RTC_IO", 20, 162);
    break;
  case ESP_SLEEP_WAKEUP_EXT1:
    Serial.println("Wakeup caused by external signal using RTC_CNTL");
    tft->drawString("Wakeup caused by", 20, 144);
    tft->drawString("external signal using RTC_CNTL", 20, 162);
    break;
  case ESP_SLEEP_WAKEUP_TIMER:
    Serial.println("Wakeup caused by timer");
    tft->drawString("Wakeup caused by", 20, 144);
    tft->drawString(" timer", 20, 162);
    break;
  case ESP_SLEEP_WAKEUP_TOUCHPAD:
    Serial.println("Wakeup caused by touchpad");
    tft->drawString("Wakeup caused by", 20, 144);
    tft->drawString(" touchpad", 20, 162);
    break;
  case ESP_SLEEP_WAKEUP_ULP:
    Serial.println("Wakeup caused by ULP program");
    tft->drawString("Wakeup caused by ", 20, 144);
    tft->drawString("ULP program", 20, 162);
    break;
  default:
    Serial.printf("Wakeup was not caused by deep sleep: %d\n", wakeup_reason);
    break;
  }
  tft->setTextColor(TFT_WHITE, TFT_BLACK);
}

void setup() {
  twatch = TWatchClass::getWatch();
  tft = twatch->tft_get_instance();

  Serial.begin(115200);
  twatch->motor_shake(2, 50);

  tft->fillScreen(TFT_BLACK);
  twatch->backlight_set_value(255);

  Serial.println("Motion Sensor Wake Up Demo");

  twatch->hal_auto_update(true, 0);

  tft->setTextFont(2);
  tft->setTextColor(TFT_WHITE, TFT_BLACK);
  tft->drawString("Motion Sensor Wake Up Demo", 42, 90);
  tft->drawString("Enter deep sleep after 5 seconds", 10, 108);
  tft->drawString("Singel / Double tag or Wrist up", 20, 126);
  print_wakeup_reason();
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println("Start in 5 Sekunden");
  delay(5000);
  Serial.println("Sensor kalibrieren");
  twatch->bma423_feature(BMA423_WRIST_WEAR | BMA423_SINGLE_TAP | BMA423_DOUBLE_TAP | BMA423_STEP_CNTR, true);
  twatch->bma423_feature(BMA423_WRIST_WEAR_INT | BMA423_STEP_CNTR_INT | BMA423_SINGLE_TAP_INT | BMA423_DOUBLE_TAP_INT, true);
  twatch->bma423_acc_feature(true);
  twatch->bma423_feature_int(BMA423_SINGLE_TAP_INT | BMA423_DOUBLE_TAP_INT | BMA423_WRIST_WEAR_INT, true);
  Serial.println("Sleep");
  twatch->hal_sleep(true);
}
14:58:37.956 -> rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
14:58:37.956 -> configsip: 271414342, SPIWP:0xee
14:58:37.956 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
14:58:38.002 -> mode:DIO, clock div:1
14:58:38.002 -> load:0x3fff0030,len:1344
14:58:38.002 -> load:0x40078000,len:13924
14:58:38.002 -> ho 0 tail 12 room 4
14:58:38.002 -> load:0x40080400,len:3600
14:58:38.002 -> entry 0x400805f0
14:58:41.826 -> Motion Sensor Wake Up Demo
14:58:46.812 -> E (17335) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
14:58:46.812 -> E (17335) task_wdt:  - IDLE (CPU 0)
14:58:46.812 -> E (17335) task_wdt: Tasks currently running:
14:58:46.812 -> E (17335) task_wdt: CPU 0: hal_update_task
14:58:46.812 -> E (17335) task_wdt: CPU 1: loopTask
14:58:46.812 -> E (17335) task_wdt: Aborting.
14:58:46.812 -> 
14:58:46.812 -> abort() was called at PC 0x4010ec80 on core 0
14:58:46.859 -> 
14:58:46.859 -> 
14:58:46.859 -> Backtrace: 0x40083eb5:0x3ffbebbc |<-CORRUPTED
14:58:46.859 -> 
14:58:46.859 -> 
14:58:46.859 -> 
14:58:46.859 -> 
14:58:46.859 -> ELF file SHA256: 4180adf436b9cfc2
14:58:46.859 -> 
14:58:46.984 -> Rebooting...
14:58:46.984 -> ets Jul 29 2019 12:21:46
14:58:46.984 -> 
14:58:46.984 -> rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
14:58:46.984 -> configsip: 271414342, SPIWP:0xee
14:58:46.984 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
14:58:46.984 -> mode:DIO, clock div:1
14:58:46.984 -> load:0x3fff0030,len:1344
14:58:46.984 -> load:0x40078000,len:13924
14:58:46.984 -> ho 0 tail 12 room 4
14:58:46.984 -> load:0x40080400,len:3600
14:58:46.984 -> entry 0x400805f0
14:58:50.784 -> Motion Sensor Wake Up Demo

When I comment the entry "//tft->drawString("Single / Double tag or Wrist up", 20, 126);", I get this message.

15:10:57.762 -> rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
15:10:57.762 -> configsip: 271414342, SPIWP:0xee
15:10:57.762 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
15:10:57.808 -> mode:DIO, clock div:1
15:10:57.808 -> load:0x3fff0030,len:1344
15:10:57.808 -> load:0x40078000,len:13924
15:10:57.808 -> ho 0 tail 12 room 4
15:10:57.808 -> load:0x40080400,len:3600
15:10:57.808 -> entry 0x400805f0
15:11:01.616 -> Motion Sensor Wake Up Demo
15:11:01.616 -> Wakeup was not caused by deep sleep: 0
15:11:01.616 -> Start in 5 Sekunden
15:11:06.618 -> Sensor kalibrieren
15:11:06.794 -> Sleep
15:11:06.794 -> go to sleep
15:11:06.794 -> ets Jul 29 2019 12:21:46
15:11:06.794 -> 
15:11:06.794 -> rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
15:11:06.794 -> configsip: 271414342, SPIWP:0xee
15:11:06.794 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
15:11:06.794 -> mode:DIO, clock div:1
15:11:06.794 -> load:0x3fff0030,len:1344
15:11:06.794 -> load:0x40078000,len:13924
15:11:06.794 -> ho 0 tail 12 room 4
15:11:06.794 -> load:0x40080400,len:3600
15:11:06.794 -> entry 0x400805f0
15:11:10.445 -> Motion Sensor Wake Up Demo
15:11:10.445 -> Wakeup caused by external signal using RTC_IO
15:11:15.443 -> E (17204) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
15:11:15.443 -> E (17204) task_wdt:  - IDLE (CPU 0)
15:11:15.443 -> E (17204) task_wdt: Tasks currently running:
15:11:15.443 -> E (17204) task_wdt: CPU 0: hal_update_task
15:11:15.443 -> E (17204) task_wdt: CPU 1: loopTask
15:11:15.443 -> E (17204) task_wdt: Aborting.
15:11:15.443 -> 
15:11:15.443 -> abort() was called at PC 0x4010ec6c on core 0
15:11:15.489 -> 
15:11:15.489 -> 
15:11:15.489 -> Backtrace: 0x40083eb5:0x3ffbebbc |<-CORRUPTED
15:11:15.489 -> 
15:11:15.489 -> 
15:11:15.489 -> 
15:11:15.489 -> 
15:11:15.489 -> ELF file SHA256: 52d8cbdbe892d865
15:11:15.489 -> 
15:11:15.601 -> Rebooting...
15:11:15.601 -> ets Jul 29 2019 12:21:46
15:11:15.601 -> 
15:11:15.601 -> rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
15:11:15.601 -> configsip: 271414342, SPIWP:0xee
15:11:15.601 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
15:11:15.601 -> mode:DIO, clock div:1
15:11:15.647 -> load:0x3fff0030,len:1344
15:11:15.647 -> load:0x40078000,len:13924
15:11:15.647 -> ho 0 tail 12 room 4
15:11:15.647 -> load:0x40080400,len:3600
15:11:15.647 -> entry 0x400805f0
Dj-EKI commented 1 year ago

The Last Text in Green is "Wakeup ca". maybe a TFT Problem? And why does the device wake up immediately after sleeping?

EDIT: I have deaktivate lvgl and maybe works. #define CONFIG_TWATCH_APP_LVGL 0 But even with "WakeFromTouch" example, the device wakes up immediately.

15:40:22.229 -> rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
15:40:22.229 -> configsip: 271414342, SPIWP:0xee
15:40:22.229 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
15:40:22.229 -> mode:DIO, clock div:1
15:40:22.229 -> load:0x3fff0030,len:1344
15:40:22.229 -> load:0x40078000,len:13924
15:40:22.229 -> ho 0 tail 12 room 4
15:40:22.229 -> load:0x40080400,len:3600
15:40:22.229 -> entry 0x400805f0
15:40:25.845 -> Touch Wake Up Demo
15:40:25.845 -> Wakeup caused by external signal using RTC_IO
15:40:30.852 -> go to sleep
15:40:30.852 -> ets Jul 29 2019 12:21:46
Dj-EKI commented 1 year ago

Sorry for the spam. Now I just tried version 1.2 because of the changed interrupt pins and everything works. I received an old manual for my device. So I thought it was version 1.0.