Skip to content

Instantly share code, notes, and snippets.

@tenderlove
Created August 20, 2011 22:17
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save tenderlove/1159737 to your computer and use it in GitHub Desktop.
Save tenderlove/1159737 to your computer and use it in GitHub Desktop.
require 'usb'
require 'betabrite'
###
# Get a betabrite sign:
#
# http://www.betabrite.com/
# http://www.amazon.com/Brite-Prism-Moving-Message-Display/dp/B000MQAI72
#
# Install gems:
#
# $ gem install usb betabrite
#
# Run once:
#
# $ rake betabrite:reset betabrite:allocate betabrite:format
#
# Subsequent runs:
#
# $ rake betabrite:update SLOT0=foo SLOT1=bar
#
namespace :betabrite do
desc 'Reset sign memory'
task :reset do
BetaBrite::USB.new.reset!
end
desc 'Allocate memory slots'
task :allocate do
bb = BetaBrite::USB.new do |sign|
sign.allocate do |memory|
memory.text('A', 4096)
memory.string('0', 64)
memory.string('1', 140)
end
end
bb.write_memory!
end
desc 'Format the main screen'
task :format do
bb = BetaBrite::USB.new do |sign|
sign.stringfile('0') do
print string("hello").red
end
sign.stringfile('1') do
print string("world").green
end
sign.textfile do
hold
print stringfile("0")
print string ' '
print stringfile("1")
end
end
bb.write!
end
task :update do
BetaBrite::USB.new { |sign|
sign.stringfile('0') do
print string(ENV['SLOT0']).rgb('0000FF')
end
sign.stringfile('1') do
print string(ENV['SLOT1']).rgb('FFFFFF')
end
}.write!
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment