Created
May 20, 2014 04:52
-
-
Save daeken/a3d3c4da11ca1c2d2b84 to your computer and use it in GitHub Desktop.
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
import serial | |
class Lifespan(object): | |
def __init__(self): | |
self.connect() | |
def connect(self): | |
self.port = serial.Serial('/dev/tty.IHP-Serialport', 19200, timeout=1) | |
while self.port.read(1) != '': | |
continue | |
def interrogate(self, type): | |
self.port.write(''.join(map(chr, (161, type, 0, 0, 0)))) | |
return tuple(map(ord, self.port.read(6))[2:]) | |
@property | |
def seconds(self): | |
msg = self.interrogate(137) | |
return msg[0] * 60 * 60 + msg[1] * 60 + msg[2] | |
@property | |
def time(self): | |
msg = self.interrogate(137) | |
return msg[0:3] | |
@property | |
def distance(self): | |
msg = self.interrogate(133) | |
return msg[0] + msg[1] / 100.0 | |
@property | |
def speed(self): | |
msg = self.interrogate(130) | |
return msg[0] + msg[1] / 100.0 | |
@property | |
def calories(self): | |
msg = self.interrogate(135) | |
return msg[0] * 256 + msg[1] | |
@property | |
def steps(self): | |
msg = self.interrogate(136) | |
return msg[0] * 256 + msg[1] | |
lifespan = Lifespan() | |
while True: | |
print 'Walking for: %i:%i:%i' % lifespan.time | |
print 'Walked %f miles (currently %f mph)' % (lifespan.distance, lifespan.speed) | |
print 'Burned %i calories in %i steps' % (lifespan.calories, lifespan.steps) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, Been hacking around here and i have some additional information in case someone else finds this thread.
I have the TR1200 with the Omni Console. I'm currently in the process of evaluating options for a better step logger. The limitations of the omni console not having any capability to remember more than one session at a time is fairly infuriating! So, if anyone else wants to hack on a new project with me. Please reach out.
I came here today to primarily share some additional data I have learned so far.
Unlike the GIST Op, I'm seeing a baud rate of 4800.
PINOUT:
Pin Label
1 +12V - but only when the console is on / awake.
2 GND
3 Treadmills TX Pin (Omni Console's RX) - It's a UART with TTL (5v logic levels)
4 Treadmills RX PIN (Omni Console's TX) - TTL Logic levels.
5 Yellow 5V, either supply, or data that mostly remains high (multimeter fluctuates from 5.03 to 5.04 V or so)
Not able to comment on 6-9 but don't think it matters it's 3 and 4 that i care about.
I have also determined which command is the "Steps" command.

Hope to post back more information but in case i never pick this project up again, figured this might help someone.