Skip to content

Instantly share code, notes, and snippets.

@smarthall
Last active December 18, 2015 22:59
Show Gist options
  • Save smarthall/5858058 to your computer and use it in GitHub Desktop.
Save smarthall/5858058 to your computer and use it in GitHub Desktop.
Beaglebone to OpenSegment code for REA Hack Day 2013
#!/bin/bash
# To use:
# Plug the left display into pin 24 on connector P9
# Plug the right display into pin 21 on connector P9
if [ -f /sys/devices/bone_capemgr*/slots ]; then
# Create and setup the UART devices if needed
if [ -f /dev/ttyO1 ]; then
echo BB-UART1 >/sys/devices/bone_capemgr*/slots
stty -F /dev/ttyO1 9600
fi
if [ -f /dev/ttyO2 ]; then
echo BB-UART2 >/sys/devices/bone_capemgr*/slots
stty -F /dev/ttyO2 9600
fi
else
# No easy way to test if this is already done
echo 20 > /sys/kernel/debug/omap_mux/uart1_rxd
echo 0 > /sys/kernel/debug/omap_mux/uart1_txd
echo 1 > /sys/kernel/debug/omap_mux/spi0_d0
echo 21 > /sys/kernel/debug/omap_mux/spi0_sclk
# Setup the serial ports
stty -F /dev/ttyO1 9600
stty -F /dev/ttyO2 9600
fi
# Get the values
LEFT="$(printf '%8s' "$1" | cut -c1-4)"
RIGHT="$(printf '%8s' "$1" | cut -c5-8)"
# Send the two numbers
printf 'y%b%4s' '\x0' "$LEFT" > /dev/ttyO2 &
printf 'y%b%4s' '\x0' "$RIGHT" > /dev/ttyO1 &
wait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment