Permalink
Browse files

Merge pull request #3 from rixth/new_example

Binary clock example
  • Loading branch information...
2 parents 7525c09 + 2bdf595 commit 67e8fd95ec65e8cd8efc5e122af1bbaae6d23d06 @thomasjachmann committed Feb 26, 2013
Showing with 30 additions and 0 deletions.
  1. +30 −0 examples/binary_clock.rb
View
@@ -0,0 +1,30 @@
+require File.join(File.dirname(__FILE__), 'setup')
+
+device = Launchpad::Device.new
+device.reset
+
+on = { :red => :high, :green => :off }
+off = { :red => :off, :green => :lo }
+
+digit_map = [
+ [off, off, off, off],
+ [on , off, off, off],
+ [off, on , off, off],
+ [on , on , off, off],
+ [off, off, on , off],
+ [on , off, on , off],
+ [off, on , on , off],
+ [on , on , on , off],
+ [off, off, off, on ],
+ [on , off, off, on ]
+]
+
+while true do
+ Time.now.strftime('%H%M%S').split('').each_with_index do |digit, x|
+ digit_map[digit.to_i].each_with_index do |color, y|
+ device.change :grid, color.merge(:x => x, :y => (7 - y))
+ end
+ end
+
+ sleep 0.25
+end

0 comments on commit 67e8fd9

Please sign in to comment.