upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
adafruitss.hpp
1 /*
2  * Author: Stan Gifford <stan@gifford.id.au>
3  * Copyright (c) 2015 Intel Corporation.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
25 #pragma once
26 
27 #include <mraa/i2c.h>
28 
29 #define MAX_BUFFER_LENGTH 6
30 
31 #define SERVO_MIN 0
32 #define SERVO_MAX 180
33 #define SERVO_FREQ 60
34 #define PCA9685_SUBADR1 0x2
35 #define PCA9685_SUBADR2 0x3
36 #define PCA9685_SUBADR3 0x4
37 
38 #define PCA9685_MODE1 0x0
39 #define PCA9685_PRESCALE 0xFE
40 
41 #define LED0_ON_L 0x6
42 #define LED0_ON_H 0x7
43 #define LED0_OFF_L 0x8
44 #define LED0_OFF_H 0x9
45 
46 #define ALLLED_ON_L 0xFA
47 #define ALLLED_ON_H 0xFB
48 #define ALLLED_OFF_L 0xFC
49 #define ALLLED_OFF_H 0xFD
50 
51 #define PCA9685_MODE1_REG 0x00
52 #define PCA9685_PRESCALE_REG 0xFE
53 #define LED0_REG 0x06
54 
55 namespace upm {
56 
83  class adafruitss {
84  public:
91  adafruitss(int bus, int i2c_address);
92  int update(void);
98  void setPWMFreq(float freq);
107  void servo(uint8_t port, uint8_t servo_type, float degrees);
108 
109  private:
110 
111  int pca9685_addr;
112  mraa_i2c_context m_i2c;
113  uint8_t m_rx_tx_buf[MAX_BUFFER_LENGTH];
114  float _duration_1ms;
115 };
116 
117 }
adafruitss(int bus, int i2c_address)
Definition: adafruitss.cxx:34
API for the Adafruit Servo Shield.
Definition: adafruitss.hpp:83
C++ API wrapper for the bh1749 driver.
Definition: a110x.hpp:29
void servo(uint8_t port, uint8_t servo_type, float degrees)
Definition: adafruitss.cxx:114
void setPWMFreq(float freq)
Definition: adafruitss.cxx:65