-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathBME280Class.cpp
49 lines (40 loc) · 1.08 KB
/
BME280Class.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "cfg.h"
#if USE_BME280
#include <Arduino.h>
#include <Adafruit_BME280.h>
#include "BME280Class.h"
#include <stdlib.h>
const char *nanpy::BME280Class::get_firmware_id()
{
return "BME280";
}
void nanpy::BME280Class::elaborate(MethodDescriptor *m)
{
ObjectsManager<Adafruit_BME280>::elaborate(m);
if (strcmp(m->getName(), "new") == 0)
{
Adafruit_BME280 *sensor = new Adafruit_BME280();
sensor->begin(m->getInt(0));
v.insert(sensor);
m->returns(v.getLastIndex());
}
// float get_temperature();
if (strcmp(m->getName(), "get_temperature") == 0)
{
float temperature = v[m->getObjectId()]->readTemperature();
m->returns(temperature);
}
// float get_pressure();
if (strcmp(m->getName(), "get_pressure") == 0)
{
float pressure = v[m->getObjectId()]->readPressure();
m->returns(pressure);
}
// float get_humidity();
if (strcmp(m->getName(), "get_humidity") == 0)
{
float humidity = v[m->getObjectId()]->readHumidity();
m->returns(humidity);
}
}
#endif