def button_pressed_falling(self): global time_rising, debug, GPIO_LED, LED_STATE time_falling = miliseconds() time_elapsed = time_falling - time_rising time_rising = 0 # reset to prevent multiple fallings from the same rising MIN_TIME_TO_ELAPSE = 500 # miliseconds MAX_TIME_TO_ELAPSE = 3000 if debug: print("button_pressed_falling") if time_elapsed >= 0 and time_elapsed <= 30000: if time_elapsed >= MIN_TIME_TO_ELAPSE and time_elapsed <= MAX_TIME_TO_ELAPSE: # normal button press to switch between measurement and maintenance tmeasurement = threading.Thread(target=toggle_measurement) tmeasurement.start() elif time_elapsed >= 5000 and time_elapsed <= 10000: # shutdown raspberry tblink = threading.Thread(target=blink_led, args=(GPIO_LED, 0.1)) tblink.start() shutdown() elif time_elapsed >= 10000 and time_elapsed <= 15000: # reset settings and shutdown tblink = threading.Thread(target=blink_led, args=(GPIO_LED, 0.1)) tblink.start() delete_settings() update_wittypi_schedule("") logger.critical("Resettet settings because Button was pressed.") shutdown() elif debug: time_elapsed_s = float("{0:.2f}".format(time_elapsed / 1000)) # ms to s logger.warning( "Too short Button press, Too long Button press OR inteference occured: " + str(time_elapsed_s) + "s elapsed.")
def button_pressed_falling(): global time_start, debug time_end = miliseconds() time_elapsed = time_end - time_start MIN_TIME_TO_ELAPSE = 500 # miliseconds MAX_TIME_TO_ELAPSE = 3000 if time_elapsed >= MIN_TIME_TO_ELAPSE and time_elapsed <= MAX_TIME_TO_ELAPSE: time_start = 0 # reset to prevent multiple fallings from the same rising toggle_measurement() elif time_elapsed >= 5000 and time_elapsed <= 10000: time_start = 0 # reset to prevent multiple fallings from the same rising shutdown() elif debug: error_log( "Info: Too short Button press, Too long Button press OR inteference occured." )
def button_pressed_falling(): global time_rising, debug time_falling = miliseconds() time_elapsed = time_falling - time_rising time_rising = 0 # reset to prevent multiple fallings from the same rising MIN_TIME_TO_ELAPSE = 500 # miliseconds MAX_TIME_TO_ELAPSE = 3000 stop_led() if time_elapsed >= MIN_TIME_TO_ELAPSE and time_elapsed <= MAX_TIME_TO_ELAPSE: toggle_measurement() elif time_elapsed >= 5000 and time_elapsed <= 10000: shutdown() elif time_elapsed >= 10000 and time_elapsed <= 15000: delete_settings() shutdown() elif debug: error_log( "Info: Too short Button press, Too long Button press OR inteference occured: " + str(time_elapsed) + "ms elapsed.")
def button_pressed_rising(self): global time_rising, debug, GPIO_LED, LED_STATE time_rising = miliseconds() if debug: print("button_pressed_rising")
def button_pressed_rising(): global time_rising time_rising = miliseconds()
def button_pressed_rising(): global time_start time_start = miliseconds()