diff --git a/companion/src/firmwares/generalsettings.cpp b/companion/src/firmwares/generalsettings.cpp index 22934cf57..6cb9fdb9f 100644 --- a/companion/src/firmwares/generalsettings.cpp +++ b/companion/src/firmwares/generalsettings.cpp @@ -114,11 +114,13 @@ GeneralSettings::GeneralSettings() speakerVolume = 12; } - if (IS_HORUS(board)) { - strcpy(bluetoothName, "Horus"); + if (IS_JUMPER_T16(board)) + strcpy(bluetoothName, "t16"); + else if (IS_HORUS(board)) { + strcpy(bluetoothName, "horus"); } else if (IS_TARANIS_X9E(board) || IS_TARANIS_SMALL(board)) { - strcpy(bluetoothName, "Taranis"); + strcpy(bluetoothName, "taranis"); } templateSetup = g.profile[g.sessionId()].channelOrder(); diff --git a/companion/src/mdichild.cpp b/companion/src/mdichild.cpp index a5f25d1ca..c31697a9f 100644 --- a/companion/src/mdichild.cpp +++ b/companion/src/mdichild.cpp @@ -1536,7 +1536,7 @@ void MdiChild::writeEeprom() // write to Tx qDebug() << "Searching for SD card, found" << radioPath; if (radioPath.isEmpty()) { qDebug() << "MdiChild::writeEeprom(): Horus radio not found"; - QMessageBox::critical(this, CPN_STR_TTL_ERROR, tr("Unable to find Horus radio SD card!")); + QMessageBox::critical(this, CPN_STR_TTL_ERROR, tr("Unable to find radio SD card!")); return; } if (saveFile(radioPath, false)) { diff --git a/companion/src/radiointerface.cpp b/companion/src/radiointerface.cpp index 63befdd0c..6c2c50052 100644 --- a/companion/src/radiointerface.cpp +++ b/companion/src/radiointerface.cpp @@ -319,7 +319,7 @@ bool readEeprom(const QString & filename, ProgressWidget * progress) qDebug() << "Searching for SD card, found" << radioPath; if (radioPath.isEmpty()) { QMessageBox::critical(progress, CPN_STR_TTL_ERROR, - QCoreApplication::translate("RadioInterface", "Unable to find Horus radio SD card!")); + QCoreApplication::translate("RadioInterface", "Unable to find radio SD card!")); return false; } RadioData radioData; diff --git a/radio/sdcard/horus/WIDGETS/Timer2/main.lua b/radio/sdcard/horus/WIDGETS/Timer2/main.lua index 6354eee4e..ee4661f2d 100644 --- a/radio/sdcard/horus/WIDGETS/Timer2/main.lua +++ b/radio/sdcard/horus/WIDGETS/Timer2/main.lua @@ -14,12 +14,9 @@ local function create(zone, options) end local function update(wgt, options) - if (wgt==nil) then - print("update(nil)") - return - end + if (wgt == nil) then return end wgt.options = options - print("TimerNumB:" .. options.Timer) + --print("TimerNumB:" .. options.Timer) end local function background(wgt) @@ -28,11 +25,11 @@ end ------------------------------------------------------------ --- This size is for top bar wgts +-- Zone size: top bar widgets local function refreshZoneTiny(wgt) end ---- Size is 160x32 1/8th +--- Zone size: 160x32 1/8th local function refreshZoneSmall(wgt) local t1 = model.getTimer(wgt.options.Timer-1) local timerInfo = string.format("T%s: ", wgt.options.Timer) @@ -41,7 +38,8 @@ local function refreshZoneSmall(wgt) return end ---- Size is 225x98 1/4th (no sliders/trim) +--- Zone size: 180x70 1/4th (with sliders/trim) +--- Zone size: 225x98 1/4th (no sliders/trim) local function refreshZoneMedium(wgt) local t1 = model.getTimer(wgt.options.Timer-1) --print(t1.value) @@ -50,7 +48,7 @@ local function refreshZoneMedium(wgt) lcd.drawTimer(wgt.zone.x, wgt.zone.y+3, t1.value, XXLSIZE + CUSTOM_COLOR) end ---- Size is 192x152 1/2 +--- Zone size: 192x152 1/2 local function refreshZoneLarge(wgt) local t1 = model.getTimer(wgt.options.Timer-1) --print(t1.value) @@ -59,8 +57,8 @@ local function refreshZoneLarge(wgt) lcd.drawTimer(wgt.zone.x, wgt.zone.y+15, t1.value, XXLSIZE + CUSTOM_COLOR) end ---- Size is 390x172 1/1 ---- Size is 460x252 1/1 (no sliders/trim/topbar) +--- Zone size: 390x172 1/1 +--- Zone size: 460x252 1/1 (no sliders/trim/topbar) local function refreshZoneXLarge(wgt) local t1 = model.getTimer(wgt.options.Timer-1) --print(t1.value) diff --git a/radio/src/gui/colorlcd/view_statistics.cpp b/radio/src/gui/colorlcd/view_statistics.cpp index 4bbfee34e..10ab5ab66 100644 --- a/radio/src/gui/colorlcd/view_statistics.cpp +++ b/radio/src/gui/colorlcd/view_statistics.cpp @@ -27,7 +27,7 @@ bool menuStatsGraph(event_t event) { - switch(event) { + switch (event) { case EVT_KEY_LONG(KEY_ENTER): g_eeGeneral.globalTimer = 0; storageDirty(EE_GENERAL); diff --git a/radio/src/lua/CMakeLists.txt b/radio/src/lua/CMakeLists.txt index 39488df3f..532ecf642 100644 --- a/radio/src/lua/CMakeLists.txt +++ b/radio/src/lua/CMakeLists.txt @@ -10,6 +10,7 @@ endmacro(add_lua_export_target) set(LUA_INCLUDES -DCPUARM -DLUA -DLUA_INPUTS -DLUA_EXPORT_GENERATION -DSIMU + -I${RADIO_SRC_DIRECTORY} -I${RADIO_SRC_DIR}/targets/${TARGET_DIR} -I${RADIO_SRC_DIR}/thirdparty -I${RADIO_SRC_DIR}/targets/common/arm/stm32 diff --git a/radio/src/main.cpp b/radio/src/main.cpp index f766d90db..07d210979 100644 --- a/radio/src/main.cpp +++ b/radio/src/main.cpp @@ -201,7 +201,8 @@ void checkEeprom() { #if defined(RTC_BACKUP_RAM) && !defined(SIMU) if (TIME_TO_BACKUP_RAM()) { - rambackupWrite(); + if (!globalData.unexpectedShutdown) + rambackupWrite(); rambackupDirtyMsk = 0; } #endif @@ -522,10 +523,10 @@ void perMain() periodicTick(); DEBUG_TIMER_STOP(debugTimerPerMain1); - if (mainRequestFlags & (1 << REQUEST_FLIGHT_RESET)) { + if (mainRequestFlags & (1u << REQUEST_FLIGHT_RESET)) { TRACE("Executing requested Flight Reset"); flightReset(); - mainRequestFlags &= ~(1 << REQUEST_FLIGHT_RESET); + mainRequestFlags &= ~(1u << REQUEST_FLIGHT_RESET); } checkBacklight(); diff --git a/radio/src/opentx.h b/radio/src/opentx.h index d144cbd75..64799b951 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -505,10 +505,12 @@ extern uint8_t flightModeTransitionLast; #define availableMemory() ((unsigned int)((unsigned char *)&_heap_end - heap)) #endif +extern uint32_t nextMixerTime[NUM_MODULES]; + void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms); void evalMixes(uint8_t tick10ms); void doMixerCalculations(); -void scheduleNextMixerCalculation(uint8_t module, uint16_t period_ms); +void scheduleNextMixerCalculation(uint8_t module, uint32_t period_ms); void checkTrims(); void perMain(); diff --git a/radio/src/pulses/modules_helpers.h b/radio/src/pulses/modules_helpers.h index 083e3fc0f..eddf2e822 100644 --- a/radio/src/pulses/modules_helpers.h +++ b/radio/src/pulses/modules_helpers.h @@ -372,6 +372,11 @@ inline int8_t defaultModuleChannels_M8(uint8_t idx) return maxModuleChannels_M8(idx); } +inline uint8_t sentModulePXXChannels(uint8_t idx) +{ + return 8 + g_model.moduleData[idx].channelsCount; +} + inline int8_t sentModuleChannels(uint8_t idx) { if (isModuleCrossfire(idx)) @@ -381,7 +386,7 @@ inline int8_t sentModuleChannels(uint8_t idx) else if (isModuleSBUS(idx)) return 16; else - return 8 + g_model.moduleData[idx].channelsCount; + return sentModulePXXChannels(idx); } inline bool isDefaultModelRegistrationID() diff --git a/radio/src/pulses/pulses.cpp b/radio/src/pulses/pulses.cpp index 21c4d7eee..289485bf2 100755 --- a/radio/src/pulses/pulses.cpp +++ b/radio/src/pulses/pulses.cpp @@ -219,21 +219,21 @@ void enablePulsesExternalModule(uint8_t protocol) } } -void setupPulsesExternalModule(uint8_t protocol) +bool setupPulsesExternalModule(uint8_t protocol) { switch (protocol) { #if defined(PXX1) case PROTOCOL_CHANNELS_PXX1_PULSES: extmodulePulsesData.pxx.setupFrame(EXTERNAL_MODULE); scheduleNextMixerCalculation(EXTERNAL_MODULE, PXX_PULSES_PERIOD); - break; + return true; #endif #if defined(PXX1) && defined(HARDWARE_EXTERNAL_MODULE_SIZE_SML) case PROTOCOL_CHANNELS_PXX1_SERIAL: extmodulePulsesData.pxx_uart.setupFrame(EXTERNAL_MODULE); scheduleNextMixerCalculation(EXTERNAL_MODULE, EXTMODULE_PXX1_SERIAL_PERIOD); - break; + return true; #endif #if defined(PXX2) @@ -241,14 +241,14 @@ void setupPulsesExternalModule(uint8_t protocol) case PROTOCOL_CHANNELS_PXX2_LOWSPEED: extmodulePulsesData.pxx2.setupFrame(EXTERNAL_MODULE); scheduleNextMixerCalculation(EXTERNAL_MODULE, PXX2_PERIOD); - break; + return true; #endif #if defined(SBUS) case PROTOCOL_CHANNELS_SBUS: setupPulsesSbus(); scheduleNextMixerCalculation(EXTERNAL_MODULE, SBUS_PERIOD); - break; + return true; #endif #if defined(DSM2) @@ -257,32 +257,33 @@ void setupPulsesExternalModule(uint8_t protocol) case PROTOCOL_CHANNELS_DSM2_DSMX: setupPulsesDSM2(); scheduleNextMixerCalculation(EXTERNAL_MODULE, DSM2_PERIOD); - break; + return true; #endif #if defined(CROSSFIRE) case PROTOCOL_CHANNELS_CROSSFIRE: setupPulsesCrossfire(); scheduleNextMixerCalculation(EXTERNAL_MODULE, CROSSFIRE_PERIOD); - break; + return true; #endif #if defined(MULTIMODULE) case PROTOCOL_CHANNELS_MULTIMODULE: setupPulsesMultiExternalModule(); scheduleNextMixerCalculation(EXTERNAL_MODULE, MULTIMODULE_PERIOD); - break; + return true; #endif #if defined(PPM) case PROTOCOL_CHANNELS_PPM: setupPulsesPPMExternalModule(); scheduleNextMixerCalculation(EXTERNAL_MODULE, PPM_PERIOD(EXTERNAL_MODULE)); - break; + return true; #endif default: - break; + scheduleNextMixerCalculation(EXTERNAL_MODULE, 50/*ms*/); + return false; } } @@ -338,7 +339,9 @@ bool setupPulsesInternalModule(uint8_t protocol) #if defined(PXX1) && defined(INTMODULE_USART) case PROTOCOL_CHANNELS_PXX1_SERIAL: intmodulePulsesData.pxx_uart.setupFrame(INTERNAL_MODULE); -#if !defined(INTMODULE_HEARTBEAT) +#if defined(INTMODULE_HEARTBEAT) + scheduleNextMixerCalculation(INTERNAL_MODULE, INTMODULE_PXX1_SERIAL_PERIOD + 1 /* backup */); +#else scheduleNextMixerCalculation(INTERNAL_MODULE, INTMODULE_PXX1_SERIAL_PERIOD); #endif return true; @@ -351,11 +354,13 @@ bool setupPulsesInternalModule(uint8_t protocol) if (moduleState[INTERNAL_MODULE].mode == MODULE_MODE_SPECTRUM_ANALYSER || moduleState[INTERNAL_MODULE].mode == MODULE_MODE_POWER_METER) { scheduleNextMixerCalculation(INTERNAL_MODULE, PXX2_TOOLS_PERIOD); } -#if !defined(INTMODULE_HEARTBEAT) else { +#if defined(INTMODULE_HEARTBEAT) + scheduleNextMixerCalculation(INTERNAL_MODULE, PXX2_PERIOD + 1 /* backup */); +#else scheduleNextMixerCalculation(INTERNAL_MODULE, PXX2_PERIOD); - } #endif + } return result; } #endif @@ -375,7 +380,8 @@ bool setupPulsesInternalModule(uint8_t protocol) #endif default: - return true; + scheduleNextMixerCalculation(INTERNAL_MODULE, 50/*ms*/); + return false; } } @@ -410,8 +416,7 @@ bool setupPulsesExternalModule() return false; } else { - setupPulsesExternalModule(protocol); - return true; + return setupPulsesExternalModule(protocol); } } diff --git a/radio/src/pulses/pxx1.cpp b/radio/src/pulses/pxx1.cpp index 0d5dd3d2c..4dfa3be95 100644 --- a/radio/src/pulses/pxx1.cpp +++ b/radio/src/pulses/pxx1.cpp @@ -69,17 +69,17 @@ void Pxx1Pulses::addExtraFlags(uint8_t module) } template -void Pxx1Pulses::addChannels(uint8_t port, uint8_t sendFailsafe, uint8_t sendUpperChannels) +void Pxx1Pulses::addChannels(uint8_t moduleIdx, uint8_t sendFailsafe, uint8_t sendUpperChannels) { uint16_t pulseValue = 0; uint16_t pulseValueLow = 0; - for (int8_t i=0; i<8; i++) { + for (uint8_t i = 0; i < 8; i++) { if (sendFailsafe) { - if (g_model.moduleData[port].failsafeMode == FAILSAFE_HOLD) { + if (g_model.moduleData[moduleIdx].failsafeMode == FAILSAFE_HOLD) { pulseValue = (i < sendUpperChannels ? 4095 : 2047); } - else if (g_model.moduleData[port].failsafeMode == FAILSAFE_NOPULSES) { + else if (g_model.moduleData[moduleIdx].failsafeMode == FAILSAFE_NOPULSES) { pulseValue = (i < sendUpperChannels ? 2048 : 0); } else { @@ -92,7 +92,7 @@ void Pxx1Pulses::addChannels(uint8_t port, uint8_t sendFailsafe, u pulseValue = 2048; } else { - failsafeValue += 2*PPM_CH_CENTER(8+g_model.moduleData[port].channelsStart+i) - 2*PPM_CENTER; + failsafeValue += 2*PPM_CH_CENTER(8+g_model.moduleData[moduleIdx].channelsStart+i) - 2*PPM_CENTER; pulseValue = limit(2049, (failsafeValue * 512 / 682) + 3072, 4094); } } @@ -105,7 +105,7 @@ void Pxx1Pulses::addChannels(uint8_t port, uint8_t sendFailsafe, u pulseValue = 0; } else { - failsafeValue += 2*PPM_CH_CENTER(g_model.moduleData[port].channelsStart+i) - 2*PPM_CENTER; + failsafeValue += 2*PPM_CH_CENTER(g_model.moduleData[moduleIdx].channelsStart+i) - 2*PPM_CENTER; pulseValue = limit(1, (failsafeValue * 512 / 682) + 1024, 2046); } } @@ -113,12 +113,12 @@ void Pxx1Pulses::addChannels(uint8_t port, uint8_t sendFailsafe, u } else { if (i < sendUpperChannels) { - int channel = 8 + g_model.moduleData[port].channelsStart + i; + int channel = 8 + g_model.moduleData[moduleIdx].channelsStart + i; int value = channelOutputs[channel] + 2*PPM_CH_CENTER(channel) - 2*PPM_CENTER; pulseValue = limit(2049, (value * 512 / 682) + 3072, 4094); } - else if (i < sentModuleChannels(port)) { - int channel = g_model.moduleData[port].channelsStart + i; + else if (i < sentModulePXXChannels(moduleIdx)) { + int channel = g_model.moduleData[moduleIdx].channelsStart + i; int value = channelOutputs[channel] + 2*PPM_CH_CENTER(channel) - 2*PPM_CENTER; pulseValue = limit(1, (value * 512 / 682) + 1024, 2046); } @@ -186,7 +186,7 @@ void Pxx1Pulses::setupFrame(uint8_t module) moduleState[module].counter = 1000; } add8ChannelsFrame(module, 0, sendFailsafe); - if (sentModuleChannels(module) > 8) { + if (sentModulePXXChannels(module) > 8) { add8ChannelsFrame(module, 8, sendFailsafe); } return; diff --git a/radio/src/pulses/pxx1.h b/radio/src/pulses/pxx1.h index d2f581580..7c9dd8276 100644 --- a/radio/src/pulses/pxx1.h +++ b/radio/src/pulses/pxx1.h @@ -25,8 +25,12 @@ #include "crc.h" struct HeartbeatCapture { +#if !defined(INTMODULE_USART) uint32_t timestamp; +#endif +#if defined(DEBUG_LATENCY) uint32_t count; +#endif uint8_t valid; }; diff --git a/radio/src/storage/storage_common.cpp b/radio/src/storage/storage_common.cpp index e05caa08b..09f879d94 100644 --- a/radio/src/storage/storage_common.cpp +++ b/radio/src/storage/storage_common.cpp @@ -25,7 +25,7 @@ uint8_t storageDirtyMsk; tmr10ms_t storageDirtyTime10ms; #if defined(RTC_BACKUP_RAM) -uint8_t rambackupDirtyMsk; +uint8_t rambackupDirtyMsk = EE_GENERAL | EE_MODEL; tmr10ms_t rambackupDirtyTime10ms; #endif diff --git a/radio/src/targets/common/arm/stm32/heartbeat_driver.cpp b/radio/src/targets/common/arm/stm32/heartbeat_driver.cpp index 70ce2b394..25544c33a 100644 --- a/radio/src/targets/common/arm/stm32/heartbeat_driver.cpp +++ b/radio/src/targets/common/arm/stm32/heartbeat_driver.cpp @@ -20,9 +20,9 @@ #include "opentx.h" +#if defined(INTMODULE_HEARTBEAT_GPIO) volatile HeartbeatCapture heartbeatCapture; -#if defined(INTMODULE_HEARTBEAT_GPIO) void init_intmodule_heartbeat() { GPIO_InitTypeDef GPIO_InitStructure; @@ -69,11 +69,13 @@ void check_intmodule_heartbeat() { if (EXTI_GetITStatus(INTMODULE_HEARTBEAT_EXTI_LINE) != RESET) { #if defined(INTMODULE_USART) - heartbeatCapture.timestamp = RTOS_GET_MS(); + nextMixerTime[INTERNAL_MODULE] = RTOS_GET_MS(); #else heartbeatCapture.timestamp = getTmr2MHz(); #endif +#if defined(DEBUG_LATENCY) heartbeatCapture.count++; +#endif EXTI_ClearITPendingBit(INTMODULE_HEARTBEAT_EXTI_LINE); } } diff --git a/radio/src/targets/horus/CMakeLists.txt b/radio/src/targets/horus/CMakeLists.txt index dc02d5c53..8d1c498a4 100644 --- a/radio/src/targets/horus/CMakeLists.txt +++ b/radio/src/targets/horus/CMakeLists.txt @@ -204,11 +204,46 @@ set(STM32LIB_SRC STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dma2d.c ) +MACRO(GET_GCC_INCLUDE_PATH gcc_include_path) + if (WIN32) + execute_process(COMMAND arm-none-eabi-gcc -v -x c -E NUL ERROR_VARIABLE _gcc_output OUTPUT_QUIET) + else() + execute_process(COMMAND arm-none-eabi-gcc -v -x c -E - INPUT_FILE /dev/null ERROR_VARIABLE _gcc_output OUTPUT_QUIET) + endif() + + # Build an array of string from the GCC output + string(REPLACE "\n" ";" _gcc_output "${_gcc_output}") + + set(_capture_include FALSE) + set(_include_path "") + + # Go through the lines and capture between '"#include <...> search starts here:"' and 'End of search list.' + foreach(_line ${_gcc_output}) + if(${_line} STREQUAL "End of search list.") + set(_capture_include FALSE) + endif() + + if(_capture_include) + # Remove the leading and trailing empty characters + string(REPLACE "\r" "" _line ${_line}) + string(SUBSTRING "${_line}" 1 -1 _line) + set(_include_path "${_include_path}" "-I${_line}") + endif() + + if(${_line} STREQUAL "#include <...> search starts here:") + set(_capture_include TRUE) + endif() + endforeach() + set(${gcc_include_path} ${_include_path}) +ENDMACRO() + if(PYTHONINTERP_FOUND) + GET_GCC_INCLUDE_PATH(arm_gcc_include_path) + add_custom_command( OUTPUT ${PROJECT_BINARY_DIR}/radio/src/datacopy.cpp WORKING_DIRECTORY ${RADIO_DIRECTORY}/src - COMMAND ${PYTHON_EXECUTABLE} ${RADIO_DIRECTORY}/util/generate_datacopy.py datastructs.h -DPCBHORUS -DPCBX10 -DCPUARM -DCOLORLCD -DBACKUP -Itargets/horus > ${PROJECT_BINARY_DIR}/radio/src/datacopy.cpp + COMMAND ${PYTHON_EXECUTABLE} ${RADIO_DIRECTORY}/util/generate_datacopy.py datastructs.h -DPCBHORUS -DPCBX10 -DCPUARM -DSTM32F4 -DSTM32F429_439xx -DCOLORLCD -DBACKUP -DSIMU -I. -Itargets/horus -Itargets/common/arm/stm32 -I${THIRDPARTY_DIR} -I${THIRDPARTY_DIR}/STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/CMSIS/Device/ST/STM32F4xx/Include ${arm_gcc_include_path} > ${PROJECT_BINARY_DIR}/radio/src/datacopy.cpp DEPENDS ${RADIO_DIRECTORY}/src/datastructs.h ${RADIO_DIRECTORY}/util/generate_datacopy.py ) add_custom_target(datacopy diff --git a/radio/src/targets/horus/board.h b/radio/src/targets/horus/board.h index 710f272ce..b7331738d 100644 --- a/radio/src/targets/horus/board.h +++ b/radio/src/targets/horus/board.h @@ -21,8 +21,8 @@ #ifndef _BOARD_H_ #define _BOARD_H_ -#include "../definitions.h" -#include "../opentx_constants.h" +#include "definitions.h" +#include "opentx_constants.h" #include "board_common.h" #include "hal.h" diff --git a/radio/src/targets/taranis/board.h b/radio/src/targets/taranis/board.h index 620ef6693..d03a0e72f 100644 --- a/radio/src/targets/taranis/board.h +++ b/radio/src/targets/taranis/board.h @@ -22,8 +22,8 @@ #define _BOARD_H_ #include -#include "../definitions.h" -#include "../opentx_constants.h" +#include "definitions.h" +#include "opentx_constants.h" #include "board_common.h" #include "hal.h" diff --git a/radio/src/tasks.cpp b/radio/src/tasks.cpp index 9cbe9e2bd..0e7bd7a09 100644 --- a/radio/src/tasks.cpp +++ b/radio/src/tasks.cpp @@ -73,9 +73,9 @@ bool isForcePowerOffRequested() return false; } -bool isModuleSynchronous(uint8_t module) +bool isModuleSynchronous(uint8_t moduleIdx) { - uint8_t protocol = moduleState[module].protocol; + uint8_t protocol = moduleState[moduleIdx].protocol; if (protocol == PROTOCOL_CHANNELS_PXX2_HIGHSPEED || protocol == PROTOCOL_CHANNELS_PXX2_LOWSPEED || protocol == PROTOCOL_CHANNELS_CROSSFIRE || protocol == PROTOCOL_CHANNELS_NONE) return true; #if defined(INTMODULE_USART) || defined(EXTMODULE_USART) @@ -85,16 +85,16 @@ bool isModuleSynchronous(uint8_t module) return false; } -void sendSynchronousPulses() +void sendSynchronousPulses(uint8_t runMask) { #if defined(HARDWARE_INTERNAL_MODULE) - if (isModuleSynchronous(INTERNAL_MODULE)) { + if ((runMask & (1 << INTERNAL_MODULE)) && isModuleSynchronous(INTERNAL_MODULE)) { if (setupPulsesInternalModule()) intmoduleSendNextFrame(); } #endif - if (isModuleSynchronous(EXTERNAL_MODULE)) { + if ((runMask & (1 << EXTERNAL_MODULE)) && isModuleSynchronous(EXTERNAL_MODULE)) { if (setupPulsesExternalModule()) extmoduleSendNextFrame(); } @@ -104,7 +104,6 @@ uint32_t nextMixerTime[NUM_MODULES]; TASK_FUNCTION(mixerTask) { - static uint32_t lastRunTime; s_pulses_paused = true; while (true) { @@ -134,35 +133,22 @@ TASK_FUNCTION(mixerTask) #endif uint32_t now = RTOS_GET_MS(); - bool run = false; + uint8_t runMask = 0; - if (now - lastRunTime >= 10) { - // run at least every 10ms - run = true; - } - -#if defined(INTMODULE_USART) && defined(INTMODULE_HEARTBEAT) - if ((moduleState[INTERNAL_MODULE].protocol == PROTOCOL_CHANNELS_PXX2_HIGHSPEED || moduleState[INTERNAL_MODULE].protocol == PROTOCOL_CHANNELS_PXX1_SERIAL) && heartbeatCapture.valid && heartbeatCapture.timestamp > lastRunTime) { - run = true; - } -#endif - - if (now == nextMixerTime[0]) { - run = true; + if (now >= nextMixerTime[0]) { + runMask |= (1 << 0); } #if NUM_MODULES >= 2 - if (now == nextMixerTime[1]) { - run = true; + if (now >= nextMixerTime[1]) { + runMask |= (1 << 1); } #endif - if (!run) { + if (!runMask) { continue; // go back to sleep } - lastRunTime = now; - if (!s_pulses_paused) { uint16_t t0 = getTmr2MHz(); @@ -197,12 +183,12 @@ TASK_FUNCTION(mixerTask) if (t0 > maxMixerDuration) maxMixerDuration = t0; - sendSynchronousPulses(); + sendSynchronousPulses(runMask); } } } -void scheduleNextMixerCalculation(uint8_t module, uint16_t period_ms) +void scheduleNextMixerCalculation(uint8_t module, uint32_t period_ms) { // Schedule next mixer calculation time, diff --git a/radio/src/telemetry/frsky.h b/radio/src/telemetry/frsky.h index d4a9ab87a..e99c0f237 100644 --- a/radio/src/telemetry/frsky.h +++ b/radio/src/telemetry/frsky.h @@ -21,9 +21,9 @@ #ifndef _FRSKY_H_ #define _FRSKY_H_ -#include "../definitions.h" +#include "../../definitions.h" #include "telemetry_holders.h" -#include "../io/frsky_pxx2.h" +#include "../../io/frsky_pxx2.h" // Receive buffer state machine state enum enum FrSkyDataState { diff --git a/radio/src/thirdparty/libopenui b/radio/src/thirdparty/libopenui index a0f482b6d..04e6ba5ae 160000 --- a/radio/src/thirdparty/libopenui +++ b/radio/src/thirdparty/libopenui @@ -1 +1 @@ -Subproject commit a0f482b6d09f5fcc4fd9f0fd0bc2106d0c48ccfa +Subproject commit 04e6ba5ae868a12e43842f0517d86a8a82f37451 diff --git a/radio/util/generate_datacopy.py b/radio/util/generate_datacopy.py index 6da1c871b..93f7c79a5 100755 --- a/radio/util/generate_datacopy.py +++ b/radio/util/generate_datacopy.py @@ -1,30 +1,33 @@ #!/usr/bin/env python -from __future__ import print_function - import sys import clang.cindex import time import os -if sys.platform == "darwin": - if os.path.exists('/usr/local/Cellar/llvm/6.0.0/lib/libclang.dylib'): - clang.cindex.Config.set_library_file('/usr/local/Cellar/llvm/6.0.0/lib/libclang.dylib') - elif os.path.exists('/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libclang.dylib'): - clang.cindex.Config.set_library_file('/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libclang.dylib') - elif os.path.exists('/Library/Developer/CommandLineTools/usr/lib/libclang.dylib'): - clang.cindex.Config.set_library_file('/Library/Developer/CommandLineTools/usr/lib/libclang.dylib') -elif sys.platform.startswith("linux"): - for version in ("7", "6.0", "3.8"): - libclang = "/usr/lib/x86_64-linux-gnu/libclang-%s.so.1" % version - if os.path.exists(libclang): - clang.cindex.Config.set_library_file(libclang) - break structs = [] extrastructs = [] +def find_libclang(): + if sys.platform == "darwin": + for path in ("/usr/local/Cellar/llvm/6.0.0/lib/libclang.dylib", + "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libclang.dylib", + "/Library/Developer/CommandLineTools/usr/lib/libclang.dylib"): + if os.path.exists(path): + return path + elif sys.platform.startswith("linux"): + for version in ("7", "6.0", "3.8"): + path = "/usr/lib/x86_64-linux-gnu/libclang-%s.so.1" % version + if os.path.exists(path): + return path + for path in ("/usr/local/lib/libclang.so", + "/usr/lib/libclang.so"): + if os.path.exists(path): + return path + + def build_struct(cursor, anonymousUnion=False): if not anonymousUnion: structs.append(cursor.spelling) @@ -98,7 +101,28 @@ def header(): print("// This file was auto-generated by %s script on %s. Do not edit this file!\n\n\n" % (os.path.basename(sys.argv[0]), time.asctime())) -index = clang.cindex.Index.create() -translation_unit = index.parse(sys.argv[1], ['-x', 'c++', '-std=c++11'] + sys.argv[2:]) -header() -build(translation_unit.cursor) +def print_translation_unit_diags(diags, prefix=''): + for diag in diags: + print(prefix + str(diag), file=sys.stderr) + print_translation_unit_diags(diag.children, ' ' + prefix) + + +def main(): + libclang = find_libclang() + if libclang: + # print(libclang, file=sys.stderr) + clang.cindex.Config.set_library_file(libclang) + + index = clang.cindex.Index.create() + translation_unit = index.parse(sys.argv[1], ['-x', 'c++', '-std=c++11'] + sys.argv[2:]) + + if translation_unit.diagnostics: + print_translation_unit_diags(translation_unit.diagnostics) + sys.exit(-1) + + header() + build(translation_unit.cursor) + + +if __name__ == "__main__": + main()