diff --git a/.travis.yml b/.travis.yml index 4b5ca6a54be..ca3b3b153e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,4 +11,4 @@ install: script: - radio/util/commit-tests.sh - - mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Debug ../companion/src && cmake --build . + - mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Debug -DPCB=TARANIS .. && cmake --build . diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000000..23d414cad42 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,21 @@ +project(OpenTX) + +set(VERSION_MAJOR "2") +set(VERSION_MINOR "2") +set(VERSION_REVISION "0") +set(VERSION_SUFFIX $ENV{OPENTX_VERSION_SUFFIX}) +set(VERSION_FAMILY ${VERSION_MAJOR}.${VERSION_MINOR}) +set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REVISION}${VERSION_SUFFIX}) +message(STATUS "OpenTX ${VERSION}") + +cmake_minimum_required(VERSION 2.8) + +set(RADIO_DIRECTORY ${PROJECT_SOURCE_DIR}/radio) +set(RADIO_SRC_DIRECTORY ${RADIO_DIRECTORY}/src) +set(COMPANION_SRC_DIRECTORY ${PROJECT_SOURCE_DIR}/companion/src) + +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake) +include(Bitmaps) + +add_subdirectory(${RADIO_SRC_DIRECTORY}) +add_subdirectory(${COMPANION_SRC_DIRECTORY}) diff --git a/cmake/Bitmaps.cmake b/cmake/Bitmaps.cmake new file mode 100644 index 00000000000..9702c8e0a6b --- /dev/null +++ b/cmake/Bitmaps.cmake @@ -0,0 +1,25 @@ +macro(add_bitmaps_target targetname filter width format) + file(GLOB bitmaps ${filter}) + foreach(bitmap ${bitmaps}) + get_filename_component(target ${bitmap} NAME_WE) + set(target ${target}.lbm) + add_custom_command( + OUTPUT ${target} + COMMAND python ${RADIO_DIRECTORY}/util/img2lbm.py ${bitmap} ${target} ${width} ${format} + DEPENDS ${bitmap} + ) + list(APPEND bitmaps_files ${target}) + endforeach() + add_custom_target(${targetname} DEPENDS ${bitmaps_files}) +endmacro(add_bitmaps_target) + +macro(add_truetype_font_target radio name font size) + set(target ${RADIO_SRC_DIRECTORY}/fonts/${radio}/font_${name}) + add_custom_command( + OUTPUT ${target}.png + OUTPUT ${target}.specs + COMMAND ${RADIO_DIRECTORY}/util/font2png.py ${font} ${size} False ${target} + WORKING_DIRECTORY ${RADIO_SRC_DIRECTORY} + ) + add_custom_target(ttf_${radio}_${name} DEPENDS ${target}.png ${target}.specs) +endmacro(add_truetype_font_target) \ No newline at end of file diff --git a/companion/src/cmake/FindLupdate.cmake b/cmake/FindLupdate.cmake similarity index 100% rename from companion/src/cmake/FindLupdate.cmake rename to cmake/FindLupdate.cmake diff --git a/companion/src/cmake/FindPhonon.cmake b/cmake/FindPhonon.cmake similarity index 100% rename from companion/src/cmake/FindPhonon.cmake rename to cmake/FindPhonon.cmake diff --git a/companion/src/cmake/FindSdl.cmake b/cmake/FindSdl.cmake similarity index 100% rename from companion/src/cmake/FindSdl.cmake rename to cmake/FindSdl.cmake diff --git a/companion/src/cmake/FindXercesC.cmake b/cmake/FindXercesC.cmake similarity index 100% rename from companion/src/cmake/FindXercesC.cmake rename to cmake/FindXercesC.cmake diff --git a/companion/src/cmake/FindXsd.cmake b/cmake/FindXsd.cmake similarity index 100% rename from companion/src/cmake/FindXsd.cmake rename to cmake/FindXsd.cmake diff --git a/cmake/Macros.cmake b/cmake/Macros.cmake new file mode 100644 index 00000000000..4ca5ad9b469 --- /dev/null +++ b/cmake/Macros.cmake @@ -0,0 +1,38 @@ +macro(today RESULT) + if(WIN32) + execute_process(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE ${RESULT}) + string(REGEX REPLACE "(..)/(..)/(....).*" "\\1.\\2.\\3" ${RESULT} ${${RESULT}}) + elseif(UNIX) + execute_process(COMMAND "date" "+%Y-%m-%d" OUTPUT_VARIABLE ${RESULT}) + string(REGEX REPLACE "(....)-(..)-(..).*" "\\1-\\2-\\3" ${RESULT} ${${RESULT}}) + else(WIN32) + message(SEND_ERROR "date not implemented") + set(${RESULT} 00.00.0000) + endif(WIN32) +endmacro(today) + +macro(now RESULT) + if(WIN32) + execute_process(COMMAND "cmd" " /C time /T" OUTPUT_VARIABLE ${RESULT}) + string(REGEX REPLACE "(..):(..).*" "\\1:\\2:00" ${RESULT} ${${RESULT}}) + elseif(UNIX) + execute_process(COMMAND "date" "+%H:%M:%S" OUTPUT_VARIABLE ${RESULT}) + string(REGEX REPLACE "(..):(..):(..).*" "\\1:\\2:\\3" ${RESULT} ${${RESULT}}) + else(WIN32) + message(SEND_ERROR "time not implemented") + set(${RESULT} 00:00:00) + endif(WIN32) +endmacro(now) + +macro(git_id RESULT) + if(WIN32) + execute_process(COMMAND "cmd" " /C git --git-dir=${PROJECT_SOURCE_DIR}/.git rev-parse HEAD" OUTPUT_VARIABLE ${RESULT}) + string(REGEX REPLACE "(.*)\n" "\\1" ${RESULT} ${${RESULT}}) + elseif(UNIX) + execute_process(COMMAND "git" "--git-dir=${PROJECT_SOURCE_DIR}/.git" "rev-parse" "HEAD" OUTPUT_VARIABLE ${RESULT}) + string(REGEX REPLACE "(.*)\n" "\\1" ${RESULT} ${${RESULT}}) + else(WIN32) + message(SEND_ERROR "Git ID implemented") + set(${RESULT} 0) + endif(WIN32) +endmacro(git_id) diff --git a/companion/src/CMakeLists.txt b/companion/src/CMakeLists.txt index cb27601d16c..02efceffc86 100644 --- a/companion/src/CMakeLists.txt +++ b/companion/src/CMakeLists.txt @@ -1,134 +1,121 @@ -PROJECT( companion ) +include(Macros) -SET(VERSION_MAJOR "2") -SET(VERSION_MINOR "2") -SET(VERSION_REVISION "0") -SET(VERSION_SUFFIX $ENV{OPENTX_VERSION_SUFFIX}) +if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + set(C9X_NAME_SUFFIX ${VERSION_MAJOR}${VERSION_MINOR}) + set(COMPANION_NAME "companion${C9X_NAME_SUFFIX}") + set(SIMULATOR_NAME "simulator${C9X_NAME_SUFFIX}") + set(SIMULATOR_LIB_PATH ${CMAKE_INSTALL_PREFIX}/lib/companion${C9X_NAME_SUFFIX}) +else(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + set(COMPANION_NAME "companion") + set(SIMULATOR_NAME "simulator") +endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + +option(ALLOW_NIGHTLY_BUILDS "Allow nightly builds download / update") # Disabled by default +if(ALLOW_NIGHTLY_BUILDS) + add_definitions(-DALLOW_NIGHTLY_BUILDS) +endif(ALLOW_NIGHTLY_BUILDS) + +option(DEBUG_IMPORT "Turn on debug output for EEPROM import") # Disabled by default +if(DEBUG_IMPORT) + add_definitions(-DDEBUG_MODEL_IMPORT) + message(STATUS "EEPROM import debugging enabled") +endif(DEBUG_IMPORT) + +option(TABLE_LAYOUT "Use QTableWidget for grid layouts") # Disabled by default +if(TABLE_LAYOUT) + add_definitions(-DTABLE_LAYOUT) + message(STATUS "Using QTableWidget") +endif(TABLE_LAYOUT) + +message(STATUS "Looking for XercesC ") +find_package(XercesC) +if(XERCESC_FOUND) + include_directories(${XERCESC_INCLUDE_DIR}) + set(LidarFormat_LIBRAIRIES ${LidarFormat_LIBRAIRIES} ${XERCESC_LIBRARIES}) +else() + message(FATAL_ERROR "XercesC not found! Please set XercesC path ...") +endif() -SET(VERSION_FAMILY ${VERSION_MAJOR}.${VERSION_MINOR}) -SET(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REVISION}${VERSION_SUFFIX}) -MESSAGE(STATUS "OpenTX Companion ${VERSION}") +message(STATUS "Looking for Xsd ") +find_package(Xsd) +if(XSD_FOUND) + include_directories(${XSD_INCLUDE_DIR}) + message("XSD Include Path: " ${XSD_INCLUDE_DIR}) +else() + message(FATAL_ERROR "XSD not found! Please set XSD path ...") +endif() -CMAKE_MINIMUM_REQUIRED( VERSION 2.8.12 ) +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.") +endif() -SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) -include(Macros) +find_package(Qt4 4.8.1 REQUIRED) +set(QT_USE_QTNETWORK True) +set(QT_USE_QTXML True) +include(${QT_USE_FILE}) + +message(STATUS "Looking for PHONON ") +find_package(Phonon) +if(PHONON_FOUND) + include_directories(${PHONO_INCLUDE_DIR}) + message("PHONON Include Path: " ${PHONON_INCLUDE_DIR}) + add_definitions(-DPHONON) +else() + message("PHONON not found!") +endif() -IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") - SET(C9X_NAME_SUFFIX ${VERSION_MAJOR}${VERSION_MINOR}) - SET(COMPANION_NAME "companion${C9X_NAME_SUFFIX}") - SET(SIMULATOR_NAME "simulator${C9X_NAME_SUFFIX}") - SET( SIMULATOR_LIB_PATH ${CMAKE_INSTALL_PREFIX}/lib/companion${C9X_NAME_SUFFIX} ) -ELSE(${CMAKE_SYSTEM_NAME} MATCHES "Linux") - SET(COMPANION_NAME "companion") - SET(SIMULATOR_NAME "simulator") -ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") - -OPTION(ALLOW_NIGHTLY_BUILDS "Allow nightly builds download / update") # Disabled by default -IF(ALLOW_NIGHTLY_BUILDS) - ADD_DEFINITIONS(-DALLOW_NIGHTLY_BUILDS) -ENDIF(ALLOW_NIGHTLY_BUILDS) - -OPTION(DEBUG_IMPORT "Turn on debug output for EEPROM import") # Disabled by default -IF(DEBUG_IMPORT) - ADD_DEFINITIONS( -DDEBUG_MODEL_IMPORT) - MESSAGE( STATUS "EEPROM import debugging enabled" ) -ENDIF(DEBUG_IMPORT) - -OPTION(TABLE_LAYOUT "Use QTableWidget for grid layouts") # Disabled by default -IF(TABLE_LAYOUT) - ADD_DEFINITIONS( -DTABLE_LAYOUT) - MESSAGE( STATUS "Using QTableWidget" ) -ENDIF(TABLE_LAYOUT) - -MESSAGE( STATUS "Looking for XercesC " ) -FIND_PACKAGE(XercesC) -IF ( XERCESC_FOUND ) - INCLUDE_DIRECTORIES( ${XERCESC_INCLUDE_DIR} ) - SET(LidarFormat_LIBRAIRIES ${LidarFormat_LIBRAIRIES} ${XERCESC_LIBRARIES}) -ELSE() - MESSAGE( FATAL_ERROR "XercesC not found! Please set XercesC path ..." ) -ENDIF() - -MESSAGE( STATUS "Looking for Xsd " ) -FIND_PACKAGE(Xsd) -IF ( XSD_FOUND ) - INCLUDE_DIRECTORIES( ${XSD_INCLUDE_DIR} ) - MESSAGE("XSD Include Path: " ${XSD_INCLUDE_DIR} ) -ELSE() - MESSAGE( FATAL_ERROR "XSD not found! Please set XSD path ..." ) -ENDIF() - -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." ) -ENDIF() - -FIND_PACKAGE(Qt4 4.8.1 REQUIRED) -SET( QT_USE_QTNETWORK True ) -SET( QT_USE_QTXML True ) -INCLUDE( ${QT_USE_FILE} ) - -MESSAGE( STATUS "Looking for PHONON " ) -FIND_PACKAGE(Phonon) -IF ( PHONON_FOUND ) - INCLUDE_DIRECTORIES( ${PHONO_INCLUDE_DIR} ) - MESSAGE("PHONON Include Path: " ${PHONON_INCLUDE_DIR} ) - ADD_DEFINITIONS( -DPHONON ) -ELSE() - MESSAGE( "PHONON not found!" ) -ENDIF() - -MESSAGE( STATUS "Looking for QT lupdate " ) -FIND_PACKAGE(Lupdate) -if( LUPDATE_FOUND ) - MESSAGE( "QT lupdate: " ${LUPDATE_EXECUTABLE} ) -ELSE() - MESSAGE( "QT lupdate not found!" ) -ENDIF() - -ADD_DEFINITIONS(-DQXT_STATIC) - -ADD_CUSTOM_COMMAND( +message(STATUS "Looking for QT lupdate ") +find_package(Lupdate) +if(LUPDATE_FOUND) + message("QT lupdate: " ${LUPDATE_EXECUTABLE}) +else() + message("QT lupdate not found!") +endif() + +add_definitions(-DQXT_STATIC) + +add_custom_command( COMMAND ${XSDCXX_EXECUTABLE} cxx-tree --root-element-all --generate-serialization --output-dir ${PROJECT_BINARY_DIR}/ ${PROJECT_SOURCE_DIR}/radio.xsd OUTPUT ${PROJECT_BINARY_DIR}/radio.hxx ${PROJECT_BINARY_DIR}/radio.cxx DEPENDS ${PROJECT_SOURCE_DIR}/radio.xsd ) -IF( MSVC ) - SET(CMAKE_CXX_FLAGS "/EHsc /LD") +if(MSVC) + set(CMAKE_CXX_FLAGS "/EHsc /LD") set(INTTYPES_INCLUDE_OPTION -IC:/Programs/msinttypes) - INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/winbuild C:/Programs/pthreads/Pre-built.2/include C:/Programs/msinttypes) - LINK_DIRECTORIES( C:/Programs/pthreads/Pre-built.2/lib/ ) - SET( PTHREAD_LIBRARY pthreadVC2.lib ) -ELSE( ) - SET( PTHREAD_LIBRARY pthread ) - ADD_DEFINITIONS( -Wall ) - LINK_DIRECTORIES( /usr/local/lib ) -ENDIF( ) - -IF( MSVC ) - MESSAGE( STATUS "Adding include C:/Programs/dirent/include for dirent.h" ) - INCLUDE_DIRECTORIES( C:/Programs/dirent/include ) -ENDIF( ) - -set(RADIO_SRC_DIRECTORY ${PROJECT_SOURCE_DIR}/../../radio/src) -set(SIMU_SRC_DIRECTORY ${PROJECT_SOURCE_DIR}/simulation) -set(COMPANION_SRC_DIRECTORY ${PROJECT_SOURCE_DIR}) + include_directories(${PROJECT_SOURCE_DIR}/winbuild C:/Programs/pthreads/Pre-built.2/include C:/Programs/msinttypes) + link_directories(C:/Programs/pthreads/Pre-built.2/lib/) + set(PTHREAD_LIBRARY pthreadVC2.lib) +else() + set(PTHREAD_LIBRARY pthread) + add_definitions(-Wall) + link_directories(/usr/local/lib) +endif() + +if(MSVC) + message(STATUS "Adding include C:/Programs/dirent/include for dirent.h") + include_directories(C:/Programs/dirent/include) +endif() + +set(RADIO_SRC_DIRECTORY ${PROJECT_SOURCE_DIR}/radio/src) +set(SIMU_SRC_DIRECTORY ${PROJECT_SOURCE_DIR}/companion/src/simulation) +set(COMPANION_SRC_DIRECTORY ${PROJECT_SOURCE_DIR}/companion/src) include_directories( + ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR} - ${PROJECT_SOURCE_DIR}/../.. - ${PROJECT_SOURCE_DIR}/shared + ${COMPANION_SRC_DIRECTORY} + ${COMPANION_SRC_DIRECTORY}/shared ${SIMU_SRC_DIRECTORY} ${XSD_INCLUDE_DIR} - ${PROJECT_SOURCE_DIR}/qxtcommandoptions + ${COMPANION_SRC_DIRECTORY}/qxtcommandoptions ) add_subdirectory(shared) @@ -156,7 +143,7 @@ set(common_SRCS firmwares/opentx/opentxinterface.cpp file.cpp appdata.cpp -) + ) qt4_wrap_cpp(common_SRCS) @@ -201,7 +188,7 @@ set(companion_SRCS radionotfound.cpp wizarddata.cpp wizarddialog.cpp -) + ) set(companion_MOC_HDRS apppreferencesdialog.h @@ -233,7 +220,7 @@ set(companion_MOC_HDRS wizarddialog.h modelprinter.h multimodelprinter.h -) + ) set(companion_UIS mdichild.ui @@ -253,51 +240,51 @@ set(companion_UIS flashfirmwaredialog.ui flasheepromdialog.ui radionotfound.ui -) + ) set(companion_RCS companion.qrc ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc -) + ) + +today(DATE) +now(TIME) -TODAY(DATE) -NOW(TIME) - -CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h @ONLY) -CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/translations.qrc.in ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc @ONLY) -CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/companion.desktop.in ${CMAKE_CURRENT_BINARY_DIR}/companion.desktop @ONLY) -CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/simulator.desktop.in ${CMAKE_CURRENT_BINARY_DIR}/simulator.desktop @ONLY) - -IF( WIN32 ) - SET( companion_SRCS ${companion_SRCS} icon.rc ) - IF ( NOT MSVC ) - SET(CMAKE_EXE_LINKER_FLAGS -mwindows) - ENDIF( ) -ENDIF( ) - -INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} ) -INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR} ) - -SET( LANGUAGES he pl pt ru de fr es it sv cs fi nl) -FOREACH( language ${LANGUAGES} ) - SET( companion_TS ${companion_TS} translations/companion_${language}.ts ) -ENDFOREACH( language ) - -set( companion_SRCS ${companion_SRCS} ) -QT4_WRAP_UI( companion_SRCS ${companion_UIS} ) -QT4_WRAP_CPP( companion_SRCS ${companion_MOC_HDRS} ) -QT4_ADD_TRANSLATION( companion_QM ${companion_TS} ) -QT4_ADD_RESOURCES( companion_SRCS ${companion_RCS} ) - -ADD_DEFINITIONS( -DQT_TRANSLATIONS_DIR="${QT_TRANSLATIONS_DIR}" ) - -IF( APPLE ) - ADD_EXECUTABLE( ${COMPANION_NAME} MACOSX_BUNDLE ${companion_SRCS} ${companion_QM} ) - # OS X compiler no longer automatically includes /Library/Frameworks in search path - SET( CMAKE_EXE_LINKER_FLAGS -F/Library/Frameworks ) -ELSE( ) - ADD_EXECUTABLE( ${COMPANION_NAME} WIN32 ${companion_SRCS} ${companion_QM} ) -ENDIF( ) +configure_file(${COMPANION_SRC_DIRECTORY}/version.h.in ${CMAKE_BINARY_DIR}/version.h @ONLY) +configure_file(${COMPANION_SRC_DIRECTORY}/translations.qrc.in ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc @ONLY) +configure_file(${COMPANION_SRC_DIRECTORY}/companion.desktop.in ${CMAKE_CURRENT_BINARY_DIR}/companion.desktop @ONLY) +configure_file(${COMPANION_SRC_DIRECTORY}/simulator.desktop.in ${CMAKE_CURRENT_BINARY_DIR}/simulator.desktop @ONLY) + +if(WIN32) + set(companion_SRCS ${companion_SRCS} icon.rc) + if(NOT MSVC) + set(CMAKE_EXE_LINKER_FLAGS -mwindows) + endif() +endif() + +include_directories(${CMAKE_BINARY_DIR}) +include_directories(${CMAKE_SOURCE_DIR}) + +set(LANGUAGES he pl pt ru de fr es it sv cs fi nl) +foreach(language ${LANGUAGES}) + set(companion_TS ${companion_TS} translations/companion_${language}.ts) +endforeach(language) + +set(companion_SRCS ${companion_SRCS}) +qt4_wrap_ui(companion_SRCS ${companion_UIS}) +qt4_wrap_cpp(companion_SRCS ${companion_MOC_HDRS}) +qt4_add_translation(companion_QM ${companion_TS}) +qt4_add_resources(companion_SRCS ${companion_RCS}) + +add_definitions(-DQT_TRANSLATIONS_DIR="${QT_TRANSLATIONS_DIR}") + +if(APPLE) + add_executable(${COMPANION_NAME} MACOSX_BUNDLE ${companion_SRCS} ${companion_QM}) + # OS X compiler no longer automatically includes /Library/Frameworks in search path + set(CMAKE_EXE_LINKER_FLAGS -F/Library/Frameworks) +else() + add_executable(${COMPANION_NAME} WIN32 ${companion_SRCS} ${companion_QM}) +endif() target_link_libraries(${COMPANION_NAME} generaledit modeledit simulation common qcustomplot shared ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY} ${XERCESC_LIBRARY} ${PTHREAD_LIBRARY} ${SDL_LIBRARY} ${PHONON_LIBS}) @@ -307,14 +294,14 @@ set(simu_SRCS modeledit/node.cpp modeledit/edge.cpp # TODO not needed simulator.cpp -) + ) set(simu_MOC_HDRS modeledit/node.h -) + ) -set( simu_SRCS ${simu_SRCS} ) -qt4_wrap_cpp(simu_SRCS ${simu_MOC_HDRS} ) +set(simu_SRCS ${simu_SRCS}) +qt4_wrap_cpp(simu_SRCS ${simu_MOC_HDRS}) qt4_add_resources(simu_SRCS companion.qrc) # TODO not needed if(WIN32) @@ -331,136 +318,136 @@ target_link_libraries(${SIMULATOR_NAME} simulation common qxtcommandoptions ${QT ############# Packaging #################### -IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") - INSTALL( TARGETS ${COMPANION_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin ) - INSTALL( TARGETS ${SIMULATOR_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin ) - INSTALL( FILES ${CMAKE_CURRENT_BINARY_DIR}/companion.desktop DESTINATION share/applications RENAME companion${C9X_NAME_SUFFIX}.desktop) - INSTALL( FILES ${CMAKE_CURRENT_BINARY_DIR}/simulator.desktop DESTINATION share/applications RENAME simulator${C9X_NAME_SUFFIX}.desktop) - INSTALL( FILES images/linuxicons/16x16/companion.png DESTINATION /usr/share/icons/hicolor/16x16/apps RENAME companion${C9X_NAME_SUFFIX}.png ) - INSTALL( FILES images/linuxicons/22x22/companion.png DESTINATION /usr/share/icons/hicolor/22x22/apps RENAME companion${C9X_NAME_SUFFIX}.png ) - INSTALL( FILES images/linuxicons/24x24/companion.png DESTINATION /usr/share/icons/hicolor/24x24/apps RENAME companion${C9X_NAME_SUFFIX}.png ) - INSTALL( FILES images/linuxicons/32x32/companion.png DESTINATION /usr/share/icons/hicolor/32x32/apps RENAME companion${C9X_NAME_SUFFIX}.png ) - INSTALL( FILES images/linuxicons/48x48/companion.png DESTINATION /usr/share/icons/hicolor/48x48/apps RENAME companion${C9X_NAME_SUFFIX}.png ) - INSTALL( FILES images/linuxicons/128x128/companion.png DESTINATION /usr/share/icons/hicolor/128x128/apps RENAME companion${C9X_NAME_SUFFIX}.png ) - INSTALL( FILES images/linuxicons/256x256/companion.png DESTINATION /usr/share/icons/hicolor/256x256/apps RENAME companion${C9X_NAME_SUFFIX}.png ) - INSTALL( FILES images/linuxicons/512x512/companion.png DESTINATION /usr/share/icons/hicolor/512x512/apps RENAME companion${C9X_NAME_SUFFIX}.png ) - INSTALL( FILES images/linuxicons/scalable/companion.svg DESTINATION /usr/share/icons/hicolor/scalable/apps RENAME companion${C9X_NAME_SUFFIX}.svg ) - 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 (${CMAKE_SYSTEM_NAME} MATCHES "Linux") - INSTALL( TARGETS ${COMPANION_NAME} DESTINATION ${QT_BINARY_DIR} ) -ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") - -IF( WIN32 ) - IF( MSVC ) - SET(COMPANION_NSI_IN_FILE companion-vs.nsi.in) - SET(SIMULATOR_NSI_IN_FILE simulator-vs.nsi.in) - ELSE( ) - SET(COMPANION_NSI_IN_FILE companion-msys.nsi.in) - SET(SIMULATOR_NSI_IN_FILE simulator-msys.nsi.in) - ENDIF( ) - - SET( SYSDIR "$ENV{windir}/system32" ) - CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/../targets/windows/${COMPANION_NSI_IN_FILE} ${CMAKE_CURRENT_BINARY_DIR}/companion.nsi @ONLY) - CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/../targets/windows/${SIMULATOR_NSI_IN_FILE} ${CMAKE_CURRENT_BINARY_DIR}/simulator.nsi @ONLY) - - FIND_PROGRAM(NSIS_EXE makensis.exe PATHS +if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + install(TARGETS ${COMPANION_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) + install(TARGETS ${SIMULATOR_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/companion.desktop DESTINATION share/applications RENAME companion${C9X_NAME_SUFFIX}.desktop) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/simulator.desktop DESTINATION share/applications RENAME simulator${C9X_NAME_SUFFIX}.desktop) + install(FILES images/linuxicons/16x16/companion.png DESTINATION /usr/share/icons/hicolor/16x16/apps RENAME companion${C9X_NAME_SUFFIX}.png) + install(FILES images/linuxicons/22x22/companion.png DESTINATION /usr/share/icons/hicolor/22x22/apps RENAME companion${C9X_NAME_SUFFIX}.png) + install(FILES images/linuxicons/24x24/companion.png DESTINATION /usr/share/icons/hicolor/24x24/apps RENAME companion${C9X_NAME_SUFFIX}.png) + install(FILES images/linuxicons/32x32/companion.png DESTINATION /usr/share/icons/hicolor/32x32/apps RENAME companion${C9X_NAME_SUFFIX}.png) + install(FILES images/linuxicons/48x48/companion.png DESTINATION /usr/share/icons/hicolor/48x48/apps RENAME companion${C9X_NAME_SUFFIX}.png) + install(FILES images/linuxicons/128x128/companion.png DESTINATION /usr/share/icons/hicolor/128x128/apps RENAME companion${C9X_NAME_SUFFIX}.png) + install(FILES images/linuxicons/256x256/companion.png DESTINATION /usr/share/icons/hicolor/256x256/apps RENAME companion${C9X_NAME_SUFFIX}.png) + install(FILES images/linuxicons/512x512/companion.png DESTINATION /usr/share/icons/hicolor/512x512/apps RENAME companion${C9X_NAME_SUFFIX}.png) + install(FILES images/linuxicons/scalable/companion.svg DESTINATION /usr/share/icons/hicolor/scalable/apps RENAME companion${C9X_NAME_SUFFIX}.svg) + 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(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + install(TARGETS ${COMPANION_NAME} DESTINATION ${QT_BINARY_DIR}) +endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + +if(WIN32) + if(MSVC) + set(COMPANION_NSI_IN_FILE companion-vs.nsi.in) + set(SIMULATOR_NSI_IN_FILE simulator-vs.nsi.in) + else() + set(COMPANION_NSI_IN_FILE companion-msys.nsi.in) + set(SIMULATOR_NSI_IN_FILE simulator-msys.nsi.in) + endif() + + set(SYSDIR "$ENV{windir}/system32") + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../targets/windows/${COMPANION_NSI_IN_FILE} ${CMAKE_CURRENT_BINARY_DIR}/companion.nsi @ONLY) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../targets/windows/${SIMULATOR_NSI_IN_FILE} ${CMAKE_CURRENT_BINARY_DIR}/simulator.nsi @ONLY) + + find_program(NSIS_EXE makensis.exe PATHS "C:/Program Files/NSIS" "C:/Program Files (x86)/NSIS" "C:/Programs/NSIS" - ) + ) - ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_BINARY_DIR}/companion-windows.exe - COMMAND "${NSIS_EXE}" ARGS companion.nsi - DEPENDS companion simulator opentx-simulators ${PROJECT_BINARY_DIR}/companion.nsi - COMMENT "Companion Windows NSIS Installer") + add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/companion-windows.exe + COMMAND "${NSIS_EXE}" ARGS companion.nsi + DEPENDS companion simulator opentx-simulators ${PROJECT_BINARY_DIR}/companion.nsi + COMMENT "Companion Windows NSIS Installer") - ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_BINARY_DIR}/simulator-install.exe - COMMAND "${NSIS_EXE}" ARGS simulator.nsi - DEPENDS simulator opentx-simulators ${PROJECT_BINARY_DIR}/simulator.nsi - COMMENT "Simulator Windows NSIS Installer") + add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/simulator-install.exe + COMMAND "${NSIS_EXE}" ARGS simulator.nsi + DEPENDS simulator opentx-simulators ${PROJECT_BINARY_DIR}/simulator.nsi + COMMENT "Simulator Windows NSIS Installer") - ADD_CUSTOM_TARGET( installer + add_custom_target(installer DEPENDS ${PROJECT_BINARY_DIR}/companion-windows.exe DEPENDS ${PROJECT_BINARY_DIR}/simulator-windows.exe SOURCES ${PROJECT_BINARY_DIR}/companion.nsi SOURCES ${PROJECT_BINARY_DIR}/simulator.nsi - ) -ENDIF( ) - -IF( APPLE ) - SET(MACOSX_BUNDLE_ICON_FILE iconmac.icns) - IF( CMAKE_GENERATOR STREQUAL Xcode ) - SET( WORK_DIR ${CMAKE_BINARY_DIR}/Debug ) - ELSE( ) - SET( WORK_DIR ${PROJECT_BINARY_DIR} ) - ENDIF() - - ADD_CUSTOM_TARGET( addframeworks - COMMAND mkdir -p companion.app/Contents/Frameworks - COMMAND mkdir -p companion.app/Contents/Resources - COMMAND mkdir -p companion.app/Contents/translations - COMMAND rsync ${PROJECT_SOURCE_DIR}/images/${MACOSX_BUNDLE_ICON_FILE} companion.app/Contents/Resources/${MACOSX_BUNDLE_ICON_FILE} # Copy the icon files - COMMAND rsync -r --exclude=.svn ${PROJECT_SOURCE_DIR}/../targets/mac/qt_menu.nib companion.app/Contents/Resources/ - COMMAND rsync ${PROJECT_BINARY_DIR}/*.qm companion.app/Contents/translations - COMMAND rsync ${PROJECT_BINARY_DIR}/*.qm companion.app/Contents/translations - COMMAND rsync -r ${XSD_INCLUDE_DIR}/.. companion.app/Contents/Frameworks/ - COMMAND rsync -r /Library/Frameworks/SDL.framework companion.app/Contents/Frameworks/ - COMMAND ${QT_BINARY_DIR}/macdeployqt companion.app - COMMAND install_name_tool -change @rpath/SDL.framework/Versions/A/SDL @executable_path/../Frameworks/SDL.framework/Versions/A/SDL companion.app/Contents/MacOS/companion - WORKING_DIRECTORY ${WORK_DIR} - DEPENDS ${COMPANION_NAME} ) - - ADD_CUSTOM_TARGET( makedmg - COMMAND ${QT_BINARY_DIR}/macdeployqt companion.app -dmg -no-plugins - WORKING_DIRECTORY ${WORK_DIR} - DEPENDS addframeworks opentx-simulators-bundle) -ENDIF( ) - -ADD_CUSTOM_TARGET( stamp - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/version.h ${CMAKE_SOURCE_DIR}/../companion.stamp - DEPENDS ${CMAKE_BINARY_DIR}/version.h ) - -IF( LUPDATE_FOUND ) - ADD_CUSTOM_TARGET( translations + ) +endif() + +if(APPLE) + set(MACOSX_BUNDLE_ICON_FILE iconmac.icns) + if(CMAKE_GENERATOR STREQUAL Xcode) + set(WORK_DIR ${CMAKE_BINARY_DIR}/Debug) + else() + set(WORK_DIR ${PROJECT_BINARY_DIR}) + endif() + + add_custom_target(addframeworks + COMMAND mkdir -p companion.app/Contents/Frameworks + COMMAND mkdir -p companion.app/Contents/Resources + COMMAND mkdir -p companion.app/Contents/translations + COMMAND rsync ${PROJECT_SOURCE_DIR}/images/${MACOSX_BUNDLE_ICON_FILE} companion.app/Contents/Resources/${MACOSX_BUNDLE_ICON_FILE} # Copy the icon files + COMMAND rsync -r --exclude=.svn ${PROJECT_SOURCE_DIR}/../targets/mac/qt_menu.nib companion.app/Contents/Resources/ + COMMAND rsync ${PROJECT_BINARY_DIR}/*.qm companion.app/Contents/translations + COMMAND rsync ${PROJECT_BINARY_DIR}/*.qm companion.app/Contents/translations + COMMAND rsync -r ${XSD_INCLUDE_DIR}/.. companion.app/Contents/Frameworks/ + COMMAND rsync -r /Library/Frameworks/SDL.framework companion.app/Contents/Frameworks/ + COMMAND ${QT_BINARY_DIR}/macdeployqt companion.app + COMMAND install_name_tool -change @rpath/SDL.framework/Versions/A/SDL @executable_path/../Frameworks/SDL.framework/Versions/A/SDL companion.app/Contents/MacOS/companion + WORKING_DIRECTORY ${WORK_DIR} + DEPENDS ${COMPANION_NAME}) + + add_custom_target(makedmg + COMMAND ${QT_BINARY_DIR}/macdeployqt companion.app -dmg -no-plugins + WORKING_DIRECTORY ${WORK_DIR} + DEPENDS addframeworks opentx-simulators-bundle) +endif() + +add_custom_target(stamp + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/version.h ${CMAKE_SOURCE_DIR}/../companion.stamp + DEPENDS ${CMAKE_BINARY_DIR}/version.h) + +if(LUPDATE_FOUND) + add_custom_target(translations WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND ${LUPDATE_EXECUTABLE} ${CMAKE_SOURCE_DIR} -no-obsolete -ts ${companion_TS} - ) -ELSE() - ADD_CUSTOM_TARGET( translations + ) +else() + add_custom_target(translations COMMAND echo "Sorry, QT lupdate was not found." - ) -ENDIF() + ) +endif() -SET(CPACK_PACKAGE_NAME "companion${C9X_NAME_SUFFIX}") -SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Models and settings editor for the OpenTx open source firmware") +set(CPACK_PACKAGE_NAME "companion${C9X_NAME_SUFFIX}") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Models and settings editor for the OpenTx open source firmware") string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_PACKAGE_NAME_LOWERCASE) # The file stripping is deliberately disabled, with the stripped file we get # very poor trace-backs from the users when they report Companion crash -SET(CPACK_STRIP_FILES FALSE) +set(CPACK_STRIP_FILES FALSE) find_program(DPKG_PROGRAM dpkg DOC "dpkg program of Debian-based systems") if(DPKG_PROGRAM) - SET(CPACK_GENERATOR "DEB") + set(CPACK_GENERATOR "DEB") execute_process( COMMAND ${DPKG_PROGRAM} --print-architecture OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE ) - SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME_LOWERCASE}_${VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}") - SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Bertrand Songis ") - SET(CPACK_DEBIAN_PACKAGE_VERSION ${VERSION}) - SET(CPACK_DEBIAN_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR}) - SET(CPACK_DEBIAN_PACKAGE_VERSION_MINOR ${VERSION_MINOR}) - SET(CPACK_DEBIAN_ARCHITECTURE $(CMAKE_SYSTEM_PROCESSOR)) - SET(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) + set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME_LOWERCASE}_${VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}") + set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Bertrand Songis ") + set(CPACK_DEBIAN_PACKAGE_VERSION ${VERSION}) + set(CPACK_DEBIAN_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR}) + set(CPACK_DEBIAN_PACKAGE_VERSION_MINOR ${VERSION_MINOR}) + set(CPACK_DEBIAN_ARCHITECTURE $(CMAKE_SYSTEM_PROCESSOR)) + set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) else(DPKG_PROGRAM) - SET(CPACK_GENERATOR "RPM") - SET(CPACK_RPM_PACKAGE_VERSION ${VERSION}) - SET(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}) - SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME_LOWERCASE}-${VERSION}-${CMAKE_SYSTEM_PROCESSOR}") + set(CPACK_GENERATOR "RPM") + set(CPACK_RPM_PACKAGE_VERSION ${VERSION}) + set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}) + set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME_LOWERCASE}-${VERSION}-${CMAKE_SYSTEM_PROCESSOR}") endif(DPKG_PROGRAM) -INCLUDE(CPack) +include(CPack) diff --git a/companion/src/cmake/Macros.cmake b/companion/src/cmake/Macros.cmake deleted file mode 100644 index a3961855876..00000000000 --- a/companion/src/cmake/Macros.cmake +++ /dev/null @@ -1,38 +0,0 @@ -MACRO (TODAY RESULT) - IF (WIN32) - EXECUTE_PROCESS(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE ${RESULT}) - string(REGEX REPLACE "(..)/(..)/(....).*" "\\1.\\2.\\3" ${RESULT} ${${RESULT}}) - ELSEIF(UNIX) - EXECUTE_PROCESS(COMMAND "date" "+%Y-%m-%d" OUTPUT_VARIABLE ${RESULT}) - string(REGEX REPLACE "(....)-(..)-(..).*" "\\1-\\2-\\3" ${RESULT} ${${RESULT}}) - ELSE (WIN32) - MESSAGE(SEND_ERROR "date not implemented") - SET(${RESULT} 00.00.0000) - ENDIF (WIN32) -ENDMACRO (TODAY) - -MACRO (NOW RESULT) - IF (WIN32) - EXECUTE_PROCESS(COMMAND "cmd" " /C time /T" OUTPUT_VARIABLE ${RESULT}) - string(REGEX REPLACE "(..):(..).*" "\\1:\\2:00" ${RESULT} ${${RESULT}}) - ELSEIF(UNIX) - EXECUTE_PROCESS(COMMAND "date" "+%H:%M:%S" OUTPUT_VARIABLE ${RESULT}) - string(REGEX REPLACE "(..):(..):(..).*" "\\1:\\2:\\3" ${RESULT} ${${RESULT}}) - ELSE (WIN32) - MESSAGE(SEND_ERROR "time not implemented") - SET(${RESULT} 00:00:00) - ENDIF (WIN32) -ENDMACRO (NOW) - -MACRO (GIT_ID RESULT) - IF (WIN32) - EXECUTE_PROCESS(COMMAND "cmd" " /C git --git-dir=${PROJECT_SOURCE_DIR}/../../.git rev-parse HEAD" OUTPUT_VARIABLE ${RESULT}) - string(REGEX REPLACE "(.*)\n" "\\1" ${RESULT} ${${RESULT}}) - ELSEIF(UNIX) - EXECUTE_PROCESS(COMMAND "git" "--git-dir=${PROJECT_SOURCE_DIR}/../../.git" "rev-parse" "HEAD" OUTPUT_VARIABLE ${RESULT}) - string(REGEX REPLACE "(.*)\n" "\\1" ${RESULT} ${${RESULT}}) - ELSE (WIN32) - MESSAGE(SEND_ERROR "Git ID implemented") - SET(${RESULT} 0) - ENDIF (WIN32) -ENDMACRO (GIT_ID) diff --git a/companion/src/firmwares/opentx/simulator/CMakeLists.txt b/companion/src/firmwares/opentx/simulator/CMakeLists.txt index 50a62e6abbc..27d22923041 100644 --- a/companion/src/firmwares/opentx/simulator/CMakeLists.txt +++ b/companion/src/firmwares/opentx/simulator/CMakeLists.txt @@ -1,109 +1,30 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) -set(RADIO_SRC_DIRECTORY ${PROJECT_SOURCE_DIR}/../../radio/src) - -macro(add_bitmaps_target targetname filter width format) - file(GLOB bitmaps ${filter}) - foreach(bitmap ${bitmaps}) - get_filename_component(target ${bitmap} NAME_WE) - get_filename_component(path ${bitmap} DIRECTORY) - set(target ${path}/${target}.lbm) - add_custom_command( - OUTPUT ${target} - COMMAND python ../util/img2lbm.py ${bitmap} ${target} ${width} ${format} - DEPENDS ${bitmap} - WORKING_DIRECTORY ${RADIO_SRC_DIRECTORY} - ) - list(APPEND bitmaps_files ${target}) - endforeach() - add_custom_target(${targetname} DEPENDS ${bitmaps_files}) -endmacro(add_bitmaps_target) - -add_bitmaps_target(lbm_xbm_1bit ${RADIO_SRC_DIRECTORY}/bitmaps/*.xbm 128 1bit) -add_bitmaps_target(lbm_fonts_1bit ${RADIO_SRC_DIRECTORY}/fonts/std/*.png 128 "") -add_bitmaps_target(lbm_9x_bitmaps ${RADIO_SRC_DIRECTORY}/bitmaps/9x/*.png 128 1bit) -add_bitmaps_target(lbm_taranis_bitmaps ${RADIO_SRC_DIRECTORY}/bitmaps/taranis/*.png 212 4bits) - -add_dependencies(lbm_9x_bitmaps lbm_fonts_1bit lbm_xbm_1bit) -add_dependencies(lbm_taranis_bitmaps lbm_fonts_1bit lbm_xbm_1bit) - -macro(add_truetype_font_target radio name font size) - set(target ${RADIO_SRC_DIRECTORY}/fonts/${radio}/font_${name}) - add_custom_command( - OUTPUT ${target}.png - OUTPUT ${target}.specs - COMMAND ../util/font2png.py ${font} ${size} False ${target} - WORKING_DIRECTORY ${RADIO_SRC_DIRECTORY} - ) - add_custom_target(ttf_${radio}_${name} DEPENDS ${target}.png ${target}.specs) -endmacro(add_truetype_font_target) - -add_truetype_font_target(horus tinsize "DejaVu Sans" 9) -add_truetype_font_target(horus smlsize "DejaVu Sans" 13) -add_truetype_font_target(horus stdsize "DejaVu Sans" 16) -add_truetype_font_target(horus midsize "DejaVu Sans" 24) -add_truetype_font_target(horus dblsize "DejaVu Sans" 32) -add_truetype_font_target(horus xxlsize "DejaVu Sans" 48) - -add_bitmaps_target(lbm_horus_bitmaps "${RADIO_SRC_DIRECTORY}/bitmaps/horus/????[^_]*.png" 480 5/6/5/8) -add_bitmaps_target(lbm_horus_masks ${RADIO_SRC_DIRECTORY}/bitmaps/horus/mask_*.png 480 8bits) -add_bitmaps_target(lbm_horus_fonts ${RADIO_SRC_DIRECTORY}/fonts/horus/*.png 480 8bits) -add_dependencies(lbm_horus_fonts ttf_horus_tinsize ttf_horus_smlsize ttf_horus_stdsize ttf_horus_midsize ttf_horus_dblsize ttf_horus_xxlsize) -add_dependencies(lbm_horus_bitmaps lbm_horus_masks lbm_horus_fonts) - -file(GLOB translations ${RADIO_SRC_DIRECTORY}/translations/*.h.txt) -foreach(translation ${translations}) - get_filename_component(language ${translation} NAME_WE) - get_filename_component(path ${translation} DIRECTORY) - set(target ${path}/${language}.h) - add_custom_command( - OUTPUT ${target} - COMMAND python ../util/translate.py ${translation} ${target} ${language} - DEPENDS ${translation} - WORKING_DIRECTORY ${RADIO_SRC_DIRECTORY} - ) - list(APPEND translations_files ${target}) -endforeach() - -add_custom_target(firmware_translations DEPENDS ${translations_files}) - -TODAY(DATE) -NOW(TIME) -GIT_ID(GIT_STR) +today(DATE) +now(TIME) +git_id(GIT_STR) configure_file(${RADIO_SRC_DIRECTORY}/stamp.h.in ${RADIO_SRC_DIRECTORY}/stamp.h @ONLY) -macro(add_lua_export_target target) - add_custom_command( - OUTPUT ${RADIO_SRC_DIRECTORY}/lua/lua_exports_${target}.inc - COMMAND ${CMAKE_C_COMPILER} -E ${ARGN} -DEXPORT ${INTTYPES_INCLUDE_OPTION} myeeprom.h | grep LEXP > lua/lua_exports_${target}.txt - COMMAND python ../util/luaexport.py ${VERSION} lua/lua_exports_${target}.txt lua/lua_exports_${target}.inc lua/lua_fields_${target}.txt - WORKING_DIRECTORY ${RADIO_SRC_DIRECTORY} - ) - add_custom_target(lua_export_${target} DEPENDS ${RADIO_SRC_DIRECTORY}/lua/lua_exports_${target}.inc) -endmacro(add_lua_export_target) - -add_lua_export_target(taranis -DPCBTARANIS -DLUA -DVIRTUALINPUTS) -add_lua_export_target(taranis_x9e -DPCBTARANIS -DREVPLUS -DREV9E -DLUA -DVIRTUALINPUTS) -add_lua_export_target(horus -DPCBHORUS -DLUA -DVIRTUALINPUTS) - set(OPENTX_SRC_FILES opentxsimulator.cpp -) + ) include_directories( ${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_SOURCE_DIR} - ${PROJECT_SOURCE_DIR}/firmwares/opentx + ${COMPANION_SRC_DIRECTORY}/firmwares/opentx ${RADIO_SRC_DIRECTORY} ${RADIO_SRC_DIRECTORY}/fonts/std + ${RADIO_BIN_DIRECTORY} ${RADIO_SRC_DIRECTORY}/lua/src ${RADIO_SRC_DIRECTORY}/thirdparty ${RADIO_SRC_DIRECTORY}/thirdparty/FatFs ${RADIO_SRC_DIRECTORY}/thirdparty/FatFs/option ${RADIO_SRC_DIRECTORY}/thirdparty/CoOS ${RADIO_SRC_DIRECTORY}/thirdparty/Lua/src + ${CMAKE_BINARY_DIR}/radio/src ) if(APPLE) @@ -119,21 +40,21 @@ endif() set(COMMON_DEFINITIONS ${COMMON_DEFINITIONS} - SUFFIX="${SUFFIX}" + SUFFIX="${SUFFIX}" HELI GVARS FLIGHT_MODES PPM_CENTER_ADJUSTABLE PPM_LIMITS_SYMETRICAL - OVERRIDE_CHANNEL_FUNCTION + OVERRIDE_CHANNEL_FUNCTION FAI_CHOICE -) + ) set(COMMON_LIBRARIES ${QT_LIBRARIES} ${PTHREAD_LIBRARY} ${SDL_LIBRARY} -) + ) add_library(opentx-9x${SUFFIX}-simulator SHARED ${OPENTX_SRC_FILES}) add_library(opentx-9xr${SUFFIX}-simulator SHARED ${OPENTX_SRC_FILES}) @@ -149,7 +70,7 @@ add_library(opentx-taranisplus${SUFFIX}-simulator SHARED ${OPENTX_SRC_FILES}) add_library(opentx-taranisx9e${SUFFIX}-simulator SHARED ${OPENTX_SRC_FILES}) add_library(opentx-horus${SUFFIX}-simulator SHARED ${OPENTX_SRC_FILES}) -set(dependencies_9x lbm_9x_bitmaps firmware_translations stamp) +set(dependencies_9x 9x_bitmaps firmware_translations stamp) add_dependencies(opentx-9x${SUFFIX}-simulator ${dependencies_9x}) add_dependencies(opentx-9xr${SUFFIX}-simulator ${dependencies_9x}) add_dependencies(opentx-9x128${SUFFIX}-simulator ${dependencies_9x}) @@ -159,12 +80,12 @@ add_dependencies(opentx-mega2560${SUFFIX}-simulator ${dependencies_9x}) add_dependencies(opentx-sky9x${SUFFIX}-simulator ${dependencies_9x}) add_dependencies(opentx-9xrpro${SUFFIX}-simulator ${dependencies_9x}) add_dependencies(opentx-ar9x${SUFFIX}-simulator ${dependencies_9x}) -set(dependencies_taranis lbm_taranis_bitmaps firmware_translations stamp) +set(dependencies_taranis taranis_bitmaps firmware_translations stamp) add_dependencies(opentx-taranis${SUFFIX}-simulator ${dependencies_taranis} lua_export_taranis) add_dependencies(opentx-taranisplus${SUFFIX}-simulator ${dependencies_taranis} lua_export_taranis) add_dependencies(opentx-taranisx9e${SUFFIX}-simulator ${dependencies_taranis} lua_export_taranis_x9e) -add_dependencies(opentx-horus${SUFFIX}-simulator lbm_horus_bitmaps lbm_horus_fonts firmware_translations lua_export_horus) +add_dependencies(opentx-horus${SUFFIX}-simulator horus_bitmaps horus_fonts firmware_translations lua_export_horus) set(OPENTX_LIBRARIES opentx-9x${SUFFIX}-simulator @@ -180,80 +101,80 @@ set(OPENTX_LIBRARIES opentx-taranisplus${SUFFIX}-simulator opentx-taranisx9e${SUFFIX}-simulator opentx-horus${SUFFIX}-simulator -) + ) if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") install(TARGETS ${OPENTX_LIBRARIES} LIBRARY DESTINATION ${SIMULATOR_LIB_PATH}) endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") # 9X with ATmega64 -target_include_directories(opentx-9x${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/9x) +target_include_directories(opentx-9x${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/9x PRIVATE ${CMAKE_BINARY_DIR}/radio/src/bitmaps/9x) target_compile_definitions(opentx-9x${SUFFIX}-simulator PRIVATE PCBSTD PCB9X CPUM64 EEPROM EEPROM_RLC ${COMMON_DEFINITIONS}) target_link_libraries(opentx-9x${SUFFIX}-simulator PRIVATE ${COMMON_LIBRARIES}) # 9XR with ATmega64 -target_include_directories(opentx-9xr${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/9x) +target_include_directories(opentx-9xr${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/9x PRIVATE ${CMAKE_BINARY_DIR}/radio/src/bitmaps/9x) target_compile_definitions(opentx-9xr${SUFFIX}-simulator PRIVATE PCBSTD PCB9XR CPUM64 EEPROM EEPROM_RLC ${COMMON_DEFINITIONS}) target_link_libraries(opentx-9xr${SUFFIX}-simulator PRIVATE ${COMMON_LIBRARIES}) # 9X with ATmega128 -target_include_directories(opentx-9x128${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/9x) +target_include_directories(opentx-9x128${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/9x PRIVATE ${CMAKE_BINARY_DIR}/radio/src/bitmaps/9x) target_compile_definitions(opentx-9x128${SUFFIX}-simulator PRIVATE PCBSTD PCB9X CPUM128 EEPROM EEPROM_RLC ${COMMON_DEFINITIONS}) target_link_libraries(opentx-9x128${SUFFIX}-simulator PRIVATE ${COMMON_LIBRARIES}) # 9XR with ATmega128 -target_include_directories(opentx-9xr128${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/9x) +target_include_directories(opentx-9xr128${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/9x PRIVATE ${CMAKE_BINARY_DIR}/radio/src/bitmaps/9x) target_compile_definitions(opentx-9xr128${SUFFIX}-simulator PRIVATE PCBSTD PCB9XR CPUM128 EEPROM EEPROM_RLC ${COMMON_DEFINITIONS}) target_link_libraries(opentx-9xr128${SUFFIX}-simulator PRIVATE ${COMMON_LIBRARIES}) # Gruvin9x -target_include_directories(opentx-gruvin9x${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/gruvin9x) +target_include_directories(opentx-gruvin9x${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/gruvin9x PRIVATE ${CMAKE_BINARY_DIR}/radio/src/bitmaps/9x) target_compile_definitions(opentx-gruvin9x${SUFFIX}-simulator PRIVATE PCBGRUVIN9X CPUM2560 EEPROM EEPROM_RLC VOICE SDCARD ${COMMON_DEFINITIONS}) target_link_libraries(opentx-gruvin9x${SUFFIX}-simulator PRIVATE ${COMMON_LIBRARIES}) # Mega2560 -target_include_directories(opentx-mega2560${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/mega2560) +target_include_directories(opentx-mega2560${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/mega2560 PRIVATE ${CMAKE_BINARY_DIR}/radio/src/bitmaps/9x) target_compile_definitions(opentx-mega2560${SUFFIX}-simulator PRIVATE PCBMEGA2560 CPUM2560 EEPROM EEPROM_RLC SDCARD ROTARY_ENCODERS=2 ${COMMON_DEFINITIONS}) target_link_libraries(opentx-mega2560${SUFFIX}-simulator PRIVATE ${COMMON_LIBRARIES}) # Sky9x -target_include_directories(opentx-sky9x${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/sky9x) +target_include_directories(opentx-sky9x${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/sky9x PRIVATE ${CMAKE_BINARY_DIR}/radio/src/bitmaps/9x) target_compile_definitions(opentx-sky9x${SUFFIX}-simulator PRIVATE PCBSKY9X CPUARM VOICE EEPROM SDCARD ${COMMON_DEFINITIONS}) target_link_libraries(opentx-sky9x${SUFFIX}-simulator PRIVATE ${COMMON_LIBRARIES}) # 9XR-PRO -target_include_directories(opentx-9xrpro${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/sky9x) +target_include_directories(opentx-9xrpro${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/sky9x PRIVATE ${CMAKE_BINARY_DIR}/radio/src/bitmaps/9x) target_compile_definitions(opentx-9xrpro${SUFFIX}-simulator PRIVATE PCBSKY9X REVX CPUARM VOICE EEPROM SDCARD ${COMMON_DEFINITIONS}) target_link_libraries(opentx-9xrpro${SUFFIX}-simulator PRIVATE ${COMMON_LIBRARIES}) # AR9X -target_include_directories(opentx-ar9x${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/sky9x) +target_include_directories(opentx-ar9x${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/sky9x PRIVATE ${CMAKE_BINARY_DIR}/radio/src/bitmaps/9x) target_compile_definitions(opentx-ar9x${SUFFIX}-simulator PRIVATE PCBSKY9X AR9X CPUARM VOICE EEPROM SDCARD ${COMMON_DEFINITIONS}) target_link_libraries(opentx-ar9x${SUFFIX}-simulator PRIVATE ${COMMON_LIBRARIES}) # Taranis standard -target_include_directories(opentx-taranis${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/taranis) +target_include_directories(opentx-taranis${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/taranis PRIVATE ${CMAKE_BINARY_DIR}/radio/src/bitmaps/taranis) target_compile_definitions(opentx-taranis${SUFFIX}-simulator PRIVATE PCBTARANIS CPUARM CPUSTM32 EEPROM EEPROM_RLC VOICE SDCARD ${COMMON_DEFINITIONS}) target_link_libraries(opentx-taranis${SUFFIX}-simulator PRIVATE ${COMMON_LIBRARIES}) # Taranis Plus -target_include_directories(opentx-taranisplus${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/taranis) +target_include_directories(opentx-taranisplus${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/taranis PRIVATE ${CMAKE_BINARY_DIR}/radio/src/bitmaps/taranis) target_compile_definitions(opentx-taranisplus${SUFFIX}-simulator PRIVATE PCBTARANIS REVPLUS CPUARM CPUSTM32 EEPROM EEPROM_RLC VOICE SDCARD ${COMMON_DEFINITIONS}) target_link_libraries(opentx-taranisplus${SUFFIX}-simulator PRIVATE ${COMMON_LIBRARIES}) # Taranis X9E -target_include_directories(opentx-taranisx9e${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/taranis) +target_include_directories(opentx-taranisx9e${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/taranis PRIVATE ${CMAKE_BINARY_DIR}/radio/src/bitmaps/taranis) target_compile_definitions(opentx-taranisx9e${SUFFIX}-simulator PRIVATE PCBTARANIS REVPLUS REV9E CPUARM CPUSTM32 STM32F40_41xxx EEPROM EEPROM_RLC VOICE SDCARD ${COMMON_DEFINITIONS}) target_link_libraries(opentx-taranisx9e${SUFFIX}-simulator PRIVATE ${COMMON_LIBRARIES}) # Horus -target_include_directories(opentx-horus${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/horus) +target_include_directories(opentx-horus${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/horus PRIVATE ${RADIO_SRC_DIRECTORY}/fonts/horus PRIVATE ${CMAKE_BINARY_DIR}/radio/src/bitmaps/horus) target_compile_definitions(opentx-horus${SUFFIX}-simulator PRIVATE PCBHORUS CPUARM CPUSTM32 STM32F40_41xxx COLORLCD VOICE SDCARD ${COMMON_DEFINITIONS}) target_link_libraries(opentx-horus${SUFFIX}-simulator PRIVATE ${COMMON_LIBRARIES}) add_custom_target(opentx-simulators DEPENDS ${OPENTX_LIBRARIES} -) + ) if(APPLE) set(SIMULATOR_BUNDLES) @@ -269,7 +190,7 @@ if(APPLE) COMMAND pwd COMMAND cp lib${_file}.dylib companion.app/Contents/Resources/ DEPENDS ${_file} - ) + ) list(APPEND SIMULATOR_BUNDLES ${SIMULATOR_BUNDLE}) endforeach() add_custom_target(opentx-simulators-bundle DEPENDS ${SIMULATOR_BUNDLES}) diff --git a/companion/src/mainwindow.cpp b/companion/src/mainwindow.cpp index 52e63ea808e..76b276da421 100644 --- a/companion/src/mainwindow.cpp +++ b/companion/src/mainwindow.cpp @@ -822,7 +822,7 @@ void MainWindow::writeBackup() cd->exec(); } -int MainWindow::getFileType(const QString &fullFileName) +int MainWindow::getFileType(const QString & fullFileName) { if(QFileInfo(fullFileName).suffix().toUpper()=="HEX") return FILE_TYPE_HEX; if(QFileInfo(fullFileName).suffix().toUpper()=="BIN") return FILE_TYPE_BIN; diff --git a/companion/src/mainwindow.h b/companion/src/mainwindow.h index ba4b7c760a1..14a7b9e2e60 100644 --- a/companion/src/mainwindow.h +++ b/companion/src/mainwindow.h @@ -184,19 +184,19 @@ class MainWindow : public QMainWindow void updateLanguageActions(); void updateIconThemeActions(); - int getFileType(const QString &fullFileName); + int getFileType(const QString & fullFileName); QString Theme; QString ISize; - QString strippedName(const QString &fullFileName); + QString strippedName(const QString & fullFileName); MdiChild *activeMdiChild(); - QMdiSubWindow *findMdiChild(const QString &fileName); + QMdiSubWindow *findMdiChild(const QString & fileName); int getEpromVersion(QString fileName); - bool readEepromFromRadio(const QString &filename); - bool writeEepromToRadio(const QString &filename); - bool readFirmwareFromRadio(const QString &filename); - bool writeFirmwareToRadio(const QString &filename); + bool readEepromFromRadio(const QString & filename); + bool writeEepromToRadio(const QString & filename); + bool readFirmwareFromRadio(const QString & filename); + bool writeFirmwareToRadio(const QString & filename); QMdiArea *mdiArea; QSignalMapper *windowMapper; diff --git a/companion/src/modeledit/CMakeLists.txt b/companion/src/modeledit/CMakeLists.txt index bf2acb40152..3f64a2c8a98 100644 --- a/companion/src/modeledit/CMakeLists.txt +++ b/companion/src/modeledit/CMakeLists.txt @@ -1,4 +1,8 @@ -include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) +include_directories( + ${CMAKE_SOURCE_DIR} + ${COMPANION_SRC_DIRECTORY} + ${CMAKE_CURRENT_BINARY_DIR} +) set(modeledit_NAMES modeledit diff --git a/companion/src/simulation/CMakeLists.txt b/companion/src/simulation/CMakeLists.txt index 8a6249219a9..c2de4c69f35 100644 --- a/companion/src/simulation/CMakeLists.txt +++ b/companion/src/simulation/CMakeLists.txt @@ -48,8 +48,8 @@ endif() include_directories( ${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_SOURCE_DIR} - ${PROJECT_SOURCE_DIR}/../.. ${COMPANION_SRC_DIRECTORY} + ${COMPANION_SRC_DIRECTORY}/simulation ${RADIO_SRC_DIRECTORY}/fonts/std ) diff --git a/radio/src/CMakeLists.txt b/radio/src/CMakeLists.txt new file mode 100644 index 00000000000..8ad9495c3a1 --- /dev/null +++ b/radio/src/CMakeLists.txt @@ -0,0 +1,569 @@ +option(PCB "Radio type") +option(HELI "Heli menu" ON) +option(FLIGHT_MODES "Flight Modes" ON) +option(CURVES "Curves" ON) +option(GVARS "Global variables") +option(LUA "Lua scripts") +option(GUI "GUI enabled" ON) +option(SPLASH "Splash enabled" ON) +option(PPM_UNIT "PPM display unit (US/PERCENT_PREC1/PERCENT_PREC0)" 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(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) +option(AUTOSWITCH "Automatic switch detection in menus" ON) + +set(OPT s) + +enable_language(ASM) + +set(THIRDPARTY_DIR thirdparty) +set(LUA_DIR ${THIRDPARTY_DIR}/Lua/src) +set(COOS_DIR ${THIRDPARTY_DIR}/CoOS) +set(FATFS_DIR ${THIRDPARTY_DIR}/FatFs) +set(RADIO_BIN_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + +add_subdirectory(translations) +add_subdirectory(bitmaps/9x) +add_subdirectory(bitmaps/taranis) +add_subdirectory(bitmaps/horus) +add_subdirectory(lua) + +set(FIRMWARE_DEPENDENCIES firmware_translations) + +if(PCB STREQUAL HORUS) + include_directories(${RADIO_SRC_DIRECTORY}/fonts/horus) + set(CPU_TYPE STM32F4) + set(HSE_VALUE 12000000) + set(GUI_DIR horus) + set(TARGET_DIR horus) + set(SDCARD YES) + set(LINKER_SCRIPT targets/horus/stm32f4_flash.ld) + set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} horus_bitmaps) + set(LUA_EXPORT lua_export_horus) + add_definitions(-DFLAVOUR="horus") + add_definitions(-DPCBHORUS -DCOLORLCD -DSTM32F429_439xx) + add_definitions(-DEEPROM_VARIANT=0 -DAUDIO -DVOICE -DRTCLOCK) + add_definitions(-DVIRTUALINPUTS -DLUAINPUTS -DXCURVES -DVARIO) + set(EEPROM SDCARD) + set(HAPTIC YES) + set(SRC ${SRC} bmp.cpp debug.cpp) + set(GUI_SRC + ${GUI_SRC} + curves.cpp + bitmaps.cpp + view_channels.cpp + view_about.cpp + view_text.cpp + view_telemetry.cpp # TODO remove it + ) + set(SRC ${SRC} targets/taranis/rtc_driver.cpp) + set(TARGET_SRC ${TARGET_SRC} board_horus.cpp) + set(FIRMWARE_TARGET_SRC + ${FIRMWARE_TARGET_SRC} + sdio_sd.c + lcd_driver.cpp + delays.c + i2c_driver.cpp + usb_driver.c + pwr_driver.c + sdram_driver.c + led_driver.cpp + ) + set(STM32LIB_SRC + STM32F4xx_StdPeriph_Driver/src/misc.c + STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c + STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dbgmcu.c + STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rcc.c + STM32F4xx_StdPeriph_Driver/src/stm32f4xx_spi.c + STM32F4xx_StdPeriph_Driver/src/stm32f4xx_i2c.c + STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dma.c + STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rtc.c + STM32F4xx_StdPeriph_Driver/src/stm32f4xx_pwr.c + STM32F4xx_StdPeriph_Driver/src/stm32f4xx_usart.c + STM32F4xx_StdPeriph_Driver/src/stm32f4xx_sdio.c + STM32F4xx_StdPeriph_Driver/src/stm32f4xx_fmc.c + STM32F4xx_StdPeriph_Driver/src/stm32f4xx_ltdc.c + STM32F4xx_StdPeriph_Driver/src/stm32f4xx_tim.c + STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dma2d.c + ) +elseif(PCB STREQUAL TARANIS) + option(SHUTDOWN_CONFIRMATION "Shutdown confirmation" OFF) + option(LCD_DUAL_BUFFER "Dual LCD Buffer" OFF) + option(TARANIS_INTERNAL_PPM "Taranis internal module hack to output PPM" OFF) + if(PCBREV STREQUAL REV9E) + set(CPU_TYPE STM32F4) + set(LINKER_SCRIPT targets/taranis/stm32f4_flash.ld) + add_definitions(-DSTM32F40_41xxx -DEEPROM_VARIANT=32768) + add_definitions(-DREVPLUS -DREV9E) + add_definitions(-DFLAVOUR="taranis-x9e") + set(HAPTIC YES) + set(LUA_EXPORT lua_export_taranis_x9e) + elseif(PCBREV STREQUAL REVPLUS) + set(CPU_TYPE STM32F2) + set(LINKER_SCRIPT targets/taranis/stm32f2_flash.ld) + add_definitions(-DEEPROM_VARIANT=0) + add_definitions(-DREVPLUS) + add_definitions(-DFLAVOUR="taranis-plus") + set(HAPTIC YES) + set(LUA_EXPORT lua_export_taranis) + else() + set(CPU_TYPE STM32F2) + set(LINKER_SCRIPT targets/taranis/stm32f2_flash.ld) + add_definitions(-DEEPROM_VARIANT=0) + add_definitions(-DFLAVOUR="taranis") + set(HAPTIC NO) + set(LUA_EXPORT lua_export_taranis) + endif() + set(HSE_VALUE 12000000) + add_definitions(-DPCBTARANIS) + add_definitions(-DAUDIO -DVOICE -DRTCLOCK) + add_definitions(-DDBLKEYS -DVIRTUALINPUTS -DLUAINPUTS -DXCURVES -DVARIO) + set(EEPROM EEPROM_RLC) + set(GUI_DIR taranis) + set(TARGET_DIR taranis) + set(SDCARD YES) + set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} taranis_bitmaps) + set(SRC ${SRC} bmp.cpp debug.cpp) + set(GUI_SRC ${GUI_SRC} menu_general_diagkeys.cpp menu_general_diaganas.cpp menu_general_hardware.cpp view_channels.cpp view_telemetry.cpp view_text.cpp view_about.cpp) + set(TARGET_SRC ${TARGET_SRC} board_taranis.cpp rtc_driver.cpp) + set(FIRMWARE_TARGET_SRC + ${FIRMWARE_TARGET_SRC} + lcd_driver.cpp + delays.c + i2c_driver.cpp + usb_driver.c + pwr_driver.c + configure_pins.cpp + flash_driver.cpp + aspi.c + ) + if(LCD_DUAL_BUFFER) + add_definitions(-DLCD_DUAL_BUFFER) + endif() + if(TARANIS_INTERNAL_PPM) + add_definitions(-DTARANIS_INTERNAL_PPM) + endif() +else() + message(FATAL_ERROR "Unknown PCB '${PCB}'") +endif() + +if(CPU_TYPE STREQUAL STM32F4) + set(MCU cortex-m4) + set(CPU_FAMILY STM32) + set(STM32LIB_DIR ${THIRDPARTY_DIR}/STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries) + include_directories(${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/inc) + include_directories(${STM32LIB_DIR}/CMSIS/Device/ST/STM32F4xx/Include) + include_directories(${STM32LIB_DIR}/CMSIS/include) + set(STM32LIB_SRC + ${STM32LIB_SRC} + CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc_ride7/startup_stm32f40_41xxx.s + ) + set(FIRMWARE_TARGET_SRC ${FIRMWARE_TARGET_SRC} system_stm32f4xx.c) +endif() + +if(CPU_TYPE STREQUAL STM32F2) + set(MCU cortex-m3) + set(CPU_FAMILY STM32) + set(STM32LIB_DIR ${THIRDPARTY_DIR}/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries) + include_directories(${STM32LIB_DIR}/STM32F2xx_StdPeriph_Driver/inc) + include_directories(${STM32LIB_DIR}/CMSIS/Device/ST/STM32F2xx/Include) + include_directories(${STM32LIB_DIR}/CMSIS/include) + set(STM32LIB_SRC + ${STM32LIB_SRC} + CMSIS/Device/ST/STM32F2xx/Source/Templates/gcc_ride7/startup_stm32f2xx.s + STM32F2xx_StdPeriph_Driver/src/misc.c + STM32F2xx_StdPeriph_Driver/src/stm32f2xx_gpio.c + STM32F2xx_StdPeriph_Driver/src/stm32f2xx_dbgmcu.c + STM32F2xx_StdPeriph_Driver/src/stm32f2xx_rcc.c + STM32F2xx_StdPeriph_Driver/src/stm32f2xx_spi.c + STM32F2xx_StdPeriph_Driver/src/stm32f2xx_i2c.c + STM32F2xx_StdPeriph_Driver/src/stm32f2xx_dma.c + STM32F2xx_StdPeriph_Driver/src/stm32f2xx_rtc.c + STM32F2xx_StdPeriph_Driver/src/stm32f2xx_pwr.c + STM32F2xx_StdPeriph_Driver/src/stm32f2xx_usart.c + ) + set(FIRMWARE_TARGET_SRC ${FIRMWARE_TARGET_SRC} system_stm32f2xx.c) +endif() + +if(CPU_FAMILY STREQUAL STM32) + option(USB "USB option (JOYSTICK/MASSSTORAGE/SERIAL)" JOYSTICK) + set(ARCH ARM) + set(STM32USB_DIR ${THIRDPARTY_DIR}/STM32_USB-Host-Device_Lib_V2.1.0/Libraries) + add_definitions(-DCPUSTM32) + add_definitions(-DFRSKY -DFRSKY_SPORT -DFRSKY_HUB -DGPS -DPXX -DDSM2 -DSBUS -DCROSSFIRE) + include_directories(${STM32USB_DIR}/STM32_USB_OTG_Driver/inc) + include_directories(${STM32USB_DIR}/STM32_USB_Device_Library/Core/inc) + include_directories(${STM32USB_DIR}/STM32_USB_Device_Library/Class/msc/inc) + include_directories(${STM32USB_DIR}/STM32_USB_Device_Library/Class/hid/inc) + include_directories(${STM32USB_DIR}/STM32_USB_Device_Library/Class/cdc/inc) + set(STM32USB_SRC + STM32_USB_OTG_Driver/src/usb_core.c + STM32_USB_OTG_Driver/src/usb_dcd.c + STM32_USB_OTG_Driver/src/usb_dcd_int.c + STM32_USB_Device_Library/Core/src/usbd_core.c + 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) + if(${EEPROM} STREQUAL SDCARD) + set(SRC ${SRC} storage/storage_common.cpp storage/sdcard_raw.cpp) + elseif(${EEPROM} STREQUAL EEPROM_RLC) + set(SRC ${SRC} storage/storage_common.cpp storage/eeprom_common.cpp storage/eeprom_rlc.cpp storage/eeprom_conversions.cpp) + add_definitions(-DEEPROM -DEEPROM_RLC) + else() + set(SRC ${SRC} storage/storage_common.cpp storage/eeprom_common.cpp storage/eeprom_raw.cpp storage/eeprom_conversions.cpp) + add_definitions(-DEEPROM) + endif() + 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) + elseif(USB STREQUAL MASSSTORAGE) + add_definitions(-DUSB_MASS_STORAGE) + set(STM32USB_SRC + ${STM32USB_SRC} + STM32_USB_Device_Library/Class/msc/src/usbd_msc_data.c + STM32_USB_Device_Library/Class/msc/src/usbd_msc_scsi.c + 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) + else() + add_definitions(-DUSB_JOYSTICK) + set(FIRMWARE_TARGET_SRC ${FIRMWARE_TARGET_SRC} usbd_hid_joystick.c) + endif() + set(FIRMWARE_SRC + ${FIRMWARE_SRC} + serial.cpp + ${FATFS_DIR}/ff.c + ${FATFS_DIR}/fattime.c + ${FATFS_DIR}/option/ccsbcs.c + ${COOS_DIR}/kernel/core.c + ${COOS_DIR}/kernel/hook.c + ${COOS_DIR}/kernel/task.c + ${COOS_DIR}/kernel/event.c + ${COOS_DIR}/kernel/time.c + ${COOS_DIR}/kernel/timer.c + ${COOS_DIR}/kernel/flag.c + ${COOS_DIR}/kernel/mutex.c + ${COOS_DIR}/kernel/serviceReq.c + ${COOS_DIR}/portable/GCC/port.c + ${COOS_DIR}/portable/arch.c + syscalls.c + targets/taranis/configure_pins.cpp + ) + foreach(FILE ${STM32LIB_SRC}) + set(FIRMWARE_SRC ${FIRMWARE_SRC} ${STM32LIB_DIR}/${FILE}) + endforeach() + foreach(FILE ${STM32USB_SRC}) + set(FIRMWARE_SRC ${FIRMWARE_SRC} ${STM32USB_DIR}/${FILE}) + endforeach() +endif() + +if(ARCH STREQUAL ARM) + option(TIMERS "Timers count" 2) + option(SPORT_FILE_LOG "S.PORT Logs on SD card" OFF) + option(TRACE_SD_CARD "SD Logs" OFF) + option(TRACE_FATFS "FatFS Logs" OFF) + option(TRACE_AUDIO "Audio Logs" OFF) + option(DEBUG_TRACE_BUFFER "Debug Trace Screen" OFF) + option(SUPPORT_D16_EU_ONLY "XJT module only supports D16-EU and LR12-EU" OFF) # TODO rename to XJT_EU_ONLY + if(TIMERS EQUAL 3) + add_definitions(-DTIMERS=3) + else() + add_definitions(-DTIMERS=2) + endif() + if(SPORT_FILE_LOG) + add_definitions(-DSPORT_FILE_LOG) + endif() + if(TRACE_SD_CARD) + add_definitions(-DTRACE_SD_CARD) + # DEBUG = YES + # DEBUG_TRACE_BUFFER = YES + endif() + if(TRACE_FATFS) + add_definitions(-DTRACE_FATFS) + # DEBUG = YES + # DEBUG_TRACE_BUFFER = YES + endif() + if(TRACE_AUDIO) + add_definitions(-DTRACE_AUDIO) + # DEBUG = YES + # DEBUG_TRACE_BUFFER = YES + endif() + if(DEBUG_TRACE_BUFFER) + add_definitions(-DDEBUG_TRACE_BUFFER) + endif() + if(SUPPORT_D16_EU_ONLY) + add_definitions(-DMODULE_D16_EU_ONLY_SUPPORT) + endif() + if(HAPTIC) + add_definitions(-DHAPTIC) + set(SRC ${SRC} haptic.cpp) + set(TARGET_SRC ${TARGET_SRC} haptic_driver.cpp) + endif() + add_definitions(-DCPUARM) + include_directories(targets/${TARGET_DIR} ${THIRDPARTY_DIR}) + include_directories(${COOS_DIR} ${COOS_DIR}/kernel ${COOS_DIR}/portable) + foreach(LANGUAGE cz de en es fr it pt sk se pl hu) # TODO add nl + set(SRC ${SRC} translations/tts_${LANGUAGE}.cpp) + string(TOUPPER LANGUAGE_UPPER LANGUAGE) + if(TRANSLATIONS STREQUAL LANGUAGE_CAPITALIZED) + add_definitions(-DTRANSLATIONS_${LANGUAGE_UPPER}) + endif() + endforeach() + set(SRC + ${SRC} + main_arm.cpp + tasks_arm.cpp + audio_arm.cpp + sbus.cpp + telemetry/telemetry.cpp + telemetry/frsky.cpp + telemetry/frsky_d_arm.cpp + telemetry/frsky_sport.cpp + telemetry/telemetry.cpp + crc16.cpp + vario.cpp + ) + set(FIRMWARE_TARGET_SRC + ${FIRMWARE_TARGET_SRC} + diskio.cpp + ) + set(TARGET_SRC + ${TARGET_SRC} + pulses_driver.cpp + keys_driver.cpp + adc_driver.cpp + trainer_driver.cpp + audio_driver.cpp + serial2_driver.cpp + telemetry_driver.cpp + ) + set(PULSES_SRC + pulses_arm.cpp + ppm_arm.cpp + pxx_arm.cpp + dsm2_arm.cpp + crossfire.cpp + ) +endif() + +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) +include_directories(${CMAKE_CURRENT_BINARY_DIR}) +include_directories(${CMAKE_CURRENT_BINARY_DIR}/bitmaps/${GUI_DIR}) + +if(NOT LUA STREQUAL OFF) + add_definitions(-DLUA) + include_directories(${LUA_DIR}) + set(FIRMWARE_DEPENDENCIES ${FIRMWARE_DEPENDENCIES} ${LUA_EXPORT}) + if(LUA STREQUAL ON) + add_definitions(-DLUA_MODEL_SCRIPTS) + set(GUI_SRC ${GUI_SRC} menu_model_custom_scripts.cpp) + endif() + set(SRC ${SRC} lua/interface.cpp lua/api_general.cpp lua/api_lcd.cpp lua/api_model.cpp) + set(LUA_SRC + lapi.c + lcode.c + lctype.c + ldebug.c + ldo.c + ldump.c + lfunc.c + lgc.c + llex.c + lmem.c + lobject.c + lopcodes.c + lparser.c + lstate.c + lstring.c + ltable.c + lrotable.c + ltm.c + lundump.c + lvm.c + lzio.c + lbaselib.c + linit.c + lmathlib.c + lbitlib.c + loadlib.c + lauxlib.c + ltablib.c + lcorolib.c + liolib.c + lstrlib.c + ) + foreach(FILE ${LUA_SRC}) + set(SRC ${SRC} ${LUA_DIR}/${FILE}) + endforeach() +endif() + +if(HELI) + add_definitions(-DHELI) + set(GUI_SRC ${GUI_SRC} menu_model_heli.cpp) +endif() + +if(FLIGHT_MODES) + add_definitions(-DFLIGHT_MODES) + set(GUI_SRC ${GUI_SRC} menu_model_flightmodes.cpp) +endif() + +if(CURVES) + add_definitions(-DCURVES) + set(GUI_SRC ${GUI_SRC} menu_model_curves.cpp) +endif() + +if(GVARS) + add_definitions(-DGVARS) + set(GUI_SRC ${GUI_SRC} menu_model_gvars.cpp) +endif() + +if(FAI STREQUAL YES) + add_definitions(-DFAI) +elseif(FAI STREQUAL CHOICE) + add_definitions(-DFAI_CHOICE) +endif() + +if(AUTOSOURCE) + add_definitions(-DAUTOSOURCE) +endif() + +if(AUTOSWITCH) + add_definitions(-DAUTOSWITCH) +endif() + +if(SDCARD STREQUAL YES) + add_definitions(-DSDCARD) + set(SRC ${SRC} sdcard.cpp rtc.cpp logs.cpp) + set(GUI_SRC ${GUI_SRC} menu_general_sdmanager.cpp) + include_directories(${FATFS_DIR} ${FATFS_DIR}/option) +endif() + +if(SHUTDOWN_CONFIRMATION) + add_definitions(-DSHUTDOWN_CONFIRMATION) +endif() + +if(PPM_UNIT STREQUAL US) + add_definitions(-DPPM_UNIT_US) +elseif(PPM_UNIT STREQUAL PERCENT_PREC1) + add_definitions(-DPPM_UNIT_PERCENT_PREC1) +else() + add_definitions(-DPPM_UNIT_PERCENT_PREC0) +endif() + +if(PPM_CENTER_ADJUSTABLE) + add_definitions(-DPPM_CENTER_ADJUSTABLE) +endif() + +if(PPM_LIMITS_SYMETRICAL) + add_definitions(-DPPM_LIMITS_SYMETRICAL) +endif() + +if(OVERRIDE_CHANNEL_FUNCTION) + add_definitions(-DOVERRIDE_CHANNEL_FUNCTION) +endif() + +if(DANGEROUS_MODULE_FUNCTIONS) + add_definitions(-DDANGEROUS_MODULE_FUNCTIONS) +endif() + +set(GUI_SRC + ${GUI_SRC} + lcd.cpp + splash.cpp + fonts.cpp + helpers.cpp + navigation.cpp + popups.cpp + widgets.cpp + menus.cpp + ) + +set(GUI_SRC + ${GUI_SRC} + menu_model.cpp + menu_model_select.cpp + menu_model_setup.cpp + menu_model_inputs_mixes.cpp + menu_model_limits.cpp + menu_model_logical_switches.cpp + menu_model_custom_functions.cpp + menu_model_telemetry.cpp + menu_general.cpp + menu_general_setup.cpp + menu_general_trainer.cpp + menu_general_version.cpp + menu_general_calib.cpp + view_main.cpp + view_statistics.cpp + ) + +set(SRC + ${SRC} + opentx.cpp + functions.cpp + strhelpers.cpp + switches.cpp + curves.cpp + mixer.cpp + stamp.cpp + timers.cpp + trainer_input.cpp + ) + +if(SPLASH) + add_definitions(-DSPLASH) +endif() + +if(GUI) + add_definitions(-DGUI) + set(SRC + ${SRC} + keys.cpp + maths.cpp + translations.cpp + gui/gui_helpers.cpp + ) + foreach(FILE ${GUI_SRC}) + set(SRC ${SRC} gui/${GUI_DIR}/${FILE}) + endforeach() +endif() + +foreach(FILE ${TARGET_SRC}) + set(SRC ${SRC} targets/${TARGET_DIR}/${FILE}) +endforeach() + +foreach(FILE ${FIRMWARE_TARGET_SRC}) + set(FIRMWARE_SRC ${FIRMWARE_SRC} targets/${TARGET_DIR}/${FILE}) +endforeach() + +foreach(FILE ${PULSES_SRC}) + set(SRC ${SRC} pulses/${FILE}) +endforeach() + +add_subdirectory(targets/simu) + +include(CMakeForceCompiler) +cmake_force_c_compiler(arm-none-eabi-gcc GNU) +cmake_force_cxx_compiler(arm-none-eabi-gcc GNU) +set(CMAKE_ASM_COMPILER arm-none-eabi-as) + +set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") +set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") + +set(CMAKE_SYSTEM_NAME Generic) +set(CMAKE_SYSTEM_VERSION 1) +set(CMAKE_ASM_COMPILE_OBJECT " -o ") + +set(COMMON_FLAGS "-mcpu=${MCU} -mthumb -fomit-frame-pointer -fverbose-asm -Wa,-ahlms=opentx.lst -DRUN_FROM_FLASH=1 -O${OPT} -gdwarf-2 -DHSE_VALUE=${HSE_VALUE} -Wall -fno-exceptions -Wno-strict-aliasing -Wformat -Wreturn-type -Wunused -Wuninitialized -Wunknown-pragmas -Wno-switch -Wtype-limits -fdata-sections -ffunction-sections") +set(CMAKE_C_FLAGS "${COMMON_FLAGS} -Wimplicit") +set(CMAKE_CXX_FLAGS "${COMMON_FLAGS}") +set(CMAKE_EXE_LINKER_FLAGS "-mcpu=${MCU} -mthumb -nostartfiles -lm -T${RADIO_SRC_DIRECTORY}/${LINKER_SCRIPT} -Wl,-Map=opentx.map,--cref,--no-warn-mismatch,--gc-sections") + +add_executable(firmware ${SRC} ${FIRMWARE_SRC}) +add_dependencies(firmware ${FIRMWARE_DEPENDENCIES}) diff --git a/radio/src/Makefile b/radio/src/Makefile index dfd87b3d380..49fab6ca549 100644 --- a/radio/src/Makefile +++ b/radio/src/Makefile @@ -444,7 +444,7 @@ ifeq ($(PCB), $(filter $(PCB), STD 9X 9XR)) OPT = s SDCARD = NO THR_TRACE = NO - INCDIRS += targets/9x + INCDIRS += targets/9x bitmaps bitmaps/9x CPPDEFS = -DF_CPU=$(F_CPU)UL -DPCBSTD -DCPUM64 -DEEPROM -DEEPROM_RLC -DEEPROM_VARIANT=$(shell echo ${EEPROM_VARIANT} | bc) BOARDSRC = main_avr.cpp targets/9x/board_stock.cpp EXTRABOARDSRC = targets/common_avr/adc_driver.cpp targets/common_avr/telemetry_driver.cpp @@ -527,7 +527,7 @@ ifeq ($(PCB), $(filter $(PCB), STD128 9X128 9XR128)) THR_TRACE = NO EEPROM_VARIANT += ${M128_VARIANT} CPPDEFS = -DF_CPU=$(F_CPU)UL -DPCBSTD -DCPUM128 -DEEPROM -DEEPROM_RLC -DEEPROM_VARIANT=$(shell echo ${EEPROM_VARIANT} | bc) - INCDIRS += targets/9x + INCDIRS += targets/9x bitmaps bitmaps/9x BOARDSRC = main_avr.cpp targets/9x/board_stock.cpp EXTRABOARDSRC = targets/common_avr/adc_driver.cpp targets/9x/lcd_driver.cpp targets/common_avr/telemetry_driver.cpp EEPROMSRC = storage/storage_common.cpp storage/eeprom_common.cpp storage/eeprom_rlc.cpp @@ -602,7 +602,7 @@ ifeq ($(PCB), $(filter $(PCB), 9X2561)) THR_TRACE = YES EEPROM_VARIANT += ${M2561_VARIANT} CPPDEFS = -DF_CPU=$(F_CPU)UL -DPCBSTD -DCPUM2561 -DEEPROM -DEEPROM_RLC -DEEPROM_VARIANT=$(shell echo ${EEPROM_VARIANT} | bc) - INCDIRS += targets/9x + INCDIRS += targets/9x bitmaps bitmaps/9x BOARDSRC = main_avr.cpp targets/9x/board_stock.cpp EXTRABOARDSRC = targets/common_avr/adc_driver.cpp targets/9x/lcd_driver.cpp targets/common_avr/telemetry_driver.cpp EEPROMSRC = storage/storage_common.cpp storage/eeprom_common.cpp storage/eeprom_rlc.cpp @@ -675,7 +675,7 @@ ifeq ($(PCB), GRUVIN9X) SDCARD = NO BUZZER = NO THR_TRACE = YES - INCDIRS += targets/gruvin9x targets/9x $(FATFSDIR) $(FATFSDIR)/option + INCDIRS += targets/gruvin9x targets/9x bitmaps bitmaps/9x $(FATFSDIR) $(FATFSDIR)/option BOARDSRC = main_avr.cpp targets/gruvin9x/board_gruvin9x.cpp EXTRABOARDSRC = targets/common_avr/adc_driver.cpp targets/9x/lcd_driver.cpp targets/common_avr/telemetry_driver.cpp EEPROMSRC = storage/storage_common.cpp storage/eeprom_common.cpp storage/eeprom_rlc.cpp @@ -721,7 +721,7 @@ ifeq ($(PCB), MEGA2560) BUZZER = YES THR_TRACE = YES PWRMANAGE = NO - INCDIRS += targets/mega2560 targets/9x $(FATFSDIR) $(FATFSDIR)/option + INCDIRS += targets/mega2560 targets/9x bitmaps bitmaps/9x $(FATFSDIR) $(FATFSDIR)/option BOARDSRC = main_avr.cpp targets/mega2560/board_mega2560.cpp EEPROMSRC = storage/storage_common.cpp storage/eeprom_common.cpp storage/eeprom_rlc.cpp PULSESSRC = pulses/pulses_avr.cpp @@ -817,7 +817,7 @@ ifeq ($(PCB), $(filter $(PCB), SKY9X 9XRPRO AR9X)) ifeq ($(SPORT_FILE_LOG), YES) CPPDEFS += -DSPORT_FILE_LOG endif - INCDIRS += targets/sky9x $(COOSDIR) $(COOSDIR)/kernel $(COOSDIR)/portable + INCDIRS += targets/sky9x bitmaps bitmaps/9x $(COOSDIR) $(COOSDIR)/kernel $(COOSDIR)/portable GUIGENERALSRC += gui/$(GUIDIRECTORY)/menu_general_hardware.cpp gui/$(GUIDIRECTORY)/menu_general_diagkeys.cpp gui/$(GUIDIRECTORY)/menu_general_diaganas.cpp BOARDSRC = main_arm.cpp targets/sky9x/board_sky9x.cpp EXTRABOARDSRC = targets/sky9x/lcd_driver.cpp @@ -935,7 +935,7 @@ ifeq ($(PCB), TARANIS) PPM_CENTER_ADJUSTABLE = YES DSM2 = PPM CPPDEFS += -DPCBTARANIS -DCPUARM -DCPUSTM32 -DVIRTUALINPUTS -DLUAINPUTS -DXCURVES -DEEPROM -DEEPROM_RLC -DAUDIO -DPXX -DSBUS -DCROSSFIRE - INCDIRS += targets/taranis $(THIRDPARTY) $(COOSDIR) $(COOSDIR)/kernel $(COOSDIR)/portable + INCDIRS += targets/taranis bitmaps bitmaps/taranis $(THIRDPARTY) $(COOSDIR) $(COOSDIR)/kernel $(COOSDIR)/portable CPPDEFS += -DHSE_VALUE=12000000 ifeq ($(PCBREV), REV9E) STM32LIBPATH = $(THIRDPARTY)/STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries @@ -1100,7 +1100,7 @@ ifeq ($(PCB), FLAMENCO) TIMERS = 2 CPPDEFS += -DTIMERS=$(TIMERS) CPPDEFS += -DPCBFLAMENCO -DCPUARM -DCPUSTM32 -DEEPROM -DVIRTUALINPUTS -DLUAINPUTS -DXCURVES -DEEPROM_VARIANT=0 -DAUDIO -DPXX - INCDIRS += targets/flamenco $(THIRDPARTY) $(COOSDIR) $(COOSDIR)/kernel $(COOSDIR)/portable + INCDIRS += targets/flamenco bitmaps/flamenco $(THIRDPARTY) $(COOSDIR) $(COOSDIR)/kernel $(COOSDIR)/portable INCDIRS += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/inc $(STM32LIBPATH)/CMSIS/Device/ST/STM32F4xx/Include $(STM32LIBPATH)/CMSIS/include STM32USBPATH = $(THIRDPARTY)/STM32_USB-Host-Device_Lib_V2.1.0/Libraries INCDIRS += $(STM32USBPATH)/STM32_USB_OTG_Driver/inc @@ -1223,7 +1223,7 @@ ifeq ($(PCB), HORUS) TIMERS = 2 CPPDEFS += -DTIMERS=$(TIMERS) CPPDEFS += -DPCBHORUS -DCPUARM -DCPUSTM32 -DVIRTUALINPUTS -DLUAINPUTS -DXCURVES -DEEPROM_VARIANT=0 -DAUDIO -DPXX - INCDIRS += targets/horus $(THIRDPARTY) $(COOSDIR) $(COOSDIR)/kernel $(COOSDIR)/portable + INCDIRS += targets/horus bitmaps/horus fonts/horus $(THIRDPARTY) $(COOSDIR) $(COOSDIR)/kernel $(COOSDIR)/portable INCDIRS += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/inc $(STM32LIBPATH)/CMSIS/Device/ST/STM32F4xx/Include $(STM32LIBPATH)/CMSIS/include STM32USBPATH = $(THIRDPARTY)/STM32_USB-Host-Device_Lib_V2.1.0/Libraries INCDIRS += $(STM32USBPATH)/STM32_USB_OTG_Driver/inc @@ -2026,7 +2026,7 @@ ifeq ($(SIMU_DISKIO), YES) endif simu: $(LUADEP) stamp.h allsimusrc.cpp Makefile simu.cpp targets/simu/simpgmspace.cpp *.h tra lbm eeprom.bin - g++ $(CPPFLAGS) $(SIMUCPPFLAGS) $(INCFLAGS) simu.cpp allsimusrc.cpp $(LUASRC) targets/simu/simpgmspace.cpp -MD $(SIMUDEFS) -O0 -o simu $(FOXINC) $(FOXLIB) $(AUDIOINC) $(AUDIOLIB) -pthread -fexceptions + gcc $(CPPFLAGS) $(SIMUCPPFLAGS) $(INCFLAGS) simu.cpp allsimusrc.cpp $(LUASRC) targets/simu/simpgmspace.cpp -MD $(SIMUDEFS) -O0 -o simu $(FOXINC) $(FOXLIB) $(AUDIOINC) $(AUDIOLIB) -pthread -fexceptions -lstdc++ -lm eeprom.bin: dd if=/dev/zero of=$@ bs=1 count=2048 @@ -2203,5 +2203,5 @@ gtest-all.o : $(GTEST_SRCS) GTEST_TESTS_SRCS = $(shell find tests/ -type f -name '*.cpp') gtests: allsimusrc.cpp $(GTEST_TESTS_SRCS) targets/simu/simpgmspace.cpp *.h tests/gtests.h gtest-all.o - g++ -std=gnu++0x $(CPPFLAGS) $(SIMUCPPFLAGS) allsimusrc.cpp $(LUASRC) $(GTEST_TESTS_SRCS) targets/simu/simpgmspace.cpp ${INCFLAGS} -I$(GTEST_INCDIR) -I/usr/include/qt4 -o gtests -lpthread -MD -DSIMU -lQtCore -lQtGui gtest-all.o -fexceptions + gcc -std=gnu++0x $(CPPFLAGS) $(SIMUCPPFLAGS) allsimusrc.cpp $(LUASRC) $(GTEST_TESTS_SRCS) targets/simu/simpgmspace.cpp ${INCFLAGS} -I$(GTEST_INCDIR) -I/usr/include/qt4 -o gtests -lpthread -MD -DSIMU -lQtCore -lQtGui gtest-all.o -fexceptions -lstdc++ -lm diff --git a/radio/src/audio_arm.h b/radio/src/audio_arm.h index 6fe1d342ab1..16d94d2f81b 100644 --- a/radio/src/audio_arm.h +++ b/radio/src/audio_arm.h @@ -358,6 +358,7 @@ enum AutomaticPromptsEvents { }; void pushPrompt(uint16_t prompt, uint8_t id=0); +void playModelName(); #define I18N_PLAY_FUNCTION(lng, x, ...) void lng ## _ ## x(__VA_ARGS__, uint8_t id) #define PLAY_FUNCTION(x, ...) void x(__VA_ARGS__, uint8_t id) diff --git a/radio/src/bitmaps/9x/CMakeLists.txt b/radio/src/bitmaps/9x/CMakeLists.txt new file mode 100644 index 00000000000..862df045873 --- /dev/null +++ b/radio/src/bitmaps/9x/CMakeLists.txt @@ -0,0 +1,4 @@ +add_bitmaps_target(9x_xbm_1bit ${RADIO_SRC_DIRECTORY}/bitmaps/*.xbm 128 1bit) +add_bitmaps_target(9x_fonts_1bit ${RADIO_SRC_DIRECTORY}/fonts/std/*.png 128 "") +add_bitmaps_target(9x_bitmaps ${RADIO_SRC_DIRECTORY}/bitmaps/9x/*.png 128 1bit) +add_dependencies(9x_bitmaps 9x_fonts_1bit 9x_xbm_1bit) diff --git a/radio/src/bitmaps/horus/CMakeLists.txt b/radio/src/bitmaps/horus/CMakeLists.txt new file mode 100644 index 00000000000..2541fb9c9b8 --- /dev/null +++ b/radio/src/bitmaps/horus/CMakeLists.txt @@ -0,0 +1,12 @@ +add_truetype_font_target(horus tinsize "DejaVu Sans" 9) +add_truetype_font_target(horus smlsize "DejaVu Sans" 13) +add_truetype_font_target(horus stdsize "DejaVu Sans" 16) +add_truetype_font_target(horus midsize "DejaVu Sans" 24) +add_truetype_font_target(horus dblsize "DejaVu Sans" 32) +add_truetype_font_target(horus xxlsize "DejaVu Sans" 48) + +add_bitmaps_target(horus_bitmaps "${RADIO_SRC_DIRECTORY}/bitmaps/horus/????[^_]*.png" 480 5/6/5/8) +add_bitmaps_target(horus_masks ${RADIO_SRC_DIRECTORY}/bitmaps/horus/mask_*.png 480 8bits) +add_bitmaps_target(horus_fonts ${RADIO_SRC_DIRECTORY}/fonts/horus/*.png 480 8bits) +add_dependencies(horus_fonts ttf_horus_tinsize ttf_horus_smlsize ttf_horus_stdsize ttf_horus_midsize ttf_horus_dblsize ttf_horus_xxlsize) +add_dependencies(horus_bitmaps horus_masks horus_fonts) diff --git a/radio/src/bitmaps/taranis/CMakeLists.txt b/radio/src/bitmaps/taranis/CMakeLists.txt new file mode 100644 index 00000000000..97f2f2f065d --- /dev/null +++ b/radio/src/bitmaps/taranis/CMakeLists.txt @@ -0,0 +1,4 @@ +add_bitmaps_target(taranis_xbm_1bit ${RADIO_SRC_DIRECTORY}/bitmaps/*.xbm 128 1bit) +add_bitmaps_target(taranis_fonts_1bit ${RADIO_SRC_DIRECTORY}/fonts/std/*.png 128 "") +add_bitmaps_target(taranis_bitmaps ${RADIO_SRC_DIRECTORY}/bitmaps/taranis/*.png 212 4bits) +add_dependencies(taranis_bitmaps taranis_fonts_1bit taranis_xbm_1bit) \ No newline at end of file diff --git a/radio/src/crc16.cpp b/radio/src/crc16.cpp index 301b4576051..37b861f0e69 100644 --- a/radio/src/crc16.cpp +++ b/radio/src/crc16.cpp @@ -34,6 +34,8 @@ * */ +#include + /* CRC16 implementation according to CCITT standards */ static const unsigned short crc16tab[256]= { 0x0000,0x1021,0x2042,0x3063,0x4084,0x50a5,0x60c6,0x70e7, diff --git a/radio/src/debug.h b/radio/src/debug.h index db2591144df..a0c67e3f47a 100644 --- a/radio/src/debug.h +++ b/radio/src/debug.h @@ -49,10 +49,6 @@ #if defined(__cplusplus) extern "C" { #endif -uint8_t serial2TracesEnabled(); -#if defined(__cplusplus) -} -#endif #if defined(SIMU) typedef void (*traceCallbackFunc)(const char * text); @@ -61,13 +57,19 @@ void debugPrintf(const char * format, ...); #elif defined(DEBUG) && defined(CLI) && defined(USB_SERIAL) #define debugPrintf(...) do { if (cliTracesEnabled) serialPrintf(__VA_ARGS__); } while(0) #elif defined(DEBUG) && defined(CLI) +uint8_t serial2TracesEnabled(); #define debugPrintf(...) do { if (serial2TracesEnabled() && cliTracesEnabled) serialPrintf(__VA_ARGS__); } while(0) #elif defined(DEBUG) && defined(CPUARM) +uint8_t serial2TracesEnabled(); #define debugPrintf(...) do { if (serial2TracesEnabled()) serialPrintf(__VA_ARGS__); } while(0) #else #define debugPrintf(...) #endif +#if defined(__cplusplus) +} +#endif + #define TRACE(...) do { debugPrintf(__VA_ARGS__); debugPrintf("\r\n"); } while(0) #define DUMP(data, size) dump(data, size) #define TRACE_DEBUG(...) debugPrintf("-D- " __VA_ARGS__) diff --git a/radio/src/fonts/horus/font_dblsize.png b/radio/src/fonts/horus/font_dblsize.png index d617ab223b5..2eb8ec6a2c4 100644 Binary files a/radio/src/fonts/horus/font_dblsize.png and b/radio/src/fonts/horus/font_dblsize.png differ diff --git a/radio/src/fonts/horus/font_dblsize.specs b/radio/src/fonts/horus/font_dblsize.specs index 8129cf4eda5..44eca3c7221 100644 --- a/radio/src/fonts/horus/font_dblsize.specs +++ b/radio/src/fonts/horus/font_dblsize.specs @@ -1 +1 @@ -{ 0,4,14,28,54,76,110,139,146,160,173,193,217,228,242,251,266,289,310,331,352,375,397,420,441,464,487,497,508,532,556,580,598,613,641,665,689,715,736,757,783,808,818,832,859,880,910,935,963,987,1015,1040,1062,1087,1112,1140,1178,1206,1234,1258,1272,1287,1300,1324,1343,1356,1378,1401,1420,1443,1466,1484,1507,1529,1539,1553,1576,1586,1618,1640,1663,1686,1709,1726,1746,1764,1786,1810,1841,1865,1889,1909,1933,1936,1960,1988,2015,2033,2051,2074,2097,2120,2143,2171 } \ No newline at end of file +{ 0,4,11,23,49,68,99,124,130,141,152,171,195,204,216,223,237,257,275,294,313,334,353,373,392,412,432,440,449,473,497,521,537,550,575,595,618,641,660,677,702,723,730,742,764,782,807,828,854,873,899,921,941,965,987,1012,1045,1069,1093,1116,1127,1141,1151,1175,1196,1208,1227,1247,1265,1285,1305,1320,1340,1359,1365,1375,1395,1401,1431,1450,1470,1490,1510,1525,1543,1558,1577,1598,1625,1646,1667,1685,1709,1712,1736,1764,1791,1809,1827,1849,1871,1893,1915,1943 } \ No newline at end of file diff --git a/radio/src/fonts/horus/font_midsize.png b/radio/src/fonts/horus/font_midsize.png index f1bc88d935d..bac14ea4e2e 100644 Binary files a/radio/src/fonts/horus/font_midsize.png and b/radio/src/fonts/horus/font_midsize.png differ diff --git a/radio/src/fonts/horus/font_smlsize.png b/radio/src/fonts/horus/font_smlsize.png index 338e064bb5e..c64e6b721ac 100644 Binary files a/radio/src/fonts/horus/font_smlsize.png and b/radio/src/fonts/horus/font_smlsize.png differ diff --git a/radio/src/fonts/horus/font_stdsize.png b/radio/src/fonts/horus/font_stdsize.png index 02cdc828424..53e33e02e7d 100644 Binary files a/radio/src/fonts/horus/font_stdsize.png and b/radio/src/fonts/horus/font_stdsize.png differ diff --git a/radio/src/fonts/horus/font_tinsize.png b/radio/src/fonts/horus/font_tinsize.png index be586e83560..ebcc00fd322 100644 Binary files a/radio/src/fonts/horus/font_tinsize.png and b/radio/src/fonts/horus/font_tinsize.png differ diff --git a/radio/src/fonts/horus/font_xxlsize.png b/radio/src/fonts/horus/font_xxlsize.png index f9752d0a8c2..d419789c7b0 100644 Binary files a/radio/src/fonts/horus/font_xxlsize.png and b/radio/src/fonts/horus/font_xxlsize.png differ diff --git a/radio/src/gui/9x/menu_general.cpp b/radio/src/gui/9x/menu_general.cpp index 89c8a820307..14fc042a2f4 100644 --- a/radio/src/gui/9x/menu_general.cpp +++ b/radio/src/gui/9x/menu_general.cpp @@ -36,36 +36,6 @@ #include "../../opentx.h" -#if defined(CPUARM) -extern LP_CONST LanguagePack czLanguagePack; -extern LP_CONST LanguagePack enLanguagePack; -extern LP_CONST LanguagePack esLanguagePack; -extern LP_CONST LanguagePack frLanguagePack; -extern LP_CONST LanguagePack deLanguagePack; -extern LP_CONST LanguagePack itLanguagePack; -extern LP_CONST LanguagePack plLanguagePack; -extern LP_CONST LanguagePack ptLanguagePack; -extern LP_CONST LanguagePack skLanguagePack; -extern LP_CONST LanguagePack seLanguagePack; -extern LP_CONST LanguagePack huLanguagePack; - -const LanguagePack * LP_CONST languagePacks[] = { - // alphabetical order - &czLanguagePack, - &deLanguagePack, - &enLanguagePack, - &esLanguagePack, - &frLanguagePack, - &huLanguagePack, - &itLanguagePack, - &plLanguagePack, - &ptLanguagePack, - &seLanguagePack, - &skLanguagePack, - NULL -}; -#endif - void menuGeneralSetup(uint8_t event); void menuGeneralSdManager(uint8_t event); void menuGeneralCustomFunctions(uint8_t event); diff --git a/radio/src/gui/9x/menu_general_setup.cpp b/radio/src/gui/9x/menu_general_setup.cpp index f0bb13a3ee6..f4aaa1a86be 100644 --- a/radio/src/gui/9x/menu_general_setup.cpp +++ b/radio/src/gui/9x/menu_general_setup.cpp @@ -37,7 +37,7 @@ #include "../../opentx.h" const pm_uchar sticks[] PROGMEM = { -#include "../../bitmaps/sticks.lbm" +#include "sticks.lbm" }; #define RADIO_SETUP_2ND_COLUMN (LCD_W-6*FW-3-MENUS_SCROLLBAR_WIDTH) diff --git a/radio/src/gui/9x/popups.cpp b/radio/src/gui/9x/popups.cpp index 90689af6713..cd02dce1f4b 100644 --- a/radio/src/gui/9x/popups.cpp +++ b/radio/src/gui/9x/popups.cpp @@ -69,6 +69,10 @@ void displayPopup(const pm_char * pstr) lcdRefresh(); } +const pm_uchar asterisk_lbm[] PROGMEM = { +#include "asterisk.lbm" +}; + void message(const pm_char *title, const pm_char *t, const char *last MESSAGE_SOUND_ARG) { lcdClear(); diff --git a/radio/src/gui/horus/bitmaps.cpp b/radio/src/gui/horus/bitmaps.cpp index 6667eaaab05..f1d11b53c80 100644 --- a/radio/src/gui/horus/bitmaps.cpp +++ b/radio/src/gui/horus/bitmaps.cpp @@ -41,23 +41,23 @@ */ const uint8_t LBM_TOPMENU_POLYGON[] = { -#include "../../bitmaps/horus/mask_topmenu_polygon.lbm" +#include "mask_topmenu_polygon.lbm" }; const uint8_t LBM_DOT[] = { -#include "../../bitmaps/horus/mask_dot.lbm" +#include "mask_dot.lbm" }; const uint8_t LBM_CURRENT_BG[] = { -#include "../../bitmaps/horus/mask_current_bg.lbm" +#include "mask_current_bg.lbm" }; const uint8_t LBM_CURRENT_SHADOW[] = { -#include "../../bitmaps/horus/mask_current_shadow.lbm" +#include "mask_current_shadow.lbm" }; const uint8_t LBM_CURRENT_DOT[] = { -#include "../../bitmaps/horus/mask_current_dot.lbm" +#include "mask_current_dot.lbm" }; /* @@ -65,35 +65,35 @@ const uint8_t LBM_CURRENT_DOT[] = { */ const uint8_t LBM_MAINVIEW_BACKGROUND[] = { -#include "../../bitmaps/horus/background.lbm" +#include "background.lbm" }; const uint8_t LBM_TOPMENU_OPENTX[] = { -#include "../../bitmaps/horus/mask_topmenu_opentx.lbm" +#include "mask_topmenu_opentx.lbm" }; const uint8_t LBM_TOPMENU_USB[] = { -#include "../../bitmaps/horus/mask_topmenu_usb.lbm" +#include "mask_topmenu_usb.lbm" }; const uint8_t LBM_HTRIM_FRAME[] = { -#include "../../bitmaps/horus/mask_htrim_frame.lbm" +#include "mask_htrim_frame.lbm" }; const uint8_t LBM_VTRIM_FRAME[] = { -#include "../../bitmaps/horus/mask_vtrim_frame.lbm" +#include "mask_vtrim_frame.lbm" }; const uint8_t LBM_TRIM_SHADOW[] = { -#include "../../bitmaps/horus/mask_trim_shadow.lbm" +#include "mask_trim_shadow.lbm" }; const uint8_t LBM_TIMER_BACKGROUND[] = { -#include "../../bitmaps/horus/mask_timer_bg.lbm" +#include "mask_timer_bg.lbm" }; const uint8_t LBM_RSCALE[] = { -#include "../../bitmaps/horus/mask_rscale.lbm" +#include "mask_rscale.lbm" }; /* @@ -101,31 +101,31 @@ const uint8_t LBM_RSCALE[] = { */ const uint8_t LBM_RADIO_ICON[] = { -#include "../../bitmaps/horus/mask_menu_radio.lbm" +#include "mask_menu_radio.lbm" }; const uint8_t LBM_RADIO_SETUP_ICON[] = { -#include "../../bitmaps/horus/mask_radio_setup.lbm" +#include "mask_radio_setup.lbm" }; const uint8_t LBM_SD_BROWSER_ICON[] = { -#include "../../bitmaps/horus/mask_sd_browser.lbm" +#include "mask_sd_browser.lbm" }; const uint8_t LBM_GLOBAL_FUNCTIONS_ICON[] = { -#include "../../bitmaps/horus/mask_global_functions.lbm" +#include "mask_global_functions.lbm" }; const uint8_t LBM_TRAINER_ICON[] = { -#include "../../bitmaps/horus/mask_trainer.lbm" +#include "mask_trainer.lbm" }; const uint8_t LBM_CALIBRATION_ICON[] = { -#include "../../bitmaps/horus/mask_calibration.lbm" +#include "mask_calibration.lbm" }; const uint8_t LBM_VERSION_ICON[] = { -#include "../../bitmaps/horus/mask_version.lbm" +#include "mask_version.lbm" }; const uint8_t * const LBM_RADIO_ICONS[] = { @@ -143,55 +143,55 @@ const uint8_t * const LBM_RADIO_ICONS[] = { */ const uint8_t LBM_MODEL_ICON[] = { -#include "../../bitmaps/horus/mask_menu_model.lbm" +#include "mask_menu_model.lbm" }; const uint8_t LBM_MODEL_SETUP_ICON[] = { -#include "../../bitmaps/horus/mask_model_setup.lbm" +#include "mask_model_setup.lbm" }; const uint8_t LBM_HELI_ICON[] = { -#include "../../bitmaps/horus/mask_heli.lbm" +#include "mask_heli.lbm" }; const uint8_t LBM_FLIGHT_MODES_ICON[] = { -#include "../../bitmaps/horus/mask_flight_modes.lbm" +#include "mask_flight_modes.lbm" }; const uint8_t LBM_INPUTS_ICON[] = { -#include "../../bitmaps/horus/mask_inputs.lbm" +#include "mask_inputs.lbm" }; const uint8_t LBM_MIXER_ICON[] = { -#include "../../bitmaps/horus/mask_mixer.lbm" +#include "mask_mixer.lbm" }; const uint8_t LBM_OUTPUTS_ICON[] = { -#include "../../bitmaps/horus/mask_outputs.lbm" +#include "mask_outputs.lbm" }; const uint8_t LBM_CURVES_ICON[] = { -#include "../../bitmaps/horus/mask_curves.lbm" +#include "mask_curves.lbm" }; const uint8_t LBM_GVARS_ICON[] = { -#include "../../bitmaps/horus/mask_gvars.lbm" +#include "mask_gvars.lbm" }; const uint8_t LBM_LOGICAL_SWITCHES_ICON[] = { -#include "../../bitmaps/horus/mask_logical_switches.lbm" +#include "mask_logical_switches.lbm" }; const uint8_t LBM_SPECIAL_FUNCTIONS_ICON[] = { -#include "../../bitmaps/horus/mask_special_functions.lbm" +#include "mask_special_functions.lbm" }; const uint8_t LBM_LUA_SCRIPTS_ICON[] = { -#include "../../bitmaps/horus/mask_lua_scripts.lbm" +#include "mask_lua_scripts.lbm" }; const uint8_t LBM_TELEMETRY_ICON[] = { -#include "../../bitmaps/horus/mask_telemetry.lbm" +#include "mask_telemetry.lbm" }; const uint8_t * const LBM_MODEL_ICONS[] = { @@ -217,31 +217,31 @@ const uint8_t * const LBM_MODEL_ICONS[] = { */ const uint8_t LBM_LIBRARY_ICON[] = { -#include "../../bitmaps/horus/mask_library.lbm" +#include "mask_library.lbm" }; const uint8_t LBM_LIBRARY_SLOT[] = { -#include "../../bitmaps/horus/mask_library_slot.lbm" +#include "mask_library_slot.lbm" }; const uint8_t LBM_LIBRARY_CURSOR[] = { -#include "../../bitmaps/horus/mask_library_category_index.lbm" +#include "mask_library_category_index.lbm" }; const uint8_t LBM_SCORE0[] = { -#include "../../bitmaps/horus/mask_library_score_0.lbm" +#include "mask_library_score_0.lbm" }; const uint8_t LBM_SCORE1[] = { -#include "../../bitmaps/horus/mask_library_score_1.lbm" +#include "mask_library_score_1.lbm" }; const uint8_t LBM_STAR0[] = { -#include "../../bitmaps/horus/mask_library_star_0.lbm" +#include "mask_library_star_0.lbm" }; const uint8_t LBM_STAR1[] = { -#include "../../bitmaps/horus/mask_library_star_1.lbm" +#include "mask_library_star_1.lbm" }; /* @@ -249,21 +249,21 @@ const uint8_t LBM_STAR1[] = { */ const uint8_t LBM_ASTERISK[] = { -#include "../../bitmaps/horus/asterisk.lbm" +#include "asterisk.lbm" }; const uint8_t LBM_POINT[] = { -#include "../../bitmaps/horus/mask_point.lbm" +#include "mask_point.lbm" }; const uint8_t LBM_CURVE_POINT[] = { -#include "../../bitmaps/horus/mask_cvpoint.lbm" +#include "mask_cvpoint.lbm" }; const uint8_t LBM_CURVE_POINT_CENTER[] = { -#include "../../bitmaps/horus/mask_cvpoint_center.lbm" +#include "mask_cvpoint_center.lbm" }; const uint8_t LBM_CURVE_COORD_SHADOW[] = { -#include "../../bitmaps/horus/mask_coord_shadow.lbm" +#include "mask_coord_shadow.lbm" }; diff --git a/radio/src/gui/horus/curves.cpp b/radio/src/gui/horus/curves.cpp index 63799a425c0..4782d27116c 100644 --- a/radio/src/gui/horus/curves.cpp +++ b/radio/src/gui/horus/curves.cpp @@ -34,6 +34,8 @@ * */ +#include "../../opentx.h" + coord_t getCurveYCoord(FnFuncP fn, coord_t x) { return limit(0, CURVE_CENTER_Y - divRoundClosest(fn(divRoundClosest(x * RESX, CURVE_SIDE_WIDTH)) * CURVE_SIDE_WIDTH, RESX), LCD_H-1); diff --git a/radio/src/gui/horus/fonts.cpp b/radio/src/gui/horus/fonts.cpp index be7b0b77005..a3d7a1402b4 100644 --- a/radio/src/gui/horus/fonts.cpp +++ b/radio/src/gui/horus/fonts.cpp @@ -37,51 +37,51 @@ #include "../../opentx.h" const uint16_t font_tinsize_specs[] PROGMEM = -#include "../../fonts/horus/font_tinsize.specs" +#include "font_tinsize.specs" ; const pm_uchar font_tinsize[] PROGMEM = { -#include "fonts/horus/font_tinsize.lbm" +#include "font_tinsize.lbm" }; const uint16_t font_smlsize_specs[] PROGMEM = -#include "../../fonts/horus/font_smlsize.specs" +#include "font_smlsize.specs" ; const pm_uchar font_smlsize[] PROGMEM = { -#include "fonts/horus/font_smlsize.lbm" +#include "font_smlsize.lbm" }; const uint16_t font_stdsize_specs[] PROGMEM = -#include "../../fonts/horus/font_stdsize.specs" +#include "font_stdsize.specs" ; const pm_uchar font_stdsize[] PROGMEM = { -#include "fonts/horus/font_stdsize.lbm" +#include "font_stdsize.lbm" }; const uint16_t font_midsize_specs[] PROGMEM = -#include "../../fonts/horus/font_midsize.specs" +#include "font_midsize.specs" ; const pm_uchar font_midsize[] PROGMEM = { -#include "fonts/horus/font_midsize.lbm" +#include "font_midsize.lbm" }; const uint16_t font_dblsize_specs[] PROGMEM = -#include "../../fonts/horus/font_dblsize.specs" +#include "font_dblsize.specs" ; const pm_uchar font_dblsize[] PROGMEM = { -#include "fonts/horus/font_dblsize.lbm" +#include "font_dblsize.lbm" }; const uint16_t font_xxlsize_specs[] PROGMEM = -#include "../../fonts/horus/font_xxlsize.specs" +#include "font_xxlsize.specs" ; const pm_uchar font_xxlsize[] PROGMEM = { -#include "fonts/horus/font_xxlsize.lbm" +#include "font_xxlsize.lbm" }; const uint16_t *fontspecsTable[16] = { font_stdsize_specs, font_tinsize_specs, font_smlsize_specs, font_midsize_specs, font_dblsize_specs, font_xxlsize_specs }; diff --git a/radio/src/gui/horus/gui.h b/radio/src/gui/horus/gui.h index 79633aa281a..41038345287 100644 --- a/radio/src/gui/horus/gui.h +++ b/radio/src/gui/horus/gui.h @@ -34,8 +34,8 @@ * */ -#include "../horus/lcd.h" -#include "../horus/menus.h" +#include "lcd.h" +#include "menus.h" #define MENU_HEADER_HEIGHT 45 #define MENU_TITLE_TOP 48 @@ -84,11 +84,15 @@ void displayScreenIndex(uint8_t index, uint8_t count); void drawVerticalScrollbar(coord_t x, coord_t y, coord_t h, uint16_t offset, uint16_t count, uint8_t visible); void drawHorizontalScrollbar(coord_t x, coord_t y, coord_t w, uint16_t offset, uint16_t count, uint8_t visible); void drawHeader(int index); +void drawColumnHeader(const char * const * headers, uint8_t index); void drawFooter(); #define drawStatusLine(...) void drawProgressBar(const char *label); void updateProgressBar(int num, int den); void drawTopmenuDatetime(); +void drawSubmenuTemplate(const char * name, uint16_t scrollbar_X); +void drawStick(coord_t centrex, int16_t xval, int16_t yval); +void drawSticks(); // Curve functions coord_t getCurveYCoord(FnFuncP fn, coord_t x); diff --git a/radio/src/gui/horus/lcd.cpp b/radio/src/gui/horus/lcd.cpp index 8d4cc3e310f..14f413968a1 100644 --- a/radio/src/gui/horus/lcd.cpp +++ b/radio/src/gui/horus/lcd.cpp @@ -34,6 +34,8 @@ * */ +#include +#include #include "../../opentx.h" #if defined(SIMU) @@ -608,7 +610,6 @@ void putsSwitches(coord_t x, coord_t y, int8_t idx, LcdFlags att) } } -#if defined(FLIGHT_MODES) void putsFlightMode(coord_t x, coord_t y, int8_t idx, LcdFlags att) { if (idx==0) { @@ -618,7 +619,6 @@ void putsFlightMode(coord_t x, coord_t y, int8_t idx, LcdFlags att) putsStrIdx(x, y, STR_FP, abs(idx)-1, att); } } -#endif void putsCurveRef(coord_t x, coord_t y, CurveRef &curve, LcdFlags att) { diff --git a/radio/src/gui/horus/menu_general.cpp b/radio/src/gui/horus/menu_general.cpp index 2f3fcd35103..34293d3f305 100644 --- a/radio/src/gui/horus/menu_general.cpp +++ b/radio/src/gui/horus/menu_general.cpp @@ -36,59 +36,6 @@ #include "../../opentx.h" -extern LP_CONST LanguagePack czLanguagePack; -extern LP_CONST LanguagePack enLanguagePack; -extern LP_CONST LanguagePack esLanguagePack; -extern LP_CONST LanguagePack frLanguagePack; -extern LP_CONST LanguagePack deLanguagePack; -extern LP_CONST LanguagePack itLanguagePack; -extern LP_CONST LanguagePack plLanguagePack; -extern LP_CONST LanguagePack ptLanguagePack; -extern LP_CONST LanguagePack skLanguagePack; -extern LP_CONST LanguagePack seLanguagePack; -extern LP_CONST LanguagePack huLanguagePack; - -const LanguagePack * LP_CONST languagePacks[] = { - // alphabetical order - &czLanguagePack, - &deLanguagePack, - &enLanguagePack, - &esLanguagePack, - &frLanguagePack, - &huLanguagePack, - &itLanguagePack, - &plLanguagePack, - &ptLanguagePack, - &seLanguagePack, - &skLanguagePack, - NULL -}; - -bool menuGeneralSetup(evt_t event); -bool menuGeneralSdManager(evt_t event); -bool menuGeneralCustomFunctions(evt_t event); -bool menuGeneralTrainer(evt_t event); -bool menuGeneralVersion(evt_t event); -bool menuGeneralCalib(evt_t event); - -enum EnumTabDiag { - e_Setup, - e_Sd, - e_GeneralCustomFunctions, - e_Trainer, - e_Calib, - e_Vers, -}; - -const MenuHandlerFunc menuTabGeneral[] PROGMEM = { - menuGeneralSetup, - menuGeneralSdManager, - menuGeneralCustomFunctions, - menuGeneralTrainer, - menuGeneralCalib, - menuGeneralVersion, -}; - bool menuGeneralCustomFunctions(evt_t event) { MENU(STR_MENUGLOBALFUNCS, menuTabGeneral, e_GeneralCustomFunctions, NUM_CFN, DEFAULT_SCROLLBAR_X, { NAVIGATION_LINE_BY_LINE|4/*repeated*/ }); diff --git a/radio/src/gui/horus/menu_general_sdmanager.cpp b/radio/src/gui/horus/menu_general_sdmanager.cpp index 6a335b5234c..68b76c247f5 100644 --- a/radio/src/gui/horus/menu_general_sdmanager.cpp +++ b/radio/src/gui/horus/menu_general_sdmanager.cpp @@ -34,6 +34,7 @@ * */ +#include #include "../../opentx.h" #define REFRESH_FILES() do { reusableBuffer.sdmanager.offset = 65535; lastBitmap = -1; } while (0) diff --git a/radio/src/gui/horus/menu_general_setup.cpp b/radio/src/gui/horus/menu_general_setup.cpp index 85a87696197..6d2440c2145 100644 --- a/radio/src/gui/horus/menu_general_setup.cpp +++ b/radio/src/gui/horus/menu_general_setup.cpp @@ -59,8 +59,8 @@ #endif enum menuGeneralSetupItems { - CASE_RTCLOCK(ITEM_SETUP_DATE) - CASE_RTCLOCK(ITEM_SETUP_TIME) + ITEM_SETUP_DATE, + ITEM_SETUP_TIME, // ITEM_SETUP_BATT_RANGE, ITEM_SETUP_SOUND_LABEL, ITEM_SETUP_BEEP_MODE, diff --git a/radio/src/gui/horus/menu_model.cpp b/radio/src/gui/horus/menu_model.cpp index 9b506e7741c..c71d876c25d 100644 --- a/radio/src/gui/horus/menu_model.cpp +++ b/radio/src/gui/horus/menu_model.cpp @@ -35,48 +35,10 @@ #include "../../opentx.h" -enum EnumTabModel { - // e_ModelSelect, - e_ModelSetup, - CASE_HELI(e_Heli) - CASE_FLIGHT_MODES(e_FlightModesAll) - e_InputsAll, - e_MixAll, - e_Limits, - CASE_CURVES(e_CurvesAll) - CASE_GVARS(e_GVars) - e_LogicalSwitches, - e_CustomFunctions, -#if defined(LUA_MODEL_SCRIPTS) - e_CustomScripts, -#endif - CASE_FRSKY(e_Telemetry) -}; - -bool menuModelSelect(evt_t event); -bool menuModelSetup(evt_t event); -bool menuModelHeli(evt_t event); -bool menuModelFlightModesAll(evt_t event); -bool menuModelExposAll(evt_t event); -bool menuModelMixAll(evt_t event); -bool menuModelLimits(evt_t event); -bool menuModelCurvesAll(evt_t event); -bool menuModelCurveOne(evt_t event); -bool menuModelGVars(evt_t event); -bool menuModelLogicalSwitches(evt_t event); -bool menuModelCustomFunctions(evt_t event); -bool menuModelCustomScripts(evt_t event); -bool menuModelTelemetry(evt_t event); -bool menuModelExpoOne(evt_t event); - extern uint8_t s_curveChan; -#define FlightModesType uint16_t - void editCurveRef(coord_t x, coord_t y, CurveRef & curve, evt_t event, uint8_t attr); -#define MIXES_2ND_COLUMN 100 - uint8_t editDelay(const coord_t x, const coord_t y, const evt_t event, const uint8_t attr, uint8_t delay) { lcdDrawNumber(x+MIXES_2ND_COLUMN, y, (10/DELAY_STEP)*delay, attr|PREC1|LEFT); @@ -84,35 +46,11 @@ uint8_t editDelay(const coord_t x, const coord_t y, const evt_t event, const uin return delay; } -const MenuHandlerFunc menuTabModel[] = { -// menuModelSelect, - menuModelSetup, - CASE_HELI(menuModelHeli) - CASE_FLIGHT_MODES(menuModelFlightModesAll) - menuModelExposAll, - menuModelMixAll, - menuModelLimits, - CASE_CURVES(menuModelCurvesAll) -#if defined(GVARS) && defined(FLIGHT_MODES) - CASE_GVARS(menuModelGVars) -#endif - menuModelLogicalSwitches, - menuModelCustomFunctions, -#if defined(LUA_MODEL_SCRIPTS) - menuModelCustomScripts, -#endif - CASE_FRSKY(menuModelTelemetry) - CASE_MAVLINK(menuTelemetryMavlinkSetup) - CASE_TEMPLATES(menuModelTemplates) -}; - -#define COPY_MODE 1 -#define MOVE_MODE 2 -static uint8_t s_copyMode = 0; -static int8_t s_copySrcRow; -static int8_t s_copyTgtOfs; - -static uint8_t editNameCursorPos = 0; +uint8_t s_copyMode = 0; +int8_t s_copySrcRow; +int8_t s_copyTgtOfs; + +uint8_t editNameCursorPos = 0; void editName(coord_t x, coord_t y, char * name, uint8_t size, evt_t event, uint8_t active, LcdFlags flags) { @@ -216,4 +154,12 @@ void editName(coord_t x, coord_t y, char * name, uint8_t size, evt_t event, uint } } -static uint8_t s_currIdx; +uint8_t s_currIdx; + +void copySelection(char * dst, const char * src, uint8_t size) +{ + if (memcmp(src, "---", 3) == 0) + memset(dst, 0, size); + else + memcpy(dst, src, size); +} diff --git a/radio/src/gui/horus/menu_model_curves.cpp b/radio/src/gui/horus/menu_model_curves.cpp index bc852d4b4f1..0bb229f8f97 100644 --- a/radio/src/gui/horus/menu_model_curves.cpp +++ b/radio/src/gui/horus/menu_model_curves.cpp @@ -33,6 +33,7 @@ * */ +#include #include "../../opentx.h" uint8_t s_curveChan; diff --git a/radio/src/gui/horus/menu_model_flightmodes.cpp b/radio/src/gui/horus/menu_model_flightmodes.cpp index bd8ac690038..cfc8f1aef7e 100644 --- a/radio/src/gui/horus/menu_model_flightmodes.cpp +++ b/radio/src/gui/horus/menu_model_flightmodes.cpp @@ -33,6 +33,7 @@ * */ +#include #include "../../opentx.h" enum FlightModesItems { @@ -73,7 +74,7 @@ bool menuModelFlightModesAll(evt_t event) } if (sub=0) { - displayColumnHeader(STR_PHASES_HEADERS, posHorz); + drawColumnHeader(STR_PHASES_HEADERS, posHorz); } for (int i=0; i #include "../../opentx.h" #define EXPO_ONE_2ND_COLUMN 110 diff --git a/radio/src/gui/horus/menu_model_limits.cpp b/radio/src/gui/horus/menu_model_limits.cpp index e0102d19a0c..67fc3e5a16b 100644 --- a/radio/src/gui/horus/menu_model_limits.cpp +++ b/radio/src/gui/horus/menu_model_limits.cpp @@ -137,7 +137,7 @@ bool menuModelLimits(evt_t event) } if (sub=0) { - displayColumnHeader(STR_LIMITS_HEADERS, menuHorizontalPosition); + drawColumnHeader(STR_LIMITS_HEADERS, menuHorizontalPosition); } if (warningResult) { diff --git a/radio/src/gui/horus/menu_model_logical_switches.cpp b/radio/src/gui/horus/menu_model_logical_switches.cpp index 06198ee95f8..13222c7882f 100644 --- a/radio/src/gui/horus/menu_model_logical_switches.cpp +++ b/radio/src/gui/horus/menu_model_logical_switches.cpp @@ -33,6 +33,7 @@ * */ +#include #include "../../opentx.h" enum LogicalSwitchFields { @@ -54,11 +55,6 @@ enum LogicalSwitchFields { #define CSW_5TH_COLUMN 245 #define CSW_6TH_COLUMN 300 -#define INCDEC_DECLARE_VARS(f) uint8_t incdecFlag = (f); IsValueAvailable isValueAvailable = NULL -#define INCDEC_SET_FLAG(f) incdecFlag = (f) -#define INCDEC_ENABLE_CHECK(fn) isValueAvailable = fn -#define CHECK_INCDEC_PARAM(event, var, min, max) checkIncDec(event, var, min, max, incdecFlag, isValueAvailable) - void putsEdgeDelayParam(coord_t x, coord_t y, LogicalSwitchData *cs, uint8_t lattr, uint8_t rattr) { char s[32]; @@ -106,7 +102,7 @@ bool menuModelLogicalSwitches(evt_t event) horzpos_t horz = menuHorizontalPosition; if (sub>= 0 && horz>=0) { - displayColumnHeader(STR_CSW_HEADERS, horz); + drawColumnHeader(STR_CSW_HEADERS, horz); } if (horz<0 && event==EVT_KEY_LONG(KEY_ENTER) && !READ_ONLY()) { diff --git a/radio/src/gui/horus/menu_model_setup.cpp b/radio/src/gui/horus/menu_model_setup.cpp index 6eb11830549..5c74c483144 100644 --- a/radio/src/gui/horus/menu_model_setup.cpp +++ b/radio/src/gui/horus/menu_model_setup.cpp @@ -94,14 +94,6 @@ enum menuModelSetupItems { #define MODEL_SETUP_RANGE_OFS 40 #define MODEL_SETUP_SET_FAILSAFE_OFS 60 -void copySelection(char *dst, const char *src, uint8_t size) -{ - if (memcmp(src, "---", 3) == 0) - memset(dst, 0, size); - else - memcpy(dst, src, size); -} - void onModelSetupBitmapMenu(const char *result) { if (result == STR_UPDATE_LIST) { diff --git a/radio/src/gui/horus/menus.h b/radio/src/gui/horus/menus.h index 8d40f48167b..80a4b874281 100644 --- a/radio/src/gui/horus/menus.h +++ b/radio/src/gui/horus/menus.h @@ -47,6 +47,8 @@ #endif #define MENU_COLUMN2_X 280 +#define MIXES_2ND_COLUMN 100 +#define COLUMN_HEADER_X 150 typedef int16_t vertpos_t; @@ -69,8 +71,6 @@ extern uint8_t noHighlightCounter; void drawCheckBox(coord_t x, coord_t y, uint8_t value, LcdFlags attr); typedef bool (*MenuHandlerFunc)(evt_t event); -extern const MenuHandlerFunc menuTabModel[]; -extern const MenuHandlerFunc menuTabGeneral[]; extern MenuHandlerFunc menuHandlers[5]; extern uint8_t menuVerticalPositions[4]; @@ -84,16 +84,90 @@ void pushMenu(MenuHandlerFunc newMenu); /// return to last menu in menustack void popMenu(); -bool menuFirstCalib(evt_t event); +enum EnumTabModel { + // e_ModelSelect, + e_ModelSetup, + CASE_HELI(e_Heli) + CASE_FLIGHT_MODES(e_FlightModesAll) + e_InputsAll, + e_MixAll, + e_Limits, + CASE_CURVES(e_CurvesAll) + CASE_GVARS(e_GVars) + e_LogicalSwitches, + e_CustomFunctions, +#if defined(LUA_MODEL_SCRIPTS) + e_CustomScripts, +#endif + CASE_FRSKY(e_Telemetry) +}; + +bool menuModelSetup(evt_t event); +bool menuModelHeli(evt_t event); +bool menuModelFlightModesAll(evt_t event); +bool menuModelExposAll(evt_t event); +bool menuModelMixAll(evt_t event); +bool menuModelLimits(evt_t event); +bool menuModelCurvesAll(evt_t event); +bool menuModelCurveOne(evt_t event); +bool menuModelGVars(evt_t event); +bool menuModelLogicalSwitches(evt_t event); +bool menuModelCustomFunctions(evt_t event); +bool menuModelCustomScripts(evt_t event); +bool menuModelTelemetry(evt_t event); +bool menuModelExpoOne(evt_t event); + +const MenuHandlerFunc menuTabModel[] = { +// menuModelSelect, + menuModelSetup, + CASE_HELI(menuModelHeli) + CASE_FLIGHT_MODES(menuModelFlightModesAll) + menuModelExposAll, + menuModelMixAll, + menuModelLimits, + CASE_CURVES(menuModelCurvesAll) +#if defined(GVARS) && defined(FLIGHT_MODES) + CASE_GVARS(menuModelGVars) +#endif + menuModelLogicalSwitches, + menuModelCustomFunctions, +#if defined(LUA_MODEL_SCRIPTS) + menuModelCustomScripts, +#endif + CASE_FRSKY(menuModelTelemetry) + CASE_MAVLINK(menuTelemetryMavlinkSetup) + CASE_TEMPLATES(menuModelTemplates) +}; + +enum EnumTabDiag { + e_Setup, + e_Sd, + e_GeneralCustomFunctions, + e_Trainer, + e_Calib, + e_Vers, +}; -bool menuMainView(evt_t event); -bool menuGeneralDiagAna(evt_t event); bool menuGeneralSetup(evt_t event); +bool menuGeneralSdManager(evt_t event); +bool menuGeneralCustomFunctions(evt_t event); +bool menuGeneralTrainer(evt_t event); +bool menuGeneralVersion(evt_t event); bool menuGeneralCalib(evt_t event); + +static const MenuHandlerFunc menuTabGeneral[] PROGMEM = { + menuGeneralSetup, + menuGeneralSdManager, + menuGeneralCustomFunctions, + menuGeneralTrainer, + menuGeneralCalib, + menuGeneralVersion, +}; + +bool menuFirstCalib(evt_t event); +bool menuMainView(evt_t event); bool menuCustomFunctions(evt_t event, CustomFunctionData * functions, CustomFunctionsContext & functionsContext); bool menuModelSelect(evt_t event); -bool menuModelSetup(evt_t event); -bool menuModelCustomFunctions(evt_t event); bool menuStatisticsView(evt_t event); bool menuStatisticsDebug(evt_t event); bool menuAboutView(evt_t event); @@ -106,6 +180,8 @@ bool menuTextView(evt_t event); void menuTraceBuffer(evt_t event); #endif +typedef uint16_t FlightModesType; + extern int8_t checkIncDec_Ret; // global helper vars #define EDIT_SELECT_MENU -1 @@ -190,10 +266,15 @@ int8_t checkIncDecMovedSwitch(int8_t val); #define CHECK_INCDEC_GENVAR(event, var, min, max) \ var = checkIncDecGen(event, var, min, max) -#define NAVIGATION_LINE_BY_LINE 0x40 -#define CURSOR_ON_LINE() (menuHorizontalPosition<0) +#define NAVIGATION_LINE_BY_LINE 0x40 +#define CURSOR_ON_LINE() (menuHorizontalPosition<0) + +#define INCDEC_DECLARE_VARS(f) uint8_t incdecFlag = (f); IsValueAvailable isValueAvailable = NULL +#define INCDEC_SET_FLAG(f) incdecFlag = (f) +#define INCDEC_ENABLE_CHECK(fn) isValueAvailable = fn +#define CHECK_INCDEC_PARAM(event, var, min, max) \ + checkIncDec(event, var, min, max, incdecFlag, isValueAvailable) -#define CHECK_FLAG_NO_SCREEN_INDEX 1 bool navigate(evt_t event, int count, int rows, int columns=1); bool check(check_event_t event, uint8_t curr, const MenuHandlerFunc * menuTab, uint8_t menuTabSize, const pm_uint8_t *horTab, uint8_t horTabMax, vertpos_t maxrow, uint8_t flags=0); bool check_simple(check_event_t event, uint8_t curr, const MenuHandlerFunc * menuTab, uint8_t menuTabSize, vertpos_t maxrow); @@ -249,8 +330,14 @@ int8_t switchMenuItem(coord_t x, coord_t y, int8_t value, LcdFlags attr, evt_t e #define displayGVar(x, y, v, min, max) lcdDrawNumber(x, y, v) #endif +extern uint8_t editNameCursorPos; void editName(coord_t x, coord_t y, char *name, uint8_t size, evt_t event, uint8_t active, LcdFlags flags=ZCHAR); +uint8_t editDelay(const coord_t x, const coord_t y, const evt_t event, const uint8_t attr, uint8_t delay); +void editCurveRef(coord_t x, coord_t y, CurveRef & curve, evt_t event, uint8_t attr); + +extern uint8_t s_curveChan; + #define WARNING_TYPE_ASTERISK 0 #define WARNING_TYPE_CONFIRM 1 #define WARNING_TYPE_INPUT 2 @@ -261,6 +348,14 @@ extern uint8_t warningInfoLength; extern uint8_t warningResult; extern uint8_t warningType; +#define COPY_MODE 1 +#define MOVE_MODE 2 +extern uint8_t s_copyMode; + +extern int8_t s_copySrcRow; +extern int8_t s_copyTgtOfs; +extern uint8_t s_currIdx; + #define MENU_X 80 #define MENU_W LCD_W-(2*MENU_X) #define POPUP_X 130 @@ -272,11 +367,12 @@ extern uint8_t warningType; #define WARNING_LINE_Y (POPUP_Y+9) #define WARNING_INFOLINE_Y (WARNING_LINE_Y+68) -void displayBox(); -void displayPopup(const char *title); +void copySelection(char * dst, const char * src, uint8_t size); + +void displayPopup(const char * title); void displayWarning(evt_t event); -extern void (*popupFunc)(evt_t event); +extern void (* popupFunc)(evt_t event); extern int16_t warningInputValue; extern int16_t warningInputValueMin; extern int16_t warningInputValueMax; @@ -322,4 +418,6 @@ void pushModelNotes(); typedef int (*FnFuncP) (int x); void drawFunction(FnFuncP fn, int offset=0); +uint8_t switchToMix(uint8_t source); + #endif // _MENUS_H_ diff --git a/radio/src/gui/horus/widgets.cpp b/radio/src/gui/horus/widgets.cpp index 8e792e5a17f..2c010cf7ff3 100644 --- a/radio/src/gui/horus/widgets.cpp +++ b/radio/src/gui/horus/widgets.cpp @@ -37,14 +37,12 @@ #include "../../opentx.h" #include -#define COLUMN_HEADER_X 150 - -void displayHeader(const char *header) +void drawHeader(const char * header) { // TODO ? lcdDrawText(COLUMN_HEADER_X, MENU_FOOTER_TOP, header, HEADER_COLOR); } -void displayColumnHeader(const char * const *headers, uint8_t index) +void drawColumnHeader(const char * const * headers, uint8_t index) { // TODO ? displayHeader(headers[index]); } diff --git a/radio/src/gui/taranis/gui.h b/radio/src/gui/taranis/gui.h index 9df15c6623e..e086beb0c82 100644 --- a/radio/src/gui/taranis/gui.h +++ b/radio/src/gui/taranis/gui.h @@ -45,13 +45,28 @@ #define BITMAP_BUFFER_SIZE(width, height) (2 + (width) * (((height)+7)/8)*4) #define MODEL_BITMAP_WIDTH 64 #define MODEL_BITMAP_HEIGHT 32 + +#define WCHART (LCD_H/2) +#define X0 (LCD_W-WCHART-2) +#define Y0 (LCD_H/2) + +#define MENUS_SCROLLBAR_WIDTH 2 +#define MENU_COLUMN2_X (8 + LCD_W / 2) + +#if MENU_COLUMNS < 2 + #define MIXES_2ND_COLUMN (18*FW) +#else + #define MIXES_2ND_COLUMN (9*FW) +#endif + #define MODEL_BITMAP_SIZE BITMAP_BUFFER_SIZE(MODEL_BITMAP_WIDTH, MODEL_BITMAP_HEIGHT) +#define LOAD_MODEL_BITMAP() loadModelBitmap(g_model.header.bitmap, modelBitmap) + extern uint8_t modelBitmap[MODEL_BITMAP_SIZE]; bool loadModelBitmap(char * name, uint8_t * bitmap); -#define LOAD_MODEL_BITMAP() loadModelBitmap(g_model.header.bitmap, modelBitmap) struct MenuItem { - const char *name; + const char * name; const MenuHandlerFunc action; }; @@ -63,7 +78,11 @@ void displayMenuBar(const MenuItem *menu, int index); void drawProgressBar(const char *label); void updateProgressBar(int num, int den); void drawGauge(coord_t x, coord_t y, coord_t w, coord_t h, int32_t val, int32_t max); +void drawColumnHeader(const char * const * headers, uint8_t index); +void drawStick(coord_t centrex, int16_t xval, int16_t yval); extern coord_t scrollbar_X; #define SET_SCROLLBAR_X(x) scrollbar_X = (x); +extern const pm_uchar sticks[] PROGMEM; + diff --git a/radio/src/gui/taranis/menu_general.cpp b/radio/src/gui/taranis/menu_general.cpp index e6086a47823..0427351bfc3 100644 --- a/radio/src/gui/taranis/menu_general.cpp +++ b/radio/src/gui/taranis/menu_general.cpp @@ -36,70 +36,6 @@ #include "../../opentx.h" -extern LP_CONST LanguagePack czLanguagePack; -extern LP_CONST LanguagePack enLanguagePack; -extern LP_CONST LanguagePack esLanguagePack; -extern LP_CONST LanguagePack frLanguagePack; -extern LP_CONST LanguagePack deLanguagePack; -extern LP_CONST LanguagePack itLanguagePack; -extern LP_CONST LanguagePack nlLanguagePack; -extern LP_CONST LanguagePack plLanguagePack; -extern LP_CONST LanguagePack ptLanguagePack; -extern LP_CONST LanguagePack skLanguagePack; -extern LP_CONST LanguagePack seLanguagePack; -extern LP_CONST LanguagePack huLanguagePack; - -const LanguagePack * LP_CONST languagePacks[] = { - // alphabetical order - &czLanguagePack, - &deLanguagePack, - &enLanguagePack, - &esLanguagePack, - &frLanguagePack, - &huLanguagePack, - &itLanguagePack, - &nlLanguagePack, - &plLanguagePack, - &ptLanguagePack, - &seLanguagePack, - &skLanguagePack, - NULL -}; - -void menuGeneralSetup(uint8_t event); -void menuGeneralSdManager(uint8_t event); -void menuGeneralCustomFunctions(uint8_t event); -void menuGeneralTrainer(uint8_t event); -void menuGeneralVersion(uint8_t event); -void menuGeneralDiagKeys(uint8_t event); -void menuGeneralDiagAna(uint8_t event); -void menuGeneralHardware(uint8_t event); -void menuGeneralCalib(uint8_t event); - -enum EnumTabDiag { - e_Setup, - e_Sd, - e_GeneralCustomFunctions, - e_Trainer, - e_Vers, - e_Keys, - e_Ana, - e_Hardware, - e_Calib -}; - -const MenuHandlerFunc menuTabGeneral[] = { - menuGeneralSetup, - menuGeneralSdManager, - menuGeneralCustomFunctions, - menuGeneralTrainer, - menuGeneralVersion, - menuGeneralDiagKeys, - menuGeneralDiagAna, - menuGeneralHardware, - menuGeneralCalib -}; - void menuGeneralCustomFunctions(uint8_t event) { MENU(STR_MENUGLOBALFUNCS, menuTabGeneral, e_GeneralCustomFunctions, NUM_CFN, { NAVIGATION_LINE_BY_LINE|4/*repeated*/ }); diff --git a/radio/src/gui/taranis/menu_general_sdmanager.cpp b/radio/src/gui/taranis/menu_general_sdmanager.cpp index d8d8f148a26..beab39bf161 100644 --- a/radio/src/gui/taranis/menu_general_sdmanager.cpp +++ b/radio/src/gui/taranis/menu_general_sdmanager.cpp @@ -77,7 +77,7 @@ inline bool isFilenameLower(bool isfile, const char * fn, const char * line) return (!isfile && IS_FILE(line)) || (isfile==IS_FILE(line) && strcasecmp(fn, line) < 0); } -bool isBootloader(const char *filename) +bool isBootloader(const char * filename) { FIL file; f_open(&file, filename, FA_READ); diff --git a/radio/src/gui/taranis/menu_general_setup.cpp b/radio/src/gui/taranis/menu_general_setup.cpp index 8eacae7d2d5..cbf3c0e9687 100644 --- a/radio/src/gui/taranis/menu_general_setup.cpp +++ b/radio/src/gui/taranis/menu_general_setup.cpp @@ -37,7 +37,7 @@ #include "../../opentx.h" const pm_uchar sticks[] PROGMEM = { -#include "../../bitmaps/sticks.lbm" +#include "sticks.lbm" }; #define RADIO_SETUP_2ND_COLUMN (LCD_W-10*FW-MENUS_SCROLLBAR_WIDTH) diff --git a/radio/src/gui/taranis/menu_model.cpp b/radio/src/gui/taranis/menu_model.cpp index 9611408fbc3..967f17109f3 100644 --- a/radio/src/gui/taranis/menu_model.cpp +++ b/radio/src/gui/taranis/menu_model.cpp @@ -35,59 +35,6 @@ #include "../../opentx.h" -// TODO elsewhere! -#define WCHART (LCD_H/2) -#define X0 (LCD_W-WCHART-2) -#define Y0 (LCD_H/2) - -enum EnumTabModel { - e_ModelSelect, - e_ModelSetup, - CASE_HELI(e_Heli) - CASE_FLIGHT_MODES(e_FlightModesAll) - e_InputsAll, - e_MixAll, - e_Limits, - CASE_CURVES(e_CurvesAll) - CASE_GVARS(e_GVars) - e_LogicalSwitches, - e_CustomFunctions, -#if defined(LUA_MODEL_SCRIPTS) - e_CustomScripts, -#endif - CASE_FRSKY(e_Telemetry) - CASE_MAVLINK(e_MavSetup) - CASE_TEMPLATES(e_Templates) -}; - -void menuModelSelect(uint8_t event); -void menuModelSetup(uint8_t event); -void menuModelHeli(uint8_t event); -void menuModelFlightModesAll(uint8_t event); -void menuModelExposAll(uint8_t event); -void menuModelMixAll(uint8_t event); -void menuModelLimits(uint8_t event); -void menuModelCurvesAll(uint8_t event); -void menuModelCurveOne(uint8_t event); -void menuModelGVars(uint8_t event); -void menuModelLogicalSwitches(uint8_t event); -void menuModelCustomFunctions(uint8_t event); -void menuModelCustomScripts(uint8_t event); -void menuModelTelemetry(uint8_t event); -void menuModelExpoOne(uint8_t event); - -extern uint8_t s_curveChan; - -#define FlightModesType uint16_t - -void editCurveRef(coord_t x, coord_t y, CurveRef & curve, uint8_t event, uint8_t attr); - -#if MENU_COLUMNS < 2 - #define MIXES_2ND_COLUMN (18*FW) -#else - #define MIXES_2ND_COLUMN (9*FW) -#endif - #if MENU_COLUMNS > 1 uint8_t editDelay(const coord_t x, const coord_t y, const uint8_t event, const uint8_t attr, const pm_char *str, uint8_t delay) { @@ -96,7 +43,6 @@ uint8_t editDelay(const coord_t x, const coord_t y, const uint8_t event, const u if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, delay, DELAY_MAX); return delay; } -#define EDIT_DELAY(x, y, event, attr, str, delay) editDelay(x, y, event, attr, str, delay) #else uint8_t editDelay(const coord_t y, const uint8_t event, const uint8_t attr, const pm_char *str, uint8_t delay) { @@ -105,38 +51,15 @@ uint8_t editDelay(const coord_t y, const uint8_t event, const uint8_t attr, cons if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, delay, DELAY_MAX); return delay; } -#define EDIT_DELAY(x, y, event, attr, str, delay) editDelay(y, event, attr, str, delay) -#endif - -const MenuHandlerFunc menuTabModel[] = { - menuModelSelect, - menuModelSetup, - CASE_HELI(menuModelHeli) - CASE_FLIGHT_MODES(menuModelFlightModesAll) - menuModelExposAll, - menuModelMixAll, - menuModelLimits, - CASE_CURVES(menuModelCurvesAll) -#if defined(GVARS) && defined(FLIGHT_MODES) - CASE_GVARS(menuModelGVars) -#endif - menuModelLogicalSwitches, - menuModelCustomFunctions, -#if defined(LUA_MODEL_SCRIPTS) - menuModelCustomScripts, #endif - CASE_FRSKY(menuModelTelemetry) - CASE_MAVLINK(menuTelemetryMavlinkSetup) - CASE_TEMPLATES(menuModelTemplates) -}; #define COPY_MODE 1 #define MOVE_MODE 2 -static uint8_t s_copyMode = 0; -static int8_t s_copySrcRow; -static int8_t s_copyTgtOfs; +uint8_t s_copyMode = 0; +int8_t s_copySrcRow; +int8_t s_copyTgtOfs; -static uint8_t editNameCursorPos = 0; +uint8_t editNameCursorPos = 0; void editName(coord_t x, coord_t y, char *name, uint8_t size, uint8_t event, uint8_t active, uint8_t attr) { @@ -232,4 +155,4 @@ void editSingleName(coord_t x, coord_t y, const pm_char *label, char *name, uint editName(x, y, name, size, event, active); } -static uint8_t s_currIdx; +uint8_t s_currIdx; diff --git a/radio/src/gui/taranis/menu_model_flightmodes.cpp b/radio/src/gui/taranis/menu_model_flightmodes.cpp index d08f38a6b3c..b97e1a0c02d 100644 --- a/radio/src/gui/taranis/menu_model_flightmodes.cpp +++ b/radio/src/gui/taranis/menu_model_flightmodes.cpp @@ -73,7 +73,7 @@ void menuModelFlightModesAll(uint8_t event) if (sub==0 && posHorz > 0) { posHorz += 1; } if (sub=0) { - displayColumnHeader(STR_PHASES_HEADERS, posHorz); + drawColumnHeader(STR_PHASES_HEADERS, posHorz); } for (uint8_t i=0; i=0) { - displayColumnHeader(STR_LIMITS_HEADERS, menuHorizontalPosition); + drawColumnHeader(STR_LIMITS_HEADERS, menuHorizontalPosition); } if (warningResult) { diff --git a/radio/src/gui/taranis/menu_model_logical_switches.cpp b/radio/src/gui/taranis/menu_model_logical_switches.cpp index 47deaf98696..5847e7981c2 100644 --- a/radio/src/gui/taranis/menu_model_logical_switches.cpp +++ b/radio/src/gui/taranis/menu_model_logical_switches.cpp @@ -54,11 +54,6 @@ enum LogicalSwitchFields { #define CSW_5TH_COLUMN (26*FW+3) #define CSW_6TH_COLUMN (31*FW+1) -#define INCDEC_DECLARE_VARS(f) uint8_t incdecFlag = (f); IsValueAvailable isValueAvailable = NULL -#define INCDEC_SET_FLAG(f) incdecFlag = (f) -#define INCDEC_ENABLE_CHECK(fn) isValueAvailable = fn -#define CHECK_INCDEC_PARAM(event, var, min, max) checkIncDec(event, var, min, max, incdecFlag, isValueAvailable) - void putsEdgeDelayParam(coord_t x, coord_t y, LogicalSwitchData *cs, uint8_t lattr, uint8_t rattr) { lcdDrawChar(x-4, y, '['); @@ -103,7 +98,7 @@ void menuModelLogicalSwitches(uint8_t event) horzpos_t horz = menuHorizontalPosition; if (horz>=0) { - displayColumnHeader(STR_CSW_HEADERS, horz); + drawColumnHeader(STR_CSW_HEADERS, horz); } if (horz<0 && event==EVT_KEY_LONG(KEY_ENTER) && !READ_ONLY()) { diff --git a/radio/src/gui/taranis/menus.h b/radio/src/gui/taranis/menus.h index a958cf43a3e..48ca38a5f65 100644 --- a/radio/src/gui/taranis/menus.h +++ b/radio/src/gui/taranis/menus.h @@ -43,8 +43,6 @@ #define MENU_COLUMNS 2 #endif -#define MENUS_SCROLLBAR_WIDTH 2 -#define MENU_COLUMN2_X (8 + LCD_W / 2) #define lcd_putsColumnLeft(x, y, str) lcdDrawText((x > (LCD_W-10*FW-MENUS_SCROLLBAR_WIDTH)) ? MENU_COLUMN2_X : 0, y, str) // Menus related stuff ... @@ -68,8 +66,6 @@ extern uint8_t noHighlightCounter; void menu_lcd_onoff(coord_t x, coord_t y, uint8_t value, LcdFlags attr); typedef void (*MenuHandlerFunc)(uint8_t event); -extern const MenuHandlerFunc menuTabModel[]; -extern const MenuHandlerFunc menuTabGeneral[]; extern MenuHandlerFunc menuHandlers[5]; extern uint8_t menuVerticalPositions[4]; @@ -87,21 +83,41 @@ void doMainScreenGraphics(); void menuFirstCalib(uint8_t event); void onMainViewMenu(const char *result); -void menuMainView(uint8_t event); -void menuGeneralDiagAna(uint8_t event); -#if defined(FRSKY) -void menuTelemetryFrsky(uint8_t event); -#endif + +void menuModelSelect(uint8_t event); void menuModelSetup(uint8_t event); -void menuModelNotes(uint8_t event); +void menuModelHeli(uint8_t event); +void menuModelFlightModesAll(uint8_t event); +void menuModelExposAll(uint8_t event); +void menuModelMixAll(uint8_t event); +void menuModelLimits(uint8_t event); +void menuModelCurvesAll(uint8_t event); +void menuModelCurveOne(uint8_t event); +void menuModelGVars(uint8_t event); +void menuModelLogicalSwitches(uint8_t event); +void menuModelCustomFunctions(uint8_t event); +void menuModelCustomScripts(uint8_t event); +void menuModelTelemetry(uint8_t event); +void menuModelExpoOne(uint8_t event); + void menuGeneralSetup(uint8_t event); void menuGeneralSdManager(uint8_t event); -void menuGeneralCalib(uint8_t event); +void menuGeneralCustomFunctions(uint8_t event); +void menuGeneralTrainer(uint8_t event); void menuGeneralVersion(uint8_t event); -void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFunctionsContext * functionsContext); +void menuGeneralDiagKeys(uint8_t event); +void menuGeneralDiagAna(uint8_t event); +void menuGeneralHardware(uint8_t event); +void menuGeneralCalib(uint8_t event); -void menuModelSelect(uint8_t event); -void menuModelCustomFunctions(uint8_t event); +void menuMainViewChannelsMonitor(uint8_t event); +void menuChannelsView(uint8_t event); +void menuMainView(uint8_t event); +#if defined(FRSKY) +void menuTelemetryFrsky(uint8_t event); +#endif +void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFunctionsContext * functionsContext); +void menuModelNotes(uint8_t event); void menuStatisticsView(uint8_t event); void menuStatisticsDebug(uint8_t event); void menuAboutView(uint8_t event); @@ -109,10 +125,75 @@ void menuAboutView(uint8_t event); void menuTraceBuffer(uint8_t event); #endif +enum EnumTabDiag { + e_Setup, + e_Sd, + e_GeneralCustomFunctions, + e_Trainer, + e_Vers, + e_Keys, + e_Ana, + e_Hardware, + e_Calib +}; + +const MenuHandlerFunc menuTabGeneral[] = { + menuGeneralSetup, + menuGeneralSdManager, + menuGeneralCustomFunctions, + menuGeneralTrainer, + menuGeneralVersion, + menuGeneralDiagKeys, + menuGeneralDiagAna, + menuGeneralHardware, + menuGeneralCalib +}; + +enum EnumTabModel { + e_ModelSelect, + e_ModelSetup, + CASE_HELI(e_Heli) + CASE_FLIGHT_MODES(e_FlightModesAll) + e_InputsAll, + e_MixAll, + e_Limits, + CASE_CURVES(e_CurvesAll) + CASE_GVARS(e_GVars) + e_LogicalSwitches, + e_CustomFunctions, +#if defined(LUA_MODEL_SCRIPTS) + e_CustomScripts, +#endif + CASE_FRSKY(e_Telemetry) + CASE_MAVLINK(e_MavSetup) + CASE_TEMPLATES(e_Templates) +}; + +const MenuHandlerFunc menuTabModel[] = { + menuModelSelect, + menuModelSetup, + CASE_HELI(menuModelHeli) + CASE_FLIGHT_MODES(menuModelFlightModesAll) + menuModelExposAll, + menuModelMixAll, + menuModelLimits, + CASE_CURVES(menuModelCurvesAll) +#if defined(GVARS) && defined(FLIGHT_MODES) + CASE_GVARS(menuModelGVars) +#endif + menuModelLogicalSwitches, + menuModelCustomFunctions, +#if defined(LUA_MODEL_SCRIPTS) + menuModelCustomScripts, +#endif + CASE_FRSKY(menuModelTelemetry) + CASE_MAVLINK(menuTelemetryMavlinkSetup) + CASE_TEMPLATES(menuModelTemplates) +}; + void drawSlider(coord_t x, coord_t y, uint8_t value, uint8_t max, uint8_t attr); -void menuMainViewChannelsMonitor(uint8_t event); -void menuChannelsView(uint8_t event); +typedef uint16_t FlightModesType; extern int8_t checkIncDec_Ret; // global helper vars @@ -131,6 +212,11 @@ extern int8_t s_editMode; // global editmode #define INCDEC_REP10 0x40 #define NO_DBLKEYS 0x80 +#define INCDEC_DECLARE_VARS(f) uint8_t incdecFlag = (f); IsValueAvailable isValueAvailable = NULL +#define INCDEC_SET_FLAG(f) incdecFlag = (f) +#define INCDEC_ENABLE_CHECK(fn) isValueAvailable = fn +#define CHECK_INCDEC_PARAM(event, var, min, max) checkIncDec(event, var, min, max, incdecFlag, isValueAvailable) + // mawrow special values #define TITLE_ROW ((uint8_t)-1) #define HIDDEN_ROW ((uint8_t)-2) @@ -265,18 +351,40 @@ swsrc_t switchMenuItem(coord_t x, coord_t y, swsrc_t value, LcdFlags attr, uint8 #define displayGVar(x, y, v, min, max) lcdDraw8bitsNumber(x, y, v) #endif +extern uint8_t s_curveChan; +void editCurveRef(coord_t x, coord_t y, CurveRef & curve, uint8_t event, uint8_t attr); + +extern uint8_t editNameCursorPos; void editName(coord_t x, coord_t y, char *name, uint8_t size, uint8_t event, uint8_t active, uint8_t attr=ZCHAR); +void editSingleName(coord_t x, coord_t y, const pm_char *label, char *name, uint8_t size, uint8_t event, uint8_t active); + +#if MENU_COLUMNS > 1 +uint8_t editDelay(const coord_t x, const coord_t y, const uint8_t event, const uint8_t attr, const pm_char *str, uint8_t delay); +#define EDIT_DELAY(x, y, event, attr, str, delay) editDelay(x, y, event, attr, str, delay) +#else +uint8_t editDelay(const coord_t y, const uint8_t event, const uint8_t attr, const pm_char *str, uint8_t delay); +#define EDIT_DELAY(x, y, event, attr, str, delay) editDelay(y, event, attr, str, delay) +#endif #define WARNING_TYPE_ASTERISK 0 #define WARNING_TYPE_CONFIRM 1 #define WARNING_TYPE_INPUT 2 +void copySelection(char * dst, const char * src, uint8_t size); + extern const pm_char * warningText; extern const pm_char * warningInfoText; extern uint8_t warningInfoLength; extern uint8_t warningResult; extern uint8_t warningType; +#define COPY_MODE 1 +#define MOVE_MODE 2 +extern uint8_t s_copyMode; +extern int8_t s_copySrcRow; +extern int8_t s_copyTgtOfs; +extern uint8_t s_currIdx; + #define MENU_X 30 #define MENU_Y 16 #define MENU_W LCD_W-(2*MENU_X) @@ -360,4 +468,8 @@ void menuChannelsView(uint8_t event); typedef int16_t (*FnFuncP) (int16_t x); void drawFunction(FnFuncP fn, uint8_t offset=0); +void onSourceLongEnterPress(const char *result); + +uint8_t switchToMix(uint8_t source); + #endif // _MENUS_H_ diff --git a/radio/src/gui/taranis/navigation.cpp b/radio/src/gui/taranis/navigation.cpp index 5e1de250614..398ad078e34 100644 --- a/radio/src/gui/taranis/navigation.cpp +++ b/radio/src/gui/taranis/navigation.cpp @@ -71,7 +71,7 @@ INIT_STOPS(stops100, 3, -100, 0, 100) INIT_STOPS(stops1000, 3, -1000, 0, 1000) INIT_STOPS(stopsSwitch, 15, SWSRC_FIRST, CATEGORY_END(-SWSRC_FIRST_LOGICAL_SWITCH), CATEGORY_END(-SWSRC_FIRST_TRIM), CATEGORY_END(-SWSRC_LAST_SWITCH+1), 0, CATEGORY_END(SWSRC_LAST_SWITCH), CATEGORY_END(SWSRC_FIRST_TRIM-1), CATEGORY_END(SWSRC_FIRST_LOGICAL_SWITCH-1), SWSRC_LAST) -void onSourceLongEnterPress(const char *result) +void onSourceLongEnterPress(const char * result) { if (result == STR_MENU_INPUTS) checkIncDecSelection = getFirstAvailable(MIXSRC_FIRST_INPUT, MIXSRC_LAST_INPUT, isInputAvailable)+1; diff --git a/radio/src/gui/taranis/popups.cpp b/radio/src/gui/taranis/popups.cpp index 480c9cdb2b0..b8f129cefe7 100644 --- a/radio/src/gui/taranis/popups.cpp +++ b/radio/src/gui/taranis/popups.cpp @@ -67,6 +67,10 @@ void displayPopup(const char *title) lcdRefresh(); } +const pm_uchar asterisk_lbm[] PROGMEM = { +#include "asterisk.lbm" +}; + void message(const pm_char *title, const pm_char *t, const char *last MESSAGE_SOUND_ARG) { lcdClear(); diff --git a/radio/src/gui/taranis/view_statistics.cpp b/radio/src/gui/taranis/view_statistics.cpp index 9c5b95a0d27..3269935baa7 100644 --- a/radio/src/gui/taranis/view_statistics.cpp +++ b/radio/src/gui/taranis/view_statistics.cpp @@ -178,7 +178,7 @@ void menuStatisticsDebug(uint8_t event) lcdDrawNumber(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_MIXMAX, DURATION_MS_PREC2(maxMixerDuration), PREC2|LEFT); lcdDrawText(lcdLastPos, MENU_DEBUG_Y_MIXMAX, "ms"); -#if defined(USB_SERIAL) +#if !defined(SIMU) && defined(USB_SERIAL) lcd_putsLeft(MENU_DEBUG_Y_USB, "Usb"); lcdDrawNumber(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_USB, charsWritten, LEFT); lcdDrawText(lcdLastPos, MENU_DEBUG_Y_USB, " "); diff --git a/radio/src/gui/taranis/widgets.cpp b/radio/src/gui/taranis/widgets.cpp index 303e2d7c8f3..c36cd990afb 100644 --- a/radio/src/gui/taranis/widgets.cpp +++ b/radio/src/gui/taranis/widgets.cpp @@ -59,7 +59,7 @@ void drawStick(coord_t centrex, int16_t xval, int16_t yval) #undef MARKER_WIDTH } -void displayColumnHeader(const char * const *headers, uint8_t index) +void drawColumnHeader(const char * const *headers, uint8_t index) { lcdDrawText(17*FW, 0, headers[index], 0); } diff --git a/radio/src/lua/CMakeLists.txt b/radio/src/lua/CMakeLists.txt new file mode 100644 index 00000000000..75aab23de8d --- /dev/null +++ b/radio/src/lua/CMakeLists.txt @@ -0,0 +1,12 @@ +macro(add_lua_export_target target) + add_custom_command( + OUTPUT lua_exports_${target}.inc + COMMAND ${CMAKE_C_COMPILER} -E ${ARGN} -DEXPORT ${INTTYPES_INCLUDE_OPTION} ${RADIO_SRC_DIRECTORY}/myeeprom.h | grep LEXP > lua_exports_${target}.txt + COMMAND python ${RADIO_DIRECTORY}/util/luaexport.py ${VERSION} lua_exports_${target}.txt lua_exports_${target}.inc lua_fields_${target}.txt + ) + add_custom_target(lua_export_${target} DEPENDS lua_exports_${target}.inc) +endmacro(add_lua_export_target) + +add_lua_export_target(taranis -DPCBTARANIS -DLUA -DVIRTUALINPUTS) +add_lua_export_target(taranis_x9e -DPCBTARANIS -DREVPLUS -DREV9E -DLUA -DVIRTUALINPUTS) +add_lua_export_target(horus -DPCBHORUS -DLUA -DVIRTUALINPUTS) diff --git a/radio/src/lua/api_general.cpp b/radio/src/lua/api_general.cpp index 03681069d8f..058664fc539 100644 --- a/radio/src/lua/api_general.cpp +++ b/radio/src/lua/api_general.cpp @@ -71,11 +71,6 @@ #define FIND_FIELD_DESC 0x01 -struct LuaField { - uint16_t id; - char desc[50]; -}; - /*luadoc @function getVersion() @@ -255,7 +250,7 @@ void luaGetValueAndPush(int src) /** Return field data for a given field name */ -bool luaFindFieldByName(const char * name, LuaField & field, unsigned int flags=0) +bool luaFindFieldByName(const char * name, LuaField & field, unsigned int flags) { // TODO better search method (binary lookup) for (unsigned int n=0; n #include #include #include -#if !defined(SIMU) } -#endif extern lua_State *L; extern bool luaLcdAllowed; @@ -149,10 +145,13 @@ extern "C" { #elif defined(PCBHORUS) #define IS_MASKABLE(key) ((key) != KEY_EXIT && (key) != KEY_ENTER) #endif + struct LuaField { + uint16_t id; + char desc[50]; + }; + bool luaFindFieldByName(const char * name, LuaField & field, unsigned int flags=0); #else // #if defined(LUA) - #define LUA_LOAD_MODEL_SCRIPTS() - #endif // #if defined(LUA) #endif // #ifndef lua_api_h diff --git a/radio/src/myeeprom.h b/radio/src/myeeprom.h index e04c7cd90a2..1302a4ea806 100644 --- a/radio/src/myeeprom.h +++ b/radio/src/myeeprom.h @@ -1383,7 +1383,8 @@ enum TelemetrySensorFormula TELEM_FORMULA_LAST = TELEM_FORMULA_DIST }; -PACK(typedef struct { +PACK(class TelemetrySensor { + public: union { uint16_t id; // data identifier, for FrSky we can reuse existing ones. Source unit is derived from type. uint16_t persistentValue; @@ -1434,7 +1435,7 @@ PACK(typedef struct { bool isPrecConfigurable() const; int32_t getPrecMultiplier() const; int32_t getPrecDivisor() const; -}) TelemetrySensor; +}) ; #endif #if !defined(CPUARM) diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 4b2199ffb9d..84f47e51474 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -37,17 +37,6 @@ #include "opentx.h" #include "timers.h" -#if defined(COLORLCD) -#elif defined(PCBTARANIS) - const pm_uchar asterisk_lbm[] PROGMEM = { - #include "bitmaps/taranis/asterisk.lbm" - }; -#else - const pm_uchar asterisk_lbm[] PROGMEM = { - #include "bitmaps/9x/asterisk.lbm" - }; -#endif - EEGeneral g_eeGeneral; ModelData g_model; @@ -1600,7 +1589,7 @@ uint16_t s_cnt_samples_thr_10s; uint16_t s_sum_samples_thr_10s; #endif -FORCEINLINE void evalTrims() +void evalTrims() { uint8_t phase = mixerCurrentFlightMode; for (uint8_t i=0; i #include "diskio.h" -#include "ff.h" - -#define LIST_NONE_SD_FILE 1 +#include "opentx.h" const char * sdCheckAndCreateDirectory(const char * path) { @@ -72,8 +70,7 @@ bool isFileAvailable(const char * filename, const char * directory) return isFileAvailable(path); } -#define LEN_FILE_EXTENSION 4 -char * getFileExtension(char * filename, int size=0) +char * getFileExtension(char * filename, int size) { int len = strlen(filename); if (size != 0 && size < len) { @@ -122,11 +119,11 @@ int findNextFileIndex(char * filename, const char * directory) return 0; } -bool sdListFiles(const char *path, const char *extension, const uint8_t maxlen, const char *selection, uint8_t flags=0) +bool sdListFiles(const char * path, const char * extension, const uint8_t maxlen, const char * selection, uint8_t flags) { FILINFO fno; DIR dir; - char *fn; /* This function is assuming non-Unicode cfg. */ + char * fn; /* This function is assuming non-Unicode cfg. */ #if _USE_LFN TCHAR lfn[_MAX_LFN + 1]; fno.lfname = lfn; diff --git a/radio/src/sdcard.h b/radio/src/sdcard.h index fc835b1dc8a..003b81b94f9 100644 --- a/radio/src/sdcard.h +++ b/radio/src/sdcard.h @@ -92,6 +92,9 @@ inline const pm_char * SDCARD_ERROR(FRESULT result) } #endif +#define LEN_FILE_EXTENSION 4 +char * getFileExtension(char * filename, int size=0); + #if defined(PCBTARANIS) #define O9X_FOURCC 0x3378396F // o9x for Taranis #elif defined(PCBSKY9X) @@ -104,7 +107,10 @@ bool isFileAvailable(const char * filename); int findNextFileIndex(char * filename, const char * directory); const char * sdCopyFile(const char * src, const char * dest); -const char * sdCopyFile(const char * filename, const char * srcDir, const char * destDir); +const char * sdCopyFile(const char * srcFilename, const char * srcDir, const char * destFilename, const char * destDir); + +#define LIST_NONE_SD_FILE 1 +bool sdListFiles(const char * path, const char * extension, const uint8_t maxlen, const char * selection, uint8_t flags=0); #endif diff --git a/radio/src/simu.cpp b/radio/src/simu.cpp index 04e4847c8a1..3fa93d7d890 100644 --- a/radio/src/simu.cpp +++ b/radio/src/simu.cpp @@ -109,20 +109,17 @@ Open9xSim::Open9xSim(FXApp* a): for (int i=0; i<4; i++) { switch (i) { #define L LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT|LAYOUT_FIX_X|LAYOUT_FIX_Y -#undef X0 -#define X0 10 -#define Y0 10 case 0: - sliders[i]=new FXSlider(hf1,NULL,0,L|SLIDER_HORIZONTAL,X0+0,Y0+100,100,20); + sliders[i]=new FXSlider(hf1,NULL,0,L|SLIDER_HORIZONTAL,10,110,100,20); break; case 1: - sliders[i]=new FXSlider(hf1,NULL,0,L|SLIDER_VERTICAL,X0+100,Y0+0,20,100); + sliders[i]=new FXSlider(hf1,NULL,0,L|SLIDER_VERTICAL,110,10,20,100); break; case 2: - sliders[i]=new FXSlider(hf1,NULL,0,L|SLIDER_VERTICAL,X0+120,Y0+0,20,100); + sliders[i]=new FXSlider(hf1,NULL,0,L|SLIDER_VERTICAL,130,10,20,100); break; case 3: - sliders[i]=new FXSlider(hf1,NULL,0,L|SLIDER_HORIZONTAL,X0+140,Y0+100,100,20); + sliders[i]=new FXSlider(hf1,NULL,0,L|SLIDER_HORIZONTAL,150,110,100,20); break; default:; } diff --git a/radio/src/storage/sdcard_raw.cpp b/radio/src/storage/sdcard_raw.cpp index da67a43bb53..f473dc04d52 100644 --- a/radio/src/storage/sdcard_raw.cpp +++ b/radio/src/storage/sdcard_raw.cpp @@ -228,10 +228,6 @@ void storageFormat() storageCreateModelsList(); } -struct StorageModelsList { - FIL file; -}; - const char * storageOpenModelsList(StorageModelsList * storage) { FRESULT result = f_open(&storage->file, RADIO_MODELSLIST_PATH, FA_OPEN_EXISTING | FA_READ); diff --git a/radio/src/storage/sdcard_raw.h b/radio/src/storage/sdcard_raw.h index 6ce72093ebb..6476537442f 100644 --- a/radio/src/storage/sdcard_raw.h +++ b/radio/src/storage/sdcard_raw.h @@ -34,6 +34,11 @@ * */ +#ifndef _SDCARD_RAW_H_ +#define _SDCARD_RAW_H_ + +#include "ff.h" + #define DEFAULT_CATEGORY "Models" #define DEFAULT_MODEL_FILENAME "model01.bin" @@ -42,3 +47,22 @@ const char * loadModel(const char * filename); const char * createModel(int category); +struct StorageModelsList { + FIL file; +}; + +const char * storageOpenModelsList(StorageModelsList * storage); +bool storageReadNextModel(StorageModelsList * storage, char * line, int maxlen); +const char * storageInsertModel(const char * name, int category, int position); +const char * storageRemoveModel(int category, int position); +const char * storageRenameModel(const char * name, int category, int position); + +const char * storageInsertCategory(const char * name, int position); +const char * storageRenameCategory(int category, const char * name); +const char * storageRemoveCategory(int category); +bool storageReadNextCategory(StorageModelsList * storage, char * line, int maxlen); +bool storageSeekCategory(StorageModelsList * storage, int category); + +#endif + + diff --git a/radio/src/targets/horus/board_horus.h b/radio/src/targets/horus/board_horus.h index 7e2c043feac..f0af5eacf01 100644 --- a/radio/src/targets/horus/board_horus.h +++ b/radio/src/targets/horus/board_horus.h @@ -180,6 +180,8 @@ void init_pxx( uint32_t module_index ); void disable_pxx( uint32_t module_index ); void init_dsm2( uint32_t module_index ); void disable_dsm2( uint32_t module_index ); +void init_crossfire( uint32_t module_index ); +void disable_crossfire( uint32_t module_index ); // Trainer driver void init_trainer_ppm(void); @@ -217,7 +219,7 @@ void watchdogInit(unsigned int duration); // ADC driver void adcInit(void); void adcRead(void); -inline uint16_t getAnalogValue(uint32_t value); +uint16_t getAnalogValue(uint32_t value); #if defined(REV3) #define BATT_SCALE 120 diff --git a/radio/src/targets/horus/diskio.cpp b/radio/src/targets/horus/diskio.cpp index da5b31ef43e..1c17c8cb25e 100644 --- a/radio/src/targets/horus/diskio.cpp +++ b/radio/src/targets/horus/diskio.cpp @@ -7,9 +7,8 @@ #include "diskio.h" #include // memcpy - -#include "../horus/sdio_sd.h" -#include "stm32f4xx.h" +#include "../../opentx.h" +#include "sdio_sd.h" #define BLOCK_SIZE 512 /* Block Size in Bytes */ diff --git a/radio/src/targets/horus/pulses_driver.cpp b/radio/src/targets/horus/pulses_driver.cpp index 7daa3f5166c..d4d9303e9a8 100644 --- a/radio/src/targets/horus/pulses_driver.cpp +++ b/radio/src/targets/horus/pulses_driver.cpp @@ -92,6 +92,14 @@ void disable_no_pulses(uint32_t port) TIM1->CR1 &= ~TIM_CR1_CEN ; } +void init_crossfire(uint32_t port) +{ +} + +void disable_crossfire(uint32_t port) +{ +} + void init_pxx(uint32_t port) { EXTERNAL_MODULE_ON(); diff --git a/radio/src/targets/horus/telemetry_driver.cpp b/radio/src/targets/horus/telemetry_driver.cpp index 1ce9c880a64..8f9e0dd667a 100644 --- a/radio/src/targets/horus/telemetry_driver.cpp +++ b/radio/src/targets/horus/telemetry_driver.cpp @@ -36,8 +36,6 @@ #include "../../opentx.h" -extern Fifo<512> telemetryFifo; - void telemetryPortInit(uint32_t baudrate) { if (baudrate == 0) { diff --git a/radio/src/targets/horus/usbd_cdc.cpp b/radio/src/targets/horus/usbd_cdc.cpp index d3c3f1d4022..ef8d4933d66 100644 --- a/radio/src/targets/horus/usbd_cdc.cpp +++ b/radio/src/targets/horus/usbd_cdc.cpp @@ -29,12 +29,12 @@ #pragma data_alignment = 4 #endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */ -#include "opentx.h" +#include "../../opentx.h" extern "C" { /* Includes ------------------------------------------------------------------*/ -#include "../horus/usb_conf.h" +#include "usb_conf.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ diff --git a/radio/src/targets/horus/usbd_desc.c b/radio/src/targets/horus/usbd_desc.c index d71600eef62..a2a60f0abeb 100644 --- a/radio/src/targets/horus/usbd_desc.c +++ b/radio/src/targets/horus/usbd_desc.c @@ -26,12 +26,12 @@ */ /* Includes ------------------------------------------------------------------*/ -#include "../horus/usbd_desc.h" +#include "usbd_desc.h" #include -#include "../horus/board_horus.h" -#include "../horus/usbd_conf.h" +#include "board_horus.h" +#include "usbd_conf.h" #include "usbd_core.h" #include "usbd_req.h" #include "usb_regs.h" diff --git a/radio/src/targets/simu/CMakeLists.txt b/radio/src/targets/simu/CMakeLists.txt new file mode 100644 index 00000000000..215e7c9b0d6 --- /dev/null +++ b/radio/src/targets/simu/CMakeLists.txt @@ -0,0 +1,11 @@ +set(SRC ${SRC} simu.cpp targets/simu/simpgmspace.cpp) +foreach(FILE ${SRC}) + set(SIMU_SRC ${SIMU_SRC} ../../${FILE}) +endforeach() + +add_definitions(-DSIMU) +add_executable(simu WIN32 ${SIMU_SRC} ) +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) \ No newline at end of file diff --git a/radio/src/targets/simu/simpgmspace.cpp b/radio/src/targets/simu/simpgmspace.cpp index 6f9e8bef438..68a115123fe 100644 --- a/radio/src/targets/simu/simpgmspace.cpp +++ b/radio/src/targets/simu/simpgmspace.cpp @@ -34,7 +34,7 @@ * */ -#include "opentx.h" +#include "../../opentx.h" #include #include #include diff --git a/radio/src/targets/taranis/board_taranis.h b/radio/src/targets/taranis/board_taranis.h index 2cea55c5f50..06e9318a6aa 100644 --- a/radio/src/targets/taranis/board_taranis.h +++ b/radio/src/targets/taranis/board_taranis.h @@ -242,8 +242,8 @@ void checkRotaryEncoder(void); #if !defined(SIMU) #define wdt_disable() void watchdogInit(unsigned int duration); -#define wdt_enable(x) watchdogInit(1500) -#define wdt_reset() IWDG->KR = 0xAAAA +#define wdt_enable(x) watchdogInit(1500) +#define wdt_reset() IWDG->KR = 0xAAAA #define WAS_RESET_BY_SOFTWARE() (RCC->CSR & RCC_CSR_SFTRSTF) #define WAS_RESET_BY_WATCHDOG() (RCC->CSR & (RCC_CSR_WDGRSTF | RCC_CSR_WWDGRSTF)) #define WAS_RESET_BY_WATCHDOG_OR_SOFTWARE() (RCC->CSR & (RCC_CSR_WDGRSTF | RCC_CSR_WWDGRSTF | RCC_CSR_SFTRSTF)) @@ -252,7 +252,7 @@ void watchdogInit(unsigned int duration); // ADC driver void adcInit(void); void adcRead(void); -inline uint16_t getAnalogValue(uint32_t value); +uint16_t getAnalogValue(uint32_t value); #define BATT_SCALE 150 @@ -372,6 +372,7 @@ void setTopBatteryValue(uint32_t volts); void usbJoystickUpdate(void); #endif +extern uint8_t currentTrainerMode; void checkTrainerSettings(void); #endif diff --git a/radio/src/targets/taranis/diskio.cpp b/radio/src/targets/taranis/diskio.cpp index d57bd284e8b..8e6459bc3b2 100644 --- a/radio/src/targets/taranis/diskio.cpp +++ b/radio/src/targets/taranis/diskio.cpp @@ -34,13 +34,9 @@ * */ -#include +#include "../../opentx.h" #include "../../thirdparty/FatFs/diskio.h" #include "../../thirdparty/FatFs/ff.h" -#include "../../thirdparty/CoOS/kernel/CoOS.h" -#include "../../debug.h" -#include "board_taranis.h" -#include "hal.h" /* Definitions for MMC/SDC command */ #define CMD0 (0x40+0) /* GO_IDLE_STATE */ diff --git a/radio/src/tasks_arm.cpp b/radio/src/tasks_arm.cpp index 640dca234d8..53a9254049c 100644 --- a/radio/src/tasks_arm.cpp +++ b/radio/src/tasks_arm.cpp @@ -36,17 +36,6 @@ #include "opentx.h" -#define MENUS_STACK_SIZE 2000 -#define MIXER_STACK_SIZE 500 -#define AUDIO_STACK_SIZE 500 -#define BLUETOOTH_STACK_SIZE 500 - -#if defined(_MSC_VER) - #define _ALIGNED(x) __declspec(align(x)) -#elif defined(__GNUC__) - #define _ALIGNED(x) __attribute__ ((aligned(x))) -#endif - OS_TID menusTaskId; // menus stack must be aligned to 8 bytes otherwise printf for %f does not work! TaskStack _ALIGNED(8) menusStack; @@ -102,12 +91,6 @@ uint16_t getStackAvailable(void * address, uint16_t size) #endif } -template -uint16_t TaskStack::available() -{ - return getStackAvailable(stack, SIZE); -} - void stackPaint() { menusStack.paint(); diff --git a/radio/src/tasks_arm.h b/radio/src/tasks_arm.h index e4d61db9119..ffe3d055e1f 100644 --- a/radio/src/tasks_arm.h +++ b/radio/src/tasks_arm.h @@ -43,6 +43,19 @@ extern "C" { } #endif +#define MENUS_STACK_SIZE 2000 +#define MIXER_STACK_SIZE 500 +#define AUDIO_STACK_SIZE 500 +#define BLUETOOTH_STACK_SIZE 500 + +#if defined(_MSC_VER) +#define _ALIGNED(x) __declspec(align(x)) +#elif defined(__GNUC__) +#define _ALIGNED(x) __attribute__ ((aligned(x))) +#endif + +uint16_t getStackAvailable(void * address, uint16_t size); + template class TaskStack { @@ -50,7 +63,10 @@ class TaskStack TaskStack() { } void paint(); uint16_t size(); - uint16_t available(); + uint16_t available() + { + return getStackAvailable(stack, SIZE); + } OS_STK stack[SIZE]; }; @@ -58,4 +74,16 @@ void stackPaint(); uint16_t stackSize(); uint16_t stackAvailable(); +extern OS_TID menusTaskId; +// menus stack must be aligned to 8 bytes otherwise printf for %f does not work! +extern TaskStack _ALIGNED(8) menusStack; + +extern OS_TID mixerTaskId; +extern TaskStack mixerStack; + +extern OS_TID audioTaskId; +extern TaskStack audioStack; + +void tasksStart(); + #endif // _TASKS_ARM_H_ diff --git a/radio/src/telemetry/frsky.h b/radio/src/telemetry/frsky.h index 1cc274db79c..c44ede300b1 100644 --- a/radio/src/telemetry/frsky.h +++ b/radio/src/telemetry/frsky.h @@ -491,7 +491,7 @@ enum FrSkyDataState { #endif }; -#if defined(CPUARM) || defined(PCBFLAMENCO) +#if defined(CPUARM) #define frskySendAlarms() #else #define SEND_RSSI_ALARMS 6 @@ -550,6 +550,8 @@ void frskySetCellVoltage(uint8_t battnumber, frskyCellVoltage_t cellVolts); void frskyUpdateCells(void); #endif +void processSerialData(uint8_t data); + #if defined(PCBTARANIS) inline uint8_t modelTelemetryProtocol() { diff --git a/radio/src/telemetry/telemetry.h b/radio/src/telemetry/telemetry.h index 64cf25b1943..37b8f559d26 100644 --- a/radio/src/telemetry/telemetry.h +++ b/radio/src/telemetry/telemetry.h @@ -37,6 +37,8 @@ #ifndef TELEMETRY_H #define TELEMETRY_H +extern Fifo<512> telemetryFifo; + enum TelemetryProtocol { TELEM_PROTO_FRSKY_D, @@ -167,6 +169,8 @@ class TelemetryItem extern TelemetryItem telemetryItems[MAX_SENSORS]; extern uint8_t allowNewSensors; +bool isGPSSensor(int sensor); + inline bool isTelemetryFieldAvailable(int index) { TelemetrySensor & sensor = g_model.telemetrySensors[index]; diff --git a/radio/src/thirdparty/Lua/src/lvm.c b/radio/src/thirdparty/Lua/src/lvm.c index ac7b51c683c..26dbe52dc4a 100644 --- a/radio/src/thirdparty/Lua/src/lvm.c +++ b/radio/src/thirdparty/Lua/src/lvm.c @@ -145,7 +145,6 @@ void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) { /* else will try the tag method */ } else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX))) { - TRACE("ERREUR ICI"); luaG_typeerror(L, t, "index"); } if (ttisfunction(tm) || ttislightfunction(tm)) { diff --git a/radio/src/trainer_input.h b/radio/src/trainer_input.h index c84264ffc9e..1ea2a42c965 100644 --- a/radio/src/trainer_input.h +++ b/radio/src/trainer_input.h @@ -34,10 +34,10 @@ * */ -#ifndef trainer_input_h -#define trainer_input_h +#ifndef _TRAINER_INPUT_H_ +#define _TRAINER_INPUT_H_ -#include "myeeprom.h" +#include "opentx.h" // Trainer input channels extern int16_t ppmInput[NUM_TRAINER]; @@ -86,4 +86,4 @@ inline void captureTrainerPulses(uint16_t capture) } } -#endif +#endif // _TRAINER_INPUT_H_ diff --git a/radio/src/translations.h b/radio/src/translations.h index 6ee196e44dc..ace86963f07 100644 --- a/radio/src/translations.h +++ b/radio/src/translations.h @@ -597,11 +597,11 @@ extern const pm_char STR_CURRENT[]; #if defined(NAVIGATION_MENUS) extern const pm_char STR_SELECT_MODEL[]; - extern const pm_char STR_CREATE_CATEGORY[]; - extern const pm_char STR_RENAME_CATEGORY[]; -extern const pm_char STR_DELETE_CATEGORY[]; + extern const pm_char STR_CREATE_CATEGORY[]; + extern const pm_char STR_RENAME_CATEGORY[]; +extern const pm_char STR_DELETE_CATEGORY[]; extern const pm_char STR_CREATE_MODEL[]; - extern const pm_char STR_DUPLICATE_MODEL[]; + extern const pm_char STR_DUPLICATE_MODEL[]; extern const pm_char STR_COPY_MODEL[]; extern const pm_char STR_MOVE_MODEL[]; extern const pm_char STR_DELETE_MODEL[]; @@ -669,10 +669,10 @@ extern const pm_char STR_NO_SOUNDS_ON_SD[]; extern const pm_char STR_NO_MODELS_ON_SD[]; extern const pm_char STR_NO_BITMAPS_ON_SD[]; extern const pm_char STR_NO_SCRIPTS_ON_SD[]; -extern const pm_char STR_SCRIPT_SYNTAX_ERROR[]; -extern const pm_char STR_SCRIPT_PANIC[]; -extern const pm_char STR_SCRIPT_KILLED[]; -extern const pm_char STR_SCRIPT_ERROR[]; +extern const pm_char STR_SCRIPT_SYNTAX_ERROR[]; +extern const pm_char STR_SCRIPT_PANIC[]; +extern const pm_char STR_SCRIPT_KILLED[]; +extern const pm_char STR_SCRIPT_ERROR[]; extern const pm_char STR_PLAY_FILE[]; extern const pm_char STR_ASSIGN_BITMAP[]; extern const pm_char STR_EXECUTE_FILE[]; @@ -724,15 +724,48 @@ extern const pm_char STR_BLCOLOR[]; #endif struct LanguagePack { - const char *id; - const char *name; + const char * id; + const char * name; void (*playNumber)(getvalue_t number, uint8_t unit, uint8_t flags, uint8_t id); void (*playDuration)(int seconds, uint8_t flags, uint8_t id); }; - extern const LanguagePack * LP_CONST languagePacks[]; + extern const LanguagePack * currentLanguagePack; extern uint8_t currentLanguagePackIdx; + + extern LP_CONST LanguagePack czLanguagePack; + extern LP_CONST LanguagePack enLanguagePack; + extern LP_CONST LanguagePack esLanguagePack; + extern LP_CONST LanguagePack frLanguagePack; + extern LP_CONST LanguagePack deLanguagePack; + extern LP_CONST LanguagePack itLanguagePack; + extern LP_CONST LanguagePack plLanguagePack; + extern LP_CONST LanguagePack ptLanguagePack; + extern LP_CONST LanguagePack skLanguagePack; + extern LP_CONST LanguagePack seLanguagePack; + extern LP_CONST LanguagePack huLanguagePack; + + static const LanguagePack * LP_CONST languagePacks[] = { + // alphabetical order + &czLanguagePack, + &deLanguagePack, + &enLanguagePack, + &esLanguagePack, + &frLanguagePack, + &huLanguagePack, + &itLanguagePack, + &plLanguagePack, + &ptLanguagePack, + &seLanguagePack, + &skLanguagePack, + NULL + }; + +#if defined(SIMU) #define LANGUAGE_PACK_DECLARE(lng, name) LP_CONST LanguagePack lng ## LanguagePack = { #lng, name, lng ## _ ## playNumber, lng ## _ ## playDuration } +#else + #define LANGUAGE_PACK_DECLARE(lng, name) extern LP_CONST LanguagePack lng ## LanguagePack = { #lng, name, lng ## _ ## playNumber, lng ## _ ## playDuration } +#endif #define LANGUAGE_PACK_DECLARE_DEFAULT(lng, name) LANGUAGE_PACK_DECLARE(lng, name); const LanguagePack * currentLanguagePack = & lng ## LanguagePack; uint8_t currentLanguagePackIdx inline PLAY_FUNCTION(playNumber, getvalue_t number, uint8_t unit, uint8_t flags) { currentLanguagePack->playNumber(number, unit, flags, id); } inline PLAY_FUNCTION(playDuration, int seconds, uint8_t flags) { currentLanguagePack->playDuration(seconds, flags, id); } @@ -773,7 +806,7 @@ extern const pm_char STR_BLCOLOR[]; extern const pm_char STR_PREFLIGHT[]; extern const pm_char STR_CHECKLIST[]; extern const pm_char STR_VIEW_NOTES[]; -extern const pm_char STR_MODEL_SELECT[]; + extern const pm_char STR_MODEL_SELECT[]; extern const pm_char STR_RESET_SUBMENU[]; extern const pm_char STR_LOWALARM[]; extern const pm_char STR_CRITICALALARM[]; @@ -800,10 +833,10 @@ extern const pm_char STR_MODEL_SELECT[]; extern const pm_char STR_TELEMETRYFULL[]; extern const pm_char STR_INVERTED_SERIAL[]; extern const pm_char STR_IGNORE_INSTANCE[]; - extern const pm_char STR_DISCOVER_SENSORS[]; + extern const pm_char STR_DISCOVER_SENSORS[]; extern const pm_char STR_STOP_DISCOVER_SENSORS[]; extern const pm_char STR_DELETE_ALL_SENSORS[]; - extern const pm_char STR_CONFIRMDELETE[]; + extern const pm_char STR_CONFIRMDELETE[]; #endif #if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS) @@ -823,10 +856,10 @@ extern const pm_char STR_MODEL_SELECT[]; extern const pm_char STR_SMOOTH[]; extern const pm_char STR_COPY_STICKS_TO_OFS[]; extern const pm_char STR_COPY_TRIMS_TO_OFS[]; - extern const pm_char STR_INCDEC[]; - extern const pm_char STR_GLOBALVAR[]; - extern const pm_char STR_MIXSOURCE[]; - extern const pm_char STR_CONSTANT[]; + extern const pm_char STR_INCDEC[]; + extern const pm_char STR_GLOBALVAR[]; + extern const pm_char STR_MIXSOURCE[]; + extern const pm_char STR_CONSTANT[]; extern const pm_char STR_TOP_BAR[]; extern const pm_char STR_ALTITUDE[]; extern const pm_char STR_SCALE[]; diff --git a/radio/src/translations/CMakeLists.txt b/radio/src/translations/CMakeLists.txt new file mode 100644 index 00000000000..9f2aafb9d36 --- /dev/null +++ b/radio/src/translations/CMakeLists.txt @@ -0,0 +1,14 @@ +file(GLOB translations *.h.txt) +foreach(translation ${translations}) + get_filename_component(language ${translation} NAME_WE) + get_filename_component(path ${translation} DIRECTORY) + set(target ${language}.h) + add_custom_command( + OUTPUT ${target} + COMMAND python ${RADIO_DIRECTORY}/util/translate.py ${translation} ${target} ${language} + DEPENDS ${translation} + ) + list(APPEND translations_files ${target}) +endforeach() + +add_custom_target(firmware_translations DEPENDS ${translations_files}) \ No newline at end of file diff --git a/radio/util/commit-tests.sh b/radio/util/commit-tests.sh index 957b69039d5..bf256f4b205 100755 --- a/radio/util/commit-tests.sh +++ b/radio/util/commit-tests.sh @@ -20,29 +20,29 @@ make PCB=9X EXT=MAVLINK HELI=YES # OpenTX on Taranis X9E make clean make PCB=TARANIS PCBREV=REV9E HELI=YES GVARS=YES LUA=YES WARNINGS_AS_ERRORS=YES -make simu PCB=TARANIS PCBREV=REV9E HELI=YES GVARS=YES LUA=YES WARNINGS_AS_ERRORS=YES -make gtests PCB=TARANIS PCBREV=REV9E HELI=YES GVARS=YES LUA=YES WARNINGS_AS_ERRORS=YES +make simu PCB=TARANIS PCBREV=REV9E HELI=YES GVARS=YES LUA=YES +make gtests PCB=TARANIS PCBREV=REV9E HELI=YES GVARS=YES LUA=YES ./gtests # OpenTX on Taranis Plus make clean make PCB=TARANIS PCBREV=REVPLUS HELI=YES LUA=YES WARNINGS_AS_ERRORS=YES -make simu PCB=TARANIS PCBREV=REVPLUS HELI=YES LUA=YES WARNINGS_AS_ERRORS=YES -make gtests PCB=TARANIS PCBREV=REVPLUS HELI=YES LUA=YES WARNINGS_AS_ERRORS=YES +make simu PCB=TARANIS PCBREV=REVPLUS HELI=YES LUA=YES +make gtests PCB=TARANIS PCBREV=REVPLUS HELI=YES LUA=YES ./gtests # OpenTX on Taranis make clean make PCB=TARANIS HELI=YES LUA=YES WARNINGS_AS_ERRORS=YES -make simu PCB=TARANIS HELI=YES LUA=YES WARNINGS_AS_ERRORS=YES -make gtests PCB=TARANIS HELI=YES LUA=YES WARNINGS_AS_ERRORS=YES +make simu PCB=TARANIS HELI=YES LUA=YES +make gtests PCB=TARANIS HELI=YES LUA=YES ./gtests # OpenTX on Sky9x make clean make PCB=SKY9X HELI=YES WARNINGS_AS_ERRORS=YES -make simu PCB=SKY9X HELI=YES WARNINGS_AS_ERRORS=YES -make gtests PCB=SKY9X HELI=YES WARNINGS_AS_ERRORS=YES +make simu PCB=SKY9X HELI=YES +make gtests PCB=SKY9X HELI=YES ./gtests # OpenTX on Gruvin9x