upm/examples/c++/ina132.cxx

50 lines
907 B
C++
Raw Normal View History

/*
* Author: Zion Orent <zorent@ics.com>
* Copyright (c) 2015 Intel Corporation.
*
* This program and the accompanying materials are made available under the
* terms of the The MIT License which is available at
* https://opensource.org/licenses/MIT.
*
* SPDX-License-Identifier: MIT
*/
#include <iostream>
#include <signal.h>
#include "ina132.hpp"
#include "upm_utilities.h"
using namespace std;
bool shouldRun = true;
void
sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int
main()
{
signal(SIGINT, sig_handler);
//! [Interesting]
// The was tested with the INA132 Differential Amplifier Sensor module.
// Instantiate an INA132 on analog pin A0
upm::INA132 amplifier(0);
while (shouldRun) {
cout << amplifier.value() << endl;
upm_delay(1);
}
//! [Interesting]
cout << "Exiting" << endl;
return 0;
}