artoo-i2c 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +6 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +59 -0
- data/LICENSE +13 -0
- data/README.md +40 -0
- data/Rakefile +10 -0
- data/artoo-i2c.gemspec +27 -0
- data/lib/artoo-i2c.rb +3 -0
- data/lib/artoo-i2c/version.rb +5 -0
- data/lib/artoo/drivers/wiichuck.rb +61 -0
- data/lib/artoo/drivers/wiiclassic.rb +139 -0
- data/lib/artoo/drivers/wiidriver.rb +88 -0
- data/test/drivers/wiichuck_test.rb +11 -0
- data/test/drivers/wiiclassic_test.rb +11 -0
- data/test/drivers/wiidriver_test.rb +54 -0
- data/test/test_helper.rb +10 -0
- metadata +117 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4cbcce1b971789149a5c60a19eda4815953dfe64
|
4
|
+
data.tar.gz: dc0751e660ab95ec064f43a3cfb287496d5d0f9a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4b95adae7a7963f80e0b33eb3143ea0b974f0fbd11d0a3a141c955025bcc1a2fa202df444c85ebdf33726391db688d080937ac235077cd9f904068a384080e4c
|
7
|
+
data.tar.gz: a813c3e6d6c46b25206c0791de84559799f9759aa54a1854d6f063d78be8c67e43089d69e9079bb5a9525af6a942f8ae03fd33f8947fb2a5a0217741126dd5f0
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
artoo-i2c (0.1.0)
|
5
|
+
artoo (~> 1.1.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
artoo (1.1.0)
|
11
|
+
celluloid (~> 0.15.0)
|
12
|
+
celluloid-io (~> 0.15.0)
|
13
|
+
multi_json (~> 1.6)
|
14
|
+
pry (~> 0.9)
|
15
|
+
rake (~> 10.0)
|
16
|
+
reel (~> 0.4.0.pre)
|
17
|
+
thor (~> 0.18.1)
|
18
|
+
celluloid (0.15.1)
|
19
|
+
timers (~> 1.1.0)
|
20
|
+
celluloid-io (0.15.0)
|
21
|
+
celluloid (>= 0.15.0)
|
22
|
+
nio4r (>= 0.5.0)
|
23
|
+
coderay (1.0.9)
|
24
|
+
http (0.5.0.pre)
|
25
|
+
http_parser.rb
|
26
|
+
http_parser.rb (0.6.0.beta.2)
|
27
|
+
metaclass (0.0.1)
|
28
|
+
method_source (0.8.2)
|
29
|
+
minitest (5.0.7)
|
30
|
+
minitest-happy (1.0.0)
|
31
|
+
mocha (0.14.0)
|
32
|
+
metaclass (~> 0.0.1)
|
33
|
+
multi_json (1.8.0)
|
34
|
+
nio4r (0.5.0)
|
35
|
+
pry (0.9.12.2)
|
36
|
+
coderay (~> 1.0.5)
|
37
|
+
method_source (~> 0.8)
|
38
|
+
slop (~> 3.4)
|
39
|
+
rake (10.1.0)
|
40
|
+
reel (0.4.0.pre5)
|
41
|
+
celluloid (>= 0.15.0)
|
42
|
+
celluloid-io (>= 0.15.0)
|
43
|
+
http (>= 0.5.0.pre)
|
44
|
+
http_parser.rb (>= 0.6.0.beta.2)
|
45
|
+
websocket_parser (>= 0.1.4)
|
46
|
+
slop (3.4.6)
|
47
|
+
thor (0.18.1)
|
48
|
+
timers (1.1.0)
|
49
|
+
websocket_parser (0.1.4)
|
50
|
+
http
|
51
|
+
|
52
|
+
PLATFORMS
|
53
|
+
ruby
|
54
|
+
|
55
|
+
DEPENDENCIES
|
56
|
+
artoo-i2c!
|
57
|
+
minitest (~> 5.0)
|
58
|
+
minitest-happy
|
59
|
+
mocha (~> 0.14.0)
|
data/LICENSE
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright (c) 2012, 2013 The Hybrid Group
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# Artoo Drivers For i2c Devices
|
2
|
+
|
3
|
+
This repository contains the Artoo (http://artoo.io/) standard drivers for i2c devices.
|
4
|
+
|
5
|
+
Artoo is a open source micro-framework for robotics using Ruby.
|
6
|
+
|
7
|
+
For more information abut Artoo, check out our repo at https://github.com/hybridgroup/artoo
|
8
|
+
|
9
|
+
[![Code Climate](https://codeclimate.com/github/hybridgroup/artoo-i2c.png)](https://codeclimate.com/github/hybridgroup/artoo-i2c) [![Build Status](https://travis-ci.org/hybridgroup/artoo-i2c.png?branch=master)](https://travis-ci.org/hybridgroup/artoo-i2c)
|
10
|
+
|
11
|
+
## Installing
|
12
|
+
|
13
|
+
```
|
14
|
+
gem install artoo-i2c
|
15
|
+
```
|
16
|
+
|
17
|
+
## Using
|
18
|
+
|
19
|
+
Normally, this gem is automatically included as part of using an Artoo adaptor that can connect to your hardware. For example, artoo-arduino and artoo-raspi both make use of the drivers in this gem.
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
require 'artoo'
|
23
|
+
|
24
|
+
puts "Example here"
|
25
|
+
```
|
26
|
+
|
27
|
+
## Devices supported
|
28
|
+
|
29
|
+
The following i2c hardware devices have driver support:
|
30
|
+
- Wiichuck
|
31
|
+
- Wiiclassic
|
32
|
+
|
33
|
+
|
34
|
+
## Contributing
|
35
|
+
|
36
|
+
1. Fork it
|
37
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
38
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
39
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
40
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/artoo-i2c.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "artoo-i2c/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "artoo-i2c"
|
7
|
+
s.version = Artoo::I2c::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Ron Evans", "Adrian Zankich",]
|
10
|
+
s.email = ["artoo@hybridgroup.com"]
|
11
|
+
s.homepage = "https://github.com/hybridgroup/artoo-i2c"
|
12
|
+
s.summary = %q{Artoo standard drivers for i2c devices}
|
13
|
+
s.description = %q{Artoo standard drivers for i2c devices}
|
14
|
+
s.license = 'Apache 2.0'
|
15
|
+
|
16
|
+
s.rubyforge_project = "artoo-i2c"
|
17
|
+
|
18
|
+
s.files = `git ls-files`.split("\n")
|
19
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
|
+
s.require_paths = ["lib"]
|
22
|
+
|
23
|
+
s.add_runtime_dependency 'artoo', '~> 1.1.0'
|
24
|
+
s.add_development_dependency 'minitest', '~> 5.0'
|
25
|
+
s.add_development_dependency 'minitest-happy'
|
26
|
+
s.add_development_dependency 'mocha', '~> 0.14.0'
|
27
|
+
end
|
data/lib/artoo-i2c.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'artoo/drivers/wiidriver'
|
2
|
+
|
3
|
+
module Artoo
|
4
|
+
module Drivers
|
5
|
+
# Wiichuck driver behaviors for i2c
|
6
|
+
class Wiichuck < Wiidriver
|
7
|
+
|
8
|
+
# Update button and joystick values
|
9
|
+
# @param [Object] value
|
10
|
+
def update(value)
|
11
|
+
begin
|
12
|
+
super
|
13
|
+
|
14
|
+
adjust_origins
|
15
|
+
update_buttons
|
16
|
+
update_joystick
|
17
|
+
|
18
|
+
rescue Exception => e
|
19
|
+
Logger.error "wiichuck update exception!"
|
20
|
+
Logger.error e.message
|
21
|
+
Logger.error e.backtrace.inspect
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# Adjust x, y origin values
|
26
|
+
def adjust_origins
|
27
|
+
set_joystick_default_value(:sy_origin, data[:sy])
|
28
|
+
set_joystick_default_value(:sx_origin, data[:sx])
|
29
|
+
end
|
30
|
+
|
31
|
+
# Publishes events for c and z buttons
|
32
|
+
def update_buttons
|
33
|
+
publish(event_topic_name("c_button")) if data[:c] == true
|
34
|
+
publish(event_topic_name("z_button")) if data[:z] == true
|
35
|
+
end
|
36
|
+
|
37
|
+
# Publishes event for joystick
|
38
|
+
def update_joystick
|
39
|
+
publish(event_topic_name("joystick"), {:x => calculate_joystick_value(:sx, :sx_origin), :y => calculate_joystick_value(:sy, :sy_origin)})
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def get_defaults
|
45
|
+
{
|
46
|
+
:sy_origin => nil,
|
47
|
+
:sx_origin => nil
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
def parse(value)
|
52
|
+
return {
|
53
|
+
:sx => decode_value(value, 0),
|
54
|
+
:sy => decode_value(value, 1),
|
55
|
+
:z => generate_bool(decode_value(value, 5) & 0x01),
|
56
|
+
:c => generate_bool(decode_value(value, 5) & 0x02)
|
57
|
+
}
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,139 @@
|
|
1
|
+
require 'artoo/drivers/wiidriver'
|
2
|
+
|
3
|
+
module Artoo
|
4
|
+
module Drivers
|
5
|
+
# Wiiclassic driver behaviors for i2c
|
6
|
+
class Wiiclassic < Wiidriver
|
7
|
+
|
8
|
+
# Update buttons and joysticks values
|
9
|
+
# @param [Object] value
|
10
|
+
def update(value)
|
11
|
+
begin
|
12
|
+
super
|
13
|
+
|
14
|
+
adjust_origins
|
15
|
+
update_buttons
|
16
|
+
update_left_joystick
|
17
|
+
update_right_joystick
|
18
|
+
update_triggers
|
19
|
+
|
20
|
+
rescue Exception => e
|
21
|
+
Logger.error "wiiclassic update exception!"
|
22
|
+
Logger.error e.message
|
23
|
+
Logger.error e.backtrace.inspect
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# Adjust all origins
|
28
|
+
def adjust_origins
|
29
|
+
set_joystick_default_value(:ly_origin, data[:ly])
|
30
|
+
set_joystick_default_value(:lx_origin, data[:lx])
|
31
|
+
set_joystick_default_value(:ry_origin, data[:ry])
|
32
|
+
set_joystick_default_value(:rx_origin, data[:rx])
|
33
|
+
set_joystick_default_value(:rt_origin, data[:rt])
|
34
|
+
set_joystick_default_value(:lt_origin, data[:lt])
|
35
|
+
end
|
36
|
+
|
37
|
+
# Update button values
|
38
|
+
def update_buttons
|
39
|
+
update_button("a_button", :a)
|
40
|
+
update_button("b_button", :b)
|
41
|
+
update_button("x_button", :x)
|
42
|
+
update_button("y_button", :y)
|
43
|
+
update_button("home_button", :h)
|
44
|
+
update_button("start_button", :+)
|
45
|
+
update_button("select_button", :-)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Publish button event
|
49
|
+
def update_button(name, key)
|
50
|
+
publish(event_topic_name(name)) if data[key] == true
|
51
|
+
end
|
52
|
+
|
53
|
+
# Publish left joystick event
|
54
|
+
def update_left_joystick
|
55
|
+
publish(event_topic_name("left_joystick"), {:x => calculate_joystick_value(:lx, :lx_origin), :y => calculate_joystick_value(:ly, :ly_origin)})
|
56
|
+
end
|
57
|
+
|
58
|
+
# Publish right joystick event
|
59
|
+
def update_right_joystick
|
60
|
+
publish(event_topic_name("right_joystick"), {:x => calculate_joystick_value(:rx, :rx_origin), :y => calculate_joystick_value(:ry, :ry_origin)})
|
61
|
+
end
|
62
|
+
|
63
|
+
# Publish triggers events
|
64
|
+
def update_triggers
|
65
|
+
publish(event_topic_name("right_trigger"), calculate_joystick_value(:rt, :rt_origin))
|
66
|
+
publish(event_topic_name("left_trigger"), calculate_joystick_value(:lt, :lt_origin))
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
def get_defaults
|
72
|
+
{
|
73
|
+
:ry_origin => nil,
|
74
|
+
:rx_origin => nil,
|
75
|
+
:ly_origin => nil,
|
76
|
+
:lx_origin => nil,
|
77
|
+
:rt_origin => nil,
|
78
|
+
:lt_origin => nil
|
79
|
+
}
|
80
|
+
end
|
81
|
+
|
82
|
+
def parse(value)
|
83
|
+
return parse_joysticks(value).
|
84
|
+
merge(parse_buttons(value)).
|
85
|
+
merge(parse_triggers(value)).
|
86
|
+
merge(parse_dpad(value)).
|
87
|
+
merge(parse_zbuttons(value))
|
88
|
+
end
|
89
|
+
|
90
|
+
def parse_joysticks(value)
|
91
|
+
{
|
92
|
+
:lx => decode_value(value, 0) & 0x3f,
|
93
|
+
:ly => decode_value(value, 1) & 0x3f,
|
94
|
+
:rx => ((decode_value(value, 0) & 0xC0) >> 3) | ((decode_value(value, 1) & 0xC0) >> 5) | (decode_value(value, 2)[7]),
|
95
|
+
:ry => decode_value(value, 2) & 0x1f
|
96
|
+
}
|
97
|
+
end
|
98
|
+
|
99
|
+
def parse_buttons(value)
|
100
|
+
{
|
101
|
+
:a => get_bool_decoded_value(value, 5, 4),
|
102
|
+
:b => get_bool_decoded_value(value, 5, 6),
|
103
|
+
:x => get_bool_decoded_value(value, 5, 3),
|
104
|
+
:y => get_bool_decoded_value(value, 5, 5),
|
105
|
+
:+ => get_bool_decoded_value(value, 4, 2),
|
106
|
+
:- => get_bool_decoded_value(value, 4, 4),
|
107
|
+
:h => get_bool_decoded_value(value, 4, 3)
|
108
|
+
}
|
109
|
+
end
|
110
|
+
|
111
|
+
def parse_triggers(value)
|
112
|
+
{
|
113
|
+
:lt => ((decode_value(value, 2) & 0x60) >> 3) | ((decode_value(value, 3) & 0xC0) >> 6),
|
114
|
+
:rt => decode_value(value, 3) & 0x1f
|
115
|
+
}
|
116
|
+
end
|
117
|
+
|
118
|
+
def parse_dpad(value)
|
119
|
+
{
|
120
|
+
:d_up => get_bool_decoded_value(value, 5, 0),
|
121
|
+
:d_down => get_bool_decoded_value(value, 4, 6),
|
122
|
+
:d_left => get_bool_decoded_value(value, 5, 1),
|
123
|
+
:d_right => get_bool_decoded_value(value, 4, 7)
|
124
|
+
}
|
125
|
+
end
|
126
|
+
|
127
|
+
def parse_zbuttons(value)
|
128
|
+
{
|
129
|
+
:zr => get_bool_decoded_value(value, 5, 2),
|
130
|
+
:zl => get_bool_decoded_value(value, 5, 7)
|
131
|
+
}
|
132
|
+
end
|
133
|
+
|
134
|
+
def get_bool_decoded_value(value, offset1, offset2)
|
135
|
+
generate_bool(decode_value(value, offset1)[offset2])
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'artoo/drivers/driver'
|
2
|
+
|
3
|
+
module Artoo
|
4
|
+
module Drivers
|
5
|
+
# Wii-based controller shared driver behaviors for i2c
|
6
|
+
class Wiidriver < Driver
|
7
|
+
attr_reader :joystick, :data
|
8
|
+
|
9
|
+
def address; 0x52; end
|
10
|
+
|
11
|
+
# Create new Wiidriver
|
12
|
+
def initialize(params={})
|
13
|
+
@joystick = get_defaults
|
14
|
+
@data = {}
|
15
|
+
super
|
16
|
+
end
|
17
|
+
|
18
|
+
# Starts drives and required connections
|
19
|
+
def start_driver
|
20
|
+
begin
|
21
|
+
connection.i2c_start(address)
|
22
|
+
|
23
|
+
every(interval) do
|
24
|
+
connection.i2c_write(0x40, 0x00)
|
25
|
+
connection.i2c_write(0x00, 0x00)
|
26
|
+
new_value = connection.i2c_read(6)
|
27
|
+
|
28
|
+
update(new_value) if !new_value.nil?
|
29
|
+
end
|
30
|
+
|
31
|
+
super
|
32
|
+
rescue Exception => e
|
33
|
+
Logger.error "Error starting wii driver!"
|
34
|
+
Logger.error e.message
|
35
|
+
Logger.error e.backtrace.inspect
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Get and update data
|
40
|
+
def update(value)
|
41
|
+
if encrypted?(value)
|
42
|
+
Logger.error "Encrypted bytes from wii device!"
|
43
|
+
raise "Encrypted bytes from wii device!"
|
44
|
+
end
|
45
|
+
|
46
|
+
@data = parse(value)
|
47
|
+
end
|
48
|
+
|
49
|
+
protected
|
50
|
+
|
51
|
+
def get_defaults
|
52
|
+
{}
|
53
|
+
end
|
54
|
+
|
55
|
+
def parse
|
56
|
+
{}
|
57
|
+
end
|
58
|
+
|
59
|
+
def set_joystick_default_value(joystick_axis, default_value)
|
60
|
+
joystick[joystick_axis] = default_value if joystick[joystick_axis].nil?
|
61
|
+
end
|
62
|
+
|
63
|
+
def calculate_joystick_value(axis, origin)
|
64
|
+
data[axis] - joystick[origin]
|
65
|
+
end
|
66
|
+
|
67
|
+
def encrypted?(value)
|
68
|
+
[[0, 1], [2, 3], [4, 5]].all? {|a| get_value(value, a[0]) == get_value(value, a[1]) }
|
69
|
+
end
|
70
|
+
|
71
|
+
def decode(x)
|
72
|
+
return ( x ^ 0x17 ) + 0x17
|
73
|
+
end
|
74
|
+
|
75
|
+
def decode_value(value, index)
|
76
|
+
decode(get_value(value, index))
|
77
|
+
end
|
78
|
+
|
79
|
+
def get_value(value, index)
|
80
|
+
value[:data][index]
|
81
|
+
end
|
82
|
+
|
83
|
+
def generate_bool(value)
|
84
|
+
value == 0 ? true : false
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,11 @@
|
|
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
|
@@ -0,0 +1,11 @@
|
|
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
|
@@ -0,0 +1,54 @@
|
|
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
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: artoo-i2c
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ron Evans
|
8
|
+
- Adrian Zankich
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-09-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: artoo
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ~>
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 1.1.0
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 1.1.0
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: minitest
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '5.0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ~>
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '5.0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: minitest-happy
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: mocha
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ~>
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 0.14.0
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.14.0
|
70
|
+
description: Artoo standard drivers for i2c devices
|
71
|
+
email:
|
72
|
+
- artoo@hybridgroup.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- .travis.yml
|
78
|
+
- Gemfile
|
79
|
+
- Gemfile.lock
|
80
|
+
- LICENSE
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- artoo-i2c.gemspec
|
84
|
+
- lib/artoo-i2c.rb
|
85
|
+
- lib/artoo-i2c/version.rb
|
86
|
+
- lib/artoo/drivers/wiichuck.rb
|
87
|
+
- lib/artoo/drivers/wiiclassic.rb
|
88
|
+
- lib/artoo/drivers/wiidriver.rb
|
89
|
+
- test/drivers/wiichuck_test.rb
|
90
|
+
- test/drivers/wiiclassic_test.rb
|
91
|
+
- test/drivers/wiidriver_test.rb
|
92
|
+
- test/test_helper.rb
|
93
|
+
homepage: https://github.com/hybridgroup/artoo-i2c
|
94
|
+
licenses:
|
95
|
+
- Apache 2.0
|
96
|
+
metadata: {}
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options: []
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - '>='
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
requirements: []
|
112
|
+
rubyforge_project: artoo-i2c
|
113
|
+
rubygems_version: 2.0.3
|
114
|
+
signing_key:
|
115
|
+
specification_version: 4
|
116
|
+
summary: Artoo standard drivers for i2c devices
|
117
|
+
test_files: []
|