Add changes getting values for upm parameters

Signed-off-by: Adelin Dobre <adelin.dobre@rinftech.com>
This commit is contained in:
Adelin Dobre 2018-07-31 14:29:52 +03:00 committed by Stefan Andritoiu
parent 5123a5c8e6
commit 252feac5c7
9 changed files with 39 additions and 39 deletions

View File

@ -90,15 +90,15 @@ ADC121C021::ADC121C021(std::string initStr) : mraaIo(initStr)
m_vref = std::stof(tok.substr(5)); m_vref = std::stof(tok.substr(5));
} }
if(tok.substr(0, 10) == "writeByte:") { if(tok.substr(0, 10) == "writeByte:") {
uint8_t reg = std::stoi(tok.substr(10), &sz, 0); uint8_t reg = std::stoul(tok.substr(10), &sz, 0);
tok = tok.substr(10); tok = tok.substr(10);
uint8_t byte = std::stoi(tok.substr(sz+1), nullptr, 0); uint8_t byte = std::stoul(tok.substr(sz+1), nullptr, 0);
writeByte(reg, byte); writeByte(reg, byte);
} }
if(tok.substr(0,10) == "writeWord:") { if(tok.substr(0,10) == "writeWord:") {
uint8_t reg = std::stoi(tok.substr(10), &sz, 0); uint8_t reg = std::stoul(tok.substr(10), &sz, 0);
tok = tok.substr(10); tok = tok.substr(10);
uint16_t word = std::stoi(tok.substr(sz+1), nullptr, 0); uint16_t word = std::stoul(tok.substr(sz+1), nullptr, 0);
writeWord(reg, word); writeWord(reg, word);
} }
if(tok.substr(0,16) == "enableAlertFlag:") { if(tok.substr(0,16) == "enableAlertFlag:") {
@ -118,15 +118,15 @@ ADC121C021::ADC121C021(std::string initStr) : mraaIo(initStr)
enableAlertPinPolarityHigh(enable); enableAlertPinPolarityHigh(enable);
} }
if(tok.substr(0,17) == "setAlertLowLimit:") { if(tok.substr(0,17) == "setAlertLowLimit:") {
uint16_t limit = std::stoi(tok.substr(17), nullptr, 0); uint16_t limit = std::stoul(tok.substr(17), nullptr, 0);
setAlertLowLimit(limit); setAlertLowLimit(limit);
} }
if(tok.substr(0,18) == "setAlertHighLimit:") { if(tok.substr(0,18) == "setAlertHighLimit:") {
uint16_t limit = std::stoi(tok.substr(18), nullptr, 0); uint16_t limit = std::stoul(tok.substr(18), nullptr, 0);
setAlertHighLimit(limit); setAlertHighLimit(limit);
} }
if(tok.substr(0,14) == "setHysteresis:") { if(tok.substr(0,14) == "setHysteresis:") {
uint16_t limit = std::stoi(tok.substr(14), nullptr, 0); uint16_t limit = std::stoul(tok.substr(14), nullptr, 0);
setHysteresis(limit); setHysteresis(limit);
} }
} }

View File

@ -125,9 +125,9 @@ ADIS16448::ADIS16448(std::string initStr) : mraaIo(initStr)
for (std::string tok : upmTokens) { for (std::string tok : upmTokens) {
if(tok.substr(0, 9) == "regWrite:") { if(tok.substr(0, 9) == "regWrite:") {
uint8_t regAddr = std::stoi(tok.substr(9), &sz, 0); uint8_t regAddr = std::stoul(tok.substr(9), &sz, 0);
tok = tok.substr(9); tok = tok.substr(9);
uint16_t regData = std::stoi(tok.substr(sz+1), nullptr, 0); uint16_t regData = std::stoul(tok.substr(sz+1), nullptr, 0);
regWrite(regAddr, regData); regWrite(regAddr, regData);
} }
} }

View File

@ -96,7 +96,7 @@ BH1750::BH1750(std::string initStr) : mraaIo(initStr)
powerDown(); powerDown();
} }
if(tok.substr(0, 12) == "sendCommand:") { if(tok.substr(0, 12) == "sendCommand:") {
uint8_t mode = (uint8_t)std::stoi(tok.substr(12), nullptr, 0); uint8_t mode = (uint8_t)std::stoul(tok.substr(12), nullptr, 0);
sendCommand(mode); sendCommand(mode);
} }
} }

View File

@ -107,9 +107,9 @@ BMA220::BMA220(std::string initStr) : mraaIo(new mraa::MraaIo(initStr))
for(std::string tok :upmTokens) for(std::string tok :upmTokens)
{ {
if(tok.substr(0, 9) == "writeReg:") { if(tok.substr(0, 9) == "writeReg:") {
uint8_t reg = std::stoi(tok.substr(9), &sz, 0); uint8_t reg = std::stoul(tok.substr(9), &sz, 0);
tok = tok.substr(9); tok = tok.substr(9);
uint8_t val = std::stoi(tok.substr(sz+1), nullptr, 0); uint8_t val = std::stoul(tok.substr(sz+1), nullptr, 0);
writeReg(reg, val); writeReg(reg, val);
} }
if(tok.substr(0, 22) == "setAccelerometerScale:") { if(tok.substr(0, 22) == "setAccelerometerScale:") {

View File

@ -167,9 +167,9 @@ BMA250E::BMA250E(std::string initStr) : mraaIo(initStr)
enableFIFO(useFIFO); enableFIFO(useFIFO);
} }
if(tok.substr(0, 9) == "writeReg:") { if(tok.substr(0, 9) == "writeReg:") {
uint8_t reg = std::stoi(tok.substr(9), &sz, 0); uint8_t reg = std::stoul(tok.substr(9), &sz, 0);
tok = tok.substr(9); tok = tok.substr(9);
uint8_t val = std::stoi(tok.substr(sz+1), nullptr, 0); uint8_t val = std::stoul(tok.substr(sz+1), nullptr, 0);
writeReg(reg, val); writeReg(reg, val);
} }
if(tok.substr(0, 9) == "setRange:") { if(tok.substr(0, 9) == "setRange:") {
@ -195,35 +195,35 @@ BMA250E::BMA250E(std::string initStr) : mraaIo(initStr)
fifoConfig(mode, axes); fifoConfig(mode, axes);
} }
if(tok.substr(0, 20) == "setInterruptEnable0:") { if(tok.substr(0, 20) == "setInterruptEnable0:") {
u_int8_t bits = (u_int8_t)std::stoi(tok.substr(20), nullptr, 0); u_int8_t bits = (u_int8_t)std::stoul(tok.substr(20), nullptr, 0);
setInterruptEnable0(bits); setInterruptEnable0(bits);
} }
if(tok.substr(0, 20) == "setInterruptEnable1:") { if(tok.substr(0, 20) == "setInterruptEnable1:") {
u_int8_t bits = (u_int8_t)std::stoi(tok.substr(20), nullptr, 0); u_int8_t bits = (u_int8_t)std::stoul(tok.substr(20), nullptr, 0);
setInterruptEnable1(bits); setInterruptEnable1(bits);
} }
if(tok.substr(0, 20) == "setInterruptEnable2:") { if(tok.substr(0, 20) == "setInterruptEnable2:") {
u_int8_t bits = (u_int8_t)std::stoi(tok.substr(20), nullptr, 0); u_int8_t bits = (u_int8_t)std::stoul(tok.substr(20), nullptr, 0);
setInterruptEnable2(bits); setInterruptEnable2(bits);
} }
if(tok.substr(0, 17) == "setInterruptMap0:") { if(tok.substr(0, 17) == "setInterruptMap0:") {
u_int8_t bits = (u_int8_t)std::stoi(tok.substr(17), nullptr, 0); u_int8_t bits = (u_int8_t)std::stoul(tok.substr(17), nullptr, 0);
setInterruptMap0(bits); setInterruptMap0(bits);
} }
if(tok.substr(0, 17) == "setInterruptMap1:") { if(tok.substr(0, 17) == "setInterruptMap1:") {
u_int8_t bits = (u_int8_t)std::stoi(tok.substr(17), nullptr, 0); u_int8_t bits = (u_int8_t)std::stoul(tok.substr(17), nullptr, 0);
setInterruptMap1(bits); setInterruptMap1(bits);
} }
if(tok.substr(0, 17) == "setInterruptMap2:") { if(tok.substr(0, 17) == "setInterruptMap2:") {
u_int8_t bits = (u_int8_t)std::stoi(tok.substr(17), nullptr, 0); u_int8_t bits = (u_int8_t)std::stoul(tok.substr(17), nullptr, 0);
setInterruptMap2(bits); setInterruptMap2(bits);
} }
if(tok.substr(0, 16) == "setInterruptSrc:") { if(tok.substr(0, 16) == "setInterruptSrc:") {
u_int8_t bits = (u_int8_t)std::stoi(tok.substr(16), nullptr, 0); u_int8_t bits = (u_int8_t)std::stoul(tok.substr(16), nullptr, 0);
setInterruptSrc(bits); setInterruptSrc(bits);
} }
if(tok.substr(0, 26) == "setInterruptOutputControl:") { if(tok.substr(0, 26) == "setInterruptOutputControl:") {
u_int8_t bits = (u_int8_t)std::stoi(tok.substr(26), nullptr, 0); u_int8_t bits = (u_int8_t)std::stoul(tok.substr(26), nullptr, 0);
setInterruptOutputControl(bits); setInterruptOutputControl(bits);
} }
if(tok.substr(0, 26) == "setInterruptLatchBehavior:") { if(tok.substr(0, 26) == "setInterruptLatchBehavior:") {

View File

@ -145,9 +145,9 @@ BMG160::BMG160(std::string initStr) : mraaIo(initStr)
enableFIFO(useFIFO); enableFIFO(useFIFO);
} }
if(tok.substr(0, 9) == "writeReg:") { if(tok.substr(0, 9) == "writeReg:") {
uint8_t reg = std::stoi(tok.substr(9), &sz, 0); uint8_t reg = std::stoul(tok.substr(9), &sz, 0);
tok = tok.substr(9); tok = tok.substr(9);
uint8_t val = std::stoi(tok.substr(sz+1), nullptr, 0); uint8_t val = std::stoul(tok.substr(sz+1), nullptr, 0);
writeReg(reg, val); writeReg(reg, val);
} }
if(tok.substr(0, 9) == "setRange:") { if(tok.substr(0, 9) == "setRange:") {
@ -173,23 +173,23 @@ BMG160::BMG160(std::string initStr) : mraaIo(initStr)
fifoConfig(mode, axes); fifoConfig(mode, axes);
} }
if(tok.substr(0, 20) == "setInterruptEnable0:") { if(tok.substr(0, 20) == "setInterruptEnable0:") {
u_int8_t bits = (u_int8_t)std::stoi(tok.substr(20), nullptr, 0); u_int8_t bits = (u_int8_t)std::stoul(tok.substr(20), nullptr, 0);
setInterruptEnable0(bits); setInterruptEnable0(bits);
} }
if(tok.substr(0, 17) == "setInterruptMap0:") { if(tok.substr(0, 17) == "setInterruptMap0:") {
u_int8_t bits = (u_int8_t)std::stoi(tok.substr(17), nullptr, 0); u_int8_t bits = (u_int8_t)std::stoul(tok.substr(17), nullptr, 0);
setInterruptMap0(bits); setInterruptMap0(bits);
} }
if(tok.substr(0, 17) == "setInterruptMap1:") { if(tok.substr(0, 17) == "setInterruptMap1:") {
u_int8_t bits = (u_int8_t)std::stoi(tok.substr(17), nullptr, 0); u_int8_t bits = (u_int8_t)std::stoul(tok.substr(17), nullptr, 0);
setInterruptMap1(bits); setInterruptMap1(bits);
} }
if(tok.substr(0, 16) == "setInterruptSrc:") { if(tok.substr(0, 16) == "setInterruptSrc:") {
u_int8_t bits = (u_int8_t)std::stoi(tok.substr(16), nullptr, 0); u_int8_t bits = (u_int8_t)std::stoul(tok.substr(16), nullptr, 0);
setInterruptSrc(bits); setInterruptSrc(bits);
} }
if(tok.substr(0, 26) == "setInterruptOutputControl:") { if(tok.substr(0, 26) == "setInterruptOutputControl:") {
u_int8_t bits = (u_int8_t)std::stoi(tok.substr(26), nullptr, 0); u_int8_t bits = (u_int8_t)std::stoul(tok.substr(26), nullptr, 0);
setInterruptOutputControl(bits); setInterruptOutputControl(bits);
} }
if(tok.substr(0, 26) == "setInterruptLatchBehavior:") { if(tok.substr(0, 26) == "setInterruptLatchBehavior:") {

View File

@ -151,9 +151,9 @@ BMM150::BMM150(std::string initStr) : mraaIo(initStr)
init(usage); init(usage);
} }
if(tok.substr(0, 9) == "writeReg:") { if(tok.substr(0, 9) == "writeReg:") {
uint8_t reg = std::stoi(tok.substr(9), &sz, 0); uint8_t reg = std::stoul(tok.substr(9), &sz, 0);
tok = tok.substr(9); tok = tok.substr(9);
uint8_t val = std::stoi(tok.substr(sz+1), nullptr, 0); uint8_t val = std::stoul(tok.substr(sz+1), nullptr, 0);
writeReg(reg, val); writeReg(reg, val);
} }
if(tok.substr(0, 18) == "setOutputDataRate:") { if(tok.substr(0, 18) == "setOutputDataRate:") {
@ -170,19 +170,19 @@ BMM150::BMM150(std::string initStr) : mraaIo(initStr)
setOpmode(opmode); setOpmode(opmode);
} }
if(tok.substr(0, 19) == "setInterruptEnable:") { if(tok.substr(0, 19) == "setInterruptEnable:") {
u_int8_t bits = (u_int8_t)std::stoi(tok.substr(19), nullptr, 0); u_int8_t bits = (u_int8_t)std::stoul(tok.substr(19), nullptr, 0);
setInterruptEnable(bits); setInterruptEnable(bits);
} }
if(tok.substr(0, 19) == "setInterruptConfig:") { if(tok.substr(0, 19) == "setInterruptConfig:") {
u_int8_t bits = (u_int8_t)std::stoi(tok.substr(19), nullptr, 0); u_int8_t bits = (u_int8_t)std::stoul(tok.substr(19), nullptr, 0);
setInterruptConfig(bits); setInterruptConfig(bits);
} }
if(tok.substr(0, 17) == "setRepetitionsXY:") { if(tok.substr(0, 17) == "setRepetitionsXY:") {
u_int8_t reps = (u_int8_t)std::stoi(tok.substr(17), nullptr, 0); u_int8_t reps = (u_int8_t)std::stoul(tok.substr(17), nullptr, 0);
setRepetitionsXY(reps); setRepetitionsXY(reps);
} }
if(tok.substr(0, 16) == "setRepetitionsZ:") { if(tok.substr(0, 16) == "setRepetitionsZ:") {
u_int8_t reps = (u_int8_t)std::stoi(tok.substr(16), nullptr, 0); u_int8_t reps = (u_int8_t)std::stoul(tok.substr(16), nullptr, 0);
setRepetitionsZ(reps); setRepetitionsZ(reps);
} }
if(tok.substr(0, 14) == "setPresetMode:") { if(tok.substr(0, 14) == "setPresetMode:") {

View File

@ -170,9 +170,9 @@ BMP280::BMP280(std::string initStr) : mraaIo(initStr)
setSeaLevelPreassure(seaLevelhPA); setSeaLevelPreassure(seaLevelhPA);
} }
if(tok.substr(0, 9) == "writeReg:") { if(tok.substr(0, 9) == "writeReg:") {
uint8_t reg = std::stoi(tok.substr(9), &sz, 0); uint8_t reg = std::stoul(tok.substr(9), &sz, 0);
tok = tok.substr(9); tok = tok.substr(9);
uint8_t val = std::stoi(tok.substr(sz+1), nullptr, 0); uint8_t val = std::stoul(tok.substr(sz+1), nullptr, 0);
writeReg(reg, val); writeReg(reg, val);
} }
if(tok.substr(0, 10) == "setFilter:") { if(tok.substr(0, 10) == "setFilter:") {

View File

@ -110,9 +110,9 @@ BMPX8X::BMPX8X(std::string initStr) : mraaIo(initStr)
setOversampling(oss); setOversampling(oss);
} }
if(tok.substr(0, 9) == "writeReg:") { if(tok.substr(0, 9) == "writeReg:") {
uint8_t reg = std::stoi(tok.substr(9), &sz, 0); uint8_t reg = std::stoul(tok.substr(9), &sz, 0);
tok = tok.substr(9); tok = tok.substr(9);
uint8_t val = std::stoi(tok.substr(sz+1), nullptr, 0); uint8_t val = std::stoul(tok.substr(sz+1), nullptr, 0);
writeReg(reg, val); writeReg(reg, val);
} }
} }