celadonremote 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8a0e4b0dfdc6a92bce531ccde5d19e2712b9e2b1c19da926df418f7c48998779
4
+ data.tar.gz: 3bf0229f84b2f7592099a4275b04b2d3f39f0803976cb6842d1cf1abe0100298
5
+ SHA512:
6
+ metadata.gz: a42895e00bb1cc6cfa6d23b9c32644ba3e8c70f25f58c78471e484d521fba60b73bb6259ebdf9e009fa833327355dd8e578afdefc972f740a53c5a779b97427c
7
+ data.tar.gz: 6f3d482e165b9ab3d3b91c99cce96d2a064417ad86327ae0b527261d6ddf9f61ce5d64266b5194de9d2737ea340ff3b51d7646843dbf6c4b55821b0590f77e0a
@@ -0,0 +1,15 @@
1
+ require_relative "lib/celadonremote/version.rb"
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'celadonremote'
5
+ s.version = CeladonRemote::VERSION
6
+ s.summary = "Celadon Remote"
7
+ s.description = "A way to interface with the celadon RCV-3000 receiver"
8
+ s.authors = ["Matthias Lee"]
9
+ s.email = 'matthias@matthiasclee.com'
10
+ dirfiles = Dir.glob("**/*")
11
+ dirfiles.delete("celadonremote-#{CeladonRemote::VERSION}.gem")
12
+ s.files = dirfiles
13
+ s.add_runtime_dependency "serialport", '~> 1.3.2'
14
+ s.require_paths = ["lib"]
15
+ end
@@ -0,0 +1,36 @@
1
+ module CeladonRemote
2
+ class Receiver
3
+ def initialize(port, code=(5..6), eol:"\r\n", eot:"N!")
4
+ @ser = SerialPort.new(port, 9600, 8, 1, SerialPort::NONE)
5
+ @eol = eol
6
+ @code = code
7
+ @eot = eot
8
+ @codes = {}
9
+ end
10
+
11
+ def oncode(code, &b)
12
+ @codes[code] = b
13
+ end
14
+
15
+ def start_listener(allow_hold:false)
16
+ prev_line = ""
17
+
18
+ loop do
19
+ l=@ser.readline(@eol)
20
+
21
+ if allow_hold && l.start_with?(@eot)
22
+ code = prev_line[@code]
23
+ elsif l.start_with?(@eot)
24
+ next
25
+ else
26
+ code = l[@code]
27
+ prev_line = l
28
+ end
29
+
30
+ if @codes[code]
31
+ @codes[code].call
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,3 @@
1
+ module CeladonRemote
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,6 @@
1
+ require_relative "celadonremote/version.rb"
2
+ require_relative "celadonremote/receiver.rb"
3
+ require "serialport"
4
+
5
+ module CeladonRemote
6
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: celadonremote
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Matthias Lee
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-04-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: serialport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.3.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.3.2
27
+ description: A way to interface with the celadon RCV-3000 receiver
28
+ email: matthias@matthiasclee.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - celadonremote.gemspec
34
+ - lib/celadonremote.rb
35
+ - lib/celadonremote/receiver.rb
36
+ - lib/celadonremote/version.rb
37
+ homepage:
38
+ licenses: []
39
+ metadata: {}
40
+ post_install_message:
41
+ rdoc_options: []
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ requirements: []
55
+ rubygems_version: 3.1.6
56
+ signing_key:
57
+ specification_version: 4
58
+ summary: Celadon Remote
59
+ test_files: []