1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-13 11:29:51 +03:00

Add custom mixer

This commit is contained in:
WismyYao 2022-09-01 16:42:35 +08:00
parent af189cf6d9
commit 3eda7d1a20
6 changed files with 97 additions and 52 deletions

View file

@ -1231,6 +1231,18 @@ void evalMixes(uint8_t tick10ms)
#endif
}
#if defined(PCBACAIR)
// A7 Custom mixing
// V1 = X1 / X2; (0 < V1 < 1)
uint16_t v1;
if (g_model.xValue[1] == 0) {
g_model.xValue[0] = 10;
g_model.xValue[1] = 50;
}
v1 = g_model.xValue[0] * 100 / g_model.xValue[1];
#endif
//========== LIMITS ===============
for (uint8_t i=0; i<MAX_OUTPUT_CHANNELS; i++) {
// chans[i] holds data from mixer. chans[i] = v*weight => 1024*256
@ -1248,6 +1260,15 @@ void evalMixes(uint8_t tick10ms)
int16_t value = applyLimits(i, q); // applyLimits will remove the 256 100% basis
#if defined(PCBACAIR)
// CH3 = V1 * CH1 + CH2 * (1 - V1)
if(i == 2)
value = (v1 * channelOutputs[0] + channelOutputs[1] * (100 - v1)) / 100;
// CH4 = V1 * CH2 + CH1 * (1 - V1)
else if (i == 3)
value = (v1 * channelOutputs[1] + channelOutputs[0] * (100 - v1)) / 100;
#endif
cli();
channelOutputs[i] = value; // copy consistent word to int-level
sei();