LinearScaling#

class LinearScaling(gain: float = 1.0, offset: float = 0.0)[source]#

Bases: ScalingFunction

Linear scaling: physical = offset + gain * raw.

Example

>>> # Temperature sensor: 0.1°C per count, -40°C offset
>>> LinearScaling(gain=0.1, offset=-40.0).to_physical(500)
10.0

Methods

to_physical

Raw register value → physical units.

to_raw

Physical value → raw integer.