Added initial interfaces and some sensors implementing them

This commit is contained in:
Mihai Stefanescu
2018-06-12 18:46:49 +03:00
committed by Serban Waltter
parent 85608a9f61
commit e7820f2831
102 changed files with 1183 additions and 182 deletions

View File

@ -0,0 +1,31 @@
#include <iostream>
#include <list>
#include "apds9002.hpp"
#include "bh1750.hpp"
#include "max44009.hpp"
using namespace std;
using namespace upm;
int
main()
{
list<iLight*> lightSensors;
// Populate list of light sensors
lightSensors.push_back(new APDS9002(0));
lightSensors.push_back(new BH1750());
lightSensors.push_back(new MAX44009(1));
// Measure luminance level from all 3 individual sensors
for (auto& sensor : lightSensors) {
sensor->getLuminance();
}
for (auto& sensor : lightSensors) {
delete sensor;
}
return 0;
}

View File

@ -0,0 +1,26 @@
#include <iostream>
#include <vector>
#include "lm35.hpp"
#include "abp.hpp"
using namespace std;
using namespace upm;
int
main()
{
vector<iTemperature*> tempSensors {new LM35(0), new ABP(0, ABP_DEFAULT_ADDRESS)};
for (auto& sensor : tempSensors) {
float celsiusTemp = sensor->getTemperature();
cout << "Temperature in Celsius degrees: " << celsiusTemp << endl;
cout << "Temperature in Kelvin: " << iTemperature::convertCelsiusTo(celsiusTemp, TemperatureUnit::KELVIN);
}
for (auto& sensor : tempSensors) {
delete sensor;
}
return 0;
}

View File

@ -62,7 +62,7 @@ getLightSensor()
int
main()
{
upm::ILightSensor* lightSensor = getLightSensor();
/*upm::ILightSensor* lightSensor = getLightSensor();
if (lightSensor == NULL) {
std::cout << "Light sensor not detected" << std::endl;
return 1;
@ -77,7 +77,7 @@ main()
}
upm_delay(1);
}
delete lightSensor;
delete lightSensor;*/
return 0;
}

View File

@ -48,12 +48,12 @@ main()
// Instantiate a LM35 on analog pin A0, with a default analog
// reference voltage of 5.0
upm::LM35 sensor(0);
upm::iTemperature* sensor = new upm::LM35(0);
// Every half second, sample the sensor and output the temperature
while (shouldRun) {
cout << "Temperature: " << sensor.getTemperature() << " C" << endl;
cout << "Temperature: " << sensor->getTemperature() << " C" << endl;
upm_delay_us(500000);
}
@ -61,6 +61,7 @@ main()
//! [Interesting]
cout << "Exiting" << endl;
delete sensor;
return 0;
}