ant-plus-next / SpeedCadenceSensor
Represents a Bicycle Speed and Cadence sensor. This class extends the AntPlusSensor class to handle specific data related to speed and cadence.
AntPlusSensor
new SpeedCadenceSensor(
stick
):SpeedCadenceSensor
Constructs an instance of the AntPlusSensor class.
The USB driver instance used for communication with the ANT+ stick.
AntPlusSensor.constructor
wheelCircumference:
number
=2.199
The wheel circumference in meters, used to calculate speed.
2.199
sensors/speedCadence/speedCadenceSensor.ts:29
readonly
static
deviceType:number
=0x79
The device type code for Bicycle Speed and Cadence sensors.
sensors/speedCadence/speedCadenceSensor.ts:22
attach(
channel
,deviceId
):Promise
<void
>
Attaches the sensor to a specified ANT+ channel and initializes its state.
number
The ANT+ channel number used for communication with the sensor.
number
The unique identifier of the sensor device.
Promise
<void
>
const sensor = new SpeedCadenceSensor();
sensor.attach(1, 12345); // Attaches to channel 1 with device ID 12345
sensors/speedCadence/speedCadenceSensor.ts:58
detach():
Promise
<void
>
Detaches the sensor from its assigned channel and stops communication.
Promise
<void
>
Will throw an error if there is an issue detaching.
AntPlusSensor.detach
setWheelCircumference(
wheelCircumference
):void
Sets the wheel circumference for speed calculation.
number
The wheel circumference in meters.
void
const sensor = new SpeedCadenceSensor();
sensor.setWheelCircumference(2.105); // Sets the wheel circumference to 2.105 meters