Skip to content

Commit 334ec13

Browse files
init commit for new calibration code in pioreactor 25.1.x
1 parent 344f5b2 commit 334ec13

File tree

7 files changed

+92
-396
lines changed

7 files changed

+92
-396
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
steps:
1515
- name: Checkout source
16-
uses: actions/checkout@v2
16+
uses: actions/checkout@v4
1717

1818
- name: Setup python
1919
uses: actions/setup-python@v2

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ This plugin offers the ability to calibrate your LEDs using an **external light
1414
Install from the command line.
1515

1616
```
17-
pio install-plugin led-calibration-plugin ## to install on a single Pioreactor
17+
pio plugins install led-calibration-plugin ## to install on a single Pioreactor
1818
1919
## OR, on the command line of the leader Pioreactor
2020
21-
pios install-plugin led-calibration-plugin ## to install on all Pioreactors in a cluster
21+
pios plugins install led-calibration-plugin ## to install on all Pioreactors in a cluster
2222
```
2323

2424
This plugin is also available on the Pioreactor web interface, in the _Plugins_ tab. Downloading from the web interface will install on all Pioreactors in a cluster.

led_calibration_plugin/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@
44
from led_calibration_plugin.calibrated_light_dark_cycle import (
55
CalibratedLightDarkCycle,
66
) # noqa: F401
7-
from led_calibration_plugin.led_calibration import click_led_calibration # noqa: F401

led_calibration_plugin/calibrated_light_dark_cycle.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from pioreactor.exc import CalibrationError
88
from pioreactor.types import LedChannel
99
from pioreactor.utils import clamp
10-
from pioreactor.utils import local_persistant_storage
10+
from pioreactor.utils import local_persistent_storage
1111

1212
from .led_calibration import LEDCalibration
1313

@@ -44,18 +44,23 @@ def __init__(
4444
self.light_duration_hours = float(light_duration_hours)
4545
self.dark_duration_hours = float(dark_duration_hours)
4646

47-
with local_persistant_storage("current_led_calibration") as cache:
47+
with local_persistent_storage("active_calibrations") as cache:
4848
for channel in self.channels:
49-
if channel not in cache:
49+
if self.channel_to_led_device(channel) not in cache:
5050
raise CalibrationError(f"Calibration for {channel} does not exist.")
5151

52+
def channel_to_led_device(self, channel: LedChannel) -> str:
53+
return f"led_{channel}"
54+
5255
def execute(self) -> events.AutomationEvent:
5356
self.hours_online += 1
5457
return self.trigger_leds(self.hours_online)
5558

5659
def calculate_intensity_percent(self, channel):
57-
with local_persistant_storage("current_led_calibration") as cache:
58-
led_calibration = decode(cache[channel], type=LEDCalibration)
60+
with local_persistent_storage("current_led_calibration") as cache:
61+
led_calibration = decode(
62+
cache[self.channel_to_led_device(channel)], type=LEDCalibration
63+
)
5964

6065
intensity_percent = (
6166
self.light_intensity - led_calibration.curve_data_[1]

0 commit comments

Comments
 (0)