twali_system.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #define LILYGO_TWATCH_2020_V1
  2. #include <TTGO.h>
  3. #define TWALI_INTERNAL
  4. #include "twali_system_internal.h"
  5. #include "twali_power.h"
  6. #include "twali_screen.h"
  7. extern "C" {
  8. static struct twali_system twali_system_singleton;
  9. static struct twali_system * twali_system_singleton_pointer = NULL;
  10. struct twali_power * twali_system_power(struct twali_system * s) {
  11. return s->power;
  12. }
  13. void twali_system_power_interrupt(void) {
  14. if (twali_system_singleton_pointer) {
  15. twali_power_interrupt(twali_system_singleton_pointer->power);
  16. }
  17. }
  18. struct twali_system * twali_system_make(void) {
  19. if (twali_system_singleton_pointer) {
  20. return twali_system_singleton_pointer;
  21. }
  22. twali_system_singleton.handle = TTGOClass::getWatch();
  23. twali_system_singleton.handle->begin();
  24. twali_system_singleton.handle->rtc->check();
  25. twali_system_singleton.handle->bl->adjust(150);
  26. twali_system_singleton.tft = twali_system_singleton.handle->eTFT;
  27. twali_system_singleton.tft->fillScreen(TFT_BLUE);
  28. twali_system_singleton.tft->setTextColor(TFT_WHITE, TFT_BLACK);
  29. twali_system_singleton.tft->setTextFont(8);
  30. twali_system_singleton.handle->openBL();
  31. twali_system_singleton.power = twali_power_make(&twali_system_singleton);
  32. pinMode(AXP202_INT, INPUT);
  33. attachInterrupt(AXP202_INT, twali_system_power_interrupt, FALLING);
  34. twali_system_singleton_pointer = &twali_system_singleton;
  35. return twali_system_singleton_pointer;
  36. }
  37. void twali_system_start(struct twali_system * s) {
  38. twali_power_start_task(s->power);
  39. }
  40. void twali_system_update(struct twali_system * s) {
  41. vTaskDelay(10000);
  42. }
  43. void twali_system_wake_up(struct twali_system *s) {
  44. // TODO
  45. }
  46. }