Fix some issues for string based constructors

Signed-off-by: Adelin Dobre <adelin.dobre@rinftech.com>
This commit is contained in:
Adelin Dobre
2018-07-27 15:46:16 +03:00
committed by Stefan Andritoiu
parent 5a42e44c86
commit b13cef3ebb
22 changed files with 257 additions and 264 deletions

View File

@ -106,17 +106,17 @@ adafruitss::adafruitss(std::string initStr) : mraaIo(initStr)
for(std::string tok : upmTokens)
{
if(tok.substr(0,8) == "pwmFreq:")
if(tok.substr(0, 8) == "pwmFreq:")
{
float freq = std::stof(tok.substr(8));
setPWMFreq(freq);
}
if(tok.substr(0,6) == "servo:")
if(tok.substr(0, 6) == "servo:")
{
uint8_t port = std::stoi(tok.substr(6),&sz,0);
uint8_t port = std::stoi(tok.substr(6), &sz, 0);
tok = tok.substr(6);
old_sz = sz+1;
uint8_t servo_type = std::stoi(tok.substr(old_sz),&sz,0);
uint8_t servo_type = std::stoi(tok.substr(old_sz), &sz, 0);
tok = tok.substr(old_sz);
float degrees = std::stof(tok.substr(sz+1));
servo(port, servo_type, degrees);