def main(): while True: #infinite loop last_time = 0 if ( time.time() - last_time ) > 500: # 500 milliseconds == 1/2 second. 1000 milliseconds == 1 second. last_time = time.time() lcd.lcd_write("FUTURE CLUB!", "APERTE ENTER") if keyboard.is_pressed("enter"): deposit.deposit()
file_prefix = 'pressure_log_' num_prev_files = len([ item for item in os.listdir('.') if item.startswith(file_prefix) ]) logfile = open(file_prefix + str(num_prev_files), 'w', buffering=128) logfile.write(unit + '\n') try: while True: pressure = '{}'.format(m.get_pressure_combined_4_digit()) pressure_float = float(pressure) pressure_string = '{}{}'.format(pressure, unit) temps = ' '.join([str(x.tempC(i)) for i in range(count)]) logfile.write('{} {}\n'.format(pressure, temps)) lcd.lcd_text(pressure_string, lcd.LCD_LINE_1) lcd.lcd_text('{}'.format(temps), lcd.LCD_LINE_2) time.sleep(sleep_time) except KeyboardInterrupt: pass finally: lcd.lcd_write(0x01, lcd.LCD_CMD) import RPi.GPIO as GPIO lcd.lcd_text("Reading stopped!", lcd.LCD_LINE_1) GPIO.cleanup() else: while True: print('{}{}'.format(m.get_pressure_combined_4_digit(), unit)) time.sleep(sleep_time)
def deposit(): #to do lcd.lcd_write("FLUXOGRAMA DE", "DEPOSITO") time.sleep(2) # wait 2 seconds
def deposit(): #to do lcd.lcd_write("insira ra","") while not keyboard.is_pressed("1"): continue lcd.lcd_write("insira ra","1") time.sleep(2) # wait 2 seconds