rfbeam 0.4.7 → 0.4.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f43572c13d87b8bd222b7cde57fb7dc7a0177b3b5259fc618a99d3de0024b7a5
4
- data.tar.gz: '061808ba887fb6d85b32f18b731c5c71d02baec97ecfa1fa648266cc1064085e'
3
+ metadata.gz: a3ca645044245d21d0248633dc68c5ac8608102c0fe4d8a93d825b7735bc225f
4
+ data.tar.gz: 5a443dad972d3c26d5e462597f166c7fa333bc2294ecd3b0529ad036fbe23375
5
5
  SHA512:
6
- metadata.gz: 72d8235c55222039286acabb5d30a9a7004d5c8922ecc3d78743e3ad3e5cfb71b1c136a7628407cc99be8e2d00bd1c47511e2062f4c6811b9bab8b001a8d9410
7
- data.tar.gz: 30099662c342218648172db87b552823fe40b095585fd169b0179a72adc0abb002e844fcca0c2fe7289190ad2d51fdb2ff5d8d04328361ae2c3a34940256011f
6
+ metadata.gz: 46e7f4cadd95cfabce4025d34e3cca666c655510b18e74edd451f3194ff70dfbd25bb116c88380873b34416c69f25274a2ee924ec45ac6913eb7cd76392d2c9d
7
+ data.tar.gz: f22887f60570dfa98d0430de0a6a487a3da566f1a9776058466015baa09b259026b4d064be99804669fddb9e1703ef8afc5892d5f42e22e6ecca8394278fdc28
data/Gemfile CHANGED
@@ -9,9 +9,12 @@ gem 'minitest', '~> 5.0'
9
9
  gem 'rake', '~> 13.0'
10
10
  gem 'tty-logger', '~> 0.6.0'
11
11
  gem 'tty-screen', '~> 0.8.1'
12
- gem 'tty-spinner', '~> 0.9.3'
13
12
  gem 'tty-table', '~> 0.12.0'
14
13
  gem 'unicode_plot', '~> 0.0.5'
15
14
 
16
- gem "syntax_tree", "~> 6.1", :groups => [:development, :test]
17
- gem "rubocop", "~> 1.39", :groups => [:development, :test]
15
+ git 'https://github.com/piotrmurach/tty-spinner.git', branch: 'master' do
16
+ gem 'tty-spinner', '~> 0.9.3'
17
+ end
18
+
19
+ gem 'rubocop', '~> 1.39', groups: %i[development test]
20
+ gem 'syntax_tree', '~> 6.1', groups: %i[development test]
data/Gemfile.lock CHANGED
@@ -1,7 +1,15 @@
1
+ GIT
2
+ remote: https://github.com/piotrmurach/tty-spinner.git
3
+ revision: a57d37a2617d4d58e33dca912061fe7e6754bea0
4
+ branch: master
5
+ specs:
6
+ tty-spinner (0.9.3)
7
+ tty-cursor (~> 0.7)
8
+
1
9
  PATH
2
10
  remote: .
3
11
  specs:
4
- rfbeam (0.4.7)
12
+ rfbeam (0.4.9)
5
13
  activesupport (~> 6.1.0)
6
14
  rubyserial (~> 0.6.0)
7
15
  thor (~> 1.2.1)
@@ -66,8 +74,6 @@ GEM
66
74
  tty-logger (0.6.0)
67
75
  pastel (~> 0.8)
68
76
  tty-screen (0.8.1)
69
- tty-spinner (0.9.3)
70
- tty-cursor (~> 0.7)
71
77
  tty-table (0.12.0)
72
78
  pastel (~> 0.8)
73
79
  strings (~> 0.2.0)
@@ -92,7 +98,7 @@ DEPENDENCIES
92
98
  syntax_tree (~> 6.1)
93
99
  tty-logger (~> 0.6.0)
94
100
  tty-screen (~> 0.8.1)
95
- tty-spinner (~> 0.9.3)
101
+ tty-spinner (~> 0.9.3)!
96
102
  tty-table (~> 0.12.0)
97
103
  unicode_plot (~> 0.0.5)
98
104
 
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
 
@@ -5,39 +5,46 @@ require 'tty-table'
5
5
  module RfBeam
6
6
  module Kld7
7
7
  class CliFormatter
8
- def tdat(data)
9
- { dist: data[2], speed: data[3], angle: data[4], mag: data[5] }
10
- end
11
-
12
- def pdat_table(data)
13
- table = TTY::Table.new header: ['index', 'dist (M)', 'speed (Km/h)', 'angle (°)', 'mag (db)']
14
- count = data[1] / 8
15
- data.shift(2)
16
- count.times do |index|
17
- values = data.shift(4).map { |value| value.to_f / 100.0 }
18
- table << [index, values].flatten
8
+ def format(type, data)
9
+ case type
10
+ when :tdat
11
+ tdat(data)
12
+ when :pdat
13
+ pdat_table(data)
14
+ when :ddat
15
+ ddat(data)
19
16
  end
20
- table
21
17
  end
18
+ end
22
19
 
23
- 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
20
+ def tdat(data)
21
+ { dist: data[2], speed: data[3], angle: data[4], mag: data[5] }
22
+ end
23
+
24
+ def pdat_table(data)
25
+ table = TTY::Table.new header: ['index', 'dist (M)', 'speed (Km/h)', 'angle (°)', 'mag (db)']
26
+ count = data[1] / 8
27
+ data.shift(2)
28
+ count.times do |index|
29
+ values = data.shift(4).map { |value| value.to_f / 100.0 }
30
+ table << [index, values].flatten
33
31
  end
32
+ table
33
+ end
34
34
 
35
- private
35
+ private
36
36
 
37
- def to_symbol(string)
38
- modified_string = string.gsub(' ', '_').downcase
39
- modified_string.to_sym
40
- end
37
+ def ddat(data)
38
+ labels = ['Detection', 'Micro Detection', 'Angle', 'Direction', 'Range', 'Speed']
39
+ labels
40
+ .map
41
+ .with_index { |label, index| "#{label}: #{DETECTION_FLAGS[to_symbol(label)][data[index + 2]]}" }
42
+ .join("\n")
43
+ end
44
+
45
+ def to_symbol(string)
46
+ modified_string = string.gsub(' ', '_').downcase
47
+ modified_string.to_sym
41
48
  end
42
49
  end
43
50
  end
@@ -21,7 +21,7 @@ module RfBeam
21
21
  end
22
22
 
23
23
  def display(type, stream: false)
24
- send("display_#{type}", stream)
24
+ stream ? send("stream_#{type}") : send("display_#{type}")
25
25
  end
26
26
 
27
27
  def plot(type, stream: false)
@@ -79,30 +79,30 @@ module RfBeam
79
79
  }
80
80
  end
81
81
 
82
- def display_ddat(stream)
83
- data = @radar.ddat
84
- if stream
85
- @streaming = true
86
- Thread.new { monitor_keypress }
87
- spinner = TTY::Spinner.new('[:spinner] :title ', format: :bouncing_ball)
88
- logger = TTY::Logger.new
82
+ def display_ddat
83
+ puts RfBeam::Kld7::CliFormatter.new.format(:ddat, @radar.ddat)
84
+ end
85
+
86
+ def stream_ddat
87
+ @streaming = true
88
+ Thread.new { monitor_keypress }
89
+ spinner = TTY::Spinner.new('[:spinner] :title ', format: :bouncing_ball)
90
+ spinner.run('Done!') do |sp|
89
91
  loop do
90
92
  break unless @streaming
91
93
 
92
- spinner.spin
93
- spinner.update title: "Detection: #{DETECTION_FLAGS[data[2]]}"
94
- logger.success @radar.tdat.to_s unless data[2].zero?
94
+ data = @radar.ddat
95
+ sp.update title: "Detection: #{DETECTION_FLAGS[:detection][data[2]]}"
95
96
  end
96
- else
97
- puts RfBeam::Kld7::CliFormatter.new.ddat(data)
97
+ spinner.update title: ''
98
98
  end
99
99
  end
100
100
 
101
- def display_tdat(stream)
101
+ def display_tdat
102
102
  puts RfBeam::Kld7::CliFormatter.new.tdat(@radar.tdat)
103
103
  end
104
104
 
105
- def display_pdat(stream)
105
+ def display_pdat
106
106
  table = RfBeam::Kld7::CliFormatter.new.pdat_table(@radar.pdat)
107
107
  puts "\n Detected Raw Targets"
108
108
  puts table.render(:unicode, alignment: :center)
@@ -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.7'
4
+ VERSION = '0.4.9'
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.7
4
+ version: 0.4.9
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-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport