forked from dhague/vpower
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/usr/bin/env python | ||
import time | ||
import Tkinter as tk | ||
|
||
from ant.core import driver | ||
from ant.core import node | ||
|
||
from PowerMeterTx import PowerMeterTx | ||
from config import DEBUG, LOG, NETKEY, POWER_SENSOR_ID | ||
|
||
antnode = None | ||
power_meter = None | ||
|
||
try: | ||
stick = driver.USB2Driver(None, log=LOG, debug=DEBUG) | ||
antnode = node.Node(stick) | ||
print "Starting ANT node" | ||
antnode.start() | ||
key = node.NetworkKey('N:ANT+', NETKEY) | ||
antnode.setNetworkKey(0, key) | ||
|
||
print "Starting power meter with ANT+ ID " + repr(POWER_SENSOR_ID) | ||
try: | ||
# Create the power meter object and open it | ||
power_meter = PowerMeterTx(antnode, POWER_SENSOR_ID) | ||
power_meter.open() | ||
except Exception as e: | ||
print "power_meter error: " + e.message | ||
power_meter = None | ||
|
||
master = tk.Tk() | ||
master.title("Bot") | ||
master.geometry("200x50") | ||
master.call('wm', 'attributes', '.', '-topmost', '1') | ||
w = tk.Scale(master, from_=0, to=1000, length=200, orient=tk.HORIZONTAL) | ||
w.pack() | ||
|
||
t = 0 | ||
last = 0 | ||
power = 0 | ||
|
||
print "Main wait loop" | ||
while True: | ||
power = w.get() | ||
t = int(time.time()) | ||
if power and t >= last + 1: | ||
power_meter.update(power) | ||
last = t | ||
master.update_idletasks() | ||
master.update() | ||
|
||
except: | ||
pass | ||
finally: | ||
if power_meter: | ||
print "Closing power meter" | ||
power_meter.close() | ||
power_meter.unassign() | ||
if antnode: | ||
print "Stopping ANT node" | ||
antnode.stop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# -*- mode: python -*- | ||
|
||
block_cipher = None | ||
|
||
binaries = [ | ||
('C:\\Windows\\System32\\libusb0.dll', '.'), | ||
] | ||
|
||
a = Analysis(['bot.py'], | ||
pathex=[], | ||
binaries=binaries, | ||
datas=[], | ||
hiddenimports=[], | ||
hookspath=[], | ||
runtime_hooks=[], | ||
excludes=[], | ||
win_no_prefer_redirects=False, | ||
win_private_assemblies=False, | ||
cipher=block_cipher, | ||
noarchive=False) | ||
pyz = PYZ(a.pure, a.zipped_data, | ||
cipher=block_cipher) | ||
exe = EXE(pyz, | ||
a.scripts, | ||
a.binaries, | ||
a.zipfiles, | ||
a.datas, | ||
[], | ||
name='bot', | ||
debug=False, | ||
bootloader_ignore_signals=False, | ||
strip=False, | ||
upx=True, | ||
upx_exclude="vcruntime140.dll", | ||
runtime_tmpdir=None, | ||
console=True ) |