Wednesday, March 16, 2011

Developing for the Chumby

Technorati Tags:

I just bought a Chumby One and of course I have to learn how to write a widget for it. I was getting a bit frustrated with not finding a complete step by step guide. I was able to find information from various places and put it all together to figure out how to write these Flash Widgets. To make matters a bit more complicated, I do not own, nor have access to any of the Adobe editors so I needed a freeware solution. This does limit you when it comes to the examples posted online as many of them are in fla file format which is of no use unless you have an Adobe Flash editor.

Environment

I am running Windows 7 (64 bit) so if you are on a Mac or Linux this may be of little use. I may try to create widgets in Ubuntu at some point. If I do, I will add a similar post.

You will need the following software installed before going into the Hello World example.

  • FlashDevelop is an open source editor for ActionScript 2 & 3.1
  • Flash Player 10.1 ActiveX runtime (required by the browser control) 2
  • Java 1.6 runtime (JRE) (required if using the Flex SDK) Flex SDK Download 2
  • Chumby Template for FlashDevelop by Raff 2 Follow the directions in the readme file as to where to copy the files.
  • A SSH Client such as PuTTY. PuTTY is a free Telnet/SSH Client for Windows.

 

Hello World

Once the environment is setup the next thing is to create a Hello World application to help become familiar with the development process. I found a very good example at http://wiki.chumby.com/mediawiki/index.php/FlashDevelop/Example. There are a few things which are not spelled out and caused me a bit of a problem. The following instructions are copied from the site. I have made a few modifications and added some screen shots.

Prerequisites 3

I made the mistake of not paying attention to these and later when told to use SSH, I connected a USB Hub to the Chumby and connected the thumbdrive and a keyboard. Everything was fine until I attempted to run the application. It was also very difficult to read the text on the small screen.

Create a New Project 3

  • Start FlashDevelop
  • Click on Project –> New Project
    05FlashDevelopNewProject
  • Select the ActionScript2 –> Chumby project template
    NOTE: If the Chumby Project is not shown then you did not copy Raff’s template in the correct location.
    06FlashDevelopChumbyProject
  • Give this project a name "Hello World", and check the "create directory for project" check box.

This will give you a Project pane on the right side, with bin and src folders. 07FlashDevelopIDE

Write Your Program 3

  • Open the Main.as file, located in the src folder, on in the right pane
  • Write the Hello world program as follows:
    class Main
    {
    public static function main():Void
    {
    _root.createTextField("t",2,20,20,100,30);
    _root.t.text = "Hello, world!";
    }
    }

Test your program in FlashDevelop 3

  • Click on Project->Test Movie (or F5)
  • A new page will open with your Hello World program running. Note the "Hello World.swf" tab. You have just created your first swf file!
    08TestFlashDevelop

Test your program on your Chumby 3 

  • Copy the HelloWorld.swf file from the bin folder to the root of the flash drive then plug the flash drive into your Chumby
  • Open the SSH Client such as PuTTY to connect to the Chumby
    09PuTTY
  • Once connected, login as root. Note, there is no password for the root account.
    10PuTTYWindow
  • Once you are logged in, you will see the Chumby Mascot
    11LoggedIn
  • Stop the current Chumby flash player
    chumby:~# stop_control_panel
    *** stopping control panel
    *** killing registered flashplayer pid: 1821
    Adobe FlashLite 3.1.7 Release (Version 9,1,122,0)- Chumby Industries (version 9 build 115-3412 [GCC 4.3.2])
    Portions copyright (C) 2005-2010 Chumby Industries, Inc.
    Built for: falconwing; Features: Video ALSA ARM-optimizations
    Build time: Wed 29Sep2010 1833
    chumbyflashplayer.x: sending signal 15 (SIGTERM) to running instance 1821
    chumbyflashplayer.x: retry #1, signalling process 1821 again
    chumbyflashplayer.x: registered instance 1821 appears to have terminated
    btplay client v1.4.1.38.50
    Connected to btplayd instance 1820
    Got response: OK 100 quit
    Matched request 100
    Waiting 500ms for process to terminate
    Continuing...
    *** killing btplayd (SIGTERM): 24335
    *** killing btplayd (SIGKILL): 24335
    chumby:~#
    

  • Run your program
    chumby:~# chumbyflashplayer.x -i /mnt/usb/HelloWorld.swf
    Adobe FlashLite 3.1.7 Release (Version 9,1,122,0)- Chumby Industries (version 9 build 115-3412 [GCC 4.3.2])
    Portions copyright (C) 2005-2010 Chumby Industries, Inc.
    Built for: falconwing; Features: Video ALSA ARM-optimizations
    Build time: Wed 29Sep2010 1833
    2011-03-17 00:06:16 OpenSoundOutputSync(): shm_open(/aplaypipe-shm) failed errno=2 (No such file or directory)Playback device is default
    Stream parameters are 44100Hz, S16_LE, 2 channels
    2011-03-17 00:06:16 TRACE: preload.swf v1.02
    2011-03-17 00:06:16 BtPlayObject::StartBtplay() - LaunchDaemon() call response timed out
    2011-03-17 00:06:16 ChumbyPipeObject::FindByRequest(103) failed - no find amongst 2 entries!
    ...

  • Confirm your program is running on your chumby!
    12RunningOnChumby
  • Use ctrl-C to exit the player.
    ^C2011-03-17 00:06:19 chumbySignalHandler(2) SIGINT - requested termination
    2011-03-17 00:06:20 ChumbyVidStats::RuntimeCleanup(): 0 sessions started, 0 cancelled, originating pid=24967, last reporting pid=0
    2011-03-17 00:06:20 chumbySignalHandler(13) SIGPIPE received, new count = 1
    2011-03-17 00:06:20 err[11]: 2011-03-17 00:06:19 chumbySignalHandler(2) SIGINT - requested termination
    
    2011-03-17 00:06:20 err[12]: 2011-03-17 00:06:20 chumbySignalHandler(13) SIGPIPE received, new count = 1
    
    2011-03-17 00:06:20 Exiting _chumby_flashplayer_version=317.9.00115-3412
    2011-03-17 00:06:20 Start time: 2011-03-17 00:06:16
    2011-03-17 00:06:20 End time  : 2011-03-17 00:06:20
    2011-03-17 00:06:20 Elapsed   : 4s (4)
    2011-03-17 00:06:20 main() - closing and deleting pid file /var/run/chumbyflashplayer.pid
    2011-03-17 00:06:20 chumbyflashplayer main() - exiting, return code 0
    chumby:~#

  • Restart your Chumby to restore to normal operations OR to restart Chumby flashplayer:-
    chumby:~# start_control_panel
    --00:10:49--  http://www.chumby.com/crossdomain.xml
    => `/dev/null'
    Resolving www.chumby.com... 69.43.206.45
    Connecting to www.chumby.com|69.43.206.45|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 272 [application/xml]
    
    100%[====================================>] 272           --.--K/s
    
    00:10:49 (1.66 MB/s) - `/dev/null' saved [272/272]
    
    imgtool 1.22 (built for falconwing)
    Filling with r,g,b 0,0,0 (0x00000000)
    Opening output /dev/fb0 fmt=0
    fb handle = 3
    Filled with 0x0, no image to load, exiting
    imgtool 1.22 (built for falconwing)
    Filling with r,g,b 0,0,0 (0x00000000)
    Opening output /dev/fb1 fmt=1
    fb handle = 3
    Filled with 0x0, no image to load, exiting
    Starting btplay daemon
    Adobe FlashLite 3.1.7 Release (Version 9,1,122,0)- Chumby Industries (version 9 build 115-3412 [GCC 4.3.2])
    Portions copyright (C) 2005-2010 Chumby Industries, Inc.
    Built for: falconwing; Features: Video ALSA ARM-optimizations
    ...

Alternate Testing on your Chumby 4

  • Create a jpg thumbnail for your widget. The thumbnail should be 80 pixels wide and 80 pixels high. Name your image “HelloWorld.jpg”.
     HelloWorld
  • Create a file named profile.xml and paste the following contents. You may edit this file in case your assembly or thumbnail file are named differently or you wish to name your widget something else.
    <profile>
    <widget_instances>
    <widget_instance id="1">
    <name>Hello World</name>
    <widget>
    <name>Hello World</name>
    <description>This is my Hello World widget</description>
    <version>1.0</version>
    <mode time="10" mode="timeout"/>
    <access sendable="false" deleteable="false" access="private" virtualable="false"/>
    <user username="myusername"/>
    <thumbnail href="file:////mnt/usb/HelloWorld.jpg" contenttype="image/jpeg"/>
    <movie href="file:////mnt/usb/HelloWorld.swf" contenttype="application/x-shockwave-flash"/>
    </widget>
    <access access="private"/>
    <mode time="5" mode="timeout"/>
    <widget_parameters>
    <widget_parameter>
    <name>zipcode</name>
    <value>90210</value>
    </widget_parameter>
    <widget_parameter>
    <name>phonenumber</name>
    <value>867-5309</value>
    </widget_parameter>
    </widget_parameters>
    </widget_instance>
    </widget_instances>
    </profile>

  • Copy the three files to the root of the thumbdrive
    • HelloWorld.jpg
    • HelloWorld.swf
    • profile.xml

  • Reboot the Chumby with the USB Thumbdrive still attached

References

  1. FlashDevelop - ChumbyWiki, http://wiki.chumby.com/mediawiki/index.php/FlashDevelop
  2. Installation – FlashDevelop, http://www.flashdevelop.org/wikidocs/index.php?title=Installation
  3. FlashDevelop/Example – ChumbyWiki, http://wiki.chumby.com/mediawiki/index.php/FlashDevelop/Example
  4. Chumby tricks – ChumbyWiki, http://wiki.chumby.com/mediawiki/index.php/Chumby_tricks#Mixing_local_widgets_into_a_channel

No comments:

Post a Comment