Removed commented code

Ran clang-format on modified files

Signed-off-by: Serban Waltter <serban.waltter@rinftech.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
Serban Waltter
2018-07-12 16:16:45 +03:00
committed by Mihai Tudor Panu
parent 664c6dd8c6
commit 57c0c8c235
9 changed files with 177 additions and 171 deletions

View File

@ -23,8 +23,8 @@
*/
#include <iostream>
#include <string>
#include <stdexcept>
#include <string>
#include "emg.hpp"
@ -33,55 +33,56 @@ using namespace std;
EMG::EMG(int pin)
{
if ( !(m_aio = mraa_aio_init(pin)) )
{
throw std::invalid_argument(std::string(__FUNCTION__) +
": mraa_aio_init() failed, invalid pin?");
return;
if (!(m_aio = mraa_aio_init(pin))) {
throw std::invalid_argument(std::string(__FUNCTION__) +
": mraa_aio_init() failed, invalid pin?");
return;
}
}
EMG::~EMG()
{
mraa_aio_close(m_aio);
mraa_aio_close(m_aio);
}
void EMG::calibrate()
void
EMG::calibrate()
{
int val, sum = 0;
int val, sum = 0;
for (int i=0; i<1100; i++)
{
val = mraa_aio_read(m_aio);
if (val != -1) throw std::runtime_error(std::string(__FUNCTION__) +
": Failed to do an aio read.");
sum += val;
usleep(1000);
}
sum /= 1100;
cout << "Static analog data = " << sum << endl;
for (int i = 0; i < 1100; i++) {
val = mraa_aio_read(m_aio);
if (val != -1)
throw std::runtime_error(std::string(__FUNCTION__) + ": Failed to do an aio read.");
sum += val;
usleep(1000);
}
sum /= 1100;
cout << "Static analog data = " << sum << endl;
}
int EMG::value()
int
EMG::value()
{
int val = mraa_aio_read(m_aio);
return val;
int val = mraa_aio_read(m_aio);
return val;
}
float EMG::getVolts()
float
EMG::getVolts()
{
float val = mraa_aio_read_float(m_aio);
if (val < 0)
return val;
float val = mraa_aio_read_float(m_aio);
if (val < 0)
return val;
/* Apply raw scale */
/* Apply raw scale */
val *= this->m_scale;
/* Scale to aRef */
/* Scale to aRef */
val *= this->m_aRef;
/* Apply the offset in volts */
val += this->m_offset;
return val;
return val;
}