Avena Webapp API - v0.0.1
    Preparing search index...

    Function applyCalibration

    • Applies a calibration formula to one raw sample value, with the same arithmetic as the Rust CalibrationSpec::apply that fills the exported calibrated_value column.

      Non-finite input is not special-cased, again as in Rust: NaN stays NaN through identity, linear and non-empty polynomial formulas, while an empty polynomial gives -0 for any input. The spec is used as given; pass it through normalizeCalibration first if it may be incomplete.

      Parameters

      • spec: CalibrationSpec

        Calibration to apply.

      • raw: number

        Raw reading, in volts.

      Returns number

      The calibrated value. An empty polynomial evaluates to -0.

      applyCalibration({ type: "linear", a: 2, b: -1 }, 3);          // 5
      applyCalibration({ type: "polynomial", coeffs: [1, 0, 2] }, 3); // 1 + 2 * 9 = 19