1 import usb.core |
1 import usb.core |
2 from psutil import cpu_percent |
2 from psutil import cpu_percent |
|
3 from time import sleep |
|
4 from random import random |
|
5 from sys import exit |
3 |
6 |
4 VALUE_MIN = 0x00 |
7 #VALUE_MIN = 0x00 # TODO |
5 VALUE_MAX = 0x88 |
8 VALUE_MAX = 0x7B |
6 |
9 |
7 VENDOR_ID = 0x16c0 |
10 VENDOR_ID = 0x16c0 |
8 PRODUCT_ID = 0x05df |
11 PRODUCT_ID = 0x05df |
9 |
12 |
10 class AnalGauge: |
13 class AnalGauge: |
11 def __init__(self): |
14 def __init__(self): |
12 self.dev = usb.core.find( |
15 self.dev = usb.core.find( |
13 idVendor = VENDOR_ID, |
16 idVendor = VENDOR_ID, |
14 idProduct = PRODUCT_ID |
17 idProduct = PRODUCT_ID |
15 ) |
18 ) |
|
19 if not self.dev: |
|
20 print "AnalGauge Device not found!" |
|
21 exit(1) |
16 |
22 |
17 def update(self, d): |
23 def update(self, d): |
18 try: |
24 try: |
19 data = [int(d)] |
25 data = [int(d)] |
20 result = self.dev.ctrl_transfer( |
26 result = self.dev.ctrl_transfer( |