Class: BlinkMMulti

Inherits:
ArduinoSketch show all
Defined in:
lib/examples/blink_m_multi.rb

Instance Attribute Summary

Attributes inherited from ArduinoSketch

#pins

Instance Method Summary collapse

Methods inherited from ArduinoSketch

#add, add_to_setup, #array, #assembler, #comment_box, #compose_setup, #define, #delay, #digitalWrite, #formatted_print, #initialize, #input_pin, #input_pins, output_pin, #output_pin, post_process_ruby_to_c_methods, pre_process, #serial_begin

Methods included from ExternalVariableProcessing

#c_type, #check_variable_type, #post_process_arrays, #post_process_vars, #pre_process_vars, #process_external_vars, #translate_variables

Constructor Details

This class inherits a constructor from ArduinoSketch

Instance Method Details

#danceObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
# 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

#loopObject



25
26
27
28
29
30
# 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) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
# 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