Some fixes.

This commit is contained in:
Marcel Otte 2017-10-20 21:48:24 +02:00
parent 6ae519f78e
commit b618b1cd21
3 changed files with 13 additions and 5 deletions

View File

@ -86,7 +86,7 @@
"frequency": 25000
},
"activated-channels": [ 0, 1],
"interval": 1.0,
"interval": 1,
"use_difference": false,
"thresholds-for": "inside",
"thresholds": {

View File

@ -49,7 +49,7 @@ class LowLevel(metaclass=Singleton):
lchbits = channel & 0x03
to_send = [hchbit | 0x06, lchbits << 6, 0x00]
self.__activate()
r=self.__spi.xfer(to_send)
r = self.__spi.xfer(to_send)
self.__deactivate()
GPIO.output(pin, False)
highbyte = r[1]

View File

@ -15,11 +15,19 @@ class Service(object):
def run(self):
interval = self.__cfg.get_data()["interval"]
t = time.time()
last = None
ran = False
while True:
t = time.time()
time.sleep(t + interval - time.time())
thread = Thread(self.work)
thread.start()
if int(t) % interval == 0 and not ran:
thread = Thread(self.work)
thread.start()
ran = True
last = int(t)
else:
time.sleep(0.01)
if t > last:
ran = False
pass
def work(self):