Posts Tagged ‘Chumby’

How to Read a Binary Watch

Wednesday, August 11th, 2010

A while ago, I received a Binary watch as an anniversary gift. Since then, I frequently get asked how I read it. So let me break it down for you.

First, note the Flash app to the left. I built this for my Chumby, but the inspiration came from my watch. The main differences are that I put in a line of bits to show seconds, and I gave it the ability to show the date. Tap the watch face to view the date for five seconds. If you’re reading this, 01 The One, take some notes.
(more…)


Database access with a Chumby

Thursday, May 6th, 2010

Chumby, Database AccessIn my earlier posts, I’ve writen about writing a Chumby widget, writing a configuration widget, and accessing the accelerometer. Now we’ll look at accessing a database from a Chumby widget.

First, you’ll need to set up a database. I’ll assume you have access to a web server and know how to create a database, tables, and code to access it. I use MySQL and PHP.

You’ll also need a Chumby widget.

And to connect the two, you’ll need a crossdomain.xml file.
(more…)


Accessing the Chumby Accelerometer

Friday, March 26th, 2010

Chumby Accelerometer
Let’s take a look at the Chumby accelerometer. It’s the thing inside Chumby that tells it if it’s looking up or down, sideways, or up-side-down. It also detects sudden changes in acceleration. It’s basically an electronic inner ear. So if you shake Chumby, knock him on the side of the head, or drop him on the floor, the accelerometer will detect this and report how hard and in what direction the jolt happened. Disclaimer: I do not recommend or endorse violent behavior to Chumby, including hitting, shaking, throwing, or dropping.

If you’re familiar with Actionscript, you know that it’s pretty easy to find the position of the mouse cursor on the stage. Well, it’s also easy to get data from the accelerometer. The trick, however, is making use of it. Let’s take a look.
(more…)


Creating a Chumby Configuration Widget

Friday, February 26th, 2010

In my last post, we quickly went over Writing your first Chumby widget. This time, we’ll expand on that by adding a configuration widget.

A configuration widget is another Flash file that sets up parameters for your Chumby widget, so those settings are available when the widget loads into your Chumby. For example, perhapse you have an analog clock widget. You could create a configuration widget that allows someone to choose a color for the face of the clock, or whether or not to display the second hand. The user could choose a color and save their preferences in the Chumby database. Then, when their Chumby loads your clock widget, it would look for and download any settings for that widget.

Here’s what we’ll need:

(more…)


Writing your first Chumby widget

Monday, February 1st, 2010

tic-toc-goes-the-clockSo, you got your first Chumby and have browsed through the 1500 open source widgets, and now you’re ready to contribute to the open source community by writing your own widget. There’s lots of resources out there, so we’ll just cover the basics here.

Here’s what you need:

  • A Chumby
  • Adobe Flash or other developing environment for creating SWF files
  • An account at Chumby.com

Open up Flash. Set your size to 320 x 240 and frame rate to 12 frames per second. In Publish Settings, set the Player to Flash Player 8 and the Script to ActionScript 2.0. Chumby allows widget up to 100kb in size, which is plenty of room for code, but can get tight when working with audio and video.

For this tutorial, we’ll make an analog clock. But there are hundreds of clocks already! Yes there are, but I like to have every other widget be a clock, and I’ve only found about a dozen clocks that I really like. That is one of its primary functions, after all.

First of all, set up your assets. You’ll need three clock hands, positioned in the center of the stage, with the registration point properly set. Name them hourHand_mc, minuteHand_mc, and secondhand_mc.

OK, now the code:

onEnterFrame = function() {
	dt = new Date();
	//set hour hand
	hrs = dt.getHours()+dt.getMinutes()/60+dt.getSeconds()/3600;
	angle = hrs*30;
	if (angle!=hourHand_mc._rotation) {
		hourHand _mc._rotation = angle;
	}
	//set minute hand
	mns = dt.getMinutes()+dt.getSeconds()/60;
	angle = mns*6;
	if (angle!=minuteHand_mc._rotation) {
		minuteHand _mc._rotation = angle;
	}
	//set second hand
	scs = dt.getSeconds();
	angle = scs*6;
	if (angle!=secondHand_mc._rotation) {
		secondHand _mc._rotation = angle;
	}
}

Let’s break it down. On each frame we create a new date object. Then we get the hours of the date object. We also add in the minutes and seconds because we want the hour hand to move a tiny bit every second, not just once an hour. Next we convert the hours into degrees by multiplying by 30. (360 degrees per 12 hours makes 30 degrees per hour). Next we check if the hour hand needs to be changed. It should only be changed once every 12 frames, not every frame. Using this if statement prevents unnecessary redrawing of the screen, which can save processing time and make a widget run more smoothly. Though, you’ll probably not notice any difference in this simple example.

The minute hand and second hand go through the same process.

OK, save it, publish it, and upload it to Chumby.com, but don’t make it public yet. Add it to a channel on your chumby and try it out. You’ll undoubtedly find lots of things to tweak with your clock. Did you even give your clock a face? Maybe it needs a tick sound, or a gong on every hour. Maybe you don’t want a typical analog clock. Changing the code for a digital clock should be pretty easy.

This is a simple example, but it should get you on your way. In my next post, I’ll write about creating a configuration file, and playing with the accelerometer. (unless I forget or change my mind). Until then, make a cool clock.


I got a Chumby

Friday, January 8th, 2010

Chumby One running Pandora internet radio

Chumby One running Pandora internet radio

I knew my wife loved me when she got me a Chumby for Christmas, without really knowing what it was.  What is a Chumby you ask?  It’s hard to define, but you might call it a wifi-internet-clock-radio, with a touch screen, accelerometer, and other inputs for running and interacting with Flash-based widgets.  But in the right hands, it’s so much more.  It’s an open source linux-based playground.  Even the hardware can be tinkered with (although I’m not about to crack open the case on my new $120 toy). (more…)