rfbeam 0.4.8 → 0.4.10

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
  SHA256:
3
- metadata.gz: a0b3dc099fbf26e535ffa58dad9e643a2556168528d206d8f0fb7d73507cba3e
4
- data.tar.gz: f75cfd53fe0bc32e982dd75e53af8a9e7c976f64abc3eca43ea1a31549ba6bd8
3
+ metadata.gz: 1d9b598dd013b48a6c19e5755f4af6a687a1fd2b82ac2aaa3d38c3a8b98db2f8
4
+ data.tar.gz: d1bf6b228eb6c0cff37ae44a178c7eb9b1e80e033894d2ae2456e2882d6ac180
5
5
  SHA512:
6
- metadata.gz: 6f00551148744f9d8f214ebef729fa5f26e84c8403f88ce1cd6534c407a577fc439f284c20899d08d861252f269c007126a06501a4175d0c802c0581c0030861
7
- data.tar.gz: cf59d75f0b12ea6bfa7b6d0dd519da5f8ef5c700c5cdf66d177e8e6bcea59911550aa7c7215049deebc7e13c0c9430ae8b6d6c5ba44c57ad9db6a1155e2c7f86
6
+ metadata.gz: 277a4e68325e439d64db8ffc1af15b5b1aeae5be8b9f9718100d6fd9cdd7bb228274c51a856960d775f8f3ecf041616e59b039acf22b029b990d4b5488793053
7
+ data.tar.gz: 54b6209b877a2304139c8ea615d9fe0437b3393ee75385c00735ffe24279d0940d29b061cf28f6fbe47cdd7c5a2b208aecffe97a49b266f2aa8fad751cf52ae2
data/Gemfile.lock CHANGED
@@ -9,7 +9,7 @@ GIT
9
9
  PATH
10
10
  remote: .
11
11
  specs:
12
- rfbeam (0.4.8)
12
+ rfbeam (0.4.10)
13
13
  activesupport (~> 6.1.0)
14
14
  rubyserial (~> 0.6.0)
15
15
  thor (~> 1.2.1)
data/README.md CHANGED
@@ -1,11 +1,14 @@
1
1
  # Rfbeam
2
2
 
3
- ![Gem](https://img.shields.io/gem/v/rfbeam?color=green&label=version)
4
3
  ![Ruby](https://img.shields.io/static/v1?message=Ruby&color=red&logo=Ruby&logoColor=FFFFFF&label=v3.1.2)
5
4
  ![Ruby](https://img.shields.io/gitlab/license/robcarruthers/rfbeam?color=orange)
6
5
 
7
- RfBeam is a simple, high-level interface for the RFBeam radar modules.
8
- The user can query process and raw detection data and set the radar parameters for the sensor.
6
+ ![Gem](https://img.shields.io/gem/v/rfbeam?color=green&label=version)
7
+ ![Build](https://img.shields.io/gitlab/pipeline-status/robcarruthers/rfbeam?branch=master)
8
+ ![Build](https://img.shields.io/gitlab/last-commit/robcarruthers/rfbeam)
9
+
10
+ RfBeam is a simple, high-level interface and CLI for the RFBeam radar modules.
11
+ The user can query/set radar parameters, raw detection data and stream data from the sensor.
9
12
 
10
13
  At this stage it only works on Linux and Mac with the K-LD7 module.
11
14
 
@@ -23,75 +26,90 @@ If bundler is not being used to manage dependencies, install the gem by executin
23
26
 
24
27
  The RfBeam class will return the path of any connected modules
25
28
 
26
- RfBeam.connected
29
+ ```ruby
30
+ RfBeam.connected
31
+ => ["/dev/ttyUSB0"]
32
+ ```
27
33
 
28
- Simple pass the path and baude rate to initialise a new radar object
34
+ Simple pass the path and optional baude rate (default: 115200) to initialise a new radar object
29
35
 
30
- RfBeam::KLD7.new("/dev/ttyUSB0", 115200) do |radar|
31
- puts radar.config
32
- end
36
+ ```ruby
37
+ RfBeam::KLD7.new("/dev/ttyUSB0") do |radar|
38
+ puts radar.config
39
+ end
40
+ =>
41
+ Software Version: K-LD7_APP-RFB-0103
42
+ Base Frequency: Low
43
+ Maximum Speed: 100km/h
44
+ Maximum Range: 100m
45
+ Threshold Offset: 30db
46
+ Tracking Filter Type: Long Visibility
47
+ Vibration Suppression: 16
48
+ Minimum Detection Distance: 0%
49
+ Maximum Detection Distance: 100%
50
+ Minimum Detection Angle: -10°
51
+ Maximum Detection Angle: 90°
52
+ Minimum Detection Speed: 0%
53
+ Maximum Detection Speed: 100%
54
+ Detection Direction: Both
55
+ Range Threshold: 10%
56
+ Angle Threshold: 0°
57
+ Speed Threshold: 50%
58
+ Digital Output 1: Direction
59
+ Digital Output 2: Angle
60
+ Digital Output 3: Range
61
+ Hold Time: 1s
62
+ Micro Detection Trigger: Off
63
+ Micro Detection Sensativity: 4
64
+ ```
33
65
 
34
- ## RfBeam::K_ld7 API
66
+ ## RfBeam::KLD7 API
35
67
 
36
68
  ### detection?
37
69
 
38
70
  Returns true if the module has a valid detection.
39
71
 
40
- radar.detection?
41
- => true
72
+ ```ruby
73
+ radar.detection?
74
+ => true
75
+ ```
42
76
 
43
77
  ### ddat
44
78
 
45
79
  Returns an array with the current detection values
46
80
 
47
- radar.ddat
48
- => ["DDAT", 6, 0, 0, 0, 0, 0, 0]
81
+ ```ruby
82
+ radar.ddat
83
+ => ["DDAT", 6, 0, 0, 0, 0, 0, 0]
84
+ ```
49
85
 
50
86
  ### tdat
51
87
 
52
88
  Returns a hash with the current tracked object values
53
89
 
54
- radar.tdat
55
- => {:dist=>68, :speed=>196, :angle=>469, :mag=>6303}
90
+ ```ruby
91
+ radar.tdat
92
+ => ["TDAT", 4, 68, 196, 469, 6303]
93
+ ```
56
94
 
57
95
  ### grps
58
96
 
59
97
  Returns the Parameter settings, values map to setting as detailed in the device datasheet.
60
98
 
61
- radar.grps
62
- => ["RPST", 42, "K-LD7_APP-RFB-0103", 1, 1, 1, 30, 0, 2, 0, 50, -90, 90, 0, 100, 2, 10, 0, 50, 0, 1, 2, 1, 0, 4]
99
+ ```ruby
100
+ radar.grps
101
+ => ["RPST", 42, "K-LD7_APP-RFB-0103", 1, 1, 1, 30, 0, 2, 0, 50, -90, 90, 0, 100, 2, 10, 0, 50, 0, 1, 2, 1, 0, 4]
102
+ ```
63
103
 
64
104
  ### config
65
105
 
66
106
  Returns a formatted String of all parameter settings. The only way to read parameter settings is with config
67
107
 
68
- radar.config
69
-
70
- Software Version: K-LD7_APP-RFB-0103
71
- Base Frequency: Low
72
- Maximum Speed: 100km/h
73
- Maximum Range: 100m
74
- Threshold Offset: 30db
75
- Tracking Filter Type: Long Visibility
76
- Vibration Suppression: 16
77
- Minimum Detection Distance: 0%
78
- Maximum Detection Distance: 100%
79
- Minimum Detection Angle: -10°
80
- Maximum Detection Angle: 90°
81
- Minimum Detection Speed: 0%
82
- Maximum Detection Speed: 100%
83
- Detection Direction: Both
84
- Range Threshold: 10%
85
- Angle Threshold: 0°
86
- Speed Threshold: 50%
87
- Digital Output 1: Direction
88
- Digital Output 2: Angle
89
- Digital Output 3: Range
90
- Hold Time: 1s
91
- Micro Detection Trigger: Off
92
- Micro Detection Sensativity: 4
93
-
94
- ## Parameter API
108
+ ```ruby
109
+ radar.config
110
+ ```
111
+
112
+ ## Radar Parameters
95
113
 
96
114
  ### Base Frequency
97
115
 
@@ -315,7 +333,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
315
333
 
316
334
  ## Contributing
317
335
 
318
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rfbeam.
336
+ Bug reports and pull requests are welcome on GitHub at https://github.com/robcarruthers/rfbeam.
319
337
 
320
338
  ## License
321
339
 
data/lib/rfbeam/cli.rb CHANGED
@@ -36,7 +36,7 @@ module RfBeam
36
36
 
37
37
  desc 'set_param <radar_id> <key> <value>', 'Set radar parameters, see readme for keys'
38
38
  def set_param(radar_id, param, value)
39
- return @logger.warn("Invalid param: '#{param}'") unless RfBeam::K_ld7::RADAR_PARAMETERS.include?(param.to_sym)
39
+ return @logger.warn("Invalid param: '#{param}'") unless Kld7::RADAR_PARAMETERS.include?(param.to_sym)
40
40
 
41
41
  r = radar(radar_id)
42
42
  r.send("#{param}=", value.to_i)
@@ -5,6 +5,17 @@ require 'tty-table'
5
5
  module RfBeam
6
6
  module Kld7
7
7
  class CliFormatter
8
+ def format(type, data)
9
+ case type
10
+ when :tdat
11
+ tdat(data)
12
+ when :pdat
13
+ pdat(data)
14
+ when :ddat
15
+ ddat(data)
16
+ end
17
+ end
18
+
8
19
  def tdat(data)
9
20
  { dist: data[2], speed: data[3], angle: data[4], mag: data[5] }
10
21
  end
@@ -20,20 +31,16 @@ module RfBeam
20
31
  table
21
32
  end
22
33
 
34
+ private
35
+
23
36
  def ddat(data)
24
- if data[2] == 1
25
- labels = ['Detection', 'Micro Detection', 'Angle', 'Direction', 'Range', 'Speed']
26
- labels
27
- .map
28
- .with_index { |label, index| "#{label}: #{DETECTION_FLAGS[to_symbol(label)][data[index + 2]]}" }
29
- .join("\n")
30
- else
31
- 'DDAT: No Detection'
32
- end
37
+ labels = ['Detection', 'Micro Detection', 'Angle', 'Direction', 'Range', 'Speed']
38
+ labels
39
+ .map
40
+ .with_index { |label, index| "#{label}: #{DETECTION_FLAGS[to_symbol(label)][data[index + 2]]}" }
41
+ .join("\n")
33
42
  end
34
43
 
35
- private
36
-
37
44
  def to_symbol(string)
38
45
  modified_string = string.gsub(' ', '_').downcase
39
46
  modified_string.to_sym
@@ -80,7 +80,7 @@ module RfBeam
80
80
  end
81
81
 
82
82
  def display_ddat
83
- puts RfBeam::Kld7::CliFormatter.new.ddat(@radar.ddat)
83
+ puts RfBeam::Kld7::CliFormatter.new.format(:ddat, @radar.ddat)
84
84
  end
85
85
 
86
86
  def stream_ddat
@@ -28,7 +28,7 @@ module RfBeam
28
28
  detection: %w[No Yes],
29
29
  micro_detection: %w[No Yes],
30
30
  angle: %w[Left Right],
31
- direction: %w[Receding Approaching],
31
+ direction: ['Going away', 'Approaching'],
32
32
  range: %w[Far Near],
33
33
  speed: %w[Low High]
34
34
  }.freeze
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RfBeam
4
- VERSION = '0.4.8'
4
+ VERSION = '0.4.10'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rfbeam
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.8
4
+ version: 0.4.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Carruthers
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-09 00:00:00.000000000 Z
11
+ date: 2023-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport