2017-03-23 18:45:29 +00:00
|
|
|
#ifndef __PCA9685
|
|
|
|
#define __PCA9685
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PCA9685 library for ESP8266
|
|
|
|
* Copyright 2017 (c) Mark van Renswoude
|
|
|
|
*/
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2017-03-24 20:40:56 +00:00
|
|
|
|
2017-03-23 18:45:29 +00:00
|
|
|
class PCA9685
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
uint8_t address;
|
|
|
|
|
|
|
|
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;
|
2017-03-24 22:04:58 +00:00
|
|
|
static const uint16_t On = 4095;
|
2017-03-23 18:45:29 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2017-03-24 20:40:56 +00:00
|
|
|
// Call this to initializes the I2C library
|
|
|
|
void setAddress(uint8_t address, uint8_t pinSDA, uint8_t pinSCL);
|
2017-03-23 18:45:29 +00:00
|
|
|
|
2017-03-24 20:40:56 +00:00
|
|
|
// Call this if you already initialized the I2C library
|
|
|
|
void setAddress(uint8_t address);
|
2017-03-23 18:45:29 +00:00
|
|
|
|
|
|
|
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
|