plus court

Fork of Adafruit-PWM-Servo-Driver by K-Study-Team

Committer:
llarquere
Date:
Thu Nov 16 18:42:52 2017 +0000
Revision:
4:b439851f9d20
Import

Who changed what in which revision?

UserRevisionLine numberNew contents of line
llarquere 4:b439851f9d20 1 /***************************************************
llarquere 4:b439851f9d20 2 This is a library for our Adafruit 16-channel PWM & Servo driver
llarquere 4:b439851f9d20 3 Pick one up today in the adafruit shop!
llarquere 4:b439851f9d20 4 ------> http://www.adafruit.com/products/815
llarquere 4:b439851f9d20 5 These displays use I2C to communicate, 2 pins are required to
llarquere 4:b439851f9d20 6 interface. For Arduino UNOs, thats SCL -> Analog 5, SDA -> Analog 4
llarquere 4:b439851f9d20 7 Adafruit invests time and resources providing this open source code,
llarquere 4:b439851f9d20 8 please support Adafruit and open-source hardware by purchasing
llarquere 4:b439851f9d20 9 products from Adafruit!
llarquere 4:b439851f9d20 10 Written by Limor Fried/Ladyada for Adafruit Industries.
llarquere 4:b439851f9d20 11 BSD license, all text above must be included in any redistribution
llarquere 4:b439851f9d20 12 ****************************************************/
llarquere 4:b439851f9d20 13 /*****************************
llarquere 4:b439851f9d20 14 This program was ported from https://github.com/adafruit/Adafruit-PWM-Servo-Driver-Library.
llarquere 4:b439851f9d20 15 I also added some functions.
llarquere 4:b439851f9d20 16 Shundo Kishi
llarquere 4:b439851f9d20 17 *****************************/
llarquere 4:b439851f9d20 18
llarquere 4:b439851f9d20 19 #ifndef _ADAFRUIT_PWMServoDriver_H
llarquere 4:b439851f9d20 20 #define _ADAFRUIT_PWMServoDriver_H
llarquere 4:b439851f9d20 21
llarquere 4:b439851f9d20 22 #include "mbed.h"
llarquere 4:b439851f9d20 23 #include <cmath>
llarquere 4:b439851f9d20 24
llarquere 4:b439851f9d20 25 #define PCA9685_SUBADR1 0x2
llarquere 4:b439851f9d20 26 #define PCA9685_SUBADR2 0x3
llarquere 4:b439851f9d20 27 #define PCA9685_SUBADR3 0x4
llarquere 4:b439851f9d20 28
llarquere 4:b439851f9d20 29 #define PCA9685_MODE1 0x0
llarquere 4:b439851f9d20 30 #define PCA9685_PRESCALE 0xFE
llarquere 4:b439851f9d20 31
llarquere 4:b439851f9d20 32 #define LED0_ON_L 0x6
llarquere 4:b439851f9d20 33 #define LED0_ON_H 0x7
llarquere 4:b439851f9d20 34 #define LED0_OFF_L 0x8
llarquere 4:b439851f9d20 35 #define LED0_OFF_H 0x9
llarquere 4:b439851f9d20 36
llarquere 4:b439851f9d20 37 #define ALLLED_ON_L 0xFA
llarquere 4:b439851f9d20 38 #define ALLLED_ON_H 0xFB
llarquere 4:b439851f9d20 39 #define ALLLED_OFF_L 0xFC
llarquere 4:b439851f9d20 40 #define ALLLED_OFF_H 0xFD
llarquere 4:b439851f9d20 41
llarquere 4:b439851f9d20 42 class AFPSD {
llarquere 4:b439851f9d20 43 public:
llarquere 4:b439851f9d20 44 AFPSD( const int addr, I2C* i2c );
llarquere 4:b439851f9d20 45 void begin( void );
llarquere 4:b439851f9d20 46 void reset( void );
llarquere 4:b439851f9d20 47 void setPWMFreq( const float freq );
llarquere 4:b439851f9d20 48 void setPrescale( const uint8_t prescale );
llarquere 4:b439851f9d20 49 void setPWM( const uint8_t num, const uint16_t on, const uint16_t off );
llarquere 4:b439851f9d20 50 void setDuty( const uint8_t num, uint16_t duty );
llarquere 4:b439851f9d20 51
llarquere 4:b439851f9d20 52 private:
llarquere 4:b439851f9d20 53 // properties
llarquere 4:b439851f9d20 54 /// external i2c object
llarquere 4:b439851f9d20 55 I2C* _i2c;
llarquere 4:b439851f9d20 56 /// device (815) address on the i2c bus
llarquere 4:b439851f9d20 57 int _devaddr;
llarquere 4:b439851f9d20 58
llarquere 4:b439851f9d20 59 // methods
llarquere 4:b439851f9d20 60 uint8_t _read8(char pin);
llarquere 4:b439851f9d20 61 void _write8(char pin, char d);
llarquere 4:b439851f9d20 62 };
llarquere 4:b439851f9d20 63
llarquere 4:b439851f9d20 64 #endif