dln2 0.2.1__tar.gz → 0.2.2__tar.gz

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.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.1
2
2
  Name: dln2
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: Unified DLN2 driver — SPI, GPIO, I2C, ADC over a single USB connection. Originally developed for the Pico USB I/O Board.
5
5
  Home-page: https://github.com/syabyr/dln2_wrapper
6
6
  Author: IPM Group
@@ -21,17 +21,6 @@ Requires-Python: >=3.9
21
21
  Description-Content-Type: text/markdown
22
22
  License-File: LICENSE
23
23
  Requires-Dist: pyusb>=1.2
24
- Dynamic: author
25
- Dynamic: author-email
26
- Dynamic: classifier
27
- Dynamic: description
28
- Dynamic: description-content-type
29
- Dynamic: home-page
30
- Dynamic: license
31
- Dynamic: license-file
32
- Dynamic: requires-dist
33
- Dynamic: requires-python
34
- Dynamic: summary
35
24
 
36
25
  # dln2 — Unified DLN2 USB I/O Board Wrapper
37
26
 
@@ -118,10 +107,6 @@ smbus-compatible API: `write_byte()`, `read_byte_data()`,
118
107
  `read_channel(channel)`, `read_all()`, `read_volts(channel)`,
119
108
  `set_resolution(bits)`, `enable_channel(ch)`, `disable_channel(ch)`
120
109
 
121
- ### BME280
122
- `read_chip_id()`, `get_temperature()`, `get_humidity()`, `get_pressure()`,
123
- `get_altitude()`, `get_all()`
124
-
125
110
  ## CLI Commands
126
111
 
127
112
  After installation, the following commands are available:
@@ -135,7 +120,6 @@ After installation, the following commands are available:
135
120
  | `dln2-adc-watch` | Stream one ADC channel |
136
121
  | `dln2-i2c-scan` | Scan I2C bus for devices |
137
122
  | `dln2-i2c-test` | Read/write I2C register |
138
- | `dln2-bme280` | Read BME280 sensor measurements |
139
123
  | `dln2-spi-test` | Send SPI JEDEC ID probe |
140
124
  | `dln2-bpw-test` | Cycle SPI bits-per-word 4..16 |
141
125
 
@@ -153,28 +137,59 @@ dln2-adc-watch --channel 0 --interval 0.5
153
137
  dln2-i2c-scan
154
138
  dln2-i2c-test --address 0x76 --register 0xD0 --read 1
155
139
 
156
- # BME280
157
- dln2-bme280 --address 0x76 --pretty
158
-
159
140
  # SPI
160
141
  dln2-spi-test
161
142
  dln2-bpw-test
162
143
  ```
163
144
 
164
- ## Examples (as scripts)
145
+ ## Examples
146
+
147
+ ### Core examples (this repo)
148
+
149
+ Basic I/O operations that exercise the wrapper itself:
165
150
 
166
151
  ```bash
167
152
  # SPI JEDEC ID read
168
153
  python3 examples/spidev_test.py
169
154
 
155
+ # SPI bits-per-word cycle
156
+ python3 examples/bpw_tester.py
157
+
170
158
  # GPIO pin toggle (default: Pico LED)
171
159
  python3 examples/gpio_toggle.py --pin 25
172
160
 
161
+ # GPIO pin info
162
+ python3 examples/gpio_info.py --pin 2
163
+
164
+ # GPIO event watch
165
+ python3 examples/gpio_watch.py --pin 2
166
+
173
167
  # I2C bus scan
174
168
  python3 examples/i2c_scan.py
175
169
 
176
- # ADC monitor
170
+ # I2C register read/write
171
+ python3 examples/i2c_test.py --address 0x76 --register 0xD0 --read 1
172
+
173
+ # ADC read
177
174
  python3 examples/adc_info.py
175
+
176
+ # ADC stream
177
+ python3 examples/adc_watch.py --channel 0
178
+ ```
179
+
180
+ ### Device-specific examples (separate repo)
181
+
182
+ Sensor test scripts live in [dln2_examples](https://github.com/syabyr/dln2_examples):
183
+
184
+ ```bash
185
+ git clone https://github.com/syabyr/dln2_examples
186
+ cd dln2_examples/i2c
187
+
188
+ python3 bh1750_full_test.py # BH1750 ambient light @ 0x23
189
+ python3 bme280_full_test.py # BME280 temp/press/humid @ 0x76
190
+ python3 bmp180_full_test.py # BMP180 temp/pressure @ 0x77
191
+ python3 tsl2561_full_test.py # TSL2561 ambient light @ 0x39
192
+ python3 mpu9250_full_test.py # MPU9250 9-axis IMU @ 0x68
178
193
  ```
179
194
 
180
195
  ## Why Unified?
@@ -211,7 +226,7 @@ To flash updated firmware:
211
226
  ## Related
212
227
 
213
228
  - [pico-usb-io-board](https://github.com/syabyr/pico-usb-io-board) — RP2040 firmware
214
- - [st7789 display driver](https://github.com/syabyr/dln2_wrapper) — example ST7789 + BME280 application
229
+ - [dln2_examples](https://github.com/syabyr/dln2_examples) — sensor test scripts (BH1750, BME280, BMP180, TSL2561, MPU9250, …)
215
230
 
216
231
  ## License
217
232
 
@@ -83,10 +83,6 @@ smbus-compatible API: `write_byte()`, `read_byte_data()`,
83
83
  `read_channel(channel)`, `read_all()`, `read_volts(channel)`,
84
84
  `set_resolution(bits)`, `enable_channel(ch)`, `disable_channel(ch)`
85
85
 
86
- ### BME280
87
- `read_chip_id()`, `get_temperature()`, `get_humidity()`, `get_pressure()`,
88
- `get_altitude()`, `get_all()`
89
-
90
86
  ## CLI Commands
91
87
 
92
88
  After installation, the following commands are available:
@@ -100,7 +96,6 @@ After installation, the following commands are available:
100
96
  | `dln2-adc-watch` | Stream one ADC channel |
101
97
  | `dln2-i2c-scan` | Scan I2C bus for devices |
102
98
  | `dln2-i2c-test` | Read/write I2C register |
103
- | `dln2-bme280` | Read BME280 sensor measurements |
104
99
  | `dln2-spi-test` | Send SPI JEDEC ID probe |
105
100
  | `dln2-bpw-test` | Cycle SPI bits-per-word 4..16 |
106
101
 
@@ -118,28 +113,59 @@ dln2-adc-watch --channel 0 --interval 0.5
118
113
  dln2-i2c-scan
119
114
  dln2-i2c-test --address 0x76 --register 0xD0 --read 1
120
115
 
121
- # BME280
122
- dln2-bme280 --address 0x76 --pretty
123
-
124
116
  # SPI
125
117
  dln2-spi-test
126
118
  dln2-bpw-test
127
119
  ```
128
120
 
129
- ## Examples (as scripts)
121
+ ## Examples
122
+
123
+ ### Core examples (this repo)
124
+
125
+ Basic I/O operations that exercise the wrapper itself:
130
126
 
131
127
  ```bash
132
128
  # SPI JEDEC ID read
133
129
  python3 examples/spidev_test.py
134
130
 
131
+ # SPI bits-per-word cycle
132
+ python3 examples/bpw_tester.py
133
+
135
134
  # GPIO pin toggle (default: Pico LED)
136
135
  python3 examples/gpio_toggle.py --pin 25
137
136
 
137
+ # GPIO pin info
138
+ python3 examples/gpio_info.py --pin 2
139
+
140
+ # GPIO event watch
141
+ python3 examples/gpio_watch.py --pin 2
142
+
138
143
  # I2C bus scan
139
144
  python3 examples/i2c_scan.py
140
145
 
141
- # ADC monitor
146
+ # I2C register read/write
147
+ python3 examples/i2c_test.py --address 0x76 --register 0xD0 --read 1
148
+
149
+ # ADC read
142
150
  python3 examples/adc_info.py
151
+
152
+ # ADC stream
153
+ python3 examples/adc_watch.py --channel 0
154
+ ```
155
+
156
+ ### Device-specific examples (separate repo)
157
+
158
+ Sensor test scripts live in [dln2_examples](https://github.com/syabyr/dln2_examples):
159
+
160
+ ```bash
161
+ git clone https://github.com/syabyr/dln2_examples
162
+ cd dln2_examples/i2c
163
+
164
+ python3 bh1750_full_test.py # BH1750 ambient light @ 0x23
165
+ python3 bme280_full_test.py # BME280 temp/press/humid @ 0x76
166
+ python3 bmp180_full_test.py # BMP180 temp/pressure @ 0x77
167
+ python3 tsl2561_full_test.py # TSL2561 ambient light @ 0x39
168
+ python3 mpu9250_full_test.py # MPU9250 9-axis IMU @ 0x68
143
169
  ```
144
170
 
145
171
  ## Why Unified?
@@ -176,7 +202,7 @@ To flash updated firmware:
176
202
  ## Related
177
203
 
178
204
  - [pico-usb-io-board](https://github.com/syabyr/pico-usb-io-board) — RP2040 firmware
179
- - [st7789 display driver](https://github.com/syabyr/dln2_wrapper) — example ST7789 + BME280 application
205
+ - [dln2_examples](https://github.com/syabyr/dln2_examples) — sensor test scripts (BH1750, BME280, BMP180, TSL2561, MPU9250, …)
180
206
 
181
207
  ## License
182
208
 
@@ -24,4 +24,3 @@ from .gpio import GPIO, \
24
24
  GPIO_EVENT_LEVEL_HIGH, GPIO_EVENT_LEVEL_LOW
25
25
  from .i2c import SMBus, i2c_msg
26
26
  from .adc import ADC
27
- from .bme280 import BME280
@@ -416,6 +416,7 @@ class Dln2Connection:
416
416
  return resp
417
417
 
418
418
  def i2c_read(self, addr, length, mem_addr_len=0, mem_addr=0):
419
+ # Use 9-byte header — firmware expects BBBIH for reads
419
420
  payload = struct.pack("<BBBIH", 0, int(addr) & 0x7F,
420
421
  int(mem_addr_len) & 0xFF,
421
422
  int(mem_addr) & 0xFFFFFFFF,
@@ -282,40 +282,6 @@ def i2c_test():
282
282
  sys.exit(1)
283
283
 
284
284
 
285
- # ═══════════════════════════════════════════════════════════════
286
- # BME280
287
- # ═══════════════════════════════════════════════════════════════
288
-
289
- def bme280():
290
- """Read BME280 sensor values (chip ID + measurements)."""
291
- from dln2.bme280 import BME280
292
-
293
- parser = argparse.ArgumentParser(description="Read BME280 values over DLN2 I2C")
294
- parser.add_argument("--address", type=_parse_int, default=0x76, help="BME280 I2C address")
295
- parser.add_argument("--pretty", action="store_true", help="Print pretty JSON")
296
- args = parser.parse_args()
297
-
298
- try:
299
- with BME280(address=args.address) as sensor:
300
- chip_id = sensor.check_chip_id()
301
- sensor.read_calibration()
302
- sensor.configure()
303
- measurement = sensor.read_measurements()
304
-
305
- payload = {
306
- "address": args.address,
307
- "chip_id": chip_id,
308
- **measurement,
309
- }
310
- if args.pretty:
311
- print(json.dumps(payload, indent=2, sort_keys=True))
312
- else:
313
- print(json.dumps(payload, sort_keys=True))
314
- except RuntimeError as e:
315
- print(f"Error: {e}", file=sys.stderr)
316
- sys.exit(1)
317
-
318
-
319
285
  # ═══════════════════════════════════════════════════════════════
320
286
  # SPI
321
287
  # ═══════════════════════════════════════════════════════════════
@@ -103,24 +103,28 @@ class SMBus:
103
103
  return self._require().i2c_read(addr, 1)[0]
104
104
 
105
105
  def read_byte_data(self, addr, cmd):
106
- return self._require().i2c_read(addr, 1, mem_addr_len=1,
107
- mem_addr=cmd)[0]
106
+ conn = self._require()
107
+ conn.i2c_write(addr, [cmd])
108
+ return conn.i2c_read(addr, 1)[0]
108
109
 
109
110
  def read_word_data(self, addr, cmd):
110
- rx = self._require().i2c_read(addr, 2, mem_addr_len=1, mem_addr=cmd)
111
+ conn = self._require()
112
+ conn.i2c_write(addr, [cmd])
113
+ rx = conn.i2c_read(addr, 2)
111
114
  return rx[0] | (rx[1] << 8)
112
115
 
113
116
  def read_block_data(self, addr, cmd):
114
- # Read count byte first, then data
115
- count = self._require().i2c_read(addr, 1, mem_addr_len=1,
116
- mem_addr=cmd)[0]
117
+ conn = self._require()
118
+ conn.i2c_write(addr, [cmd])
119
+ count = conn.i2c_read(addr, 1)[0]
117
120
  if count == 0:
118
121
  return []
119
- return list(self._require().i2c_read(addr, count))
122
+ return list(conn.i2c_read(addr, count))
120
123
 
121
124
  def read_i2c_block_data(self, addr, cmd, length=32):
122
- return list(self._require().i2c_read(addr, length,
123
- mem_addr_len=1, mem_addr=cmd))
125
+ conn = self._require()
126
+ conn.i2c_write(addr, [cmd])
127
+ return list(conn.i2c_read(addr, length))
124
128
 
125
129
  # ── Raw access ─────────────────────────────────────
126
130
 
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.1
2
2
  Name: dln2
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: Unified DLN2 driver — SPI, GPIO, I2C, ADC over a single USB connection. Originally developed for the Pico USB I/O Board.
5
5
  Home-page: https://github.com/syabyr/dln2_wrapper
6
6
  Author: IPM Group
@@ -21,17 +21,6 @@ Requires-Python: >=3.9
21
21
  Description-Content-Type: text/markdown
22
22
  License-File: LICENSE
23
23
  Requires-Dist: pyusb>=1.2
24
- Dynamic: author
25
- Dynamic: author-email
26
- Dynamic: classifier
27
- Dynamic: description
28
- Dynamic: description-content-type
29
- Dynamic: home-page
30
- Dynamic: license
31
- Dynamic: license-file
32
- Dynamic: requires-dist
33
- Dynamic: requires-python
34
- Dynamic: summary
35
24
 
36
25
  # dln2 — Unified DLN2 USB I/O Board Wrapper
37
26
 
@@ -118,10 +107,6 @@ smbus-compatible API: `write_byte()`, `read_byte_data()`,
118
107
  `read_channel(channel)`, `read_all()`, `read_volts(channel)`,
119
108
  `set_resolution(bits)`, `enable_channel(ch)`, `disable_channel(ch)`
120
109
 
121
- ### BME280
122
- `read_chip_id()`, `get_temperature()`, `get_humidity()`, `get_pressure()`,
123
- `get_altitude()`, `get_all()`
124
-
125
110
  ## CLI Commands
126
111
 
127
112
  After installation, the following commands are available:
@@ -135,7 +120,6 @@ After installation, the following commands are available:
135
120
  | `dln2-adc-watch` | Stream one ADC channel |
136
121
  | `dln2-i2c-scan` | Scan I2C bus for devices |
137
122
  | `dln2-i2c-test` | Read/write I2C register |
138
- | `dln2-bme280` | Read BME280 sensor measurements |
139
123
  | `dln2-spi-test` | Send SPI JEDEC ID probe |
140
124
  | `dln2-bpw-test` | Cycle SPI bits-per-word 4..16 |
141
125
 
@@ -153,28 +137,59 @@ dln2-adc-watch --channel 0 --interval 0.5
153
137
  dln2-i2c-scan
154
138
  dln2-i2c-test --address 0x76 --register 0xD0 --read 1
155
139
 
156
- # BME280
157
- dln2-bme280 --address 0x76 --pretty
158
-
159
140
  # SPI
160
141
  dln2-spi-test
161
142
  dln2-bpw-test
162
143
  ```
163
144
 
164
- ## Examples (as scripts)
145
+ ## Examples
146
+
147
+ ### Core examples (this repo)
148
+
149
+ Basic I/O operations that exercise the wrapper itself:
165
150
 
166
151
  ```bash
167
152
  # SPI JEDEC ID read
168
153
  python3 examples/spidev_test.py
169
154
 
155
+ # SPI bits-per-word cycle
156
+ python3 examples/bpw_tester.py
157
+
170
158
  # GPIO pin toggle (default: Pico LED)
171
159
  python3 examples/gpio_toggle.py --pin 25
172
160
 
161
+ # GPIO pin info
162
+ python3 examples/gpio_info.py --pin 2
163
+
164
+ # GPIO event watch
165
+ python3 examples/gpio_watch.py --pin 2
166
+
173
167
  # I2C bus scan
174
168
  python3 examples/i2c_scan.py
175
169
 
176
- # ADC monitor
170
+ # I2C register read/write
171
+ python3 examples/i2c_test.py --address 0x76 --register 0xD0 --read 1
172
+
173
+ # ADC read
177
174
  python3 examples/adc_info.py
175
+
176
+ # ADC stream
177
+ python3 examples/adc_watch.py --channel 0
178
+ ```
179
+
180
+ ### Device-specific examples (separate repo)
181
+
182
+ Sensor test scripts live in [dln2_examples](https://github.com/syabyr/dln2_examples):
183
+
184
+ ```bash
185
+ git clone https://github.com/syabyr/dln2_examples
186
+ cd dln2_examples/i2c
187
+
188
+ python3 bh1750_full_test.py # BH1750 ambient light @ 0x23
189
+ python3 bme280_full_test.py # BME280 temp/press/humid @ 0x76
190
+ python3 bmp180_full_test.py # BMP180 temp/pressure @ 0x77
191
+ python3 tsl2561_full_test.py # TSL2561 ambient light @ 0x39
192
+ python3 mpu9250_full_test.py # MPU9250 9-axis IMU @ 0x68
178
193
  ```
179
194
 
180
195
  ## Why Unified?
@@ -211,7 +226,7 @@ To flash updated firmware:
211
226
  ## Related
212
227
 
213
228
  - [pico-usb-io-board](https://github.com/syabyr/pico-usb-io-board) — RP2040 firmware
214
- - [st7789 display driver](https://github.com/syabyr/dln2_wrapper) — example ST7789 + BME280 application
229
+ - [dln2_examples](https://github.com/syabyr/dln2_examples) — sensor test scripts (BH1750, BME280, BMP180, TSL2561, MPU9250, …)
215
230
 
216
231
  ## License
217
232
 
@@ -1,7 +1,6 @@
1
1
  [console_scripts]
2
2
  dln2-adc-info = dln2.cli:adc_info
3
3
  dln2-adc-watch = dln2.cli:adc_watch
4
- dln2-bme280 = dln2.cli:bme280
5
4
  dln2-bpw-test = dln2.cli:bpw_test
6
5
  dln2-gpio-info = dln2.cli:gpio_info
7
6
  dln2-gpio-toggle = dln2.cli:gpio_toggle
@@ -5,7 +5,7 @@ from setuptools import setup, find_packages
5
5
 
6
6
  setup(
7
7
  name="dln2",
8
- version="0.2.1",
8
+ version="0.2.2",
9
9
  description="Unified DLN2 driver — SPI, GPIO, I2C, ADC over a single USB connection. "
10
10
  "Originally developed for the Pico USB I/O Board.",
11
11
  long_description=open("README.md").read(),
@@ -14,7 +14,7 @@ setup(
14
14
  author="IPM Group",
15
15
  author_email="contact@ipmgroup.dev",
16
16
  license="MIT",
17
- packages=find_packages(exclude=["examples"]),
17
+ packages=find_packages(exclude=["examples", "i2c", "i2c.*"]),
18
18
  package_data={"dln2": ["py.typed"]},
19
19
  install_requires=[
20
20
  "pyusb>=1.2",
@@ -29,7 +29,6 @@ setup(
29
29
  "dln2-adc-watch=dln2.cli:adc_watch",
30
30
  "dln2-i2c-scan=dln2.cli:i2c_scan",
31
31
  "dln2-i2c-test=dln2.cli:i2c_test",
32
- "dln2-bme280=dln2.cli:bme280",
33
32
  "dln2-spi-test=dln2.cli:spi_test",
34
33
  "dln2-bpw-test=dln2.cli:bpw_test",
35
34
  ],
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes