mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-24 19:43:35 +08:00
parameters: merge generated files ito single static constexpr header
- store parameter type and if volatile separately (saves kilobytes of flash)
- use Bitset for tracking active and changed parameters
- use atomic for autosave_enabled flag
- compile at ${MAX_CUSTOM_OPT_LEVEL} (-O2 on non flash constrained boards)
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
{# jinja syntax: http://jinja.pocoo.org/docs/2.9/templates/ #}
|
||||
#include "px4_parameters.h"
|
||||
|
||||
// DO NOT EDIT
|
||||
// This file is autogenerated from paramaters.xml
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
const
|
||||
|
||||
struct px4_parameters_t px4_parameters = {
|
||||
{% for param in params %}
|
||||
{
|
||||
"{{ param.attrib["name"] }}",
|
||||
PARAM_TYPE_{{ param.attrib["type"] }},
|
||||
{%- if param.attrib["volatile"] == "true" %}
|
||||
.volatile_param = 1,
|
||||
{%- else %}
|
||||
.volatile_param = 0,
|
||||
{%- endif %}
|
||||
{%- if param.attrib["type"] == "FLOAT" %}
|
||||
.val.f = {{ param.attrib["default"] }}
|
||||
{%- elif param.attrib["type"] == "INT32" %}
|
||||
.val.i = {{ param.attrib["default"] }}
|
||||
{%- endif %}
|
||||
},
|
||||
{% endfor %}
|
||||
{{ params | length }}
|
||||
};
|
||||
|
||||
//extern const struct px4_parameters_t px4_parameters;
|
||||
|
||||
__END_DECLS
|
||||
|
||||
{# vim: set noet ft=jinja fenc=utf-8 ff=unix sts=4 sw=4 ts=4 : #}
|
||||
@@ -1,21 +0,0 @@
|
||||
{# jinja syntax: http://jinja.pocoo.org/docs/2.9/templates/ #}
|
||||
#include <stdint.h>
|
||||
#include <parameters/param.h>
|
||||
|
||||
// DO NOT EDIT
|
||||
// This file is autogenerated from parameters.xml
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
struct px4_parameters_t {
|
||||
{%- for param in params %}
|
||||
const struct param_info_s __param__{{ param.attrib["name"] }};
|
||||
{%- endfor %}
|
||||
const unsigned int param_count;
|
||||
};
|
||||
|
||||
extern const struct px4_parameters_t px4_parameters;
|
||||
|
||||
__END_DECLS
|
||||
|
||||
{# vim: set noet ft=jinja fenc=utf-8 ff=unix sts=4 sw=4 ts=4 : #}
|
||||
@@ -0,0 +1,49 @@
|
||||
{# jinja syntax: http://jinja.pocoo.org/docs/2.9/templates/ #}
|
||||
|
||||
#include <stdint.h>
|
||||
#include <parameters/param.h>
|
||||
|
||||
// DO NOT EDIT
|
||||
// This file is autogenerated from parameters.xml
|
||||
|
||||
namespace px4 { {# wrap the enum in a namespace, otherwise we get shadowing errors for MAV_TYPE #}
|
||||
|
||||
/// Enum with all parameters
|
||||
enum class params : uint16_t {
|
||||
{# enums are guaranteed to start with 0 (if the value for the first is not
|
||||
specified), and then incremented by 1 (the implementation depends on that!) #}
|
||||
{%- for param in params %}
|
||||
{{ param.attrib["name"] }},
|
||||
{%- endfor %}
|
||||
|
||||
};
|
||||
|
||||
static constexpr param_info_s parameters[] = {
|
||||
{% for param in params %}
|
||||
{
|
||||
"{{ param.attrib["name"] }}",
|
||||
{%- if param.attrib["type"] == "FLOAT" %}
|
||||
.val = {{ "{" }} .f = {{ param.attrib["default"] }} {{ "}" }},
|
||||
{%- elif param.attrib["type"] == "INT32" %}
|
||||
.val = {{ "{" }} .i = {{ param.attrib["default"] }}{{ "}" }},
|
||||
{%- endif %}
|
||||
},
|
||||
{% endfor %}
|
||||
};
|
||||
|
||||
static constexpr param_type_t parameters_type[] = {
|
||||
{% for param in params %}
|
||||
PARAM_TYPE_{{ param.attrib["type"] }},
|
||||
{%- endfor -%}
|
||||
};
|
||||
|
||||
static constexpr params parameters_volatile[] = {
|
||||
{% for param in params %}
|
||||
{%- if param.attrib["volatile"] == "true" %}
|
||||
params::{{ param.attrib["name"] }},
|
||||
{%- endif -%}
|
||||
{% endfor %}
|
||||
};
|
||||
|
||||
|
||||
} // namespace px4
|
||||
@@ -1,37 +0,0 @@
|
||||
{# jinja syntax: http://jinja.pocoo.org/docs/2.9/templates/ #}
|
||||
#include <stdint.h>
|
||||
#include <parameters/param.h>
|
||||
|
||||
// DO NOT EDIT
|
||||
// This file is autogenerated from parameters.xml
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace px4 { {# wrap the enum in a namespace, otherwise we get shadowing errors for MAV_TYPE #}
|
||||
|
||||
/// Enum with all parameters
|
||||
enum class params {
|
||||
{# enums are guaranteed to start with 0 (if the value for the first is not
|
||||
specified), and then incremented by 1 (the implementation depends on that!) #}
|
||||
{%- for param in params %}
|
||||
{{ param.attrib["name"] }},
|
||||
{%- endfor %}
|
||||
|
||||
_COUNT
|
||||
};
|
||||
|
||||
// All parameter types
|
||||
{# (px4_parameters is marked as extern, so we cannot use it as constexpr) #}
|
||||
static const constexpr int param_types_array[] = {
|
||||
{%- for param in params %}
|
||||
PARAM_TYPE_{{ param.attrib["type"] }}, // {{ param.attrib["name"] }}
|
||||
{%- endfor %}
|
||||
};
|
||||
|
||||
|
||||
} // namespace px4
|
||||
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
Reference in New Issue
Block a user