galoebn
Published © LGPL

TTGO T-Watch touch tutorial

In this tutorial I show you how to use the touch detection on the TTGO T-Watch

BeginnerProtip1 hour599
TTGO T-Watch touch tutorial

Things used in this project

Hardware components

LILYGO TTGO T-Watch
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

This project does not need schematics

Code

Code

Arduino
#define LILYGO_WATCH_2020_V2
#include <LilyGoWatch.h>
#include <soc/rtc.h>

TTGOClass *ttgo;

void setup(){
  ttgo = TTGOClass::getWatch();
  ttgo->begin();
  ttgo->tft->setTextFont(8);
  ttgo->tft->fillScreen(TFT_BLACK);
  ttgo->tft->setTextColor(TFT_WHITE, TFT_BLACK);
  ttgo->openBL();
}


int count = 0;
int16_t x,y;

void loop(){
  ttgo->tft->setCursor(50, 80);
  ttgo->tft->print(count);

  while(!ttgo->getTouch(x,y)){}
  unsigned long t = millis();

  int y0 = y;
  
  while(ttgo->getTouch(x,y)){
     if(millis() - t > 1000){
        count = -1;
        ttgo->tft->fillScreen(TFT_BLACK);
     }
  }

  if(y0 - y > 50){
    count += 10;
  }

  count += 1;
}

Credits

galoebn
9 projects • 4 followers
Contact

Comments

Please log in or sign up to comment.