I2C PWM expander added from different Project
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* @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 <array>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
/**
|
||||
* @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<uint16_t, PwmChannels>;
|
||||
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<uint8_t> _data;
|
||||
|
||||
bool write(uint8_t reg, uint8_t data);
|
||||
std::optional<uint8_t> read(uint8_t reg);
|
||||
};
|
||||
Reference in New Issue
Block a user