pycycling.cycling_power_service module¶
A module for interacting with Bluetooth devices which support the Cycling Power Service.
This service is supported by most power meters and some turbo trainers.
Example¶
This example prints cycling power measurements broadcast from the Bluetooth device to the console. Please see also information on obtaining the Bluetooth address of your device.
import asyncio
from bleak import BleakClient
from pycycling.cycling_power_service import CyclingPowerService
async def run(address):
async with BleakClient(address) as client:
def my_measurement_handler(data):
print(data)
await client.is_connected()
trainer = CyclingPowerService(client)
trainer.set_cycling_power_measurement_handler(my_measurement_handler)
await trainer.enable_cycling_power_measurement_notifications()
await asyncio.sleep(30.0)
await trainer.disable_cycling_power_measurement_notifications()
if __name__ == "__main__":
import os
os.environ["PYTHONASYNCIODEBUG"] = str(1)
device_address = "EAAA3D1F-6760-4D77-961E-8DDAC1CC9AED"
loop = asyncio.get_event_loop()
loop.run_until_complete(run(device_address))
- class pycycling.cycling_power_service.CyclingPowerFeature(pedal_power_balance_supported, accumulated_torque_supported, wheel_rev_supported, crank_rev_supported, extreme_magnitudes_supported, dead_spot_angles_supported, accumulated_energy_supported, offset_compensation_supported, cycling_power_measurement_content_masking_supported, multiple_locations_supported, crank_length_adjustment_supported, chain_length_adjustment_supported, chain_weight_adjustment_supported, span_length_adjustment_supported, sensor_measurement_context, instantaneous_measurement_direction_supported, factory_calibration_date_supported, enhanced_offset_compensation_supported, distribute_system_support)¶
Bases:
tuple
- accumulated_energy_supported¶
Alias for field number 6
- accumulated_torque_supported¶
Alias for field number 1
- chain_length_adjustment_supported¶
Alias for field number 11
- chain_weight_adjustment_supported¶
Alias for field number 12
- crank_length_adjustment_supported¶
Alias for field number 10
- crank_rev_supported¶
Alias for field number 3
- cycling_power_measurement_content_masking_supported¶
Alias for field number 8
- dead_spot_angles_supported¶
Alias for field number 5
- distribute_system_support¶
Alias for field number 18
- enhanced_offset_compensation_supported¶
Alias for field number 17
- extreme_magnitudes_supported¶
Alias for field number 4
- factory_calibration_date_supported¶
Alias for field number 16
- instantaneous_measurement_direction_supported¶
Alias for field number 15
- multiple_locations_supported¶
Alias for field number 9
- offset_compensation_supported¶
Alias for field number 7
- pedal_power_balance_supported¶
Alias for field number 0
- sensor_measurement_context¶
Alias for field number 14
- span_length_adjustment_supported¶
Alias for field number 13
- wheel_rev_supported¶
Alias for field number 2
- class pycycling.cycling_power_service.CyclingPowerMeasurement(instantaneous_power, accumulated_energy, pedal_power_balance, accumulated_torque, cumulative_wheel_revs, last_wheel_event_time, cumulative_crank_revs, last_crank_event_time, maximum_force_magnitude, minimum_force_magnitude, maximum_torque_magnitude, minimum_torque_magnitude, top_dead_spot_angle, bottom_dead_spot_angle)¶
Bases:
tuple
- accumulated_energy¶
Alias for field number 1
- accumulated_torque¶
Alias for field number 3
- bottom_dead_spot_angle¶
Alias for field number 13
- cumulative_crank_revs¶
Alias for field number 6
- cumulative_wheel_revs¶
Alias for field number 4
- instantaneous_power¶
Alias for field number 0
- last_crank_event_time¶
Alias for field number 7
- last_wheel_event_time¶
Alias for field number 5
- maximum_force_magnitude¶
Alias for field number 8
- maximum_torque_magnitude¶
Alias for field number 10
- minimum_force_magnitude¶
Alias for field number 9
- minimum_torque_magnitude¶
Alias for field number 11
- pedal_power_balance¶
Alias for field number 2
- top_dead_spot_angle¶
Alias for field number 12
- class pycycling.cycling_power_service.CyclingPowerVector(instantaneous_measurement_direction, cumulative_crank_revs, last_crank_event_time, first_crank_measurement_angle, instantaneous_force_magnitudes, instantaneous_torque_magnitudes)¶
Bases:
tuple
- cumulative_crank_revs¶
Alias for field number 1
- first_crank_measurement_angle¶
Alias for field number 3
- instantaneous_force_magnitudes¶
Alias for field number 4
- instantaneous_measurement_direction¶
Alias for field number 0
- instantaneous_torque_magnitudes¶
Alias for field number 5
- last_crank_event_time¶
Alias for field number 2
- class pycycling.cycling_power_service.DistributeSystemSupport(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
Enum
- distributed_system_support = 3¶
- no_distributed_system_support = 2¶
- rfu = 4¶
- unspecified = 1¶
- class pycycling.cycling_power_service.InstantaneousMeasurementDirection(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
Enum
- lateral_component = 4¶
- radial_component = 3¶
- tangential_component = 2¶
- unknown = 1¶
- class pycycling.cycling_power_service.SensorLocation(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)¶
Bases:
Enum
- chain_ring = 17¶
- chainstay = 12¶
- chest = 15¶
- front_hub = 10¶
- front_wheel = 5¶
- hip = 4¶
- in_shoe = 3¶
- left_crank = 6¶
- left_pedal = 8¶
- other = 1¶
- rear_dropout = 11¶
- rear_hub = 14¶
- rear_wheel = 13¶
- right_crank = 7¶
- right_pedal = 9¶
- spider = 16¶
- top_of_shoe = 2¶