Modify servo_sample() to accept integer values.
Current date stored in nanoseconds doesn't fit in 64-bit double format. Keep the offset and the time stamp in integer nanoseconds. Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>master
parent
8a23bf1d66
commit
ab29608e0b
8
pi.c
8
pi.c
|
@ -38,8 +38,8 @@ double configured_pi_offset = 0.0;
|
||||||
|
|
||||||
struct pi_servo {
|
struct pi_servo {
|
||||||
struct servo servo;
|
struct servo servo;
|
||||||
double offset[2];
|
int64_t offset[2];
|
||||||
double local[2];
|
uint64_t local[2];
|
||||||
double drift;
|
double drift;
|
||||||
double maxppb;
|
double maxppb;
|
||||||
double kp;
|
double kp;
|
||||||
|
@ -55,8 +55,8 @@ static void pi_destroy(struct servo *servo)
|
||||||
}
|
}
|
||||||
|
|
||||||
static double pi_sample(struct servo *servo,
|
static double pi_sample(struct servo *servo,
|
||||||
double offset,
|
int64_t offset,
|
||||||
double local_ts,
|
uint64_t local_ts,
|
||||||
enum servo_state *state)
|
enum servo_state *state)
|
||||||
{
|
{
|
||||||
double ki_term, ppb = 0.0;
|
double ki_term, ppb = 0.0;
|
||||||
|
|
4
servo.c
4
servo.c
|
@ -35,8 +35,8 @@ void servo_destroy(struct servo *servo)
|
||||||
}
|
}
|
||||||
|
|
||||||
double servo_sample(struct servo *servo,
|
double servo_sample(struct servo *servo,
|
||||||
double offset,
|
int64_t offset,
|
||||||
double local_ts,
|
uint64_t local_ts,
|
||||||
enum servo_state *state)
|
enum servo_state *state)
|
||||||
{
|
{
|
||||||
return servo->sample(servo, offset, local_ts, state);
|
return servo->sample(servo, offset, local_ts, state);
|
||||||
|
|
6
servo.h
6
servo.h
|
@ -20,6 +20,8 @@
|
||||||
#ifndef HAVE_SERVO_H
|
#ifndef HAVE_SERVO_H
|
||||||
#define HAVE_SERVO_H
|
#define HAVE_SERVO_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
/** Opaque type */
|
/** Opaque type */
|
||||||
struct servo;
|
struct servo;
|
||||||
|
|
||||||
|
@ -80,8 +82,8 @@ void servo_destroy(struct servo *servo);
|
||||||
* @return The clock adjustment in parts per billion.
|
* @return The clock adjustment in parts per billion.
|
||||||
*/
|
*/
|
||||||
double servo_sample(struct servo *servo,
|
double servo_sample(struct servo *servo,
|
||||||
double offset,
|
int64_t offset,
|
||||||
double local_ts,
|
uint64_t local_ts,
|
||||||
enum servo_state *state);
|
enum servo_state *state);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -26,7 +26,7 @@ struct servo {
|
||||||
void (*destroy)(struct servo *servo);
|
void (*destroy)(struct servo *servo);
|
||||||
|
|
||||||
double (*sample)(struct servo *servo,
|
double (*sample)(struct servo *servo,
|
||||||
double offset, double local_ts,
|
int64_t offset, uint64_t local_ts,
|
||||||
enum servo_state *state);
|
enum servo_state *state);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue