mirror of
https://github.com/opentx/opentx.git
synced 2025-07-25 17:25:13 +03:00
Spectrum analyser fixes
Compatibily issue when telemetry comes from int + ext modules
This commit is contained in:
parent
14c282110d
commit
d70f3a40ef
12 changed files with 13 additions and 39 deletions
|
@ -94,7 +94,10 @@ void menuModelModuleOptions(event_t event)
|
|||
});
|
||||
|
||||
if (reusableBuffer.hardwareAndSettings.moduleSettings.state == PXX2_HARDWARE_INFO && moduleState[g_moduleIdx].mode == MODULE_MODE_NORMAL) {
|
||||
moduleState[g_moduleIdx].readModuleSettings(&reusableBuffer.hardwareAndSettings.moduleSettings);
|
||||
if (modelId)
|
||||
moduleState[g_moduleIdx].readModuleSettings(&reusableBuffer.hardwareAndSettings.moduleSettings);
|
||||
else
|
||||
moduleState[g_moduleIdx].readModuleInformation(&reusableBuffer.hardwareAndSettings.modules[g_moduleIdx], PXX2_HW_INFO_TX_ID, PXX2_HW_INFO_TX_ID);
|
||||
}
|
||||
|
||||
if (menuEvent) {
|
||||
|
|
|
@ -1191,7 +1191,7 @@ void menuModelSetup(event_t event)
|
|||
if (bluetooth.distantAddr[0]) {
|
||||
lcdDrawText(INDENT_WIDTH, y+1, bluetooth.distantAddr, TINSIZE);
|
||||
lcdDrawText(MODEL_SETUP_2ND_COLUMN, y, BUTTON(TR_CLEAR), attr);
|
||||
if (attr && event == EVT_KEY_FIRST(KEY_ENTER)) {
|
||||
if (attr && event == EVT_KEY_BREAK(KEY_ENTER)) {
|
||||
bluetooth.state = BLUETOOTH_STATE_CLEAR_REQUESTED;
|
||||
memclear(bluetooth.distantAddr, sizeof(bluetooth.distantAddr));
|
||||
}
|
||||
|
@ -1202,8 +1202,7 @@ void menuModelSetup(event_t event)
|
|||
lcdDrawText(MODEL_SETUP_2ND_COLUMN, y, STR_BUTTON_INIT, attr);
|
||||
else
|
||||
lcdDrawText(MODEL_SETUP_2ND_COLUMN, y, STR_BUTTON_DISCOVER, attr);
|
||||
if (attr && event == EVT_KEY_FIRST(KEY_ENTER)) {
|
||||
killEvents(KEY_ENTER);
|
||||
if (attr && event == EVT_KEY_BREAK(KEY_ENTER)) {
|
||||
if (bluetooth.state < BLUETOOTH_STATE_IDLE) {
|
||||
bluetooth.state = BLUETOOTH_STATE_OFF;
|
||||
}
|
||||
|
|
|
@ -466,8 +466,7 @@ enum TelemetryProtocols
|
|||
PROTOCOL_TELEMETRY_SPEKTRUM,
|
||||
PROTOCOL_TELEMETRY_FLYSKY_IBUS,
|
||||
PROTOCOL_TELEMETRY_MULTIMODULE,
|
||||
PROTOCOL_TELEMETRY_LAST=PROTOCOL_TELEMETRY_MULTIMODULE,
|
||||
PROTOCOL_TELEMETRY_PXX2,
|
||||
PROTOCOL_TELEMETRY_LAST=PROTOCOL_TELEMETRY_MULTIMODULE
|
||||
};
|
||||
|
||||
enum DisplayTrims
|
||||
|
|
|
@ -1202,7 +1202,7 @@ union ReusableBuffer
|
|||
|
||||
struct
|
||||
{
|
||||
uint8_t bars[LCD_W];
|
||||
int8_t bars[LCD_W];
|
||||
uint32_t freq;
|
||||
uint32_t span;
|
||||
uint32_t step;
|
||||
|
|
|
@ -263,7 +263,7 @@ void setupPulsesInternalModule(uint8_t protocol)
|
|||
#if defined(PXX2)
|
||||
case PROTOCOL_CHANNELS_PXX2:
|
||||
intmodulePulsesData.pxx2.setupFrame(INTERNAL_MODULE);
|
||||
scheduleNextMixerCalculation(INTERNAL_MODULE, moduleState[INTERNAL_MODULE].mode == MODULE_MODE_SPECTRUM_ANALYSER || moduleState[INTERNAL_MODULE].mode == MODULE_MODE_POWER_METER ? 1 : PXX2_PERIOD);
|
||||
scheduleNextMixerCalculation(INTERNAL_MODULE, moduleState[INTERNAL_MODULE].mode == MODULE_MODE_SPECTRUM_ANALYSER || moduleState[INTERNAL_MODULE].mode == MODULE_MODE_POWER_METER ? PXX2_TOOLS_PERIOD : PXX2_PERIOD);
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#define PXX2_ON_SPORT_BAUDRATE 230400
|
||||
#define PXX2_PERIOD 4 // 4ms
|
||||
#define PXX2_TOOLS_PERIOD 1 // 1ms
|
||||
#define PXX2_FRAME_MAXLENGTH 64
|
||||
|
||||
#define PXX_PULSES_PERIOD 9/*ms*/
|
||||
|
|
|
@ -267,13 +267,6 @@ void Pxx2Pulses::setupResetFrame(uint8_t module)
|
|||
|
||||
void Pxx2Pulses::setupSpectrumAnalyser(uint8_t module)
|
||||
{
|
||||
if (moduleState[module].counter > 1000) {
|
||||
moduleState[module].counter = 1002;
|
||||
return;
|
||||
}
|
||||
|
||||
moduleState[module].counter = 1002;
|
||||
|
||||
addFrameType(PXX2_TYPE_C_POWER_METER, PXX2_TYPE_ID_SPECTRUM);
|
||||
Pxx2Transport::addByte(0x00);
|
||||
Pxx2Transport::addWord(reusableBuffer.spectrumAnalyser.freq);
|
||||
|
@ -283,16 +276,8 @@ void Pxx2Pulses::setupSpectrumAnalyser(uint8_t module)
|
|||
|
||||
void Pxx2Pulses::setupPowerMeter(uint8_t module)
|
||||
{
|
||||
if (moduleState[module].counter > 1000) {
|
||||
moduleState[module].counter = 1002;
|
||||
return;
|
||||
}
|
||||
|
||||
moduleState[module].counter = 1002;
|
||||
|
||||
addFrameType(PXX2_TYPE_C_POWER_METER, PXX2_TYPE_ID_POWER_METER);
|
||||
Pxx2Transport::addByte(0x00);
|
||||
|
||||
Pxx2Transport::addWord(reusableBuffer.powerMeter.freq);
|
||||
}
|
||||
|
||||
|
|
|
@ -127,7 +127,7 @@ extern "C" void TELEMETRY_DMA_TX_IRQHandler(void)
|
|||
if (DMA_GetITStatus(TELEMETRY_DMA_Stream_TX, TELEMETRY_DMA_TX_FLAG_TC)) {
|
||||
DMA_ClearITPendingBit(TELEMETRY_DMA_Stream_TX, TELEMETRY_DMA_TX_FLAG_TC);
|
||||
TELEMETRY_USART->CR1 |= USART_CR1_TCIE;
|
||||
if (telemetryProtocol == PROTOCOL_TELEMETRY_FRSKY_SPORT || telemetryProtocol == PROTOCOL_TELEMETRY_PXX2) {
|
||||
if (telemetryProtocol == PROTOCOL_TELEMETRY_FRSKY_SPORT) {
|
||||
outputTelemetryBuffer.reset();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -218,7 +218,7 @@ void processSpectrumAnalyserFrame(uint8_t module, uint8_t * frame)
|
|||
// TRACE("Fq=%u, Pw=%d, X=%d, Y=%d", *frequency, int32_t(*power), D * 128 / 40000000, int32_t(127 + *power));
|
||||
|
||||
int32_t position = *frequency - (reusableBuffer.spectrumAnalyser.freq - reusableBuffer.spectrumAnalyser.span / 2);
|
||||
int32_t x = (position * LCD_W / 8) / (reusableBuffer.spectrumAnalyser.span / 8);
|
||||
uint32_t x = (position * LCD_W / 8) / (reusableBuffer.spectrumAnalyser.span / 8);
|
||||
if (x < LCD_W) {
|
||||
reusableBuffer.spectrumAnalyser.bars[x] = 127 + *power;
|
||||
}
|
||||
|
|
|
@ -170,7 +170,7 @@ void sportProcessTelemetryPacketWithoutCrc(uint8_t origin, const uint8_t * packe
|
|||
data = SPORT_DATA_U8(packet);
|
||||
if (g_model.rssiSource) {
|
||||
TelemetrySensor * sensor = & g_model.telemetrySensors[g_model.rssiSource];
|
||||
if (sensor->instance == instance) {
|
||||
if (sensor->isSameInstance(TELEM_PROTO_FRSKY_SPORT, instance)) {
|
||||
telemetryData.rssi.set(data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -292,12 +292,6 @@ void telemetryInit(uint8_t protocol)
|
|||
}
|
||||
#endif
|
||||
|
||||
else if (protocol == PROTOCOL_TELEMETRY_PXX2) {
|
||||
telemetryPortInit(PXX2_ON_SPORT_BAUDRATE, TELEMETRY_SERIAL_WITHOUT_DMA);
|
||||
#if defined(LUA)
|
||||
outputTelemetryBuffer.reset();
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
telemetryPortInit(FRSKY_SPORT_BAUDRATE, TELEMETRY_SERIAL_WITHOUT_DMA);
|
||||
#if defined(LUA)
|
||||
|
|
|
@ -126,13 +126,6 @@ inline uint8_t modelTelemetryProtocol()
|
|||
return g_model.telemetryProtocol;
|
||||
}
|
||||
|
||||
if (!IS_INTERNAL_MODULE_ENABLED() && isModulePXX2(EXTERNAL_MODULE)) {
|
||||
return PROTOCOL_TELEMETRY_PXX2;
|
||||
}
|
||||
|
||||
if (!IS_INTERNAL_MODULE_ENABLED() && isModulePXX(EXTERNAL_MODULE)) {
|
||||
return PROTOCOL_TELEMETRY_FRSKY_SPORT;
|
||||
}
|
||||
#if defined(MULTIMODULE)
|
||||
if (!IS_INTERNAL_MODULE_ENABLED() && g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_MULTIMODULE) {
|
||||
return PROTOCOL_TELEMETRY_MULTIMODULE;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue