pi-lights-control 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +59 -2
- data/exe/pi-lights-control +124 -0
- data/lib/pi-lights-control/command.rb +3 -1
- data/lib/pi-lights-control/version.rb +1 -1
- data/pi-lights-control.gemspec +1 -0
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85d3641e75455c5cfeab30f37440f883d6cd9d08
|
4
|
+
data.tar.gz: f782c16c5118db1487003f39539e5cc4217249f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1902a4eeebcb9eeb78f37c8e020751e2dc97f0ac88723bf82962829a4781288eebf9aebc553f7ec30db79068f1f55388f9bfba642119ae91672e1e6a9d0e8110
|
7
|
+
data.tar.gz: 1d18644a4819eb70db4de901db65d488665e2e86ef98b8eed757bd79be08bc4b81deb1286f8364ddeb27ebfe63d037fe0220ce2aab2a96bdae72189a59c2895f
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -28,9 +28,64 @@ You can use this gem in two ways, as a Ruby library or as an executable.
|
|
28
28
|
|
29
29
|
### Executable Usage
|
30
30
|
|
31
|
-
Using the executable from the command line allows you to quickly test the library.
|
31
|
+
Using the executable from the command line allows you to quickly test the library. After installing the gem, the `pi-lights-control` binary will be available in your gem bin path.
|
32
|
+
|
33
|
+
```shell
|
34
|
+
$ pi-lights-control
|
35
|
+
NAME
|
36
|
+
pi-lights-control - Control Home Collection Lights over GPIO and RF Transmitter
|
37
|
+
|
38
|
+
SYNOPSIS
|
39
|
+
pi-lights-control [global options] command [command options] [arguments...]
|
40
|
+
|
41
|
+
GLOBAL OPTIONS
|
42
|
+
--help - Show this message
|
43
|
+
-p, --pin=arg - GPIO pin number for RF Transmitter. Mandatory. (default: none)
|
44
|
+
|
45
|
+
COMMANDS
|
46
|
+
help - Shows a list of commands or help for one command
|
47
|
+
off - Turn lights off
|
48
|
+
on - Turn lights on
|
49
|
+
program - Run a lights program
|
50
|
+
sync - Sync multiple light sets
|
51
|
+
```
|
52
|
+
|
53
|
+
The `--pin` argument is mandatory as all the commands need to know which pin to control. The `off`, `on` commands should be self-explanatory.
|
54
|
+
|
55
|
+
The `sync` command will send a code that resets all lights to the same state.
|
56
|
+
|
57
|
+
The `program` command has multiple sub-commands:
|
58
|
+
|
59
|
+
```shell
|
60
|
+
$ pi-lights-control help program
|
61
|
+
NAME
|
62
|
+
program - Run a lights program
|
63
|
+
|
64
|
+
SYNOPSIS
|
65
|
+
pi-lights-control [global options] program blink_steady
|
66
|
+
pi-lights-control [global options] program combination
|
67
|
+
pi-lights-control [global options] program fast_blink
|
68
|
+
pi-lights-control [global options] program fast_fade
|
69
|
+
pi-lights-control [global options] program slow_blink
|
70
|
+
pi-lights-control [global options] program slow_fade
|
71
|
+
pi-lights-control [global options] program steady
|
72
|
+
pi-lights-control [global options] program step_fade
|
73
|
+
|
74
|
+
DESCRIPTION
|
75
|
+
Sends a command to run a specific lights program
|
76
|
+
|
77
|
+
COMMANDS
|
78
|
+
blink_steady - Blink Steady
|
79
|
+
combination - Combination
|
80
|
+
fast_blink - Fast Blink
|
81
|
+
fast_fade - Fast Fade
|
82
|
+
slow_blink - Slow Blink
|
83
|
+
slow_fade - Slow Fade
|
84
|
+
steady - Steady
|
85
|
+
step_fade - Step Fade
|
86
|
+
```
|
32
87
|
|
33
|
-
|
88
|
+
Remember to send the `--pin` argument!
|
34
89
|
|
35
90
|
### Library API
|
36
91
|
|
@@ -81,6 +136,8 @@ c.program(:blink_steady) # Lights blink twice, then are steady for a second or t
|
|
81
136
|
c.program(:step_fade) # Lights fade from off to on but at discrete brightness steps instead of a continuous increase/decrease
|
82
137
|
```
|
83
138
|
|
139
|
+
(Secret: The default remote actually sends 16 different codes! However codes 9–16 trigger the same eight programs as codes 1–8.)
|
140
|
+
|
84
141
|
## Roadmap
|
85
142
|
|
86
143
|
For v0.1.0:
|
data/exe/pi-lights-control
CHANGED
@@ -1,3 +1,127 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
require "gli"
|
3
4
|
require "pi-lights-control"
|
5
|
+
|
6
|
+
include GLI::App
|
7
|
+
|
8
|
+
program_desc "Control Home Collection Lights over GPIO and RF Transmitter"
|
9
|
+
|
10
|
+
desc "GPIO pin number for RF Transmitter. Mandatory."
|
11
|
+
flag [:p,:pin], type: Integer
|
12
|
+
|
13
|
+
desc "Turn lights on"
|
14
|
+
long_desc "Sends a \"power on\" command to the lights"
|
15
|
+
command :on do |c|
|
16
|
+
c.action do |global_options,options,args|
|
17
|
+
help_now!("No pin number specified") if global_options[:pin].nil?
|
18
|
+
command = PiLightsControl::Command.new(global_options[:pin].to_i)
|
19
|
+
command.power_on
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "Turn lights off"
|
24
|
+
long_desc "Sends a \"power off\" command to the lights"
|
25
|
+
command :off do |c|
|
26
|
+
c.action do |global_options,options,args|
|
27
|
+
help_now!("No pin number specified") if global_options[:pin].nil?
|
28
|
+
command = PiLightsControl::Command.new(global_options[:pin].to_i)
|
29
|
+
command.power_off
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "Sync multiple light sets"
|
34
|
+
long_desc "Sends a \"sync\" command to any lights in range"
|
35
|
+
command :sync do |c|
|
36
|
+
c.action do |global_options,options,args|
|
37
|
+
help_now!("No pin number specified") if global_options[:pin].nil?
|
38
|
+
command = PiLightsControl::Command.new(global_options[:pin].to_i)
|
39
|
+
command.sync_lights
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "Run a lights program"
|
44
|
+
long_desc "Sends a command to run a specific lights program"
|
45
|
+
command :program do |c|
|
46
|
+
c.desc "Combination"
|
47
|
+
c.long_desc "Cycles through the other 7 programs"
|
48
|
+
c.command :combination do |p|
|
49
|
+
p.action do |global_options,options,args|
|
50
|
+
help_now!("No pin number specified") if global_options[:pin].nil?
|
51
|
+
command = PiLightsControl::Command.new(global_options[:pin].to_i)
|
52
|
+
command.program(:combination)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
c.desc "Steady"
|
57
|
+
c.long_desc "Lights are continuously on"
|
58
|
+
c.command :steady do |p|
|
59
|
+
p.action do |global_options,options,args|
|
60
|
+
help_now!("No pin number specified") if global_options[:pin].nil?
|
61
|
+
command = PiLightsControl::Command.new(global_options[:pin].to_i)
|
62
|
+
command.program(:steady)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
c.desc "Slow Blink"
|
67
|
+
c.long_desc "Lights are on 1/2 second, then off 1/2 second"
|
68
|
+
c.command :slow_blink do |p|
|
69
|
+
p.action do |global_options,options,args|
|
70
|
+
help_now!("No pin number specified") if global_options[:pin].nil?
|
71
|
+
command = PiLightsControl::Command.new(global_options[:pin].to_i)
|
72
|
+
command.program(:slow_blink)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
c.desc "Fast Blink"
|
77
|
+
c.long_desc "Lights blink on/off much faster"
|
78
|
+
c.command :fast_blink do |p|
|
79
|
+
p.action do |global_options,options,args|
|
80
|
+
help_now!("No pin number specified") if global_options[:pin].nil?
|
81
|
+
command = PiLightsControl::Command.new(global_options[:pin].to_i)
|
82
|
+
command.program(:fast_blink)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
c.desc "Slow Fade"
|
87
|
+
c.long_desc "Lights fade from off to on at a slow rate"
|
88
|
+
c.command :slow_fade do |p|
|
89
|
+
p.action do |global_options,options,args|
|
90
|
+
help_now!("No pin number specified") if global_options[:pin].nil?
|
91
|
+
command = PiLightsControl::Command.new(global_options[:pin].to_i)
|
92
|
+
command.program(:slow_fade)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
c.desc "Fast Fade"
|
97
|
+
c.long_desc "Lights fade from off to on at a fast rate"
|
98
|
+
c.command :fast_fade do |p|
|
99
|
+
p.action do |global_options,options,args|
|
100
|
+
help_now!("No pin number specified") if global_options[:pin].nil?
|
101
|
+
command = PiLightsControl::Command.new(global_options[:pin].to_i)
|
102
|
+
command.program(:fast_fade)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
c.desc "Blink Steady"
|
107
|
+
c.long_desc "Lights blink twice, then are steady for a second or two"
|
108
|
+
c.command :blink_steady do |p|
|
109
|
+
p.action do |global_options,options,args|
|
110
|
+
help_now!("No pin number specified") if global_options[:pin].nil?
|
111
|
+
command = PiLightsControl::Command.new(global_options[:pin].to_i)
|
112
|
+
command.program(:blink_steady)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
c.desc "Step Fade"
|
117
|
+
c.long_desc "Lights fade from off to on but at discrete brightness steps instead of a continuous increase/decrease"
|
118
|
+
c.command :step_fade do |p|
|
119
|
+
p.action do |global_options,options,args|
|
120
|
+
help_now!("No pin number specified") if global_options[:pin].nil?
|
121
|
+
command = PiLightsControl::Command.new(global_options[:pin].to_i)
|
122
|
+
command.program(:step_fade)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
exit run(ARGV)
|
@@ -3,7 +3,7 @@ module PiLightsControl
|
|
3
3
|
attr_accessor :repeat_count
|
4
4
|
|
5
5
|
def initialize(pin, options = {})
|
6
|
-
RPi::GPIO.set_numbering
|
6
|
+
RPi::GPIO.set_numbering(options[:numbering] || :board)
|
7
7
|
@repeat_count = 6
|
8
8
|
@pin = pin
|
9
9
|
end
|
@@ -28,6 +28,7 @@ module PiLightsControl
|
|
28
28
|
private
|
29
29
|
|
30
30
|
def transmit_command(command)
|
31
|
+
RPi::GPIO.setup @pin, as: :output
|
31
32
|
@repeat_count.times do
|
32
33
|
command.each do |code|
|
33
34
|
high_length = PiLightsControl::CODE_TABLE[code][0]
|
@@ -40,6 +41,7 @@ module PiLightsControl
|
|
40
41
|
sleep(low_length * PiLightsControl::TIME_DELAY / 1000000.0)
|
41
42
|
end
|
42
43
|
end
|
44
|
+
RPi::GPIO.clean_up @pin
|
43
45
|
end
|
44
46
|
end
|
45
47
|
end
|
data/pi-lights-control.gemspec
CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
|
+
spec.add_dependency "gli", "~> 2.14.0"
|
24
25
|
spec.add_dependency "rpi_gpio", "~> 0.3.2"
|
25
26
|
|
26
27
|
spec.add_development_dependency "bundler", "~> 1.13"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pi-lights-control
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Badger
|
@@ -10,6 +10,20 @@ bindir: exe
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2016-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: gli
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.14.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.14.0
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rpi_gpio
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|