/** * @file pwmExpanderPca9685.hpp * @author Gustice * @brief PWM-Expander PCA9685 * @details https://www.nxp.com/docs/en/data-sheet/PCA9685.pdf * * @copyright Copyright (c) 2024 */ #pragma once #include "i2cPort.hpp" #include #include #include /** * @brief I2C-Connected LED-Driver with 16 ports * @note This module can also be used to generate Servo-Motor signals */ class PmwExpanderPca9685 { public: static constexpr int PwmChannels = 16; using GrayValues = std::array; PmwExpanderPca9685(I2cMaster &port, bool inverted = false, uint8_t address = 0x40); // 0x40 default Address void sendImage(GrayValues &grayValues); void reset(); void setPwmFreq(float frequency, bool inverted); private: I2cMaster::Slave _port; const uint8_t _address; const size_t _count = 16; // 16 LED-Channels with 4 bytes each + 4 byte overhead std::vector _data; bool write(uint8_t reg, uint8_t data); std::optional read(uint8_t reg); };