# Class CyclingPowerMeasurement

java.lang.Object
com.codename1.health.sensors.CyclingPowerMeasurement

public final class CyclingPowerMeasurement extends Object

A decoded Cycling Power Measurement, characteristic `0x2A63`.

##### Wire format

Unlike most SIG characteristics the flags field here is a `uint16`, not a single byte, because the profile defines sixteen optional fields. It is followed immediately by the instantaneous power.

##### Instantaneous power is signed

The power field is `sint16`, and negative values are real: a power meter reports negative watts when the rider is back-pedalling or the drivetrain is driving the cranks on a descent. Reading it as unsigned turns a brief -5 W into 65531 W, which then poisons every average and maximum for the whole ride.

This parser exposes the common fields -- instantaneous power, accumulated energy, pedal balance, crank revolutions. The remaining optional fields are skipped in order so that the fields after them still decode correctly.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `getAccumulatedEnergyKilojoules()`
  Total energy in kilojoules since the meter powered on, or `-1` when absent.
  `int`
  `getCrankRevolutions()`
  Cumulative crank revolutions, or `-1` when absent.
  `int`
  `getInstantaneousPowerWatts()`
  Instantaneous power in watts.
  `int`
  `getLastCrankEventTime()`
  The crank-event timestamp in 1/1024-second units, or `-1` when absent.
  `int`
  `getLastWheelEventTime()`
  The wheel-event timestamp in 1/2048-second units, or `-1` when absent.
  `double`
  `getPedalPowerBalancePercent()`
  The share of power contributed by one pedal, as a percentage, or `Double.NaN` when absent.
  `long`
  `getWheelRevolutions()`
  Cumulative wheel revolutions since the meter powered on, or `-1` when absent.
  `boolean`
  `hasCrankData()`
  `true` when this notification carried crank data, from which cadence can be derived.
  `static CyclingPowerMeasurement`
  `parse(byte[] value)`
  Decodes a `0x2A63` value.
  `String`
  `toString()`
  Returns a string representation of the object.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Method Details

  - ### parse

    public static CyclingPowerMeasurement parse(byte[] value)
    Decodes a `0x2A63` value. Returns `null` for a malformed or truncated payload; never throws.

  - ### getInstantaneousPowerWatts

    public int getInstantaneousPowerWatts()
    Instantaneous power in watts. May be negative -- see the class documentation.

  - ### getPedalPowerBalancePercent

    public double getPedalPowerBalancePercent()
    The share of power contributed by one pedal, as a percentage, or `Double.NaN` when absent. Which pedal it refers to depends on the reference bit; most meters report the left.

  - ### getWheelRevolutions

    public long getWheelRevolutions()
    Cumulative wheel revolutions since the meter powered on, or `-1` when absent. Wraps at 2^32.

  - ### getLastWheelEventTime

    public int getLastWheelEventTime()
    The wheel-event timestamp in 1/2048-second units, or `-1` when absent. Wraps roughly every 32 seconds.

  - ### getCrankRevolutions

    public int getCrankRevolutions()
    Cumulative crank revolutions, or `-1` when absent. Wraps at 2^16.

  - ### getLastCrankEventTime

    public int getLastCrankEventTime()
    The crank-event timestamp in 1/1024-second units, or `-1` when absent. Wraps roughly every 64 seconds.

  - ### getAccumulatedEnergyKilojoules

    public int getAccumulatedEnergyKilojoules()
    Total energy in kilojoules since the meter powered on, or `-1` when absent.

  - ### hasCrankData

    public boolean hasCrankData()
    `true` when this notification carried crank data, from which cadence can be derived.

  - ### toString

    public String toString()
    Description copied from class: `Object`
    Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method. The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: getClass().getName() + '@' + Integer.toHexString(hashCode())
    Overrides:
      `toString` in class `Object`