adafruitss: renamed to adafruit pca9685 servo shield

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
Mihai Tudor Panu 2015-03-06 12:37:45 -08:00
parent 2725342c19
commit f53d8e79cc
9 changed files with 39 additions and 33 deletions

View File

@ -100,7 +100,7 @@ add_executable (at42qt1070-example at42qt1070.cxx)
add_executable (grovemd-example grovemd.cxx) add_executable (grovemd-example grovemd.cxx)
add_executable (pca9685-example pca9685.cxx) add_executable (pca9685-example pca9685.cxx)
add_executable (groveeldriver-example groveeldriver.cxx) add_executable (groveeldriver-example groveeldriver.cxx)
add_executable (pca9685ss-example pca9685ss.cxx) add_executable (adafruitss-example adafruitss.cxx)
include_directories (${PROJECT_SOURCE_DIR}/src/hmc5883l) include_directories (${PROJECT_SOURCE_DIR}/src/hmc5883l)
include_directories (${PROJECT_SOURCE_DIR}/src/grove) include_directories (${PROJECT_SOURCE_DIR}/src/grove)
@ -182,6 +182,7 @@ include_directories (${PROJECT_SOURCE_DIR}/src/at42qt1070)
include_directories (${PROJECT_SOURCE_DIR}/src/grovemd) include_directories (${PROJECT_SOURCE_DIR}/src/grovemd)
include_directories (${PROJECT_SOURCE_DIR}/src/pca9685) include_directories (${PROJECT_SOURCE_DIR}/src/pca9685)
include_directories (${PROJECT_SOURCE_DIR}/src/groveeldriver) include_directories (${PROJECT_SOURCE_DIR}/src/groveeldriver)
include_directories (${PROJECT_SOURCE_DIR}/src/adafruitss)
target_link_libraries (hmc5883l-example hmc5883l ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries (hmc5883l-example hmc5883l ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (groveled-example grove ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries (groveled-example grove ${CMAKE_THREAD_LIBS_INIT})
@ -283,4 +284,4 @@ target_link_libraries (at42qt1070-example at42qt1070 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (grovemd-example grovemd ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries (grovemd-example grovemd ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (pca9685-example pca9685 ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries (pca9685-example pca9685 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (groveeldriver-example groveeldriver ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries (groveeldriver-example groveeldriver ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (pca9685ss-example pca9685 ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries (adafruitss-example adafruitss ${CMAKE_THREAD_LIBS_INIT})

View File

@ -33,7 +33,7 @@
*/ */
#include <iostream> #include <iostream>
#include "pca9685ss.h" #include "adafruitss.h"
#include <unistd.h> #include <unistd.h>
using namespace std; using namespace std;
@ -43,7 +43,7 @@ int main() {
int n; int n;
//! [Interesting] //! [Interesting]
upm::pca9685ss* servos = new upm::pca9685ss(6,0x40); upm::adafruitss* servos = new upm::adafruitss(6,0x40);
for (;;) for (;;)
{ {

View File

@ -0,0 +1,5 @@
set (libname "adafruitss")
set (libdescription "upm Adafruit pca9685 based 16-channel servo shield")
set (module_src ${libname}.cxx)
set (module_h ${libname}.h)
upm_module_init()

View File

@ -22,13 +22,13 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include "pca9685ss.h" #include "adafruitss.h"
#include <unistd.h> #include <unistd.h>
#include <math.h> #include <math.h>
using namespace upm; using namespace upm;
pca9685ss::pca9685ss(int bus,int i2c_address) adafruitss::adafruitss(int bus,int i2c_address)
{ {
int n; int n;
int result; int result;
@ -44,13 +44,13 @@ pca9685ss::pca9685ss(int bus,int i2c_address)
m_rx_tx_buf[1]=0; m_rx_tx_buf[1]=0;
result=mraa_i2c_write(m_i2c,m_rx_tx_buf,2); result=mraa_i2c_write(m_i2c,m_rx_tx_buf,2);
pca9685ss::setPWMFreq(60); adafruitss::setPWMFreq(60);
pca9685ss::update(); adafruitss::update();
} }
void pca9685ss::setPWMFreq(float freq) { void adafruitss::setPWMFreq(float freq) {
int result; int result;
freq *= 0.88; // Correct for overshoot in the frequency setting (see issue #11). freq *= 0.88; // Correct for overshoot in the frequency setting (see issue #11).
float prescaleval = 25000000; float prescaleval = 25000000;
@ -101,13 +101,13 @@ void pca9685ss::setPWMFreq(float freq) {
result=mraa_i2c_write(m_i2c,m_rx_tx_buf,2); result=mraa_i2c_write(m_i2c,m_rx_tx_buf,2);
} }
int pca9685ss::update(void) int adafruitss::update(void)
{ {
return MRAA_SUCCESS; return MRAA_SUCCESS;
} }
void pca9685ss::servo(uint8_t port, uint8_t servo_type, uint16_t degrees) { void adafruitss::servo(uint8_t port, uint8_t servo_type, uint16_t degrees) {
// Set Servo values // Set Servo values
// Degrees is from 0 to 180 // Degrees is from 0 to 180
// servo_type: 0 = standard 1ms to 2ms // servo_type: 0 = standard 1ms to 2ms

View File

@ -56,8 +56,8 @@
namespace upm { namespace upm {
/** /**
* @brief pca9685 based servo controller * @brief Adafruit PCA9685 based servo controller
* @defgroup pca9685 libupm-pca9685 * @defgroup adafruitss libupm-adafruitss
*/ */
/** /**
@ -66,17 +66,17 @@ namespace upm {
* Adafruit do recommend a capacitor be installed on the board which should alleviate the issue. Sizing depends on servos and count. * Adafruit do recommend a capacitor be installed on the board which should alleviate the issue. Sizing depends on servos and count.
* *
* @ingroup i2c * @ingroup i2c
* @snippet pca9685ss.cxx Interesting * @snippet adafruitss.cxx Interesting
*/ */
class pca9685ss { class adafruitss {
public: public:
/** /**
* Creates a pca9685ss object * Creates a adafruitss object
* *
* @param bus number of used i2c bus * @param bus number of used i2c bus
* @param i2c_address address of servo controller on i2c bus * @param i2c_address address of servo controller on i2c bus
*/ */
pca9685ss(int bus, int i2c_address); adafruitss(int bus, int i2c_address);
int update(void); int update(void);
/** /**
* Sets the frequency for your servos * Sets the frequency for your servos

View File

@ -0,0 +1,7 @@
%module jsupm_adafruitss
%include "../upm.i"
%include "adafruitss.h"
%{
#include "adafruitss.h"
%}

View File

@ -0,0 +1,9 @@
%module pyupm_adafruitss
%include "../upm.i"
%feature("autodoc", "3");
%include "adafruitss.h"
%{
#include "adafruitss.h"
%}

View File

@ -1,7 +0,0 @@
%module jsupm_pca9685
%include "../upm.i"
%include "pca9685ss.h"
%{
#include "pca9685ss.h"
%}

View File

@ -1,9 +0,0 @@
%module pyupm_pca9685
%include "../upm.i"
%feature("autodoc", "3");
%include "pca9685ss.h"
%{
#include "pca9685ss.h"
%}