From 11ba837aabdea596166a8f11329b7074bee8b888 Mon Sep 17 00:00:00 2001 From: MrYsLab Date: Fri, 27 Aug 2021 10:32:56 -0400 Subject: [PATCH] SPI and OneWire --- examples/onewire_ds18x20.py | 2 +- examples/spi_mpu9250.py | 5 +---- html/telemetrix/index.html | 32 +++++++++++++++++++------------- telemetrix/telemetrix.py | 3 ++- 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/examples/onewire_ds18x20.py b/examples/onewire_ds18x20.py index 497a036..2690fb9 100644 --- a/examples/onewire_ds18x20.py +++ b/examples/onewire_ds18x20.py @@ -1,5 +1,5 @@ """ - Copyright (c) 2020 Alan Yorinks All rights reserved. + Copyright (c) 2021 Alan Yorinks All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE diff --git a/examples/spi_mpu9250.py b/examples/spi_mpu9250.py index 1e729f4..bb3acf9 100644 --- a/examples/spi_mpu9250.py +++ b/examples/spi_mpu9250.py @@ -30,7 +30,7 @@ from telemetrix import telemetrix # Instantiate the TelemetrixRpiPico class accepting all default parameters. -board = telemetrix.Telemetrix(ip_address='192.168.2.174') +board = telemetrix.Telemetrix() # Convenience values for the pins. @@ -57,7 +57,6 @@ def the_device_callback(report): Verify the device ID :param report: [SPI_REPORT, read register, Number of bytes, device_id] """ - # print(f'device_callback {report}') if report[3] == 0x71: print('MPU9250 Device ID confirmed.') else: @@ -71,7 +70,6 @@ def accel_callback(report): :param report: [SPI_REPORT, Register, Number of bytes, AX-msb, AX-lsb AY-msb, AY-lsb, AX-msb, AX-lsb] """ - # print(f'accel_callback {report}') print(f"AX = {int.from_bytes(report[3:5], byteorder='big', signed=True)} " f"AY = {int.from_bytes(report[5:7], byteorder='big', signed=True)} " f"AZ = {int.from_bytes(report[7:9], byteorder='big', signed=True)} ") @@ -85,7 +83,6 @@ def gyro_callback(report): :param report: [SPI_REPORT, Register, Number of bytes, GX-msb, GX-lsb GY-msb, GY-lsb, GX-msb, GX-lsb] """ - # print(f'gyro_callback {report}') print(f"GX = {int.from_bytes(report[3:5], byteorder='big', signed=True)} " f"GY = {int.from_bytes(report[5:7], byteorder='big', signed=True)} " diff --git a/html/telemetrix/index.html b/html/telemetrix/index.html index c975b2b..77b9f04 100644 --- a/html/telemetrix/index.html +++ b/html/telemetrix/index.html @@ -5,7 +5,7 @@ telemetrix.telemetrix API documentation - + @@ -22,12 +22,12 @@

Module telemetrix.telemetrix

-

Copyright (c) 2020 Alan Yorinks All rights reserved.

+

Copyright (c) 2021 Alan Yorinks All rights reserved.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE Version 3 as published by the Free Software Foundation; either or (at your option) any later version. -This library is distributed in the hope that it will be useful,f +This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -42,13 +42,13 @@

Module telemetrix.telemetrix

Expand source code
"""
- Copyright (c) 2020 Alan Yorinks All rights reserved.
+ Copyright (c) 2021 Alan Yorinks All rights reserved.
 
  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  Version 3 as published by the Free Software Foundation; either
  or (at your option) any later version.
- This library is distributed in the hope that it will be useful,f
+ This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  General Public License for more details.
@@ -1136,7 +1136,8 @@ 

Module telemetrix.telemetrix

def set_pin_mode_one_wire(self, pin): """ Initialize the one wire serial bus. - :param pin: Data pin used with the OneWire device + + :param pin: Data pin connected to the OneWire device """ self.onewire_enabled = True command = [PrivateConstants.ONE_WIRE_INIT, pin] @@ -1264,7 +1265,8 @@

Module telemetrix.telemetrix

if not self.onewire_enabled: if self.shutdown_on_exception: self.shutdown() - raise RuntimeError(f'onewire_reset_serach: OneWire interface is not enabled.') + raise RuntimeError(f'onewire_reset_search: OneWire interface is not ' + f'enabled.') else: command = [PrivateConstants.ONE_WIRE_RESET_SEARCH] self._send_command(command) @@ -2770,7 +2772,8 @@

Classes

def set_pin_mode_one_wire(self, pin): """ Initialize the one wire serial bus. - :param pin: Data pin used with the OneWire device + + :param pin: Data pin connected to the OneWire device """ self.onewire_enabled = True command = [PrivateConstants.ONE_WIRE_INIT, pin] @@ -2898,7 +2901,8 @@

Classes

if not self.onewire_enabled: if self.shutdown_on_exception: self.shutdown() - raise RuntimeError(f'onewire_reset_serach: OneWire interface is not enabled.') + raise RuntimeError(f'onewire_reset_search: OneWire interface is not ' + f'enabled.') else: command = [PrivateConstants.ONE_WIRE_RESET_SEARCH] self._send_command(command) @@ -3801,7 +3805,8 @@

Methods

if not self.onewire_enabled: if self.shutdown_on_exception: self.shutdown() - raise RuntimeError(f'onewire_reset_serach: OneWire interface is not enabled.') + raise RuntimeError(f'onewire_reset_search: OneWire interface is not ' + f'enabled.') else: command = [PrivateConstants.ONE_WIRE_RESET_SEARCH] self._send_command(command)
@@ -4277,8 +4282,8 @@

Methods

def set_pin_mode_one_wire(self, pin)
-

Initialize the one wire serial bus. -:param pin: Data pin used with the OneWire device

+

Initialize the one wire serial bus.

+

:param pin: Data pin connected to the OneWire device

Expand source code @@ -4286,7 +4291,8 @@

Methods

def set_pin_mode_one_wire(self, pin):
     """
     Initialize the one wire serial bus.
-    :param pin: Data pin used with the OneWire device
+
+    :param pin: Data pin connected to the OneWire device
     """
     self.onewire_enabled = True
     command = [PrivateConstants.ONE_WIRE_INIT, pin]
diff --git a/telemetrix/telemetrix.py b/telemetrix/telemetrix.py
index 6d3db34..445ab55 100644
--- a/telemetrix/telemetrix.py
+++ b/telemetrix/telemetrix.py
@@ -1093,7 +1093,8 @@ def spi_write_blocking(self, bytes_to_write):
     def set_pin_mode_one_wire(self, pin):
         """
         Initialize the one wire serial bus.
-        :param pin: Data pin used with the OneWire device
+
+        :param pin: Data pin connected to the OneWire device
         """
         self.onewire_enabled = True
         command = [PrivateConstants.ONE_WIRE_INIT, pin]