pioled-display-plugin 0.3.0__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.
- pioled_display_plugin-0.3.0/LICENSE.txt +7 -0
- pioled_display_plugin-0.3.0/MANIFEST.in +2 -0
- pioled_display_plugin-0.3.0/PKG-INFO +39 -0
- pioled_display_plugin-0.3.0/README.md +27 -0
- pioled_display_plugin-0.3.0/pioled_display_plugin/__init__.py +177 -0
- pioled_display_plugin-0.3.0/pioled_display_plugin/post_install.sh +9 -0
- pioled_display_plugin-0.3.0/pioled_display_plugin/pre_uninstall.sh +9 -0
- pioled_display_plugin-0.3.0/pioled_display_plugin.egg-info/PKG-INFO +39 -0
- pioled_display_plugin-0.3.0/pioled_display_plugin.egg-info/SOURCES.txt +13 -0
- pioled_display_plugin-0.3.0/pioled_display_plugin.egg-info/dependency_links.txt +1 -0
- pioled_display_plugin-0.3.0/pioled_display_plugin.egg-info/entry_points.txt +2 -0
- pioled_display_plugin-0.3.0/pioled_display_plugin.egg-info/requires.txt +2 -0
- pioled_display_plugin-0.3.0/pioled_display_plugin.egg-info/top_level.txt +1 -0
- pioled_display_plugin-0.3.0/setup.cfg +4 -0
- pioled_display_plugin-0.3.0/setup.py +21 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright Pioreactor
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: pioled-display-plugin
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Use an OLED display with your Pioreactor
|
|
5
|
+
Home-page: https://github.com/Pioreactor/PiOLED-display-plugin
|
|
6
|
+
Author: Pioreactor
|
|
7
|
+
Author-email: hello@pioreactor.com
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE.txt
|
|
10
|
+
Requires-Dist: adafruit-circuitpython-ssd1306==2.12.16
|
|
11
|
+
Requires-Dist: Pillow==10.1.0
|
|
12
|
+
|
|
13
|
+
## PiOLED display plugin for the Pioreactor
|
|
14
|
+
|
|
15
|
+
Display growth rate, normalized OD, and temperature for each Pioreactor using the [Adafruit PiOLED display](https://www.adafruit.com/product/3527)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Hardware required
|
|
19
|
+
|
|
20
|
+
- [Adafruit PiOLED display](https://www.adafruit.com/product/3527)
|
|
21
|
+
- [0.1" 2x20-pin Strip Right Angle Female Header](https://www.adafruit.com/product/2823)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Software installation
|
|
25
|
+
|
|
26
|
+
Install from the UI, or run:
|
|
27
|
+
```
|
|
28
|
+
pio plugins install pioled-display-plugin
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
You may get a "hardware not installed" error. That's okay, we'll do that next.
|
|
32
|
+
|
|
33
|
+
### Hardware installation
|
|
34
|
+
|
|
35
|
+
With the Pioreactor turned off (you can pull the plug), install the 2x20 right-angle header onto the the 2x20 header on the Pioreactor HAT. Attach the PiOLED display onto the right-hand side of the new header, with the orientation as shown in the image below:
|
|
36
|
+
|
|
37
|
+
<img width="462" alt="Screenshot 2023-06-21 at 2 40 14 PM" alt="PiOLD attached to the right-angle headers." src="https://github.com/Pioreactor/PiOLED-display-plugin/assets/884032/3b3096d0-4cfa-4a74-8ff1-36cff2fb4d99">
|
|
38
|
+
|
|
39
|
+
Power back on the Pioreactor.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
## PiOLED display plugin for the Pioreactor
|
|
2
|
+
|
|
3
|
+
Display growth rate, normalized OD, and temperature for each Pioreactor using the [Adafruit PiOLED display](https://www.adafruit.com/product/3527)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Hardware required
|
|
7
|
+
|
|
8
|
+
- [Adafruit PiOLED display](https://www.adafruit.com/product/3527)
|
|
9
|
+
- [0.1" 2x20-pin Strip Right Angle Female Header](https://www.adafruit.com/product/2823)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Software installation
|
|
13
|
+
|
|
14
|
+
Install from the UI, or run:
|
|
15
|
+
```
|
|
16
|
+
pio plugins install pioled-display-plugin
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
You may get a "hardware not installed" error. That's okay, we'll do that next.
|
|
20
|
+
|
|
21
|
+
### Hardware installation
|
|
22
|
+
|
|
23
|
+
With the Pioreactor turned off (you can pull the plug), install the 2x20 right-angle header onto the the 2x20 header on the Pioreactor HAT. Attach the PiOLED display onto the right-hand side of the new header, with the orientation as shown in the image below:
|
|
24
|
+
|
|
25
|
+
<img width="462" alt="Screenshot 2023-06-21 at 2 40 14 PM" alt="PiOLD attached to the right-angle headers." src="https://github.com/Pioreactor/PiOLED-display-plugin/assets/884032/3b3096d0-4cfa-4a74-8ff1-36cff2fb4d99">
|
|
26
|
+
|
|
27
|
+
Power back on the Pioreactor.
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
from typing import Optional
|
|
5
|
+
|
|
6
|
+
import adafruit_ssd1306
|
|
7
|
+
import busio
|
|
8
|
+
import click
|
|
9
|
+
from msgspec.json import decode
|
|
10
|
+
from PIL import Image
|
|
11
|
+
from PIL import ImageDraw
|
|
12
|
+
from PIL import ImageFont
|
|
13
|
+
from pioreactor import structs
|
|
14
|
+
from pioreactor import types as pt
|
|
15
|
+
from pioreactor.background_jobs.base import BackgroundJobContrib
|
|
16
|
+
from pioreactor.cli.pio import JOBS_TO_SKIP_KILLING
|
|
17
|
+
from pioreactor.hardware import SCL
|
|
18
|
+
from pioreactor.hardware import SDA
|
|
19
|
+
from pioreactor.utils.networking import get_ip
|
|
20
|
+
from pioreactor.whoami import get_unit_name
|
|
21
|
+
from pioreactor.whoami import UNIVERSAL_EXPERIMENT
|
|
22
|
+
|
|
23
|
+
# since this is a long-running job, we don't want it to be killed by pio kill --all-jobs.
|
|
24
|
+
|
|
25
|
+
JOBS_TO_SKIP_KILLING.append("pioled_display")
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class PiOLEDDisplay(BackgroundJobContrib):
|
|
29
|
+
|
|
30
|
+
job_name = "pioled_display"
|
|
31
|
+
|
|
32
|
+
growth_rate: Optional[float] = None
|
|
33
|
+
od: Optional[float] = None
|
|
34
|
+
temp: Optional[float] = None
|
|
35
|
+
|
|
36
|
+
def __init__(self, unit: str, experiment: str) -> None:
|
|
37
|
+
super().__init__(unit=unit, experiment=experiment, plugin_name="pioled_display_plugin")
|
|
38
|
+
|
|
39
|
+
# Create the I2C interface.
|
|
40
|
+
i2c = busio.I2C(SCL, SDA)
|
|
41
|
+
|
|
42
|
+
try:
|
|
43
|
+
self.disp = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c)
|
|
44
|
+
except Exception as e:
|
|
45
|
+
self.logger.error("Unable to find PiOLED hardware. Is it attached?")
|
|
46
|
+
self.clean_up()
|
|
47
|
+
raise e
|
|
48
|
+
|
|
49
|
+
# get ip for displaying
|
|
50
|
+
self._ip = get_ip()
|
|
51
|
+
|
|
52
|
+
# rotate the screen since we are flipping it
|
|
53
|
+
self.disp.rotation = 2
|
|
54
|
+
|
|
55
|
+
# Clear display.
|
|
56
|
+
self.disp.fill(0)
|
|
57
|
+
self.disp.show()
|
|
58
|
+
|
|
59
|
+
# Create blank image for drawing.
|
|
60
|
+
# Make sure to create image with mode '1' for 1-bit color.
|
|
61
|
+
self.width = self.disp.width
|
|
62
|
+
self.height = self.disp.height
|
|
63
|
+
self.image = Image.new("1", (self.width, self.height))
|
|
64
|
+
|
|
65
|
+
# Get drawing object to draw on image.
|
|
66
|
+
self.draw = ImageDraw.Draw(self.image)
|
|
67
|
+
|
|
68
|
+
# Draw some shapes.
|
|
69
|
+
# First define some constants to allow easy resizing of shapes.
|
|
70
|
+
padding = -2
|
|
71
|
+
self.top = padding
|
|
72
|
+
self.bottom = self.height - padding
|
|
73
|
+
# Move left to right keeping track of the current x position for drawing shapes.
|
|
74
|
+
self.x = 0
|
|
75
|
+
|
|
76
|
+
# Load default font.
|
|
77
|
+
self.font = ImageFont.load_default()
|
|
78
|
+
|
|
79
|
+
self.update_display()
|
|
80
|
+
self.start_passive_listeners()
|
|
81
|
+
|
|
82
|
+
def update_od(self, msg: pt.MQTTMessage) -> None:
|
|
83
|
+
if msg.payload:
|
|
84
|
+
self.od = decode(msg.payload, type=structs.ODFiltered).od_filtered
|
|
85
|
+
else:
|
|
86
|
+
self.od = None
|
|
87
|
+
self.update_display()
|
|
88
|
+
|
|
89
|
+
def update_growth_rate(self, msg: pt.MQTTMessage) -> None:
|
|
90
|
+
if msg.payload:
|
|
91
|
+
self.growth_rate = decode(msg.payload, type=structs.GrowthRate).growth_rate
|
|
92
|
+
else:
|
|
93
|
+
self.growth_rate = None
|
|
94
|
+
self.update_display()
|
|
95
|
+
|
|
96
|
+
def update_temp(self, msg: pt.MQTTMessage) -> None:
|
|
97
|
+
if msg.payload:
|
|
98
|
+
self.temp = decode(msg.payload, type=structs.Temperature).temperature
|
|
99
|
+
else:
|
|
100
|
+
self.temp = None
|
|
101
|
+
self.update_display()
|
|
102
|
+
|
|
103
|
+
def start_passive_listeners(self) -> None:
|
|
104
|
+
self.subscribe_and_callback(
|
|
105
|
+
self.update_od,
|
|
106
|
+
f"pioreactor/{self.unit}/+/growth_rate_calculating/od_filtered",
|
|
107
|
+
allow_retained=False,
|
|
108
|
+
)
|
|
109
|
+
self.subscribe_and_callback(
|
|
110
|
+
self.update_growth_rate,
|
|
111
|
+
f"pioreactor/{self.unit}/+/growth_rate_calculating/growth_rate",
|
|
112
|
+
allow_retained=False,
|
|
113
|
+
)
|
|
114
|
+
self.subscribe_and_callback(
|
|
115
|
+
self.update_temp,
|
|
116
|
+
f"pioreactor/{self.unit}/+/temperature_automation/temperature",
|
|
117
|
+
allow_retained=False,
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
def clear_display(self) -> None:
|
|
121
|
+
self.draw.rectangle((0, 0, self.width, self.height), outline=0, fill=0)
|
|
122
|
+
self.disp.image(self.image)
|
|
123
|
+
self.disp.show()
|
|
124
|
+
|
|
125
|
+
def on_disconnected(self) -> None:
|
|
126
|
+
try:
|
|
127
|
+
self.clear_display()
|
|
128
|
+
except Exception:
|
|
129
|
+
pass
|
|
130
|
+
|
|
131
|
+
def update_display(self) -> None:
|
|
132
|
+
# Draw a black filled box to clear the image.
|
|
133
|
+
self.draw.rectangle((0, 0, self.width, self.height), outline=0, fill=0)
|
|
134
|
+
# Write four lines of text.
|
|
135
|
+
self.draw.text((self.x, self.top + 0), self.unit, font=self.font, fill=255)
|
|
136
|
+
if self.growth_rate:
|
|
137
|
+
self.draw.text(
|
|
138
|
+
(self.x, self.top + 8),
|
|
139
|
+
f" Growth rate: {self.growth_rate:.2f}/h",
|
|
140
|
+
font=self.font,
|
|
141
|
+
fill=255,
|
|
142
|
+
)
|
|
143
|
+
if self.od:
|
|
144
|
+
self.draw.text(
|
|
145
|
+
(self.x, self.top + 16),
|
|
146
|
+
f" nOD: {self.od:.2f} AU",
|
|
147
|
+
font=self.font,
|
|
148
|
+
fill=255,
|
|
149
|
+
)
|
|
150
|
+
if self.temp:
|
|
151
|
+
self.draw.text(
|
|
152
|
+
(self.x, self.top + 25),
|
|
153
|
+
f" Temperature: {self.temp:.1f} C",
|
|
154
|
+
font=self.font,
|
|
155
|
+
fill=255,
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
if not self.temp and not self.od and not self.growth_rate:
|
|
159
|
+
self.draw.text(
|
|
160
|
+
(self.x, self.top + 8),
|
|
161
|
+
f" IP: {self._ip}",
|
|
162
|
+
font=self.font,
|
|
163
|
+
fill=255,
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
# Display image.
|
|
167
|
+
self.disp.image(self.image)
|
|
168
|
+
self.disp.show()
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
@click.command(name="pioled_display")
|
|
172
|
+
def click_pioled_display() -> None:
|
|
173
|
+
"""
|
|
174
|
+
Turn on the OLED display
|
|
175
|
+
"""
|
|
176
|
+
lg = PiOLEDDisplay(unit=get_unit_name(), experiment=UNIVERSAL_EXPERIMENT)
|
|
177
|
+
lg.block_until_disconnected()
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: pioled-display-plugin
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Use an OLED display with your Pioreactor
|
|
5
|
+
Home-page: https://github.com/Pioreactor/PiOLED-display-plugin
|
|
6
|
+
Author: Pioreactor
|
|
7
|
+
Author-email: hello@pioreactor.com
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE.txt
|
|
10
|
+
Requires-Dist: adafruit-circuitpython-ssd1306==2.12.16
|
|
11
|
+
Requires-Dist: Pillow==10.1.0
|
|
12
|
+
|
|
13
|
+
## PiOLED display plugin for the Pioreactor
|
|
14
|
+
|
|
15
|
+
Display growth rate, normalized OD, and temperature for each Pioreactor using the [Adafruit PiOLED display](https://www.adafruit.com/product/3527)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Hardware required
|
|
19
|
+
|
|
20
|
+
- [Adafruit PiOLED display](https://www.adafruit.com/product/3527)
|
|
21
|
+
- [0.1" 2x20-pin Strip Right Angle Female Header](https://www.adafruit.com/product/2823)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Software installation
|
|
25
|
+
|
|
26
|
+
Install from the UI, or run:
|
|
27
|
+
```
|
|
28
|
+
pio plugins install pioled-display-plugin
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
You may get a "hardware not installed" error. That's okay, we'll do that next.
|
|
32
|
+
|
|
33
|
+
### Hardware installation
|
|
34
|
+
|
|
35
|
+
With the Pioreactor turned off (you can pull the plug), install the 2x20 right-angle header onto the the 2x20 header on the Pioreactor HAT. Attach the PiOLED display onto the right-hand side of the new header, with the orientation as shown in the image below:
|
|
36
|
+
|
|
37
|
+
<img width="462" alt="Screenshot 2023-06-21 at 2 40 14 PM" alt="PiOLD attached to the right-angle headers." src="https://github.com/Pioreactor/PiOLED-display-plugin/assets/884032/3b3096d0-4cfa-4a74-8ff1-36cff2fb4d99">
|
|
38
|
+
|
|
39
|
+
Power back on the Pioreactor.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
LICENSE.txt
|
|
2
|
+
MANIFEST.in
|
|
3
|
+
README.md
|
|
4
|
+
setup.py
|
|
5
|
+
pioled_display_plugin/__init__.py
|
|
6
|
+
pioled_display_plugin/post_install.sh
|
|
7
|
+
pioled_display_plugin/pre_uninstall.sh
|
|
8
|
+
pioled_display_plugin.egg-info/PKG-INFO
|
|
9
|
+
pioled_display_plugin.egg-info/SOURCES.txt
|
|
10
|
+
pioled_display_plugin.egg-info/dependency_links.txt
|
|
11
|
+
pioled_display_plugin.egg-info/entry_points.txt
|
|
12
|
+
pioled_display_plugin.egg-info/requires.txt
|
|
13
|
+
pioled_display_plugin.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pioled_display_plugin
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
from setuptools import find_packages
|
|
5
|
+
from setuptools import setup
|
|
6
|
+
|
|
7
|
+
setup(
|
|
8
|
+
name="pioled-display-plugin",
|
|
9
|
+
version="0.3.0",
|
|
10
|
+
license_files=("LICENSE.txt",),
|
|
11
|
+
description="Use an OLED display with your Pioreactor",
|
|
12
|
+
long_description=open("README.md").read(),
|
|
13
|
+
long_description_content_type="text/markdown",
|
|
14
|
+
author_email="hello@pioreactor.com",
|
|
15
|
+
author="Pioreactor",
|
|
16
|
+
url="https://github.com/Pioreactor/PiOLED-display-plugin",
|
|
17
|
+
packages=find_packages(),
|
|
18
|
+
include_package_data=True,
|
|
19
|
+
install_requires=["adafruit-circuitpython-ssd1306==2.12.16", "Pillow==10.1.0"],
|
|
20
|
+
entry_points={"pioreactor.plugins": "pioled_display_plugin = pioled_display_plugin"},
|
|
21
|
+
)
|