tamashii-agent 0.3.3 → 0.3.4

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
2
  SHA1:
3
- metadata.gz: f9d22e0f412ffe228a1d91b28c78da5108f60024
4
- data.tar.gz: 686f0b637d4a6a941b06fff85df869b568fb4f0d
3
+ metadata.gz: 4f8a6bed3bf8f1f705b5c21447fdf9ac48d6cf03
4
+ data.tar.gz: 339afb9a39fdf6f5c478d124ca0e73997fd49c93
5
5
  SHA512:
6
- metadata.gz: 59b573c6b0a744a33c19d1424d62abb05173df4e1fa546c48ec5bb8d253c65d4ba3c34fef3217c7113181968e396b9ca9ece0d40ffa576e04034684e36613638
7
- data.tar.gz: 7cdd4e93f41cd4e66e640c8636917f2c4c93b03a50c5e591a73677c33c1911e23c7702411c0c80334ce1e311f8cfa43562b73fb9dc500f889dfe791bbefa93ab
6
+ metadata.gz: 7c2bbc212637f2120e34eee02ac695c8543ad6c260e4f1bf1d31df0fc432a2a00e2d5f5129d19a80f811928c3341d0c4f0e2aae9b0bf960557851e9b3ec2434e
7
+ data.tar.gz: 0ba0b3399a3a811e6f4a616a23438d5f042c3a6e6ff380c168fa1e0741cf5992b9b111353cc548cda8b129cc8ea3bb2f6738724525fe720a7513e2d62eb510f8
@@ -34,7 +34,7 @@ module Tamashii
34
34
  end
35
35
 
36
36
  def default_pin
37
- 19
37
+ 18
38
38
  end
39
39
 
40
40
  private
@@ -10,7 +10,7 @@ module Tamashii
10
10
  def initialize(*args)
11
11
  super(*args)
12
12
  initialize_hardware
13
- @number_of_keys = fetch_option(:number_of_keys, default_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
- puts "watcher started"
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
@@ -33,8 +33,8 @@ module Tamashii
33
33
  end
34
34
 
35
35
  def finalize_hardware
36
- unexport_pin(fetch_option(:scl_pin, default_scl_pin))
37
- unexport_pin(fetch_option(:sdo_pin, default_sdo_pin))
36
+ unexport_pin(@scl_pin.pin)
37
+ unexport_pin(@sdo_pin.pin)
38
38
  end
39
39
 
40
40
  def read_key
@@ -3,7 +3,7 @@ require 'tamashii/agent/event'
3
3
 
4
4
  module Tamashii
5
5
  module Agent
6
- class Keyboard < Component
6
+ class KeyboardLogger < Component
7
7
  def initialize(name, master, options = {})
8
8
  options[:watch] = true # Force enable watch mode
9
9
  super
@@ -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/keyboard'
6
+ require 'tamashii/agent/keyboard_logger'
7
7
  require 'tamashii/agent/event'
8
8
 
9
9
  module Tamashii
@@ -1,5 +1,5 @@
1
1
  module Tamashii
2
2
  module Agent
3
- VERSION = "0.3.3"
3
+ VERSION = "0.3.4"
4
4
  end
5
5
  end
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.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 00:00:00.000000000 Z
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/keyboard.rb
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