Skip to content

Commit 9e02589

Browse files
don't create those indexes - takes too long during an update; we needed to change the scale value with the new firmware code v0.4
1 parent ed14127 commit 9e02589

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed

pioreactor/background_jobs/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ def _confirm_state_in_broker(self, message: pt.MQTTMessage) -> None:
895895
self.logger.debug(
896896
f"Job is in state {self.state}, but in state {state_in_broker} in broker. Attempting fix by publishing {self.state}."
897897
)
898-
sleep(1)
898+
sleep(5)
899899
self._publish_setting("state")
900900

901901
def _clear_caches(self) -> None:

pioreactor/background_jobs/monitor.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,8 @@ def flicker_led_response_okay(self, *args) -> None:
532532
self.led_off()
533533
sleep(0.45)
534534

535+
self._republish_state()
536+
535537
self.led_in_use = False
536538

537539
def flicker_led_with_error_code(self, error_code: int) -> None:

pioreactor/utils/adcs.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ class Pico_ADC(_ADC):
9494
def __init__(self) -> None:
9595
# set up i2c connection to hardware.ADC
9696
self.i2c = I2C(hardware.SCL, hardware.SDA)
97+
assert self.get_firmware_version() == (0, 4), "Firmware version mismatch."
9798

9899
def read_from_channel(self, channel: pt.AdcChannel) -> pt.AnalogValue:
99100
assert 0 <= channel <= 3
@@ -108,14 +109,19 @@ def read_from_channel(self, channel: pt.AdcChannel) -> pt.AnalogValue:
108109
f"Unable to find i2c channel {hardware.ADC}. Is the HAT attached? Is the firmware loaded?"
109110
)
110111

112+
def get_firmware_version(self) -> tuple[int, int]:
113+
result = bytearray(2)
114+
self.i2c.writeto_then_readfrom(hardware.ADC, bytes([0x08]), result)
115+
return (result[1], result[0])
116+
111117
def from_voltage_to_raw(self, voltage: pt.Voltage) -> pt.AnalogValue:
112-
return int((voltage / 3.3) * 4095 * 16)
118+
return int((voltage / 3.3) * 4095 * 32)
113119

114120
def from_voltage_to_raw_precise(self, voltage: pt.Voltage) -> float:
115-
return (voltage / 3.3) * 4095 * 16
121+
return (voltage / 3.3) * 4095 * 32
116122

117123
def from_raw_to_voltage(self, raw: pt.AnalogValue) -> pt.Voltage:
118-
return (raw / 4095 / 16) * 3.3
124+
return (raw / 4095 / 32) * 3.3
119125

120126
def check_on_gain(self, value: pt.Voltage, tol: float = 0.85) -> None:
121127
# pico has no gain.

update_scripts/upcoming/update.sql

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# update.sql
22

3+
# Actually, I'm not going to do this. These can take a _long_ time to execute.
34

4-
CREATE INDEX IF NOT EXISTS stirring_rates_ix
5-
ON stirring_rates (experiment, pioreactor_unit);
6-
7-
CREATE INDEX IF NOT EXISTS pwm_dcs_ix
8-
ON pwm_dcs (experiment, pioreactor_unit);
5+
# CREATE INDEX IF NOT EXISTS stirring_rates_ix
6+
# ON stirring_rates (experiment, pioreactor_unit);
7+
#
8+
# CREATE INDEX IF NOT EXISTS pwm_dcs_ix
9+
# ON pwm_dcs (experiment, pioreactor_unit);
10+
#

0 commit comments

Comments
 (0)