Wednesday, January 26, 2011

Coop Door Code Update Success!

Firstly, a thank-you to Brian, who commented on my last post.  I had a very detailed reply, but commenting on Blogspot seems to be borked for me.  I'll try to answer some of your questions at some point in time if I get commenting fixed.

Now, on to the progress...    I finally implemented sunrise/sunset time-offsetting for the door.  If I enable either sunrise or sunset offsetting, the door-open time becomes a base time, and then the controller checks the day-of-year, and does a table-lookup to obtain the offset in minutes.  It adds the offset to the door-open time, and subtracts the offset from the door-close time.  Now the Winter Solstice has passed, the days are starting to get longer again, so I got this in place just in time.

I also gutted the code that checks to see if it's time to open or close the door and made it a lot simpler.

Lastly, and this was probably the biggest "bugfix", I added some "keepalive" code to the WiFi connection.  Before, if the connection dropped, the BlackWidow board wouldn't do anything to reconnect.  I would have to go out and reboot the controller in order to get it talking to the network again.   To fix this, I added a method to the WiShield object that returns the WiFi connection status.  The webserver checks this periodically and re-inits the WiFi connection if it is down.