tamashii-agent 0.3.3 → 0.3.4
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 +4 -4
- data/lib/tamashii/agent/device/buzzer/pwm_buzzer.rb +1 -1
- data/lib/tamashii/agent/device/keyboard/base.rb +6 -2
- data/lib/tamashii/agent/device/keyboard/button_matrix4x4.rb +64 -0
- data/lib/tamashii/agent/device/keyboard/ttp229_serial.rb +2 -2
- data/lib/tamashii/agent/{keyboard.rb → keyboard_logger.rb} +1 -1
- data/lib/tamashii/agent/master.rb +1 -1
- data/lib/tamashii/agent/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f8a6bed3bf8f1f705b5c21447fdf9ac48d6cf03
|
4
|
+
data.tar.gz: 339afb9a39fdf6f5c478d124ca0e73997fd49c93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c2bbc212637f2120e34eee02ac695c8543ad6c260e4f1bf1d31df0fc432a2a00e2d5f5129d19a80f811928c3341d0c4f0e2aae9b0bf960557851e9b3ec2434e
|
7
|
+
data.tar.gz: 0ba0b3399a3a811e6f4a616a23438d5f042c3a6e6ff380c168fa1e0741cf5992b9b111353cc548cda8b129cc8ea3bb2f6738724525fe720a7513e2d62eb510f8
|
@@ -10,7 +10,7 @@ module Tamashii
|
|
10
10
|
def initialize(*args)
|
11
11
|
super(*args)
|
12
12
|
initialize_hardware
|
13
|
-
@number_of_keys =
|
13
|
+
@number_of_keys = number_of_keys
|
14
14
|
@watcher_mode = fetch_option(:watch, default_watch)
|
15
15
|
@watcher_stopping = Concurrent::AtomicBoolean.new(false)
|
16
16
|
if @watcher_mode
|
@@ -19,6 +19,10 @@ module Tamashii
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
def number_of_keys
|
23
|
+
fetch_option(:number_of_keys, default_number_of_keys)
|
24
|
+
end
|
25
|
+
|
22
26
|
def default_number_of_keys
|
23
27
|
raise NotImplementedError
|
24
28
|
end
|
@@ -75,7 +79,7 @@ module Tamashii
|
|
75
79
|
end
|
76
80
|
|
77
81
|
def watcher_loop
|
78
|
-
|
82
|
+
logger.debug "Watcher started"
|
79
83
|
loop do
|
80
84
|
if watcher_stopping?
|
81
85
|
break
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'pi_piper'
|
2
|
+
require 'tamashii/agent/device/keyboard/base'
|
3
|
+
|
4
|
+
module Tamashii
|
5
|
+
module Agent
|
6
|
+
module Device
|
7
|
+
module Keyboard
|
8
|
+
class ButtonMatrix4x4 < Base
|
9
|
+
|
10
|
+
def initialize_hardware
|
11
|
+
@row_pins = fetch_option(:row_pins, default_row_pins).map do |pin_number|
|
12
|
+
PiPiper::Pin.new(pin: pin_number, direction: :out).tap {|pin| pin.on}
|
13
|
+
end
|
14
|
+
@col_pins = fetch_option(:col_pins, default_col_pins).map do |pin_number|
|
15
|
+
PiPiper::Pin.new(pin: pin_number, direction: :in, pull: :up)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def number_of_keys
|
20
|
+
16
|
21
|
+
end
|
22
|
+
|
23
|
+
def polling_interval
|
24
|
+
0.01
|
25
|
+
end
|
26
|
+
|
27
|
+
def default_row_pins
|
28
|
+
[21, 20, 16, 12]
|
29
|
+
end
|
30
|
+
|
31
|
+
def default_col_pins
|
32
|
+
[26, 19, 13, 6]
|
33
|
+
end
|
34
|
+
|
35
|
+
def finalize_hardware
|
36
|
+
(@row_pins + @col_pins).each do |pin|
|
37
|
+
unexport_pin(pin.pin)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def read_key
|
42
|
+
current_key = nil
|
43
|
+
@row_pins.each_with_index do |row_pin, row_index|
|
44
|
+
row_pin.off
|
45
|
+
@col_pins.each_with_index do |col_pin, col_index|
|
46
|
+
col_pin.read
|
47
|
+
key = row_index * 4 + col_index
|
48
|
+
if col_pin.off?
|
49
|
+
current_key = key
|
50
|
+
mark_key_down(key)
|
51
|
+
else
|
52
|
+
mark_key_up(key)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
row_pin.on
|
56
|
+
sleep 0.001
|
57
|
+
end
|
58
|
+
current_key
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -3,7 +3,7 @@ require 'tamashii/agent/networking'
|
|
3
3
|
require 'tamashii/agent/lcd'
|
4
4
|
require 'tamashii/agent/buzzer'
|
5
5
|
require 'tamashii/agent/card_reader'
|
6
|
-
require 'tamashii/agent/
|
6
|
+
require 'tamashii/agent/keyboard_logger'
|
7
7
|
require 'tamashii/agent/event'
|
8
8
|
|
9
9
|
module Tamashii
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tamashii-agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 蒼時弦也
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-09-
|
13
|
+
date: 2017-09-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -302,6 +302,7 @@ files:
|
|
302
302
|
- lib/tamashii/agent/device/card_reader/pn532_uart.rb
|
303
303
|
- lib/tamashii/agent/device/device_base.rb
|
304
304
|
- lib/tamashii/agent/device/keyboard/base.rb
|
305
|
+
- lib/tamashii/agent/device/keyboard/button_matrix4x4.rb
|
305
306
|
- lib/tamashii/agent/device/keyboard/dummy.rb
|
306
307
|
- lib/tamashii/agent/device/keyboard/ttp229_serial.rb
|
307
308
|
- lib/tamashii/agent/device/lcd/base.rb
|
@@ -314,7 +315,7 @@ files:
|
|
314
315
|
- lib/tamashii/agent/handler/lcd.rb
|
315
316
|
- lib/tamashii/agent/handler/remote_response.rb
|
316
317
|
- lib/tamashii/agent/handler/system.rb
|
317
|
-
- lib/tamashii/agent/
|
318
|
+
- lib/tamashii/agent/keyboard_logger.rb
|
318
319
|
- lib/tamashii/agent/lcd.rb
|
319
320
|
- lib/tamashii/agent/master.rb
|
320
321
|
- lib/tamashii/agent/networking.rb
|