Merge branch 'next' into kilrah/taranis_gpio
This commit is contained in:
+7
-3
@@ -9,12 +9,16 @@ before_install:
|
||||
- sudo add-apt-repository 'deb http://llvm.org/apt/precise/ llvm-toolchain-precise main' --yes
|
||||
- wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key | sudo apt-key add -
|
||||
- sudo apt-get update -qq
|
||||
- rsync -av firmware.diydrones.com::Tools/Travis/*.deb ExtraPackages
|
||||
|
||||
install:
|
||||
- sudo apt-get install -y xvfb lcov cmake cmake-data bc curl gcc-arm-none-eabi qt-latest g++-5 libxerces-c-dev xsdcxx libsdl1.2-dev libusb-1.0-0 libfox-1.6-dev libgtest-dev python-clang-3.8 libclang-3.8-dev python-qt4
|
||||
- sudo dpkg -i ExtraPackages/*.deb || echo "FAILED INSTALL OF EXTRA DEBS"
|
||||
- sudo apt-get install -y xvfb lcov cmake cmake-data bc curl gcc-arm-none-eabi qt-latest g++-5 libxerces-c-dev xsdcxx libsdl1.2-dev libusb-1.0-0 libfox-1.6-dev libgtest-dev python-clang-3.9 libclang-3.9-dev python-qt4
|
||||
- export CXX="g++-5" CC="gcc-5"
|
||||
- wget --quiet http://firmware.ardupilot.org/Tools/Travis/gcc-avr_1%253a4.8-2.1_amd64.deb
|
||||
- wget --quiet http://firmware.ardupilot.org/Tools/Travis/libmpfr4_3.1.2-1_amd64.deb
|
||||
- wget --quiet http://firmware.ardupilot.org/Tools/Travis/avr-libc_1%253a1.8.0-4.1_all.deb
|
||||
- wget --quiet http://firmware.ardupilot.org/Tools/Travis/binutils-avr_2.23.1-2.1_amd64.deb
|
||||
- wget --quiet http://firmware.ardupilot.org/Tools/Travis/libmpc3_1.0.1-1ubuntu1_amd64.deb
|
||||
- sudo dpkg --install gcc-avr_1%3a4.8-2.1_amd64.deb avr-libc_1%3a1.8.0-4.1_all.deb libmpfr4_3.1.2-1_amd64.deb binutils-avr_2.23.1-2.1_amd64.deb libmpc3_1.0.1-1ubuntu1_amd64.deb
|
||||
|
||||
script:
|
||||
- ./radio/util/commit-tests.sh .
|
||||
|
||||
@@ -31,6 +31,14 @@ find_package(Qt5LinguistTools)
|
||||
find_package(Qt5PrintSupport)
|
||||
find_package(Qt5Multimedia)
|
||||
|
||||
message(STATUS "Looking for SDL ")
|
||||
find_package(Sdl)
|
||||
if(SDL_FOUND)
|
||||
message("SDL Include Path: " ${SDL_INCLUDE_DIR})
|
||||
else()
|
||||
message("SDL not found! Joysticks support will be disabled. Simulator audio will not work.")
|
||||
endif()
|
||||
|
||||
include(Macros)
|
||||
today(DATE)
|
||||
now(TIME)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
macro(add_bitmaps_target targetname filter width format)
|
||||
set(bitmaps_files)
|
||||
file(GLOB bitmaps ${filter})
|
||||
foreach(bitmap ${bitmaps})
|
||||
get_filename_component(target ${bitmap} NAME_WE)
|
||||
|
||||
@@ -25,15 +25,10 @@ if(TABLE_LAYOUT)
|
||||
message(STATUS "Using QTableWidget")
|
||||
endif(TABLE_LAYOUT)
|
||||
|
||||
message(STATUS "Looking for SDL ")
|
||||
find_package(Sdl)
|
||||
if(SDL_FOUND)
|
||||
include_directories(${SDL_INCLUDE_DIR})
|
||||
message("SDL Include Path: " ${SDL_INCLUDE_DIR})
|
||||
add_definitions(-DJOYSTICKS)
|
||||
add_definitions(-DSIMU_AUDIO)
|
||||
else()
|
||||
message("SDL not found! Joysticks support will be disabled. Simulator audio will not work.")
|
||||
add_definitions(-DJOYSTICKS)
|
||||
endif()
|
||||
|
||||
message(STATUS "Looking for QT lupdate ")
|
||||
@@ -283,7 +278,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
install(FILES ../targets/linux/45-companion-taranis.rules DESTINATION /lib/udev/rules.d RENAME 45-companion${C9X_NAME_SUFFIX}-taranis.rules)
|
||||
# Linux specific code
|
||||
set(OperatingSystem "Linux")
|
||||
else()
|
||||
elseif(WIN32)
|
||||
get_target_property(QtCore_LOCATION Qt5::Core LOCATION)
|
||||
get_filename_component(QT_DLL_DIR ${QtCore_LOCATION} PATH)
|
||||
get_filename_component(SDL_DIR ${SDL_LIBRARY} PATH)
|
||||
|
||||
@@ -1171,8 +1171,117 @@ void registerOpenTxFirmwares()
|
||||
Option nav_options[] = { { "rotenc", QObject::tr("Rotary Encoder use in menus navigation") }, { "potscroll", QObject::tr("Pots use in menus navigation") }, { NULL } };
|
||||
Option dsm2_options[] = { { "DSM2", QObject::tr("Support for DSM2 modules"), 0 }, { "DSM2PPM", QObject::tr("Support for DSM2 modules using ppm instead of true serial"), 0 }, { NULL } };
|
||||
|
||||
/* Taranis Plus board */
|
||||
firmware = new OpenTxFirmware("opentx-taranisplus", QObject::tr("FrSky Taranis Plus"), BOARD_TARANIS_PLUS);
|
||||
addOpenTxTaranisOptions(firmware);
|
||||
addOpenTxCommonOptions(firmware);
|
||||
firmwares.push_back(firmware);
|
||||
|
||||
/* Taranis board */
|
||||
firmware = new OpenTxFirmware("opentx-taranis", QObject::tr("FrSky Taranis"), BOARD_TARANIS);
|
||||
firmware->addOption("haptic", QObject::tr("Haptic module installed"));
|
||||
addOpenTxTaranisOptions(firmware);
|
||||
addOpenTxCommonOptions(firmware);
|
||||
firmwares.push_back(firmware);
|
||||
|
||||
/* Taranis X9E board */
|
||||
firmware = new OpenTxFirmware("opentx-taranisx9e", QObject::tr("FrSky Taranis X9E"), BOARD_TARANIS_X9E);
|
||||
firmware->addOption("shutdownconfirm", QObject::tr("Confirmation before radio shutdown"));
|
||||
addOpenTxTaranisOptions(firmware);
|
||||
addOpenTxCommonOptions(firmware);
|
||||
firmwares.push_back(firmware);
|
||||
|
||||
/* Horus board */
|
||||
firmware = new OpenTxFirmware("opentx-horus", QObject::tr("FrSky Horus"), BOARD_HORUS);
|
||||
firmware->addOption("noheli", QObject::tr("Disable HELI menu and cyclic mix support"));
|
||||
firmware->addOption("nogvars", QObject::tr("Disable Global variables"));
|
||||
firmware->addOption("lua", QObject::tr("Support for Lua model scripts"));
|
||||
addOpenTxCommonOptions(firmware);
|
||||
firmwares.push_back(firmware);
|
||||
|
||||
/* 9XR-Pro */
|
||||
firmware = new OpenTxFirmware("opentx-9xrpro", QObject::tr("Turnigy 9XR-PRO"), BOARD_9XRPRO);
|
||||
firmware->addOption("heli", QObject::tr("Enable HELI menu and cyclic mix support"));
|
||||
firmware->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
|
||||
firmware->addOption("nofp", QObject::tr("No flight modes"));
|
||||
firmware->addOption("nocurves", QObject::tr("Disable curves menus"));
|
||||
firmware->addOption("ppmca", QObject::tr("PPM center adjustment in limits"));
|
||||
firmware->addOption("gvars", QObject::tr("Global variables"), GVARS_VARIANT);
|
||||
firmware->addOption("symlimits", QObject::tr("Symetrical Limits"));
|
||||
firmware->addOption("timer3", QObject::tr("Support for a third timer"));
|
||||
firmware->addOption("potscroll", QObject::tr("Pots use in menus navigation"));
|
||||
firmware->addOption("autosource", QObject::tr("In model setup menus automatically set source by moving the control"));
|
||||
firmware->addOption("autoswitch", QObject::tr("In model setup menus automatically set switch by moving the control"));
|
||||
firmware->addOption("nographics", QObject::tr("No graphical check boxes and sliders"));
|
||||
firmware->addOption("battgraph", QObject::tr("Battery graph"));
|
||||
firmware->addOption("nobold", QObject::tr("Don't use bold font for highlighting active items"));
|
||||
firmware->addOption("bluetooth", QObject::tr("Bluetooth interface"));
|
||||
addOpenTxCommonOptions(firmware);
|
||||
firmwares.push_back(firmware);
|
||||
|
||||
/* 9XR board with M128 chip */
|
||||
firmware = new OpenTxFirmware("opentx-9xr128", QObject::tr("Turnigy 9XR with m128 chip"), BOARD_M128);
|
||||
firmware->addOptions(extr_options);
|
||||
firmware->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support"));
|
||||
firmware->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
|
||||
firmware->addOption("nosplash", QObject::tr("No splash screen"));
|
||||
firmware->addOption("nofp", QObject::tr("No flight modes"));
|
||||
firmware->addOption("nocurves", QObject::tr("Disable curves menus"));
|
||||
firmware->addOption("audio", QObject::tr("Support for radio modified with regular speaker"));
|
||||
firmware->addOption("voice", QObject::tr("Used if you have modified your radio with voice mode"));
|
||||
firmware->addOption("haptic", QObject::tr("Used if you have modified your radio with haptic mode"));
|
||||
// NOT TESTED firmware->addOption("PXX", QObject::tr("Support of FrSky PXX protocol"));
|
||||
firmware->addOption("DSM2", QObject::tr("Support for DSM2 modules"));
|
||||
firmware->addOption("ppmca", QObject::tr("PPM center adjustment in limits"));
|
||||
firmware->addOption("gvars", QObject::tr("Global variables"), GVARS_VARIANT);
|
||||
firmware->addOption("symlimits", QObject::tr("Symetrical Limits"));
|
||||
firmware->addOption("potscroll", QObject::tr("Pots use in menus navigation"));
|
||||
firmware->addOption("autosource", QObject::tr("In model setup menus automatically set source by moving the control"));
|
||||
firmware->addOption("autoswitch", QObject::tr("In model setup menus automatically set switch by moving the control"));
|
||||
firmware->addOption("nographics", QObject::tr("No graphical check boxes and sliders"));
|
||||
firmware->addOption("battgraph", QObject::tr("Battery graph"));
|
||||
firmware->addOption("nobold", QObject::tr("Don't use bold font for highlighting active items"));
|
||||
firmware->addOption("thrtrace", QObject::tr("Enable the throttle trace in Statistics"));
|
||||
firmware->addOption("pgbar", QObject::tr("EEprom write Progress bar"));
|
||||
firmware->addOption("imperial", QObject::tr("Imperial units"));
|
||||
addOpenTxCommonOptions(firmware);
|
||||
firmwares.push_back(firmware);
|
||||
|
||||
/* 9XR board */
|
||||
firmware = new OpenTxFirmware("opentx-9xr", QObject::tr("Turnigy 9XR"), BOARD_STOCK);
|
||||
firmware->addOptions(extr_options);
|
||||
firmware->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support"));
|
||||
firmware->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
|
||||
firmware->addOption("nosplash", QObject::tr("No splash screen"));
|
||||
firmware->addOption("nofp", QObject::tr("No flight modes"));
|
||||
firmware->addOption("nocurves", QObject::tr("Disable curves menus"));
|
||||
firmware->addOption("audio", QObject::tr("Support for radio modified with regular speaker"));
|
||||
firmware->addOption("voice", QObject::tr("Used if you have modified your radio with voice mode"));
|
||||
firmware->addOption("haptic", QObject::tr("Used if you have modified your radio with haptic mode"));
|
||||
// NOT TESTED firmware->addOption("PXX", QObject::tr("Support of FrSky PXX protocol"));
|
||||
firmware->addOption("DSM2", QObject::tr("Support for DSM2 modules"));
|
||||
firmware->addOption("ppmca", QObject::tr("PPM center adjustment in limits"));
|
||||
firmware->addOption("gvars", QObject::tr("Global variables"), GVARS_VARIANT);
|
||||
firmware->addOption("symlimits", QObject::tr("Symetrical Limits"));
|
||||
firmware->addOption("potscroll", QObject::tr("Pots use in menus navigation"));
|
||||
firmware->addOption("autosource", QObject::tr("In model setup menus automatically set source by moving the control"));
|
||||
firmware->addOption("autoswitch", QObject::tr("In model setup menus automatically set switch by moving the control"));
|
||||
firmware->addOption("nographics", QObject::tr("No graphical check boxes and sliders"));
|
||||
firmware->addOption("battgraph", QObject::tr("Battery graph"));
|
||||
firmware->addOption("nobold", QObject::tr("Don't use bold font for highlighting active items"));
|
||||
firmware->addOption("thrtrace", QObject::tr("Enable the throttle trace in Statistics"));
|
||||
firmware->addOption("pgbar", QObject::tr("EEprom write Progress bar"));
|
||||
firmware->addOption("imperial", QObject::tr("Imperial units"));
|
||||
firmware->addOption("nowshh", QObject::tr("No Winged Shadow How High support"));
|
||||
firmware->addOption("novario", QObject::tr("No vario support"));
|
||||
firmware->addOption("nogps", QObject::tr("No GPS support"));
|
||||
firmware->addOption("nogauges", QObject::tr("No gauges in the custom telemetry screen"));
|
||||
firmware->addOption("stickrev", QObject::tr("Add support for reversing stick inputs (e.g. needed for FrSky gimbals)"));
|
||||
addOpenTxCommonOptions(firmware);
|
||||
firmwares.push_back(firmware);
|
||||
|
||||
/* 9x board */
|
||||
firmware = new OpenTxFirmware("opentx-9x", QObject::tr("9X board"), BOARD_STOCK);
|
||||
firmware = new OpenTxFirmware("opentx-9x", QObject::tr("9X with stock board"), BOARD_STOCK);
|
||||
firmware->addOptions(ext_options);
|
||||
firmware->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support"));
|
||||
firmware->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
|
||||
@@ -1208,7 +1317,7 @@ void registerOpenTxFirmwares()
|
||||
firmwares.push_back(firmware);
|
||||
|
||||
/* 9x board with M128 chip */
|
||||
firmware = new OpenTxFirmware("opentx-9x128", QObject::tr("M128 / 9X board"), BOARD_M128);
|
||||
firmware = new OpenTxFirmware("opentx-9x128", QObject::tr("9X with stock board and m128 chip"), BOARD_M128);
|
||||
firmware->addOptions(ext_options);
|
||||
firmware->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support"));
|
||||
firmware->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
|
||||
@@ -1237,69 +1346,52 @@ void registerOpenTxFirmwares()
|
||||
addOpenTxCommonOptions(firmware);
|
||||
firmwares.push_back(firmware);
|
||||
|
||||
/* 9XR board */
|
||||
firmware = new OpenTxFirmware("opentx-9xr", QObject::tr("9XR"), BOARD_STOCK);
|
||||
firmware->addOptions(extr_options);
|
||||
firmware->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support"));
|
||||
/* ar9x board */
|
||||
firmware = new OpenTxFirmware("opentx-ar9x", QObject::tr("9X with AR9X board"), BOARD_AR9X);
|
||||
firmware->addOption("heli", QObject::tr("Enable HELI menu and cyclic mix support"));
|
||||
firmware->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
|
||||
firmware->addOption("nosplash", QObject::tr("No splash screen"));
|
||||
firmware->addOption("nofp", QObject::tr("No flight modes"));
|
||||
firmware->addOption("nocurves", QObject::tr("Disable curves menus"));
|
||||
firmware->addOption("audio", QObject::tr("Support for radio modified with regular speaker"));
|
||||
firmware->addOption("voice", QObject::tr("Used if you have modified your radio with voice mode"));
|
||||
firmware->addOption("haptic", QObject::tr("Used if you have modified your radio with haptic mode"));
|
||||
// NOT TESTED firmware->addOption("PXX", QObject::tr("Support of FrSky PXX protocol"));
|
||||
firmware->addOption("DSM2", QObject::tr("Support for DSM2 modules"));
|
||||
firmware->addOption("ppmca", QObject::tr("PPM center adjustment in limits"));
|
||||
firmware->addOption("gvars", QObject::tr("Global variables"), GVARS_VARIANT);
|
||||
firmware->addOption("symlimits", QObject::tr("Symetrical Limits"));
|
||||
firmware->addOption("timer3", QObject::tr("Support for a third timer"));
|
||||
firmware->addOption("potscroll", QObject::tr("Pots use in menus navigation"));
|
||||
firmware->addOption("autosource", QObject::tr("In model setup menus automatically set source by moving the control"));
|
||||
firmware->addOption("autoswitch", QObject::tr("In model setup menus automatically set switch by moving the control"));
|
||||
firmware->addOption("dblkeys", QObject::tr("Enable resetting values by pressing up and down at the same time"));
|
||||
firmware->addOption("nographics", QObject::tr("No graphical check boxes and sliders"));
|
||||
firmware->addOption("battgraph", QObject::tr("Battery graph"));
|
||||
firmware->addOption("nobold", QObject::tr("Don't use bold font for highlighting active items"));
|
||||
firmware->addOption("thrtrace", QObject::tr("Enable the throttle trace in Statistics"));
|
||||
firmware->addOption("pgbar", QObject::tr("EEprom write Progress bar"));
|
||||
firmware->addOption("imperial", QObject::tr("Imperial units"));
|
||||
firmware->addOption("nowshh", QObject::tr("No Winged Shadow How High support"));
|
||||
firmware->addOption("novario", QObject::tr("No vario support"));
|
||||
firmware->addOption("nogps", QObject::tr("No GPS support"));
|
||||
firmware->addOption("nogauges", QObject::tr("No gauges in the custom telemetry screen"));
|
||||
firmware->addOption("stickrev", QObject::tr("Add support for reversing stick inputs (e.g. needed for FrSky gimbals)"));
|
||||
firmware->addOption("bluetooth", QObject::tr("Bluetooth interface"));
|
||||
// firmware->addOption("rtc", QObject::tr("Optional RTC added"));
|
||||
// firmware->addOption("volume", QObject::tr("i2c volume control added"));
|
||||
addOpenTxCommonOptions(firmware);
|
||||
firmwares.push_back(firmware);
|
||||
|
||||
/* 9XR board with M128 chip */
|
||||
firmware = new OpenTxFirmware("opentx-9xr128", QObject::tr("9XR with M128 chip"), BOARD_M128);
|
||||
firmware->addOptions(extr_options);
|
||||
firmware->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support"));
|
||||
/* Sky9x board */
|
||||
firmware = new OpenTxFirmware("opentx-sky9x", QObject::tr("9X with Sky9x board"), BOARD_SKY9X);
|
||||
firmware->addOption("heli", QObject::tr("Enable HELI menu and cyclic mix support"));
|
||||
firmware->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
|
||||
firmware->addOption("nosplash", QObject::tr("No splash screen"));
|
||||
firmware->addOption("nofp", QObject::tr("No flight modes"));
|
||||
firmware->addOption("nocurves", QObject::tr("Disable curves menus"));
|
||||
firmware->addOption("audio", QObject::tr("Support for radio modified with regular speaker"));
|
||||
firmware->addOption("voice", QObject::tr("Used if you have modified your radio with voice mode"));
|
||||
firmware->addOption("haptic", QObject::tr("Used if you have modified your radio with haptic mode"));
|
||||
// NOT TESTED firmware->addOption("PXX", QObject::tr("Support of FrSky PXX protocol"));
|
||||
firmware->addOption("DSM2", QObject::tr("Support for DSM2 modules"));
|
||||
firmware->addOption("ppmca", QObject::tr("PPM center adjustment in limits"));
|
||||
firmware->addOption("gvars", QObject::tr("Global variables"), GVARS_VARIANT);
|
||||
firmware->addOption("symlimits", QObject::tr("Symetrical Limits"));
|
||||
firmware->addOption("timer3", QObject::tr("Support for a third timer"));
|
||||
firmware->addOption("potscroll", QObject::tr("Pots use in menus navigation"));
|
||||
firmware->addOption("autosource", QObject::tr("In model setup menus automatically set source by moving the control"));
|
||||
firmware->addOption("autoswitch", QObject::tr("In model setup menus automatically set switch by moving the control"));
|
||||
firmware->addOption("dblkeys", QObject::tr("Enable resetting values by pressing up and down at the same time"));
|
||||
firmware->addOption("nographics", QObject::tr("No graphical check boxes and sliders"));
|
||||
firmware->addOption("battgraph", QObject::tr("Battery graph"));
|
||||
firmware->addOption("nobold", QObject::tr("Don't use bold font for highlighting active items"));
|
||||
firmware->addOption("thrtrace", QObject::tr("Enable the throttle trace in Statistics"));
|
||||
firmware->addOption("pgbar", QObject::tr("EEprom write Progress bar"));
|
||||
firmware->addOption("imperial", QObject::tr("Imperial units"));
|
||||
firmware->addOption("bluetooth", QObject::tr("Bluetooth interface"));
|
||||
addOpenTxCommonOptions(firmware);
|
||||
firmwares.push_back(firmware);
|
||||
|
||||
/* Gruvin9x board */
|
||||
firmware = new OpenTxFirmware("opentx-gruvin9x", QObject::tr("Gruvin9x board / 9X"), BOARD_GRUVIN9X);
|
||||
firmware = new OpenTxFirmware("opentx-gruvin9x", QObject::tr("9X with Gruvin9x board"), BOARD_GRUVIN9X);
|
||||
firmware->addOption("heli", QObject::tr("Enable heli menu and cyclic mix support"));
|
||||
firmware->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
|
||||
firmware->addOption("nofp", QObject::tr("No flight modes"));
|
||||
@@ -1324,7 +1416,7 @@ void registerOpenTxFirmwares()
|
||||
firmwares.push_back(firmware);
|
||||
|
||||
/* MEGA2560 board */
|
||||
firmware = new OpenTxFirmware("opentx-mega2560", QObject::tr("MEGA2560 board"), BOARD_MEGA2560);
|
||||
firmware = new OpenTxFirmware("opentx-mega2560", QObject::tr("DIY MEGA2560 radio"), BOARD_MEGA2560);
|
||||
addOpenTxLcdOptions(firmware);
|
||||
firmware->addOption("PWR", QObject::tr("Power management by soft-off circuitry"));
|
||||
firmware->addOptions(ext_options);
|
||||
@@ -1353,99 +1445,6 @@ void registerOpenTxFirmwares()
|
||||
addOpenTxCommonOptions(firmware);
|
||||
firmwares.push_back(firmware);
|
||||
|
||||
/* Sky9x board */
|
||||
firmware = new OpenTxFirmware("opentx-sky9x", QObject::tr("Sky9x board / 9X"), BOARD_SKY9X);
|
||||
firmware->addOption("heli", QObject::tr("Enable HELI menu and cyclic mix support"));
|
||||
firmware->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
|
||||
firmware->addOption("nofp", QObject::tr("No flight modes"));
|
||||
firmware->addOption("nocurves", QObject::tr("Disable curves menus"));
|
||||
firmware->addOption("ppmca", QObject::tr("PPM center adjustment in limits"));
|
||||
firmware->addOption("gvars", QObject::tr("Global variables"), GVARS_VARIANT);
|
||||
firmware->addOption("symlimits", QObject::tr("Symetrical Limits"));
|
||||
firmware->addOption("timer3", QObject::tr("Support for a third timer"));
|
||||
firmware->addOption("potscroll", QObject::tr("Pots use in menus navigation"));
|
||||
firmware->addOption("autosource", QObject::tr("In model setup menus automatically set source by moving the control"));
|
||||
firmware->addOption("autoswitch", QObject::tr("In model setup menus automatically set switch by moving the control"));
|
||||
firmware->addOption("dblkeys", QObject::tr("Enable resetting values by pressing up and down at the same time"));
|
||||
firmware->addOption("nographics", QObject::tr("No graphical check boxes and sliders"));
|
||||
firmware->addOption("battgraph", QObject::tr("Battery graph"));
|
||||
firmware->addOption("nobold", QObject::tr("Don't use bold font for highlighting active items"));
|
||||
firmware->addOption("bluetooth", QObject::tr("Bluetooth interface"));
|
||||
addOpenTxCommonOptions(firmware);
|
||||
firmwares.push_back(firmware);
|
||||
|
||||
/* ar9x board */
|
||||
firmware = new OpenTxFirmware("opentx-ar9x", QObject::tr("ar9x board / 9X"), BOARD_AR9X);
|
||||
firmware->addOption("heli", QObject::tr("Enable HELI menu and cyclic mix support"));
|
||||
firmware->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
|
||||
firmware->addOption("nofp", QObject::tr("No flight modes"));
|
||||
firmware->addOption("nocurves", QObject::tr("Disable curves menus"));
|
||||
firmware->addOption("ppmca", QObject::tr("PPM center adjustment in limits"));
|
||||
firmware->addOption("gvars", QObject::tr("Global variables"), GVARS_VARIANT);
|
||||
firmware->addOption("symlimits", QObject::tr("Symetrical Limits"));
|
||||
firmware->addOption("timer3", QObject::tr("Support for a third timer"));
|
||||
firmware->addOption("potscroll", QObject::tr("Pots use in menus navigation"));
|
||||
firmware->addOption("autosource", QObject::tr("In model setup menus automatically set source by moving the control"));
|
||||
firmware->addOption("autoswitch", QObject::tr("In model setup menus automatically set switch by moving the control"));
|
||||
firmware->addOption("dblkeys", QObject::tr("Enable resetting values by pressing up and down at the same time"));
|
||||
firmware->addOption("nographics", QObject::tr("No graphical check boxes and sliders"));
|
||||
firmware->addOption("battgraph", QObject::tr("Battery graph"));
|
||||
firmware->addOption("nobold", QObject::tr("Don't use bold font for highlighting active items"));
|
||||
firmware->addOption("bluetooth", QObject::tr("Bluetooth interface"));
|
||||
// firmware->addOption("rtc", QObject::tr("Optional RTC added"));
|
||||
// firmware->addOption("volume", QObject::tr("i2c volume control added"));
|
||||
addOpenTxCommonOptions(firmware);
|
||||
firmwares.push_back(firmware);
|
||||
|
||||
/* 9XR-Pro */
|
||||
firmware = new OpenTxFirmware("opentx-9xrpro", QObject::tr("9XR-PRO"), BOARD_9XRPRO);
|
||||
firmware->addOption("heli", QObject::tr("Enable HELI menu and cyclic mix support"));
|
||||
firmware->addOption("templates", QObject::tr("Enable TEMPLATES menu"));
|
||||
firmware->addOption("nofp", QObject::tr("No flight modes"));
|
||||
firmware->addOption("nocurves", QObject::tr("Disable curves menus"));
|
||||
firmware->addOption("ppmca", QObject::tr("PPM center adjustment in limits"));
|
||||
firmware->addOption("gvars", QObject::tr("Global variables"), GVARS_VARIANT);
|
||||
firmware->addOption("symlimits", QObject::tr("Symetrical Limits"));
|
||||
firmware->addOption("timer3", QObject::tr("Support for a third timer"));
|
||||
firmware->addOption("potscroll", QObject::tr("Pots use in menus navigation"));
|
||||
firmware->addOption("autosource", QObject::tr("In model setup menus automatically set source by moving the control"));
|
||||
firmware->addOption("autoswitch", QObject::tr("In model setup menus automatically set switch by moving the control"));
|
||||
firmware->addOption("nographics", QObject::tr("No graphical check boxes and sliders"));
|
||||
firmware->addOption("battgraph", QObject::tr("Battery graph"));
|
||||
firmware->addOption("nobold", QObject::tr("Don't use bold font for highlighting active items"));
|
||||
firmware->addOption("bluetooth", QObject::tr("Bluetooth interface"));
|
||||
addOpenTxCommonOptions(firmware);
|
||||
firmwares.push_back(firmware);
|
||||
|
||||
/* Taranis board */
|
||||
firmware = new OpenTxFirmware("opentx-taranis", QObject::tr("FrSky Taranis"), BOARD_TARANIS);
|
||||
firmware->addOption("haptic", QObject::tr("Haptic module installed"));
|
||||
addOpenTxTaranisOptions(firmware);
|
||||
addOpenTxCommonOptions(firmware);
|
||||
firmwares.push_back(firmware);
|
||||
|
||||
/* Taranis Plus board */
|
||||
firmware = new OpenTxFirmware("opentx-taranisplus", QObject::tr("FrSky Taranis Plus"), BOARD_TARANIS_PLUS);
|
||||
addOpenTxTaranisOptions(firmware);
|
||||
addOpenTxCommonOptions(firmware);
|
||||
firmwares.push_back(firmware);
|
||||
|
||||
/* Taranis X9E board */
|
||||
firmware = new OpenTxFirmware("opentx-taranisx9e", QObject::tr("FrSky Taranis X9E"), BOARD_TARANIS_X9E);
|
||||
firmware->addOption("shutdownconfirm", QObject::tr("Confirmation before radio shutdown"));
|
||||
firmware->addOption("horussticks", QObject::tr("Horus magnetic sticks"));
|
||||
addOpenTxTaranisOptions(firmware);
|
||||
addOpenTxCommonOptions(firmware);
|
||||
firmwares.push_back(firmware);
|
||||
|
||||
/* Horus board */
|
||||
firmware = new OpenTxFirmware("opentx-horus", QObject::tr("FrSky Horus"), BOARD_HORUS);
|
||||
firmware->addOption("noheli", QObject::tr("Disable HELI menu and cyclic mix support"));
|
||||
firmware->addOption("nogvars", QObject::tr("Disable Global variables"));
|
||||
firmware->addOption("lua", QObject::tr("Support for Lua model scripts"));
|
||||
addOpenTxCommonOptions(firmware);
|
||||
firmwares.push_back(firmware);
|
||||
|
||||
default_firmware_variant = GetFirmware("opentx-taranisplus-en");
|
||||
current_firmware_variant = default_firmware_variant;
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ void FlashFirmwareDialog::on_firmwareLoad_clicked()
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Open Firmware File"), g.flashDir(), FLASH_FILES_FILTER);
|
||||
if (!fileName.isEmpty()) {
|
||||
fwName = fileName;
|
||||
if (!fwName.isEmpty() && !FirmwareInterface(fwName).isValid()) {
|
||||
if (!fwName.isEmpty() && !fwName.endsWith(".dfu") && !FirmwareInterface(fwName).isValid()) {
|
||||
QMessageBox::warning(this, tr("Warning"), tr("%1 may not be a valid firmware file").arg(fwName));
|
||||
}
|
||||
updateUI();
|
||||
|
||||
@@ -8,9 +8,10 @@
|
||||
|
||||
#define HEX_FILES_FILTER "HEX files (*.hex);;"
|
||||
#define BIN_FILES_FILTER "BIN files (*.bin);;"
|
||||
#define DFU_FILES_FILTER "DFU files (*.dfu);;"
|
||||
#define EEPE_FILES_FILTER "EEPE EEPROM files (*.eepe);;"
|
||||
#define EEPROM_FILES_FILTER "EEPE files (*.eepe *.bin *.hex);;" EEPE_FILES_FILTER BIN_FILES_FILTER HEX_FILES_FILTER
|
||||
#define FLASH_FILES_FILTER "FLASH files (*.bin *.hex);;" BIN_FILES_FILTER HEX_FILES_FILTER
|
||||
#define FLASH_FILES_FILTER "FLASH files (*.bin *.hex *.dfu);;" BIN_FILES_FILTER HEX_FILES_FILTER DFU_FILES_FILTER
|
||||
#define EXTERNAL_EEPROM_FILES_FILTER "EEPROM files (*.bin *.hex);;" BIN_FILES_FILTER HEX_FILES_FILTER
|
||||
#define ER9X_EEPROM_FILE_TYPE "ER9X_EEPROM_FILE"
|
||||
#define EEPE_EEPROM_FILE_HEADER "EEPE EEPROM FILE"
|
||||
|
||||
@@ -360,16 +360,25 @@ void MainWindow::firmwareDownloadAccepted()
|
||||
int errnum = hline.mid(6).toInt();
|
||||
switch(errnum) {
|
||||
case 1:
|
||||
errormsg = tr("Not enough memory for all the selected firmware options");
|
||||
errormsg = tr("Not enough flash available on this board for all the selected options");
|
||||
break;
|
||||
case 2:
|
||||
errormsg = tr("Compilation server termporary failure, try later");
|
||||
errormsg = tr("Compilation server temporary failure, try later");
|
||||
break;
|
||||
case 3:
|
||||
errormsg = tr("Compilation server too busy, try later");
|
||||
break;
|
||||
case 4:
|
||||
errormsg = tr("Compilation server requires registration, please check OpenTX web site");
|
||||
errormsg = tr("Compilation error");
|
||||
break;
|
||||
case 5:
|
||||
errormsg = tr("Invalid firmware");
|
||||
break;
|
||||
case 6:
|
||||
errormsg = tr("Invalid board");
|
||||
break;
|
||||
case 7:
|
||||
errormsg = tr("Invalid language");
|
||||
break;
|
||||
default:
|
||||
errormsg = tr("Unknown server failure, try later");
|
||||
|
||||
@@ -331,8 +331,8 @@ void ModulePanel::update()
|
||||
ui->failsafesFrame->setVisible(mask & MASK_FAILSAFES);
|
||||
|
||||
if (mask & MASK_CHANNELS_RANGE) {
|
||||
ui->channelsStart->setMaximum(32 - ui->channelsCount->value());
|
||||
ui->channelsCount->setMaximum(qMin(16, 32-ui->channelsStart->value()));
|
||||
ui->channelsStart->setMaximum(33 - ui->channelsCount->value());
|
||||
ui->channelsCount->setMaximum(qMin(16, 33-ui->channelsStart->value()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,18 +62,20 @@ QStringList getAvrdudeArgs(const QString &cmd, const QString &filename)
|
||||
|
||||
QStringList getDfuArgs(const QString & cmd, const QString & filename)
|
||||
{
|
||||
QStringList arguments;
|
||||
QStringList args;
|
||||
burnConfigDialog bcd;
|
||||
QString memory = "0x08000000";
|
||||
if (cmd == "-U") {
|
||||
memory.append(QString(":%1").arg(MAX_FSIZE));
|
||||
}
|
||||
arguments << bcd.getDFUArgs() << "--dfuse-address" << memory; // removed for Horus, is it really needed? << "-d" << "0483:df11";
|
||||
args << bcd.getDFUArgs();
|
||||
if (!filename.endsWith(".dfu")) {
|
||||
args << "--dfuse-address" << memory;
|
||||
}
|
||||
args << "-d" << "0483:df11";
|
||||
QString fullcmd = cmd + filename;
|
||||
|
||||
arguments << "" << fullcmd;
|
||||
|
||||
return arguments;
|
||||
args << "" << fullcmd;
|
||||
return args;
|
||||
}
|
||||
|
||||
QStringList getSambaArgs(const QString &tcl)
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#ifdef INIT_IMPORT
|
||||
#undef INIT_IMPORT
|
||||
#ifdef FRSKY
|
||||
frskyStreaming = 20;
|
||||
telemetryStreaming = 20;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ void registerSimulators()
|
||||
}
|
||||
}
|
||||
|
||||
SimulatorFactory *getSimulatorFactory(const QString &name)
|
||||
SimulatorFactory * getSimulatorFactory(const QString & name)
|
||||
{
|
||||
QString simuName = name;
|
||||
while(1) {
|
||||
@@ -85,6 +85,8 @@ SimulatorFactory *getSimulatorFactory(const QString &name)
|
||||
if (pos <= 0)
|
||||
break;
|
||||
simuName = simuName.mid(0, pos);
|
||||
if (simuName.count('-') == 0)
|
||||
break;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+9
-9
@@ -13,29 +13,29 @@ cd build
|
||||
SET COMMON_OPTIONS=-DCMAKE_PREFIX_PATH=C:\Qt\5.6\msvc2015 -DALLOW_NIGHTLY_BUILDS=YES -DVERSION_SUFFIX=%1
|
||||
|
||||
cmake %COMMON_OPTIONS% -DPCB=9X %CODE_DIR%
|
||||
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" radio\src\targets\simu\opentx-simulator.vcxproj /t:Rebuild /p:Configuration=Release
|
||||
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" radio\src\targets\simu\libsimulator.vcxproj /t:Rebuild /p:Configuration=Release
|
||||
|
||||
cmake %COMMON_OPTIONS% -DPCB=GRUVIN9X %CODE_DIR%
|
||||
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" radio\src\targets\simu\opentx-simulator.vcxproj /t:Rebuild /p:Configuration=Release
|
||||
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" radio\src\targets\simu\libsimulator.vcxproj /t:Rebuild /p:Configuration=Release
|
||||
|
||||
cmake %COMMON_OPTIONS% -DPCB=MEGA2560 %CODE_DIR%
|
||||
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" radio\src\targets\simu\opentx-simulator.vcxproj /t:Rebuild /p:Configuration=Release
|
||||
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" radio\src\targets\simu\libsimulator.vcxproj /t:Rebuild /p:Configuration=Release
|
||||
|
||||
cmake %COMMON_OPTIONS% -DPCB=SKY9X %CODE_DIR%
|
||||
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" radio\src\targets\simu\opentx-simulator.vcxproj /t:Rebuild /p:Configuration=Release
|
||||
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" radio\src\targets\simu\libsimulator.vcxproj /t:Rebuild /p:Configuration=Release
|
||||
|
||||
cmake %COMMON_OPTIONS% -DPCB=9XRPRO %CODE_DIR%
|
||||
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" radio\src\targets\simu\opentx-simulator.vcxproj /t:Rebuild /p:Configuration=Release
|
||||
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" radio\src\targets\simu\libsimulator.vcxproj /t:Rebuild /p:Configuration=Release
|
||||
|
||||
cmake %COMMON_OPTIONS% -DPCB=TARANIS %CODE_DIR%
|
||||
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" radio\src\targets\simu\opentx-simulator.vcxproj /t:Rebuild /p:Configuration=Release
|
||||
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" radio\src\targets\simu\libsimulator.vcxproj /t:Rebuild /p:Configuration=Release
|
||||
|
||||
cmake %COMMON_OPTIONS% -DPCB=TARANIS -DPCBREV=REVPLUS %CODE_DIR%
|
||||
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" radio\src\targets\simu\opentx-simulator.vcxproj /t:Rebuild /p:Configuration=Release
|
||||
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" radio\src\targets\simu\libsimulator.vcxproj /t:Rebuild /p:Configuration=Release
|
||||
|
||||
cmake %COMMON_OPTIONS% -DPCB=TARANIS -DPCBREV=REV9E %CODE_DIR%
|
||||
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" radio\src\targets\simu\opentx-simulator.vcxproj /t:Rebuild /p:Configuration=Release
|
||||
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" radio\src\targets\simu\libsimulator.vcxproj /t:Rebuild /p:Configuration=Release
|
||||
|
||||
cmake %COMMON_OPTIONS% -DPCB=HORUS %CODE_DIR%
|
||||
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" radio\src\targets\simu\opentx-simulator.vcxproj /t:Rebuild /p:Configuration=Release
|
||||
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" radio\src\targets\simu\libsimulator.vcxproj /t:Rebuild /p:Configuration=Release
|
||||
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" companion\src\installer.vcxproj /t:Rebuild /p:Configuration=Release
|
||||
|
||||
+50
-12
@@ -9,10 +9,10 @@ option(CURVES "Curves" ON)
|
||||
option(GVARS "Global variables")
|
||||
option(GUI "GUI enabled" ON)
|
||||
option(SPLASH "Splash enabled" ON)
|
||||
option(PPM_UNIT "PPM display unit (US/PERCENT_PREC1/PERCENT_PREC0)" PERCENT_PREC0)
|
||||
set(PPM_UNIT "PERCENT_PREC1" CACHE STRING "PPM display unit (US/PERCENT_PREC1/PERCENT_PREC0)")
|
||||
option(PPM_CENTER_ADJUSTABLE "PPM center adjustable" OFF)
|
||||
option(PPM_LIMITS_SYMETRICAL "PPM limits symetrical" OFF)
|
||||
option(OVERRIDE_CHANNEL_FUNCTION "OverrideChannel function available" OFF)
|
||||
option(OVERRIDE_CHANNEL_FUNCTION "OverrideChannel function available" ON)
|
||||
option(DANGEROUS_MODULE_FUNCTIONS "Dangerous module functions (RangeCheck / Bind / Module OFF, etc.) available" OFF)
|
||||
option(FAI "Competition mode (no telemetry)" OFF)
|
||||
option(AUTOSOURCE "Automatic source detection in menus" ON)
|
||||
@@ -407,11 +407,22 @@ if(CPU_FAMILY STREQUAL STM32)
|
||||
STM32_USB_Device_Library/Core/src/usbd_ioreq.c
|
||||
STM32_USB_Device_Library/Core/src/usbd_req.c
|
||||
)
|
||||
set(FIRMWARE_TARGET_SRC ${FIRMWARE_TARGET_SRC} usb_bsp.c usbd_desc.c usbd_usr.cpp)
|
||||
set(FIRMWARE_TARGET_SRC
|
||||
${FIRMWARE_TARGET_SRC}
|
||||
usb_bsp.c
|
||||
usbd_desc.c
|
||||
usbd_usr.cpp
|
||||
)
|
||||
if(USB STREQUAL SERIAL)
|
||||
add_definitions(-DUSB_SERIAL)
|
||||
set(FIRMWARE_TARGET_SRC ${FIRMWARE_TARGET_SRC} usbd_cdc.cpp)
|
||||
set(STM32USB_SRC ${STM32USB_SRC} STM32_USB_Device_Library/Class/cdc/src/usbd_cdc_core.c)
|
||||
set(FIRMWARE_TARGET_SRC
|
||||
${FIRMWARE_TARGET_SRC}
|
||||
usbd_cdc.cpp
|
||||
)
|
||||
set(STM32USB_SRC
|
||||
${STM32USB_SRC}
|
||||
STM32_USB_Device_Library/Class/cdc/src/usbd_cdc_core.c
|
||||
)
|
||||
elseif(USB STREQUAL MASSSTORAGE)
|
||||
add_definitions(-DUSB_MASS_STORAGE)
|
||||
set(STM32USB_SRC
|
||||
@@ -421,13 +432,22 @@ if(CPU_FAMILY STREQUAL STM32)
|
||||
STM32_USB_Device_Library/Class/msc/src/usbd_msc_bot.c
|
||||
STM32_USB_Device_Library/Class/msc/src/usbd_msc_core.c
|
||||
)
|
||||
set(FIRMWARE_TARGET_SRC ${FIRMWARE_TARGET_SRC} usbd_storage_msd.cpp)
|
||||
set(FIRMWARE_TARGET_SRC
|
||||
${FIRMWARE_TARGET_SRC}
|
||||
usbd_storage_msd.cpp
|
||||
)
|
||||
else()
|
||||
add_definitions(-DUSB_JOYSTICK)
|
||||
set(FIRMWARE_TARGET_SRC ${FIRMWARE_TARGET_SRC} usbd_hid_joystick.c)
|
||||
set(FIRMWARE_TARGET_SRC
|
||||
${FIRMWARE_TARGET_SRC}
|
||||
usbd_hid_joystick.c
|
||||
)
|
||||
endif()
|
||||
if(GVARS)
|
||||
set(GUI_SRC ${GUI_SRC} menu_model_gvars.cpp)
|
||||
set(GUI_SRC
|
||||
${GUI_SRC}
|
||||
menu_model_gvars.cpp
|
||||
)
|
||||
endif()
|
||||
set(FIRMWARE_SRC
|
||||
${FIRMWARE_SRC}
|
||||
@@ -436,12 +456,22 @@ if(CPU_FAMILY STREQUAL STM32)
|
||||
targets/taranis/configure_pins.cpp
|
||||
)
|
||||
foreach(FILE ${STM32LIB_SRC})
|
||||
set(FIRMWARE_SRC ${FIRMWARE_SRC} ${STM32LIB_DIR}/${FILE})
|
||||
set(FIRMWARE_SRC
|
||||
${FIRMWARE_SRC}
|
||||
${STM32LIB_DIR}/${FILE}
|
||||
)
|
||||
endforeach()
|
||||
foreach(FILE ${STM32USB_SRC})
|
||||
set(FIRMWARE_SRC ${FIRMWARE_SRC} ${STM32USB_DIR}/${FILE})
|
||||
set(FIRMWARE_SRC
|
||||
${FIRMWARE_SRC}
|
||||
${STM32USB_DIR}/${FILE}
|
||||
)
|
||||
endforeach()
|
||||
set(SRC ${SRC} sbus.cpp)
|
||||
set(SRC
|
||||
${SRC}
|
||||
sbus.cpp
|
||||
telemetry/crossfire.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if(ARCH STREQUAL ARM)
|
||||
@@ -512,6 +542,8 @@ if(ARCH STREQUAL ARM)
|
||||
tasks_arm.cpp
|
||||
audio_arm.cpp
|
||||
telemetry/telemetry.cpp
|
||||
telemetry/telemetry_holders.cpp
|
||||
telemetry/telemetry_sensors.cpp
|
||||
telemetry/frsky.cpp
|
||||
telemetry/frsky_d_arm.cpp
|
||||
telemetry/frsky_sport.cpp
|
||||
@@ -637,7 +669,7 @@ else()
|
||||
option(GPS "GPS support" ON)
|
||||
option(VARIO "Vario support" ON)
|
||||
add_definitions(-DFRSKY)
|
||||
set(SRC ${SRC} telemetry/frsky.cpp telemetry/frsky_d.cpp)
|
||||
set(SRC ${SRC} telemetry/telemetry.cpp telemetry/telemetry_holders.cpp telemetry/frsky.cpp telemetry/frsky_d.cpp)
|
||||
set(FIRMWARE_SRC ${FIRMWARE_SRC} targets/common_avr/telemetry_driver.cpp)
|
||||
set(GUI_SRC ${GUI_SRC} view_telemetry.cpp)
|
||||
if(FRSKY_HUB)
|
||||
@@ -918,7 +950,13 @@ if(ARCH STREQUAL ARM)
|
||||
|
||||
set(COMMON_FLAGS "-mcpu=${MCU} -mthumb -fomit-frame-pointer -fverbose-asm -Wa,-ahlms=firmware.lst -O${OPT} -gdwarf-2 -DHSE_VALUE=${HSE_VALUE} -fno-exceptions -fdata-sections -ffunction-sections ${WARNING_FLAGS}")
|
||||
set(CMAKE_C_FLAGS "${COMMON_FLAGS} -Wimplicit")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${COMMON_FLAGS} -Wimplicit -g")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${COMMON_FLAGS} -Wimplicit")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${COMMON_FLAGS} -Wimplicit -g")
|
||||
set(CMAKE_CXX_FLAGS "${COMMON_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${COMMON_FLAGS} -g")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${COMMON_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${COMMON_FLAGS} -g")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-mcpu=${MCU} -mthumb -lm -T${RADIO_SRC_DIRECTORY}/${LINKER_SCRIPT} -Wl,-Map=firmware.map,--cref,--no-warn-mismatch,--gc-sections")
|
||||
|
||||
if(PCB STREQUAL TARANIS)
|
||||
|
||||
-2087
File diff suppressed because it is too large
Load Diff
@@ -18,4 +18,4 @@ add_bitmaps_target(horus_layouts_masks "${RADIO_SRC_DIRECTORY}/gui/horus/layouts
|
||||
add_bitmaps_target(horus_themes_bitmaps "${RADIO_SRC_DIRECTORY}/gui/horus/themes/*.png" 480 5/6/5)
|
||||
add_bitmaps_target(horus_fonts ${RADIO_SRC_DIRECTORY}/fonts/horus/*.png 480 8bits)
|
||||
add_bitmaps_target(horus_volume_masks ${RADIO_SRC_DIRECTORY}/bitmaps/horus/volume/*.png 480 8bits)
|
||||
add_dependencies(horus_bitmaps horus_volume_masks horus_calibration_bitmaps horus_alpha_bitmaps horus_alpha_calibration_bitmaps horus_masks horus_slider_masks horus_themes_bitmaps horus_layouts_masks horus_fonts)
|
||||
add_dependencies(horus_bitmaps horus_calibration_bitmaps horus_button_bitmaps horus_alpha_bitmaps horus_alpha_calibration_bitmaps horus_masks horus_slider_masks horus_layouts_masks horus_themes_bitmaps horus_fonts horus_volume_masks)
|
||||
|
||||
+50
-5
@@ -20,8 +20,8 @@
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
/* CRC16 implementation according to CCITT standards */
|
||||
static const unsigned short crc16tab[256]= {
|
||||
// CRC16 implementation according to CCITT standards
|
||||
static const unsigned short crc16tab[256] = {
|
||||
0x0000,0x1021,0x2042,0x3063,0x4084,0x50a5,0x60c6,0x70e7,
|
||||
0x8108,0x9129,0xa14a,0xb16b,0xc18c,0xd1ad,0xe1ce,0xf1ef,
|
||||
0x1231,0x0210,0x3273,0x2252,0x52b5,0x4294,0x72f7,0x62d6,
|
||||
@@ -56,11 +56,56 @@ static const unsigned short crc16tab[256]= {
|
||||
0x6e17,0x7e36,0x4e55,0x5e74,0x2e93,0x3eb2,0x0ed1,0x1ef0
|
||||
};
|
||||
|
||||
uint16_t crc16(uint8_t * buf, uint32_t len)
|
||||
uint16_t crc16(const uint8_t * buf, uint32_t len)
|
||||
{
|
||||
uint16_t crc = 0;
|
||||
for (uint32_t counter=0; counter<len; counter++) {
|
||||
crc = (crc<<8) ^ crc16tab[ ((crc>>8) ^ *buf++ ) & 0x00FF];
|
||||
for (uint32_t i=0; i<len; i++) {
|
||||
crc = (crc<<8) ^ crc16tab[((crc>>8) ^ *buf++) & 0x00FF];
|
||||
}
|
||||
return crc;
|
||||
}
|
||||
|
||||
// CRC8 implementation with polynom = x^8+x^7+x^6+x^4+x^2+1 (0xD5)
|
||||
unsigned char crc8tab[256] = {
|
||||
0x00, 0xD5, 0x7F, 0xAA, 0xFE, 0x2B, 0x81, 0x54,
|
||||
0x29, 0xFC, 0x56, 0x83, 0xD7, 0x02, 0xA8, 0x7D,
|
||||
0x52, 0x87, 0x2D, 0xF8, 0xAC, 0x79, 0xD3, 0x06,
|
||||
0x7B, 0xAE, 0x04, 0xD1, 0x85, 0x50, 0xFA, 0x2F,
|
||||
0xA4, 0x71, 0xDB, 0x0E, 0x5A, 0x8F, 0x25, 0xF0,
|
||||
0x8D, 0x58, 0xF2, 0x27, 0x73, 0xA6, 0x0C, 0xD9,
|
||||
0xF6, 0x23, 0x89, 0x5C, 0x08, 0xDD, 0x77, 0xA2,
|
||||
0xDF, 0x0A, 0xA0, 0x75, 0x21, 0xF4, 0x5E, 0x8B,
|
||||
0x9D, 0x48, 0xE2, 0x37, 0x63, 0xB6, 0x1C, 0xC9,
|
||||
0xB4, 0x61, 0xCB, 0x1E, 0x4A, 0x9F, 0x35, 0xE0,
|
||||
0xCF, 0x1A, 0xB0, 0x65, 0x31, 0xE4, 0x4E, 0x9B,
|
||||
0xE6, 0x33, 0x99, 0x4C, 0x18, 0xCD, 0x67, 0xB2,
|
||||
0x39, 0xEC, 0x46, 0x93, 0xC7, 0x12, 0xB8, 0x6D,
|
||||
0x10, 0xC5, 0x6F, 0xBA, 0xEE, 0x3B, 0x91, 0x44,
|
||||
0x6B, 0xBE, 0x14, 0xC1, 0x95, 0x40, 0xEA, 0x3F,
|
||||
0x42, 0x97, 0x3D, 0xE8, 0xBC, 0x69, 0xC3, 0x16,
|
||||
0xEF, 0x3A, 0x90, 0x45, 0x11, 0xC4, 0x6E, 0xBB,
|
||||
0xC6, 0x13, 0xB9, 0x6C, 0x38, 0xED, 0x47, 0x92,
|
||||
0xBD, 0x68, 0xC2, 0x17, 0x43, 0x96, 0x3C, 0xE9,
|
||||
0x94, 0x41, 0xEB, 0x3E, 0x6A, 0xBF, 0x15, 0xC0,
|
||||
0x4B, 0x9E, 0x34, 0xE1, 0xB5, 0x60, 0xCA, 0x1F,
|
||||
0x62, 0xB7, 0x1D, 0xC8, 0x9C, 0x49, 0xE3, 0x36,
|
||||
0x19, 0xCC, 0x66, 0xB3, 0xE7, 0x32, 0x98, 0x4D,
|
||||
0x30, 0xE5, 0x4F, 0x9A, 0xCE, 0x1B, 0xB1, 0x64,
|
||||
0x72, 0xA7, 0x0D, 0xD8, 0x8C, 0x59, 0xF3, 0x26,
|
||||
0x5B, 0x8E, 0x24, 0xF1, 0xA5, 0x70, 0xDA, 0x0F,
|
||||
0x20, 0xF5, 0x5F, 0x8A, 0xDE, 0x0B, 0xA1, 0x74,
|
||||
0x09, 0xDC, 0x76, 0xA3, 0xF7, 0x22, 0x88, 0x5D,
|
||||
0xD6, 0x03, 0xA9, 0x7C, 0x28, 0xFD, 0x57, 0x82,
|
||||
0xFF, 0x2A, 0x80, 0x55, 0x01, 0xD4, 0x7E, 0xAB,
|
||||
0x84, 0x51, 0xFB, 0x2E, 0x7A, 0xAF, 0x05, 0xD0,
|
||||
0xAD, 0x78, 0xD2, 0x07, 0x53, 0x86, 0x2C, 0xF9
|
||||
};
|
||||
|
||||
uint8_t crc8(const uint8_t * ptr, uint32_t len)
|
||||
{
|
||||
uint8_t crc = 0;
|
||||
for (uint32_t i=0; i<len; i++) {
|
||||
crc = crc8tab[crc ^ *ptr++];
|
||||
}
|
||||
return crc;
|
||||
}
|
||||
@@ -346,6 +346,7 @@ enum TelemetryUnit {
|
||||
UNIT_PERCENT,
|
||||
UNIT_MAH,
|
||||
UNIT_WATTS,
|
||||
UNIT_MILLIWATTS,
|
||||
UNIT_DB,
|
||||
UNIT_RPMS,
|
||||
UNIT_G,
|
||||
@@ -473,7 +474,7 @@ enum TelemetryUnit {
|
||||
UNIT_SECONDS,
|
||||
UNIT_RPMS,
|
||||
UNIT_G,
|
||||
UNIT_HDG,
|
||||
UNIT_HDG
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
@@ -622,9 +622,7 @@ PACK(struct MavlinkTelemetryData {
|
||||
*/
|
||||
|
||||
#if defined(CPUARM)
|
||||
// TODO struct as others
|
||||
PACK(class TelemetrySensor {
|
||||
public:
|
||||
PACK(struct TelemetrySensor {
|
||||
union {
|
||||
uint16_t id; // data identifier, for FrSky we can reuse existing ones. Source unit is derived from type.
|
||||
uint16_t persistentValue;
|
||||
|
||||
@@ -609,7 +609,7 @@ void menuModelTelemetry(uint8_t event)
|
||||
case ITEM_TELEMETRY_A2_LABEL:
|
||||
lcd_putsLeft(y, STR_ACHANNEL);
|
||||
lcdDrawNumber(2*FW, y, ch+1, 0);
|
||||
putsTelemetryChannelValue(TELEM_COL2+6*FW, y, dest, frskyData.analog[ch].value, LEFT);
|
||||
putsTelemetryChannelValue(TELEM_COL2+6*FW, y, dest, telemetryData.analog[ch].value, LEFT);
|
||||
break;
|
||||
|
||||
case ITEM_TELEMETRY_A1_RANGE:
|
||||
@@ -739,7 +739,7 @@ void menuModelTelemetry(uint8_t event)
|
||||
case ITEM_TELEMETRY_FAS_OFFSET:
|
||||
lcd_putsLeft(y, STR_FAS_OFFSET);
|
||||
lcdDrawNumber(TELEM_COL2, y, g_model.frsky.fasOffset, attr|LEFT|PREC1);
|
||||
lcdDrawNumber(TELEM_COL2+6*FW, y, frskyData.hub.current, LEFT|PREC1);
|
||||
lcdDrawNumber(TELEM_COL2+6*FW, y, telemetryData.hub.current, LEFT|PREC1);
|
||||
lcdDrawChar(TELEM_COL2+8*FW, y, 'A');
|
||||
if (attr) g_model.frsky.fasOffset = checkIncDec(event, g_model.frsky.fasOffset, -120, 120, EE_MODEL);
|
||||
break;
|
||||
|
||||
@@ -38,7 +38,7 @@ void displayRssiLine()
|
||||
lcdDrawSolidHorizontalLine(0, 55, 128, 0); // separator
|
||||
uint8_t rssi;
|
||||
#if !defined(CPUARM)
|
||||
rssi = min((uint8_t)99, frskyData.rssi[1].value);
|
||||
rssi = min((uint8_t)99, telemetryData.rssi[1].value);
|
||||
lcd_putsLeft(STATUS_BAR_Y, STR_TX); lcdDrawNumber(4*FW+1, STATUS_BAR_Y, rssi, LEADING0, 2);
|
||||
lcdDrawRect(BAR_LEFT+1, 57, 38, 7);
|
||||
lcdDrawFilledRect(BAR_LEFT+1, 58, 4*rssi/11, 5, (rssi < getRssiAlarmValue(0)) ? DOTTED : SOLID);
|
||||
@@ -59,17 +59,17 @@ void displayRssiLine()
|
||||
void displayGpsTime()
|
||||
{
|
||||
uint8_t att = (TELEMETRY_STREAMING() ? LEFT|LEADING0 : LEFT|LEADING0|BLINK);
|
||||
lcdDrawNumber(CENTER_OFS+6*FW+7, STATUS_BAR_Y, frskyData.hub.hour, att, 2);
|
||||
lcdDrawNumber(CENTER_OFS+6*FW+7, STATUS_BAR_Y, telemetryData.hub.hour, att, 2);
|
||||
lcdDrawChar(CENTER_OFS+8*FW+4, STATUS_BAR_Y, ':', att);
|
||||
lcdDrawNumber(CENTER_OFS+9*FW+2, STATUS_BAR_Y, frskyData.hub.min, att, 2);
|
||||
lcdDrawNumber(CENTER_OFS+9*FW+2, STATUS_BAR_Y, telemetryData.hub.min, att, 2);
|
||||
lcdDrawChar(CENTER_OFS+11*FW-1, STATUS_BAR_Y, ':', att);
|
||||
lcdDrawNumber(CENTER_OFS+12*FW-3, STATUS_BAR_Y, frskyData.hub.sec, att, 2);
|
||||
lcdDrawNumber(CENTER_OFS+12*FW-3, STATUS_BAR_Y, telemetryData.hub.sec, att, 2);
|
||||
lcdInvertLastLine();
|
||||
}
|
||||
|
||||
void displayGpsCoord(uint8_t y, char direction, int16_t bp, int16_t ap)
|
||||
{
|
||||
if (frskyData.hub.gpsFix >= 0) {
|
||||
if (telemetryData.hub.gpsFix >= 0) {
|
||||
if (!direction) direction = '-';
|
||||
lcdDrawNumber(TELEM_2ND_COLUMN, y, bp / 100, LEFT); // ddd before '.'
|
||||
lcdDrawChar(lcdLastPos, y, '@');
|
||||
@@ -107,9 +107,9 @@ void displayVoltageScreenLine(uint8_t y, uint8_t index)
|
||||
{
|
||||
drawStringWithIndex(0, y, STR_A, index+1, 0);
|
||||
if (TELEMETRY_STREAMING()) {
|
||||
putsTelemetryChannelValue(3*FW+6*FW+4, y-FH, index+TELEM_A1-1, frskyData.analog[index].value, DBLSIZE);
|
||||
lcdDrawChar(12*FW-1, y-FH, '<'); putsTelemetryChannelValue(17*FW, y-FH, index+TELEM_A1-1, frskyData.analog[index].min, NO_UNIT);
|
||||
lcdDrawChar(12*FW, y, '>'); putsTelemetryChannelValue(17*FW, y, index+TELEM_A1-1, frskyData.analog[index].max, NO_UNIT);
|
||||
putsTelemetryChannelValue(3*FW+6*FW+4, y-FH, index+TELEM_A1-1, telemetryData.analog[index].value, DBLSIZE);
|
||||
lcdDrawChar(12*FW-1, y-FH, '<'); putsTelemetryChannelValue(17*FW, y-FH, index+TELEM_A1-1, telemetryData.analog[index].min, NO_UNIT);
|
||||
lcdDrawChar(12*FW, y, '>'); putsTelemetryChannelValue(17*FW, y, index+TELEM_A1-1, telemetryData.analog[index].max, NO_UNIT);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -142,10 +142,10 @@ void displayVoltagesScreen()
|
||||
break;
|
||||
#if defined(FRSKY_HUB)
|
||||
case FRSKY_VOLTS_SOURCE_FAS:
|
||||
putsTelemetryChannelValue(3*FW+6*FW+4, FH, TELEM_VFAS-1, frskyData.hub.vfas, DBLSIZE);
|
||||
putsTelemetryChannelValue(3*FW+6*FW+4, FH, TELEM_VFAS-1, telemetryData.hub.vfas, DBLSIZE);
|
||||
break;
|
||||
case FRSKY_VOLTS_SOURCE_CELLS:
|
||||
putsTelemetryChannelValue(3*FW+6*FW+4, FH, TELEM_CELLS_SUM-1, frskyData.hub.cellsSum, DBLSIZE);
|
||||
putsTelemetryChannelValue(3*FW+6*FW+4, FH, TELEM_CELLS_SUM-1, telemetryData.hub.cellsSum, DBLSIZE);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
@@ -159,13 +159,13 @@ void displayVoltagesScreen()
|
||||
break;
|
||||
#if defined(FRSKY_HUB)
|
||||
case FRSKY_CURRENT_SOURCE_FAS:
|
||||
putsTelemetryChannelValue(3*FW+6*FW+4, 3*FH, TELEM_CURRENT-1, frskyData.hub.current, DBLSIZE);
|
||||
putsTelemetryChannelValue(3*FW+6*FW+4, 3*FH, TELEM_CURRENT-1, telemetryData.hub.current, DBLSIZE);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
putsTelemetryChannelValue(4, 5*FH, TELEM_POWER-1, frskyData.hub.power, LEFT|DBLSIZE);
|
||||
putsTelemetryChannelValue(3*FW+4+4*FW+6*FW+FW, 5*FH, TELEM_CONSUMPTION-1, frskyData.hub.currentConsumption, DBLSIZE);
|
||||
putsTelemetryChannelValue(4, 5*FH, TELEM_POWER-1, telemetryData.hub.power, LEFT|DBLSIZE);
|
||||
putsTelemetryChannelValue(3*FW+4+4*FW+6*FW+FW, 5*FH, TELEM_CONSUMPTION-1, telemetryData.hub.currentConsumption, DBLSIZE);
|
||||
}
|
||||
else {
|
||||
displayVoltageScreenLine(analog > 0 ? 5*FH : 4*FH, analog ? 2-analog : 0);
|
||||
@@ -174,11 +174,11 @@ void displayVoltagesScreen()
|
||||
|
||||
#if defined(FRSKY_HUB)
|
||||
// Cells voltage
|
||||
if (frskyData.hub.cellsCount > 0) {
|
||||
if (telemetryData.hub.cellsCount > 0) {
|
||||
uint8_t y = 1*FH;
|
||||
for (uint8_t k=0; k<frskyData.hub.cellsCount && k<6; k++) {
|
||||
for (uint8_t k=0; k<telemetryData.hub.cellsCount && k<6; k++) {
|
||||
#if defined(GAUGES)
|
||||
uint8_t attr = (barsThresholds[THLD_CELL] && frskyData.hub.cellVolts[k] < barsThresholds[THLD_CELL]) ? BLINK|PREC2 : PREC2;
|
||||
uint8_t attr = (barsThresholds[THLD_CELL] && telemetryData.hub.cellVolts[k] < barsThresholds[THLD_CELL]) ? BLINK|PREC2 : PREC2;
|
||||
#else
|
||||
uint8_t attr = PREC2;
|
||||
#endif
|
||||
@@ -198,20 +198,20 @@ void displayAfterFlightScreen()
|
||||
if (IS_GPS_AVAILABLE()) {
|
||||
// Latitude
|
||||
lcd_putsLeft(line, STR_LATITUDE);
|
||||
displayGpsCoord(line, frskyData.hub.gpsLatitudeNS, frskyData.hub.gpsLatitude_bp, frskyData.hub.gpsLatitude_ap);
|
||||
displayGpsCoord(line, telemetryData.hub.gpsLatitudeNS, telemetryData.hub.gpsLatitude_bp, telemetryData.hub.gpsLatitude_ap);
|
||||
// Longitude
|
||||
line+=1*FH+1;
|
||||
lcd_putsLeft(line, STR_LONGITUDE);
|
||||
displayGpsCoord(line, frskyData.hub.gpsLongitudeEW, frskyData.hub.gpsLongitude_bp, frskyData.hub.gpsLongitude_ap);
|
||||
displayGpsCoord(line, telemetryData.hub.gpsLongitudeEW, telemetryData.hub.gpsLongitude_bp, telemetryData.hub.gpsLongitude_ap);
|
||||
displayGpsTime();
|
||||
line+=1*FH+1;
|
||||
}
|
||||
// Rssi
|
||||
lcd_putsLeft(line, STR_MINRSSI);
|
||||
lcdDrawText(TELEM_2ND_COLUMN, line, STR_TX);
|
||||
lcdDrawNumber(TELEM_2ND_COLUMN+3*FW, line, frskyData.rssi[1].min, LEFT|LEADING0, 2);
|
||||
lcdDrawNumber(TELEM_2ND_COLUMN+3*FW, line, telemetryData.rssi[1].min, LEFT|LEADING0, 2);
|
||||
lcdDrawText(TELEM_2ND_COLUMN+6*FW, line, STR_RX);
|
||||
lcdDrawNumber(TELEM_2ND_COLUMN+9*FW, line, frskyData.rssi[0].min, LEFT|LEADING0, 2);
|
||||
lcdDrawNumber(TELEM_2ND_COLUMN+9*FW, line, telemetryData.rssi[0].min, LEFT|LEADING0, 2);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -372,9 +372,9 @@ bool displayNumbersTelemetryScreen(FrSkyScreenData & screen)
|
||||
#if defined(FRSKY_HUB)
|
||||
if (field == TELEM_ACC) {
|
||||
lcd_putsLeft(STATUS_BAR_Y, STR_ACCEL);
|
||||
lcdDrawNumber(4*FW, STATUS_BAR_Y, frskyData.hub.accelX, LEFT|PREC2);
|
||||
lcdDrawNumber(10*FW, STATUS_BAR_Y, frskyData.hub.accelY, LEFT|PREC2);
|
||||
lcdDrawNumber(16*FW, STATUS_BAR_Y, frskyData.hub.accelZ, LEFT|PREC2);
|
||||
lcdDrawNumber(4*FW, STATUS_BAR_Y, telemetryData.hub.accelX, LEFT|PREC2);
|
||||
lcdDrawNumber(10*FW, STATUS_BAR_Y, telemetryData.hub.accelY, LEFT|PREC2);
|
||||
lcdDrawNumber(16*FW, STATUS_BAR_Y, telemetryData.hub.accelZ, LEFT|PREC2);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -457,11 +457,21 @@ bool isSourceAvailableInResetSpecialFunction(int index)
|
||||
|
||||
bool isModuleAvailable(int module)
|
||||
{
|
||||
#if defined(CROSSFIRE)
|
||||
if (module == MODULE_TYPE_CROSSFIRE && g_model.moduleData[INTERNAL_MODULE].rfProtocol != RF_PROTO_OFF) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isRfProtocolAvailable(int protocol)
|
||||
{
|
||||
#if defined(CROSSFIRE)
|
||||
if (protocol != RF_PROTO_OFF && g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_CROSSFIRE) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
#if defined(MODULE_D16_EU_ONLY_SUPPORT)
|
||||
if (protocol == RF_PROTO_D8) {
|
||||
return false;
|
||||
|
||||
@@ -256,7 +256,7 @@ void BitmapBuffer::drawFontPattern(coord_t x, coord_t y, const uint8_t * font, c
|
||||
lcdNextPos = x + width;
|
||||
}
|
||||
|
||||
void BitmapBuffer::drawSizedText(coord_t x, coord_t y, const pm_char * s, uint8_t len, LcdFlags flags)
|
||||
void BitmapBuffer::drawSizedText(coord_t x, coord_t y, const char * s, uint8_t len, LcdFlags flags)
|
||||
{
|
||||
int width = getTextWidth(s, len, flags);
|
||||
int height = getFontHeight(flags);
|
||||
@@ -279,12 +279,6 @@ void BitmapBuffer::drawSizedText(coord_t x, coord_t y, const pm_char * s, uint8_
|
||||
drawSolidFilledRect(x-INVERT_HORZ_MARGIN, y, width+2*INVERT_HORZ_MARGIN, INVERT_LINE_HEIGHT, TEXT_INVERTED_BGCOLOR);
|
||||
}
|
||||
|
||||
char str[256];
|
||||
if (flags & ZCHAR)
|
||||
strcat_zchar(str, s, len);
|
||||
else
|
||||
strAppend(str, s, len);
|
||||
|
||||
const coord_t orig_x = x;
|
||||
bool setx = false;
|
||||
while (len--) {
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "../../opentx.h"
|
||||
#include "opentx.h"
|
||||
|
||||
bool menuGeneralVersion(evt_t event)
|
||||
{
|
||||
|
||||
@@ -426,7 +426,7 @@ bool menuModelTelemetry(evt_t event)
|
||||
lcdDrawSizedText(60, y, g_model.telemetrySensors[index].label, TELEM_LABEL_LEN, ZCHAR);
|
||||
TelemetryItem & telemetryItem = telemetryItems[index];
|
||||
if (telemetryItem.isFresh()) {
|
||||
lcdDrawText(100, y, "*");
|
||||
lcdDrawText(130, y, "*");
|
||||
}
|
||||
if (telemetryItem.isAvailable()) {
|
||||
LcdFlags color = telemetryItem.isOld() ? ALARM_COLOR : TEXT_COLOR;
|
||||
|
||||
@@ -487,18 +487,21 @@ bool menuScreenSetup(int index, evt_t event)
|
||||
currentContainer = currentScreen;
|
||||
bool needsOffsetCheck = (menuVerticalPosition != 0 || menuHorizontalPosition < 0);
|
||||
|
||||
const ZoneOption * options = currentScreen->getFactory()->getOptions();
|
||||
int optionsCount = getOptionsCount(options);
|
||||
linesCount = ITEM_SCREEN_SETUP_LAYOUT_OPTION1 + optionsCount;
|
||||
|
||||
char title[] = "Main view X";
|
||||
title[sizeof(title)-2] = '1' + index;
|
||||
menuPageCount = updateMainviewsMenu();
|
||||
|
||||
uint8_t mstate_tab[2 + MAX_LAYOUT_OPTIONS] = { uint8_t(NAVIGATION_LINE_BY_LINE|uint8_t(countRegisteredLayouts-1)), ORPHAN_ROW };
|
||||
const ZoneOption * options = currentScreen->getFactory()->getOptions();
|
||||
int optionsCount = getOptionsCount(options);
|
||||
linesCount = ITEM_SCREEN_SETUP_LAYOUT_OPTION1 + optionsCount;
|
||||
if (menuPageCount > 3)
|
||||
++linesCount;
|
||||
|
||||
uint8_t mstate_tab[2 + MAX_LAYOUT_OPTIONS + 1] = { uint8_t(NAVIGATION_LINE_BY_LINE|uint8_t(countRegisteredLayouts-1)), ORPHAN_ROW };
|
||||
for (int i=0; i<optionsCount; i++) {
|
||||
mstate_tab[3+i] = getZoneOptionColumns(&options[i]);
|
||||
}
|
||||
mstate_tab[3+optionsCount] = 0; // The remove button
|
||||
|
||||
CUSTOM_MENU_WITH_OPTIONS(title, LBM_SCREENS_SETUP_ICONS, menuTabScreensSetup, menuPageCount, index+1, linesCount);
|
||||
|
||||
@@ -533,26 +536,33 @@ bool menuScreenSetup(int index, evt_t event)
|
||||
|
||||
default:
|
||||
{
|
||||
uint8_t index = k - ITEM_SCREEN_SETUP_LAYOUT_OPTION1;
|
||||
if (index < optionsCount) {
|
||||
const ZoneOption * option = &options[index];
|
||||
ZoneOptionValue * value = currentScreen->getOptionValue(index);
|
||||
uint8_t o = k - ITEM_SCREEN_SETUP_LAYOUT_OPTION1;
|
||||
if (o < optionsCount) {
|
||||
const ZoneOption * option = &options[o];
|
||||
ZoneOptionValue * value = currentScreen->getOptionValue(o);
|
||||
if (editZoneOption(y, option, value, attr, EE_MODEL, event)) {
|
||||
currentScreen->update();
|
||||
}
|
||||
}
|
||||
else if (menuPageCount > 3 && o == optionsCount) {
|
||||
drawButton(SCREENS_SETUP_2ND_COLUMN, y, STR_REMOVE_SCREEN, attr);
|
||||
if (attr && event == EVT_KEY_BREAK(KEY_ENTER)) {
|
||||
delete currentScreen;
|
||||
if (index != MAX_CUSTOM_SCREENS-1) {
|
||||
memmove(&g_model.screenData[index], &g_model.screenData[index + 1], sizeof(CustomScreenData) * (MAX_CUSTOM_SCREENS - index - 1));
|
||||
memmove(&customScreens[index], &customScreens[index + 1], sizeof(Layout *) * (MAX_CUSTOM_SCREENS - index - 1));
|
||||
}
|
||||
memset(&g_model.screenData[MAX_CUSTOM_SCREENS-1], 0, sizeof(CustomScreenData));
|
||||
customScreens[MAX_CUSTOM_SCREENS-1] = NULL;
|
||||
chainMenu(menuTabScreensSetup[index > 0 ? index : 1]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (menuVerticalPosition == -1 && index > 0 && event == EVT_KEY_LONG(KEY_ENTER)) {
|
||||
killEvents(KEY_ENTER);
|
||||
menuHorizontalPosition = index;
|
||||
POPUP_MENU_ADD_ITEM(STR_REMOVE_SCREEN);
|
||||
popupMenuHandler = onScreenSetupMenu;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -592,23 +602,10 @@ bool menuScreenAdd(evt_t event)
|
||||
if (event == EVT_KEY_BREAK(KEY_ENTER)) {
|
||||
customScreens[menuPageCount-2] = registeredLayouts[0]->create(&g_model.screenData[menuPageCount-2].layoutData);
|
||||
s_editMode = 0;
|
||||
menuHorizontalPosition = -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
SIMPLE_MENU_WITH_OPTIONS("Add main view", LBM_SCREENS_SETUP_ICONS, menuTabScreensSetup, menuPageCount, menuPageCount-1, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
void onScreenSetupMenu(const char * result)
|
||||
{
|
||||
if (result == STR_REMOVE_SCREEN) {
|
||||
delete customScreens[menuHorizontalPosition];
|
||||
if (menuHorizontalPosition != MAX_CUSTOM_SCREENS-1) {
|
||||
memmove(&g_model.screenData[menuHorizontalPosition], &g_model.screenData[menuHorizontalPosition + 1], sizeof(CustomScreenData) * (MAX_CUSTOM_SCREENS - menuHorizontalPosition - 1));
|
||||
memmove(&customScreens[menuHorizontalPosition], &customScreens[menuHorizontalPosition + 1], sizeof(Layout *) * (MAX_CUSTOM_SCREENS - menuHorizontalPosition - 1));
|
||||
}
|
||||
memset(&g_model.screenData[MAX_CUSTOM_SCREENS-1], 0, sizeof(CustomScreenData));
|
||||
customScreens[MAX_CUSTOM_SCREENS-1] = NULL;
|
||||
// chainMenu(menuMainviews[menuHorizontalPosition > 0 ? menuHorizontalPosition-1 : 0]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ void drawTopBar()
|
||||
theme->drawTopbarBackground(NULL);
|
||||
|
||||
// USB icon
|
||||
if (1/*usbPlugged()*/) {
|
||||
if (usbPlugged()) {
|
||||
lcdDrawBitmapPattern(LCD_W-98, 8, LBM_TOPMENU_USB, MENU_TITLE_COLOR);
|
||||
}
|
||||
|
||||
|
||||
@@ -137,10 +137,6 @@ bool menuMainView(evt_t event)
|
||||
killEvents(KEY_DOWN);
|
||||
break;
|
||||
|
||||
case EVT_ENTRY_UP:
|
||||
LOAD_MODEL_BITMAP();
|
||||
break;
|
||||
|
||||
case EVT_KEY_LONG(KEY_ENTER):
|
||||
killEvents(event);
|
||||
POPUP_MENU_ADD_ITEM(STR_MODEL_SELECT);
|
||||
@@ -157,17 +153,17 @@ bool menuMainView(evt_t event)
|
||||
case EVT_KEY_LONG(KEY_MODEL):
|
||||
killEvents(event);
|
||||
pushMenu(menuTabModel[0]);
|
||||
break;
|
||||
return false;
|
||||
|
||||
case EVT_KEY_LONG(KEY_RADIO):
|
||||
killEvents(event);
|
||||
pushMenu(menuTabGeneral[0]);
|
||||
break;
|
||||
return false;
|
||||
|
||||
case EVT_KEY_LONG(KEY_TELEM):
|
||||
killEvents(event);
|
||||
pushMenu(menuTabScreensSetup[1]);
|
||||
break;
|
||||
return false;
|
||||
|
||||
case EVT_KEY_BREAK(KEY_PGDN):
|
||||
storageDirty(EE_GENERAL);
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "../../opentx.h"
|
||||
#include "opentx.h"
|
||||
|
||||
enum menuModelTelemetryItems {
|
||||
ITEM_TELEMETRY_PROTOCOL_TYPE,
|
||||
|
||||
@@ -273,7 +273,6 @@ void displayTopBar()
|
||||
}
|
||||
|
||||
/* Audio volume */
|
||||
TRACE("%d", requiredSpeakerVolume);
|
||||
if (requiredSpeakerVolume == 0 || g_eeGeneral.beepMode == e_mode_quiet)
|
||||
LCD_ICON(BAR_VOLUME_X, BAR_Y, ICON_SPEAKER0);
|
||||
else if (requiredSpeakerVolume <= 6)
|
||||
|
||||
+24
-24
@@ -234,9 +234,9 @@ void writeLogs()
|
||||
|
||||
#if defined(FRSKY)
|
||||
#if !defined(CPUARM)
|
||||
f_printf(&g_oLogFile, "%d,%d,%d,", frskyStreaming, RAW_FRSKY_MINMAX(frskyData.rssi[0]), RAW_FRSKY_MINMAX(frskyData.rssi[1]));
|
||||
f_printf(&g_oLogFile, "%d,%d,%d,", telemetryStreaming, RAW_FRSKY_MINMAX(telemetryData.rssi[0]), RAW_FRSKY_MINMAX(telemetryData.rssi[1]));
|
||||
for (uint8_t i=0; i<MAX_FRSKY_A_CHANNELS; i++) {
|
||||
int16_t converted_value = applyChannelRatio(i, RAW_FRSKY_MINMAX(frskyData.analog[i]));
|
||||
int16_t converted_value = applyChannelRatio(i, RAW_FRSKY_MINMAX(telemetryData.analog[i]));
|
||||
f_printf(&g_oLogFile, "%d.%02d,", converted_value/100, converted_value%100);
|
||||
}
|
||||
|
||||
@@ -245,36 +245,36 @@ void writeLogs()
|
||||
|
||||
if (IS_USR_PROTO_FRSKY_HUB()) {
|
||||
f_printf(&g_oLogFile, "%4d-%02d-%02d,%02d:%02d:%02d,%03d.%04d%c,%03d.%04d%c,%03d.%02d," TELEMETRY_GPS_SPEED_FORMAT TELEMETRY_GPS_ALT_FORMAT TELEMETRY_BARO_ALT_FORMAT TELEMETRY_VSPEED_FORMAT TELEMETRY_ASPEED_FORMAT "%d,%d,%d,%d," TELEMETRY_CELLS_FORMAT TELEMETRY_CURRENT_FORMAT "%d," TELEMETRY_VFAS_FORMAT "%d,%d,%d,",
|
||||
frskyData.hub.year+2000,
|
||||
frskyData.hub.month,
|
||||
frskyData.hub.day,
|
||||
frskyData.hub.hour,
|
||||
frskyData.hub.min,
|
||||
frskyData.hub.sec,
|
||||
frskyData.hub.gpsLongitude_bp,
|
||||
frskyData.hub.gpsLongitude_ap,
|
||||
frskyData.hub.gpsLongitudeEW ? frskyData.hub.gpsLongitudeEW : '-',
|
||||
frskyData.hub.gpsLatitude_bp,
|
||||
frskyData.hub.gpsLatitude_ap,
|
||||
frskyData.hub.gpsLatitudeNS ? frskyData.hub.gpsLatitudeNS : '-',
|
||||
frskyData.hub.gpsCourse_bp,
|
||||
frskyData.hub.gpsCourse_ap,
|
||||
telemetryData.hub.year+2000,
|
||||
telemetryData.hub.month,
|
||||
telemetryData.hub.day,
|
||||
telemetryData.hub.hour,
|
||||
telemetryData.hub.min,
|
||||
telemetryData.hub.sec,
|
||||
telemetryData.hub.gpsLongitude_bp,
|
||||
telemetryData.hub.gpsLongitude_ap,
|
||||
telemetryData.hub.gpsLongitudeEW ? telemetryData.hub.gpsLongitudeEW : '-',
|
||||
telemetryData.hub.gpsLatitude_bp,
|
||||
telemetryData.hub.gpsLatitude_ap,
|
||||
telemetryData.hub.gpsLatitudeNS ? telemetryData.hub.gpsLatitudeNS : '-',
|
||||
telemetryData.hub.gpsCourse_bp,
|
||||
telemetryData.hub.gpsCourse_ap,
|
||||
TELEMETRY_GPS_SPEED_ARGS
|
||||
TELEMETRY_GPS_ALT_ARGS
|
||||
TELEMETRY_BARO_ALT_ARGS
|
||||
TELEMETRY_VSPEED_ARGS
|
||||
TELEMETRY_ASPEED_ARGS
|
||||
frskyData.hub.temperature1,
|
||||
frskyData.hub.temperature2,
|
||||
frskyData.hub.rpm,
|
||||
frskyData.hub.fuelLevel,
|
||||
telemetryData.hub.temperature1,
|
||||
telemetryData.hub.temperature2,
|
||||
telemetryData.hub.rpm,
|
||||
telemetryData.hub.fuelLevel,
|
||||
TELEMETRY_CELLS_ARGS
|
||||
TELEMETRY_CURRENT_ARGS
|
||||
frskyData.hub.currentConsumption,
|
||||
telemetryData.hub.currentConsumption,
|
||||
TELEMETRY_VFAS_ARGS
|
||||
frskyData.hub.accelX,
|
||||
frskyData.hub.accelY,
|
||||
frskyData.hub.accelZ);
|
||||
telemetryData.hub.accelX,
|
||||
telemetryData.hub.accelY,
|
||||
telemetryData.hub.accelZ);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,27 +1,12 @@
|
||||
/*
|
||||
* Authors (alphabetical order)
|
||||
* - Andre Bernet <bernet.andre@gmail.com>
|
||||
* - Andreas Weitl
|
||||
* - Bertrand Songis <bsongis@gmail.com>
|
||||
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||
* - Cameron Weeks <th9xer@gmail.com>
|
||||
* - Erez Raviv
|
||||
* - Gabriel Birkus
|
||||
* - Jean-Pierre Parisy
|
||||
* - Karl Szmutny
|
||||
* - Michael Blandford
|
||||
* - Michal Hlavinka
|
||||
* - Pat Mackenzie
|
||||
* - Philip Moss
|
||||
* - Rob Thomson
|
||||
* - Romolo Manfredini <romolo.manfredini@gmail.com>
|
||||
* - Thomas Husterer
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* opentx is based on code named
|
||||
* gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/,
|
||||
* er9x by Erez Raviv: http://code.google.com/p/er9x/,
|
||||
* and the original (and ongoing) project by
|
||||
* Thomas Husterer, th9x: http://code.google.com/p/th9x/
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
@@ -31,7 +16,6 @@
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
@@ -1,27 +1,12 @@
|
||||
/*
|
||||
* Authors (alphabetical order)
|
||||
* - Andre Bernet <bernet.andre@gmail.com>
|
||||
* - Andreas Weitl
|
||||
* - Bertrand Songis <bsongis@gmail.com>
|
||||
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||
* - Cameron Weeks <th9xer@gmail.com>
|
||||
* - Erez Raviv
|
||||
* - Gabriel Birkus
|
||||
* - Jean-Pierre Parisy
|
||||
* - Karl Szmutny
|
||||
* - Michael Blandford
|
||||
* - Michal Hlavinka
|
||||
* - Pat Mackenzie
|
||||
* - Philip Moss
|
||||
* - Rob Thomson
|
||||
* - Romolo Manfredini <romolo.manfredini@gmail.com>
|
||||
* - Thomas Husterer
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* opentx is based on code named
|
||||
* gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/,
|
||||
* er9x by Erez Raviv: http://code.google.com/p/er9x/,
|
||||
* and the original (and ongoing) project by
|
||||
* Thomas Husterer, th9x: http://code.google.com/p/th9x/
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
@@ -31,7 +16,6 @@
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
@@ -1,27 +1,12 @@
|
||||
/*
|
||||
* Authors (alphabetical order)
|
||||
* - Andre Bernet <bernet.andre@gmail.com>
|
||||
* - Andreas Weitl
|
||||
* - Bertrand Songis <bsongis@gmail.com>
|
||||
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||
* - Cameron Weeks <th9xer@gmail.com>
|
||||
* - Erez Raviv
|
||||
* - Gabriel Birkus
|
||||
* - Jean-Pierre Parisy
|
||||
* - Karl Szmutny
|
||||
* - Michael Blandford
|
||||
* - Michal Hlavinka
|
||||
* - Pat Mackenzie
|
||||
* - Philip Moss
|
||||
* - Rob Thomson
|
||||
* - Romolo Manfredini <romolo.manfredini@gmail.com>
|
||||
* - Thomas Husterer
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* opentx is based on code named
|
||||
* gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/,
|
||||
* er9x by Erez Raviv: http://code.google.com/p/er9x/,
|
||||
* and the original (and ongoing) project by
|
||||
* Thomas Husterer, th9x: http://code.google.com/p/th9x/
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
@@ -31,7 +16,6 @@
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
@@ -1,27 +1,12 @@
|
||||
/*
|
||||
* Authors (alphabetical order)
|
||||
* - Andre Bernet <bernet.andre@gmail.com>
|
||||
* - Andreas Weitl
|
||||
* - Bertrand Songis <bsongis@gmail.com>
|
||||
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||
* - Cameron Weeks <th9xer@gmail.com>
|
||||
* - Erez Raviv
|
||||
* - Gabriel Birkus
|
||||
* - Jean-Pierre Parisy
|
||||
* - Karl Szmutny
|
||||
* - Michael Blandford
|
||||
* - Michal Hlavinka
|
||||
* - Pat Mackenzie
|
||||
* - Philip Moss
|
||||
* - Rob Thomson
|
||||
* - Romolo Manfredini <romolo.manfredini@gmail.com>
|
||||
* - Thomas Husterer
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* opentx is based on code named
|
||||
* gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/,
|
||||
* er9x by Erez Raviv: http://code.google.com/p/er9x/,
|
||||
* and the original (and ongoing) project by
|
||||
* Thomas Husterer, th9x: http://code.google.com/p/th9x/
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
@@ -31,7 +16,6 @@
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
+7
-23
@@ -1,27 +1,12 @@
|
||||
/*
|
||||
* Authors (alphabetical order)
|
||||
* - Andre Bernet <bernet.andre@gmail.com>
|
||||
* - Andreas Weitl
|
||||
* - Bertrand Songis <bsongis@gmail.com>
|
||||
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||
* - Cameron Weeks <th9xer@gmail.com>
|
||||
* - Erez Raviv
|
||||
* - Gabriel Birkus
|
||||
* - Jean-Pierre Parisy
|
||||
* - Karl Szmutny
|
||||
* - Michael Blandford
|
||||
* - Michal Hlavinka
|
||||
* - Pat Mackenzie
|
||||
* - Philip Moss
|
||||
* - Rob Thomson
|
||||
* - Romolo Manfredini <romolo.manfredini@gmail.com>
|
||||
* - Thomas Husterer
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* opentx is based on code named
|
||||
* gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/,
|
||||
* er9x by Erez Raviv: http://code.google.com/p/er9x/,
|
||||
* and the original (and ongoing) project by
|
||||
* Thomas Husterer, th9x: http://code.google.com/p/th9x/
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
@@ -31,7 +16,6 @@
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _LUA_API_H_
|
||||
|
||||
+15
-15
@@ -143,21 +143,21 @@ double gpsToDouble(bool neg, int16_t bp, int16_t ap)
|
||||
#if defined(FRSKY_HUB) && !defined(CPUARM)
|
||||
void extractLatitudeLongitude(uint32_t * latitude, uint32_t * longitude)
|
||||
{
|
||||
div_t qr = div(frskyData.hub.gpsLatitude_bp, 100);
|
||||
*latitude = ((uint32_t)(qr.quot) * 1000000) + (((uint32_t)(qr.rem) * 10000 + frskyData.hub.gpsLatitude_ap) * 5) / 3;
|
||||
div_t qr = div(telemetryData.hub.gpsLatitude_bp, 100);
|
||||
*latitude = ((uint32_t)(qr.quot) * 1000000) + (((uint32_t)(qr.rem) * 10000 + telemetryData.hub.gpsLatitude_ap) * 5) / 3;
|
||||
|
||||
qr = div(frskyData.hub.gpsLongitude_bp, 100);
|
||||
*longitude = ((uint32_t)(qr.quot) * 1000000) + (((uint32_t)(qr.rem) * 10000 + frskyData.hub.gpsLongitude_ap) * 5) / 3;
|
||||
qr = div(telemetryData.hub.gpsLongitude_bp, 100);
|
||||
*longitude = ((uint32_t)(qr.quot) * 1000000) + (((uint32_t)(qr.rem) * 10000 + telemetryData.hub.gpsLongitude_ap) * 5) / 3;
|
||||
}
|
||||
|
||||
void getGpsPilotPosition()
|
||||
{
|
||||
extractLatitudeLongitude(&frskyData.hub.pilotLatitude, &frskyData.hub.pilotLongitude);
|
||||
uint32_t lat = frskyData.hub.pilotLatitude / 10000;
|
||||
extractLatitudeLongitude(&telemetryData.hub.pilotLatitude, &telemetryData.hub.pilotLongitude);
|
||||
uint32_t lat = telemetryData.hub.pilotLatitude / 10000;
|
||||
uint32_t angle2 = (lat*lat) / 10000;
|
||||
uint32_t angle4 = angle2 * angle2;
|
||||
frskyData.hub.distFromEarthAxis = 139*(((uint32_t)10000000-((angle2*(uint32_t)123370)/81)+(angle4/25))/12500);
|
||||
// TRACE("frskyData.hub.distFromEarthAxis=%d", frskyData.hub.distFromEarthAxis);
|
||||
telemetryData.hub.distFromEarthAxis = 139*(((uint32_t)10000000-((angle2*(uint32_t)123370)/81)+(angle4/25))/12500);
|
||||
// TRACE("telemetryData.hub.distFromEarthAxis=%d", telemetryData.hub.distFromEarthAxis);
|
||||
}
|
||||
|
||||
void getGpsDistance()
|
||||
@@ -166,21 +166,21 @@ void getGpsDistance()
|
||||
|
||||
extractLatitudeLongitude(&lat, &lng);
|
||||
|
||||
// printf("lat=%d (%d), long=%d (%d)\n", lat, abs(lat - frskyData.hub.pilotLatitude), lng, abs(lng - frskyData.hub.pilotLongitude));
|
||||
// printf("lat=%d (%d), long=%d (%d)\n", lat, abs(lat - telemetryData.hub.pilotLatitude), lng, abs(lng - telemetryData.hub.pilotLongitude));
|
||||
|
||||
uint32_t angle = (lat > frskyData.hub.pilotLatitude) ? lat - frskyData.hub.pilotLatitude : frskyData.hub.pilotLatitude - lat;
|
||||
uint32_t angle = (lat > telemetryData.hub.pilotLatitude) ? lat - telemetryData.hub.pilotLatitude : telemetryData.hub.pilotLatitude - lat;
|
||||
uint32_t dist = EARTH_RADIUS * angle / 1000000;
|
||||
uint32_t result = dist*dist;
|
||||
|
||||
angle = (lng > frskyData.hub.pilotLongitude) ? lng - frskyData.hub.pilotLongitude : frskyData.hub.pilotLongitude - lng;
|
||||
dist = frskyData.hub.distFromEarthAxis * angle / 1000000;
|
||||
angle = (lng > telemetryData.hub.pilotLongitude) ? lng - telemetryData.hub.pilotLongitude : telemetryData.hub.pilotLongitude - lng;
|
||||
dist = telemetryData.hub.distFromEarthAxis * angle / 1000000;
|
||||
result += dist*dist;
|
||||
|
||||
dist = abs(TELEMETRY_BARO_ALT_AVAILABLE() ? TELEMETRY_RELATIVE_BARO_ALT_BP : TELEMETRY_RELATIVE_GPS_ALT_BP);
|
||||
result += dist*dist;
|
||||
|
||||
frskyData.hub.gpsDistance = isqrt32(result);
|
||||
if (frskyData.hub.gpsDistance > frskyData.hub.maxGpsDistance)
|
||||
frskyData.hub.maxGpsDistance = frskyData.hub.gpsDistance;
|
||||
telemetryData.hub.gpsDistance = isqrt32(result);
|
||||
if (telemetryData.hub.gpsDistance > telemetryData.hub.maxGpsDistance)
|
||||
telemetryData.hub.maxGpsDistance = telemetryData.hub.gpsDistance;
|
||||
}
|
||||
#endif
|
||||
|
||||
+25
-25
@@ -370,39 +370,39 @@ getvalue_t getValue(mixsrc_t i)
|
||||
}
|
||||
}
|
||||
#elif defined(FRSKY)
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_RSSI_TX) return frskyData.rssi[1].value;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_RSSI_RX) return frskyData.rssi[0].value;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_A1) return frskyData.analog[TELEM_ANA_A1].value;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_A2) return frskyData.analog[TELEM_ANA_A2].value;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_RSSI_TX) return telemetryData.rssi[1].value;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_RSSI_RX) return telemetryData.rssi[0].value;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_A1) return telemetryData.analog[TELEM_ANA_A1].value;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_A2) return telemetryData.analog[TELEM_ANA_A2].value;
|
||||
#if defined(FRSKY_SPORT)
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_ALT) return frskyData.hub.baroAltitude;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_ALT) return telemetryData.hub.baroAltitude;
|
||||
#elif defined(FRSKY_HUB) || defined(WS_HOW_HIGH)
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_ALT) return TELEMETRY_RELATIVE_BARO_ALT_BP;
|
||||
#endif
|
||||
#if defined(FRSKY_HUB)
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_RPM) return frskyData.hub.rpm;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_FUEL) return frskyData.hub.fuelLevel;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_T1) return frskyData.hub.temperature1;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_T2) return frskyData.hub.temperature2;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_RPM) return telemetryData.hub.rpm;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_FUEL) return telemetryData.hub.fuelLevel;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_T1) return telemetryData.hub.temperature1;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_T2) return telemetryData.hub.temperature2;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_SPEED) return TELEMETRY_GPS_SPEED_BP;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_DIST) return frskyData.hub.gpsDistance;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_DIST) return telemetryData.hub.gpsDistance;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_GPSALT) return TELEMETRY_RELATIVE_GPS_ALT_BP;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_CELL) return (int16_t)TELEMETRY_MIN_CELL_VOLTAGE;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_CELLS_SUM) return (int16_t)frskyData.hub.cellsSum;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_VFAS) return (int16_t)frskyData.hub.vfas;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_CURRENT) return (int16_t)frskyData.hub.current;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_CONSUMPTION) return frskyData.hub.currentConsumption;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_POWER) return frskyData.hub.power;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_ACCx) return frskyData.hub.accelX;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_ACCy) return frskyData.hub.accelY;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_ACCz) return frskyData.hub.accelZ;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_HDG) return frskyData.hub.gpsCourse_bp;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_VSPEED) return frskyData.hub.varioSpeed;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_ASPEED) return frskyData.hub.airSpeed;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_DTE) return frskyData.hub.dTE;
|
||||
else if (i<=MIXSRC_FIRST_TELEM-1+TELEM_MIN_A1) return frskyData.analog[TELEM_ANA_A1].min;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_MIN_A2) return frskyData.analog[TELEM_ANA_A2].min;
|
||||
else if (i<=MIXSRC_FIRST_TELEM-1+TELEM_CSW_MAX) return *(((int16_t*)(&frskyData.hub.minAltitude))+i-(MIXSRC_FIRST_TELEM-1+TELEM_MIN_ALT));
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_CELLS_SUM) return (int16_t)telemetryData.hub.cellsSum;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_VFAS) return (int16_t)telemetryData.hub.vfas;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_CURRENT) return (int16_t)telemetryData.hub.current;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_CONSUMPTION) return telemetryData.hub.currentConsumption;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_POWER) return telemetryData.hub.power;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_ACCx) return telemetryData.hub.accelX;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_ACCy) return telemetryData.hub.accelY;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_ACCz) return telemetryData.hub.accelZ;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_HDG) return telemetryData.hub.gpsCourse_bp;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_VSPEED) return telemetryData.hub.varioSpeed;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_ASPEED) return telemetryData.hub.airSpeed;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_DTE) return telemetryData.hub.dTE;
|
||||
else if (i<=MIXSRC_FIRST_TELEM-1+TELEM_MIN_A1) return telemetryData.analog[TELEM_ANA_A1].min;
|
||||
else if (i==MIXSRC_FIRST_TELEM-1+TELEM_MIN_A2) return telemetryData.analog[TELEM_ANA_A2].min;
|
||||
else if (i<=MIXSRC_FIRST_TELEM-1+TELEM_CSW_MAX) return *(((int16_t*)(&telemetryData.hub.minAltitude))+i-(MIXSRC_FIRST_TELEM-1+TELEM_MIN_ALT));
|
||||
#endif
|
||||
#endif
|
||||
else return 0;
|
||||
|
||||
@@ -921,7 +921,7 @@ getvalue_t convert8bitsTelemValue(uint8_t channel, ls_telemetry_value_t value)
|
||||
#endif
|
||||
|
||||
#if defined(FRSKY)&& !defined(CPUARM)
|
||||
FORCEINLINE void convertUnit(getvalue_t & val, uint8_t & unit)
|
||||
void convertUnit(getvalue_t & val, uint8_t & unit)
|
||||
{
|
||||
if (IS_IMPERIAL_ENABLE()) {
|
||||
if (unit == UNIT_TEMPERATURE) {
|
||||
|
||||
+5
-23
@@ -222,8 +222,8 @@
|
||||
#endif
|
||||
|
||||
#if defined(SIMU)
|
||||
#ifndef FORCEINLINE
|
||||
#define FORCEINLINE
|
||||
#if !defined(FORCEINLINE)
|
||||
#define FORCEINLINE inline
|
||||
#endif
|
||||
#if !defined(NOINLINE)
|
||||
#define NOINLINE
|
||||
@@ -1301,29 +1301,11 @@ void evalFunctions();
|
||||
extern volatile rotenc_t g_rotenc[1];
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
#include "telemetry/telemetry.h"
|
||||
#endif
|
||||
|
||||
#if defined (FRSKY)
|
||||
// FrSky Telemetry
|
||||
#include "telemetry/frsky.h"
|
||||
#elif defined(JETI)
|
||||
// Jeti-DUPLEX Telemetry
|
||||
#include "telemetry/jeti.h"
|
||||
#elif defined(ARDUPILOT)
|
||||
// ArduPilot Telemetry
|
||||
#include "telemetry/ardupilot.h"
|
||||
#elif defined(NMEA)
|
||||
// NMEA Telemetry
|
||||
#include "telemetry/nmea.h"
|
||||
#elif defined(MAVLINK)
|
||||
// Mavlink Telemetry
|
||||
#include "telemetry/mavlink.h"
|
||||
#endif
|
||||
#include "telemetry/telemetry.h"
|
||||
|
||||
#if defined(CPUARM)
|
||||
uint16_t crc16(uint8_t * buf, uint32_t len);
|
||||
uint8_t crc8(const uint8_t * ptr, uint32_t len);
|
||||
uint16_t crc16(const uint8_t * ptr, uint32_t len);
|
||||
#endif
|
||||
|
||||
#define PLAY_REPEAT(x) (x) /* Range 0 to 15 */
|
||||
|
||||
@@ -68,7 +68,7 @@ PACK(struct Dsm2PulsesData {
|
||||
});
|
||||
#endif
|
||||
|
||||
#define CROSSFIRE_BAUDRATE 921600
|
||||
#define CROSSFIRE_BAUDRATE 400000
|
||||
#define CROSSFIRE_FRAME_LEN 25
|
||||
#define CROSSFIRE_CHANNELS_COUNT 16
|
||||
PACK(struct CrossfirePulsesData {
|
||||
|
||||
+1
-1
@@ -524,7 +524,7 @@ int main(int argc,char **argv)
|
||||
#endif
|
||||
|
||||
#if defined(FRSKY) && !defined(FRSKY_SPORT)
|
||||
frskyStreaming = 1;
|
||||
telemetryStreaming = 1;
|
||||
#endif
|
||||
|
||||
printf("Model size = %d\n", (int)sizeof(g_model));
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//This file was auto-generated by generate_datacopy.py script on Wed Mar 16 20:12:19 2016. Do not edit this file!
|
||||
//This file was auto-generated by generate_datacopy.py script on Fri Mar 25 14:17:31 2016. Do not edit this file!
|
||||
|
||||
|
||||
|
||||
@@ -77,6 +77,7 @@ void copyCustomFunctionData(A * dest, B * src)
|
||||
{
|
||||
dest->swtch = src->swtch;
|
||||
dest->func = src->func;
|
||||
copyCustomFunctionData_all(&dest->all, &src->all);
|
||||
dest->active = src->active;
|
||||
}
|
||||
|
||||
@@ -165,6 +166,24 @@ void copyFrSkyTelemetryData(A * dest, B * src)
|
||||
}
|
||||
}
|
||||
|
||||
template <class A, class B>
|
||||
void copyTelemetrySensor(A * dest, B * src)
|
||||
{
|
||||
dest->id = src->id;
|
||||
dest->instance = src->instance;
|
||||
memcpy(dest->label, src->label, sizeof(dest->label));
|
||||
dest->type = src->type;
|
||||
dest->unit = src->unit;
|
||||
dest->prec = src->prec;
|
||||
dest->autoOffset = src->autoOffset;
|
||||
dest->filter = src->filter;
|
||||
dest->logs = src->logs;
|
||||
dest->persistent = src->persistent;
|
||||
dest->onlyPositive = src->onlyPositive;
|
||||
dest->subId = src->subId;
|
||||
copyTelemetrySensor_custom(&dest->custom, &src->custom);
|
||||
}
|
||||
|
||||
template <class A, class B>
|
||||
void copyModuleData(A * dest, B * src)
|
||||
{
|
||||
@@ -305,3 +324,17 @@ void copyRadioData(A * dest, B * src)
|
||||
dest->potsConfig = src->potsConfig;
|
||||
}
|
||||
|
||||
template <class A, class B>
|
||||
void copyCustomFunctionData_all(A * dest, B * src)
|
||||
{
|
||||
dest->val = src->val;
|
||||
dest->mode = src->mode;
|
||||
dest->param = src->param;
|
||||
}
|
||||
|
||||
template <class A, class B>
|
||||
void copyTelemetrySensor_custom(A * dest, B * src)
|
||||
{
|
||||
dest->ratio = src->ratio;
|
||||
dest->offset = src->offset;
|
||||
}
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "../../opentx.h"
|
||||
|
||||
#if defined(ROTARY_ENCODER_NAVIGATION)
|
||||
@@ -279,7 +279,7 @@ uint8_t trimDown(uint8_t idx)
|
||||
return trimHelper(~PIND, idx);
|
||||
}
|
||||
|
||||
FORCEINLINE void readKeysAndTrims()
|
||||
void readKeysAndTrims()
|
||||
{
|
||||
uint8_t enuk = KEY_MENU;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "../../opentx.h"
|
||||
#include "opentx.h"
|
||||
|
||||
#if defined(FRSKY)
|
||||
|
||||
@@ -33,9 +33,6 @@ void telemetryEnableRx(void)
|
||||
UCSRB_N(TLM_USART) |= (1 << RXCIE_N(TLM_USART)); // enable Interrupt
|
||||
}
|
||||
|
||||
void processSerialData(uint8_t data);
|
||||
extern uint8_t frskyRxBufferCount; // TODO not driver, change name
|
||||
|
||||
ISR(USART_RX_vect_N(TLM_USART))
|
||||
{
|
||||
uint8_t stat;
|
||||
@@ -79,10 +76,10 @@ ISR(USART_RX_vect_N(TLM_USART))
|
||||
|
||||
if (stat & ((1 << FE_N(TLM_USART)) | (1 << DOR_N(TLM_USART)) | (1 << UPE_N(TLM_USART)))) {
|
||||
// discard buffer and start fresh on any comms error
|
||||
frskyRxBufferCount = 0;
|
||||
telemetryRxBufferCount = 0;
|
||||
}
|
||||
else {
|
||||
processSerialData(data);
|
||||
processFrskyTelemetryData(data);
|
||||
}
|
||||
|
||||
cli() ;
|
||||
|
||||
@@ -164,7 +164,7 @@ void pwrOff()
|
||||
#endif
|
||||
}
|
||||
|
||||
FORCEINLINE uint8_t keyDown()
|
||||
uint8_t keyDown()
|
||||
{
|
||||
return ((~PINL) & 0x3F) || ROTENC_DOWN();
|
||||
}
|
||||
@@ -240,7 +240,7 @@ uint8_t trimDown(uint8_t idx)
|
||||
return (in & pgm_read_byte(crossTrim+idx));
|
||||
}
|
||||
|
||||
FORCEINLINE void readKeysAndTrims()
|
||||
void readKeysAndTrims()
|
||||
{
|
||||
uint8_t enuk = KEY_MENU;
|
||||
|
||||
|
||||
@@ -17,6 +17,116 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file system_stm32f4xx.c
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 25-March-2016
|
||||
* @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File.
|
||||
* This file contains the system clock configuration for STM32F4xx devices,
|
||||
* and is generated by the clock configuration tool
|
||||
* stm32f4xx_Clock_Configuration_V1.1.0.xls
|
||||
*
|
||||
* 1. This file provides two functions and one global variable to be called from
|
||||
* user application:
|
||||
* - SystemInit(): Setups the system clock (System clock source, PLL Multiplier
|
||||
* and Divider factors, AHB/APBx prescalers and Flash settings),
|
||||
* depending on the configuration made in the clock xls tool.
|
||||
* This function is called at startup just after reset and
|
||||
* before branch to main program. This call is made inside
|
||||
* the "startup_stm32f4xx.s" file.
|
||||
*
|
||||
* - SystemCoreClock variable: Contains the core clock (HCLK), it can be used
|
||||
* by the user application to setup the SysTick
|
||||
* timer or configure other parameters.
|
||||
*
|
||||
* - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must
|
||||
* be called whenever the core clock is changed
|
||||
* during program execution.
|
||||
*
|
||||
* 2. After each device reset the HSI (16 MHz) is used as system clock source.
|
||||
* Then SystemInit() function is called, in "startup_stm32f4xx.s" file, to
|
||||
* configure the system clock before to branch to main program.
|
||||
*
|
||||
* 3. If the system clock source selected by user fails to startup, the SystemInit()
|
||||
* function will do nothing and HSI still used as system clock source. User can
|
||||
* add some code to deal with this issue inside the SetSysClock() function.
|
||||
*
|
||||
* 4. The default value of HSE crystal is set to 25MHz, refer to "HSE_VALUE" define
|
||||
* in "stm32f4xx.h" file. When HSE is used as system clock source, directly or
|
||||
* through PLL, and you are using different crystal you have to adapt the HSE
|
||||
* value to your own configuration.
|
||||
*
|
||||
* 5. This file configures the system clock as follows:
|
||||
*=============================================================================
|
||||
*=============================================================================
|
||||
* Supported STM32F40xx/41xx/427x/437x devices
|
||||
*-----------------------------------------------------------------------------
|
||||
* System Clock source | PLL (HSE)
|
||||
*-----------------------------------------------------------------------------
|
||||
* SYSCLK(Hz) | 168000000
|
||||
*-----------------------------------------------------------------------------
|
||||
* HCLK(Hz) | 168000000
|
||||
*-----------------------------------------------------------------------------
|
||||
* AHB Prescaler | 1
|
||||
*-----------------------------------------------------------------------------
|
||||
* APB1 Prescaler | 4
|
||||
*-----------------------------------------------------------------------------
|
||||
* APB2 Prescaler | 2
|
||||
*-----------------------------------------------------------------------------
|
||||
* HSE Frequency(Hz) | 12000000
|
||||
*-----------------------------------------------------------------------------
|
||||
* PLL_M | 12
|
||||
*-----------------------------------------------------------------------------
|
||||
* PLL_N | 336
|
||||
*-----------------------------------------------------------------------------
|
||||
* PLL_P | 2
|
||||
*-----------------------------------------------------------------------------
|
||||
* PLL_Q | 7
|
||||
*-----------------------------------------------------------------------------
|
||||
* PLLI2S_N | NA
|
||||
*-----------------------------------------------------------------------------
|
||||
* PLLI2S_R | NA
|
||||
*-----------------------------------------------------------------------------
|
||||
* I2S input clock | NA
|
||||
*-----------------------------------------------------------------------------
|
||||
* VDD(V) | 3.3
|
||||
*-----------------------------------------------------------------------------
|
||||
* Main regulator output voltage | Scale1 mode
|
||||
*-----------------------------------------------------------------------------
|
||||
* Flash Latency(WS) | 5
|
||||
*-----------------------------------------------------------------------------
|
||||
* Prefetch Buffer | ON
|
||||
*-----------------------------------------------------------------------------
|
||||
* Instruction cache | ON
|
||||
*-----------------------------------------------------------------------------
|
||||
* Data cache | ON
|
||||
*-----------------------------------------------------------------------------
|
||||
* Require 48MHz for USB OTG FS, | Enabled
|
||||
* SDIO and RNG clock |
|
||||
*-----------------------------------------------------------------------------
|
||||
*=============================================================================
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2013 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
|
||||
* You may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/** @addtogroup CMSIS
|
||||
* @{
|
||||
@@ -89,7 +199,7 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
uint32_t SystemCoreClock = 180000000;
|
||||
uint32_t SystemCoreClock = 168000000;
|
||||
|
||||
__I uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
|
||||
|
||||
@@ -316,7 +426,7 @@ static void SetSysClock(void)
|
||||
}
|
||||
|
||||
/* Configure Flash prefetch, Instruction cache, Data cache and wait state */
|
||||
FLASH->ACR = FLASH_ACR_PRFTEN |FLASH_ACR_ICEN |FLASH_ACR_DCEN |FLASH_ACR_LATENCY_5WS;
|
||||
FLASH->ACR = FLASH_ACR_PRFTEN | FLASH_ACR_ICEN |FLASH_ACR_DCEN |FLASH_ACR_LATENCY_5WS;
|
||||
|
||||
/* Select the main PLL as system clock source */
|
||||
RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW));
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
|
||||
#include "usb_bsp.h"
|
||||
|
||||
#include "../horus/board_horus.h"
|
||||
#include "../horus/usbd_conf.h"
|
||||
#include "board_horus.h"
|
||||
#include "usbd_conf.h"
|
||||
|
||||
extern uint32_t SystemCoreClock;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "../horus/board_horus.h"
|
||||
#include "board_horus.h"
|
||||
#include "STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/inc/usb_dcd_int.h"
|
||||
|
||||
int usbPlugged(void)
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
|
||||
#pragma data_alignment = 4
|
||||
#endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
|
||||
|
||||
#include "../../opentx.h"
|
||||
#include "opentx.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef _USBD_CONF_H_
|
||||
#define _USBD_CONF_H_
|
||||
#ifndef _USBD_CONF_H_
|
||||
#define _USBD_CONF_H_
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "../horus/usb_conf.h"
|
||||
#include "usb_conf.h"
|
||||
|
||||
#define USBD_CFG_MAX_NUM 1
|
||||
#define USBD_ITF_MAX_NUM 1
|
||||
@@ -57,7 +57,7 @@
|
||||
#define APP_RX_DATA_SIZE 512 // USB serial port output buffer. TODO: tune this buffer size /* Total size of IN buffer: APP_RX_DATA_SIZE*8/MAX_BAUDARATE*1000 should be > CDC_IN_FRAME_INTERVAL */
|
||||
#define APP_FOPS VCP_fops
|
||||
|
||||
#endif // _USBD_CONF_H_
|
||||
#endif // _USBD_CONF_H_
|
||||
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
||||
@@ -87,7 +87,7 @@ void pwrOff()
|
||||
PORTH &= ~0x10; // PortH-4 set to 0
|
||||
}
|
||||
|
||||
FORCEINLINE uint8_t keyDown()
|
||||
uint8_t keyDown()
|
||||
{
|
||||
return ((~PINL) & 0x3F) || ROTENC_DOWN();
|
||||
}
|
||||
@@ -165,7 +165,7 @@ uint8_t trimDown(uint8_t idx)
|
||||
return (in & pgm_read_byte(crossTrim+idx));
|
||||
}
|
||||
|
||||
FORCEINLINE void readKeysAndTrims()
|
||||
void readKeysAndTrims()
|
||||
{
|
||||
uint8_t enuk = KEY_MENU;
|
||||
|
||||
|
||||
@@ -7,21 +7,26 @@ set(SIMU_SRC ${SIMU_SRC} simpgmspace.cpp)
|
||||
add_definitions(-DSIMU)
|
||||
remove_definitions(-DCLI)
|
||||
|
||||
if(SDL_FOUND)
|
||||
include_directories(${SDL_INCLUDE_DIR})
|
||||
add_definitions(-DSIMU_AUDIO)
|
||||
add_definitions(-DJOYSTICKS)
|
||||
endif()
|
||||
|
||||
if(Qt5Widgets_FOUND)
|
||||
string(TOLOWER ${TRANSLATIONS} TRANSLATION_LOWERCASE)
|
||||
set(SIMULATOR_FLAVOUR opentx-${FLAVOUR}-${TRANSLATION_LOWERCASE})
|
||||
set(SIMULATOR_FLAVOUR opentx-${FLAVOUR})
|
||||
set(SIMULATOR_TARGET ${SIMULATOR_FLAVOUR}-simulator)
|
||||
add_definitions(-DSIMULATOR_FLAVOUR="${SIMULATOR_FLAVOUR}")
|
||||
include_directories(${COMPANION_SRC_DIRECTORY} ${COMPANION_SRC_DIRECTORY}/simulation)
|
||||
add_library(${SIMULATOR_TARGET} SHARED ${SIMU_SRC} opentxsimulator.cpp)
|
||||
add_dependencies(${SIMULATOR_TARGET} ${FIRMWARE_DEPENDENCIES})
|
||||
target_link_libraries(${SIMULATOR_TARGET} ${SDL_LIBRARY})
|
||||
qt5_use_modules(${SIMULATOR_TARGET} Core)
|
||||
add_custom_target(opentx-simulator DEPENDS ${SIMULATOR_TARGET})
|
||||
add_custom_target(libsimulator DEPENDS ${SIMULATOR_TARGET})
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
set(CMAKE_CXX_FLAGS "/EHsc /LD")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /FORCE:MULTIPLE")
|
||||
include_directories(${PROJECT_SOURCE_DIR}/winbuild C:/Programs/pthreads/Pre-built.2/include C:/Programs/msinttypes C:/Programs/dirent/include)
|
||||
target_link_libraries(${SIMULATOR_TARGET} PRIVATE C:/Programs/pthreads/Pre-built.2/lib/pthreadVC2.lib)
|
||||
else()
|
||||
@@ -32,7 +37,7 @@ if(NOT WIN32)
|
||||
add_executable(simu WIN32 ${SIMU_SRC} ../../simu.cpp)
|
||||
add_dependencies(simu ${FIRMWARE_DEPENDENCIES})
|
||||
target_include_directories(simu PUBLIC /usr/local/include/fox-1.6 PUBLIC /usr/include/fox-1.6 /opt/local/include/fox-1.6)
|
||||
target_link_libraries(simu FOX-1.6 pthread)
|
||||
target_link_libraries(simu FOX-1.6 pthread ${SDL_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
|
||||
@@ -880,7 +880,7 @@ FRESULT f_opendir (DIR * rep, const TCHAR * name)
|
||||
FRESULT f_closedir (DIR * rep)
|
||||
{
|
||||
TRACE("f_closedir(%p)", rep);
|
||||
simu::closedir((simu::DIR *)rep->fs);
|
||||
if (rep->fs) simu::closedir((simu::DIR *)rep->fs);
|
||||
return FR_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,342 +0,0 @@
|
||||
#
|
||||
# !!!! Do NOT edit this makefile with an editor which replace tabs by spaces !!!!
|
||||
#
|
||||
##############################################################################################
|
||||
#
|
||||
# On command line:
|
||||
#
|
||||
# make all = Create project
|
||||
#
|
||||
# make clean = Clean project files.
|
||||
#
|
||||
# To rebuild project do "make clean" and "make all".
|
||||
#
|
||||
|
||||
##############################################################################################
|
||||
# Start of default section
|
||||
#
|
||||
|
||||
TRGT = arm-none-eabi-
|
||||
CC = $(TRGT)gcc
|
||||
CP = $(TRGT)objcopy
|
||||
CLSS = $(TRGT)objdump
|
||||
AS = $(TRGT)as
|
||||
#gcc -x assembler-with-cpp
|
||||
BIN = $(CP) -O ihex
|
||||
BINX = $(CP) -O binary
|
||||
|
||||
OBJDIR = .
|
||||
|
||||
THIRDPARTY = ../../../thirdparty
|
||||
FATFSDIR = $(THIRDPARTY)/FatFs
|
||||
|
||||
ifeq ($(PCBREV), REV9E)
|
||||
MCU = cortex-m4
|
||||
STM32LIBPATH = $(THIRDPARTY)/STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries
|
||||
else
|
||||
MCU = cortex-m3
|
||||
STM32LIBPATH = $(THIRDPARTY)/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries
|
||||
endif
|
||||
|
||||
# List all default C defines here, like -D_DEBUG=1
|
||||
DDEFS =
|
||||
|
||||
# List all default ASM defines here, like -D_DEBUG=1
|
||||
DADEFS =
|
||||
|
||||
# List all default directories to look for include files here
|
||||
DINCDIR =
|
||||
|
||||
# List the default directory to look for the libraries here
|
||||
DLIBDIR =
|
||||
|
||||
# List all default libraries here
|
||||
DLIBS =
|
||||
|
||||
MEMORIES = sram
|
||||
|
||||
EXT = STD
|
||||
|
||||
#
|
||||
# End of default section
|
||||
##############################################################################################
|
||||
|
||||
##############################################################################################
|
||||
# Start of user section
|
||||
#
|
||||
|
||||
#
|
||||
# Define project name and Ram/Flash mode here
|
||||
PROJECT = bootloader
|
||||
|
||||
ifeq ($(PCB), TARANIS)
|
||||
RUN_FROM_FLASH = 0
|
||||
else
|
||||
ifeq ($(PCB), X9D)
|
||||
RUN_FROM_FLASH = 0
|
||||
else
|
||||
RUN_FROM_FLASH = 1
|
||||
endif
|
||||
endif
|
||||
|
||||
# PCB revision
|
||||
PCBREV =
|
||||
|
||||
EXTRAINCDIRS = $(THIRDPARTY) $(FATFSDIR) $(FATFSDIR)/option
|
||||
|
||||
STM32USBPATH = ../../../thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries
|
||||
|
||||
#
|
||||
# Define linker script file here
|
||||
#
|
||||
ifeq ($(PCB), TARANIS)
|
||||
ARCH = ARM
|
||||
LDSCRIPT = ../stm32_ramboot.ld
|
||||
TRGT = arm-none-eabi-
|
||||
CPPDEFS += -DHSE_VALUE=12000000
|
||||
CPPDEFS += -DPCBTARANIS -DEEPROM_RLC -DUSB_MASS_STORAGE
|
||||
FULL_PRJ = $(PROJECT)_ramBoot
|
||||
ifeq ($(PCBREV), REV9E)
|
||||
CPPDEFS += -DSTM32F40_41xxx
|
||||
EXTRAINCDIRS += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/inc
|
||||
EXTRAINCDIRS += $(STM32LIBPATH)/CMSIS/Device/ST/STM32F4xx/Include
|
||||
EXTRAINCDIRS += $(STM32LIBPATH)/CMSIS/Include
|
||||
else
|
||||
EXTRAINCDIRS += $(STM32LIBPATH)/STM32F2xx_StdPeriph_Driver/inc
|
||||
EXTRAINCDIRS += $(STM32LIBPATH)/CMSIS/Device/ST/STM32F2xx/Include
|
||||
EXTRAINCDIRS += $(STM32LIBPATH)/CMSIS/include
|
||||
endif
|
||||
EXTRAINCDIRS += $(STM32USBPATH)/STM32_USB_OTG_Driver/inc
|
||||
EXTRAINCDIRS += $(STM32USBPATH)/STM32_USB_Device_Library/Core/inc
|
||||
EXTRAINCDIRS += $(STM32USBPATH)/STM32_USB_Device_Library/Class/msc/inc
|
||||
EXTRAINCDIRS += $(STM32USBPATH)/STM32_USB_Device_Library/Class/hid/inc
|
||||
EXTRAINCDIRS += $(STM32USBPATH)/STM32_USB_Device_Library/Class/cdc/inc
|
||||
EXTRAINCDIRS += .. ../../.. ../../../fonts/std
|
||||
ifeq ($(PCBREV), REV4a)
|
||||
CPPDEFS += -DREV4a
|
||||
else ifeq ($(PCBREV), REVPLUS)
|
||||
CPPDEFS += -DREVPLUS
|
||||
HAPTIC = YES
|
||||
else ifeq ($(PCBREV), REV9E)
|
||||
CPPDEFS += -DREVPLUS -DREV9E
|
||||
HAPTIC = YES
|
||||
else
|
||||
CPPDEFS += -DREV4
|
||||
endif
|
||||
endif
|
||||
|
||||
# List all user C define here, like -D_DEBUG=1
|
||||
|
||||
# Define ASM defines here
|
||||
UADEFS =
|
||||
|
||||
SRC =
|
||||
|
||||
ifeq ($(PCBREV), REV9E)
|
||||
SRC += ../system_stm32f4xx.c
|
||||
SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rcc.c
|
||||
SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c
|
||||
SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_spi.c
|
||||
SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_i2c.c
|
||||
SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/misc.c
|
||||
else
|
||||
SRC += ../system_stm32f2xx.c
|
||||
SRC += $(STM32LIBPATH)/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_rcc.c
|
||||
SRC += $(STM32LIBPATH)/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_gpio.c
|
||||
SRC += $(STM32LIBPATH)/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_spi.c
|
||||
SRC += $(STM32LIBPATH)/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_i2c.c
|
||||
SRC += $(STM32LIBPATH)/STM32F2xx_StdPeriph_Driver/src/misc.c
|
||||
endif
|
||||
|
||||
SRC += $(STM32USBPATH)/STM32_USB_OTG_Driver/src/usb_core.c
|
||||
SRC += $(STM32USBPATH)/STM32_USB_OTG_Driver/src/usb_dcd.c
|
||||
SRC += $(STM32USBPATH)/STM32_USB_OTG_Driver/src/usb_dcd_int.c
|
||||
SRC += $(STM32USBPATH)/STM32_USB_Device_Library/Core/src/usbd_core.c
|
||||
SRC += $(STM32USBPATH)/STM32_USB_Device_Library/Core/src/usbd_ioreq.c
|
||||
SRC += $(STM32USBPATH)/STM32_USB_Device_Library/Core/src/usbd_req.c
|
||||
SRC += $(STM32USBPATH)/STM32_USB_Device_Library/Class/msc/src/usbd_msc_data.c
|
||||
SRC += $(STM32USBPATH)/STM32_USB_Device_Library/Class/msc/src/usbd_msc_scsi.c
|
||||
SRC += $(STM32USBPATH)/STM32_USB_Device_Library/Class/msc/src/usbd_msc_bot.c
|
||||
SRC += $(STM32USBPATH)/STM32_USB_Device_Library/Class/msc/src/usbd_msc_core.c
|
||||
SRC += ../delays.c
|
||||
SRC += $(THIRDPARTY)/FatFs/ff.c $(THIRDPARTY)/FatFs/option/ccsbcs.c
|
||||
SRC += ../usbd_desc.c
|
||||
SRC += ../aspi.c
|
||||
SRC += ../usb_bsp.c
|
||||
SRC += ../usb_driver.c
|
||||
SRC += ../pwr_driver.c
|
||||
SRC += init.c
|
||||
|
||||
CPPSRC = ../lcd_driver.cpp \
|
||||
../configure_pins.cpp \
|
||||
../keys_driver.cpp \
|
||||
../i2c_driver.cpp \
|
||||
../flash_driver.cpp \
|
||||
../diskio.cpp \
|
||||
../usbd_usr.cpp \
|
||||
../usbd_storage_msd.cpp \
|
||||
../../../gui/taranis/lcd.cpp \
|
||||
../../../keys.cpp \
|
||||
../../../fonts.cpp \
|
||||
../../../strhelpers.cpp \
|
||||
boot.cpp
|
||||
|
||||
# List ASM source files here
|
||||
|
||||
ifeq ($(PCBREV), REV9E)
|
||||
ASRC = $(STM32LIBPATH)/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc_ride7/startup_stm32f40_41xxx.s
|
||||
else
|
||||
ASRC = $(STM32LIBPATH)/CMSIS/Device/ST/STM32F2xx/Source/Templates/gcc_ride7/startup_stm32f2xx.s
|
||||
endif
|
||||
|
||||
# List all user directories here
|
||||
UINCDIR = ./inc
|
||||
# \
|
||||
# ./cmsis/core \
|
||||
# ./cmsis/device
|
||||
|
||||
# List the user directory to look for the libraries here
|
||||
ULIBDIR =
|
||||
|
||||
# List all user libraries here
|
||||
ULIBS =
|
||||
|
||||
# Define optimisation level here
|
||||
OPT = -Os
|
||||
|
||||
#
|
||||
# End of user defines
|
||||
##############################################################################################
|
||||
|
||||
|
||||
VPATH = $(DIRS)
|
||||
|
||||
INCDIR = $(patsubst %,-I%,$(DINCDIR) $(UINCDIR))
|
||||
LIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR))
|
||||
|
||||
ifeq ($(RUN_FROM_FLASH), 0)
|
||||
DEFS = $(DDEFS) $(UDEFS) -DRUN_FROM_FLASH=0
|
||||
else
|
||||
DEFS = $(DDEFS) $(UDEFS) -DRUN_FROM_FLASH=1
|
||||
endif
|
||||
|
||||
ADEFS = $(DADEFS) $(UADEFS)
|
||||
|
||||
AXOBJS = $(ASRC:%.s=%.o)
|
||||
CXOBJS = $(SRC:%.c=%.o)
|
||||
CPPXOBJS = $(CPPSRC:%.cpp=%.o)
|
||||
|
||||
LIBS = $(DLIBS) $(ULIBS)
|
||||
MCFLAGS = -mcpu=$(MCU)
|
||||
|
||||
ifeq ($(NANO), YES)
|
||||
# use newlib-nano for linking
|
||||
# NEWLIB_NANO_FLAGS = --specs=nano.specs -u _printf_float #use this version if printf for floats is needed!
|
||||
NEWLIB_NANO_FLAGS = --specs=nano.specs
|
||||
endif
|
||||
|
||||
#ASFLAGS = $(MCFLAGS) -g -gdwarf-2 -Wa,-amhls=$(OBJDIR)/$(notdir $(<:.s=.lst)) $(ADEFS)
|
||||
CPFLAGS = $(MCFLAGS) $(OPT) -gdwarf-2 -mthumb -fomit-frame-pointer -Wall -Wstrict-prototypes -fverbose-asm $(DEFS)
|
||||
LDFLAGS = $(MCFLAGS) -mthumb -nostartfiles -T$(LDSCRIPT) -Wl,-Map=$(FULL_PRJ).map,--cref,--no-warn-mismatch,--gc-sections $(LIBDIR) $(NEWLIB_NANO_FLAGS)
|
||||
CPPFLAGS = $(MCFLAGS) $(OPT) -gdwarf-2 -mthumb -fomit-frame-pointer -fdata-sections -ffunction-sections -Wall -fverbose-asm $(DEFS)
|
||||
|
||||
ifeq ($(WARNINGS_AS_ERRORS), YES)
|
||||
CPFLAGS += -Werror
|
||||
CPPFLAGS += -Werror
|
||||
endif
|
||||
|
||||
CPPFLAGS += $(CPPDEFS)
|
||||
CPFLAGS += $(CPPDEFS)
|
||||
CPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
||||
|
||||
AOBJS = $(patsubst %,$(OBJDIR)/%,$(notdir $(AXOBJS) ))
|
||||
COBJS = $(patsubst %,$(OBJDIR)/%,$(notdir $(CXOBJS) ))
|
||||
CPPOBJS = $(patsubst %,$(OBJDIR)/%,$(notdir $(CPPXOBJS) ))
|
||||
DIRS = $(sort $(dir $(AXOBJS) $(CXOBJS) $(CPPXOBJS) ) )
|
||||
|
||||
|
||||
CPPDEFS += -DCPUARM
|
||||
|
||||
ifeq ($(PCB), TARANIS)
|
||||
CPPDEFS += -DCPUSTM32
|
||||
endif
|
||||
|
||||
CPPDEFS += -DTIMERS=0
|
||||
|
||||
# If serial Debug required
|
||||
ifeq ($(DEBUG), 1)
|
||||
CPPDEFS += -DDEBUG
|
||||
endif
|
||||
|
||||
CPPDEFS += -DBOOT
|
||||
|
||||
# Generate dependency information
|
||||
CPFLAGS += -MD -MP -MF .dep/$(@F).d
|
||||
CPPFLAGS += -MD -MP -MF .dep/$(@F).d
|
||||
CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
||||
|
||||
#
|
||||
# makefile rules
|
||||
#
|
||||
|
||||
all: size_before $(OBJS) $(COBJS) $(CPPOBJS) $(FULL_PRJ).elf $(FULL_PRJ).hex $(FULL_PRJ).lss $(FULL_PRJ).bin size
|
||||
|
||||
#begin:
|
||||
# @echo $(AXOBJS) $(CXOBJS) $(CPPXOBJS)
|
||||
# @echo
|
||||
# @echo $(OBJS) $(COBJS) $(CPPOBJS)
|
||||
# @echo
|
||||
# @echo $(DIRS)
|
||||
|
||||
size_before:
|
||||
# arm-none-eabi-size $(FULL_PRJ).elf
|
||||
@if test -f $(FULL_PRJ).elf; then arm-none-eabi-size $(FULL_PRJ).elf; fi
|
||||
|
||||
size:
|
||||
# arm-none-eabi-size $(FULL_PRJ).elf
|
||||
@if test -f $(FULL_PRJ).elf; then arm-none-eabi-size $(FULL_PRJ).elf; fi
|
||||
|
||||
$(CPPOBJS) : $(OBJDIR)/%.o : %.cpp
|
||||
$(CC) -c $(CPPFLAGS) -fno-exceptions -I . $(INCDIR) $< -o $@
|
||||
|
||||
$(COBJS) : $(OBJDIR)/%.o : %.c
|
||||
$(CC) -c $(CPFLAGS) -I . $(INCDIR) $< -o $@
|
||||
|
||||
|
||||
$(AOBJS) : $(OBJDIR)/%.o : %.s
|
||||
$(AS) -c $(ASFLAGS) $< -o $@
|
||||
|
||||
%elf: $(AOBJS) $(COBJS) $(CPPOBJS)
|
||||
$(CC) $(AOBJS) $(COBJS) $(CPPOBJS) $(LDFLAGS) $(LIBS) -o $@
|
||||
|
||||
# Create extended listing file from ELF output file.
|
||||
%.lss: %.elf
|
||||
$(CLSS) -h -S $< > $@
|
||||
|
||||
%hex: %elf
|
||||
$(BIN) $< $@
|
||||
|
||||
%bin: %elf
|
||||
$(BINX) $< $@
|
||||
|
||||
# $(PROJECT)_flash8
|
||||
# $(PROJECT)_flash4
|
||||
# $(PROJECT)_ramBootS
|
||||
# $(PROJECT)_ramBootT
|
||||
|
||||
clean:
|
||||
-rm -f *.o
|
||||
-rm -f *.elf
|
||||
-rm -f *.map
|
||||
-rm -f *.hex
|
||||
-rm -f *.bin
|
||||
-rm -f *.lss
|
||||
-rm -fR .dep
|
||||
|
||||
|
||||
#
|
||||
# Include the dependency files, should be the last of the makefile
|
||||
#
|
||||
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
|
||||
|
||||
# *** EOF ***
|
||||
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "opentx.h"
|
||||
|
||||
struct CrossfireSensor {
|
||||
const uint8_t id;
|
||||
const uint8_t subId;
|
||||
const char * name;
|
||||
const TelemetryUnit unit;
|
||||
const uint8_t prec;
|
||||
};
|
||||
|
||||
const CrossfireSensor crossfireSensors[] = {
|
||||
{LINK_STATS_ID, 0, ZSTR_RX_RSSI1, UNIT_DB, 0},
|
||||
{LINK_STATS_ID, 1, ZSTR_RX_RSSI2, UNIT_DB, 0},
|
||||
{LINK_STATS_ID, 2, ZSTR_RX_QUALITY, UNIT_PERCENT, 0},
|
||||
{LINK_STATS_ID, 3, ZSTR_RX_SNR, UNIT_DB, 0},
|
||||
{LINK_STATS_ID, 4, ZSTR_ANTENNA, UNIT_RAW, 0},
|
||||
{LINK_STATS_ID, 5, ZSTR_RF_MODE, UNIT_RAW, 0},
|
||||
{LINK_STATS_ID, 6, ZSTR_TX_POWER, UNIT_MILLIWATTS, 0},
|
||||
{LINK_STATS_ID, 7, ZSTR_TX_RSSI, UNIT_DB, 0},
|
||||
{LINK_STATS_ID, 8, ZSTR_TX_QUALITY, UNIT_PERCENT, 0},
|
||||
{LINK_STATS_ID, 9, ZSTR_TX_SNR, UNIT_DB, 0},
|
||||
{ 0, 0, NULL, UNIT_RAW, 0} // sentinel
|
||||
};
|
||||
|
||||
const CrossfireSensor * getCrossfireSensor(uint8_t id, uint8_t subId=0)
|
||||
{
|
||||
const CrossfireSensor * result = NULL;
|
||||
for (const CrossfireSensor * sensor = crossfireSensors; sensor->id; sensor++) {
|
||||
if (id == sensor->id && subId == sensor->subId) {
|
||||
result = sensor;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void processCrossfireTelemetryFrame(uint8_t id, uint8_t subId, uint32_t value)
|
||||
{
|
||||
const CrossfireSensor * sensor = getCrossfireSensor(id, subId);
|
||||
TelemetryUnit unit = UNIT_RAW;
|
||||
uint8_t precision = 0;
|
||||
if (sensor) {
|
||||
unit = sensor->unit;
|
||||
precision = sensor->prec;
|
||||
}
|
||||
setTelemetryValue(TELEM_PROTO_CROSSFIRE, id, 0, subId, value, unit, precision);
|
||||
}
|
||||
|
||||
bool checkCrossfireTelemetryFrameCRC()
|
||||
{
|
||||
uint8_t len = telemetryRxBuffer[1];
|
||||
uint8_t crc = crc8(&telemetryRxBuffer[2], len-1);
|
||||
return (crc == telemetryRxBuffer[len+1]);
|
||||
}
|
||||
|
||||
void processCrossfireTelemetryFrame()
|
||||
{
|
||||
if (!checkCrossfireTelemetryFrameCRC()) {
|
||||
TRACE("processCrossfirePacket(): CRC error ");
|
||||
DUMP(telemetryRxBuffer, TELEMETRY_RX_PACKET_SIZE);
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t id = telemetryRxBuffer[2];
|
||||
switch(id) {
|
||||
case LINK_STATS_ID:
|
||||
for (int i=0; i<10; i++) {
|
||||
processCrossfireTelemetryFrame(id, i, telemetryRxBuffer[3+i]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void processCrossfireTelemetryData(uint8_t data)
|
||||
{
|
||||
if (telemetryRxBufferCount == 0 && data != 0x00) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (telemetryRxBufferCount == 1 && (data < 2 || data > TELEMETRY_RX_PACKET_SIZE-2)) {
|
||||
telemetryRxBufferCount = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (telemetryRxBufferCount < TELEMETRY_RX_PACKET_SIZE) {
|
||||
telemetryRxBuffer[telemetryRxBufferCount++] = data;
|
||||
}
|
||||
else {
|
||||
TRACE("processCrossfirePacket(): length error ");
|
||||
DUMP(telemetryRxBuffer, TELEMETRY_RX_PACKET_SIZE);
|
||||
telemetryRxBufferCount = 0;
|
||||
}
|
||||
|
||||
if (telemetryRxBufferCount > 4) {
|
||||
uint8_t length = telemetryRxBuffer[1];
|
||||
if (length + 2 == telemetryRxBufferCount) {
|
||||
processCrossfireTelemetryFrame();
|
||||
telemetryRxBufferCount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void crossfireSetDefault(int index, uint8_t id, uint8_t subId)
|
||||
{
|
||||
TelemetrySensor & telemetrySensor = g_model.telemetrySensors[index];
|
||||
|
||||
telemetrySensor.id = id;
|
||||
telemetrySensor.instance = subId;
|
||||
|
||||
const CrossfireSensor * sensor = getCrossfireSensor(id, subId);
|
||||
if (sensor) {
|
||||
TelemetryUnit unit = sensor->unit;
|
||||
uint8_t prec = min<uint8_t>(2, sensor->prec);
|
||||
telemetrySensor.init(sensor->name, unit, prec);
|
||||
if (id == LINK_STATS_ID) {
|
||||
telemetrySensor.logs = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
telemetrySensor.init(id);
|
||||
}
|
||||
|
||||
storageDirty(EE_MODEL);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef _CROSSFIRE_H_
|
||||
#define _CROSSFIRE_H_
|
||||
|
||||
#define LINK_STATS_ID 0x14
|
||||
|
||||
void processCrossfireTelemetryData(uint8_t data);
|
||||
void crossfireSetDefault(int index, uint8_t id, uint8_t subId);
|
||||
|
||||
#endif // _CROSSFIRE_H_
|
||||
+38
-518
@@ -18,115 +18,13 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "../opentx.h"
|
||||
#include "opentx.h"
|
||||
|
||||
uint8_t frskyStreaming = 0;
|
||||
|
||||
#if defined(WS_HOW_HIGH)
|
||||
uint8_t frskyUsrStreaming = 0;
|
||||
#endif
|
||||
|
||||
uint8_t link_counter = 0;
|
||||
|
||||
#define FRSKY_RX_PACKET_SIZE 19
|
||||
uint8_t frskyRxBuffer[FRSKY_RX_PACKET_SIZE]; // Receive buffer. 9 bytes (full packet), worst case 18 bytes with byte-stuffing (+1)
|
||||
|
||||
#if !defined(CPUARM) && !defined(PCBFLAMENCO)
|
||||
#if !defined(CPUARM)
|
||||
uint8_t frskyTxBuffer[FRSKY_TX_PACKET_SIZE];
|
||||
#endif
|
||||
|
||||
#if !defined(CPUARM)
|
||||
uint8_t frskyTxBufferCount = 0;
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
uint8_t telemetryState = TELEMETRY_INIT;
|
||||
#endif
|
||||
|
||||
uint8_t frskyRxBufferCount = 0;
|
||||
|
||||
FrskyData frskyData;
|
||||
|
||||
#if defined(CPUARM)
|
||||
uint8_t telemetryProtocol = 255;
|
||||
#if defined(REVX)
|
||||
uint8_t serialInversion = 0;
|
||||
#endif
|
||||
#define IS_FRSKY_D_PROTOCOL() (telemetryProtocol == PROTOCOL_FRSKY_D)
|
||||
#define IS_FRSKY_SPORT_PROTOCOL() (telemetryProtocol == PROTOCOL_FRSKY_SPORT)
|
||||
#else
|
||||
#define IS_FRSKY_D_PROTOCOL() (true)
|
||||
#define IS_FRSKY_SPORT_PROTOCOL() (false)
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
void FrskyValueWithMin::reset()
|
||||
{
|
||||
memclear(this, sizeof(*this));
|
||||
}
|
||||
#endif
|
||||
|
||||
void FrskyValueWithMin::set(uint8_t value)
|
||||
{
|
||||
#if defined(CPUARM)
|
||||
if (this->value == 0) {
|
||||
memset(values, value, TELEMETRY_AVERAGE_COUNT);
|
||||
this->value = value;
|
||||
}
|
||||
else {
|
||||
//calculate the average from values[] and value
|
||||
//also shift readings in values [] array
|
||||
unsigned int sum = values[0];
|
||||
for (int i=0; i<TELEMETRY_AVERAGE_COUNT-1; i++) {
|
||||
uint8_t tmp = values[i+1];
|
||||
values[i] = tmp;
|
||||
sum += tmp;
|
||||
}
|
||||
values[TELEMETRY_AVERAGE_COUNT-1] = value;
|
||||
sum += value;
|
||||
this->value = sum/(TELEMETRY_AVERAGE_COUNT+1);
|
||||
}
|
||||
#else
|
||||
if (this->value == 0) {
|
||||
this->value = value;
|
||||
}
|
||||
else {
|
||||
sum += value;
|
||||
if (link_counter == 0) {
|
||||
this->value = sum / (IS_FRSKY_D_PROTOCOL() ? FRSKY_D_AVERAGING : FRSKY_SPORT_AVERAGING);
|
||||
sum = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!min || value < min) {
|
||||
min = value;
|
||||
}
|
||||
}
|
||||
|
||||
void FrskyValueWithMinMax::set(uint8_t value, uint8_t unit)
|
||||
{
|
||||
FrskyValueWithMin::set(value);
|
||||
if (unit != UNIT_VOLTS) {
|
||||
this->value = value;
|
||||
}
|
||||
if (!max || value > max) {
|
||||
max = value;
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(CPUARM)
|
||||
uint16_t getChannelRatio(source_t channel)
|
||||
{
|
||||
return (uint16_t)g_model.frsky.channels[channel].ratio << g_model.frsky.channels[channel].multiplier;
|
||||
}
|
||||
|
||||
lcdint_t applyChannelRatio(source_t channel, lcdint_t val)
|
||||
{
|
||||
return ((int32_t)val+g_model.frsky.channels[channel].offset) * getChannelRatio(channel) * 2 / 51;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(TELEMETREZ)
|
||||
#define PRIVATE 0x1B
|
||||
uint8_t privateDataLen;
|
||||
@@ -138,7 +36,19 @@ extern uint8_t TrotCount;
|
||||
extern uint8_t TezRotary;
|
||||
#endif
|
||||
|
||||
NOINLINE void processSerialData(uint8_t data)
|
||||
// Receive buffer state machine state enum
|
||||
enum FrSkyDataState {
|
||||
STATE_DATA_IDLE,
|
||||
STATE_DATA_START,
|
||||
STATE_DATA_IN_FRAME,
|
||||
STATE_DATA_XOR,
|
||||
#if defined(TELEMETREZ)
|
||||
STATE_DATA_PRIVATE_LEN,
|
||||
STATE_DATA_PRIVATE_VALUE
|
||||
#endif
|
||||
};
|
||||
|
||||
NOINLINE void processFrskyTelemetryData(uint8_t data)
|
||||
{
|
||||
static uint8_t dataState = STATE_DATA_IDLE;
|
||||
|
||||
@@ -166,18 +76,17 @@ NOINLINE void processSerialData(uint8_t data)
|
||||
}
|
||||
#endif
|
||||
|
||||
switch (dataState)
|
||||
{
|
||||
switch (dataState) {
|
||||
case STATE_DATA_START:
|
||||
if (data == START_STOP) {
|
||||
if (IS_FRSKY_SPORT_PROTOCOL()) {
|
||||
dataState = STATE_DATA_IN_FRAME ;
|
||||
frskyRxBufferCount = 0;
|
||||
telemetryRxBufferCount = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (frskyRxBufferCount < FRSKY_RX_PACKET_SIZE) {
|
||||
frskyRxBuffer[frskyRxBufferCount++] = data;
|
||||
if (telemetryRxBufferCount < TELEMETRY_RX_PACKET_SIZE) {
|
||||
telemetryRxBuffer[telemetryRxBufferCount++] = data;
|
||||
}
|
||||
dataState = STATE_DATA_IN_FRAME;
|
||||
}
|
||||
@@ -190,30 +99,30 @@ NOINLINE void processSerialData(uint8_t data)
|
||||
else if (data == START_STOP) {
|
||||
if (IS_FRSKY_SPORT_PROTOCOL()) {
|
||||
dataState = STATE_DATA_IN_FRAME ;
|
||||
frskyRxBufferCount = 0;
|
||||
telemetryRxBufferCount = 0;
|
||||
}
|
||||
else {
|
||||
// end of frame detected
|
||||
frskyDProcessPacket(frskyRxBuffer);
|
||||
frskyDProcessPacket(telemetryRxBuffer);
|
||||
dataState = STATE_DATA_IDLE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if (frskyRxBufferCount < FRSKY_RX_PACKET_SIZE) {
|
||||
frskyRxBuffer[frskyRxBufferCount++] = data;
|
||||
else if (telemetryRxBufferCount < TELEMETRY_RX_PACKET_SIZE) {
|
||||
telemetryRxBuffer[telemetryRxBufferCount++] = data;
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_DATA_XOR:
|
||||
if (frskyRxBufferCount < FRSKY_RX_PACKET_SIZE) {
|
||||
frskyRxBuffer[frskyRxBufferCount++] = data ^ STUFF_MASK;
|
||||
if (telemetryRxBufferCount < TELEMETRY_RX_PACKET_SIZE) {
|
||||
telemetryRxBuffer[telemetryRxBufferCount++] = data ^ STUFF_MASK;
|
||||
}
|
||||
dataState = STATE_DATA_IN_FRAME;
|
||||
break;
|
||||
|
||||
case STATE_DATA_IDLE:
|
||||
if (data == START_STOP) {
|
||||
frskyRxBufferCount = 0;
|
||||
telemetryRxBufferCount = 0;
|
||||
dataState = STATE_DATA_START;
|
||||
}
|
||||
#if defined(TELEMETREZ)
|
||||
@@ -255,419 +164,30 @@ NOINLINE void processSerialData(uint8_t data)
|
||||
} // switch
|
||||
|
||||
#if defined(FRSKY_SPORT)
|
||||
if (IS_FRSKY_SPORT_PROTOCOL() && frskyRxBufferCount >= FRSKY_SPORT_PACKET_SIZE) {
|
||||
processSportPacket(frskyRxBuffer);
|
||||
if (IS_FRSKY_SPORT_PROTOCOL() && telemetryRxBufferCount >= FRSKY_SPORT_PACKET_SIZE) {
|
||||
processSportPacket(telemetryRxBuffer);
|
||||
dataState = STATE_DATA_IDLE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void telemetryWakeup()
|
||||
{
|
||||
#if defined(CPUARM)
|
||||
uint8_t requiredTelemetryProtocol = MODEL_TELEMETRY_PROTOCOL();
|
||||
#if defined(REVX)
|
||||
uint8_t requiredSerialInversion = g_model.moduleData[EXTERNAL_MODULE].invertedSerial;
|
||||
if (telemetryProtocol != requiredTelemetryProtocol || serialInversion != requiredSerialInversion) {
|
||||
serialInversion = requiredSerialInversion;
|
||||
#else
|
||||
if (telemetryProtocol != requiredTelemetryProtocol) {
|
||||
#endif
|
||||
telemetryInit(requiredTelemetryProtocol);
|
||||
telemetryProtocol = requiredTelemetryProtocol;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CPUSTM32)
|
||||
uint8_t data;
|
||||
#if defined(LOG_TELEMETRY) && !defined(SIMU)
|
||||
static tmr10ms_t lastTime = 0;
|
||||
tmr10ms_t newTime = get_tmr10ms();
|
||||
struct gtm utm;
|
||||
gettime(&utm);
|
||||
#endif
|
||||
while (telemetryFifo.pop(data)) {
|
||||
processSerialData(data);
|
||||
#if defined(LOG_TELEMETRY) && !defined(SIMU)
|
||||
extern FIL g_telemetryFile;
|
||||
if (lastTime != newTime) {
|
||||
f_printf(&g_telemetryFile, "\r\n%4d-%02d-%02d,%02d:%02d:%02d.%02d0: %02X", utm.tm_year+1900, utm.tm_mon+1, utm.tm_mday, utm.tm_hour, utm.tm_min, utm.tm_sec, g_ms100, data);
|
||||
lastTime = newTime;
|
||||
}
|
||||
else {
|
||||
f_printf(&g_telemetryFile, " %02X", data);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#elif defined(PCBSKY9X)
|
||||
if (telemetryProtocol == PROTOCOL_FRSKY_D_SECONDARY) {
|
||||
uint8_t data;
|
||||
while (telemetrySecondPortReceive(data)) {
|
||||
processSerialData(data);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Receive serial data here
|
||||
rxPdcUsart(processSerialData);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(CPUARM)
|
||||
if (IS_FRSKY_D_PROTOCOL()) {
|
||||
// Attempt to transmit any waiting Fr-Sky alarm set packets every 50ms (subject to packet buffer availability)
|
||||
static uint8_t frskyTxDelay = 5;
|
||||
if (frskyAlarmsSendState && (--frskyTxDelay == 0)) {
|
||||
frskyTxDelay = 5; // 50ms
|
||||
#if !defined(SIMU)
|
||||
frskyDSendNextAlarm();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
for (int i=0; i<MAX_SENSORS; i++) {
|
||||
const TelemetrySensor & sensor = g_model.telemetrySensors[i];
|
||||
if (sensor.type == TELEM_TYPE_CALCULATED) {
|
||||
telemetryItems[i].eval(sensor);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(VARIO)
|
||||
if (TELEMETRY_STREAMING() && !IS_FAI_ENABLED()) {
|
||||
varioWakeup();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PCBTARANIS) && defined(REVPLUS)
|
||||
#define FRSKY_BAD_ANTENNA() (IS_VALID_XJT_VERSION() && frskyData.swr.value > 0x33)
|
||||
#else
|
||||
#define FRSKY_BAD_ANTENNA() (frskyData.swr.value > 0x33)
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
static tmr10ms_t alarmsCheckTime = 0;
|
||||
#define SCHEDULE_NEXT_ALARMS_CHECK(seconds) alarmsCheckTime = get_tmr10ms() + (100*(seconds))
|
||||
if (int32_t(get_tmr10ms() - alarmsCheckTime) > 0) {
|
||||
|
||||
SCHEDULE_NEXT_ALARMS_CHECK(1/*second*/);
|
||||
|
||||
uint8_t now = TelemetryItem::now();
|
||||
bool sensor_lost = false;
|
||||
for (int i=0; i<MAX_SENSORS; i++) {
|
||||
if (isTelemetryFieldAvailable(i)) {
|
||||
uint8_t lastReceived = telemetryItems[i].lastReceived;
|
||||
if (lastReceived < TELEMETRY_VALUE_TIMER_CYCLE && uint8_t(now - lastReceived) > TELEMETRY_VALUE_OLD_THRESHOLD) {
|
||||
sensor_lost = true;
|
||||
telemetryItems[i].lastReceived = TELEMETRY_VALUE_OLD;
|
||||
TelemetrySensor * sensor = & g_model.telemetrySensors[i];
|
||||
if (sensor->unit == UNIT_DATETIME) {
|
||||
telemetryItems[i].datetime.datestate = 0;
|
||||
telemetryItems[i].datetime.timestate = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sensor_lost && TELEMETRY_STREAMING()) {
|
||||
audioEvent(AU_SENSOR_LOST);
|
||||
}
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
if ((g_model.moduleData[INTERNAL_MODULE].rfProtocol != RF_PROTO_OFF || g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_XJT) && FRSKY_BAD_ANTENNA()) {
|
||||
AUDIO_SWR_RED();
|
||||
POPUP_WARNING(STR_ANTENNAPROBLEM);
|
||||
SCHEDULE_NEXT_ALARMS_CHECK(10/*seconds*/);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (TELEMETRY_STREAMING()) {
|
||||
if (getRssiAlarmValue(1) && TELEMETRY_RSSI() < getRssiAlarmValue(1)) {
|
||||
AUDIO_RSSI_RED();
|
||||
SCHEDULE_NEXT_ALARMS_CHECK(10/*seconds*/);
|
||||
}
|
||||
else if (getRssiAlarmValue(0) && TELEMETRY_RSSI() < getRssiAlarmValue(0)) {
|
||||
AUDIO_RSSI_ORANGE();
|
||||
SCHEDULE_NEXT_ALARMS_CHECK(10/*seconds*/);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (TELEMETRY_STREAMING()) {
|
||||
if (telemetryState == TELEMETRY_KO) {
|
||||
AUDIO_TELEMETRY_BACK();
|
||||
}
|
||||
telemetryState = TELEMETRY_OK;
|
||||
}
|
||||
else if (telemetryState == TELEMETRY_OK) {
|
||||
telemetryState = TELEMETRY_KO;
|
||||
AUDIO_TELEMETRY_LOST();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void telemetryInterrupt10ms()
|
||||
{
|
||||
#if defined(CPUARM)
|
||||
#elif defined(FRSKY_HUB)
|
||||
uint16_t voltage = 0; /* unit: 1/10 volts */
|
||||
for (uint8_t i=0; i<frskyData.hub.cellsCount; i++)
|
||||
voltage += frskyData.hub.cellVolts[i];
|
||||
voltage /= (10 / TELEMETRY_CELL_VOLTAGE_MUTLIPLIER);
|
||||
frskyData.hub.cellsSum = voltage;
|
||||
if (frskyData.hub.cellsSum < frskyData.hub.minCells) {
|
||||
frskyData.hub.minCells = frskyData.hub.cellsSum;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (TELEMETRY_STREAMING()) {
|
||||
if (!TELEMETRY_OPENXSENSOR()) {
|
||||
#if defined(CPUARM)
|
||||
for (int i=0; i<MAX_SENSORS; i++) {
|
||||
const TelemetrySensor & sensor = g_model.telemetrySensors[i];
|
||||
if (sensor.type == TELEM_TYPE_CALCULATED) {
|
||||
telemetryItems[i].per10ms(sensor);
|
||||
}
|
||||
}
|
||||
#else
|
||||
// power calculation
|
||||
uint8_t channel = g_model.frsky.voltsSource;
|
||||
if (channel <= FRSKY_VOLTS_SOURCE_A2) {
|
||||
voltage = applyChannelRatio(channel, frskyData.analog[channel].value) / 10;
|
||||
}
|
||||
|
||||
#if defined(FRSKY_HUB)
|
||||
else if (channel == FRSKY_VOLTS_SOURCE_FAS) {
|
||||
voltage = frskyData.hub.vfas;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FRSKY_HUB)
|
||||
uint16_t current = frskyData.hub.current; /* unit: 1/10 amps */
|
||||
#else
|
||||
uint16_t current = 0;
|
||||
#endif
|
||||
|
||||
channel = g_model.frsky.currentSource - FRSKY_CURRENT_SOURCE_A1;
|
||||
if (channel < MAX_FRSKY_A_CHANNELS) {
|
||||
current = applyChannelRatio(channel, frskyData.analog[channel].value) / 10;
|
||||
}
|
||||
|
||||
frskyData.hub.power = ((current>>1) * (voltage>>1)) / 25;
|
||||
|
||||
frskyData.hub.currentPrescale += current;
|
||||
if (frskyData.hub.currentPrescale >= 3600) {
|
||||
frskyData.hub.currentConsumption += 1;
|
||||
frskyData.hub.currentPrescale -= 3600;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(CPUARM)
|
||||
if (frskyData.hub.power > frskyData.hub.maxPower) {
|
||||
frskyData.hub.maxPower = frskyData.hub.power;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(WS_HOW_HIGH)
|
||||
if (frskyUsrStreaming > 0) {
|
||||
frskyUsrStreaming--;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (frskyStreaming > 0) {
|
||||
frskyStreaming--;
|
||||
}
|
||||
else {
|
||||
#if !defined(SIMU)
|
||||
#if defined(CPUARM)
|
||||
frskyData.rssi.reset();
|
||||
#else
|
||||
frskyData.rssi[0].set(0);
|
||||
frskyData.rssi[1].set(0);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void telemetryReset()
|
||||
{
|
||||
memclear(&frskyData, sizeof(frskyData));
|
||||
|
||||
#if defined(CPUARM)
|
||||
for (int index=0; index<MAX_SENSORS; index++) {
|
||||
telemetryItems[index].clear();
|
||||
}
|
||||
#endif
|
||||
|
||||
frskyStreaming = 0; // reset counter only if valid frsky packets are being detected
|
||||
link_counter = 0;
|
||||
|
||||
#if defined(CPUARM)
|
||||
telemetryState = TELEMETRY_INIT;
|
||||
#endif
|
||||
|
||||
#if defined(FRSKY_HUB) && !defined(CPUARM)
|
||||
frskyData.hub.gpsLatitude_bp = 2;
|
||||
frskyData.hub.gpsLongitude_bp = 2;
|
||||
frskyData.hub.gpsFix = -1;
|
||||
#endif
|
||||
|
||||
#if defined(SIMU)
|
||||
|
||||
#if defined(CPUARM)
|
||||
frskyData.swr.value = 30;
|
||||
frskyData.rssi.value = 75;
|
||||
#else
|
||||
frskyData.rssi[0].value = 75;
|
||||
frskyData.rssi[1].value = 75;
|
||||
frskyData.analog[TELEM_ANA_A1].set(120, UNIT_VOLTS);
|
||||
frskyData.analog[TELEM_ANA_A2].set(240, UNIT_VOLTS);
|
||||
#endif
|
||||
|
||||
#if !defined(CPUARM)
|
||||
frskyData.hub.fuelLevel = 75;
|
||||
frskyData.hub.rpm = 12000;
|
||||
frskyData.hub.vfas = 100;
|
||||
frskyData.hub.minVfas = 90;
|
||||
|
||||
#if defined(GPS)
|
||||
frskyData.hub.gpsFix = 1;
|
||||
frskyData.hub.gpsLatitude_bp = 4401;
|
||||
frskyData.hub.gpsLatitude_ap = 7710;
|
||||
frskyData.hub.gpsLongitude_bp = 1006;
|
||||
frskyData.hub.gpsLongitude_ap = 8872;
|
||||
frskyData.hub.gpsSpeed_bp = 200; //in knots
|
||||
frskyData.hub.gpsSpeed_ap = 0;
|
||||
getGpsPilotPosition();
|
||||
|
||||
frskyData.hub.gpsLatitude_bp = 4401;
|
||||
frskyData.hub.gpsLatitude_ap = 7455;
|
||||
frskyData.hub.gpsLongitude_bp = 1006;
|
||||
frskyData.hub.gpsLongitude_ap = 9533;
|
||||
getGpsDistance();
|
||||
#endif
|
||||
|
||||
frskyData.hub.airSpeed = 1000; // 185.1 km/h
|
||||
|
||||
frskyData.hub.cellsCount = 6;
|
||||
frskyData.hub.cellVolts[0] = 410/TELEMETRY_CELL_VOLTAGE_MUTLIPLIER;
|
||||
frskyData.hub.cellVolts[1] = 420/TELEMETRY_CELL_VOLTAGE_MUTLIPLIER;
|
||||
frskyData.hub.cellVolts[2] = 430/TELEMETRY_CELL_VOLTAGE_MUTLIPLIER;
|
||||
frskyData.hub.cellVolts[3] = 440/TELEMETRY_CELL_VOLTAGE_MUTLIPLIER;
|
||||
frskyData.hub.cellVolts[4] = 450/TELEMETRY_CELL_VOLTAGE_MUTLIPLIER;
|
||||
frskyData.hub.cellVolts[5] = 460/TELEMETRY_CELL_VOLTAGE_MUTLIPLIER;
|
||||
frskyData.hub.minCellVolts = 250/TELEMETRY_CELL_VOLTAGE_MUTLIPLIER;
|
||||
frskyData.hub.minCell = 300; //unit 10mV
|
||||
frskyData.hub.minCells = 220; //unit 100mV
|
||||
//frskyData.hub.cellsSum = 261; //calculated from cellVolts[]
|
||||
|
||||
frskyData.hub.gpsAltitude_bp = 50;
|
||||
frskyData.hub.baroAltitude_bp = 50;
|
||||
frskyData.hub.minAltitude = 10;
|
||||
frskyData.hub.maxAltitude = 500;
|
||||
|
||||
frskyData.hub.accelY = 100;
|
||||
frskyData.hub.temperature1 = -30;
|
||||
frskyData.hub.maxTemperature1 = 100;
|
||||
|
||||
frskyData.hub.current = 55;
|
||||
frskyData.hub.maxCurrent = 65;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*Add some default sensor values to the simulator*/
|
||||
#if defined(CPUARM) && defined(SIMU)
|
||||
for (int i=0; i<MAX_SENSORS; i++) {
|
||||
const TelemetrySensor & sensor = g_model.telemetrySensors[i];
|
||||
switch (sensor.id)
|
||||
{
|
||||
case RSSI_ID:
|
||||
setTelemetryValue(TELEM_PROTO_FRSKY_SPORT, RSSI_ID, 0, sensor.instance , 75, UNIT_RAW, 0);
|
||||
break;
|
||||
case ADC1_ID:
|
||||
setTelemetryValue(TELEM_PROTO_FRSKY_SPORT, ADC1_ID, 0, sensor.instance, 100, UNIT_RAW, 0);
|
||||
break;
|
||||
case ADC2_ID:
|
||||
setTelemetryValue(TELEM_PROTO_FRSKY_SPORT, ADC2_ID, 0, sensor.instance, 245, UNIT_RAW, 0);
|
||||
break;
|
||||
case SWR_ID:
|
||||
setTelemetryValue(TELEM_PROTO_FRSKY_SPORT, SWR_ID, 0, sensor.instance, 30, UNIT_RAW, 0);
|
||||
break;
|
||||
case BATT_ID:
|
||||
setTelemetryValue(TELEM_PROTO_FRSKY_SPORT, BATT_ID, 0, sensor.instance, 100, UNIT_RAW, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(CPUARM)
|
||||
// we don't reset the telemetry here as we would also reset the consumption after model load
|
||||
void telemetryInit(uint8_t protocol)
|
||||
{
|
||||
if (protocol == PROTOCOL_FRSKY_D) {
|
||||
telemetryPortInit(FRSKY_D_BAUDRATE);
|
||||
}
|
||||
#if defined(CROSSFIRE)
|
||||
else if (protocol == PROTOCOL_PULSES_CROSSFIRE) {
|
||||
telemetryPortInit(CROSSFIRE_BAUDRATE);
|
||||
telemetryPortSetDirectionOutput();
|
||||
}
|
||||
#endif
|
||||
else if (protocol == PROTOCOL_FRSKY_D_SECONDARY) {
|
||||
telemetryPortInit(0);
|
||||
serial2TelemetryInit(PROTOCOL_FRSKY_D_SECONDARY);
|
||||
}
|
||||
else {
|
||||
telemetryPortInit(FRSKY_SPORT_BAUDRATE);
|
||||
}
|
||||
|
||||
#if defined(REVX) && !defined(SIMU)
|
||||
if (serialInversion) {
|
||||
setMFP();
|
||||
}
|
||||
else {
|
||||
clearMFP();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
void telemetryInit()
|
||||
{
|
||||
telemetryPortInit();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
#elif defined(FRSKY_HUB)
|
||||
void frskyUpdateCells(void)
|
||||
{
|
||||
// Voltage => Cell number + Cell voltage
|
||||
uint8_t battnumber = ((frskyData.hub.volts & 0x00F0) >> 4);
|
||||
uint8_t battnumber = ((telemetryData.hub.volts & 0x00F0) >> 4);
|
||||
if (battnumber < 12) {
|
||||
if (frskyData.hub.cellsCount < battnumber+1) {
|
||||
frskyData.hub.cellsCount = battnumber+1;
|
||||
if (telemetryData.hub.cellsCount < battnumber+1) {
|
||||
telemetryData.hub.cellsCount = battnumber+1;
|
||||
}
|
||||
uint8_t cellVolts = (uint8_t)(((((frskyData.hub.volts & 0xFF00) >> 8) + ((frskyData.hub.volts & 0x000F) << 8))) / 10);
|
||||
frskyData.hub.cellVolts[battnumber] = cellVolts;
|
||||
if (!frskyData.hub.minCellVolts || cellVolts<frskyData.hub.minCellVolts || battnumber==frskyData.hub.minCellIdx) {
|
||||
frskyData.hub.minCellIdx = battnumber;
|
||||
frskyData.hub.minCellVolts = cellVolts;
|
||||
if (!frskyData.hub.minCell || frskyData.hub.minCellVolts<frskyData.hub.minCell)
|
||||
frskyData.hub.minCell = frskyData.hub.minCellVolts;
|
||||
uint8_t cellVolts = (uint8_t)(((((telemetryData.hub.volts & 0xFF00) >> 8) + ((telemetryData.hub.volts & 0x000F) << 8))) / 10);
|
||||
telemetryData.hub.cellVolts[battnumber] = cellVolts;
|
||||
if (!telemetryData.hub.minCellVolts || cellVolts<telemetryData.hub.minCellVolts || battnumber==telemetryData.hub.minCellIdx) {
|
||||
telemetryData.hub.minCellIdx = battnumber;
|
||||
telemetryData.hub.minCellVolts = cellVolts;
|
||||
if (!telemetryData.hub.minCell || telemetryData.hub.minCellVolts<telemetryData.hub.minCell)
|
||||
telemetryData.hub.minCell = telemetryData.hub.minCellVolts;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
NOINLINE uint8_t getRssiAlarmValue(uint8_t alarm)
|
||||
{
|
||||
return (45 - 3*alarm + g_model.frsky.rssiAlarms[alarm].value);
|
||||
}
|
||||
|
||||
#if defined(LUA)
|
||||
Fifo<LuaTelemetryValue, 16> * luaInputTelemetryFifo = NULL;
|
||||
Fifo<LuaTelemetryValue, 16> * luaOutputTelemetryFifo = NULL;
|
||||
#endif
|
||||
|
||||
+83
-154
@@ -21,7 +21,7 @@
|
||||
#ifndef _FRSKY_H_
|
||||
#define _FRSKY_H_
|
||||
|
||||
#include <inttypes.h>
|
||||
#include "telemetry_holders.h"
|
||||
|
||||
#define FRSKY_SPORT_BAUDRATE 57600
|
||||
#define FRSKY_D_BAUDRATE 9600
|
||||
@@ -161,59 +161,9 @@
|
||||
#define DATA_ID_SP2UH 0x45 // 5
|
||||
#define DATA_ID_SP2UR 0xC6 // 6
|
||||
|
||||
|
||||
// Global Fr-Sky telemetry data variables
|
||||
extern uint8_t frskyStreaming; // >0 (true) == data is streaming in. 0 = nodata detected for some time
|
||||
|
||||
#if defined(WS_HOW_HIGH)
|
||||
extern uint8_t frskyUsrStreaming;
|
||||
#endif
|
||||
|
||||
extern uint8_t link_counter;
|
||||
|
||||
#if defined(CPUARM)
|
||||
enum TelemetryStates {
|
||||
TELEMETRY_INIT,
|
||||
TELEMETRY_OK,
|
||||
TELEMETRY_KO
|
||||
};
|
||||
|
||||
extern uint8_t telemetryState;
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
#define TELEMETRY_AVERAGE_COUNT 3 // we actually average one more reading!
|
||||
#define RAW_FRSKY_MINMAX(v) v.values[TELEMETRY_AVERAGE_COUNT-1]
|
||||
class FrskyValueWithMin {
|
||||
public:
|
||||
uint8_t value; // fitered value (average of last TELEMETRY_AVERAGE_COUNT+1 values)
|
||||
uint8_t min;
|
||||
uint8_t values[TELEMETRY_AVERAGE_COUNT];
|
||||
void set(uint8_t value);
|
||||
void reset();
|
||||
};
|
||||
#else
|
||||
#define RAW_FRSKY_MINMAX(v) v.value
|
||||
class FrskyValueWithMin {
|
||||
public:
|
||||
uint8_t value;
|
||||
uint8_t min;
|
||||
uint16_t sum;
|
||||
void set(uint8_t value);
|
||||
};
|
||||
#endif
|
||||
|
||||
class FrskyValueWithMinMax: public FrskyValueWithMin {
|
||||
public:
|
||||
uint8_t max;
|
||||
void set(uint8_t value, uint8_t unit);
|
||||
};
|
||||
|
||||
#if defined(CPUARM)
|
||||
|
||||
|
||||
#elif defined(FRSKY_HUB)
|
||||
PACK(struct FrskySerialData {
|
||||
#if !defined(CPUARM)
|
||||
#if defined(FRSKY_HUB)
|
||||
PACK(struct FrskyTelemetryData {
|
||||
int16_t baroAltitudeOffset; // spare reused
|
||||
int16_t gpsAltitude_bp; // 0x01 before punct
|
||||
int16_t temperature1; // 0x02 -20 .. 250 deg. celcius
|
||||
@@ -291,7 +241,7 @@ PACK(struct FrskySerialData {
|
||||
int16_t dTE;
|
||||
});
|
||||
#elif defined(WS_HOW_HIGH)
|
||||
PACK(struct FrskySerialData {
|
||||
PACK(struct FrskyTelemetryData {
|
||||
int16_t baroAltitude_bp; // 0..9,999 meters
|
||||
int16_t baroAltitudeOffset;
|
||||
int16_t minAltitude;
|
||||
@@ -305,7 +255,7 @@ PACK(struct FrskySerialData {
|
||||
#endif
|
||||
});
|
||||
#elif defined(VARIO)
|
||||
PACK(struct FrskySerialData {
|
||||
PACK(struct FrskyTelemetryData {
|
||||
int16_t varioSpeed; // Vertical speed in cm/s
|
||||
uint16_t currentConsumption;
|
||||
uint16_t currentPrescale;
|
||||
@@ -313,41 +263,17 @@ PACK(struct FrskySerialData {
|
||||
uint16_t maxPower;
|
||||
});
|
||||
#else
|
||||
PACK(struct FrskySerialData {
|
||||
PACK(struct FrskyTelemetryData {
|
||||
uint16_t currentConsumption;
|
||||
uint16_t currentPrescale;
|
||||
uint16_t power;
|
||||
uint16_t maxPower;
|
||||
});
|
||||
#endif
|
||||
|
||||
enum TelemAnas {
|
||||
TELEM_ANA_A1,
|
||||
TELEM_ANA_A2,
|
||||
#if defined(CPUARM)
|
||||
TELEM_ANA_A3,
|
||||
TELEM_ANA_A4,
|
||||
#endif
|
||||
TELEM_ANA_COUNT
|
||||
};
|
||||
|
||||
#if defined(CPUARM)
|
||||
struct FrskyData {
|
||||
FrskyValueWithMin swr; // TODO Min not needed
|
||||
FrskyValueWithMin rssi; // TODO Min not needed
|
||||
uint16_t xjtVersion;
|
||||
bool varioHighPrecision;
|
||||
};
|
||||
#else
|
||||
struct FrskyData {
|
||||
FrskyValueWithMinMax analog[TELEM_ANA_COUNT];
|
||||
FrskyValueWithMin rssi[2];
|
||||
FrskySerialData hub;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(PCBTARANIS) && defined(REVPLUS)
|
||||
#define IS_VALID_XJT_VERSION() (frskyData.xjtVersion != 0 && frskyData.xjtVersion != 0xff)
|
||||
#define IS_VALID_XJT_VERSION() (telemetryData.xjtVersion != 0 && telemetryData.xjtVersion != 0xff)
|
||||
#else
|
||||
#define IS_VALID_XJT_VERSION() (1)
|
||||
#endif
|
||||
@@ -364,118 +290,104 @@ enum AlarmLevel {
|
||||
#define ALARM_LEVEL(channel, alarm) ((g_model.frsky.channels[channel].alarms_level >> (2*alarm)) & 3)
|
||||
|
||||
#if defined(CPUARM)
|
||||
#define TELEMETRY_STREAMING() (frskyData.rssi.value > 0)
|
||||
#define TELEMETRY_RSSI() (frskyData.rssi.value)
|
||||
#define TELEMETRY_RSSI_MIN() (frskyData.rssi.min)
|
||||
#define TELEMETRY_STREAMING() (telemetryData.rssi.value > 0)
|
||||
#define TELEMETRY_RSSI() (telemetryData.rssi.value)
|
||||
#define TELEMETRY_RSSI_MIN() (telemetryData.rssi.min)
|
||||
|
||||
#define TELEMETRY_CELL_VOLTAGE_MUTLIPLIER 1
|
||||
|
||||
#define TELEMETRY_GPS_SPEED_BP frskyData.hub.gpsSpeed_bp
|
||||
#define TELEMETRY_GPS_SPEED_AP frskyData.hub.gpsSpeed_ap
|
||||
#define TELEMETRY_GPS_SPEED_BP telemetryData.hub.gpsSpeed_bp
|
||||
#define TELEMETRY_GPS_SPEED_AP telemetryData.hub.gpsSpeed_ap
|
||||
|
||||
#define TELEMETRY_ABSOLUTE_GPS_ALT (frskyData.hub.gpsAltitude)
|
||||
#define TELEMETRY_RELATIVE_GPS_ALT (frskyData.hub.gpsAltitude + frskyData.hub.gpsAltitudeOffset)
|
||||
#define TELEMETRY_ABSOLUTE_GPS_ALT (telemetryData.hub.gpsAltitude)
|
||||
#define TELEMETRY_RELATIVE_GPS_ALT (telemetryData.hub.gpsAltitude + telemetryData.hub.gpsAltitudeOffset)
|
||||
#define TELEMETRY_RELATIVE_GPS_ALT_BP (TELEMETRY_RELATIVE_GPS_ALT / 100)
|
||||
|
||||
#define TELEMETRY_RELATIVE_BARO_ALT_BP (frskyData.hub.baroAltitude / 100)
|
||||
#define TELEMETRY_RELATIVE_BARO_ALT_AP (frskyData.hub.baroAltitude % 100)
|
||||
#define TELEMETRY_RELATIVE_BARO_ALT_BP (telemetryData.hub.baroAltitude / 100)
|
||||
#define TELEMETRY_RELATIVE_BARO_ALT_AP (telemetryData.hub.baroAltitude % 100)
|
||||
|
||||
#define TELEMETRY_BARO_ALT_PREPARE() div_t baroAltitudeDivision = div(getConvertedTelemetryValue(frskyData.hub.baroAltitude, UNIT_DIST), 100)
|
||||
#define TELEMETRY_BARO_ALT_PREPARE() div_t baroAltitudeDivision = div(getConvertedTelemetryValue(telemetryData.hub.baroAltitude, UNIT_DIST), 100)
|
||||
#define TELEMETRY_BARO_ALT_FORMAT "%c%d.%02d,"
|
||||
#define TELEMETRY_BARO_ALT_ARGS frskyData.hub.baroAltitude < 0 ? '-' : ' ', abs(baroAltitudeDivision.quot), abs(baroAltitudeDivision.rem),
|
||||
#define TELEMETRY_BARO_ALT_ARGS telemetryData.hub.baroAltitude < 0 ? '-' : ' ', abs(baroAltitudeDivision.quot), abs(baroAltitudeDivision.rem),
|
||||
#define TELEMETRY_GPS_ALT_FORMAT "%c%d.%02d,"
|
||||
#define TELEMETRY_GPS_ALT_ARGS frskyData.hub.gpsAltitude < 0 ? '-' : ' ', abs(frskyData.hub.gpsAltitude / 100), abs(frskyData.hub.gpsAltitude % 100),
|
||||
#define TELEMETRY_GPS_ALT_ARGS telemetryData.hub.gpsAltitude < 0 ? '-' : ' ', abs(telemetryData.hub.gpsAltitude / 100), abs(telemetryData.hub.gpsAltitude % 100),
|
||||
#define TELEMETRY_SPEED_UNIT (IS_IMPERIAL_ENABLE() ? SPEED_UNIT_IMP : SPEED_UNIT_METR)
|
||||
#define TELEMETRY_GPS_SPEED_FORMAT "%d,"
|
||||
#define TELEMETRY_GPS_SPEED_ARGS frskyData.hub.gpsSpeed_bp,
|
||||
#define TELEMETRY_GPS_SPEED_ARGS telemetryData.hub.gpsSpeed_bp,
|
||||
#if defined(CPUARM)
|
||||
#define TELEMETRY_CELLS_ARGS frskyData.hub.cellsSum / 10, frskyData.hub.cellsSum % 10, TELEMETRY_CELL_VOLTAGE(0)/100, TELEMETRY_CELL_VOLTAGE(0)%100, TELEMETRY_CELL_VOLTAGE(1)/100, TELEMETRY_CELL_VOLTAGE(1)%100, TELEMETRY_CELL_VOLTAGE(2)/100, TELEMETRY_CELL_VOLTAGE(2)%100, TELEMETRY_CELL_VOLTAGE(3)/100, TELEMETRY_CELL_VOLTAGE(3)%100, TELEMETRY_CELL_VOLTAGE(4)/100, TELEMETRY_CELL_VOLTAGE(4)%100, TELEMETRY_CELL_VOLTAGE(5)/100, TELEMETRY_CELL_VOLTAGE(5)%100, TELEMETRY_CELL_VOLTAGE(6)/100, TELEMETRY_CELL_VOLTAGE(6)%100, TELEMETRY_CELL_VOLTAGE(7)/100, TELEMETRY_CELL_VOLTAGE(7)%100, TELEMETRY_CELL_VOLTAGE(8)/100, TELEMETRY_CELL_VOLTAGE(8)%100, TELEMETRY_CELL_VOLTAGE(9)/100, TELEMETRY_CELL_VOLTAGE(9)%100, TELEMETRY_CELL_VOLTAGE(10)/100, TELEMETRY_CELL_VOLTAGE(10)%100, TELEMETRY_CELL_VOLTAGE(11)/100, TELEMETRY_CELL_VOLTAGE(11)%100,
|
||||
#define TELEMETRY_CELLS_ARGS telemetryData.hub.cellsSum / 10, telemetryData.hub.cellsSum % 10, TELEMETRY_CELL_VOLTAGE(0)/100, TELEMETRY_CELL_VOLTAGE(0)%100, TELEMETRY_CELL_VOLTAGE(1)/100, TELEMETRY_CELL_VOLTAGE(1)%100, TELEMETRY_CELL_VOLTAGE(2)/100, TELEMETRY_CELL_VOLTAGE(2)%100, TELEMETRY_CELL_VOLTAGE(3)/100, TELEMETRY_CELL_VOLTAGE(3)%100, TELEMETRY_CELL_VOLTAGE(4)/100, TELEMETRY_CELL_VOLTAGE(4)%100, TELEMETRY_CELL_VOLTAGE(5)/100, TELEMETRY_CELL_VOLTAGE(5)%100, TELEMETRY_CELL_VOLTAGE(6)/100, TELEMETRY_CELL_VOLTAGE(6)%100, TELEMETRY_CELL_VOLTAGE(7)/100, TELEMETRY_CELL_VOLTAGE(7)%100, TELEMETRY_CELL_VOLTAGE(8)/100, TELEMETRY_CELL_VOLTAGE(8)%100, TELEMETRY_CELL_VOLTAGE(9)/100, TELEMETRY_CELL_VOLTAGE(9)%100, TELEMETRY_CELL_VOLTAGE(10)/100, TELEMETRY_CELL_VOLTAGE(10)%100, TELEMETRY_CELL_VOLTAGE(11)/100, TELEMETRY_CELL_VOLTAGE(11)%100,
|
||||
#define TELEMETRY_CELLS_FORMAT "%d.%d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,"
|
||||
#define TELEMETRY_CELLS_LABEL "Cell volts,Cell 1,Cell 2,Cell 3,Cell 4,Cell 5,Cell 6,Cell 7,Cell 8,Cell 9,Cell 10,Cell 11,Cell 12,"
|
||||
#else
|
||||
#define TELEMETRY_CELLS_ARGS frskyData.hub.cellsSum / 10, frskyData.hub.cellsSum % 10, TELEMETRY_CELL_VOLTAGE(0)/100, TELEMETRY_CELL_VOLTAGE(0)%100, TELEMETRY_CELL_VOLTAGE(1)/100, TELEMETRY_CELL_VOLTAGE(1)%100, TELEMETRY_CELL_VOLTAGE(2)/100, TELEMETRY_CELL_VOLTAGE(2)%100, TELEMETRY_CELL_VOLTAGE(3)/100, TELEMETRY_CELL_VOLTAGE(3)%100, TELEMETRY_CELL_VOLTAGE(4)/100, TELEMETRY_CELL_VOLTAGE(4)%100, TELEMETRY_CELL_VOLTAGE(5)/100, TELEMETRY_CELL_VOLTAGE(5)%100,
|
||||
#define TELEMETRY_CELLS_ARGS telemetryData.hub.cellsSum / 10, telemetryData.hub.cellsSum % 10, TELEMETRY_CELL_VOLTAGE(0)/100, TELEMETRY_CELL_VOLTAGE(0)%100, TELEMETRY_CELL_VOLTAGE(1)/100, TELEMETRY_CELL_VOLTAGE(1)%100, TELEMETRY_CELL_VOLTAGE(2)/100, TELEMETRY_CELL_VOLTAGE(2)%100, TELEMETRY_CELL_VOLTAGE(3)/100, TELEMETRY_CELL_VOLTAGE(3)%100, TELEMETRY_CELL_VOLTAGE(4)/100, TELEMETRY_CELL_VOLTAGE(4)%100, TELEMETRY_CELL_VOLTAGE(5)/100, TELEMETRY_CELL_VOLTAGE(5)%100,
|
||||
#define TELEMETRY_CELLS_FORMAT "%d.%d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,"
|
||||
#define TELEMETRY_CELLS_LABEL "Cell volts,Cell 1,Cell 2,Cell 3,Cell 4,Cell 5,Cell 6,"
|
||||
#endif
|
||||
#define TELEMETRY_CURRENT_FORMAT "%d.%d,"
|
||||
#define TELEMETRY_CURRENT_ARGS frskyData.hub.current / 10, frskyData.hub.current % 10,
|
||||
#define TELEMETRY_CURRENT_ARGS telemetryData.hub.current / 10, telemetryData.hub.current % 10,
|
||||
#define TELEMETRY_VFAS_FORMAT "%d.%d,"
|
||||
#define TELEMETRY_VFAS_ARGS frskyData.hub.vfas / 10, frskyData.hub.vfas % 10,
|
||||
#define TELEMETRY_VFAS_ARGS telemetryData.hub.vfas / 10, telemetryData.hub.vfas % 10,
|
||||
#define TELEMETRY_VSPEED_FORMAT "%c%d.%02d,"
|
||||
#define TELEMETRY_VSPEED_ARGS frskyData.hub.varioSpeed < 0 ? '-' : ' ', abs(frskyData.hub.varioSpeed / 100), abs(frskyData.hub.varioSpeed % 100),
|
||||
#define TELEMETRY_VSPEED_ARGS telemetryData.hub.varioSpeed < 0 ? '-' : ' ', abs(telemetryData.hub.varioSpeed / 100), abs(telemetryData.hub.varioSpeed % 100),
|
||||
#define TELEMETRY_ASPEED_FORMAT "%d.%d,"
|
||||
#define TELEMETRY_ASPEED_ARGS frskyData.hub.airSpeed / 10, frskyData.hub.airSpeed % 10,
|
||||
#define TELEMETRY_ASPEED_ARGS telemetryData.hub.airSpeed / 10, telemetryData.hub.airSpeed % 10,
|
||||
#define TELEMETRY_OPENXSENSOR() (0)
|
||||
#else
|
||||
#define TELEMETRY_STREAMING() (frskyStreaming > 0)
|
||||
#define TELEMETRY_RSSI() (frskyData.rssi[0].value)
|
||||
#define TELEMETRY_RSSI_MIN() (frskyData.rssi[0].min)
|
||||
#define TELEMETRY_STREAMING() (telemetryStreaming > 0)
|
||||
#define TELEMETRY_RSSI() (telemetryData.rssi[0].value)
|
||||
#define TELEMETRY_RSSI_MIN() (telemetryData.rssi[0].min)
|
||||
|
||||
#define TELEMETRY_CELL_VOLTAGE_MUTLIPLIER 2
|
||||
|
||||
#define TELEMETRY_BARO_ALT_AVAILABLE() (frskyData.hub.baroAltitudeOffset)
|
||||
#define TELEMETRY_BARO_ALT_AVAILABLE() (telemetryData.hub.baroAltitudeOffset)
|
||||
#define TELEMETRY_BARO_ALT_UNIT (IS_IMPERIAL_ENABLE() ? LENGTH_UNIT_IMP : LENGTH_UNIT_METR)
|
||||
|
||||
#define TELEMETRY_RELATIVE_BARO_ALT_BP frskyData.hub.baroAltitude_bp
|
||||
#define TELEMETRY_RELATIVE_BARO_ALT_AP frskyData.hub.baroAltitude_ap
|
||||
#define TELEMETRY_RELATIVE_GPS_ALT_BP frskyData.hub.gpsAltitude_bp
|
||||
#define TELEMETRY_GPS_SPEED_BP frskyData.hub.gpsSpeed_bp
|
||||
#define TELEMETRY_GPS_SPEED_AP frskyData.hub.gpsSpeed_ap
|
||||
#define TELEMETRY_RELATIVE_BARO_ALT_BP telemetryData.hub.baroAltitude_bp
|
||||
#define TELEMETRY_RELATIVE_BARO_ALT_AP telemetryData.hub.baroAltitude_ap
|
||||
#define TELEMETRY_RELATIVE_GPS_ALT_BP telemetryData.hub.gpsAltitude_bp
|
||||
#define TELEMETRY_GPS_SPEED_BP telemetryData.hub.gpsSpeed_bp
|
||||
#define TELEMETRY_GPS_SPEED_AP telemetryData.hub.gpsSpeed_ap
|
||||
|
||||
#define TELEMETRY_BARO_ALT_PREPARE()
|
||||
#define TELEMETRY_BARO_ALT_FORMAT "%d,"
|
||||
#define TELEMETRY_BARO_ALT_ARGS frskyData.hub.baroAltitude_bp,
|
||||
#define TELEMETRY_BARO_ALT_ARGS telemetryData.hub.baroAltitude_bp,
|
||||
#define TELEMETRY_GPS_ALT_FORMAT "%d,"
|
||||
#define TELEMETRY_GPS_ALT_ARGS frskyData.hub.gpsAltitude_bp,
|
||||
#define TELEMETRY_GPS_ALT_ARGS telemetryData.hub.gpsAltitude_bp,
|
||||
#define TELEMETRY_SPEED_UNIT (IS_IMPERIAL_ENABLE() ? SPEED_UNIT_IMP : SPEED_UNIT_METR)
|
||||
#define TELEMETRY_GPS_SPEED_FORMAT "%d,"
|
||||
#define TELEMETRY_GPS_SPEED_ARGS frskyData.hub.gpsSpeed_bp,
|
||||
#define TELEMETRY_GPS_SPEED_ARGS telemetryData.hub.gpsSpeed_bp,
|
||||
#if defined(CPUARM)
|
||||
#define TELEMETRY_CELLS_ARGS frskyData.hub.cellsSum / 10, frskyData.hub.cellsSum % 10, frskyData.hub.cellVolts[0]*2/100, frskyData.hub.cellVolts[0]*2%100, frskyData.hub.cellVolts[1]*2/100, frskyData.hub.cellVolts[1]*2%100, frskyData.hub.cellVolts[2]*2/100, frskyData.hub.cellVolts[2]*2%100, frskyData.hub.cellVolts[3]*2/100, frskyData.hub.cellVolts[3]*2%100, frskyData.hub.cellVolts[4]*2/100, frskyData.hub.cellVolts[4]*2%100, frskyData.hub.cellVolts[5]*2/100, frskyData.hub.cellVolts[5]*2%100, frskyData.hub.cellVolts[6]*2/100, frskyData.hub.cellVolts[6]*2%100, frskyData.hub.cellVolts[7]*2/100, frskyData.hub.cellVolts[7]*2%100, frskyData.hub.cellVolts[8]*2/100, frskyData.hub.cellVolts[8]*2%100, frskyData.hub.cellVolts[9]*2/100, frskyData.hub.cellVolts[9]*2%100, frskyData.hub.cellVolts[10]*2/100, frskyData.hub.cellVolts[10]*2%100, frskyData.hub.cellVolts[11]*2/100, frskyData.hub.cellVolts[11]*2%100,
|
||||
#define TELEMETRY_CELLS_ARGS telemetryData.hub.cellsSum / 10, telemetryData.hub.cellsSum % 10, telemetryData.hub.cellVolts[0]*2/100, telemetryData.hub.cellVolts[0]*2%100, telemetryData.hub.cellVolts[1]*2/100, telemetryData.hub.cellVolts[1]*2%100, telemetryData.hub.cellVolts[2]*2/100, telemetryData.hub.cellVolts[2]*2%100, telemetryData.hub.cellVolts[3]*2/100, telemetryData.hub.cellVolts[3]*2%100, telemetryData.hub.cellVolts[4]*2/100, telemetryData.hub.cellVolts[4]*2%100, telemetryData.hub.cellVolts[5]*2/100, telemetryData.hub.cellVolts[5]*2%100, telemetryData.hub.cellVolts[6]*2/100, telemetryData.hub.cellVolts[6]*2%100, telemetryData.hub.cellVolts[7]*2/100, telemetryData.hub.cellVolts[7]*2%100, telemetryData.hub.cellVolts[8]*2/100, telemetryData.hub.cellVolts[8]*2%100, telemetryData.hub.cellVolts[9]*2/100, telemetryData.hub.cellVolts[9]*2%100, telemetryData.hub.cellVolts[10]*2/100, telemetryData.hub.cellVolts[10]*2%100, telemetryData.hub.cellVolts[11]*2/100, telemetryData.hub.cellVolts[11]*2%100,
|
||||
#define TELEMETRY_CELLS_FORMAT "%d.%d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,"
|
||||
#define TELEMETRY_CELLS_LABEL "Cell volts,Cell 1,Cell 2,Cell 3,Cell 4,Cell 5,Cell 6,Cell 7,Cell 8,Cell 9,Cell 10,Cell 11,Cell 12,"
|
||||
#else
|
||||
#define TELEMETRY_CELLS_ARGS frskyData.hub.cellsSum / 10, frskyData.hub.cellsSum % 10, frskyData.hub.cellVolts[0]*2/100, frskyData.hub.cellVolts[0]*2%100, frskyData.hub.cellVolts[1]*2/100, frskyData.hub.cellVolts[1]*2%100, frskyData.hub.cellVolts[2]*2/100, frskyData.hub.cellVolts[2]*2%100, frskyData.hub.cellVolts[3]*2/100, frskyData.hub.cellVolts[3]*2%100, frskyData.hub.cellVolts[4]*2/100, frskyData.hub.cellVolts[4]*2%100, frskyData.hub.cellVolts[5]*2/100, frskyData.hub.cellVolts[5]*2%100,
|
||||
#define TELEMETRY_CELLS_ARGS telemetryData.hub.cellsSum / 10, telemetryData.hub.cellsSum % 10, telemetryData.hub.cellVolts[0]*2/100, telemetryData.hub.cellVolts[0]*2%100, telemetryData.hub.cellVolts[1]*2/100, telemetryData.hub.cellVolts[1]*2%100, telemetryData.hub.cellVolts[2]*2/100, telemetryData.hub.cellVolts[2]*2%100, telemetryData.hub.cellVolts[3]*2/100, telemetryData.hub.cellVolts[3]*2%100, telemetryData.hub.cellVolts[4]*2/100, telemetryData.hub.cellVolts[4]*2%100, telemetryData.hub.cellVolts[5]*2/100, telemetryData.hub.cellVolts[5]*2%100,
|
||||
#define TELEMETRY_CELLS_FORMAT "%d.%d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,%d.%02d,"
|
||||
#define TELEMETRY_CELLS_LABEL "Cell volts,Cell 1,Cell 2,Cell 3,Cell 4,Cell 5,Cell 6,"
|
||||
#endif
|
||||
#define TELEMETRY_CURRENT_FORMAT "%d.%02d,"
|
||||
#define TELEMETRY_CURRENT_ARGS frskyData.hub.current / 100, frskyData.hub.current % 100,
|
||||
#define TELEMETRY_CURRENT_ARGS telemetryData.hub.current / 100, telemetryData.hub.current % 100,
|
||||
#define TELEMETRY_VFAS_FORMAT "%d.%d,"
|
||||
#define TELEMETRY_VFAS_ARGS frskyData.hub.vfas / 10, frskyData.hub.vfas % 10,
|
||||
#define TELEMETRY_VFAS_ARGS telemetryData.hub.vfas / 10, telemetryData.hub.vfas % 10,
|
||||
#define TELEMETRY_VSPEED_FORMAT "%c%d.%02d,"
|
||||
#define TELEMETRY_VSPEED_ARGS frskyData.hub.varioSpeed < 0 ? '-' : ' ', frskyData.hub.varioSpeed / 100, frskyData.hub.varioSpeed % 100,
|
||||
#define TELEMETRY_VSPEED_ARGS telemetryData.hub.varioSpeed < 0 ? '-' : ' ', telemetryData.hub.varioSpeed / 100, telemetryData.hub.varioSpeed % 100,
|
||||
#define TELEMETRY_ASPEED_FORMAT "%d.%d,"
|
||||
#define TELEMETRY_ASPEED_ARGS frskyData.hub.airSpeed / 10, frskyData.hub.airSpeed % 10,
|
||||
#define TELEMETRY_ASPEED_ARGS telemetryData.hub.airSpeed / 10, telemetryData.hub.airSpeed % 10,
|
||||
|
||||
#if defined(FRSKY_HUB)
|
||||
#define TELEMETRY_OPENXSENSOR() (frskyData.hub.openXsensor)
|
||||
#define TELEMETRY_OPENXSENSOR() (telemetryData.hub.openXsensor)
|
||||
#else
|
||||
#define TELEMETRY_OPENXSENSOR() (0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define TELEMETRY_CELL_VOLTAGE(k) (frskyData.hub.cellVolts[k] * TELEMETRY_CELL_VOLTAGE_MUTLIPLIER)
|
||||
#define TELEMETRY_MIN_CELL_VOLTAGE (frskyData.hub.minCellVolts * TELEMETRY_CELL_VOLTAGE_MUTLIPLIER)
|
||||
|
||||
extern FrskyData frskyData;
|
||||
#define TELEMETRY_CELL_VOLTAGE(k) (telemetryData.hub.cellVolts[k] * TELEMETRY_CELL_VOLTAGE_MUTLIPLIER)
|
||||
#define TELEMETRY_MIN_CELL_VOLTAGE (telemetryData.hub.minCellVolts * TELEMETRY_CELL_VOLTAGE_MUTLIPLIER)
|
||||
|
||||
#define START_STOP 0x7e
|
||||
#define BYTESTUFF 0x7d
|
||||
#define STUFF_MASK 0x20
|
||||
|
||||
// Receive buffer state machine state enum
|
||||
enum FrSkyDataState {
|
||||
STATE_DATA_IDLE,
|
||||
STATE_DATA_START,
|
||||
STATE_DATA_IN_FRAME,
|
||||
STATE_DATA_XOR,
|
||||
#if defined(TELEMETREZ)
|
||||
STATE_DATA_PRIVATE_LEN,
|
||||
STATE_DATA_PRIVATE_VALUE
|
||||
#endif
|
||||
};
|
||||
|
||||
#if defined(CPUARM)
|
||||
#define frskySendAlarms()
|
||||
#else
|
||||
@@ -523,6 +435,40 @@ void telemetryInit(void);
|
||||
|
||||
void telemetryInterrupt10ms();
|
||||
|
||||
enum TelemetryProtocol
|
||||
{
|
||||
TELEM_PROTO_FRSKY_D,
|
||||
TELEM_PROTO_FRSKY_SPORT,
|
||||
TELEM_PROTO_CROSSFIRE,
|
||||
};
|
||||
|
||||
enum TelemAnas {
|
||||
TELEM_ANA_A1,
|
||||
TELEM_ANA_A2,
|
||||
#if defined(CPUARM)
|
||||
TELEM_ANA_A3,
|
||||
TELEM_ANA_A4,
|
||||
#endif
|
||||
TELEM_ANA_COUNT
|
||||
};
|
||||
|
||||
#if defined(CPUARM)
|
||||
struct TelemetryData {
|
||||
TelemetryValueWithMin swr; // TODO Min not needed
|
||||
TelemetryValueWithMin rssi; // TODO Min not needed
|
||||
uint16_t xjtVersion;
|
||||
bool varioHighPrecision;
|
||||
};
|
||||
#else
|
||||
struct TelemetryData {
|
||||
TelemetryValueWithMinMax analog[TELEM_ANA_COUNT];
|
||||
TelemetryValueWithMin rssi[2];
|
||||
FrskyTelemetryData hub;
|
||||
};
|
||||
#endif
|
||||
|
||||
extern TelemetryData telemetryData;
|
||||
|
||||
#if defined(CPUARM)
|
||||
typedef uint16_t frskyCellVoltage_t;
|
||||
#elif defined(FRSKY_HUB)
|
||||
@@ -535,24 +481,7 @@ void frskySetCellVoltage(uint8_t battnumber, frskyCellVoltage_t cellVolts);
|
||||
void frskyUpdateCells();
|
||||
#endif
|
||||
|
||||
void processSerialData(uint8_t data);
|
||||
|
||||
#if defined(PCBTARANIS)
|
||||
inline uint8_t modelTelemetryProtocol()
|
||||
{
|
||||
#if defined(CROSSFIRE)
|
||||
if (g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_CROSSFIRE)
|
||||
return PROTOCOL_PULSES_CROSSFIRE;
|
||||
#endif
|
||||
if (g_model.moduleData[INTERNAL_MODULE].rfProtocol == RF_PROTO_OFF && g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_PPM)
|
||||
return g_model.telemetryProtocol;
|
||||
else
|
||||
return PROTOCOL_FRSKY_SPORT;
|
||||
}
|
||||
#define MODEL_TELEMETRY_PROTOCOL() modelTelemetryProtocol()
|
||||
#elif defined(CPUARM)
|
||||
#define MODEL_TELEMETRY_PROTOCOL() g_model.telemetryProtocol
|
||||
#endif
|
||||
void processFrskyTelemetryData(uint8_t data);
|
||||
|
||||
#if defined(LUA)
|
||||
struct LuaTelemetryValue
|
||||
|
||||
@@ -23,10 +23,10 @@
|
||||
#if (defined(FRSKY_HUB) || defined(WS_HOW_HIGH))
|
||||
void checkMinMaxAltitude()
|
||||
{
|
||||
if (TELEMETRY_RELATIVE_BARO_ALT_BP > frskyData.hub.maxAltitude)
|
||||
frskyData.hub.maxAltitude = TELEMETRY_RELATIVE_BARO_ALT_BP;
|
||||
if (TELEMETRY_RELATIVE_BARO_ALT_BP < frskyData.hub.minAltitude)
|
||||
frskyData.hub.minAltitude = TELEMETRY_RELATIVE_BARO_ALT_BP;
|
||||
if (TELEMETRY_RELATIVE_BARO_ALT_BP > telemetryData.hub.maxAltitude)
|
||||
telemetryData.hub.maxAltitude = TELEMETRY_RELATIVE_BARO_ALT_BP;
|
||||
if (TELEMETRY_RELATIVE_BARO_ALT_BP < telemetryData.hub.minAltitude)
|
||||
telemetryData.hub.minAltitude = TELEMETRY_RELATIVE_BARO_ALT_BP;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -71,148 +71,148 @@ void parseTelemHubByte(uint8_t byte)
|
||||
state = TS_IDLE;
|
||||
|
||||
#if defined(GPS)
|
||||
if ((uint8_t)structPos == offsetof(FrskySerialData, gpsLatitude_bp)) {
|
||||
if ((uint8_t)structPos == offsetof(FrskyTelemetryData, gpsLatitude_bp)) {
|
||||
if (lowByte || byte)
|
||||
frskyData.hub.gpsFix = 1;
|
||||
else if (frskyData.hub.gpsFix > 0 && frskyData.hub.gpsLatitude_bp > 1)
|
||||
frskyData.hub.gpsFix = 0;
|
||||
telemetryData.hub.gpsFix = 1;
|
||||
else if (telemetryData.hub.gpsFix > 0 && telemetryData.hub.gpsLatitude_bp > 1)
|
||||
telemetryData.hub.gpsFix = 0;
|
||||
}
|
||||
else if ((uint8_t)structPos == offsetof(FrskySerialData, gpsLongitude_bp)) {
|
||||
else if ((uint8_t)structPos == offsetof(FrskyTelemetryData, gpsLongitude_bp)) {
|
||||
if (lowByte || byte)
|
||||
frskyData.hub.gpsFix = 1;
|
||||
else if (frskyData.hub.gpsFix > 0 && frskyData.hub.gpsLongitude_bp > 1)
|
||||
frskyData.hub.gpsFix = 0;
|
||||
telemetryData.hub.gpsFix = 1;
|
||||
else if (telemetryData.hub.gpsFix > 0 && telemetryData.hub.gpsLongitude_bp > 1)
|
||||
telemetryData.hub.gpsFix = 0;
|
||||
}
|
||||
|
||||
if ((uint8_t)structPos == offsetof(FrskySerialData, gpsAltitude_bp) ||
|
||||
((uint8_t)structPos >= offsetof(FrskySerialData, gpsAltitude_ap) && (uint8_t)structPos <= offsetof(FrskySerialData, gpsLatitudeNS) && (uint8_t)structPos != offsetof(FrskySerialData, baroAltitude_bp) && (uint8_t)structPos != offsetof(FrskySerialData, baroAltitude_ap))) {
|
||||
if ((uint8_t)structPos == offsetof(FrskyTelemetryData, gpsAltitude_bp) ||
|
||||
((uint8_t)structPos >= offsetof(FrskyTelemetryData, gpsAltitude_ap) && (uint8_t)structPos <= offsetof(FrskyTelemetryData, gpsLatitudeNS) && (uint8_t)structPos != offsetof(FrskyTelemetryData, baroAltitude_bp) && (uint8_t)structPos != offsetof(FrskyTelemetryData, baroAltitude_ap))) {
|
||||
// If we don't have a fix, we may discard the value
|
||||
if (frskyData.hub.gpsFix <= 0)
|
||||
if (telemetryData.hub.gpsFix <= 0)
|
||||
return;
|
||||
}
|
||||
#endif // #if defined(GPS)
|
||||
|
||||
((uint8_t*)&frskyData.hub)[structPos] = lowByte;
|
||||
((uint8_t*)&frskyData.hub)[structPos+1] = byte;
|
||||
((uint8_t*)&telemetryData.hub)[structPos] = lowByte;
|
||||
((uint8_t*)&telemetryData.hub)[structPos+1] = byte;
|
||||
|
||||
switch ((uint8_t)structPos) {
|
||||
|
||||
case offsetof(FrskySerialData, rpm):
|
||||
frskyData.hub.rpm *= (uint8_t)60/(g_model.frsky.blades+2);
|
||||
if (frskyData.hub.rpm > frskyData.hub.maxRpm)
|
||||
frskyData.hub.maxRpm = frskyData.hub.rpm;
|
||||
case offsetof(FrskyTelemetryData, rpm):
|
||||
telemetryData.hub.rpm *= (uint8_t)60/(g_model.frsky.blades+2);
|
||||
if (telemetryData.hub.rpm > telemetryData.hub.maxRpm)
|
||||
telemetryData.hub.maxRpm = telemetryData.hub.rpm;
|
||||
break;
|
||||
|
||||
case offsetof(FrskySerialData, temperature1):
|
||||
if (frskyData.hub.temperature1 > frskyData.hub.maxTemperature1)
|
||||
frskyData.hub.maxTemperature1 = frskyData.hub.temperature1;
|
||||
case offsetof(FrskyTelemetryData, temperature1):
|
||||
if (telemetryData.hub.temperature1 > telemetryData.hub.maxTemperature1)
|
||||
telemetryData.hub.maxTemperature1 = telemetryData.hub.temperature1;
|
||||
break;
|
||||
|
||||
case offsetof(FrskySerialData, temperature2):
|
||||
if (frskyData.hub.temperature2 > frskyData.hub.maxTemperature2)
|
||||
frskyData.hub.maxTemperature2 = frskyData.hub.temperature2;
|
||||
case offsetof(FrskyTelemetryData, temperature2):
|
||||
if (telemetryData.hub.temperature2 > telemetryData.hub.maxTemperature2)
|
||||
telemetryData.hub.maxTemperature2 = telemetryData.hub.temperature2;
|
||||
break;
|
||||
|
||||
case offsetof(FrskySerialData, current):
|
||||
case offsetof(FrskyTelemetryData, current):
|
||||
#if defined(FAS_OFFSET) || !defined(CPUM64)
|
||||
if ((int16_t)frskyData.hub.current > 0 && ((int16_t)frskyData.hub.current + g_model.frsky.fasOffset) > 0)
|
||||
frskyData.hub.current += g_model.frsky.fasOffset;
|
||||
if ((int16_t)telemetryData.hub.current > 0 && ((int16_t)telemetryData.hub.current + g_model.frsky.fasOffset) > 0)
|
||||
telemetryData.hub.current += g_model.frsky.fasOffset;
|
||||
else
|
||||
frskyData.hub.current = 0;
|
||||
telemetryData.hub.current = 0;
|
||||
#endif
|
||||
if (frskyData.hub.current > frskyData.hub.maxCurrent)
|
||||
frskyData.hub.maxCurrent = frskyData.hub.current;
|
||||
if (telemetryData.hub.current > telemetryData.hub.maxCurrent)
|
||||
telemetryData.hub.maxCurrent = telemetryData.hub.current;
|
||||
break;
|
||||
|
||||
case offsetof(FrskySerialData, currentConsumption):
|
||||
case offsetof(FrskyTelemetryData, currentConsumption):
|
||||
// we receive data from openXsensor. stops the calculation of consumption and power
|
||||
frskyData.hub.openXsensor = 1;
|
||||
telemetryData.hub.openXsensor = 1;
|
||||
break;
|
||||
|
||||
case offsetof(FrskySerialData, volts_ap):
|
||||
case offsetof(FrskyTelemetryData, volts_ap):
|
||||
#if defined(FAS_BSS)
|
||||
frskyData.hub.vfas = (frskyData.hub.volts_bp * 10 + frskyData.hub.volts_ap);
|
||||
telemetryData.hub.vfas = (telemetryData.hub.volts_bp * 10 + telemetryData.hub.volts_ap);
|
||||
#else
|
||||
frskyData.hub.vfas = ((frskyData.hub.volts_bp * 100 + frskyData.hub.volts_ap * 10) * 21) / 110;
|
||||
telemetryData.hub.vfas = ((telemetryData.hub.volts_bp * 100 + telemetryData.hub.volts_ap * 10) * 21) / 110;
|
||||
#endif
|
||||
/* TODO later if (!frskyData.hub.minVfas || frskyData.hub.minVfas > frskyData.hub.vfas)
|
||||
frskyData.hub.minVfas = frskyData.hub.vfas; */
|
||||
/* TODO later if (!telemetryData.hub.minVfas || telemetryData.hub.minVfas > telemetryData.hub.vfas)
|
||||
telemetryData.hub.minVfas = telemetryData.hub.vfas; */
|
||||
break;
|
||||
|
||||
case offsetof(FrskySerialData, baroAltitude_bp):
|
||||
case offsetof(FrskyTelemetryData, baroAltitude_bp):
|
||||
// First received barometer altitude => Altitude offset
|
||||
if (!frskyData.hub.baroAltitudeOffset)
|
||||
frskyData.hub.baroAltitudeOffset = -frskyData.hub.baroAltitude_bp;
|
||||
frskyData.hub.baroAltitude_bp += frskyData.hub.baroAltitudeOffset;
|
||||
if (!telemetryData.hub.baroAltitudeOffset)
|
||||
telemetryData.hub.baroAltitudeOffset = -telemetryData.hub.baroAltitude_bp;
|
||||
telemetryData.hub.baroAltitude_bp += telemetryData.hub.baroAltitudeOffset;
|
||||
checkMinMaxAltitude();
|
||||
break;
|
||||
|
||||
#if defined(GPS)
|
||||
case offsetof(FrskySerialData, gpsAltitude_ap):
|
||||
if (!frskyData.hub.gpsAltitudeOffset)
|
||||
frskyData.hub.gpsAltitudeOffset = -frskyData.hub.gpsAltitude_bp;
|
||||
frskyData.hub.gpsAltitude_bp += frskyData.hub.gpsAltitudeOffset;
|
||||
if (!frskyData.hub.baroAltitudeOffset) {
|
||||
if (frskyData.hub.gpsAltitude_bp > frskyData.hub.maxAltitude)
|
||||
frskyData.hub.maxAltitude = frskyData.hub.gpsAltitude_bp;
|
||||
if (frskyData.hub.gpsAltitude_bp < frskyData.hub.minAltitude)
|
||||
frskyData.hub.minAltitude = frskyData.hub.gpsAltitude_bp;
|
||||
case offsetof(FrskyTelemetryData, gpsAltitude_ap):
|
||||
if (!telemetryData.hub.gpsAltitudeOffset)
|
||||
telemetryData.hub.gpsAltitudeOffset = -telemetryData.hub.gpsAltitude_bp;
|
||||
telemetryData.hub.gpsAltitude_bp += telemetryData.hub.gpsAltitudeOffset;
|
||||
if (!telemetryData.hub.baroAltitudeOffset) {
|
||||
if (telemetryData.hub.gpsAltitude_bp > telemetryData.hub.maxAltitude)
|
||||
telemetryData.hub.maxAltitude = telemetryData.hub.gpsAltitude_bp;
|
||||
if (telemetryData.hub.gpsAltitude_bp < telemetryData.hub.minAltitude)
|
||||
telemetryData.hub.minAltitude = telemetryData.hub.gpsAltitude_bp;
|
||||
}
|
||||
if (!frskyData.hub.pilotLatitude && !frskyData.hub.pilotLongitude) {
|
||||
if (!telemetryData.hub.pilotLatitude && !telemetryData.hub.pilotLongitude) {
|
||||
// First received GPS position => Pilot GPS position
|
||||
getGpsPilotPosition();
|
||||
}
|
||||
else if (frskyData.hub.gpsDistNeeded || menuHandlers[menuLevel] == menuTelemetryFrsky) {
|
||||
else if (telemetryData.hub.gpsDistNeeded || menuHandlers[menuLevel] == menuTelemetryFrsky) {
|
||||
getGpsDistance();
|
||||
}
|
||||
break;
|
||||
|
||||
case offsetof(FrskySerialData, gpsSpeed_bp):
|
||||
case offsetof(FrskyTelemetryData, gpsSpeed_bp):
|
||||
// Speed => Max speed
|
||||
if (frskyData.hub.gpsSpeed_bp > frskyData.hub.maxGpsSpeed)
|
||||
frskyData.hub.maxGpsSpeed = frskyData.hub.gpsSpeed_bp;
|
||||
if (telemetryData.hub.gpsSpeed_bp > telemetryData.hub.maxGpsSpeed)
|
||||
telemetryData.hub.maxGpsSpeed = telemetryData.hub.gpsSpeed_bp;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case offsetof(FrskySerialData, volts):
|
||||
case offsetof(FrskyTelemetryData, volts):
|
||||
frskyUpdateCells();
|
||||
break;
|
||||
|
||||
#if defined(GPS)
|
||||
case offsetof(FrskySerialData, hour):
|
||||
frskyData.hub.hour = ((uint8_t)(frskyData.hub.hour + g_eeGeneral.timezone + 24)) % 24;
|
||||
case offsetof(FrskyTelemetryData, hour):
|
||||
telemetryData.hub.hour = ((uint8_t)(telemetryData.hub.hour + g_eeGeneral.timezone + 24)) % 24;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case offsetof(FrskySerialData, accelX):
|
||||
case offsetof(FrskySerialData, accelY):
|
||||
case offsetof(FrskySerialData, accelZ):
|
||||
*(int16_t*)(&((uint8_t*)&frskyData.hub)[structPos]) /= 10;
|
||||
case offsetof(FrskyTelemetryData, accelX):
|
||||
case offsetof(FrskyTelemetryData, accelY):
|
||||
case offsetof(FrskyTelemetryData, accelZ):
|
||||
*(int16_t*)(&((uint8_t*)&telemetryData.hub)[structPos]) /= 10;
|
||||
break;
|
||||
|
||||
#if 0
|
||||
case offsetof(FrskySerialData, gpsAltitude_bp):
|
||||
case offsetof(FrskySerialData, fuelLevel):
|
||||
case offsetof(FrskySerialData, gpsLongitude_bp):
|
||||
case offsetof(FrskySerialData, gpsLatitude_bp):
|
||||
case offsetof(FrskySerialData, gpsCourse_bp):
|
||||
case offsetof(FrskySerialData, day):
|
||||
case offsetof(FrskySerialData, year):
|
||||
case offsetof(FrskySerialData, sec):
|
||||
case offsetof(FrskySerialData, gpsSpeed_ap):
|
||||
case offsetof(FrskySerialData, gpsLongitude_ap):
|
||||
case offsetof(FrskySerialData, gpsLatitude_ap):
|
||||
case offsetof(FrskySerialData, gpsCourse_ap):
|
||||
case offsetof(FrskySerialData, gpsLongitudeEW):
|
||||
case offsetof(FrskySerialData, gpsLatitudeNS):
|
||||
case offsetof(FrskySerialData, varioSpeed):
|
||||
case offsetof(FrskySerialData, power): /* because sent by openXsensor */
|
||||
case offsetof(FrskySerialData, vfas):
|
||||
case offsetof(FrskySerialData, volts_bp):
|
||||
case offsetof(FrskyTelemetryData, gpsAltitude_bp):
|
||||
case offsetof(FrskyTelemetryData, fuelLevel):
|
||||
case offsetof(FrskyTelemetryData, gpsLongitude_bp):
|
||||
case offsetof(FrskyTelemetryData, gpsLatitude_bp):
|
||||
case offsetof(FrskyTelemetryData, gpsCourse_bp):
|
||||
case offsetof(FrskyTelemetryData, day):
|
||||
case offsetof(FrskyTelemetryData, year):
|
||||
case offsetof(FrskyTelemetryData, sec):
|
||||
case offsetof(FrskyTelemetryData, gpsSpeed_ap):
|
||||
case offsetof(FrskyTelemetryData, gpsLongitude_ap):
|
||||
case offsetof(FrskyTelemetryData, gpsLatitude_ap):
|
||||
case offsetof(FrskyTelemetryData, gpsCourse_ap):
|
||||
case offsetof(FrskyTelemetryData, gpsLongitudeEW):
|
||||
case offsetof(FrskyTelemetryData, gpsLatitudeNS):
|
||||
case offsetof(FrskyTelemetryData, varioSpeed):
|
||||
case offsetof(FrskyTelemetryData, power): /* because sent by openXsensor */
|
||||
case offsetof(FrskyTelemetryData, vfas):
|
||||
case offsetof(FrskyTelemetryData, volts_bp):
|
||||
break;
|
||||
|
||||
default:
|
||||
*((uint16_t *)(((uint8_t*)&frskyData.hub) + structPos)) = previousValue;
|
||||
*((uint16_t *)(((uint8_t*)&telemetryData.hub) + structPos)) = previousValue;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
@@ -222,16 +222,16 @@ void parseTelemHubByte(uint8_t byte)
|
||||
#if defined(WS_HOW_HIGH)
|
||||
void parseTelemWSHowHighByte(uint8_t byte)
|
||||
{
|
||||
if (frskyUsrStreaming < (WSHH_TIMEOUT10ms - 10)) {
|
||||
((uint8_t*)&frskyData.hub)[offsetof(FrskySerialData, baroAltitude_bp)] = byte;
|
||||
if (wshhStreaming < (WSHH_TIMEOUT10ms - 10)) {
|
||||
((uint8_t*)&telemetryData.hub)[offsetof(FrskyTelemetryData, baroAltitude_bp)] = byte;
|
||||
checkMinMaxAltitude();
|
||||
}
|
||||
else {
|
||||
// At least 100mS passed since last data received
|
||||
((uint8_t*)&frskyData.hub)[offsetof(FrskySerialData, baroAltitude_bp)+1] = byte;
|
||||
((uint8_t*)&telemetryData.hub)[offsetof(FrskyTelemetryData, baroAltitude_bp)+1] = byte;
|
||||
}
|
||||
// baroAltitude_bp unit here is feet!
|
||||
frskyUsrStreaming = WSHH_TIMEOUT10ms; // reset counter
|
||||
wshhStreaming = WSHH_TIMEOUT10ms; // reset counter
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -242,16 +242,16 @@ void frskyDProcessPacket(uint8_t *packet)
|
||||
{
|
||||
case LINKPKT: // A1/A2/RSSI values
|
||||
{
|
||||
frskyData.analog[TELEM_ANA_A1].set(packet[1], g_model.frsky.channels[TELEM_ANA_A1].type);
|
||||
frskyData.analog[TELEM_ANA_A2].set(packet[2], g_model.frsky.channels[TELEM_ANA_A2].type);
|
||||
frskyData.rssi[0].set(packet[3]);
|
||||
frskyData.rssi[1].set(packet[4] / 2);
|
||||
frskyStreaming = FRSKY_TIMEOUT10ms; // reset counter only if valid frsky packets are being detected
|
||||
telemetryData.analog[TELEM_ANA_A1].set(packet[1], g_model.frsky.channels[TELEM_ANA_A1].type);
|
||||
telemetryData.analog[TELEM_ANA_A2].set(packet[2], g_model.frsky.channels[TELEM_ANA_A2].type);
|
||||
telemetryData.rssi[0].set(packet[3]);
|
||||
telemetryData.rssi[1].set(packet[4] / 2);
|
||||
telemetryStreaming = FRSKY_TIMEOUT10ms; // reset counter only if valid frsky packets are being detected
|
||||
link_counter += 256 / FRSKY_D_AVERAGING;
|
||||
#if defined(VARIO)
|
||||
uint8_t varioSource = g_model.frsky.varioSource - VARIO_SOURCE_A1;
|
||||
if (varioSource < 2) {
|
||||
frskyData.hub.varioSpeed = applyChannelRatio(varioSource, frskyData.analog[varioSource].value);
|
||||
telemetryData.hub.varioSpeed = applyChannelRatio(varioSource, telemetryData.analog[varioSource].value);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
@@ -73,8 +73,8 @@ void frskyDProcessPacket(uint8_t *packet)
|
||||
setTelemetryValue(TELEM_PROTO_FRSKY_D, D_A1_ID, 0, 0, packet[1], UNIT_VOLTS, 0);
|
||||
setTelemetryValue(TELEM_PROTO_FRSKY_D, D_A2_ID, 0, 0, packet[2], UNIT_VOLTS, 0);
|
||||
setTelemetryValue(TELEM_PROTO_FRSKY_D, D_RSSI_ID, 0, 0, packet[3], UNIT_RAW, 0);
|
||||
frskyData.rssi.set(packet[3]);
|
||||
frskyStreaming = FRSKY_TIMEOUT10ms; // reset counter only if valid frsky packets are being detected
|
||||
telemetryData.rssi.set(packet[3]);
|
||||
telemetryStreaming = FRSKY_TIMEOUT10ms; // reset counter only if valid frsky packets are being detected
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -178,8 +178,8 @@ void processHubPacket(uint8_t id, int16_t value)
|
||||
}
|
||||
else if (id == BARO_ALT_AP_ID) {
|
||||
if (lastId == BARO_ALT_BP_ID) {
|
||||
if (data > 9 || frskyData.varioHighPrecision) {
|
||||
frskyData.varioHighPrecision = true;
|
||||
if (data > 9 || telemetryData.varioHighPrecision) {
|
||||
telemetryData.varioHighPrecision = true;
|
||||
data /= 10; // map hi precision vario into low precision. Altitude is stored in 0.1m anyways
|
||||
}
|
||||
data = (int16_t)lastValue * 10 + (((int16_t)lastValue < 0) ? -data : data);
|
||||
|
||||
@@ -212,32 +212,32 @@ void processSportPacket(uint8_t * packet)
|
||||
uint32_t data = SPORT_DATA_S32(packet);
|
||||
|
||||
if (id == RSSI_ID) {
|
||||
frskyStreaming = FRSKY_TIMEOUT10ms; // reset counter only if valid frsky packets are being detected
|
||||
telemetryStreaming = FRSKY_TIMEOUT10ms; // reset counter only if valid frsky packets are being detected
|
||||
data = SPORT_DATA_U8(packet);
|
||||
if (data == 0)
|
||||
frskyData.rssi.reset();
|
||||
telemetryData.rssi.reset();
|
||||
else
|
||||
frskyData.rssi.set(data);
|
||||
telemetryData.rssi.set(data);
|
||||
}
|
||||
#if defined(PCBTARANIS) && defined(REVPLUS)
|
||||
else if (id == XJT_VERSION_ID) {
|
||||
frskyData.xjtVersion = HUB_DATA_U16(packet);
|
||||
telemetryData.xjtVersion = HUB_DATA_U16(packet);
|
||||
if (!IS_VALID_XJT_VERSION()) {
|
||||
frskyData.swr.set(0x00);
|
||||
telemetryData.swr.set(0x00);
|
||||
}
|
||||
}
|
||||
else if (id == SWR_ID) {
|
||||
if (IS_VALID_XJT_VERSION())
|
||||
frskyData.swr.set(SPORT_DATA_U8(packet));
|
||||
telemetryData.swr.set(SPORT_DATA_U8(packet));
|
||||
else
|
||||
frskyData.swr.set(0x00);
|
||||
telemetryData.swr.set(0x00);
|
||||
}
|
||||
#else
|
||||
else if (id == XJT_VERSION_ID) {
|
||||
frskyData.xjtVersion = HUB_DATA_U16(packet);
|
||||
telemetryData.xjtVersion = HUB_DATA_U16(packet);
|
||||
}
|
||||
else if (id == SWR_ID) {
|
||||
frskyData.swr.set(SPORT_DATA_U8(packet));
|
||||
telemetryData.swr.set(SPORT_DATA_U8(packet));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -339,7 +339,7 @@ bool sportWaitState(SportUpdateState state, int timeout)
|
||||
for (int i=timeout/2; i>=0; i--) {
|
||||
uint8_t byte ;
|
||||
while (telemetryGetByte(&byte)) {
|
||||
processSerialData(byte);
|
||||
processFrskyTelemetryData(byte);
|
||||
}
|
||||
if (sportUpdateState == state) {
|
||||
return true;
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
/*! \file mavlink.h
|
||||
* Mavlink include file
|
||||
*/
|
||||
|
||||
#ifndef _MAVLINK_H_
|
||||
#define _MAVLINK_H_
|
||||
#ifndef _MAVLINK_H_
|
||||
#define _MAVLINK_H_
|
||||
|
||||
#define MAVLINK_USE_CONVENIENCE_FUNCTIONS
|
||||
#define MAVLINK_COMM_NUM_BUFFERS 1
|
||||
@@ -32,11 +32,11 @@
|
||||
#include "targets/common_avr/serial_driver.h"
|
||||
#include "opentx.h"
|
||||
|
||||
extern int8_t mav_heartbeat;
|
||||
extern int8_t mav_heartbeat;
|
||||
extern mavlink_system_t mavlink_system;
|
||||
#define LEN_STATUSTEXT 20
|
||||
extern char mav_statustext[LEN_STATUSTEXT];
|
||||
|
||||
#define LEN_STATUSTEXT 20
|
||||
extern char mav_statustext[LEN_STATUSTEXT];
|
||||
|
||||
extern void SERIAL_start_uart_send();
|
||||
extern void SERIAL_end_uart_send();
|
||||
extern void SERIAL_send_uart_bytes(const uint8_t * buf, uint16_t len);
|
||||
@@ -321,5 +321,5 @@ inline uint8_t getPrecisMavlinParamsValue(uint8_t idx) {
|
||||
void lcd_outdezFloat(uint8_t x, uint8_t y, float val, uint8_t precis, uint8_t mode);
|
||||
#endif
|
||||
|
||||
#endif // _MAVLINK_H_
|
||||
#endif // _MAVLINK_H_
|
||||
|
||||
|
||||
+380
-615
File diff suppressed because it is too large
Load Diff
@@ -21,12 +21,49 @@
|
||||
#ifndef _TELEMETRY_H_
|
||||
#define _TELEMETRY_H_
|
||||
|
||||
enum TelemetryProtocol
|
||||
{
|
||||
TELEM_PROTO_FRSKY_D,
|
||||
TELEM_PROTO_FRSKY_SPORT,
|
||||
};
|
||||
#if defined(FRSKY)
|
||||
// FrSky Telemetry
|
||||
#include "frsky.h"
|
||||
#elif defined(JETI)
|
||||
// Jeti-DUPLEX Telemetry
|
||||
#include "jeti.h"
|
||||
#elif defined(ARDUPILOT)
|
||||
// ArduPilot Telemetry
|
||||
#include "ardupilot.h"
|
||||
#elif defined(NMEA)
|
||||
// NMEA Telemetry
|
||||
#include "nmea.h"
|
||||
#elif defined(MAVLINK)
|
||||
// Mavlink Telemetry
|
||||
#include "mavlink.h"
|
||||
#endif
|
||||
|
||||
#if defined(CROSSFIRE)
|
||||
#include "crossfire.h"
|
||||
#endif
|
||||
|
||||
extern uint8_t telemetryStreaming; // >0 (true) == data is streaming in. 0 = no data detected for some time
|
||||
|
||||
#if defined(WS_HOW_HIGH)
|
||||
extern uint8_t wshhStreaming;
|
||||
#endif
|
||||
|
||||
extern uint8_t link_counter;
|
||||
|
||||
#if defined(CPUARM)
|
||||
enum TelemetryStates {
|
||||
TELEMETRY_INIT,
|
||||
TELEMETRY_OK,
|
||||
TELEMETRY_KO
|
||||
};
|
||||
extern uint8_t telemetryState;
|
||||
#endif
|
||||
|
||||
#define TELEMETRY_RX_PACKET_SIZE 19 // 9 bytes (full packet), worst case 18 bytes with byte-stuffing (+1)
|
||||
extern uint8_t telemetryRxBuffer[TELEMETRY_RX_PACKET_SIZE];
|
||||
extern uint8_t telemetryRxBufferCount;
|
||||
|
||||
#if defined(CPUARM)
|
||||
#define TELEMETRY_VALUE_TIMER_CYCLE 200 /*20 seconds*/
|
||||
#define TELEMETRY_VALUE_OLD_THRESHOLD 150 /*15 seconds*/
|
||||
#define TELEMETRY_VALUE_UNAVAILABLE 255
|
||||
@@ -60,108 +97,49 @@ PACK(struct CellValue
|
||||
}
|
||||
});
|
||||
|
||||
class TelemetryItem
|
||||
{
|
||||
public:
|
||||
union {
|
||||
int32_t value; // value, stored as uint32_t but interpreted accordingly to type
|
||||
uint32_t distFromEarthAxis;
|
||||
};
|
||||
|
||||
union {
|
||||
int32_t valueMin; // min store
|
||||
uint32_t pilotLongitude;
|
||||
};
|
||||
|
||||
union {
|
||||
int32_t valueMax; // max store
|
||||
uint32_t pilotLatitude;
|
||||
};
|
||||
|
||||
uint8_t lastReceived; // for detection of sensor loss
|
||||
|
||||
union {
|
||||
struct {
|
||||
int32_t offsetAuto;
|
||||
int32_t filterValues[TELEMETRY_AVERAGE_COUNT];
|
||||
} std;
|
||||
struct {
|
||||
uint16_t prescale;
|
||||
} consumption;
|
||||
struct {
|
||||
uint8_t count;
|
||||
CellValue values[6];
|
||||
} cells;
|
||||
struct {
|
||||
uint8_t datestate;
|
||||
uint16_t year;
|
||||
uint8_t month;
|
||||
uint8_t day;
|
||||
uint8_t timestate;
|
||||
uint8_t hour;
|
||||
uint8_t min;
|
||||
uint8_t sec;
|
||||
} datetime;
|
||||
struct {
|
||||
uint16_t longitude_bp;
|
||||
uint16_t longitude_ap;
|
||||
char longitudeEW;
|
||||
uint16_t latitude_bp;
|
||||
uint16_t latitude_ap;
|
||||
char latitudeNS;
|
||||
// pilot longitude is stored in min
|
||||
// pilot latitude is stored in max
|
||||
// distFromEarthAxis is stored in value
|
||||
void extractLatitudeLongitude(uint32_t * latitude, uint32_t * longitude)
|
||||
{
|
||||
div_t qr = div(latitude_bp, 100);
|
||||
*latitude = ((uint32_t)(qr.quot) * 1000000) + (((uint32_t)(qr.rem) * 10000 + latitude_ap) * 5) / 3;
|
||||
qr = div(longitude_bp, 100);
|
||||
*longitude = ((uint32_t)(qr.quot) * 1000000) + (((uint32_t)(qr.rem) * 10000 + longitude_ap) * 5) / 3;
|
||||
}
|
||||
} gps;
|
||||
};
|
||||
|
||||
static uint8_t now()
|
||||
{
|
||||
return (get_tmr10ms() / 10) % TELEMETRY_VALUE_TIMER_CYCLE;
|
||||
}
|
||||
|
||||
TelemetryItem()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
memset(this, 0, sizeof(*this));
|
||||
lastReceived = TELEMETRY_VALUE_UNAVAILABLE;
|
||||
}
|
||||
|
||||
void eval(const TelemetrySensor & sensor);
|
||||
void per10ms(const TelemetrySensor & sensor);
|
||||
|
||||
void setValue(const TelemetrySensor & sensor, int32_t newVal, uint32_t unit, uint32_t prec=0);
|
||||
bool isAvailable();
|
||||
bool isFresh();
|
||||
bool isOld();
|
||||
void gpsReceived();
|
||||
};
|
||||
|
||||
extern TelemetryItem telemetryItems[MAX_SENSORS];
|
||||
extern uint8_t allowNewSensors;
|
||||
|
||||
void setTelemetryValue(TelemetryProtocol protocol, uint16_t id, uint8_t subId, uint8_t instance, int32_t value, uint32_t unit, uint32_t prec);
|
||||
void delTelemetryIndex(uint8_t index);
|
||||
int availableTelemetryIndex();
|
||||
int lastUsedTelemetryIndex();
|
||||
|
||||
int32_t getTelemetryValue(uint8_t index, uint8_t & prec);
|
||||
int32_t convertTelemetryValue(int32_t value, uint8_t unit, uint8_t prec, uint8_t destUnit, uint8_t destPrec);
|
||||
|
||||
void frskySportSetDefault(int index, uint16_t id, uint8_t subId, uint8_t instance);
|
||||
void frskyDSetDefault(int index, uint16_t id);
|
||||
#endif
|
||||
|
||||
#define IS_DISTANCE_UNIT(unit) ((unit) == UNIT_METERS || (unit) == UNIT_FEET)
|
||||
#define IS_SPEED_UNIT(unit) ((unit) >= UNIT_KTS && (unit) <= UNIT_MPH)
|
||||
|
||||
#if defined(CPUARM)
|
||||
extern uint8_t telemetryProtocol;
|
||||
#define IS_FRSKY_D_PROTOCOL() (telemetryProtocol == PROTOCOL_FRSKY_D)
|
||||
#define IS_FRSKY_SPORT_PROTOCOL() (telemetryProtocol == PROTOCOL_FRSKY_SPORT)
|
||||
#else
|
||||
#define IS_FRSKY_D_PROTOCOL() (true)
|
||||
#define IS_FRSKY_SPORT_PROTOCOL() (false)
|
||||
#endif
|
||||
|
||||
#if defined(CPUSTM32)
|
||||
inline uint8_t modelTelemetryProtocol()
|
||||
{
|
||||
#if defined(CROSSFIRE)
|
||||
if (g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_CROSSFIRE)
|
||||
return PROTOCOL_PULSES_CROSSFIRE;
|
||||
#endif
|
||||
if (g_model.moduleData[INTERNAL_MODULE].rfProtocol == RF_PROTO_OFF && g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_PPM)
|
||||
return g_model.telemetryProtocol;
|
||||
else
|
||||
return PROTOCOL_FRSKY_SPORT;
|
||||
}
|
||||
#define MODEL_TELEMETRY_PROTOCOL() modelTelemetryProtocol()
|
||||
#elif defined(CPUARM)
|
||||
#define MODEL_TELEMETRY_PROTOCOL() g_model.telemetryProtocol
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM)
|
||||
#include "telemetry_sensors.h"
|
||||
#endif
|
||||
|
||||
#endif // _TELEMETRY_H_
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "opentx.h"
|
||||
|
||||
#if defined(CPUARM)
|
||||
void TelemetryValueWithMin::reset()
|
||||
{
|
||||
memclear(this, sizeof(*this));
|
||||
}
|
||||
#endif
|
||||
|
||||
void TelemetryValueWithMin::set(uint8_t value)
|
||||
{
|
||||
#if defined(CPUARM)
|
||||
if (this->value == 0) {
|
||||
memset(values, value, TELEMETRY_AVERAGE_COUNT);
|
||||
this->value = value;
|
||||
}
|
||||
else {
|
||||
//calculate the average from values[] and value
|
||||
//also shift readings in values [] array
|
||||
unsigned int sum = values[0];
|
||||
for (int i=0; i<TELEMETRY_AVERAGE_COUNT-1; i++) {
|
||||
uint8_t tmp = values[i+1];
|
||||
values[i] = tmp;
|
||||
sum += tmp;
|
||||
}
|
||||
values[TELEMETRY_AVERAGE_COUNT-1] = value;
|
||||
sum += value;
|
||||
this->value = sum/(TELEMETRY_AVERAGE_COUNT+1);
|
||||
}
|
||||
#else
|
||||
if (this->value == 0) {
|
||||
this->value = value;
|
||||
}
|
||||
else {
|
||||
sum += value;
|
||||
if (link_counter == 0) {
|
||||
this->value = sum / (IS_FRSKY_D_PROTOCOL() ? FRSKY_D_AVERAGING : FRSKY_SPORT_AVERAGING);
|
||||
sum = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!min || value < min) {
|
||||
min = value;
|
||||
}
|
||||
}
|
||||
|
||||
void TelemetryValueWithMinMax::set(uint8_t value, uint8_t unit)
|
||||
{
|
||||
TelemetryValueWithMin::set(value);
|
||||
if (unit != UNIT_VOLTS) {
|
||||
this->value = value;
|
||||
}
|
||||
if (!max || value > max) {
|
||||
max = value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef _TELEMETRY_HOLDERS_H_
|
||||
#define _TELEMETRY_HOLDERS_H_
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#if defined(CPUARM)
|
||||
#define TELEMETRY_AVERAGE_COUNT 3 // we actually average one more reading!
|
||||
#define RAW_FRSKY_MINMAX(v) v.values[TELEMETRY_AVERAGE_COUNT-1]
|
||||
class TelemetryValueWithMin {
|
||||
public:
|
||||
uint8_t value; // fitered value (average of last TELEMETRY_AVERAGE_COUNT+1 values)
|
||||
uint8_t min;
|
||||
uint8_t values[TELEMETRY_AVERAGE_COUNT];
|
||||
void set(uint8_t value);
|
||||
void reset();
|
||||
};
|
||||
#else
|
||||
#define RAW_FRSKY_MINMAX(v) v.value
|
||||
class TelemetryValueWithMin {
|
||||
public:
|
||||
uint8_t value;
|
||||
uint8_t min;
|
||||
uint16_t sum;
|
||||
void set(uint8_t value);
|
||||
};
|
||||
#endif
|
||||
|
||||
class TelemetryValueWithMinMax: public TelemetryValueWithMin {
|
||||
public:
|
||||
uint8_t max;
|
||||
void set(uint8_t value, uint8_t unit);
|
||||
};
|
||||
|
||||
#endif // _TELEMETRY_HOLDERS_H_
|
||||
@@ -0,0 +1,698 @@
|
||||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "opentx.h"
|
||||
|
||||
TelemetryItem telemetryItems[MAX_SENSORS];
|
||||
uint8_t allowNewSensors;
|
||||
|
||||
void TelemetryItem::gpsReceived()
|
||||
{
|
||||
if (!distFromEarthAxis) {
|
||||
gps.extractLatitudeLongitude(&pilotLatitude, &pilotLongitude);
|
||||
uint32_t lat = pilotLatitude / 10000;
|
||||
uint32_t angle2 = (lat*lat) / 10000;
|
||||
uint32_t angle4 = angle2 * angle2;
|
||||
distFromEarthAxis = 139*(((uint32_t)10000000-((angle2*(uint32_t)123370)/81)+(angle4/25))/12500);
|
||||
}
|
||||
lastReceived = now();
|
||||
}
|
||||
|
||||
void TelemetryItem::setValue(const TelemetrySensor & sensor, int32_t val, uint32_t unit, uint32_t prec)
|
||||
{
|
||||
int32_t newVal = val;
|
||||
|
||||
if (unit == UNIT_CELLS) {
|
||||
uint32_t data = uint32_t(newVal);
|
||||
uint8_t cellsCount = (data >> 24);
|
||||
uint8_t cellIndex = ((data >> 16) & 0x0F);
|
||||
uint16_t cellValue = (data & 0xFFFF);
|
||||
if (cellsCount == 0) {
|
||||
cellsCount = (cellIndex >= cells.count ? cellIndex + 1 : cells.count);
|
||||
if (cellsCount != cells.count) {
|
||||
clear();
|
||||
cells.count = cellsCount;
|
||||
// we skip this round as we are not sure we received all cells values
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (cellsCount != cells.count) {
|
||||
clear();
|
||||
cells.count = cellsCount;
|
||||
}
|
||||
cells.values[cellIndex].set(cellValue);
|
||||
if (cellIndex+1 == cells.count) {
|
||||
newVal = 0;
|
||||
for (int i=0; i<cellsCount; i++) {
|
||||
if (cells.values[i].state) {
|
||||
newVal += cells.values[i].value;
|
||||
}
|
||||
else {
|
||||
// we didn't receive all cells values
|
||||
return;
|
||||
}
|
||||
}
|
||||
newVal = sensor.getValue(newVal, UNIT_VOLTS, 2);
|
||||
}
|
||||
else {
|
||||
// we didn't receive all cells values
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (unit == UNIT_DATETIME) {
|
||||
uint32_t data = uint32_t(newVal);
|
||||
if (data & 0x000000ff) {
|
||||
datetime.year = (uint16_t) ((data & 0xff000000) >> 24);
|
||||
datetime.month = (uint8_t) ((data & 0x00ff0000) >> 16);
|
||||
datetime.day = (uint8_t) ((data & 0x0000ff00) >> 8);
|
||||
if (datetime.year != 0) {
|
||||
datetime.datestate = 1;
|
||||
}
|
||||
#if defined(RTCLOCK)
|
||||
if (g_eeGeneral.adjustRTC && (datetime.datestate == 1)) {
|
||||
struct gtm t;
|
||||
gettime(&t);
|
||||
t.tm_year = datetime.year+4;
|
||||
t.tm_mon = datetime.month-1;
|
||||
t.tm_mday = datetime.day;
|
||||
rtcSetTime(&t);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
datetime.hour = ((uint8_t) ((data & 0xff000000) >> 24) + g_eeGeneral.timezone + 24) % 24;
|
||||
datetime.min = (uint8_t) ((data & 0x00ff0000) >> 16);
|
||||
datetime.sec = (uint16_t) ((data & 0x0000ff00) >> 8);
|
||||
if (datetime.datestate == 1) {
|
||||
datetime.timestate = 1;
|
||||
}
|
||||
#if defined(RTCLOCK)
|
||||
if (g_eeGeneral.adjustRTC && datetime.datestate == 1) {
|
||||
struct gtm t;
|
||||
gettime(&t);
|
||||
if (abs((t.tm_hour-datetime.hour)*3600 + (t.tm_min-datetime.min)*60 + (t.tm_sec-datetime.sec)) > 20) {
|
||||
// we adjust RTC only if difference is > 20 seconds
|
||||
t.tm_hour = datetime.hour;
|
||||
t.tm_min = datetime.min;
|
||||
t.tm_sec = datetime.sec;
|
||||
g_rtcTime = gmktime(&t); // update local timestamp and get wday calculated
|
||||
rtcSetTime(&t);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (datetime.year == 0) {
|
||||
return;
|
||||
}
|
||||
newVal = 0;
|
||||
}
|
||||
else if (unit == UNIT_GPS) {
|
||||
uint32_t gps_long_lati_data = uint32_t(newVal);
|
||||
uint32_t gps_long_lati_b1w, gps_long_lati_a1w;
|
||||
gps_long_lati_b1w = (gps_long_lati_data & 0x3fffffff) / 10000;
|
||||
gps_long_lati_a1w = (gps_long_lati_data & 0x3fffffff) % 10000;
|
||||
switch ((gps_long_lati_data & 0xc0000000) >> 30) {
|
||||
case 0:
|
||||
gps.latitude_bp = (gps_long_lati_b1w / 60 * 100) + (gps_long_lati_b1w % 60);
|
||||
gps.latitude_ap = gps_long_lati_a1w;
|
||||
gps.latitudeNS = 'N';
|
||||
break;
|
||||
case 1:
|
||||
gps.latitude_bp = (gps_long_lati_b1w / 60 * 100) + (gps_long_lati_b1w % 60);
|
||||
gps.latitude_ap = gps_long_lati_a1w;
|
||||
gps.latitudeNS = 'S';
|
||||
break;
|
||||
case 2:
|
||||
gps.longitude_bp = (gps_long_lati_b1w / 60 * 100) + (gps_long_lati_b1w % 60);
|
||||
gps.longitude_ap = gps_long_lati_a1w;
|
||||
gps.longitudeEW = 'E';
|
||||
break;
|
||||
case 3:
|
||||
gps.longitude_bp = (gps_long_lati_b1w / 60 * 100) + (gps_long_lati_b1w % 60);
|
||||
gps.longitude_ap = gps_long_lati_a1w;
|
||||
gps.longitudeEW = 'W';
|
||||
break;
|
||||
}
|
||||
if (gps.longitudeEW && gps.latitudeNS) {
|
||||
gpsReceived();
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (unit >= UNIT_GPS_LONGITUDE && unit <= UNIT_GPS_LATITUDE_NS) {
|
||||
uint32_t data = uint32_t(newVal);
|
||||
switch (unit) {
|
||||
case UNIT_GPS_LONGITUDE:
|
||||
gps.longitude_bp = data >> 16;
|
||||
gps.longitude_ap = data & 0xFFFF;
|
||||
break;
|
||||
case UNIT_GPS_LATITUDE:
|
||||
gps.latitude_bp = data >> 16;
|
||||
gps.latitude_ap = data & 0xFFFF;
|
||||
break;
|
||||
case UNIT_GPS_LONGITUDE_EW:
|
||||
gps.longitudeEW = data;
|
||||
break;
|
||||
case UNIT_GPS_LATITUDE_NS:
|
||||
gps.latitudeNS = data;
|
||||
break;
|
||||
}
|
||||
if (gps.longitudeEW && gps.latitudeNS && gps.longitude_ap && gps.latitude_ap) {
|
||||
gpsReceived();
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (unit == UNIT_DATETIME_YEAR) {
|
||||
datetime.year = newVal;
|
||||
return;
|
||||
}
|
||||
else if (unit == UNIT_DATETIME_DAY_MONTH) {
|
||||
uint32_t data = uint32_t(newVal);
|
||||
datetime.month = data >> 8;
|
||||
datetime.day = data & 0xFF;
|
||||
datetime.datestate = 1;
|
||||
return;
|
||||
}
|
||||
else if (unit == UNIT_DATETIME_HOUR_MIN) {
|
||||
uint32_t data = uint32_t(newVal);
|
||||
datetime.hour = ((data & 0xFF) + g_eeGeneral.timezone + 24) % 24;
|
||||
datetime.min = data >> 8;
|
||||
}
|
||||
else if (unit == UNIT_DATETIME_SEC) {
|
||||
datetime.sec = newVal & 0xFF;
|
||||
datetime.timestate = 1;
|
||||
newVal = 0;
|
||||
}
|
||||
else if (unit == UNIT_RPMS) {
|
||||
if (sensor.custom.ratio != 0) {
|
||||
newVal = (newVal * sensor.custom.offset) / sensor.custom.ratio;
|
||||
}
|
||||
}
|
||||
else {
|
||||
newVal = sensor.getValue(newVal, unit, prec);
|
||||
if (sensor.autoOffset) {
|
||||
if (!isAvailable()) {
|
||||
std.offsetAuto = -newVal;
|
||||
}
|
||||
newVal += std.offsetAuto;
|
||||
}
|
||||
else if (sensor.filter) {
|
||||
if (!isAvailable()) {
|
||||
for (int i=0; i<TELEMETRY_AVERAGE_COUNT; i++) {
|
||||
std.filterValues[i] = newVal;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// calculate the average from values[] and value
|
||||
// also shift readings in values [] array
|
||||
unsigned int sum = std.filterValues[0];
|
||||
for (int i=0; i<TELEMETRY_AVERAGE_COUNT-1; i++) {
|
||||
int32_t tmp = std.filterValues[i+1];
|
||||
std.filterValues[i] = tmp;
|
||||
sum += tmp;
|
||||
}
|
||||
std.filterValues[TELEMETRY_AVERAGE_COUNT-1] = newVal;
|
||||
sum += newVal;
|
||||
newVal = sum/(TELEMETRY_AVERAGE_COUNT+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isAvailable()) {
|
||||
valueMin = newVal;
|
||||
valueMax = newVal;
|
||||
}
|
||||
else if (newVal < valueMin) {
|
||||
valueMin = newVal;
|
||||
}
|
||||
else if (newVal > valueMax) {
|
||||
valueMax = newVal;
|
||||
if (sensor.unit == UNIT_VOLTS) {
|
||||
valueMin = newVal; // the batt was changed
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=0; i<MAX_SENSORS; i++) {
|
||||
TelemetrySensor & it = g_model.telemetrySensors[i];
|
||||
if (it.type == TELEM_TYPE_CALCULATED && it.formula == TELEM_FORMULA_TOTALIZE && &g_model.telemetrySensors[it.consumption.source-1] == &sensor) {
|
||||
TelemetryItem & item = telemetryItems[i];
|
||||
int32_t increment = it.getValue(val, unit, prec);
|
||||
item.setValue(it, item.value+increment, it.unit, it.prec);
|
||||
}
|
||||
}
|
||||
|
||||
value = newVal;
|
||||
lastReceived = now();
|
||||
}
|
||||
|
||||
bool TelemetryItem::isAvailable()
|
||||
{
|
||||
return (lastReceived != TELEMETRY_VALUE_UNAVAILABLE);
|
||||
}
|
||||
|
||||
bool TelemetryItem::isFresh()
|
||||
{
|
||||
return (lastReceived < TELEMETRY_VALUE_TIMER_CYCLE) && (uint8_t(now() - lastReceived) < 2);
|
||||
}
|
||||
|
||||
bool TelemetryItem::isOld()
|
||||
{
|
||||
return (lastReceived == TELEMETRY_VALUE_OLD);
|
||||
}
|
||||
|
||||
void TelemetryItem::per10ms(const TelemetrySensor & sensor)
|
||||
{
|
||||
switch (sensor.formula) {
|
||||
case TELEM_FORMULA_CONSUMPTION:
|
||||
if (sensor.consumption.source) {
|
||||
TelemetrySensor & currentSensor = g_model.telemetrySensors[sensor.consumption.source-1];
|
||||
TelemetryItem & currentItem = telemetryItems[sensor.consumption.source-1];
|
||||
if (!currentItem.isAvailable()) {
|
||||
return;
|
||||
}
|
||||
else if (currentItem.isOld()) {
|
||||
lastReceived = TELEMETRY_VALUE_OLD;
|
||||
return;
|
||||
}
|
||||
int32_t current = convertTelemetryValue(currentItem.value, currentSensor.unit, currentSensor.prec, UNIT_AMPS, 1);
|
||||
currentItem.consumption.prescale += current;
|
||||
if (currentItem.consumption.prescale >= 3600) {
|
||||
currentItem.consumption.prescale -= 3600;
|
||||
setValue(sensor, value+1, sensor.unit, sensor.prec);
|
||||
}
|
||||
lastReceived = now();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void TelemetryItem::eval(const TelemetrySensor & sensor)
|
||||
{
|
||||
switch (sensor.formula) {
|
||||
case TELEM_FORMULA_CELL:
|
||||
if (sensor.cell.source) {
|
||||
TelemetryItem & cellsItem = telemetryItems[sensor.cell.source-1];
|
||||
if (cellsItem.isOld()) {
|
||||
lastReceived = TELEMETRY_VALUE_OLD;
|
||||
}
|
||||
else {
|
||||
unsigned int index = sensor.cell.index;
|
||||
if (index == TELEM_CELL_INDEX_LOWEST || index == TELEM_CELL_INDEX_HIGHEST || index == TELEM_CELL_INDEX_DELTA) {
|
||||
unsigned int lowest=0, highest=0;
|
||||
for (int i=0; i<cellsItem.cells.count; i++) {
|
||||
if (cellsItem.cells.values[i].state) {
|
||||
if (!lowest || cellsItem.cells.values[i].value < cellsItem.cells.values[lowest-1].value)
|
||||
lowest = i+1;
|
||||
if (!highest || cellsItem.cells.values[i].value > cellsItem.cells.values[highest-1].value)
|
||||
highest = i+1;
|
||||
}
|
||||
else {
|
||||
lowest = highest = 0;
|
||||
}
|
||||
}
|
||||
if (lowest) {
|
||||
switch (index) {
|
||||
case TELEM_CELL_INDEX_LOWEST:
|
||||
setValue(sensor, cellsItem.cells.values[lowest-1].value, UNIT_VOLTS, 2);
|
||||
break;
|
||||
case TELEM_CELL_INDEX_HIGHEST:
|
||||
setValue(sensor, cellsItem.cells.values[highest-1].value, UNIT_VOLTS, 2);
|
||||
break;
|
||||
case TELEM_CELL_INDEX_DELTA:
|
||||
setValue(sensor, cellsItem.cells.values[highest-1].value - cellsItem.cells.values[lowest-1].value, UNIT_VOLTS, 2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
index -= 1;
|
||||
if (index < cellsItem.cells.count && cellsItem.cells.values[index].state) {
|
||||
setValue(sensor, cellsItem.cells.values[index].value, UNIT_VOLTS, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case TELEM_FORMULA_DIST:
|
||||
if (sensor.dist.gps) {
|
||||
TelemetryItem gpsItem = telemetryItems[sensor.dist.gps-1];
|
||||
TelemetryItem * altItem = NULL;
|
||||
if (!gpsItem.isAvailable()) {
|
||||
return;
|
||||
}
|
||||
else if (gpsItem.isOld()) {
|
||||
lastReceived = TELEMETRY_VALUE_OLD;
|
||||
return;
|
||||
}
|
||||
if (sensor.dist.alt) {
|
||||
altItem = &telemetryItems[sensor.dist.alt-1];
|
||||
if (!altItem->isAvailable()) {
|
||||
return;
|
||||
}
|
||||
else if (altItem->isOld()) {
|
||||
lastReceived = TELEMETRY_VALUE_OLD;
|
||||
return;
|
||||
}
|
||||
}
|
||||
uint32_t latitude, longitude;
|
||||
gpsItem.gps.extractLatitudeLongitude(&latitude, &longitude);
|
||||
|
||||
uint32_t angle = (latitude > gpsItem.pilotLatitude) ? latitude - gpsItem.pilotLatitude : gpsItem.pilotLatitude - latitude;
|
||||
uint32_t dist = EARTH_RADIUS * angle / 1000000;
|
||||
uint32_t result = dist*dist;
|
||||
|
||||
angle = (longitude > gpsItem.pilotLongitude) ? longitude - gpsItem.pilotLongitude : gpsItem.pilotLongitude - longitude;
|
||||
dist = gpsItem.distFromEarthAxis * angle / 1000000;
|
||||
result += dist*dist;
|
||||
|
||||
if (altItem) {
|
||||
dist = abs(altItem->value) / g_model.telemetrySensors[sensor.dist.alt-1].getPrecDivisor();
|
||||
result += dist*dist;
|
||||
}
|
||||
|
||||
setValue(sensor, isqrt32(result), UNIT_METERS);
|
||||
}
|
||||
break;
|
||||
|
||||
case TELEM_FORMULA_ADD:
|
||||
case TELEM_FORMULA_AVERAGE:
|
||||
case TELEM_FORMULA_MIN:
|
||||
case TELEM_FORMULA_MAX:
|
||||
case TELEM_FORMULA_MULTIPLY:
|
||||
{
|
||||
int32_t value=0, count=0, available=0, maxitems=4, mulprec=0;
|
||||
if (sensor.formula == TELEM_FORMULA_MULTIPLY) {
|
||||
maxitems = 2;
|
||||
value = 1;
|
||||
}
|
||||
for (int i=0; i<maxitems; i++) {
|
||||
int8_t source = sensor.calc.sources[i];
|
||||
if (source) {
|
||||
unsigned int index = abs(source)-1;
|
||||
TelemetrySensor & telemetrySensor = g_model.telemetrySensors[index];
|
||||
TelemetryItem & telemetryItem = telemetryItems[index];
|
||||
if (sensor.formula == TELEM_FORMULA_AVERAGE) {
|
||||
if (telemetryItem.isAvailable())
|
||||
available = 1;
|
||||
else
|
||||
continue;
|
||||
if (telemetryItem.isOld())
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
if (!telemetryItem.isAvailable()) {
|
||||
return;
|
||||
}
|
||||
else if (telemetryItem.isOld()) {
|
||||
lastReceived = TELEMETRY_VALUE_OLD;
|
||||
return;
|
||||
}
|
||||
}
|
||||
int32_t sensorValue = telemetryItem.value;
|
||||
if (source < 0)
|
||||
sensorValue = -sensorValue;
|
||||
count += 1;
|
||||
if (sensor.formula == TELEM_FORMULA_MULTIPLY) {
|
||||
mulprec += telemetrySensor.prec;
|
||||
value *= convertTelemetryValue(sensorValue, telemetrySensor.unit, 0, sensor.unit, 0);
|
||||
}
|
||||
else {
|
||||
sensorValue = convertTelemetryValue(sensorValue, telemetrySensor.unit, telemetrySensor.prec, sensor.unit, sensor.prec);
|
||||
if (sensor.formula == TELEM_FORMULA_MIN)
|
||||
value = (count==1 ? sensorValue : min<int32_t>(value, sensorValue));
|
||||
else if (sensor.formula == TELEM_FORMULA_MAX)
|
||||
value = (count==1 ? sensorValue : max<int32_t>(value, sensorValue));
|
||||
else
|
||||
value += sensorValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sensor.formula == TELEM_FORMULA_AVERAGE) {
|
||||
if (count == 0) {
|
||||
if (available)
|
||||
lastReceived = TELEMETRY_VALUE_OLD;
|
||||
return;
|
||||
}
|
||||
else {
|
||||
value = (value + count/2) / count;
|
||||
}
|
||||
}
|
||||
else if (sensor.formula == TELEM_FORMULA_MULTIPLY) {
|
||||
if (count == 0)
|
||||
return;
|
||||
value = convertTelemetryValue(value, sensor.unit, mulprec, sensor.unit, sensor.prec);
|
||||
}
|
||||
setValue(sensor, value, sensor.unit, sensor.prec);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void delTelemetryIndex(uint8_t index)
|
||||
{
|
||||
memclear(&g_model.telemetrySensors[index], sizeof(TelemetrySensor));
|
||||
telemetryItems[index].clear();
|
||||
storageDirty(EE_MODEL);
|
||||
}
|
||||
|
||||
int availableTelemetryIndex()
|
||||
{
|
||||
for (int index=0; index<MAX_SENSORS; index++) {
|
||||
TelemetrySensor & telemetrySensor = g_model.telemetrySensors[index];
|
||||
if (!telemetrySensor.isAvailable()) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int lastUsedTelemetryIndex()
|
||||
{
|
||||
for (int index=MAX_SENSORS-1; index>=0; index--) {
|
||||
TelemetrySensor & telemetrySensor = g_model.telemetrySensors[index];
|
||||
if (telemetrySensor.isAvailable()) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void setTelemetryValue(TelemetryProtocol protocol, uint16_t id, uint8_t subId, uint8_t instance, int32_t value, uint32_t unit, uint32_t prec)
|
||||
{
|
||||
bool available = false;
|
||||
|
||||
for (int index=0; index<MAX_SENSORS; index++) {
|
||||
TelemetrySensor & telemetrySensor = g_model.telemetrySensors[index];
|
||||
if (telemetrySensor.type == TELEM_TYPE_CUSTOM && telemetrySensor.id == id && telemetrySensor.subId == subId && (telemetrySensor.instance == instance || g_model.ignoreSensorIds)) {
|
||||
telemetryItems[index].setValue(telemetrySensor, value, unit, prec);
|
||||
available = true;
|
||||
// we continue search here, because sensors can share the same id and instance
|
||||
}
|
||||
}
|
||||
|
||||
if (available || !allowNewSensors) {
|
||||
return;
|
||||
}
|
||||
|
||||
int index = availableTelemetryIndex();
|
||||
if (index >= 0) {
|
||||
switch (protocol) {
|
||||
#if defined(FRSKY_SPORT)
|
||||
case TELEM_PROTO_FRSKY_SPORT:
|
||||
frskySportSetDefault(index, id, subId, instance);
|
||||
break;
|
||||
#endif
|
||||
#if defined(FRSKY)
|
||||
case TELEM_PROTO_FRSKY_D:
|
||||
frskyDSetDefault(index, id);
|
||||
break;
|
||||
#endif
|
||||
#if defined(CROSSFIRE)
|
||||
case TELEM_PROTO_CROSSFIRE:
|
||||
crossfireSetDefault(index, id, instance);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
return;
|
||||
}
|
||||
telemetryItems[index].setValue(g_model.telemetrySensors[index], value, unit, prec);
|
||||
}
|
||||
else {
|
||||
POPUP_WARNING(STR_TELEMETRYFULL);
|
||||
}
|
||||
}
|
||||
|
||||
void TelemetrySensor::init(const char * label, uint8_t unit, uint8_t prec)
|
||||
{
|
||||
memclear(this->label, TELEM_LABEL_LEN);
|
||||
strncpy(this->label, label, TELEM_LABEL_LEN);
|
||||
this->unit = unit;
|
||||
if (prec > 1 && (IS_DISTANCE_UNIT(unit) || IS_SPEED_UNIT(unit))) {
|
||||
// 2 digits precision is not needed here
|
||||
prec = 1;
|
||||
}
|
||||
this->prec = prec;
|
||||
}
|
||||
|
||||
void TelemetrySensor::init(uint16_t id)
|
||||
{
|
||||
char label[4];
|
||||
label[0] = hex2zchar((id & 0xf000) >> 12);
|
||||
label[1] = hex2zchar((id & 0x0f00) >> 8);
|
||||
label[2] = hex2zchar((id & 0x00f0) >> 4);
|
||||
label[3] = hex2zchar((id & 0x000f) >> 0);
|
||||
init(label);
|
||||
}
|
||||
|
||||
bool TelemetrySensor::isAvailable() const
|
||||
{
|
||||
return ZLEN(label) > 0;
|
||||
}
|
||||
|
||||
PACK(typedef struct {
|
||||
uint8_t unitFrom;
|
||||
uint8_t unitTo;
|
||||
int16_t multiplier;
|
||||
int16_t divisor;
|
||||
}) UnitConversionRule;
|
||||
|
||||
const UnitConversionRule unitConversionTable[] = {
|
||||
/* unitFrom unitTo multiplier divisor */
|
||||
{ UNIT_METERS, UNIT_FEET, 105, 32},
|
||||
{ UNIT_METERS_PER_SECOND, UNIT_FEET_PER_SECOND, 105, 32},
|
||||
|
||||
{ UNIT_KTS, UNIT_KMH, 1852, 1000}, // 1 knot = 1.85200 kilometers per hour
|
||||
{ UNIT_KTS, UNIT_MPH, 1151, 1000}, // 1 knot = 1.15077945 miles per hour
|
||||
{ UNIT_KTS, UNIT_METERS_PER_SECOND, 1000, 1944}, // 1 knot = 0.514444444 meters / second (divide with 1.94384449)
|
||||
{ UNIT_KTS, UNIT_FEET_PER_SECOND, 1688, 1000}, // 1 knot = 1.68780986 feet per second
|
||||
|
||||
{ UNIT_KMH, UNIT_KTS, 1000, 1852}, // 1 km/h = 0.539956803 knots (divide with 1.85200)
|
||||
{ UNIT_KMH, UNIT_MPH, 1000, 1609}, // 1 km/h = 0.621371192 miles per hour (divide with 1.60934400)
|
||||
{ UNIT_KMH, UNIT_METERS_PER_SECOND, 10, 36}, // 1 km/h = 0.277777778 meters / second (divide with 3.6)
|
||||
{ UNIT_KMH, UNIT_FEET_PER_SECOND, 911, 1000}, // 1 km/h = 0.911344415 feet per second
|
||||
|
||||
{ UNIT_MILLILITERS, UNIT_FLOZ, 100, 2957},
|
||||
{ 0, 0, 0, 0} // termination
|
||||
};
|
||||
|
||||
int32_t convertTelemetryValue(int32_t value, uint8_t unit, uint8_t prec, uint8_t destUnit, uint8_t destPrec)
|
||||
{
|
||||
for (int i=prec; i<destPrec; i++)
|
||||
value *= 10;
|
||||
|
||||
if (unit == UNIT_CELSIUS) {
|
||||
if (destUnit == UNIT_FAHRENHEIT) {
|
||||
// T(°F) = T(°C)×1,8 + 32
|
||||
value = 32 + (value*18) / 10;
|
||||
}
|
||||
}
|
||||
else {
|
||||
const UnitConversionRule * p = unitConversionTable;
|
||||
while (p->divisor) {
|
||||
if (p->unitFrom == unit && p->unitTo == destUnit) {
|
||||
value = (value * (int32_t)p->multiplier) / (int32_t)p->divisor;
|
||||
break;
|
||||
}
|
||||
++p;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=destPrec; i<prec; i++)
|
||||
value /= 10;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
int32_t TelemetrySensor::getValue(int32_t value, uint8_t unit, uint8_t prec) const
|
||||
{
|
||||
if (type == TELEM_TYPE_CUSTOM && custom.ratio) {
|
||||
if (this->prec == 2) {
|
||||
value *= 10;
|
||||
prec = 2;
|
||||
}
|
||||
else {
|
||||
prec = 1;
|
||||
}
|
||||
value = (custom.ratio * value + 122) / 255;
|
||||
}
|
||||
|
||||
value = convertTelemetryValue(value, unit, prec, this->unit, this->prec);
|
||||
|
||||
if (type == TELEM_TYPE_CUSTOM) {
|
||||
value += custom.offset;
|
||||
if (value < 0 && onlyPositive) {
|
||||
value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
bool TelemetrySensor::isConfigurable() const
|
||||
{
|
||||
if (type == TELEM_TYPE_CALCULATED) {
|
||||
if (formula >= TELEM_FORMULA_CELL) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (unit >= UNIT_FIRST_VIRTUAL) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TelemetrySensor::isPrecConfigurable() const
|
||||
{
|
||||
if (isConfigurable()) {
|
||||
return true;
|
||||
}
|
||||
else if (unit == UNIT_CELLS) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t TelemetrySensor::getPrecMultiplier() const
|
||||
{
|
||||
/*
|
||||
Important: the return type must be signed, otherwise
|
||||
mathematic operations with a negative telemetry value won't work
|
||||
*/
|
||||
if (prec == 2) return 1;
|
||||
if (prec == 1) return 10;
|
||||
return 100;
|
||||
}
|
||||
|
||||
int32_t TelemetrySensor::getPrecDivisor() const
|
||||
{
|
||||
if (prec == 2) return 100;
|
||||
if (prec == 1) return 10;
|
||||
return 1;
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef _TELEMETRY_SENSORS_H_
|
||||
#define _TELEMETRY_SENSORS_H_
|
||||
|
||||
class TelemetryItem
|
||||
{
|
||||
public:
|
||||
union {
|
||||
int32_t value; // value, stored as uint32_t but interpreted accordingly to type
|
||||
uint32_t distFromEarthAxis;
|
||||
};
|
||||
|
||||
union {
|
||||
int32_t valueMin; // min store
|
||||
uint32_t pilotLongitude;
|
||||
};
|
||||
|
||||
union {
|
||||
int32_t valueMax; // max store
|
||||
uint32_t pilotLatitude;
|
||||
};
|
||||
|
||||
uint8_t lastReceived; // for detection of sensor loss
|
||||
|
||||
union {
|
||||
struct {
|
||||
int32_t offsetAuto;
|
||||
int32_t filterValues[TELEMETRY_AVERAGE_COUNT];
|
||||
} std;
|
||||
struct {
|
||||
uint16_t prescale;
|
||||
} consumption;
|
||||
struct {
|
||||
uint8_t count;
|
||||
CellValue values[6];
|
||||
} cells;
|
||||
struct {
|
||||
uint8_t datestate;
|
||||
uint16_t year;
|
||||
uint8_t month;
|
||||
uint8_t day;
|
||||
uint8_t timestate;
|
||||
uint8_t hour;
|
||||
uint8_t min;
|
||||
uint8_t sec;
|
||||
} datetime;
|
||||
struct {
|
||||
uint16_t longitude_bp;
|
||||
uint16_t longitude_ap;
|
||||
char longitudeEW;
|
||||
uint16_t latitude_bp;
|
||||
uint16_t latitude_ap;
|
||||
char latitudeNS;
|
||||
// pilot longitude is stored in min
|
||||
// pilot latitude is stored in max
|
||||
// distFromEarthAxis is stored in value
|
||||
void extractLatitudeLongitude(uint32_t * latitude, uint32_t * longitude)
|
||||
{
|
||||
div_t qr = div(latitude_bp, 100);
|
||||
*latitude = ((uint32_t)(qr.quot) * 1000000) + (((uint32_t)(qr.rem) * 10000 + latitude_ap) * 5) / 3;
|
||||
qr = div(longitude_bp, 100);
|
||||
*longitude = ((uint32_t)(qr.quot) * 1000000) + (((uint32_t)(qr.rem) * 10000 + longitude_ap) * 5) / 3;
|
||||
}
|
||||
} gps;
|
||||
};
|
||||
|
||||
static uint8_t now()
|
||||
{
|
||||
return (get_tmr10ms() / 10) % TELEMETRY_VALUE_TIMER_CYCLE;
|
||||
}
|
||||
|
||||
TelemetryItem()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
memset(this, 0, sizeof(*this));
|
||||
lastReceived = TELEMETRY_VALUE_UNAVAILABLE;
|
||||
}
|
||||
|
||||
void eval(const TelemetrySensor & sensor);
|
||||
void per10ms(const TelemetrySensor & sensor);
|
||||
|
||||
void setValue(const TelemetrySensor & sensor, int32_t newVal, uint32_t unit, uint32_t prec=0);
|
||||
bool isAvailable();
|
||||
bool isFresh();
|
||||
bool isOld();
|
||||
void gpsReceived();
|
||||
};
|
||||
|
||||
extern TelemetryItem telemetryItems[MAX_SENSORS];
|
||||
extern uint8_t allowNewSensors;
|
||||
|
||||
#endif // _TELEMETRY_SENSORS_H_
|
||||
@@ -4,9 +4,6 @@ set(GTEST_SRCDIR /usr/src/gtest)
|
||||
if(EXISTS "${GTEST_SRCDIR}/src/gtest-all.cc")
|
||||
add_library(gtests-lib STATIC EXCLUDE_FROM_ALL ${GTEST_SRCDIR}/src/gtest-all.cc )
|
||||
target_include_directories(gtests-lib PUBLIC ${GTEST_INCDIR} PUBLIC ${GTEST_SRCDIR})
|
||||
|
||||
find_package(Qt4 4.8.1 REQUIRED)
|
||||
include(${QT_USE_FILE})
|
||||
add_definitions(-DSIMU)
|
||||
set(TESTS_PATH ${RADIO_SRC_DIRECTORY})
|
||||
configure_file(${RADIO_SRC_DIRECTORY}/tests/location.h.in ${CMAKE_CURRENT_BINARY_DIR}/location.h @ONLY)
|
||||
@@ -19,8 +16,9 @@ if(EXISTS "${GTEST_SRCDIR}/src/gtest-all.cc")
|
||||
file(GLOB TEST_SRC_FILES ${RADIO_SRC_DIRECTORY}/tests/*.cpp)
|
||||
|
||||
add_executable(gtests EXCLUDE_FROM_ALL ${TEST_SRC_FILES} ${CMAKE_CURRENT_SOURCE_DIR}/location.h ${RADIO_SRC} ../targets/simu/simpgmspace.cpp)
|
||||
qt5_use_modules(gtests Core Widgets)
|
||||
add_dependencies(gtests ${FIRMWARE_DEPENDENCIES} gtests-lib)
|
||||
target_link_libraries(gtests gtests-lib ${QT_LIBRARIES} pthread)
|
||||
target_link_libraries(gtests gtests-lib pthread)
|
||||
message("Added optional gtests target")
|
||||
else()
|
||||
message("WARNING: can't find gtests source, gtest target will not be available!")
|
||||
|
||||
@@ -35,5 +35,12 @@ TEST(Crossfire, createCrossfireFrame)
|
||||
|
||||
// TODO check
|
||||
}
|
||||
|
||||
TEST(Crossfire, crc8)
|
||||
{
|
||||
uint8_t frame[] = { 0x00, 0x0C, 0x14, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x01, 0x03, 0x00, 0x00, 0x00, 0xF4 };
|
||||
uint8_t crc = crc8(&frame[2], frame[1]-1);
|
||||
ASSERT_EQ(frame[frame[1]+1], crc);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
+17
-17
@@ -34,7 +34,7 @@ void displayVoltagesScreen();
|
||||
TEST(FrSky, gpsNfuel)
|
||||
{
|
||||
g_model.frsky.usrProto = 1;
|
||||
frskyData.hub.gpsFix = 1;
|
||||
telemetryData.hub.gpsFix = 1;
|
||||
|
||||
uint8_t pkt1[] = { 0xfd, 0x07, 0x00, 0x5e, 0x14, 0x2c, 0x00, 0x5e, 0x1c, 0x03 };
|
||||
uint8_t pkt2[] = { 0xfd, 0x07, 0x00, 0x00, 0x5e, 0x13, 0x38, 0x0c, 0x5e, 0x1b };
|
||||
@@ -50,14 +50,14 @@ TEST(FrSky, gpsNfuel)
|
||||
frskyDProcessPacket(pkt5);
|
||||
frskyDProcessPacket(pkt6);
|
||||
frskyDProcessPacket(pkt7);
|
||||
EXPECT_EQ(frskyData.hub.gpsCourse_bp, 44);
|
||||
EXPECT_EQ(frskyData.hub.gpsCourse_ap, 03);
|
||||
EXPECT_EQ(frskyData.hub.gpsLongitude_bp / 100, 120);
|
||||
EXPECT_EQ(frskyData.hub.gpsLongitude_bp % 100, 15);
|
||||
EXPECT_EQ(frskyData.hub.gpsLongitude_ap, 0x2698);
|
||||
EXPECT_EQ(frskyData.hub.gpsLatitudeNS, 'N');
|
||||
EXPECT_EQ(frskyData.hub.gpsLongitudeEW, 'E');
|
||||
EXPECT_EQ(frskyData.hub.fuelLevel, 100);
|
||||
EXPECT_EQ(telemetryData.hub.gpsCourse_bp, 44);
|
||||
EXPECT_EQ(telemetryData.hub.gpsCourse_ap, 03);
|
||||
EXPECT_EQ(telemetryData.hub.gpsLongitude_bp / 100, 120);
|
||||
EXPECT_EQ(telemetryData.hub.gpsLongitude_bp % 100, 15);
|
||||
EXPECT_EQ(telemetryData.hub.gpsLongitude_ap, 0x2698);
|
||||
EXPECT_EQ(telemetryData.hub.gpsLatitudeNS, 'N');
|
||||
EXPECT_EQ(telemetryData.hub.gpsLongitudeEW, 'E');
|
||||
EXPECT_EQ(telemetryData.hub.fuelLevel, 100);
|
||||
}
|
||||
|
||||
TEST(FrSky, dateNtime)
|
||||
@@ -68,17 +68,17 @@ TEST(FrSky, dateNtime)
|
||||
frskyDProcessPacket(pkt1);
|
||||
frskyDProcessPacket(pkt2);
|
||||
frskyDProcessPacket(pkt3);
|
||||
EXPECT_EQ(frskyData.hub.day, 15);
|
||||
EXPECT_EQ(frskyData.hub.month, 07);
|
||||
EXPECT_EQ(frskyData.hub.year, 11);
|
||||
EXPECT_EQ(frskyData.hub.hour, 06);
|
||||
EXPECT_EQ(frskyData.hub.min, 18);
|
||||
EXPECT_EQ(frskyData.hub.sec, 50);
|
||||
EXPECT_EQ(telemetryData.hub.day, 15);
|
||||
EXPECT_EQ(telemetryData.hub.month, 07);
|
||||
EXPECT_EQ(telemetryData.hub.year, 11);
|
||||
EXPECT_EQ(telemetryData.hub.hour, 06);
|
||||
EXPECT_EQ(telemetryData.hub.min, 18);
|
||||
EXPECT_EQ(telemetryData.hub.sec, 50);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FRSKY) && defined(CPUARM)
|
||||
TEST(FrSky, FrskyValueWithMinAveraging)
|
||||
TEST(FrSky, TelemetryValueWithMinAveraging)
|
||||
{
|
||||
/*
|
||||
The following expected[] array is filled
|
||||
@@ -90,7 +90,7 @@ TEST(FrSky, FrskyValueWithMinAveraging)
|
||||
uint8_t expected[] = { 10, 12, 17, 25, 35, 45, 55, 65, 75, 85, 92, 97, 100, 100, 100, 100, 100};
|
||||
int testPos = 0;
|
||||
//test of averaging
|
||||
FrskyValueWithMin testVal;
|
||||
TelemetryValueWithMin testVal;
|
||||
testVal.value = 0;
|
||||
testVal.set(10);
|
||||
EXPECT_EQ(RAW_FRSKY_MINMAX(testVal), 10);
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <QtGui/QApplication>
|
||||
#include <QApplication>
|
||||
#include "gtests.h"
|
||||
|
||||
int32_t lastAct = 0;
|
||||
|
||||
@@ -79,7 +79,7 @@ inline void MIXER_RESET()
|
||||
inline void TELEMETRY_RESET()
|
||||
{
|
||||
#if defined(FRSKY)
|
||||
memclear(&frskyData, sizeof(frskyData));
|
||||
memclear(&telemetryData, sizeof(telemetryData));
|
||||
TELEMETRY_RSSI() = 100;
|
||||
#endif
|
||||
#if defined(CPUARM) && defined(FRSKY)
|
||||
|
||||
+6
-13
@@ -20,8 +20,8 @@
|
||||
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QPainter>
|
||||
#include <QApplication>
|
||||
#include <QPainter>
|
||||
#include <math.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
@@ -82,18 +82,11 @@ bool checkScreenshot(const QString & test)
|
||||
QImage buffer(LCD_W, LCD_H, QImage::Format_RGB32);
|
||||
QPainter p(&buffer);
|
||||
doPaint(p);
|
||||
|
||||
QString filename(QString("%1_%2x%3.png").arg(test).arg(LCD_W).arg(LCD_H));
|
||||
buffer.save("/tmp/" + filename);
|
||||
QFile screenshot("/tmp/" + filename);
|
||||
if (!screenshot.open(QIODevice::ReadOnly))
|
||||
return false;
|
||||
QFile reference( TESTS_PATH "/tests/" + filename);
|
||||
if (!reference.open(QIODevice::ReadOnly))
|
||||
return false;
|
||||
if (reference.readAll() != screenshot.readAll())
|
||||
return false;
|
||||
screenshot.remove();
|
||||
return true;
|
||||
QImage reference(TESTS_PATH "/tests/" + filename);
|
||||
|
||||
return buffer == reference;
|
||||
}
|
||||
|
||||
#if defined(COLORLCD)
|
||||
|
||||
Vendored
+33
-33
@@ -1,39 +1,39 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file OsConfig.h
|
||||
* @version V1.1.6
|
||||
* @date 2014.05.23
|
||||
* @version V1.1.6
|
||||
* @date 2014.05.23
|
||||
* @brief This file use by user to configuration CooCox CoOS.
|
||||
* @note Ensure you have knew every item before modify this file.
|
||||
*******************************************************************************
|
||||
* @copy
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the <ORGANIZATION> nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the <ORGANIZATION> nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2014 CooCox </center></h2>
|
||||
* <h2><center>© COPYRIGHT 2014 CooCox </center></h2>
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
@@ -60,18 +60,18 @@ Max number of tasks that can be running.
|
||||
/*!<
|
||||
Idle task stack size(word).
|
||||
*/
|
||||
#if CFG_CHIP_TYPE == 3
|
||||
#define CFG_IDLE_STACK_SIZE (58)
|
||||
#else
|
||||
#if CFG_CHIP_TYPE == 3
|
||||
#define CFG_IDLE_STACK_SIZE (58)
|
||||
#else
|
||||
#define CFG_IDLE_STACK_SIZE (25)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*!<
|
||||
System frequency (Hz).
|
||||
*/
|
||||
#if defined(PCBFLAMENCO) || (defined(PCBTARANIS) && defined(REV9E))
|
||||
#if defined(PCBFLAMENCO) || (defined(PCBTARANIS) && defined(REV9E)) || defined(PCBHORUS)
|
||||
#define CFG_CPU_FREQ (168000000)
|
||||
#elif defined(PCBTARANIS) || defined(PCBHORUS)
|
||||
#elif defined(PCBTARANIS)
|
||||
#define CFG_CPU_FREQ (120000000)
|
||||
#else
|
||||
#define CFG_CPU_FREQ (36000000) // TODO check if really correct for sky9x?
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
/en.h
|
||||
/cz.h
|
||||
/de.h
|
||||
/es.h
|
||||
/fi.h
|
||||
/fr.h
|
||||
/it.h
|
||||
/nl.h
|
||||
/pl.h
|
||||
/pt.h
|
||||
/se.h
|
||||
@@ -1,16 +1,12 @@
|
||||
/*
|
||||
* Authors (alphabetical order)
|
||||
* - Bertrand Songis <bsongis@gmail.com>
|
||||
* - Bernet Andre <bernet.andre@gmail.com>
|
||||
* - Kjell Kernen <kjell.kernen@gmail.com>
|
||||
* - Martin Hotar <mhotar@gmail.com>
|
||||
* - Romolo Manfredini <romolo.manfredini@gmail.com>
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* opentx is based on code named
|
||||
* gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/,
|
||||
* er9x by Erez Raviv: http://code.google.com/p/er9x/,
|
||||
* and the original (and ongoing) project by
|
||||
* Thomas Husterer, th9x: http://code.google.com/p/th9x/
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
@@ -21,10 +17,11 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
// CZ translations author: Martin Hotar <mhotar@gmail.com>
|
||||
|
||||
/*
|
||||
* !!!!! DO NOT EDIT cz.h - EDIT cz.h.txt INSTEAD !!!!!!!
|
||||
*
|
||||
* In order to make translations easier cz.h.txt is parsed and national
|
||||
@@ -33,7 +30,9 @@
|
||||
*
|
||||
* !!!!! DO NOT EDIT cz.h - EDIT cz.h.txt INSTEAD !!!!!!!
|
||||
*/
|
||||
/* Formatting octal codes available in TR_ strings:
|
||||
|
||||
/*
|
||||
* Formatting octal codes available in TR_ strings:
|
||||
* \037\x -sets LCD x-coord (x value in octal)
|
||||
* \036 -newline
|
||||
* \035 -horizontal tab (ARM only)
|
||||
@@ -43,14 +42,6 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// NON ZERO TERMINATED STRINGS
|
||||
#define LEN_OFFON "\003"
|
||||
#define TR_OFFON "VYP""ZAP"
|
||||
@@ -385,7 +376,7 @@
|
||||
#define LEN_VUNITSSYSTEM TR("\006", "\010")
|
||||
#define TR_VUNITSSYSTEM TR("Metr.\0""Imper.", "Metrické""Imperial")
|
||||
#define LEN_VTELEMUNIT "\003"
|
||||
#define TR_VTELEMUNIT "-\0 ""V\0 ""A\0 ""mA\0""kts""m/s""f/s""kmh""mph""m\0 ""ft\0""@C\0""@F\0""%\0 ""mAh""W\0 ""dB\0""rpm""g\0 ""@\0 ""ml\0""fOz"
|
||||
#define TR_VTELEMUNIT "-\0 ""V\0 ""A\0 ""mA\0""kts""m/s""f/s""kmh""mph""m\0 ""ft\0""@C\0""@F\0""%\0 ""mAh""W\0 ""mW\0""dB\0""rpm""g\0 ""@\0 ""ml\0""fOz"
|
||||
#else
|
||||
#if defined(IMPERIAL_UNITS)
|
||||
#define LENGTH_UNIT LENGTH_UNIT_IMP
|
||||
@@ -1169,3 +1160,13 @@
|
||||
#define ZSTR_BATT2_CONSUMPTION "RB2C"
|
||||
#define ZSTR_RB_STATE "RBS"
|
||||
#define ZSTR_CHANS_STATE "RBCS"
|
||||
#define ZSTR_RX_RSSI1 "1RSS"
|
||||
#define ZSTR_RX_RSSI2 "2RSS"
|
||||
#define ZSTR_RX_QUALITY "RQly"
|
||||
#define ZSTR_RX_SNR "RSNR"
|
||||
#define ZSTR_ANTENNA "ANT"
|
||||
#define ZSTR_RF_MODE "RFMD"
|
||||
#define ZSTR_TX_POWER "TPWR"
|
||||
#define ZSTR_TX_RSSI "TRSS"
|
||||
#define ZSTR_TX_QUALITY "TQly"
|
||||
#define ZSTR_TX_SNR "TSNR"
|
||||
+1175
-1174
File diff suppressed because it is too large
Load Diff
@@ -1,27 +1,12 @@
|
||||
/*
|
||||
* Authors (alphabetical order)
|
||||
* - Andre Bernet <bernet.andre@gmail.com>
|
||||
* - Andreas Weitl
|
||||
* - Bertrand Songis <bsongis@gmail.com>
|
||||
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||
* - Cameron Weeks <th9xer@gmail.com>
|
||||
* - Erez Raviv
|
||||
* - Gabriel Birkus
|
||||
* - Jean-Pierre Parisy
|
||||
* - Karl Szmutny
|
||||
* - Michael Blandford
|
||||
* - Michal Hlavinka
|
||||
* - Pat Mackenzie
|
||||
* - Philip Moss
|
||||
* - Rob Thomson
|
||||
* - Romolo Manfredini <romolo.manfredini@gmail.com>
|
||||
* - Thomas Husterer
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* opentx is based on code named
|
||||
* gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/,
|
||||
* er9x by Erez Raviv: http://code.google.com/p/er9x/,
|
||||
* and the original (and ongoing) project by
|
||||
* Thomas Husterer, th9x: http://code.google.com/p/th9x/
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
@@ -32,6 +17,11 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* !!!!! DO NOT EDIT en.h - EDIT en.h.txt INSTEAD !!!!!!!
|
||||
*
|
||||
* In order to make translations easier en.h.txt is parsed and national
|
||||
@@ -41,9 +31,8 @@
|
||||
* !!!!! DO NOT EDIT en.h - EDIT en.h.txt INSTEAD !!!!!!!
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* Formatting octal codes available in TR_ strings:
|
||||
/*
|
||||
* Formatting octal codes available in TR_ strings:
|
||||
* \037\x -sets LCD x-coord (x value in octal)
|
||||
* \036 -newline
|
||||
* \035 -horizontal tab (ARM only)
|
||||
@@ -51,6 +40,8 @@
|
||||
* \0 -ends current string
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// NON ZERO TERMINATED STRINGS
|
||||
#define LEN_OFFON "\003"
|
||||
#define TR_OFFON "OFF""ON\0"
|
||||
@@ -387,7 +378,7 @@
|
||||
#define LEN_VUNITSSYSTEM TR("\006", "\010")
|
||||
#define TR_VUNITSSYSTEM TR("Metric""Imper.", "Metric\0 ""Imperial")
|
||||
#define LEN_VTELEMUNIT "\003"
|
||||
#define TR_VTELEMUNIT "-\0 ""V\0 ""A\0 ""mA\0""kts""m/s""f/s""kmh""mph""m\0 ""ft\0""@C\0""@F\0""%\0 ""mAh""W\0 ""dB\0""rpm""g\0 ""@\0 ""ml\0""fOz"
|
||||
#define TR_VTELEMUNIT "-\0 ""V\0 ""A\0 ""mA\0""kts""m/s""f/s""kmh""mph""m\0 ""ft\0""@C\0""@F\0""%\0 ""mAh""W\0 ""mW\0""dB\0""rpm""g\0 ""@\0 ""ml\0""fOz"
|
||||
#else
|
||||
#if defined(IMPERIAL_UNITS)
|
||||
#define LENGTH_UNIT LENGTH_UNIT_IMP
|
||||
@@ -1187,3 +1178,13 @@
|
||||
#define ZSTR_BATT2_CONSUMPTION "RB2C"
|
||||
#define ZSTR_RB_STATE "RBS"
|
||||
#define ZSTR_CHANS_STATE "RBCS"
|
||||
#define ZSTR_RX_RSSI1 "1RSS"
|
||||
#define ZSTR_RX_RSSI2 "2RSS"
|
||||
#define ZSTR_RX_QUALITY "RQly"
|
||||
#define ZSTR_RX_SNR "RSNR"
|
||||
#define ZSTR_ANTENNA "ANT"
|
||||
#define ZSTR_RF_MODE "RFMD"
|
||||
#define ZSTR_TX_POWER "TPWR"
|
||||
#define ZSTR_TX_RSSI "TRSS"
|
||||
#define ZSTR_TX_QUALITY "TQly"
|
||||
#define ZSTR_TX_SNR "TSNR"
|
||||
@@ -1,17 +1,12 @@
|
||||
/*
|
||||
* Authors (alphabetical order)
|
||||
* - Bertrand Songis <bsongis@gmail.com>
|
||||
* - Bernet Andre <bernet.andre@gmail.com>
|
||||
* - Jose Moreno <josemoreno259@gmail.com>
|
||||
* - Kjell Kernen <kjell.kernen@gmail.com>
|
||||
* - Martin Hotar <mhotar@gmail.com>
|
||||
* - Romolo Manfredini <romolo.manfredini@gmail.com>
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* opentx is based on code named
|
||||
* gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/,
|
||||
* er9x by Erez Raviv: http://code.google.com/p/er9x/,
|
||||
* and the original (and ongoing) project by
|
||||
* Thomas Husterer, th9x: http://code.google.com/p/th9x/
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
@@ -22,8 +17,11 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
// ES translations author: Jose Moreno <josemoreno259@gmail.com>
|
||||
|
||||
/*
|
||||
* !!!!! DO NOT EDIT es.h - EDIT es.h.txt INSTEAD !!!!!!!
|
||||
*
|
||||
* In order to make translations easier es.h.txt is parsed and national
|
||||
@@ -33,7 +31,8 @@
|
||||
*
|
||||
* !!!!! DO NOT EDIT es.h - EDIT es.h.txt INSTEAD !!!!!!!
|
||||
*/
|
||||
/* Formatting octal codes available in TR_ strings:
|
||||
|
||||
/* Formatting octal codes available in TR_ strings:
|
||||
* \037\x -sets LCD x-coord (x value in octal)
|
||||
* \036 -newline
|
||||
* \035 -horizontal tab (ARM only)
|
||||
@@ -43,14 +42,6 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// NON ZERO TERMINATED STRINGS
|
||||
#define LEN_OFFON "\003"
|
||||
#define TR_OFFON "OFF""ON\0"
|
||||
@@ -385,7 +376,7 @@
|
||||
#define LEN_VUNITSSYSTEM TR("\006", "\010")
|
||||
#define TR_VUNITSSYSTEM TR("Metric""Imper.", "Metric\0 ""Imperial")
|
||||
#define LEN_VTELEMUNIT "\003"
|
||||
#define TR_VTELEMUNIT "-\0 ""V\0 ""A\0 ""mA\0""kts""m/s""f/s""kmh""mph""m\0 ""ft\0""@C\0""@F\0""%\0 ""mAh""W\0 ""dB\0""rpm""g\0 ""@\0 ""ml\0""fOz"
|
||||
#define TR_VTELEMUNIT "-\0 ""V\0 ""A\0 ""mA\0""kts""m/s""f/s""kmh""mph""m\0 ""ft\0""@C\0""@F\0""%\0 ""mAh""W\0 ""mW\0""dB\0""rpm""g\0 ""@\0 ""ml\0""fOz"
|
||||
#else
|
||||
#if defined(IMPERIAL_UNITS)
|
||||
#define LENGTH_UNIT LENGTH_UNIT_IMP
|
||||
@@ -1129,3 +1120,13 @@
|
||||
#define ZSTR_BATT2_CONSUMPTION "RB2C"
|
||||
#define ZSTR_RB_STATE "RBS"
|
||||
#define ZSTR_CHANS_STATE "RBCS"
|
||||
#define ZSTR_RX_RSSI1 "1RSS"
|
||||
#define ZSTR_RX_RSSI2 "2RSS"
|
||||
#define ZSTR_RX_QUALITY "RQly"
|
||||
#define ZSTR_RX_SNR "RSNR"
|
||||
#define ZSTR_ANTENNA "ANT"
|
||||
#define ZSTR_RF_MODE "RFMD"
|
||||
#define ZSTR_TX_POWER "TPWR"
|
||||
#define ZSTR_TX_RSSI "TRSS"
|
||||
#define ZSTR_TX_QUALITY "TQly"
|
||||
#define ZSTR_TX_SNR "TSNR"
|
||||
@@ -1,16 +1,12 @@
|
||||
/*
|
||||
* Authors (alphabetical order)
|
||||
* - Bertrand Songis <bsongis@gmail.com>
|
||||
* - Bernet Andre <bernet.andre@gmail.com>
|
||||
* - Kjell Kernen <kjell.kernen@gmail.com>
|
||||
* - Martin Hotar <mhotar@gmail.com>
|
||||
* - Romolo Manfredini <romolo.manfredini@gmail.com>
|
||||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* opentx is based on code named
|
||||
* gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/,
|
||||
* er9x by Erez Raviv: http://code.google.com/p/er9x/,
|
||||
* and the original (and ongoing) project by
|
||||
* Thomas Husterer, th9x: http://code.google.com/p/th9x/
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
@@ -21,9 +17,11 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
// FI translations author: who?
|
||||
|
||||
/*
|
||||
* !!!!! DO NOT EDIT fi.h - EDIT fi.h.txt INSTEAD !!!!!!!
|
||||
*
|
||||
* In order to make translations easier fi.h.txt is parsed and national
|
||||
@@ -33,7 +31,9 @@
|
||||
*
|
||||
* !!!!! DO NOT EDIT fi.h - EDIT fi.h.txt INSTEAD !!!!!!!
|
||||
*/
|
||||
/* Formatting octal codes available in TR_ strings:
|
||||
|
||||
/*
|
||||
* Formatting octal codes available in TR_ strings:
|
||||
* \037\x -sets LCD x-coord (x value in octal)
|
||||
* \036 -newline
|
||||
* \035 -horizontal tab (ARM only)
|
||||
@@ -42,15 +42,6 @@
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// NON ZERO TERMINATED STRINGS
|
||||
#define LEN_OFFON "\003"
|
||||
#define TR_OFFON "POI""PÄÄ"
|
||||
@@ -385,7 +376,7 @@
|
||||
#define LEN_VUNITSSYSTEM TR("\006", "\010")
|
||||
#define TR_VUNITSSYSTEM TR("Metric""Imper.", "Metric\0 ""Imperial")
|
||||
#define LEN_VTELEMUNIT "\003"
|
||||
#define TR_VTELEMUNIT "-\0 ""V\0 ""A\0 ""mA\0""kts""m/s""f/s""kmh""mph""m\0 ""ft\0""@C\0""@F\0""%\0 ""mAh""W\0 ""dB\0""rpm""g\0 ""@\0 ""ml\0""fOz"
|
||||
#define TR_VTELEMUNIT "-\0 ""V\0 ""A\0 ""mA\0""kts""m/s""f/s""kmh""mph""m\0 ""ft\0""@C\0""@F\0""%\0 ""mAh""W\0 ""mW\0""dB\0""rpm""g\0 ""@\0 ""ml\0""fOz"
|
||||
#else
|
||||
#if defined(IMPERIAL_UNITS)
|
||||
#define LENGTH_UNIT LENGTH_UNIT_IMP
|
||||
@@ -1129,3 +1120,13 @@
|
||||
#define ZSTR_BATT2_CONSUMPTION "RB2C"
|
||||
#define ZSTR_RB_STATE "RBS"
|
||||
#define ZSTR_CHANS_STATE "RBCS"
|
||||
#define ZSTR_RX_RSSI1 "1RSS"
|
||||
#define ZSTR_RX_RSSI2 "2RSS"
|
||||
#define ZSTR_RX_QUALITY "RQly"
|
||||
#define ZSTR_RX_SNR "RSNR"
|
||||
#define ZSTR_ANTENNA "ANT"
|
||||
#define ZSTR_RF_MODE "RFMD"
|
||||
#define ZSTR_TX_POWER "TPWR"
|
||||
#define ZSTR_TX_RSSI "TRSS"
|
||||
#define ZSTR_TX_QUALITY "TQly"
|
||||
#define ZSTR_TX_SNR "TSNR"
|
||||
@@ -1,13 +1,12 @@
|
||||
/*
|
||||
* Authors (alphabetical order)
|
||||
* - Andre Bernet <bernet.andre@gmail.com>
|
||||
* - Bertrand Songis <bsongis@gmail.com>
|
||||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* opentx is based on code named
|
||||
* gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/,
|
||||
* er9x by Erez Raviv: http://code.google.com/p/er9x/,
|
||||
* and the original (and ongoing) project by
|
||||
* Thomas Husterer, th9x: http://code.google.com/p/th9x/
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
@@ -18,9 +17,11 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
// FR translations author: Andre Bernet <bernet.andre@gmail.com>
|
||||
|
||||
/*
|
||||
* !!!!! DO NOT EDIT fr.h - EDIT fr.h.txt INSTEAD !!!!!!!
|
||||
*
|
||||
* In order to make translations easier fr.h.txt is parsed and national
|
||||
@@ -30,7 +31,9 @@
|
||||
*
|
||||
* !!!!! DO NOT EDIT fr.h - EDIT fr.h.txt INSTEAD !!!!!!!
|
||||
*/
|
||||
/* Formatting octal codes available in TR_ strings:
|
||||
|
||||
/*
|
||||
* Formatting octal codes available in TR_ strings:
|
||||
* \037\x -sets LCD x-coord (x value in octal)
|
||||
* \036 -newline
|
||||
* \035 -horizontal tab (ARM only)
|
||||
@@ -39,18 +42,6 @@
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// NON ZERO TERMINATED STRINGS
|
||||
#define LEN_OFFON "\003"
|
||||
#define TR_OFFON "OFF""ON\0"
|
||||
@@ -387,7 +378,7 @@
|
||||
#define LEN_VUNITSSYSTEM TR("\006", "\012")
|
||||
#define TR_VUNITSSYSTEM TR("Métr.\0""Impér.", "Métriques\0""Impériales")
|
||||
#define LEN_VTELEMUNIT "\003"
|
||||
#define TR_VTELEMUNIT "-\0 ""V\0 ""A\0 ""mA\0""kts""m/s""f/s""kmh""mph""m\0 ""ft\0""@C\0""@F\0""%\0 ""mAh""W\0 ""dB\0""rpm""g\0 ""@\0 ""ml\0""fOz"
|
||||
#define TR_VTELEMUNIT "-\0 ""V\0 ""A\0 ""mA\0""kts""m/s""f/s""kmh""mph""m\0 ""ft\0""@C\0""@F\0""%\0 ""mAh""W\0 ""mW\0""dB\0""rpm""g\0 ""@\0 ""ml\0""fOz"
|
||||
#else
|
||||
#if defined(IMPERIAL_UNITS)
|
||||
#define LENGTH_UNIT LENGTH_UNIT_IMP
|
||||
@@ -1159,3 +1150,13 @@
|
||||
#define ZSTR_BATT2_CONSUMPTION "RB2C"
|
||||
#define ZSTR_RB_STATE "RBS"
|
||||
#define ZSTR_CHANS_STATE "RBCS"
|
||||
#define ZSTR_RX_RSSI1 "1RSS"
|
||||
#define ZSTR_RX_RSSI2 "2RSS"
|
||||
#define ZSTR_RX_QUALITY "RQly"
|
||||
#define ZSTR_RX_SNR "RSNR"
|
||||
#define ZSTR_ANTENNA "ANT"
|
||||
#define ZSTR_RF_MODE "RFMD"
|
||||
#define ZSTR_TX_POWER "TPWR"
|
||||
#define ZSTR_TX_RSSI "TRSS"
|
||||
#define ZSTR_TX_QUALITY "TQly"
|
||||
#define ZSTR_TX_SNR "TSNR"
|
||||
+1171
-1173
File diff suppressed because it is too large
Load Diff
@@ -1,29 +1,12 @@
|
||||
|
||||
/*
|
||||
* Authors (alphabetical order)
|
||||
* - Andre Bernet <bernet.andre@gmail.com>
|
||||
* - Andreas Weitl
|
||||
* - Bertrand Songis <bsongis@gmail.com>
|
||||
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||
* - Cameron Weeks <th9xer@gmail.com>
|
||||
* - Erez Raviv
|
||||
* - Gabriel Birkus
|
||||
* - Jean-Pierre Parisy
|
||||
* - Jean-Pierre van Melis
|
||||
* - Karl Szmutny
|
||||
* - Michael Blandford
|
||||
* - Michal Hlavinka
|
||||
* - Pat Mackenzie
|
||||
* - Philip Moss
|
||||
* - Rob Thomson
|
||||
* - Romolo Manfredini <romolo.manfredini@gmail.com>
|
||||
* - Thomas Husterer
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* opentx is based on code named
|
||||
* gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/,
|
||||
* er9x by Erez Raviv: http://code.google.com/p/er9x/,
|
||||
* and the original (and ongoing) project by
|
||||
* Thomas Husterer, th9x: http://code.google.com/p/th9x/
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
@@ -34,6 +17,11 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
// NL translations author: who?
|
||||
|
||||
/*
|
||||
* !!!!! DO NOT EDIT nl.h - EDIT nl.h.txt INSTEAD !!!!!!!
|
||||
*
|
||||
* In order to make translations easier nl.h.txt is parsed and national
|
||||
@@ -43,9 +31,8 @@
|
||||
* !!!!! DO NOT EDIT nl.h - EDIT nl.h.txt INSTEAD !!!!!!!
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* Formatting octal codes available in TR_ strings:
|
||||
/*
|
||||
* Formatting octal codes available in TR_ strings:
|
||||
* \037\x -sets LCD x-coord (x value in octal)
|
||||
* \036 -newline
|
||||
* \035 -horizontal tab (ARM only)
|
||||
@@ -53,6 +40,8 @@
|
||||
* \0 -ends current string
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// NON ZERO TERMINATED STRINGS
|
||||
#define LEN_OFFON "\003"
|
||||
#define TR_OFFON "UIT""AAN"
|
||||
@@ -390,7 +379,7 @@
|
||||
#define LEN_VUNITSSYSTEM TR("\006", "\010")
|
||||
#define TR_VUNITSSYSTEM TR("Metrs.""Engels", "Metrisch\0 ""Engels\0 ")
|
||||
#define LEN_VTELEMUNIT "\003"
|
||||
#define TR_VTELEMUNIT "-\0 ""V\0 ""A\0 ""mA\0""kts""m/s""f/s""kmh""mph""m\0 ""ft\0""@C\0""@F\0""%\0 ""mAh""W\0 ""dB\0""rpm""g\0 ""@\0 ""ml\0""fOz"
|
||||
#define TR_VTELEMUNIT "-\0 ""V\0 ""A\0 ""mA\0""kts""m/s""f/s""kmh""mph""m\0 ""ft\0""@C\0""@F\0""%\0 ""mAh""W\0 ""mW\0""dB\0""rpm""g\0 ""@\0 ""ml\0""fOz"
|
||||
#else
|
||||
#if defined(IMPERIAL_UNITS)
|
||||
#define LENGTH_UNIT LENGTH_UNIT_IMP
|
||||
@@ -1185,3 +1174,13 @@
|
||||
#define ZSTR_BATT2_CONSUMPTION "RB2C"
|
||||
#define ZSTR_RB_STATE "RBS"
|
||||
#define ZSTR_CHANS_STATE "RBCS"
|
||||
#define ZSTR_RX_RSSI1 "1RSS"
|
||||
#define ZSTR_RX_RSSI2 "2RSS"
|
||||
#define ZSTR_RX_QUALITY "RQly"
|
||||
#define ZSTR_RX_SNR "RSNR"
|
||||
#define ZSTR_ANTENNA "ANT"
|
||||
#define ZSTR_RF_MODE "RFMD"
|
||||
#define ZSTR_TX_POWER "TPWR"
|
||||
#define ZSTR_TX_RSSI "TRSS"
|
||||
#define ZSTR_TX_QUALITY "TQly"
|
||||
#define ZSTR_TX_SNR "TSNR"
|
||||
@@ -1,28 +1,12 @@
|
||||
/*
|
||||
* Authors (alphabetical order)
|
||||
* - Andre Bernet <bernet.andre@gmail.com>
|
||||
* - Andreas Weitl
|
||||
* - Bertrand Songis <bsongis@gmail.com>
|
||||
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||
* - Cameron Weeks <th9xer@gmail.com>
|
||||
* - Erez Raviv
|
||||
* - Gabriel Birkus
|
||||
* - Jean-Pierre Parisy
|
||||
* - Karl Szmutny
|
||||
* - Michael Blandford
|
||||
* - Michal Hlavinka
|
||||
* - Pat Mackenzie
|
||||
* - Philip Moss
|
||||
* - Rob Thomson
|
||||
* - Romolo Manfredini <romolo.manfredini@gmail.com>
|
||||
* - Jacek Drewniak <jpdjpd33@gmail.com>
|
||||
* - Thomas Husterer
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* opentx is based on code named
|
||||
* gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/,
|
||||
* er9x by Erez Raviv: http://code.google.com/p/er9x/,
|
||||
* and the original (and ongoing) project by
|
||||
* Thomas Husterer, th9x: http://code.google.com/p/th9x/
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
@@ -33,6 +17,11 @@
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
// PL translations author: Jacek Drewniak <jpdjpd33@gmail.com>
|
||||
|
||||
/*
|
||||
* !!!!! DO NOT EDIT pl.h - EDIT pl.h.txt INSTEAD !!!!!!!
|
||||
*
|
||||
* In order to make translations easier pl.h.txt is parsed and national
|
||||
@@ -43,9 +32,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* Formatting octal codes available in TR_ strings:
|
||||
/*
|
||||
* Formatting octal codes available in TR_ strings:
|
||||
* \037\x -sets LCD x-coord (x value in octal)
|
||||
* \036 -newline
|
||||
* \035 -horizontal tab (ARM only)
|
||||
@@ -53,6 +41,7 @@
|
||||
* \0 -ends current string
|
||||
*/
|
||||
|
||||
|
||||
// NON ZERO TERMINATED STRINGS
|
||||
#define LEN_OFFON "\003"
|
||||
#define TR_OFFON "WYŁ""ZAŁ"
|
||||
@@ -391,7 +380,7 @@
|
||||
#define LEN_VUNITSSYSTEM TR("\006", "\010") /*8 decimal*/
|
||||
#define TR_VUNITSSYSTEM TR("Metr. ""Imper.", "Metryczn""Imperial")
|
||||
#define LEN_VTELEMUNIT "\003"
|
||||
#define TR_VTELEMUNIT "-\0 ""V\0 ""A\0 ""mA\0""kts""m/s""f/s""kmh""mph""m\0 ""ft\0""@C\0""@F\0""%\0 ""mAh""W\0 ""dB\0""rpm""g\0 ""@\0 ""ml\0""fOz"
|
||||
#define TR_VTELEMUNIT "-\0 ""V\0 ""A\0 ""mA\0""kts""m/s""f/s""kmh""mph""m\0 ""ft\0""@C\0""@F\0""%\0 ""mAh""W\0 ""mW\0""dB\0""rpm""g\0 ""@\0 ""ml\0""fOz"
|
||||
#else
|
||||
#if defined(IMPERIAL_UNITS)
|
||||
#define LENGTH_UNIT LENGTH_UNIT_IMP
|
||||
@@ -1172,3 +1161,13 @@
|
||||
#define ZSTR_BATT2_CONSUMPTION "RB2C"
|
||||
#define ZSTR_RB_STATE "RBS"
|
||||
#define ZSTR_CHANS_STATE "RBCS"
|
||||
#define ZSTR_RX_RSSI1 "1RSS"
|
||||
#define ZSTR_RX_RSSI2 "2RSS"
|
||||
#define ZSTR_RX_QUALITY "RQly"
|
||||
#define ZSTR_RX_SNR "RSNR"
|
||||
#define ZSTR_ANTENNA "ANT"
|
||||
#define ZSTR_RF_MODE "RFMD"
|
||||
#define ZSTR_TX_POWER "TPWR"
|
||||
#define ZSTR_TX_RSSI "TRSS"
|
||||
#define ZSTR_TX_QUALITY "TQly"
|
||||
#define ZSTR_TX_SNR "TSNR"
|
||||
+1126
-1125
File diff suppressed because it is too large
Load Diff
+1187
-1186
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -80,7 +80,7 @@ void varioWakeup()
|
||||
if (isFunctionActive(FUNCTION_VARIO)) {
|
||||
#if defined(AUDIO)
|
||||
cli();
|
||||
int16_t verticalSpeed = frskyData.hub.varioSpeed;
|
||||
int16_t verticalSpeed = telemetryData.hub.varioSpeed;
|
||||
sei();
|
||||
|
||||
#if defined(PCBSTD)
|
||||
@@ -126,7 +126,7 @@ void varioWakeup()
|
||||
|
||||
#elif defined(BUZZER) // && !defined(AUDIO)
|
||||
|
||||
int8_t verticalSpeed = limit((int16_t)-100, (int16_t)(frskyData.hub.varioSpeed/10), (int16_t)+100);
|
||||
int8_t verticalSpeed = limit((int16_t)-100, (int16_t)(telemetryData.hub.varioSpeed/10), (int16_t)+100);
|
||||
|
||||
uint16_t interval;
|
||||
if (verticalSpeed == 0) {
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
# An Debian image for compiling OpenTX 2.2
|
||||
|
||||
FROM debian:jessie
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y \
|
||||
avr-libc \
|
||||
build-essential \
|
||||
cmake \
|
||||
gcc \
|
||||
git \
|
||||
lib32ncurses5 \
|
||||
lib32z1 \
|
||||
libfox-1.6-dev \
|
||||
libsdl1.2-dev \
|
||||
python-qt4 \
|
||||
qt5-default \
|
||||
qtmultimedia5-dev \
|
||||
qttools5-dev \
|
||||
qttools5-dev-tools \
|
||||
software-properties-common \
|
||||
wget
|
||||
|
||||
RUN wget -q https://launchpad.net/gcc-arm-embedded/4.7/4.7-2013-q3-update/+download/gcc-arm-none-eabi-4_7-2013q3-20130916-linux.tar.bz2 && \
|
||||
tar xjf gcc-arm-none-eabi-4_7-2013q3-20130916-linux.tar.bz2 && \
|
||||
mv gcc-arm-none-eabi-4_7-2013q3 /opt/gcc-arm-none-eabi
|
||||
|
||||
RUN wget -q http://ftp.de.debian.org/debian/pool/main/g/gcc-avr/gcc-avr_4.7.2-2_amd64.deb && \
|
||||
wget -q http://ftp.de.debian.org/debian/pool/main/a/avr-libc/avr-libc_1.8.0-2_all.deb && \
|
||||
wget -q http://ftp.de.debian.org/debian/pool/main/b/binutils-avr/binutils-avr_2.24+Atmel3.4.4-1_amd64.deb && \
|
||||
wget -q http://ftp.de.debian.org/debian/pool/main/m/mpclib/libmpc2_0.9-4_amd64.deb && \
|
||||
dpkg -i gcc-avr_4.7.2-2_amd64.deb libmpc2_0.9-4_amd64.deb avr-libc_1.8.0-2_all.deb binutils-avr_2.24+Atmel3.4.4-1_amd64.deb
|
||||
|
||||
VOLUME ["/opentx"]
|
||||
|
||||
ENV PATH $PATH:/opt/gcc-arm-none-eabi/bin:/opentx/code/radio/util
|
||||
ARG OPENTX_VERSION_SUFFIX=
|
||||
ENV OPENTX_VERSION_SUFFIX ${OPENTX_VERSION_SUFFIX}
|
||||
|
||||
Regular → Executable
+82
-37
@@ -2,8 +2,17 @@
|
||||
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import shutil
|
||||
from fwoptions import *
|
||||
|
||||
# Error codes
|
||||
FIRMWARE_SIZE_TOO_BIG = 1
|
||||
COMPILATION_ERROR = 4
|
||||
INVALID_FIRMWARE = 5
|
||||
INVALID_BOARD = 6
|
||||
INVALID_LANGUAGE = 7
|
||||
|
||||
# Board types
|
||||
BOARD_9X = 0
|
||||
BOARD_GRUVIN9X = 1
|
||||
@@ -15,17 +24,18 @@ BOARD_HORUS = 4
|
||||
BOARD_FAMILY_AVR = 0
|
||||
BOARD_FAMILY_ARM = 1
|
||||
|
||||
srcdir = os.path.dirname(os.path.realpath(__file__)) + "/../.."
|
||||
filename = sys.argv[1]
|
||||
if len(sys.argv) != 3:
|
||||
exit(INVALID_FIRMWARE)
|
||||
|
||||
what = sys.argv[1]
|
||||
directory, filename = os.path.split(sys.argv[2])
|
||||
root, ext = os.path.splitext(filename)
|
||||
options = root.split("-")
|
||||
|
||||
if options[0] != "opentx":
|
||||
sys.exit("Invalid firmware");
|
||||
if len(options) < 2 or options[0] != "opentx":
|
||||
exit(INVALID_FIRMWARE)
|
||||
|
||||
filename = "opentx-"
|
||||
optcount = 1
|
||||
|
||||
command_options = {}
|
||||
|
||||
if options[optcount] == "9x":
|
||||
@@ -116,9 +126,23 @@ elif options[optcount] == "horus":
|
||||
board = BOARD_HORUS
|
||||
board_family = BOARD_FAMILY_ARM
|
||||
else:
|
||||
sys.exit("Unknown board")
|
||||
exit(INVALID_BOARD)
|
||||
|
||||
filename += options[optcount]
|
||||
if what == "firmware":
|
||||
if board_family == BOARD_FAMILY_ARM:
|
||||
ext = ".bin"
|
||||
else:
|
||||
ext = ".hex"
|
||||
target = "firmware" + ext
|
||||
filename = "opentx"
|
||||
elif what == "libsimulator":
|
||||
ext = ".so"
|
||||
target = "libopentx-" + options[optcount] + "-simulator.so"
|
||||
filename = "libopentx"
|
||||
else:
|
||||
exit(INVALID_BOARD)
|
||||
|
||||
filename += "-" + options[optcount]
|
||||
optcount += 1
|
||||
|
||||
# The firmware options
|
||||
@@ -135,7 +159,7 @@ for opt, value in firmware_options.items():
|
||||
else:
|
||||
optvalue = value[2]
|
||||
|
||||
if optvalue != None:
|
||||
if optvalue is not None:
|
||||
command_options[value[0]] = optvalue
|
||||
|
||||
# The firmware display language
|
||||
@@ -144,36 +168,57 @@ for key in languages:
|
||||
if key == options[-1]:
|
||||
language = key
|
||||
if not language:
|
||||
sys.exit("Invalid language")
|
||||
exit(INVALID_LANGUAGE)
|
||||
command_options["TRANSLATIONS"] = language.upper()
|
||||
filename += "-" + language
|
||||
|
||||
if board_family == BOARD_FAMILY_ARM:
|
||||
ext = ".bin"
|
||||
else:
|
||||
ext = ".hex"
|
||||
filename += ext
|
||||
firmware = "firmware" + ext
|
||||
filename += "-" + language + ext
|
||||
srcdir = os.path.dirname(os.path.realpath(__file__)) + "/../.."
|
||||
path = os.path.join(directory, filename)
|
||||
outpath = path + ".out"
|
||||
errpath = path + ".err"
|
||||
|
||||
# Launch CMake
|
||||
cmd = "cmake"
|
||||
for opt, value in command_options.items():
|
||||
cmd += " -D%s=%s" % (opt, value)
|
||||
cmd += " " + srcdir
|
||||
if "OPENTX_VERSION_SUFFIX" in os.environ:
|
||||
cmd += ' -DVERSION_SUFFIX="%s"' % os.environ["OPENTX_VERSION_SUFFIX"]
|
||||
print cmd
|
||||
os.system(cmd)
|
||||
if os.path.isfile(errpath):
|
||||
exit(COMPILATION_ERROR)
|
||||
|
||||
# Launch make firmware
|
||||
cmd = "make firmware"
|
||||
os.system(cmd)
|
||||
if not os.path.isfile(path):
|
||||
# Launch CMake
|
||||
cmd = ["cmake"]
|
||||
for opt, value in command_options.items():
|
||||
cmd.append("-D%s=%s" % (opt, value))
|
||||
if "OPENTX_VERSION_SUFFIX" in os.environ:
|
||||
cmd.append('-DVERSION_SUFFIX="%s"' % os.environ["OPENTX_VERSION_SUFFIX"])
|
||||
cmd.append(srcdir)
|
||||
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
output, error = proc.communicate()
|
||||
if proc.returncode == 0:
|
||||
file(outpath, "a").write(output + error)
|
||||
else:
|
||||
file(errpath, "w").write(output + error)
|
||||
exit(COMPILATION_ERROR)
|
||||
|
||||
# Check binary size
|
||||
if board_family == BOARD_FAMILY_ARM:
|
||||
size = os.stat(firmware).st_size
|
||||
else:
|
||||
os.system("avr-size -A %s | grep Total | cut -f2- -d \" \" > ./size" % firmware)
|
||||
size = file("./size").read().strip()
|
||||
if int(size) > maxsize:
|
||||
exit("Invalid size")
|
||||
# Launch make
|
||||
cmd = ["make", what]
|
||||
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
output, error = proc.communicate()
|
||||
if proc.returncode == 0:
|
||||
file(outpath, "a").write(output + error)
|
||||
else:
|
||||
file(errpath, "w").write(output + error)
|
||||
exit(COMPILATION_ERROR)
|
||||
|
||||
if what == "firmware":
|
||||
# Check binary size
|
||||
if board_family == BOARD_FAMILY_ARM:
|
||||
size = os.stat(target).st_size
|
||||
else:
|
||||
size = subprocess.check_output('avr-size -A %s | grep Total | cut -f2- -d " "' % target, shell=True)
|
||||
size = int(size.strip())
|
||||
if size > maxsize:
|
||||
exit(FIRMWARE_SIZE_TOO_BIG)
|
||||
|
||||
|
||||
# Copy binary to the binaries directory
|
||||
shutil.copyfile(target, path)
|
||||
|
||||
print filename
|
||||
exit(0)
|
||||
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
index = -1
|
||||
size = None
|
||||
|
||||
options = sys.argv[1:]
|
||||
srcdir = os.path.dirname(os.path.realpath(__file__)) + "/../.."
|
||||
buildir = os.getcwd()
|
||||
|
||||
while 1:
|
||||
sys.stdout.flush()
|
||||
index += 1
|
||||
|
||||
os.chdir(srcdir)
|
||||
cmd = ["git", "reset", "--hard", "FETCH_HEAD~%d" % index]
|
||||
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
output, error = proc.communicate()
|
||||
if proc.returncode != 0:
|
||||
print "HEAD~%d git reset failed" % index
|
||||
continue
|
||||
|
||||
os.chdir(buildir)
|
||||
cmd = ["cmake"] + options + [srcdir]
|
||||
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
output, error = proc.communicate()
|
||||
if proc.returncode != 0:
|
||||
print "HEAD~%d cmake failed" % index
|
||||
continue
|
||||
|
||||
cmd = ["make", "-j4", "firmware"]
|
||||
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
output, error = proc.communicate()
|
||||
if proc.returncode != 0:
|
||||
print "HEAD~%d make firmware failed" % index
|
||||
continue
|
||||
|
||||
if os.path.isfile("firmware.bin"):
|
||||
oldsize = os.stat("firmware.bin").st_size
|
||||
else:
|
||||
oldsize = int(subprocess.check_output('avr-size -A firmware.hex | grep Total | cut -f2- -d " "', shell=True))
|
||||
if size:
|
||||
if size > oldsize:
|
||||
print "HEAD~%d %d: increase by %d bytes" % (index-1, size, size-oldsize)
|
||||
elif size < oldsize:
|
||||
print "HEAD~%d %d: decrease by %d bytes" % (index-1, size, oldsize-size)
|
||||
else:
|
||||
print "HEAD~%d %d" % (index-1, size)
|
||||
size = oldsize
|
||||
|
||||
|
||||
Regular → Executable
Regular → Executable
+59
-15
@@ -12,33 +12,77 @@ if sys.platform == "darwin":
|
||||
|
||||
|
||||
structs = []
|
||||
extrastructs = []
|
||||
|
||||
def build_struct(cursor, anonymousUnion=False):
|
||||
if not anonymousUnion:
|
||||
structs.append(cursor.spelling)
|
||||
print("template <class A, class B>\nvoid copy%s(A * dest, B * src)\n{" % cursor.spelling)
|
||||
|
||||
def build_struct(cursor):
|
||||
structs.append(cursor.spelling)
|
||||
print("template <class A, class B>\nvoid copy%s(A * dest, B * src)\n{" % cursor.spelling)
|
||||
for c in cursor.get_children():
|
||||
if c.kind == clang.cindex.CursorKind.FIELD_DECL:
|
||||
if c.type.get_array_size() > 0:
|
||||
if c.type.get_array_element_type().spelling in structs:
|
||||
print(" for (int i=0; i<%d; i++) {" % c.type.get_array_size())
|
||||
print(" copy%s(&dest->%s[i], &src->%s[i]);" % (c.type.get_array_element_type().spelling, c.spelling, c.spelling))
|
||||
print(" }")
|
||||
if c.kind == clang.cindex.CursorKind.UNION_DECL:
|
||||
if c.spelling:
|
||||
raise "Cannot handle non anonymous unions"
|
||||
|
||||
copiedUnionMember = False
|
||||
for uc in c.get_children():
|
||||
if not uc.spelling or uc.kind == clang.cindex.CursorKind.PACKED_ATTR:
|
||||
# Ignore
|
||||
pass
|
||||
else:
|
||||
print(" memcpy(dest->%s, src->%s, sizeof(dest->%s));" % (c.spelling, c.spelling, c.spelling))
|
||||
elif c.type.get_declaration().spelling in structs:
|
||||
print(" copy%s(&dest->%s, &src->%s);" % (c.type.get_declaration().spelling, c.spelling, c.spelling))
|
||||
else:
|
||||
print(" dest->%s = src->%s;" % (c.spelling, c.spelling))
|
||||
print("}\n")
|
||||
# per default we copy only the first member of a union and warn if there are more
|
||||
# members (declare the other members NOBACKUP)
|
||||
if copiedUnionMember:
|
||||
print ("Warning more than one union member (%s) in anynomous union inside struct %s, consider NOBACKUP statements" % (uc.spelling, cursor.spelling), file=sys.stderr)
|
||||
else:
|
||||
copy_decl(uc, uc.spelling)
|
||||
copiedUnionMember = True
|
||||
|
||||
elif c.kind == clang.cindex.CursorKind.FIELD_DECL:
|
||||
copy_decl(c, c.spelling)
|
||||
|
||||
|
||||
if not anonymousUnion:
|
||||
print("}\n")
|
||||
|
||||
def build(cursor):
|
||||
result = []
|
||||
for c in cursor.get_children():
|
||||
if c.kind == clang.cindex.CursorKind.STRUCT_DECL:
|
||||
build_struct(c)
|
||||
for c, spelling in extrastructs:
|
||||
print("template <class A, class B>\nvoid copy%s(A * dest, B * src)\n{" % spelling)
|
||||
build_struct(c, True)
|
||||
print ("}\n")
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def copy_decl(c, spelling):
|
||||
childs = [ch for ch in c.get_children()]
|
||||
if c.type.get_array_size() > 0:
|
||||
if c.type.get_array_element_type().spelling in structs:
|
||||
print(" for (int i=0; i<%d; i++) {" % c.type.get_array_size())
|
||||
print(" copy%s(&dest->%s[i], &src->%s[i]);" % (c.type.get_array_element_type().spelling, spelling, spelling))
|
||||
print(" }")
|
||||
else:
|
||||
print(" memcpy(dest->%s, src->%s, sizeof(dest->%s));" % (spelling, spelling, spelling))
|
||||
elif c.type.kind == clang.cindex.TypeKind.UNEXPOSED and len(childs)==1 and childs[0].kind == clang.cindex.CursorKind.STRUCT_DECL:
|
||||
# inline declared structs
|
||||
if c.semantic_parent.spelling:
|
||||
spellingFunc = c.semantic_parent.spelling + "_" + spelling
|
||||
else:
|
||||
spellingFunc = c.semantic_parent.semantic_parent.spelling + "_" + spelling
|
||||
|
||||
extrastructs.append((childs[0], spellingFunc))
|
||||
print(" copy%s(&dest->%s, &src->%s);" % (spellingFunc, spelling, spelling))
|
||||
|
||||
elif c.type.get_declaration().spelling in structs:
|
||||
print(" copy%s(&dest->%s, &src->%s);" % (c.type.get_declaration().spelling, spelling, spelling))
|
||||
else:
|
||||
print(" dest->%s = src->%s;" % (spelling, spelling))
|
||||
|
||||
|
||||
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()))
|
||||
|
||||
|
||||
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user