Stairs/src/components/PCA9685.h

53 lines
1.3 KiB
C
Raw Normal View History

#ifndef __PCA9685
#define __PCA9685
/*
* PCA9685 library for ESP8266
* Copyright 2017 (c) Mark van Renswoude
*
* Uses brzo I2C library.
*/
#include <stdint.h>
class PCA9685
{
private:
uint8_t address;
uint16_t sclFrequency;
protected:
uint8_t read(uint8_t registerAddress);
void write(uint8_t registerAddress, uint8_t value);
inline void write(uint8_t data);
public:
static const uint16_t Off = 0;
static const uint16_t On = 4096;
static const uint8_t RegisterMode1 = 0x0;
static const uint8_t RegisterPrescale = 0xFE;
static const uint8_t RegisterLED0OnL = 0x6;
static const uint8_t RegisterAllLEDOnL = 0xFA;
static const uint8_t Mode1Restart = 0x80;
static const uint8_t Mode1AI = 0x20;
static const uint8_t Mode1Sleep = 0x10;
static const uint8_t Mode1AllCall = 0x01;
// Call this to initializes the brzo I2C library
void setAddress(uint8_t address, uint16_t sclFrequency, uint8_t pinSDA, uint8_t pinSCL, uint32_t timeoutUSec);
// Call this if you already initialized the brzo I2C library
void setAddress(uint8_t address, uint16_t sclFrequency);
void setPWMFrequency(float frequency);
void setPWM(uint8_t pin, uint16_t value);
void setPWM(uint8_t pin, uint16_t on, uint16_t off);
void setAll(uint16_t value);
void setAll(uint16_t on, uint16_t off);
};
#endif