Class: BlinkMAddressAssignment

Inherits:
ArduinoSketch show all
Defined in:
lib/examples/blink_m_address_assignment.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

#assign_addressObject



69
70
71
72
73
74
75
76
77
# File 'lib/examples/blink_m_address_assignment.rb', line 69

def assign_address
  @flag = true
  my_lcd.clearscr "setting to "
  my_lcd.print @blink_m_start_address
  delay 100
  BlinkM_setAddress @blink_m_start_address
  my_lcd.clearscr "done"
  control_it
end

#control_itObject



79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/examples/blink_m_address_assignment.rb', line 79

def control_it
  delay 500
  my_lcd.clearscr "stopping script"
  BlinkM_stopScript @blink_m_start_address
  my_lcd.clearscr "stopping script.."
  delay 500
  my_lcd.clearscr "fade to purple.."
  BlinkM_fadeToRGB(@blink_m_start_address, 0xff,0x00,0xff)
  my_lcd.clearscr "fade to purple"
  delay 500
  BlinkM_fadeToRGB(@blink_m_start_address, 0xff,0x00,0xff)
end

#loopObject



38
39
40
41
42
43
44
45
46
# File 'lib/examples/blink_m_address_assignment.rb', line 38

def loop  
 
  if @flag == false
    staging
  else
    test_address 
  end
  delay 100
end

#setupObject



32
33
34
35
36
# File 'lib/examples/blink_m_address_assignment.rb', line 32

def setup
  delay 1000
  my_lcd.setxy 0,0, "bienvenue"
      delay 5000
end

#stagingObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/examples/blink_m_address_assignment.rb', line 48

def staging
  my_lcd.setxy 0,0, "press button one to"
  my_lcd.setxy 0,1, "set address to "
  my_lcd.print @blink_m_start_address
  my_lcd.setxy 0,2, "or two for status"
  delay 60
  my_lcd.setxy 0,3, "                "
  my_lcd.setxy 0,3
  800.times do |i|
    return 0 if @flag == true
    my_lcd.print "." if i % 50 == 0 
    delay 5
    if button_one.read_input
      assign_address 
    elsif button_two.read_input
      test_address
    end 
  end
  @blink_m_start_address += 1 
end

#test_addressObject



93
94
95
96
97
98
99
# File 'lib/examples/blink_m_address_assignment.rb', line 93

def test_address
  my_lcd.clearscr
  my_lcd.setxy 0,0, "testing address"
  my_lcd.setxy 0,1
  my_lcd.print blink_m_check_address_message @blink_m_start_address
  delay 5000
end