estorm_button 0.1.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/Gemfile +6 -0
- data/Gemfile.lock +31 -0
- data/README.md +16 -0
- data/bin/button_basic.rb +6 -0
- data/lib/estorm_button.rb +4 -0
- data/lib/estorm_button/button.rb +51 -0
- data/test/test_estormbutton.rb +22 -0
- data/test/test_helper.rb +17 -0
- metadata +66 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4c53eb332a69d782ee2dfebcb2cbe35b6502e522
|
4
|
+
data.tar.gz: 2c1a2e776203e21819704fe0e4cdbeb83a5c090a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2d4de7f5b2674c4489ee8612803383b869f35876065f6edf5b98f2cc84f6060fb9df21b619d2a9d6b2f5225c333b00f7089d6315107209ef6ade36e3c9ab1b3a
|
7
|
+
data.tar.gz: 93d7c7ecb962195cb46e26fa94425a28336c54b7f87b641c2c6a05939300ff7c8beb92fda72680587d3b1cdbf96658017b6eed432e11c1a56fc1fb8883db71ef
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
estorm_button (0.1.0)
|
5
|
+
pi_piper
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
codeclimate-test-reporter (0.4.0)
|
11
|
+
simplecov (>= 0.7.1, < 1.0.0)
|
12
|
+
docile (1.1.5)
|
13
|
+
ffi (1.9.3)
|
14
|
+
minitest (5.4.1)
|
15
|
+
multi_json (1.10.1)
|
16
|
+
pi_piper (1.3.2)
|
17
|
+
ffi
|
18
|
+
simplecov (0.9.0)
|
19
|
+
docile (~> 1.1.0)
|
20
|
+
multi_json
|
21
|
+
simplecov-html (~> 0.8.0)
|
22
|
+
simplecov-html (0.8.0)
|
23
|
+
|
24
|
+
PLATFORMS
|
25
|
+
ruby
|
26
|
+
|
27
|
+
DEPENDENCIES
|
28
|
+
codeclimate-test-reporter
|
29
|
+
estorm_button!
|
30
|
+
minitest
|
31
|
+
pi_piper
|
data/README.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
[](https://magnum.travis-ci.com/semdinsp/estorm_lotto_gem)
|
2
|
+
[[](https://codeclimate.com/repos/5308ca80695680067600452f/feed)
|
3
|
+
[](http://badge.fury.io/rb/estorm_lotto_gem)
|
4
|
+
|
5
|
+
estorm_button
|
6
|
+
============
|
7
|
+
|
8
|
+
Gem for button on raspberry pi.
|
9
|
+
|
10
|
+
|
11
|
+
pi_piper
|
12
|
+
==========
|
13
|
+
|
14
|
+
Remember that early versions of pi_piper can not hold the resistors high. You may need to call a python script to do that.
|
15
|
+
|
16
|
+
|
data/bin/button_basic.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
OS_FLAG=(/arm-linux/ =~ RUBY_PLATFORM) != nil
|
2
|
+
gem 'pi_piper' if OS_FLAG
|
3
|
+
require 'pi_piper' if OS_FLAG
|
4
|
+
module EstormButton
|
5
|
+
class Button
|
6
|
+
include PiPiper if OS_FLAG
|
7
|
+
|
8
|
+
def self.tap
|
9
|
+
puts "button TAPPED"
|
10
|
+
end
|
11
|
+
def self.test_flag
|
12
|
+
true
|
13
|
+
end
|
14
|
+
def bootup
|
15
|
+
puts " bootup script"
|
16
|
+
end
|
17
|
+
def self.led_mgr(cmd)
|
18
|
+
@@led.on
|
19
|
+
cmd
|
20
|
+
@@led.off
|
21
|
+
end
|
22
|
+
def self.held
|
23
|
+
puts "button HELD: "
|
24
|
+
end
|
25
|
+
#ADD MUTEX TO MANAGE TIME
|
26
|
+
def manage_buttons
|
27
|
+
bootup
|
28
|
+
@@pin=PiPiper::Pin.new(:pin => 23, :pull => :up)
|
29
|
+
@@led=PiPiper::Pin.new(:pin => 18, :direction => :out)
|
30
|
+
@@led.on
|
31
|
+
@@t=Time.now
|
32
|
+
PiPiper.watch :pin => 23,:trigger => :falling , :pull => :up do
|
33
|
+
#puts "Button pressed changed from #{last_value} to #{value}"
|
34
|
+
#puts "."
|
35
|
+
@@t=Time.now
|
36
|
+
end
|
37
|
+
PiPiper.watch :pin => 23,:trigger => :rising , :pull => :up do
|
38
|
+
delta = Time.now.to_f - @@t.to_f
|
39
|
+
@@t = Time.now
|
40
|
+
EstormLottoGem::Button.led_mgr(EstormLottoGem::Button.tap()) if 0.03 <= delta and delta < 0.7
|
41
|
+
EstormLottoGem::Button.led_mgr(EstormLottoGem::Button.held()) if 2 < delta and delta < 20
|
42
|
+
#puts "debounce" if 0.1 > delta
|
43
|
+
end
|
44
|
+
sleep 5
|
45
|
+
|
46
|
+
@@led.off
|
47
|
+
@@t=Time.now
|
48
|
+
PiPiper.wait
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end # module
|
@@ -0,0 +1,22 @@
|
|
1
|
+
puts File.dirname(__FILE__)
|
2
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
3
|
+
|
4
|
+
|
5
|
+
class EstormButtonTest < Minitest::Test
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@btn=EstormButton::Button.new
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
def test_button
|
13
|
+
assert @btn!=nil, "should not be nil"
|
14
|
+
assert EstormButton::Button.test_flag, "should return true"
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
puts "in test helper"
|
2
|
+
require 'rubygems'
|
3
|
+
require 'bundler/setup'
|
4
|
+
require "codeclimate-test-reporter"
|
5
|
+
#CodeClimate::TestReporter.start
|
6
|
+
require 'stringio'
|
7
|
+
require 'minitest/autorun'
|
8
|
+
require 'minitest/unit'
|
9
|
+
#SimpleCov.command_name 'test'
|
10
|
+
#SimpleCov.profiles.define 'mygem' do
|
11
|
+
# add_group "Gem", '/lib/' # additional config here
|
12
|
+
#end
|
13
|
+
#SimpleCov.start
|
14
|
+
|
15
|
+
require File.dirname(__FILE__) + '/../lib/estorm_lotto_gem'
|
16
|
+
|
17
|
+
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: estorm_button
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Scott Sproule
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: pi_piper
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: Tools for raspberry pi and other remote access
|
28
|
+
email: scott.sproule@ficonab.com
|
29
|
+
executables:
|
30
|
+
- button_basic.rb
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- Gemfile
|
35
|
+
- Gemfile.lock
|
36
|
+
- README.md
|
37
|
+
- bin/button_basic.rb
|
38
|
+
- lib/estorm_button.rb
|
39
|
+
- lib/estorm_button/button.rb
|
40
|
+
- test/test_estormbutton.rb
|
41
|
+
- test/test_helper.rb
|
42
|
+
homepage: http://github.com/semdinsp/estorm_button
|
43
|
+
licenses:
|
44
|
+
- MIT
|
45
|
+
metadata: {}
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options: []
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 1.3.4
|
60
|
+
requirements: []
|
61
|
+
rubyforge_project: estorm_button
|
62
|
+
rubygems_version: 2.2.2
|
63
|
+
signing_key:
|
64
|
+
specification_version: 4
|
65
|
+
summary: Estorm Button Controller for raspbery pi
|
66
|
+
test_files: []
|