Quite happy with this flow I wrote that automatically adds a task in Todoist to replace a sensor’s battery when it’s low.
One of the coolest things announced at this year’s Google I/O was the Android Open Accessory Kit, which allows Android devices to interact with accessories over USB. As an attendee, I received the Arduino-based ADK DemoKit board, which I’ve used to build an app to monitor my Aerogarden.
The garden monitor project was built with the following components:
- Arduino-based Open Accessory Kit
- LM34DZ temperature sensor
- HS1101 humidity sensor
- 0.5″ force sensing resistor
- Analog servo
The force sensing resistor is mounted below the Aerogarden’s water tank to measure the weight of the water, and the servo is used to open and close the tank door.
The Arduino firmware reads the values from the temperature, humidity, and force sensors and sends them to the attached Android device over USB using the Open Accessory protocol. It also accepts commands over USB from the Android app to open and close the door.
The Android app reads the sensor data from the Arduino and broadcasts them over the wifi network using xPL so they can be monitored by MisterHouse, which can alert me via email and text-to-speech when the water level is low. When the water level is below 20%, the app signals the Arduino to open the door as a visual indicator that the tank needs to be refilled. After the tank is filled, the app automatically closes the door again. The app also snaps a photo every hour, which I’ve used to create the time lapse video below.
The source code for the Arduino sketch and the Android app are available on github.
This video was created by combining the hourly snapshots taken by the Nexus One using ffmpeg and then edited in iMovie ’09.
One of the great new user-facing features of Android 2.0 is the is the new Facebook app, which brings your Facebook contacts and statuses into your Android contacts database:
So, how exactly does my Nexus One know that Chris is excited about the upcoming launch of his new mobile apps? The answer is a Contacts sync provider in the Facebook app. Read on to learn how to create your own!
One of the highlights of the Android 2.0 SDK is that you can write custom sync providers to integrate with the system contacts, calendars, etc. The only problem is that there’s very little documentation on how it all fits together. And worse, if you mess up in certain places, the Android system will crash and reboot! Always up for a challenge, I’ve navigated through the sparse documentation, vague mailing list posts, and the Android source code itself to build a sync provider for our Last.fm app. Want to know how to build your own? Read on!
ZZT-OOP is fine for simple scripts, but it’s very dated and not very powerful. Starting with DreamZZT 3.2, another scripting language will be available in addition to ZZT-OOP: Lua 5.0. Lua supports functions, variables, and file access, among other things.
Creating a Lua object using a 3rd party editor is as simple as creating a ZZT-OOP object that executes “#become lua”. DreamZZT will then run everything past that line as a Lua script instead of ZZT-OOP. Of course, if DreamZZT ever gets a text editor, or if someone adds the Lua object type to KevEdit, you’ll be able to create Lua objects directly.
Here’s a simple example of using Lua from within DreamZZT:
@Luatest #become lua function main() wait_for_message("touch") set_msg("Here, the player, have some health") zzt.status.give_health(20) end
And a more advanced example that handles more than one message:
@Luatest #become lua function main() local msg = nil local them = nil while true do while (msg == nil) do coroutine.yield() them,msg = pop_message(me) end if(msg == "shot") then set_msg("Ouch! I was shot by a " .. them.name .. "!") end if(msg == "touch") then set_msg("That's my purse! I don't know you!") end end end
Note that you must call coroutine.yield() inside your loop to pass control from your script back to the game engine. The set_msg(), move() and wait_for_message() functions automatically call coroutine.yield() for you. Also note that the Lua implementation is using a message queue, so you don’t have to worry about locking and unlocking your objects like you do with ZZT-OOP.
For a more complex example, I’ve rewritten the DremZZT Tutorial in Lua, which you can view here. You can compare it to the original ZZT-OOP code to get an idea of what the new functions do. You’ll also notice that Lua has full access to the TUIWindow class, so you’ll be able to use text entry fields, check boxes, etc. from inside your games.
The Lua interpreter and updated tutorial are in the svn trunk, however saved games containing Lua objects created on PowerPC Macs are not compatible with other platforms and vice versa, due to how that CPU stores data. This issue will be resolved eventually, but right now just don’t transfer saves between PowerPC Macs and the rest of the world 🙂 For information on checking out and building DreamZZT from svn, see Building DreamZZT from Source.
Introducing the MythTV Upcoming Recordings widget:
This widget will connect to your MythTV backend server and display the list of upcoming scheduled recordings. It requires a MythTV backend server configured to accept network connections.
You csn download it from the MythTV Upcoming Recordings page.
I’ve started working on a dashboard widget to display the upcoming recordings on a MythTV backend server:
I’ll post it for download once I finish styling it. As a side note, creating widgets with DashCode is amazingly easy. Writing the Cocoa plugin to connect to the MythTV server, on the other hand, was a pain.
I’ve added a few improvements to the flickr post script, as demonstrated in the previous entry. Posts now get tagged with the Flickr photo’s tags as well as the “photos” tag, and it adds a copyright notice (depending on the license of the photo on flickr) to the end of the posts. I also updated it to work with the latest version of the phpFlickr library.
Yay! My second script fired off properly, too! Every Sunday at midnight, my box will post my StumbleUpon favorites. The StumbleUpon RSS feed doesn’t provide the date or time, so the script is keeping track of what was posted the week before and only posting new favorites. Since it’s never been run before, today’s list probably spans a bit longer than a week.
I wish Netflix had a way to retrieve the star ratings for movies I’ve rented. I was considering setting up a monthly “movies I’ve watched” script, too, but it’s a bit impersonal without the ratings I’ve assigned, and I’m too lazy to compile it myself.
I might set one up that posts when I complete a goal on 43things, but I haven’t really been using that much. Maybe I’d use it more if they published their data as an ics file, so I could view my goals on my iCal todo list. Though, I suppose I could write that, too…