dredger-iot 0.3.0 → 0.3.1

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: 701ad99dd1f271df310ba3dffbb3295084b54e64689f4d3ed77f9b6ab9e31df5
4
- data.tar.gz: e9b5ba95c4d2af83b529e6f66af5c81fb83c43f3f679e89e894209661651f93e
3
+ metadata.gz: 43ffc058382fa946c209b4908e84dccc2dd7d5918f24a5449dc57aed9418e61a
4
+ data.tar.gz: 84c8f5d4e1657798fe2cf65f18ab2ac3a652baff213ff03c44b8fb2976d3350c
5
5
  SHA512:
6
- metadata.gz: 5362ae41f8f92d403809728857c139b00e3d8141e8f83725a3cc302eb7e7ace2c32b8bd7306fba5e83c2ee197e42c633b7beaeb9a84b9b77f1d95299e80aad1d
7
- data.tar.gz: 220b5834cd302cef375c3922211c055788855d4b516b7260aa952d13fc312a3f9c028248863906e93a38badbd32839d2083783bb1431ba5fd1ada0b4df92bca5
6
+ metadata.gz: b583b40d4c2506e03784a40e05eb1ec55d335a39a96274a38669735c861c48e61c843d63d64f73d7f831813119e8ffeba54135b8ac4bf219e97a54686e41012c
7
+ data.tar.gz: 0a244d5ad53168492dac9e820d47007c88631451a0c23464a0b09bb3034bec90afd630ca3ed25aa015d0f9d746f290c20908a4213d579838940f825b056af4b6
@@ -8,7 +8,7 @@ module Dredger
8
8
  # Uses a provider interface to allow simulation in tests and hardware backends in production.
9
9
  class ADXL345 < BaseSensor
10
10
  # provider must respond to :read_measurements(i2c_addr) -> { x_g:, y_g:, z_g: }
11
- def initialize(i2c_addr: 0x53, provider:, metadata: {})
11
+ def initialize(provider:, i2c_addr: 0x53, metadata: {})
12
12
  super(metadata: metadata)
13
13
  @i2c_addr = i2c_addr
14
14
  @provider = provider
@@ -8,7 +8,7 @@ module Dredger
8
8
  # Uses a provider interface to allow simulation in tests and hardware backends in production.
9
9
  class NEO6M < BaseSensor
10
10
  # provider must respond to :read_position(device) -> { latitude:, longitude:, altitude:, speed:, satellites: }
11
- def initialize(device: '/dev/ttyAMA0', provider:, metadata: {})
11
+ def initialize(provider:, device: '/dev/ttyAMA0', metadata: {})
12
12
  super(metadata: metadata)
13
13
  @device = device
14
14
  @provider = provider
@@ -45,9 +45,9 @@ module Dredger
45
45
  line = read_line(serial, @timeout)
46
46
  next unless line
47
47
 
48
- if line.start_with?('$GPGGA') || line.start_with?('$GNGGA')
48
+ if line.start_with?('$GPGGA', '$GNGGA')
49
49
  gga_data = parse_gga(line)
50
- elsif line.start_with?('$GPRMC') || line.start_with?('$GNRMC')
50
+ elsif line.start_with?('$GPRMC', '$GNRMC')
51
51
  rmc_data = parse_rmc(line)
52
52
  end
53
53
  end
@@ -125,7 +125,7 @@ module Dredger
125
125
  degree_digits = coord_str.length >= 5 && coord_str[4] == '.' ? 2 : 3
126
126
 
127
127
  degrees = coord_str[0, degree_digits].to_f
128
- minutes = coord_str[degree_digits..-1].to_f
128
+ minutes = coord_str[degree_digits..].to_f
129
129
 
130
130
  decimal_degrees = degrees + (minutes / 60.0)
131
131
 
@@ -8,7 +8,7 @@ module Dredger
8
8
  # Uses a provider interface to allow simulation in tests and hardware backends in production.
9
9
  class SCD30 < BaseSensor
10
10
  # provider must respond to :read_measurements(i2c_addr) -> { co2_ppm:, temperature_c:, humidity: }
11
- def initialize(i2c_addr: 0x61, provider:, metadata: {})
11
+ def initialize(provider:, i2c_addr: 0x61, metadata: {})
12
12
  super(metadata: metadata)
13
13
  @i2c_addr = i2c_addr
14
14
  @provider = provider
@@ -87,7 +87,7 @@ module Dredger
87
87
  sleep(0.01)
88
88
  status = @i2c.read(addr, 3)
89
89
  # Data ready when bit 0 of word is 1
90
- data_ready = (status[1] & 0x01) == 1
90
+ data_ready = status[1].allbits?(0x01)
91
91
  return if data_ready
92
92
 
93
93
  raise IOError, 'SCD30 data ready timeout' if Time.now - start_time > timeout
@@ -130,7 +130,7 @@ module Dredger
130
130
  data.each do |byte|
131
131
  crc ^= byte
132
132
  8.times do
133
- crc = (crc & 0x80) != 0 ? ((crc << 1) ^ 0x31) : (crc << 1)
133
+ crc = crc.anybits?(0x80) ? ((crc << 1) ^ 0x31) : (crc << 1)
134
134
  crc &= 0xFF
135
135
  end
136
136
  end
@@ -66,14 +66,12 @@ module Dredger
66
66
  # For production, use hardware interrupts or kernel GPIO edge detection
67
67
  while Time.now - start_time < duration
68
68
  current_state = @gpio.read(pin_label)
69
-
69
+
70
70
  # Detect rising edge (0 -> 1 transition)
71
- if current_state == 1 && last_state == 0
72
- pulses += 1
73
- end
74
-
71
+ pulses += 1 if current_state == 1 && last_state.zero?
72
+
75
73
  last_state = current_state
76
-
74
+
77
75
  # Small sleep to reduce CPU usage
78
76
  # Trade-off: Higher sleep = lower CPU, but may miss pulses
79
77
  # For accurate counting, use interrupts instead
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Dredger
4
4
  module IoT
5
- VERSION = '0.3.0'
5
+ VERSION = '0.3.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dredger-iot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Mad Botter INC
@@ -106,7 +106,7 @@ post_install_message: "\n ═════════════════
106
106
  \ | \n |_____________________________| \n
107
107
  \ ~~~ \\ // ~~~ \n \\_______________//
108
108
  \ \n ═══════════════════════════════════════════════════════════════════\nHardware
109
- Integration for Embedded Linux v0.3.0\n ═══════════════════════════════════════════════════════════════════\n\n
109
+ Integration for Embedded Linux v0.3.1\n ═══════════════════════════════════════════════════════════════════\n\n
110
110
  \ \U0001F389 Thanks for installing!\n\n \U0001F4DA Hardware Setup (kernel modules
111
111
  & permissions):\n https://github.com/TheMadBotterINC/dredger-iot#hardware-setup\n\n
112
112
  \ \U0001F680 Quick Start:\n require 'dredger/iot'\n gpio = Dredger::IoT::Bus::Auto.gpio\n