ACwing FC firmware
STM32WB55: attitude IEKF, altitude Kalman filter, flight core, protocol v2
Loading...
Searching...
No Matches
params.c File Reference

Parameter table and rules (see params.h). More...

#include "params.h"
#include "proto_v2.h"
#include <math.h>
#include <string.h>
Include dependency graph for params.c:

Go to the source code of this file.

Functions

void params_defaults (void)
 RAM <- defaults (dirty until saved)
 
int params_index (uint16_t id)
 -1 if unknown
 
float param_get (int idx)
 lock-free read, any thread
 
static int in_range (int i, float v)
 
uint8_t params_set (uint16_t id, float v, uint8_t *reason)
 PARAM_SET rules: returns an ACK result (PV2_ACK_*) and sets *reason.
 
void params_load (const float *values, uint16_t n)
 flash image
 
void params_get_all (float *values)
 PARAM_COUNT values.
 
void params_mark_saved (void)
 saved <- RAM
 
uint8_t params_dirty (int idx)
 RAM != flash.
 
uint8_t params_visible (int idx, uint16_t sensors)
 listing: parameters whose sensor is missing are omitted
 
uint16_t params_visible_count (uint16_t sensors)
 
int params_visible_pos (int idx, uint16_t sensors)
 index in PARAM_LIST, -1 if hidden
 

Variables

const param_def_t g_param_def [PARAM_COUNT]
 
static volatile float s_val [PARAM_COUNT]
 
static float s_saved [PARAM_COUNT]
 

Detailed Description

Parameter table and rules (see params.h).

Definition in file params.c.

Function Documentation

◆ params_defaults()

void params_defaults ( void  )

RAM <- defaults (dirty until saved)

Definition at line 45 of file params.c.

References g_param_def, PARAM_COUNT, and s_val.

Referenced by app_task_boot(), local_cmd(), and params_load().

Here is the caller graph for this function:

◆ params_index()

int params_index ( uint16_t  id)

-1 if unknown

Definition at line 50 of file params.c.

References g_param_def, and PARAM_COUNT.

Referenced by cfg_params_get(), local_cmd(), and params_set().

Here is the caller graph for this function:

◆ param_get()

float param_get ( int  idx)

lock-free read, any thread

Definition at line 56 of file params.c.

References PARAM_COUNT, and s_val.

Referenced by send_param().

Here is the caller graph for this function:

◆ in_range()

static int in_range ( int  i,
float  v 
)
static

Definition at line 62 of file params.c.

References g_param_def, param_def_t::max, and param_def_t::min.

Referenced by params_load(), and params_set().

Here is the caller graph for this function:

◆ params_set()

uint8_t params_set ( uint16_t  id,
float  v,
uint8_t *  reason 
)

PARAM_SET rules: returns an ACK result (PV2_ACK_*) and sets *reason.

Definition at line 68 of file params.c.

References in_range(), P_BATT_CRIT, P_BATT_EMERG, P_BATT_WARN, params_index(), PV2_ACK_INVALID, PV2_ACK_OK, PV2_R_NONE, PV2_R_OUT_OF_RANGE, PV2_R_UNKNOWN_PARAM, and s_val.

Referenced by local_cmd().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ params_load()

void params_load ( const float *  values,
uint16_t  n 
)

flash image

out-of-range values -> default

Definition at line 84 of file params.c.

References param_def_t::def, g_param_def, in_range(), n, P_BATT_CRIT, P_BATT_EMERG, P_BATT_WARN, PARAM_COUNT, params_defaults(), and s_val.

Referenced by app_task_boot().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ params_get_all()

void params_get_all ( float *  values)

PARAM_COUNT values.

Definition at line 96 of file params.c.

References PARAM_COUNT, and s_val.

Referenced by save_image().

Here is the caller graph for this function:

◆ params_mark_saved()

void params_mark_saved ( void  )

saved <- RAM

Definition at line 101 of file params.c.

References PARAM_COUNT, s_saved, and s_val.

Referenced by app_task_boot(), and local_cmd().

Here is the caller graph for this function:

◆ params_dirty()

uint8_t params_dirty ( int  idx)

RAM != flash.

Definition at line 106 of file params.c.

References PARAM_COUNT, s_saved, and s_val.

Referenced by send_param().

Here is the caller graph for this function:

◆ params_visible()

uint8_t params_visible ( int  idx,
uint16_t  sensors 
)

listing: parameters whose sensor is missing are omitted

Definition at line 112 of file params.c.

References g_param_def, param_def_t::needs, and PARAM_COUNT.

Referenced by list_pace(), local_cmd(), params_visible_count(), and params_visible_pos().

Here is the caller graph for this function:

◆ params_visible_count()

uint16_t params_visible_count ( uint16_t  sensors)

Definition at line 119 of file params.c.

References n, PARAM_COUNT, and params_visible().

Referenced by send_param().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ params_visible_pos()

int params_visible_pos ( int  idx,
uint16_t  sensors 
)

index in PARAM_LIST, -1 if hidden

Definition at line 126 of file params.c.

References params_visible(), and pos.

Referenced by send_param().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ g_param_def

const param_def_t g_param_def[PARAM_COUNT]
Initial value:
= {
[P_TAKEOFF_ALT] = { 1, 1.0f, 0.5f, 3.0f, 0 },
[P_LAND_SPEED] = { 2, 0.7f, 0.3f, 1.5f, 0 },
[P_AUTO_DISARM] = { 3, 2.0f, 1.0f, 10.0f, 0 },
[P_MAX_TILT] = { 4, 30.0f, 10.0f, 45.0f, 0 },
[P_MAX_YAW_RATE] = { 5, 120.0f, 30.0f, 360.0f, 0 },
[P_MAX_CLIMB] = { 6, 2.0f, 0.5f, 5.0f, 0 },
[P_MAX_HSPEED] = { 7, 8.0f, 1.0f, 15.0f, 0 },
[P_BEGINNER] = { 8, 0.0f, 0.0f, 1.0f, 0 },
[P_FS_APP_SHORT] = { 10, 0.0f, 0.0f, 1.0f, 0 },
[P_FS_APP_LONG] = { 11, 2.0f, 0.0f, 2.0f, 0 },
[P_FS_RADIO] = { 12, 2.0f, 0.0f, 2.0f, 0 },
[P_FS_GPS_LOST] = { 13, 0.0f, 0.0f, 2.0f, PV2_S_GNSS },
[P_FS_FLOW_LOST] = { 14, 0.0f, 0.0f, 1.0f, PV2_S_FLOW },
[P_BATT_WARN] = { 20, 3.6f, 3.3f, 3.9f, 0 },
[P_BATT_CRIT] = { 21, 3.5f, 3.2f, 3.8f, 0 },
[P_BATT_EMERG] = { 22, 3.3f, 3.0f, 3.6f, 0 },
[P_GF_MAX_ALT] = { 30, 30.0f, 5.0f, 120.0f, 0 },
[P_GF_CEILING] = { 31, 2.5f, 1.0f, 4.0f, PV2_S_TOF },
[P_GF_MAX_DIST] = { 32, 150.0f, 20.0f, 500.0f, PV2_S_GNSS },
[P_GF_ACTION] = { 33, 0.0f, 0.0f, 2.0f, 0 },
[P_RTH_ALT] = { 40, 30.0f, 5.0f, 60.0f, PV2_S_GNSS },
[P_RTH_STICK_CANCEL] = { 41, 1.0f, 0.0f, 1.0f, PV2_S_GNSS },
[P_ARM_REQUIRE_CHECKS] = { 50, 1.0f, 0.0f, 1.0f, 0 },
[P_COMPASS_PRIMARY] = { 60, 1.0f, 0.0f, 1.0f, PV2_S_MAG_GPS },
[P_BATT_CAPACITY] = { 23, 0.0f, 0.0f, 20000.0f, PV2_S_CURRENT },
[P_BATT_CELLS] = { 24, 0.0f, 0.0f, 6.0f, 0 },
[P_LOG_MODE] = { 70, 1.0f, 0.0f, 2.0f, PV2_S_FLASH_LOG },
}
@ P_LOG_MODE
Definition params.h:28
@ P_BATT_CELLS
Definition params.h:28
@ P_RTH_ALT
Definition params.h:24
@ P_BATT_WARN
Definition params.h:22
@ P_GF_MAX_DIST
Definition params.h:23
@ P_FS_GPS_LOST
Definition params.h:21
@ P_TAKEOFF_ALT
Definition params.h:19
@ P_FS_APP_LONG
Definition params.h:21
@ P_BATT_CAPACITY
Definition params.h:28
@ P_MAX_YAW_RATE
Definition params.h:19
@ P_GF_CEILING
Definition params.h:23
@ P_AUTO_DISARM
Definition params.h:19
@ P_LAND_SPEED
Definition params.h:19
@ P_BATT_EMERG
Definition params.h:22
@ P_FS_RADIO
Definition params.h:21
@ P_FS_APP_SHORT
Definition params.h:21
@ P_BATT_CRIT
Definition params.h:22
@ P_MAX_TILT
Definition params.h:19
@ P_MAX_HSPEED
Definition params.h:20
@ P_COMPASS_PRIMARY
Definition params.h:26
@ P_GF_MAX_ALT
Definition params.h:23
@ P_GF_ACTION
Definition params.h:23
@ P_RTH_STICK_CANCEL
Definition params.h:24
@ P_MAX_CLIMB
Definition params.h:19
@ P_ARM_REQUIRE_CHECKS
Definition params.h:25
@ P_BEGINNER
Definition params.h:20
@ P_FS_FLOW_LOST
Definition params.h:21
#define PV2_S_FLASH_LOG
Definition proto_v2.h:132
#define PV2_S_TOF
Definition proto_v2.h:127
#define PV2_S_FLOW
Definition proto_v2.h:126
#define PV2_S_GNSS
Definition proto_v2.h:125
#define PV2_S_CURRENT
Definition proto_v2.h:129
#define PV2_S_MAG_GPS
Definition proto_v2.h:124

Definition at line 11 of file params.c.

Referenced by cfg_load(), cfg_params_get(), cfg_params_put(), in_range(), params_defaults(), params_index(), params_load(), params_visible(), and send_param().

◆ s_val

volatile float s_val[PARAM_COUNT]
static

◆ s_saved

float s_saved[PARAM_COUNT]
static

Definition at line 43 of file params.c.

Referenced by params_dirty(), and params_mark_saved().