feat: implement Haptika PPG and Watch V1
This commit is contained in:
Generated
+112
@@ -0,0 +1,112 @@
|
||||
///
|
||||
/// NativePPGConfiguration.hpp
|
||||
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
||||
/// https://github.com/mrousavy/nitro
|
||||
/// Copyright © Marc Rousavy @ Margelo
|
||||
///
|
||||
|
||||
#pragma once
|
||||
|
||||
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
||||
#include <NitroModules/JSIConverter.hpp>
|
||||
#else
|
||||
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
||||
#endif
|
||||
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
||||
#include <NitroModules/NitroDefines.hpp>
|
||||
#else
|
||||
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
||||
#endif
|
||||
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
||||
#include <NitroModules/JSIHelpers.hpp>
|
||||
#else
|
||||
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
||||
#endif
|
||||
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
|
||||
#include <NitroModules/PropNameIDCache.hpp>
|
||||
#else
|
||||
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
||||
#endif
|
||||
|
||||
// Forward declaration of `PPGSessionPurpose` to properly resolve imports.
|
||||
namespace margelo::nitro::haptika::ppg { enum class PPGSessionPurpose; }
|
||||
|
||||
#include "PPGSessionPurpose.hpp"
|
||||
|
||||
namespace margelo::nitro::haptika::ppg {
|
||||
|
||||
/**
|
||||
* A struct which can be represented as a JavaScript object (NativePPGConfiguration).
|
||||
*/
|
||||
struct NativePPGConfiguration final {
|
||||
public:
|
||||
PPGSessionPurpose sessionPurpose SWIFT_PRIVATE;
|
||||
double targetSampleRate SWIFT_PRIVATE;
|
||||
double minimumFrequencyHz SWIFT_PRIVATE;
|
||||
double maximumFrequencyHz SWIFT_PRIVATE;
|
||||
double stabilizationSeconds SWIFT_PRIVATE;
|
||||
double measurementSeconds SWIFT_PRIVATE;
|
||||
double emitEveryFrames SWIFT_PRIVATE;
|
||||
double minimumContactConfidence SWIFT_PRIVATE;
|
||||
|
||||
public:
|
||||
NativePPGConfiguration() = default;
|
||||
explicit NativePPGConfiguration(PPGSessionPurpose sessionPurpose, double targetSampleRate, double minimumFrequencyHz, double maximumFrequencyHz, double stabilizationSeconds, double measurementSeconds, double emitEveryFrames, double minimumContactConfidence): sessionPurpose(sessionPurpose), targetSampleRate(targetSampleRate), minimumFrequencyHz(minimumFrequencyHz), maximumFrequencyHz(maximumFrequencyHz), stabilizationSeconds(stabilizationSeconds), measurementSeconds(measurementSeconds), emitEveryFrames(emitEveryFrames), minimumContactConfidence(minimumContactConfidence) {}
|
||||
|
||||
public:
|
||||
friend bool operator==(const NativePPGConfiguration& lhs, const NativePPGConfiguration& rhs) = default;
|
||||
};
|
||||
|
||||
} // namespace margelo::nitro::haptika::ppg
|
||||
|
||||
namespace margelo::nitro {
|
||||
|
||||
// C++ NativePPGConfiguration <> JS NativePPGConfiguration (object)
|
||||
template <>
|
||||
struct JSIConverter<margelo::nitro::haptika::ppg::NativePPGConfiguration> final {
|
||||
static inline margelo::nitro::haptika::ppg::NativePPGConfiguration fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
||||
jsi::Object obj = arg.asObject(runtime);
|
||||
return margelo::nitro::haptika::ppg::NativePPGConfiguration(
|
||||
JSIConverter<margelo::nitro::haptika::ppg::PPGSessionPurpose>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "sessionPurpose"))),
|
||||
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "targetSampleRate"))),
|
||||
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "minimumFrequencyHz"))),
|
||||
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "maximumFrequencyHz"))),
|
||||
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "stabilizationSeconds"))),
|
||||
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "measurementSeconds"))),
|
||||
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "emitEveryFrames"))),
|
||||
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "minimumContactConfidence")))
|
||||
);
|
||||
}
|
||||
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::haptika::ppg::NativePPGConfiguration& arg) {
|
||||
jsi::Object obj(runtime);
|
||||
obj.setProperty(runtime, PropNameIDCache::get(runtime, "sessionPurpose"), JSIConverter<margelo::nitro::haptika::ppg::PPGSessionPurpose>::toJSI(runtime, arg.sessionPurpose));
|
||||
obj.setProperty(runtime, PropNameIDCache::get(runtime, "targetSampleRate"), JSIConverter<double>::toJSI(runtime, arg.targetSampleRate));
|
||||
obj.setProperty(runtime, PropNameIDCache::get(runtime, "minimumFrequencyHz"), JSIConverter<double>::toJSI(runtime, arg.minimumFrequencyHz));
|
||||
obj.setProperty(runtime, PropNameIDCache::get(runtime, "maximumFrequencyHz"), JSIConverter<double>::toJSI(runtime, arg.maximumFrequencyHz));
|
||||
obj.setProperty(runtime, PropNameIDCache::get(runtime, "stabilizationSeconds"), JSIConverter<double>::toJSI(runtime, arg.stabilizationSeconds));
|
||||
obj.setProperty(runtime, PropNameIDCache::get(runtime, "measurementSeconds"), JSIConverter<double>::toJSI(runtime, arg.measurementSeconds));
|
||||
obj.setProperty(runtime, PropNameIDCache::get(runtime, "emitEveryFrames"), JSIConverter<double>::toJSI(runtime, arg.emitEveryFrames));
|
||||
obj.setProperty(runtime, PropNameIDCache::get(runtime, "minimumContactConfidence"), JSIConverter<double>::toJSI(runtime, arg.minimumContactConfidence));
|
||||
return obj;
|
||||
}
|
||||
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
||||
if (!value.isObject()) {
|
||||
return false;
|
||||
}
|
||||
jsi::Object obj = value.getObject(runtime);
|
||||
if (!nitro::isPlainObject(runtime, obj)) {
|
||||
return false;
|
||||
}
|
||||
if (!JSIConverter<margelo::nitro::haptika::ppg::PPGSessionPurpose>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "sessionPurpose")))) return false;
|
||||
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "targetSampleRate")))) return false;
|
||||
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "minimumFrequencyHz")))) return false;
|
||||
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "maximumFrequencyHz")))) return false;
|
||||
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "stabilizationSeconds")))) return false;
|
||||
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "measurementSeconds")))) return false;
|
||||
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "emitEveryFrames")))) return false;
|
||||
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "minimumContactConfidence")))) return false;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace margelo::nitro
|
||||
Reference in New Issue
Block a user