pi_mote 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: be461efcc380ccb5d91c8aa845031a615ded2851
4
- data.tar.gz: 0ef99f7c00934f8977b3d8b0fd024b0783529e8b
2
+ SHA256:
3
+ metadata.gz: d8fdebfe73c4fcdfceac47f151e5f31b3c2e1d7ac8fd5427186b736a7ed42146
4
+ data.tar.gz: 4b2d8f47ed027bdfbdc84fc8dc0d6ec9e9441fdecc406de44a7a2d0375c993fa
5
5
  SHA512:
6
- metadata.gz: 3adac4a8c229deaee11e2da5b4f19acb3d9a0f3ffa773eb0cafc0f22971cf2b87566b5b5917807d784ff435d859b2e1b5cb671800f46425d163a664b62d850f5
7
- data.tar.gz: 501848cfdc1d2054835f5986e03ca1681d17c8059a9f92ea9b035802b95fed6d79be4f77951428b6a1185bca6e1f8bef7668183c82b80801493e5914cc8de8aa
6
+ metadata.gz: 154a3080770d772b1aad74034c20a3b79b20b1f29637cadc599af98eed0aee59b42a8f819fcfcaa25495e5f13370fac1b63c43285324b603b30a8431345dfe3b
7
+ data.tar.gz: '08a4d59dfbb45a7aa9bb6b34d9e74728809c7e02ade5cb88653bbe948f7a81e828f96ea56d6bedd48411b283d2c6384f8595c9a7daa0ce3675bd70d813290a2e'
data/lib/pi_mote.rb ADDED
@@ -0,0 +1,66 @@
1
+ require 'rpi_gpio'
2
+ require 'pi_mote/version'
3
+
4
+ module PiMote
5
+ class Sockets
6
+ ON_SIGNALS = {
7
+ 0 => %w(high high low high),
8
+ 1 => %w(high high high high),
9
+ 2 => %w(low high high high),
10
+ 3 => %w(high low high high),
11
+ 4 => %w(low low high high)
12
+ }.freeze
13
+
14
+ OFF_SIGNALS = {
15
+ 0 => %w(high high low low),
16
+ 1 => %w(high high high low),
17
+ 2 => %w(low high high low),
18
+ 3 => %w(high low high low),
19
+ 4 => %w(low low high low)
20
+ }.freeze
21
+
22
+ # Pin numbers in this method comes from energenie manual
23
+ def initialize(given_opt = {})
24
+ @opt = {
25
+ signal_pins: [17, 22, 23, 27],
26
+ on_off_pin: 24,
27
+ enable_pin: 25,
28
+ board_numbering: :bcm
29
+ }
30
+
31
+ @opt = @opt.merge(given_opt) if defined? given_opt
32
+ RPi::GPIO.set_numbering @opt[:board_numbering]
33
+
34
+ @opt[:signal_pins].map do |pin|
35
+ RPi::GPIO.setup pin, as: :output, initialize: :low
36
+ end
37
+ RPi::GPIO.setup @opt[:on_off_pin], as: :output, initialize: :low
38
+ RPi::GPIO.setup @opt[:enable_pin], as: :output, initialize: :low
39
+ end
40
+
41
+ def change_plug_state(socket, signals_hash)
42
+ socket_signals = signals_hash[socket]
43
+ @opt[:signal_pins].zip(socket_signals).each do |pin, signal|
44
+ RPi::GPIO.send("set_#{signal}", pin)
45
+ end
46
+ sleep(0.1)
47
+ RPi::GPIO.set_high @opt[:enable_pin]
48
+ sleep(0.25)
49
+ RPi::GPIO.set_low @opt[:enable_pin]
50
+ end
51
+
52
+ def switch_on(socket = 0)
53
+ change_plug_state(socket, ON_SIGNALS)
54
+ end
55
+
56
+ def switch_off(socket = 0)
57
+ change_plug_state(socket, OFF_SIGNALS)
58
+ end
59
+
60
+ def cleanup
61
+ @opt[:signal_pins].each { |pin| RPi::GPIO.clean_up pin }
62
+ RPi::GPIO.clean_up @opt[:enable_pin]
63
+ RPi::GPIO.clean_up @opt[:on_off_pin]
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,3 @@
1
+ module PiMote
2
+ VERSION = "0.1.1"
3
+ end
metadata CHANGED
@@ -1,57 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pi_mote
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Can Eldem
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-09 00:00:00.000000000 Z
11
+ date: 2021-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
14
+ name: rpi_gpio
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
20
- type: :development
19
+ version: 0.5.0
20
+ type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.0'
26
+ version: 0.5.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
28
+ name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '2.1'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '2.1'
41
41
  - !ruby/object:Gem::Dependency
42
- name: minitest
42
+ name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '5.0'
47
+ version: '3.10'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '5.0'
54
+ version: '3.10'
55
55
  description: Ruby library for pi mite raspberry pi
56
56
  email:
57
57
  - eldemcan@gmail.com
@@ -59,18 +59,8 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
- - ".gitignore"
63
- - ".ruby-version"
64
- - ".travis.yml"
65
- - CODE_OF_CONDUCT.md
66
- - Gemfile
67
- - LICENSE
68
- - LICENSE.txt
69
- - README.md
70
- - Rakefile
71
- - bin/console
72
- - bin/setup
73
- - pi_mote.gemspec
62
+ - lib/pi_mote.rb
63
+ - lib/pi_mote/version.rb
74
64
  homepage: https://github.com/eldemcan/pi-mote-ruby
75
65
  licenses:
76
66
  - MIT
@@ -90,8 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
80
  - !ruby/object:Gem::Version
91
81
  version: '0'
92
82
  requirements: []
93
- rubyforge_project:
94
- rubygems_version: 2.6.14.3
83
+ rubygems_version: 3.0.3
95
84
  signing_key:
96
85
  specification_version: 4
97
86
  summary: Control your pi mote with ruby
data/.gitignore DELETED
@@ -1,50 +0,0 @@
1
- *.gem
2
- *.rbc
3
- /.config
4
- /coverage/
5
- /InstalledFiles
6
- /pkg/
7
- /spec/reports/
8
- /spec/examples.txt
9
- /test/tmp/
10
- /test/version_tmp/
11
- /tmp/
12
-
13
- # Used by dotenv library to load environment variables.
14
- # .env
15
-
16
- ## Specific to RubyMotion:
17
- .dat*
18
- .repl_history
19
- build/
20
- *.bridgesupport
21
- build-iPhoneOS/
22
- build-iPhoneSimulator/
23
-
24
- ## Specific to RubyMotion (use of CocoaPods):
25
- #
26
- # We recommend against adding the Pods directory to your .gitignore. However
27
- # you should judge for yourself, the pros and cons are mentioned at:
28
- # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29
- #
30
- # vendor/Pods/
31
-
32
- ## Documentation cache and generated files:
33
- /.yardoc/
34
- /_yardoc/
35
- /doc/
36
- /rdoc/
37
-
38
- ## Environment normalization:
39
- /.bundle/
40
- /vendor/bundle
41
- /lib/bundler/man/
42
-
43
- # for a library or gem, you might want to ignore these files since the code is
44
- # intended to run in multiple environments; otherwise, check them in:
45
- # Gemfile.lock
46
- # .ruby-version
47
- # .ruby-gemset
48
-
49
- # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
- .rvmrc
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 2.4.5
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.4.5
7
- before_install: gem install bundler -v 2.0.1
data/CODE_OF_CONDUCT.md DELETED
@@ -1,74 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, gender identity and expression, level of experience,
9
- nationality, personal appearance, race, religion, or sexual identity and
10
- orientation.
11
-
12
- ## Our Standards
13
-
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
16
-
17
- * Using welcoming and inclusive language
18
- * Being respectful of differing viewpoints and experiences
19
- * Gracefully accepting constructive criticism
20
- * Focusing on what is best for the community
21
- * Showing empathy towards other community members
22
-
23
- Examples of unacceptable behavior by participants include:
24
-
25
- * The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- * Trolling, insulting/derogatory comments, and personal or political attacks
28
- * Public or private harassment
29
- * Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
31
- * Other conduct which could reasonably be considered inappropriate in a
32
- professional setting
33
-
34
- ## Our Responsibilities
35
-
36
- Project maintainers are responsible for clarifying the standards of acceptable
37
- behavior and are expected to take appropriate and fair corrective action in
38
- response to any instances of unacceptable behavior.
39
-
40
- Project maintainers have the right and responsibility to remove, edit, or
41
- reject comments, commits, code, wiki edits, issues, and other contributions
42
- that are not aligned to this Code of Conduct, or to ban temporarily or
43
- permanently any contributor for other behaviors that they deem inappropriate,
44
- threatening, offensive, or harmful.
45
-
46
- ## Scope
47
-
48
- This Code of Conduct applies both within project spaces and in public spaces
49
- when an individual is representing the project or its community. Examples of
50
- representing a project or community include using an official project e-mail
51
- address, posting via an official social media account, or acting as an appointed
52
- representative at an online or offline event. Representation of a project may be
53
- further defined and clarified by project maintainers.
54
-
55
- ## Enforcement
56
-
57
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at eldemcan@gmail.com. All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
63
-
64
- Project maintainers who do not follow or enforce the Code of Conduct in good
65
- faith may face temporary or permanent repercussions as determined by other
66
- members of the project's leadership.
67
-
68
- ## Attribution
69
-
70
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at [http://contributor-covenant.org/version/1/4][version]
72
-
73
- [homepage]: http://contributor-covenant.org
74
- [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in pi_mote.gemspec
4
- gemspec
5
-
6
- gem 'rpi_gpio', '~> 0.3.3'
data/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2018 Can Eldem
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
data/LICENSE.txt DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2019 Can Eldem
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
data/README.md DELETED
@@ -1,53 +0,0 @@
1
- # Pi Mote ruby
2
- Energenie [Pi-mote](https://energenie4u.co.uk/catalogue/product/ENER002-2PI) ruby api for Raspberry Pi.
3
-
4
- ## Installation
5
-
6
- Add this line to your application's Gemfile:
7
-
8
- ```ruby
9
- gem 'pi_mote'
10
- ```
11
-
12
- And then execute:
13
-
14
- $ bundle
15
-
16
- Or install it yourself as:
17
-
18
- $ gem install pi_mote
19
-
20
- # Dependency
21
-
22
- You need to install [rpi gpio](https://github.com/ClockVapor/rpi_gpio) library.
23
- If you encounter problems related with permissions you can change ownership of `/dev/gpiomem` folder with `sudo chown root.gpio /dev/gpiomem
24
- sudo chmod g+rw /dev/gpiomem` chmod one will give write permissions.
25
-
26
- # Usage
27
-
28
- ```ruby
29
- sc = PiMote.new
30
- sc.switch_on(socket_number)
31
- sc.switch_off(socket_number)
32
-
33
- sc.switch_on # all sockets on
34
- sc.switch_off # all sockets on
35
- ```
36
-
37
- ## Development
38
-
39
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
40
-
41
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
42
-
43
- ## Contributing
44
-
45
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/pi_mote. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
46
-
47
- ## License
48
-
49
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
50
-
51
- ## Code of Conduct
52
-
53
- Everyone interacting in the PiMote project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/celdem/pi_mote/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
3
-
4
- Rake::TestTask.new(:test) do |t|
5
- t.libs << "test"
6
- t.libs << "lib"
7
- t.test_files = FileList["test/**/*_test.rb"]
8
- end
9
-
10
- task :default => :test
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "pi_mote"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
data/pi_mote.gemspec DELETED
@@ -1,42 +0,0 @@
1
-
2
- lib = File.expand_path("../lib", __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "pi_mote/version"
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "pi_mote"
8
- spec.version = PiMote::VERSION
9
- spec.authors = ["Can Eldem"]
10
- spec.email = ["eldemcan@gmail.com"]
11
-
12
- spec.summary = %q{Control your pi mote with ruby}
13
- spec.description = %q{Ruby library for pi mite raspberry pi}
14
- spec.homepage = "https://github.com/eldemcan/pi-mote-ruby"
15
- spec.license = "MIT"
16
-
17
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
- # to allow pushing to a single host or delete this section to allow pushing to any host.
19
- # if spec.respond_to?(:metadata)
20
- # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
21
-
22
- # spec.metadata["homepage_uri"] = spec.homepage
23
- # spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
24
- # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
25
- # else
26
- # raise "RubyGems 2.0 or newer is required to protect against " \
27
- # "public gem pushes."
28
- # end
29
-
30
- # Specify which files should be added to the gem when it is released.
31
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
32
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
33
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
34
- end
35
- spec.bindir = "exe"
36
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
37
- spec.require_paths = ["lib"]
38
-
39
- spec.add_development_dependency "bundler", "~> 2.0"
40
- spec.add_development_dependency "rake", "~> 10.0"
41
- spec.add_development_dependency "minitest", "~> 5.0"
42
- end