mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-21 14:03:11 -07:00
Add Orientation Tracker
This commit is contained in:
parent
88c03aa744
commit
32e1539c22
6 changed files with 182 additions and 8 deletions
|
@ -44,7 +44,7 @@ void sigint(int s)
|
|||
|
||||
#define BAR_LENGTH 100
|
||||
#define BAR_MAX 2.0f
|
||||
#define BAR_MAX_GYRO 180.0f
|
||||
#define BAR_MAX_GYRO M_PI
|
||||
|
||||
void print_state()
|
||||
{
|
||||
|
@ -69,7 +69,7 @@ void print_state()
|
|||
}
|
||||
bool cov = ((vals.v[b] < 0.0f) == (cur < 0.0f)) && fabsf(vals.v[b]) > fabsf(cur);
|
||||
float next = BAR_VAL(bi + 1);
|
||||
#define MARK_VAL (b > 2 ? 90.0f : 1.0f)
|
||||
#define MARK_VAL (b > 2 ? 0.5f * M_PI : 1.0f)
|
||||
bool mark = cur < -MARK_VAL && next >= -MARK_VAL || prev < MARK_VAL && cur >= MARK_VAL;
|
||||
buf[i++] = cov ? (mark ? '#' : '=') : (mark ? '.' : ' ');
|
||||
#undef BAR_VAL
|
||||
|
|
|
@ -80,7 +80,7 @@ typedef struct setsu_event_t
|
|||
struct
|
||||
{
|
||||
float accel_x, accel_y, accel_z; // unit is 1G
|
||||
float gyro_x, gyro_y, gyro_z; // unit is deg/sec
|
||||
float gyro_x, gyro_y, gyro_z; // unit is rad/sec
|
||||
uint32_t timestamp; // microseconds
|
||||
} motion;
|
||||
};
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
@ -22,6 +23,8 @@
|
|||
#define SETSU_LOG(...) do {} while(0)
|
||||
#endif
|
||||
|
||||
#define DEG2RAD (2.0f * M_PI / 360.0f)
|
||||
|
||||
typedef struct setsu_avail_device_t
|
||||
{
|
||||
struct setsu_avail_device_t *next;
|
||||
|
@ -686,9 +689,9 @@ static void device_drain(Setsu *setsu, SetsuDevice *dev, SetsuEventCb cb, void *
|
|||
event.motion.accel_x = (float)dev->motion.accel_x / (float)dev->motion.accel_res_x;
|
||||
event.motion.accel_y = (float)dev->motion.accel_y / (float)dev->motion.accel_res_y;
|
||||
event.motion.accel_z = (float)dev->motion.accel_z / (float)dev->motion.accel_res_z;
|
||||
event.motion.gyro_x = (float)dev->motion.gyro_x / (float)dev->motion.gyro_res_x;
|
||||
event.motion.gyro_y = (float)dev->motion.gyro_y / (float)dev->motion.gyro_res_y;
|
||||
event.motion.gyro_z = (float)dev->motion.gyro_z / (float)dev->motion.gyro_res_z;
|
||||
event.motion.gyro_x = DEG2RAD * (float)dev->motion.gyro_x / (float)dev->motion.gyro_res_x;
|
||||
event.motion.gyro_y = DEG2RAD * (float)dev->motion.gyro_y / (float)dev->motion.gyro_res_y;
|
||||
event.motion.gyro_z = DEG2RAD * (float)dev->motion.gyro_z / (float)dev->motion.gyro_res_z;
|
||||
event.motion.timestamp = dev->motion.timestamp;
|
||||
SEND_EVENT();
|
||||
dev->motion.dirty = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue