def show(y, x, string, addr=None): if isinstance(string, bytes): command(slot(addr, 1), b'DisplayGB2312,%d,%d,' % (y, x) + string[:16]) else: string = str(string)[:16] command(slot(addr, 1), b'DisplayGB2312,%d,%d,%s' % (y, x, string)) sleep(len(string))
def values(addr=None): data = command(slot(addr, 7), b'get_key_val', 9, True) if isinstance(data, bytes): return conv(data) if data == None: return None, None return tuple(conv(i) for i in data)
def time(addr=None): t = command(slot(addr, 36), b'getT', 6, 1) if not t: return t for i in range(6): _[i] = t[i] - 1 return tuple(_)
def temp_humi(addr=None): res = command(slot(addr, 2), b'get_temp_humi', 2) if isinstance(res, int): t, h = res // 256, res % 256 if t >= 128: t -= 256 return t, h if res == None: return None, None _res.clear() for rr in res: t, h = rr // 256, rr % 256 if t >= 128: t -= 256 _res.append((t, h)) return tuple(_res)
def get(addr=None): return command(slot(addr, 9), b'get_touch', 1)
def off(addr=None): command(slot(addr, 3), b'set_led_off')
def on(addr=None): command(slot(addr, 3), b'set_led_on')
def humi(addr=None): return command(slot(addr, 2), b'get_humi', 1)
def temp(addr=None): return command(slot(addr, 2), b'get_temp', 1)
def set_time(Y, M, D, h, m, s, addr=None): command(slot(addr, 36), b"setT%c%c%c%c%c%c" % (Y, M, D, h, m, s))
def value(addr=None): return command(slot(addr, 4), b'get_poten_val', 2)
def value(addr=None): return command(slot(addr,8),b'get_distance_val',2)
def value(addr=None): return command(slot(addr,6),b'get_mic_val',2)
def value(addr=None): return command(slot(addr,5),b'get_light_val',2)
def clear(addr=None): command(slot(addr, 1), b'ClearScreen') sleep(15)
def motor(val, addr=None): return command(slot(addr, 20), b'get%s%c' % ('bf'[val > 0], abs(val) // 4))