Geschrieben January 20, 2017 at 09:2520. Jan 2017 Hallo, ich versuche ein Programm zu schreiben, dass beendet wird sobald von einem TF Aktuator ein Event eintritt. Im Moment nutze ich den Threshold von einem Poti dafür. Es klappt auch soweit, nur bleibt in der Konsole der raw_input stehen. Wie kann man das umgehen? Ich habe es mit einer while-Schleife probiert aber ich bekomme den Wert des Thresholds nicht in die Schleife. Wäre für Tipps sehr dankbar. Hier mein Code: HOST = "localhost" PORT = 4223 UID_TEMP = 'zv2' UID_OLED = 'Bgv' UID_ROTA = 'g5H' stop = 0.0 from tinkerforge.ip_connection import IPConnection from tinkerforge.bricklet_temperature import BrickletTemperature from tinkerforge.bricklet_rotary_poti import BrickletRotaryPoti from tinkerforge.bricklet_oled_128x64 import BrickletOLED128x64 import sys def cb_temperature(temperature): oled.write_line(0, 0, 'Temperature: ' + str(temperature/100.0) + ' C') def cb_position(position): oled.clear_display() ipcon.disconnect() if __name__ == "__main__": ipcon = IPConnection() t = BrickletTemperature(UID_TEMP, ipcon) rp = BrickletRotaryPoti(UID_ROTA, ipcon) oled = BrickletOLED128x64(UID_OLED, ipcon) ipcon.connect(HOST, PORT) t.register_callback(t.CALLBACK_TEMPERATURE, cb_temperature) t.set_temperature_callback_period(1000) rp.register_callback(rp.CALLBACK_ANALOG_VALUE_REACHED, cb_position) rp.set_debounce_period(100) rp.set_analog_value_callback_threshold('>', 3000.0, 4095) raw_input("Press key to exit\n")
Geschrieben January 23, 2017 at 12:3023. Jan 2017 def cb_position(position): oled.clear_display() ipcon.disconnect() sys.exit(0) # Beendet das Program
Geschrieben January 23, 2017 at 13:1323. Jan 2017 Autor Hallo, das habe ich auch schonmal gemacht, allerdings bleibt dann in der Konsole der raw_input stehen. Eben den will ich umgehen.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.