tlalok-adapter-ospi 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 21ef739aa41e8dd6fa0dda26e0456ee8c4082dc5
4
+ data.tar.gz: 2625f354450ed31562665d783b5a4ac5f9c4b513
5
+ SHA512:
6
+ metadata.gz: 5766fc8a5ed56873f66a1a7d6d0a5a88aaef7b08a8574f3bf835569905bc5b6a028371b9f672e9ec45a01ca795f0c0d5ea2ff38483158e34ce7b6c0d9220ff29
7
+ data.tar.gz: c88f937dd4192aee6dc5155caa0b17a649df0107c0af80d1503f09c2bc68b53fd5c2c09236b07f376d318d2166073f953eec70f20d32512a5abead66c0ec5e22
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.2
4
+ before_install: gem install bundler -v 1.10.0
5
+ bundler_args: --without raspberry
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in tlalok-adapter-ospi.gemspec
4
+ gemspec
5
+
6
+ group :raspberry do
7
+ gem "wiringpi", "~> 2.0"
8
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Brad Horrocks
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.
@@ -0,0 +1,65 @@
1
+ # Tlalok::Adapter::Ospi
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/tlalok-adapter-ospi.svg)](http://badge.fury.io/rb/tlalok-adapter-ospi)
4
+ [![Build Status](https://travis-ci.org/tlalok-sprinklers/tlalok-adapter-ospi.svg?branch=master)](https://travis-ci.org/tlalok-sprinklers/tlalok-adapter-ospi/)
5
+ [![Code Climate](https://codeclimate.com/github/tlalok-sprinklers/tlalok-adapter-ospi/badges/gpa.svg)](https://codeclimate.com/github/tlalok-sprinklers/tlalok-adapter-ospi)
6
+ [![Dependency Status](https://gemnasium.com/tlalok-sprinklers/tlalok-adapter-ospi.svg)](https://gemnasium.com/tlalok-sprinklers/tlalok-adapter-ospi)
7
+
8
+ An [OSPI](http://rayshobby.net/ospi/) Adapter for [Tlalok](https://github.com/tlalok-sprinklers)
9
+
10
+
11
+ Can also be used as a stand alone executable, useful if you wanted to cron your sprinklers.
12
+
13
+ ## Installation
14
+
15
+ Add this line to your application's Gemfile:
16
+
17
+ ```ruby
18
+ gem 'tlalok-adapter-ospi'
19
+ ```
20
+
21
+ And then execute:
22
+
23
+ $ bundle
24
+
25
+ Or install it yourself as:
26
+
27
+ $ gem install tlalok-adapter-ospi
28
+
29
+ ## Usage
30
+
31
+ ### CLI
32
+
33
+ # this will run station one
34
+ ospi open 1
35
+
36
+ # this will stop station one
37
+ ospi close 1
38
+
39
+ ### From the code
40
+
41
+ ```ruby
42
+ require 'tlalok/adapter/ospi'
43
+
44
+ controller = ::Tlalok::Adapter::Ospi::Controller.new
45
+
46
+ # this will open station 1
47
+ controller.open 1
48
+
49
+ controller.close 1
50
+ ```
51
+
52
+ ## Development
53
+
54
+ 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. Run `bundle exec tlalok-adapter-ospi` to use the gem in this directory, ignoring other installed copies of this gem.
55
+
56
+ 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).
57
+
58
+ ## Contributing
59
+
60
+ Bug reports and pull requests are welcome on GitHub at https://github.com/tlalok-sprinklers/tlalok-adapter-ospi.
61
+
62
+
63
+ ## License
64
+
65
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,10 @@
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
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "tlalok/adapter/ospi"
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
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "tlalok/adapter/ospi"
4
+
5
+
6
+ Tlalok::Adapter::Ospi::CLI.start(ARGV)
@@ -0,0 +1,19 @@
1
+ require "tlalok/adapter/ospi/version"
2
+ require 'thor'
3
+
4
+ begin
5
+ require 'wiringpi'
6
+ rescue LoadError
7
+ require 'tlalok/adapter/ospi/wiringpi'
8
+ end
9
+
10
+ module Tlalok
11
+ module Adapter
12
+ module Ospi
13
+
14
+ end
15
+ end
16
+ end
17
+
18
+ require 'tlalok/adapter/ospi/cli'
19
+ require 'tlalok/adapter/ospi/controller'
@@ -0,0 +1,22 @@
1
+ module Tlalok
2
+ module Adapter
3
+ module Ospi
4
+ class CLI < Thor
5
+
6
+ map ["run", "start", "open"] => "on"
7
+ desc "on STATION_NUM", "Turn STATION_NUM on"
8
+ def on(station)
9
+ controller = Controller.new
10
+ controller.open station.to_i
11
+ end
12
+
13
+ map ["stop", "close"] => "off"
14
+ desc "off STATION_NUM", "Turn STATION_NUM off"
15
+ def off(station)
16
+ controller = Controller.new
17
+ controller.close station.to_i
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,54 @@
1
+ module Tlalok
2
+ module Adapter
3
+ module Ospi
4
+ class Controller
5
+
6
+ # wiring pi pin numbers
7
+ CLOCK_PIN = 7
8
+ DATA_PIN = 2
9
+ PIN_SR_NOE = 0
10
+ LATCH_PIN = 3
11
+
12
+ NUMBER_OF_STATIONS = 8
13
+
14
+ def initialize(io = nil)
15
+ @stations = [0] * 8
16
+ @io = io || WiringPi::GPIO.new do |gpio|
17
+ # Set the pinmode of pin 0 for output
18
+ gpio.pin_mode(CLOCK_PIN, 1)
19
+ gpio.pin_mode(DATA_PIN, 1)
20
+ gpio.pin_mode(PIN_SR_NOE, 1)
21
+ gpio.pin_mode(LATCH_PIN, 1)
22
+ end
23
+ end
24
+
25
+ def open(station_number)
26
+ set_station station_number, 1
27
+ end
28
+
29
+ def close(station_number)
30
+ set_station station_number, 0
31
+ end
32
+
33
+ def close_all()
34
+ @stations = [0] * 8
35
+ send_array @stations
36
+ end
37
+
38
+ def set_station(station_number, status)
39
+ station_index = station_number - 1
40
+ @stations[station_index] = status
41
+ send_array @stations
42
+ end
43
+
44
+ def send_array(array)
45
+ @io.digital_write(LATCH_PIN, 0)
46
+ @io.shift_out(DATA_PIN, CLOCK_PIN, 0, array.join.to_i(2))
47
+ @io.digital_write(LATCH_PIN, 1)
48
+ end
49
+
50
+
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,7 @@
1
+ module Tlalok
2
+ module Adapter
3
+ module Ospi
4
+ VERSION = "1.0.0"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,17 @@
1
+ module Tlalok
2
+ module Adapter
3
+ module Ospi
4
+ module WiringPi
5
+ class GPIO
6
+ def digital_write(pin, value)
7
+
8
+ end
9
+
10
+ def shift_out(pin, pin_other, mode, value)
11
+
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'tlalok/adapter/ospi/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "tlalok-adapter-ospi"
8
+ spec.version = Tlalok::Adapter::Ospi::VERSION
9
+ spec.authors = ["defektive"]
10
+ spec.email = ["sirbradleyd@gmail.com"]
11
+
12
+ spec.summary = %q{gem for controlling an open sprinkler pi http://rayshobby.net/ospi/}
13
+ spec.homepage = "https://github.com/tlalok-sprinklers/tlalok-adapter-ospi"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "thor", "~> 0.19"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.10"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "minitest"
26
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tlalok-adapter-ospi
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - defektive
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-08-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.19'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.19'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description:
70
+ email:
71
+ - sirbradleyd@gmail.com
72
+ executables:
73
+ - ospi
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - bin/console
84
+ - bin/setup
85
+ - exe/ospi
86
+ - lib/tlalok/adapter/ospi.rb
87
+ - lib/tlalok/adapter/ospi/cli.rb
88
+ - lib/tlalok/adapter/ospi/controller.rb
89
+ - lib/tlalok/adapter/ospi/version.rb
90
+ - lib/tlalok/adapter/ospi/wiringpi.rb
91
+ - tlalok-adapter-ospi.gemspec
92
+ homepage: https://github.com/tlalok-sprinklers/tlalok-adapter-ospi
93
+ licenses:
94
+ - MIT
95
+ metadata: {}
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubyforge_project:
112
+ rubygems_version: 2.4.5
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: gem for controlling an open sprinkler pi http://rayshobby.net/ospi/
116
+ test_files: []