Skip to content

Commit

Permalink
SPI and OneWire
Browse files Browse the repository at this point in the history
  • Loading branch information
MrYsLab committed Aug 27, 2021
1 parent b7aa9be commit 11ba837
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion examples/onewire_ds18x20.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 1 addition & 4 deletions examples/spi_mpu9250.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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:
Expand All @@ -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)} ")
Expand All @@ -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)} "
Expand Down
32 changes: 19 additions & 13 deletions html/telemetrix/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<meta name="generator" content="pdoc 0.10.0" />
<title>telemetrix.telemetrix API documentation</title>
<meta name="description" content="Copyright (c) 2020 Alan Yorinks All rights reserved …" />
<meta name="description" content="Copyright (c) 2021 Alan Yorinks All rights reserved …" />
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/sanitize.min.css" integrity="sha256-PK9q560IAAa6WVRRh76LtCaI8pjTJ2z11v0miyNNjrs=" crossorigin>
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/typography.min.css" integrity="sha256-7l/o7C8jubJiy74VsKTidCy1yBkRtiUGbVkYBylBqUg=" crossorigin>
<link rel="stylesheet preload" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/styles/github.min.css" crossorigin>
Expand All @@ -22,12 +22,12 @@
<h1 class="title">Module <code>telemetrix.telemetrix</code></h1>
</header>
<section id="section-intro">
<p>Copyright (c) 2020 Alan Yorinks All rights reserved.</p>
<p>Copyright (c) 2021 Alan Yorinks All rights reserved.</p>
<p>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
Expand All @@ -42,13 +42,13 @@ <h1 class="title">Module <code>telemetrix.telemetrix</code></h1>
<span>Expand source code</span>
</summary>
<pre><code class="python">&#34;&#34;&#34;
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.
Expand Down Expand Up @@ -1136,7 +1136,8 @@ <h1 class="title">Module <code>telemetrix.telemetrix</code></h1>
def set_pin_mode_one_wire(self, pin):
&#34;&#34;&#34;
Initialize the one wire serial bus.
:param pin: Data pin used with the OneWire device

:param pin: Data pin connected to the OneWire device
&#34;&#34;&#34;
self.onewire_enabled = True
command = [PrivateConstants.ONE_WIRE_INIT, pin]
Expand Down Expand Up @@ -1264,7 +1265,8 @@ <h1 class="title">Module <code>telemetrix.telemetrix</code></h1>
if not self.onewire_enabled:
if self.shutdown_on_exception:
self.shutdown()
raise RuntimeError(f&#39;onewire_reset_serach: OneWire interface is not enabled.&#39;)
raise RuntimeError(f&#39;onewire_reset_search: OneWire interface is not &#39;
f&#39;enabled.&#39;)
else:
command = [PrivateConstants.ONE_WIRE_RESET_SEARCH]
self._send_command(command)
Expand Down Expand Up @@ -2770,7 +2772,8 @@ <h2 class="section-title" id="header-classes">Classes</h2>
def set_pin_mode_one_wire(self, pin):
&#34;&#34;&#34;
Initialize the one wire serial bus.
:param pin: Data pin used with the OneWire device

:param pin: Data pin connected to the OneWire device
&#34;&#34;&#34;
self.onewire_enabled = True
command = [PrivateConstants.ONE_WIRE_INIT, pin]
Expand Down Expand Up @@ -2898,7 +2901,8 @@ <h2 class="section-title" id="header-classes">Classes</h2>
if not self.onewire_enabled:
if self.shutdown_on_exception:
self.shutdown()
raise RuntimeError(f&#39;onewire_reset_serach: OneWire interface is not enabled.&#39;)
raise RuntimeError(f&#39;onewire_reset_search: OneWire interface is not &#39;
f&#39;enabled.&#39;)
else:
command = [PrivateConstants.ONE_WIRE_RESET_SEARCH]
self._send_command(command)
Expand Down Expand Up @@ -3801,7 +3805,8 @@ <h3>Methods</h3>
if not self.onewire_enabled:
if self.shutdown_on_exception:
self.shutdown()
raise RuntimeError(f&#39;onewire_reset_serach: OneWire interface is not enabled.&#39;)
raise RuntimeError(f&#39;onewire_reset_search: OneWire interface is not &#39;
f&#39;enabled.&#39;)
else:
command = [PrivateConstants.ONE_WIRE_RESET_SEARCH]
self._send_command(command)</code></pre>
Expand Down Expand Up @@ -4277,16 +4282,17 @@ <h3>Methods</h3>
<span>def <span class="ident">set_pin_mode_one_wire</span></span>(<span>self, pin)</span>
</code></dt>
<dd>
<div class="desc"><p>Initialize the one wire serial bus.
:param pin: Data pin used with the OneWire device</p></div>
<div class="desc"><p>Initialize the one wire serial bus.</p>
<p>:param pin: Data pin connected to the OneWire device</p></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def set_pin_mode_one_wire(self, pin):
&#34;&#34;&#34;
Initialize the one wire serial bus.
:param pin: Data pin used with the OneWire device

:param pin: Data pin connected to the OneWire device
&#34;&#34;&#34;
self.onewire_enabled = True
command = [PrivateConstants.ONE_WIRE_INIT, pin]
Expand Down
3 changes: 2 additions & 1 deletion telemetrix/telemetrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 11ba837

Please sign in to comment.