rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
openyge_params.c File Reference

SPDX-License-Identifier: MIT. More...

#include "openyge.h"
#include <string.h>

Functions

void openyge_params_reset (openyge_params_t *p)
 Clear the parameter cache.
void openyge_params_observe (openyge_params_t *p, uint16_t index, uint16_t value)
 Record one (index, value) pair from a telemetry frame.
void openyge_params_begin_writes (openyge_params_t *p)
 Mark writes outstanding, which withdraws the table until it is re-read.
void openyge_params_end_writes (openyge_params_t *p)
 Clear the outstanding-writes mark.
bool openyge_params_complete (const openyge_params_t *p)
 True once every index 0..count-1 has been seen and no write is pending.
bool openyge_params_get (const openyge_params_t *p, uint16_t index, uint16_t *out)
 Read one.
float openyge_params_progress (const openyge_params_t *p)
 0..1, for a progress bar.
bool openyge_motor_rpm (const openyge_params_t *p, uint32_t erpm, float *motor_rpm)
 Mechanical and head RPM (revolutions per minute) from eRPM (electrical RPM) and the gear train.
bool openyge_head_rpm (const openyge_params_t *p, uint32_t erpm, float *head_rpm)
 Head rpm from eRPM and the gear train.

Detailed Description

SPDX-License-Identifier: MIT.

Function Documentation

◆ openyge_head_rpm()

bool openyge_head_rpm ( const openyge_params_t * p,
uint32_t erpm,
float * head_rpm )

Head rpm from eRPM and the gear train.

Parameters
pCache with the pole count and both gear teeth counts.
erpmElectrical rpm.
head_rpmReceives the head rpm.
Returns
true when the value was written.

◆ openyge_motor_rpm()

bool openyge_motor_rpm ( const openyge_params_t * p,
uint32_t erpm,
float * motor_rpm )

Mechanical and head RPM (revolutions per minute) from eRPM (electrical RPM) and the gear train.

False unless the table is complete and the pole count is at least 2. Head speed needs the pinion and main gear teeth too; when either is zero the head figure is not written.

Parameters
pCache with the pole count.
erpmElectrical rpm.
motor_rpmReceives the motor rpm.
Returns
true when the value was written.

◆ openyge_params_begin_writes()

void openyge_params_begin_writes ( openyge_params_t * p)

Mark writes outstanding, which withdraws the table until it is re-read.

Parameters
pCache to update; NULL does nothing.

◆ openyge_params_complete()

bool openyge_params_complete ( const openyge_params_t * p)

True once every index 0..count-1 has been seen and no write is pending.

Parameters
pCache to test.
Returns
true when the whole table is in the cache.

◆ openyge_params_end_writes()

void openyge_params_end_writes ( openyge_params_t * p)

Clear the outstanding-writes mark.

Parameters
pCache to update; NULL does nothing.

◆ openyge_params_get()

bool openyge_params_get ( const openyge_params_t * p,
uint16_t index,
uint16_t * out )

Read one.

False unless the whole table is complete: a half-read table is not the ESC's settings.

Parameters
pCache to read.
indexParameter index, below the table count.
outReceives the value.
Returns
true when the value was read.

◆ openyge_params_observe()

void openyge_params_observe ( openyge_params_t * p,
uint16_t index,
uint16_t value )

Record one (index, value) pair from a telemetry frame.

Ignored while writes are outstanding: a frame already in flight from before a write carries the old value and would overwrite the new one.

Parameters
pCache to update.
indexParameter index, below OPENYGE_MAX_PARAMS; other values are ignored.
valueParameter value.

◆ openyge_params_progress()

float openyge_params_progress ( const openyge_params_t * p)

0..1, for a progress bar.

The table fills in about 1.6s at 20Hz and 32 parameters.

Parameters
pCache to read.
Returns
0..1; 0 while writes are pending, or while the count is 0 or above OPENYGE_MAX_PARAMS.

◆ openyge_params_reset()

void openyge_params_reset ( openyge_params_t * p)

Clear the parameter cache.

Parameters
pCache to clear; NULL does nothing.