#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
