#ifndef SAITEK_THROTTLE_QUADRANT_HPP #define SAITEK_THROTTLE_QUADRANT_HPP #include #include #include struct SaitekThrottleQuadrant { //! The data read from the throttle quadrant. struct [[gnu::packed]] Data { uint8_t left; uint8_t right; uint8_t middle; uint16_t buttons : 9; uint16_t : 0; }; //! The minimum delay between successive read operations. auto constexpr static readDelayMillis = 25u; //! Initialize the throttle quadrant interface. auto begin(unsigned clock_pin, unsigned latch_pin, unsigned data_pin) noexcept -> void; //! Read the current state of the throttle quadrant. auto read() noexcept -> Data; private: //! The time for the clock to propagate. auto constexpr static clockDelayMicros = 25u; //! The time for the latch to settle. auto constexpr static latchDelayMicros = 5u; //! The number of buttons on the throttle quadrant. auto constexpr static numberOfButtons = 9u; auto beginTransaction() -> void; auto endTransaction() -> void; template auto doRead() -> T; unsigned clock_pin{}; unsigned latch_pin{}; unsigned data_pin{}; } static ThrottleQuadrant; #endif