1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-19 14:25:11 +03:00

A3/A4 support

This commit is contained in:
bsongis 2014-05-23 11:08:41 +02:00
parent 4164481d0a
commit daf80cad83
5 changed files with 39 additions and 6 deletions

View file

@ -1218,19 +1218,29 @@ void putsTelemetryChannel(xcoord_t x, uint8_t y, uint8_t channel, lcdint_t val,
#if defined(FRSKY)
case TELEM_MIN_A1-1:
case TELEM_MIN_A2-1:
#if defined(CPUARM)
case TELEM_MIN_A3-1:
case TELEM_MIN_A4-1:
#endif
channel -= TELEM_MIN_A1-TELEM_A1;
// no break
case TELEM_A1-1:
case TELEM_A2-1:
#if defined(CPUARM)
case TELEM_A3-1:
case TELEM_A4-1:
#endif
channel -= TELEM_A1-1;
// A1 and A2
{
lcdint_t converted_value = applyChannelRatio(channel, val);
if (g_model.frsky.channels[channel].type >= UNIT_RAW) {
if (ANA_CHANNEL_UNIT(channel) >= UNIT_RAW) {
converted_value = div10_and_round(converted_value);
}
else {
#if !defined(PCBTARANIS)
#if LCD_W >= 212
att |= PREC2;
#else
if (abs(converted_value) < 1000) {
att |= PREC2;
}
@ -1238,8 +1248,6 @@ void putsTelemetryChannel(xcoord_t x, uint8_t y, uint8_t channel, lcdint_t val,
converted_value = div10_and_round(converted_value);
att |= PREC1;
}
#else
att |= PREC2;
#endif
}
putsTelemetryValue(x, y, converted_value, g_model.frsky.channels[channel].type, att);

View file

@ -163,6 +163,11 @@ uint16_t getChannelRatio(uint8_t channel)
lcdint_t applyChannelRatio(uint8_t channel, lcdint_t val)
{
#if defined(CPUARM)
// A3 and A4 don't have ratio settings
if (channel > 1)
return val;
#endif
return ((int32_t)val+g_model.frsky.channels[channel].offset) * getChannelRatio(channel) * 2 / 51;
}
#endif

View file

@ -1614,20 +1614,28 @@ PLAY_FUNCTION(playValue, uint8_t idx)
break;
case MIXSRC_FIRST_TELEM+TELEM_MIN_A1-1:
case MIXSRC_FIRST_TELEM+TELEM_MIN_A2-1:
#if defined(CPUARM)
case MIXSRC_FIRST_TELEM+TELEM_MIN_A3-1:
case MIXSRC_FIRST_TELEM+TELEM_MIN_A4-1:
#endif
idx -= TELEM_MIN_A1-TELEM_A1;
// no break
case MIXSRC_FIRST_TELEM+TELEM_A1-1:
case MIXSRC_FIRST_TELEM+TELEM_A2-1:
#if defined(CPUARM)
case MIXSRC_FIRST_TELEM+TELEM_A3-1:
case MIXSRC_FIRST_TELEM+TELEM_A4-1:
#endif
// A1 and A2
idx -= (MIXSRC_FIRST_TELEM+TELEM_A1-1);
{
if (TELEMETRY_STREAMING()) {
uint8_t att = 0;
int16_t converted_value = div10_and_round(applyChannelRatio(idx, val));;
if (g_model.frsky.channels[idx].type < UNIT_RAW) {
if (ANA_CHANNEL_UNIT(idx) < UNIT_RAW) {
att = PREC1;
}
PLAY_NUMBER(converted_value, 1+g_model.frsky.channels[idx].type, att);
PLAY_NUMBER(converted_value, 1+ANA_CHANNEL_UNIT(idx), att);
}
break;
}

View file

@ -1572,6 +1572,12 @@ getvalue_t convertLswTelemValue(LogicalSwitchData * cs);
lcdint_t applyChannelRatio(uint8_t channel, lcdint_t val);
#endif
#if defined(CPUARM)
#define ANA_CHANNEL_UNIT(channel) (channel > 1 ? UNIT_VOLTS : g_model.frsky.channels[channel].type)
#else
#define ANA_CHANNEL_UNIT(channel) g_model.frsky.channels[channel].type
#endif
getvalue_t div10_and_round(getvalue_t value);

View file

@ -463,6 +463,12 @@ void frskySportProcessPacket(uint8_t *packet)
frskyData.hub.gpsFix = 0;
}
}
else if (appId >= A3_FIRST_ID && appId <= A3_LAST_ID) {
frskyData.analog[2].set(SPORT_DATA_U32(packet), 0);
}
else if (appId >= A4_FIRST_ID && appId <= A4_LAST_ID) {
frskyData.analog[3].set(SPORT_DATA_U32(packet), 0);
}
else if (appId >= CELLS_FIRST_ID && appId <= CELLS_LAST_ID) {
uint32_t cells = SPORT_DATA_U32(packet);
uint8_t battnumber = cells & 0xF;