forum.getinpulse.com
http://www.getinpulse.com/hack/forum/

Util - polite_buzz()
http://www.getinpulse.com/hack/forum/viewtopic.php?f=6&t=240
Page 1 of 1

Author:  MonkeyEnFuego [ Tue Apr 19, 2011 2:24 pm ]
Post subject:  Util - polite_buzz()

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();
}

Author:  Eric [ Tue Apr 19, 2011 5:35 pm ]
Post subject:  Re: Util - polite_buzz()

Smart! Then you can resist being distracted all those work emails outside of the appropriate hours of the day. Cool stuff.

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/