class BlinkMMulti

Public Instance Methods

dance() click to toggle source
# File lib/examples/blink_m_multi.rb, line 45
def dance
  BlinkM_setFadeSpeed(@addr_all, 20) # 1-255, with 1 producing the slowest fade
  my_lcd.clearscr
  my_lcd.setxy 0,0, "Do the shimmy.."
  my_lcd.setxy 0,1
  @blink_addresses.each do |a|
    BlinkM_fadeToRGB(a, 1,166,138)
    delay 100
  end
  @blink_addresses.each do |a|
    BlinkM_fadeToRGB(a, 35,0,112)
    delay 100
  end
end
loop() click to toggle source
# File lib/examples/blink_m_multi.rb, line 25
def loop  
  stop_and_fade(@addr1) if button_one.read_input
  stop_and_fade(@addr2) if button_two.read_input 
  stop_and_fade(@addr3) if button_three.read_input 
  dance if button_four.read_input 
end
stop_and_fade(addr) click to toggle source
# File lib/examples/blink_m_multi.rb, line 32
def stop_and_fade(addr)
  f = 1 + addr # hack to coerce addr to int
  my_lcd.clearscr
  my_lcd.setxy 0,0, "blinkm # "
  my_lcd.print addr
  delay 700
  BlinkM_stopScript addr
  my_lcd.setxy 0,1, "stopping script.."
  delay 700
  my_lcd.setxy 0,2, "fade to purple.."
  BlinkM_fadeToRGB(addr, 0xff,0x00,0xff)
end