public
Description: A Sinatra application that turns LEDs on and off on an embedded system
Homepage:
Clone URL: git://github.com/dougbradbury/weblink.git
weblink / lib / led.rb
100644 24 lines (19 sloc) 0.393 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class Led
  def initialize(options)
    @data_register = options[:data_register]
    @mask = options[:mask]
    @mmio = options[:mmio]
  end
  
  def on
    @mmio.write(@data_register,"w", current & ~@mask)
  end
  
  def off
    @mmio.write(@data_register,"w", current | @mask)
  end
  
  def on?
    current & @mask == 0
  end
  
  def current
    @mmio.read(@data_register,"w")
  end
  
end