123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- #define LILYGO_TWATCH_2020_V1
- #include <TTGO.h>
- #define TWALI_INTERNAL
- #include "twali_system_internal.h"
- #include "twali_power.h"
- #include "twali_screen.h"
- extern "C" {
- static struct twali_system twali_system_singleton;
- static struct twali_system * twali_system_singleton_pointer = NULL;
- struct twali_power * twali_system_power(struct twali_system * s) {
- return s->power;
- }
- void twali_system_power_interrupt(void) {
- if (twali_system_singleton_pointer) {
- twali_power_interrupt(twali_system_singleton_pointer->power);
- }
- }
- struct twali_system * twali_system_make(void) {
- if (twali_system_singleton_pointer) {
- return twali_system_singleton_pointer;
- }
- twali_system_singleton.handle = TTGOClass::getWatch();
- twali_system_singleton.handle->begin();
- twali_system_singleton.handle->rtc->check();
- twali_system_singleton.handle->bl->adjust(150);
- twali_system_singleton.tft = twali_system_singleton.handle->eTFT;
- twali_system_singleton.tft->fillScreen(TFT_BLUE);
- twali_system_singleton.tft->setTextColor(TFT_WHITE, TFT_BLACK);
- twali_system_singleton.tft->setTextFont(8);
- twali_system_singleton.handle->openBL();
- twali_system_singleton.power = twali_power_make(&twali_system_singleton);
- pinMode(AXP202_INT, INPUT);
- attachInterrupt(AXP202_INT, twali_system_power_interrupt, FALLING);
- twali_system_singleton_pointer = &twali_system_singleton;
- return twali_system_singleton_pointer;
- }
- void twali_system_start(struct twali_system * s) {
- twali_power_start_task(s->power);
- }
- void twali_system_update(struct twali_system * s) {
- vTaskDelay(10000);
- }
- void twali_system_wake_up(struct twali_system *s) {
- // TODO
- }
- }
|