sharandac / My-TTGO-Watch

A GUI named hedge for smartwatch like devices based on ESP32. Currently support for T-Watch2020 (V1,V2,V3), T-Watch2021, M5Paper, M5Core2 and native Linux support for testing.
GNU General Public License v2.0
524 stars 246 forks source link

Help with Time Function #338

Closed Crsarmv7l closed 2 years ago

Crsarmv7l commented 2 years ago

Hi, Hoping for some help with a simple timer function.I took a look through time.h and timesync, tried to implement and figure a method but ended up very confused. Seems like most time stuff is relative to something else, which makes sense but also makes it confusing.

I would like to create a timer function that simply executes another function after say 25 minutes. Appreciate any direction for implementation

Crsarmv7l commented 2 years ago

Closing. The below section of the alarm app and the timestamp function in bluetooth_messages helped me understand how to implement what I wanted.

static bool is_alarm_time(){
    time_t now;
    struct tm time_tm;
    time( &now );
    localtime_r( &now, &time_tm );
    return time_tm.tm_hour == rtcctl_get_alarm_data()->hour && time_tm.tm_min == rtcctl_get_alarm_data()->minute;
}