rfbeam 0.5.0 → 0.5.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/.pre-commit-config.yaml +8 -0
  3. data/.streerc +1 -0
  4. data/.tool-versions +1 -1
  5. data/CHANGELOG.md +48 -47
  6. data/Gemfile +10 -7
  7. data/Gemfile.lock +48 -44
  8. data/README.md +71 -113
  9. data/Rakefile +3 -2
  10. data/cliff.toml +74 -0
  11. data/cog.toml +28 -0
  12. data/exe/rfbeam +0 -1
  13. data/lib/rfbeam/cli.rb +93 -36
  14. data/lib/rfbeam/kld7/constants.rb +66 -138
  15. data/lib/rfbeam/kld7/detection_params.rb +149 -0
  16. data/lib/rfbeam/kld7/module_params.rb +96 -0
  17. data/lib/rfbeam/kld7/operation_params.rb +162 -0
  18. data/lib/rfbeam/kld7/radar_messages.rb +18 -17
  19. data/lib/rfbeam/kld7/serial_connection.rb +13 -14
  20. data/lib/rfbeam/kld7/streamer.rb +83 -0
  21. data/lib/rfbeam/version.rb +1 -1
  22. data/lib/rfbeam.rb +8 -7
  23. data/output.csv +257 -0
  24. data/rfbeam.gemspec +6 -11
  25. data/streamer2.rb +55 -0
  26. data/streaming.rb +71 -0
  27. data/yarn.lock +221 -12
  28. metadata +23 -173
  29. data/.rubocop.yml +0 -25
  30. data/.streerc +0 -2
  31. data/lib/rfbeam/kld7/cli_formatter.rb +0 -61
  32. data/lib/rfbeam/kld7/cli_output.rb +0 -141
  33. data/lib/rfbeam/kld7/radar_parameters.rb +0 -397
  34. data/node_modules/.bin/prettier +0 -1
  35. data/node_modules/.yarn-integrity +0 -19
  36. data/node_modules/@prettier/plugin-ruby/CHANGELOG.md +0 -1351
  37. data/node_modules/@prettier/plugin-ruby/CODE_OF_CONDUCT.md +0 -76
  38. data/node_modules/@prettier/plugin-ruby/CONTRIBUTING.md +0 -185
  39. data/node_modules/@prettier/plugin-ruby/LICENSE +0 -21
  40. data/node_modules/@prettier/plugin-ruby/README.md +0 -226
  41. data/node_modules/@prettier/plugin-ruby/docs/logo.png +0 -0
  42. data/node_modules/@prettier/plugin-ruby/node_modules/.bin/prettier +0 -1
  43. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/LICENSE +0 -5945
  44. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/README.md +0 -109
  45. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/bin-prettier.js +0 -62
  46. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/cli.js +0 -15136
  47. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/doc.js +0 -1473
  48. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/parser-angular.mjs +0 -2
  49. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/parser-babel.mjs +0 -29
  50. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/parser-espree.mjs +0 -26
  51. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/parser-flow.mjs +0 -35
  52. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/parser-glimmer.mjs +0 -27
  53. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/parser-graphql.mjs +0 -15
  54. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/parser-html.mjs +0 -36
  55. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/parser-markdown.mjs +0 -76
  56. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/parser-meriyah.mjs +0 -19
  57. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/parser-postcss.mjs +0 -76
  58. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/parser-typescript.mjs +0 -257
  59. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/parser-yaml.mjs +0 -150
  60. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/esm/standalone.mjs +0 -116
  61. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/index.js +0 -37885
  62. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/package.json +0 -21
  63. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/parser-angular.js +0 -2
  64. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/parser-babel.js +0 -29
  65. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/parser-espree.js +0 -26
  66. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/parser-flow.js +0 -35
  67. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/parser-glimmer.js +0 -27
  68. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/parser-graphql.js +0 -15
  69. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/parser-html.js +0 -36
  70. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/parser-markdown.js +0 -76
  71. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/parser-meriyah.js +0 -19
  72. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/parser-postcss.js +0 -76
  73. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/parser-typescript.js +0 -257
  74. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/parser-yaml.js +0 -150
  75. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/standalone.js +0 -116
  76. data/node_modules/@prettier/plugin-ruby/node_modules/prettier/third-party.js +0 -8978
  77. data/node_modules/@prettier/plugin-ruby/package.json +0 -64
  78. data/node_modules/@prettier/plugin-ruby/prettier.gemspec +0 -36
  79. data/node_modules/@prettier/plugin-ruby/rubocop.yml +0 -64
  80. data/node_modules/@prettier/plugin-ruby/src/getInfo.js +0 -23
  81. data/node_modules/@prettier/plugin-ruby/src/netcat.js +0 -13
  82. data/node_modules/@prettier/plugin-ruby/src/parseSync.js +0 -236
  83. data/node_modules/@prettier/plugin-ruby/src/plugin.js +0 -172
  84. data/node_modules/@prettier/plugin-ruby/src/server.rb +0 -199
  85. data/node_modules/prettier/LICENSE +0 -5970
  86. data/node_modules/prettier/README.md +0 -109
  87. data/node_modules/prettier/bin-prettier.js +0 -64
  88. data/node_modules/prettier/cli.js +0 -15364
  89. data/node_modules/prettier/doc.js +0 -1473
  90. data/node_modules/prettier/esm/parser-angular.mjs +0 -2
  91. data/node_modules/prettier/esm/parser-babel.mjs +0 -29
  92. data/node_modules/prettier/esm/parser-espree.mjs +0 -26
  93. data/node_modules/prettier/esm/parser-flow.mjs +0 -35
  94. data/node_modules/prettier/esm/parser-glimmer.mjs +0 -27
  95. data/node_modules/prettier/esm/parser-graphql.mjs +0 -15
  96. data/node_modules/prettier/esm/parser-html.mjs +0 -36
  97. data/node_modules/prettier/esm/parser-markdown.mjs +0 -76
  98. data/node_modules/prettier/esm/parser-meriyah.mjs +0 -19
  99. data/node_modules/prettier/esm/parser-postcss.mjs +0 -76
  100. data/node_modules/prettier/esm/parser-typescript.mjs +0 -49
  101. data/node_modules/prettier/esm/parser-yaml.mjs +0 -150
  102. data/node_modules/prettier/esm/standalone.mjs +0 -116
  103. data/node_modules/prettier/index.js +0 -38236
  104. data/node_modules/prettier/package.json +0 -21
  105. data/node_modules/prettier/parser-angular.js +0 -2
  106. data/node_modules/prettier/parser-babel.js +0 -29
  107. data/node_modules/prettier/parser-espree.js +0 -26
  108. data/node_modules/prettier/parser-flow.js +0 -35
  109. data/node_modules/prettier/parser-glimmer.js +0 -27
  110. data/node_modules/prettier/parser-graphql.js +0 -15
  111. data/node_modules/prettier/parser-html.js +0 -36
  112. data/node_modules/prettier/parser-markdown.js +0 -76
  113. data/node_modules/prettier/parser-meriyah.js +0 -19
  114. data/node_modules/prettier/parser-postcss.js +0 -76
  115. data/node_modules/prettier/parser-typescript.js +0 -49
  116. data/node_modules/prettier/parser-yaml.js +0 -150
  117. data/node_modules/prettier/standalone.js +0 -116
  118. data/node_modules/prettier/third-party.js +0 -8978
  119. data/package.json +0 -6
data/README.md CHANGED
@@ -1,14 +1,11 @@
1
1
  # Rfbeam
2
2
 
3
- ![Ruby](https://img.shields.io/static/v1?message=Ruby&color=red&logo=Ruby&logoColor=FFFFFF&label=v3.1.2)
4
- ![Ruby](https://img.shields.io/gitlab/license/robcarruthers/rfbeam?color=orange)
5
-
6
3
  ![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)
4
+ ![Ruby](https://img.shields.io/static/v1?message=Ruby&color=red&logo=Ruby&logoColor=FFFFFF&label=v3.2.1)
5
+ ![Ruby](https://img.shields.io/gitlab/license/robcarruthers/rfbeam?color=orange)
9
6
 
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.
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.
12
9
 
13
10
  At this stage it only works on Linux and Mac with the K-LD7 module.
14
11
 
@@ -26,90 +23,75 @@ If bundler is not being used to manage dependencies, install the gem by executin
26
23
 
27
24
  The RfBeam class will return the path of any connected modules
28
25
 
29
- ```ruby
30
- RfBeam.connected
31
- => ["/dev/ttyUSB0"]
32
- ```
26
+ RfBeam.connected
33
27
 
34
- Simple pass the path and optional baude rate (default: 115200) to initialise a new radar object
28
+ Simple pass the path and baude rate to initialise a new radar object
35
29
 
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
- ```
30
+ RfBeam::Kld7.new("/dev/ttyUSB0", 115200) do |radar|
31
+ puts radar.config
32
+ end
65
33
 
66
- ## RfBeam::KLD7 API
34
+ ## RfBeam::Kld7 API
67
35
 
68
36
  ### detection?
69
37
 
70
38
  Returns true if the module has a valid detection.
71
39
 
72
- ```ruby
73
- radar.detection?
74
- => true
75
- ```
40
+ radar.detection?
41
+ => true
76
42
 
77
43
  ### ddat
78
44
 
79
45
  Returns an array with the current detection values
80
46
 
81
- ```ruby
82
- radar.ddat
83
- => ["DDAT", 6, 0, 0, 0, 0, 0, 0]
84
- ```
47
+ radar.ddat
48
+ => ["DDAT", 6, 0, 0, 0, 0, 0, 0]
85
49
 
86
50
  ### tdat
87
51
 
88
52
  Returns a hash with the current tracked object values
89
53
 
90
- ```ruby
91
- radar.tdat
92
- => ["TDAT", 4, 68, 196, 469, 6303]
93
- ```
54
+ radar.tdat
55
+ => {:dist=>68, :speed=>196, :angle=>469, :mag=>6303}
94
56
 
95
57
  ### grps
96
58
 
97
59
  Returns the Parameter settings, values map to setting as detailed in the device datasheet.
98
60
 
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
- ```
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]
103
63
 
104
64
  ### config
105
65
 
106
66
  Returns a formatted String of all parameter settings. The only way to read parameter settings is with config
107
67
 
108
- ```ruby
109
- radar.config
110
- ```
111
-
112
- ## Radar Parameters
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 setters
113
95
 
114
96
  ### Base Frequency
115
97
 
@@ -118,7 +100,7 @@ radar.config
118
100
  alias :rbfr
119
101
 
120
102
  ```ruby
121
- radar.base_frequency = 1
103
+ set_base_frequency(1)
122
104
  ```
123
105
 
124
106
  ### Maximum Speed
@@ -126,7 +108,7 @@ radar.base_frequency = 1
126
108
  0 = 12.5km/h, 1 = 25km/h (default), 2 = 50km/h, 3 = 100km/h, alias :rspi
127
109
 
128
110
  ```ruby
129
- radar.max_speed = 1
111
+ set_max_speed(1)
130
112
  ```
131
113
 
132
114
  ### Maximum Range
@@ -134,7 +116,7 @@ radar.max_speed = 1
134
116
  0 = 5m, 1 = 10m (default), 2 = 30m, 3 = 100m, alias :rrai
135
117
 
136
118
  ```ruby
137
- radar.max_range = 1
119
+ set_max_range(1)
138
120
  ```
139
121
 
140
122
  ### Threshold Offset
@@ -142,7 +124,7 @@ radar.max_range = 1
142
124
  10 - 60db, (default = 30), alias :thof
143
125
 
144
126
  ```ruby
145
- radar.threshold_offset = 30
127
+ set_threshold_offset(30)
146
128
  ```
147
129
 
148
130
  ### Tracking filter type
@@ -150,7 +132,7 @@ radar.threshold_offset = 30
150
132
  0 = Standard (Default), 1 = Fast Tracking, 2 = Long visibility, alias :trtf
151
133
 
152
134
  ```ruby
153
- radar.tracking_filter = 0
135
+ set_tracking_filter(0)
154
136
  ```
155
137
 
156
138
  ### Vibration suppression
@@ -158,7 +140,7 @@ radar.tracking_filter = 0
158
140
  0 - 16, 0 = No Suppression, 16 = High Suppression, default = 2, alias :visu
159
141
 
160
142
  ```ruby
161
- radar.vibration_suppression = 2
143
+ set_vibration_suppression(2)
162
144
  ```
163
145
 
164
146
  ### Minimum Detection distance
@@ -166,7 +148,7 @@ radar.vibration_suppression = 2
166
148
  0 - 100% of Range setting, default = 0, alias :mira
167
149
 
168
150
  ```ruby
169
- radar.min_detection_distance = 0
151
+ set_min_detection_distance(0)
170
152
  ```
171
153
 
172
154
  ### Maximum Detection distance
@@ -174,7 +156,7 @@ radar.min_detection_distance = 0
174
156
  0 - 100% of Range setting, default = 50, alias :mara
175
157
 
176
158
  ```ruby
177
- radar.max_detection_distance = 50
159
+ set_max_detection_distance(50)
178
160
  ```
179
161
 
180
162
  ### Minimum Detection Angle
@@ -182,7 +164,7 @@ radar.max_detection_distance = 50
182
164
  -90° - 90°, default = -90, alias :mian
183
165
 
184
166
  ```ruby
185
- radar.min_detection_angle = -90
167
+ set_min_detection_angle(-90
186
168
  ```
187
169
 
188
170
  ### Maximum Detection Angle
@@ -190,7 +172,7 @@ radar.min_detection_angle = -90
190
172
  -90° - 90°, default = 90, alias :maan
191
173
 
192
174
  ```ruby
193
- radar.min_detection_angle = 90
175
+ set_min_detection_angle(90)
194
176
  ```
195
177
 
196
178
  ### Minimum Detection Speed
@@ -198,7 +180,7 @@ radar.min_detection_angle = 90
198
180
  0 - 100% of Speed setting, default = 0, alias :misp
199
181
 
200
182
  ```ruby
201
- radar.min_detection_speed = 0
183
+ set_min_detection_speed(0)
202
184
  ```
203
185
 
204
186
  ### Maximum Detection Speed
@@ -206,7 +188,7 @@ radar.min_detection_speed = 0
206
188
  0 - 100% of Speed setting, default = 100, alias :masp
207
189
 
208
190
  ```ruby
209
- radar.max_detection_speed = 100
191
+ set_max_detection_speed(100)
210
192
  ```
211
193
 
212
194
  ### Detection Direction
@@ -214,7 +196,7 @@ radar.max_detection_speed = 100
214
196
  0 = Receding, 1 = Approaching, 2 = Both (default), alias :dedi
215
197
 
216
198
  ```ruby
217
- radar. detection_direction = 2
199
+ set_detection_direction(2)
218
200
  ```
219
201
 
220
202
  ### Range Threshold
@@ -222,7 +204,7 @@ radar. detection_direction = 2
222
204
  0 - 100% of Range setting, default = 10, alias :rath
223
205
 
224
206
  ```ruby
225
- radar. range_threshold = 10
207
+ set_range_threshold(10)
226
208
  ```
227
209
 
228
210
  ### Angle Threshold
@@ -230,7 +212,7 @@ radar. range_threshold = 10
230
212
  -90° to 90°, default = 0, alias :anth
231
213
 
232
214
  ```ruby
233
- radar. range_threshold = 0
215
+ set_range_threshold(0)
234
216
  ```
235
217
 
236
218
  ### Speed Threshold
@@ -238,37 +220,37 @@ radar. range_threshold = 0
238
220
  0 - 100% of speed setting, default = 50, alias :spth
239
221
 
240
222
  ```ruby
241
- radar. angle_threshold = 50
223
+ set_angle_threshold(50)
242
224
  ```
243
225
 
244
226
  ### Digital output 1
245
227
 
246
228
  0 = Direction, 1 = Angle, 2 = Range, 3 = Speed, 4 = Micro Detection, default = 0
247
229
 
248
- alias :dig1
230
+ alias :dig1, :set_dio_1
249
231
 
250
232
  ```ruby
251
- radar.digital_output1 = 0
233
+ set_dio_1(0)
252
234
  ```
253
235
 
254
236
  ### Digital output 2
255
237
 
256
238
  0 = Direction, 1 = Angle, 2 = Range, 3 = Speed, 4 = Micro Detection, default = 1
257
239
 
258
- alias :dig2
240
+ alias :dig2, :set_dio_2
259
241
 
260
242
  ```ruby
261
- radar.digital_output2 = 1
243
+ set_dio_2(1)
262
244
  ```
263
245
 
264
246
  ### Digital output 3
265
247
 
266
248
  0 = Direction, 1 = Angle, 2 = Range, 3 = Speed, 4 = Micro Detection, default = 2
267
249
 
268
- alias :dig3
250
+ alias :dig3, :set_dio_3
269
251
 
270
252
  ```ruby
271
- radar.digital_output3 = 2
253
+ set_dio_3(2)
272
254
  ```
273
255
 
274
256
  ### Hold Time
@@ -278,7 +260,7 @@ radar.digital_output3 = 2
278
260
  alias :hold
279
261
 
280
262
  ```ruby
281
- radar.hold_time = 1
263
+ set_hold_time(1)
282
264
  ```
283
265
 
284
266
  ### Micro Detection retrigger
@@ -288,7 +270,7 @@ radar.hold_time = 1
288
270
  alias: :mide
289
271
 
290
272
  ```ruby
291
- radar.micro_detection_retrigger = 0
273
+ set_micro_detection_retrigger(0)
292
274
  ```
293
275
 
294
276
  ### Micro Detection sensitivity
@@ -298,31 +280,7 @@ radar.micro_detection_retrigger = 0
298
280
  alias: :mids
299
281
 
300
282
  ```ruby
301
- radar.micro_detection_sensitivty = 4
302
- ```
303
-
304
- ## CLI
305
-
306
- ```fish
307
- ❯ bundle exec rfbeam list
308
-
309
- +--+------------+------------------+
310
- |id|Path |Version |
311
- +--+------------+------------------+
312
- |0 |/dev/ttyUSB0|K-LD7_APP-RFB-0103|
313
- +--+------------+------------------+
314
-
315
- ❯ bundle exec rfbeam help
316
- Commands:
317
- rfbeam config <radar_id> # Shows the parameter setting for the Radar module
318
- rfbeam ddat <radar_id> -s, [--stream] # stream any valid detections, stop stream with q and enter
319
- rfbeam help [COMMAND] # Describe available commands or one specific command
320
- rfbeam list # List available radar modules
321
- rfbeam pdat <radar_id> # Display Tracked Targets
322
- rfbeam reset <radar_id> # Shows the parameter setting for the Radar module
323
- rfbeam rfft <radar_id> -s, [--stream] # Display the dopplar radar data as a plot
324
- rfbeam set_param <radar_id> <key> <value> # Set radar parameters, see readme for keys
325
- rfbeam tdat <radar_id> # Display tracked target data
283
+ set_micro_detection_sensitivty(4)
326
284
  ```
327
285
 
328
286
  ## Development
@@ -333,7 +291,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
333
291
 
334
292
  ## Contributing
335
293
 
336
- Bug reports and pull requests are welcome on GitHub at https://github.com/robcarruthers/rfbeam.
294
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rfbeam.
337
295
 
338
296
  ## License
339
297
 
data/Rakefile CHANGED
@@ -2,11 +2,12 @@
2
2
 
3
3
  require 'bundler/gem_tasks'
4
4
  require 'rake/testtask'
5
+ Dir.glob('tasks/*.rake').each { |r| import r }
5
6
 
6
7
  Rake::TestTask.new(:test) do |t|
7
- t.libs << 'test'
8
+ t.libs << %w[test spec]
8
9
  t.libs << 'lib'
9
- t.test_files = FileList['test/**/test_*.rb']
10
+ t.test_files = FileList['test/**/test_*.rb', 'spec/**/*_spec.rb']
10
11
  end
11
12
 
12
13
  require 'rubocop/rake_task'
data/cliff.toml ADDED
@@ -0,0 +1,74 @@
1
+ # configuration file for git-cliff (0.1.0)
2
+
3
+ [changelog]
4
+ # changelog header
5
+ header = """
6
+ # Changelog\n
7
+ All notable changes to this project will be documented in this file.\n
8
+ """
9
+ # template for the changelog body
10
+ # https://tera.netlify.app/docs/#introduction
11
+ body = """
12
+ {% if version %}\
13
+ ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
14
+ {% else %}\
15
+ ## [unreleased]
16
+ {% endif %}\
17
+ {% if previous %}\
18
+ {% if previous.commit_id %}
19
+ [{{ previous.commit_id | truncate(length=7, end="") }}]({{ previous.commit_id }})...\
20
+ [{{ commit_id | truncate(length=7, end="") }}]({{ commit_id }})
21
+ {% endif %}\
22
+ {% endif %}\
23
+ {% for group, commits in commits | group_by(attribute="group") %}
24
+ ### {{ group | upper_first }}
25
+ {% for commit in commits %}
26
+ - {{ commit.message | upper_first }} ([{{ commit.id | truncate(length=7, end="") }}]({{ commit.id }}))\
27
+ {% for footer in commit.footers -%}
28
+ , {{ footer.token }}{{ footer.separator }}{{ footer.value }}\
29
+ {% endfor %}\
30
+ {% endfor %}
31
+ {% endfor %}\n
32
+ """
33
+ # remove the leading and trailing whitespace from the template
34
+ trim = true
35
+ # changelog footer
36
+ footer = """
37
+ <!-- generated by git-cliff -->
38
+ """
39
+
40
+ [git]
41
+ # parse the commits based on https://www.conventionalcommits.org
42
+ conventional_commits = true
43
+ # filter out the commits that are not conventional
44
+ filter_unconventional = true
45
+ # process each line of a commit as an individual commit
46
+ split_commits = false
47
+ # regex for parsing and grouping commits
48
+ commit_parsers = [
49
+ { message = "^feat", group = "Features"},
50
+ { message = "^fix", group = "Bug Fixes"},
51
+ { message = "^doc", group = "Documentation"},
52
+ { message = "^perf", group = "Performance"},
53
+ { message = "^refactor", group = "Refactor"},
54
+ { message = "^style", group = "Styling"},
55
+ { message = "^test", group = "Testing"},
56
+ { message = "^chore\\(release\\): prepare for", skip = true},
57
+ { message = "^chore", group = "Miscellaneous Tasks"},
58
+ { message = "^task", group = "Miscellaneous Tasks"},
59
+ { body = ".*security", group = "Security"},
60
+ ]
61
+ # protect breaking changes from being skipped due to matching a skipping commit_parser
62
+ protect_breaking_commits = false
63
+ # filter out the commits that are not matched by commit parsers
64
+ filter_commits = false
65
+ # glob pattern for matching git tags
66
+ tag_pattern = "v[0-9]*"
67
+ # regex for skipping tags
68
+ skip_tags = "v0.1.0-beta.1"
69
+ # regex for ignoring tags
70
+ ignore_tags = ""
71
+ # sort the tags topologically
72
+ topo_order = false
73
+ # sort the commits inside sections by oldest/newest order
74
+ sort_commits = "oldest"
data/cog.toml ADDED
@@ -0,0 +1,28 @@
1
+ from_latest_tag = true
2
+ ignore_merge_commits = false
3
+ branch_whitelist = []
4
+ pre_bump_hooks = ["bump set {{version}} --no-bundle --no-commit"]
5
+ post_bump_hooks = []
6
+ pre_package_bump_hooks = []
7
+ post_package_bump_hooks = []
8
+ tag_prefix = "v"
9
+
10
+ [commit_types]
11
+ hotfix = { changelog_title = "Hotfixes" }
12
+ release = { changelog_title = "Releases" }
13
+ task = { changelog_title = "Miscellaneous Tasks" }
14
+ chore = { changelog_title = "Miscellaneous Tasks" }
15
+
16
+ [changelog]
17
+ path = "CHANGELOG.md"
18
+ template = "remote"
19
+ remote = "github.com"
20
+ repository = "rfbeam"
21
+ owner = "robcarruthers"
22
+ authors = [
23
+ { signature = "Rob Carruthers", username = "robcarruthers" }
24
+ ]
25
+
26
+ [bump_profiles]
27
+
28
+ [packages]
data/exe/rfbeam CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
2
 
4
3
  require 'rfbeam'
5
4
 
data/lib/rfbeam/cli.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
+ # rubocop:disable all
2
3
 
3
4
  require 'thor'
4
- require 'rfbeam'
5
5
  require 'tty-table'
6
6
  require 'tty-logger'
7
7
  require 'tty-spinner'
@@ -10,80 +10,137 @@ require 'unicode_plot'
10
10
 
11
11
  module RfBeam
12
12
  class CLI < Thor
13
- attr_accessor :logger
13
+ attr_accessor :radar, :logger
14
14
 
15
15
  desc 'list', 'List available radar modules'
16
16
  def list
17
17
  logger = TTY::Logger.new
18
18
  devices = RfBeam.connected
19
- return logger.warn 'No Radar modules found.' if devices.empty?
19
+ logger.info 'No Radar modules found.' unless devices.count.positive?
20
20
 
21
21
  table = TTY::Table.new(header: %w[id Path Version])
22
22
 
23
- devices.each.with_index { |path, index| table << [index.to_s, path, radar(index).sw_version] }
23
+ devices.each.with_index do |path, index|
24
+ init_radar(index)
25
+ table << ["#{index}", path, @radar.sw_version]
26
+ end
24
27
  puts table.render(:ascii)
25
28
  end
26
29
 
27
- desc 'config [RADAR_ID]', 'Shows the parameter setting for the Radar module'
30
+ desc 'config <radar_id>', 'Shows the parameter setting for the Radar module'
28
31
  def config(radar_id)
29
- puts radar(radar_id).config
32
+ init_radar(radar_id)
33
+ puts @radar.config
30
34
  end
31
35
 
32
- desc 'reset [RADAR_ID]', 'Shows the parameter setting for the Radar module'
36
+ desc 'reset <radar_id>', 'Shows the parameter setting for the Radar module'
33
37
  def reset(radar_id)
34
- @logger.success 'Radar reset to factory defaults' if radar(radar_id).reset
38
+ init_radar(radar_id)
39
+ @logger.success 'Radar reset to factory defaults' if @radar.reset
35
40
  end
36
41
 
37
- desc 'set_param [RADAR_ID] [KEY] [VALUE]', 'Set radar parameters, see readme for KEYS'
42
+ desc 'set_param <radar_id> <key> <value>', 'Set radar parameters, see readme for keys'
38
43
  def set_param(radar_id, param, value)
39
- return @logger.warn("Invalid param: '#{param}'") unless Kld7::RADAR_PARAMETERS.include?(param.to_sym)
44
+ init_radar radar_id
45
+ return @logger.warn("Invalid param: '#{param}'") unless RfBeam::KLD7::RADAR_PARAMETERS.include?(param.to_sym)
40
46
 
41
- r = radar(radar_id)
42
- r.send("#{param}=", value.to_i)
43
- @logger.success r.formatted_parameter(param.to_sym)
47
+ @radar.send("#{param}=", value.to_i)
48
+ @logger.success "Set #{@radar.formatted_parameter(param.to_sym)}"
44
49
  end
45
50
 
46
- desc 'ddat [RADAR_ID]', 'stream any valid detections, stop stream with q and enter'
47
- option :stream, type: :boolean, aliases: '-s', desc: 'Stream the data from the device, press q to stop'
48
- option :raw, type: :boolean, aliases: '-r', desc: 'Display raw data'
51
+ desc 'ddat <radar_id>', 'stream any valid detections, stop stream with q and enter'
52
+ option :stream, type: :boolean, aliases: '-s', desc: 'Stream the data from the device'
49
53
  def ddat(radar_id)
50
- cli = RfBeam::Kld7::CliOutput.new(radar_id)
51
- cli.display(:ddat, options)
52
- end
53
-
54
- desc 'tdat [RADAR_ID]', 'Display tracked target data'
55
- option :raw, type: :boolean, aliases: '-r', desc: 'Display raw data'
56
- def tdat(radar_id)
57
- cli = RfBeam::Kld7::CliOutput.new(radar_id)
58
- cli.display(:tdat, options)
54
+ init_radar radar_id
55
+
56
+ if options[:stream]
57
+ Thread.new { monitor_keypress }
58
+ spinner = TTY::Spinner.new('[:spinner] :title ', format: :bouncing_ball)
59
+ loop do
60
+ break if @stop_streaming
61
+ spinner.spin
62
+ data = @radar.ddat
63
+ spinner.update title: "Searching... #{data[:detection_str]}"
64
+ @logger.success "#{@radar.tdat}" if data[:detection]
65
+ end
66
+ puts "\nTask Quit."
67
+ else
68
+ puts "\n#{@radar.ddat}"
69
+ end
59
70
  end
60
71
 
61
- desc 'pdat [RADAR_ID]', 'Display Tracked Targets'
72
+ desc 'pdat <radar_id>', 'Display Tracked Targets'
62
73
  def pdat(radar_id)
63
- cli = RfBeam::Kld7::CliOutput.new(radar_id)
64
- cli.display(:pdat, options)
74
+ init_radar radar_id
75
+ puts @radar.pdat
65
76
  end
66
77
 
67
- desc 'rfft [RADAR_ID]', 'Display the dopplar radar data as a plot'
78
+ desc 'rfft <radar_id>', 'Display the dopplar radar data as a plot'
68
79
  option :stream, type: :boolean, aliases: '-s', desc: 'Stream the data from the device'
69
80
  option :raw, type: :boolean, aliases: '-r', desc: 'Display raw data'
70
81
  def rfft(radar_id)
71
- plotter = RfBeam::Kld7::CliOutput.new(radar_id)
72
- if options[:raw]
73
- print radar(radar_id).rfft
82
+ init_radar(radar_id)
83
+
84
+ case
85
+ when options[:stream]
86
+ streamer = RfBeam::KLD7::Streamer.new(@radar)
87
+ streamer.rfft
88
+ when options[:raw]
89
+ print @radar.rfft
74
90
  else
75
- plotter.plot(:rfft, stream: options[:stream])
91
+ plot = rfft_plot(@radar)
92
+ p plot.render
76
93
  end
77
94
  end
78
95
 
79
96
  private
80
97
 
81
- def radar(id)
98
+ def init_radar(id)
82
99
  devices = RfBeam.connected
83
100
  @logger = TTY::Logger.new
84
- return @logger.warning 'No Radar modules found.' unless devices.count.positive?
101
+ return @logger.warn 'No Radar modules found.' unless devices.count.positive?
102
+
103
+ @radar = RfBeam::K_ld7.new(devices[id.to_i])
104
+ end
105
+
106
+ def plot_data(data)
107
+ {
108
+ x: Array(-128...128),
109
+ series1: data.shift(256).map { |value| value / 100 },
110
+ series2: data.shift(256).map { |value| value.to_i / 100 }
111
+ }
112
+ end
113
+
114
+ def monitor_keypress
115
+ @stop_streaming = false
116
+ loop do
117
+ key = STDIN.getch
118
+ if key.downcase == 'q'
119
+ @stop_streaming = true
120
+ break
121
+ end
122
+ end
123
+ end
85
124
 
86
- RfBeam::KLD7.new(devices[id.to_i])
125
+ def rfft_plot(radar)
126
+ speed = radar.max_speed
127
+ speed_label = radar.formatted_parameter(:max_speed)
128
+ data = plot_data(radar.rfft)
129
+ plot =
130
+ UnicodePlot.lineplot(
131
+ data[:x],
132
+ data[:series1],
133
+ name: 'IF1/2 Averaged',
134
+ title: 'Raw FFT',
135
+ height: 25,
136
+ width: 120,
137
+ xlabel: "Speed (km/h), #{speed_label}",
138
+ ylabel: 'Signal (db)',
139
+ xlim: [-128, 128],
140
+ ylim: [0, 100]
141
+ )
142
+ UnicodePlot.lineplot!(plot, data[:x], data[:series2], name: 'Threshold')
143
+ plot
87
144
  end
88
145
  end
89
146
  end