ev3dev 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/ev3dev.rb +3 -0
- data/lib/ev3dev/device.rb +20 -0
- data/lib/ev3dev/motor.rb +22 -0
- data/lib/ev3dev/sensor.rb +14 -0
- metadata +47 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 72e5459cbe5935bc2970e4c15dc205828e434346
|
4
|
+
data.tar.gz: 6fd095620d29d5ee34a0fa866fb30a8ab311be4b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 88441d206de1446120c586eb68a5c82e11e1fc2d2f42b20a58b83a8bd3e6391bf90790f36f9991673e680876c73dc1b1f162065be3aab38f5889bb9d9f6558be
|
7
|
+
data.tar.gz: a7705471f54e020bfe4298d4c567e99c98a7bd1434e9c68a5f8c32e488f4eaf40313299879c362105bea091f64a3aab67bb00bffef3951af137f3788ba60521e
|
data/lib/ev3dev.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
module Ev3dev
|
2
|
+
class Device
|
3
|
+
attr :device_path
|
4
|
+
|
5
|
+
def initialize(device_path)
|
6
|
+
@device_path = device_path
|
7
|
+
end
|
8
|
+
|
9
|
+
def method_missing(name, *args, &block)
|
10
|
+
raise "no device connected" if @device_path.nil?
|
11
|
+
param = File.join @device_path, name.to_s
|
12
|
+
raise "no such attribute: #{param}" unless File.exist? param
|
13
|
+
if args.first.nil?
|
14
|
+
IO.read(param).strip
|
15
|
+
else
|
16
|
+
IO.write param, args.first.to_s
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/ev3dev/motor.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
module Ev3dev
|
2
|
+
class Motor < Device
|
3
|
+
PATH = "/sys/class/tacho-motor"
|
4
|
+
|
5
|
+
def initialize(port)
|
6
|
+
Dir.glob("#{PATH}/motor*").each do |path|
|
7
|
+
if IO.read("#{path}/port_name").strip == "out#{port.to_s.upcase}"
|
8
|
+
super path
|
9
|
+
return
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def go
|
15
|
+
run 1
|
16
|
+
end
|
17
|
+
|
18
|
+
def stop
|
19
|
+
run 0
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Ev3dev
|
2
|
+
class Sensor < Device
|
3
|
+
PATH = "/sys/class/lego-sensor"
|
4
|
+
|
5
|
+
def initialize(port)
|
6
|
+
Dir.glob("#{PATH}/sensor*").each do |path|
|
7
|
+
if IO.read("#{path}/port_name").strip == "in#{port.to_s}"
|
8
|
+
super path
|
9
|
+
return
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ev3dev
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- quake wang
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-28 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: ev3dev ruby binding
|
14
|
+
email: quake@chanyouji.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/ev3dev.rb
|
20
|
+
- lib/ev3dev/device.rb
|
21
|
+
- lib/ev3dev/motor.rb
|
22
|
+
- lib/ev3dev/sensor.rb
|
23
|
+
homepage: https://github.com/quake/ev3dev_ruby
|
24
|
+
licenses:
|
25
|
+
- MIT
|
26
|
+
metadata: {}
|
27
|
+
post_install_message:
|
28
|
+
rdoc_options: []
|
29
|
+
require_paths:
|
30
|
+
- lib
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
requirements: []
|
42
|
+
rubyforge_project:
|
43
|
+
rubygems_version: 2.4.5
|
44
|
+
signing_key:
|
45
|
+
specification_version: 4
|
46
|
+
summary: ev3dev
|
47
|
+
test_files: []
|