def _read_logpoints_format_5(buf, time, count): log_points = [] for i in range(count): speed = buf.uint8_from(0x00) speed = speed / 8.0 * 60 * 60 / 1000 if speed != 0xff else 0 lp = LogPoint(timestamp=time, speed=speed, temperature=buf.int16_from(0x05) / 10.0, airpressure=buf.uint16_from(0x07) * 2.0) cad = buf.uint8_from(0x01) if cad != 0xff: lp.cadence = cad w = buf.uint16_from(0x02) if w != 0xff: lp.watts = w log_points.append(lp) time += 1 buf.set_offset(0x9) return log_points
def _read_logpoints_format_3(buf, time, count): log_points = [] for i in range(count): speed = buf.uint8_from(0x00) speed = speed / 8.0 * 60 * 60 / 1000 if speed != 0xff else 0 lp = LogPoint(timestamp=time, speed=speed, temperature=buf.int16_from(0x03) / 10.0, airpressure=buf.uint16_from(0x05) * 2.0) cad = buf.uint8_from(0x01) if cad != 0xff: lp.cadence = cad hr = buf.uint8_from(0x02) if hr != 0xff: lp.heartrate = hr log_points.append(lp) time += 4 buf.set_offset(0x8) return log_points
def _read_logpoints_format_3(buf, time, count): log_points = [] for i in range(count): speed = buf.uint8_from(0x00) speed = speed / 8.0 * 60 * 60 / 1000 if speed != 0xff else 0 lp = LogPoint( timestamp=time, speed=speed, temperature=buf.int16_from(0x03) / 10.0, airpressure=buf.uint16_from(0x05) * 2.0 ) cad = buf.uint8_from(0x01) if cad != 0xff: lp.cadence = cad hr = buf.uint8_from(0x02) if hr != 0xff: lp.heartrate = hr log_points.append(lp) time += 4 buf.set_offset(0x8) return log_points
def _read_logpoints_format_5(buf, time, count): log_points = [] for i in range(count): speed = buf.uint8_from(0x00) speed = speed / 8.0 * 60 * 60 / 1000 if speed != 0xff else 0 lp = LogPoint( timestamp=time, speed=speed, temperature=buf.int16_from(0x05) / 10.0, airpressure=buf.uint16_from(0x07) * 2.0 ) cad = buf.uint8_from(0x01) if cad != 0xff: lp.cadence = cad w = buf.uint16_from(0x02) if w != 0xff: lp.watts = w log_points.append(lp) time += 1 buf.set_offset(0x9) return log_points
def _read_logpoints(buf, start_time, count): log_points = [] for i in range(count): if buf.abs_position == buf.data_len: # Reached end of file return log_points, count if buf.be_uint16_from(4) == 0xfefe and buf.be_uint32_from(6) == 0: #It's a pause return log_points, i # don't add 1 to i time = start_time + buf.be_uint32_from(0) speed = buf.be_uint16_from(20) speed = speed * 60.0 / 1000.0 if speed != 0xff else 0 lp = LogPoint( timestamp=time, speed=speed, temperature=buf.be_int16_from(8), airpressure=buf.be_uint32_from(12) / 100.0, ) hr = buf.uint8_from(4) if hr != 0xff: lp.heartrate = hr cad = buf.uint8_from(5) if cad != 0xff: lp.cadence = cad log_points.append(lp) buf.set_offset(22) return log_points, i + 1
def _read_logpoints_format_1(buf, time, count): log_points = [] for i in range(count): speed = buf.uint8_from(0x00) speed = speed / 8.0 * 60 * 60 / 1000 if speed != 0xff else 0 lp = LogPoint(timestamp=time, speed=speed, temperature=buf.int16_from(0x01) / 10.0, airpressure=buf.uint16_from(0x03) * 2.0) log_points.append(lp) time += 4 buf.set_offset(0x6) return log_points