-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathnodeimu.h
45 lines (30 loc) · 946 Bytes
/
nodeimu.h
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
#ifndef NODEIMU_H
#define NODEIMU_H
#include "RTIMULib.h"
#include <node.h>
#include <node_object_wrap.h>
#include <nan.h>
// tested on node 0.12.7 LSM9DS1 (IMU), LPS25H (pressure), HTS221 (humidity)
class NodeIMU : public Nan::ObjectWrap {
public:
static NAN_MODULE_INIT(Init) {
v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
tpl->SetClassName(Nan::New("IMU").ToLocalChecked());
tpl->InstanceTemplate()->SetInternalFieldCount(1);
Nan::SetPrototypeMethod(tpl, "getValue", GetValue);
Nan::SetPrototypeMethod(tpl, "getValueSync", GetValueSync);
Nan::Set(target, Nan::New("IMU").ToLocalChecked(),
Nan::GetFunction(tpl).ToLocalChecked());
}
private:
explicit NodeIMU();
~NodeIMU();
static NAN_METHOD(New);
static NAN_METHOD(GetValue);
static NAN_METHOD(GetValueSync);
RTIMU *imu;
RTIMUSettings *settings;
RTPressure *pressure;
RTHumidity *humidity;
};
#endif