Änderungen

NachtderMuseen2020

755 Byte hinzugefügt, 23:52, 21. Feb. 2020
/* Labyrinth-Controller */
<pre>
# command interpreter for CircuitPython 4.x
import supervisor
import sys
import time
def serial_readcmd_id(arg1): print("3 Door1") def cmd_open(arg1): print("open door: " + arg1) cmd_line = ""cmd_dict = { '?': cmd_id, 'o': cmd_open,} def receive_serial_cmd(): global cmd_line if supervisor.runtime.serial_bytes_available: value = inputsys.stdin.read(1) print ch = ord(value) if 32 <= ch <= 126: # printable character cmd_line += chr(ch) elif ch in {10, 13}: # EOL - try to process if len(cmd_line) >= 1: if cmd_line[0] in cmd_dict: cmd_dict[cmd_line[0]](cmd_line[1:]) else: print('unkown command.') cmd_line = '' i = 0while(1): receive_serial_cmd() #print(i) i = i + 1 time.sleep(.1)
</pre>
1.995
Bearbeitungen