Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
oldnapalm authored Jun 26, 2020
1 parent 52ed9bb commit b35563a
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 0 deletions.
61 changes: 61 additions & 0 deletions bot.py
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()
36 changes: 36 additions & 0 deletions bot.spec
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 )

0 comments on commit b35563a

Please sign in to comment.