Adafruitms1438: Add string based constructor

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
Adelin Dobre 2018-06-29 16:56:54 +03:00 committed by Mihai Tudor Panu
parent 9db28cd4fc
commit 7b5b02d859
2 changed files with 37 additions and 14 deletions

View File

@ -35,6 +35,21 @@ using namespace std;
AdafruitMS1438::AdafruitMS1438(int bus, uint8_t address) :
m_pca9685(new PCA9685(bus, address))
{
initAdafruitMS1438();
}
AdafruitMS1438::AdafruitMS1438(std::string initStr) : m_pca9685(new PCA9685(initStr))
{
initAdafruitMS1438();
}
AdafruitMS1438::~AdafruitMS1438()
{
delete m_pca9685;
}
void AdafruitMS1438::initAdafruitMS1438()
{
setupPinMaps();
@ -56,11 +71,6 @@ AdafruitMS1438::AdafruitMS1438(int bus, uint8_t address) :
stepConfig(STEPMOTOR_M34, 200);
}
AdafruitMS1438::~AdafruitMS1438()
{
delete m_pca9685;
}
void AdafruitMS1438::initClock(STEPMOTORS_T motor)
{
gettimeofday(&m_stepConfig[motor].startTime, NULL);

View File

@ -29,6 +29,7 @@
#include <string>
#include <mraa/i2c.h>
#include <mraa/gpio.h>
#include <mraa/initio.hpp>
#include "pca9685.hpp"
@ -104,11 +105,23 @@ namespace upm {
*/
AdafruitMS1438(int bus, uint8_t address = ADAFRUITMS1438_DEFAULT_I2C_ADDR);
/**
* Instantiates AdafruitMS1438 based on a given string.
*
* @param initStr string containing specific information for AdafruitMS1438 initialization.
*/
AdafruitMS1438(std::string initStr);
/**
* AdafruitMS1438 destructor
*/
~AdafruitMS1438();
/**
* AdafruitMS1438 initialization method
*/
void initAdafruitMS1438();
/**
* Returns the number of milliseconds elapsed since initClock(...)
* was last called.