accel: Add per-axis accel scale helpers
This commit is contained in:
@@ -30,8 +30,10 @@ iio_sensor_proxy_SOURCES = \
|
||||
iio-buffer-utils.c \
|
||||
accel-mount-matrix.h \
|
||||
accel-mount-matrix.c \
|
||||
accel-attributes.h \
|
||||
accel-attributes.c \
|
||||
accel-attributes.h \
|
||||
accel-attributes.c \
|
||||
accel-scale.h \
|
||||
accel-scale.c \
|
||||
$(BUILT_SOURCES)
|
||||
|
||||
iio_sensor_proxy_CPPFLAGS = \
|
||||
|
39
src/accel-scale.c
Normal file
39
src/accel-scale.c
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2020 Bastien Nocera <hadess@hadess.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 3 as published by
|
||||
* the Free Software Foundation.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "accel-scale.h"
|
||||
|
||||
void
|
||||
reset_accel_scale (AccelScale *scale)
|
||||
{
|
||||
set_accel_scale (scale, 1.0);
|
||||
}
|
||||
|
||||
void
|
||||
set_accel_scale (AccelScale *scale,
|
||||
double value)
|
||||
{
|
||||
g_return_if_fail (scale != NULL);
|
||||
g_return_if_fail (value != 0.0);
|
||||
|
||||
scale->x = scale->y = scale->z = value;
|
||||
}
|
||||
|
||||
void
|
||||
copy_accel_scale (AccelScale *target,
|
||||
AccelScale source)
|
||||
{
|
||||
g_return_if_fail (target != NULL);
|
||||
|
||||
target->x = source.x;
|
||||
target->y = source.y;
|
||||
target->z = source.z;
|
||||
}
|
20
src/accel-scale.h
Normal file
20
src/accel-scale.h
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright (c) 2020 Bastien Nocera <hadess@hadess.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 3 as published by
|
||||
* the Free Software Foundation.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef struct {
|
||||
double x;
|
||||
double y;
|
||||
double z;
|
||||
} AccelScale;
|
||||
|
||||
void reset_accel_scale (AccelScale *scale);
|
||||
void set_accel_scale (AccelScale *scale, double value);
|
||||
void copy_accel_scale (AccelScale *target, AccelScale source);
|
Reference in New Issue
Block a user