Created
December 12, 2022 06:36
-
-
Save reefwing/5983c267e833489d377e8110adfda1e1 to your computer and use it in GitHub Desktop.
TWatch-2020 RTC Alarm Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| TTGOClass *ttgo; | |
| bool rtcIrq = false; | |
| void setup() { | |
| ttgo = TTGOClass::getWatch(); | |
| ttgo->begin(); | |
| ttgo->openBL(); | |
| pinMode(RTC_INT_PIN, INPUT_PULLUP); | |
| attachInterrupt(RTC_INT_PIN, [] { | |
| rtcIrq = 1; | |
| }, FALLING); | |
| ttgo->rtc->disableAlarm(); | |
| ttgo->rtc->setDateTime(2020, 8, 12, 15, 0, 53); | |
| ttgo->rtc->setAlarmByMinutes(1); | |
| ttgo->rtc->enableAlarm(); | |
| } | |
| void loop() { | |
| if (rtcIrq) { | |
| rtcIrq = 0; | |
| detachInterrupt(RTC_INT_PIN); | |
| ttgo->rtc->resetAlarm(); | |
| ttgo->tft->setTextColor(TFT_WHITE, TFT_RED); | |
| ttgo->tft->drawString("RTC Alarm", 60, 118, 4); | |
| } | |
| delay(1000); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment