Пример #1
0
def set_clock(ent):
    logging.debug('set_clock')
    with Serial(PORT, 115200, timeout=1) as ser:
        set_rtc(ser)
Пример #2
0
 def f():
     try:
         return abs(time.time() - float(set_rtc(ser))) < 5
     except:
         return False
Пример #3
0
 def set_clock(self):
     logging.debug('set_rtc')
     with Serial(PORT, 115200, timeout=1) as ser:
         set_rtc(ser, time.time())
         self.label1.set(read_rtc(ser))
Пример #4
0
    def cl(lx):
        #print(lx)
        lx = float(lx.strip().split(',')[0].replace('lx', ''))
        return lx >= 0 and lx <= 130e3

    check('read_ambient_lx', cl)

    def crgbw(r):
        #print(r)
        r = [float(v) for v in r.strip().split(',')]
        return all([rr >= 0 for rr in r])

    check('read_rgbw', crgbw)

    set_rtc(ser)

    def f(r):
        #print(datetime.fromtimestamp(int(r.strip())))
        return abs(float(r) - time.time()) < 5

    check('read_rtc', f)

    def f(r):
        Vcc, Vbatt = r.split(',')
        Vcc = float(Vcc)
        Vbatt = float(Vbatt)
        #print('Vcc = {}V, Vbatt = {}V'.format(Vcc, Vbatt))
        return abs(Vcc - 3.3) / 3.3 < 0.1 and Vbatt >= 1.8

    check('read_sys_volt', f)