aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJustin Berger <j.david.berger@gmail.com>2018-03-16 10:39:26 -0600
committerJustin Berger <j.david.berger@gmail.com>2018-03-16 10:39:26 -0600
commite5cc00096e7b0700c75160c62f598a8af412c082 (patch)
treeea341f6bf2af0609d888c5910a15e323cd24be73 /include
parentfc575131ccf05c605ba567b95851976fad7c5444 (diff)
downloadlibsurvive-e5cc00096e7b0700c75160c62f598a8af412c082.tar.gz
libsurvive-e5cc00096e7b0700c75160c62f598a8af412c082.tar.bz2
Refactored how the persistence (now called sensor_activations) worked
Diffstat (limited to 'include')
-rw-r--r--include/libsurvive/poser.h3
-rw-r--r--include/libsurvive/survive.h34
-rw-r--r--include/libsurvive/survive_types.h2
3 files changed, 35 insertions, 4 deletions
diff --git a/include/libsurvive/poser.h b/include/libsurvive/poser.h
index eb0de3b..6c74c52 100644
--- a/include/libsurvive/poser.h
+++ b/include/libsurvive/poser.h
@@ -41,8 +41,7 @@ typedef struct
uint32_t timecode; //In object-local ticks.
} PoserDataIMU;
-typedef struct
-{
+typedef struct PoserDataLight {
PoserData hdr;
int sensor_id;
int acode; //OOTX Code associated with this sweep. bit 1 indicates vertical(1) or horizontal(0) sweep
diff --git a/include/libsurvive/survive.h b/include/libsurvive/survive.h
index 7a0ed1e..7a9ec64 100644
--- a/include/libsurvive/survive.h
+++ b/include/libsurvive/survive.h
@@ -1,14 +1,43 @@
#ifndef _SURVIVE_H
#define _SURVIVE_H
-#include <stdint.h>
-#include "survive_types.h"
#include "poser.h"
+#include "survive_types.h"
+#include <stdbool.h>
+#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
+/**
+ * This struct encodes what the last effective angles seen on a sensor were, and when they occured.
+ */
+typedef struct {
+ FLT angles[SENSORS_PER_OBJECT][NUM_LIGHTHOUSES][2]; // 2 Axes (Angles in LH space)
+ uint32_t timecode[SENSORS_PER_OBJECT][NUM_LIGHTHOUSES][2]; // Timecode per axis in ticks
+} SurviveSensorActivations;
+
+struct PoserDataLight;
+/**
+ * Adds a lightData packet to the table.
+ */
+void SurviveSensorActivations_add(SurviveSensorActivations *self, struct PoserDataLight *lightData);
+
+/**
+ * Returns true iff both angles for the given sensor and lighthouse were seen at most `tolerance` ticks before the given
+ * `timecode_now`.
+ */
+bool SurviveSensorActivations_isPairValid(const SurviveSensorActivations *self, uint32_t tolerance,
+ uint32_t timecode_now, uint32_t sensor_idx, int lh);
+
+/**
+ * Default tolerance that gives a somewhat accuate representation of current state.
+ *
+ * Don't rely on this to be a given value.
+ */
+extern uint32_t SurviveSensorActivations_default_tolerance;
+
//DANGER: This structure may be redefined. Note that it is logically split into 64-bit chunks
//for optimization on 32- and 64-bit systems.
@@ -70,6 +99,7 @@ struct SurviveObject
haptic_func haptic;
+ SurviveSensorActivations activations;
//Debug
int tsl;
};
diff --git a/include/libsurvive/survive_types.h b/include/libsurvive/survive_types.h
index ce0baac..3c7dc7f 100644
--- a/include/libsurvive/survive_types.h
+++ b/include/libsurvive/survive_types.h
@@ -1,6 +1,8 @@
#ifndef _SURVIVE_TYPES_H
#define _SURVIVE_TYPES_H
+#include "stdint.h"
+
#ifdef __cplusplus
extern "C" {
#endif