|
| 1 | +""" |
| 2 | +The file to hold the Set pH Calibration Midpoint class |
| 3 | +""" |
| 4 | + |
| 5 | +from src.ui_state.set_menu.set_ph_calibration_high import PHCalibrationHigh |
| 6 | +from src.ui_state.set_menu.set_ph_calibration_low import PHCalibrationLower |
| 7 | +from src.ui_state.user_value import UserValue |
| 8 | + |
| 9 | + |
| 10 | +class PHCalibrationOnly(UserValue): |
| 11 | + """ |
| 12 | + UI state to set the pH Calibration Midpoint. |
| 13 | + Uses UserValue's keypad flow: implement get_label and save_value. |
| 14 | + """ |
| 15 | + |
| 16 | + def __init__(self, titrator, previous_state=None): |
| 17 | + super().__init__(titrator, previous_state) |
| 18 | + self.previous_state = previous_state |
| 19 | + self.value = str(self.titrator.ph_probe._midpoint_calibration or "") |
| 20 | + |
| 21 | + def get_label(self): |
| 22 | + """ |
| 23 | + Returns the label for the user value input. |
| 24 | + """ |
| 25 | + return "Buffer pH" |
| 26 | + |
| 27 | + def save_value(self): |
| 28 | + """ |
| 29 | + Saves the entered pH Calibration Midpoint to the pH probe. |
| 30 | + """ |
| 31 | + self.titrator.ph_probe._midpoint_calibration = float(self.value) |
| 32 | + |
| 33 | + self.titrator.lcd.print( |
| 34 | + f"Buffer = {self.titrator.ph_probe._midpoint_calibration}", line=2 |
| 35 | + ) |
| 36 | + self.return_to_main_menu(ms_delay=3000) |
| 37 | + |
| 38 | + |
| 39 | +class PHCalibrationHigher(UserValue): |
| 40 | + """ |
| 41 | + Docstring for PHCalibrationHigher |
| 42 | + """ |
| 43 | + |
| 44 | + def __init__(self, titrator, previous_state=None): |
| 45 | + super().__init__(titrator, previous_state) |
| 46 | + self.previous_state = previous_state |
| 47 | + self.value = str(self.titrator.ph_probe._midpoint_calibration or "") |
| 48 | + |
| 49 | + def get_label(self): |
| 50 | + """ |
| 51 | + Returns the label for the user value input. |
| 52 | + """ |
| 53 | + return "Higher buffer pH" |
| 54 | + |
| 55 | + def save_value(self): |
| 56 | + """ |
| 57 | + Saves the entered pH Calibration Midpoint to the pH probe. |
| 58 | + """ |
| 59 | + self.titrator.ph_probe._midpoint_calibration = float(self.value) |
| 60 | + |
| 61 | + self.titrator.lcd.print( |
| 62 | + f"Mid = {self.titrator.ph_probe._midpoint_calibration}", line=2 |
| 63 | + ) |
| 64 | + self._set_next_state(PHCalibrationLower(self.titrator, self), True) |
| 65 | + |
| 66 | + |
| 67 | +class PHCalibrationMid(UserValue): |
| 68 | + """ |
| 69 | + UI state to set the pH Calibration Midpoint. |
| 70 | + Uses UserValue's keypad flow: implement get_label and save_value. |
| 71 | + """ |
| 72 | + |
| 73 | + def __init__(self, titrator, previous_state=None): |
| 74 | + super().__init__(titrator, previous_state) |
| 75 | + self.previous_state = previous_state |
| 76 | + self.value = str(self.titrator.ph_probe._midpoint_calibration or "") |
| 77 | + |
| 78 | + def get_label(self): |
| 79 | + """ |
| 80 | + Returns the label for the user value input. |
| 81 | + """ |
| 82 | + return "Mid buffer pH" |
| 83 | + |
| 84 | + def save_value(self): |
| 85 | + """ |
| 86 | + Saves the entered pH Calibration Midpoint to the pH probe. |
| 87 | + """ |
| 88 | + self.titrator.ph_probe._midpoint_calibration = float(self.value) |
| 89 | + |
| 90 | + self.titrator.lcd.print( |
| 91 | + f"Mid = {self.titrator.ph_probe._midpoint_calibration}", line=2 |
| 92 | + ) |
| 93 | + self._set_next_state(PHCalibrationHigh(self.titrator, self), True) |
0 commit comments