Skip to content

File NeedleGauge.h

File List > Firmware > Libraries > PanelGroup > Outputs > NeedleGauge > NeedleGauge.h

Go to the documentation of this file


#pragma once
#ifdef ARDUINO_ARCH_STM32

#include <PanelGroup.h>                       // OutputBase
#include <Drivers/MotorDriver/MotorDriver.h>  // MotorDriver

namespace OpenSkyhawk {

struct GaugeCal {
    int16_t         minTravel;  
    int16_t         maxTravel;  
    bool            reverse;    
    const uint16_t* curveIn;    
    const uint16_t* curveOut;   
    uint8_t         curveN;     
};

class NeedleGauge : public OutputBase {
public:
    NeedleGauge(uint16_t controlId, uint16_t mask, MotorDriver& motor, const GaugeCal& cal);

    void configure() override;

    void onControlPacket(uint16_t controlId, uint16_t value) override;

    void update() override;

#ifdef NEEDLEGAUGE_TEST
    int32_t debugValueToPos(uint16_t value) const { return valueToPos(value); } 
#endif

private:
    uint16_t      _controlId;
    uint16_t      _mask;
    MotorDriver*  _motor;   // caller-owned
    const GaugeCal* _cal;   // caller-owned

    int32_t valueToPos(uint16_t value) const;  // decode → position (linear or piecewise)
};

} // namespace OpenSkyhawk

#endif // ARDUINO_ARCH_STM32