def calibration(): """Routine for letting the user pick the sensor to calibrate. Call another routine to calibrate the sensor""" interfaces.display_list(constants.SENSOR_OPTIONS) sensor_selection = interfaces.read_user_input() if sensor_selection == "1" or sensor_selection == constants.KEY_1: _calibrate_pH() elif sensor_selection == "2" or sensor_selection == constants.KEY_2: _calibrate_temperature() analysis.save_calibration_data()
def test_mode(): """Function for running specific tests for the program""" page = 1 user_choice = None while True: # Swap page display if user chooses * if user_choice == constants.KEY_STAR: if page == 1: page = 2 else: page = 1 # Display the proper page if page == 1: interfaces.display_list(constants.TEST_OPTIONS_1) else: interfaces.display_list(constants.TEST_OPTIONS_2) user_choice = interfaces.read_user_input() if user_choice == "6" or user_choice == constants.KEY_6: break else: test_mode_selection(user_choice)
def run(): """Main driver for the program. Initializes components and queries the user for next steps""" try: # initialize components initialize_components() # output prompt to LCD screen routine_selection = "0" page = 1 while routine_selection != "6" or routine_selection != constants.KEY_6: if routine_selection is constants.KEY_STAR: if page == 1: page = 2 else: page = 1 if page == 1: interfaces.display_list(constants.ROUTINE_OPTIONS_1) else: interfaces.display_list(constants.ROUTINE_OPTIONS_2) # wait for user input to select which routine (polling should be fine here) routine_selection = interfaces.read_user_input() routines.run_routine(routine_selection) analysis.save_calibration_data() interfaces.temperature_controller.deactivate() interfaces.lcd_clear() interfaces.ui_lcd.lcd_backlight(False) except Exception: # Deactivate the SSR if any crash occurs if interfaces.temperature_controller is not None: interfaces.temperature_controller.deactivate() print("\nDeactivated SSR") print(sys.exc_info()[0]) traceback.print_exc()
def run(): """Main driver for the program. Initializes components and queries the user for next steps""" try: # initialize components initialize_components() # output prompt to LCD screen routine_selection = "0" page = 1 while routine_selection != "6" or routine_selection != constants.KEY_6: if routine_selection is constants.KEY_STAR: if page == 1: page = 2 else: page = 1 if page == 1: interfaces.display_list(constants.ROUTINE_OPTIONS_1) else: interfaces.display_list(constants.ROUTINE_OPTIONS_2) # wait for user input to select which routine (polling should be fine here) routine_selection = interfaces.read_user_input() routines.run_routine(routine_selection) analysis.save_calibration_data() interfaces.temperature_controller.deactivate() interfaces.lcd_clear() interfaces.ui_lcd.lcd_backlight(False) except (BaseException, Exception): # Deactivate the SSR if any crash occurs if interfaces.temperature_controller is not None: interfaces.temperature_controller.deactivate() print("\n************************\nDeactivated SSR\n************************\n") try: interfaces.lcd_clear() except BaseException: pass try: interfaces.lcd_out("Deactivated SSR", 1) except BaseException: pass # Attempt to save calibration data, this will save syringe position # and any recent calibrations try: analysis.save_calibration_data() print( "\n************************\nCalibration Saved\n************************\n" ) try: interfaces.lcd_out("Calibration Saved", 2) except Exception: pass except Exception: print( "\n!!!!!!!!!!!!!!!!!!!!!!!!\nUnable to save calibration data\n!!!!!!!!!!!!!!!!!!!!!!!!\n" ) try: interfaces.lcd_out("Calibration UNSAVED", 2) except Exception: pass print(sys.exc_info()[0]) traceback.print_exc()