X10: Fix throttle source conversion from binary format
This commit is contained in:
committed by
Raphael Coeffic
parent
7ec9651304
commit
03cdc879b9
@@ -45,9 +45,11 @@
|
||||
#define STORAGE_NUM_MOUSE_ANALOGS 2
|
||||
|
||||
#if defined(PCBX10)
|
||||
#define NUM_POTS 5
|
||||
#define NUM_POTS 5
|
||||
#define NUM_SLIDERS 2
|
||||
#else
|
||||
#define NUM_POTS 3
|
||||
#define NUM_POTS 3
|
||||
#define NUM_SLIDERS 4
|
||||
#endif
|
||||
#define NUM_XPOTS NUM_POTS
|
||||
|
||||
@@ -110,6 +112,14 @@
|
||||
#error "Unsupported board"
|
||||
#endif
|
||||
|
||||
#if !defined(NUM_POTS)
|
||||
#define NUM_POTS STORAGE_NUM_POTS
|
||||
#endif
|
||||
|
||||
#if !defined(NUM_SLIDERS)
|
||||
#define NUM_SLIDERS STORAGE_NUM_SLIDERS
|
||||
#endif
|
||||
|
||||
#define STORAGE_NUM_SWITCHES_POSITIONS (STORAGE_NUM_SWITCHES * 3)
|
||||
|
||||
#define NUM_STICKS 4
|
||||
@@ -746,7 +756,7 @@ enum MixSources {
|
||||
MIXSRC_MOUSE2, LUA_EXPORT("jsy", "Joystick Y")
|
||||
#endif
|
||||
|
||||
#if defined(IMU)
|
||||
#if defined(PCBXLITES)
|
||||
MIXSRC_GYRO1, LUA_EXPORT("gyrx", "Gyro X")
|
||||
MIXSRC_GYRO2, LUA_EXPORT("gyry", "Gyro Y")
|
||||
#endif
|
||||
|
||||
@@ -1086,9 +1086,17 @@ bool w_logicSw(void* user, uint8_t* data, uint32_t bitoffs,
|
||||
|
||||
#define r_thrSrc nullptr
|
||||
|
||||
bool w_thrSrc(const YamlNode* node, uint32_t val, yaml_writer_func wf, void* opaque)
|
||||
int16_t throttleSource2Source_v220(int16_t thrSrc)
|
||||
{
|
||||
auto src = throttleSource2Source(val);
|
||||
if (thrSrc == 0) return (int16_t)MIXSRC_Thr;
|
||||
if (--thrSrc < NUM_POTS + NUM_SLIDERS)
|
||||
return (int16_t)(thrSrc + MIXSRC_FIRST_POT);
|
||||
return (int16_t)(thrSrc - (NUM_POTS + NUM_SLIDERS) + MIXSRC_FIRST_CH);
|
||||
}
|
||||
|
||||
static bool w_thrSrc(const YamlNode* node, uint32_t val, yaml_writer_func wf, void* opaque)
|
||||
{
|
||||
auto src = throttleSource2Source_v220(val);
|
||||
return w_mixSrcRaw(nullptr, src, wf, opaque);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -363,7 +363,7 @@ TEST(Conversions, ConversionX10From23)
|
||||
EXPECT_STRNEQ("Tes", g_model.telemetrySensors[0].label);
|
||||
EXPECT_EQ(10, g_model.telemetrySensors[0].id);
|
||||
EXPECT_EQ(9, g_model.telemetrySensors[0].frskyInstance.physID);
|
||||
EXPECT_EQ((NUM_POTS + NUM_SLIDERS + 3), g_model.thrTraceSrc); // CH3
|
||||
EXPECT_EQ(source2ThrottleSource(MIXSRC_CH3), g_model.thrTraceSrc); // CH3
|
||||
|
||||
simuFatfsSetPaths("","");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user