plus court
Fork of Adafruit-PWM-Servo-Driver by
AFPSD.h
- Committer:
- llarquere
- Date:
- 2017-11-16
- Revision:
- 4:b439851f9d20
File content as of revision 4:b439851f9d20:
/*************************************************** This is a library for our Adafruit 16-channel PWM & Servo driver Pick one up today in the adafruit shop! ------> http://www.adafruit.com/products/815 These displays use I2C to communicate, 2 pins are required to interface. For Arduino UNOs, thats SCL -> Analog 5, SDA -> Analog 4 Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit! Written by Limor Fried/Ladyada for Adafruit Industries. BSD license, all text above must be included in any redistribution ****************************************************/ /***************************** This program was ported from https://github.com/adafruit/Adafruit-PWM-Servo-Driver-Library. I also added some functions. Shundo Kishi *****************************/ #ifndef _ADAFRUIT_PWMServoDriver_H #define _ADAFRUIT_PWMServoDriver_H #include "mbed.h" #include <cmath> #define PCA9685_SUBADR1 0x2 #define PCA9685_SUBADR2 0x3 #define PCA9685_SUBADR3 0x4 #define PCA9685_MODE1 0x0 #define PCA9685_PRESCALE 0xFE #define LED0_ON_L 0x6 #define LED0_ON_H 0x7 #define LED0_OFF_L 0x8 #define LED0_OFF_H 0x9 #define ALLLED_ON_L 0xFA #define ALLLED_ON_H 0xFB #define ALLLED_OFF_L 0xFC #define ALLLED_OFF_H 0xFD class AFPSD { public: AFPSD( const int addr, I2C* i2c ); void begin( void ); void reset( void ); void setPWMFreq( const float freq ); void setPrescale( const uint8_t prescale ); void setPWM( const uint8_t num, const uint16_t on, const uint16_t off ); void setDuty( const uint8_t num, uint16_t duty ); private: // properties /// external i2c object I2C* _i2c; /// device (815) address on the i2c bus int _devaddr; // methods uint8_t _read8(char pin); void _write8(char pin, char d); }; #endif