artoo-arduino 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +15 -17
  3. data/README.md +8 -63
  4. data/artoo-arduino.gemspec +4 -3
  5. data/examples/analog_sensor.rb +31 -0
  6. data/examples/{firmata_blink_led.rb → blink_led.rb} +1 -1
  7. data/examples/{firmata_blink_led_with_toggle.rb → blink_led_with_toggle.rb} +1 -1
  8. data/examples/{firmata_button_and_led.rb → button_and_led.rb} +0 -0
  9. data/examples/{firmata_dc_motor_speed.rb → dc_motor_speed.rb} +1 -1
  10. data/examples/{firmata_dc_motor_speed_h-bridge_2_pins.rb → dc_motor_speed_h-bridge_2_pins.rb} +1 -1
  11. data/examples/{firmata_dc_motor_switch.rb → dc_motor_switch.rb} +1 -1
  12. data/examples/{firmata_dc_motor_switch_h-bridge_2_pins.rb → dc_motor_switch_h-bridge_2_pins.rb} +1 -1
  13. data/examples/{firmata_led_brightness.rb → led_brightness.rb} +1 -1
  14. data/examples/led_brightness_with_analog_input.rb +29 -0
  15. data/examples/{firmata_led_with_button_toggle.rb → led_with_button_toggle.rb} +1 -1
  16. data/examples/{firmata_maxbotix.rb → maxbotix.rb} +2 -2
  17. data/examples/{firmata_motor.rb → motor.rb} +1 -1
  18. data/examples/motor_speed_with_analog_input.rb +30 -0
  19. data/examples/{firmata_servo.rb → servo.rb} +1 -1
  20. data/examples/{firmata_wiichuck.rb → wiichuck.rb} +0 -0
  21. data/lib/artoo-arduino/version.rb +1 -1
  22. data/lib/artoo/adaptors/firmata.rb +51 -9
  23. data/test/adaptors/firmata_test.rb +30 -0
  24. metadata +43 -48
  25. data/examples/littlewire_blink_led_with_toggle.rb +0 -17
  26. data/examples/littlewire_button_and_led.rb +0 -16
  27. data/examples/littlewire_dc_motor_speed.rb +0 -31
  28. data/examples/littlewire_maxbotix.rb +0 -19
  29. data/lib/artoo/adaptors/littlewire.rb +0 -63
  30. data/lib/artoo/drivers/board.rb +0 -10
  31. data/lib/artoo/drivers/button.rb +0 -43
  32. data/lib/artoo/drivers/led.rb +0 -59
  33. data/lib/artoo/drivers/maxbotix.rb +0 -44
  34. data/lib/artoo/drivers/motor.rb +0 -167
  35. data/lib/artoo/drivers/servo.rb +0 -49
  36. data/lib/artoo/drivers/wiichuck.rb +0 -61
  37. data/lib/artoo/drivers/wiiclassic.rb +0 -139
  38. data/lib/artoo/drivers/wiidriver.rb +0 -103
  39. data/test/adaptors/littlewire_test.rb +0 -25
  40. data/test/drivers/firmata_board_test.rb +0 -21
  41. data/test/drivers/led_test.rb +0 -92
  42. data/test/drivers/maxbotix_test.rb +0 -25
  43. data/test/drivers/motor_test.rb +0 -204
  44. data/test/drivers/servo_test.rb +0 -43
  45. data/test/drivers/wiichuck_test.rb +0 -11
  46. data/test/drivers/wiiclassic_test.rb +0 -11
  47. data/test/drivers/wiidriver_test.rb +0 -54
@@ -1,43 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
2
- require 'artoo/drivers/servo'
3
-
4
- describe Artoo::Drivers::Servo do
5
- before do
6
- @device = mock('device')
7
- @device.stubs(:pin).returns(3)
8
- @servo = Artoo::Drivers::Servo.new(:parent => @device)
9
-
10
- @connection = mock('connection')
11
- @connection.stubs(:servo_write)
12
- @device.stubs(:connection).returns(@connection)
13
- end
14
-
15
- it "Servo#angle_to_span" do
16
- @servo.angle_to_span(0).must_equal 0
17
- @servo.angle_to_span(30).must_equal 42
18
- @servo.angle_to_span(90).must_equal 127
19
- @servo.angle_to_span(180).must_equal 255
20
- end
21
-
22
- it 'Servo#move must be valid' do
23
- invalid_angle = lambda { @servo2 = Artoo::Drivers::Servo.new(:parent => @device); @servo2.move(360) }
24
- invalid_angle.must_raise RuntimeError
25
- error = invalid_angle.call rescue $!
26
- error.message.must_equal 'Servo angle must be an integer between 0-180'
27
- end
28
-
29
- it 'Servo#min' do
30
- @servo.min
31
- @servo.current_angle.must_equal 0
32
- end
33
-
34
- it 'Servo#center' do
35
- @servo.center
36
- @servo.current_angle.must_equal 90
37
- end
38
-
39
- it 'Servo#max' do
40
- @servo.max
41
- @servo.current_angle.must_equal 180
42
- end
43
- end
@@ -1,11 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
2
- require 'artoo/drivers/wiichuck'
3
-
4
- describe Artoo::Drivers::Wiichuck do
5
- before do
6
- @device = mock('device')
7
- @driver = Artoo::Drivers::Wiichuck.new(:parent => @device)
8
- end
9
-
10
- it 'must do things'
11
- end
@@ -1,11 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
2
- require 'artoo/drivers/wiiclassic'
3
-
4
- describe Artoo::Drivers::Wiiclassic do
5
- before do
6
- @device = mock('device')
7
- @driver = Artoo::Drivers::Wiiclassic.new(:parent => @device)
8
- end
9
-
10
- it 'must do things'
11
- end
@@ -1,54 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
2
- require 'artoo/drivers/wiidriver'
3
-
4
- class Artoo::Drivers::Wiidriver
5
- public :set_joystick_default_value, :calculate_joystick_value, :encrypted?,
6
- :decode, :get_value, :generate_bool
7
- end
8
-
9
- describe Artoo::Drivers::Wiidriver do
10
- before do
11
- @device = mock('device')
12
- @driver = Artoo::Drivers::Wiidriver.new(:parent => @device)
13
- end
14
-
15
- it 'Artoo::Drivers::Wiidriver#set_joystick_default_value' do
16
- val = "101"
17
- @driver.joystick[:test_axis] = nil
18
- @driver.set_joystick_default_value(:test_axis, val)
19
- @driver.joystick[:test_axis].must_equal val
20
- end
21
-
22
- it 'Artoo::Drivers::Wiidriver#calculate_joystick_value' do
23
- @driver.data[:test_axis] = 8
24
- @driver.joystick[:test_origin] = 5
25
- @driver.calculate_joystick_value(:test_axis, :test_origin).must_equal 3
26
- end
27
-
28
- it 'Artoo::Drivers::Wiidriver#encrypted?' do
29
- value = {:data => [0, 0, 0, 0, 0, 0]}
30
- @driver.encrypted?(value).must_equal true
31
- end
32
-
33
- it 'Artoo::Drivers::Wiidriver#encrypted?' do
34
- value = {:data => [1, 2, 3, 4, 5, 6]}
35
- @driver.encrypted?(value).must_equal false
36
- end
37
-
38
- it 'Artoo::Drivers::Wiidriver#decode' do
39
- @driver.decode(22).must_equal 24
40
- @driver.decode(0).must_equal 46
41
- @driver.decode(16).must_equal 30
42
- end
43
-
44
- it 'Artoo::Drivers::Wiidriver#get_value' do
45
- value = {:data => [1, 2, 3, 4, 5, 6], :other_data => [10, 20, 30, 40, 50, 60]}
46
- @driver.get_value(value, 1).must_equal 2
47
- @driver.get_value(value, 5).must_equal 6
48
- end
49
-
50
- it 'Artoo::Drivers::Wiidriver#generate_bool' do
51
- @driver.generate_bool(0).must_equal true
52
- @driver.generate_bool(1).must_equal false
53
- end
54
- end