calibration tests added

Thu, 16 Feb 2017 16:24:25 +0100

author
Malte Di Donato <mdd@neo-soft.org>
date
Thu, 16 Feb 2017 16:24:25 +0100
changeset 4
99a5439f349f
parent 2
93b48be0aa53
child 5
06ccfef112fc

calibration tests added

analgauge.py file | annotate | diff | comparison | revisions
--- a/analgauge.py	Thu Feb 16 14:45:20 2017 +0100
+++ b/analgauge.py	Thu Feb 16 16:24:25 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)

mercurial