mirror of
https://github.com/eclipse/upm.git
synced 2025-03-14 20:47:30 +03:00
Removed commented code
Ran clang-format on modified files Signed-off-by: Serban Waltter <serban.waltter@rinftech.com>
This commit is contained in:
parent
f870362923
commit
2acecb1e62
@ -5,27 +5,24 @@
|
||||
#include "bh1750.hpp"
|
||||
#include "max44009.hpp"
|
||||
|
||||
// using namespace std;
|
||||
// using namespace upm;
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
std::list<upm::iLight*> lightSensors;
|
||||
std::list<upm::iLight*> lightSensors;
|
||||
|
||||
// Populate list of light sensors
|
||||
lightSensors.push_back(new upm::APDS9002(0));
|
||||
lightSensors.push_back(new upm::BH1750());
|
||||
lightSensors.push_back(new upm::MAX44009(1));
|
||||
// Populate list of light sensors
|
||||
lightSensors.push_back(new upm::APDS9002(0));
|
||||
lightSensors.push_back(new upm::BH1750());
|
||||
lightSensors.push_back(new upm::MAX44009(1));
|
||||
|
||||
// Measure luminance level from all 3 individual sensors
|
||||
for (auto& sensor : lightSensors) {
|
||||
sensor->getLuminance();
|
||||
}
|
||||
// Measure luminance level from all 3 individual sensors
|
||||
for (auto& sensor : lightSensors) {
|
||||
sensor->getLuminance();
|
||||
}
|
||||
|
||||
for (auto& sensor : lightSensors) {
|
||||
delete sensor;
|
||||
}
|
||||
for (auto& sensor : lightSensors) {
|
||||
delete sensor;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,26 +1,26 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include "lm35.hpp"
|
||||
#include "abp.hpp"
|
||||
|
||||
// using namespace std;
|
||||
// using namespace upm;
|
||||
#include "lm35.hpp"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
std::vector<upm::iTemperature*> tempSensors {new upm::LM35(0), new upm::ABP(0, ABP_DEFAULT_ADDRESS)};
|
||||
std::vector<upm::iTemperature*> tempSensors{ new upm::LM35(0),
|
||||
new upm::ABP(0, ABP_DEFAULT_ADDRESS) };
|
||||
|
||||
for (auto& sensor : tempSensors) {
|
||||
float celsiusTemp = sensor->getTemperature();
|
||||
std::cout << "Temperature in Celsius degrees: " << celsiusTemp << std::endl;
|
||||
std::cout << "Temperature in Kelvin: " << upm::iTemperature::convertCelsiusTo(celsiusTemp, upm::TemperatureUnit::KELVIN) << std::endl;
|
||||
}
|
||||
for (auto& sensor : tempSensors) {
|
||||
float celsiusTemp = sensor->getTemperature();
|
||||
std::cout << "Temperature in Celsius degrees: " << celsiusTemp << std::endl;
|
||||
std::cout << "Temperature in Kelvin: "
|
||||
<< upm::iTemperature::convertCelsiusTo(celsiusTemp, upm::TemperatureUnit::KELVIN)
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
for (auto& sensor : tempSensors) {
|
||||
delete sensor;
|
||||
}
|
||||
for (auto& sensor : tempSensors) {
|
||||
delete sensor;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -23,8 +23,8 @@
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#include "groveemg.hpp"
|
||||
|
||||
@ -33,55 +33,56 @@ using namespace std;
|
||||
|
||||
GroveEMG::GroveEMG(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;
|
||||
}
|
||||
}
|
||||
|
||||
GroveEMG::~GroveEMG()
|
||||
{
|
||||
mraa_aio_close(m_aio);
|
||||
mraa_aio_close(m_aio);
|
||||
}
|
||||
|
||||
void GroveEMG::calibrate()
|
||||
void
|
||||
GroveEMG::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 GroveEMG::value()
|
||||
int
|
||||
GroveEMG::value()
|
||||
{
|
||||
int val = mraa_aio_read(m_aio);
|
||||
return val;
|
||||
int val = mraa_aio_read(m_aio);
|
||||
return val;
|
||||
}
|
||||
|
||||
float GroveEMG::getVolts()
|
||||
float
|
||||
GroveEMG::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;
|
||||
}
|
@ -24,16 +24,17 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "groveultrasonic.hpp"
|
||||
|
||||
using namespace upm;
|
||||
|
||||
GroveUltraSonic::GroveUltraSonic (int pin) {
|
||||
GroveUltraSonic::GroveUltraSonic(int pin)
|
||||
{
|
||||
m_name = "GroveUltraSonic";
|
||||
|
||||
mraa_init();
|
||||
@ -41,23 +42,23 @@ GroveUltraSonic::GroveUltraSonic (int pin) {
|
||||
// setup pin
|
||||
m_pinCtx = mraa_gpio_init(pin);
|
||||
if (m_pinCtx == NULL) {
|
||||
fprintf (stderr, "Are you sure that pin%d you requested is valid on your platform?", pin);
|
||||
exit (1);
|
||||
fprintf(stderr, "Are you sure that pin%d you requested is valid on your platform?", pin);
|
||||
exit(1);
|
||||
}
|
||||
mraa_gpio_isr (m_pinCtx, MRAA_GPIO_EDGE_BOTH,
|
||||
&signalISR, this);
|
||||
}
|
||||
|
||||
GroveUltraSonic::~GroveUltraSonic () {
|
||||
|
||||
GroveUltraSonic::~GroveUltraSonic()
|
||||
{
|
||||
// close pin
|
||||
mraa_gpio_isr_exit(m_pinCtx);
|
||||
mraa_gpio_close (m_pinCtx);
|
||||
mraa_gpio_close(m_pinCtx);
|
||||
}
|
||||
|
||||
float
|
||||
GroveUltraSonic::getDistance () {
|
||||
|
||||
GroveUltraSonic::getDistance()
|
||||
{
|
||||
// output trigger signal
|
||||
mraa_gpio_dir(m_pinCtx, MRAA_GPIO_OUT);
|
||||
mraa_gpio_write(m_pinCtx, LOW);
|
||||
@ -86,13 +87,15 @@ GroveUltraSonic::getDistance () {
|
||||
}
|
||||
|
||||
void
|
||||
GroveUltraSonic::signalISR(void *ctx) {
|
||||
upm::GroveUltraSonic *This = (upm::GroveUltraSonic *)ctx;
|
||||
GroveUltraSonic::signalISR(void* ctx)
|
||||
{
|
||||
upm::GroveUltraSonic* This = (upm::GroveUltraSonic*) ctx;
|
||||
This->ackEdgeDetected();
|
||||
}
|
||||
|
||||
void
|
||||
GroveUltraSonic::ackEdgeDetected () {
|
||||
GroveUltraSonic::ackEdgeDetected()
|
||||
{
|
||||
if (++m_InterruptCounter % 2 == 0) {
|
||||
gettimeofday(&m_FallingTimeStamp, NULL);
|
||||
m_doWork = false;
|
||||
|
@ -24,22 +24,20 @@
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#include "hcsr04.hpp"
|
||||
|
||||
using namespace upm;
|
||||
|
||||
HCSR04::HCSR04 (int triggerPin, int echoPin) :
|
||||
m_hcsr04(hcsr04_init(triggerPin, echoPin))
|
||||
HCSR04::HCSR04(int triggerPin, int echoPin) : m_hcsr04(hcsr04_init(triggerPin, echoPin))
|
||||
{
|
||||
if(!m_hcsr04)
|
||||
throw std::runtime_error(std::string(__FUNCTION__) +
|
||||
": hcsr04_init failed");
|
||||
if (!m_hcsr04)
|
||||
throw std::runtime_error(std::string(__FUNCTION__) + ": hcsr04_init failed");
|
||||
}
|
||||
|
||||
HCSR04::~HCSR04 ()
|
||||
HCSR04::~HCSR04()
|
||||
{
|
||||
hcsr04_close(m_hcsr04);
|
||||
}
|
||||
|
@ -24,16 +24,17 @@
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "lidarlitev3.hpp"
|
||||
|
||||
using namespace upm;
|
||||
|
||||
LIDARLITEV3::LIDARLITEV3 (int bus, int devAddr) : m_i2ControlCtx(bus) {
|
||||
LIDARLITEV3::LIDARLITEV3(int bus, int devAddr) : m_i2ControlCtx(bus)
|
||||
{
|
||||
m_name = "LIDARLITEV3";
|
||||
|
||||
m_controlAddr = devAddr;
|
||||
@ -41,40 +42,40 @@ LIDARLITEV3::LIDARLITEV3 (int bus, int devAddr) : m_i2ControlCtx(bus) {
|
||||
|
||||
mraa::Result ret = m_i2ControlCtx.address(m_controlAddr);
|
||||
if (ret != mraa::SUCCESS) {
|
||||
throw std::invalid_argument(std::string(__FUNCTION__) +
|
||||
": mraa_i2c_address() failed");
|
||||
throw std::invalid_argument(std::string(__FUNCTION__) + ": mraa_i2c_address() failed");
|
||||
}
|
||||
}
|
||||
|
||||
float
|
||||
LIDARLITEV3::getDistance () {
|
||||
|
||||
if(i2cWriteReg(ACQ_COMMAND, 0x04) < 0)
|
||||
LIDARLITEV3::getDistance()
|
||||
{
|
||||
if (i2cWriteReg(ACQ_COMMAND, 0x04) < 0)
|
||||
return -1;
|
||||
|
||||
return read(0x8f,true);
|
||||
return read(0x8f, true);
|
||||
}
|
||||
|
||||
uint16_t
|
||||
LIDARLITEV3::read(int reg, bool monitorBusyFlag) {
|
||||
int busyFlag = 0; // busyFlag monitors when the device is done with a measurement
|
||||
LIDARLITEV3::read(int reg, bool monitorBusyFlag)
|
||||
{
|
||||
int busyFlag = 0; // busyFlag monitors when the device is done with a measurement
|
||||
int busyCounter = 0; // busyCounter counts number of times busy flag is checked, for timeout
|
||||
uint8_t data;
|
||||
uint16_t distance;
|
||||
|
||||
if(monitorBusyFlag) {
|
||||
if (monitorBusyFlag) {
|
||||
busyFlag = 1; // Begin read immediately if not monitoring busy flag
|
||||
}
|
||||
|
||||
while(busyFlag != 0) { // Loop until device is not busy
|
||||
while (busyFlag != 0) { // Loop until device is not busy
|
||||
// Read status register to check busy flag
|
||||
data = i2cReadReg_8 (0x01); // Read register 0x01
|
||||
busyFlag = data & 1; // Assign the LSB of the status register to busyFlag
|
||||
data = i2cReadReg_8(0x01); // Read register 0x01
|
||||
busyFlag = data & 1; // Assign the LSB of the status register to busyFlag
|
||||
|
||||
busyCounter++; // Increment busyCounter for timeout
|
||||
|
||||
// Handle timeout condition, exit while loop and goto bailout
|
||||
if(busyCounter > 9999) {
|
||||
if (busyCounter > 9999) {
|
||||
goto timeout;
|
||||
}
|
||||
}
|
||||
@ -85,22 +86,22 @@ LIDARLITEV3::read(int reg, bool monitorBusyFlag) {
|
||||
}
|
||||
|
||||
// timeout reports error
|
||||
if(busyCounter > 9999) {
|
||||
timeout:
|
||||
if (busyCounter > 9999) {
|
||||
timeout:
|
||||
busyCounter = 0;
|
||||
throw std::invalid_argument(std::string(__FUNCTION__) +
|
||||
": Read timeout");
|
||||
throw std::invalid_argument(std::string(__FUNCTION__) + ": Read timeout");
|
||||
}
|
||||
return distance;
|
||||
}
|
||||
|
||||
uint16_t
|
||||
LIDARLITEV3::i2cReadReg_16 (int reg) {
|
||||
LIDARLITEV3::i2cReadReg_16(int reg)
|
||||
{
|
||||
uint16_t data;
|
||||
|
||||
m_i2ControlCtx.writeByte(reg);
|
||||
|
||||
m_i2ControlCtx.read((uint8_t *)&data, 0x2);
|
||||
m_i2ControlCtx.read((uint8_t*) &data, 0x2);
|
||||
|
||||
uint8_t high = (data & 0xFF00) >> 8;
|
||||
data = (data << 8) & 0xFF00;
|
||||
@ -110,7 +111,8 @@ LIDARLITEV3::i2cReadReg_16 (int reg) {
|
||||
}
|
||||
|
||||
uint8_t
|
||||
LIDARLITEV3::i2cReadReg_8 (int reg) {
|
||||
LIDARLITEV3::i2cReadReg_8(int reg)
|
||||
{
|
||||
uint8_t data;
|
||||
|
||||
m_i2ControlCtx.writeByte(reg);
|
||||
@ -121,14 +123,14 @@ LIDARLITEV3::i2cReadReg_8 (int reg) {
|
||||
}
|
||||
|
||||
mraa::Result
|
||||
LIDARLITEV3::i2cWriteReg (uint8_t reg, uint8_t value) {
|
||||
LIDARLITEV3::i2cWriteReg(uint8_t reg, uint8_t value)
|
||||
{
|
||||
mraa::Result error = mraa::SUCCESS;
|
||||
|
||||
uint8_t data[2] = { reg, value };
|
||||
error = m_i2ControlCtx.write (data, 2);
|
||||
if ( error != mraa::SUCCESS)
|
||||
throw std::invalid_argument(std::string(__FUNCTION__) +
|
||||
": mraa_i2c_write() failed");
|
||||
error = m_i2ControlCtx.write(data, 2);
|
||||
if (error != mraa::SUCCESS)
|
||||
throw std::invalid_argument(std::string(__FUNCTION__) + ": mraa_i2c_write() failed");
|
||||
|
||||
return error;
|
||||
}
|
||||
|
@ -23,8 +23,8 @@
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#include "maxsonarez.hpp"
|
||||
|
||||
@ -33,37 +33,38 @@ using namespace upm;
|
||||
|
||||
MAXSONAREZ::MAXSONAREZ(int pin, float aref)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
m_aRes = (1 << mraa_aio_get_bit(m_aio));
|
||||
m_aref = aref;
|
||||
m_aRes = (1 << mraa_aio_get_bit(m_aio));
|
||||
m_aref = aref;
|
||||
|
||||
// volt's per inch of this sensor
|
||||
m_vI = (m_aref / MAXSONAREZ_RES);
|
||||
// volt's per inch of this sensor
|
||||
m_vI = (m_aref / MAXSONAREZ_RES);
|
||||
}
|
||||
|
||||
MAXSONAREZ::~MAXSONAREZ()
|
||||
{
|
||||
mraa_aio_close(m_aio);
|
||||
mraa_aio_close(m_aio);
|
||||
}
|
||||
|
||||
int MAXSONAREZ::inches()
|
||||
int
|
||||
MAXSONAREZ::inches()
|
||||
{
|
||||
int val = mraa_aio_read(m_aio);
|
||||
if (val == -1) {
|
||||
return -1;
|
||||
}
|
||||
float volts = float(val) * (m_aref / m_aRes);
|
||||
int val = mraa_aio_read(m_aio);
|
||||
if (val == -1) {
|
||||
return -1;
|
||||
}
|
||||
float volts = float(val) * (m_aref / m_aRes);
|
||||
|
||||
return int(volts / m_vI);
|
||||
return int(volts / m_vI);
|
||||
}
|
||||
|
||||
float MAXSONAREZ::getDistance()
|
||||
float
|
||||
MAXSONAREZ::getDistance()
|
||||
{
|
||||
return inches() * 2.54;
|
||||
return inches() * 2.54;
|
||||
}
|
||||
|
@ -24,16 +24,17 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "ultrasonic.hpp"
|
||||
|
||||
using namespace upm;
|
||||
|
||||
UltraSonic::UltraSonic (int pin) {
|
||||
UltraSonic::UltraSonic(int pin)
|
||||
{
|
||||
m_name = "UltraSonic";
|
||||
|
||||
mraa_init();
|
||||
@ -41,23 +42,23 @@ UltraSonic::UltraSonic (int pin) {
|
||||
// setup pin
|
||||
m_pinCtx = mraa_gpio_init(pin);
|
||||
if (m_pinCtx == NULL) {
|
||||
fprintf (stderr, "Are you sure that pin%d you requested is valid on your platform?", pin);
|
||||
exit (1);
|
||||
fprintf(stderr, "Are you sure that pin%d you requested is valid on your platform?", pin);
|
||||
exit(1);
|
||||
}
|
||||
mraa_gpio_isr (m_pinCtx, MRAA_GPIO_EDGE_BOTH,
|
||||
&signalISR, this);
|
||||
}
|
||||
|
||||
UltraSonic::~UltraSonic () {
|
||||
|
||||
UltraSonic::~UltraSonic()
|
||||
{
|
||||
// close pin
|
||||
mraa_gpio_isr_exit(m_pinCtx);
|
||||
mraa_gpio_close (m_pinCtx);
|
||||
mraa_gpio_close(m_pinCtx);
|
||||
}
|
||||
|
||||
float
|
||||
UltraSonic::getDistance () {
|
||||
|
||||
UltraSonic::getDistance()
|
||||
{
|
||||
// output trigger signal
|
||||
mraa_gpio_dir(m_pinCtx, MRAA_GPIO_OUT);
|
||||
mraa_gpio_write(m_pinCtx, LOW);
|
||||
@ -86,13 +87,15 @@ UltraSonic::getDistance () {
|
||||
}
|
||||
|
||||
void
|
||||
UltraSonic::signalISR(void *ctx) {
|
||||
upm::UltraSonic *This = (upm::UltraSonic *)ctx;
|
||||
UltraSonic::signalISR(void* ctx)
|
||||
{
|
||||
upm::UltraSonic* This = (upm::UltraSonic*) ctx;
|
||||
This->ackEdgeDetected();
|
||||
}
|
||||
|
||||
void
|
||||
UltraSonic::ackEdgeDetected () {
|
||||
UltraSonic::ackEdgeDetected()
|
||||
{
|
||||
if (++m_InterruptCounter % 2 == 0) {
|
||||
gettimeofday(&m_FallingTimeStamp, NULL);
|
||||
m_doWork = false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user