-
Notifications
You must be signed in to change notification settings - Fork 0
/
Htu21dNode.h
executable file
·69 lines (47 loc) · 1.86 KB
/
Htu21dNode.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/**
* \file Htu21dNode.h
*
* Created by Scott Erholm on 6/17/16.
* Copyright (c) 2016 Agilatech. All rights reserved.
*/
#ifndef __HTU21D__Htu21dNode__
#define __HTU21D__Htu21dNode__
#include <node.h>
#include <node_object_wrap.h>
#include <uv.h>
#include <iostream>
#include <cmath>
#include <string>
#include <thread>
#include "Htu21dDrv.h"
namespace htu21d {
class Htu21dNode : public node::ObjectWrap {
public:
static void Init(v8::Local<v8::Object> exports);
static void getDeviceName(const v8::FunctionCallbackInfo<v8::Value>& args);
static void getDeviceType(const v8::FunctionCallbackInfo<v8::Value>& args);
static void getDeviceVersion(const v8::FunctionCallbackInfo<v8::Value>& args);
static void getDeviceNumValues (const v8::FunctionCallbackInfo<v8::Value>& args);
static void getTypeAtIndex (const v8::FunctionCallbackInfo<v8::Value>& args);
static void getNameAtIndex (const v8::FunctionCallbackInfo<v8::Value>& args);
static void isDeviceActive (const v8::FunctionCallbackInfo<v8::Value>& args);
static void getValueAtIndexSync (const v8::FunctionCallbackInfo<v8::Value>& args);
static void getValueAtIndex (const v8::FunctionCallbackInfo<v8::Value>& args);
private:
explicit Htu21dNode(std::string devfile = "/dev/i2c-1", uint32_t addr = 0x40) {}
~Htu21dNode() {}
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
static void WorkAsync(uv_work_t *req);
static void WorkAsyncComplete(uv_work_t *req,int status);
static v8::Persistent<v8::Function> constructor;
static Htu21dDrv *driver;
uint32_t bus_;
struct Work {
uv_work_t request;
v8::Persistent<v8::Function> callback;
int valueIndex;
std::string value;
};
};
} // namespace
#endif /* defined(__HTU21D__Htu21dNode__) */