Created
November 9, 2012 09:35
-
-
Save ilmanzo/4044809 to your computer and use it in GitHub Desktop.
Led sulle PC Engines ALIX
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Led | |
#numero da 1 a 3 | |
def initialize(ledno) | |
ledno++ # passo 0 ma comando 1 | |
ledno=1 if ledno<1 | |
ledno=3 if ledno>3 | |
@ledsyspath="/sys/devices/platform/leds_alix2/leds/alix:#{ledno}/" | |
end | |
def blink(millisec) | |
File.open(@ledsyspath+'trigger','w') { |f| f.write('timer') } | |
File.open(@ledsyspath+'delay_off','w') do |f| | |
f.write(millisec.to_s) | |
end | |
File.open(@ledsyspath+'delay_on','w') do |f| | |
f.write(millisec.to_s) | |
end | |
end | |
def blink_slow! | |
blink(500) | |
end | |
def blink_fast! | |
blink(50) | |
end | |
def on! | |
File.open(@ledsyspath+'trigger','w') { |f| f.write('default-on') } | |
File.open(@ledsyspath+'brightness','w') do |f| | |
f.write('1') | |
end | |
end | |
def off! | |
File.open(@ledsyspath+'trigger','w') { |f| f.write("none") } | |
File.open(@ledsyspath+'brightness','w') do |f| | |
f.write('0') | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment