Skip to content

Instantly share code, notes, and snippets.

@reefwing
Created December 12, 2022 06:36
Show Gist options
  • Select an option

  • Save reefwing/5983c267e833489d377e8110adfda1e1 to your computer and use it in GitHub Desktop.

Select an option

Save reefwing/5983c267e833489d377e8110adfda1e1 to your computer and use it in GitHub Desktop.
TWatch-2020 RTC Alarm Example
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