It is currently Wed Jul 06, 2011 8:12 pm

All times are UTC - 8 hours




 Page 1 of 1 [ 2 posts ] 
Author Message
 Post subject: Util - polite_buzz()
PostPosted: Tue Apr 19, 2011 2:24 pm 

Joined: Wed Mar 23, 2011 9:35 am
Posts: 54
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();
}


Offline
 Profile  
 
 Post subject: Re: Util - polite_buzz()
PostPosted: Tue Apr 19, 2011 5:35 pm 
User avatar

Joined: Mon Feb 14, 2011 7:07 pm
Posts: 172
Smart! Then you can resist being distracted all those work emails outside of the appropriate hours of the day. Cool stuff.



_________________
---

Lead designer of inPulse
Offline
 Profile  
 
Display posts from previous:  Sort by  
 Page 1 of 1 [ 2 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: