Calibration use dynamic analogs array
This commit is contained in:
committed by
Raphael Coeffic
parent
8fd3e0d5c8
commit
f33d5c005e
@@ -20,30 +20,6 @@
|
|||||||
|
|
||||||
#include "yaml_calibdata.h"
|
#include "yaml_calibdata.h"
|
||||||
|
|
||||||
// TODO: we need a function that
|
|
||||||
// does the opposite of Boards::getAnalogInputName()
|
|
||||||
//
|
|
||||||
// This is only valid for X10, T16, TX16S (not X12S)
|
|
||||||
//
|
|
||||||
static const YamlLookupTable calibIdxLut = {
|
|
||||||
{ 0, "Rud" },
|
|
||||||
{ 1, "Ele" },
|
|
||||||
{ 2, "Thr" },
|
|
||||||
{ 3, "Ail" },
|
|
||||||
{ 4, "S1" },
|
|
||||||
{ 5, "6POS" },
|
|
||||||
{ 6, "S2" },
|
|
||||||
{ 7, "EXT1" },
|
|
||||||
{ 8, "EXT2" },
|
|
||||||
// not yet supported in Companion:
|
|
||||||
// { 9, "EXT3" },
|
|
||||||
// { 10, "EXT4" },
|
|
||||||
{ 9, "LS" },
|
|
||||||
{ 10, "RS" },
|
|
||||||
{ 11, "MOUSE1" },
|
|
||||||
{ 12, "MOUSE2" },
|
|
||||||
};
|
|
||||||
|
|
||||||
YamlCalibData::YamlCalibData() { memset(calib, 0, sizeof(calib)); }
|
YamlCalibData::YamlCalibData() { memset(calib, 0, sizeof(calib)); }
|
||||||
|
|
||||||
YamlCalibData::YamlCalibData(const int* calibMid, const int* calibSpanNeg,
|
YamlCalibData::YamlCalibData(const int* calibMid, const int* calibSpanNeg,
|
||||||
@@ -90,6 +66,8 @@ bool convert<CalibData>::decode(const Node& node, CalibData& rhs)
|
|||||||
Node convert<YamlCalibData>::encode(const YamlCalibData& rhs)
|
Node convert<YamlCalibData>::encode(const YamlCalibData& rhs)
|
||||||
{
|
{
|
||||||
Node node;
|
Node node;
|
||||||
|
// TODO: for efficiency construct once at an outer level possibly add to Firmware?
|
||||||
|
const YamlLookupTable calibIdxLut = Boards::getAnalogNamesLookupTable(getCurrentBoard());
|
||||||
// TODO: we need something better here!
|
// TODO: we need something better here!
|
||||||
for (const auto& kv : calibIdxLut) {
|
for (const auto& kv : calibIdxLut) {
|
||||||
node[kv.second] = rhs.calib[kv.first];
|
node[kv.second] = rhs.calib[kv.first];
|
||||||
@@ -100,6 +78,8 @@ Node convert<YamlCalibData>::encode(const YamlCalibData& rhs)
|
|||||||
bool convert<YamlCalibData>::decode(const Node& node, YamlCalibData& rhs)
|
bool convert<YamlCalibData>::decode(const Node& node, YamlCalibData& rhs)
|
||||||
{
|
{
|
||||||
if (!node.IsMap()) return false;
|
if (!node.IsMap()) return false;
|
||||||
|
// TODO: for efficiency construct once at an outer level possibly add to Firmware?
|
||||||
|
const YamlLookupTable calibIdxLut = Boards::getAnalogNamesLookupTable(getCurrentBoard());
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
for (const auto& kv : node) {
|
for (const auto& kv : node) {
|
||||||
kv.first >> calibIdxLut >> idx;
|
kv.first >> calibIdxLut >> idx;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "yaml_ops.h"
|
#include "yaml_ops.h"
|
||||||
#include "generalsettings.h"
|
#include "generalsettings.h"
|
||||||
|
#include "eeprominterface.h"
|
||||||
|
|
||||||
struct CalibData {
|
struct CalibData {
|
||||||
int16_t mid;
|
int16_t mid;
|
||||||
|
|||||||
Reference in New Issue
Block a user