Thought I would share a little idea. I have a watch app that I want to buzz on the hour and half hour, and eventually buzz for things like calls/sms/etc. But, I have always hated that smartphones don't take the time of day into consideration when buzzing. That is why I wrote a simple function polite_buzz() that just does a time check before actually vibrating the watch. For me, that is before 8am and after 10pm. Also, I wanted to account for the case of the time not being set.
Thanks
static struct pulse_time_tm current_time; // This gets set elsewhere in code
void buzz () {
pulse_vibe_on();
pulse_mdelay(100);
pulse_vibe_off();
}
void polite_buzz () {
// We are confused and must have lost power with no time set
if (current_time.tm_year < 100) return;
// If it is before 8am or after 10pm, shhh!
if (current_time.tm_hour < 8 || current_time.tm_hour >= 22) return;
// Otherwise we are good to go
buzz();
}