testing gpio with node.js and onoff

Today was a pretty good day playing around with the Raspberry Pi. First thing I was able to do was fix my problem with the SDHC flash file system. That was fixed with fsck. See the updates from 16 February.

The second was to test the node.js module onoff. I ran the straightforward tests using my Parallax Propeller Professional Development Board. I flashed a few LEDs and pressed a button on the board simply wired into the Raspberry Pi’s GPIO header. You can see the run above.

One interesting issue seems to be the switch inputs (GPIO 18/pin 12). The switch inputs need debouncing, either in hardware or software.

But those are issues for another time, another experiment. Right now I’ve regained confidence in the overall board and its software. And for me that’s a very good thing.

latest twm configuration

My (near) final twm desktop. I promise. Desktop is tiled with a paisley grey pattern to give it a subtle texture and depth, and to make it easier on the eyes over long periods of time. It’s better than a pure black or even a pure gray color. I’m using Saddle Brown and Sienna everywhere else (those are real X11 colors). What follows is my .twmrc file, complete with comments. Yes, it’s old school (how about 20 years old school?). For the full details check the X.org twm(1) man page.

Here’s some of the features I’ve enabled so far:

  • Default icons on the title bar are gone now (via NoDefaults). I use my own icons, and now have a close window directly on the title bar.
  • The resize icon is now on the far left corner of the titlebar, the kill window on the far right. There’s also a minimize and maximize button now. This makes window control a bit more contemporary.
  • The titlebar highlight is gone (NoTitleHighlight)
  • The titlebar looks like BeOS window decorations (SqueezeTitle)
  • Cursor movement now pops the window up to the top automatically (AutoRaise)
  • Borders are much larger and the whole looks a lot like Microsoft’s Windows 8 Metro (BorderWidth 4)
  • When you move any window, the contents move as well instead of the nearly invisible outline (OpaqueMove)
  • The desktop menus make more sense, especially left mouse button click on the desktop (see screen capture above)

And here’s my .twmrc

# Modified wbeebe 16 February 2014

AutoRaise {


TitleFont "10x20"
ResizeFont "9x15"
MenuFont "10x20"
IconFont "10x20"
IconManagerFont "9x15"

BorderWidth 4
MenuBorderWidth 3
# Show window contents as you move the window. This does not
# have the same effect on resizing.
# Show the icon manager on the desktop. It's size and location
# are defined in .Xresources.

# Define which desktop applications won't have
# title bars. Remember that without a titlebar
# you can't easily close it,resize it, or iconize
# it.
NoTitle {

# Now define which cursor will appear as the the mouse
# cursor passes over different parts of the X-window
# The cursors are all part of the cursor font and can
# be displayed with the command:
# xfd -fn cursor
# The list of cursor names can be accessed by looking at
# /usr/X11R6/include/X11/cursorfont.h on Spiffy
# /usr/lpp/X11/include/X11/cursorfont.h on morgana
    Frame   "left_ptr"
    Title   "left_ptr"
    Icon    "left_ptr"
    Iconmgr "left_ptr"
    Menu    "left_ptr"
    Button  "hand"
# This hand feature moves the cursor into the center of
# a window that has been de-iconified.

# Add buttons to a window's titlebars
# First, remove the defaults from the window titlebars.
# And get rid of the annoying titlebar hightlighting effect.
TitleButtonBorderWidth 2
# I like SqueezeTitle. The titlebar only occupies as much space as needed.
# Reminds me of BeOS.
# If you want to have standard titlebars, remove or comment out this line.
# Now add our buttons.
LeftTitleButton     "~/twm/icons/resize.xbm" = f.resize
# Note that declarations are from left to right in the order they'll
# be displayed on the right upper corner.
RightTitleButton    "~/twm/icons/minimize.xbm" = f.iconify
RightTitleButton    "~/twm/icons/maximize.xbm" = f.fullzoom
RightTitleButton    "~/twm/icons/close.xbm" = f.delete

Color {
    # Colors that I've experimented with
    # 305030 - green
    # 203020 - darker green - unselected border
    # 406040 - another green

    BorderColor          "Sienna"
    BorderTileBackground "SaddleBrown"
    BorderTileForeground "SaddleBrown"

    DefaultBackground   "#E6E6E6"
    DefaultForeground   "#000000"

    TitleBackground     "Sienna"
    TitleForeground     "#e6e6e6"

    MenuTitleBackground "#ff4500"
    MenuTitleForeground "#e6e6e6"

    MenuBackground      "#C0C0C0"
    MenuForeground      "#414D5B"

    MenuBorderColor     "#ff4500"
    MenuShadowColor     "Gray"

    IconBackground        "Firebrick"
    IconForeground        "White"
    IconBorderColor       "Firebrick"

    IconManagerBackground "Sienna"
    IconManagerForeground "#e6e6e6"
    IconManagerGeometry   "=300x250-0+0"

# Define some useful functions for motion-based actions.
MoveDelta 3
Function "move-or-lower" { f.move f.deltastop f.lower }
Function "move-or-raise" { f.move f.deltastop f.raise }
Function "move-or-iconify" { f.move f.deltastop f.iconify }

# Mouse button bindings. Button 1 is the left button,
# Button 3 is the right mouse button.
Button1 = : root : f.menu "applications"
Button3 = : root : f.menu "desktop_ops"

Button1 = m : window|icon : f.fuction "move-or-lower"
Button3 = m : window|icon : f.function "move-or-raise"

Button1 = : title : f.function "move-or-raise"
Button3 = : title : f.raiselower

Button1 = : icon : f.function "move-or-iconify"
Button3 = : icon : f.iconify

Button1 = : iconmgr : f.iconify
Button3 = : iconmgr : f.iconify

# Desktop Operations menu
menu "desktop_ops" {
"TWM Functions"	f.title
"Force Move"    f.forcemove
"Raise"         f.raise
"Lower"         f.lower
"Zoom"          f.zoom
"Full Zoom"     f.fullzoom
"Identify"      f.identify
""              f.nop
"Kill"          f.destroy
""              f.nop
"Swap Screen"   f.warptoscreen "next"
"Focus"         f.focus
"Unfocus"       f.unfocus
""              f.nop
"Refresh"       f.refresh
"Restart"       f.restart
"Read twmrc"    f.twmrc
"Version"       f.version
""              f.nop
"Exit"          f.quit

# Application menu
menu "applications" {
"Applications"  f.title
"Terminal"	!"xterm &"
"MEdit"         !"medit &"
"Xload"         !"xload &"
"Oclock"        !"oclock &"
"Xlogo"         !"xlogo &"
"Xeyes"         !"xeyes &"
""              f.nop
"Show Icon Manager"  f.showiconmgr
"Hide Icon Manager"  f.hideiconmgr
""              f.nop
"Raise"         f.raise
"Lower"         f.lower
"Iconify"       f.iconify
"Resize"        f.resize
"Move"          f.move
"Delete"        f.delete
""              f.nop
"Exit"          f.quit

My .Xresources file:

XTerm*local: true
XTerm*foreground: white
XTerm*background: black
XTerm*font: 9x15
XTerm*scrollBar: true
XTerm*rightScrollBar: true
XLogo*geometry: 150x150
oclock*geometry: 150x150-0-0
oclock*background: Gold
XEyes*geometry: 250x135
XLoad*geometry: 250x140
XLoad*foreground: white
XLoad*background: black

And my .xinitrc file:



# merge in defaults and keymaps

if [ -f $sysresources ]; then
    xrdb -merge $sysresources

if [ -f $sysmodmap ]; then
    xmodmap $sysmodmap

if [ -f "$userresources" ]; then
    xrdb -merge "$userresources"

if [ -f "$usermodmap" ]; then
    xmodmap "$usermodmap"

# Look for default system-wide applications to
# start. This is left as an historical reference.
# You should start programs in the local .xinitrc
if [ -d /etc/X11/xinit/xinitrc.d ] ; then
 for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do
  [ -x "$f" ] && . "$f"
 unset f

# Set default desktop cursor to arrow instead of 'X'
xsetroot -cursor_name left_ptr
# Set the desktop background, either a solid color
# or a tiled image.
# xsetroot -solid steelblue4 &
xv ~/twm/tiles/black_mosaic.jpg -root -quit
# Switch off default beeps
xset -b

# Start some default applications.
exec xterm -geometry 80x20+0-0 &
exec xterm -geometry 80x40+0+0 &
exec oclock &
# Launch twm. This should be the last thing you do,
# and it should be execed. This allows f.quit in
# the TWM menus to work, instead of using something
# crude like 'pkill x'
exec twm

I have not included my icons directory or their files. I’ll probably check all those into Sourceforge along with the images in the near future. But I have reached a point of diminished returns. It works and looks pretty much the way I want, and is reasonably fast, much faster than a contemporary desktop environment.