mirror of
https://github.com/Xinyuan-LilyGO/TTGO_TWatch_Library.git
synced 2026-03-03 14:54:08 +01:00
42 lines
930 B
C++
42 lines
930 B
C++
|
|
#include <TTGO.h>
|
|
|
|
TTGOClass *ttgo;
|
|
|
|
void pressed()
|
|
{
|
|
uint16_t color = random(0xFFFF);
|
|
ttgo->eTFT->fillScreen(color);
|
|
ttgo->eTFT->setTextColor(color, TFT_WHITE);
|
|
ttgo->eTFT->drawString("User Button pressed", 5, 100, 4);
|
|
}
|
|
void released()
|
|
{
|
|
uint16_t color = random(0xFFFF);
|
|
ttgo->eTFT->fillScreen(color);
|
|
ttgo->eTFT->setTextColor(color, TFT_WHITE);
|
|
ttgo->eTFT->drawString("User Button released", 5, 100, 4);
|
|
}
|
|
|
|
void setup()
|
|
{
|
|
Serial.begin(115200);
|
|
ttgo = TTGOClass::getWatch();
|
|
ttgo->begin();
|
|
ttgo->openBL();
|
|
|
|
ttgo->eTFT->fillScreen(TFT_BLACK);
|
|
ttgo->eTFT->setTextColor(TFT_WHITE, TFT_BLACK);
|
|
ttgo->eTFT->setTextFont(4);
|
|
ttgo->eTFT->drawString("User Button released", 5, 100, 4);
|
|
|
|
ttgo->button->setPressedHandler(pressed);
|
|
ttgo->button->setReleasedHandler(released);
|
|
|
|
}
|
|
|
|
void loop()
|
|
{
|
|
ttgo->button->loop();
|
|
}
|