# HG changeset patch # User Malte Di Donato # Date 1487258692 -3600 # Node ID 06ccfef112fc0ace94dc31155e5a307549f0806d # Parent 99a5439f349fbf5936f39a8c0346172dd41125aa# Parent 93fe2226cbc89c0f62daf77f49dc199f5d7fd50a gnf..... merge diff -r 93fe2226cbc8 -r 06ccfef112fc analgauge.py --- a/analgauge.py Thu Feb 16 14:50:25 2017 +0100 +++ b/analgauge.py Thu Feb 16 16:24:52 2017 +0100 @@ -1,8 +1,11 @@ import usb.core from psutil import cpu_percent +from time import sleep +from random import random +from sys import exit -VALUE_MIN = 0x00 -VALUE_MAX = 0x88 +#VALUE_MIN = 0x00 # TODO +VALUE_MAX = 0x7B VENDOR_ID = 0x16c0 PRODUCT_ID = 0x05df @@ -13,6 +16,9 @@ idVendor = VENDOR_ID, idProduct = PRODUCT_ID ) + if not self.dev: + print "AnalGauge Device not found!" + exit(1) def update(self, d): try: @@ -28,6 +34,14 @@ if __name__ == "__main__": g = AnalGauge() + + #g.update(VALUE_MAX) + #exit() + + #while True: + # g.update(random() * VALUE_MAX) + # sleep(0.5) + while True: pct = cpu_percent(interval=1) g.update((VALUE_MAX * pct)/100)