diff --git a/.travis.yml b/.travis.yml index 5ed6a1991..4b5ca6a54 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ before_install: - sudo apt-get update install: - - sudo apt-get install -y lcov cmake cmake-data bc curl gcc-arm-none-eabi gcc-avr avr-libc avrdude libqtcore4 libqt4-dev qt4-qmake g++ libxerces-c-dev xsdcxx libsdl1.2-dev libusb-1.0-0 libphonon-dev phonon libqtwebkit-dev python-qt4 python-qt4-dev libfox-1.6-dev libgtest-dev + - sudo apt-get install -y xvfb lcov cmake cmake-data bc curl gcc-arm-none-eabi gcc-avr avr-libc avrdude libqtcore4 libqt4-dev qt4-qmake g++ libxerces-c-dev xsdcxx libsdl1.2-dev libusb-1.0-0 libphonon-dev phonon libqtwebkit-dev python-qt4 python-qt4-dev libfox-1.6-dev libgtest-dev script: - radio/util/commit-tests.sh diff --git a/companion/src/CMakeLists.txt b/companion/src/CMakeLists.txt index 88bfad593..8b46c7b0f 100644 --- a/companion/src/CMakeLists.txt +++ b/companion/src/CMakeLists.txt @@ -1,19 +1,20 @@ PROJECT( companion ) -SET(C9X_VERSION_MAJOR "2") -SET(C9X_VERSION_MINOR "2") -SET(C9X_VERSION_REVISION "0") -SET(C9X_VERSION_SUFFIX $ENV{OPENTX_VERSION_SUFFIX}) +SET(VERSION_MAJOR "2") +SET(VERSION_MINOR "2") +SET(VERSION_REVISION "0") +SET(VERSION_SUFFIX $ENV{OPENTX_VERSION_SUFFIX}) -SET(C9X_VERSION ${C9X_VERSION_MAJOR}.${C9X_VERSION_MINOR}.${C9X_VERSION_REVISION}${C9X_VERSION_SUFFIX}) -MESSAGE(STATUS "OpenTX Companion ${C9X_VERSION}") +SET(VERSION_FAMILY ${VERSION_MAJOR}.${VERSION_MINOR}) +SET(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REVISION}${VERSION_SUFFIX}) +MESSAGE(STATUS "OpenTX Companion ${VERSION}") CMAKE_MINIMUM_REQUIRED( VERSION 2.8.12 ) SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") - SET(C9X_NAME_SUFFIX ${C9X_VERSION_MAJOR}${C9X_VERSION_MINOR}) + 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} ) @@ -452,7 +453,7 @@ 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) @@ -462,18 +463,18 @@ if(DPKG_PROGRAM) OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE ) - SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME_LOWERCASE}_${C9X_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}") + 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 ${C9X_VERSION}) - SET(CPACK_DEBIAN_PACKAGE_VERSION_MAJOR ${C9X_VERSION_MAJOR}) - SET(CPACK_DEBIAN_PACKAGE_VERSION_MINOR ${C9X_VERSION_MINOR}) + 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 ${C9X_VERSION}) + SET(CPACK_RPM_PACKAGE_VERSION ${VERSION}) SET(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}) - SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME_LOWERCASE}-${C9X_VERSION}-${CMAKE_SYSTEM_PROCESSOR}") + SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME_LOWERCASE}-${VERSION}-${CMAKE_SYSTEM_PROCESSOR}") endif(DPKG_PROGRAM) INCLUDE(CPack) diff --git a/companion/src/appdata.cpp b/companion/src/appdata.cpp index e6e45029d..86b7db3e9 100644 --- a/companion/src/appdata.cpp +++ b/companion/src/appdata.cpp @@ -604,8 +604,28 @@ AppData::AppData() for (int i=0; i #define COMPANY "OpenTX" -#define PRODUCT "Companion 2.1" +#define PRODUCT "Companion 2.2" #define MAX_PROFILES 15 #define MAX_JOYSTICKS 8 diff --git a/companion/src/companion.cpp b/companion/src/companion.cpp index 51886611e..0d62fdf3a 100644 --- a/companion/src/companion.cpp +++ b/companion/src/companion.cpp @@ -90,7 +90,7 @@ int main(int argc, char *argv[]) QStringList strl = QApplication::arguments(); if (strl.contains("--version")) { - printf("%s\n", C9X_VERSION); + printf("%s\n", VERSION); fflush(stdout); exit(0); } diff --git a/companion/src/companion.desktop.in b/companion/src/companion.desktop.in index 007244755..58614f40f 100644 --- a/companion/src/companion.desktop.in +++ b/companion/src/companion.desktop.in @@ -1,7 +1,7 @@ [Desktop Entry] Type=Application Encoding=UTF-8 -Name=Companion @C9X_VERSION@ +Name=Companion @VERSION@ GenericName=Transmitter Companion App Comment=The Ultimate Transmitter Companion Icon=@COMPANION_NAME@ diff --git a/companion/src/companion.qrc b/companion/src/companion.qrc index ed4700fc7..ced3841ec 100644 --- a/companion/src/companion.qrc +++ b/companion/src/companion.qrc @@ -5,39 +5,54 @@ ../../CREDITS.txt ../../DONATIONS.txt ../releasenotes.txt - images/9xdb.png - images/9xdl.png - images/9xdr.png - images/9xdt.png - images/9xdb-bl.png - images/9xdl-bl.png - images/9xdr-bl.png - images/9xdt-bl.png - images/9xdb-gr.png - images/9xdl-gr.png - images/9xdr-gr.png - images/9xdt-gr.png - images/9xdb-or.png - images/9xdl-or.png - images/9xdr-or.png - images/9xdt-or.png - images/9xdb-yl.png - images/9xdl-yl.png - images/9xdr-yl.png - images/9xdt-yl.png - images/9xdb-rd.png - images/9xdl-rd.png - images/9xdr-rd.png - images/9xdt-rd.png - images/9xmenu.png - images/9xmenumenu.png - images/9xmenuexit.png - images/9xcurs.png - images/9xcursup.png - images/9xcursplus.png - images/9xcursmin.png - images/9xcursdown.png - images/9xcursphoto.png + images/simulator/Horus/middle.png + images/simulator/Horus/left.png + images/simulator/Horus/right.png + images/simulator/Horus/top.png + images/simulator/Horus/bottom.png + images/simulator/Horus/led.png + images/simulator/Horus/border-right.png + images/simulator/Horus/left_btn1.png + images/simulator/Horus/left_btn2.png + images/simulator/Horus/left_scrnsht.png + images/simulator/Horus/right_btnU.png + images/simulator/Horus/right_btnL.png + images/simulator/Horus/right_btnD.png + images/simulator/Horus/right_btnR.png + images/simulator/Horus/right_ent.png + images/simulator/9X/9xdb.png + images/simulator/9X/9xdl.png + images/simulator/9X/9xdr.png + images/simulator/9X/9xdt.png + images/simulator/9X/9xdb-bl.png + images/simulator/9X/9xdl-bl.png + images/simulator/9X/9xdr-bl.png + images/simulator/9X/9xdt-bl.png + images/simulator/9X/9xdb-gr.png + images/simulator/9X/9xdl-gr.png + images/simulator/9X/9xdr-gr.png + images/simulator/9X/9xdt-gr.png + images/simulator/9X/9xdb-or.png + images/simulator/9X/9xdl-or.png + images/simulator/9X/9xdr-or.png + images/simulator/9X/9xdt-or.png + images/simulator/9X/9xdb-yl.png + images/simulator/9X/9xdl-yl.png + images/simulator/9X/9xdr-yl.png + images/simulator/9X/9xdt-yl.png + images/simulator/9X/9xdb-rd.png + images/simulator/9X/9xdl-rd.png + images/simulator/9X/9xdr-rd.png + images/simulator/9X/9xdt-rd.png + images/simulator/9X/9xmenu.png + images/simulator/9X/9xmenumenu.png + images/simulator/9X/9xmenuexit.png + images/simulator/9X/9xcurs.png + images/simulator/9X/9xcursup.png + images/simulator/9X/9xcursplus.png + images/simulator/9X/9xcursmin.png + images/simulator/9X/9xcursdown.png + images/simulator/9X/9xcursphoto.png images/screenshot.png images/splash-9x.png images/splash-9xrpro.png @@ -47,18 +62,18 @@ images/maps.png images/track.png images/track0.png - images/x9b0.png - images/x9l0.png - images/x9l1.png - images/x9l2.png - images/x9l3.png - images/x9l4.png - images/x9r0.png - images/x9r1.png - images/x9r2.png - images/x9r3.png - images/x9s0.png - images/x9t0.png + images/simulator/Taranis/x9b0.png + images/simulator/Taranis/x9l0.png + images/simulator/Taranis/x9l1.png + images/simulator/Taranis/x9l2.png + images/simulator/Taranis/x9l3.png + images/simulator/Taranis/x9l4.png + images/simulator/Taranis/x9r0.png + images/simulator/Taranis/x9r1.png + images/simulator/Taranis/x9r2.png + images/simulator/Taranis/x9r3.png + images/simulator/Taranis/x9s0.png + images/simulator/Taranis/x9t0.png images/taranison.png images/wizard/ailerons.png images/wizard/airbrakes.png diff --git a/companion/src/constants.h b/companion/src/constants.h index 958134e07..b1f85fba2 100644 --- a/companion/src/constants.h +++ b/companion/src/constants.h @@ -11,7 +11,9 @@ enum BoardEnum { BOARD_AR9X, BOARD_TARANIS, BOARD_TARANIS_PLUS, - BOARD_TARANIS_X9E + BOARD_TARANIS_X9E, + BOARD_FLAMENCO, + BOARD_HORUS }; #define C9X_MAX_MODELS 60 diff --git a/companion/src/file.cpp b/companion/src/file.cpp index 34873a37d..c1c613f19 100644 --- a/companion/src/file.cpp +++ b/companion/src/file.cpp @@ -36,7 +36,6 @@ eepromFatHeader(NULL) #define EEPROM_BLOCK_SIZE (4*1024) #define EEPROM_MARK 0x84697771 /* thanks ;) */ #define EEPROM_ZONE_SIZE (8*1024) -#define EEPROM_BUFFER_SIZE 256 #define EEPROM_FAT_SIZE 128 #define EEPROM_MAX_ZONES (EEPROM_SIZE / EEPROM_ZONE_SIZE) #define EEPROM_MAX_FILES (EEPROM_MAX_ZONES - 1) diff --git a/companion/src/firmwares/opentx/opentxinterface.cpp b/companion/src/firmwares/opentx/opentxinterface.cpp index 1a4f68a77..295c6ac64 100644 --- a/companion/src/firmwares/opentx/opentxinterface.cpp +++ b/companion/src/firmwares/opentx/opentxinterface.cpp @@ -23,8 +23,8 @@ #include "file.h" #include "appdata.h" -#define OPENTX_FIRMWARE_DOWNLOADS "http://downloads-21.open-tx.org/firmware" -#define OPENTX_NIGHT_FIRMWARE_DOWNLOADS "http://downloads-21.open-tx.org/nightly/firmware" +#define OPENTX_FIRMWARE_DOWNLOADS "http://downloads-22.open-tx.org/firmware" +#define OPENTX_NIGHT_FIRMWARE_DOWNLOADS "http://downloads-22.open-tx.org/nightly/firmware" #define FILE_TYP_GENERAL 1 #define FILE_TYP_MODEL 2 @@ -75,6 +75,10 @@ const char * OpenTxEepromInterface::getName() return "OpenTX for 9XR-PRO"; case BOARD_AR9X: return "OpenTX for ar9x board / 9X"; + case BOARD_FLAMENCO: + return "OpenTX for Flamenco experimental"; + case BOARD_HORUS: + return "OpenTX for FrSky Horus"; default: return "OpenTX for an unknown board"; } @@ -98,6 +102,8 @@ const int OpenTxEepromInterface::getEEpromSize() case BOARD_TARANIS: case BOARD_TARANIS_PLUS: case BOARD_TARANIS_X9E: + case BOARD_FLAMENCO: + case BOARD_HORUS: return EESIZE_TARANIS; default: return 0; @@ -403,6 +409,8 @@ int OpenTxEepromInterface::save(uint8_t *eeprom, RadioData &radioData, uint32_t case BOARD_SKY9X: case BOARD_AR9X: case BOARD_9XRPRO: + case BOARD_FLAMENCO: + case BOARD_HORUS: version = 218; break; case BOARD_GRUVIN9X: @@ -1433,6 +1441,14 @@ void registerOpenTxFirmwares() addOpenTxCommonOptions(firmware); firmwares.push_back(firmware); + /* Horus board */ + firmware = new OpenTxFirmware("opentx-horus", QObject::tr("FrSky Horus"), BOARD_HORUS); + firmware->addOption("noheli", QObject::tr("Disable HELI menu and cyclic mix support")); + firmware->addOption("nogvars", QObject::tr("Disable Global variables")); + firmware->addOption("lua", QObject::tr("Support for Lua model scripts")); + addOpenTxCommonOptions(firmware); + firmwares.push_back(firmware); + default_firmware_variant = GetFirmware("opentx-taranisplus-en"); current_firmware_variant = default_firmware_variant; } diff --git a/companion/src/firmwares/opentx/simulator/CMakeLists.txt b/companion/src/firmwares/opentx/simulator/CMakeLists.txt index 062a8f4cd..d2d2a2def 100644 --- a/companion/src/firmwares/opentx/simulator/CMakeLists.txt +++ b/companion/src/firmwares/opentx/simulator/CMakeLists.txt @@ -13,6 +13,16 @@ add_custom_target(about_lbm_taranis WORKING_DIRECTORY ${RADIO_SRC_DIRECTORY} ) +add_custom_target(about_lbm_flamenco + make lbm PCB=FLAMENCO + WORKING_DIRECTORY ${RADIO_SRC_DIRECTORY} +) + +add_custom_target(about_lbm_horus + make lbm PCB=HORUS + WORKING_DIRECTORY ${RADIO_SRC_DIRECTORY} +) + add_custom_target(commondeps make stamp_header tra WORKING_DIRECTORY ${RADIO_SRC_DIRECTORY} @@ -20,8 +30,11 @@ add_custom_target(commondeps set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${RADIO_SRC_DIRECTORY}/stamp-opentx.h) -add_custom_target(lua_exports - make PCB=TARANIS lua_exports.inc +add_custom_target(lua_exports + COMMAND make PCB=TARANIS lua/lua_exports_taranis.inc + COMMAND make PCB=FLAMENCO lua/lua_exports_flamenco.inc + COMMAND make PCB=HORUS lua/lua_exports_horus.inc + DEPENDS ${RADIO_SRC_DIRECTORY}/myeeprom.h WORKING_DIRECTORY ${RADIO_SRC_DIRECTORY} ) @@ -84,6 +97,7 @@ add_library(opentx-ar9x${SUFFIX}-simulator SHARED ${OPENTX_SRC_FILES}) add_library(opentx-taranis${SUFFIX}-simulator SHARED ${OPENTX_SRC_FILES}) 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}) add_dependencies(opentx-9x${SUFFIX}-simulator about_lbm_9x commondeps) add_dependencies(opentx-9xr${SUFFIX}-simulator about_lbm_9x commondeps) @@ -97,6 +111,7 @@ add_dependencies(opentx-ar9x${SUFFIX}-simulator about_lbm_9x commondeps) add_dependencies(opentx-taranis${SUFFIX}-simulator about_lbm_taranis commondeps lua_exports) add_dependencies(opentx-taranisplus${SUFFIX}-simulator about_lbm_taranis commondeps lua_exports) add_dependencies(opentx-taranisx9e${SUFFIX}-simulator about_lbm_taranis commondeps lua_exports) +add_dependencies(opentx-horus${SUFFIX}-simulator about_lbm_horus commondeps lua_exports) set(OPENTX_LIBRARIES opentx-9x${SUFFIX}-simulator @@ -111,6 +126,7 @@ set(OPENTX_LIBRARIES opentx-taranis${SUFFIX}-simulator opentx-taranisplus${SUFFIX}-simulator opentx-taranisx9e${SUFFIX}-simulator + opentx-horus${SUFFIX}-simulator ) if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") @@ -118,65 +134,70 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") # 9X with ATmega64 -target_include_directories(opentx-9x${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/stock) -target_compile_definitions(opentx-9x${SUFFIX}-simulator PRIVATE PCBSTD PCB9X CPUM64 EEPROM_RLC ${COMMON_DEFINITIONS}) +target_include_directories(opentx-9x${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/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/stock) -target_compile_definitions(opentx-9xr${SUFFIX}-simulator PRIVATE PCBSTD PCB9XR CPUM64 EEPROM_RLC ${COMMON_DEFINITIONS}) +target_include_directories(opentx-9xr${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/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/stock) -target_compile_definitions(opentx-9x128${SUFFIX}-simulator PRIVATE PCBSTD PCB9X CPUM128 EEPROM_RLC ${COMMON_DEFINITIONS}) +target_include_directories(opentx-9x128${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/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/stock) -target_compile_definitions(opentx-9xr128${SUFFIX}-simulator PRIVATE PCBSTD PCB9XR CPUM128 EEPROM_RLC ${COMMON_DEFINITIONS}) +target_include_directories(opentx-9xr128${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/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_compile_definitions(opentx-gruvin9x${SUFFIX}-simulator PRIVATE PCBGRUVIN9X CPUM2560 EEPROM_RLC VOICE SDCARD ${COMMON_DEFINITIONS}) +target_include_directories(opentx-gruvin9x${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/Gruvin9x) +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_compile_definitions(opentx-mega2560${SUFFIX}-simulator PRIVATE PCBMEGA2560 CPUM2560 EEPROM_RLC SDCARD ROTARY_ENCODERS=2 ${COMMON_DEFINITIONS}) +target_include_directories(opentx-mega2560${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/Mega2560) +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_compile_definitions(opentx-sky9x${SUFFIX}-simulator PRIVATE PCBSKY9X CPUARM VOICE SDCARD ${COMMON_DEFINITIONS}) +target_include_directories(opentx-sky9x${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/Sky9x) +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_compile_definitions(opentx-9xrpro${SUFFIX}-simulator PRIVATE PCBSKY9X REVX CPUARM VOICE SDCARD ${COMMON_DEFINITIONS}) +target_include_directories(opentx-9xrpro${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/Sky9x) +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_compile_definitions(opentx-ar9x${SUFFIX}-simulator PRIVATE PCBSKY9X AR9X CPUARM VOICE SDCARD ${COMMON_DEFINITIONS}) +target_include_directories(opentx-ar9x${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/Sky9x) +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_compile_definitions(opentx-taranis${SUFFIX}-simulator PRIVATE PCBTARANIS CPUARM CPUSTM32 EEPROM_RLC VOICE SDCARD ${COMMON_DEFINITIONS}) +target_include_directories(opentx-taranis${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/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_compile_definitions(opentx-taranisplus${SUFFIX}-simulator PRIVATE PCBTARANIS REVPLUS CPUARM CPUSTM32 EEPROM_RLC VOICE SDCARD ${COMMON_DEFINITIONS}) +target_include_directories(opentx-taranisplus${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/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_compile_definitions(opentx-taranisx9e${SUFFIX}-simulator PRIVATE PCBTARANIS REVPLUS REV9E CPUARM CPUSTM32 STM32F40_41xxx EEPROM_RLC VOICE SDCARD ${COMMON_DEFINITIONS}) +target_include_directories(opentx-taranisx9e${SUFFIX}-simulator PRIVATE ${RADIO_SRC_DIRECTORY}/targets/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_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} ) diff --git a/companion/src/firmwares/opentx/simulator/opentxsimulator.cpp b/companion/src/firmwares/opentx/simulator/opentxsimulator.cpp index c573046d1..706b0e39d 100644 --- a/companion/src/firmwares/opentx/simulator/opentxsimulator.cpp +++ b/companion/src/firmwares/opentx/simulator/opentxsimulator.cpp @@ -40,7 +40,11 @@ #define AUTOSWITCH #define GRAPHICS #define CURVES -#if defined(PCBTARANIS) +#if defined(PCBFLAMENCO) || defined(PCBHORUS) +#define RTCLOCK +#define XCURVES +#define VIRTUALINPUTS +#elif defined(PCBTARANIS) #define RTCLOCK #define XCURVES #define VIRTUALINPUTS @@ -97,15 +101,19 @@ namespace NAMESPACE { #include "radio/src/pulses/pulses_avr.cpp" #endif -#include "radio/src/eeprom_common.cpp" +#include "radio/src/storage/storage_common.cpp" #if defined(EEPROM_RLC) -#include "radio/src/eeprom_rlc.cpp" -#else -#include "radio/src/eeprom_raw.cpp" +#include "radio/src/storage/eeprom_common.cpp" +#include "radio/src/storage/eeprom_rlc.cpp" +#elif defined(EEPROM) +#include "radio/src/storage/eeprom_common.cpp" +#include "radio/src/storage/eeprom_raw.cpp" +#elif defined(SDCARD) +#include "radio/src/storage/sdcard_raw.cpp" #endif #if defined(PCBTARANIS) || defined(PCBSKY9X) -#include "radio/src/eeprom_conversions.cpp" +#include "radio/src/storage/eeprom_conversions.cpp" #endif #include "radio/src/opentx.cpp" @@ -124,7 +132,80 @@ namespace NAMESPACE { #include "radio/src/vario.cpp" #include "radio/src/trainer_input.cpp" -#if defined(PCBTARANIS) +#if defined(PCBHORUS) +#include "radio/src/bmp.cpp" +#include "radio/src/gui/Horus/bitmaps.cpp" +#include "radio/src/gui/Horus/fonts.cpp" +#include "radio/src/gui/Horus/widgets.cpp" +#include "radio/src/gui/Horus/navigation.cpp" +#include "radio/src/gui/Horus/popups.cpp" +#include "radio/src/gui/Horus/helpers.cpp" +#include "radio/src/gui/Horus/menus.cpp" +#include "radio/src/gui/Horus/menu_model.cpp" +#include "radio/src/gui/Horus/menu_model_select.cpp" +#include "radio/src/gui/Horus/menu_model_setup.cpp" +#include "radio/src/gui/Horus/menu_model_heli.cpp" +#include "radio/src/gui/Horus/menu_model_flightmodes.cpp" +#include "radio/src/gui/Horus/menu_model_inputs_mixes.cpp" +#include "radio/src/gui/Horus/menu_model_curves.cpp" +#include "radio/src/gui/Horus/menu_model_logical_switches.cpp" +#include "radio/src/gui/Horus/menu_model_custom_functions.cpp" +// #include "radio/src/gui/Horus/menu_model_custom_scripts.cpp" +#include "radio/src/gui/Horus/menu_model_gvars.cpp" +#include "radio/src/gui/Horus/menu_model_limits.cpp" +#include "radio/src/gui/Horus/menu_model_telemetry.cpp" +#include "radio/src/gui/Horus/menu_general.cpp" +#include "radio/src/gui/Horus/menu_general_setup.cpp" +#include "radio/src/gui/Horus/menu_general_sdmanager.cpp" +#include "radio/src/gui/Horus/menu_general_trainer.cpp" +#include "radio/src/gui/Horus/menu_general_version.cpp" +// #include "radio/src/gui/Horus/menu_general_hardware.cpp" +#include "radio/src/gui/Horus/menu_general_calib.cpp" +#include "radio/src/gui/Horus/view_main.cpp" +#include "radio/src/gui/Horus/view_statistics.cpp" +#include "radio/src/gui/Horus/view_channels.cpp" +#include "radio/src/gui/Horus/view_telemetry.cpp" +#include "radio/src/gui/Horus/view_text.cpp" +#include "radio/src/gui/Horus/view_about.cpp" +#include "radio/src/gui/Horus/lcd.cpp" +#include "radio/src/gui/Horus/splash.cpp" +#elif defined(PCBFLAMENCO) +#include "radio/src/gui/Flamenco/fonts.cpp" +#include "radio/src/gui/Flamenco/widgets.cpp" +#include "radio/src/gui/Flamenco/navigation.cpp" +#include "radio/src/gui/Flamenco/popups.cpp" +#include "radio/src/gui/Flamenco/helpers.cpp" +#include "radio/src/gui/Flamenco/menus.cpp" +#include "radio/src/gui/Flamenco/menu_model.cpp" +#include "radio/src/gui/Flamenco/menu_model_select.cpp" +#include "radio/src/gui/Flamenco/menu_model_setup.cpp" +#include "radio/src/gui/Flamenco/menu_model_heli.cpp" +#include "radio/src/gui/Flamenco/menu_model_flightmodes.cpp" +#include "radio/src/gui/Flamenco/menu_model_inputs_mixes.cpp" +#include "radio/src/gui/Flamenco/menu_model_curves.cpp" +#include "radio/src/gui/Flamenco/menu_model_logical_switches.cpp" +#include "radio/src/gui/Flamenco/menu_model_custom_functions.cpp" +// #include "radio/src/gui/Flamenco/menu_model_custom_scripts.cpp" +#include "radio/src/gui/Flamenco/menu_model_gvars.cpp" +#include "radio/src/gui/Flamenco/menu_model_limits.cpp" +#include "radio/src/gui/Flamenco/menu_model_telemetry.cpp" +#include "radio/src/gui/Flamenco/menu_general.cpp" +#include "radio/src/gui/Flamenco/menu_general_setup.cpp" +#include "radio/src/gui/Flamenco/menu_general_sdmanager.cpp" +#include "radio/src/gui/Flamenco/menu_general_trainer.cpp" +#include "radio/src/gui/Flamenco/menu_general_version.cpp" +// #include "radio/src/gui/Flamenco/menu_general_hardware.cpp" +#include "radio/src/gui/Flamenco/menu_general_calib.cpp" +#include "radio/src/gui/Flamenco/view_main.cpp" +#include "radio/src/gui/Flamenco/view_statistics.cpp" +#include "radio/src/gui/Flamenco/view_channels.cpp" +#include "radio/src/gui/Flamenco/view_telemetry.cpp" +#include "radio/src/gui/Flamenco/view_text.cpp" +#include "radio/src/gui/Flamenco/view_about.cpp" +#include "radio/src/gui/Flamenco/lcd.cpp" +#include "radio/src/gui/Flamenco/splash.cpp" +#include "radio/src/targets/Flamenco/tw8823_driver.cpp" +#elif defined(PCBTARANIS) #include "radio/src/bmp.cpp" #include "radio/src/gui/Taranis/fonts.cpp" #include "radio/src/gui/Taranis/widgets.cpp" @@ -221,38 +302,62 @@ namespace NAMESPACE { #include "radio/src/buzzer.cpp" #endif -#if defined(PCBTARANIS) -#include "radio/src/targets/taranis/board_taranis.cpp" -#include "radio/src/targets/taranis/keys_driver.cpp" -#include "radio/src/targets/taranis/audio_driver.cpp" -#include "radio/src/targets/taranis/telemetry_driver.cpp" -#include "radio/src/targets/taranis/haptic_driver.cpp" +#if defined(PCBHORUS) +#include "radio/src/targets/Horus/board_horus.cpp" +#include "radio/src/targets/Horus/keys_driver.cpp" +#include "radio/src/targets/Horus/audio_driver.cpp" +#include "radio/src/targets/Horus/telemetry_driver.cpp" +#include "radio/src/targets/Horus/haptic_driver.cpp" +#include "radio/src/targets/Horus/pulses_driver.cpp" +#include "radio/src/targets/Taranis/rtc_driver.cpp" +#include "radio/src/targets/Horus/trainer_driver.cpp" +#include "radio/src/targets/Horus/serial2_driver.cpp" +#elif defined(PCBFLAMENCO) +#include "radio/src/targets/Flamenco/board_flamenco.cpp" +#include "radio/src/targets/Flamenco/keys_driver.cpp" +#include "radio/src/targets/Flamenco/audio_driver.cpp" +#include "radio/src/targets/Flamenco/telemetry_driver.cpp" +#include "radio/src/targets/Flamenco/eeprom_driver.cpp" +// #include "radio/src/targets/Flamenco/haptic_driver.cpp" +#include "radio/src/targets/Flamenco/pulses_driver.cpp" +#include "radio/src/targets/Flamenco/rtc_driver.cpp" +#include "radio/src/targets/Flamenco/trainer_driver.cpp" +#elif defined(PCBTARANIS) +#include "radio/src/targets/Taranis/board_taranis.cpp" +#include "radio/src/targets/Taranis/keys_driver.cpp" +#include "radio/src/targets/Taranis/audio_driver.cpp" +#include "radio/src/targets/Taranis/telemetry_driver.cpp" +#include "radio/src/targets/Taranis/haptic_driver.cpp" #if defined(REV9E) -#include "radio/src/targets/taranis/top_lcd_driver.cpp" +#include "radio/src/targets/Taranis/top_lcd_driver.cpp" #endif -#include "radio/src/targets/taranis/pulses_driver.cpp" -#include "radio/src/targets/taranis/rtc_driver.cpp" -#include "radio/src/targets/taranis/trainer_driver.cpp" -#include "radio/src/targets/taranis/serial2_driver.cpp" +#include "radio/src/targets/Taranis/pulses_driver.cpp" +#include "radio/src/targets/Taranis/rtc_driver.cpp" +#include "radio/src/targets/Taranis/trainer_driver.cpp" +#include "radio/src/targets/Taranis/serial2_driver.cpp" #elif defined(PCBSKY9X) -#include "radio/src/targets/sky9x/board_sky9x.cpp" -#include "radio/src/targets/sky9x/telemetry_driver.cpp" -#include "radio/src/targets/sky9x/pwr_driver.cpp" -#include "radio/src/targets/sky9x/eeprom_driver.cpp" -#include "radio/src/targets/sky9x/keys_driver.cpp" -#include "radio/src/targets/sky9x/audio_driver.cpp" -#include "radio/src/targets/sky9x/sdcard_driver.cpp" -#include "radio/src/targets/sky9x/coproc_driver.cpp" -#include "radio/src/targets/sky9x/haptic_driver.cpp" -#include "radio/src/targets/sky9x/serial2_driver.cpp" -#include "radio/src/targets/sky9x/pulses_driver.cpp" +#include "radio/src/targets/Sky9x/board_sky9x.cpp" +#include "radio/src/targets/Sky9x/telemetry_driver.cpp" +#include "radio/src/targets/Sky9x/pwr_driver.cpp" +#include "radio/src/targets/Sky9x/eeprom_driver.cpp" +#include "radio/src/targets/Sky9x/keys_driver.cpp" +#include "radio/src/targets/Sky9x/audio_driver.cpp" +#include "radio/src/targets/Sky9x/sdcard_driver.cpp" +#include "radio/src/targets/Sky9x/coproc_driver.cpp" +#include "radio/src/targets/Sky9x/haptic_driver.cpp" +#include "radio/src/targets/Sky9x/serial2_driver.cpp" +#include "radio/src/targets/Sky9x/pulses_driver.cpp" #elif defined(PCBGRUVIN9X) -#include "radio/src/targets/gruvin9x/board_gruvin9x.cpp" -#include "radio/src/targets/gruvin9x/somo14d.cpp" +#include "radio/src/targets/Gruvin9x/board_gruvin9x.cpp" +#include "radio/src/targets/Gruvin9x/somo14d.cpp" #elif defined(PCBMEGA2560) -#include "radio/src/targets/mega2560/board_mega2560.cpp" +#include "radio/src/targets/Mega2560/board_mega2560.cpp" #else -#include "radio/src/targets/stock/board_stock.cpp" +#include "radio/src/targets/9x/board_stock.cpp" +#endif + +#if defined(CPUARM) +#include "radio/src/gui/gui_helpers.cpp" #endif #include "radio/src/keys.cpp" @@ -459,11 +564,16 @@ void OpenTxSimulator::getTrims(Trims & trims) void OpenTxSimulator::wheelEvent(int steps) { -#if defined(REV9E) - if (steps == 255) - x9de_rotenc -= 2; +#if defined(PCBHORUS) || defined(PCBFLAMENCO) + if (steps > 0) + rotencValue -= 2; else - x9de_rotenc += 2; + rotencValue += 2; +#elif defined(REV9E) + if (steps == 255) + rotencValue -= 2; + else + rotencValue += 2; #elif defined(PCBSKY9X) && !defined(REVX) g_rotenc[0] += steps*4; #elif defined(PCBGRUVIN9X) @@ -526,7 +636,11 @@ class OpenTxSimulatorFactory: public SimulatorFactory virtual BoardEnum type() { -#if defined(PCBTARANIS) +#if defined(PCBHORUS) + return BOARD_HORUS; +#elif defined(PCBFLAMENCO) + return BOARD_FLAMENCO; +#elif defined(PCBTARANIS) return BOARD_TARANIS; #else return BOARD_STOCK; diff --git a/companion/src/firmwares/opentx/simulator/opentxsimulator.h b/companion/src/firmwares/opentx/simulator/opentxsimulator.h index a17f2aba5..95cdafd39 100644 --- a/companion/src/firmwares/opentx/simulator/opentxsimulator.h +++ b/companion/src/firmwares/opentx/simulator/opentxsimulator.h @@ -19,7 +19,15 @@ #include "simulatorinterface.h" -#if defined(PCBTARANIS) && defined(REV9E) +#if defined(PCBHORUS) + #define FLAVOUR "horus" + #define NAMESPACE HORUS + #define EEPROM_VARIANT 0 +#elif defined(PCBFLAMENCO) + #define FLAVOUR "flamenco" + #define NAMESPACE FLAMENCO + #define EEPROM_VARIANT 0 +#elif defined(PCBTARANIS) && defined(REV9E) #define FLAVOUR "taranisx9e" #define NAMESPACE TaranisX9E #define EEPROM_VARIANT 0x8000 diff --git a/companion/src/helpers.cpp b/companion/src/helpers.cpp index c396f13b4..518e3cbc2 100644 --- a/companion/src/helpers.cpp +++ b/companion/src/helpers.cpp @@ -788,7 +788,13 @@ void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx) } BoardEnum board = GetCurrentFirmware()->getBoard(); SimulatorDialog * sd; - if (IS_TARANIS(board)) { + if (board == BOARD_HORUS) { + sd = new SimulatorDialogHorus(parent, si, flags); + } + else if (board == BOARD_FLAMENCO) { + sd = new SimulatorDialogFlamenco(parent, si, flags); + } + else if (IS_TARANIS(board)) { for (int i=0; igetCapability(Pots); i++) { if (radioData.generalSettings.isPotAvailable(i)) { flags |= (SIMULATOR_FLAGS_S1 << i); diff --git a/companion/src/images/originals/simufront/horus_slim.svg b/companion/src/images/originals/simufront/horus_slim.svg new file mode 100644 index 000000000..63123eddf --- /dev/null +++ b/companion/src/images/originals/simufront/horus_slim.svg @@ -0,0 +1,28801 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + HORUS X12D + HORUS X12D + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Activated button= black/opacity 30% + + + diff --git a/companion/src/images/9xcurs.png b/companion/src/images/simulator/9X/9xcurs.png similarity index 100% rename from companion/src/images/9xcurs.png rename to companion/src/images/simulator/9X/9xcurs.png diff --git a/companion/src/images/9xcursdown.png b/companion/src/images/simulator/9X/9xcursdown.png similarity index 100% rename from companion/src/images/9xcursdown.png rename to companion/src/images/simulator/9X/9xcursdown.png diff --git a/companion/src/images/9xcursmin.png b/companion/src/images/simulator/9X/9xcursmin.png similarity index 100% rename from companion/src/images/9xcursmin.png rename to companion/src/images/simulator/9X/9xcursmin.png diff --git a/companion/src/images/9xcursphoto.png b/companion/src/images/simulator/9X/9xcursphoto.png similarity index 100% rename from companion/src/images/9xcursphoto.png rename to companion/src/images/simulator/9X/9xcursphoto.png diff --git a/companion/src/images/9xcursplus.png b/companion/src/images/simulator/9X/9xcursplus.png similarity index 100% rename from companion/src/images/9xcursplus.png rename to companion/src/images/simulator/9X/9xcursplus.png diff --git a/companion/src/images/9xcursup.png b/companion/src/images/simulator/9X/9xcursup.png similarity index 100% rename from companion/src/images/9xcursup.png rename to companion/src/images/simulator/9X/9xcursup.png diff --git a/companion/src/images/9xdb-bl.png b/companion/src/images/simulator/9X/9xdb-bl.png similarity index 100% rename from companion/src/images/9xdb-bl.png rename to companion/src/images/simulator/9X/9xdb-bl.png diff --git a/companion/src/images/9xdb-gr.png b/companion/src/images/simulator/9X/9xdb-gr.png similarity index 100% rename from companion/src/images/9xdb-gr.png rename to companion/src/images/simulator/9X/9xdb-gr.png diff --git a/companion/src/images/9xdb-or.png b/companion/src/images/simulator/9X/9xdb-or.png similarity index 100% rename from companion/src/images/9xdb-or.png rename to companion/src/images/simulator/9X/9xdb-or.png diff --git a/companion/src/images/9xdb-rd.png b/companion/src/images/simulator/9X/9xdb-rd.png similarity index 100% rename from companion/src/images/9xdb-rd.png rename to companion/src/images/simulator/9X/9xdb-rd.png diff --git a/companion/src/images/9xdb-yl.png b/companion/src/images/simulator/9X/9xdb-yl.png similarity index 100% rename from companion/src/images/9xdb-yl.png rename to companion/src/images/simulator/9X/9xdb-yl.png diff --git a/companion/src/images/9xdb.png b/companion/src/images/simulator/9X/9xdb.png similarity index 100% rename from companion/src/images/9xdb.png rename to companion/src/images/simulator/9X/9xdb.png diff --git a/companion/src/images/9xdl-bl.png b/companion/src/images/simulator/9X/9xdl-bl.png similarity index 100% rename from companion/src/images/9xdl-bl.png rename to companion/src/images/simulator/9X/9xdl-bl.png diff --git a/companion/src/images/9xdl-gr.png b/companion/src/images/simulator/9X/9xdl-gr.png similarity index 100% rename from companion/src/images/9xdl-gr.png rename to companion/src/images/simulator/9X/9xdl-gr.png diff --git a/companion/src/images/9xdl-or.png b/companion/src/images/simulator/9X/9xdl-or.png similarity index 100% rename from companion/src/images/9xdl-or.png rename to companion/src/images/simulator/9X/9xdl-or.png diff --git a/companion/src/images/9xdl-rd.png b/companion/src/images/simulator/9X/9xdl-rd.png similarity index 100% rename from companion/src/images/9xdl-rd.png rename to companion/src/images/simulator/9X/9xdl-rd.png diff --git a/companion/src/images/9xdl-yl.png b/companion/src/images/simulator/9X/9xdl-yl.png similarity index 100% rename from companion/src/images/9xdl-yl.png rename to companion/src/images/simulator/9X/9xdl-yl.png diff --git a/companion/src/images/9xdl.png b/companion/src/images/simulator/9X/9xdl.png similarity index 100% rename from companion/src/images/9xdl.png rename to companion/src/images/simulator/9X/9xdl.png diff --git a/companion/src/images/9xdr-bl.png b/companion/src/images/simulator/9X/9xdr-bl.png similarity index 100% rename from companion/src/images/9xdr-bl.png rename to companion/src/images/simulator/9X/9xdr-bl.png diff --git a/companion/src/images/9xdr-gr.png b/companion/src/images/simulator/9X/9xdr-gr.png similarity index 100% rename from companion/src/images/9xdr-gr.png rename to companion/src/images/simulator/9X/9xdr-gr.png diff --git a/companion/src/images/9xdr-or.png b/companion/src/images/simulator/9X/9xdr-or.png similarity index 100% rename from companion/src/images/9xdr-or.png rename to companion/src/images/simulator/9X/9xdr-or.png diff --git a/companion/src/images/9xdr-rd.png b/companion/src/images/simulator/9X/9xdr-rd.png similarity index 100% rename from companion/src/images/9xdr-rd.png rename to companion/src/images/simulator/9X/9xdr-rd.png diff --git a/companion/src/images/9xdr-yl.png b/companion/src/images/simulator/9X/9xdr-yl.png similarity index 100% rename from companion/src/images/9xdr-yl.png rename to companion/src/images/simulator/9X/9xdr-yl.png diff --git a/companion/src/images/9xdr.png b/companion/src/images/simulator/9X/9xdr.png similarity index 100% rename from companion/src/images/9xdr.png rename to companion/src/images/simulator/9X/9xdr.png diff --git a/companion/src/images/9xdt-bl.png b/companion/src/images/simulator/9X/9xdt-bl.png similarity index 100% rename from companion/src/images/9xdt-bl.png rename to companion/src/images/simulator/9X/9xdt-bl.png diff --git a/companion/src/images/9xdt-gr.png b/companion/src/images/simulator/9X/9xdt-gr.png similarity index 100% rename from companion/src/images/9xdt-gr.png rename to companion/src/images/simulator/9X/9xdt-gr.png diff --git a/companion/src/images/9xdt-or.png b/companion/src/images/simulator/9X/9xdt-or.png similarity index 100% rename from companion/src/images/9xdt-or.png rename to companion/src/images/simulator/9X/9xdt-or.png diff --git a/companion/src/images/9xdt-rd.png b/companion/src/images/simulator/9X/9xdt-rd.png similarity index 100% rename from companion/src/images/9xdt-rd.png rename to companion/src/images/simulator/9X/9xdt-rd.png diff --git a/companion/src/images/9xdt-yl.png b/companion/src/images/simulator/9X/9xdt-yl.png similarity index 100% rename from companion/src/images/9xdt-yl.png rename to companion/src/images/simulator/9X/9xdt-yl.png diff --git a/companion/src/images/9xdt.png b/companion/src/images/simulator/9X/9xdt.png similarity index 100% rename from companion/src/images/9xdt.png rename to companion/src/images/simulator/9X/9xdt.png diff --git a/companion/src/images/9xmenu.png b/companion/src/images/simulator/9X/9xmenu.png similarity index 100% rename from companion/src/images/9xmenu.png rename to companion/src/images/simulator/9X/9xmenu.png diff --git a/companion/src/images/9xmenuexit.png b/companion/src/images/simulator/9X/9xmenuexit.png similarity index 100% rename from companion/src/images/9xmenuexit.png rename to companion/src/images/simulator/9X/9xmenuexit.png diff --git a/companion/src/images/9xmenumenu.png b/companion/src/images/simulator/9X/9xmenumenu.png similarity index 100% rename from companion/src/images/9xmenumenu.png rename to companion/src/images/simulator/9X/9xmenumenu.png diff --git a/companion/src/images/simulator/Horus/border-right.png b/companion/src/images/simulator/Horus/border-right.png new file mode 100644 index 000000000..8c2398885 Binary files /dev/null and b/companion/src/images/simulator/Horus/border-right.png differ diff --git a/companion/src/images/simulator/Horus/bottom.png b/companion/src/images/simulator/Horus/bottom.png new file mode 100644 index 000000000..7d3fb11b1 Binary files /dev/null and b/companion/src/images/simulator/Horus/bottom.png differ diff --git a/companion/src/images/simulator/Horus/led.png b/companion/src/images/simulator/Horus/led.png new file mode 100644 index 000000000..faa808888 Binary files /dev/null and b/companion/src/images/simulator/Horus/led.png differ diff --git a/companion/src/images/simulator/Horus/left.png b/companion/src/images/simulator/Horus/left.png new file mode 100644 index 000000000..51d2cdaf4 Binary files /dev/null and b/companion/src/images/simulator/Horus/left.png differ diff --git a/companion/src/images/simulator/Horus/left_btn1.png b/companion/src/images/simulator/Horus/left_btn1.png new file mode 100644 index 000000000..4da7ef401 Binary files /dev/null and b/companion/src/images/simulator/Horus/left_btn1.png differ diff --git a/companion/src/images/simulator/Horus/left_btn2.png b/companion/src/images/simulator/Horus/left_btn2.png new file mode 100644 index 000000000..6a77606ae Binary files /dev/null and b/companion/src/images/simulator/Horus/left_btn2.png differ diff --git a/companion/src/images/simulator/Horus/left_scrnsht.png b/companion/src/images/simulator/Horus/left_scrnsht.png new file mode 100644 index 000000000..625aa7208 Binary files /dev/null and b/companion/src/images/simulator/Horus/left_scrnsht.png differ diff --git a/companion/src/images/simulator/Horus/middle.png b/companion/src/images/simulator/Horus/middle.png new file mode 100644 index 000000000..2964334da Binary files /dev/null and b/companion/src/images/simulator/Horus/middle.png differ diff --git a/companion/src/images/simulator/Horus/right.png b/companion/src/images/simulator/Horus/right.png new file mode 100644 index 000000000..67a77e8f7 Binary files /dev/null and b/companion/src/images/simulator/Horus/right.png differ diff --git a/companion/src/images/simulator/Horus/right_btnD.png b/companion/src/images/simulator/Horus/right_btnD.png new file mode 100644 index 000000000..0fff8f9ef Binary files /dev/null and b/companion/src/images/simulator/Horus/right_btnD.png differ diff --git a/companion/src/images/simulator/Horus/right_btnL.png b/companion/src/images/simulator/Horus/right_btnL.png new file mode 100644 index 000000000..af5500fd4 Binary files /dev/null and b/companion/src/images/simulator/Horus/right_btnL.png differ diff --git a/companion/src/images/simulator/Horus/right_btnR.png b/companion/src/images/simulator/Horus/right_btnR.png new file mode 100644 index 000000000..d7fb27970 Binary files /dev/null and b/companion/src/images/simulator/Horus/right_btnR.png differ diff --git a/companion/src/images/simulator/Horus/right_btnU.png b/companion/src/images/simulator/Horus/right_btnU.png new file mode 100644 index 000000000..16a9b6cd1 Binary files /dev/null and b/companion/src/images/simulator/Horus/right_btnU.png differ diff --git a/companion/src/images/simulator/Horus/right_ent.png b/companion/src/images/simulator/Horus/right_ent.png new file mode 100644 index 000000000..9fc69d470 Binary files /dev/null and b/companion/src/images/simulator/Horus/right_ent.png differ diff --git a/companion/src/images/simulator/Horus/right_re_ph2.png b/companion/src/images/simulator/Horus/right_re_ph2.png new file mode 100644 index 000000000..6808a453e Binary files /dev/null and b/companion/src/images/simulator/Horus/right_re_ph2.png differ diff --git a/companion/src/images/simulator/Horus/right_re_ph3.png b/companion/src/images/simulator/Horus/right_re_ph3.png new file mode 100644 index 000000000..67a77e8f7 Binary files /dev/null and b/companion/src/images/simulator/Horus/right_re_ph3.png differ diff --git a/companion/src/images/simulator/Horus/top.png b/companion/src/images/simulator/Horus/top.png new file mode 100644 index 000000000..334f6bc56 Binary files /dev/null and b/companion/src/images/simulator/Horus/top.png differ diff --git a/companion/src/images/x9b0.png b/companion/src/images/simulator/Taranis/x9b0.png similarity index 100% rename from companion/src/images/x9b0.png rename to companion/src/images/simulator/Taranis/x9b0.png diff --git a/companion/src/images/x9l0.png b/companion/src/images/simulator/Taranis/x9l0.png similarity index 100% rename from companion/src/images/x9l0.png rename to companion/src/images/simulator/Taranis/x9l0.png diff --git a/companion/src/images/x9l1.png b/companion/src/images/simulator/Taranis/x9l1.png similarity index 100% rename from companion/src/images/x9l1.png rename to companion/src/images/simulator/Taranis/x9l1.png diff --git a/companion/src/images/x9l2.png b/companion/src/images/simulator/Taranis/x9l2.png similarity index 100% rename from companion/src/images/x9l2.png rename to companion/src/images/simulator/Taranis/x9l2.png diff --git a/companion/src/images/x9l3.png b/companion/src/images/simulator/Taranis/x9l3.png similarity index 100% rename from companion/src/images/x9l3.png rename to companion/src/images/simulator/Taranis/x9l3.png diff --git a/companion/src/images/x9l4.png b/companion/src/images/simulator/Taranis/x9l4.png similarity index 100% rename from companion/src/images/x9l4.png rename to companion/src/images/simulator/Taranis/x9l4.png diff --git a/companion/src/images/x9r0.png b/companion/src/images/simulator/Taranis/x9r0.png similarity index 100% rename from companion/src/images/x9r0.png rename to companion/src/images/simulator/Taranis/x9r0.png diff --git a/companion/src/images/x9r1.png b/companion/src/images/simulator/Taranis/x9r1.png similarity index 100% rename from companion/src/images/x9r1.png rename to companion/src/images/simulator/Taranis/x9r1.png diff --git a/companion/src/images/x9r2.png b/companion/src/images/simulator/Taranis/x9r2.png similarity index 100% rename from companion/src/images/x9r2.png rename to companion/src/images/simulator/Taranis/x9r2.png diff --git a/companion/src/images/x9r3.png b/companion/src/images/simulator/Taranis/x9r3.png similarity index 100% rename from companion/src/images/x9r3.png rename to companion/src/images/simulator/Taranis/x9r3.png diff --git a/companion/src/images/x9s0.png b/companion/src/images/simulator/Taranis/x9s0.png similarity index 100% rename from companion/src/images/x9s0.png rename to companion/src/images/simulator/Taranis/x9s0.png diff --git a/companion/src/images/x9t0.png b/companion/src/images/simulator/Taranis/x9t0.png similarity index 100% rename from companion/src/images/x9t0.png rename to companion/src/images/simulator/Taranis/x9t0.png diff --git a/companion/src/mainwindow.cpp b/companion/src/mainwindow.cpp index e30143ba5..52e63ea80 100644 --- a/companion/src/mainwindow.cpp +++ b/companion/src/mainwindow.cpp @@ -70,8 +70,8 @@ #include "radiointerface.h" #include "progressdialog.h" -#define OPENTX_COMPANION_DOWNLOADS "http://downloads-21.open-tx.org/companion" -#define OPENTX_NIGHT_COMPANION_DOWNLOADS "http://downloads-21.open-tx.org/nightly/companion" +#define OPENTX_COMPANION_DOWNLOADS "http://downloads-22.open-tx.org/companion" +#define OPENTX_NIGHT_COMPANION_DOWNLOADS "http://downloads-22.open-tx.org/nightly/companion" #define DONATE_STR "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QUZ48K4SEXDP2" #ifdef __APPLE__ @@ -278,7 +278,7 @@ void MainWindow::closeUpdatesWaitDialog() void MainWindow::checkForCompanionUpdateFinished(QNetworkReply * reply) { QByteArray qba = reply->readAll(); - int i = qba.indexOf("C9X_VERSION"); + int i = qba.indexOf("VERSION"); if (i>0) { QString version = qba.mid(i+14, qba.indexOf("\"", i+14)-i-14); @@ -288,7 +288,7 @@ void MainWindow::checkForCompanionUpdateFinished(QNetworkReply * reply) int vnum = version2index(version); - QString c9xversion = QString(C9X_VERSION); + QString c9xversion = QString(VERSION); int c9xver = version2index(c9xversion); if (c9xver < vnum) { @@ -899,7 +899,7 @@ void MainWindow::about() aboutStr.append("

"); aboutStr.append(tr("If you've found this program useful, please support by donating").arg(DONATE_STR)); aboutStr.append("

"); - aboutStr.append(QString("Version %1, %2").arg(C9X_VERSION).arg(__DATE__)); + aboutStr.append(QString("Version %1, %2").arg(VERSION).arg(__DATE__)); aboutStr.append("

"); aboutStr.append(tr("Copyright OpenTX Team") + "
© 2011-2015
"); QMessageBox msgBox(this); @@ -930,7 +930,7 @@ void MainWindow::updateMenus() updateLanguageActions(); updateIconSizeActions(); updateIconThemeActions(); - setWindowTitle(tr("OpenTX Companion %1 - Radio: %2 - Profile: %3").arg(C9X_VERSION).arg(GetCurrentFirmware()->getName()).arg(g.profile[g.id()].name())); + setWindowTitle(tr("OpenTX Companion %1 - Radio: %2 - Profile: %3").arg(VERSION).arg(GetCurrentFirmware()->getName()).arg(g.profile[g.id()].name())); } MdiChild *MainWindow::createMdiChild() diff --git a/companion/src/simulation/CMakeLists.txt b/companion/src/simulation/CMakeLists.txt index bda9fed7f..8a6249219 100644 --- a/companion/src/simulation/CMakeLists.txt +++ b/companion/src/simulation/CMakeLists.txt @@ -9,6 +9,8 @@ set(simulation_SRCS set(simulation_UIS simulatordialog-9x.ui simulatordialog-taranis.ui + simulatordialog-horus.ui + simulatordialog-flamenco.ui telemetrysimu.ui trainersimu.ui debugoutput.ui @@ -16,11 +18,9 @@ set(simulation_UIS set(simulation_HDRS simulatordialog.h - cursorwidget.h - menuwidget.h - xcursorwidget.h - xmenuwidget.h - myslider.h + # lcdwidget.h + buttonswidget.h + sliderwidget.h telemetrysimu.h trainersimu.h debugoutput.h diff --git a/companion/src/simulation/buttonswidget.h b/companion/src/simulation/buttonswidget.h new file mode 100644 index 000000000..56f417b26 --- /dev/null +++ b/companion/src/simulation/buttonswidget.h @@ -0,0 +1,122 @@ +/* + * Author - Bertrand Songis + * + * Based on th9x -> http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#ifndef _BUTTONSWIDGET_H_ +#define _BUTTONSWIDGET_H_ + +#include +#include + +class ButtonsWidget : public QWidget +{ + + Q_OBJECT + + public: + + explicit ButtonsWidget(QWidget * parent): + QWidget(parent) + { + } + + + virtual void setStyleSheet(const QString & sheet) + { + defaultStyleSheet = sheet; + QWidget::setStyleSheet(sheet); + } + + void addArea(int x1, int y1, int x2, int y2, int key, const char * bitmap) + { + QPolygon polygon; + polygon.setPoints(4, x1, y1, x1, y2, x2, y2, x2, y1); + addArea(polygon, key, bitmap); + } + + void addArea(const QPolygon & polygon, int key, const char * bitmap) + { + areas.push_back(Area(polygon, key, bitmap)); + } + + protected: + + class Area { + public: + Area(const QPolygon & polygon, int key, const char * bitmap): + polygon(polygon), + key(key), + bitmap(bitmap) + { + } + bool contains(int x, int y) + { + return polygon.containsPoint(QPoint(x, y), Qt::OddEvenFill); + } + public: + QPolygon polygon; + int key; + const char * bitmap; + }; + + void setBitmap(const char * bitmap) + { + if (bitmap) { + QWidget::setStyleSheet(QString("background:url(:/images/simulator/%1);").arg(bitmap)); + } + } + + virtual void mousePressEvent(QMouseEvent * event) + { + int x = event->x(); + int y = event->y(); + setFocus(); + if (event->button() == Qt::LeftButton) { + foreach(Area area, areas) { + if (area.contains(x, y)) { + setBitmap(area.bitmap); + emit buttonPressed(area.key); + break; + } + } + } + } + + virtual void mouseReleaseEvent(QMouseEvent * event) + { + QWidget::setStyleSheet(defaultStyleSheet); + setFocus(); + emit buttonPressed(0); + } + + void paintEvent(QPaintEvent *) + { + QStyleOption opt; + opt.init(this); + QPainter p(this); + style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); + } + + signals: + + void buttonPressed(int button); + + protected: + + QList areas; + QString defaultStyleSheet; +}; + +#endif /* _BUTTONSWIDGET_H_ */ diff --git a/companion/src/simulation/cursorwidget.h b/companion/src/simulation/cursorwidget.h deleted file mode 100644 index 7d35b343e..000000000 --- a/companion/src/simulation/cursorwidget.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Author - Bertrand Songis - * - * Based on th9x -> http://code.google.com/p/th9x/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ -#ifndef CURSORWIDGET_H -#define CURSORWIDGET_H - -#include -#include - -class cursorWidget : public QWidget { - - Q_OBJECT - - public: - - explicit cursorWidget(QWidget * parent = 0): - QWidget(parent) - { - } - - protected: - - virtual void mousePressEvent(QMouseEvent * event) - { - float upx[] = {68,28,51,83,105,68}; - float upy[] = {83,45,32,32,45,83}; - float minx[] = {74,114,127,127,114,74}; - float miny[] = {90,51,80,106,130,90}; - float dox[] = {68,28,51,83,105,68}; - float doy[] = {98,137,151,151,137,98}; - float plusx[] = { 80,20,7,7,20,80}; - float plusy[] = {90,51,80,106,130,90}; - - int x=event->x(); - int y=event->y(); - setFocus(); - if (event->button()==Qt::LeftButton) { - if (pnpoly(6,upx,upy,(float)x,(float)y)==1) { - setStyleSheet("background:url(:/images/9xcursup.png);"); - emit buttonPressed(Qt::Key_Up); - } - else if (pnpoly(6,minx,miny,(float)x,(float)y)==1) { - setStyleSheet("background:url(:/images/9xcursmin.png);"); - emit buttonPressed(Qt::Key_Right); - } - else if (pnpoly(6,dox,doy,(float)x,(float)y)==1) { - setStyleSheet("background:url(:/images/9xcursdown.png);"); - emit buttonPressed(Qt::Key_Down); - } - else if (pnpoly(6,plusx,plusy,(float)x,(float)y)==1) { - setStyleSheet("background:url(:/images/9xcursplus.png);"); - emit buttonPressed(Qt::Key_Left); - } else if (sqrt(((float)x-22)*((float)x-22)+((float)y-165)*((float)y-165))<17) { - setStyleSheet("background:url(:/images/9xcursphoto.png);"); - emit buttonPressed(Qt::Key_Print); - } - } - // QWidget::mousePressEvent(event); - } - - virtual void mouseReleaseEvent(QMouseEvent * event) - { - setStyleSheet("background:url(:/images/9xcurs.png);"); - emit buttonPressed(0); - setFocus(); - //QWidget::mouseReleaseEvent(event); - } - - void paintEvent(QPaintEvent *) - { - QStyleOption opt; - opt.init(this); - QPainter p(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); - } - - inline int pnpoly(int nvert, float *vertx, float *verty, float testx, float testy) - { - int i, j, c = 0; - for (i = 0, j = nvert-1; i < nvert; j = i++) { - if ( ((verty[i]>testy) != (verty[j]>testy)) && (testx < (vertx[j]-vertx[i]) * (testy-verty[i]) / (verty[j]-verty[i]) + vertx[i]) ) - c = !c; - } - return c; - } - - signals: - void buttonPressed(int button); - -}; - - -#endif /* CURSORWIDGET_H */ - diff --git a/companion/src/simulation/dialwidget.h b/companion/src/simulation/dialwidget.h new file mode 100644 index 000000000..d84099a61 --- /dev/null +++ b/companion/src/simulation/dialwidget.h @@ -0,0 +1,25 @@ +#ifndef _DIALWIDGET_H_ +#define _DIALWIDGET_H_ + +class DialWidget : public QDial +{ + public: + + explicit DialWidget(QWidget * parent = 0): + QDial(parent) + { + } + + protected: + + void mousePressEvent(QMouseEvent * event) + { + if (event->button() == Qt::RightButton && event->type() == QEvent::MouseButtonDblClick) { + setValue(0); + event->accept(); + } + QDial::mousePressEvent(event); + } +}; + +#endif // _DIALWIDGET_H_ diff --git a/companion/src/simulation/lcdwidget.h b/companion/src/simulation/lcdwidget.h index 35af6e114..12dbbc8bb 100644 --- a/companion/src/simulation/lcdwidget.h +++ b/companion/src/simulation/lcdwidget.h @@ -14,15 +14,17 @@ * */ -#ifndef lcd_widget_h -#define lcd_widget_h +#ifndef _LCDWIDGET_H_ +#define _LCDWIDGET_H_ #include #include "appdata.h" -class lcdWidget : public QWidget { +class LcdWidget : public QWidget +{ public: - lcdWidget(QWidget * parent = 0): + + LcdWidget(QWidget * parent = 0): QWidget(parent), lcdBuf(NULL), previousBuf(NULL), @@ -30,10 +32,11 @@ class lcdWidget : public QWidget { { } - ~lcdWidget() + ~LcdWidget() { - if (previousBuf) + if (previousBuf) { free(previousBuf); + } } void setData(unsigned char *buf, int width, int height, int depth=1) @@ -43,7 +46,7 @@ class lcdWidget : public QWidget { lcdHeight = height; lcdDepth = depth; if (depth >= 8) - lcdSize = (width * height) * (depth / 8); + lcdSize = (width * height) * ((depth+7) / 8); else lcdSize = (width * ((height+7)/8)) * depth; previousBuf = (unsigned char *)malloc(lcdSize); @@ -109,7 +112,17 @@ class lcdWidget : public QWidget { { QRgb rgb; - if (lcdDepth >= 8) { + if (lcdDepth == 16) { + for (int x=0; x>11)/0x1F, 255*((z&0x07E0)>>5)/0x3F, 255*(z&0x001F)/0x1F); + p.setPen(rgb); + p.drawPoint(x, y); + } + } + } + else if (lcdDepth == 12) { for (int x=0; x - * - * Based on th9x -> http://code.google.com/p/th9x/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ -#ifndef MENUWIDGET_H -#define MENUWIDGET_H - -#include -#include - -class menuWidget : public QWidget { - - Q_OBJECT - - public: - - explicit menuWidget(QWidget * parent = 0): - QWidget(parent) - { - } - - protected: - - virtual void mousePressEvent(QMouseEvent * event) - { - int x=event->x(); - int y=event->y(); - setFocus(); - if (event->button()==Qt::LeftButton) { - if (x>25 && x<71 && y>60 && y<81) { - setStyleSheet("background:url(:/images/9xmenumenu.png);"); - emit buttonPressed(Qt::Key_Enter); - } else if (x>25 && x<71 && y>117 && y<139) { - setStyleSheet("background:url(:/images/9xmenuexit.png);"); - emit buttonPressed(Qt::Key_Escape); - } - } - // QWidget::mousePressEvent(event); - } - - virtual void mouseReleaseEvent(QMouseEvent * event) - { - setStyleSheet("background:url(:/images/9xmenu.png);"); - setFocus(); - emit buttonPressed(0); - // QWidget::mouseReleaseEvent(event); - } - - void paintEvent(QPaintEvent *) - { - QStyleOption opt; - opt.init(this); - QPainter p(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); - } - - signals: - void buttonPressed(int button); - -}; -#endif /* MENUWIDGET_H */ - diff --git a/companion/src/simulation/myqdial.h b/companion/src/simulation/myqdial.h deleted file mode 100644 index 54f76473e..000000000 --- a/companion/src/simulation/myqdial.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef MYQDIAL_H -#define MYQDIAL_H - - -class myQDial : public QDial -{ -public: - explicit myQDial(QWidget *parent = 0) : QDial(parent) {} - -protected: - void mousePressEvent(QMouseEvent *event) - { - if (event->button() == Qt::RightButton && event->type() == QEvent::MouseButtonDblClick) { - setValue(0); - event->accept(); - } - QDial::mousePressEvent(event); - } -}; - -#endif diff --git a/companion/src/simulation/myslider.h b/companion/src/simulation/myslider.h deleted file mode 100644 index d2c6801a5..000000000 --- a/companion/src/simulation/myslider.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef MYSLIDER_H -#define MYSLIDER_H - -#include -#include - -class mySlider : public QSlider -{ - Q_OBJECT - - public: - - explicit mySlider(QFrame * parent = 0): - QSlider(parent) - { - } - - -protected: - - void mousePressEvent(QMouseEvent * event) - { - if (event->button() == Qt::RightButton && event->type() == QEvent::MouseButtonDblClick) { - setValue(0); - event->accept(); - } - QSlider::mousePressEvent(event); - } -}; - -#endif diff --git a/companion/src/simulation/simulatordialog-9x.ui b/companion/src/simulation/simulatordialog-9x.ui index 73bbb2586..c7dde17b3 100644 --- a/companion/src/simulation/simulatordialog-9x.ui +++ b/companion/src/simulation/simulatordialog-9x.ui @@ -30,7 +30,16 @@ :/icon.png:/icon.png - + + 5 + + + 5 + + + 5 + + 5 @@ -66,7 +75,16 @@ 2 - + + 5 + + + 5 + + + 5 + + 5 @@ -399,7 +417,7 @@ QPushButton:checked { - + Right Double Click to Reset @@ -463,7 +481,7 @@ QPushButton:checked { - + Right Double Click to Reset @@ -868,7 +886,7 @@ QPushButton:checked { - + Right Double Click to Reset @@ -932,7 +950,7 @@ QPushButton:checked { - + Right Double Click to Reset @@ -990,7 +1008,16 @@ QPushButton:checked { 2 - + + 2 + + + 2 + + + 2 + + 2 @@ -1020,7 +1047,7 @@ QPushButton:checked { - + 0 @@ -1077,7 +1104,7 @@ QPushButton:checked { - + 0 @@ -1137,7 +1164,7 @@ QPushButton:checked { - + 0 @@ -1262,7 +1289,7 @@ QPushButton:checked { - background:url(:/images/9xdt.png) + background:url(:/images/simulator/9X/9xdt.png) @@ -1281,12 +1308,12 @@ QPushButton:checked { - background:url(:/images/9xdl.png) + background:url(:/images/simulator/9X/9xdl.png) - + 0 @@ -1300,12 +1327,12 @@ QPushButton:checked { - background:url(:/images/9xmenu.png) + background:url(:/images/simulator/9X/9xmenu.png) - + 0 @@ -1335,29 +1362,7 @@ QPushButton:checked { - background:url(:/images/9xdb.png) - - - - - - - - 0 - 0 - - - - - 128 - 186 - - - - true - - - background:url(:/images/9xcurs.png); + background:url(:/images/simulator/9X/9xdb.png) @@ -1376,7 +1381,29 @@ QPushButton:checked { - background:url(:/images/9xdr.png) + background:url(:/images/simulator/9X/9xdr.png) + + + + + + + + 0 + 0 + + + + + 128 + 186 + + + + true + + + background:url(:/images/simulator/9X/9xcurs.png); @@ -1469,32 +1496,26 @@ QPushButton:checked { - lcdWidget + LcdWidget QWidget
lcdwidget.h
1
- mySlider + SliderWidget QSlider -
myslider.h
+
sliderwidget.h
- cursorWidget - QWidget -
cursorwidget.h
- 1 -
- - menuWidget - QWidget -
menuwidget.h
- 1 -
- - myQDial + DialWidget QDial -
myqdial.h
+
dialwidget.h
+
+ + ButtonsWidget + QWidget +
buttonswidget.h
+ 1
diff --git a/companion/src/simulation/simulatordialog-flamenco.ui b/companion/src/simulation/simulatordialog-flamenco.ui new file mode 100644 index 000000000..74beb1638 --- /dev/null +++ b/companion/src/simulation/simulatordialog-flamenco.ui @@ -0,0 +1,1675 @@ + + + SimulatorDialogFlamenco + + + + 0 + 0 + 726 + 708 + + + + + 0 + 0 + + + + + 739 + 16777215 + + + + Companion Simulator + + + + :/icon.png:/icon.png + + + + 5 + + + 5 + + + 5 + + + 5 + + + 0 + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 570 + 5 + + + + + + + + true + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + 0 + + + + Flamenco Simulator + + + + + + QLayout::SetMinimumSize + + + 0 + + + + + + 0 + 0 + + + + + 120 + 208 + + + + true + + + background:url(:/images/x9l0.png); + + + + + + + + 0 + 0 + + + + + 120 + 208 + + + + background:url(:/images/x9r0.png) + + + + + + + + 0 + 0 + + + + + 320 + 240 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Horizontal + + + + 438 + 6 + + + + + + + + + + + Outputs + + + + + + + + + + + + + Outputs2 + + + + + + + + + + + + + Gvars + + + + + 10 + 10 + 691 + 231 + + + + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + QFrame::Panel + + + QFrame::Raised + + + 2 + + + + 5 + + + 5 + + + 5 + + + 5 + + + 6 + + + + + + + + + + + + 0 + 0 + + + + + 23 + 23 + + + + ^ + + + false + + + + + + + + 0 + 0 + + + + Right Double Click to Reset + + + -125 + + + 125 + + + Qt::Vertical + + + + + + + + 0 + 0 + + + + + 23 + 23 + + + + v + + + false + + + + + + + + + Qt::Horizontal + + + QSizePolicy::MinimumExpanding + + + + 5 + 20 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + 8 + + + + QPushButton { + background-color: #EEEEEE; + border-style: outset; + border-width: 1px; + border-radius: 4px; + border-color: black; + padding: 2px; + } + +QPushButton:checked { + background-color: #4CC417; + border-style: inset; + } + + + Hold Y + + + true + + + + + + + + 8 + + + + QPushButton { + background-color: #EEEEEE; + border-style: outset; + border-width: 1px; + border-radius: 4px; + border-color: black; + padding: 2px; + } + +QPushButton:checked { + background-color: #4CC417; + border-style: inset; + } + + + Fix Y + + + true + + + + + + + + 8 + + + + QPushButton { + background-color: #EEEEEE; + border-style: outset; + border-width: 1px; + border-radius: 4px; + border-color: black; + padding: 2px; + } + +QPushButton:checked { + background-color: #4CC417; + border-style: inset; + } + + + Fix X + + + true + + + + + + + + 8 + + + + QPushButton { + background-color: #EEEEEE; + border-style: outset; + border-width: 1px; + border-radius: 4px; + border-color: black; + padding: 2px; + } + +QPushButton:checked { + background-color: #4CC417; + border-style: inset; + } + + + Hold X + + + true + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 42 + 42 + + + + + + + -1024 + + + 1024 + + + 128 + + + 64.000000000000000 + + + true + + + + + + + 20 + + + 20 + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + + + 0 + 0 + + + + + 16777215 + 50 + + + + + + + 2 + + + 1 + + + 0 + + + Qt::Vertical + + + true + + + QSlider::TicksBothSides + + + 1 + + + + + + + + 245 + 245 + + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + + + + + + 0 + 0 + + + + + 16777215 + 50 + + + + + + + 2 + + + 1 + + + 0 + + + Qt::Vertical + + + true + + + QSlider::TicksBothSides + + + 1 + + + + + + + + 0 + 0 + + + + + 16777215 + 50 + + + + + + + 2 + + + 1 + + + 0 + + + Qt::Vertical + + + true + + + QSlider::TicksBothSides + + + 1 + + + + + + + SF + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 16777215 + 50 + + + + + + + + + + 1 + + + 1 + + + 0 + + + 0 + + + Qt::Vertical + + + true + + + QSlider::TicksBothSides + + + 1 + + + + + + + + 0 + 0 + + + + + 42 + 42 + + + + + + + -1024 + + + 1024 + + + 128 + + + 64.000000000000000 + + + true + + + + + + + SA + + + Qt::AlignCenter + + + + + + + SB + + + Qt::AlignCenter + + + + + + + SE + + + Qt::AlignCenter + + + + + + + LS + + + Qt::AlignCenter + + + + + + + S1 + + + Qt::AlignCenter + + + + + + + + + + 0 + 0 + + + + + 23 + 23 + + + + <- + + + false + + + + + + + Right Double Click to Reset + + + -125 + + + 125 + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + + 23 + 23 + + + + -> + + + false + + + + + + + + + + + QLayout::SetDefaultConstraint + + + + + + + Qt::Horizontal + + + QSizePolicy::MinimumExpanding + + + + 5 + 20 + + + + + + + + + + + 0 + 0 + + + + + 23 + 23 + + + + ^ + + + false + + + + + + + Right Double Click to Reset + + + -125 + + + 125 + + + Qt::Vertical + + + + + + + + 0 + 0 + + + + + 23 + 23 + + + + v + + + false + + + + + + + + + + + + 0 + 0 + + + + + 42 + 42 + + + + + + + -1024 + + + 1024 + + + 128 + + + 64.000000000000000 + + + true + + + + + + + S2 + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 245 + 245 + + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + + + + + + + + 8 + + + + QPushButton { + background-color: #EEEEEE; + border-style: outset; + border-width: 1px; + border-radius: 4px; + border-color: black; + padding: 2px; + } + +QPushButton:checked { + background-color: #4CC417; + border-style: inset; + } + + + Hold Y + + + true + + + + + + + + 8 + + + + QPushButton { + background-color: #EEEEEE; + border-style: outset; + border-width: 1px; + border-radius: 4px; + border-color: black; + padding: 2px; + } + +QPushButton:checked { + background-color: #4CC417; + border-style: inset; + } + + + Fix Y + + + true + + + + + + + + 8 + + + + QPushButton { + background-color: #EEEEEE; + border-style: outset; + border-width: 1px; + border-radius: 4px; + border-color: black; + padding: 2px; + } + +QPushButton:checked { + background-color: #4CC417; + border-style: inset; + } + + + Fix X + + + true + + + + + + + + 8 + + + + QPushButton { + background-color: #EEEEEE; + border-style: outset; + border-width: 1px; + border-radius: 4px; + border-color: black; + padding: 2px; + } + +QPushButton:checked { + background-color: #4CC417; + border-style: inset; + } + + + Hold X + + + true + + + + + + + + + + 0 + 0 + + + + + 16777215 + 50 + + + + + + + 2 + + + 1 + + + 0 + + + Qt::Vertical + + + true + + + QSlider::TicksBothSides + + + 1 + + + + + + + + 0 + 0 + + + + + 16777215 + 50 + + + + + + + 2 + + + 1 + + + 0 + + + Qt::Vertical + + + true + + + QSlider::TicksBothSides + + + 1 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 16777215 + 50 + + + + + + + 2 + + + 1 + + + 0 + + + Qt::Vertical + + + true + + + false + + + QSlider::TicksBothSides + + + 1 + + + + + + + + 0 + 0 + + + + + 42 + 42 + + + + + + + -1024 + + + 1024 + + + 128 + + + 64.000000000000000 + + + true + + + + + + + + 0 + 0 + + + + + 16777215 + 50 + + + + + + + + + + 1 + + + 0 + + + 0 + + + Qt::Vertical + + + true + + + QSlider::TicksBothSides + + + 1 + + + + + + + SC + + + Qt::AlignCenter + + + + + + + SD + + + Qt::AlignCenter + + + + + + + SG + + + Qt::AlignCenter + + + + + + + SH + + + Qt::AlignCenter + + + + + + + RS + + + Qt::AlignCenter + + + + + + + 20 + + + 20 + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + + + + + 0 + 0 + + + + + 23 + 23 + + + + <- + + + false + + + + + + + + 0 + 0 + + + + Right Double Click to Reset + + + -125 + + + 125 + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + + 23 + 23 + + + + -> + + + false + + + + + + + + + + + + + + + LcdWidget + QWidget +
lcdwidget.h
+ 1 +
+ + ButtonsWidget + QWidget +
buttonswidget.h
+ 1 +
+ + SliderWidget + QSlider +
sliderwidget.h
+
+
+ + + + +
diff --git a/companion/src/simulation/simulatordialog-horus.ui b/companion/src/simulation/simulatordialog-horus.ui new file mode 100644 index 000000000..09db52e34 --- /dev/null +++ b/companion/src/simulation/simulatordialog-horus.ui @@ -0,0 +1,1807 @@ + + + SimulatorDialogHorus + + + + 0 + 0 + 960 + 850 + + + + + 0 + 0 + + + + + 960 + 850 + + + + + 960 + 850 + + + + Companion Simulator + + + + :/icon.png:/icon.png + + + + 5 + + + 5 + + + 5 + + + 5 + + + 0 + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 700 + 5 + + + + + + + + true + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + 0 + + + + Horus Simulator + + + + 5 + + + 5 + + + 0 + + + + + QLayout::SetFixedSize + + + 0 + + + + + + 0 + 0 + + + + + 147 + 292 + + + + + 147 + 292 + + + + true + + + background:url(:/images/simulator/Horus/left.png); + + + + + + + + 0 + 0 + + + + + 480 + 9 + + + + + 480 + 9 + + + + + 5 + + + + background:url(:/images/simulator/Horus/top.png) + + + + + + + + 0 + 0 + + + + + 480 + 272 + + + + + 480 + 272 + + + + + 5 + + + + + + + + + 0 + 0 + + + + + 480 + 11 + + + + + 480 + 11 + + + + + 5 + false + + + + background:url(:/images/simulator/Horus/bottom.png) + + + + + + + + 0 + 0 + + + + + 24 + 292 + + + + + 24 + 292 + + + + background:url(:/images/simulator/Horus/led.png) + + + + + + + + 0 + 0 + + + + + 27 + 292 + + + + + 27 + 292 + + + + background:url(:/images/simulator/Horus/border-right.png) + + + + + + + + 0 + 0 + + + + + 147 + 292 + + + + + 147 + 292 + + + + background:url(:/images/simulator/Horus/right.png) + + + + + + + + + Qt::Horizontal + + + + 20 + 292 + + + + + + + + Qt::Horizontal + + + + 20 + 292 + + + + + + + + + O&utputs + + + + + + + + + + + + + Ou&tputs2 + + + + + + + + + + + + + &Gvars + + + + + 10 + 10 + 691 + 231 + + + + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + QFrame::Panel + + + QFrame::Raised + + + 2 + + + + 5 + + + 5 + + + 5 + + + 5 + + + 6 + + + + + + + + + + + + 0 + 0 + + + + + 23 + 23 + + + + ^ + + + false + + + + + + + + 0 + 0 + + + + Right Double Click to Reset + + + -125 + + + 125 + + + Qt::Vertical + + + + + + + + 0 + 0 + + + + + 23 + 23 + + + + v + + + false + + + + + + + + + Qt::Horizontal + + + QSizePolicy::MinimumExpanding + + + + 5 + 20 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + 8 + + + + QPushButton { + background-color: #EEEEEE; + border-style: outset; + border-width: 1px; + border-radius: 4px; + border-color: black; + padding: 2px; + } + +QPushButton:checked { + background-color: #4CC417; + border-style: inset; + } + + + Hold Y + + + true + + + + + + + + 8 + + + + QPushButton { + background-color: #EEEEEE; + border-style: outset; + border-width: 1px; + border-radius: 4px; + border-color: black; + padding: 2px; + } + +QPushButton:checked { + background-color: #4CC417; + border-style: inset; + } + + + Fix Y + + + true + + + + + + + + 8 + + + + QPushButton { + background-color: #EEEEEE; + border-style: outset; + border-width: 1px; + border-radius: 4px; + border-color: black; + padding: 2px; + } + +QPushButton:checked { + background-color: #4CC417; + border-style: inset; + } + + + Fix X + + + true + + + + + + + + 8 + + + + QPushButton { + background-color: #EEEEEE; + border-style: outset; + border-width: 1px; + border-radius: 4px; + border-color: black; + padding: 2px; + } + +QPushButton:checked { + background-color: #4CC417; + border-style: inset; + } + + + Hold X + + + true + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 42 + 42 + + + + + + + -1024 + + + 1024 + + + 128 + + + 64.000000000000000 + + + true + + + + + + + 20 + + + 20 + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + + + 0 + 0 + + + + + 16777215 + 50 + + + + + + + 2 + + + 1 + + + 0 + + + Qt::Vertical + + + true + + + QSlider::TicksBothSides + + + 1 + + + + + + + + 245 + 245 + + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + + + + + + 0 + 0 + + + + + 16777215 + 50 + + + + + + + 2 + + + 1 + + + 0 + + + Qt::Vertical + + + true + + + QSlider::TicksBothSides + + + 1 + + + + + + + + 0 + 0 + + + + + 16777215 + 50 + + + + + + + 2 + + + 1 + + + 0 + + + Qt::Vertical + + + true + + + QSlider::TicksBothSides + + + 1 + + + + + + + SF + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 16777215 + 50 + + + + + + + + + + 1 + + + 1 + + + 0 + + + 0 + + + Qt::Vertical + + + true + + + QSlider::TicksBothSides + + + 1 + + + + + + + + 0 + 0 + + + + + 42 + 42 + + + + + + + -1024 + + + 1024 + + + 128 + + + 64.000000000000000 + + + true + + + + + + + SA + + + Qt::AlignCenter + + + + + + + SB + + + Qt::AlignCenter + + + + + + + SE + + + Qt::AlignCenter + + + + + + + LS + + + Qt::AlignCenter + + + + + + + S1 + + + Qt::AlignCenter + + + + + + + + + + 0 + 0 + + + + + 23 + 23 + + + + <- + + + false + + + + + + + Right Double Click to Reset + + + -125 + + + 125 + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + + 23 + 23 + + + + -> + + + false + + + + + + + + + + + QLayout::SetDefaultConstraint + + + + + + + Qt::Horizontal + + + QSizePolicy::MinimumExpanding + + + + 5 + 20 + + + + + + + + + + + 0 + 0 + + + + + 23 + 23 + + + + ^ + + + false + + + + + + + Right Double Click to Reset + + + -125 + + + 125 + + + Qt::Vertical + + + + + + + + 0 + 0 + + + + + 23 + 23 + + + + v + + + false + + + + + + + + + + + + 0 + 0 + + + + + 42 + 42 + + + + + + + -1024 + + + 1024 + + + 128 + + + 64.000000000000000 + + + true + + + + + + + S2 + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 245 + 245 + + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + + + + + + + + 8 + + + + QPushButton { + background-color: #EEEEEE; + border-style: outset; + border-width: 1px; + border-radius: 4px; + border-color: black; + padding: 2px; + } + +QPushButton:checked { + background-color: #4CC417; + border-style: inset; + } + + + Hold Y + + + true + + + + + + + + 8 + + + + QPushButton { + background-color: #EEEEEE; + border-style: outset; + border-width: 1px; + border-radius: 4px; + border-color: black; + padding: 2px; + } + +QPushButton:checked { + background-color: #4CC417; + border-style: inset; + } + + + Fix Y + + + true + + + + + + + + 8 + + + + QPushButton { + background-color: #EEEEEE; + border-style: outset; + border-width: 1px; + border-radius: 4px; + border-color: black; + padding: 2px; + } + +QPushButton:checked { + background-color: #4CC417; + border-style: inset; + } + + + Fix X + + + true + + + + + + + + 8 + + + + QPushButton { + background-color: #EEEEEE; + border-style: outset; + border-width: 1px; + border-radius: 4px; + border-color: black; + padding: 2px; + } + +QPushButton:checked { + background-color: #4CC417; + border-style: inset; + } + + + Hold X + + + true + + + + + + + + + + 0 + 0 + + + + + 16777215 + 50 + + + + + + + 2 + + + 1 + + + 0 + + + Qt::Vertical + + + true + + + QSlider::TicksBothSides + + + 1 + + + + + + + + 0 + 0 + + + + + 16777215 + 50 + + + + + + + 2 + + + 1 + + + 0 + + + Qt::Vertical + + + true + + + QSlider::TicksBothSides + + + 1 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 16777215 + 50 + + + + + + + 2 + + + 1 + + + 0 + + + Qt::Vertical + + + true + + + false + + + QSlider::TicksBothSides + + + 1 + + + + + + + + 0 + 0 + + + + + 42 + 42 + + + + + + + -1024 + + + 1024 + + + 128 + + + 64.000000000000000 + + + true + + + + + + + + 0 + 0 + + + + + 16777215 + 50 + + + + + + + + + + 1 + + + 0 + + + 0 + + + Qt::Vertical + + + true + + + QSlider::TicksBothSides + + + 1 + + + + + + + SC + + + Qt::AlignCenter + + + + + + + SD + + + Qt::AlignCenter + + + + + + + SG + + + Qt::AlignCenter + + + + + + + SH + + + Qt::AlignCenter + + + + + + + RS + + + Qt::AlignCenter + + + + + + + 20 + + + 20 + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + + + + + 0 + 0 + + + + + 23 + 23 + + + + <- + + + false + + + + + + + + 0 + 0 + + + + Right Double Click to Reset + + + -125 + + + 125 + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + + 23 + 23 + + + + -> + + + false + + + + + + + + + + + + + + + LcdWidget + QWidget +
lcdwidget.h
+ 1 +
+ + ButtonsWidget + QWidget +
buttonswidget.h
+ 1 +
+ + SliderWidget + QSlider +
sliderwidget.h
+
+
+ + + + +
diff --git a/companion/src/simulation/simulatordialog-taranis.ui b/companion/src/simulation/simulatordialog-taranis.ui index 34fec2025..e2f693cb8 100644 --- a/companion/src/simulation/simulatordialog-taranis.ui +++ b/companion/src/simulation/simulatordialog-taranis.ui @@ -7,7 +7,7 @@ 0 0 739 - 658 + 695
@@ -30,7 +30,16 @@ :/icon.png:/icon.png - + + 5 + + + 5 + + + 5 + + 5 @@ -86,7 +95,7 @@ 0 - + 0 @@ -103,7 +112,7 @@ true - background:url(:/images/x9l0.png); + background:url(:/images/simulator/Taranis/x9l0.png); @@ -122,12 +131,12 @@ - background:url(:/images/x9t0.png) + background:url(:/images/simulator/Taranis/x9t0.png) - + 0 @@ -141,12 +150,12 @@ - background:url(:/images/x9r0.png) + background:url(:/images/simulator/Taranis/x9r0.png) - + 0 @@ -176,7 +185,7 @@ - background:url(:/images/x9b0.png) + background:url(:/images/simulator/Taranis/x9b0.png) @@ -864,7 +873,7 @@ - + 0 @@ -904,7 +913,7 @@ - + 0 @@ -935,7 +944,7 @@ - + 0 @@ -966,7 +975,7 @@ - + 0 @@ -1248,7 +1257,7 @@ QPushButton:checked { - + 0 @@ -1320,7 +1329,7 @@ QPushButton:checked { - + Right Double Click to Reset @@ -1420,7 +1429,7 @@ QPushButton:checked { - + Right Double Click to Reset @@ -1638,7 +1647,7 @@ QPushButton:checked { - + 0 @@ -1735,32 +1744,26 @@ QPushButton:checked { - lcdWidget + LcdWidget QWidget
lcdwidget.h
1
- mySlider + ButtonsWidget + QWidget +
buttonswidget.h
+ 1 +
+ + SliderWidget QSlider -
myslider.h
+
sliderwidget.h
- xcursorWidget - QWidget -
xcursorwidget.h
- 1 -
- - xmenuWidget - QWidget -
xmenuwidget.h
- 1 -
- - myQDial + DialWidget QDial -
myqdial.h
+
dialwidget.h
diff --git a/companion/src/simulation/simulatordialog.cpp b/companion/src/simulation/simulatordialog.cpp index 31fa94406..6d4b3f8e0 100644 --- a/companion/src/simulation/simulatordialog.cpp +++ b/companion/src/simulation/simulatordialog.cpp @@ -1,9 +1,10 @@ #include "simulatordialog.h" -#include "ui_simulatordialog-9x.h" -#include "ui_simulatordialog-taranis.h" +#include "appdata.h" +#include "lcdwidget.h" #include #include "helpers.h" #include "simulatorinterface.h" +#include "sliderwidget.h" #define GBALL_SIZE 20 #define RESX 1024 @@ -47,6 +48,11 @@ void SimulatorDialog::updateDebugOutput() traceMutex.unlock(); } +void SimulatorDialog::wheelEvent (QWheelEvent *event) +{ + simulator->wheelEvent(event->delta() > 0 ? 1 : -1); +} + SimulatorDialog::SimulatorDialog(QWidget * parent, SimulatorInterface *simulator, unsigned int flags): QDialog(parent), flags(flags), @@ -70,153 +76,6 @@ SimulatorDialog::SimulatorDialog(QWidget * parent, SimulatorInterface *simulator traceCallbackInstance = this; } -uint32_t SimulatorDialog9X::switchstatus = 0; - -SimulatorDialog9X::SimulatorDialog9X(QWidget * parent, SimulatorInterface *simulator, unsigned int flags): - SimulatorDialog(parent, simulator, flags), - ui(new Ui::SimulatorDialog9X), - beepShow(0) -{ - lcdWidth = 128; - lcdHeight = 64; - lcdDepth = 1; - - initUi(ui); - - // install simulator TRACE hook - simulator->installTraceHook(traceCb); - - backLight = g.backLight(); - if (backLight > 4) backLight = 0; - switch (backLight) { - case 1: - ui->lcd->setBackgroundColor(166,247,159); - break; - case 2: - ui->lcd->setBackgroundColor(247,159,166); - break; - case 3: - ui->lcd->setBackgroundColor(255,195,151); - break; - case 4: - ui->lcd->setBackgroundColor(247,242,159); - break; - default: - ui->lcd->setBackgroundColor(159,165,247); - break; - } - - //restore switches - if (g.simuSW()) - restoreSwitches(); - - ui->trimHR_L->setText(QString::fromUtf8(leftArrow)); - ui->trimHR_R->setText(QString::fromUtf8(rightArrow)); - ui->trimVR_U->setText(QString::fromUtf8(upArrow)); - ui->trimVR_D->setText(QString::fromUtf8(downArrow)); - ui->trimHL_L->setText(QString::fromUtf8(leftArrow)); - ui->trimHL_R->setText(QString::fromUtf8(rightArrow)); - ui->trimVL_U->setText(QString::fromUtf8(upArrow)); - ui->trimVL_D->setText(QString::fromUtf8(downArrow)); - for (int i=0; isetProperty("index", i); - connect(pots[i], SIGNAL(valueChanged(int)), this, SLOT(dialChanged(int))); - } - connect(ui->cursor, SIGNAL(buttonPressed(int)), this, SLOT(onButtonPressed(int))); - connect(ui->menu, SIGNAL(buttonPressed(int)), this, SLOT(onButtonPressed(int))); - connect(ui->trimHR_L, SIGNAL(pressed()), this, SLOT(onTrimPressed())); - connect(ui->trimHR_R, SIGNAL(pressed()), this, SLOT(onTrimPressed())); - connect(ui->trimVR_U, SIGNAL(pressed()), this, SLOT(onTrimPressed())); - connect(ui->trimVR_D, SIGNAL(pressed()), this, SLOT(onTrimPressed())); - connect(ui->trimHL_R, SIGNAL(pressed()), this, SLOT(onTrimPressed())); - connect(ui->trimHL_L, SIGNAL(pressed()), this, SLOT(onTrimPressed())); - connect(ui->trimVL_U, SIGNAL(pressed()), this, SLOT(onTrimPressed())); - connect(ui->trimVL_D, SIGNAL(pressed()), this, SLOT(onTrimPressed())); - connect(ui->trimHR_L, SIGNAL(released()), this, SLOT(onTrimReleased())); - connect(ui->trimHR_R, SIGNAL(released()), this, SLOT(onTrimReleased())); - connect(ui->trimVR_U, SIGNAL(released()), this, SLOT(onTrimReleased())); - connect(ui->trimVR_D, SIGNAL(released()), this, SLOT(onTrimReleased())); - connect(ui->trimHL_R, SIGNAL(released()), this, SLOT(onTrimReleased())); - connect(ui->trimHL_L, SIGNAL(released()), this, SLOT(onTrimReleased())); - connect(ui->trimVL_U, SIGNAL(released()), this, SLOT(onTrimReleased())); - connect(ui->trimVL_D, SIGNAL(released()), this, SLOT(onTrimReleased())); -} - -SimulatorDialog9X::~SimulatorDialog9X() -{ - saveSwitches(); - delete ui; -} - -uint32_t SimulatorDialogTaranis::switchstatus = 0; - -SimulatorDialogTaranis::SimulatorDialogTaranis(QWidget * parent, SimulatorInterface *simulator, unsigned int flags): - SimulatorDialog(parent, simulator, flags), - ui(new Ui::SimulatorDialogTaranis) -{ - lcdWidth = 212; - lcdHeight = 64; - lcdDepth = 4; - - initUi(ui); - - // install simulator TRACE hook - simulator->installTraceHook(traceCb); - - ui->lcd->setBackgroundColor(47, 123, 227); - - // restore switches - if (g.simuSW()) { - restoreSwitches(); - } - - for (int i=0; isetValue(-1024); - pots[i]->setSingleStep(2048/5); - pots[i]->setPageStep(2048/5); - } - else if (!(flags & (SIMULATOR_FLAGS_S1 << i))) { - pots[i]->hide(); - potLabels[i]->hide(); - } - } - - ui->trimHR_L->setText(QString::fromUtf8(leftArrow)); - ui->trimHR_R->setText(QString::fromUtf8(rightArrow)); - ui->trimVR_U->setText(QString::fromUtf8(upArrow)); - ui->trimVR_D->setText(QString::fromUtf8(downArrow)); - ui->trimHL_L->setText(QString::fromUtf8(leftArrow)); - ui->trimHL_R->setText(QString::fromUtf8(rightArrow)); - ui->trimVL_U->setText(QString::fromUtf8(upArrow)); - ui->trimVL_D->setText(QString::fromUtf8(downArrow)); - - connect(ui->cursor, SIGNAL(buttonPressed(int)), this, SLOT(onButtonPressed(int))); - connect(ui->menu, SIGNAL(buttonPressed(int)), this, SLOT(onButtonPressed(int))); - connect(ui->trimHR_L, SIGNAL(pressed()), this, SLOT(onTrimPressed())); - connect(ui->trimHR_R, SIGNAL(pressed()), this, SLOT(onTrimPressed())); - connect(ui->trimVR_U, SIGNAL(pressed()), this, SLOT(onTrimPressed())); - connect(ui->trimVR_D, SIGNAL(pressed()), this, SLOT(onTrimPressed())); - connect(ui->trimHL_R, SIGNAL(pressed()), this, SLOT(onTrimPressed())); - connect(ui->trimHL_L, SIGNAL(pressed()), this, SLOT(onTrimPressed())); - connect(ui->trimVL_U, SIGNAL(pressed()), this, SLOT(onTrimPressed())); - connect(ui->trimVL_D, SIGNAL(pressed()), this, SLOT(onTrimPressed())); - connect(ui->trimHR_L, SIGNAL(released()), this, SLOT(onTrimReleased())); - connect(ui->trimHR_R, SIGNAL(released()), this, SLOT(onTrimReleased())); - connect(ui->trimVR_U, SIGNAL(released()), this, SLOT(onTrimReleased())); - connect(ui->trimVR_D, SIGNAL(released()), this, SLOT(onTrimReleased())); - connect(ui->trimHL_R, SIGNAL(released()), this, SLOT(onTrimReleased())); - connect(ui->trimHL_L, SIGNAL(released()), this, SLOT(onTrimReleased())); - connect(ui->trimVL_U, SIGNAL(released()), this, SLOT(onTrimReleased())); - connect(ui->trimVL_D, SIGNAL(released()), this, SLOT(onTrimReleased())); -} - -SimulatorDialogTaranis::~SimulatorDialogTaranis() -{ - saveSwitches(); - delete ui; -} - SimulatorDialog::~SimulatorDialog() { traceCallbackInstance = 0; @@ -244,17 +103,6 @@ void SimulatorDialog::mouseReleaseEvent(QMouseEvent *event) } } -void SimulatorDialog9X::dialChanged(int value) -{ - int index = sender()->property("index").toInt(); - potValues[index]->setText(QString("%1 %").arg((value*100)/1024)); -} - -void SimulatorDialog::wheelEvent (QWheelEvent *event) -{ - simulator->wheelEvent(event->delta() > 0 ? 1 : -1); -} - void SimulatorDialog::onTrimPressed() { if (sender()->objectName() == QString("trimHL_L")) @@ -488,7 +336,7 @@ void SimulatorDialog::initUi(T * ui) QSlider * slider = new QSlider(tabWidget); slider->setEnabled(false); - slider->setMaximumSize(QSize(16777215, 18)); + /*slider->setMaximumSize(QSize(16777215, 18)); slider->setStyleSheet(QString::fromUtf8("QSlider::sub-page:horizontal:disabled {\n" "border-color: #999;\n" "}\n" @@ -501,7 +349,7 @@ void SimulatorDialog::initUi(T * ui) "background: #0000CC;\n" "border: 1px solid #aaa;\n" "border-radius: 4px;\n" - "}")); + "}")); */ slider->setMinimum(-1024); slider->setMaximum(1024); slider->setPageStep(128); @@ -599,36 +447,6 @@ void SimulatorDialog::onButtonPressed(int value) } } -void SimulatorDialog9X::setLightOn(bool enable) -{ - QString bg = ""; - if (enable) { - QStringList list; - list << "bl" << "gr" << "rd" << "or" << "yl"; - bg = QString("-") + list[backLight]; - } - ui->top->setStyleSheet(QString("background:url(:/images/9xdt%1.png);").arg(bg)); - ui->bottom->setStyleSheet(QString("background:url(:/images/9xdb%1.png);").arg(bg)); - ui->left->setStyleSheet(QString("background:url(:/images/9xdl%1.png);").arg(bg)); - ui->right->setStyleSheet(QString("background:url(:/images/9xdr%1.png);").arg(bg)); -} - -void SimulatorDialog9X::updateBeepButton() -{ - #define CBEEP_ON "QLabel { background-color: #FF364E }" - #define CBEEP_OFF "QLabel { }" - - if (beepVal) { - beepShow = 20; - } - - ui->label_beep->setStyleSheet(beepShow ? CBEEP_ON : CBEEP_OFF); - - if (beepShow) { - beepShow--; - } -} - void SimulatorDialog::onTimerEvent() { static unsigned int lcd_counter = 0; @@ -728,211 +546,6 @@ void SimulatorDialog::setTrims() trimHRight->setRange(trimMin, trimMax); trimHRight->setValue(trims.values[3]); } -void SimulatorDialog9X::getValues() -{ - TxInputs inputs = { - { - int(1024*nodeLeft->getX()), // LEFT HORZ - int(-1024*nodeLeft->getY()), // LEFT VERT - int(-1024*nodeRight->getY()), // RGHT VERT - int(1024*nodeRight->getX()) // RGHT HORZ - }, - - { - pots[0]->value(), - pots[1]->value(), - pots[2]->value() - }, - - { - ui->switchTHR->isChecked(), - ui->switchRUD->isChecked(), - ui->switchELE->isChecked(), - ui->switchID2->isChecked() ? 1 : (ui->switchID1->isChecked() ? 0 : -1), - ui->switchAIL->isChecked(), - ui->switchGEA->isChecked(), - ui->switchTRN->isDown(), - 0, 0, 0 - }, - - { - buttonPressed == Qt::Key_Enter, - buttonPressed == Qt::Key_Escape, - buttonPressed == Qt::Key_Down, - buttonPressed == Qt::Key_Up, - buttonPressed == Qt::Key_Right, - buttonPressed == Qt::Key_Left, - }, - - middleButtonPressed, - - { - trimPressed == TRIM_LH_L, - trimPressed == TRIM_LH_R, - trimPressed == TRIM_LV_DN, - trimPressed == TRIM_LV_UP, - trimPressed == TRIM_RV_DN, - trimPressed == TRIM_RV_UP, - trimPressed == TRIM_RH_L, - trimPressed == TRIM_RH_R - } - }; - - simulator->setValues(inputs); -} - -void SimulatorDialog9X::saveSwitches(void) -{ - // qDebug() << "SimulatorDialog9X::saveSwitches()"; - switchstatus=ui->switchTHR->isChecked(); - switchstatus<<=1; - switchstatus+=(ui->switchRUD->isChecked()&0x1); - switchstatus<<=1; - switchstatus+=(ui->switchID2->isChecked()&0x1); - switchstatus<<=1; - switchstatus+=(ui->switchID1->isChecked()&0x1); - switchstatus<<=1; - switchstatus+=(ui->switchID0->isChecked()&0x1); - switchstatus<<=1; - switchstatus+=(ui->switchGEA->isChecked()&0x1); - switchstatus<<=1; - switchstatus+=(ui->switchELE->isChecked()&0x1); - switchstatus<<=1; - switchstatus+=(ui->switchAIL->isChecked()&0x1); -} - -void SimulatorDialog9X::restoreSwitches(void) -{ - // qDebug() << "SimulatorDialog9X::restoreSwitches()"; - ui->switchAIL->setChecked(switchstatus & 0x1); - switchstatus >>=1; - ui->switchELE->setChecked(switchstatus & 0x1); - switchstatus >>=1; - ui->switchGEA->setChecked(switchstatus & 0x1); - switchstatus >>=1; - ui->switchID0->setChecked(switchstatus & 0x1); - switchstatus >>=1; - ui->switchID1->setChecked(switchstatus & 0x1); - switchstatus >>=1; - ui->switchID2->setChecked(switchstatus & 0x1); - switchstatus >>=1; - ui->switchRUD->setChecked(switchstatus & 0x1); - switchstatus >>=1; - ui->switchTHR->setChecked(switchstatus & 0x1); -} - -void SimulatorDialogTaranis::resetSH() -{ - ui->switchH->setValue(0); -} - -void SimulatorDialogTaranis::on_switchH_sliderReleased() -{ - QTimer::singleShot(400, this, SLOT(resetSH())); -} - -void SimulatorDialogTaranis::getValues() -{ - for (int i=0; ivalue()+1024)/(2048.0/5))*(2048.0/5)-1024; - pots[i]->setValue(s1); - } - } - - TxInputs inputs = { - { - int(1024*nodeLeft->getX()), // LEFT HORZ - int(-1024*nodeLeft->getY()), // LEFT VERT - int(-1024*nodeRight->getY()), // RGHT VERT - int(1024*nodeRight->getX()) // RGHT HORZ - }, - - { - -pots[0]->value(), - pots[1]->value(), - ((flags && SIMULATOR_FLAGS_S3) ? pots[2]->value() : 0), - -sliders[0]->value(), - sliders[1]->value() - }, - - { - ui->switchA->value() - 1, - ui->switchB->value() - 1, - ui->switchC->value() - 1, - ui->switchD->value() - 1, - ui->switchE->value() - 1, - ui->switchF->value(), - ui->switchG->value() - 1, - ui->switchH->value(), 0, 0 - }, - - { - buttonPressed == Qt::Key_PageUp, - buttonPressed == Qt::Key_Escape, - buttonPressed == Qt::Key_Enter, - buttonPressed == Qt::Key_PageDown, - buttonPressed == Qt::Key_Plus, - buttonPressed == Qt::Key_Minus - }, - - middleButtonPressed, - - { - trimPressed == TRIM_LH_L, - trimPressed == TRIM_LH_R, - trimPressed == TRIM_LV_DN, - trimPressed == TRIM_LV_UP, - trimPressed == TRIM_RV_DN, - trimPressed == TRIM_RV_UP, - trimPressed == TRIM_RH_L, - trimPressed == TRIM_RH_R - } - }; - - simulator->setValues(inputs); -} - -void SimulatorDialogTaranis::saveSwitches(void) -{ - // qDebug() << "SimulatorDialogTaranis::saveSwitches()"; - switchstatus=ui->switchA->value(); - switchstatus<<=2; - switchstatus+=ui->switchB->value(); - switchstatus<<=2; - switchstatus+=ui->switchC->value(); - switchstatus<<=2; - switchstatus+=ui->switchD->value(); - switchstatus<<=2; - switchstatus+=ui->switchE->value(); - switchstatus<<=2; - switchstatus+=ui->switchF->value(); - switchstatus<<=2; - switchstatus+=ui->switchG->value(); - switchstatus<<=2; - switchstatus+=ui->switchH->value(); -} - -void SimulatorDialogTaranis::restoreSwitches(void) -{ - // qDebug() << "SimulatorDialogTaranis::restoreSwitches()"; - ui->switchH->setValue(switchstatus & 0x3); - switchstatus>>=2; - ui->switchG->setValue(switchstatus & 0x3); - switchstatus>>=2; - ui->switchF->setValue(switchstatus & 0x3); - switchstatus>>=2; - ui->switchE->setValue(switchstatus & 0x3); - switchstatus>>=2; - ui->switchD->setValue(switchstatus & 0x3); - switchstatus>>=2; - ui->switchC->setValue(switchstatus & 0x3); - switchstatus>>=2; - ui->switchB->setValue(switchstatus & 0x3); - switchstatus>>=2; - ui->switchA->setValue(switchstatus & 0x3); -} - inline int chVal(int val) { return qMin(1024, qMax(-1024, val)); @@ -1134,3 +747,8 @@ void SimulatorDialog::onjoystickAxisValueChanged(int axis, int value) } } #endif + +#include "simulatordialog9x.cpp" +#include "simulatordialogtaranis.cpp" +#include "simulatordialogflamenco.cpp" +#include "simulatordialoghorus.cpp" diff --git a/companion/src/simulation/simulatordialog.h b/companion/src/simulation/simulatordialog.h index 18f30dfdf..c63ba6d0b 100644 --- a/companion/src/simulation/simulatordialog.h +++ b/companion/src/simulation/simulatordialog.h @@ -21,11 +21,13 @@ namespace Ui { class SimulatorDialog9X; class SimulatorDialogTaranis; + class SimulatorDialogFlamenco; + class SimulatorDialogHorus; } // TODO rename + move? -class lcdWidget; -class mySlider; +class LcdWidget; +class SliderWidget; #define SIMULATOR_FLAGS_NOTX 1 #define SIMULATOR_FLAGS_STICK_MODE_LEFT 2 @@ -38,6 +40,8 @@ class mySlider; #define SIMULATOR_FLAGS_S3_MULTI 256 #define SIMULATOR_FLAGS_S4_MULTI 512 // reserved for the future +void traceCb(const char * text); + class SimulatorDialog : public QDialog { Q_OBJECT @@ -56,14 +60,14 @@ class SimulatorDialog : public QDialog virtual void updateBeepButton() { } unsigned int flags; - lcdWidget * lcd; + LcdWidget * lcd; QGraphicsView * leftStick, * rightStick; QVector pots; QVector potLabels; QVector potValues; QVector sliders; - mySlider * trimHLeft, * trimVLeft, * trimHRight, * trimVRight; + SliderWidget * trimHLeft, * trimVLeft, * trimHRight, * trimVRight; QLabel * leftXPerc, * rightXPerc, * leftYPerc, * rightYPerc; QTabWidget * tabWidget; QVector logicalSwitchLabels; @@ -205,4 +209,48 @@ class SimulatorDialogTaranis: public SimulatorDialog void on_switchH_sliderReleased(); }; +class SimulatorDialogFlamenco: public SimulatorDialog +{ + Q_OBJECT + + public: + explicit SimulatorDialogFlamenco(QWidget * parent, SimulatorInterface *simulator, unsigned int flags=0); + virtual ~SimulatorDialogFlamenco(); + + protected: + virtual void getValues(); + void saveSwitches(void); + void restoreSwitches(void); + + private: + Ui::SimulatorDialogFlamenco * ui; + static uint32_t switchstatus; + + private slots: + void resetSH(); + void on_switchH_sliderReleased(); +}; + +class SimulatorDialogHorus: public SimulatorDialog +{ + Q_OBJECT + + public: + explicit SimulatorDialogHorus(QWidget * parent, SimulatorInterface *simulator, unsigned int flags=0); + virtual ~SimulatorDialogHorus(); + + protected: + virtual void getValues(); + void saveSwitches(void); + void restoreSwitches(void); + + private: + Ui::SimulatorDialogHorus * ui; + static uint32_t switchstatus; + + private slots: + void resetSH(); + void on_switchH_sliderReleased(); +}; + #endif // SIMULATORDIALOG_H diff --git a/companion/src/simulation/simulatordialog9x.cpp b/companion/src/simulation/simulatordialog9x.cpp new file mode 100644 index 000000000..a2a87455e --- /dev/null +++ b/companion/src/simulation/simulatordialog9x.cpp @@ -0,0 +1,225 @@ +#include "ui_simulatordialog-9x.h" + +uint32_t SimulatorDialog9X::switchstatus = 0; + +SimulatorDialog9X::SimulatorDialog9X(QWidget * parent, SimulatorInterface *simulator, unsigned int flags): + SimulatorDialog(parent, simulator, flags), + ui(new Ui::SimulatorDialog9X), + beepShow(0) +{ + QPolygon polygon; + + lcdWidth = 128; + lcdHeight = 64; + lcdDepth = 1; + + initUi(ui); + + polygon.setPoints(6, 68, 83, 28, 45, 51, 32, 83, 32, 105, 45, 68, 83); + ui->leftbuttons->addArea(polygon, Qt::Key_Up, "9X/9xcursup.png"); + polygon.setPoints(6, 74, 90, 114, 51, 127, 80, 127, 106, 114, 130, 74, 90); + ui->leftbuttons->addArea(polygon, Qt::Key_Right, "9X/9xcursmin.png"); + polygon.setPoints(6, 68, 98, 28, 137, 51, 151, 83, 151, 105, 137, 68, 98); + ui->leftbuttons->addArea(polygon, Qt::Key_Down, "9X/9xcursdown.png"); + polygon.setPoints(6, 80, 90, 20, 51, 7, 80, 7, 106, 20, 130, 80, 90); + ui->leftbuttons->addArea(polygon, Qt::Key_Left, "9X/9xcursplus.png"); + ui->leftbuttons->addArea(5, 148, 39, 182, Qt::Key_Print, "9X/9xcursphoto.png"); + + ui->rightbuttons->addArea(25, 60, 71, 81, Qt::Key_Enter, "9X/9xmenumenu.png"); + ui->rightbuttons->addArea(25, 117, 71, 139, Qt::Key_Escape, "9X/9xmenuexit.png"); + + // install simulator TRACE hook + simulator->installTraceHook(traceCb); + + backLight = g.backLight(); + if (backLight > 4) backLight = 0; + switch (backLight) { + case 1: + ui->lcd->setBackgroundColor(166,247,159); + break; + case 2: + ui->lcd->setBackgroundColor(247,159,166); + break; + case 3: + ui->lcd->setBackgroundColor(255,195,151); + break; + case 4: + ui->lcd->setBackgroundColor(247,242,159); + break; + default: + ui->lcd->setBackgroundColor(159,165,247); + break; + } + + //restore switches + if (g.simuSW()) + restoreSwitches(); + + ui->trimHR_L->setText(QString::fromUtf8(leftArrow)); + ui->trimHR_R->setText(QString::fromUtf8(rightArrow)); + ui->trimVR_U->setText(QString::fromUtf8(upArrow)); + ui->trimVR_D->setText(QString::fromUtf8(downArrow)); + ui->trimHL_L->setText(QString::fromUtf8(leftArrow)); + ui->trimHL_R->setText(QString::fromUtf8(rightArrow)); + ui->trimVL_U->setText(QString::fromUtf8(upArrow)); + ui->trimVL_D->setText(QString::fromUtf8(downArrow)); + for (int i=0; isetProperty("index", i); + connect(pots[i], SIGNAL(valueChanged(int)), this, SLOT(dialChanged(int))); + } + connect(ui->leftbuttons, SIGNAL(buttonPressed(int)), this, SLOT(onButtonPressed(int))); + connect(ui->rightbuttons, SIGNAL(buttonPressed(int)), this, SLOT(onButtonPressed(int))); + connect(ui->trimHR_L, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimHR_R, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimVR_U, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimVR_D, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimHL_R, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimHL_L, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimVL_U, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimVL_D, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimHR_L, SIGNAL(released()), this, SLOT(onTrimReleased())); + connect(ui->trimHR_R, SIGNAL(released()), this, SLOT(onTrimReleased())); + connect(ui->trimVR_U, SIGNAL(released()), this, SLOT(onTrimReleased())); + connect(ui->trimVR_D, SIGNAL(released()), this, SLOT(onTrimReleased())); + connect(ui->trimHL_R, SIGNAL(released()), this, SLOT(onTrimReleased())); + connect(ui->trimHL_L, SIGNAL(released()), this, SLOT(onTrimReleased())); + connect(ui->trimVL_U, SIGNAL(released()), this, SLOT(onTrimReleased())); + connect(ui->trimVL_D, SIGNAL(released()), this, SLOT(onTrimReleased())); +} + +SimulatorDialog9X::~SimulatorDialog9X() +{ + saveSwitches(); + delete ui; +} + +void SimulatorDialog9X::dialChanged(int value) +{ + int index = sender()->property("index").toInt(); + potValues[index]->setText(QString("%1 %").arg((value*100)/1024)); +} + +void SimulatorDialog9X::setLightOn(bool enable) +{ + QString bg = ""; + if (enable) { + QStringList list; + list << "bl" << "gr" << "rd" << "or" << "yl"; + bg = QString("-") + list[backLight]; + } + ui->top->setStyleSheet(QString("background:url(:/images/simulator/9X/9xdt%1.png);").arg(bg)); + ui->bottom->setStyleSheet(QString("background:url(:/images/simulator/9X/9xdb%1.png);").arg(bg)); + ui->left->setStyleSheet(QString("background:url(:/images/simulator/9X/9xdl%1.png);").arg(bg)); + ui->right->setStyleSheet(QString("background:url(:/images/simulator/9X/9xdr%1.png);").arg(bg)); +} + +void SimulatorDialog9X::updateBeepButton() +{ + #define CBEEP_ON "QLabel { background-color: #FF364E }" + #define CBEEP_OFF "QLabel { }" + + if (beepVal) { + beepShow = 20; + } + + ui->label_beep->setStyleSheet(beepShow ? CBEEP_ON : CBEEP_OFF); + + if (beepShow) { + beepShow--; + } +} + + +void SimulatorDialog9X::getValues() +{ + TxInputs inputs = { + { + int(1024*nodeLeft->getX()), // LEFT HORZ + int(-1024*nodeLeft->getY()), // LEFT VERT + int(-1024*nodeRight->getY()), // RGHT VERT + int(1024*nodeRight->getX()) // RGHT HORZ + }, + + { + pots[0]->value(), + pots[1]->value(), + pots[2]->value() + }, + + { + ui->switchTHR->isChecked(), + ui->switchRUD->isChecked(), + ui->switchELE->isChecked(), + ui->switchID2->isChecked() ? 1 : (ui->switchID1->isChecked() ? 0 : -1), + ui->switchAIL->isChecked(), + ui->switchGEA->isChecked(), + ui->switchTRN->isDown(), + 0, 0, 0 + }, + + { + buttonPressed == Qt::Key_Enter, + buttonPressed == Qt::Key_Escape, + buttonPressed == Qt::Key_Down, + buttonPressed == Qt::Key_Up, + buttonPressed == Qt::Key_Right, + buttonPressed == Qt::Key_Left, + }, + + middleButtonPressed, + + { + trimPressed == TRIM_LH_L, + trimPressed == TRIM_LH_R, + trimPressed == TRIM_LV_DN, + trimPressed == TRIM_LV_UP, + trimPressed == TRIM_RV_DN, + trimPressed == TRIM_RV_UP, + trimPressed == TRIM_RH_L, + trimPressed == TRIM_RH_R + } + }; + + simulator->setValues(inputs); +} + +void SimulatorDialog9X::saveSwitches(void) +{ + // qDebug() << "SimulatorDialog9X::saveSwitches()"; + switchstatus=ui->switchTHR->isChecked(); + switchstatus<<=1; + switchstatus+=(ui->switchRUD->isChecked()&0x1); + switchstatus<<=1; + switchstatus+=(ui->switchID2->isChecked()&0x1); + switchstatus<<=1; + switchstatus+=(ui->switchID1->isChecked()&0x1); + switchstatus<<=1; + switchstatus+=(ui->switchID0->isChecked()&0x1); + switchstatus<<=1; + switchstatus+=(ui->switchGEA->isChecked()&0x1); + switchstatus<<=1; + switchstatus+=(ui->switchELE->isChecked()&0x1); + switchstatus<<=1; + switchstatus+=(ui->switchAIL->isChecked()&0x1); +} + +void SimulatorDialog9X::restoreSwitches(void) +{ + // qDebug() << "SimulatorDialog9X::restoreSwitches()"; + ui->switchAIL->setChecked(switchstatus & 0x1); + switchstatus >>=1; + ui->switchELE->setChecked(switchstatus & 0x1); + switchstatus >>=1; + ui->switchGEA->setChecked(switchstatus & 0x1); + switchstatus >>=1; + ui->switchID0->setChecked(switchstatus & 0x1); + switchstatus >>=1; + ui->switchID1->setChecked(switchstatus & 0x1); + switchstatus >>=1; + ui->switchID2->setChecked(switchstatus & 0x1); + switchstatus >>=1; + ui->switchRUD->setChecked(switchstatus & 0x1); + switchstatus >>=1; + ui->switchTHR->setChecked(switchstatus & 0x1); +} + diff --git a/companion/src/simulation/simulatordialogflamenco.cpp b/companion/src/simulation/simulatordialogflamenco.cpp new file mode 100644 index 000000000..c3ecac913 --- /dev/null +++ b/companion/src/simulation/simulatordialogflamenco.cpp @@ -0,0 +1,166 @@ +#include "simulatordialog.h" +#include "ui_simulatordialog-flamenco.h" +#include "helpers.h" + +uint32_t SimulatorDialogFlamenco::switchstatus = 0; + +SimulatorDialogFlamenco::SimulatorDialogFlamenco(QWidget * parent, SimulatorInterface *simulator, unsigned int flags): + SimulatorDialog(parent, simulator, flags), + ui(new Ui::SimulatorDialogFlamenco) +{ + lcdWidth = 320; + lcdHeight = 240; + lcdDepth = 12; + + initUi(ui); + + // install simulator TRACE hook + simulator->installTraceHook(traceCb); + + // TODO dialP_4 = ui->dialP_4; + + ui->lcd->setBackgroundColor(47, 123, 227); + + //restore switches + if (g.simuSW()) + restoreSwitches(); + + ui->trimHR_L->setText(QString::fromUtf8(leftArrow)); + ui->trimHR_R->setText(QString::fromUtf8(rightArrow)); + ui->trimVR_U->setText(QString::fromUtf8(upArrow)); + ui->trimVR_D->setText(QString::fromUtf8(downArrow)); + ui->trimHL_L->setText(QString::fromUtf8(leftArrow)); + ui->trimHL_R->setText(QString::fromUtf8(rightArrow)); + ui->trimVL_U->setText(QString::fromUtf8(upArrow)); + ui->trimVL_D->setText(QString::fromUtf8(downArrow)); + + connect(ui->leftbuttons, SIGNAL(buttonPressed(int)), this, SLOT(onButtonPressed(int))); + connect(ui->rightbuttons, SIGNAL(buttonPressed(int)), this, SLOT(onButtonPressed(int))); + connect(ui->trimHR_L, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimHR_R, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimVR_U, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimVR_D, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimHL_R, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimHL_L, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimVL_U, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimVL_D, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimHR_L, SIGNAL(released()), this, SLOT(onTrimReleased())); + connect(ui->trimHR_R, SIGNAL(released()), this, SLOT(onTrimReleased())); + connect(ui->trimVR_U, SIGNAL(released()), this, SLOT(onTrimReleased())); + connect(ui->trimVR_D, SIGNAL(released()), this, SLOT(onTrimReleased())); + connect(ui->trimHL_R, SIGNAL(released()), this, SLOT(onTrimReleased())); + connect(ui->trimHL_L, SIGNAL(released()), this, SLOT(onTrimReleased())); + connect(ui->trimVL_U, SIGNAL(released()), this, SLOT(onTrimReleased())); + connect(ui->trimVL_D, SIGNAL(released()), this, SLOT(onTrimReleased())); +} + +SimulatorDialogFlamenco::~SimulatorDialogFlamenco() +{ + saveSwitches(); + delete ui; +} + +void SimulatorDialogFlamenco::resetSH() +{ + ui->switchH->setValue(0); +} + +void SimulatorDialogFlamenco::on_switchH_sliderReleased() +{ + QTimer::singleShot(400, this, SLOT(resetSH())); +} + +void SimulatorDialogFlamenco::getValues() +{ + TxInputs inputs = { + { + int(1024*nodeLeft->getX()), // LEFT HORZ + int(-1024*nodeLeft->getY()), // LEFT VERT + int(-1024*nodeRight->getY()), // RGHT VERT + int(1024*nodeRight->getX()) // RGHT HORZ + }, + + { + -ui->dialP_1->value(), + ui->dialP_2->value(), + 0, + -ui->dialP_3->value(), + ui->dialP_4->value() + }, + + { + ui->switchA->value() - 1, + ui->switchB->value() - 1, + ui->switchC->value() - 1, + ui->switchD->value() - 1, + ui->switchE->value() - 1, + ui->switchF->value(), + ui->switchG->value() - 1, + ui->switchH->value(), 0, 0 + }, + + { + buttonPressed == Qt::Key_PageUp, + buttonPressed == Qt::Key_Escape, + buttonPressed == Qt::Key_Enter, + buttonPressed == Qt::Key_PageDown, + buttonPressed == Qt::Key_Plus, + buttonPressed == Qt::Key_Minus + }, + + middleButtonPressed, + + { + trimPressed == TRIM_LH_L, + trimPressed == TRIM_LH_R, + trimPressed == TRIM_LV_DN, + trimPressed == TRIM_LV_UP, + trimPressed == TRIM_RV_DN, + trimPressed == TRIM_RV_UP, + trimPressed == TRIM_RH_L, + trimPressed == TRIM_RH_R + } + }; + + simulator->setValues(inputs); +} + +void SimulatorDialogFlamenco::saveSwitches(void) +{ + // qDebug() << "SimulatorDialogTaranis::saveSwitches()"; + switchstatus=ui->switchA->value(); + switchstatus<<=2; + switchstatus+=ui->switchB->value(); + switchstatus<<=2; + switchstatus+=ui->switchC->value(); + switchstatus<<=2; + switchstatus+=ui->switchD->value(); + switchstatus<<=2; + switchstatus+=ui->switchE->value(); + switchstatus<<=2; + switchstatus+=ui->switchF->value(); + switchstatus<<=2; + switchstatus+=ui->switchG->value(); + switchstatus<<=2; + switchstatus+=ui->switchH->value(); +} + +void SimulatorDialogFlamenco::restoreSwitches(void) +{ + // qDebug() << "SimulatorDialogTaranis::restoreSwitches()"; + ui->switchH->setValue(switchstatus & 0x3); + switchstatus>>=2; + ui->switchG->setValue(switchstatus & 0x3); + switchstatus>>=2; + ui->switchF->setValue(switchstatus & 0x3); + switchstatus>>=2; + ui->switchE->setValue(switchstatus & 0x3); + switchstatus>>=2; + ui->switchD->setValue(switchstatus & 0x3); + switchstatus>>=2; + ui->switchC->setValue(switchstatus & 0x3); + switchstatus>>=2; + ui->switchB->setValue(switchstatus & 0x3); + switchstatus>>=2; + ui->switchA->setValue(switchstatus & 0x3); +} diff --git a/companion/src/simulation/simulatordialoghorus.cpp b/companion/src/simulation/simulatordialoghorus.cpp new file mode 100644 index 000000000..c18b6755a --- /dev/null +++ b/companion/src/simulation/simulatordialoghorus.cpp @@ -0,0 +1,185 @@ +#include "simulatordialog.h" +#include "ui_simulatordialog-horus.h" +#include "helpers.h" + +uint32_t SimulatorDialogHorus::switchstatus = 0; + +SimulatorDialogHorus::SimulatorDialogHorus(QWidget * parent, SimulatorInterface *simulator, unsigned int flags): + SimulatorDialog(parent, simulator, flags), + ui(new Ui::SimulatorDialogHorus) +{ + QPolygon polygon; + + lcdWidth = 480; + lcdHeight = 272; + lcdDepth = 16; + + initUi(ui); + + polygon.setPoints(23, 72,125, 85,126, 92,129, 98,133, 100,136, 100,141, 99,145, 96,148, 92,149, 87,147, 82,146, 76,145, 69,146, 63,147, 58,148, 54,148, 52,147, 49,144, 48,139, 47,135, 53,130, 63,127, 72,125); + ui->rightbuttons->addArea(polygon, Qt::Key_Up, "Horus/right_btnU.png"); + polygon.setPoints(25, 125,163, 129,164, 132,167, 135,171, 136,177, 137,184, 138,189, 138,195, 137,202, 135,207, 134,211, 131,214, 130,216, 125,217, 121,216, 118,214, 115,211, 115,204, 118,195, 118,187, 118,181, 116,176, 116,171, 118,165, 125,163); + ui->rightbuttons->addArea(polygon, Qt::Key_Right, "Horus/right_btnR.png"); + polygon.setPoints(20, 64,234, 72,235, 84,234, 91,232, 97,234, 99,237, 101,242, 100,248, 96,250, 92,252, 83,254, 72,255, 64,254, 57,253, 50,249, 48,245, 47,240, 50,235, 55,233, 64,234); + ui->rightbuttons->addArea(polygon, Qt::Key_Down, "Horus/right_btnD.png"); + polygon.setPoints(22, 24,163, 29,166, 30,168, 31,171, 31,175, 30,179, 29,187, 29,192, 30,198, 32,204, 32,209, 30,214, 27,216, 22,217, 17,216, 13,208, 10,197, 9,188, 9,178, 12,169, 15,165, 24,162); + ui->rightbuttons->addArea(polygon, Qt::Key_Left, "Horus/right_btnL.png"); + polygon.setPoints(21, 72,148, 83,149, 97,155, 106,163, 112,174, 114,187, 114,198, 110,210, 101,221, 89,228, 78,230, 66,230, 53,226, 43,218, 36,208, 32,196, 32,181, 37,168, 47,157, 57,151, 73,148); + ui->rightbuttons->addArea(polygon, Qt::Key_Enter, "Horus/right_ent.png"); + polygon.setPoints(26, 25,164, 31,165, 33,167, 35,169, 35,172, 35,174, 34,179, 34,183, 34,190, 34,195, 36,200, 37,204, 38,208, 37,212, 34,216, 29,218, 25,217, 21,215, 18,210, 16,203, 14,194, 14,184, 15,175, 17,169, 21,165, 25,164); + ui->leftbuttons->addArea(polygon, Qt::Key_PageUp, "Horus/left_btn1.png"); + polygon.setPoints(27, 60,227, 66,228, 71,229, 75,230, 81,229, 86,228, 89,227, 94,227, 97,229, 100,232, 100, 234, 100,238, 100,241, 99,243, 94,246, 88,248, 81,249, 73,249, 63,248, 56,246, 50,243, 48,240, 47,235, 48,232, 51,228, 56,227, 60,227); + ui->leftbuttons->addArea(polygon, Qt::Key_Escape, "Horus/left_btn2.png"); + ui->leftbuttons->addArea(9, 259, 34, 282, Qt::Key_Print, "Horus/left_scrnsht.png"); + + // install simulator TRACE hook + simulator->installTraceHook(traceCb); + + // TODO dialP_4 = ui->dialP_4; + + ui->lcd->setBackgroundColor(47, 123, 227); + + //restore switches + if (g.simuSW()) + restoreSwitches(); + + ui->trimHR_L->setText(QString::fromUtf8(leftArrow)); + ui->trimHR_R->setText(QString::fromUtf8(rightArrow)); + ui->trimVR_U->setText(QString::fromUtf8(upArrow)); + ui->trimVR_D->setText(QString::fromUtf8(downArrow)); + ui->trimHL_L->setText(QString::fromUtf8(leftArrow)); + ui->trimHL_R->setText(QString::fromUtf8(rightArrow)); + ui->trimVL_U->setText(QString::fromUtf8(upArrow)); + ui->trimVL_D->setText(QString::fromUtf8(downArrow)); + + connect(ui->leftbuttons, SIGNAL(buttonPressed(int)), this, SLOT(onButtonPressed(int))); + connect(ui->rightbuttons, SIGNAL(buttonPressed(int)), this, SLOT(onButtonPressed(int))); + connect(ui->trimHR_L, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimHR_R, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimVR_U, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimVR_D, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimHL_R, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimHL_L, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimVL_U, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimVL_D, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimHR_L, SIGNAL(released()), this, SLOT(onTrimReleased())); + connect(ui->trimHR_R, SIGNAL(released()), this, SLOT(onTrimReleased())); + connect(ui->trimVR_U, SIGNAL(released()), this, SLOT(onTrimReleased())); + connect(ui->trimVR_D, SIGNAL(released()), this, SLOT(onTrimReleased())); + connect(ui->trimHL_R, SIGNAL(released()), this, SLOT(onTrimReleased())); + connect(ui->trimHL_L, SIGNAL(released()), this, SLOT(onTrimReleased())); + connect(ui->trimVL_U, SIGNAL(released()), this, SLOT(onTrimReleased())); + connect(ui->trimVL_D, SIGNAL(released()), this, SLOT(onTrimReleased())); +} + +SimulatorDialogHorus::~SimulatorDialogHorus() +{ + saveSwitches(); + delete ui; +} + +void SimulatorDialogHorus::resetSH() +{ + ui->switchH->setValue(0); +} + +void SimulatorDialogHorus::on_switchH_sliderReleased() +{ + QTimer::singleShot(400, this, SLOT(resetSH())); +} + +void SimulatorDialogHorus::getValues() +{ + TxInputs inputs = { + { + int(1024*nodeLeft->getX()), // LEFT HORZ + int(-1024*nodeLeft->getY()), // LEFT VERT + int(-1024*nodeRight->getY()), // RGHT VERT + int(1024*nodeRight->getX()) // RGHT HORZ + }, + + { + -ui->dialP_1->value(), + ui->dialP_2->value(), + 0, + -ui->dialP_3->value(), + ui->dialP_4->value() + }, + + { + ui->switchA->value() - 1, + ui->switchB->value() - 1, + ui->switchC->value() - 1, + ui->switchD->value() - 1, + ui->switchE->value() - 1, + ui->switchF->value(), + ui->switchG->value() - 1, + ui->switchH->value(), 0, 0 + }, + + { + buttonPressed == Qt::Key_PageUp, + buttonPressed == Qt::Key_Escape, + buttonPressed == Qt::Key_Enter || middleButtonPressed, + buttonPressed == Qt::Key_Up, + buttonPressed == Qt::Key_Down, + buttonPressed == Qt::Key_Right, + buttonPressed == Qt::Key_Left + }, + + middleButtonPressed, + + { + trimPressed == TRIM_LH_L, + trimPressed == TRIM_LH_R, + trimPressed == TRIM_LV_DN, + trimPressed == TRIM_LV_UP, + trimPressed == TRIM_RV_DN, + trimPressed == TRIM_RV_UP, + trimPressed == TRIM_RH_L, + trimPressed == TRIM_RH_R + } + }; + + simulator->setValues(inputs); +} + +void SimulatorDialogHorus::saveSwitches(void) +{ + // qDebug() << "SimulatorDialogTaranis::saveSwitches()"; + switchstatus=ui->switchA->value(); + switchstatus<<=2; + switchstatus+=ui->switchB->value(); + switchstatus<<=2; + switchstatus+=ui->switchC->value(); + switchstatus<<=2; + switchstatus+=ui->switchD->value(); + switchstatus<<=2; + switchstatus+=ui->switchE->value(); + switchstatus<<=2; + switchstatus+=ui->switchF->value(); + switchstatus<<=2; + switchstatus+=ui->switchG->value(); + switchstatus<<=2; + switchstatus+=ui->switchH->value(); +} + +void SimulatorDialogHorus::restoreSwitches(void) +{ + // qDebug() << "SimulatorDialogTaranis::restoreSwitches()"; + ui->switchH->setValue(switchstatus & 0x3); + switchstatus>>=2; + ui->switchG->setValue(switchstatus & 0x3); + switchstatus>>=2; + ui->switchF->setValue(switchstatus & 0x3); + switchstatus>>=2; + ui->switchE->setValue(switchstatus & 0x3); + switchstatus>>=2; + ui->switchD->setValue(switchstatus & 0x3); + switchstatus>>=2; + ui->switchC->setValue(switchstatus & 0x3); + switchstatus>>=2; + ui->switchB->setValue(switchstatus & 0x3); + switchstatus>>=2; + ui->switchA->setValue(switchstatus & 0x3); +} diff --git a/companion/src/simulation/simulatordialogtaranis.cpp b/companion/src/simulation/simulatordialogtaranis.cpp new file mode 100644 index 000000000..dc67dfa6c --- /dev/null +++ b/companion/src/simulation/simulatordialogtaranis.cpp @@ -0,0 +1,201 @@ +#include "ui_simulatordialog-taranis.h" + +uint32_t SimulatorDialogTaranis::switchstatus = 0; + +SimulatorDialogTaranis::SimulatorDialogTaranis(QWidget * parent, SimulatorInterface *simulator, unsigned int flags): + SimulatorDialog(parent, simulator, flags), + ui(new Ui::SimulatorDialogTaranis) +{ + QPolygon polygon; + + lcdWidth = 212; + lcdHeight = 64; + lcdDepth = 4; + + initUi(ui); + + polygon.setPoints(6, 20, 59, 27, 50, 45, 52, 56, 59, 50, 71, 26, 72); + ui->leftbuttons->addArea(polygon, Qt::Key_PageUp, "Taranis/x9l1.png"); + polygon.setPoints(6, 23, 107, 30, 99, 46, 100, 55, 106, 47, 117, 28, 117); + ui->leftbuttons->addArea(polygon, Qt::Key_PageDown, "Taranis/x9l2.png"); + polygon.setPoints(6, 24, 154, 32, 144, 46, 146, 57, 156, 46, 167, 29, 166); + ui->leftbuttons->addArea(polygon, Qt::Key_Escape, "Taranis/x9l3.png"); + ui->leftbuttons->addArea(90, 177, 118, 197, Qt::Key_Print, "Taranis/x9l4.png"); + polygon.setPoints(6, 64, 60, 71, 50, 90, 50, 100, 60, 90, 73, 72, 73); + ui->rightbuttons->addArea(polygon, Qt::Key_Plus, "Taranis/x9r1.png"); + polygon.setPoints(6, 63, 109, 73, 100, 88, 100, 98, 109, 88, 119, 72, 119); + ui->rightbuttons->addArea(polygon, Qt::Key_Minus, "Taranis/x9r2.png"); + polygon.setPoints(6, 63, 155, 72, 146, 90, 146, 98, 155, 88, 166, 72, 166); + ui->rightbuttons->addArea(polygon, Qt::Key_Enter, "Taranis/x9r3.png"); + + // install simulator TRACE hook + simulator->installTraceHook(traceCb); + + ui->lcd->setBackgroundColor(47, 123, 227); + + // restore switches + if (g.simuSW()) { + restoreSwitches(); + } + + for (int i=0; isetValue(-1024); + pots[i]->setSingleStep(2048/5); + pots[i]->setPageStep(2048/5); + } + else if (!(flags & (SIMULATOR_FLAGS_S1 << i))) { + pots[i]->hide(); + potLabels[i]->hide(); + } + } + + ui->trimHR_L->setText(QString::fromUtf8(leftArrow)); + ui->trimHR_R->setText(QString::fromUtf8(rightArrow)); + ui->trimVR_U->setText(QString::fromUtf8(upArrow)); + ui->trimVR_D->setText(QString::fromUtf8(downArrow)); + ui->trimHL_L->setText(QString::fromUtf8(leftArrow)); + ui->trimHL_R->setText(QString::fromUtf8(rightArrow)); + ui->trimVL_U->setText(QString::fromUtf8(upArrow)); + ui->trimVL_D->setText(QString::fromUtf8(downArrow)); + + connect(ui->leftbuttons, SIGNAL(buttonPressed(int)), this, SLOT(onButtonPressed(int))); + connect(ui->rightbuttons, SIGNAL(buttonPressed(int)), this, SLOT(onButtonPressed(int))); + connect(ui->trimHR_L, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimHR_R, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimVR_U, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimVR_D, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimHL_R, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimHL_L, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimVL_U, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimVL_D, SIGNAL(pressed()), this, SLOT(onTrimPressed())); + connect(ui->trimHR_L, SIGNAL(released()), this, SLOT(onTrimReleased())); + connect(ui->trimHR_R, SIGNAL(released()), this, SLOT(onTrimReleased())); + connect(ui->trimVR_U, SIGNAL(released()), this, SLOT(onTrimReleased())); + connect(ui->trimVR_D, SIGNAL(released()), this, SLOT(onTrimReleased())); + connect(ui->trimHL_R, SIGNAL(released()), this, SLOT(onTrimReleased())); + connect(ui->trimHL_L, SIGNAL(released()), this, SLOT(onTrimReleased())); + connect(ui->trimVL_U, SIGNAL(released()), this, SLOT(onTrimReleased())); + connect(ui->trimVL_D, SIGNAL(released()), this, SLOT(onTrimReleased())); +} + +SimulatorDialogTaranis::~SimulatorDialogTaranis() +{ + saveSwitches(); + delete ui; +} + + +void SimulatorDialogTaranis::resetSH() +{ + ui->switchH->setValue(0); +} + +void SimulatorDialogTaranis::on_switchH_sliderReleased() +{ + QTimer::singleShot(400, this, SLOT(resetSH())); +} + +void SimulatorDialogTaranis::getValues() +{ + for (int i=0; ivalue()+1024)/(2048.0/5))*(2048.0/5)-1024; + pots[i]->setValue(s1); + } + } + + TxInputs inputs = { + { + int(1024*nodeLeft->getX()), // LEFT HORZ + int(-1024*nodeLeft->getY()), // LEFT VERT + int(-1024*nodeRight->getY()), // RGHT VERT + int(1024*nodeRight->getX()) // RGHT HORZ + }, + + { + -pots[0]->value(), + pots[1]->value(), + ((flags && SIMULATOR_FLAGS_S3) ? pots[2]->value() : 0), + -sliders[0]->value(), + sliders[1]->value() + }, + + { + ui->switchA->value() - 1, + ui->switchB->value() - 1, + ui->switchC->value() - 1, + ui->switchD->value() - 1, + ui->switchE->value() - 1, + ui->switchF->value(), + ui->switchG->value() - 1, + ui->switchH->value(), 0, 0 + }, + + { + buttonPressed == Qt::Key_PageUp, + buttonPressed == Qt::Key_Escape, + buttonPressed == Qt::Key_Enter, + buttonPressed == Qt::Key_PageDown, + buttonPressed == Qt::Key_Plus, + buttonPressed == Qt::Key_Minus + }, + + middleButtonPressed, + + { + trimPressed == TRIM_LH_L, + trimPressed == TRIM_LH_R, + trimPressed == TRIM_LV_DN, + trimPressed == TRIM_LV_UP, + trimPressed == TRIM_RV_DN, + trimPressed == TRIM_RV_UP, + trimPressed == TRIM_RH_L, + trimPressed == TRIM_RH_R + } + }; + + simulator->setValues(inputs); +} + +void SimulatorDialogTaranis::saveSwitches(void) +{ + // qDebug() << "SimulatorDialogTaranis::saveSwitches()"; + switchstatus=ui->switchA->value(); + switchstatus<<=2; + switchstatus+=ui->switchB->value(); + switchstatus<<=2; + switchstatus+=ui->switchC->value(); + switchstatus<<=2; + switchstatus+=ui->switchD->value(); + switchstatus<<=2; + switchstatus+=ui->switchE->value(); + switchstatus<<=2; + switchstatus+=ui->switchF->value(); + switchstatus<<=2; + switchstatus+=ui->switchG->value(); + switchstatus<<=2; + switchstatus+=ui->switchH->value(); +} + +void SimulatorDialogTaranis::restoreSwitches(void) +{ + // qDebug() << "SimulatorDialogTaranis::restoreSwitches()"; + ui->switchH->setValue(switchstatus & 0x3); + switchstatus>>=2; + ui->switchG->setValue(switchstatus & 0x3); + switchstatus>>=2; + ui->switchF->setValue(switchstatus & 0x3); + switchstatus>>=2; + ui->switchE->setValue(switchstatus & 0x3); + switchstatus>>=2; + ui->switchD->setValue(switchstatus & 0x3); + switchstatus>>=2; + ui->switchC->setValue(switchstatus & 0x3); + switchstatus>>=2; + ui->switchB->setValue(switchstatus & 0x3); + switchstatus>>=2; + ui->switchA->setValue(switchstatus & 0x3); +} + + diff --git a/companion/src/simulation/simulatorimport.h b/companion/src/simulation/simulatorimport.h index 0f4fee47e..01b86bd96 100644 --- a/companion/src/simulation/simulatorimport.h +++ b/companion/src/simulation/simulatorimport.h @@ -50,7 +50,7 @@ if (inputs.rotenc) pind |= 0x20; if (inputs.rotenc) PIOB->PIO_PDSR &= ~0x40; else PIOB->PIO_PDSR |= 0x40; #endif -#if defined(PCBTARANIS) && defined(REV9E) +#if defined(PCBFLAMENCO) || (defined(PCBTARANIS) && defined(REV9E)) if (inputs.rotenc) simuSetKey(KEY_ENTER, true); #endif #endif @@ -80,9 +80,9 @@ for (int fm=0; fm +#include + +class SliderWidget : public QSlider +{ + Q_OBJECT + + public: + + explicit SliderWidget(QFrame * parent = 0): + QSlider(parent) + { + } + + protected: + + void mousePressEvent(QMouseEvent * event) + { + if (event->button() == Qt::RightButton && event->type() == QEvent::MouseButtonDblClick) { + setValue(0); + event->accept(); + } + QSlider::mousePressEvent(event); + } +}; + +#endif // _SLIDERWIDGET_H_ diff --git a/companion/src/simulation/xcursorwidget.h b/companion/src/simulation/xcursorwidget.h deleted file mode 100644 index 36c024149..000000000 --- a/companion/src/simulation/xcursorwidget.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Author - Bertrand Songis - * - * Based on th9x -> http://code.google.com/p/th9x/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ -#ifndef XCURSORWIDGET_H -#define XCURSORWIDGET_H - -#include -#include - -class xcursorWidget : public QWidget { - - Q_OBJECT - - public: - - explicit xcursorWidget(QWidget * parent = 0): - QWidget(parent) - { - } - - protected: - - virtual void mousePressEvent(QMouseEvent * event) - { - float p1x[] = {20,27,45,56,50,26}; - float p1y[] = {59,50,52,59,71,72}; - float p2x[] = {23,30,46,55,47,28}; - float p2y[] = {107,99,100,106,117,117}; - float p3x[] = {24,32,46,57,46,29}; - float p3y[] = {154,144,146,156,167,166}; - - int x=event->x(); - int y=event->y(); - setFocus(); - if (event->button()==Qt::LeftButton) { - if (pnpoly(6,p1x,p1y,(float)x,(float)y)==1) { - setStyleSheet("background:url(:/images/x9l1.png);"); - emit buttonPressed(Qt::Key_PageUp); - } - else if (pnpoly(6,p2x,p2y,(float)x,(float)y)==1) { - setStyleSheet("background:url(:/images/x9l2.png);"); - emit buttonPressed(Qt::Key_PageDown); - } - else if (pnpoly(6,p3x,p3y,(float)x,(float)y)==1) { - setStyleSheet("background:url(:/images/x9l3.png);"); - emit buttonPressed(Qt::Key_Escape); - } else if ((x>90 && x<118) && (y>177 && y<197)) { - setStyleSheet("background:url(:/images/x9l4.png);"); - emit buttonPressed(Qt::Key_Print); - } - } - // QWidget::mousePressEvent(event); - } - - virtual void mouseReleaseEvent(QMouseEvent * event) - { - setStyleSheet("background:url(:/images/x9l0.png);"); - emit buttonPressed(0); - setFocus(); - //QWidget::mouseReleaseEvent(event); - } - - void paintEvent(QPaintEvent *) - { - QStyleOption opt; - opt.init(this); - QPainter p(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); - } - - inline int pnpoly(int nvert, float *vertx, float *verty, float testx, float testy) - { - int i, j, c = 0; - for (i = 0, j = nvert-1; i < nvert; j = i++) { - if ( ((verty[i]>testy) != (verty[j]>testy)) && (testx < (vertx[j]-vertx[i]) * (testy-verty[i]) / (verty[j]-verty[i]) + vertx[i]) ) - c = !c; - } - return c; - } - - signals: - void buttonPressed(int button); - -}; - - -#endif /* CURSORWIDGET_H */ - diff --git a/companion/src/simulation/xmenuwidget.h b/companion/src/simulation/xmenuwidget.h deleted file mode 100644 index 6bcf7795c..000000000 --- a/companion/src/simulation/xmenuwidget.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Author - Bertrand Songis - * - * Based on th9x -> http://code.google.com/p/th9x/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ -#ifndef XMENUWIDGET_H -#define XMENUWIDGET_H - -#include -#include - -class xmenuWidget : public QWidget { - - Q_OBJECT - - public: - - explicit xmenuWidget(QWidget * parent = 0): - QWidget(parent) - { - } - - protected: - - virtual void mousePressEvent(QMouseEvent * event) - { - float p1x[] = {64,71,90,100,90,72}; - float p1y[] = {60,50,50,60,73,73}; - float p2x[] = {63,73,88,98,88,72}; - float p2y[] = {109,100,100,109,119,119}; - float p3x[] = {63,72,90,98,88,72}; - float p3y[] = {155,146,146,155,166,166}; - - int x=event->x(); - int y=event->y(); - setFocus(); - if (event->button()==Qt::LeftButton) { - if (pnpoly(6,p1x,p1y,(float)x,(float)y)==1) { - setStyleSheet("background:url(:/images/x9r1.png);"); - emit buttonPressed(Qt::Key_Plus); - } - else if (pnpoly(6,p2x,p2y,(float)x,(float)y)==1) { - setStyleSheet("background:url(:/images/x9r2.png);"); - emit buttonPressed(Qt::Key_Minus); - } - else if (pnpoly(6,p3x,p3y,(float)x,(float)y)==1) { - setStyleSheet("background:url(:/images/x9r3.png);"); - emit buttonPressed(Qt::Key_Enter); - } - } - // QWidget::mousePressEvent(event); - } - - virtual void mouseReleaseEvent(QMouseEvent * event) - { - setStyleSheet("background:url(:/images/x9r0.png);"); - setFocus(); - emit buttonPressed(0); - // QWidget::mouseReleaseEvent(event); - } - - void paintEvent(QPaintEvent *) - { - QStyleOption opt; - opt.init(this); - QPainter p(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); - } - - inline int pnpoly(int nvert, float *vertx, float *verty, float testx, float testy) - { - int i, j, c = 0; - for (i = 0, j = nvert-1; i < nvert; j = i++) { - if ( ((verty[i]>testy) != (verty[j]>testy)) && (testx < (vertx[j]-vertx[i]) * (testy-verty[i]) / (verty[j]-verty[i]) + vertx[i]) ) - c = !c; - } - return c; - } - - signals: - void buttonPressed(int button); - -}; -#endif /* XMENUWIDGET_H */ - diff --git a/companion/src/simulator.cpp b/companion/src/simulator.cpp index e8b3fb653..9257d68df 100644 --- a/companion/src/simulator.cpp +++ b/companion/src/simulator.cpp @@ -160,7 +160,11 @@ int main(int argc, char *argv[]) eepromFileName = QString("eeprom-%1.bin").arg(radioId); eepromFileName = eedir.filePath(eepromFileName.toAscii()); SimulatorFactory *factory = getSimulatorFactory(firmwareId); - if (factory->type() == BOARD_TARANIS) + if (factory->type() == BOARD_HORUS) + dialog = new SimulatorDialogHorus(NULL, factory->create()); + else if (factory->type() == BOARD_FLAMENCO) + dialog = new SimulatorDialogFlamenco(NULL, factory->create()); + else if (factory->type() == BOARD_TARANIS) dialog = new SimulatorDialogTaranis(NULL, factory->create(), SIMULATOR_FLAGS_S1|SIMULATOR_FLAGS_S2); else dialog = new SimulatorDialog9X(NULL, factory->create()); diff --git a/companion/src/simulator.desktop.in b/companion/src/simulator.desktop.in index d87e3c404..c5715ac24 100644 --- a/companion/src/simulator.desktop.in +++ b/companion/src/simulator.desktop.in @@ -1,7 +1,7 @@ [Desktop Entry] Type=Application Encoding=UTF-8 -Name=Simulator @C9X_VERSION@ +Name=Simulator @VERSION@ GenericName=Transmitter Simulator App Comment=The Ultimate Transmitter Simulator Icon=@COMPANION_NAME@ diff --git a/companion/src/version.h.in b/companion/src/version.h.in index b7bbfbd2e..145b881d4 100644 --- a/companion/src/version.h.in +++ b/companion/src/version.h.in @@ -1,2 +1,2 @@ -#define C9X_VERSION "@C9X_VERSION@" +#define VERSION "@VERSION@" #define SIMULATOR_LIB_SEARCH_PATH "@SIMULATOR_LIB_PATH@" diff --git a/companion/targets/windows/companion-msys.nsi.in b/companion/targets/windows/companion-msys.nsi.in index 6d0975dc7..1d1a31139 100644 --- a/companion/targets/windows/companion-msys.nsi.in +++ b/companion/targets/windows/companion-msys.nsi.in @@ -13,7 +13,7 @@ ;Name and file Name "OpenTX companion" - OutFile "companion-windows-v@C9X_VERSION@.exe" + OutFile "companion-windows-v@VERSION@.exe" ;Default installation folder InstallDir "$PROGRAMFILES\OpenTX companion" diff --git a/companion/targets/windows/companion-vs.nsi.in b/companion/targets/windows/companion-vs.nsi.in index 698a3e617..f6150ae91 100644 --- a/companion/targets/windows/companion-vs.nsi.in +++ b/companion/targets/windows/companion-vs.nsi.in @@ -12,14 +12,14 @@ ;General ;Name and file - Name "OpenTX Companion 2.1" - OutFile "companion-windows-@C9X_VERSION@.exe" + Name "OpenTX Companion @VERSION_FAMILY@" + OutFile "companion-windows-@VERSION@.exe" ;Default installation folder - InstallDir "$PROGRAMFILES\OpenTX\Companion 2.1" + InstallDir "$PROGRAMFILES\OpenTX\Companion @VERSION_FAMILY@" ;Get installation folder from registry if available - InstallDirRegKey HKCU "Software\OpenTX\Companion 2.1" "" + InstallDirRegKey HKCU "Software\OpenTX\Companion @VERSION_FAMILY@" "" ;Compressor options SetCompressor /FINAL /SOLID lzma @@ -66,7 +66,7 @@ ;Start Menu Folder Page Configuration !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU" - !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\OpenTX\Companion 2.1" + !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\OpenTX\Companion @VERSION_FAMILY@" !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder" !insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder @@ -77,7 +77,7 @@ !define MUI_FINISHPAGE_NOAUTOCLOSE !define MUI_FINISHPAGE_RUN !define MUI_FINISHPAGE_RUN_CHECKED - !define MUI_FINISHPAGE_RUN_TEXT "Launch OpenTX Companion 2.1" + !define MUI_FINISHPAGE_RUN_TEXT "Launch OpenTX Companion @VERSION_FAMILY@" !define MUI_FINISHPAGE_RUN_FUNCTION "LaunchLink" # !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED # !define MUI_FINISHPAGE_SHOWREADME $INSTDIR\readme.txt @@ -134,7 +134,7 @@ Section "OpenTX Companion" SecDummy SetOutPath "$INSTDIR" ;Store installation folder - WriteRegStr HKCU "Software\OpenTX\Companion 2.1" "" $INSTDIR + WriteRegStr HKCU "Software\OpenTX\Companion @VERSION_FAMILY@" "" $INSTDIR ;Associate with extentions ,bin and .hex ${registerExtension} "$INSTDIR\companion.exe" ".bin" "BIN_File" @@ -147,20 +147,20 @@ Section "OpenTX Companion" SecDummy WriteUninstaller "$INSTDIR\Uninstall.exe" ;Registry information for add/remove programs - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenTX Companion 2.1" "DisplayName" "OpenTX Companion 2.1" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenTX Companion 2.1" "UninstallString" "$\"$INSTDIR\Uninstall.exe$\"" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenTX Companion 2.1" "DisplayIcon" "$\"$INSTDIR\companion.exe$\"" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenTX Companion 2.1" "Publisher" "OpenTX" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenTX Companion 2.1" "URLInfoAbout" "http://www.open-tx.org" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenTX Companion 2.1" "QuietUninstallString" "$\"$INSTDIR\Uninstall.exe$\" /S" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenTX Companion @VERSION_FAMILY@" "DisplayName" "OpenTX Companion @VERSION_FAMILY@" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenTX Companion @VERSION_FAMILY@" "UninstallString" "$\"$INSTDIR\Uninstall.exe$\"" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenTX Companion @VERSION_FAMILY@" "DisplayIcon" "$\"$INSTDIR\companion.exe$\"" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenTX Companion @VERSION_FAMILY@" "Publisher" "OpenTX" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenTX Companion @VERSION_FAMILY@" "URLInfoAbout" "http://www.open-tx.org" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenTX Companion @VERSION_FAMILY@" "QuietUninstallString" "$\"$INSTDIR\Uninstall.exe$\" /S" !insertmacro MUI_STARTMENU_WRITE_BEGIN Application ;Create shortcuts CreateDirectory "$SMPROGRAMS\$StartMenuFolder" - CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Companion 2.1.lnk" "$INSTDIR\companion.exe" - CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Firmware Simulator 2.1.lnk" "$INSTDIR\simulator.exe" - CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall Companion 2.1.lnk" "$INSTDIR\Uninstall.exe" + CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Companion @VERSION_FAMILY@.lnk" "$INSTDIR\companion.exe" + CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Firmware Simulator @VERSION_FAMILY@.lnk" "$INSTDIR\simulator.exe" + CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall Companion @VERSION_FAMILY@.lnk" "$INSTDIR\Uninstall.exe" !insertmacro MUI_STARTMENU_WRITE_END @@ -220,13 +220,13 @@ Section "Uninstall" !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder - Delete "$SMPROGRAMS\$StartMenuFolder\Companion 2.1.lnk" - Delete "$SMPROGRAMS\$StartMenuFolder\Firmware Simulator 2.1.lnk" - Delete "$SMPROGRAMS\$StartMenuFolder\Uninstall Companion 2.1.lnk" + Delete "$SMPROGRAMS\$StartMenuFolder\Companion @VERSION_FAMILY@.lnk" + Delete "$SMPROGRAMS\$StartMenuFolder\Firmware Simulator @VERSION_FAMILY@.lnk" + Delete "$SMPROGRAMS\$StartMenuFolder\Uninstall Companion @VERSION_FAMILY@.lnk" RMDir "$SMPROGRAMS\$StartMenuFolder" - DeleteRegKey /ifempty HKCU "Software\OpenTX Companion 2.1" - DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenTX Companion 2.1" + DeleteRegKey /ifempty HKCU "Software\OpenTX Companion @VERSION_FAMILY@" + DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenTX Companion @VERSION_FAMILY@" SectionEnd diff --git a/companion/targets/windows/simulator-vs.nsi.in b/companion/targets/windows/simulator-vs.nsi.in index 7111ecd83..3b603b283 100644 --- a/companion/targets/windows/simulator-vs.nsi.in +++ b/companion/targets/windows/simulator-vs.nsi.in @@ -12,7 +12,7 @@ ;Name and file Name "OpenTX Simulator" - OutFile "simulator-windows-@C9X_VERSION@.exe" + OutFile "simulator-windows-@VERSION@.exe" ;Default installation folder InstallDir "$PROGRAMFILES\OpenTX" diff --git a/radio/src/.gitignore b/radio/src/.gitignore index 32e628d55..a33e0f3ed 100644 --- a/radio/src/.gitignore +++ b/radio/src/.gitignore @@ -19,6 +19,7 @@ /allsimusrc.cpp /BMP /traces +/RADIO /MODELS /FIRMWARES /EEPROMS @@ -27,4 +28,5 @@ /gtests.d /lua_exports* /lua_fields* +.directory diff --git a/radio/src/Makefile b/radio/src/Makefile index 503ee5315..ffdcfdfd3 100644 --- a/radio/src/Makefile +++ b/radio/src/Makefile @@ -397,8 +397,13 @@ endif IMG2LBM = -$(PYTHON) ../util/img2lbm.py BIN2LBM = -$(PYTHON) ../util/bin2lbm.py -FONT2PNG = -$(PYTHON) ../util/font2png.py +ifeq ($(OS), Windows_NT) + FONT2PNG = -$(PYTHON) ../util/font2png.py +else + FONT2PNG = -xvfb-run --server-args="-screen 0 1024x768x24" $(PYTHON) ../util/font2png.py +endif TRANSLATE = -$(PYTHON) ../util/translate.py + VERSION = 2.2.0$(OPENTX_VERSION_SUFFIX) THIRDPARTY = thirdparty @@ -413,7 +418,7 @@ LUADEP = DEBUG_TRACE_BUFFER = NO # MCU name -ifneq ($(PCB), $(filter $(PCB), STD 9X 9XR STD128 9X128 9XR128 9X2561 9XR2561 GRUVIN9X MEGA2560 SKY9X 9XRPRO AR9X TARANIS)) +ifneq ($(PCB), $(filter $(PCB), STD 9X 9XR STD128 9X128 9XR128 9X2561 9XR2561 GRUVIN9X MEGA2560 SKY9X 9XRPRO AR9X TARANIS FLAMENCO HORUS)) $(error Sorry, the PCB $(PCB) is not supported yet in OpenTX) endif @@ -428,7 +433,7 @@ EEPROM_VARIANT = 0 GUIMODELSRC = gui/$(GUIDIRECTORY)/menu_model.cpp gui/$(GUIDIRECTORY)/menu_model_select.cpp gui/$(GUIDIRECTORY)/menu_model_setup.cpp gui/$(GUIDIRECTORY)/menu_model_inputs_mixes.cpp gui/$(GUIDIRECTORY)/menu_model_limits.cpp gui/$(GUIDIRECTORY)/menu_model_logical_switches.cpp gui/$(GUIDIRECTORY)/menu_model_custom_functions.cpp gui/$(GUIDIRECTORY)/menu_model_telemetry.cpp GUIGENERALSRC = gui/$(GUIDIRECTORY)/menu_general.cpp gui/$(GUIDIRECTORY)/menu_general_setup.cpp gui/$(GUIDIRECTORY)/menu_general_trainer.cpp gui/$(GUIDIRECTORY)/menu_general_version.cpp gui/$(GUIDIRECTORY)/menu_general_calib.cpp -BITMAPS = bitmaps/sticks.lbm +BITMAPS = bitmaps/sticks.lbm FONTS = $(patsubst %.png,%.lbm,$(wildcard fonts/std/*.png)) @@ -442,14 +447,14 @@ ifeq ($(PCB), $(filter $(PCB), STD 9X 9XR)) OPT = s SDCARD = NO THR_TRACE = NO - INCDIRS += targets/stock - CPPDEFS = -DF_CPU=$(F_CPU)UL -DPCBSTD -DCPUM64 -DEEPROM_RLC -DEEPROM_VARIANT=$(shell echo ${EEPROM_VARIANT} | bc) - BOARDSRC = main_avr.cpp targets/stock/board_stock.cpp + INCDIRS += targets/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 ifeq ($(GUI), YES) - EXTRABOARDSRC += targets/stock/lcd_driver.cpp + EXTRABOARDSRC += targets/9x/lcd_driver.cpp endif - EEPROMSRC = eeprom_common.cpp eeprom_rlc.cpp + EEPROMSRC = storage/storage_common.cpp storage/eeprom_common.cpp storage/eeprom_rlc.cpp PULSESSRC = pulses/pulses_avr.cpp CPPSRC += debug.cpp BITMAPS += bitmaps/9X/splash.lbm bitmaps/9X/asterisk.lbm bitmaps/9X/about.lbm @@ -486,7 +491,7 @@ ifeq ($(PCB), $(filter $(PCB), STD 9X 9XR)) ifeq ($(VOICE), YES) CPPDEFS += -DVOICE - CPPSRC += targets/stock/voice.cpp + CPPSRC += targets/9x/voice.cpp endif ifeq ($(PWM_BACKLIGHT), YES) @@ -524,11 +529,11 @@ ifeq ($(PCB), $(filter $(PCB), STD128 9X128 9XR128)) SDCARD = NO THR_TRACE = NO EEPROM_VARIANT += ${M128_VARIANT} - CPPDEFS = -DF_CPU=$(F_CPU)UL -DPCBSTD -DCPUM128 -DEEPROM_RLC -DEEPROM_VARIANT=$(shell echo ${EEPROM_VARIANT} | bc) - INCDIRS += targets/stock - BOARDSRC = main_avr.cpp targets/stock/board_stock.cpp - EXTRABOARDSRC = targets/common_avr/adc_driver.cpp targets/stock/lcd_driver.cpp targets/common_avr/telemetry_driver.cpp - EEPROMSRC = eeprom_common.cpp eeprom_rlc.cpp + CPPDEFS = -DF_CPU=$(F_CPU)UL -DPCBSTD -DCPUM128 -DEEPROM -DEEPROM_RLC -DEEPROM_VARIANT=$(shell echo ${EEPROM_VARIANT} | bc) + INCDIRS += targets/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 PULSESSRC = pulses/pulses_avr.cpp CPPSRC += debug.cpp BITMAPS += bitmaps/9X/splash.lbm bitmaps/9X/asterisk.lbm bitmaps/9X/about.lbm @@ -565,7 +570,7 @@ ifeq ($(PCB), $(filter $(PCB), STD128 9X128 9XR128)) ifeq ($(VOICE), YES) CPPDEFS += -DVOICE - CPPSRC += targets/stock/voice.cpp + CPPSRC += targets/9x/voice.cpp endif ifeq ($(PWM_BACKLIGHT), YES) @@ -599,11 +604,11 @@ ifeq ($(PCB), $(filter $(PCB), 9X2561)) SDCARD = NO THR_TRACE = YES EEPROM_VARIANT += ${M2561_VARIANT} - CPPDEFS = -DF_CPU=$(F_CPU)UL -DPCBSTD -DCPUM2561 -DEEPROM_RLC -DEEPROM_VARIANT=$(shell echo ${EEPROM_VARIANT} | bc) - INCDIRS += targets/stock - BOARDSRC = main_avr.cpp targets/stock/board_stock.cpp - EXTRABOARDSRC = targets/common_avr/adc_driver.cpp targets/stock/lcd_driver.cpp targets/common_avr/telemetry_driver.cpp - EEPROMSRC = eeprom_common.cpp eeprom_rlc.cpp + CPPDEFS = -DF_CPU=$(F_CPU)UL -DPCBSTD -DCPUM2561 -DEEPROM -DEEPROM_RLC -DEEPROM_VARIANT=$(shell echo ${EEPROM_VARIANT} | bc) + INCDIRS += targets/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 PULSESSRC = pulses/pulses_avr.cpp CPPSRC += debug.cpp BITMAPS += bitmaps/9X/splash.lbm bitmaps/9X/asterisk.lbm bitmaps/9X/about.lbm @@ -632,7 +637,7 @@ ifeq ($(PCB), $(filter $(PCB), 9X2561)) ifeq ($(VOICE), YES) CPPDEFS += -DVOICE - CPPSRC += targets/stock/voice.cpp + CPPSRC += targets/9x/voice.cpp endif ifeq ($(PWM_BACKLIGHT), YES) @@ -669,14 +674,14 @@ ifeq ($(PCB), GRUVIN9X) TRGT = avr- MCU = atmega2560 OPT = s - CPPDEFS += -DF_CPU=$(F_CPU)UL -DPCBGRUVIN9X -DCPUM2560 -DEEPROM_RLC -DEEPROM_VARIANT=0 -DAUDIO -DHAPTIC + CPPDEFS += -DF_CPU=$(F_CPU)UL -DPCBGRUVIN9X -DCPUM2560 -DEEPROM -DEEPROM_RLC -DEEPROM_VARIANT=0 -DAUDIO -DHAPTIC SDCARD = NO BUZZER = NO THR_TRACE = YES - INCDIRS += targets/gruvin9x targets/stock $(FATFSDIR) $(FATFSDIR)/option - BOARDSRC = main_avr.cpp targets/gruvin9x/board_gruvin9x.cpp - EXTRABOARDSRC = targets/common_avr/adc_driver.cpp targets/stock/lcd_driver.cpp targets/common_avr/telemetry_driver.cpp - EEPROMSRC = eeprom_common.cpp eeprom_rlc.cpp + INCDIRS += targets/Gruvin9x targets/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 PULSESSRC = pulses/pulses_avr.cpp CPPSRC += audio_avr.cpp haptic.cpp debug.cpp BITMAPS += bitmaps/9X/splash.lbm bitmaps/9X/asterisk.lbm bitmaps/9X/about.lbm @@ -684,9 +689,9 @@ ifeq ($(PCB), GRUVIN9X) ifeq ($(SDCARD), YES) CPPDEFS += -DRTCLOCK -DSDCARD - CPPSRC += rtc.cpp sdcard.cpp logs.cpp targets/gruvin9x/rtc_driver.cpp + CPPSRC += rtc.cpp sdcard.cpp logs.cpp targets/Gruvin9x/rtc_driver.cpp GUIGENERALSRC += gui/$(GUIDIRECTORY)/menu_general_sdmanager.cpp - EXTRABOARDSRC += $(FATFSDIR)/ff.c $(FATFSDIR)/fattime.c $(FATFSDIR)/option/ccsbcs.c targets/gruvin9x/diskio.cpp + EXTRABOARDSRC += $(FATFSDIR)/ff.c $(FATFSDIR)/fattime.c $(FATFSDIR)/option/ccsbcs.c targets/Gruvin9x/diskio.cpp endif ifeq ($(BUZZER), YES) @@ -696,7 +701,7 @@ ifeq ($(PCB), GRUVIN9X) ifeq ($(VOICE), YES) CPPDEFS += -DVOICE - CPPSRC += targets/gruvin9x/somo14d.cpp + CPPSRC += targets/Gruvin9x/somo14d.cpp endif # Enable extra rotary encoders (Gruvin9x board only) @@ -714,30 +719,30 @@ ifeq ($(PCB), MEGA2560) TRGT = avr- MCU = atmega2560 OPT = s - CPPDEFS = -DF_CPU=$(F_CPU)UL -DPCBMEGA2560 -DCPUM2560 -DEEPROM_RLC -DEEPROM_VARIANT=0 -DAUDIO + CPPDEFS = -DF_CPU=$(F_CPU)UL -DPCBMEGA2560 -DCPUM2560 -DEEPROM -DEEPROM_RLC -DEEPROM_VARIANT=0 -DAUDIO SDCARD = NO BUZZER = YES THR_TRACE = YES PWRMANAGE = NO - INCDIRS += targets/mega2560 targets/stock $(FATFSDIR) $(FATFSDIR)/option - BOARDSRC = main_avr.cpp targets/mega2560/board_mega2560.cpp - EEPROMSRC = eeprom_common.cpp eeprom_rlc.cpp + INCDIRS += targets/Mega2560 targets/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 CPPSRC += audio_avr.cpp debug.cpp BITMAPS += bitmaps/9X/splash.lbm bitmaps/9X/asterisk.lbm bitmaps/9X/about.lbm GUIGENERALSRC += gui/$(GUIDIRECTORY)/menu_general_diagkeys.cpp gui/$(GUIDIRECTORY)/menu_general_diaganas.cpp - EXTRABOARDSRC = targets/common_avr/adc_driver.cpp targets/stock/lcd_driver.cpp targets/common_avr/telemetry_driver.cpp + EXTRABOARDSRC = targets/common_avr/adc_driver.cpp targets/9x/lcd_driver.cpp targets/common_avr/telemetry_driver.cpp ifeq ($(PWRMANAGE), YES) CPPDEFS += -DPWRMANAGE endif ifeq ($(SDCARD), YES) - EXTRABOARDSRC += $(FATFSDIR)/ff.c $(FATFSDIR)/fattime.c $(FATFSDIR)/option/ccsbcs.c targets/gruvin9x/diskio.cpp + EXTRABOARDSRC += $(FATFSDIR)/ff.c $(FATFSDIR)/fattime.c $(FATFSDIR)/option/ccsbcs.c targets/Gruvin9x/diskio.cpp CPPDEFS += -DSDCARD -DRTCLOCK GUIGENERALSRC += gui/$(GUIDIRECTORY)/menu_general_sdmanager.cpp - CPPSRC += rtc.cpp sdcard.cpp logs.cpp targets/gruvin9x/rtc_driver.cpp + CPPSRC += rtc.cpp sdcard.cpp logs.cpp targets/Gruvin9x/rtc_driver.cpp endif ifeq ($(AUDIO), YES) @@ -755,7 +760,7 @@ ifeq ($(PCB), MEGA2560) ifeq ($(VOICE), YES) CPPDEFS += -DVOICE - CPPSRC += targets/gruvin9x/somo14d.cpp + CPPSRC += targets/Gruvin9x/somo14d.cpp endif ifeq ($(HAPTIC), YES) @@ -773,32 +778,32 @@ ifeq ($(PCB), $(filter $(PCB), SKY9X 9XRPRO AR9X)) GUIDIRECTORY = 9X ARCH = ARM LCDSIZE = 128 - CPPDEFS = -Dat91sam3s4 + CPPDEFS = -Dat91sam3s4 -DPPM_PIN_HW_SERIAL ifeq ($(PCB), 9XRPRO) CPPDEFS = -Dat91sam3s8 FLAVOUR = 9xrpro CPPDEFS += -DREVX - LDSCRIPT = targets/sky9x/sam3s8c_flash.ld + LDSCRIPT = targets/Sky9x/sam3s8c_flash.ld else ifeq ($(PCB), AR9X) CPPDEFS = -Dat91sam3s8 FLAVOUR = ar9x CPPDEFS += -DAR9X - LDSCRIPT = targets/sky9x/sam3s8c_flash.ld + LDSCRIPT = targets/Sky9x/sam3s8c_flash.ld else ifeq ($(PCBREV), REVA) FLAVOUR = sky9x CPPDEFS += -DREVA - LDSCRIPT = targets/sky9x/sam3s2c_flash.ld - CPPSRC += targets/sky9x/coproc_driver.cpp + LDSCRIPT = targets/Sky9x/sam3s2c_flash.ld + CPPSRC += targets/Sky9x/coproc_driver.cpp else ifeq ($(PCBREV), REVB) FLAVOUR = sky9x CPPDEFS += -DREVB -DCOPROCESSOR - LDSCRIPT = targets/sky9x/sam3s4c_flash.ld - CPPSRC += targets/sky9x/coproc_driver.cpp + LDSCRIPT = targets/Sky9x/sam3s4c_flash.ld + CPPSRC += targets/Sky9x/coproc_driver.cpp else FLAVOUR = sky9x CPPDEFS += -DREVC -DCOPROCESSOR - LDSCRIPT = targets/sky9x/sam3s4c_flash.ld - CPPSRC += targets/sky9x/coproc_driver.cpp + LDSCRIPT = targets/Sky9x/sam3s4c_flash.ld + CPPSRC += targets/Sky9x/coproc_driver.cpp endif TRGT = arm-none-eabi- MCU = cortex-m3 @@ -807,28 +812,28 @@ ifeq ($(PCB), $(filter $(PCB), SKY9X 9XRPRO AR9X)) BUZZER = NO THR_TRACE = YES EXT = FRSKY_SPORT - CPPDEFS += -DPCBSKY9X -DCPUARM -DEEPROM_VARIANT=0 -DAUDIO -DHAPTIC -DDSM2 -DDSM2_PPM -DPXX + CPPDEFS += -DPCBSKY9X -DCPUARM -DEEPROM -DEEPROM_VARIANT=0 -DAUDIO -DHAPTIC -DDSM2 -DDSM2_PPM -DPXX ifeq ($(PCB), SKY9X) CPPDEFS += -DROTARY_ENCODERS=1 - CPPSRC += targets/sky9x/rotenc_driver.cpp + CPPSRC += targets/Sky9x/rotenc_driver.cpp endif ifeq ($(SPORT_FILE_LOG), YES) CPPDEFS += -DSPORT_FILE_LOG endif - INCDIRS += targets/sky9x $(COOSDIR) $(COOSDIR)/kernel $(COOSDIR)/portable + INCDIRS += targets/Sky9x $(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 - SRC += targets/sky9x/core_cm3.c targets/sky9x/board_lowlevel.c targets/sky9x/crt.c targets/sky9x/vectors_sam3s.c + BOARDSRC = main_arm.cpp targets/Sky9x/board_sky9x.cpp + EXTRABOARDSRC = targets/Sky9x/lcd_driver.cpp + SRC += targets/Sky9x/core_cm3.c targets/Sky9x/board_lowlevel.c targets/Sky9x/crt.c targets/Sky9x/vectors_sam3s.c SRC += $(COOSDIR)/kernel/core.c $(COOSDIR)/kernel/hook.c $(COOSDIR)/kernel/task.c $(COOSDIR)/kernel/event.c $(COOSDIR)/kernel/time.c $(COOSDIR)/kernel/timer.c $(COOSDIR)/kernel/flag.c $(COOSDIR)/kernel/mutex.c $(COOSDIR)/kernel/serviceReq.c $(COOSDIR)/portable/GCC/port.c $(COOSDIR)/portable/arch.c - SRC += targets/sky9x/usb/device/core/USBD_UDP.c targets/sky9x/usb/device/core/USBDDriver.c - SRC += targets/sky9x/usb/device/massstorage/MSDDriver.c targets/sky9x/usb/device/massstorage/MSDDStateMachine.c targets/sky9x/usb/device/massstorage/MSDLun.c targets/sky9x/usb/device/massstorage/MSDDriverDescriptors.c targets/sky9x/usb/device/massstorage/SBCMethods.c - SRC += targets/sky9x/usb/common/core/USBEndpointDescriptor.c targets/sky9x/usb/common/core/USBGenericRequest.c targets/sky9x/usb/common/core/USBFeatureRequest.c targets/sky9x/usb/common/core/USBInterfaceRequest.c targets/sky9x/usb/common/core/USBGetDescriptorRequest.c targets/sky9x/usb/common/core/USBSetAddressRequest.c targets/sky9x/usb/common/core/USBSetConfigurationRequest.c targets/sky9x/usb/common/core/USBConfigurationDescriptor.c targets/sky9x/usb/common/core/USBGenericDescriptor.c - SRC += targets/sky9x/MEDSdcard.c - EEPROMSRC = eeprom_common.cpp eeprom_raw.cpp eeprom_conversions.cpp + SRC += targets/Sky9x/usb/device/core/USBD_UDP.c targets/Sky9x/usb/device/core/USBDDriver.c + SRC += targets/Sky9x/usb/device/massstorage/MSDDriver.c targets/Sky9x/usb/device/massstorage/MSDDStateMachine.c targets/Sky9x/usb/device/massstorage/MSDLun.c targets/Sky9x/usb/device/massstorage/MSDDriverDescriptors.c targets/Sky9x/usb/device/massstorage/SBCMethods.c + SRC += targets/Sky9x/usb/common/core/USBEndpointDescriptor.c targets/Sky9x/usb/common/core/USBGenericRequest.c targets/Sky9x/usb/common/core/USBFeatureRequest.c targets/Sky9x/usb/common/core/USBInterfaceRequest.c targets/Sky9x/usb/common/core/USBGetDescriptorRequest.c targets/Sky9x/usb/common/core/USBSetAddressRequest.c targets/Sky9x/usb/common/core/USBSetConfigurationRequest.c targets/Sky9x/usb/common/core/USBConfigurationDescriptor.c targets/Sky9x/usb/common/core/USBGenericDescriptor.c + SRC += targets/Sky9x/MEDSdcard.c + EEPROMSRC = storage/storage_common.cpp storage/eeprom_common.cpp storage/eeprom_raw.cpp storage/eeprom_conversions.cpp PULSESSRC = pulses/pulses_arm.cpp pulses/ppm_arm.cpp pulses/pxx_arm.cpp pulses/dsm2_arm.cpp CPPSRC += tasks_arm.cpp audio_arm.cpp haptic.cpp gui/$(GUIDIRECTORY)/view_about.cpp gui/$(GUIDIRECTORY)/view_text.cpp telemetry/telemetry.cpp - CPPSRC += targets/sky9x/telemetry_driver.cpp targets/sky9x/serial2_driver.cpp targets/sky9x/pwr_driver.cpp targets/sky9x/adc_driver.cpp targets/sky9x/eeprom_driver.cpp targets/sky9x/pulses_driver.cpp targets/sky9x/keys_driver.cpp targets/sky9x/audio_driver.cpp targets/sky9x/buzzer_driver.cpp targets/sky9x/haptic_driver.cpp targets/sky9x/sdcard_driver.cpp targets/sky9x/massstorage.cpp + CPPSRC += targets/Sky9x/telemetry_driver.cpp targets/Sky9x/serial2_driver.cpp targets/Sky9x/pwr_driver.cpp targets/Sky9x/adc_driver.cpp targets/Sky9x/eeprom_driver.cpp targets/Sky9x/pulses_driver.cpp targets/Sky9x/keys_driver.cpp targets/Sky9x/audio_driver.cpp targets/Sky9x/buzzer_driver.cpp targets/Sky9x/haptic_driver.cpp targets/Sky9x/sdcard_driver.cpp targets/Sky9x/massstorage.cpp CPPSRC += loadboot.cpp debug.cpp BITMAPS += bitmaps/9X/splash.lbm bitmaps/9X/asterisk.lbm bitmaps/9X/about.lbm ifeq ($(SDCARD), YES) @@ -836,7 +841,7 @@ ifeq ($(PCB), $(filter $(PCB), SKY9X 9XRPRO AR9X)) INCDIRS += $(FATFSDIR) $(FATFSDIR)/option CPPSRC += sdcard.cpp logs.cpp GUIGENERALSRC += gui/$(GUIDIRECTORY)/menu_general_sdmanager.cpp - EXTRABOARDSRC += $(FATFSDIR)/ff.c $(FATFSDIR)/fattime.c $(FATFSDIR)/option/ccsbcs.c targets/sky9x/diskio.cpp + EXTRABOARDSRC += $(FATFSDIR)/ff.c $(FATFSDIR)/fattime.c $(FATFSDIR)/option/ccsbcs.c targets/Sky9x/diskio.cpp endif ifeq ($(BUZZER), YES) CPPDEFS += -DBUZZER @@ -844,11 +849,11 @@ ifeq ($(PCB), $(filter $(PCB), SKY9X 9XRPRO AR9X)) endif ifeq ($(RTCLOCK), YES) CPPDEFS += -DRTCLOCK - CPPSRC += rtc.cpp targets/sky9x/rtc_driver.cpp + CPPSRC += rtc.cpp targets/Sky9x/rtc_driver.cpp endif ifeq ($(BLUETOOTH), YES) CPPDEFS += -DBLUETOOTH - CPPSRC += targets/sky9x/bluetooth.cpp + CPPSRC += targets/Sky9x/bluetooth.cpp endif ifeq ($(DEBUG), YES) SRC += syscalls.c @@ -871,7 +876,7 @@ ifeq ($(PCB), TARANIS) CPPDEFS += -DLCD_DUAL_BUFFER endif HAPTIC = YES - EXTRABOARDSRC += targets/taranis/bluetooth_driver.cpp + EXTRABOARDSRC += targets/Taranis/bluetooth_driver.cpp else ifeq ($(PCBREV), REVPLUS) MCU = cortex-m3 FLAVOUR = taranis-plus @@ -930,19 +935,19 @@ ifeq ($(PCB), TARANIS) PPM_LIMITS_SYMETRICAL = YES PPM_CENTER_ADJUSTABLE = YES DSM2 = PPM - CPPDEFS += -DPCBTARANIS -DCPUARM -DCPUSTM32 -DVIRTUALINPUTS -DLUAINPUTS -DXCURVES -DEEPROM_RLC -DAUDIO -DPXX - INCDIRS += targets/taranis $(THIRDPARTY) $(COOSDIR) $(COOSDIR)/kernel $(COOSDIR)/portable + CPPDEFS += -DPCBTARANIS -DCPUARM -DCPUSTM32 -DVIRTUALINPUTS -DLUAINPUTS -DXCURVES -DEEPROM -DEEPROM_RLC -DAUDIO -DPXX + INCDIRS += targets/Taranis $(THIRDPARTY) $(COOSDIR) $(COOSDIR)/kernel $(COOSDIR)/portable CPPDEFS += -DHSE_VALUE=12000000 ifeq ($(PCBREV), REV9E) STM32LIBPATH = $(THIRDPARTY)/STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries CPPDEFS += -DSTM32F4 -DSTM32F40_41xxx -DEEPROM_VARIANT=32768 INCDIRS += $(STM32LIBPATH)/CMSIS/Device/ST/STM32F4xx/Include $(STM32LIBPATH)/CMSIS/Include $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/inc - LDSCRIPT = targets/taranis/stm32f4_flash.ld + LDSCRIPT = targets/Taranis/stm32f4_flash.ld else STM32LIBPATH= $(THIRDPARTY)/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries CPPDEFS += -DEEPROM_VARIANT=0 INCDIRS += $(STM32LIBPATH)/STM32F2xx_StdPeriph_Driver/inc $(STM32LIBPATH)/CMSIS/Device/ST/STM32F2xx/Include $(STM32LIBPATH)/CMSIS/include - LDSCRIPT = targets/taranis/stm32f2_flash.ld + LDSCRIPT = targets/Taranis/stm32f2_flash.ld endif STM32USBPATH = $(THIRDPARTY)/STM32_USB-Host-Device_Lib_V2.1.0/Libraries INCDIRS += $(STM32USBPATH)/STM32_USB_OTG_Driver/inc @@ -951,19 +956,19 @@ ifeq ($(PCB), TARANIS) INCDIRS += $(STM32USBPATH)/STM32_USB_Device_Library/Class/hid/inc INCDIRS += $(STM32USBPATH)/STM32_USB_Device_Library/Class/cdc/inc GUIGENERALSRC += gui/$(GUIDIRECTORY)/menu_general_hardware.cpp - BOARDSRC = main_arm.cpp targets/taranis/board_taranis.cpp - EXTRABOARDSRC += targets/taranis/configure_pins.cpp targets/taranis/lcd_driver.cpp targets/taranis/flash_driver.cpp targets/taranis/i2c_driver.cpp targets/taranis/aspi.c targets/taranis/delays.c serial.cpp + BOARDSRC = main_arm.cpp targets/Taranis/board_taranis.cpp + EXTRABOARDSRC += targets/Taranis/configure_pins.cpp targets/Taranis/lcd_driver.cpp targets/Taranis/flash_driver.cpp targets/Taranis/i2c_driver.cpp targets/Taranis/aspi.c targets/Taranis/delays.c serial.cpp SRC += $(COOSDIR)/kernel/core.c $(COOSDIR)/kernel/hook.c $(COOSDIR)/kernel/task.c $(COOSDIR)/kernel/event.c $(COOSDIR)/kernel/time.c $(COOSDIR)/kernel/timer.c $(COOSDIR)/kernel/flag.c $(COOSDIR)/kernel/mutex.c $(COOSDIR)/kernel/serviceReq.c $(COOSDIR)/portable/GCC/port.c $(COOSDIR)/portable/arch.c - SRC += targets/taranis/pwr_driver.c targets/taranis/usb_driver.c - EEPROMSRC = eeprom_common.cpp eeprom_rlc.cpp eeprom_conversions.cpp + SRC += targets/Taranis/pwr_driver.c targets/Taranis/usb_driver.c + EEPROMSRC = storage/storage_common.cpp storage/eeprom_common.cpp storage/eeprom_rlc.cpp storage/eeprom_conversions.cpp PULSESSRC = pulses/pulses_arm.cpp pulses/ppm_arm.cpp pulses/pxx_arm.cpp CPPSRC += tasks_arm.cpp audio_arm.cpp sbus.cpp telemetry/telemetry.cpp - CPPSRC += targets/taranis/pulses_driver.cpp targets/taranis/keys_driver.cpp targets/taranis/adc_driver.cpp targets/taranis/trainer_driver.cpp targets/taranis/audio_driver.cpp targets/taranis/serial2_driver.cpp targets/taranis/telemetry_driver.cpp + CPPSRC += targets/Taranis/pulses_driver.cpp targets/Taranis/keys_driver.cpp targets/Taranis/adc_driver.cpp targets/Taranis/trainer_driver.cpp targets/Taranis/audio_driver.cpp targets/Taranis/serial2_driver.cpp targets/Taranis/telemetry_driver.cpp CPPSRC += bmp.cpp gui/$(GUIDIRECTORY)/view_channels.cpp gui/$(GUIDIRECTORY)/view_about.cpp gui/$(GUIDIRECTORY)/view_text.cpp debug.cpp CPPSRC += loadboot.cpp ifeq ($(PCBREV), REV9E) - CPPSRC += targets/taranis/top_lcd_driver.cpp - SRC += targets/taranis/system_stm32f4xx.c + CPPSRC += targets/Taranis/top_lcd_driver.cpp + SRC += targets/Taranis/system_stm32f4xx.c SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/misc.c SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dbgmcu.c @@ -976,7 +981,7 @@ ifeq ($(PCB), TARANIS) SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_usart.c SRC += $(STM32LIBPATH)/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc_ride7/startup_stm32f40_41xxx.s else - SRC += targets/taranis/system_stm32f2xx.c + SRC += targets/Taranis/system_stm32f2xx.c SRC += $(STM32LIBPATH)/STM32F2xx_StdPeriph_Driver/src/misc.c SRC += $(STM32LIBPATH)/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_gpio.c SRC += $(STM32LIBPATH)/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_dbgmcu.c @@ -989,29 +994,29 @@ ifeq ($(PCB), TARANIS) SRC += $(STM32LIBPATH)/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_usart.c SRC += $(STM32LIBPATH)/CMSIS/Device/ST/STM32F2xx/Source/Templates/gcc_ride7/startup_stm32f2xx.s endif - SRC += targets/taranis/usb_bsp.c targets/taranis/usbd_desc.c + SRC += targets/Taranis/usb_bsp.c targets/Taranis/usbd_desc.c SRC += $(STM32USBPATH)/STM32_USB_OTG_Driver/src/usb_core.c SRC += $(STM32USBPATH)/STM32_USB_OTG_Driver/src/usb_dcd.c SRC += $(STM32USBPATH)/STM32_USB_OTG_Driver/src/usb_dcd_int.c SRC += $(STM32USBPATH)/STM32_USB_Device_Library/Core/src/usbd_core.c SRC += $(STM32USBPATH)/STM32_USB_Device_Library/Core/src/usbd_ioreq.c SRC += $(STM32USBPATH)/STM32_USB_Device_Library/Core/src/usbd_req.c - EXTRABOARDSRC += targets/taranis/usbd_usr.cpp + EXTRABOARDSRC += targets/Taranis/usbd_usr.cpp SRC += syscalls.c ifeq ($(USB), JOYSTICK) CPPDEFS += -DUSB_JOYSTICK - SRC += targets/taranis/usbd_hid_joystick.c + SRC += targets/Taranis/usbd_hid_joystick.c else ifeq ($(USB), SERIAL) CPPDEFS += -DUSB_SERIAL SRC += $(STM32USBPATH)/STM32_USB_Device_Library/Class/cdc/src/usbd_cdc_core.c - EXTRABOARDSRC += targets/taranis/usbd_cdc.cpp + EXTRABOARDSRC += targets/Taranis/usbd_cdc.cpp else CPPDEFS += -DUSB_MASS_STORAGE SRC += $(STM32USBPATH)/STM32_USB_Device_Library/Class/msc/src/usbd_msc_data.c SRC += $(STM32USBPATH)/STM32_USB_Device_Library/Class/msc/src/usbd_msc_scsi.c SRC += $(STM32USBPATH)/STM32_USB_Device_Library/Class/msc/src/usbd_msc_bot.c SRC += $(STM32USBPATH)/STM32_USB_Device_Library/Class/msc/src/usbd_msc_core.c - EXTRABOARDSRC += targets/taranis/usbd_storage_msd.cpp + EXTRABOARDSRC += targets/Taranis/usbd_storage_msd.cpp endif ifeq ($(NANO), YES) # use newlib-nano for linking @@ -1033,14 +1038,14 @@ ifeq ($(PCB), TARANIS) $(LUADIR)/lobject.c $(LUADIR)/lopcodes.c $(LUADIR)/lparser.c $(LUADIR)/lstate.c $(LUADIR)/lstring.c $(LUADIR)/ltable.c $(LUADIR)/lrotable.c $(LUADIR)/ltm.c $(LUADIR)/lundump.c $(LUADIR)/lvm.c $(LUADIR)/lzio.c \ $(LUADIR)/lbaselib.c $(LUADIR)/linit.c $(LUADIR)/lmathlib.c $(LUADIR)/lbitlib.c $(LUADIR)/loadlib.c $(LUADIR)/lauxlib.c $(LUADIR)/ltablib.c $(LUADIR)/lcorolib.c $(LUADIR)/liolib.c SRC += $(LUASRC) - LUADEP = lua_exports.inc + LUADEP = lua/lua_exports_taranis.inc ifeq ($(USE_BIN_ALLOCATOR), YES) CPPDEFS += -DUSE_BIN_ALLOCATOR CPPSRC += bin_allocator.cpp endif endif - EXTRABOARDSRC += $(FATFSDIR)/ff.c $(FATFSDIR)/fattime.c $(FATFSDIR)/option/ccsbcs.c targets/taranis/diskio.cpp - CPPSRC += sdcard.cpp logs.cpp rtc.cpp targets/taranis/rtc_driver.cpp + EXTRABOARDSRC += $(FATFSDIR)/ff.c $(FATFSDIR)/fattime.c $(FATFSDIR)/option/ccsbcs.c targets/Taranis/diskio.cpp + CPPSRC += sdcard.cpp logs.cpp rtc.cpp targets/Taranis/rtc_driver.cpp GUIGENERALSRC += gui/$(GUIDIRECTORY)/menu_general_sdmanager.cpp gui/$(GUIDIRECTORY)/menu_general_diagkeys.cpp gui/$(GUIDIRECTORY)/menu_general_diaganas.cpp CPPDEFS += -DSDCARD -DVOICE -DRTCLOCK INCDIRS += $(FATFSDIR) $(FATFSDIR)/option @@ -1050,12 +1055,12 @@ ifeq ($(PCB), TARANIS) ifeq ($(HUBSAN), YES) CPPDEFS += -DHUBSAN CPPSRC += pulses/hubsan.cpp - CPPSRC += targets/taranis/a7105_driver.cpp + CPPSRC += targets/Taranis/a7105_driver.cpp endif ifeq ($(HAPTIC), YES) CPPDEFS += -DHAPTIC CPPSRC += haptic.cpp - CPPSRC += targets/taranis/haptic_driver.cpp + CPPSRC += targets/Taranis/haptic_driver.cpp endif ifeq ($(MIXERS_MONITOR), YES) CPPDEFS += -DMIXERS_MONITOR @@ -1065,6 +1070,246 @@ ifeq ($(PCB), TARANIS) endif endif +ifeq ($(PCB), FLAMENCO) + # FLAMENCO radio + ARCH = ARM + LCDSIZE = 320 + GUIDIRECTORY = Flamenco + FLAVOUR = FLAMENCO + LDSCRIPT = targets/Flamenco/stm32f4_flash.ld + STM32LIBPATH = $(THIRDPARTY)/STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries + STM32USBPATH = $(THIRDPARTY)/STM32_USB-Host-Device_Lib_V2.1.0/Libraries + TRGT = arm-none-eabi- + MCU = cortex-m4 + OPT = 2 + CPPDEFS += -DHSE_VALUE=12000000 -DCOLORLCD -DSTM32F40_41xxx + BITMAPS += $(patsubst %.png,%.lbm,$(wildcard bitmaps/Flamenco/*.png)) + FONTS = fonts/Flamenco/font_stdsize.lbm fonts/Flamenco/font_tinsize.lbm fonts/Flamenco/font_smlsize.lbm fonts/Flamenco/font_midsize.lbm fonts/Flamenco/font_dblsize.lbm fonts/Flamenco/font_xxlsize.lbm + SDCARD = YES + THR_TRACE = YES + EXT = FRSKY_SPORT + AUTOSWITCH = YES + AUTOSOURCE = YES + DBLKEYS = YES + PPM_LIMITS_SYMETRICAL = YES + PPM_CENTER_ADJUSTABLE = YES + DSM2 = PPM + 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 += $(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 + INCDIRS += $(STM32USBPATH)/STM32_USB_Device_Library/Core/inc + INCDIRS += $(STM32USBPATH)/STM32_USB_Device_Library/Class/msc/inc + INCDIRS += $(STM32USBPATH)/STM32_USB_Device_Library/Class/hid/inc + INCDIRS += $(STM32USBPATH)/STM32_USB_Device_Library/Class/cdc/inc + BOARDSRC = main_arm.cpp targets/Flamenco/board_flamenco.cpp + EXTRABOARDSRC += targets/Flamenco/lcd_driver.cpp targets/Flamenco/delays.c targets/Flamenco/i2c_driver.cpp targets/Taranis/configure_pins.cpp serial.cpp # targets/Taranis/flash_driver.cpp + SRC += $(COOSDIR)/kernel/core.c $(COOSDIR)/kernel/hook.c $(COOSDIR)/kernel/task.c $(COOSDIR)/kernel/event.c $(COOSDIR)/kernel/time.c $(COOSDIR)/kernel/timer.c $(COOSDIR)/kernel/flag.c $(COOSDIR)/kernel/mutex.c $(COOSDIR)/kernel/serviceReq.c $(COOSDIR)/portable/GCC/port.c $(COOSDIR)/portable/arch.c + SRC += targets/Flamenco/pwr_driver.c targets/Flamenco/usb_driver.c + EEPROMSRC = storage/storage_common.cpp storage/eeprom_common.cpp storage/eeprom_raw.cpp + PULSESSRC = pulses/pulses_arm.cpp pulses/ppm_arm.cpp pulses/pxx_arm.cpp + CPPSRC += tasks_arm.cpp audio_arm.cpp sbus.cpp telemetry/telemetry.cpp + CPPSRC += targets/Flamenco/tw8823_driver.cpp targets/Flamenco/pulses_driver.cpp targets/Flamenco/keys_driver.cpp targets/Flamenco/adc_driver.cpp targets/Flamenco/eeprom_driver.cpp targets/Flamenco/trainer_driver.cpp targets/Flamenco/audio_driver.cpp targets/Flamenco/serial2_driver.cpp targets/Flamenco/telemetry_driver.cpp + CPPSRC += gui/$(GUIDIRECTORY)/view_channels.cpp gui/$(GUIDIRECTORY)/view_about.cpp gui/$(GUIDIRECTORY)/view_text.cpp debug.cpp + SRC += targets/Flamenco/system_stm32f4xx.c + SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/misc.c + SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c + SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dbgmcu.c + SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rcc.c + SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_spi.c + SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_i2c.c + SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dma.c + SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rtc.c + SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_pwr.c + SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_usart.c + SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_sdio.c + SRC += $(STM32LIBPATH)/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc_ride7/startup_stm32f40_41xxx.s + SRC += targets/Flamenco/sdio_sd.c targets/Flamenco/usb_bsp.c targets/Flamenco/usbd_desc.c + SRC += $(STM32USBPATH)/STM32_USB_OTG_Driver/src/usb_core.c + SRC += $(STM32USBPATH)/STM32_USB_OTG_Driver/src/usb_dcd.c + SRC += $(STM32USBPATH)/STM32_USB_OTG_Driver/src/usb_dcd_int.c + SRC += $(STM32USBPATH)/STM32_USB_Device_Library/Core/src/usbd_core.c + SRC += $(STM32USBPATH)/STM32_USB_Device_Library/Core/src/usbd_ioreq.c + SRC += $(STM32USBPATH)/STM32_USB_Device_Library/Core/src/usbd_req.c + EXTRABOARDSRC += targets/Flamenco/usbd_usr.cpp + SRC += syscalls.c + ifeq ($(USB), JOYSTICK) + CPPDEFS += -DUSB_JOYSTICK + SRC += targets/Flamenco/usbd_hid_joystick.c + else + CPPDEFS += -DUSB_MASS_STORAGE + SRC += $(STM32USBPATH)/STM32_USB_Device_Library/Class/msc/src/usbd_msc_data.c + SRC += $(STM32USBPATH)/STM32_USB_Device_Library/Class/msc/src/usbd_msc_scsi.c + SRC += $(STM32USBPATH)/STM32_USB_Device_Library/Class/msc/src/usbd_msc_bot.c + SRC += $(STM32USBPATH)/STM32_USB_Device_Library/Class/msc/src/usbd_msc_core.c + EXTRABOARDSRC += targets/Flamenco/usbd_storage_msd.cpp + endif + ifeq ($(GVARS), YES) + GUIMODELSRC += gui/$(GUIDIRECTORY)/menu_model_gvars.cpp + endif + ifneq ($(LUA), NO) + ifeq ($(LUA), YES) + CPPDEFS += -DLUA_MODEL_SCRIPTS + endif + CPPDEFS += -DLUA + INCDIRS += $(LUADIR) + CPPSRC += lua_api.cpp + LUASRC = $(LUADIR)/lapi.c $(LUADIR)/lcode.c $(LUADIR)/lctype.c $(LUADIR)/ldebug.c $(LUADIR)/ldo.c $(LUADIR)/ldump.c $(LUADIR)/lfunc.c $(LUADIR)/lgc.c $(LUADIR)/llex.c $(LUADIR)/lmem.c \ + $(LUADIR)/lobject.c $(LUADIR)/lopcodes.c $(LUADIR)/lparser.c $(LUADIR)/lstate.c $(LUADIR)/lstring.c $(LUADIR)/ltable.c $(LUADIR)/lrotable.c $(LUADIR)/ltm.c $(LUADIR)/lundump.c $(LUADIR)/lvm.c $(LUADIR)/lzio.c \ + $(LUADIR)/lbaselib.c $(LUADIR)/linit.c $(LUADIR)/lmathlib.c $(LUADIR)/lbitlib.c $(LUADIR)/loadlib.c $(LUADIR)/lauxlib.c $(LUADIR)/ltablib.c $(LUADIR)/lcorolib.c $(LUADIR)/liolib.c + SRC += $(LUASRC) + LUADEP = lua/lua_exports_flamenco.inc + endif + + EXTRABOARDSRC += $(FATFSDIR)/ff.c $(FATFSDIR)/fattime.c $(FATFSDIR)/option/ccsbcs.c targets/Flamenco/diskio.cpp + CPPDEFS += -DSDCARD -DVOICE -DRTCLOCK + CPPSRC += sdcard.cpp rtc.cpp logs.cpp targets/Taranis/rtc_driver.cpp + GUIGENERALSRC += gui/$(GUIDIRECTORY)/menu_general_sdmanager.cpp + INCDIRS += $(FATFSDIR) $(FATFSDIR)/option + + ifeq ($(DSM2), PPM) + CPPSRC += pulses/dsm2_arm.cpp + endif + + CPPDEFS += -DHAPTIC + CPPSRC += haptic.cpp + CPPSRC += targets/Flamenco/haptic_driver.cpp + EXTRABOARDSRC += + + ifeq ($(TW8823_TRACES), YES) + CPPDEFS += -DTW8823_TRACES + endif + + ifeq ($(TW8823_BITMAPS), YES) + CPPDEFS += -DTW8823_BITMAPS + endif + + ifeq ($(TW8823_SERIAL), YES) + CPPDEFS += -DTW8823_SERIAL + endif +endif + +ifeq ($(PCB), HORUS) + # HORUS radio + ARCH = ARM + LCDSIZE = 480 + GUIDIRECTORY = Horus + FLAVOUR = HORUS + LDSCRIPT = targets/Horus/stm32f4_flash.ld + STM32LIBPATH = $(THIRDPARTY)/STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries + STM32USBPATH = $(THIRDPARTY)/STM32_USB-Host-Device_Lib_V2.1.0/Libraries + TRGT = arm-none-eabi- + MCU = cortex-m4 + OPT = 2 + CPPDEFS += -DHSE_VALUE=12000000 -DCOLORLCD -DSTM32F429_439xx + BITMAPS += $(patsubst %.png,%.lbm,$(wildcard bitmaps/Horus/*.png)) + FONTS = fonts/Horus/font_stdsize.lbm fonts/Horus/font_tinsize.lbm fonts/Horus/font_smlsize.lbm fonts/Horus/font_midsize.lbm fonts/Horus/font_dblsize.lbm fonts/Horus/font_xxlsize.lbm + SDCARD = YES + THR_TRACE = YES + EXT = FRSKY_SPORT + AUTOSWITCH = YES + AUTOSOURCE = YES + DBLKEYS = YES + PPM_LIMITS_SYMETRICAL = YES + PPM_CENTER_ADJUSTABLE = YES + DSM2 = PPM + 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 += $(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 + INCDIRS += $(STM32USBPATH)/STM32_USB_Device_Library/Core/inc + INCDIRS += $(STM32USBPATH)/STM32_USB_Device_Library/Class/msc/inc + INCDIRS += $(STM32USBPATH)/STM32_USB_Device_Library/Class/hid/inc + INCDIRS += $(STM32USBPATH)/STM32_USB_Device_Library/Class/cdc/inc + BOARDSRC = main_arm.cpp targets/Horus/board_horus.cpp targets/Horus/led_driver.cpp + EXTRABOARDSRC += targets/Horus/lcd_driver.cpp targets/Horus/delays.c targets/Horus/i2c_driver.cpp targets/Taranis/configure_pins.cpp serial.cpp # targets/Taranis/flash_driver.cpp + SRC += $(COOSDIR)/kernel/core.c $(COOSDIR)/kernel/hook.c $(COOSDIR)/kernel/task.c $(COOSDIR)/kernel/event.c $(COOSDIR)/kernel/time.c $(COOSDIR)/kernel/timer.c $(COOSDIR)/kernel/flag.c $(COOSDIR)/kernel/mutex.c $(COOSDIR)/kernel/serviceReq.c $(COOSDIR)/portable/GCC/port.c $(COOSDIR)/portable/arch.c + SRC += targets/Horus/pwr_driver.c targets/Horus/usb_driver.c targets/Horus/sdram_driver.c + PULSESSRC = pulses/pulses_arm.cpp pulses/ppm_arm.cpp pulses/pxx_arm.cpp + CPPSRC += tasks_arm.cpp audio_arm.cpp sbus.cpp telemetry/telemetry.cpp + CPPSRC += targets/Horus/pulses_driver.cpp targets/Horus/keys_driver.cpp targets/Horus/adc_driver.cpp targets/Horus/trainer_driver.cpp targets/Horus/audio_driver.cpp targets/Horus/serial2_driver.cpp targets/Horus/telemetry_driver.cpp + CPPSRC += bmp.cpp gui/$(GUIDIRECTORY)/bitmaps.cpp gui/$(GUIDIRECTORY)/view_channels.cpp gui/$(GUIDIRECTORY)/view_about.cpp gui/$(GUIDIRECTORY)/view_text.cpp debug.cpp + SRC += targets/Horus/system_stm32f4xx.c + CPPSRC += storage/storage_common.cpp storage/sdcard_raw.cpp + SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/misc.c + SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c + SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dbgmcu.c + SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rcc.c + SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_spi.c + SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_i2c.c + SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dma.c + SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rtc.c + SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_pwr.c + SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_usart.c + SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_sdio.c + SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_fmc.c + SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_ltdc.c + SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_tim.c + SRC += $(STM32LIBPATH)/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dma2d.c + SRC += $(STM32LIBPATH)/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc_ride7/startup_stm32f40_41xxx.s + SRC += targets/Horus/sdio_sd.c targets/Horus/usb_bsp.c targets/Horus/usbd_desc.c + SRC += $(STM32USBPATH)/STM32_USB_OTG_Driver/src/usb_core.c + SRC += $(STM32USBPATH)/STM32_USB_OTG_Driver/src/usb_dcd.c + SRC += $(STM32USBPATH)/STM32_USB_OTG_Driver/src/usb_dcd_int.c + SRC += $(STM32USBPATH)/STM32_USB_Device_Library/Core/src/usbd_core.c + SRC += $(STM32USBPATH)/STM32_USB_Device_Library/Core/src/usbd_ioreq.c + SRC += $(STM32USBPATH)/STM32_USB_Device_Library/Core/src/usbd_req.c + EXTRABOARDSRC += targets/Horus/usbd_usr.cpp + SRC += syscalls.c + ifeq ($(USB), JOYSTICK) + CPPDEFS += -DUSB_JOYSTICK + SRC += targets/Horus/usbd_hid_joystick.c + else ifeq ($(USB), SERIAL) + CPPDEFS += -DUSB_SERIAL + SRC += $(STM32USBPATH)/STM32_USB_Device_Library/Class/cdc/src/usbd_cdc_core.c + EXTRABOARDSRC += targets/Horus/usbd_cdc.cpp + else + CPPDEFS += -DUSB_MASS_STORAGE + SRC += $(STM32USBPATH)/STM32_USB_Device_Library/Class/msc/src/usbd_msc_data.c + SRC += $(STM32USBPATH)/STM32_USB_Device_Library/Class/msc/src/usbd_msc_scsi.c + SRC += $(STM32USBPATH)/STM32_USB_Device_Library/Class/msc/src/usbd_msc_bot.c + SRC += $(STM32USBPATH)/STM32_USB_Device_Library/Class/msc/src/usbd_msc_core.c + EXTRABOARDSRC += targets/Horus/usbd_storage_msd.cpp + endif + ifeq ($(GVARS), YES) + GUIMODELSRC += gui/$(GUIDIRECTORY)/menu_model_gvars.cpp + endif + ifneq ($(LUA), NO) + ifeq ($(LUA), YES) + CPPDEFS += -DLUA_MODEL_SCRIPTS + endif + CPPDEFS += -DLUA + INCDIRS += $(LUADIR) + CPPSRC += lua_api.cpp + LUASRC = $(LUADIR)/lapi.c $(LUADIR)/lcode.c $(LUADIR)/lctype.c $(LUADIR)/ldebug.c $(LUADIR)/ldo.c $(LUADIR)/ldump.c $(LUADIR)/lfunc.c $(LUADIR)/lgc.c $(LUADIR)/llex.c $(LUADIR)/lmem.c \ + $(LUADIR)/lobject.c $(LUADIR)/lopcodes.c $(LUADIR)/lparser.c $(LUADIR)/lstate.c $(LUADIR)/lstring.c $(LUADIR)/ltable.c $(LUADIR)/lrotable.c $(LUADIR)/ltm.c $(LUADIR)/lundump.c $(LUADIR)/lvm.c $(LUADIR)/lzio.c \ + $(LUADIR)/lbaselib.c $(LUADIR)/linit.c $(LUADIR)/lmathlib.c $(LUADIR)/lbitlib.c $(LUADIR)/loadlib.c $(LUADIR)/lauxlib.c $(LUADIR)/ltablib.c $(LUADIR)/lcorolib.c $(LUADIR)/liolib.c + SRC += $(LUASRC) + LUADEP = lua/lua_exports_horus.inc + endif + + EXTRABOARDSRC += $(FATFSDIR)/ff.c $(FATFSDIR)/fattime.c $(FATFSDIR)/option/ccsbcs.c targets/Horus/diskio.cpp + CPPDEFS += -DSDCARD -DVOICE -DRTCLOCK + CPPSRC += sdcard.cpp rtc.cpp logs.cpp targets/Taranis/rtc_driver.cpp + GUIGENERALSRC += gui/$(GUIDIRECTORY)/menu_general_sdmanager.cpp + INCDIRS += $(FATFSDIR) $(FATFSDIR)/option + + ifeq ($(DSM2), PPM) + CPPSRC += pulses/dsm2_arm.cpp + endif + + CPPDEFS += -DHAPTIC + CPPSRC += haptic.cpp + CPPSRC += targets/Horus/haptic_driver.cpp + EXTRABOARDSRC += +endif + CC = $(TRGT)gcc CPP = $(TRGT)cpp AS = $(TRGT)as @@ -1088,7 +1333,7 @@ FORMAT = ihex TARGET = opentx # List C++ source files here. (C dependencies are automatically generated.) -ifeq ($(PCB), $(filter $(PCB), SKY9X 9XRPRO AR9X TARANIS)) +ifeq ($(PCB), $(filter $(PCB), SKY9X 9XRPRO AR9X TARANIS FLAMENCO HORUS)) TTS_SRC = translations/tts_cz.cpp translations/tts_de.cpp translations/tts_en.cpp translations/tts_es.cpp translations/tts_fr.cpp translations/tts_it.cpp translations/tts_nl.cpp translations/tts_pt.cpp translations/tts_sk.cpp translations/tts_se.cpp translations/tts_pl.cpp translations/tts_hu.cpp else STD_TTS_SRC = translations/tts_$(shell sh -c "echo $(TTS) | tr '[:upper:]' '[:lower:]'").cpp @@ -1097,6 +1342,9 @@ endif ifeq ($(GUI), YES) GUISRC = gui/$(GUIDIRECTORY)/helpers.cpp gui/$(GUIDIRECTORY)/navigation.cpp gui/$(GUIDIRECTORY)/popups.cpp gui/$(GUIDIRECTORY)/widgets.cpp gui/$(GUIDIRECTORY)/menus.cpp $(GUIMODELSRC) $(GUIGENERALSRC) gui/$(GUIDIRECTORY)/view_main.cpp gui/$(GUIDIRECTORY)/view_statistics.cpp + ifeq ($(ARCH), ARM) + GUISRC += gui/gui_helpers.cpp + endif CPPDEFS += -DGUI endif @@ -1148,7 +1396,7 @@ ifeq ($(NAVIGATION), ROTENC) endif ifeq ($(TURNIGY_TRANSMITTER_FIX), YES) - ifeq ($(PCB), $(filter $(PCB), TARANIS)) + ifeq ($(PCB), $(filter $(PCB), TARANIS FLAMENCO HORUS)) $(warning TURNIGY_TRANSMITTER_FIX is not available on this radio) else CPPDEFS += -DMODULE_ALWAYS_SEND_PULSES @@ -1199,7 +1447,7 @@ ifeq ($(BOLD), YES) CPPDEFS += -DBOLD_FONT endif -ifneq ($(PCB), $(filter $(PCB), TARANIS)) +ifneq ($(PCB), $(filter $(PCB), TARANIS FLAMENCO HORUS)) ifeq ($(BATTGRAPH), YES) CPPDEFS += -DBATTGRAPH endif @@ -1333,13 +1581,16 @@ ifeq ($(SIMU), YES) CPPDEFS += -DDEBUG CPPSRC += dump.cpp else ifeq ($(CLI), YES) - CPPDEFS += -DCLI -DDEBUG + CPPDEFS += -DCLI CPPSRC += cli.cpp dump.cpp else ifeq ($(DEBUG), YES) - CPPDEFS += -DDEBUG CPPSRC += dump.cpp endif +ifeq ($(DEBUG), YES) + CPPDEFS += -DDEBUG +endif + ifeq ($(EEPROM_PROGRESS_BAR), YES) CPPDEFS += -DEEPROM_PROGRESS_BAR endif @@ -1393,7 +1644,7 @@ ifeq ($(HELI), YES) endif ifeq ($(TEMPLATES), YES) - ifneq ($(PCB), $(filter $(PCB), TARANIS)) + ifneq ($(PCB), $(filter $(PCB), TARANIS FLAMENCO HORUS)) CPPDEFS += -DTEMPLATES CPPSRC += templates.cpp GUIMODELSRC += gui/$(GUIDIRECTORY)/menu_model_templates.cpp @@ -1505,11 +1756,11 @@ endif # build bootloader ifeq ($(PCB), $(filter $(PCB), TARANIS)) -bootloader.lbm: targets/taranis/bootloader/bootloader_ramBoot.bin +bootloader.lbm: targets/Taranis/bootloader/bootloader_ramBoot.bin $(BIN2LBM) $^ $@ -.PHONY targets/taranis/bootloader/bootloader_ramBoot.bin: +.PHONY targets/Taranis/bootloader/bootloader_ramBoot.bin: @echo "Building bootloader..." - $(MAKE) -C targets/taranis/bootloader PCB=$(PCB) PCBREV=$(PCBREV) NANO=$(NANO) WARNINGS_AS_ERRORS=$(WARNINGS_AS_ERRORS) + $(MAKE) -C targets/Taranis/bootloader PCB=$(PCB) PCBREV=$(PCBREV) NANO=$(NANO) WARNINGS_AS_ERRORS=$(WARNINGS_AS_ERRORS) else ifeq ($(PCB), $(filter $(PCB), 9XRPRO AR9X)) bootloader.lbm: @echo "Fetching Mike's bootloader..." @@ -1600,30 +1851,57 @@ translations/se.h: translations/se.h.txt @echo "Create Swedish language specific header files" $(TRANSLATE) translations/se.h.txt translations/se.h se -FONTNAME = Roboto +ifeq ($(PCB), $(filter $(PCB), HORUS)) + FONTDIR = Horus + FONTNAME = DejaVu\ Sans + TINSIZE = 9 + SMLSIZE = 13 + STDSIZE = 16 + MIDSIZE = 24 + DBLSIZE = 32 + DBLBOLD = True + XXLSIZE = 48 + MASKFORMAT = 8bits +else + FONTDIR = Flamenco + FONTNAME = Roboto + TINSIZE = 5 + SMLSIZE = 7 + STDSIZE = 8 + MIDSIZE = 11 + DBLSIZE = 14 + DBLBOLD = False + XXLSIZE = 38 + MASKFORMAT = 4bits +endif .PHONY: fonts fonts: $(FONTS) +fonts/$(FONTDIR)/font_%size.lbm: fonts/$(FONTDIR)/font_%size.png + $(IMG2LBM) $^ $@ $(LCDSIZE) $(MASKFORMAT) + +fonts/$(FONTDIR)/font_tinsize.png: + $(FONT2PNG) $(FONTNAME) $(TINSIZE) False fonts/$(FONTDIR)/font_tinsize + +fonts/$(FONTDIR)/font_smlsize.png: + $(FONT2PNG) $(FONTNAME) $(SMLSIZE) False fonts/$(FONTDIR)/font_smlsize + +fonts/$(FONTDIR)/font_stdsize.png: + $(FONT2PNG) $(FONTNAME) $(STDSIZE) False fonts/$(FONTDIR)/font_stdsize + +fonts/$(FONTDIR)/font_midsize.png: + $(FONT2PNG) $(FONTNAME) $(MIDSIZE) False fonts/$(FONTDIR)/font_midsize + +fonts/$(FONTDIR)/font_dblsize.png: + $(FONT2PNG) $(FONTNAME) $(DBLSIZE) $(DBLBOLD) fonts/$(FONTDIR)/font_dblsize + +fonts/$(FONTDIR)/font_xxlsize.png: + $(FONT2PNG) $(FONTNAME) $(XXLSIZE) False fonts/$(FONTDIR)/font_xxlsize + fonts/%.lbm: fonts/%.png $(IMG2LBM) $^ $@ $(LCDSIZE) -fonts/font_tinsize.lbm: - $(FONT2PNG) $(FONTNAME) 5 fonts/font_tinsize.png - $(IMG2LBM) fonts/font_tinsize.png $@ $(LCDSIZE) 4bits - -fonts/font_stdsize.lbm: - $(FONT2PNG) $(FONTNAME) 8 fonts/font_stdsize.png - $(IMG2LBM) fonts/font_stdsize.png $@ $(LCDSIZE) 4bits - -fonts/font_midsize.lbm: - $(FONT2PNG) $(FONTNAME) 10 fonts/font_midsize.png - $(IMG2LBM) fonts/font_midsize.png $@ $(LCDSIZE) 4bits - -fonts/font_dblsize.lbm: - $(FONT2PNG) $(FONTNAME) 14 fonts/font_dblsize.png - $(IMG2LBM) fonts/font_dblsize.png $@ $(LCDSIZE) 4bits - .PHONY: bitmaps bitmaps: $(BITMAPS) @@ -1639,23 +1917,41 @@ bitmaps/Taranis/%.lbm: bitmaps/Taranis/%.png bitmaps/Taranis/mainmenu.png: ../util/taranisicons.py $(wildcard bitmaps/Taranis/std/*.png) @$(PYTHON) ../util/taranisicons.py +bitmaps/Flamenco/%.lbm: bitmaps/Flamenco/%.png + $(IMG2LBM) $^ $@ $(LCDSIZE) 4/4/4/4 + +bitmaps/Horus/mask_%.lbm: bitmaps/Horus/mask_%.png + $(IMG2LBM) $^ $@ $(LCDSIZE) $(MASKFORMAT) + +bitmaps/Horus/%.lbm: bitmaps/Horus/%.png + $(IMG2LBM) $^ $@ $(LCDSIZE) 5/6/5/8 + ifeq ($(OS),Windows_NT) PARSER = avr-cpp else PARSER = gcc -E -x c++ endif -.PHONY: lua_exports.inc -lua_exports.inc: lua/lua_exports.inc lua_fields.txt +lua/lua_exports_taranis.inc: myeeprom.h ../util/luaexport.py + @echo "Generating a list of Lua exported constants in lua_exports_taranis.txt" + @$(PARSER) -DPCBTARANIS -DCPUARM -DCPUSTM32 -DLUA -DEXPORT myeeprom.h | grep LEXP > lua_exports_taranis.txt + @echo "Parsing and generating C Lua exports in lua/lua_exports_taranis.inc" + @$(PYTHON) ../util/luaexport.py $(VERSION) lua_exports_taranis.txt lua/lua_exports_taranis.inc lua_fields_taranis.txt + @rm lua_exports_taranis.txt -lua/lua_exports.inc lua_fields.txt: lua_exports.dummy +lua/lua_exports_horus.inc: myeeprom.h ../util/luaexport.py + @echo "Generating a list of Lua exported constants in lua_exports_horus.txt" + @$(PARSER) -DPCBHORUS -DCPUARM -DCPUSTM32 -DLUA -DEXPORT myeeprom.h | grep LEXP > lua_exports_horus.txt + @echo "Parsing and generating C Lua exports in lua/lua_exports_horus.inc" + @$(PYTHON) ../util/luaexport.py $(VERSION) lua_exports_horus.txt lua/lua_exports_horus.inc lua_fields_horus.txt + @rm lua_exports_horus.txt -lua_exports.dummy: myeeprom.h ../util/luaexport.py - @echo "Generating a list of Lua exported constants in lua_exports.txt" - @$(PARSER) -DPCBTARANIS -DCPUARM -DCPUSTM32 -DLUA -DEXPORT myeeprom.h | grep LEXP > lua_exports.txt - @echo "Parsing and generating C Lua exports in lua/lua_exports.inc" - @$(PYTHON) ../util/luaexport.py $(VERSION) lua_exports.txt lua/lua_exports.inc lua_fields.txt - @rm lua_exports.txt +lua/lua_exports_flamenco.inc: myeeprom.h ../util/luaexport.py + @echo "Generating a list of Lua exported constants in lua_exports_flamenco.txt" + @$(PARSER) -DPCBFLAMENCO -DCPUARM -DCPUSTM32 -DLUA -DEXPORT myeeprom.h | grep LEXP > lua_exports_flamenco.txt + @echo "Parsing and generating C Lua exports in lua/lua_exports_flamenco.inc" + @$(PYTHON) ../util/luaexport.py $(VERSION) lua_exports_flamenco.txt lua/lua_exports_flamenco.inc lua_fields_flamenco.txt + @rm lua_exports_flamenco.txt # Eye candy. # AVR Studio 3.x does not check make's exit code but relies on @@ -1810,14 +2106,11 @@ clean_list : $(REMOVE) allsrc.cpp $(REMOVE) allsimusrc.cpp $(REMOVE) stamp-opentx.h - $(REMOVE) *.lbm $(REMOVE) bitmaps/*.lbm $(REMOVE) bitmaps/*/*.lbm - $(REMOVE) bitmaps/*/*/*.lbm - $(REMOVE) fonts/*.lbm $(REMOVE) fonts/*/*.lbm - $(REMOVE) lua_exports.txt lua/lua_exports.inc lua_fields.txt - $(MAKE) -C targets/taranis/bootloader clean + $(REMOVE) lua_exports*.txt lua_fields.txt lua/lua_exports*.inc + $(MAKE) -C targets/Taranis/bootloader clean #### Install diff --git a/radio/src/audio_arm.cpp b/radio/src/audio_arm.cpp index 23b9b4c39..b5494982e 100644 --- a/radio/src/audio_arm.cpp +++ b/radio/src/audio_arm.cpp @@ -152,8 +152,8 @@ const char * const audioFilenames[] = { "bye", "thralert", "swalert", - "eebad", - "eeformat", + "baddata", + "format", "lowbatt", "inactiv", "a1_org", @@ -189,7 +189,7 @@ const char * const audioFilenames[] = { "midstck2", "midstck3", "midstck4", -#if defined(PCBTARANIS) +#if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS) "midpot1", "midpot2", "midslid1", @@ -265,6 +265,8 @@ void referenceSystemAudioFiles() fn = *fno.lfname ? fno.lfname : fno.fname; uint8_t len = strlen(fn); + TRACE("%s", fn); + // Eliminates directories / non wav files if (len < 5 || strcasecmp(fn+len-4, SOUNDS_EXT) || (fno.fattrib & AM_DIR)) continue; @@ -288,7 +290,7 @@ char * getModelAudioPath(char * path) { strcpy(path, SOUNDS_PATH "/"); strncpy(path+SOUNDS_PATH_LNG_OFS, currentLanguagePack->id, 2); - char * result = strcat_modelname(path+sizeof(SOUNDS_PATH), g_eeGeneral.currModel); + char * result = strcat_currentmodelname(path+sizeof(SOUNDS_PATH)); *result++ = '/'; *result = '\0'; return result; @@ -510,7 +512,7 @@ void AudioQueue::start() #define CODEC_ID_PCM_ALAW 6 #define CODEC_ID_PCM_MULAW 7 -#ifndef SIMU +#if !defined(SIMU) void audioTask(void* pdata) { while (!audioQueue.started()) { @@ -519,7 +521,9 @@ void audioTask(void* pdata) setSampleRate(AUDIO_SAMPLE_RATE); -#if defined(SDCARD) +#if !defined(EEPROM) + AUDIO_TADA(); +#elif defined(SDCARD) if (!unexpectedShutdown) { sdInit(); AUDIO_TADA(); @@ -1096,7 +1100,7 @@ void audioEvent(unsigned int index, unsigned int freq) case AU_STICK4_MIDDLE: case AU_POT1_MIDDLE: case AU_POT2_MIDDLE: -#if defined(PCBTARANIS) +#if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS) case AU_SLIDER1_MIDDLE: case AU_SLIDER2_MIDDLE: #else diff --git a/radio/src/bitmaps/Horus/asterisk.png b/radio/src/bitmaps/Horus/asterisk.png new file mode 100644 index 000000000..1e12a2492 Binary files /dev/null and b/radio/src/bitmaps/Horus/asterisk.png differ diff --git a/radio/src/bitmaps/Horus/background.png b/radio/src/bitmaps/Horus/background.png new file mode 100644 index 000000000..02fa6695d Binary files /dev/null and b/radio/src/bitmaps/Horus/background.png differ diff --git a/radio/src/bitmaps/Horus/corsair.png b/radio/src/bitmaps/Horus/corsair.png new file mode 100644 index 000000000..25b6def09 Binary files /dev/null and b/radio/src/bitmaps/Horus/corsair.png differ diff --git a/radio/src/bitmaps/Horus/mainview_flat.png b/radio/src/bitmaps/Horus/mainview_flat.png new file mode 100644 index 000000000..44f8ca652 Binary files /dev/null and b/radio/src/bitmaps/Horus/mainview_flat.png differ diff --git a/radio/src/bitmaps/Horus/mask_analogs.png b/radio/src/bitmaps/Horus/mask_analogs.png new file mode 100644 index 000000000..96fc0c8a2 Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_analogs.png differ diff --git a/radio/src/bitmaps/Horus/mask_calibration.png b/radio/src/bitmaps/Horus/mask_calibration.png new file mode 100644 index 000000000..db696778b Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_calibration.png differ diff --git a/radio/src/bitmaps/Horus/mask_current_bg.png b/radio/src/bitmaps/Horus/mask_current_bg.png new file mode 100644 index 000000000..715792023 Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_current_bg.png differ diff --git a/radio/src/bitmaps/Horus/mask_current_dot.png b/radio/src/bitmaps/Horus/mask_current_dot.png new file mode 100644 index 000000000..6f76965a9 Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_current_dot.png differ diff --git a/radio/src/bitmaps/Horus/mask_current_shadow.png b/radio/src/bitmaps/Horus/mask_current_shadow.png new file mode 100644 index 000000000..4632c601f Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_current_shadow.png differ diff --git a/radio/src/bitmaps/Horus/mask_curves.png b/radio/src/bitmaps/Horus/mask_curves.png new file mode 100644 index 000000000..6e1e19e8e Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_curves.png differ diff --git a/radio/src/bitmaps/Horus/mask_cvpoint.png b/radio/src/bitmaps/Horus/mask_cvpoint.png new file mode 100644 index 000000000..48f9609db Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_cvpoint.png differ diff --git a/radio/src/bitmaps/Horus/mask_cvpoint_center.png b/radio/src/bitmaps/Horus/mask_cvpoint_center.png new file mode 100644 index 000000000..e3dac7b20 Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_cvpoint_center.png differ diff --git a/radio/src/bitmaps/Horus/mask_dot.png b/radio/src/bitmaps/Horus/mask_dot.png new file mode 100644 index 000000000..55a92e79e Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_dot.png differ diff --git a/radio/src/bitmaps/Horus/mask_flight_modes.png b/radio/src/bitmaps/Horus/mask_flight_modes.png new file mode 100644 index 000000000..e963f0abb Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_flight_modes.png differ diff --git a/radio/src/bitmaps/Horus/mask_global_functions.png b/radio/src/bitmaps/Horus/mask_global_functions.png new file mode 100644 index 000000000..3b3efefb5 Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_global_functions.png differ diff --git a/radio/src/bitmaps/Horus/mask_gvars.png b/radio/src/bitmaps/Horus/mask_gvars.png new file mode 100644 index 000000000..0b5015dac Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_gvars.png differ diff --git a/radio/src/bitmaps/Horus/mask_hardware.png b/radio/src/bitmaps/Horus/mask_hardware.png new file mode 100644 index 000000000..f51a1aee1 Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_hardware.png differ diff --git a/radio/src/bitmaps/Horus/mask_heli.png b/radio/src/bitmaps/Horus/mask_heli.png new file mode 100644 index 000000000..ecd93d2ff Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_heli.png differ diff --git a/radio/src/bitmaps/Horus/mask_htrim_frame.png b/radio/src/bitmaps/Horus/mask_htrim_frame.png new file mode 100644 index 000000000..964827b53 Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_htrim_frame.png differ diff --git a/radio/src/bitmaps/Horus/mask_inputs.png b/radio/src/bitmaps/Horus/mask_inputs.png new file mode 100644 index 000000000..720099c47 Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_inputs.png differ diff --git a/radio/src/bitmaps/Horus/mask_library.png b/radio/src/bitmaps/Horus/mask_library.png new file mode 100644 index 000000000..237883fc5 Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_library.png differ diff --git a/radio/src/bitmaps/Horus/mask_library_active_model.png b/radio/src/bitmaps/Horus/mask_library_active_model.png new file mode 100644 index 000000000..a4bd20f3c Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_library_active_model.png differ diff --git a/radio/src/bitmaps/Horus/mask_library_category_index.png b/radio/src/bitmaps/Horus/mask_library_category_index.png new file mode 100644 index 000000000..da2fd5bd6 Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_library_category_index.png differ diff --git a/radio/src/bitmaps/Horus/mask_library_score_0.png b/radio/src/bitmaps/Horus/mask_library_score_0.png new file mode 100644 index 000000000..18c9cc063 Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_library_score_0.png differ diff --git a/radio/src/bitmaps/Horus/mask_library_score_1.png b/radio/src/bitmaps/Horus/mask_library_score_1.png new file mode 100644 index 000000000..001e32d20 Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_library_score_1.png differ diff --git a/radio/src/bitmaps/Horus/mask_library_slot.png b/radio/src/bitmaps/Horus/mask_library_slot.png new file mode 100644 index 000000000..d53131e3c Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_library_slot.png differ diff --git a/radio/src/bitmaps/Horus/mask_library_star_0.png b/radio/src/bitmaps/Horus/mask_library_star_0.png new file mode 100644 index 000000000..506a36abe Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_library_star_0.png differ diff --git a/radio/src/bitmaps/Horus/mask_library_star_1.png b/radio/src/bitmaps/Horus/mask_library_star_1.png new file mode 100644 index 000000000..bcefd5314 Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_library_star_1.png differ diff --git a/radio/src/bitmaps/Horus/mask_logical_switches.png b/radio/src/bitmaps/Horus/mask_logical_switches.png new file mode 100644 index 000000000..5cd1e3834 Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_logical_switches.png differ diff --git a/radio/src/bitmaps/Horus/mask_lua_scripts.png b/radio/src/bitmaps/Horus/mask_lua_scripts.png new file mode 100644 index 000000000..a20c1ccbd Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_lua_scripts.png differ diff --git a/radio/src/bitmaps/Horus/mask_menu_model.png b/radio/src/bitmaps/Horus/mask_menu_model.png new file mode 100644 index 000000000..9832267b7 Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_menu_model.png differ diff --git a/radio/src/bitmaps/Horus/mask_menu_radio.png b/radio/src/bitmaps/Horus/mask_menu_radio.png new file mode 100644 index 000000000..6d93fbccc Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_menu_radio.png differ diff --git a/radio/src/bitmaps/Horus/mask_mixer.png b/radio/src/bitmaps/Horus/mask_mixer.png new file mode 100644 index 000000000..009b360f1 Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_mixer.png differ diff --git a/radio/src/bitmaps/Horus/mask_model_setup.png b/radio/src/bitmaps/Horus/mask_model_setup.png new file mode 100644 index 000000000..afe526c8f Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_model_setup.png differ diff --git a/radio/src/bitmaps/Horus/mask_noscale_ico.png b/radio/src/bitmaps/Horus/mask_noscale_ico.png new file mode 100644 index 000000000..7038d41c8 Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_noscale_ico.png differ diff --git a/radio/src/bitmaps/Horus/mask_outputs.png b/radio/src/bitmaps/Horus/mask_outputs.png new file mode 100644 index 000000000..a209ae8d3 Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_outputs.png differ diff --git a/radio/src/bitmaps/Horus/mask_point.png b/radio/src/bitmaps/Horus/mask_point.png new file mode 100644 index 000000000..bb161021e Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_point.png differ diff --git a/radio/src/bitmaps/Horus/mask_radio_setup.png b/radio/src/bitmaps/Horus/mask_radio_setup.png new file mode 100644 index 000000000..0010a06ab Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_radio_setup.png differ diff --git a/radio/src/bitmaps/Horus/mask_rscale.png b/radio/src/bitmaps/Horus/mask_rscale.png new file mode 100644 index 000000000..967766871 Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_rscale.png differ diff --git a/radio/src/bitmaps/Horus/mask_sd_browser.png b/radio/src/bitmaps/Horus/mask_sd_browser.png new file mode 100644 index 000000000..75b6a9296 Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_sd_browser.png differ diff --git a/radio/src/bitmaps/Horus/mask_special_functions.png b/radio/src/bitmaps/Horus/mask_special_functions.png new file mode 100644 index 000000000..a12a2a50d Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_special_functions.png differ diff --git a/radio/src/bitmaps/Horus/mask_switches.png b/radio/src/bitmaps/Horus/mask_switches.png new file mode 100644 index 000000000..4097ed751 Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_switches.png differ diff --git a/radio/src/bitmaps/Horus/mask_telemetry.png b/radio/src/bitmaps/Horus/mask_telemetry.png new file mode 100644 index 000000000..d95d3b25f Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_telemetry.png differ diff --git a/radio/src/bitmaps/Horus/mask_timer_bg.png b/radio/src/bitmaps/Horus/mask_timer_bg.png new file mode 100644 index 000000000..e8d000e78 Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_timer_bg.png differ diff --git a/radio/src/bitmaps/Horus/mask_topmenu_altitude_ico.png b/radio/src/bitmaps/Horus/mask_topmenu_altitude_ico.png new file mode 100644 index 000000000..b51eaf71a Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_topmenu_altitude_ico.png differ diff --git a/radio/src/bitmaps/Horus/mask_topmenu_masterpart_ico.png b/radio/src/bitmaps/Horus/mask_topmenu_masterpart_ico.png new file mode 100644 index 000000000..1da37a42e Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_topmenu_masterpart_ico.png differ diff --git a/radio/src/bitmaps/Horus/mask_topmenu_opentx.png b/radio/src/bitmaps/Horus/mask_topmenu_opentx.png new file mode 100644 index 000000000..df2b0b356 Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_topmenu_opentx.png differ diff --git a/radio/src/bitmaps/Horus/mask_topmenu_polygon.png b/radio/src/bitmaps/Horus/mask_topmenu_polygon.png new file mode 100644 index 000000000..603bfe1cf Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_topmenu_polygon.png differ diff --git a/radio/src/bitmaps/Horus/mask_topmenu_sdcard.png b/radio/src/bitmaps/Horus/mask_topmenu_sdcard.png new file mode 100644 index 000000000..875f14be4 Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_topmenu_sdcard.png differ diff --git a/radio/src/bitmaps/Horus/mask_topmenu_slavepart_ico.png b/radio/src/bitmaps/Horus/mask_topmenu_slavepart_ico.png new file mode 100644 index 000000000..db6eb756c Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_topmenu_slavepart_ico.png differ diff --git a/radio/src/bitmaps/Horus/mask_topmenu_usb.png b/radio/src/bitmaps/Horus/mask_topmenu_usb.png new file mode 100644 index 000000000..92272dd56 Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_topmenu_usb.png differ diff --git a/radio/src/bitmaps/Horus/mask_topmenu_volume_ico.png b/radio/src/bitmaps/Horus/mask_topmenu_volume_ico.png new file mode 100644 index 000000000..01afa66b2 Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_topmenu_volume_ico.png differ diff --git a/radio/src/bitmaps/Horus/mask_trainer.png b/radio/src/bitmaps/Horus/mask_trainer.png new file mode 100644 index 000000000..7a0b56970 Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_trainer.png differ diff --git a/radio/src/bitmaps/Horus/mask_trim_shadow.png b/radio/src/bitmaps/Horus/mask_trim_shadow.png new file mode 100644 index 000000000..4870e77e3 Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_trim_shadow.png differ diff --git a/radio/src/bitmaps/Horus/mask_version.png b/radio/src/bitmaps/Horus/mask_version.png new file mode 100644 index 000000000..8730f6c1a Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_version.png differ diff --git a/radio/src/bitmaps/Horus/mask_vtrim_frame.png b/radio/src/bitmaps/Horus/mask_vtrim_frame.png new file mode 100644 index 000000000..bf0f329f0 Binary files /dev/null and b/radio/src/bitmaps/Horus/mask_vtrim_frame.png differ diff --git a/radio/src/bitmaps/Horus/splash.png b/radio/src/bitmaps/Horus/splash.png new file mode 100644 index 000000000..1ed7a9ae9 Binary files /dev/null and b/radio/src/bitmaps/Horus/splash.png differ diff --git a/radio/src/bmp.cpp b/radio/src/bmp.cpp index 7051e4703..7dc7edc54 100644 --- a/radio/src/bmp.cpp +++ b/radio/src/bmp.cpp @@ -36,7 +36,8 @@ #include "opentx.h" -const pm_char * bmpLoad(uint8_t *bmp, const char *filename, const unsigned int width, const unsigned int height) +#if defined(PCBTARANIS) +const char * bmpLoad(uint8_t * bmp, const char * filename, uint16_t width, uint16_t height) { FIL bmpFile; UINT read; @@ -203,6 +204,177 @@ const pm_char * bmpLoad(uint8_t *bmp, const char *filename, const unsigned int w f_close(&bmpFile); return 0; } +#elif defined(PCBHORUS) +const char * bmpLoad(uint8_t * bmp, const char * filename, uint16_t width, uint16_t height) +{ + FIL bmpFile; + UINT read; + uint8_t palette[16]; + uint8_t bmpBuf[LCD_W]; /* maximum with LCD_W */ + uint8_t *buf = &bmpBuf[0]; + + if (width > LCD_W) { + return STR_INCOMPATIBLE; + } + + FRESULT result = f_open(&bmpFile, filename, FA_OPEN_EXISTING | FA_READ); + if (result != FR_OK) { + return SDCARD_ERROR(result); + } + + if (f_size(&bmpFile) < 14) { + f_close(&bmpFile); + return STR_INCOMPATIBLE; + } + + result = f_read(&bmpFile, buf, 14, &read); + if (result != FR_OK || read != 14) { + f_close(&bmpFile); + return SDCARD_ERROR(result); + } + + if (buf[0] != 'B' || buf[1] != 'M') { + f_close(&bmpFile); + return STR_INCOMPATIBLE; + } + + uint32_t fsize = *((uint32_t *)&buf[2]); + uint32_t hsize = *((uint32_t *)&buf[10]); /* header size */ + + uint32_t len = limit((uint32_t)4, (uint32_t)(hsize-14), (uint32_t)32); + result = f_read(&bmpFile, buf, len, &read); + if (result != FR_OK || read != len) { + f_close(&bmpFile); + return SDCARD_ERROR(result); + } + + uint32_t ihsize = *((uint32_t *)&buf[0]); /* more header size */ + + /* invalid header size */ + if (ihsize + 14 > hsize) { + f_close(&bmpFile); + return STR_INCOMPATIBLE; + } + + /* sometimes file size is set to some headers size, set a real size in that case */ + if (fsize == 14 || fsize == ihsize + 14) + fsize = f_size(&bmpFile) - 2; + + /* declared file size less than header size */ + if (fsize <= hsize) { + f_close(&bmpFile); + return STR_INCOMPATIBLE; + } + + uint32_t w, h; + + switch (ihsize){ + case 40: // windib + case 56: // windib v3 + case 64: // OS/2 v2 + case 108: // windib v4 + case 124: // windib v5 + w = *((uint32_t *)&buf[4]); + h = *((uint32_t *)&buf[8]); + buf += 12; + break; + case 12: // OS/2 v1 + w = *((uint16_t *)&buf[4]); + h = *((uint16_t *)&buf[6]); + buf += 8; + break; + default: + f_close(&bmpFile); + return STR_INCOMPATIBLE; + } + + if (*((uint16_t *)&buf[0]) != 1) { /* planes */ + f_close(&bmpFile); + return STR_INCOMPATIBLE; + } + + if (w > width || h > height) { + f_close(&bmpFile); + return STR_INCOMPATIBLE; + } + + uint16_t depth = *((uint16_t *)&buf[2]); + + buf = &bmpBuf[0]; + + if (depth == 4) { + if (f_lseek(&bmpFile, hsize-64) != FR_OK || f_read(&bmpFile, buf, 64, &read) != FR_OK || read != 64) { + f_close(&bmpFile); + return SDCARD_ERROR(result); + } + for (uint8_t i=0; i<16; i++) { + palette[i] = buf[4*i]; + } + } + else { + if (f_lseek(&bmpFile, hsize) != FR_OK) { + f_close(&bmpFile); + return SDCARD_ERROR(result); + } + } + + uint16_t * dest = (uint16_t *)bmp; + + *dest++ = w; + *dest++ = h; + + memset(dest, 0, BITMAP_BUFFER_SIZE(w, h) - 4); + + uint32_t rowSize; + + switch (depth) { + case 32: + for (int i=h-1; i>=0; i--) { + uint8_t * dst = ((uint8_t *)dest) + i*w*2; + for (unsigned int j=0; j>24) & 0xff, (pixel>>16) & 0xff, (pixel>>8) & 0xff); + dst += 2; + } + } + break; + + case 1: + break; + + case 4: + rowSize = ((4*w+31)/32)*4; + for (int32_t i=h-1; i>=0; i--) { + result = f_read(&bmpFile, buf, rowSize, &read); + if (result != FR_OK || read != rowSize) { + f_close(&bmpFile); + return SDCARD_ERROR(result); + } + uint8_t * dst = ((uint8_t *)dest) + i*w*2; + for (uint32_t j=0; j> ((j & 1) ? 0 : 4)) & 0x0F; + uint8_t val = palette[index]; + *((uint16_t *)dst) = RGB(val, val, val); + dst += 2; + // *dst++ = 0x0F; + } + } + break; + + default: + f_close(&bmpFile); + return STR_INCOMPATIBLE; + } + + f_close(&bmpFile); + return 0; +} +#endif const uint8_t bmpHeader[] = { 0x42, 0x4d, 0xF8, 0x1A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x00, 0x00, 0x00, 0x28, 0x00, @@ -228,23 +400,19 @@ const char *writeScreenshot() FIL bmpFile; UINT written; char filename[42]; // /SCREENSHOTS/screen-2013-01-01-123540.bmp - DIR folder; // check and create folder here strcpy_P(filename, SCREENSHOTS_PATH); - FRESULT result = f_opendir(&folder, filename); - if (result != FR_OK) { - if (result == FR_NO_PATH) - result = f_mkdir(filename); - if (result != FR_OK) - return SDCARD_ERROR(result); + const char * error = sdCheckAndCreateDirectory(filename); + if (error) { + return error; } - char *tmp = strAppend(&filename[sizeof(SCREENSHOTS_PATH)-1], "/screen"); + char * tmp = strAppend(&filename[sizeof(SCREENSHOTS_PATH)-1], "/screen"); tmp = strAppendDate(tmp, true); strcpy(tmp, BITMAPS_EXT); - result = f_open(&bmpFile, filename, FA_CREATE_ALWAYS | FA_WRITE); + FRESULT result = f_open(&bmpFile, filename, FA_CREATE_ALWAYS | FA_WRITE); if (result != FR_OK) { return SDCARD_ERROR(result); } diff --git a/radio/src/buzzer.h b/radio/src/buzzer.h index 2a451b6fa..8bb0b8463 100644 --- a/radio/src/buzzer.h +++ b/radio/src/buzzer.h @@ -65,7 +65,7 @@ inline void _beep(uint8_t b) void beep(uint8_t val); #else /* BUZZER */ -#define beep(...) +inline void beep(uint8_t) { } #endif /* BUZZER */ #if !defined(AUDIO) diff --git a/radio/src/cli.cpp b/radio/src/cli.cpp index ac1b2407d..76dbc244f 100644 --- a/radio/src/cli.cpp +++ b/radio/src/cli.cpp @@ -43,9 +43,13 @@ OS_TID cliTaskId; TaskStack cliStack; Fifo<256> cliRxFifo; -uint8_t cliTracesEnabled = false; +uint8_t cliTracesEnabled = true; +// char cliLastLine[CLI_COMMAND_MAX_LEN+1]; typedef int (* CliFunction) (const char ** args); +int cliExecLine(char * line); +int cliExecCommand(const char ** argv); +int cliHelp(const char ** argv); struct CliCommand { @@ -66,7 +70,7 @@ void cliPrompt() serialPutc('>'); } -int toInt(const char ** argv, int index, int * val) +int toLongLongInt(const char ** argv, int index, long long int * val) { if (*argv[index] == '\0') { return 0; @@ -79,7 +83,7 @@ int toInt(const char ** argv, int index, int * val) s = &argv[index][2]; } char * endptr = NULL; - *val = strtol(s, &endptr, base); + *val = strtoll(s, &endptr, base); if (*endptr == '\0') return 1; else { @@ -89,6 +93,14 @@ int toInt(const char ** argv, int index, int * val) } } +int toInt(const char ** argv, int index, int * val) +{ + long long int lval = 0; + int result = toLongLongInt(argv, index, &lval); + *val = (int)lval; + return result; +} + int cliBeep(const char ** argv) { int freq = BEEP_DEFAULT_FREQ; @@ -152,39 +164,11 @@ int cliTrace(const char ** argv) int cliStackInfo(const char ** argv) { - int tid = 0; - if (toInt(argv, 1, &tid) > 0) { - int available = 0; - int total = 0; - switch(tid) { - case MENU_TASK_INDEX: - total = menusStack.size(); - available = menusStack.available(); - break; - case MIXER_TASK_INDEX: - total = mixerStack.size(); - available = mixerStack.available(); - break; - case AUDIO_TASK_INDEX: - total = audioStack.size(); - available = audioStack.available(); - break; - case CLI_TASK_INDEX: - total = cliStack.size(); - available = cliStack.available(); - break; - case MAIN_TASK_INDEX: - total = stackSize() * 4; - available = stackAvailable(); - break; - default: - break; - } - serialPrint("%d available (%d total)", available, total); - } - else { - serialPrint("%s: Invalid argument \"%s\"", argv[0], argv[1]); - } + serialPrint("[MAIN] %d available / %d", stackAvailable(), stackSize()); + serialPrint("[MENUS] %d available / %d", menusStack.available(), menusStack.size()); + serialPrint("[MIXER] %d available / %d", mixerStack.available(), mixerStack.size()); + serialPrint("[AUDIO] %d available / %d", audioStack.available(), audioStack.size()); + serialPrint("[CLI] %d available / %d", cliStack.available(), cliStack.size()); return 0; } @@ -200,6 +184,33 @@ int cliVolume(const char ** argv) return 0; } +#if defined(PCBFLAMENCO) +int cliReadBQ24195(const char ** argv) +{ + int index = 0; + if (toInt(argv, 1, &index) > 0) { + serialPrint("BQ24195[%d] = 0x%02x", index, i2cReadBQ24195(index)); + } + else { + serialPrint("%s: Invalid arguments \"%s\" \"%s\"", argv[0], argv[1]); + } + return 0; +} + +int cliWriteBQ24195(const char ** argv) +{ + int index = 0; + int data = 0; + if (toInt(argv, 1, &index) > 0 && toInt(argv, 2, &data) > 0) { + i2cWriteBQ24195(index, data); + } + else { + serialPrint("%s: Invalid arguments \"%s\" \"%s\"", argv[0], argv[1], argv[2]); + } + return 0; +} +#endif + const MemArea memAreas[] = { { "RCC", RCC, sizeof(RCC_TypeDef) }, { "GPIOA", GPIOA, sizeof(GPIO_TypeDef) }, @@ -210,13 +221,14 @@ const MemArea memAreas[] = { { "GPIOF", GPIOF, sizeof(GPIO_TypeDef) }, { "GPIOG", GPIOG, sizeof(GPIO_TypeDef) }, { "USART1", USART1, sizeof(USART_TypeDef) }, + { "USART2", USART2, sizeof(USART_TypeDef) }, { "USART3", USART3, sizeof(USART_TypeDef) }, { NULL, NULL, 0 }, }; int cliDisplay(const char ** argv) { - int address = 0; + long long int address = 0; for (const MemArea * area = memAreas; area->name != NULL; area++) { if (!strcmp(area->name, argv[1])) { @@ -225,9 +237,30 @@ int cliDisplay(const char ** argv) } } - if (!strcmp(argv[1], "adc")) { + if (!strcmp(argv[1], "keys")) { + for (int i=0; i 0) { +#if defined(PCBFLAMENCO) + else if (!strcmp(argv[1], "bq24195")) { + { + uint8_t reg = i2cReadBQ24195(0x00); + serialPrint(reg & 0x80 ? "HIZ enable" : "HIZ disable"); + } + { + uint8_t reg = i2cReadBQ24195(0x08); + serialPrint(reg & 0x01 ? "VBatt < VSysMin" : "VBatt > VSysMin"); + serialPrint(reg & 0x02 ? "Thermal sensor bad" : "Thermal sensor ok"); + serialPrint(reg & 0x04 ? "Power ok" : "Power bad"); + serialPrint(reg & 0x08 ? "Connected to charger" : "Not connected to charger"); + const char * CHARGE_STATUS[] = { "Not Charging", "Precharge", "Fast Charging", "Charge done" }; + serialPrint(CHARGE_STATUS[(reg & 0x30) >> 4]); + const char * INPUT_STATUS[] = { "Unknown input", "USB host input", "USB adapter port input", "OTG input" }; + serialPrint(INPUT_STATUS[(reg & 0xC0) >> 6]); + } + { + uint8_t reg = i2cReadBQ24195(0x09); + if (reg & 0x80) serialPrint("Watchdog timer expiration"); + uint8_t chargerFault = (reg & 0x30) >> 4; + if (chargerFault == 0x01) + serialPrint("Input fault"); + else if (chargerFault == 0x02) + serialPrint("Thermal shutdown"); + else if (chargerFault == 0x03) + serialPrint("Charge safety timer expiration"); + if (reg & 0x08) serialPrint("Battery over voltage fault"); + uint8_t ntcFault = (reg & 0x07); + if (ntcFault == 0x05) + serialPrint("NTC cold"); + else if (ntcFault == 0x06) + serialPrint("NTC hot"); + } + } +#endif + else if (toLongLongInt(argv, 1, &address) > 0) { int size = 256; if (toInt(argv, 2, &size) >= 0) { dump((uint8_t *)address, size); @@ -249,17 +318,56 @@ int cliDisplay(const char ** argv) return 0; } -int cliHelp(const char ** argv); +int cliDebugVars(const char ** argv) +{ +#if defined(PCBHORUS) + extern unsigned int ioMutexReq, ioMutexRel; + extern unsigned int sdReadRetries; + + serialPrint("ioMutexReq=%d", ioMutexReq); + serialPrint("ioMutexRel=%d", ioMutexRel); + serialPrint("sdReadRetries=%d", sdReadRetries); +#endif + return 0; +} + +int cliRepeat(const char ** argv) +{ + int interval = 0; + int counter = 0; + if (toInt(argv, 1, &interval) > 0 && argv[2]) { + interval *= 50; + counter = interval; + uint8_t c; + while (!cliRxFifo.pop(c) || !(c == '\r' || c == '\n' || c == ' ')) { + CoTickDelay(10); // 20ms + if (++counter >= interval) { + cliExecCommand(&argv[2]); + counter = 0; + } + } + } + else { + serialPrint("%s: Invalid arguments", argv[0]); + } + return 0; +} const CliCommand cliCommands[] = { { "beep", cliBeep, "[] []" }, { "ls", cliLs, "" }, { "play", cliPlay, "" }, { "print", cliDisplay, "
[] | " }, - { "stackinfo", cliStackInfo, "" }, + { "stackinfo", cliStackInfo, "" }, { "trace", cliTrace, "on | off" }, { "volume", cliVolume, "" }, +#if defined(PCBFLAMENCO) + { "read_bq24195", cliReadBQ24195, "" }, + { "write_bq24195", cliWriteBQ24195, " " }, +#endif { "help", cliHelp, "[]" }, + { "debugvars", cliDebugVars, "" }, + { "repeat", cliRepeat, " " }, { NULL, NULL, NULL } /* sentinel */ }; @@ -341,6 +449,7 @@ void cliTask(void * pdata) // enter serialCrlf(); line[pos] = '\0'; + // strcpy(cliLastLine, line); cliExecLine(line); pos = 0; cliPrompt(); diff --git a/radio/src/cli.h b/radio/src/cli.h index 83836eeef..5a57f7755 100644 --- a/radio/src/cli.h +++ b/radio/src/cli.h @@ -50,5 +50,7 @@ extern TaskStack cliStack; #endif void cliStart(); +void cliStackPaint(); +uint32_t cliStackFree(); #endif // _CLI_H_ diff --git a/radio/src/debug.h b/radio/src/debug.h index 0832db330..db2591144 100644 --- a/radio/src/debug.h +++ b/radio/src/debug.h @@ -78,6 +78,14 @@ void debugPrintf(const char * format, ...); #define TRACE_WARNING_WP(...) debugPrintf(__VA_ARGS__) #define TRACE_ERROR(...) debugPrintf("-E- " __VA_ARGS__) +#if defined(DEBUG) && !defined(SIMU) +#define TIME_MEASURE_START(id) uint16_t t0 ## id = getTmr2MHz() +#define TIME_MEASURE_STOP(id) TRACE("Measure(" # id ") = %.1fus", float((uint16_t)(getTmr2MHz() - t0 ## id))/2) +#else +#define TIME_MEASURE_START(id) +#define TIME_MEASURE_STOP(id) +#endif + #if defined(DEBUG_TRACE_BUFFER) #define TRACE_BUFFER_LEN 50 diff --git a/radio/src/fifo.h b/radio/src/fifo.h index 18a1d478a..312877bda 100644 --- a/radio/src/fifo.h +++ b/radio/src/fifo.h @@ -47,6 +47,11 @@ class Fifo { } + void clear() + { + widx = ridx = 0; + } + void push(uint8_t byte) { uint32_t next = (widx+1) & (N-1); if (next != ridx) { diff --git a/radio/src/fonts.h b/radio/src/fonts.h index bb7bd0b18..6bba1021a 100644 --- a/radio/src/fonts.h +++ b/radio/src/fonts.h @@ -37,6 +37,13 @@ #ifndef fonts_h #define fonts_h +#if defined(COLORLCD) + +extern const uint16_t *fontspecsTable[16]; +extern const pm_uchar *fontsTable[16]; + +#else + extern const pm_uchar font_5x7[]; extern const pm_uchar font_10x14[]; @@ -56,3 +63,5 @@ extern const pm_uchar font_4x6_extra[]; #endif #endif + +#endif diff --git a/radio/src/fonts/Horus/font_dblsize.png b/radio/src/fonts/Horus/font_dblsize.png new file mode 100644 index 000000000..d617ab223 Binary files /dev/null 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 new file mode 100644 index 000000000..8129cf4ed --- /dev/null +++ b/radio/src/fonts/Horus/font_dblsize.specs @@ -0,0 +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 diff --git a/radio/src/fonts/Horus/font_midsize.png b/radio/src/fonts/Horus/font_midsize.png new file mode 100644 index 000000000..f1bc88d93 Binary files /dev/null and b/radio/src/fonts/Horus/font_midsize.png differ diff --git a/radio/src/fonts/Horus/font_midsize.specs b/radio/src/fonts/Horus/font_midsize.specs new file mode 100644 index 000000000..7244eaedd --- /dev/null +++ b/radio/src/fonts/Horus/font_midsize.specs @@ -0,0 +1 @@ +{ 0,4,10,20,41,56,80,100,106,115,125,140,159,167,177,184,196,212,227,242,258,274,290,306,322,338,354,361,369,388,407,426,440,451,471,487,505,524,539,553,572,589,595,605,623,638,658,675,695,710,730,747,763,782,799,819,845,864,883,901,910,922,931,950,967,976,991,1006,1020,1036,1052,1064,1080,1095,1101,1110,1125,1131,1154,1169,1185,1200,1216,1227,1241,1253,1268,1285,1306,1323,1340,1354,1373,1376,1395,1416,1437,1452,1467,1484,1501,1518,1535,1557 } \ No newline at end of file diff --git a/radio/src/fonts/Horus/font_smlsize.png b/radio/src/fonts/Horus/font_smlsize.png new file mode 100644 index 000000000..338e064bb Binary files /dev/null and b/radio/src/fonts/Horus/font_smlsize.png differ diff --git a/radio/src/fonts/Horus/font_smlsize.specs b/radio/src/fonts/Horus/font_smlsize.specs new file mode 100644 index 000000000..3e3184a10 --- /dev/null +++ b/radio/src/fonts/Horus/font_smlsize.specs @@ -0,0 +1 @@ +{ 0,4,8,13,23,31,44,55,58,63,67,75,85,88,94,97,103,112,120,128,137,146,154,163,171,180,189,192,195,205,215,225,232,238,248,256,266,276,284,291,301,310,313,318,327,335,345,354,365,373,384,393,402,412,421,431,445,455,465,475,479,485,489,499,508,513,521,529,537,546,555,561,570,578,581,586,594,597,609,617,626,634,643,649,657,663,671,680,692,701,710,718,728,729,739,751,763,771,779,789,799,809,819,830 } \ No newline at end of file diff --git a/radio/src/fonts/Horus/font_stdsize.png b/radio/src/fonts/Horus/font_stdsize.png new file mode 100644 index 000000000..02cdc8284 Binary files /dev/null and b/radio/src/fonts/Horus/font_stdsize.png differ diff --git a/radio/src/fonts/Horus/font_stdsize.specs b/radio/src/fonts/Horus/font_stdsize.specs new file mode 100644 index 000000000..fe043dfda --- /dev/null +++ b/radio/src/fonts/Horus/font_stdsize.specs @@ -0,0 +1 @@ +{ 0,4,7,13,26,35,51,63,66,71,76,85,97,101,107,111,118,128,137,146,155,166,175,185,194,204,214,218,222,234,246,258,266,273,285,295,307,319,329,338,351,362,366,372,383,392,405,416,429,439,452,463,473,485,496,508,525,537,549,561,566,573,578,590,601,607,617,627,636,646,656,663,673,682,685,690,700,703,718,727,737,747,757,764,773,780,789,799,813,823,833,842,854,855,867,881,895,904,913,924,935,946,957,971, 986, 1001, 1016, 1031, 1046, 1061, 1076, 1091, 1106, 1121, 1136, 1151, 1166 } \ No newline at end of file diff --git a/radio/src/fonts/Horus/font_tinsize.png b/radio/src/fonts/Horus/font_tinsize.png new file mode 100644 index 000000000..be586e835 Binary files /dev/null and b/radio/src/fonts/Horus/font_tinsize.png differ diff --git a/radio/src/fonts/Horus/font_tinsize.specs b/radio/src/fonts/Horus/font_tinsize.specs new file mode 100644 index 000000000..2fbef2d86 --- /dev/null +++ b/radio/src/fonts/Horus/font_tinsize.specs @@ -0,0 +1 @@ +{ 0,4,7,12,20,26,36,44,47,51,55,61,69,72,76,79,84,91,97,103,109,116,122,129,135,142,149,151,154,162,170,178,184,189,197,204,211,219,226,232,240,247,250,254,262,268,276,283,291,298,306,313,320,328,335,343,353,360,368,375,379,384,388,396,403,407,413,420,426,432,439,444,450,456,459,463,470,473,482,488,495,502,508,513,519,524,530,537,545,552,559,565,573,574,582,591,600,606,612,619,626,633,640,648 } \ No newline at end of file diff --git a/radio/src/fonts/Horus/font_xxlsize.png b/radio/src/fonts/Horus/font_xxlsize.png new file mode 100644 index 000000000..f9752d0a8 Binary files /dev/null and b/radio/src/fonts/Horus/font_xxlsize.png differ diff --git a/radio/src/fonts/Horus/font_xxlsize.specs b/radio/src/fonts/Horus/font_xxlsize.specs new file mode 100644 index 000000000..b3c0b02d3 --- /dev/null +++ b/radio/src/fonts/Horus/font_xxlsize.specs @@ -0,0 +1 @@ +{ 0,4,12,29,66,93,137,173,181,195,210,235,269,280,296,305,325,353,378,404,431,460,487,515,542,570,598,607,618,652,686,720,743,762,798,827,859,893,920,944,979,1010,1019,1035,1067,1093,1129,1160,1197,1224,1261,1292,1320,1354,1384,1420,1468,1502,1536,1568,1582,1602,1616,1650,1679,1695,1722,1749,1774,1802,1830,1850,1878,1904,1912,1925,1952,1960,2002,2028,2056,2083,2111,2130,2154,2174,2200,2229,2268,2297,2326,2351,2385,2388,2422,2461,2500,2525,2550,2581,2612,2643,2674,2714 } \ No newline at end of file diff --git a/radio/src/fonts/extra_16px.png b/radio/src/fonts/extra_16px.png new file mode 100644 index 000000000..5f3d9cb91 Binary files /dev/null and b/radio/src/fonts/extra_16px.png differ diff --git a/radio/src/functions.cpp b/radio/src/functions.cpp index 6fdd9b646..6d0e8b213 100644 --- a/radio/src/functions.cpp +++ b/radio/src/functions.cpp @@ -324,7 +324,7 @@ void evalFunctions() if (!isFunctionActive(FUNCTION_INSTANT_TRIM)) { #if defined(GUI) if (g_menuStack[0] == menuMainView -#if defined(FRSKY) +#if defined(FRSKY) && !defined(PCBFLAMENCO) && !defined(PCBHORUS) || g_menuStack[0] == menuTelemetryFrsky #endif #if defined(PCBTARANIS) diff --git a/radio/src/gui/9X/gui.h b/radio/src/gui/9X/gui.h index f99cb17c8..8f225bf2a 100644 --- a/radio/src/gui/9X/gui.h +++ b/radio/src/gui/9X/gui.h @@ -39,13 +39,14 @@ #define NUM_BODY_LINES (LCD_LINES-1) #define MENU_HEADER_HEIGHT FH +#define MENU_INIT_VPOS 0 void displaySplash(); void displayScreenIndex(uint8_t index, uint8_t count, uint8_t attr); #if !defined(CPUM64) #define DEFAULT_SCROLLBAR_X (LCD_W-1) - void displayScrollbar(coord_t x, coord_t y, coord_t h, uint16_t offset, uint16_t count, uint8_t visible); + void drawScrollbar(coord_t x, coord_t y, coord_t h, uint16_t offset, uint16_t count, uint8_t visible); #endif #define SET_SCROLLBAR_X(x) diff --git a/radio/src/gui/9X/helpers.cpp b/radio/src/gui/9X/helpers.cpp index 82440939e..0db4fb4ff 100644 --- a/radio/src/gui/9X/helpers.cpp +++ b/radio/src/gui/9X/helpers.cpp @@ -43,234 +43,3 @@ uint8_t switchToMix(uint8_t source) else return MIXSRC_FIRST_SWITCH - 3 + source; } - -#if defined(CPUARM) -bool isSourceAvailable(int source) -{ -#if !defined(HELI) - if (source>=MIXSRC_CYC1 && source<=MIXSRC_CYC3) - return false; -#endif - - if (source>=MIXSRC_CH1 && source<=MIXSRC_LAST_CH) { - uint8_t destCh = source-MIXSRC_CH1; - for (uint8_t i = 0; i < MAX_MIXERS; i++) { - MixData *md = mixAddress(i); - if (md->srcRaw == 0) return false; - if (md->destCh==destCh) return true; - } - return false; - } - - if (source>=MIXSRC_SW1 && source<=MIXSRC_LAST_LOGICAL_SWITCH) { - LogicalSwitchData * cs = lswAddress(source-MIXSRC_SW1); - return (cs->func != LS_FUNC_NONE); - } - -#if !defined(GVARS) - if (source>=MIXSRC_GVAR1 && source<=MIXSRC_LAST_GVAR) - return false; -#endif - - if (source>=MIXSRC_RESERVE1 && source<=MIXSRC_RESERVE5) - return false; - - if (source>=MIXSRC_FIRST_TELEM && source<=MIXSRC_LAST_TELEM) { - div_t qr = div(source-MIXSRC_FIRST_TELEM, 3); - if (qr.rem == 0) - return isTelemetryFieldAvailable(qr.quot); - else - return isTelemetryFieldComparisonAvailable(qr.quot); - } - - return true; -} - -bool isSourceAvailableInGlobalFunctions(int source) -{ - if (source>=MIXSRC_FIRST_TELEM && source<=MIXSRC_LAST_TELEM) { - return false; - } - return isSourceAvailable(source); -} - -bool isSourceAvailableInCustomSwitches(int source) -{ - bool result = isSourceAvailable(source); - -#if defined(FRSKY) - if (result && source>=MIXSRC_FIRST_TELEM && source<=MIXSRC_LAST_TELEM) { - div_t qr = div(source-MIXSRC_FIRST_TELEM, 3); - result = isTelemetryFieldComparisonAvailable(qr.quot); - } -#endif - - return result; -} - -bool isInputSourceAvailable(int source) -{ - if (source>=MIXSRC_Rud && source<=MIXSRC_MAX) - return true; - - if (source>=MIXSRC_TrimRud && source=MIXSRC_FIRST_CH && source<=MIXSRC_LAST_CH) - return true; - - if (source>=MIXSRC_FIRST_TRAINER && source<=MIXSRC_LAST_TRAINER) - return true; - - if (source>=MIXSRC_FIRST_TELEM && source<=MIXSRC_LAST_TELEM) - return isTelemetryFieldAvailable(source-MIXSRC_FIRST_TELEM); - - return false; -} - -enum SwitchContext -{ - LogicalSwitchesContext, - ModelCustomFunctionsContext, - GeneralCustomFunctionsContext, - TimersContext, - MixesContext -}; - -bool isSwitchAvailable(int swtch, SwitchContext context) -{ - if (swtch < 0) { - if (swtch == -SWSRC_ON || swtch == -SWSRC_ONE) { - return false; - } - swtch = -swtch; - } - - if (swtch >= SWSRC_FIRST_LOGICAL_SWITCH && swtch <= SWSRC_LAST_LOGICAL_SWITCH) { - if (context == GeneralCustomFunctionsContext) { - return false; - } - else if (context != LogicalSwitchesContext) { - LogicalSwitchData * cs = lswAddress(swtch-SWSRC_FIRST_LOGICAL_SWITCH); - return (cs->func != LS_FUNC_NONE); - } - } - - if (context != ModelCustomFunctionsContext && context != GeneralCustomFunctionsContext && (swtch == SWSRC_ON || swtch == SWSRC_ONE)) { - return false; - } - - if (swtch >= SWSRC_FIRST_FLIGHT_MODE && swtch <= SWSRC_LAST_FLIGHT_MODE) { - if (context == MixesContext || context == GeneralCustomFunctionsContext) { - return false; - } - else { - swtch -= SWSRC_FIRST_FLIGHT_MODE; - if (swtch == 0) { - return true; - } - FlightModeData * fm = flightModeAddress(swtch); - return (fm->swtch != SWSRC_NONE); - } - } - - return true; -} - -bool isSwitchAvailableInLogicalSwitches(int swtch) -{ - return isSwitchAvailable(swtch, LogicalSwitchesContext); -} - -bool isSwitchAvailableInCustomFunctions(int swtch) -{ - if (g_menuStack[g_menuStackPtr] == menuModelCustomFunctions) - return isSwitchAvailable(swtch, ModelCustomFunctionsContext); - else - return isSwitchAvailable(swtch, GeneralCustomFunctionsContext); -} - -bool isSwitchAvailableInMixes(int swtch) -{ - return isSwitchAvailable(swtch, MixesContext); -} - -bool isSwitchAvailableInTimers(int swtch) -{ - if (swtch >= 0) { - if (swtch < TMRMODE_COUNT) - return true; - else - swtch -= TMRMODE_COUNT-1; - } - else { - if (swtch > -TMRMODE_COUNT) - return false; - else - swtch += TMRMODE_COUNT-1; - } - - return isSwitchAvailable(swtch, TimersContext); -} - -bool isLogicalSwitchFunctionAvailable(int function) -{ - return function != LS_FUNC_RANGE; -} - -bool isAssignableFunctionAvailable(int function) -{ - bool modelFunctions = (g_menuStack[g_menuStackPtr] == menuModelCustomFunctions); - - switch (function) { - case FUNC_OVERRIDE_CHANNEL: -#if defined(OVERRIDE_CHANNEL_FUNCTION) - return modelFunctions; -#else - return false; -#endif - case FUNC_ADJUST_GVAR: -#if defined(GVARS) - return modelFunctions; -#else - return false; -#endif -#if !defined(HAPTIC) - case FUNC_HAPTIC: -#endif - case FUNC_RESERVE4: -#if !defined(DANGEROUS_MODULE_FUNCTIONS) - case FUNC_RANGECHECK: - case FUNC_BIND: -#endif - case FUNC_PLAY_SCRIPT: - case FUNC_RESERVE5: - return false; - - default: - return true; - } -} - -bool isModuleAvailable(int module) -{ - if (module == MODULE_TYPE_NONE) - return false; - -#if !defined(PXX) - if (module == MODULE_TYPE_XJT) - return false; -#endif - - return true; -} - -bool modelHasNotes() -{ - char filename[sizeof(MODELS_PATH)+1+sizeof(g_model.header.name)+sizeof(TEXT_EXT)] = MODELS_PATH "/"; - char *buf = strcat_modelname(&filename[sizeof(MODELS_PATH)], g_eeGeneral.currModel); - strcpy(buf, TEXT_EXT); - return isFileAvailable(filename); -} - -#endif diff --git a/radio/src/gui/9X/lcd.cpp b/radio/src/gui/9X/lcd.cpp index 4e8d27ccb..8fa0d523e 100644 --- a/radio/src/gui/9X/lcd.cpp +++ b/radio/src/gui/9X/lcd.cpp @@ -36,11 +36,11 @@ #include "opentx.h" -display_t displayBuf[DISPLAY_BUF_SIZE]; +display_t displayBuf[DISPLAY_BUFFER_SIZE]; -void lcd_clear() +void lcdClear() { - memset(displayBuf, 0, DISPLAY_BUFER_SIZE); + memset(displayBuf, 0, DISPLAY_BUFFER_SIZE); } coord_t lcdLastPos; @@ -132,7 +132,7 @@ void lcdPutPattern(coord_t x, coord_t y, const uint8_t * pattern, uint8_t width, } } -void lcd_putcAtt(coord_t x, coord_t y, const unsigned char c, LcdFlags flags) +void lcdDrawChar(coord_t x, coord_t y, const unsigned char c, LcdFlags flags) { const pm_uchar * q; @@ -205,10 +205,10 @@ void lcd_putcAtt(coord_t x, coord_t y, const unsigned char c, LcdFlags flags) void lcd_putc(coord_t x, coord_t y, const unsigned char c) { - lcd_putcAtt(x, y, c, 0); + lcdDrawChar(x, y, c, 0); } -void lcd_putsnAtt(coord_t x, coord_t y, const pm_char * s, uint8_t len, LcdFlags flags) +void lcdDrawTextWithLen(coord_t x, coord_t y, const pm_char * s, uint8_t len, LcdFlags flags) { const coord_t orig_x = x; #if defined(CPUARM) @@ -240,7 +240,7 @@ void lcd_putsnAtt(coord_t x, coord_t y, const pm_char * s, uint8_t len, LcdFlags break; } else if (c >= 0x20) { - lcd_putcAtt(x, y, c, flags); + lcdDrawChar(x, y, c, flags); x = lcdNextPos; } else if (c == 0x1F) { //X-coord prefix @@ -283,17 +283,17 @@ void lcd_putsnAtt(coord_t x, coord_t y, const pm_char * s, uint8_t len, LcdFlags void lcd_putsn(coord_t x, coord_t y, const pm_char * s, uint8_t len) { - lcd_putsnAtt(x, y, s, len, 0); + lcdDrawTextWithLen(x, y, s, len, 0); } -void lcd_putsAtt(coord_t x, coord_t y, const pm_char * s, LcdFlags flags) +void lcdDrawText(coord_t x, coord_t y, const pm_char * s, LcdFlags flags) { - lcd_putsnAtt(x, y, s, 255, flags); + lcdDrawTextWithLen(x, y, s, 255, flags); } void lcd_puts(coord_t x, coord_t y, const pm_char * s) { - lcd_putsAtt(x, y, s, 0); + lcdDrawText(x, y, s, 0); } void lcd_putsLeft(coord_t y, const pm_char * s) @@ -302,11 +302,11 @@ void lcd_putsLeft(coord_t y, const pm_char * s) } #if !defined(BOOT) -void lcd_putsiAtt(coord_t x, coord_t y, const pm_char * s,uint8_t idx, LcdFlags flags) +void lcdDrawTextAtIndex(coord_t x, coord_t y, const pm_char * s,uint8_t idx, LcdFlags flags) { uint8_t length; length = pgm_read_byte(s++); - lcd_putsnAtt(x, y, s+length*idx, length, flags & ~(BSS|ZCHAR)); + lcdDrawTextWithLen(x, y, s+length*idx, length, flags & ~(BSS|ZCHAR)); } #if defined(CPUARM) @@ -317,7 +317,7 @@ void lcd_outhex4(coord_t x, coord_t y, uint32_t val, LcdFlags flags) x -= FWNUM; char c = val & 0xf; c = c>9 ? c+'A'-10 : c+'0'; - lcd_putcAtt(x, y, c, flags|(c>='A' ? CONDENSED : 0)); + lcdDrawChar(x, y, c, flags|(c>='A' ? CONDENSED : 0)); val >>= 4; } } @@ -329,7 +329,7 @@ void lcd_outhex4(coord_t x, coord_t y, uint16_t val) x -= FWNUM; char c = val & 0xf; c = c>9 ? c+'A'-10 : c+'0'; - lcd_putcAtt(x, y, c, c>='A' ? CONDENSED : 0); + lcdDrawChar(x, y, c, c>='A' ? CONDENSED : 0); val >>= 4; } } @@ -430,7 +430,7 @@ void lcd_outdezNAtt(coord_t x, coord_t y, lcdint_t val, LcdFlags flags, uint8_t if (c=='1' && i==len && xn>x+10) { x+=1; } if ((lcduint_t)val >= 1000) { x+=FWNUM; f &= ~DBLSIZE; } } - lcd_putcAtt(x, y, c, f); + lcdDrawChar(x, y, c, f); if (mode == i) { flags &= ~PREC2; // TODO not needed but removes 20bytes, could be improved for sure, check asm if (dblsize) { @@ -449,7 +449,7 @@ void lcd_outdezNAtt(coord_t x, coord_t y, lcdint_t val, LcdFlags flags, uint8_t } else if (xxlsize) { x -= 17; - lcd_putcAtt(x+2, y, '.', f); + lcdDrawChar(x+2, y, '.', f); } else if (midsize) { x -= 3; @@ -472,7 +472,7 @@ void lcd_outdezNAtt(coord_t x, coord_t y, lcdint_t val, LcdFlags flags, uint8_t } else { x -= 2; - lcd_putcAtt(x, y, '.', f); + lcdDrawChar(x, y, '.', f); } } if (dblsize && (lcduint_t)val >= 1000 && (lcduint_t)val < 10000) x-=2; @@ -497,17 +497,17 @@ void lcd_outdezNAtt(coord_t x, coord_t y, lcdint_t val, LcdFlags flags, uint8_t drawFilledRect(xn, y+2*FH-3, ln, 2); } } - if (neg) lcd_putcAtt(x, y, '-', flags); + if (neg) lcdDrawChar(x, y, '-', flags); } #endif void lcd_hline(coord_t x, coord_t y, coord_t w, LcdFlags att) { - lcd_hlineStip(x, y, w, 0xff, att); + lcdDrawHorizontalLine(x, y, w, 0xff, att); } #if defined(CPUARM) && !defined(BOOT) -void lcd_line(coord_t x1, coord_t y1, coord_t x2, coord_t y2, uint8_t pat, LcdFlags att) +void lcdDrawLine(coord_t x1, coord_t y1, coord_t x2, coord_t y2, uint8_t pat, LcdFlags att) { int dx = x2-x1; /* the horizontal distance of the line */ int dy = y2-y1; /* the vertical distance of the line */ @@ -553,16 +553,16 @@ void lcd_line(coord_t x1, coord_t y1, coord_t x2, coord_t y2, uint8_t pat, LcdFl void lcd_vline(coord_t x, scoord_t y, scoord_t h) { - lcd_vlineStip(x, y, h, SOLID); + lcdDrawVerticalLine(x, y, h, SOLID); } -void lcd_rect(coord_t x, coord_t y, coord_t w, coord_t h, uint8_t pat, LcdFlags att) +void lcdDrawRect(coord_t x, coord_t y, coord_t w, coord_t h, uint8_t pat, LcdFlags att) { - lcd_vlineStip(x, y, h, pat); - lcd_vlineStip(x+w-1, y, h, pat); + lcdDrawVerticalLine(x, y, h, pat); + lcdDrawVerticalLine(x+w-1, y, h, pat); if (~att & ROUND) { x+=1; w-=2; } - lcd_hlineStip(x, y+h-1, w, pat); - lcd_hlineStip(x, y, w, pat); + lcdDrawHorizontalLine(x, y+h-1, w, pat); + lcdDrawHorizontalLine(x, y, w, pat); } #if !defined(BOOT) @@ -570,15 +570,15 @@ void drawFilledRect(coord_t x, scoord_t y, coord_t w, coord_t h, uint8_t pat, Lc { #if defined(CPUM64) for (scoord_t i=y; i> 1) + ((pat & 1) << 7); } #else for (scoord_t i=y; i> 1) + ((pat & 1) << 7); } #endif @@ -617,7 +617,7 @@ void putsTimer(coord_t x, coord_t y, putstime_t tme, LcdFlags att, LcdFlags att2 } if (tme < 0) { - lcd_putcAtt(x - ((att & DBLSIZE) ? FW+2 : ((att & MIDSIZE) ? FW+0 : FWNUM)), y, '-', att); + lcdDrawChar(x - ((att & DBLSIZE) ? FW+2 : ((att & MIDSIZE) ? FW+0 : FWNUM)), y, '-', att); tme = -tme; } @@ -635,10 +635,10 @@ void putsTimer(coord_t x, coord_t y, putstime_t tme, LcdFlags att, LcdFlags att2 lcd_outdezNAtt(x, y, qr.quot, att|LEADING0|LEFT, 2); #if defined(CPUARM) && defined(RTCLOCK) if (att&TIMEBLINK) - lcd_putcAtt(lcdLastPos, y, separator, BLINK); + lcdDrawChar(lcdLastPos, y, separator, BLINK); else #endif - lcd_putcAtt(lcdLastPos, y, separator, att&att2); + lcdDrawChar(lcdLastPos, y, separator, att&att2); lcd_outdezNAtt(lcdNextPos, y, qr.rem, att2|LEADING0|LEFT, 2); } @@ -646,7 +646,7 @@ void putsTimer(coord_t x, coord_t y, putstime_t tme, LcdFlags att, LcdFlags att2 void putsVolts(coord_t x, coord_t y, uint16_t volts, LcdFlags att) { lcd_outdezAtt(x, y, (int16_t)volts, (~NO_UNIT) & (att | ((att&PREC2)==PREC2 ? 0 : PREC1))); - if (~att & NO_UNIT) lcd_putcAtt(lcdLastPos, y, 'V', att); + if (~att & NO_UNIT) lcdDrawChar(lcdLastPos, y, 'V', att); } void putsVBat(coord_t x, coord_t y, LcdFlags att) @@ -656,14 +656,14 @@ void putsVBat(coord_t x, coord_t y, LcdFlags att) void putsStrIdx(coord_t x, coord_t y, const pm_char *str, uint8_t idx, LcdFlags att) { - lcd_putsAtt(x, y, str, att & ~LEADING0); + lcdDrawText(x, y, str, att & ~LEADING0); lcd_outdezNAtt(lcdNextPos, y, idx, att|LEFT, 2); } void putsMixerSource(coord_t x, coord_t y, uint8_t idx, LcdFlags att) { if (idx < MIXSRC_THR) - lcd_putsiAtt(x, y, STR_VSRCRAW, idx, att); + lcdDrawTextAtIndex(x, y, STR_VSRCRAW, idx, att); else if (idx < MIXSRC_SW1) putsSwitches(x, y, idx-MIXSRC_THR+1+3*(1), att); else if (idx <= MIXSRC_LAST_LOGICAL_SWITCH) @@ -678,24 +678,24 @@ void putsMixerSource(coord_t x, coord_t y, uint8_t idx, LcdFlags att) putsStrIdx(x, y, STR_GV, idx-MIXSRC_GVAR1+1, att); #endif else if (idx < MIXSRC_FIRST_TELEM) { - lcd_putsiAtt(x, y, STR_VSRCRAW, idx-MIXSRC_Rud+1-(MIXSRC_SW1-MIXSRC_THR)-NUM_LOGICAL_SWITCH-NUM_TRAINER-NUM_CHNOUT-MAX_GVARS, att); + lcdDrawTextAtIndex(x, y, STR_VSRCRAW, idx-MIXSRC_Rud+1-(MIXSRC_SW1-MIXSRC_THR)-NUM_LOGICAL_SWITCH-NUM_TRAINER-NUM_CHNOUT-MAX_GVARS, att); } #if defined(CPUARM) else { idx -= MIXSRC_FIRST_TELEM; div_t qr = div(idx, 3); - lcd_putsnAtt(x, y, g_model.telemetrySensors[qr.quot].label, ZLEN(g_model.telemetrySensors[qr.quot].label), ZCHAR|att); - if (qr.rem) lcd_putcAtt(lcdLastPos, y, qr.rem==2 ? '+' : '-', att); + lcdDrawTextWithLen(x, y, g_model.telemetrySensors[qr.quot].label, ZLEN(g_model.telemetrySensors[qr.quot].label), ZCHAR|att); + if (qr.rem) lcdDrawChar(lcdLastPos, y, qr.rem==2 ? '+' : '-', att); } #else else - lcd_putsiAtt(x, y, STR_VTELEMCHNS, idx-MIXSRC_FIRST_TELEM+1, att); + lcdDrawTextAtIndex(x, y, STR_VTELEMCHNS, idx-MIXSRC_FIRST_TELEM+1, att); #endif } void putsChnLetter(coord_t x, coord_t y, uint8_t idx, LcdFlags att) { - lcd_putsiAtt(x, y, STR_RETA123, idx-1, att); + lcdDrawTextAtIndex(x, y, STR_RETA123, idx-1, att); } void putsModelName(coord_t x, coord_t y, char *name, uint8_t id, LcdFlags att) @@ -706,16 +706,16 @@ void putsModelName(coord_t x, coord_t y, char *name, uint8_t id, LcdFlags att) putsStrIdx(x, y, STR_MODEL, id+1, att|LEADING0); } else { - lcd_putsnAtt(x, y, name, sizeof(g_model.header.name), ZCHAR|att); + lcdDrawTextWithLen(x, y, name, sizeof(g_model.header.name), ZCHAR|att); } } void putsSwitches(coord_t x, coord_t y, int8_t idx, LcdFlags att) { if (idx == SWSRC_OFF) - return lcd_putsiAtt(x, y, STR_OFFON, 0, att); + return lcdDrawTextAtIndex(x, y, STR_OFFON, 0, att); if (idx < 0) { - lcd_putcAtt(x-2, y, '!', att); + lcdDrawChar(x-2, y, '!', att); idx = -idx; } #if defined(CPUARM) && defined(FLIGHT_MODES) @@ -723,14 +723,14 @@ void putsSwitches(coord_t x, coord_t y, int8_t idx, LcdFlags att) return putsStrIdx(x, y, STR_FP, idx-SWSRC_FIRST_FLIGHT_MODE, att); } #endif - return lcd_putsiAtt(x, y, STR_VSWITCHES, idx, att); + return lcdDrawTextAtIndex(x, y, STR_VSWITCHES, idx, att); } #if defined(FLIGHT_MODES) void putsFlightMode(coord_t x, coord_t y, int8_t idx, LcdFlags att) { - if (idx==0) { lcd_putsiAtt(x, y, STR_MMMINV, 0, att); return; } - if (idx < 0) { lcd_putcAtt(x-2, y, '!', att); idx = -idx; } + if (idx==0) { lcdDrawTextAtIndex(x, y, STR_MMMINV, 0, att); return; } + if (idx < 0) { lcdDrawChar(x-2, y, '!', att); idx = -idx; } if (att & CONDENSED) lcd_outdezNAtt(x+FW*1, y, idx-1, (att & ~CONDENSED), 1); else @@ -741,11 +741,11 @@ void putsFlightMode(coord_t x, coord_t y, int8_t idx, LcdFlags att) void putsCurve(coord_t x, coord_t y, int8_t idx, LcdFlags att) { if (idx < 0) { - lcd_putcAtt(x-3, y, '!', att); + lcdDrawChar(x-3, y, '!', att); idx = -idx+CURVE_BASE-1; } if (idx < CURVE_BASE) - lcd_putsiAtt(x, y, STR_VCURVEFUNC, idx, att); + lcdDrawTextAtIndex(x, y, STR_VCURVEFUNC, idx, att); else putsStrIdx(x, y, STR_CV, idx-CURVE_BASE+1, att); } @@ -754,7 +754,7 @@ void putsTimerMode(coord_t x, coord_t y, int8_t mode, LcdFlags att) { if (mode >= 0) { if (mode < TMRMODE_COUNT) - return lcd_putsiAtt(x, y, STR_VTMRMODES, mode, att); + return lcdDrawTextAtIndex(x, y, STR_VTMRMODES, mode, att); else mode -= (TMRMODE_COUNT-1); } @@ -768,7 +768,7 @@ void putsTrimMode(coord_t x, coord_t y, uint8_t phase, uint8_t idx, LcdFlags att if (v > TRIM_EXTENDED_MAX) { uint8_t p = v - TRIM_EXTENDED_MAX - 1; if (p >= phase) p++; - lcd_putcAtt(x, y, '0'+p, att); + lcdDrawChar(x, y, '0'+p, att); } else { putsChnLetter(x, y, idx+1, att); @@ -783,10 +783,10 @@ void putsRotaryEncoderMode(coord_t x, coord_t y, uint8_t phase, uint8_t idx, Lcd if (v > ROTARY_ENCODER_MAX) { uint8_t p = v - ROTARY_ENCODER_MAX - 1; if (p >= phase) p++; - lcd_putcAtt(x, y, '0'+p, att); + lcdDrawChar(x, y, '0'+p, att); } else { - lcd_putcAtt(x, y, 'a'+idx, att); + lcdDrawChar(x, y, 'a'+idx, att); } } #endif @@ -808,7 +808,7 @@ void putsValueWithUnit(coord_t x, coord_t y, lcdint_t val, uint8_t unit, LcdFlag // convertUnit(val, unit); lcd_outdezAtt(x, y, val, att & (~NO_UNIT)); if (!(att & NO_UNIT) && unit != UNIT_RAW) { - lcd_putsiAtt(lcdLastPos/*+1*/, y, STR_VTELEMUNIT, unit, 0); + lcdDrawTextAtIndex(lcdLastPos/*+1*/, y, STR_VTELEMUNIT, unit, 0); } } @@ -816,7 +816,7 @@ void displayGpsCoord(coord_t x, coord_t y, char direction, int16_t bp, int16_t a { if (!direction) direction = '-'; lcd_outdezAtt(x, y, bp / 100, att); // ddd before '.' - lcd_putcAtt(lcdLastPos, y, '@', att); + lcdDrawChar(lcdLastPos, y, '@', att); uint8_t mn = bp % 100; // TODO div_t if (g_eeGeneral.gpsFormat == 0) { lcd_outdezNAtt(lcdNextPos, y, mn, att|LEFT|LEADING0, 2); // mm before '.' @@ -845,22 +845,22 @@ void displayDate(coord_t x, coord_t y, TelemetryItem & telemetryItem, LcdFlags a x -= 42; att &= ~0x0F00; // TODO constant lcd_outdezNAtt(x, y, telemetryItem.datetime.day, att|LEADING0|LEFT, 2); - lcd_putcAtt(lcdLastPos-1, y, '-', att); + lcdDrawChar(lcdLastPos-1, y, '-', att); lcd_outdezNAtt(lcdNextPos-1, y, telemetryItem.datetime.month, att|LEFT, 2); - lcd_putcAtt(lcdLastPos-1, y, '-', att); + lcdDrawChar(lcdLastPos-1, y, '-', att); lcd_outdezAtt(lcdNextPos-1, y, telemetryItem.datetime.year, att|LEFT); y += FH; lcd_outdezNAtt(x, y, telemetryItem.datetime.hour, att|LEADING0|LEFT, 2); - lcd_putcAtt(lcdLastPos, y, ':', att); + lcdDrawChar(lcdLastPos, y, ':', att); lcd_outdezNAtt(lcdNextPos, y, telemetryItem.datetime.min, att|LEADING0|LEFT, 2); - lcd_putcAtt(lcdLastPos, y, ':', att); + lcdDrawChar(lcdLastPos, y, ':', att); lcd_outdezNAtt(lcdNextPos, y, telemetryItem.datetime.sec, att|LEADING0|LEFT, 2); } else { lcd_outdezNAtt(x, y, telemetryItem.datetime.hour, att|LEADING0|LEFT, 2); - lcd_putcAtt(lcdLastPos, y, ':', att); + lcdDrawChar(lcdLastPos, y, ':', att); lcd_outdezNAtt(lcdNextPos, y, telemetryItem.datetime.min, att|LEADING0|LEFT, 2); - lcd_putcAtt(lcdLastPos, y, ':', att); + lcdDrawChar(lcdLastPos, y, ':', att); lcd_outdezNAtt(lcdNextPos, y, telemetryItem.datetime.sec, att|LEADING0|LEFT, 2); } } @@ -932,7 +932,7 @@ void putsValueWithUnit(coord_t x, coord_t y, lcdint_t val, uint8_t unit, LcdFlag convertUnit(val, unit); lcd_outdezAtt(x, y, val, att & (~NO_UNIT)); if (!(att & NO_UNIT) && unit != UNIT_RAW) { - lcd_putsiAtt(lcdLastPos/*+1*/, y, STR_VTELEMUNIT, unit, 0); + lcdDrawTextAtIndex(lcdLastPos/*+1*/, y, STR_VTELEMUNIT, unit, 0); } } @@ -1111,7 +1111,7 @@ void lcdSetContrast() #define LCD_BYTE_FILTER(p, keep, add) *(p) = (*(p) & (keep)) | (add) #if !defined(CPUARM) -void lcd_putcAtt(coord_t x, uint8_t y, const unsigned char c, LcdFlags flags) +void lcdDrawChar(coord_t x, uint8_t y, const unsigned char c, LcdFlags flags) { uint8_t *p = &displayBuf[ y / 8 * LCD_W + x ]; const pm_uchar *q = &font_5x7[(c-0x20)*5]; @@ -1281,7 +1281,7 @@ void lcd_plot(coord_t x, coord_t y, LcdFlags att) lcd_mask(p, BITMASK(y%8), att); } -void lcd_hlineStip(coord_t x, coord_t y, coord_t w, uint8_t pat, LcdFlags att) +void lcdDrawHorizontalLine(coord_t x, coord_t y, coord_t w, uint8_t pat, LcdFlags att) { if (y >= LCD_H) return; if (x+w > LCD_W) { w = LCD_W - x; } @@ -1301,7 +1301,7 @@ void lcd_hlineStip(coord_t x, coord_t y, coord_t w, uint8_t pat, LcdFlags att) } #if defined(CPUM64) -void lcd_vlineStip(coord_t x, int8_t y, int8_t h, uint8_t pat) +void lcdDrawVerticalLine(coord_t x, int8_t y, int8_t h, uint8_t pat) { if (x >= LCD_W) return; if (h<0) { y+=h; h=-h; } @@ -1334,7 +1334,7 @@ void lcd_vlineStip(coord_t x, int8_t y, int8_t h, uint8_t pat) } #else // allows the att parameter... -void lcd_vlineStip(coord_t x, scoord_t y, scoord_t h, uint8_t pat, LcdFlags att) +void lcdDrawVerticalLine(coord_t x, scoord_t y, scoord_t h, uint8_t pat, LcdFlags att) { if (x >= LCD_W) return; #if defined(CPUARM) diff --git a/radio/src/gui/9X/lcd.h b/radio/src/gui/9X/lcd.h index 6503e93bc..14a27318a 100644 --- a/radio/src/gui/9X/lcd.h +++ b/radio/src/gui/9X/lcd.h @@ -135,17 +135,16 @@ #endif #define display_t uint8_t -#define DISPLAY_BUF_SIZE (LCD_W*((LCD_H+7)/8)) +#define DISPLAY_BUFFER_SIZE (LCD_W*((LCD_H+7)/8)) -extern display_t displayBuf[DISPLAY_BUF_SIZE]; +extern display_t displayBuf[DISPLAY_BUFFER_SIZE]; #define lcdRefreshWait() extern coord_t lcdLastPos; extern coord_t lcdNextPos; -#define DISPLAY_BUFER_SIZE (sizeof(display_t)*DISPLAY_BUF_SIZE) -#define DISPLAY_END (displayBuf + DISPLAY_BUF_SIZE) +#define DISPLAY_END (displayBuf + DISPLAY_BUFFER_SIZE) #define ASSERT_IN_DISPLAY(p) assert((p) >= displayBuf && (p) < DISPLAY_END) #if defined(PCBSTD) && defined(VOICE) @@ -164,10 +163,10 @@ typedef const char pm_char; #endif void lcd_putc(coord_t x, coord_t y, const unsigned char c); -void lcd_putcAtt(coord_t x, coord_t y, const unsigned char c, LcdFlags mode); -void lcd_putsAtt(coord_t x, coord_t y, const pm_char * s, LcdFlags mode); -void lcd_putsiAtt(coord_t x, coord_t y, const pm_char * s,uint8_t idx, LcdFlags mode); -void lcd_putsnAtt(coord_t x, coord_t y, const pm_char * s,unsigned char len, LcdFlags mode); +void lcdDrawChar(coord_t x, coord_t y, const unsigned char c, LcdFlags flags); +void lcdDrawText(coord_t x, coord_t y, const pm_char * s, LcdFlags flags); +void lcdDrawTextAtIndex(coord_t x, coord_t y, const pm_char * s,uint8_t idx, LcdFlags flags); +void lcdDrawTextWithLen(coord_t x, coord_t y, const pm_char * s,unsigned char len, LcdFlags flags); void lcd_puts(coord_t x, coord_t y, const pm_char * s); void lcd_putsn(coord_t x, coord_t y, const pm_char * s, unsigned char len); void lcd_putsLeft(coord_t y, const pm_char * s); @@ -227,24 +226,24 @@ void putsTimer(coord_t x, coord_t y, putstime_t tme, LcdFlags att, LcdFlags att2 void lcd_plot(coord_t x, coord_t y, LcdFlags att=0); void lcd_mask(uint8_t *p, uint8_t mask, LcdFlags att=0); void lcd_hline(coord_t x, coord_t y, coord_t w, LcdFlags att=0); -void lcd_hlineStip(coord_t x, coord_t y, coord_t w, uint8_t pat, LcdFlags att=0); +void lcdDrawHorizontalLine(coord_t x, coord_t y, coord_t w, uint8_t pat, LcdFlags att=0); void lcd_vline(coord_t x, scoord_t y, scoord_t h); #if defined(CPUM64) - void lcd_vlineStip(coord_t x, scoord_t y, int8_t h, uint8_t pat); + void lcdDrawVerticalLine(coord_t x, scoord_t y, int8_t h, uint8_t pat); #else - void lcd_vlineStip(coord_t x, scoord_t y, scoord_t h, uint8_t pat, LcdFlags att=0); + void lcdDrawVerticalLine(coord_t x, scoord_t y, scoord_t h, uint8_t pat, LcdFlags att=0); #endif #if defined(CPUARM) - void lcd_line(coord_t x1, coord_t y1, coord_t x2, coord_t y2, uint8_t pat=SOLID, LcdFlags att=0); + void lcdDrawLine(coord_t x1, coord_t y1, coord_t x2, coord_t y2, uint8_t pat=SOLID, LcdFlags att=0); #endif void drawFilledRect(coord_t x, scoord_t y, coord_t w, coord_t h, uint8_t pat=SOLID, LcdFlags att=0); -void lcd_rect(coord_t x, coord_t y, coord_t w, coord_t h, uint8_t pat=SOLID, LcdFlags att=0); +void lcdDrawRect(coord_t x, coord_t y, coord_t w, coord_t h, uint8_t pat=SOLID, LcdFlags att=0); void lcd_invert_line(int8_t line); #define lcd_status_line() lcd_invert_line(LCD_LINES-1) -inline void lcd_square(coord_t x, coord_t y, coord_t w, LcdFlags att=0) { lcd_rect(x, y, w, w, SOLID, att); } +inline void lcd_square(coord_t x, coord_t y, coord_t w, LcdFlags att=0) { lcdDrawRect(x, y, w, w, SOLID, att); } void lcdDrawTelemetryTopBar(); @@ -256,7 +255,7 @@ void lcdDrawTelemetryTopBar(); void lcd_img(coord_t x, coord_t y, const pm_uchar * img, uint8_t idx, LcdFlags att=0); void lcdSetRefVolt(unsigned char val); -void lcd_clear(); +void lcdClear(); void lcdSetContrast(); void lcdInit(); #define lcdOff() @@ -276,14 +275,4 @@ uint8_t lcdRefresh_ST7920(uint8_t full); #define BLINK_ON_PHASE (g_blinkTmr10ms & (1<<6)) #endif -#if defined(SIMU) - extern bool lcd_refresh; - extern display_t lcd_buf[DISPLAY_BUF_SIZE]; -#endif - -char *strAppend(char * dest, const char * source, int len=0); -char *strSetCursor(char *dest, int position); -char *strAppendDate(char * str, bool time=false); -char *strAppendFilename(char * dest, const char * filename, const int size); - #endif diff --git a/radio/src/gui/9X/menu_general.cpp b/radio/src/gui/9X/menu_general.cpp index d7d56ec13..461f15fbe 100644 --- a/radio/src/gui/9X/menu_general.cpp +++ b/radio/src/gui/9X/menu_general.cpp @@ -88,7 +88,7 @@ enum EnumTabDiag { e_Calib }; -const MenuFuncP_PROGMEM menuTabGeneral[] PROGMEM = { +const MenuFuncP menuTabGeneral[] PROGMEM = { menuGeneralSetup, CASE_SDCARD(menuGeneralSdManager) CASE_CPUARM(menuGeneralCustomFunctions) diff --git a/radio/src/gui/9X/menu_general_calib.cpp b/radio/src/gui/9X/menu_general_calib.cpp index 72e04e491..8e775eb63 100644 --- a/radio/src/gui/9X/menu_general_calib.cpp +++ b/radio/src/gui/9X/menu_general_calib.cpp @@ -75,7 +75,7 @@ void menuCommonCalib(uint8_t event) case 1: // SET MIDPOINT - lcd_putsAtt(0*FW, MENU_HEADER_HEIGHT+FH, STR_SETMIDPOINT, INVERS); + lcdDrawText(0*FW, MENU_HEADER_HEIGHT+FH, STR_SETMIDPOINT, INVERS); lcd_putsLeft(MENU_HEADER_HEIGHT+2*FH, STR_MENUWHENDONE); for (uint8_t i=0; iname, attr); + lcdDrawText(RADIO_SETUP_2ND_COLUMN, y, currentLanguagePack->name, attr); if (attr) { currentLanguagePackIdx = checkIncDec(event, currentLanguagePackIdx, 0, DIM(languagePacks)-2, EE_GENERAL); if (checkIncDec_Ret) { @@ -538,7 +538,7 @@ void menuGeneralSetup(uint8_t event) case ITEM_SETUP_SWITCHES_DELAY: lcd_putsLeft(y, STR_SWITCHES_DELAY); lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, 10*SWITCHES_DELAY(), attr|LEFT); - lcd_putsAtt(lcdLastPos, y, STR_MS, attr); + lcdDrawText(lcdLastPos, y, STR_MS, attr); if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.switchesDelay, -15, +15); break; #endif @@ -565,13 +565,13 @@ void menuGeneralSetup(uint8_t event) if (attr) { s_editMode = 0; CHECK_INCDEC_GENVAR(event, g_eeGeneral.stickReverse, 0, 15); - lcd_rect(6*FW-1, y-1, 15*FW+2, 9); + lcdDrawRect(6*FW-1, y-1, 15*FW+2, 9); } #endif break; case ITEM_SETUP_STICK_MODE: - lcd_putcAtt(2*FW, y, '1'+g_eeGeneral.stickMode, attr); + lcdDrawChar(2*FW, y, '1'+g_eeGeneral.stickMode, attr); for (uint8_t i=0; i<4; i++) { putsMixerSource((6+4*i)*FW, y, MIXSRC_Rud + pgm_read_byte(modn12x3 + 4*g_eeGeneral.stickMode + i), 0); } diff --git a/radio/src/gui/9X/menu_general_trainer.cpp b/radio/src/gui/9X/menu_general_trainer.cpp index cc24541f7..f7a685793 100644 --- a/radio/src/gui/9X/menu_general_trainer.cpp +++ b/radio/src/gui/9X/menu_general_trainer.cpp @@ -68,7 +68,7 @@ void menuGeneralTrainer(uint8_t event) switch(j) { case 0: - lcd_putsiAtt(4*FW, y, STR_TRNMODE, td->mode, attr); + lcdDrawTextAtIndex(4*FW, y, STR_TRNMODE, td->mode, attr); if (attr&BLINK) CHECK_INCDEC_GENVAR(event, td->mode, 0, 2); break; @@ -78,7 +78,7 @@ void menuGeneralTrainer(uint8_t event) break; case 2: - lcd_putsiAtt(12*FW, y, STR_TRNCHN, td->srcChn, attr); + lcdDrawTextAtIndex(12*FW, y, STR_TRNCHN, td->srcChn, attr); if (attr&BLINK) CHECK_INCDEC_GENVAR(event, td->srcChn, 0, 3); break; } @@ -93,7 +93,7 @@ void menuGeneralTrainer(uint8_t event) attr = (m_posVert==6) ? INVERS : 0; if (attr) s_editMode = 0; - lcd_putsAtt(0*FW, MENU_HEADER_HEIGHT+1+6*FH, STR_CAL, attr); + lcdDrawText(0*FW, MENU_HEADER_HEIGHT+1+6*FH, STR_CAL, attr); for (uint8_t i=0; i<4; i++) { uint8_t x = (i*TRAINER_CALIB_POS+16)*FW/2; #if defined (PPM_UNIT_PERCENT_PREC1) @@ -106,7 +106,7 @@ void menuGeneralTrainer(uint8_t event) if (attr) { if (event==EVT_KEY_LONG(KEY_ENTER)){ memcpy(g_eeGeneral.trainer.calib, ppmInput, sizeof(g_eeGeneral.trainer.calib)); - eeDirty(EE_GENERAL); + storageDirty(EE_GENERAL); AUDIO_WARNING1(); } } diff --git a/radio/src/gui/9X/menu_model.cpp b/radio/src/gui/9X/menu_model.cpp index 23cdc2456..5a4a28bc8 100644 --- a/radio/src/gui/9X/menu_model.cpp +++ b/radio/src/gui/9X/menu_model.cpp @@ -99,7 +99,7 @@ uint8_t editDelay(const coord_t y, const uint8_t event, const uint8_t attr, cons } #define EDIT_DELAY(x, y, event, attr, str, delay) editDelay(y, event, attr, str, delay) -const MenuFuncP_PROGMEM menuTabModel[] PROGMEM = { +const MenuFuncP menuTabModel[] PROGMEM = { menuModelSelect, menuModelSetup, CASE_HELI(menuModelHeli) @@ -142,7 +142,7 @@ void editName(coord_t x, coord_t y, char *name, uint8_t size, uint8_t event, uin mode = FIXEDWIDTH; } - lcd_putsnAtt(x, y, name, size, ZCHAR | mode); + lcdDrawTextWithLen(x, y, name, size, ZCHAR | mode); if (active) { uint8_t cur = editNameCursorPos; @@ -199,10 +199,10 @@ void editName(coord_t x, coord_t y, char *name, uint8_t size, uint8_t event, uin if (c != v) { name[cur] = v; - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } - lcd_putcAtt(x+editNameCursorPos*FW, y, idx2char(v), ERASEBG|INVERS|FIXEDWIDTH); + lcdDrawChar(x+editNameCursorPos*FW, y, idx2char(v), ERASEBG|INVERS|FIXEDWIDTH); } else { cur = 0; diff --git a/radio/src/gui/9X/menu_model_curves.cpp b/radio/src/gui/9X/menu_model_curves.cpp index bcfc77215..27420a502 100644 --- a/radio/src/gui/9X/menu_model_curves.cpp +++ b/radio/src/gui/9X/menu_model_curves.cpp @@ -98,7 +98,7 @@ bool moveCurve(uint8_t index, int8_t shift, int8_t custom=0) for (uint8_t i=0; i0 && iplay.name)) - lcd_putsnAtt(x, y, cfn->play.name, sizeof(cfn->play.name), attr); + lcdDrawTextWithLen(x, y, cfn->play.name, sizeof(cfn->play.name), attr); else - lcd_putsiAtt(x, y, STR_VCSWFUNC, 0, attr); + lcdDrawTextAtIndex(x, y, STR_VCSWFUNC, 0, attr); if (active && event==EVT_KEY_BREAK(KEY_ENTER)) { s_editMode = 0; char directory[256]; @@ -244,7 +244,7 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu strcpy(directory, SOUNDS_PATH); strncpy(directory+SOUNDS_PATH_LNG_OFS, currentLanguagePack->id, 2); } - if (listSdFiles(directory, func==FUNC_PLAY_SCRIPT ? SCRIPTS_EXT : SOUNDS_EXT, sizeof(cfn->play.name), cfn->play.name)) { + if (sdListFiles(directory, func==FUNC_PLAY_SCRIPT ? SCRIPTS_EXT : SOUNDS_EXT, sizeof(cfn->play.name), cfn->play.name)) { menuHandler = onCustomFunctionsFileSelectionMenu; } else { @@ -287,7 +287,7 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu #endif } else if (func == FUNC_PLAY_BOTH) { - lcd_putcAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN+3*FWNUM, y, '|', attr); + lcdDrawChar(MODEL_CUSTOM_FUNC_3RD_COLUMN+3*FWNUM, y, '|', attr); lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN+3*FWNUM, y, val_displayed+PROMPT_CUSTOM_BASE, attr); lcd_outdezAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN+2+3*FWNUM, y, (val_displayed+PROMPT_CUSTOM_BASE+1)%10, attr|LEFT); } @@ -304,7 +304,7 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu lcd_putc(lcdLastPos, y, 's'); } else { - lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_MMMINV, 0, attr); + lcdDrawTextAtIndex(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_MMMINV, 0, attr); } } #endif @@ -328,7 +328,7 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu break; default: // FUNC_ADJUST_GVAR_INC val_max = 1; - lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, PSTR("\003-=1+=1"), val_displayed, attr); + lcdDrawTextAtIndex(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, PSTR("\003-=1+=1"), val_displayed, attr); break; } @@ -365,11 +365,11 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu } else if (HAS_REPEAT_PARAM(func)) { if (CFN_PLAY_REPEAT(cfn) == 0) { - lcd_putcAtt(MODEL_CUSTOM_FUNC_4TH_COLUMN_ONOFF+3, y, '-', attr); + lcdDrawChar(MODEL_CUSTOM_FUNC_4TH_COLUMN_ONOFF+3, y, '-', attr); } #if defined(CPUARM) else if (CFN_PLAY_REPEAT(cfn) == CFN_PLAY_REPEAT_NOSTART) { - lcd_putsAtt(MODEL_CUSTOM_FUNC_4TH_COLUMN_ONOFF, y, "!-", attr); + lcdDrawText(MODEL_CUSTOM_FUNC_4TH_COLUMN_ONOFF, y, "!-", attr); } #endif else { diff --git a/radio/src/gui/9X/menu_model_flightmodes.cpp b/radio/src/gui/9X/menu_model_flightmodes.cpp index 231e82d79..158ad4c12 100644 --- a/radio/src/gui/9X/menu_model_flightmodes.cpp +++ b/radio/src/gui/9X/menu_model_flightmodes.cpp @@ -177,7 +177,7 @@ void menuModelPhaseOne(uint8_t event) putsFlightMode(11*FW, y, p+1, posHorz==1 ? attr : 0); } else { - lcd_putsAtt(11*FW, y, STR_OWN, posHorz==1 ? attr : 0); + lcdDrawText(11*FW, y, STR_OWN, posHorz==1 ? attr : 0); } if (attr && s_currIdx>0 && posHorz==1 && (editMode>0 || p1valdiff)) { if (v < GVAR_MAX) v = GVAR_MAX; @@ -253,7 +253,7 @@ void menuModelFlightModesAll(uint8_t event) FlightModeData *p = flightModeAddress(i); putsFlightMode(0, y, i+1, att|(getFlightMode()==i ? BOLD : 0)); - lcd_putsnAtt(4*FW+NAME_OFS, y, p->name, sizeof(p->name), ZCHAR); + lcdDrawTextWithLen(4*FW+NAME_OFS, y, p->name, sizeof(p->name), ZCHAR); if (i == 0) { lcd_puts((5+LEN_FLIGHT_MODE_NAME)*FW+SWITCH_OFS, y, STR_DEFAULT); } diff --git a/radio/src/gui/9X/menu_model_inputs_mixes.cpp b/radio/src/gui/9X/menu_model_inputs_mixes.cpp index de7c86825..33fd0d860 100644 --- a/radio/src/gui/9X/menu_model_inputs_mixes.cpp +++ b/radio/src/gui/9X/menu_model_inputs_mixes.cpp @@ -55,7 +55,7 @@ FlightModesType editFlightModes(coord_t x, coord_t y, uint8_t event, FlightModes if (expoMenu && ((attr && p < posHorz-4) || (x > EXPO_ONE_2ND_COLUMN-FW))) continue; #endif - lcd_putcAtt(x, y, '0'+p, ((posHorz==p) && attr) ? BLINK|INVERS : ((value & (1<weight = 100; } resumeMixerCalculations(); - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } void copyExpoMix(uint8_t expo, uint8_t idx) @@ -183,7 +183,7 @@ void copyExpoMix(uint8_t expo, uint8_t idx) memmove(mix+1, mix, (MAX_MIXERS-(idx+1))*sizeof(MixData)); } resumeMixerCalculations(); - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } void memswap(void *a, void *b, uint8_t size) @@ -327,7 +327,7 @@ void menuModelExpoOne(uint8_t event) ed->curveParam = GVAR_MENU_ITEM(EXPO_ONE_2ND_COLUMN, y, ed->curveParam, -100, 100, attr, 0, event); } else { - lcd_putsAtt(EXPO_ONE_2ND_COLUMN-3*FW, y, STR_NA, attr); + lcdDrawText(EXPO_ONE_2ND_COLUMN-3*FW, y, STR_NA, attr); } break; @@ -346,7 +346,7 @@ void menuModelExpoOne(uint8_t event) } } else { - lcd_putsAtt(EXPO_ONE_2ND_COLUMN-3*FW, y, STR_NA, attr); + lcdDrawText(EXPO_ONE_2ND_COLUMN-3*FW, y, STR_NA, attr); } break; #endif @@ -435,8 +435,8 @@ void drawOffsetBar(uint8_t x, uint8_t y, MixData * md) barMin = -101; if (barMax > 101) barMax = 101; - lcd_hlineStip(x-2, y, GAUGE_WIDTH+2, DOTTED); - lcd_hlineStip(x-2, y+GAUGE_HEIGHT, GAUGE_WIDTH+2, DOTTED); + lcdDrawHorizontalLine(x-2, y, GAUGE_WIDTH+2, DOTTED); + lcdDrawHorizontalLine(x-2, y+GAUGE_HEIGHT, GAUGE_WIDTH+2, DOTTED); lcd_vline(x-2, y+1, GAUGE_HEIGHT-1); lcd_vline(x+GAUGE_WIDTH-1, y+1, GAUGE_HEIGHT-1); if (barMin <= barMax) { @@ -541,7 +541,7 @@ void menuModelMixOne(uint8_t event) uint8_t not_stick = (md2->srcRaw > NUM_STICKS); int8_t carryTrim = -md2->carryTrim; lcd_putsColumnLeft(COLUMN_X, y, STR_TRIM); - lcd_putsiAtt((not_stick ? COLUMN_X+MIXES_2ND_COLUMN : COLUMN_X+6*FW-3), y, STR_VMIXTRIMS, (not_stick && carryTrim == 0) ? 0 : carryTrim+1, m_posHorz==0 ? attr : 0); + lcdDrawTextAtIndex((not_stick ? COLUMN_X+MIXES_2ND_COLUMN : COLUMN_X+6*FW-3), y, STR_VMIXTRIMS, (not_stick && carryTrim == 0) ? 0 : carryTrim+1, m_posHorz==0 ? attr : 0); if (attr && m_posHorz==0 && (not_stick || editMode>0)) md2->carryTrim = -checkIncDecModel(event, carryTrim, not_stick ? TRIM_ON : -TRIM_OFF, -TRIM_AIL); if (!not_stick) { lcd_puts(COLUMN_X+MIXES_2ND_COLUMN, y, STR_DREX); @@ -574,7 +574,7 @@ void menuModelMixOne(uint8_t event) } } else { - lcd_putsAtt(COLUMN_X+MIXES_2ND_COLUMN, y, PSTR("Diff"), m_posHorz==0 ? attr : 0); + lcdDrawText(COLUMN_X+MIXES_2ND_COLUMN, y, PSTR("Diff"), m_posHorz==0 ? attr : 0); md2->curveParam = GVAR_MENU_ITEM(COLUMN_X+MIXES_2ND_COLUMN+5*FW, y, curveParam, -100, 100, LEFT|(m_posHorz==1 ? attr : 0), 0, editMode>0 ? event : 0); if (attr && editMode>0 && m_posHorz==0) { int8_t tmp = 0; @@ -601,7 +601,7 @@ void menuModelMixOne(uint8_t event) if (md2->mixWarn) lcd_outdezAtt(COLUMN_X+MIXES_2ND_COLUMN, y, md2->mixWarn, attr|LEFT); else - lcd_putsAtt(COLUMN_X+MIXES_2ND_COLUMN, y, STR_OFF, attr); + lcdDrawText(COLUMN_X+MIXES_2ND_COLUMN, y, STR_OFF, attr); if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, md2->mixWarn, 3); break; case MIX_FIELD_MLTPX: @@ -708,7 +708,7 @@ void displayMixInfos(coord_t y, MixData *md) void displayMixLine(coord_t y, MixData *md) { if (md->name[0]) { - lcd_putsnAtt(EXPO_LINE_NAME_POS, y, md->name, sizeof(md->name), ZCHAR); + lcdDrawTextWithLen(EXPO_LINE_NAME_POS, y, md->name, sizeof(md->name), ZCHAR); } else { displayMixInfos(y, md); @@ -734,7 +734,7 @@ void displayExpoLine(coord_t y, ExpoData *ed) displayExpoInfos(y, ed); if (ed->name[0]) { - lcd_putsnAtt(EXPO_LINE_NAME_POS, y, ed->name, sizeof(ed->name), ZCHAR); + lcdDrawTextWithLen(EXPO_LINE_NAME_POS, y, ed->name, sizeof(ed->name), ZCHAR); } } #else @@ -784,7 +784,7 @@ void menuModelExpoMix(uint8_t expo, uint8_t event) swapExpoMix(expo, s_currIdx, s_copyTgtOfs > 0); s_copyTgtOfs += (s_copyTgtOfs < 0 ? +1 : -1); } while (s_copyTgtOfs != 0); - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } m_posVert = s_copySrcRow; s_copyTgtOfs = 0; @@ -867,30 +867,30 @@ void menuModelExpoMix(uint8_t expo, uint8_t event) case EVT_ROTARY_LEFT: case EVT_ROTARY_RIGHT: #endif - case EVT_KEY_FIRST(KEY_MOVE_UP): - case EVT_KEY_REPT(KEY_MOVE_UP): - case EVT_KEY_FIRST(KEY_MOVE_DOWN): - case EVT_KEY_REPT(KEY_MOVE_DOWN): + case EVT_KEY_FIRST(KEY_UP): + case EVT_KEY_REPT(KEY_UP): + case EVT_KEY_FIRST(KEY_DOWN): + case EVT_KEY_REPT(KEY_DOWN): if (s_copyMode) { uint8_t key = (event & 0x1f); - uint8_t next_ofs = ((IS_ROTARY_UP(event) || key==KEY_MOVE_UP) ? s_copyTgtOfs - 1 : s_copyTgtOfs + 1); + uint8_t next_ofs = ((IS_ROTARY_LEFT(event) || key==KEY_UP) ? s_copyTgtOfs - 1 : s_copyTgtOfs + 1); if (s_copyTgtOfs==0 && s_copyMode==COPY_MODE) { // insert a mix on the same channel (just above / just below) if (reachExpoMixCountLimit(expo)) break; copyExpoMix(expo, s_currIdx); - if (IS_ROTARY_DOWN(event) || key==KEY_MOVE_DOWN) s_currIdx++; + if (IS_ROTARY_RIGHT(event) || key==KEY_DOWN) s_currIdx++; else if (sub-s_pgOfs >= 6) s_pgOfs++; } else if (next_ofs==0 && s_copyMode==COPY_MODE) { // delete the mix deleteExpoMix(expo, s_currIdx); - if (IS_ROTARY_UP(event) || key==KEY_MOVE_UP) s_currIdx--; + if (IS_ROTARY_LEFT(event) || key==KEY_UP) s_currIdx--; } else { // only swap the mix with its neighbor - if (!swapExpoMix(expo, s_currIdx, IS_ROTARY_UP(event) || key==KEY_MOVE_UP)) break; - eeDirty(EE_MODEL); + if (!swapExpoMix(expo, s_currIdx, IS_ROTARY_LEFT(event) || key==KEY_UP)) break; + storageDirty(EE_MODEL); } s_copyTgtOfs = next_ofs; @@ -924,7 +924,7 @@ void menuModelExpoMix(uint8_t expo, uint8_t event) do { if (s_copyMode) { if (s_copyMode == MOVE_MODE && s_pgOfs < cur && cur-s_pgOfs < 8 && s_copySrcCh == ch && s_copyTgtOfs != 0 && i == (s_copySrcIdx + (s_copyTgtOfs<0))) { - lcd_rect(expo ? 18 : 22, y-1, expo ? LCD_W-18 : LCD_W-22, 9, DOTTED); + lcdDrawRect(expo ? 18 : 22, y-1, expo ? LCD_W-18 : LCD_W-22, 9, DOTTED); cur++; y+=FH; } if (s_currIdx == i) { @@ -945,7 +945,7 @@ void menuModelExpoMix(uint8_t expo, uint8_t event) } } else { - if (mixCnt > 0) lcd_putsiAtt(FW, y, STR_VMLTPX2, md->mltpx, 0); + if (mixCnt > 0) lcdDrawTextAtIndex(FW, y, STR_VMLTPX2, md->mltpx, 0); putsMixerSource(MIX_LINE_SRC_POS, y, md->srcRaw, 0); @@ -963,7 +963,7 @@ void menuModelExpoMix(uint8_t expo, uint8_t event) if (s_copyMode) { if ((s_copyMode==COPY_MODE || s_copyTgtOfs == 0) && s_copySrcCh == ch && i == (s_copySrcIdx + (s_copyTgtOfs<0))) { /* draw a border around the raw on selection mode (copy/move) */ - lcd_rect(expo ? EXPO_LINE_SELECT_POS : 22, y-1, expo ? (LCD_W-EXPO_LINE_SELECT_POS) : (LCD_W-22), 9, s_copyMode == COPY_MODE ? SOLID : DOTTED); + lcdDrawRect(expo ? EXPO_LINE_SELECT_POS : 22, y-1, expo ? (LCD_W-EXPO_LINE_SELECT_POS) : (LCD_W-22), 9, s_copyMode == COPY_MODE ? SOLID : DOTTED); } if (cur == sub) { /* invert the raw when it's the current one */ @@ -974,7 +974,7 @@ void menuModelExpoMix(uint8_t expo, uint8_t event) cur++; y+=FH; mixCnt++; i++; if (expo) ed++; else md++; } while (expo ? (ichn+1 == ch && EXPO_VALID(ed)) : (isrcRaw && md->destCh+1 == ch)); if (s_copyMode == MOVE_MODE && s_pgOfs < cur && cur-s_pgOfs < LCD_LINES && s_copySrcCh == ch && i == (s_copySrcIdx + (s_copyTgtOfs<0))) { - lcd_rect(expo ? EXPO_LINE_SELECT_POS : 22, y-1, expo ? LCD_W-EXPO_LINE_SELECT_POS : LCD_W-22, 9, DOTTED); + lcdDrawRect(expo ? EXPO_LINE_SELECT_POS : 22, y-1, expo ? LCD_W-EXPO_LINE_SELECT_POS : LCD_W-22, 9, DOTTED); cur++; y+=FH; } } @@ -995,7 +995,7 @@ void menuModelExpoMix(uint8_t expo, uint8_t event) putsChn(0, y, ch, attr); // show CHx } if (s_copyMode == MOVE_MODE && s_copySrcCh == ch) { - lcd_rect(expo ? EXPO_LINE_SELECT_POS : 22, y-1, expo ? (LCD_W-EXPO_LINE_SELECT_POS) : (LCD_W-22), 9, DOTTED); + lcdDrawRect(expo ? EXPO_LINE_SELECT_POS : 22, y-1, expo ? (LCD_W-EXPO_LINE_SELECT_POS) : (LCD_W-22), 9, DOTTED); } } cur++; y+=FH; diff --git a/radio/src/gui/9X/menu_model_limits.cpp b/radio/src/gui/9X/menu_model_limits.cpp index e0b5eba2d..83c256ee6 100644 --- a/radio/src/gui/9X/menu_model_limits.cpp +++ b/radio/src/gui/9X/menu_model_limits.cpp @@ -125,7 +125,7 @@ void menuModelLimits(uint8_t event) s_warning_result = 0; LimitData *ld = limitAddress(sub); ld->revert = !ld->revert; - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } for (uint8_t i=0; irevert; #if defined(PPM_CENTER_ADJUSTABLE) - lcd_putcAtt(LIMITS_REVERT_POS, y, revert ? 127 : 126, attr); + lcdDrawChar(LIMITS_REVERT_POS, y, revert ? 127 : 126, attr); #else - lcd_putsiAtt(LIMITS_REVERT_POS, y, STR_MMMINV, revert, attr); + lcdDrawTextAtIndex(LIMITS_REVERT_POS, y, STR_MMMINV, revert, attr); #endif if (active) { uint8_t revert_new = checkIncDecModel(event, revert, 0, 1); @@ -237,9 +237,9 @@ void menuModelLimits(uint8_t event) #if defined(PPM_LIMITS_SYMETRICAL) case ITEM_LIMITS_SYMETRICAL: #if defined(CPUARM) - lcd_putcAtt(LCD_W-FW-MENUS_SCROLLBAR_WIDTH, y, ld->symetrical ? '=' : '\306', attr); + lcdDrawChar(LCD_W-FW-MENUS_SCROLLBAR_WIDTH, y, ld->symetrical ? '=' : '\306', attr); #else - lcd_putcAtt(LCD_W-FW-MENUS_SCROLLBAR_WIDTH, y, ld->symetrical ? '=' : '^', attr); + lcdDrawChar(LCD_W-FW-MENUS_SCROLLBAR_WIDTH, y, ld->symetrical ? '=' : '^', attr); #endif if (active) { CHECK_INCDEC_MODELVAR_ZERO(event, ld->symetrical, 1); diff --git a/radio/src/gui/9X/menu_model_logical_switches.cpp b/radio/src/gui/9X/menu_model_logical_switches.cpp index 138a74d62..a66dbcd90 100644 --- a/radio/src/gui/9X/menu_model_logical_switches.cpp +++ b/radio/src/gui/9X/menu_model_logical_switches.cpp @@ -77,9 +77,9 @@ void putsEdgeDelayParam(coord_t x, coord_t y, LogicalSwitchData *cs, uint8_t lat lcd_outdezAtt(x, y, lswTimerValue(cs->v2), LEFT|PREC1|lattr); lcd_putc(lcdLastPos, y, ':'); if (cs->v3 < 0) - lcd_putsAtt(lcdLastPos+3, y, "<<", rattr); + lcdDrawText(lcdLastPos+3, y, "<<", rattr); else if (cs->v3 == 0) - lcd_putsAtt(lcdLastPos+3, y, "--", rattr); + lcdDrawText(lcdLastPos+3, y, "--", rattr); else lcd_outdezAtt(lcdLastPos+3, y, lswTimerValue(cs->v2+cs->v3), LEFT|PREC1|rattr); lcd_putc(lcdLastPos, y, ']'); @@ -114,7 +114,7 @@ void menuModelLogicalSwitchOne(uint8_t event) switch(i) { case LS_FIELD_FUNCTION: lcd_putsLeft(y, STR_FUNC); - lcd_putsiAtt(CSWONE_2ND_COLUMN, y, STR_VCSWFUNC, cs->func, attr); + lcdDrawTextAtIndex(CSWONE_2ND_COLUMN, y, STR_VCSWFUNC, cs->func, attr); if (attr) { cs->func = checkIncDec(event, cs->func, 0, LS_FUNC_MAX, EE_MODEL, isLogicalSwitchFunctionAvailable); uint8_t new_cstate = lswFamily(cs->func); @@ -200,7 +200,7 @@ void menuModelLogicalSwitchOne(uint8_t event) INCDEC_SET_FLAG(EE_MODEL | INCDEC_REP10 | NO_INCDEC_MARKS); if (cs->v2 < v2_min || cs->v2 > v2_max) { cs->v2 = 0; - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } } else @@ -226,7 +226,7 @@ void menuModelLogicalSwitchOne(uint8_t event) if (cs->duration > 0) lcd_outdezAtt(CSWONE_2ND_COLUMN, y, cs->duration, attr|PREC1|LEFT); else - lcd_putsiAtt(CSWONE_2ND_COLUMN, y, STR_MMMINV, 0, attr); + lcdDrawTextAtIndex(CSWONE_2ND_COLUMN, y, STR_MMMINV, 0, attr); if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, cs->duration, MAX_LS_DURATION); break; case LS_FIELD_DELAY: @@ -234,7 +234,7 @@ void menuModelLogicalSwitchOne(uint8_t event) if (cs->delay > 0) lcd_outdezAtt(CSWONE_2ND_COLUMN, y, cs->delay, attr|PREC1|LEFT); else - lcd_putsiAtt(CSWONE_2ND_COLUMN, y, STR_MMMINV, 0, attr); + lcdDrawTextAtIndex(CSWONE_2ND_COLUMN, y, STR_MMMINV, 0, attr); if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, cs->delay, MAX_LS_DELAY); break; } @@ -274,7 +274,7 @@ void menuModelLogicalSwitches(uint8_t event) if (cs->func > 0) { // CSW func - lcd_putsiAtt(CSW_1ST_COLUMN, y, STR_VCSWFUNC, cs->func, 0); + lcdDrawTextAtIndex(CSW_1ST_COLUMN, y, STR_VCSWFUNC, cs->func, 0); // CSW params uint8_t cstate = lswFamily(cs->func); @@ -341,7 +341,7 @@ void menuModelLogicalSwitches(uint8_t event) putsSwitches(0, y, sw, (getSwitch(sw) ? BOLD : 0) | ((sub==k && CURSOR_ON_LINE()) ? INVERS : 0)); // CSW func - lcd_putsiAtt(CSW_1ST_COLUMN, y, STR_VCSWFUNC, cs->func, horz==0 ? attr : 0); + lcdDrawTextAtIndex(CSW_1ST_COLUMN, y, STR_VCSWFUNC, cs->func, horz==0 ? attr : 0); // CSW params uint8_t cstate = lswFamily(cs->func); @@ -427,7 +427,7 @@ void menuModelLogicalSwitches(uint8_t event) INCDEC_SET_FLAG(EE_MODEL | INCDEC_REP10 | NO_INCDEC_MARKS); if (cs->v2 < v2_min || cs->v2 > v2_max) { cs->v2 = 0; - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } #else if (cstate == LS_FAMILY_OFS) { @@ -440,7 +440,7 @@ void menuModelLogicalSwitches(uint8_t event) } if (cs->v2 > v2_max) { cs->v2 = v2_max; - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } #endif } @@ -484,7 +484,7 @@ void menuModelLogicalSwitches(uint8_t event) if (cs->duration > 0) lcd_outdezAtt(CSW_5TH_COLUMN, y, cs->duration, (horz==LS_FIELD_DURATION ? attr : 0)|PREC1|LEFT); else - lcd_putsiAtt(CSW_5TH_COLUMN, y, STR_MMMINV, 0, horz==LS_FIELD_DURATION ? attr : 0); + lcdDrawTextAtIndex(CSW_5TH_COLUMN, y, STR_MMMINV, 0, horz==LS_FIELD_DURATION ? attr : 0); // CSW delay if (cstate == LS_FAMILY_EDGE) { @@ -497,7 +497,7 @@ void menuModelLogicalSwitches(uint8_t event) lcd_outdezAtt(CSW_6TH_COLUMN, y, cs->delay, (horz==LS_FIELD_DELAY ? attr : 0)|PREC1|LEFT); } else { - lcd_putsiAtt(CSW_6TH_COLUMN, y, STR_MMMINV, 0, horz==LS_FIELD_DELAY ? attr : 0); + lcdDrawTextAtIndex(CSW_6TH_COLUMN, y, STR_MMMINV, 0, horz==LS_FIELD_DELAY ? attr : 0); } if (attr && horz == LS_FIELD_V3 && cstate != LS_FAMILY_EDGE) { diff --git a/radio/src/gui/9X/menu_model_select.cpp b/radio/src/gui/9X/menu_model_select.cpp index c88a9eb28..f763de8b2 100644 --- a/radio/src/gui/9X/menu_model_select.cpp +++ b/radio/src/gui/9X/menu_model_select.cpp @@ -58,11 +58,11 @@ void onModelSelectMenu(const char *result) } #if defined(SDCARD) else if (result == STR_BACKUP_MODEL) { - eeCheck(true); // force writing of current model data before this is changed + storageCheck(true); // force writing of current model data before this is changed POPUP_WARNING(eeBackupModel(sub)); } else if (result == STR_RESTORE_MODEL || result == STR_UPDATE_LIST) { - if (!listSdFiles(MODELS_PATH, MODELS_EXT, MENU_LINE_LENGTH-1, NULL)) { + if (!sdListFiles(MODELS_PATH, MODELS_EXT, MENU_LINE_LENGTH-1, NULL)) { POPUP_WARNING(STR_NO_MODELS_ON_SD); s_menu_flags = 0; } @@ -132,7 +132,7 @@ void menuModelSelect(uint8_t event) if (sub >= LCD_LINES-1) s_pgOfs = sub-LCD_LINES+2; s_copyMode = 0; s_editMode = EDIT_MODE_INIT; - eeCheck(true); + storageCheck(true); break; case EVT_KEY_LONG(KEY_EXIT): @@ -200,7 +200,7 @@ void menuModelSelect(uint8_t event) } else if (s_copyMode && (s_copyTgtOfs || s_copySrcRow>=0)) { displayPopup(s_copyMode==COPY_MODE ? STR_COPYINGMODEL : STR_MOVINGMODEL); - eeCheck(true); // force writing of current model data before this is changed + storageCheck(true); // force writing of current model data before this is changed uint8_t cur = (MAX_MODELS + sub + s_copyTgtOfs) % MAX_MODELS; @@ -223,7 +223,7 @@ void menuModelSelect(uint8_t event) if (s_copySrcRow != g_eeGeneral.currModel) { g_eeGeneral.currModel = s_copySrcRow; - eeDirty(EE_GENERAL); + storageDirty(EE_GENERAL); } s_copyMode = 0; @@ -290,10 +290,10 @@ void menuModelSelect(uint8_t event) // no break #endif - case EVT_KEY_FIRST(KEY_MOVE_UP): - case EVT_KEY_REPT(KEY_MOVE_UP): - case EVT_KEY_FIRST(KEY_MOVE_DOWN): - case EVT_KEY_REPT(KEY_MOVE_DOWN): + case EVT_KEY_FIRST(KEY_UP): + case EVT_KEY_REPT(KEY_UP): + case EVT_KEY_FIRST(KEY_DOWN): + case EVT_KEY_REPT(KEY_DOWN): if (s_copyMode) { int8_t next_ofs = s_copyTgtOfs + oldSub - m_posVert; if (next_ofs == MAX_MODELS || next_ofs == -MAX_MODELS) @@ -302,7 +302,7 @@ void menuModelSelect(uint8_t event) if (s_copySrcRow < 0 && s_copyMode==COPY_MODE) { s_copySrcRow = oldSub; // find a hole (in the first empty slot above / below) - sub = eeFindEmptyModel(s_copySrcRow, IS_ROTARY_DOWN(event) || event==EVT_KEY_FIRST(KEY_MOVE_DOWN)); + sub = eeFindEmptyModel(s_copySrcRow, IS_ROTARY_RIGHT(event) || event==EVT_KEY_FIRST(KEY_DOWN)); if (sub < 0) { // no free room for duplicating the model AUDIO_ERROR(); @@ -370,7 +370,7 @@ void menuModelSelect(uint8_t event) if (s_copyMode && (vertpos_t)sub==i+s_pgOfs) { drawFilledRect(9, y, MODELSEL_W-1-9, 7); - lcd_rect(8, y-1, MODELSEL_W-1-7, 9, s_copyMode == COPY_MODE ? SOLID : DOTTED); + lcdDrawRect(8, y-1, MODELSEL_W-1-7, 9, s_copyMode == COPY_MODE ? SOLID : DOTTED); } } } diff --git a/radio/src/gui/9X/menu_model_setup.cpp b/radio/src/gui/9X/menu_model_setup.cpp index 17bd92e60..19843992e 100644 --- a/radio/src/gui/9X/menu_model_setup.cpp +++ b/radio/src/gui/9X/menu_model_setup.cpp @@ -213,7 +213,7 @@ void menuModelSetup(uint8_t event) int8_t switchVal = checkIncDecMovedSwitch(val); if (val != switchVal) { timer->mode = switchVal + (TMRMODE_COUNT-1); - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } } #endif @@ -327,7 +327,7 @@ void menuModelSetup(uint8_t event) ON_OFF_MENU_ITEM(g_model.extendedTrims, MODEL_SETUP_2ND_COLUMN, y, STR_ETRIMS, attr, event); #else ON_OFF_MENU_ITEM(g_model.extendedTrims, MODEL_SETUP_2ND_COLUMN, y, STR_ETRIMS, m_posHorz<=0 ? attr : 0, event==EVT_KEY_BREAK(KEY_ENTER) ? event : 0); - lcd_putsAtt(MODEL_SETUP_2ND_COLUMN+3*FW, y, STR_RESET_BTN, m_posHorz>0 && !s_noHi ? attr : 0); + lcdDrawText(MODEL_SETUP_2ND_COLUMN+3*FW, y, STR_RESET_BTN, m_posHorz>0 && !s_noHi ? attr : 0); if (attr && m_posHorz>0) { s_editMode = 0; if (event==EVT_KEY_LONG(KEY_ENTER)) { @@ -335,7 +335,7 @@ void menuModelSetup(uint8_t event) for (uint8_t i=0; i0 || p1valdiff)) { switch (m_posHorz) { case 0: @@ -540,7 +540,7 @@ void menuModelSetup(uint8_t event) ModuleData & moduleData = g_model.moduleData[moduleIdx]; lcd_putsLeft(y, STR_CHANNELRANGE); if ((int8_t)PORT_CHANNELS_ROWS(moduleIdx) >= 0) { - lcd_putsAtt(MODEL_SETUP_2ND_COLUMN, y, STR_CH, m_posHorz==0 ? attr : 0); + lcdDrawText(MODEL_SETUP_2ND_COLUMN, y, STR_CH, m_posHorz==0 ? attr : 0); lcd_outdezAtt(lcdLastPos, y, moduleData.channelsStart+1, LEFT | (m_posHorz==0 ? attr : 0)); lcd_putc(lcdLastPos, y, '-'); lcd_outdezAtt(lcdLastPos + FW+1, y, moduleData.channelsStart+NUM_CHANNELS(moduleIdx), LEFT | (m_posHorz==1 ? attr : 0)); @@ -576,7 +576,7 @@ void menuModelSetup(uint8_t event) lcd_outdezAtt(MODEL_SETUP_2ND_COLUMN, y, (int16_t)moduleData.ppmFrameLength*5 + 225, (m_posHorz<=0 ? attr : 0) | PREC1|LEFT); lcd_putc(MODEL_SETUP_2ND_COLUMN+8*FW+2, y, 'u'); lcd_outdezAtt(MODEL_SETUP_2ND_COLUMN+8*FW+2, y, (moduleData.ppmDelay*50)+300, (CURSOR_ON_LINE() || m_posHorz==1) ? attr : 0); - lcd_putcAtt(MODEL_SETUP_2ND_COLUMN+10*FW, y, moduleData.ppmPulsePol ? '+' : '-', (CURSOR_ON_LINE() || m_posHorz==2) ? attr : 0); + lcdDrawChar(MODEL_SETUP_2ND_COLUMN+10*FW, y, moduleData.ppmPulsePol ? '+' : '-', (CURSOR_ON_LINE() || m_posHorz==2) ? attr : 0); if (attr && (editMode>0 || p1valdiff)) { switch (m_posHorz) { @@ -616,8 +616,8 @@ void menuModelSetup(uint8_t event) checkModelIdUnique(g_eeGeneral.currModel, moduleIdx); } } - lcd_putsAtt(MODEL_SETUP_2ND_COLUMN+xOffsetBind, y, STR_MODULE_BIND, l_posHorz==1 ? attr : 0); - lcd_putsAtt(MODEL_SETUP_2ND_COLUMN+MODEL_SETUP_RANGE_OFS+xOffsetBind, y, STR_MODULE_RANGE, l_posHorz==2 ? attr : 0); + lcdDrawText(MODEL_SETUP_2ND_COLUMN+xOffsetBind, y, STR_MODULE_BIND, l_posHorz==1 ? attr : 0); + lcdDrawText(MODEL_SETUP_2ND_COLUMN+MODEL_SETUP_RANGE_OFS+xOffsetBind, y, STR_MODULE_RANGE, l_posHorz==2 ? attr : 0); uint8_t newFlag = 0; if (attr && l_posHorz>0 && s_editMode>0) { if (l_posHorz == 1) @@ -650,8 +650,8 @@ void menuModelSetup(uint8_t event) ModuleData & moduleData = g_model.moduleData[moduleIdx]; lcd_putsLeft(y, TR_FAILSAFE); if (IS_MODULE_XJT(moduleIdx)) { - lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN, y, STR_VFAILSAFE, moduleData.failsafeMode, m_posHorz==0 ? attr : 0); - if (moduleData.failsafeMode == FAILSAFE_CUSTOM) lcd_putsAtt(MODEL_SETUP_2ND_COLUMN + MODEL_SETUP_SET_FAILSAFE_OFS, y, STR_SET, m_posHorz==1 ? attr : 0); + lcdDrawTextAtIndex(MODEL_SETUP_2ND_COLUMN, y, STR_VFAILSAFE, moduleData.failsafeMode, m_posHorz==0 ? attr : 0); + if (moduleData.failsafeMode == FAILSAFE_CUSTOM) lcdDrawText(MODEL_SETUP_2ND_COLUMN + MODEL_SETUP_SET_FAILSAFE_OFS, y, STR_SET, m_posHorz==1 ? attr : 0); if (attr) { if (moduleData.failsafeMode != FAILSAFE_CUSTOM) m_posHorz = 0; @@ -680,9 +680,9 @@ void menuModelSetup(uint8_t event) #if !defined(CPUARM) case ITEM_MODEL_PPM1_PROTOCOL: lcd_putsLeft(y, NO_INDENT(STR_PROTO)); - lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN, y, STR_VPROTOS, protocol, m_posHorz<=0 ? attr : 0); + lcdDrawTextAtIndex(MODEL_SETUP_2ND_COLUMN, y, STR_VPROTOS, protocol, m_posHorz<=0 ? attr : 0); if (IS_PPM_PROTOCOL(protocol)) { - lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN+7*FW, y, STR_NCHANNELS, g_model.ppmNCH+2, m_posHorz!=0 ? attr : 0); + lcdDrawTextAtIndex(MODEL_SETUP_2ND_COLUMN+7*FW, y, STR_NCHANNELS, g_model.ppmNCH+2, m_posHorz!=0 ? attr : 0); } else if (m_posHorz>0 && attr) { MOVE_CURSOR_FROM_HERE(); @@ -704,8 +704,8 @@ void menuModelSetup(uint8_t event) #if 0 case ITEM_MODEL_PPM2_PROTOCOL: lcd_putsLeft(y, PSTR("Port2")); - lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN, y, STR_VPROTOS, 0, 0); - lcd_putsAtt(MODEL_SETUP_2ND_COLUMN+4*FW+3, y, STR_CH, m_posHorz<=0 ? attr : 0); + lcdDrawTextAtIndex(MODEL_SETUP_2ND_COLUMN, y, STR_VPROTOS, 0, 0); + lcdDrawText(MODEL_SETUP_2ND_COLUMN+4*FW+3, y, STR_CH, m_posHorz<=0 ? attr : 0); lcd_outdezAtt(lcdLastPos, y, g_model.moduleData[1].channelsStart+1, LEFT | (m_posHorz<=0 ? attr : 0)); lcd_putc(lcdLastPos, y, '-'); lcd_outdezAtt(lcdLastPos + FW+1, y, g_model.moduleData[1].channelsStart+8+g_model.moduleData[1].channelsCount, LEFT | (m_posHorz!=0 ? attr : 0)); @@ -729,7 +729,7 @@ void menuModelSetup(uint8_t event) lcd_outdezAtt(MODEL_SETUP_2ND_COLUMN, y, (int16_t)g_model.moduleData[1].ppmFrameLength*5 + 225, (m_posHorz<=0 ? attr : 0) | PREC1|LEFT); lcd_putc(MODEL_SETUP_2ND_COLUMN+8*FW+2, y, 'u'); lcd_outdezAtt(MODEL_SETUP_2ND_COLUMN+8*FW+2, y, (g_model.moduleData[1].ppmDelay*50)+300, (m_posHorz < 0 || m_posHorz==1) ? attr : 0); - lcd_putcAtt(MODEL_SETUP_2ND_COLUMN+10*FW, y, g_model.moduleData[1].ppmPulsePol ? '+' : '-', (m_posHorz < 0 || m_posHorz==2) ? attr : 0); + lcdDrawChar(MODEL_SETUP_2ND_COLUMN+10*FW, y, g_model.moduleData[1].ppmPulsePol ? '+' : '-', (m_posHorz < 0 || m_posHorz==2) ? attr : 0); if (attr && (editMode>0 || p1valdiff)) { switch (m_posHorz) { case 0: @@ -754,7 +754,7 @@ void menuModelSetup(uint8_t event) lcd_outdezAtt(MODEL_SETUP_2ND_COLUMN, y, (int16_t)g_model.ppmFrameLength*5 + 225, (m_posHorz<=0 ? attr : 0) | PREC1|LEFT); lcd_putc(MODEL_SETUP_2ND_COLUMN+8*FW+2, y, 'u'); lcd_outdezAtt(MODEL_SETUP_2ND_COLUMN+8*FW+2, y, (g_model.ppmDelay*50)+300, (CURSOR_ON_LINE() || m_posHorz==1) ? attr : 0); - lcd_putcAtt(MODEL_SETUP_2ND_COLUMN+10*FW, y, g_model.pulsePol ? '+' : '-', (CURSOR_ON_LINE() || m_posHorz==2) ? attr : 0); + lcdDrawChar(MODEL_SETUP_2ND_COLUMN+10*FW, y, g_model.pulsePol ? '+' : '-', (CURSOR_ON_LINE() || m_posHorz==2) ? attr : 0); if (attr && (editMode>0 || p1valdiff)) { switch (m_posHorz) { case 0: @@ -781,7 +781,7 @@ void menuModelSetup(uint8_t event) } #if defined(PXX) if (protocol == PROTO_PXX) { - lcd_putsAtt(MODEL_SETUP_2ND_COLUMN+4*FW, y, STR_SYNCMENU, m_posHorz!=0 ? attr : 0); + lcdDrawText(MODEL_SETUP_2ND_COLUMN+4*FW, y, STR_SYNCMENU, m_posHorz!=0 ? attr : 0); uint8_t newFlag = 0; if (attr && m_posHorz>0 && editMode>0) { // send reset code @@ -792,7 +792,7 @@ void menuModelSetup(uint8_t event) #endif #if defined(DSM2) if (IS_DSM2_PROTOCOL(protocol)) { - lcd_putsAtt(MODEL_SETUP_2ND_COLUMN+4*FW, y, STR_MODULE_RANGE, m_posHorz!=0 ? attr : 0); + lcdDrawText(MODEL_SETUP_2ND_COLUMN+4*FW, y, STR_MODULE_RANGE, m_posHorz!=0 ? attr : 0); moduleFlag[0] = (attr && m_posHorz>0 && editMode>0) ? MODULE_RANGECHECK : 0; // [MENU] key toggles range check mode } #endif @@ -821,7 +821,7 @@ void menuModelFailsafe(uint8_t event) if (event == EVT_KEY_LONG(KEY_ENTER) && s_editMode) { s_noHi = NO_HI_LEN; g_model.moduleData[g_moduleIdx].failsafeChannels[m_posVert] = channelOutputs[m_posVert]; - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); AUDIO_WARNING1(); SEND_FAILSAFE_NOW(g_moduleIdx); } @@ -876,7 +876,7 @@ void menuModelFailsafe(uint8_t event) #endif // Gauge - lcd_rect(x+COL_W-3-wbar-ofs, y, wbar+1, 6); + lcdDrawRect(x+COL_W-3-wbar-ofs, y, wbar+1, 6); uint16_t lim = g_model.extendedLimits ? 640*2 : 512*2; uint8_t len = limit((uint8_t)1, uint8_t((abs(val) * wbar/2 + lim/2) / lim), uint8_t(wbar/2)); coord_t x0 = (val>0) ? x+COL_W-ofs-3-wbar/2 : x+COL_W-ofs-2-wbar/2-len; diff --git a/radio/src/gui/9X/menu_model_telemetry.cpp b/radio/src/gui/9X/menu_model_telemetry.cpp index d6c6cc44e..98007d3c5 100644 --- a/radio/src/gui/9X/menu_model_telemetry.cpp +++ b/radio/src/gui/9X/menu_model_telemetry.cpp @@ -355,7 +355,7 @@ void menuModelSensor(uint8_t event) case SENSOR_FIELD_UNIT: lcd_putsLeft(y, "Unit"); // TODO flash saving with selectMenuItem where I copied those 2 lines? - lcd_putsiAtt(SENSOR_2ND_COLUMN, y, STR_VTELEMUNIT, sensor->unit, attr); + lcdDrawTextAtIndex(SENSOR_2ND_COLUMN, y, STR_VTELEMUNIT, sensor->unit, attr); if (attr) { CHECK_INCDEC_MODELVAR_ZERO(event, sensor->unit, UNIT_MAX); if (checkIncDec_Ret) { @@ -409,7 +409,7 @@ void menuModelSensor(uint8_t event) lcd_putsLeft(y, STR_RATIO); if (attr) CHECK_INCDEC_MODELVAR(event, sensor->custom.ratio, 0, 30000); if (sensor->custom.ratio == 0) - lcd_putcAtt(SENSOR_2ND_COLUMN, y, '-', attr); + lcdDrawChar(SENSOR_2ND_COLUMN, y, '-', attr); else lcd_outdezAtt(SENSOR_2ND_COLUMN, y, sensor->custom.ratio, LEFT|attr|PREC1); break; @@ -452,7 +452,7 @@ void menuModelSensor(uint8_t event) source = checkIncDec(event, source, -MAX_SENSORS, MAX_SENSORS, EE_MODEL|NO_INCDEC_MARKS, isSensorAvailable); } if (source < 0) { - lcd_putcAtt(SENSOR_2ND_COLUMN, y, '-', attr); + lcdDrawChar(SENSOR_2ND_COLUMN, y, '-', attr); putsMixerSource(lcdNextPos, y, MIXSRC_FIRST_TELEM+3*(-1-source), attr); } else { @@ -511,7 +511,7 @@ void onSensorMenu(const char *result) TelemetryItem & sourceItem = telemetryItems[index]; TelemetryItem & newItem = telemetryItems[newIndex]; newItem = sourceItem; - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } else { POPUP_WARNING(STR_TELEMETRYFULL); @@ -569,8 +569,8 @@ void menuModelTelemetry(uint8_t event) if (k>=ITEM_TELEMETRY_SENSOR1 && k0 || p1valdiff)) { if (m_posHorz == 0) { uint16_t ratio = checkIncDec(event, channel.ratio, 0, 256, EE_MODEL); @@ -700,8 +700,8 @@ void menuModelTelemetry(uint8_t event) { uint8_t alarm = ((k==ITEM_TELEMETRY_A1_ALARM1 || k==ITEM_TELEMETRY_A2_ALARM1) ? 0 : 1); lcd_putsLeft(y, STR_ALARM); - lcd_putsiAtt(TELEM_COL2, y, STR_VALARM, ALARM_LEVEL(ch, alarm), m_posHorz<=0 ? attr : 0); - lcd_putsiAtt(TELEM_COL2+4*FW, y, STR_VALARMFN, ALARM_GREATER(ch, alarm), (CURSOR_ON_LINE() || m_posHorz==1) ? attr : 0); + lcdDrawTextAtIndex(TELEM_COL2, y, STR_VALARM, ALARM_LEVEL(ch, alarm), m_posHorz<=0 ? attr : 0); + lcdDrawTextAtIndex(TELEM_COL2+4*FW, y, STR_VALARMFN, ALARM_GREATER(ch, alarm), (CURSOR_ON_LINE() || m_posHorz==1) ? attr : 0); putsTelemetryChannelValue(TELEM_COL2+6*FW, y, dest, channel.alarms_value[alarm], ((CURSOR_ON_LINE() || m_posHorz==2) ? attr : 0) | LEFT); if (attr && (s_editMode>0 || p1valdiff)) { @@ -735,7 +735,7 @@ void menuModelTelemetry(uint8_t event) case ITEM_TELEMETRY_RSSI_ALARM2: { uint8_t alarm = k-ITEM_TELEMETRY_RSSI_ALARM1; lcd_putsLeft(y, STR_ALARM); - lcd_putsiAtt(TELEM_COL2, y, STR_VALARM, ((2+alarm+g_model.frsky.rssiAlarms[alarm].level)%4), m_posHorz<=0 ? attr : 0); + lcdDrawTextAtIndex(TELEM_COL2, y, STR_VALARM, ((2+alarm+g_model.frsky.rssiAlarms[alarm].level)%4), m_posHorz<=0 ? attr : 0); lcd_putc(TELEM_COL2+4*FW, y, '<'); lcd_outdezNAtt(TELEM_COL2+6*FW, y, getRssiAlarmValue(alarm), LEFT|(m_posHorz!=0 ? attr : 0), 3); @@ -760,7 +760,7 @@ void menuModelTelemetry(uint8_t event) case ITEM_TELEMETRY_USR_PROTO: lcd_putsLeft(y, STR_PROTO); - lcd_putsiAtt(TELEM_COL2, y, STR_VTELPROTO, g_model.frsky.usrProto, attr); + lcdDrawTextAtIndex(TELEM_COL2, y, STR_VTELPROTO, g_model.frsky.usrProto, attr); if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, g_model.frsky.usrProto, USR_PROTO_LAST); break; @@ -773,13 +773,13 @@ void menuModelTelemetry(uint8_t event) case ITEM_TELEMETRY_USR_VOLTAGE_SOURCE: lcd_putsLeft(y, STR_VOLTAGE); - lcd_putsiAtt(TELEM_COL2, y, STR_AMPSRC, g_model.frsky.voltsSource+1, attr); + lcdDrawTextAtIndex(TELEM_COL2, y, STR_AMPSRC, g_model.frsky.voltsSource+1, attr); if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, g_model.frsky.voltsSource, FRSKY_VOLTS_SOURCE_LAST); break; case ITEM_TELEMETRY_USR_CURRENT_SOURCE: lcd_putsLeft(y, STR_CURRENT); - lcd_putsiAtt(TELEM_COL2, y, STR_AMPSRC, g_model.frsky.currentSource, attr); + lcdDrawTextAtIndex(TELEM_COL2, y, STR_AMPSRC, g_model.frsky.currentSource, attr); if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, g_model.frsky.currentSource, FRSKY_CURRENT_SOURCE_LAST); break; @@ -807,7 +807,7 @@ void menuModelTelemetry(uint8_t event) g_model.frsky.varioSource = checkIncDec(event, g_model.frsky.varioSource, 0, MAX_SENSORS, EE_MODEL|NO_INCDEC_MARKS, isSensorAvailable); } #else - lcd_putsiAtt(TELEM_COL2, y, STR_VARIOSRC, g_model.frsky.varioSource, attr); + lcdDrawTextAtIndex(TELEM_COL2, y, STR_VARIOSRC, g_model.frsky.varioSource, attr); if (attr) CHECK_INCDEC_MODELVAR(event, g_model.frsky.varioSource, 0, VARIO_SOURCE_LAST); #endif break; @@ -938,7 +938,7 @@ void menuModelTelemetry(uint8_t event) } } #else - lcd_putsiAtt(TELEM_COL1, y, STR_VTELEMCHNS, barSource, m_posHorz==0 ? attr : 0); + lcdDrawTextAtIndex(TELEM_COL1, y, STR_VTELEMCHNS, barSource, m_posHorz==0 ? attr : 0); if (barSource) { putsTelemetryChannelValue(TELEM_BARS_COLMIN, y, barSource-1, convertBarTelemValue(barSource, bar.barMin), (m_posHorz==1 ? attr : 0) | LEFT); putsTelemetryChannelValue(TELEM_BARS_COLMAX, y, barSource-1, convertBarTelemValue(barSource, 255-bar.barMax), (m_posHorz==2 ? attr : 0) | LEFT); @@ -994,7 +994,7 @@ void menuModelTelemetry(uint8_t event) CHECK_INCDEC_MODELVAR_ZERO_CHECK(event, value, MIXSRC_LAST_TELEM, isSourceAvailable); } #else - lcd_putsiAtt(pos[c], y, STR_VTELEMCHNS, value, cellAttr); + lcdDrawTextAtIndex(pos[c], y, STR_VTELEMCHNS, value, cellAttr); if (cellAttr && (s_editMode>0 || p1valdiff)) { CHECK_INCDEC_MODELVAR_ZERO_CHECK(event, value, (lineIndex==3 && c==0) ? TELEM_STATUS_MAX : TELEM_DISPLAY_MAX, isTelemetrySourceAvailable); } diff --git a/radio/src/gui/9X/menu_model_templates.cpp b/radio/src/gui/9X/menu_model_templates.cpp index d14118e71..c150b52d7 100644 --- a/radio/src/gui/9X/menu_model_templates.cpp +++ b/radio/src/gui/9X/menu_model_templates.cpp @@ -59,7 +59,7 @@ void menuModelTemplates(uint8_t event) for (uint8_t i=0; i= 0x0e) + #define CASE_EVT_ROTARY_BREAK case EVT_ROTARY_BREAK: + #define CASE_EVT_ROTARY_LONG case EVT_ROTARY_LONG: + #define CASE_EVT_ROTARY_LEFT case EVT_ROTARY_LEFT: + #define CASE_EVT_ROTARY_RIGHT case EVT_ROTARY_RIGHT: void repeatLastCursorMove(uint8_t event); #define REPEAT_LAST_CURSOR_MOVE() { if (EVT_KEY_MASK(event) >= 0x0e) putEvent(event); else repeatLastCursorMove(event); } #define MOVE_CURSOR_FROM_HERE() if (m_posHorz > 0) REPEAT_LAST_CURSOR_MOVE() #else + #define IS_ROTARY_LEFT(evt) (0) + #define IS_ROTARY_RIGHT(evt) (0) + #define IS_ROTARY_BREAK(evt) (0) + #define IS_ROTARY_LONG(evt) (0) + #define IS_ROTARY_EVENT(evt) (0) + #define CASE_EVT_ROTARY_BREAK + #define CASE_EVT_ROTARY_LONG + #define CASE_EVT_ROTARY_LEFT + #define CASE_EVT_ROTARY_RIGHT void repeatLastCursorMove(uint8_t event); #define REPEAT_LAST_CURSOR_MOVE() repeatLastCursorMove(event) #define MOVE_CURSOR_FROM_HERE() REPEAT_LAST_CURSOR_MOVE() #endif -#define POS_VERT_INIT 0 #define POS_HORZ_INIT(posVert) 0 #define EDIT_MODE_INIT -1 diff --git a/radio/src/gui/9X/navigation.cpp b/radio/src/gui/9X/navigation.cpp index 00cfb01c2..98cb316a8 100644 --- a/radio/src/gui/9X/navigation.cpp +++ b/radio/src/gui/9X/navigation.cpp @@ -205,7 +205,7 @@ int checkIncDec(unsigned int event, int val, int i_min, int i_max, unsigned int else AUDIO_KEYPAD_DOWN(); } - eeDirty(i_flags & (EE_GENERAL|EE_MODEL)); + storageDirty(i_flags & (EE_GENERAL|EE_MODEL)); checkIncDec_Ret = (newval > val ? 1 : -1); } else { @@ -306,7 +306,7 @@ int16_t checkIncDec(uint8_t event, int16_t val, int16_t i_min, int16_t i_max, ui else AUDIO_KEYPAD_DOWN(); } - eeDirty(i_flags & (EE_GENERAL|EE_MODEL)); + storageDirty(i_flags & (EE_GENERAL|EE_MODEL)); checkIncDec_Ret = (newval > val ? 1 : -1); } else { @@ -474,7 +474,7 @@ void check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t #if defined(CPUARM) menuEntryTime = get_tmr10ms(); #endif - l_posVert = POS_VERT_INIT; + l_posVert = 0; l_posHorz = POS_HORZ_INIT(l_posVert); SET_SCROLLBAR_X(LCD_W-1); #if defined(ROTARY_ENCODER_NAVIGATION) @@ -510,8 +510,8 @@ void check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t case EVT_ROTARY_LONG: if (s_editMode > 1) break; killEvents(event); - if (l_posVert != POS_VERT_INIT) { - l_posVert = POS_VERT_INIT; + if (l_posVert != 0) { + l_posVert = 0; s_editMode = EDIT_MODE_INIT; break; } @@ -551,7 +551,7 @@ void check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t if (!horTab || s_editMode>0) break; #if defined(ROTARY_ENCODER_NAVIGATION) - CASE_EVT_ROTARY_MOVE_RIGHT + CASE_EVT_ROTARY_RIGHT if (s_editMode != 0) break; if (l_posHorz < maxcol) { l_posHorz++; @@ -559,7 +559,7 @@ void check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t } else { l_posHorz = 0; - if (!IS_ROTARY_MOVE_RIGHT(event)) + if (!IS_ROTARY_RIGHT(event)) break; } #else @@ -574,7 +574,7 @@ void check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t case EVT_KEY_FIRST(KEY_DOWN): //inc if (s_editMode>0) break; do { - INC(l_posVert, POS_VERT_INIT, maxrow); + INC(l_posVert, 0, maxrow); } while (CURSOR_NOT_ALLOWED_IN_ROW(l_posVert)); #if defined(ROTARY_ENCODER_NAVIGATION) @@ -592,13 +592,13 @@ void check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t if (!horTab || s_editMode>0) break; #if defined(ROTARY_ENCODER_NAVIGATION) - CASE_EVT_ROTARY_MOVE_LEFT + CASE_EVT_ROTARY_LEFT if (s_editMode != 0) break; if (l_posHorz > 0) { l_posHorz--; break; } - else if (IS_ROTARY_MOVE_LEFT(event) && s_editMode == 0) { + else if (IS_ROTARY_LEFT(event) && s_editMode == 0) { l_posHorz = 0xff; } else { @@ -617,7 +617,7 @@ void check(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t if (s_editMode>0) break; do { - DEC(l_posVert, POS_VERT_INIT, maxrow); + DEC(l_posVert, 0, maxrow); } while (CURSOR_NOT_ALLOWED_IN_ROW(l_posVert)); #if defined(ROTARY_ENCODER_NAVIGATION) diff --git a/radio/src/gui/9X/popups.cpp b/radio/src/gui/9X/popups.cpp index 4c97bf67e..83c541aa8 100644 --- a/radio/src/gui/9X/popups.cpp +++ b/radio/src/gui/9X/popups.cpp @@ -52,7 +52,7 @@ int16_t s_warning_input_max; void displayBox() { drawFilledRect(10, 16, LCD_W-20, 40, SOLID, ERASE); - lcd_rect(10, 16, LCD_W-20, 40); + lcdDrawRect(10, 16, LCD_W-20, 40); #if defined(CPUARM) lcd_putsn(WARNING_LINE_X, WARNING_LINE_Y, s_warning, WARNING_LINE_LEN); #else @@ -71,17 +71,17 @@ void displayPopup(const pm_char * pstr) void message(const pm_char *title, const pm_char *t, const char *last MESSAGE_SOUND_ARG) { - lcd_clear(); + lcdClear(); lcd_img(2, 0, asterisk_lbm, 0, 0); #define MESSAGE_LCD_OFFSET 6*FW #if defined(TRANSLATIONS_FR) || defined(TRANSLATIONS_IT) || defined(TRANSLATIONS_CZ) - lcd_putsAtt(MESSAGE_LCD_OFFSET, 0, STR_WARNING, DBLSIZE); - lcd_putsAtt(MESSAGE_LCD_OFFSET, 2*FH, title, DBLSIZE); + lcdDrawText(MESSAGE_LCD_OFFSET, 0, STR_WARNING, DBLSIZE); + lcdDrawText(MESSAGE_LCD_OFFSET, 2*FH, title, DBLSIZE); #else - lcd_putsAtt(MESSAGE_LCD_OFFSET, 0, title, DBLSIZE); - lcd_putsAtt(MESSAGE_LCD_OFFSET, 2*FH, STR_WARNING, DBLSIZE); + lcdDrawText(MESSAGE_LCD_OFFSET, 0, title, DBLSIZE); + lcdDrawText(MESSAGE_LCD_OFFSET, 2*FH, STR_WARNING, DBLSIZE); #endif drawFilledRect(0, 0, LCD_W, 32); @@ -103,7 +103,7 @@ void displayWarning(uint8_t event) s_warning_result = false; displayBox(); if (s_warning_info) { - lcd_putsnAtt(WARNING_LINE_X, WARNING_LINE_Y+FH, s_warning_info, s_warning_info_len, WARNING_INFO_FLAGS); + lcdDrawTextWithLen(WARNING_LINE_X, WARNING_LINE_Y+FH, s_warning_info, s_warning_info_len, WARNING_INFO_FLAGS); } lcd_puts(WARNING_LINE_X, WARNING_LINE_Y+2*FH, s_warning_type == WARNING_TYPE_ASTERISK ? STR_EXIT : STR_POPUPS); switch (event) { @@ -152,23 +152,23 @@ const char * displayMenu(uint8_t event) uint8_t display_count = min(s_menu_count, MENU_MAX_LINES); uint8_t y = (display_count >= 5 ? MENU_Y - FH - 1 : MENU_Y); drawFilledRect(MENU_X, y, MENU_W, display_count * (FH+1) + 2, SOLID, ERASE); - lcd_rect(MENU_X, y, MENU_W, display_count * (FH+1) + 2); + lcdDrawRect(MENU_X, y, MENU_W, display_count * (FH+1) + 2); for (uint8_t i=0; i display_count) { - displayScrollbar(MENU_X+MENU_W-1, y+1, MENU_MAX_LINES * (FH+1), s_menu_offset, s_menu_count, MENU_MAX_LINES); + drawScrollbar(MENU_X+MENU_W-1, y+1, MENU_MAX_LINES * (FH+1), s_menu_offset, s_menu_count, MENU_MAX_LINES); } switch(event) { #if defined(ROTARY_ENCODER_NAVIGATION) CASE_EVT_ROTARY_LEFT #endif - case EVT_KEY_FIRST(KEY_MOVE_UP): - case EVT_KEY_REPT(KEY_MOVE_UP): + case EVT_KEY_FIRST(KEY_UP): + case EVT_KEY_REPT(KEY_UP): if (s_menu_item > 0) { s_menu_item--; } @@ -192,8 +192,8 @@ const char * displayMenu(uint8_t event) #if defined(ROTARY_ENCODER_NAVIGATION) CASE_EVT_ROTARY_RIGHT #endif - case EVT_KEY_FIRST(KEY_MOVE_DOWN): - case EVT_KEY_REPT(KEY_MOVE_DOWN): + case EVT_KEY_FIRST(KEY_DOWN): + case EVT_KEY_REPT(KEY_DOWN): if (s_menu_item < display_count - 1 && s_menu_offset + s_menu_item + 1 < s_menu_count) { s_menu_item++; } diff --git a/radio/src/gui/9X/splash.cpp b/radio/src/gui/9X/splash.cpp index 5075df0dc..5d9fc72b7 100644 --- a/radio/src/gui/9X/splash.cpp +++ b/radio/src/gui/9X/splash.cpp @@ -45,7 +45,7 @@ const pm_uchar * const splash_lbm = splashdata+4; void displaySplash() { - lcd_clear(); + lcdClear(); lcd_img(0, 0, splash_lbm, 0, 0); #if MENUS_LOCK == 1 diff --git a/radio/src/gui/9X/view_about.cpp b/radio/src/gui/9X/view_about.cpp index 67b0254f2..bdf22b007 100644 --- a/radio/src/gui/9X/view_about.cpp +++ b/radio/src/gui/9X/view_about.cpp @@ -82,7 +82,7 @@ void menuAboutView(uint8_t event) break; } - lcd_putsAtt(17, 0, STR_ABOUTUS, DBLSIZE|INVERS); + lcdDrawText(17, 0, STR_ABOUTUS, DBLSIZE|INVERS); lcd_hline(17, 16, LCD_W-17); lcd_img(8, 0, about_bmp, 0); LcdFlags att = 0; @@ -92,67 +92,67 @@ void menuAboutView(uint8_t event) switch (screenIndex) { case ABOUT_OPENTX: case ABOUT_END: - lcd_putsAtt(ABOUT_X, 22, STR_ABOUT_OPENTX_1, SMLSIZE); - lcd_putsAtt(ABOUT_X, 30, STR_ABOUT_OPENTX_2, SMLSIZE); - lcd_putsAtt(ABOUT_X, 38, STR_ABOUT_OPENTX_3, SMLSIZE); - lcd_putsAtt(ABOUT_X, 46, STR_ABOUT_OPENTX_4, SMLSIZE); - lcd_putsAtt(ABOUT_X, 54, STR_ABOUT_OPENTX_5, SMLSIZE); + lcdDrawText(ABOUT_X, 22, STR_ABOUT_OPENTX_1, SMLSIZE); + lcdDrawText(ABOUT_X, 30, STR_ABOUT_OPENTX_2, SMLSIZE); + lcdDrawText(ABOUT_X, 38, STR_ABOUT_OPENTX_3, SMLSIZE); + lcdDrawText(ABOUT_X, 46, STR_ABOUT_OPENTX_4, SMLSIZE); + lcdDrawText(ABOUT_X, 54, STR_ABOUT_OPENTX_5, SMLSIZE); screenDuration = 255; break; case ABOUT_BERTRAND: - lcd_putsAtt(ABOUT_X, 24, STR_ABOUT_BERTRAND_1, att); - lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_BERTRAND_2, att|SMLSIZE); - lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_BERTRAND_3, att|SMLSIZE); + lcdDrawText(ABOUT_X, 24, STR_ABOUT_BERTRAND_1, att); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_BERTRAND_2, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_BERTRAND_3, att|SMLSIZE); break; case ABOUT_ANDRE: - lcd_putsAtt(ABOUT_X, 24, STR_ABOUT_ANDRE_1, att); - lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_ANDRE_2, att|SMLSIZE); - lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_ANDRE_3, att|SMLSIZE); + lcdDrawText(ABOUT_X, 24, STR_ABOUT_ANDRE_1, att); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_ANDRE_2, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_ANDRE_3, att|SMLSIZE); break; case ABOUT_MIKE: - lcd_putsAtt(ABOUT_X, 24, STR_ABOUT_MIKE_1, att); - lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_MIKE_2, att|SMLSIZE); - lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_MIKE_3, att|SMLSIZE); - lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 52, STR_ABOUT_MIKE_4, att|SMLSIZE); + lcdDrawText(ABOUT_X, 24, STR_ABOUT_MIKE_1, att); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_MIKE_2, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_MIKE_3, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 52, STR_ABOUT_MIKE_4, att|SMLSIZE); break; case ABOUT_KJELL: - lcd_putsAtt(ABOUT_X, 24, STR_ABOUT_KJELL_1, att); - lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_KJELL_2, att|SMLSIZE); - lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_KJELL_3, att|SMLSIZE); - lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 52, STR_ABOUT_KJELL_4, att|SMLSIZE); + lcdDrawText(ABOUT_X, 24, STR_ABOUT_KJELL_1, att); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_KJELL_2, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_KJELL_3, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 52, STR_ABOUT_KJELL_4, att|SMLSIZE); break; case ABOUT_MARTIN: - lcd_putsAtt(ABOUT_X, 24, STR_ABOUT_MARTIN_1, att); - lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_MARTIN_2, att|SMLSIZE); + lcdDrawText(ABOUT_X, 24, STR_ABOUT_MARTIN_1, att); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_MARTIN_2, att|SMLSIZE); break; case ABOUT_ROMOLO: - lcd_putsAtt(ABOUT_X, 24, STR_ABOUT_ROMOLO_1, att); - lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_ROMOLO_2, att|SMLSIZE); - lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_ROMOLO_3, att|SMLSIZE); + lcdDrawText(ABOUT_X, 24, STR_ABOUT_ROMOLO_1, att); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_ROMOLO_2, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_ROMOLO_3, att|SMLSIZE); break; case ABOUT_ROB: - lcd_putsAtt(ABOUT_X, 24, STR_ABOUT_ROB_1, att); - lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_ROB_2, att|SMLSIZE); + lcdDrawText(ABOUT_X, 24, STR_ABOUT_ROB_1, att); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_ROB_2, att|SMLSIZE); break; case ABOUT_HARDWARE: - lcd_putsAtt(ABOUT_X, 24, STR_ABOUT_HARDWARE_1, att); - lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_HARDWARE_2, att|SMLSIZE); - lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_HARDWARE_3, att|SMLSIZE); + lcdDrawText(ABOUT_X, 24, STR_ABOUT_HARDWARE_1, att); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_HARDWARE_2, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_HARDWARE_3, att|SMLSIZE); break; case ABOUT_PARENTS: - lcd_putsAtt(ABOUT_X, 24, STR_ABOUT_PARENTS_1, att); - lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_PARENTS_2, att|SMLSIZE); - lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_PARENTS_3, att|SMLSIZE); - lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 52, STR_ABOUT_PARENTS_4, att|SMLSIZE); + lcdDrawText(ABOUT_X, 24, STR_ABOUT_PARENTS_1, att); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_PARENTS_2, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_PARENTS_3, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 52, STR_ABOUT_PARENTS_4, att|SMLSIZE); screenDuration = 255; break; } diff --git a/radio/src/gui/9X/view_main.cpp b/radio/src/gui/9X/view_main.cpp index 491eff174..7241e9a21 100644 --- a/radio/src/gui/9X/view_main.cpp +++ b/radio/src/gui/9X/view_main.cpp @@ -191,7 +191,7 @@ void displayTimers() uint8_t len = zlen(g_model.timers[0].name, LEN_TIMER_NAME); if (len > 0) { xLabel += (LEN_TIMER_NAME-len)*FW; - lcd_putsnAtt(xLabel, FH*3, g_model.timers[0].name, len, ZCHAR); + lcdDrawTextWithLen(xLabel, FH*3, g_model.timers[0].name, len, ZCHAR); } else { putsTimerMode(xLabel, FH*3, g_model.timers[0].mode); @@ -325,7 +325,7 @@ void menuMainView(uint8_t event) #else g_eeGeneral.view ^= ALTERNATE_VIEW; #endif - eeDirty(EE_GENERAL); + storageDirty(EE_GENERAL); AUDIO_KEYPAD_UP(); } break; @@ -381,7 +381,7 @@ void menuMainView(uint8_t event) case EVT_KEY_BREAK(KEY_UP): case EVT_KEY_BREAK(KEY_DOWN): g_eeGeneral.view = (event == EVT_KEY_BREAK(KEY_UP) ? (view_base == VIEW_COUNT-1 ? 0 : view_base+1) : (view_base == 0 ? VIEW_COUNT-1 : view_base-1)); - eeDirty(EE_GENERAL); + storageDirty(EE_GENERAL); AUDIO_KEYPAD_UP(); break; @@ -434,7 +434,7 @@ void menuMainView(uint8_t event) { // Flight Mode Name uint8_t mode = mixerCurrentFlightMode; - lcd_putsnAtt(PHASE_X, PHASE_Y, g_model.flightModeData[mode].name, sizeof(g_model.flightModeData[mode].name), ZCHAR|PHASE_FLAGS); + lcdDrawTextWithLen(PHASE_X, PHASE_Y, g_model.flightModeData[mode].name, sizeof(g_model.flightModeData[mode].name), ZCHAR|PHASE_FLAGS); // Model Name putsModelName(MODELNAME_X, MODELNAME_Y, g_model.header.name, g_eeGeneral.currModel, BIGSIZE); @@ -451,7 +451,7 @@ void menuMainView(uint8_t event) if (view_base < VIEW_INPUTS) { // scroll bar - lcd_hlineStip(38, 34, 54, DOTTED); + lcdDrawHorizontalLine(38, 34, 54, DOTTED); #if defined(PCBSKY9X) lcd_hline(38 + (g_eeGeneral.view / ALTERNATE_VIEW) * 13, 34, 13, SOLID); #else @@ -491,7 +491,7 @@ void menuMainView(uint8_t event) int8_t len = (abs(val) * WBAR2 + lim/2) / lim; if(len>WBAR2) len = WBAR2; // prevent bars from going over the end - comment for debugging - lcd_hlineStip(x0-WBAR2, y0, WBAR2*2+1, DOTTED); + lcdDrawHorizontalLine(x0-WBAR2, y0, WBAR2*2+1, DOTTED); lcd_vline(x0,y0-2,5); if (val>0) x0+=1; @@ -567,7 +567,7 @@ void menuMainView(uint8_t event) // And ! in case of unexpected shutdown if (unexpectedShutdown) { - lcd_putcAtt(REBOOT_X, 0*FH, '!', INVERS); + lcdDrawChar(REBOOT_X, 0*FH, '!', INVERS); } #if defined(GVARS) && !defined(PCBSTD) @@ -575,8 +575,8 @@ void menuMainView(uint8_t event) s_gvar_timer--; s_warning = STR_GLOBAL_VAR; displayBox(); - lcd_putsnAtt(16, 5*FH, g_model.gvars[s_gvar_last].name, LEN_GVAR_NAME, ZCHAR); - lcd_putsAtt(16+7*FW, 5*FH, PSTR("[\010]"), BOLD); + lcdDrawTextWithLen(16, 5*FH, g_model.gvars[s_gvar_last].name, LEN_GVAR_NAME, ZCHAR); + lcdDrawText(16+7*FW, 5*FH, PSTR("[\010]"), BOLD); lcd_outdezAtt(16+7*FW+4*FW+FW/2, 5*FH, GVAR_VALUE(s_gvar_last, getGVarFlightPhase(mixerCurrentFlightMode, s_gvar_last)), BOLD); s_warning = NULL; } @@ -585,7 +585,7 @@ void menuMainView(uint8_t event) #if defined(DSM2) if (moduleFlag[0] == MODULE_BIND) { // Issue 98 - lcd_putsAtt(15*FW, 0, PSTR("BIND"), 0); + lcdDrawText(15*FW, 0, PSTR("BIND"), 0); } #endif } diff --git a/radio/src/gui/9X/view_mavlink.cpp b/radio/src/gui/9X/view_mavlink.cpp index 672e28081..935690c03 100644 --- a/radio/src/gui/9X/view_mavlink.cpp +++ b/radio/src/gui/9X/view_mavlink.cpp @@ -131,7 +131,7 @@ void lcd_outdezFloat(uint8_t x, uint8_t y, float val, uint8_t precis, uint8_t mo for (; i < 4; i++) { c = (lnum % 10) + '0'; x1 -= xinc; - lcd_putcAtt(x1, y, c, mode); + lcdDrawChar(x1, y, c, mode); lnum /= 10; if (lnum == 0) { break; @@ -142,20 +142,20 @@ void lcd_outdezFloat(uint8_t x, uint8_t y, float val, uint8_t precis, uint8_t mo x1 = x; for (i = 0; i < 4; i++) { x1 -= FW; - lcd_putcAtt(x1, y, '?', mode); + lcdDrawChar(x1, y, '?', mode); } } else { if (val < 0) { val = -val; x1 -= xinc; - lcd_putcAtt(x1, y, '-', mode); + lcdDrawChar(x1, y, '-', mode); } if (precis) { uint8_t y_temp = y; if (mode & DBLSIZE) y_temp += FH; - lcd_putcAtt(x, y_temp, '.', (mode & (~DBLSIZE))); + lcdDrawChar(x, y_temp, '.', (mode & (~DBLSIZE))); x -= (xinc / 2); } for (i = 0; i < precis; i++) { @@ -163,7 +163,7 @@ void lcd_outdezFloat(uint8_t x, uint8_t y, float val, uint8_t precis, uint8_t mo int a = val; c = a + '0'; x += xinc; - lcd_putcAtt(x, y, c, mode); + lcdDrawChar(x, y, c, mode); val -= a; } } @@ -182,13 +182,13 @@ void print_mav_mode(uint8_t x, uint8_t y, uint32_t custom_mode, uint8_t attr) // uint8_t mode = (uint8_t) custom_mode; switch (telemetry_data.type_autopilot) { case MAVLINK_ARDUCOPTER: - lcd_putsiAtt(x,y,STR_MAVLINK_AC_MODES,mode,attr); + lcdDrawTextAtIndex(x,y,STR_MAVLINK_AC_MODES,mode,attr); break; case MAVLINK_ARDUPLANE: - lcd_putsiAtt(x,y,STR_MAVLINK_AP_MODES,ap_modes_lut[custom_mode],attr); + lcdDrawTextAtIndex(x,y,STR_MAVLINK_AP_MODES,ap_modes_lut[custom_mode],attr); break; default: - lcd_putsAtt (FW, y, PSTR("INV. MAV TYPE"), attr); + lcdDrawText (FW, y, PSTR("INV. MAV TYPE"), attr); break; } } @@ -198,12 +198,12 @@ void print_mav_mode(uint8_t x, uint8_t y, uint32_t custom_mode, uint8_t attr) // */ void mav_title(const pm_char * s, uint8_t index) { - lcd_putsAtt(0, 0, PSTR("MAVLINK"), INVERS); + lcdDrawText(0, 0, PSTR("MAVLINK"), INVERS); lcd_puts(10 * FW, 0, s); displayScreenIndex(index, MAX_MAVLINK_MENU, INVERS); lcd_putc(7 * FW, 0, (mav_heartbeat > 0) ? '*' : ' '); if (telemetry_data.active) - lcd_putcAtt(8 * FW, 0, 'A', BLINK); + lcdDrawChar(8 * FW, 0, 'A', BLINK); } /*! \brief Global info menu @@ -236,9 +236,9 @@ void menuTelemetryMavlinkInfos(void) { */ if (telemetry_data.status) { - lcd_putsnAtt(x1, y, STR_MAVLINK_MODE, 4, 0); + lcdDrawTextWithLen(x1, y, STR_MAVLINK_MODE, 4, 0); if (telemetry_data.active) - lcd_putsnAtt(x2, y, PSTR("A"), 1, 0); + lcdDrawTextWithLen(x2, y, PSTR("A"), 1, 0); lcd_outdezAtt(xnum, y, telemetry_data.mode, 0); y += FH; @@ -298,7 +298,7 @@ void menuTelemetryMavlinkFlightMode(void) { x = 0; if (telemetry_data.active) - lcd_putsAtt (FW, y, STR_MAVLINK_ARMED, DBLSIZE); + lcdDrawText (FW, y, STR_MAVLINK_ARMED, DBLSIZE); } /*! \brief Batterystatus dislplay @@ -400,9 +400,9 @@ void menuTelemetryMavlinkGPS(void) { xnum2 = xnum + 11 * FWNUM; y = FH; - lcd_putsnAtt(x1, y, STR_MAVLINK_GPS, 3, 0); + lcdDrawTextWithLen(x1, y, STR_MAVLINK_GPS, 3, 0); if (telemetry_data.fix_type < 2) { - lcd_putsnAtt(xnum, y, STR_MAVLINK_NO_FIX, 6, 0); + lcdDrawTextWithLen(xnum, y, STR_MAVLINK_NO_FIX, 6, 0); } else { lcd_outdezNAtt(xnum, y, telemetry_data.fix_type, 0, 3); lcd_puts(xnum, y, PSTR("D")); @@ -419,19 +419,19 @@ void menuTelemetryMavlinkGPS(void) { lcd_puts(x1, y, STR_MAVLINK_LAT); lcd_outdezFloat(xnum, y, telemetry_data.loc_current.lat, 2); - lcd_putsnAtt(x2, y, STR_MAVLINK_LON, 3, 0); + lcdDrawTextWithLen(x2, y, STR_MAVLINK_LON, 3, 0); lcd_outdezFloat(xnum2, y, telemetry_data.loc_current.lon, 2); y += FH; - lcd_putsnAtt(x1, y, STR_MAVLINK_ALTITUDE, 3, 0); + lcdDrawTextWithLen(x1, y, STR_MAVLINK_ALTITUDE, 3, 0); lcd_outdezAtt(xnum, y, telemetry_data.loc_current.gps_alt, 0); y += FH; - lcd_putsnAtt(x1, y, STR_MAVLINK_COURSE, 6, 0); + lcdDrawTextWithLen(x1, y, STR_MAVLINK_COURSE, 6, 0); lcd_outdezFloat(xnum, y, telemetry_data.course, 2); y += FH; - lcd_putsnAtt(x1, y, PSTR("V"), 1, 0); + lcdDrawTextWithLen(x1, y, PSTR("V"), 1, 0); lcd_outdezAtt(xnum, y, telemetry_data.v, 0); //} } @@ -444,7 +444,7 @@ void lcd_outhex2(uint8_t x, uint8_t y, uint8_t val) { x -= FWNUM; char c = val & 0xf; c = c > 9 ? c + 'A' - 10 : c + '0'; - lcd_putcAtt(x, y, c, c >= 'A' ? CONDENSED : 0); + lcdDrawChar(x, y, c, c >= 'A' ? CONDENSED : 0); val >>= 4; } } diff --git a/radio/src/gui/9X/view_mavlink.h b/radio/src/gui/9X/view_mavlink.h index 9032124f2..64cf00cd0 100644 --- a/radio/src/gui/9X/view_mavlink.h +++ b/radio/src/gui/9X/view_mavlink.h @@ -83,7 +83,7 @@ enum mavlink_menu_ { }; //! \brief Pointer array to mavlink settings menus. -const MenuFuncP_PROGMEM menuTabMav[] PROGMEM = { +const MenuFuncP menuTabMav[] PROGMEM = { menuTelemetryMavlinkSetup }; diff --git a/radio/src/gui/9X/view_statistics.cpp b/radio/src/gui/9X/view_statistics.cpp index 209c3b033..09a1dca45 100644 --- a/radio/src/gui/9X/view_statistics.cpp +++ b/radio/src/gui/9X/view_statistics.cpp @@ -50,7 +50,7 @@ void menuStatisticsView(uint8_t event) #if defined(CPUARM) case EVT_KEY_LONG(KEY_MENU): g_eeGeneral.globalTimer = 0; - eeDirty(EE_GENERAL); + storageDirty(EE_GENERAL); sessionTimer = 0; break; #endif @@ -110,7 +110,7 @@ void menuStatisticsDebug(uint8_t event) case EVT_KEY_LONG(KEY_ENTER): g_eeGeneral.mAhUsed = 0; g_eeGeneral.globalTimer = 0; - eeDirty(EE_GENERAL); + storageDirty(EE_GENERAL); #if defined(PCBSKY9X) Current_used = 0; #endif @@ -174,13 +174,13 @@ void menuStatisticsDebug(uint8_t event) lcd_putsLeft(MENU_DEBUG_Y_COPROC, STR_COPROC_TEMP); if (Coproc_read==0) { - lcd_putsAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_COPROC, PSTR("Co Proc NACK"),INVERS); + lcdDrawText(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_COPROC, PSTR("Co Proc NACK"),INVERS); } else if (Coproc_read==0x81) { - lcd_putsAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_COPROC, PSTR("Inst.TinyApp"),INVERS); + lcdDrawText(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_COPROC, PSTR("Inst.TinyApp"),INVERS); } else if (Coproc_read<3) { - lcd_putsAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_COPROC, PSTR("Upgr.TinyApp"),INVERS); + lcdDrawText(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_COPROC, PSTR("Upgr.TinyApp"),INVERS); } else { putsValueWithUnit(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_COPROC, Coproc_temp, UNIT_TEMPERATURE, LEFT); diff --git a/radio/src/gui/9X/view_telemetry.cpp b/radio/src/gui/9X/view_telemetry.cpp index d948da6b8..4f1c0c0c9 100644 --- a/radio/src/gui/9X/view_telemetry.cpp +++ b/radio/src/gui/9X/view_telemetry.cpp @@ -56,17 +56,17 @@ void displayRssiLine() #if !defined(CPUARM) rssi = min((uint8_t)99, frskyData.rssi[1].value); lcd_putsLeft(STATUS_BAR_Y, STR_TX); lcd_outdezNAtt(4*FW+1, STATUS_BAR_Y, rssi, LEADING0, 2); - lcd_rect(BAR_LEFT+1, 57, 38, 7); + lcdDrawRect(BAR_LEFT+1, 57, 38, 7); drawFilledRect(BAR_LEFT+1, 58, 4*rssi/11, 5, (rssi < getRssiAlarmValue(0)) ? DOTTED : SOLID); #endif rssi = min((uint8_t)99, TELEMETRY_RSSI()); lcd_puts(104, STATUS_BAR_Y, STR_RX); lcd_outdezNAtt(105+4*FW, STATUS_BAR_Y, rssi, LEADING0, 2); - lcd_rect(65, 57, 38, 7); + lcdDrawRect(65, 57, 38, 7); uint8_t v = 4*rssi/11; drawFilledRect(66+36-v, 58, v, 5, (rssi < getRssiAlarmValue(0)) ? DOTTED : SOLID); } else { - lcd_putsAtt(7*FW, STATUS_BAR_Y, STR_NODATA, BLINK); + lcdDrawText(7*FW, STATUS_BAR_Y, STR_NODATA, BLINK); lcd_status_line(); } } @@ -76,9 +76,9 @@ void displayGpsTime() { uint8_t att = (TELEMETRY_STREAMING() ? LEFT|LEADING0 : LEFT|LEADING0|BLINK); lcd_outdezNAtt(CENTER_OFS+6*FW+7, STATUS_BAR_Y, frskyData.hub.hour, att, 2); - lcd_putcAtt(CENTER_OFS+8*FW+4, STATUS_BAR_Y, ':', att); + lcdDrawChar(CENTER_OFS+8*FW+4, STATUS_BAR_Y, ':', att); lcd_outdezNAtt(CENTER_OFS+9*FW+2, STATUS_BAR_Y, frskyData.hub.min, att, 2); - lcd_putcAtt(CENTER_OFS+11*FW-1, STATUS_BAR_Y, ':', att); + lcdDrawChar(CENTER_OFS+11*FW-1, STATUS_BAR_Y, ':', att); lcd_outdezNAtt(CENTER_OFS+12*FW-3, STATUS_BAR_Y, frskyData.hub.sec, att, 2); lcd_status_line(); } @@ -154,7 +154,7 @@ void displayVoltagesScreen() { // Volts / Amps / Watts / mAh uint8_t analog = 0; - lcd_putsiAtt(0, 2*FH, STR_AMPSRC, g_model.frsky.voltsSource+1, 0); + lcdDrawTextAtIndex(0, 2*FH, STR_AMPSRC, g_model.frsky.voltsSource+1, 0); switch (g_model.frsky.voltsSource) { case FRSKY_VOLTS_SOURCE_A1: case FRSKY_VOLTS_SOURCE_A2: @@ -172,7 +172,7 @@ void displayVoltagesScreen() } if (g_model.frsky.currentSource) { - lcd_putsiAtt(0, 4*FH, STR_AMPSRC, g_model.frsky.currentSource, 0); + lcdDrawTextAtIndex(0, 4*FH, STR_AMPSRC, g_model.frsky.currentSource, 0); switch(g_model.frsky.currentSource) { case FRSKY_CURRENT_SOURCE_A1: case FRSKY_CURRENT_SOURCE_A2: @@ -259,9 +259,9 @@ bool displayGaugesTelemetryScreen(FrSkyScreenData & screen) #if defined(CPUARM) putsMixerSource(0, y+barHeight-5, source, 0); #else - lcd_putsiAtt(0, y+barHeight-5, STR_VTELEMCHNS, source, 0); + lcdDrawTextAtIndex(0, y+barHeight-5, STR_VTELEMCHNS, source, 0); #endif - lcd_rect(BAR_LEFT, y, BAR_WIDTH+1, barHeight+2); + lcdDrawRect(BAR_LEFT, y, BAR_WIDTH+1, barHeight+2); #if defined(CPUARM) getvalue_t value = getValue(source); #else @@ -314,7 +314,7 @@ bool displayGaugesTelemetryScreen(FrSkyScreenData & screen) } if (thresholdX) { - lcd_vlineStip(BAR_LEFT+1+thresholdX, y-2, barHeight+3, DOTTED); + lcdDrawVerticalLine(BAR_LEFT+1+thresholdX, y-2, barHeight+3, DOTTED); lcd_hline(BAR_LEFT+thresholdX, y-2, 3); } } @@ -422,7 +422,7 @@ bool displayNumbersTelemetryScreen(FrSkyScreenData & screen) field = field-TELEM_TIMER1+TELEM_T1; } - lcd_putsiAtt(pos[j], 1+FH+2*FH*i, STR_VTELEMCHNS, field, 0); + lcdDrawTextAtIndex(pos[j], 1+FH+2*FH*i, STR_VTELEMCHNS, field, 0); } } } diff --git a/radio/src/gui/9X/view_text.cpp b/radio/src/gui/9X/view_text.cpp index 4c5af8948..6000a9f82 100644 --- a/radio/src/gui/9X/view_text.cpp +++ b/radio/src/gui/9X/view_text.cpp @@ -138,7 +138,7 @@ void menuTextView(uint8_t event) } for (int i=0; i LCD_LINES-1) { - displayScrollbar(LCD_W-1, FH, LCD_H-FH, s_pgOfs, lines_count, LCD_LINES-1); + drawScrollbar(LCD_W-1, FH, LCD_H-FH, s_pgOfs, lines_count, LCD_LINES-1); } } diff --git a/radio/src/gui/9X/widgets.cpp b/radio/src/gui/9X/widgets.cpp index 5d1b09aa7..a3abec3f6 100644 --- a/radio/src/gui/9X/widgets.cpp +++ b/radio/src/gui/9X/widgets.cpp @@ -59,7 +59,7 @@ void menu_lcd_onoff(coord_t x, coord_t y, uint8_t value, LcdFlags attr) lcd_square(x, y, 7); #else /* ON / OFF version */ - lcd_putsiAtt(x, y, STR_OFFON, value, attr ? INVERS:0) ; + lcdDrawTextAtIndex(x, y, STR_OFFON, value, attr ? INVERS:0) ; #endif } @@ -67,31 +67,31 @@ void displayScreenIndex(uint8_t index, uint8_t count, uint8_t attr) { lcd_outdezAtt(LCD_W, 0, count, attr); coord_t x = 1+LCD_W-FW*(count>9 ? 3 : 2); - lcd_putcAtt(x, 0, '/', attr); + lcdDrawChar(x, 0, '/', attr); lcd_outdezAtt(x, 0, index+1, attr); } #if !defined(CPUM64) -void displayScrollbar(coord_t x, coord_t y, coord_t h, uint16_t offset, uint16_t count, uint8_t visible) +void drawScrollbar(coord_t x, coord_t y, coord_t h, uint16_t offset, uint16_t count, uint8_t visible) { - lcd_vlineStip(x, y, h, DOTTED); + lcdDrawVerticalLine(x, y, h, DOTTED); coord_t yofs = (h * offset) / count; coord_t yhgt = (h * visible) / count; if (yhgt + yofs > h) yhgt = h - yofs; - lcd_vlineStip(x, y + yofs, yhgt, SOLID, FORCE); + lcdDrawVerticalLine(x, y + yofs, yhgt, SOLID, FORCE); } #endif void title(const pm_char * s) { - lcd_putsAtt(0, 0, s, INVERS); + lcdDrawText(0, 0, s, INVERS); } select_menu_value_t selectMenuItem(coord_t x, coord_t y, const pm_char *label, const pm_char *values, select_menu_value_t value, select_menu_value_t min, select_menu_value_t max, LcdFlags attr, uint8_t event) { lcd_putsColumnLeft(x, y, label); - if (values) lcd_putsiAtt(x, y, values, value-min, attr); + if (values) lcdDrawTextAtIndex(x, y, values, value-min, attr); if (attr) value = checkIncDec(event, value, min, max, (g_menuPos[0] == 0) ? EE_MODEL : EE_GENERAL); return value; } @@ -115,7 +115,7 @@ int8_t switchMenuItem(coord_t x, coord_t y, int8_t value, LcdFlags attr, uint8_t } #if !defined(CPUM64) -void displaySlider(coord_t x, coord_t y, uint8_t value, uint8_t max, uint8_t attr) +void drawSlider(coord_t x, coord_t y, uint8_t value, uint8_t max, uint8_t attr) { lcd_putc(x+(value*4*FW)/max, y, '$'); lcd_hline(x, y+3, 5*FW-1, FORCE); @@ -149,7 +149,7 @@ int16_t gvarMenuItem(coord_t x, coord_t y, int16_t value, int16_t min, int16_t m value = (GV_IS_GV_VALUE(value, min, max) ? GET_GVAR(value, min, max, mixerCurrentFlightMode)*10 : delta); else value = (GV_IS_GV_VALUE(value, min, max) ? GET_GVAR(value, min, max, mixerCurrentFlightMode) : delta); - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } if (GV_IS_GV_VALUE(value, min, max)) { @@ -169,7 +169,7 @@ int16_t gvarMenuItem(coord_t x, coord_t y, int16_t value, int16_t min, int16_t m if (idx < 0) { value = (int16_t) GV_CALC_VALUE_IDX_NEG(idx, delta); idx = -idx; - lcd_putcAtt(x-6, y, '-', attr); + lcdDrawChar(x-6, y, '-', attr); } else { value = (int16_t) GV_CALC_VALUE_IDX_POS(idx-1, delta); @@ -193,7 +193,7 @@ int16_t gvarMenuItem(coord_t x, coord_t y, int16_t value, int16_t min, int16_t m if (invers && event == EVT_KEY_LONG(KEY_ENTER)) { s_editMode = !s_editMode; value = (GV_IS_GV_VALUE(value, min, max) ? GET_GVAR(value, min, max, mixerCurrentFlightMode) : delta); - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } if (GV_IS_GV_VALUE(value, min, max)) { if (attr & LEFT) @@ -208,7 +208,7 @@ int16_t gvarMenuItem(coord_t x, coord_t y, int16_t value, int16_t min, int16_t m if (idx < 0) { value = (int16_t) GV_CALC_VALUE_IDX_NEG(idx, delta); idx = -idx; - lcd_putcAtt(x-6, y, '-', attr); + lcdDrawChar(x-6, y, '-', attr); } else { value = (int16_t) GV_CALC_VALUE_IDX_POS(idx, delta); @@ -256,7 +256,7 @@ void drawStatusLine() } drawFilledRect(0, LCD_H-statusLineHeight, LCD_W, FH, SOLID, ERASE); - lcd_putsAtt(5, LCD_H+1-statusLineHeight, statusLineMsg, BSS); + lcdDrawText(5, LCD_H+1-statusLineHeight, statusLineMsg, BSS); drawFilledRect(0, LCD_H-statusLineHeight, LCD_W, FH, SOLID); } } diff --git a/radio/src/gui/Horus/bitmaps.cpp b/radio/src/gui/Horus/bitmaps.cpp new file mode 100644 index 000000000..8ee4ad21a --- /dev/null +++ b/radio/src/gui/Horus/bitmaps.cpp @@ -0,0 +1,265 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../../opentx.h" + +/* + * Header bitmaps + */ + +const uint8_t LBM_TOPMENU_POLYGON[] = { +#include "../../bitmaps/Horus/mask_topmenu_polygon.lbm" +}; + +const uint8_t LBM_DOT[] = { +#include "../../bitmaps/Horus/mask_dot.lbm" +}; + +const uint8_t LBM_CURRENT_BG[] = { +#include "../../bitmaps/Horus/mask_current_bg.lbm" +}; + +const uint8_t LBM_CURRENT_SHADOW[] = { +#include "../../bitmaps/Horus/mask_current_shadow.lbm" +}; + +const uint8_t LBM_CURRENT_DOT[] = { +#include "../../bitmaps/Horus/mask_current_dot.lbm" +}; + +/* + * Main view bitmaps + */ + +const uint8_t LBM_MAINVIEW_BACKGROUND[] = { +#include "../../bitmaps/Horus/background.lbm" +}; + +const uint8_t LBM_TOPMENU_OPENTX[] = { +#include "../../bitmaps/Horus/mask_topmenu_opentx.lbm" +}; + +const uint8_t LBM_TOPMENU_USB[] = { +#include "../../bitmaps/Horus/mask_topmenu_usb.lbm" +}; + +const uint8_t LBM_HTRIM_FRAME[] = { +#include "../../bitmaps/Horus/mask_htrim_frame.lbm" +}; + +const uint8_t LBM_VTRIM_FRAME[] = { +#include "../../bitmaps/Horus/mask_vtrim_frame.lbm" +}; + +const uint8_t LBM_TRIM_SHADOW[] = { +#include "../../bitmaps/Horus/mask_trim_shadow.lbm" +}; + +const uint8_t LBM_TIMER_BACKGROUND[] = { +#include "../../bitmaps/Horus/mask_timer_bg.lbm" +}; + +const uint8_t LBM_RSCALE[] = { +#include "../../bitmaps/Horus/mask_rscale.lbm" +}; + +/* + * Radio menu bitmaps + */ + +const uint8_t LBM_RADIO_ICON[] = { +#include "../../bitmaps/Horus/mask_menu_radio.lbm" +}; + +const uint8_t LBM_RADIO_SETUP_ICON[] = { +#include "../../bitmaps/Horus/mask_radio_setup.lbm" +}; + +const uint8_t LBM_SD_BROWSER_ICON[] = { +#include "../../bitmaps/Horus/mask_sd_browser.lbm" +}; + +const uint8_t LBM_GLOBAL_FUNCTIONS_ICON[] = { +#include "../../bitmaps/Horus/mask_global_functions.lbm" +}; + +const uint8_t LBM_TRAINER_ICON[] = { +#include "../../bitmaps/Horus/mask_trainer.lbm" +}; + +const uint8_t LBM_CALIBRATION_ICON[] = { +#include "../../bitmaps/Horus/mask_calibration.lbm" +}; + +const uint8_t LBM_VERSION_ICON[] = { +#include "../../bitmaps/Horus/mask_version.lbm" +}; + +const uint8_t * const LBM_RADIO_ICONS[] = { + LBM_RADIO_ICON, + LBM_RADIO_SETUP_ICON, + LBM_SD_BROWSER_ICON, + LBM_GLOBAL_FUNCTIONS_ICON, + LBM_TRAINER_ICON, + LBM_CALIBRATION_ICON, + LBM_VERSION_ICON +}; + +/* + * Model menu bitmaps + */ + +const uint8_t LBM_MODEL_ICON[] = { +#include "../../bitmaps/Horus/mask_menu_model.lbm" +}; + +const uint8_t LBM_MODEL_SETUP_ICON[] = { +#include "../../bitmaps/Horus/mask_model_setup.lbm" +}; + +const uint8_t LBM_HELI_ICON[] = { +#include "../../bitmaps/Horus/mask_heli.lbm" +}; + +const uint8_t LBM_FLIGHT_MODES_ICON[] = { +#include "../../bitmaps/Horus/mask_flight_modes.lbm" +}; + +const uint8_t LBM_INPUTS_ICON[] = { +#include "../../bitmaps/Horus/mask_inputs.lbm" +}; + +const uint8_t LBM_MIXER_ICON[] = { +#include "../../bitmaps/Horus/mask_mixer.lbm" +}; + +const uint8_t LBM_OUTPUTS_ICON[] = { +#include "../../bitmaps/Horus/mask_outputs.lbm" +}; + +const uint8_t LBM_CURVES_ICON[] = { +#include "../../bitmaps/Horus/mask_curves.lbm" +}; + +const uint8_t LBM_GVARS_ICON[] = { +#include "../../bitmaps/Horus/mask_gvars.lbm" +}; + +const uint8_t LBM_LOGICAL_SWITCHES_ICON[] = { +#include "../../bitmaps/Horus/mask_logical_switches.lbm" +}; + +const uint8_t LBM_SPECIAL_FUNCTIONS_ICON[] = { +#include "../../bitmaps/Horus/mask_special_functions.lbm" +}; + +const uint8_t LBM_LUA_SCRIPTS_ICON[] = { +#include "../../bitmaps/Horus/mask_lua_scripts.lbm" +}; + +const uint8_t LBM_TELEMETRY_ICON[] = { +#include "../../bitmaps/Horus/mask_telemetry.lbm" +}; + +const uint8_t * const LBM_MODEL_ICONS[] = { + LBM_MODEL_ICON, + LBM_MODEL_SETUP_ICON, + CASE_HELI(LBM_HELI_ICON) + CASE_FLIGHT_MODES(LBM_FLIGHT_MODES_ICON) + LBM_INPUTS_ICON, + LBM_MIXER_ICON, + LBM_OUTPUTS_ICON, + CASE_CURVES(LBM_CURVES_ICON) + CASE_GVARS(LBM_GVARS_ICON) + LBM_LOGICAL_SWITCHES_ICON, + LBM_SPECIAL_FUNCTIONS_ICON, +#if defined(LUA_MODEL_SCRIPTS) + LBM_LUA_SCRIPTS_ICON, +#endif + LBM_TELEMETRY_ICON +}; + +/* + * Model selection screen bitmaps + */ + +const uint8_t LBM_LIBRARY_ICON[] = { +#include "../../bitmaps/Horus/mask_library.lbm" +}; + +const uint8_t LBM_LIBRARY_SLOT[] = { +#include "../../bitmaps/Horus/mask_library_slot.lbm" +}; + +const uint8_t LBM_LIBRARY_CURSOR[] = { +#include "../../bitmaps/Horus/mask_library_category_index.lbm" +}; + +const uint8_t LBM_SCORE0[] = { +#include "../../bitmaps/Horus/mask_library_score_0.lbm" +}; + +const uint8_t LBM_SCORE1[] = { +#include "../../bitmaps/Horus/mask_library_score_1.lbm" +}; + +const uint8_t LBM_STAR0[] = { +#include "../../bitmaps/Horus/mask_library_star_0.lbm" +}; + +const uint8_t LBM_STAR1[] = { +#include "../../bitmaps/Horus/mask_library_star_1.lbm" +}; + +/* + * Other + */ + +const uint8_t LBM_ASTERISK[] = { +#include "../../bitmaps/Horus/asterisk.lbm" +}; + +const uint8_t LBM_POINT[] = { +#include "../../bitmaps/Horus/mask_point.lbm" +}; + +const uint8_t LBM_CURVE_POINT[] = { +#include "../../bitmaps/Horus/mask_cvpoint.lbm" +}; + +const uint8_t LBM_CURVE_POINT_CENTER[] = { +#include "../../bitmaps/Horus/mask_cvpoint_center.lbm" +}; diff --git a/radio/src/gui/Horus/fonts.cpp b/radio/src/gui/Horus/fonts.cpp new file mode 100644 index 000000000..08b9ca28b --- /dev/null +++ b/radio/src/gui/Horus/fonts.cpp @@ -0,0 +1,88 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../../opentx.h" + +const uint16_t font_tinsize_specs[] PROGMEM = +#include "fonts/Horus/font_tinsize.specs" +; + +const pm_uchar font_tinsize[] PROGMEM = { +#include "fonts/Horus/font_tinsize.lbm" +}; + +const uint16_t font_smlsize_specs[] PROGMEM = +#include "fonts/Horus/font_smlsize.specs" +; + +const pm_uchar font_smlsize[] PROGMEM = { +#include "fonts/Horus/font_smlsize.lbm" +}; + +const uint16_t font_stdsize_specs[] PROGMEM = +#include "fonts/Horus/font_stdsize.specs" +; + +const pm_uchar font_stdsize[] PROGMEM = { +#include "fonts/Horus/font_stdsize.lbm" +}; + +const uint16_t font_midsize_specs[] PROGMEM = +#include "fonts/Horus/font_midsize.specs" +; + +const pm_uchar font_midsize[] PROGMEM = { +#include "fonts/Horus/font_midsize.lbm" +}; + +const uint16_t font_dblsize_specs[] PROGMEM = +#include "fonts/Horus/font_dblsize.specs" +; + +const pm_uchar font_dblsize[] PROGMEM = { +#include "fonts/Horus/font_dblsize.lbm" +}; + +const uint16_t font_xxlsize_specs[] PROGMEM = +#include "fonts/Horus/font_xxlsize.specs" +; + +const pm_uchar font_xxlsize[] PROGMEM = { +#include "fonts/Horus/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 }; +const pm_uchar *fontsTable[16] = { font_stdsize, font_tinsize, font_smlsize, font_midsize, font_dblsize, font_xxlsize }; diff --git a/radio/src/gui/Horus/gui.h b/radio/src/gui/Horus/gui.h new file mode 100644 index 000000000..5a2a096b8 --- /dev/null +++ b/radio/src/gui/Horus/gui.h @@ -0,0 +1,116 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "lcd.h" +#include "menus.h" + +#define MENU_HEADER_HEIGHT 45 +#define MENU_TITLE_TOP 48 +#define MENU_TITLE_HEIGHT 21 +#define MENU_BODY_TOP 69 // MENU_TITLE_TOP + MENU_TITLE_HEIGHT +#define MENU_CONTENT_TOP 72 +#define MENU_BODY_HEIGHT 182 +#define MENU_FOOTER_TOP 251 // MENU_BODY_TOP + MENU_BODY_HEIGHT +#define MENU_FOOTER_HEIGHT 21 + +#define MENUS_MARGIN_LEFT 6 + +#define DEFAULT_SCROLLBAR_X LCD_W-10 +#define DEFAULT_SCROLLBAR_Y MENU_CONTENT_TOP +#define DEFAULT_SCROLLBAR_H (MENU_FOOTER_TOP - DEFAULT_SCROLLBAR_Y - 6) + +#define NUM_BODY_LINES 9 +#define FH 20 + +#define INVERT_HORZ_MARGIN 3 +#define INVERT_VERT_MARGIN 1 +#define INVERT_LINE_HEIGHT 18 + +#define CURVE_SIDE_WIDTH 100 +#define CURVE_CENTER_X (LCD_W-CURVE_SIDE_WIDTH-7) +#define CURVE_CENTER_Y 151 + +#define MENU_TITLE_NEXT_POS (lcdNextPos + 10) +#define MENU_INIT_VPOS -1 + +void displaySplash(); +void displayScreenIndex(uint8_t index, uint8_t count); +void drawScrollbar(coord_t x, coord_t y, coord_t h, uint16_t offset, uint16_t count, uint8_t visible); +void drawHeader(int index); +void drawFooter(); +#define drawStatusLine(...) +void drawProgressBar(const char *label); +void updateProgressBar(int num, int den); +void drawTopmenuDatetime(); + + +// Header bitmaps +extern const uint8_t LBM_TOPMENU_POLYGON[]; +extern const uint8_t LBM_DOT[]; +extern const uint8_t LBM_CURRENT_BG[]; +extern const uint8_t LBM_CURRENT_SHADOW[]; +extern const uint8_t LBM_CURRENT_DOT[]; + +// Main view icons +extern const uint8_t LBM_MAINVIEW_BACKGROUND[]; +extern const uint8_t LBM_TOPMENU_OPENTX[]; +extern const uint8_t LBM_TOPMENU_USB[]; +extern const uint8_t LBM_HTRIM_FRAME[]; +extern const uint8_t LBM_VTRIM_FRAME[]; +extern const uint8_t LBM_TRIM_SHADOW[]; +extern const uint8_t LBM_RADIO_ICON[]; +extern const uint8_t LBM_MODEL_ICON[]; +extern const uint8_t LBM_TIMER_BACKGROUND[]; +extern const uint8_t LBM_RSCALE[]; + +// Menu icons +extern const uint8_t * const LBM_RADIO_ICONS[]; +extern const uint8_t * const LBM_MODEL_ICONS[]; + +// Model selection icons +extern const uint8_t LBM_LIBRARY_ICON[]; +extern const uint8_t LBM_LIBRARY_SLOT[]; +extern const uint8_t LBM_LIBRARY_CURSOR[]; +extern const uint8_t LBM_SCORE0[]; +extern const uint8_t LBM_SCORE1[]; +extern const uint8_t LBM_STAR0[]; +extern const uint8_t LBM_STAR1[]; + +// Other icons +extern const uint8_t LBM_ASTERISK[]; +extern const uint8_t LBM_POINT[]; +extern const uint8_t LBM_CURVE_POINT[]; +extern const uint8_t LBM_CURVE_POINT_CENTER[]; diff --git a/radio/src/gui/Horus/helpers.cpp b/radio/src/gui/Horus/helpers.cpp new file mode 100644 index 000000000..58de6d51d --- /dev/null +++ b/radio/src/gui/Horus/helpers.cpp @@ -0,0 +1,43 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../../opentx.h" + +uint8_t switchToMix(uint8_t source) +{ + div_t qr = div(source-1, 3); + return qr.quot+MIXSRC_FIRST_SWITCH; +} diff --git a/radio/src/gui/Horus/lcd.cpp b/radio/src/gui/Horus/lcd.cpp new file mode 100644 index 000000000..c23e393bd --- /dev/null +++ b/radio/src/gui/Horus/lcd.cpp @@ -0,0 +1,1094 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../../opentx.h" + +#if defined(SIMU) +display_t displayBuf[DISPLAY_BUFFER_SIZE]; +#endif + +uint16_t lcdColorTable[LCD_COLOR_COUNT]; + +void lcdColorsInit() +{ + lcdColorTable[TEXT_COLOR_INDEX] = BLACK; + lcdColorTable[TEXT_BGCOLOR_INDEX] = WHITE; + lcdColorTable[TEXT_INVERTED_COLOR_INDEX] = WHITE; + lcdColorTable[TEXT_INVERTED_BGCOLOR_INDEX] = RED; + lcdColorTable[LINE_COLOR_INDEX] = RGB(88, 88, 90); + lcdColorTable[SCROLLBOX_COLOR_INDEX] = RED; + lcdColorTable[MENU_TITLE_BGCOLOR_INDEX] = DARKGREY; + lcdColorTable[MENU_TITLE_COLOR_INDEX] = WHITE; + lcdColorTable[MENU_TITLE_DISABLE_COLOR_INDEX] = RGB(130, 1, 5); + lcdColorTable[HEADER_COLOR_INDEX] = DARKGREY; + lcdColorTable[ALARM_COLOR_INDEX] = RED; + lcdColorTable[WARNING_COLOR_INDEX] = YELLOW; + lcdColorTable[TEXT_DISABLE_COLOR_INDEX] = RGB(0x60, 0x60, 0x60); + lcdColorTable[CURVE_AXIS_COLOR_INDEX] = RGB(180, 180, 180); + lcdColorTable[CURVE_COLOR_INDEX] = RED; + lcdColorTable[CURVE_CURSOR_COLOR_INDEX] = RED; + lcdColorTable[TITLE_BGCOLOR_INDEX] = RED; + lcdColorTable[HEADER_BGCOLOR_INDEX] = DARKRED; +} + +coord_t lcdNextPos; + +#define FONT_CHARS_COUNT 103 + +char getMappedChar(unsigned char c) +{ + if (c == 0) + return 0; + else if (c < 0xC0) + return c - 0x20; + else + return c - 0xC0 + 96; +} + +int getFontPatternWidth(const uint16_t * spec, int index) +{ + return spec[index+1] - spec[index]; +} + +int getCharWidth(char c, const uint16_t * spec) +{ + return getFontPatternWidth(spec, getMappedChar(c)); +} + +void lcdDrawBitmapPattern(coord_t x, coord_t y, const uint8_t * img, LcdFlags flags, coord_t offset, coord_t width) +{ + coord_t w = *((uint16_t *)img); + coord_t height = *(((uint16_t *)img)+1); + + if (!width || width > w) { + width = w; + } + + if (x+width > LCD_W) { + width = LCD_W-x; + } + + display_t color = lcdColorTable[COLOR_IDX(flags)]; + + for (coord_t row=0; row> 8; + const pm_uchar * font = fontsTable[fontindex]; + const uint16_t * fontspecs = fontspecsTable[fontindex]; + lcdPutFontPattern(x, y, font, fontspecs, getMappedChar(c), flags); +} + +uint8_t getStringInfo(const char *s) +{ + uint8_t result = 0; + for (int i=0; s[i]; i++) { + result += s[i]; + } + return result; +} + +int getFontHeight(LcdFlags flags) +{ + static const int heightTable[16] = { 12, 10, 11, 14, 32, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12 }; + return heightTable[FONTSIZE(flags) >> 8]; +} + +int getBitmapScale(const uint8_t * bmp, int dstWidth, int dstHeight) +{ + int widthScale, heightScale; + + int bmpWidth = getBitmapWidth(bmp); + int bmpHeight = getBitmapHeight(bmp); + + if (bmpWidth == 0 || bmpHeight == 0) + return 0; + + if (bmpWidth > dstWidth) + widthScale = -((bmpWidth+dstWidth-1) / dstWidth); + else + widthScale = (dstWidth / bmpWidth); + if (bmpHeight > dstHeight) + heightScale = -((bmpHeight+dstHeight-1) / dstHeight); + else + heightScale = (dstHeight / bmpHeight); + return min(widthScale, heightScale); +} + +int getTextWidth(const pm_char * s, int len, LcdFlags flags) +{ + const uint16_t * specs = fontspecsTable[FONTSIZE(flags) >> 8]; + int result = 0; + for (int i=0; len==0 || i> 8; + const pm_uchar * font = fontsTable[fontindex]; + const uint16_t * fontspecs = fontspecsTable[fontindex]; + + if ((flags&INVERS) && ((~flags & BLINK) || BLINK_ON_PHASE)) { + if (COLOR_IDX(flags) == TEXT_COLOR_INDEX) { + flags += TEXT_INVERTED_COLOR - TEXT_COLOR; + } + if (FONTSIZE(flags) == TINSIZE) + lcdDrawSolidFilledRect(x-INVERT_HORZ_MARGIN+2, y-INVERT_VERT_MARGIN+2, width+2*INVERT_HORZ_MARGIN-5, INVERT_LINE_HEIGHT-7, TEXT_INVERTED_BGCOLOR); + else if (FONTSIZE(flags) == SMLSIZE) + lcdDrawSolidFilledRect(x-INVERT_HORZ_MARGIN+1, y-INVERT_VERT_MARGIN, width+2*INVERT_HORZ_MARGIN-2, INVERT_LINE_HEIGHT, TEXT_INVERTED_BGCOLOR); + else + lcdDrawSolidFilledRect(x-INVERT_HORZ_MARGIN, y/*-INVERT_VERT_MARGIN*/, width+2*INVERT_HORZ_MARGIN, INVERT_LINE_HEIGHT, TEXT_INVERTED_BGCOLOR); + } + + char str[256]; + if (flags & ZCHAR) + strcat_zchar(str, s, len); + else + strAppend(str, s, len); + + const coord_t orig_x = x; + bool setx = false; + while (len--) { + unsigned char c; + if (flags & ZCHAR) + c = idx2char(*s); + else + c = pgm_read_byte(s); + if (setx) { + x = c; + setx = false; + } + else if (!c) { + break; + } + else if (c >= 0x20) { + lcdPutFontPattern(x, y, font, fontspecs, getMappedChar(c), flags); + x = lcdNextPos; + } + else if (c == 0x1F) { // X-coord prefix + setx = true; + } + else if (c == 0x1E) { + x = orig_x; + y += height; + } + else if (c == 1) { + x += 1; + } + else { + x += 2*(c-1); + } + s++; + } + lcdNextPos = x; +} + +void lcdDrawText(coord_t x, coord_t y, const pm_char * s, LcdFlags flags) +{ + lcdDrawTextWithLen(x, y, s, 255, flags); +} + +void lcd_putsCenter(coord_t y, const pm_char * s, LcdFlags attr) +{ + int x = (LCD_W - getTextWidth(s)) / 2; + lcdDrawText(x, y, s, attr); +} + +void lcdDrawTextAtIndex(coord_t x, coord_t y, const pm_char * s,uint8_t idx, LcdFlags flags) +{ + uint8_t length; + length = pgm_read_byte(s++); + lcdDrawTextWithLen(x, y, s+length*idx, length, flags & ~ZCHAR); +} + +void lcd_outhex4(coord_t x, coord_t y, uint32_t val, LcdFlags flags) +{ + char s[5]; + for (int i=0; i<4; i++) { + char c = val & 0xf; + s[3-i] = c>9 ? c+'A'-10 : c+'0'; + val >>= 4; + } + s[4] = '\0'; + if (!(flags & LEFT)) + x -= getTextWidth(s); + else + flags -= LEFT; + lcdDrawText(x, y, s, flags); +} + +void lcdDrawNumber(coord_t x, coord_t y, int32_t val, LcdFlags flags, uint8_t len, const char * prefix, const char * suffix) +{ + char str[48+1]; // max=16 for the prefix, 16 chars for the number, 16 chars for the suffix + char *s = str+32; + *s = '\0'; + int idx = 0; + int mode = MODE(flags); + bool neg = false; + if (val < 0) { + val = -val; + neg = true; + } + do { + *--s = '0' + (val % 10); + ++idx; + val /= 10; + if (mode!=0 && idx==mode) { + mode = 0; + *--s = '.'; + if (val==0) + *--s = '0'; + } + } while (val!=0 || mode>0 || (mode==MODE(LEADING0) && idx>1; + int y = dxabs>>1; + int px = x1; + int py = y1; + + if (dxabs >= dyabs) { + /* the line is more horizontal than vertical */ + for (int i=0; i<=dxabs; i++) { + y += dyabs; + if (y>=dxabs) { + y -= dxabs; + py += sdy; + } + if ((1<<(px%8)) & pat) { + lcdDrawPoint(px, py, att); + } + px += sdx; + } + } + else { + /* the line is more vertical than horizontal */ + for (int i=0; i<=dyabs; i++) { + x += dxabs; + if (x >= dyabs) { + x -= dyabs; + px += sdx; + } + if ((1<<(py%8)) & pat) { + lcdDrawPoint(px, py, att); + } + py += sdy; + } + } +} +#endif + +void lcdDrawRect(coord_t x, coord_t y, coord_t w, coord_t h, uint8_t pat, LcdFlags att) +{ + if (att & ROUND) { + lcdDrawVerticalLine(x, y+1, h-2, pat, att); + lcdDrawVerticalLine(x+w-1, y+1, h-2, pat, att); + lcdDrawHorizontalLine(x+1, y+h-1, w-2, pat, att); + lcdDrawHorizontalLine(x+1, y, w-2, pat, att); + } + else { + lcdDrawVerticalLine(x, y, h, pat, att); + lcdDrawVerticalLine(x+w-1, y, h, pat, att); + lcdDrawHorizontalLine(x+1, y+h-1, w-2, pat, att); + lcdDrawHorizontalLine(x+1, y, w-2, pat, att); + } +} + +#if defined(SIMU) +void lcdDrawSolidFilledRect(coord_t x, scoord_t y, coord_t w, coord_t h, LcdFlags att) +{ + for (scoord_t i=y; i= MIXSRC_FIRST_SWITCH && idx < MIXSRC_FIRST_LOGICAL_SWITCH) { + idx = idx-MIXSRC_FIRST_SWITCH; + if (ZEXIST(g_eeGeneral.switchNames[idx])) + lcdDrawTextWithLen(x, y, g_eeGeneral.switchNames[idx], LEN_SWITCH_NAME, ZCHAR|att); + else + lcdDrawTextAtIndex(x, y, STR_VSRCRAW, idx+MIXSRC_FIRST_SWITCH-MIXSRC_Rud+1, att); + } + else if (idx < MIXSRC_SW1) + lcdDrawTextAtIndex(x, y, STR_VSRCRAW, idx-MIXSRC_Rud+1, att); + else if (idx <= MIXSRC_LAST_LOGICAL_SWITCH) + putsSwitches(x, y, SWSRC_SW1+idx-MIXSRC_SW1, att); + else if (idx < MIXSRC_CH1) + putsStrIdx(x, y, STR_PPM_TRAINER, idx-MIXSRC_FIRST_TRAINER+1, att); + else if (idx <= MIXSRC_LAST_CH) { + putsStrIdx(x, y, STR_CH, idx-MIXSRC_CH1+1, att); +#if 0 + if (ZEXIST(g_model.limitData[idx-MIXSRC_CH1].name) && (att & STREXPANDED)) { + lcdDrawChar(lcdNextPos, y, ' ', att); + lcdDrawTextWithLen(lcdNextPos+3, y, g_model.limitData[idx-MIXSRC_CH1].name, LEN_CHANNEL_NAME, ZCHAR|att); + } +#endif + } + else if (idx <= MIXSRC_LAST_GVAR) + putsStrIdx(x, y, STR_GV, idx-MIXSRC_GVAR1+1, att); + else if (idx < MIXSRC_FIRST_TELEM) { + lcdDrawTextAtIndex(x, y, STR_VSRCRAW, idx-MIXSRC_Rud+1-NUM_LOGICAL_SWITCH-NUM_TRAINER-NUM_CHNOUT-MAX_GVARS, att); + } + else { + idx -= MIXSRC_FIRST_TELEM; + div_t qr = div(idx, 3); + char s[sizeof(g_model.telemetrySensors[qr.quot].label)+2]; + int pos = zchar2str(s, g_model.telemetrySensors[qr.quot].label, sizeof(g_model.telemetrySensors[qr.quot].label)); + if (qr.rem) s[pos++] = (qr.rem==2 ? '+' : '-'); + s[pos] = '\0'; + lcdDrawText(x, y, s, att); + } +} + +void putsChnLetter(coord_t x, coord_t y, uint8_t idx, LcdFlags att) +{ + lcdDrawTextAtIndex(x, y, STR_RETA123, idx-1, att); +} + +void putsModelName(coord_t x, coord_t y, char *name, uint8_t id, LcdFlags att) +{ + uint8_t len = sizeof(g_model.header.name); + while (len>0 && !name[len-1]) --len; + if (len==0) { + putsStrIdx(x, y, STR_MODEL, id+1, att|LEADING0); + } + else { + lcdDrawTextWithLen(x, y, name, sizeof(g_model.header.name), ZCHAR|att); + } +} + +void putsSwitches(coord_t x, coord_t y, int8_t idx, LcdFlags att) +{ + if (idx == SWSRC_NONE) { + return lcdDrawTextAtIndex(x, y, STR_VSWITCHES, 0, att); + } + else if (idx == SWSRC_OFF) { + return lcdDrawTextAtIndex(x, y, STR_OFFON, 0, att); + } + + char s[8]; + int pos = 0; + if (idx < 0) { + s[pos++] = '!'; + idx = -idx; + } + + if (idx <= SWSRC_LAST_SWITCH) { + div_t swinfo = switchInfo(idx); + if (ZEXIST(g_eeGeneral.switchNames[swinfo.quot])) { + pos = zchar2str(&s[pos], g_eeGeneral.switchNames[swinfo.quot], LEN_SWITCH_NAME); + } + else { + s[pos++] = 'S'; + s[pos++] = 'A'+swinfo.quot; + } + s[pos++] = "\300-\301"[swinfo.rem]; + s[pos] = '\0'; + lcdDrawText(x, y, s, att); + } + /*else if (idx <= SWSRC_LAST_MULTIPOS_SWITCH) { + div_t swinfo = div(idx - SWSRC_FIRST_MULTIPOS_SWITCH, XPOTS_MULTIPOS_COUNT); + putsStrIdx(x, y, "S", swinfo.quot*10+swinfo.rem+11, att); + }*/ + else if (idx <= SWSRC_LAST_TRIM) { + lcdDrawTextAtIndex(x, y, STR_VSWITCHES, idx-SWSRC_FIRST_TRIM+1, att); + } + else if (idx <= SWSRC_LAST_LOGICAL_SWITCH) { + putsStrIdx(x, y, "L", idx-SWSRC_FIRST_LOGICAL_SWITCH+1, att); + } + else if (idx <= SWSRC_ONE) { + lcdDrawTextAtIndex(x, y, STR_VSWITCHES, idx-SWSRC_ON+1+(2*NUM_STICKS), att); + } + else if (idx <= SWSRC_LAST_FLIGHT_MODE) { + putsStrIdx(x, y, STR_FP, idx-SWSRC_FIRST_FLIGHT_MODE, att); + } + else if (idx == SWSRC_TELEMETRY_STREAMING) { + lcdDrawText(x, y, "Tele", att); + } + else { + lcdDrawTextWithLen(x, y, g_model.telemetrySensors[idx-SWSRC_FIRST_SENSOR].label, TELEM_LABEL_LEN, ZCHAR|att); + } +} + +#if defined(FLIGHT_MODES) +void putsFlightMode(coord_t x, coord_t y, int8_t idx, LcdFlags att) +{ + if (idx==0) { + lcdDrawTextAtIndex(x, y, STR_MMMINV, 0, att); + } + else { + putsStrIdx(x, y, STR_FP, abs(idx)-1, att); + } +} +#endif + +void putsCurveRef(coord_t x, coord_t y, CurveRef &curve, LcdFlags att) +{ + if (curve.value != 0) { + switch (curve.type) { + case CURVE_REF_DIFF: + lcdDrawText(x, y, "D", att); + GVAR_MENU_ITEM(lcdNextPos, y, curve.value, -100, 100, LEFT|att, 0, 0); + break; + + case CURVE_REF_EXPO: + lcdDrawText(x, y, "E", att); + GVAR_MENU_ITEM(lcdNextPos, y, curve.value, -100, 100, LEFT|att, 0, 0); + break; + + case CURVE_REF_FUNC: + lcdDrawTextAtIndex(x, y, STR_VCURVEFUNC, curve.value, att); + break; + + case CURVE_REF_CUSTOM: + putsCurve(x, y, curve.value, att); + break; + } + } +} + +void putsCurve(coord_t x, coord_t y, int8_t idx, LcdFlags att) +{ + if (idx == 0) { + return lcdDrawTextAtIndex(x, y, STR_MMMINV, 0, att); + } + bool neg = false; + if (idx < 0) { + idx = -idx; + neg = true; + } + putsStrIdx(x, y, STR_CV, idx, att); + if (neg) { + if ((att&INVERS) && ((~att&BLINK) || BLINK_ON_PHASE)) + att &= ~(INVERS|BLINK); + lcdDrawChar(x-3, y, '!', att); + } +} + +void putsTimerMode(coord_t x, coord_t y, int8_t mode, LcdFlags att) +{ + if (mode >= 0) { + if (mode < TMRMODE_COUNT) + return lcdDrawTextAtIndex(x, y, STR_VTMRMODES, mode, att); + else + mode -= (TMRMODE_COUNT-1); + } + putsSwitches(x, y, mode, att); +} + +void putsTrimMode(coord_t x, coord_t y, uint8_t phase, uint8_t idx, LcdFlags att) +{ + trim_t v = getRawTrimValue(phase, idx); + unsigned int mode = v.mode; + unsigned int p = mode >> 1; + + if (mode == TRIM_MODE_NONE) { + lcdDrawText(x, y, "--", att); + } + else { + char s[2]; + s[0] = (mode % 2 == 0) ? ':' : '+'; + s[1] = '0'+p; + lcdDrawTextWithLen(x, y, s, 2, att); + } +} + +const pm_uint8_t bchunit_ar[] PROGMEM = { + UNIT_DIST, // Alt + UNIT_RAW, // Rpm + UNIT_PERCENT, // Fuel + UNIT_TEMPERATURE, // T1 + UNIT_TEMPERATURE, // T2 + UNIT_KTS, // Speed + UNIT_DIST, // Dist + UNIT_DIST, // GPS Alt +}; + +void putsValueWithUnit(coord_t x, coord_t y, int32_t val, uint8_t unit, LcdFlags att) +{ + // convertUnit(val, unit); + if (!(att & NO_UNIT) && unit != UNIT_RAW) { + char unitStr[8]; + strAppend(unitStr, STR_VTELEMUNIT+1+unit*STR_VTELEMUNIT[0], STR_VTELEMUNIT[0]); + lcdDrawNumber(x, y, val, att, 0, NULL, unitStr); + } + else { + lcdDrawNumber(x, y, val, att); + } +} + +void displayDate(coord_t x, coord_t y, TelemetryItem & telemetryItem, LcdFlags att) +{ +} + +void displayGpsCoords(coord_t x, coord_t y, TelemetryItem & telemetryItem, LcdFlags att) +{ +} + +void putsTelemetryChannelValue(coord_t x, coord_t y, uint8_t channel, int32_t value, LcdFlags att) +{ + TelemetryItem & telemetryItem = telemetryItems[channel]; + TelemetrySensor & telemetrySensor = g_model.telemetrySensors[channel]; + + if (telemetrySensor.unit == UNIT_DATETIME) { + displayDate(x, y, telemetryItem, att); + } + else if (telemetrySensor.unit == UNIT_GPS) { + displayGpsCoords(x, y, telemetryItem, att); + } + else { + LcdFlags flags = att; + if (telemetrySensor.prec==2) + flags |= PREC2; + else if (telemetrySensor.prec==1) + flags |= PREC1; + putsValueWithUnit(x, y, value, telemetrySensor.unit == UNIT_CELLS ? UNIT_VOLTS : telemetrySensor.unit, flags); + } +} + +void putsChannelValue(coord_t x, coord_t y, source_t channel, int32_t value, LcdFlags att) +{ + if (channel >= MIXSRC_FIRST_TELEM) { + channel = (channel-MIXSRC_FIRST_TELEM) / 3; + putsTelemetryChannelValue(x, y, channel, value, att); + } + else if (channel >= MIXSRC_FIRST_TIMER || channel == MIXSRC_TX_TIME) { + putsTimer(x, y, value, att); + } + else if (channel == MIXSRC_TX_VOLTAGE) { + lcdDrawNumber(x, y, value, att|PREC1); + } + else if (channel < MIXSRC_FIRST_CH) { + lcdDrawNumber(x, y, calcRESXto100(value), att); + } + else if (channel <= MIXSRC_LAST_CH) { +#if defined(PPM_UNIT_PERCENT_PREC1) + lcdDrawNumber(x, y, calcRESXto1000(value), att|PREC1); +#else + lcdDrawNumber(x, y, calcRESXto100(value), att); +#endif + } + else { + lcdDrawNumber(x, y, value, att); + } +} + +void putsChannel(coord_t x, coord_t y, source_t channel, LcdFlags att) +{ + getvalue_t value = getValue(channel); + putsChannelValue(x, y, channel, value, att); +} + +void lcdSetContrast() +{ + lcdSetRefVolt(g_eeGeneral.contrast); +} + +void lcdDrawTransparentPixel(display_t * p, uint8_t opacity, uint16_t color) +{ + ASSERT_IN_DISPLAY(p); + + if (opacity == OPACITY_MAX) { + lcdDrawPixel(p, color); + } + else if (opacity != 0) { + uint8_t bgWeight = OPACITY_MAX - opacity; + COLOR_SPLIT(color, red, green, blue); + COLOR_SPLIT(*p, bgRed, bgGreen, bgBlue); + uint16_t r = (bgRed * bgWeight + red * opacity) / OPACITY_MAX; + uint16_t g = (bgGreen * bgWeight + green * opacity) / OPACITY_MAX; + uint16_t b = (bgBlue * bgWeight + blue * opacity) / OPACITY_MAX; + lcdDrawPixel(p, COLOR_JOIN(r, g, b)); + } +} + +void lcdDrawPoint(coord_t x, coord_t y, LcdFlags att) +{ + display_t * p = PIXEL_PTR(x, y); + display_t color = lcdColorTable[COLOR_IDX(att)]; + if (p < DISPLAY_END) { + *p = color; + } +} + +void lcdDrawHorizontalLine(coord_t x, coord_t y, coord_t w, uint8_t pat, LcdFlags att) +{ + if (y >= LCD_H) return; + if (x+w > LCD_W) { w = LCD_W - x; } + + display_t * p = PIXEL_PTR(x, y); + display_t color = lcdColorTable[COLOR_IDX(att)]; + uint8_t opacity = 0x0F - (att >> 24); + + if (pat == SOLID) { + while (w--) { + lcdDrawTransparentPixel(p, opacity, color); + p++; + } + } + else { + while (w--) { + if (pat & 1) { + lcdDrawTransparentPixel(p, opacity, color); + pat = (pat >> 1) | 0x80; + } + else { + pat = pat >> 1; + } + p++; + } + } +} + +void lcdDrawVerticalLine(coord_t x, coord_t y, coord_t h, uint8_t pat, LcdFlags att) +{ + if (x >= LCD_W) return; + if (y >= LCD_H) return; + if (h<0) { y+=h; h=-h; } + if (y<0) { h+=y; y=0; if (h<=0) return; } + if (y+h > LCD_H) { h = LCD_H - y; } + + display_t color = lcdColorTable[COLOR_IDX(att)]; + uint8_t opacity = 0x0F - (att >> 24); + + if (pat == SOLID) { + while (h--) { + lcdDrawTransparentPixel(x, y, opacity, color); + y++; + } + } + else { + if (pat==DOTTED && !(y%2)) { + pat = ~pat; + } + while (h--) { + if (pat & 1) { + lcdDrawTransparentPixel(x, y, opacity, color); + pat = (pat >> 1) | 0x80; + } + else { + pat = pat >> 1; + } + y++; + } + } +} + +#if defined(SIMU) +inline void lcdDrawBitmapDMA(coord_t x, coord_t y, coord_t width, coord_t height, const uint8_t * img) +{ + lcdDrawBitmap(x, y, img-4, 0, 0, -1); +} +#endif + +#if !defined(BOOT) +void lcdDrawBitmap(coord_t x, coord_t y, const uint8_t * bmp, coord_t offset, coord_t width, int scale) +{ + int w = getBitmapWidth(bmp); + int height = getBitmapHeight(bmp); + + if (!width || width > w) { + width = w; + } + + if (x+width > LCD_W) { + width = LCD_W-x; + } + + if (scale == 0) { + lcdDrawBitmapDMA(x, y, width, height, bmp+4); + } + else if (scale < 0) { + for (coord_t i=0, row=0; row= 360 || endAngle <= 0) + return false; + + if (startAngle == 0) { + slopes[1] = 100000; + slopes[2] = -100000; + } + else { + float angle1 = float(startAngle) * PI / 180; + if (startAngle >= 180) { + slopes[1] = -100000; + slopes[2] = cos(angle1) * 100 / sin(angle1); + } + else { + slopes[1] = cos(angle1) * 100 / sin(angle1); + slopes[2] = -100000; + } + } + + if (endAngle == 360) { + slopes[0] = -100000; + slopes[3] = 100000; + } + else { + float angle2 = float(endAngle) * PI / 180; + if (endAngle >= 180) { + slopes[0] = -100000; + slopes[3] = -cos(angle2) * 100 / sin(angle2); + } + else { + slopes[0] = cos(angle2) * 100 / sin(angle2); + slopes[3] = -100000; + } + } + + return true; +} + +void lcdDrawPie(int x0, int y0, int radius, int startAngle, int endAngle) +{ + int slopes[4]; + if (!evalSlopes(slopes, startAngle, endAngle)) + return; + + for (int y=0; y<=radius; y++) { + for (int x=0; x<=radius; x++) { + if (x*x+y*y <= radius*radius) { + int slope = (x==0 ? (y<0 ? -99000 : 99000) : y*100/x); + if (slope >= slopes[0] && slope < slopes[1]) { + lcdDrawPixel(x0+x, y0-y, WHITE); + } + if (-slope >= slopes[0] && -slope < slopes[1]) { + lcdDrawPixel(x0+x, y0+y, WHITE); + } + if (slope >= slopes[2] && slope < slopes[3]) { + lcdDrawPixel(x0-x, y0-y, WHITE); + } + if (-slope >= slopes[2] && -slope < slopes[3]) { + lcdDrawPixel(x0-x, y0+y, WHITE); + } + } + } + } +} + +void lcdDrawBitmapPie(int x0, int y0, const uint16_t * img, int startAngle, int endAngle) +{ + const uint16_t * q = img; + coord_t width = *q++; + coord_t height = *q++; + + int slopes[4]; + if (!evalSlopes(slopes, startAngle, endAngle)) + return; + + int w2 = width/2; + int h2 = height/2; + + for (int y=h2-1; y>=0; y--) { + for (int x=w2-1; x>=0; x--) { + int slope = (x==0 ? (y<0 ? -99000 : 99000) : y*100/x); + if (slope >= slopes[0] && slope < slopes[1]) { + displayBuf[(y0+h2-y)*LCD_W + x0+w2+x] = q[(h2-y)*width + w2+x]; + } + if (-slope >= slopes[0] && -slope < slopes[1]) { + displayBuf[(y0+h2+y)*LCD_W + x0+w2+x] = q[(h2+y)*width + w2+x]; + } + if (slope >= slopes[2] && slope < slopes[3]) { + displayBuf[(y0+h2-y)*LCD_W + x0+w2-x] = q[(h2-y)*width + w2-x]; + } + if (-slope >= slopes[2] && -slope < slopes[3]) { + displayBuf[(y0+h2+y)*LCD_W + x0+w2-x] = q[(h2+y)*width + w2-x]; + } + } + } +} + +void lcdDrawBitmapPatternPie(coord_t x0, coord_t y0, const uint8_t * img, LcdFlags flags, int startAngle, int endAngle) +{ + coord_t width = *((uint16_t *)img); + coord_t height = *(((uint16_t *)img)+1); + const uint8_t * q = img+4; + + int slopes[4]; + if (!evalSlopes(slopes, startAngle, endAngle)) + return; + + display_t color = lcdColorTable[COLOR_IDX(flags)]; + + int w2 = width/2; + int h2 = height/2; + + for (int y=h2-1; y>=0; y--) { + for (int x=w2-1; x>=0; x--) { + int slope = (x==0 ? (y<0 ? -99000 : 99000) : y*100/x); + if (slope >= slopes[0] && slope < slopes[1]) { + lcdDrawTransparentPixel(x0+w2+x, y0+h2-y, q[(h2-y)*width + w2+x], color); + } + if (-slope >= slopes[0] && -slope < slopes[1]) { + lcdDrawTransparentPixel(x0+w2+x, y0+h2+y, q[(h2+y)*width + w2+x], color); + } + if (slope >= slopes[2] && slope < slopes[3]) { + lcdDrawTransparentPixel(x0+w2-x, y0+h2-y, q[(h2-y)*width + w2-x], color); + } + if (-slope >= slopes[2] && -slope < slopes[3]) { + lcdDrawTransparentPixel(x0+w2-x, y0+h2+y, q[(h2+y)*width + w2-x], color); + } + } + } +} diff --git a/radio/src/gui/Horus/lcd.h b/radio/src/gui/Horus/lcd.h new file mode 100644 index 000000000..e54e06ea8 --- /dev/null +++ b/radio/src/gui/Horus/lcd.h @@ -0,0 +1,337 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#ifndef _LCD_H_ +#define _LCD_H_ + +#define LCD_W 480 +#define LCD_H 272 + +#define BOX_WIDTH 81 +#define coord_t int +#define scoord_t int +#define CENTER +#define CENTER_OFS 0 +#define CONTRAST_MIN 0 +#define CONTRAST_MAX 45 + +#define lcdint_t int32_t + +#define LCD_COLS 30 + +#define BSS 0x00 +#define FIXEDWIDTH 0x00 +#define BOLD 0x00 + +/* lcd common flags */ +#define BLINK 0x01 + +/* lcd text flags */ +#define INVERS 0x02 +#define LEFT 0x08 /* align left */ + +/* lcd puts flags */ +#define ZCHAR 0x04 + +/* lcd outdez flags */ +#define LEADING0 0x10 +#define PREC1 0x20 +#define PREC2 0x30 +#define MODE(flags) ((((int8_t)(flags) & 0x30) - 0x10) >> 4) + +/* rect, square flags */ +#define ROUND 0x02 + +/* telemetry flags */ +#define NO_UNIT 0x40 + +#define FONTSIZE(x) ((x) & 0x0700) +#define TINSIZE 0x0100 +#define SMLSIZE 0x0200 +#define MIDSIZE 0x0300 +#define DBLSIZE 0x0400 +#define XXLSIZE 0x0500 +#define ERASEBG 0x8000 +#define VERTICAL 0x0800 + +#define TIMEBLINK 0x1000 +#define TIMEHOUR 0x2000 +#define STREXPANDED 0x4000 + +// remove windows default definitions +#undef OPAQUE +#undef RGB + +#define TO5BITS(x) ((x) >> 3) +#define TO6BITS(x) ((x) >> 2) +#define RGB(r, g, b) ((TO5BITS(r) << 11) + (TO6BITS(g) << 5) + (TO5BITS(b) << 0)) +#define WHITE RGB(0xF0, 0xF0, 0xF0) +#define BLACK RGB(0, 0, 0) +#define YELLOW RGB(0xF0, 0xD0, 0x10) +#define BLUE RGB(0x30, 0xA0, 0xE0) +#define DARKGREY RGB(0x40, 0x40, 0x40) +#define RED RGB(229, 32, 30) +#define DARKRED RGB(160, 0, 6) + +#define LcdFlags uint32_t + +enum LcdColorIndex +{ + TEXT_COLOR_INDEX, + TEXT_BGCOLOR_INDEX, + TEXT_INVERTED_COLOR_INDEX, + TEXT_INVERTED_BGCOLOR_INDEX, + LINE_COLOR_INDEX, + SCROLLBOX_COLOR_INDEX, + MENU_TITLE_BGCOLOR_INDEX, + MENU_TITLE_COLOR_INDEX, + MENU_TITLE_DISABLE_COLOR_INDEX, + HEADER_COLOR_INDEX, + ALARM_COLOR_INDEX, + WARNING_COLOR_INDEX, + TEXT_DISABLE_COLOR_INDEX, + CURVE_AXIS_COLOR_INDEX, + CURVE_COLOR_INDEX, + CURVE_CURSOR_COLOR_INDEX, + HEADER_BGCOLOR_INDEX, + TITLE_BGCOLOR_INDEX, + LCD_COLOR_COUNT +}; + +extern uint16_t lcdColorTable[LCD_COLOR_COUNT]; +void lcdColorsInit(); + +#define OPACITY_MAX 0x0F +#define OPACITY(x) ((x)<<24) + +#define COLOR(index) ((index) << 16) +#define TEXT_COLOR COLOR(TEXT_COLOR_INDEX) +#define TEXT_BGCOLOR COLOR(TEXT_BGCOLOR_INDEX) +#define TEXT_INVERTED_COLOR COLOR(TEXT_INVERTED_COLOR_INDEX) +#define TEXT_INVERTED_BGCOLOR COLOR(TEXT_INVERTED_BGCOLOR_INDEX) +#define LINE_COLOR COLOR(LINE_COLOR_INDEX) +#define SCROLLBOX_COLOR COLOR(SCROLLBOX_COLOR_INDEX) +#define HEADER_SEPARATOR_COLOR COLOR(HEADER_SEPARATOR_COLOR_INDEX) +#define MENU_TITLE_BGCOLOR COLOR(MENU_TITLE_BGCOLOR_INDEX) +#define MENU_TITLE_COLOR COLOR(MENU_TITLE_COLOR_INDEX) +#define MENU_TITLE_DISABLE_COLOR COLOR(MENU_TITLE_DISABLE_COLOR_INDEX) +#define HEADER_COLOR COLOR(HEADER_COLOR_INDEX) +#define ALARM_COLOR COLOR(ALARM_COLOR_INDEX) +#define WARNING_COLOR COLOR(WARNING_COLOR_INDEX) +#define TEXT_DISABLE_COLOR COLOR(TEXT_DISABLE_COLOR_INDEX) +#define CURVE_AXIS_COLOR COLOR(CURVE_AXIS_COLOR_INDEX) +#define CURVE_COLOR COLOR(CURVE_COLOR_INDEX) +#define CURVE_CURSOR_COLOR COLOR(CURVE_CURSOR_COLOR_INDEX) +#define TITLE_BGCOLOR COLOR(TITLE_BGCOLOR_INDEX) +#define HEADER_BGCOLOR COLOR(HEADER_BGCOLOR_INDEX) + +#define COLOR_IDX(att) uint8_t((att) >> 16) + +#define COLOR_SPLIT(color, r, g, b) \ + uint16_t r = ((color) & 0xF800) >> 11; \ + uint16_t g = ((color) & 0x07E0) >> 5; \ + uint16_t b = ((color) & 0x001F) + +#define COLOR_JOIN(r, g, b) \ + (((r) << 11) + ((g) << 5) + (b)) + +#define display_t uint16_t +#define DISPLAY_PIXELS_COUNT (LCD_W*LCD_H) +#define DISPLAY_BUFFER_SIZE (sizeof(display_t)*DISPLAY_PIXELS_COUNT) + +#if defined(SIMU) +extern display_t displayBuf[DISPLAY_BUFFER_SIZE]; +#else +extern uint32_t CurrentFrameBuffer; +#define displayBuf ((uint16_t *)CurrentFrameBuffer) +#endif + +#define lcdRefreshWait() + +#define DISPLAY_END (displayBuf + DISPLAY_BUFFER_SIZE) +#define ASSERT_IN_DISPLAY(p) assert((p) >= displayBuf && (p) < DISPLAY_END) + +extern coord_t lcdNextPos; + +void lcdDrawChar(coord_t x, coord_t y, const unsigned char c, LcdFlags attr=TEXT_COLOR); +void lcdDrawText(coord_t x, coord_t y, const pm_char * s, LcdFlags attr=TEXT_COLOR); +void lcdDrawTextAtIndex(coord_t x, coord_t y, const pm_char * s, uint8_t idx, LcdFlags attr=TEXT_COLOR); +void lcdDrawTextWithLen(coord_t x, coord_t y, const pm_char * s, uint8_t len, LcdFlags attr=TEXT_COLOR); +void lcdDrawTextWithLen(coord_t x, coord_t y, const pm_char * s, unsigned char len); +void lcd_putsCenter(coord_t y, const pm_char * s, LcdFlags attr=0); +void lcd_outhex4(coord_t x, coord_t y, uint32_t val, LcdFlags mode=0); +void lcdDrawNumber(coord_t x, coord_t y, int32_t val, LcdFlags flags=0, uint8_t len=0, const char * prefix=NULL, const char * suffix=NULL); + +void putsStrIdx(coord_t x, coord_t y, const pm_char *str, int idx, LcdFlags att=0, const char *prefix=""); +void putsModelName(coord_t x, coord_t y, char *name, uint8_t id, LcdFlags att); +void putsSwitches(coord_t x, coord_t y, int8_t swtch, LcdFlags att=0); +void putsMixerSource(coord_t x, coord_t y, uint8_t idx, LcdFlags att=0); +void putsFlightMode(coord_t x, coord_t y, int8_t idx, LcdFlags att=0); +void putsCurveRef(coord_t x, coord_t y, CurveRef &curve, LcdFlags att=0); +void putsCurve(coord_t x, coord_t y, int8_t idx, LcdFlags att=0); +void putsTimerMode(coord_t x, coord_t y, int8_t mode, LcdFlags att=0); +void putsTrimMode(coord_t x, coord_t y, uint8_t phase, uint8_t idx, LcdFlags att); + +#define putsChn(x, y, idx, att) putsMixerSource(x, y, MIXSRC_CH1+idx-1, att) +void putsChnLetter(coord_t x, coord_t y, uint8_t idx, LcdFlags attr); + +void putsVolts(coord_t x, coord_t y, uint16_t volts, LcdFlags att); +void putsVBat(coord_t x, coord_t y, LcdFlags att); + +void putsChannelValue(coord_t x, coord_t y, source_t channel, int32_t val, LcdFlags att=0); +void putsChannel(coord_t x, coord_t y, source_t channel, LcdFlags att=0); +void putsTelemetryChannelValue(coord_t x, coord_t y, uint8_t channel, int32_t val, LcdFlags att=0); + +#define putstime_t int32_t + +void getTimerString(char * str, putstime_t tme, LcdFlags att=0); +void putsRtcTime(coord_t x, coord_t y, LcdFlags att=0); +void putsTimer(coord_t x, coord_t y, putstime_t tme, LcdFlags att=0); + +#define SOLID 0xff +#define DOTTED 0x55 +#define STASHED 0x70 + +#define PIXEL_PTR(x, y) &displayBuf[(y)*LCD_W + (x)] + + +inline void lcdDrawPixel(display_t * p, display_t value) +{ + *p = value; +} + +inline void lcdDrawPixel(coord_t x, coord_t y, display_t value) +{ + display_t * p = PIXEL_PTR(x, y); + lcdDrawPixel(p, value); +} + +void lcdDrawTransparentPixel(display_t * p, uint8_t opacity, uint16_t color); +void lcdDrawPoint(coord_t x, coord_t y, LcdFlags att=0); +void lcdDrawHorizontalLine(coord_t x, coord_t y, coord_t w, uint8_t pat, LcdFlags att=0); +void lcdDrawVerticalLine(coord_t x, scoord_t y, scoord_t h, uint8_t pat, LcdFlags att=0); +void lcdDrawLine(coord_t x1, coord_t y1, coord_t x2, coord_t y2, uint8_t pat=SOLID, LcdFlags att=0); + +inline void lcdDrawTransparentPixel(coord_t x, coord_t y, uint8_t opacity, uint16_t color) +{ + display_t * p = PIXEL_PTR(x, y); + lcdDrawTransparentPixel(p, opacity, color); +} + +#if !defined(SIMU) +inline void lcdDrawSolidFilledRect(coord_t x, scoord_t y, coord_t w, coord_t h, LcdFlags att) +{ + lcdDrawSolidFilledRectDMA(x, y, w, h, lcdColorTable[COLOR_IDX(att)]); +} +#else +void lcdDrawSolidFilledRect(coord_t x, scoord_t y, coord_t w, coord_t h, LcdFlags att); +#endif + +inline void lcdClear() +{ + lcdDrawSolidFilledRect(0, 0, LCD_W, LCD_H, 0); +} + +inline void lcdDrawSolidHorizontalLine(coord_t x, scoord_t y, coord_t w, LcdFlags att) +{ + lcdDrawSolidFilledRect(x, y, w, 1, att); +} + +inline void lcdDrawSolidVerticalLine(coord_t x, scoord_t y, coord_t h, LcdFlags att) +{ + if (h<0) { y+=h; h=-h; } + lcdDrawSolidFilledRect(x, y, 1, h, att); +} + +inline void lcdDrawSolidRect(coord_t x, scoord_t y, coord_t w, coord_t h, LcdFlags att) +{ + lcdDrawSolidVerticalLine(x, y, h, att); + lcdDrawSolidVerticalLine(x+w-1, y, h, att); + lcdDrawSolidHorizontalLine(x, y, w, att); + lcdDrawSolidHorizontalLine(x, y+h-1, w, att); +} + +void lcdDrawFilledRect(coord_t x, scoord_t y, coord_t w, coord_t h, LcdFlags att); +void lcdDrawBlackOverlay(); +void lcdDrawRect(coord_t x, coord_t y, coord_t w, coord_t h, uint8_t pat=SOLID, LcdFlags att=0); +void lcdDrawCircle(int x0, int y0, int radius); +void lcdDrawPie(int x0, int y0, int radius, int angle1=0, int angle2=360); +void lcdDrawBitmapPie(int x0, int y0, const uint16_t * img, int startAngle, int endAngle); +void lcdDrawBitmapPatternPie(coord_t x0, coord_t y0, const uint8_t * img, LcdFlags flags=0, int startAngle=0, int endAngle=360); + +inline void lcdDrawSquare(coord_t x, coord_t y, coord_t w, LcdFlags att=0) +{ + lcdDrawSolidRect(x, y, w, w, att); +} + +inline int getBitmapWidth(const uint8_t * bmp) +{ + return *((const uint16_t *)bmp); +} + +inline int getBitmapHeight(const uint8_t * bmp) +{ + return *(((const uint16_t *)bmp)+1); +} + +inline int getBitmapScaledSize(int size, int scale) +{ + if (scale >= -1 && scale <= 1) + return size; + else if (scale < 0) + return -(size / scale); + else + return size * scale; +} + +int getBitmapScale(const uint8_t * bmp, int dstWidth, int dstHeight); +int getTextWidth(const pm_char *s, int len=0, LcdFlags flags=0); +void lcdDrawBitmap(coord_t x, coord_t y, const uint8_t * img, coord_t offset=0, coord_t width=0, int scale=0); +void lcdDrawBitmapPattern(coord_t x, coord_t y, const uint8_t * img, LcdFlags flags=0, coord_t offset=0, coord_t width=0); + +#define lcdSetRefVolt(...) +void lcdSetContrast(); +#define lcdOff(...) + +const char * bmpLoad(uint8_t * dest, const char * filename, uint16_t width, uint16_t height); + +#if defined(BOOT) + #define BLINK_ON_PHASE (0) +#else + #define BLINK_ON_PHASE (g_blinkTmr10ms & (1<<6)) +#endif + +#endif // _LCD_H_ diff --git a/radio/src/gui/Horus/menu_general.cpp b/radio/src/gui/Horus/menu_general.cpp new file mode 100644 index 000000000..9be272d63 --- /dev/null +++ b/radio/src/gui/Horus/menu_general.cpp @@ -0,0 +1,96 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../../opentx.h" + +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 MenuFuncP 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*/ }); + return menuCustomFunctions(event, g_eeGeneral.customFn, globalFunctionsContext); +} diff --git a/radio/src/gui/Horus/menu_general_calib.cpp b/radio/src/gui/Horus/menu_general_calib.cpp new file mode 100644 index 000000000..bd6dd7674 --- /dev/null +++ b/radio/src/gui/Horus/menu_general_calib.cpp @@ -0,0 +1,251 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../../opentx.h" + +#define XPOT_DELTA 10 +#define XPOT_DELAY 10 /* cycles */ + +#define BAR_HEIGHT (BOX_WIDTH-9) +#define LBOX_CENTERX (BOX_WIDTH/2 + 17) +#define RBOX_CENTERX (LCD_W-LBOX_CENTERX) + +void drawPotsBars() +{ + // Optimization by Mike Blandford + uint8_t x, i, len ; // declare temporary variables + for (x=LCD_W/2-9, i=NUM_STICKS; i= POT1 && i <= POT_LAST) { + if (IS_POT_WITHOUT_DETENT(i)) { + reusableBuffer.calib.midVals[i] = (reusableBuffer.calib.hiVals[i] + reusableBuffer.calib.loVals[i]) / 2; + } +#if 0 + uint8_t idx = i - POT1; + int count = reusableBuffer.calib.xpotsCalib[idx].stepsCount; + if (IS_POT_MULTIPOS(i) && count <= XPOTS_MULTIPOS_COUNT) { + if (reusableBuffer.calib.xpotsCalib[idx].lastCount == 0 || vt < reusableBuffer.calib.xpotsCalib[idx].lastPosition - XPOT_DELTA || vt > reusableBuffer.calib.xpotsCalib[idx].lastPosition + XPOT_DELTA) { + reusableBuffer.calib.xpotsCalib[idx].lastPosition = vt; + reusableBuffer.calib.xpotsCalib[idx].lastCount = 1; + } + else { + if (reusableBuffer.calib.xpotsCalib[idx].lastCount < 255) reusableBuffer.calib.xpotsCalib[idx].lastCount++; + } + if (reusableBuffer.calib.xpotsCalib[idx].lastCount == XPOT_DELAY) { + int16_t position = reusableBuffer.calib.xpotsCalib[idx].lastPosition; + bool found = false; + for (int j=0; j= step-XPOT_DELTA && position <= step+XPOT_DELTA) { + found = true; + break; + } + } + if (!found) { + if (count < XPOTS_MULTIPOS_COUNT) { + reusableBuffer.calib.xpotsCalib[idx].steps[count] = position; + } + reusableBuffer.calib.xpotsCalib[idx].stepsCount += 1; + } + } + } +#endif + } + } + + calibrationState = reusableBuffer.calib.state; // make sure we don't scroll while calibrating + + switch (event) + { + case EVT_ENTRY: + reusableBuffer.calib.state = 0; + break; + + case EVT_KEY_BREAK(KEY_ENTER): + reusableBuffer.calib.state++; + break; + } + + switch (reusableBuffer.calib.state) { + case 0: + // START CALIBRATION + if (!READ_ONLY()) { + lcd_putsCenter(MENU_CONTENT_TOP+FH, STR_MENUTOSTART); + } + break; + + case 1: + // SET MIDPOINT + lcd_putsCenter(MENU_CONTENT_TOP+FH, STR_SETMIDPOINT, INVERS); + lcd_putsCenter(MENU_CONTENT_TOP+2*FH, STR_MENUWHENDONE); + + for (int i=0; i 50) { + g_eeGeneral.calib[i].mid = reusableBuffer.calib.midVals[i]; + int16_t v = reusableBuffer.calib.midVals[i] - reusableBuffer.calib.loVals[i]; + g_eeGeneral.calib[i].spanNeg = v - v/STICK_TOLERANCE; + v = reusableBuffer.calib.hiVals[i] - reusableBuffer.calib.midVals[i]; + g_eeGeneral.calib[i].spanPos = v - v/STICK_TOLERANCE; + } + } + break; + + case 3: +#if 0 + for (int i=POT1; i<=POT_LAST; i++) { + int idx = i - POT1; + int count = reusableBuffer.calib.xpotsCalib[idx].stepsCount; + if (IS_POT_MULTIPOS(i)) { + if (count > 1 && count <= XPOTS_MULTIPOS_COUNT) { + for (int j=0; jcount = count - 1; + for (int j=0; jcount; j++) { + calib->steps[j] = (reusableBuffer.calib.xpotsCalib[idx].steps[j+1] + reusableBuffer.calib.xpotsCalib[idx].steps[j]) >> 5; + } + } + else { + g_eeGeneral.potsType &= ~(0x03<<(2*idx)); + } + } + } +#endif + g_eeGeneral.chkSum = evalChkSum(); + storageDirty(EE_GENERAL); + reusableBuffer.calib.state = 4; + break; + + default: + reusableBuffer.calib.state = 0; + break; + } + + drawSticksPositions(); + drawPotsBars(); + +#if 0 + for (int i=POT1; i<=POT_LAST; i++) { + uint8_t steps = 0; + if (reusableBuffer.calib.state == 2) { + steps = reusableBuffer.calib.xpotsCalib[i-POT1].stepsCount; + } + else if (IS_POT_MULTIPOS(i)) { + StepsCalibData * calib = (StepsCalibData *) &g_eeGeneral.calib[i]; + steps = calib->count + 1; + } + if (steps > 0 && steps <= XPOTS_MULTIPOS_COUNT) { + lcdDrawNumber(LCD_W/2-2+(i-POT1)*5, LCD_H-6, steps, TINSIZE); + } + } +#endif + + return true; +} + +bool menuGeneralCalib(evt_t event) +{ + SIMPLE_MENU(STR_MENUCALIBRATION, menuTabGeneral, e_Calib, 0, DEFAULT_SCROLLBAR_X); + + m_posVert = -1; + + if (menuEvent) { + calibrationState = 0; + } + + return menuCommonCalib(READ_ONLY() ? 0 : event); +} + +bool menuFirstCalib(evt_t event) +{ + if (event == EVT_KEY_BREAK(KEY_EXIT) || reusableBuffer.calib.state == 4) { + calibrationState = 0; + chainMenu(menuMainView); + return false; + } + else { + drawScreenTemplate(STR_MENUCALIBRATION); + return menuCommonCalib(event); + } +} diff --git a/radio/src/gui/Horus/menu_general_sdmanager.cpp b/radio/src/gui/Horus/menu_general_sdmanager.cpp new file mode 100644 index 000000000..fb02d63b3 --- /dev/null +++ b/radio/src/gui/Horus/menu_general_sdmanager.cpp @@ -0,0 +1,386 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../../opentx.h" + +#define REFRESH_FILES() do { reusableBuffer.sdmanager.offset = 65535; lastBitmap = -1; } while (0) +#define NODE_TYPE(fname) fname[SD_SCREEN_FILE_LENGTH+1] +#define IS_DIRECTORY(fname) ((bool)(!NODE_TYPE(fname))) +#define IS_FILE(fname) ((bool)(NODE_TYPE(fname))) + +int lastBitmap; + +bool menuGeneralSdManagerInfo(evt_t event) +{ + SIMPLE_SUBMENU(STR_SD_INFO_TITLE, 1, DEFAULT_SCROLLBAR_X); + + lcdDrawText(MENUS_MARGIN_LEFT, 2*FH, STR_SD_TYPE); + lcdDrawText(100, 2*FH, SD_IS_HC() ? STR_SDHC_CARD : STR_SD_CARD); + + lcdDrawText(MENUS_MARGIN_LEFT, 3*FH, STR_SD_SIZE); + lcdDrawNumber(100, 3*FH, sdGetSize(), LEFT, 0, NULL, "M"); + + lcdDrawText(MENUS_MARGIN_LEFT, 4*FH, STR_SD_SECTORS); +#if defined(SD_GET_FREE_BLOCKNR) + lcdDrawNumber(100, 4*FH, SD_GET_FREE_BLOCKNR()/1000, LEFT, 0, NULL, "/"); + lcdDrawNumber(150, 4*FH, sdGetNoSectors()/1000, LEFT); +#else + lcdDrawNumber(100, 4*FH, sdGetNoSectors()/1000, LEFT, 0, NULL, "k"); +#endif + + lcdDrawText(MENUS_MARGIN_LEFT, 5*FH, STR_SD_SPEED); + lcdDrawNumber(100, 5*FH, SD_GET_SPEED()/1000, LEFT, 0, NULL, "kb/s"); + + return true; +} + +inline bool isFilenameGreater(bool isfile, const char * fn, const char * line) +{ + return (isfile && IS_DIRECTORY(line)) || (isfile==IS_FILE(line) && strcasecmp(fn, line) > 0); +} + +inline bool isFilenameLower(bool isfile, const char * fn, const char * line) +{ + return (!isfile && IS_FILE(line)) || (isfile==IS_FILE(line) && strcasecmp(fn, line) < 0); +} + +void getSelectionFullPath(char *lfn) +{ + f_getcwd(lfn, _MAX_LFN); + strcat(lfn, PSTR("/")); + strcat(lfn, reusableBuffer.sdmanager.lines[m_posVert - s_pgOfs]); +} + +void onSdManagerMenu(const char *result) +{ + TCHAR lfn[_MAX_LFN+1]; + + // TODO possible buffer overflows here! + + uint8_t index = m_posVert-s_pgOfs; + char *line = reusableBuffer.sdmanager.lines[index]; + + if (result == STR_SD_INFO) { + pushMenu(menuGeneralSdManagerInfo); + } + else if (result == STR_SD_FORMAT) { + POPUP_CONFIRMATION(STR_CONFIRM_FORMAT); + } + else if (result == STR_COPY_FILE) { + clipboard.type = CLIPBOARD_TYPE_SD_FILE; + f_getcwd(clipboard.data.sd.directory, CLIPBOARD_PATH_LEN); + strncpy(clipboard.data.sd.filename, line, CLIPBOARD_PATH_LEN-1); + } + else if (result == STR_PASTE) { + f_getcwd(lfn, _MAX_LFN); + // if destination is dir, copy into that dir + if (IS_DIRECTORY(line)) { + strcat(lfn, PSTR("/")); + strcat(lfn, line); + } + if (strcmp(clipboard.data.sd.directory, lfn)) { // prevent copying to the same directory + POPUP_WARNING(sdCopyFile(clipboard.data.sd.filename, clipboard.data.sd.directory, clipboard.data.sd.filename, lfn)); + REFRESH_FILES(); + } + } + else if (result == STR_RENAME_FILE) { + memcpy(reusableBuffer.sdmanager.originalName, line, sizeof(reusableBuffer.sdmanager.originalName)); + char * ext = getFileExtension(line, SD_SCREEN_FILE_LENGTH+1); + if (ext) { + // write spaces to allow a longer filename + memset(ext, ' ', SD_SCREEN_FILE_LENGTH-LEN_FILE_EXTENSION-(ext-line)); + line[SD_SCREEN_FILE_LENGTH-LEN_FILE_EXTENSION] = '\0'; + } + else { + int len = strlen(line); + memset(line + strlen(line), ' ', SD_SCREEN_FILE_LENGTH - len); + line[SD_SCREEN_FILE_LENGTH] = '\0'; + } + s_editMode = EDIT_MODIFY_STRING; + editNameCursorPos = 0; + } + else if (result == STR_DELETE_FILE) { + getSelectionFullPath(lfn); + f_unlink(lfn); + REFRESH_FILES(); + } + else if (result == STR_PLAY_FILE) { + getSelectionFullPath(lfn); + audioQueue.stopAll(); + audioQueue.playFile(lfn, 0, ID_PLAY_FROM_SD_MANAGER); + } +#if 0 + else if (result == STR_ASSIGN_BITMAP) { + strAppendFilename(g_model.header.bitmap, line, sizeof(g_model.header.bitmap)); + memcpy(modelHeaders[g_eeGeneral.currModel].bitmap, g_model.header.bitmap, sizeof(g_model.header.bitmap)); + storageDirty(EE_MODEL); + } +#endif + else if (result == STR_VIEW_TEXT) { + getSelectionFullPath(lfn); + pushMenuTextView(lfn); + } +#if 0 + else if (result == STR_FLASH_BOOTLOADER) { + getSelectionFullPath(lfn); + flashBootloader(lfn); + } +#endif +#if defined(LUA) + else if (result == STR_EXECUTE_FILE) { + getSelectionFullPath(lfn); + luaExec(lfn); + } +#endif +} + +bool menuGeneralSdManager(evt_t _event) +{ + if (s_warning_result) { + s_warning_result = 0; + displayPopup(STR_FORMATTING); + closeLogs(); + audioQueue.stopSD(); + if (f_mkfs(0, 1, 0) == FR_OK) { + f_chdir("/"); + REFRESH_FILES(); + } + else { + POPUP_WARNING(STR_SDCARD_ERROR); + } + } + + evt_t event = (EVT_KEY_MASK(_event) == KEY_ENTER ? 0 : _event); + SIMPLE_MENU(SD_IS_HC() ? STR_SDHC_CARD : STR_SD_CARD, menuTabGeneral, e_Sd, reusableBuffer.sdmanager.count, DEFAULT_SCROLLBAR_X); + + int index = m_posVert-s_pgOfs; + + switch(_event) { + case EVT_ENTRY: + f_chdir(ROOT_PATH); + REFRESH_FILES(); + break; + +#if 0 + case EVT_KEY_LONG(KEY_MENU): + if (!READ_ONLY() && s_editMode == 0) { + killEvents(_event); + MENU_ADD_ITEM(STR_SD_INFO); + MENU_ADD_ITEM(STR_SD_FORMAT); + menuHandler = onSdManagerMenu; + } + break; +#endif + + case EVT_KEY_BREAK(KEY_EXIT): + REFRESH_FILES(); + break; + + case EVT_KEY_BREAK(KEY_ENTER): + if (m_posVert < 0) { + if (reusableBuffer.sdmanager.count > 0) { + m_posVert = 0; + } + break; + } + else if (s_editMode > 0) { + break; + } + else { + if (IS_DIRECTORY(reusableBuffer.sdmanager.lines[index])) { + f_chdir(reusableBuffer.sdmanager.lines[index]); + s_pgOfs = 0; + m_posVert = 1; + index = 1; + REFRESH_FILES(); + killEvents(_event); + return true; + } + } + // no break + + case EVT_KEY_LONG(KEY_ENTER): + if (s_editMode == 0) { + killEvents(_event); + char * line = reusableBuffer.sdmanager.lines[index]; + char * ext = getFileExtension(line, SD_SCREEN_FILE_LENGTH+1); + if (!strcmp(line, "..")) { + break; // no menu for parent dir + } + if (ext) { + if (!strcasecmp(ext, SOUNDS_EXT)) { + MENU_ADD_ITEM(STR_PLAY_FILE); + } + else if (!strcasecmp(ext, TEXT_EXT)) { + MENU_ADD_ITEM(STR_VIEW_TEXT); + } +#if defined(LUA) + else if (!strcasecmp(ext, SCRIPTS_EXT)) { + MENU_ADD_ITEM(STR_EXECUTE_FILE); + } +#endif + } + if (!READ_ONLY()) { + if (IS_FILE(line)) + MENU_ADD_ITEM(STR_COPY_FILE); + if (clipboard.type == CLIPBOARD_TYPE_SD_FILE) + MENU_ADD_ITEM(STR_PASTE); + MENU_ADD_ITEM(STR_RENAME_FILE); + if (IS_FILE(line)) + MENU_ADD_ITEM(STR_DELETE_FILE); + } + menuHandler = onSdManagerMenu; + } + break; + } + + if (reusableBuffer.sdmanager.offset != s_pgOfs) { + FILINFO fno; + DIR dir; + char *fn; /* This function is assuming non-Unicode cfg. */ + TCHAR lfn[_MAX_LFN + 1]; + fno.lfname = lfn; + fno.lfsize = sizeof(lfn); + + if (s_pgOfs == 0) { + reusableBuffer.sdmanager.offset = 0; + memset(reusableBuffer.sdmanager.lines, 0, sizeof(reusableBuffer.sdmanager.lines)); + } + else if (s_pgOfs == reusableBuffer.sdmanager.count-NUM_BODY_LINES) { + reusableBuffer.sdmanager.offset = s_pgOfs; + memset(reusableBuffer.sdmanager.lines, 0, sizeof(reusableBuffer.sdmanager.lines)); + } + else if (s_pgOfs > reusableBuffer.sdmanager.offset) { + memmove(reusableBuffer.sdmanager.lines[0], reusableBuffer.sdmanager.lines[1], (NUM_BODY_LINES-1)*sizeof(reusableBuffer.sdmanager.lines[0])); + memset(reusableBuffer.sdmanager.lines[NUM_BODY_LINES-1], 0xff, SD_SCREEN_FILE_LENGTH); + NODE_TYPE(reusableBuffer.sdmanager.lines[NUM_BODY_LINES-1]) = 1; + } + else { + memmove(reusableBuffer.sdmanager.lines[1], reusableBuffer.sdmanager.lines[0], (NUM_BODY_LINES-1)*sizeof(reusableBuffer.sdmanager.lines[0])); + memset(reusableBuffer.sdmanager.lines[0], 0, sizeof(reusableBuffer.sdmanager.lines[0])); + } + + reusableBuffer.sdmanager.count = 0; + + FRESULT res = f_opendir(&dir, "."); /* Open the directory */ + if (res == FR_OK) { + for (;;) { + res = f_readdir(&dir, &fno); /* Read a directory item */ + if (res != FR_OK || fno.fname[0] == 0) break; /* Break on error or end of dir */ + if (fno.fname[0] == '.' && fno.fname[1] == '\0') continue; /* Ignore dot entry */ +#if _USE_LFN + fn = *fno.lfname ? fno.lfname : fno.fname; +#else + fn = fno.fname; +#endif + if (strlen(fn) > SD_SCREEN_FILE_LENGTH) continue; + + reusableBuffer.sdmanager.count++; + + bool isfile = !(fno.fattrib & AM_DIR); + + if (s_pgOfs == 0) { + for (int i=0; i=0; i--) { + char *line = reusableBuffer.sdmanager.lines[i]; + if (line[0] == '\0' || isFilenameGreater(isfile, fn, line)) { + if (i > 0) memmove(reusableBuffer.sdmanager.lines[0], reusableBuffer.sdmanager.lines[1], sizeof(reusableBuffer.sdmanager.lines[0]) * i); + memset(line, 0, sizeof(reusableBuffer.sdmanager.lines[0])); + strcpy(line, fn); + NODE_TYPE(line) = isfile; + break; + } + } + } + else if (s_pgOfs > reusableBuffer.sdmanager.offset) { + if (isFilenameGreater(isfile, fn, reusableBuffer.sdmanager.lines[NUM_BODY_LINES-2]) && isFilenameLower(isfile, fn, reusableBuffer.sdmanager.lines[NUM_BODY_LINES-1])) { + memset(reusableBuffer.sdmanager.lines[NUM_BODY_LINES-1], 0, sizeof(reusableBuffer.sdmanager.lines[0])); + strcpy(reusableBuffer.sdmanager.lines[NUM_BODY_LINES-1], fn); + NODE_TYPE(reusableBuffer.sdmanager.lines[NUM_BODY_LINES-1]) = isfile; + } + } + else { + if (isFilenameLower(isfile, fn, reusableBuffer.sdmanager.lines[1]) && isFilenameGreater(isfile, fn, reusableBuffer.sdmanager.lines[0])) { + memset(reusableBuffer.sdmanager.lines[0], 0, sizeof(reusableBuffer.sdmanager.lines[0])); + strcpy(reusableBuffer.sdmanager.lines[0], fn); + NODE_TYPE(reusableBuffer.sdmanager.lines[0]) = isfile; + } + } + } + } + } + + reusableBuffer.sdmanager.offset = s_pgOfs; + + for (int i=0; i + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../../opentx.h" + +#define RADIO_SETUP_2ND_COLUMN 220 +#define YEAR_SEPARATOR_OFFSET 42 +#define MONTH_OFFSET 55 +#define MONTH_SEPARATOR_OFFSET 79 +#define DAY_OFFSET 91 +#define HOUR_SEPARATOR_OFFSET 26 +#define MINUTE_OFFSET 36 +#define MINUTE_SEPARATOR_OFFSET 63 +#define SECOND_OFFSET 75 + +#define SLIDER_5POS(y, value, event, attr) { \ + int8_t tmp = value; \ + drawSlider(RADIO_SETUP_2ND_COLUMN, y, 2+tmp, 4, attr); \ + value = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, NULL, tmp, -2, +2, attr, event); \ +} + +#if defined(SPLASH) && !defined(FSPLASH) + #define CASE_SPLASH_PARAM(x) x, +#else + #define CASE_SPLASH_PARAM(x) +#endif + +enum menuGeneralSetupItems { + CASE_RTCLOCK(ITEM_SETUP_DATE) + CASE_RTCLOCK(ITEM_SETUP_TIME) + // ITEM_SETUP_BATT_RANGE, + ITEM_SETUP_SOUND_LABEL, + ITEM_SETUP_BEEP_MODE, + ITEM_SETUP_SPEAKER_VOLUME, + ITEM_SETUP_BEEP_VOLUME, + ITEM_SETUP_BEEP_LENGTH, + ITEM_SETUP_SPEAKER_PITCH, + ITEM_SETUP_WAV_VOLUME, + ITEM_SETUP_BACKGROUND_VOLUME, + CASE_VARIO(ITEM_SETUP_VARIO_LABEL) + CASE_VARIO(ITEM_SETUP_VARIO_VOLUME) + CASE_VARIO(ITEM_SETUP_VARIO_PITCH) + CASE_VARIO(ITEM_SETUP_VARIO_RANGE) + CASE_VARIO(ITEM_SETUP_VARIO_REPEAT) + CASE_HAPTIC(ITEM_SETUP_HAPTIC_LABEL) + CASE_HAPTIC(ITEM_SETUP_HAPTIC_MODE) + CASE_HAPTIC(ITEM_SETUP_HAPTIC_LENGTH) + CASE_HAPTIC(ITEM_SETUP_HAPTIC_STRENGTH) + // ITEM_SETUP_CONTRAST, + ITEM_SETUP_ALARMS_LABEL, + ITEM_SETUP_BATTERY_WARNING, + ITEM_SETUP_INACTIVITY_ALARM, + // ITEM_SETUP_MEMORY_WARNING, + ITEM_SETUP_ALARM_WARNING, + // ITEM_SETUP_BACKLIGHT_LABEL, + // ITEM_SETUP_BACKLIGHT_MODE, + // ITEM_SETUP_BACKLIGHT_DELAY, + // ITEM_SETUP_BRIGHTNESS, + // ITEM_SETUP_FLASH_BEEP, + // CASE_SPLASH_PARAM(ITEM_SETUP_DISABLE_SPLASH) + CASE_GPS(ITEM_SETUP_TIMEZONE) + CASE_GPS(ITEM_SETUP_GPSFORMAT) + CASE_PXX(ITEM_SETUP_COUNTRYCODE) + ITEM_SETUP_LANGUAGE, + ITEM_SETUP_IMPERIAL, + // IF_FAI_CHOICE(ITEM_SETUP_FAI) + // CASE_MAVLINK(ITEM_MAVLINK_BAUD) + ITEM_SETUP_SWITCHES_DELAY, + ITEM_SETUP_RX_CHANNEL_ORD, + ITEM_SETUP_STICK_MODE, + ITEM_SETUP_MAX +}; + +bool menuGeneralSetup(evt_t event) +{ +#if defined(RTCLOCK) + struct gtm t; + gettime(&t); + + if ((m_posVert==ITEM_SETUP_DATE || m_posVert==ITEM_SETUP_TIME) && + (s_editMode>0) && + (event==EVT_KEY_FIRST(KEY_ENTER) || event==EVT_KEY_BREAK(KEY_ENTER) || event==EVT_KEY_LONG(KEY_ENTER) || event==EVT_KEY_FIRST(KEY_EXIT))) { + // set the date and time into RTC chip + rtcSetTime(&t); + } +#endif + +#if defined(FAI_CHOICE) + if (s_warning_result) { + s_warning_result = 0; + g_eeGeneral.fai = true; + storageDirty(EE_GENERAL); + } +#endif + + MENU(STR_MENURADIOSETUP, menuTabGeneral, e_Setup, ITEM_SETUP_MAX, DEFAULT_SCROLLBAR_X, { 2|NAVIGATION_LINE_BY_LINE, 2|NAVIGATION_LINE_BY_LINE, LABEL(SOUND), 0, 0, 0, 0, 0, 0, 0, CASE_VARIO(LABEL(VARIO)) CASE_VARIO(0) CASE_VARIO(0) CASE_VARIO(0) CASE_VARIO(0) CASE_HAPTIC(LABEL(HAPTIC)) CASE_HAPTIC(0) CASE_HAPTIC(0) CASE_HAPTIC(0) LABEL(ALARMS), 0, 0, 0, CASE_GPS(0) CASE_GPS(0) CASE_PXX(0) 0, 0, CASE_MAVLINK(0) 0, 0, 0, 0, 1/*to force edit mode*/ }); + + int sub = m_posVert; + + for (int i=0; i0) ? BLINK|INVERS : INVERS); + LcdFlags attr = (sub == k ? blink : 0); + + switch(k) { + case ITEM_SETUP_DATE: + { + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_DATE); + LcdFlags flags = 0; + if (attr && m_posHorz < 0) { + flags |= INVERS; + lcdDrawSolidFilledRect(RADIO_SETUP_2ND_COLUMN-INVERT_HORZ_MARGIN, y-INVERT_VERT_MARGIN, 85, INVERT_LINE_HEIGHT, TEXT_INVERTED_BGCOLOR); + } + lcdDrawText(RADIO_SETUP_2ND_COLUMN+YEAR_SEPARATOR_OFFSET, y, "-", flags); + lcdDrawText(RADIO_SETUP_2ND_COLUMN+MONTH_SEPARATOR_OFFSET, y, "-", flags); + for (uint8_t j=0; j<3; j++) { + uint8_t rowattr = (m_posHorz==j ? attr : 0); + switch (j) { + case 0: + lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, t.tm_year+1900, LEFT|flags|rowattr); + if (rowattr && s_editMode>0) t.tm_year = checkIncDec(event, t.tm_year, 112, 200, 0); + break; + case 1: + lcdDrawNumber(RADIO_SETUP_2ND_COLUMN+MONTH_OFFSET, y, t.tm_mon+1, LEFT|flags|rowattr|LEADING0, 2); + if (rowattr && s_editMode>0) t.tm_mon = checkIncDec(event, t.tm_mon, 0, 11, 0); + break; + case 2: + { + int16_t year = 1900 + t.tm_year; + int8_t dlim = (((((year%4==0) && (year%100!=0)) || (year%400==0)) && (t.tm_mon==1)) ? 1 : 0); + static const pm_uint8_t dmon[] PROGMEM = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; + dlim += pgm_read_byte(&dmon[t.tm_mon]); + lcdDrawNumber(RADIO_SETUP_2ND_COLUMN+DAY_OFFSET, y, t.tm_mday, LEFT|flags|rowattr|LEADING0, 2); + if (rowattr && s_editMode>0) t.tm_mday = checkIncDec(event, t.tm_mday, 1, dlim, 0); + break; + } + } + } + if (attr && checkIncDec_Ret) { + g_rtcTime = gmktime(&t); // update local timestamp and get wday calculated + } + break; + } + + case ITEM_SETUP_TIME: + { + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_TIME); + LcdFlags flags = 0; + if (attr && m_posHorz < 0) { + flags |= INVERS; + lcdDrawSolidFilledRect(RADIO_SETUP_2ND_COLUMN-INVERT_HORZ_MARGIN, y-INVERT_VERT_MARGIN, 85, INVERT_LINE_HEIGHT, TEXT_INVERTED_BGCOLOR); + } + lcdDrawText(RADIO_SETUP_2ND_COLUMN+HOUR_SEPARATOR_OFFSET, y, ":", flags); + lcdDrawText(RADIO_SETUP_2ND_COLUMN+MINUTE_SEPARATOR_OFFSET, y, ":", flags); + for (uint8_t j=0; j<3; j++) { + uint8_t rowattr = (m_posHorz==j ? attr : 0); + switch (j) { + case 0: + if (rowattr && s_editMode>0) t.tm_hour = checkIncDec(event, t.tm_hour, 0, 23, 0); + lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, t.tm_hour, flags|rowattr|LEFT|LEADING0, 2); + break; + case 1: + if (rowattr && s_editMode>0) t.tm_min = checkIncDec(event, t.tm_min, 0, 59, 0); + lcdDrawNumber(RADIO_SETUP_2ND_COLUMN+MINUTE_OFFSET, y, t.tm_min, flags|rowattr|LEFT|LEADING0, 2); + break; + case 2: + if (rowattr && s_editMode>0) t.tm_sec = checkIncDec(event, t.tm_sec, 0, 59, 0); + lcdDrawNumber(RADIO_SETUP_2ND_COLUMN+SECOND_OFFSET, y, t.tm_sec, flags|rowattr|LEFT|LEADING0, 2); + break; + } + } + if (attr && checkIncDec_Ret) + g_rtcTime = gmktime(&t); // update local timestamp and get wday calculated + break; + } + +#if 0 + case ITEM_SETUP_BATT_RANGE: + { + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_BATTERY_RANGE); + LcdFlags color = WHITE; + if (attr && m_posHorz < 0) { + color = BLACK; + lcdDrawSolidFilledRect(RADIO_SETUP_2ND_COLUMN-INVERT_HORZ_MARGIN, y-INVERT_VERT_MARGIN, 90, INVERT_LINE_HEIGHT, TEXT_INVERTED_BGCOLOR); + } + putsVolts(RADIO_SETUP_2ND_COLUMN, y, 90+g_eeGeneral.vBatMin, color|(m_posHorz==0 ? attr : 0)|LEFT|NO_UNIT); + lcdDrawText(RADIO_SETUP_2ND_COLUMN+20, y, "-"); + putsVolts(RADIO_SETUP_2ND_COLUMN+28, y, 120+g_eeGeneral.vBatMax, color|(m_posHorz>0 ? attr : 0)|LEFT|NO_UNIT); + if (attr && s_editMode>0) { + if (m_posHorz==0) + CHECK_INCDEC_GENVAR(event, g_eeGeneral.vBatMin, -50, g_eeGeneral.vBatMax+29); // min=4.0V + else + CHECK_INCDEC_GENVAR(event, g_eeGeneral.vBatMax, g_eeGeneral.vBatMin-29, +40); // max=16.0V + } + break; + } +#endif + + case ITEM_SETUP_SOUND_LABEL: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_SOUND_LABEL); + break; + + case ITEM_SETUP_BEEP_MODE: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_SPEAKER); + g_eeGeneral.beepMode = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, STR_VBEEPMODE, g_eeGeneral.beepMode, -2, 1, attr, event); +#if defined(FRSKY) + if (attr && checkIncDec_Ret) frskySendAlarms(); +#endif + break; + + case ITEM_SETUP_SPEAKER_VOLUME: + { + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_SPEAKER_VOLUME); + uint8_t b = g_eeGeneral.speakerVolume+VOLUME_LEVEL_DEF; + drawSlider(RADIO_SETUP_2ND_COLUMN, y, b, VOLUME_LEVEL_MAX, attr); + if (attr) { + CHECK_INCDEC_GENVAR(event, b, 0, VOLUME_LEVEL_MAX); + if (checkIncDec_Ret) { + g_eeGeneral.speakerVolume = (int8_t)b-VOLUME_LEVEL_DEF; + } + } + break; + } + + case ITEM_SETUP_BEEP_VOLUME: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_BEEP_VOLUME); + SLIDER_5POS(y, g_eeGeneral.beepVolume, event, attr); + break; + case ITEM_SETUP_WAV_VOLUME: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_WAV_VOLUME); + SLIDER_5POS(y, g_eeGeneral.wavVolume, event, attr); + break; + case ITEM_SETUP_BACKGROUND_VOLUME: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_BG_VOLUME); + SLIDER_5POS(y, g_eeGeneral.backgroundVolume, event, attr); + break; + + case ITEM_SETUP_BEEP_LENGTH: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_BEEP_LENGTH); + SLIDER_5POS(y, g_eeGeneral.beepLength, event, attr); + break; + + case ITEM_SETUP_SPEAKER_PITCH: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_SPKRPITCH); + lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.speakerPitch*15, attr|LEFT, 0, "+", "Hz"); + if (attr) { + CHECK_INCDEC_GENVAR(event, g_eeGeneral.speakerPitch, 0, 20); + } + break; + +#if defined(VARIO) + case ITEM_SETUP_VARIO_LABEL: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_VARIO); + break; + case ITEM_SETUP_VARIO_VOLUME: + lcdDrawText(MENUS_MARGIN_LEFT, y, TR_SPEAKER_VOLUME); + SLIDER_5POS(y, g_eeGeneral.varioVolume, event, attr); + break; + case ITEM_SETUP_VARIO_PITCH: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_PITCH_AT_ZERO); + lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, VARIO_FREQUENCY_ZERO+(g_eeGeneral.varioPitch*10), attr|LEFT, 0, NULL, "Hz"); + if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.varioPitch, -40, 40); + break; + case ITEM_SETUP_VARIO_RANGE: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_PITCH_AT_MAX); + lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, VARIO_FREQUENCY_ZERO+(g_eeGeneral.varioPitch*10)+VARIO_FREQUENCY_RANGE+(g_eeGeneral.varioRange*10), attr|LEFT, 0, NULL, "Hz"); + if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.varioRange, -80, 80); + break; + case ITEM_SETUP_VARIO_REPEAT: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_REPEAT_AT_ZERO); + lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, VARIO_REPEAT_ZERO+(g_eeGeneral.varioRepeat*10), attr|LEFT, 0, NULL, STR_MS); + if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.varioRepeat, -30, 50); + break; +#endif + +#if defined(HAPTIC) + case ITEM_SETUP_HAPTIC_LABEL: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_HAPTIC_LABEL); + break; + + case ITEM_SETUP_HAPTIC_MODE: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_MODE); + g_eeGeneral.hapticMode = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, STR_VBEEPMODE, g_eeGeneral.hapticMode, -2, 1, attr, event); + break; + + case ITEM_SETUP_HAPTIC_LENGTH: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_LENGTH); + SLIDER_5POS(y, g_eeGeneral.hapticLength, event, attr); + break; + + case ITEM_SETUP_HAPTIC_STRENGTH: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_HAPTICSTRENGTH); + SLIDER_5POS(y, g_eeGeneral.hapticStrength, event, attr); + break; +#endif + +#if 0 + case ITEM_SETUP_CONTRAST: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_CONTRAST); + lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.contrast, attr|LEFT); + if (attr) { + CHECK_INCDEC_GENVAR(event, g_eeGeneral.contrast, CONTRAST_MIN, CONTRAST_MAX); + lcdSetContrast(); + } + break; +#endif + + case ITEM_SETUP_ALARMS_LABEL: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_ALARMS_LABEL); + break; + + case ITEM_SETUP_BATTERY_WARNING: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_BATTERYWARNING); + putsVolts(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.vBatWarn, attr|LEFT); + if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.vBatWarn, 27, 42); // 2.7-4.2V + break; + +#if 0 + case ITEM_SETUP_MEMORY_WARNING: + { + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_MEMORYWARNING); + uint8_t b = 1-g_eeGeneral.disableMemoryWarning; + g_eeGeneral.disableMemoryWarning = 1 - onoffMenuItem(b, RADIO_SETUP_2ND_COLUMN, y, attr, event); + break; + } +#endif + + case ITEM_SETUP_ALARM_WARNING: + { + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_ALARMWARNING); + uint8_t b = 1-g_eeGeneral.disableAlarmWarning; + g_eeGeneral.disableAlarmWarning = 1 - onoffMenuItem(b, RADIO_SETUP_2ND_COLUMN, y, attr, event); + break; + } + +#if defined(PCBSKY9X) + case ITEM_SETUP_CAPACITY_WARNING: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_CAPAWARNING); + putsValueWithUnit(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.mAhWarn*50, UNIT_MAH, attr|LEFT) ; + if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.mAhWarn, 0, 100); + break; +#endif + +#if defined(PCBSKY9X) + case ITEM_SETUP_TEMPERATURE_WARNING: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_TEMPWARNING); + putsValueWithUnit(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.temperatureWarn, UNIT_TEMPERATURE, attr|LEFT) ; + if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.temperatureWarn, 0, 120); // 0 means no alarm + break; +#endif + + case ITEM_SETUP_INACTIVITY_ALARM: + lcdDrawText(MENUS_MARGIN_LEFT, y,STR_INACTIVITYALARM); + lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.inactivityTimer, attr|LEFT, 0, NULL, "m"); + if (attr) g_eeGeneral.inactivityTimer = checkIncDec(event, g_eeGeneral.inactivityTimer, 0, 250, EE_GENERAL); //0..250minutes + break; + +#if 0 + case ITEM_SETUP_BACKLIGHT_LABEL: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_BACKLIGHT_LABEL); + break; + + case ITEM_SETUP_BACKLIGHT_MODE: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_MODE); + g_eeGeneral.backlightMode = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, STR_VBLMODE, g_eeGeneral.backlightMode, e_backlight_mode_off, e_backlight_mode_on, attr, event); + break; + + case ITEM_SETUP_FLASH_BEEP: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_ALARM); + g_eeGeneral.alarmsFlash = onoffMenuItem(g_eeGeneral.alarmsFlash, RADIO_SETUP_2ND_COLUMN, y, attr, event ) ; + break; + + case ITEM_SETUP_BACKLIGHT_DELAY: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_BLDELAY); + lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.lightAutoOff*5, attr|LEFT, 0, NULL, "s"); + if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.lightAutoOff, 0, 600/5); + break; + + case ITEM_SETUP_BRIGHTNESS: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_BRIGHTNESS); + lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, 100-g_eeGeneral.backlightBright, attr|LEFT) ; + if (attr) { + uint8_t b = 100 - g_eeGeneral.backlightBright; + CHECK_INCDEC_GENVAR(event, b, 0, 100); + g_eeGeneral.backlightBright = 100 - b; + } + break; + + case ITEM_SETUP_BACKLIGHT_COLOR: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_BLCOLOR); + drawSlider(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.backlightColor, 20, attr); + if (attr) g_eeGeneral.backlightColor = checkIncDec(event, g_eeGeneral.backlightColor, 0, 20, EE_GENERAL | NO_INCDEC_MARKS); + break; +#endif + +#if 0 + case ITEM_SETUP_DISABLE_SPLASH: + { + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_SPLASHSCREEN); + if (SPLASH_NEEDED()) { + lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, SPLASH_TIMEOUT/100, attr|LEFT, 0, NULL, "s"); + } + else { + lcdDrawTextAtIndex(RADIO_SETUP_2ND_COLUMN, y, STR_MMMINV, 0, attr); // TODO define + } + if (attr) g_eeGeneral.splashMode = -checkIncDecGen(event, -g_eeGeneral.splashMode, -3, 4); + break; + } +#endif + + case ITEM_SETUP_TIMEZONE: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_TIMEZONE); + lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.timezone, attr|LEFT); + if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.timezone, -12, 12); + break; + + case ITEM_SETUP_GPSFORMAT: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_GPSCOORD); + g_eeGeneral.gpsFormat = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, STR_GPSFORMAT, g_eeGeneral.gpsFormat, 0, 1, attr, event); + break; + + case ITEM_SETUP_COUNTRYCODE: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_COUNTRYCODE); + g_eeGeneral.countryCode = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, STR_COUNTRYCODES, g_eeGeneral.countryCode, 0, 2, attr, event); + break; + + case ITEM_SETUP_LANGUAGE: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_VOICELANG); + lcdDrawText(RADIO_SETUP_2ND_COLUMN, y, currentLanguagePack->name, attr); + if (attr) { + currentLanguagePackIdx = checkIncDec(event, currentLanguagePackIdx, 0, DIM(languagePacks)-2, EE_GENERAL); + if (checkIncDec_Ret) { + currentLanguagePack = languagePacks[currentLanguagePackIdx]; + strncpy(g_eeGeneral.ttsLanguage, currentLanguagePack->id, 2); + } + } + break; + + case ITEM_SETUP_IMPERIAL: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_UNITSSYSTEM); + g_eeGeneral.imperial = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, STR_VUNITSSYSTEM, g_eeGeneral.imperial, 0, 1, attr, event); + break; + +#if 0 + case ITEM_SETUP_FAI: + lcdDrawText(MENUS_MARGIN_LEFT, y, PSTR("FAI Mode")); + onoffMenuItem(g_eeGeneral.fai, RADIO_SETUP_2ND_COLUMN, y, attr, event); + if (attr && checkIncDec_Ret) { + if (g_eeGeneral.fai) + POPUP_WARNING(PSTR("FAI\001mode blocked!")); + else + POPUP_CONFIRMATION(PSTR("FAI mode?")); + } + break; +#endif + +#if defined(MAVLINK) + case ITEM_MAVLINK_BAUD: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_MAVLINK_BAUD_LABEL); + g_eeGeneral.mavbaud = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, STR_MAVLINK_BAUDS, g_eeGeneral.mavbaud, 0, 7, attr, event); + break; +#endif + + case ITEM_SETUP_SWITCHES_DELAY: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_SWITCHES_DELAY); + lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, 10*SWITCHES_DELAY(), attr|LEFT, 0, NULL, STR_MS); + if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.switchesDelay, -15, +15); + break; + + case ITEM_SETUP_RX_CHANNEL_ORD: + { + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_RXCHANNELORD); // RAET->AETR + char s[5]; + for (uint8_t i=0; i<4; i++) { + s[i] = STR_RETA123[channel_order(i+1)]; + } + s[4] = '\0'; + lcdDrawText(RADIO_SETUP_2ND_COLUMN, y, s, attr); + if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.templateSetup, 0, 23); + break; + } + + case ITEM_SETUP_STICK_MODE: + { + lcdDrawText(MENUS_MARGIN_LEFT, y, NO_INDENT(STR_MODE)); + char s[2] = " "; + s[0] = '1'+g_eeGeneral.stickMode; + lcdDrawText(RADIO_SETUP_2ND_COLUMN, y, s, attr); + for (uint8_t i=0; i<4; i++) { + putsMixerSource(RADIO_SETUP_2ND_COLUMN + 40 + 50*i, y, MIXSRC_Rud + pgm_read_byte(modn12x3 + 4*g_eeGeneral.stickMode + i)); + } + if (attr && s_editMode>0) { + CHECK_INCDEC_GENVAR(event, g_eeGeneral.stickMode, 0, 3); + } + else if (stickMode != g_eeGeneral.stickMode) { + pausePulses(); + stickMode = g_eeGeneral.stickMode; + checkTHR(); + resumePulses(); + clearKeyEvents(); + } + break; + } + } + } + + return true; +} diff --git a/radio/src/gui/Horus/menu_general_trainer.cpp b/radio/src/gui/Horus/menu_general_trainer.cpp new file mode 100644 index 000000000..847f55276 --- /dev/null +++ b/radio/src/gui/Horus/menu_general_trainer.cpp @@ -0,0 +1,124 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../../opentx.h" + +#define TRAINER_COLUMN_WIDTH 60 +#define TRAINER_COLUMN_1 MENUS_MARGIN_LEFT+80 +#define TRAINER_COLUMN_2 TRAINER_COLUMN_1+TRAINER_COLUMN_WIDTH +#define TRAINER_COLUMN_3 TRAINER_COLUMN_2+TRAINER_COLUMN_WIDTH + +#define TRAINER_CALIB_POS 12 + +bool menuGeneralTrainer(evt_t event) +{ + uint8_t y; + bool slave = SLAVE_MODE(); + + MENU(STR_MENUTRAINER, menuTabGeneral, e_Trainer, (slave ? 0 : 6), DEFAULT_SCROLLBAR_X, { 2, 2, 2, 2, 0/*, 0*/ }); + + if (slave) { + lcd_putsCenter(5*FH, STR_SLAVE, TEXT_COLOR); + return true; + } + + uint8_t attr; + uint8_t blink = ((s_editMode>0) ? BLINK|INVERS : INVERS); + + /* lcdDrawText(TRAINER_COLUMN_1, MENU_HEADER_HEIGHT+1, "Mode", HEADER_COLOR); + lcdDrawText(TRAINER_COLUMN_2, MENU_HEADER_HEIGHT+1, "Weight", HEADER_COLOR); + lcdDrawText(TRAINER_COLUMN_3, MENU_HEADER_HEIGHT+1, "Source", HEADER_COLOR); + */ + + y = MENU_CONTENT_TOP + FH; + int sub = m_posVert + 1; + + for (int i=1; i<=NUM_STICKS; i++) { + uint8_t chan = channel_order(i); + volatile TrainerMix *td = &g_eeGeneral.trainer.mix[chan-1]; + + putsMixerSource(MENUS_MARGIN_LEFT, y, MIXSRC_Rud-1+chan, ((sub==i && CURSOR_ON_LINE()) ? INVERS : 0)); + + for (int j=0; j<3; j++) { + + attr = ((sub==i && m_posHorz==j) ? blink : 0); + + switch(j) { + case 0: + lcdDrawTextAtIndex(TRAINER_COLUMN_1, y, STR_TRNMODE, td->mode, attr); + if (attr&BLINK) CHECK_INCDEC_GENVAR(event, td->mode, 0, 2); + break; + + case 1: + lcdDrawNumber(TRAINER_COLUMN_2, y, td->studWeight, LEFT|attr, 0, NULL, "%"); + if (attr&BLINK) CHECK_INCDEC_GENVAR(event, td->studWeight, -125, 125); + break; + + case 2: + lcdDrawTextAtIndex(TRAINER_COLUMN_3, y, STR_TRNCHN, td->srcChn, attr); + if (attr&BLINK) CHECK_INCDEC_GENVAR(event, td->srcChn, 0, 3); + break; + } + } + y += FH; + } + + attr = (sub==5) ? blink : 0; + lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + 5*FH, STR_MULTIPLIER); + lcdDrawNumber(TRAINER_COLUMN_1, MENU_CONTENT_TOP + 5*FH, g_eeGeneral.PPM_Multiplier+10, LEFT|attr|PREC1); + if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.PPM_Multiplier, -10, 40); + + attr = (sub==6) ? INVERS : 0; + if (attr) s_editMode = 0; + lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + 6*FH, STR_CAL, attr); + for (int i=0; i<4; i++) { +#if defined (PPM_UNIT_PERCENT_PREC1) + lcdDrawNumber(TRAINER_COLUMN_1+i*TRAINER_COLUMN_WIDTH, MENU_CONTENT_TOP + 6*FH, (ppmInput[i]-g_eeGeneral.trainer.calib[i])*2, LEFT|PREC1); +#else + lcdDrawNumber(TRAINER_COLUMN_1+i*TRAINER_COLUMN_WIDTH, MENU_CONTENT_TOP + 6*FH, (ppmInput[i]-g_eeGeneral.trainer.calib[i])/5, LEFT); +#endif + } + + if (attr) { + if (event==EVT_KEY_LONG(KEY_ENTER)){ + memcpy(g_eeGeneral.trainer.calib, ppmInput, sizeof(g_eeGeneral.trainer.calib)); + storageDirty(EE_GENERAL); + AUDIO_WARNING1(); + } + } + + return true; +} diff --git a/radio/src/gui/Horus/menu_general_version.cpp b/radio/src/gui/Horus/menu_general_version.cpp new file mode 100644 index 000000000..e7662b2ca --- /dev/null +++ b/radio/src/gui/Horus/menu_general_version.cpp @@ -0,0 +1,55 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../../opentx.h" + +bool menuGeneralVersion(evt_t event) +{ + SIMPLE_MENU(STR_MENUVERSION, menuTabGeneral, e_Vers, 1, DEFAULT_SCROLLBAR_X); + + lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + FH, vers_stamp); + lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + 2*FH, date_stamp); + lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + 3*FH, time_stamp); + lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + 4*FH, eeprom_stamp); + + // TODO EEPROM erase + backup + // lcd_putsCenter(MENU_HEADER_HEIGHT+6*FH, STR_EEBACKUP); + // if (event == EVT_KEY_LONG(KEY_ENTER)) { + // backupEeprom(); + // } + + return true; +} diff --git a/radio/src/gui/Horus/menu_model.cpp b/radio/src/gui/Horus/menu_model.cpp new file mode 100644 index 000000000..898c8c6f1 --- /dev/null +++ b/radio/src/gui/Horus/menu_model.cpp @@ -0,0 +1,202 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../../opentx.h" + +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); + if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, delay, DELAY_MAX); + return delay; +} + +const MenuFuncP 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; + +void editName(coord_t x, coord_t y, char * name, uint8_t size, evt_t event, uint8_t active) +{ + uint8_t flags = 0; + if (active && s_editMode <= 0) { + flags = INVERS; + } + + if (!active || s_editMode <= 0) { + uint8_t len = zlen(name, size); + if (len == 0) { + char tmp[] = "---"; + lcdDrawTextWithLen(x, y, tmp, size, flags); + } + else { + lcdDrawTextWithLen(x, y, name, len, ZCHAR | flags); + } + } + + if (active) { + uint8_t cur = editNameCursorPos; + if (s_editMode > 0) { + int8_t c = name[cur]; + int8_t v = c; + + if (event==EVT_ROTARY_RIGHT || event==EVT_ROTARY_LEFT) { + v = checkIncDec(event, abs(v), 0, ZCHAR_MAX, 0); + if (c <= 0) v = -v; + } + + switch (event) { + case EVT_KEY_BREAK(KEY_LEFT): + if (cur>0) cur--; + break; + + case EVT_KEY_BREAK(KEY_RIGHT): + if (cur=-26 && v<=26) { + v = -v; // toggle case + if (event==EVT_KEY_LONG(KEY_LEFT)) + killEvents(KEY_LEFT); + } + break; + } + + if (c != v) { + name[cur] = v; + storageDirty(g_menuPos[0] == 0 ? EE_MODEL : EE_GENERAL); + } + + lcdDrawTextWithLen(x, y, name, size, ZCHAR | flags); + coord_t w = (editNameCursorPos == 0 ? 0 : getTextWidth(name, editNameCursorPos, ZCHAR)); + char s[] = { idx2char(v), '\0' }; + lcdDrawSolidFilledRect(x+w-1, y-INVERT_VERT_MARGIN, getTextWidth(s, 1)+1, INVERT_LINE_HEIGHT, TEXT_INVERTED_BGCOLOR); + lcdDrawText(x+w, y, s, TEXT_INVERTED_COLOR); + } + else { + cur = 0; + } + editNameCursorPos = cur; + } +} + +static uint8_t s_currIdx; diff --git a/radio/src/gui/Horus/menu_model_curves.cpp b/radio/src/gui/Horus/menu_model_curves.cpp new file mode 100644 index 000000000..333c66df3 --- /dev/null +++ b/radio/src/gui/Horus/menu_model_curves.cpp @@ -0,0 +1,327 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../../opentx.h" + +uint8_t s_curveChan; + +int curveFn(int x) +{ + return applyCustomCurve(x, s_curveChan); +} + +struct point_t { + coord_t x; + coord_t y; +}; + +point_t getPoint(uint8_t i) +{ + point_t result = {0, 0}; + CurveInfo &crv = g_model.curves[s_curveChan]; + int8_t *points = curveAddress(s_curveChan); + bool custom = (crv.type == CURVE_TYPE_CUSTOM); + uint8_t count = 5+crv.points; + if (i < count) { + result.x = CURVE_CENTER_X-1-CURVE_SIDE_WIDTH+i*CURVE_SIDE_WIDTH*2/(count-1); + result.y = CURVE_CENTER_Y - (points[i]) * (CURVE_SIDE_WIDTH-1) / 100; + if (custom && i>0 && i g_model.points + sizeof(g_model.points)) { + AUDIO_WARNING2(); + return false; + } + + int8_t *nextCrv = curveAddress(index+1); + memmove(nextCrv+shift, nextCrv, 5*(MAX_CURVES-index-1)+curveEnd[MAX_CURVES-1]-curveEnd[index]); + if (shift < 0) memclear(&g_model.points[NUM_POINTS-1] + shift, -shift); + while (index0 ? INVERS|BLINK : INVERS) : 0); + lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + 2*FH, "Type"); + lcdDrawTextAtIndex(MENUS_MARGIN_LEFT+INDENT_WIDTH, MENU_CONTENT_TOP + 3*FH, STR_CURVE_TYPES, crv.type, attr); + if (attr) { + uint8_t newType = checkIncDecModelZero(event, crv.type, CURVE_TYPE_LAST); + if (newType != crv.type) { + for (int i=1; i<4+crv.points; i++) + points[i] = calcRESXto100(applyCustomCurve(calc100toRESX(-100 + i*200/(4+crv.points)), s_curveChan)); + moveCurve(s_curveChan, checkIncDec_Ret > 0 ? 3+crv.points : -3-crv.points); + if (newType == CURVE_TYPE_CUSTOM) { + for (int i=0; i<3+crv.points; i++) + points[5+crv.points+i] = -100 + ((i+1)*200) / (4+crv.points); + } + crv.type = newType; + } + } + + attr = (m_posVert==2 ? (s_editMode>0 ? INVERS|BLINK : INVERS) : 0); + lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + 4*FH, STR_COUNT); + lcdDrawNumber(MENUS_MARGIN_LEFT+INDENT_WIDTH, MENU_CONTENT_TOP + 5*FH, 5+crv.points, LEFT|attr, 0, NULL, STR_PTS); + if (attr) { + int count = checkIncDecModel(event, crv.points, -3, 12); // 2pts - 17pts + if (checkIncDec_Ret) { + int newPoints[MAX_POINTS]; + newPoints[0] = points[0]; + newPoints[4+count] = points[4+crv.points]; + for (int i=1; i<4+count; i++) + newPoints[i] = calcRESXto100(applyCustomCurve(calc100toRESX(-100 + (i*200) / (4+count)), s_curveChan)); + moveCurve(s_curveChan, checkIncDec_Ret*(crv.type==CURVE_TYPE_CUSTOM?2:1)); + for (int i=0; i<5+count; i++) { + points[i] = newPoints[i]; + if (crv.type == CURVE_TYPE_CUSTOM && i!=0 && i!=4+count) + points[5+count+i-1] = -100 + (i*200) / (4+count); + } + crv.points = count; + } + } + + lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + 6*FH, STR_SMOOTH); + drawCheckBox(lcdNextPos + 10, MENU_CONTENT_TOP + 6*FH, crv.smooth, m_posVert==3 ? INVERS : 0); + if (m_posVert==3) crv.smooth = checkIncDecModel(event, crv.smooth, 0, 1); + + switch(event) { + case EVT_ENTRY: + pointsOfs = 0; + break; + case EVT_KEY_LONG(KEY_ENTER): + if (m_posVert > 1) { + killEvents(event); + MENU_ADD_ITEM(STR_CURVE_PRESET); + MENU_ADD_ITEM(STR_MIRROR); + MENU_ADD_ITEM(STR_CLEAR); + menuHandler = onCurveOneMenu; + } + break; + case EVT_KEY_LONG(KEY_MENU): + pushMenu(menuChannelsView); + killEvents(event); + } + + if (m_posVert >= 0) { + DrawCurve(6); + } + + // lcdDrawText(115, MENU_FOOTER_TOP, "X", HEADER_COLOR); + // lcdDrawText(145, MENU_FOOTER_TOP, "Y", HEADER_COLOR); + + coord_t posY = MENU_CONTENT_TOP; + attr = (s_editMode > 0 ? INVERS|BLINK : INVERS); + for (int i=0; i<5+crv.points; i++) { + point_t point = getPoint(i); + uint8_t selectionMode = 0; + if (crv.type==CURVE_TYPE_CUSTOM) { + if (m_posVert==4+2*i || (i==5+crv.points-1 && m_posVert==4+5+crv.points+5+crv.points-2-1)) + selectionMode = 2; + else if (i>0 && m_posVert==3+2*i) + selectionMode = 1; + } + else if (m_posVert == 4+i) { + selectionMode = 2; + } + + if (i>=pointsOfs && i0 && i<5+crv.points-1) x = points[5+crv.points+i-1]; + lcdDrawNumber(120, posY, i+1, LEFT|TEXT_DISABLE_COLOR); + lcdDrawNumber(150, posY, x, LEFT|(selectionMode==1 ? attr : 0)); + lcdDrawNumber(200, posY, points[i], LEFT|(selectionMode==2 ? attr : 0)); + posY += FH; + } + + if (selectionMode > 0) { + // do selection square + lcdDrawSolidFilledRect(point.x-7, point.y-2, 5, 5, TEXT_INVERTED_BGCOLOR); + if (s_editMode > 0) { + if (selectionMode == 1) + CHECK_INCDEC_MODELVAR(event, points[5+crv.points+i-1], i==1 ? -100 : points[5+crv.points+i-2], i==5+crv.points-2 ? 100 : points[5+crv.points+i]); // edit X + else if (selectionMode == 2) + CHECK_INCDEC_MODELVAR(event, points[i], -100, 100); + } + if (i < pointsOfs) + pointsOfs = i; + else if (i > pointsOfs+NUM_BODY_LINES-1) + pointsOfs = i-NUM_BODY_LINES+1; + } + } + + drawScrollbar(250, DEFAULT_SCROLLBAR_Y, DEFAULT_SCROLLBAR_H, pointsOfs, 5+crv.points, NUM_BODY_LINES); + + return true; +} + +void editCurveRef(coord_t x, coord_t y, CurveRef & curve, evt_t event, uint8_t attr) +{ + lcdDrawTextAtIndex(x, y, "\004DiffExpoFuncCstm", curve.type, (m_posHorz==0 ? attr : 0)); + if (attr && m_posHorz==0) { + CHECK_INCDEC_MODELVAR_ZERO(event, curve.type, CURVE_REF_CUSTOM); + if (checkIncDec_Ret) curve.value = 0; + } + switch (curve.type) { + case CURVE_REF_DIFF: + case CURVE_REF_EXPO: + curve.value = GVAR_MENU_ITEM(lcdNextPos+10, y, curve.value, -100, 100, m_posHorz==1 ? LEFT|attr : LEFT, 0, event); + break; + case CURVE_REF_FUNC: + lcdDrawTextAtIndex(lcdNextPos+10, y, STR_VCURVEFUNC, curve.value, (m_posHorz==1 ? attr : 0)); + if (attr && m_posHorz==1) CHECK_INCDEC_MODELVAR_ZERO(event, curve.value, CURVE_BASE-1); + break; + case CURVE_REF_CUSTOM: + putsCurve(lcdNextPos+10, y, curve.value, (m_posHorz==1 ? attr : 0)); + if (attr && m_posHorz==1) { + if (event==EVT_KEY_LONG(KEY_ENTER) && curve.value!=0) { + s_curveChan = (curve.value<0 ? -curve.value-1 : curve.value-1); + pushMenu(menuModelCurveOne); + } + else { + CHECK_INCDEC_MODELVAR(event, curve.value, -MAX_CURVES, MAX_CURVES); + } + } + break; + } +} + +bool menuModelCurvesAll(evt_t event) +{ + SIMPLE_MENU(STR_MENUCURVES, menuTabModel, e_CurvesAll, MAX_CURVES, DEFAULT_SCROLLBAR_X); + + int8_t sub = m_posVert; + + switch (event) { + case EVT_KEY_BREAK(KEY_ENTER): + if (!READ_ONLY()) { + s_curveChan = sub; + pushMenu(menuModelCurveOne); + } + break; + } + + for (int i=0; i= 0) { + s_curveChan = sub; + DrawCurve(23); + } + + return true; +} diff --git a/radio/src/gui/Horus/menu_model_custom_functions.cpp b/radio/src/gui/Horus/menu_model_custom_functions.cpp new file mode 100644 index 000000000..109ec5da6 --- /dev/null +++ b/radio/src/gui/Horus/menu_model_custom_functions.cpp @@ -0,0 +1,374 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../../opentx.h" + +#define MODEL_CUSTOM_FUNC_1ST_COLUMN 50 +#define MODEL_CUSTOM_FUNC_2ND_COLUMN 100 +#define MODEL_CUSTOM_FUNC_2ND_COLUMN_EXT 180 +#define MODEL_CUSTOM_FUNC_3RD_COLUMN 300 +#define MODEL_CUSTOM_FUNC_4TH_COLUMN 440 +#define MODEL_CUSTOM_FUNC_4TH_COLUMN_ONOFF 450 + +void onCustomFunctionsFileSelectionMenu(const char *result) +{ + int sub = m_posVert; + CustomFunctionData * cf = &g_model.customFn[sub]; + uint8_t func = CFN_FUNC(cf); + + if (result == STR_UPDATE_LIST) { + char directory[256]; + if (func == FUNC_PLAY_SCRIPT) { + strcpy(directory, SCRIPTS_FUNCS_PATH); + } + else { + strcpy(directory, SOUNDS_PATH); + strncpy(directory+SOUNDS_PATH_LNG_OFS, currentLanguagePack->id, 2); + } + if (!sdListFiles(directory, func==FUNC_PLAY_SCRIPT ? SCRIPTS_EXT : SOUNDS_EXT, sizeof(cf->play.name), NULL)) { + POPUP_WARNING(func==FUNC_PLAY_SCRIPT ? STR_NO_SCRIPTS_ON_SD : STR_NO_SOUNDS_ON_SD); + s_menu_flags = 0; + } + } + else { + // The user choosed a file in the list + memcpy(cf->play.name, result, sizeof(cf->play.name)); + storageDirty(EE_MODEL); + if (func == FUNC_PLAY_SCRIPT) { + LUA_LOAD_MODEL_SCRIPTS(); + } + } +} + +void onCustomFunctionsMenu(const char *result) +{ + int sub = m_posVert; + CustomFunctionData * cfn; + uint8_t eeFlags; + + if (g_menuStack[g_menuStackPtr] == menuModelCustomFunctions) { + cfn = &g_model.customFn[sub]; + eeFlags = EE_MODEL; + } + else { + cfn = &g_eeGeneral.customFn[sub]; + eeFlags = EE_GENERAL; + } + + if (result == STR_COPY) { + clipboard.type = CLIPBOARD_TYPE_CUSTOM_FUNCTION; + clipboard.data.cfn = *cfn; + } + else if (result == STR_PASTE) { + *cfn = clipboard.data.cfn; + storageDirty(eeFlags); + } + else if (result == STR_CLEAR) { + memset(cfn, 0, sizeof(CustomFunctionData)); + storageDirty(eeFlags); + } + else if (result == STR_INSERT) { + memmove(cfn+1, cfn, (NUM_CFN-sub-1)*sizeof(CustomFunctionData)); + memset(cfn, 0, sizeof(CustomFunctionData)); + storageDirty(eeFlags); + } + else if (result == STR_DELETE) { + memmove(cfn, cfn+1, (NUM_CFN-sub-1)*sizeof(CustomFunctionData)); + memset(&g_model.customFn[NUM_CFN-1], 0, sizeof(CustomFunctionData)); + storageDirty(eeFlags); + } +} + +bool menuCustomFunctions(evt_t event, CustomFunctionData * functions, CustomFunctionsContext & functionsContext) +{ + uint32_t sub = m_posVert; + + uint8_t eeFlags = (functions == g_model.customFn) ? EE_MODEL : EE_GENERAL; + + if (m_posHorz<0 && event==EVT_KEY_LONG(KEY_ENTER) && !READ_ONLY()) { + killEvents(event); + CustomFunctionData *cfn = &functions[sub]; + if (!CFN_EMPTY(cfn)) + MENU_ADD_ITEM(STR_COPY); + if (clipboard.type == CLIPBOARD_TYPE_CUSTOM_FUNCTION) + MENU_ADD_ITEM(STR_PASTE); + if (!CFN_EMPTY(cfn) && CFN_EMPTY(&functions[NUM_CFN-1])) + MENU_ADD_ITEM(STR_INSERT); + if (!CFN_EMPTY(cfn)) + MENU_ADD_ITEM(STR_CLEAR); + for (int i=sub+1; i0) ? BLINK|INVERS : INVERS) : 0); + LcdFlags active = (attr && s_editMode>0); + switch (j) { + case 0: + if (active || AUTOSWITCH_ENTER_LONG()) CHECK_INCDEC_SWITCH(event, CFN_SWITCH(cfn), SWSRC_FIRST, SWSRC_LAST, eeFlags, isSwitchAvailableInCustomFunctions); + putsSwitches(MODEL_CUSTOM_FUNC_1ST_COLUMN, y, CFN_SWITCH(cfn), attr | ((functionsContext.activeSwitches & ((MASK_CFN_TYPE)1 << k)) ? BOLD : 0)); + break; + + case 1: + if (CFN_SWITCH(cfn)) { + if (active) { + func = CFN_FUNC(cfn) = checkIncDec(event, CFN_FUNC(cfn), 0, FUNC_MAX-1, eeFlags, isAssignableFunctionAvailable); + if (checkIncDec_Ret) CFN_RESET(cfn); + } + lcdDrawTextAtIndex(MODEL_CUSTOM_FUNC_2ND_COLUMN, y, STR_VFSWFUNC, func, attr); + } + else { + j = 4; // skip other fields + if (sub==k && m_posHorz > 0) { + REPEAT_LAST_CURSOR_MOVE(); + } + } + break; + + case 2: + { + int8_t maxParam = NUM_CHNOUT-1; +#if defined(OVERRIDE_CHANNEL_FUNCTION) + if (func == FUNC_OVERRIDE_CHANNEL) { + putsChn(MODEL_CUSTOM_FUNC_2ND_COLUMN_EXT, y, CFN_CH_INDEX(cfn)+1, attr); + } + else +#endif + if (func == FUNC_TRAINER) { + maxParam = 4; + putsMixerSource(MODEL_CUSTOM_FUNC_2ND_COLUMN_EXT, y, CFN_CH_INDEX(cfn)==0 ? 0 : MIXSRC_Rud+CFN_CH_INDEX(cfn)-1, attr); + } +#if defined(GVARS) + else if (func == FUNC_ADJUST_GVAR) { + maxParam = MAX_GVARS-1; + putsStrIdx(MODEL_CUSTOM_FUNC_2ND_COLUMN_EXT, y, STR_GV, CFN_GVAR_INDEX(cfn)+1, attr); + if (active) CFN_GVAR_INDEX(cfn) = checkIncDec(event, CFN_GVAR_INDEX(cfn), 0, maxParam, eeFlags); + break; + } +#endif + else if (func == FUNC_SET_TIMER) { + maxParam = MAX_TIMERS-1; + putsStrIdx(MODEL_CUSTOM_FUNC_2ND_COLUMN_EXT, y, STR_TIMER, CFN_TIMER_INDEX(cfn)+1, attr); + if (active) CFN_TIMER_INDEX(cfn) = checkIncDec(event, CFN_TIMER_INDEX(cfn), 0, maxParam, eeFlags); + break; + } + else if (attr) { + REPEAT_LAST_CURSOR_MOVE(); + } + if (active) CHECK_INCDEC_MODELVAR_ZERO(event, CFN_CH_INDEX(cfn), maxParam); + break; + } + + case 3: + { + INCDEC_DECLARE_VARS(eeFlags); + int16_t val_displayed = CFN_PARAM(cfn); + int16_t val_min = 0; + int16_t val_max = 255; + if (func == FUNC_RESET) { + val_max = FUNC_RESET_PARAM_LAST; + lcdDrawTextAtIndex(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_VFSWRESET, CFN_PARAM(cfn), attr); + } +#if defined(OVERRIDE_CHANNEL_FUNCTION) + else if (func == FUNC_OVERRIDE_CHANNEL) { + val_min = -LIMIT_EXT_PERCENT; val_max = +LIMIT_EXT_PERCENT; + lcdDrawNumber(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT); + } +#endif +#if defined(DANGEROUS_MODULE_FUNCTIONS) + else if (func >= FUNC_RANGECHECK && func <= FUNC_MODULE_OFF) { + val_max = NUM_MODULES-1; + lcdDrawTextAtIndex(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, "\004Int.Ext.", CFN_PARAM(cfn), attr); + } +#endif + else if (func == FUNC_SET_TIMER) { + val_max = 59*60+59; + putsTimer(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT); + } + else if (func == FUNC_PLAY_SOUND) { + val_max = AU_FRSKY_LAST-AU_FRSKY_FIRST-1; + lcdDrawTextAtIndex(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_FUNCSOUNDS, val_displayed, attr); + } +#if defined(HAPTIC) + else if (func == FUNC_HAPTIC) { + val_max = 3; + lcdDrawNumber(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT); + } +#endif +#if defined(SDCARD) + else if (func == FUNC_PLAY_TRACK || func == FUNC_BACKGND_MUSIC || func == FUNC_PLAY_SCRIPT) { + coord_t x = MODEL_CUSTOM_FUNC_3RD_COLUMN; + if (ZEXIST(cfn->play.name)) + lcdDrawTextWithLen(x, y, cfn->play.name, sizeof(cfn->play.name), attr); + else + lcdDrawTextAtIndex(x, y, STR_VCSWFUNC, 0, attr); + if (active && event==EVT_KEY_BREAK(KEY_ENTER)) { + s_editMode = 0; + char directory[256]; + if (func==FUNC_PLAY_SCRIPT) { + strcpy(directory, SCRIPTS_FUNCS_PATH); + } + else { + strcpy(directory, SOUNDS_PATH); + strncpy(directory+SOUNDS_PATH_LNG_OFS, currentLanguagePack->id, 2); + } + if (sdListFiles(directory, func==FUNC_PLAY_SCRIPT ? SCRIPTS_EXT : SOUNDS_EXT, sizeof(cfn->play.name), cfn->play.name)) { + menuHandler = onCustomFunctionsFileSelectionMenu; + } + else { + POPUP_WARNING(func==FUNC_PLAY_SCRIPT ? STR_NO_SCRIPTS_ON_SD : STR_NO_SOUNDS_ON_SD); + s_menu_flags = 0; + } + } + break; + } + else if (func == FUNC_PLAY_VALUE) { + val_max = MIXSRC_LAST_TELEM; + putsMixerSource(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr); + INCDEC_ENABLE_CHECK(isSourceAvailable); + } +#endif + else if (func == FUNC_VOLUME) { + val_max = MIXSRC_LAST_CH; + putsMixerSource(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr); + INCDEC_SET_FLAG(eeFlags | INCDEC_SOURCE); + INCDEC_ENABLE_CHECK(isSourceAvailable); + } + else if (func == FUNC_LOGS) { + if (val_displayed) { + lcdDrawNumber(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|PREC1|LEFT, 0, NULL, "s"); + } + else { + lcdDrawTextAtIndex(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_MMMINV, 0, attr); + } + } +#if defined(REVPLUS) + else if (func == FUNC_BACKLIGHT) { + drawSlider(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, CFN_PARAM(cfn), 100, attr); + INCDEC_SET_FLAG(eeFlags | NO_INCDEC_MARKS); + val_min = 0; + val_max = 100; + } +#endif +#if defined(GVARS) + else if (func == FUNC_ADJUST_GVAR) { + switch (CFN_GVAR_MODE(cfn)) { + case FUNC_ADJUST_GVAR_CONSTANT: + val_displayed = (int16_t)CFN_PARAM(cfn); + val_min = -CFN_GVAR_CST_MAX; val_max = +CFN_GVAR_CST_MAX; + lcdDrawNumber(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr|LEFT); + break; + case FUNC_ADJUST_GVAR_SOURCE: + val_max = MIXSRC_LAST_CH; + putsMixerSource(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, val_displayed, attr); + INCDEC_SET_FLAG(eeFlags | INCDEC_SOURCE); + INCDEC_ENABLE_CHECK(isSourceAvailable); + break; + case FUNC_ADJUST_GVAR_GVAR: + val_max = MAX_GVARS-1; + putsStrIdx(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_GV, val_displayed+1, attr); + break; + default: // FUNC_ADJUST_GVAR_INC + val_max = 1; + lcdDrawTextAtIndex(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, PSTR("\003-=1+=1"), val_displayed, attr); + break; + } + + if (attr && event==EVT_KEY_LONG(KEY_ENTER)) { + killEvents(event); + s_editMode = !s_editMode; + active = true; + CFN_GVAR_MODE(cfn) += 1; + CFN_GVAR_MODE(cfn) &= 0x03; + val_displayed = 0; + } + } +#endif + else if (attr) { + REPEAT_LAST_CURSOR_MOVE(); + } + + if (active) { + CFN_PARAM(cfn) = CHECK_INCDEC_PARAM(event, val_displayed, val_min, val_max); + } + break; + } + + case 4: + if (HAS_ENABLE_PARAM(func)) { + if (active) CFN_ACTIVE(cfn) = checkIncDec(event, CFN_ACTIVE(cfn), 0, 1, eeFlags); + drawCheckBox(MODEL_CUSTOM_FUNC_4TH_COLUMN_ONOFF, y, CFN_ACTIVE(cfn), attr); + } + else if (HAS_REPEAT_PARAM(func)) { + if (active) CFN_PLAY_REPEAT(cfn) = checkIncDec(event, CFN_PLAY_REPEAT(cfn)==CFN_PLAY_REPEAT_NOSTART?-1:CFN_PLAY_REPEAT(cfn), -1, 60/CFN_PLAY_REPEAT_MUL, eeFlags); + if (CFN_PLAY_REPEAT(cfn) == 0) { + lcdDrawText(MODEL_CUSTOM_FUNC_4TH_COLUMN+2, y, "1x", attr); + } + else if (CFN_PLAY_REPEAT(cfn) == CFN_PLAY_REPEAT_NOSTART) { + lcdDrawText(MODEL_CUSTOM_FUNC_4TH_COLUMN-1, y, "!1x", attr); + } + else { + lcdDrawNumber(MODEL_CUSTOM_FUNC_4TH_COLUMN+12, y, CFN_PLAY_REPEAT(cfn)*CFN_PLAY_REPEAT_MUL, attr, 0, NULL, "s"); + } + } + else if (attr) { + REPEAT_LAST_CURSOR_MOVE(); + } + break; + } + } + } + + return true; +} + +bool menuModelCustomFunctions(evt_t event) +{ + MENU(STR_MENUCUSTOMFUNC, menuTabModel, e_CustomFunctions, NUM_CFN, DEFAULT_SCROLLBAR_X, { NAVIGATION_LINE_BY_LINE|4/*repeated*/ }); + return menuCustomFunctions(event, g_model.customFn, modelFunctionsContext); +} diff --git a/radio/src/gui/Horus/menu_model_flightmodes.cpp b/radio/src/gui/Horus/menu_model_flightmodes.cpp new file mode 100644 index 000000000..a95a4dec6 --- /dev/null +++ b/radio/src/gui/Horus/menu_model_flightmodes.cpp @@ -0,0 +1,161 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../../opentx.h" + +enum FlightModesItems { + ITEM_FLIGHT_MODES_NAME, + ITEM_FLIGHT_MODES_SWITCH, + ITEM_FLIGHT_MODES_TRIM_RUD, + ITEM_FLIGHT_MODES_TRIM_ELE, + ITEM_FLIGHT_MODES_TRIM_THR, + ITEM_FLIGHT_MODES_TRIM_AIL, + ITEM_FLIGHT_MODES_FADE_IN, + ITEM_FLIGHT_MODES_FADE_OUT, + ITEM_FLIGHT_MODES_COUNT, + ITEM_FLIGHT_MODES_LAST = ITEM_FLIGHT_MODES_COUNT-1 +}; + +bool isTrimModeAvailable(int mode) +{ + return (mode < 0 || (mode%2) == 0 || (mode/2) != m_posVert); +} + +#define FLIGHT_MODES_NAME_COLUMN 60 +#define FLIGHT_MODES_SWITCH_COLUMN 200 +#define FLIGHT_MODES_TRIMS_COLUMN 210 +#define FLIGHT_MODES_TRIM_WIDTH 25 +#define FLIGHT_MODES_FADEIN_COLUMN 400 +#define FLIGHT_MODES_FADEOUT_COLUMN 450 + +bool menuModelFlightModesAll(evt_t event) +{ + MENU(STR_MENUFLIGHTPHASES, menuTabModel, e_FlightModesAll, MAX_FLIGHT_MODES+1, DEFAULT_SCROLLBAR_X, { NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, NAVIGATION_LINE_BY_LINE|ITEM_FLIGHT_MODES_LAST, 0}); + + int sub = m_posVert; + + horzpos_t posHorz = m_posHorz; + if (sub==0 && posHorz == 1) { + REPEAT_LAST_CURSOR_MOVE(); + posHorz = m_posHorz; + } + + if (sub=0) { + displayColumnHeader(STR_PHASES_HEADERS, posHorz); + } + + for (int i=0; i0) ? BLINK|INVERS : INVERS) : 0); + LcdFlags active = (attr && s_editMode>0) ; + switch (j) { + case ITEM_FLIGHT_MODES_NAME: + editName(FLIGHT_MODES_NAME_COLUMN, y, p->name, sizeof(p->name), event, attr); + break; + + case ITEM_FLIGHT_MODES_SWITCH: + if (active) CHECK_INCDEC_MODELSWITCH(event, p->swtch, SWSRC_FIRST_IN_MIXES, SWSRC_LAST_IN_MIXES, isSwitchAvailableInMixes); + if (k == 0) + lcdDrawText(FLIGHT_MODES_SWITCH_COLUMN, y, "N/A"); + else + putsSwitches(FLIGHT_MODES_SWITCH_COLUMN, y, p->swtch, attr); + break; + + case ITEM_FLIGHT_MODES_TRIM_RUD: + case ITEM_FLIGHT_MODES_TRIM_ELE: + case ITEM_FLIGHT_MODES_TRIM_THR: + case ITEM_FLIGHT_MODES_TRIM_AIL: + { + uint8_t t = j-ITEM_FLIGHT_MODES_TRIM_RUD; + if (active) { + trim_t & v = p->trim[t]; + v.mode = checkIncDec(event, v.mode==TRIM_MODE_NONE ? -1 : v.mode, -1, k==0 ? 0 : 2*MAX_FLIGHT_MODES-1, EE_MODEL, isTrimModeAvailable); + } + putsTrimMode(FLIGHT_MODES_TRIMS_COLUMN+j*FLIGHT_MODES_TRIM_WIDTH, y, k, t, attr); + break; + } + + case ITEM_FLIGHT_MODES_FADE_IN: + if (active) p->fadeIn = checkIncDec(event, p->fadeIn, 0, DELAY_MAX, EE_MODEL|NO_INCDEC_MARKS); + lcdDrawNumber(FLIGHT_MODES_FADEIN_COLUMN, y, (10/DELAY_STEP)*p->fadeIn, attr|PREC1); + break; + + case ITEM_FLIGHT_MODES_FADE_OUT: + if (active) p->fadeOut = checkIncDec(event, p->fadeOut, 0, DELAY_MAX, EE_MODEL|NO_INCDEC_MARKS); + lcdDrawNumber(FLIGHT_MODES_FADEOUT_COLUMN, y, (10/DELAY_STEP)*p->fadeOut, attr|PREC1); + break; + + } + } + } + + return true; +} diff --git a/radio/src/gui/Horus/menu_model_gvars.cpp b/radio/src/gui/Horus/menu_model_gvars.cpp new file mode 100644 index 000000000..d3e9c9c67 --- /dev/null +++ b/radio/src/gui/Horus/menu_model_gvars.cpp @@ -0,0 +1,125 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../../opentx.h" + +void onGVARSMenu(const char *result) +{ + int8_t sub = m_posVert; + + if (result == STR_ENABLE_POPUP) { + g_model.gvars[sub].popup = true; + storageDirty(EE_MODEL); + } + else if (result == STR_DISABLE_POPUP) { + g_model.gvars[sub].popup = false; + storageDirty(EE_MODEL); + } + else if (result == STR_CLEAR) { + for (int i=0; i0) ? BLINK|INVERS : INVERS) : 0); + coord_t x = GVARS_FM_COLUMN(j-1); + switch(j) + { + case 0: + editName(MENUS_MARGIN_LEFT+50, y, g_model.gvars[i].name, LEN_GVAR_NAME, event, attr); + break; + + default: + { + FlightModeData *fm = &g_model.flightModeData[j-1]; + int16_t & v = fm->gvars[i]; + int16_t vmin, vmax; + if (v > GVAR_MAX) { + uint8_t p = v - GVAR_MAX - 1; + if (p >= j-1) p++; + putsFlightMode(x-21, y, p+1, attr); + vmin = GVAR_MAX+1; vmax = GVAR_MAX+MAX_FLIGHT_MODES-1; + } + else { + if (abs(v) >= 1000) + lcdDrawNumber(x, y+1, v, TINSIZE|attr); + else + lcdDrawNumber(x, y, v, attr); + vmin = -GVAR_MAX; vmax = GVAR_MAX; + } + if (attr) { + if (event == EVT_KEY_LONG(KEY_ENTER)) { + v = (v > GVAR_MAX ? 0 : GVAR_MAX+1); + storageDirty(EE_MODEL); + } + else if (s_editMode>0) { + v = checkIncDec(event, v, vmin, vmax, EE_MODEL); + } + } + break; + } + } + } + } + + if (m_posHorz < 0 && event==EVT_KEY_LONG(KEY_ENTER)) { + killEvents(event); + if (g_model.gvars[sub].popup) + MENU_ADD_ITEM(STR_DISABLE_POPUP); + else + MENU_ADD_ITEM(STR_ENABLE_POPUP); + MENU_ADD_ITEM(STR_CLEAR); + menuHandler = onGVARSMenu; + } + + return true; +} diff --git a/radio/src/gui/Horus/menu_model_heli.cpp b/radio/src/gui/Horus/menu_model_heli.cpp new file mode 100644 index 000000000..d9217de75 --- /dev/null +++ b/radio/src/gui/Horus/menu_model_heli.cpp @@ -0,0 +1,116 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../../opentx.h" + +enum menuModelHeliItems { + ITEM_HELI_SWASHTYPE, + ITEM_HELI_SWASHRING, + ITEM_HELI_ELE, + ITEM_HELI_ELE_WEIGHT, + ITEM_HELI_AIL, + ITEM_HELI_AIL_WEIGHT, + ITEM_HELI_COL, + ITEM_HELI_COL_WEIGHT, + ITEM_HELI_MAX +}; + +#define MODEL_HELI_2ND_COLUMN (230) + +bool menuModelHeli(evt_t event) +{ + SIMPLE_MENU(STR_MENUHELISETUP, menuTabModel, e_Heli, ITEM_HELI_MAX, DEFAULT_SCROLLBAR_X); + + int sub = m_posVert; + + for (unsigned int i=0; i0) ? BLINK|INVERS : INVERS); + LcdFlags attr = (sub == k ? blink : 0); + + switch(k) { + case ITEM_HELI_SWASHTYPE: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_SWASHTYPE); + g_model.swashR.type = selectMenuItem(MODEL_HELI_2ND_COLUMN, y, STR_VSWASHTYPE, g_model.swashR.type, 0, SWASH_TYPE_MAX, attr, event); + break; + + case ITEM_HELI_SWASHRING: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_SWASHRING); + lcdDrawNumber(MODEL_HELI_2ND_COLUMN, y, g_model.swashR.value, LEFT|attr); + if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, g_model.swashR.value, 100); + break; + + case ITEM_HELI_ELE: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_ELEVATOR); + putsMixerSource(MODEL_HELI_2ND_COLUMN, y, g_model.swashR.elevatorSource, attr); + if (attr) CHECK_INCDEC_MODELSOURCE(event, g_model.swashR.elevatorSource, 0, MIXSRC_LAST_CH); + break; + + case ITEM_HELI_ELE_WEIGHT: + lcdDrawText(MENUS_MARGIN_LEFT+INDENT_WIDTH, y, STR_WEIGHT); + lcdDrawNumber(MODEL_HELI_2ND_COLUMN, y, g_model.swashR.elevatorWeight, LEFT|attr); + if (attr) CHECK_INCDEC_MODELVAR(event, g_model.swashR.elevatorWeight, -100, 100); + break; + + case ITEM_HELI_AIL: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_AILERON); + putsMixerSource(MODEL_HELI_2ND_COLUMN, y, g_model.swashR.aileronSource, attr); + if (attr) CHECK_INCDEC_MODELSOURCE(event, g_model.swashR.aileronSource, 0, MIXSRC_LAST_CH); + break; + + case ITEM_HELI_AIL_WEIGHT: + lcdDrawText(MENUS_MARGIN_LEFT+INDENT_WIDTH, y, STR_WEIGHT); + lcdDrawNumber(MODEL_HELI_2ND_COLUMN, y, g_model.swashR.aileronWeight, LEFT|attr); + if (attr) CHECK_INCDEC_MODELVAR(event, g_model.swashR.aileronWeight, -100, 100); + break; + + case ITEM_HELI_COL: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_COLLECTIVE); + putsMixerSource(MODEL_HELI_2ND_COLUMN, y, g_model.swashR.collectiveSource, attr); + if (attr) CHECK_INCDEC_MODELSOURCE(event, g_model.swashR.collectiveSource, 0, MIXSRC_LAST_CH); + break; + + case ITEM_HELI_COL_WEIGHT: + lcdDrawText(MENUS_MARGIN_LEFT+INDENT_WIDTH, y, STR_WEIGHT); + lcdDrawNumber(MODEL_HELI_2ND_COLUMN, y, g_model.swashR.collectiveWeight, LEFT|attr); + if (attr) CHECK_INCDEC_MODELVAR(event, g_model.swashR.collectiveWeight, -100, 100); + break; + + } + } + + return true; +} diff --git a/radio/src/gui/Horus/menu_model_inputs_mixes.cpp b/radio/src/gui/Horus/menu_model_inputs_mixes.cpp new file mode 100644 index 000000000..6fd2210bd --- /dev/null +++ b/radio/src/gui/Horus/menu_model_inputs_mixes.cpp @@ -0,0 +1,1011 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../../opentx.h" + +#define EXPO_ONE_2ND_COLUMN 110 + +#if defined(FLIGHT_MODES) +void displayFlightModes(coord_t x, coord_t y, FlightModesType value, uint8_t attr) +{ + for (int i=0; isrcRaw, x); + return anas[ed->chn]; +} + +int divRound(int num, int den) +{ + if (num < 0) + return (num - den/2) / den; + else + return (num + den/2) / den; +} + +coord_t getYCoord(FnFuncP fn, coord_t x) +{ + return limit(0, CURVE_CENTER_Y - divRound(fn(divRound(x * RESX, CURVE_SIDE_WIDTH)) * CURVE_SIDE_WIDTH, RESX), LCD_H-1); +} + +void DrawFunction(FnFuncP fn, int offset) +{ + int left = CURVE_CENTER_X-offset-CURVE_SIDE_WIDTH; + int right = CURVE_CENTER_X-offset+CURVE_SIDE_WIDTH; + int center = CURVE_CENTER_X-offset; + + // Axis + lcdDrawSolidHorizontalLine(left, CURVE_CENTER_Y, CURVE_SIDE_WIDTH*2+1, CURVE_AXIS_COLOR); + lcdDrawSolidVerticalLine(center, CURVE_CENTER_Y-CURVE_SIDE_WIDTH, CURVE_SIDE_WIDTH*2, CURVE_AXIS_COLOR); + + // Extra lines + lcdDrawVerticalLine(left+CURVE_SIDE_WIDTH/2, CURVE_CENTER_Y-CURVE_SIDE_WIDTH, CURVE_SIDE_WIDTH*2, STASHED, CURVE_AXIS_COLOR); + lcdDrawVerticalLine(right-CURVE_SIDE_WIDTH/2, CURVE_CENTER_Y-CURVE_SIDE_WIDTH, CURVE_SIDE_WIDTH*2, STASHED, CURVE_AXIS_COLOR); + lcdDrawHorizontalLine(left, CURVE_CENTER_Y-CURVE_SIDE_WIDTH/2, CURVE_SIDE_WIDTH*2+1, STASHED, CURVE_AXIS_COLOR); + lcdDrawHorizontalLine(left, CURVE_CENTER_Y+CURVE_SIDE_WIDTH/2, CURVE_SIDE_WIDTH*2+1, STASHED, CURVE_AXIS_COLOR); + + // Outside border + lcdDrawSolidVerticalLine(left, CURVE_CENTER_Y-CURVE_SIDE_WIDTH, CURVE_SIDE_WIDTH*2, TEXT_COLOR); + lcdDrawSolidVerticalLine(right, CURVE_CENTER_Y-CURVE_SIDE_WIDTH, CURVE_SIDE_WIDTH*2, TEXT_COLOR); + lcdDrawSolidHorizontalLine(left, CURVE_CENTER_Y-CURVE_SIDE_WIDTH, CURVE_SIDE_WIDTH*2+1, TEXT_COLOR); + lcdDrawSolidHorizontalLine(left, CURVE_CENTER_Y+CURVE_SIDE_WIDTH, CURVE_SIDE_WIDTH*2+1, TEXT_COLOR); + + // Horizontal / Vertical scale + for (int i=0; i<=20; i++) { + lcdDrawSolidHorizontalLine(left-15, CURVE_CENTER_Y-CURVE_SIDE_WIDTH+i*CURVE_SIDE_WIDTH/10, 10, TEXT_COLOR); + lcdDrawSolidVerticalLine(left+i*CURVE_SIDE_WIDTH/10, CURVE_CENTER_Y+CURVE_SIDE_WIDTH+5, 10, TEXT_COLOR); + } + + coord_t prev_yv = (coord_t)-1; + + for (int xv=-CURVE_SIDE_WIDTH; xv<=CURVE_SIDE_WIDTH; xv+=1) { + coord_t yv = getYCoord(fn, xv); + if (prev_yv != (coord_t)-1) { + if (prev_yv < yv) { + for (int y=prev_yv; y<=yv; y+=1) { + lcdDrawBitmapPattern(CURVE_CENTER_X+xv-offset-2, y-2, LBM_POINT, TEXT_COLOR); + } + } + else { + for (int y=yv; y<=prev_yv; y+=1) { + lcdDrawBitmapPattern(CURVE_CENTER_X+xv-offset-2, y-2, LBM_POINT, TEXT_COLOR); + } + } + } + prev_yv = yv; + } +} + +int getLinesCount(uint8_t expo) +{ + int lastch = -1; + uint8_t count = (expo ? MAX_INPUTS : NUM_CHNOUT); + for (int i=0; i<(expo ? MAX_EXPOS : MAX_MIXERS); i++) { + bool valid = (expo ? EXPO_VALID(expoAddress(i)) : mixAddress(i)->srcRaw); + if (!valid) + break; + int ch = (expo ? expoAddress(i)->chn : mixAddress(i)->destCh); + if (ch == lastch) { + count++; + } + else { + lastch = ch; + } + } + return count; +} + +uint8_t getExpoMixCount(uint8_t expo) +{ + uint8_t count = 0; + uint8_t ch ; + + for(int8_t i=(expo ? MAX_EXPOS-1 : MAX_MIXERS-1); i>=0; i--) { + ch = (expo ? EXPO_VALID(expoAddress(i)) : mixAddress(i)->srcRaw); + if (ch != 0) { + count++; + } + } + return count; +} + +bool reachExpoMixCountLimit(uint8_t expo) +{ + // check mixers count limit + if (getExpoMixCount(expo) >= (expo ? MAX_EXPOS : MAX_MIXERS)) { + POPUP_WARNING(expo ? STR_NOFREEEXPO : STR_NOFREEMIXER); + return true; + } + return false; +} + +void deleteExpoMix(uint8_t expo, uint8_t idx) +{ + pauseMixerCalculations(); + if (expo) { + ExpoData *expo = expoAddress(idx); + int input = expo->chn; + memmove(expo, expo+1, (MAX_EXPOS-(idx+1))*sizeof(ExpoData)); + memclear(&g_model.expoData[MAX_EXPOS-1], sizeof(ExpoData)); + if (!isInputAvailable(input)) { + memclear(&g_model.inputNames[input], LEN_INPUT_NAME); + } + } + else { + MixData *mix = mixAddress(idx); + memmove(mix, mix+1, (MAX_MIXERS-(idx+1))*sizeof(MixData)); + memclear(&g_model.mixData[MAX_MIXERS-1], sizeof(MixData)); + } + resumeMixerCalculations(); + storageDirty(EE_MODEL); +} + +// TODO avoid this global s_currCh on ARM boards ... +int8_t s_currCh; +void insertExpoMix(uint8_t expo, uint8_t idx) +{ + pauseMixerCalculations(); + if (expo) { + ExpoData *expo = expoAddress(idx); + memmove(expo+1, expo, (MAX_EXPOS-(idx+1))*sizeof(ExpoData)); + memclear(expo, sizeof(ExpoData)); + expo->srcRaw = (s_currCh > 4 ? MIXSRC_Rud - 1 + s_currCh : MIXSRC_Rud - 1 + channel_order(s_currCh)); + expo->curve.type = CURVE_REF_EXPO; + expo->mode = 3; // pos&neg + expo->chn = s_currCh - 1; + expo->weight = 100; + } + else { + MixData *mix = mixAddress(idx); + memmove(mix+1, mix, (MAX_MIXERS-(idx+1))*sizeof(MixData)); + memclear(mix, sizeof(MixData)); + mix->destCh = s_currCh-1; + mix->srcRaw = s_currCh; + if (!isSourceAvailable(mix->srcRaw)) { + mix->srcRaw = (s_currCh > 4 ? MIXSRC_Rud - 1 + s_currCh : MIXSRC_Rud - 1 + channel_order(s_currCh)); + while (!isSourceAvailable(mix->srcRaw)) { + mix->srcRaw += 1; + } + } + mix->weight = 100; + } + resumeMixerCalculations(); + storageDirty(EE_MODEL); +} + +void copyExpoMix(uint8_t expo, uint8_t idx) +{ + pauseMixerCalculations(); + if (expo) { + ExpoData *expo = expoAddress(idx); + memmove(expo+1, expo, (MAX_EXPOS-(idx+1))*sizeof(ExpoData)); + } + else { + MixData *mix = mixAddress(idx); + memmove(mix+1, mix, (MAX_MIXERS-(idx+1))*sizeof(MixData)); + } + resumeMixerCalculations(); + storageDirty(EE_MODEL); +} + +void memswap(void *a, void *b, uint8_t size) +{ + uint8_t *x = (uint8_t*)a; + uint8_t *y = (uint8_t*)b; + uint8_t temp ; + + while (size--) { + temp = *x; + *x++ = *y; + *y++ = temp; + } +} + +bool swapExpoMix(uint8_t expo, uint8_t &idx, uint8_t up) +{ + void *x, *y; + uint8_t size; + int8_t tgt_idx = (up ? idx-1 : idx+1); + + if (expo) { + x = (ExpoData *)expoAddress(idx); + + if (tgt_idx < 0) { + if (((ExpoData *)x)->chn == 0) + return false; + ((ExpoData *)x)->chn--; + return true; + } + + if (tgt_idx == MAX_EXPOS) { + if (((ExpoData *)x)->chn == NUM_INPUTS-1) + return false; + ((ExpoData *)x)->chn++; + return true; + } + + y = (ExpoData *)expoAddress(tgt_idx); + if(((ExpoData *)x)->chn != ((ExpoData *)y)->chn || !EXPO_VALID((ExpoData *)y)) { + if (up) { + if (((ExpoData *)x)->chn>0) ((ExpoData *)x)->chn--; + else return false; + } + else { + if (((ExpoData *)x)->chnchn++; + else return false; + } + return true; + } + + size = sizeof(ExpoData); + } + else { + x = (MixData *)mixAddress(idx); + + if (tgt_idx < 0) { + if (((MixData *)x)->destCh == 0) + return false; + ((MixData *)x)->destCh--; + return true; + } + + if (tgt_idx == MAX_MIXERS) { + if (((MixData *)x)->destCh == NUM_CHNOUT-1) + return false; + ((MixData *)x)->destCh++; + return true; + } + + y = (MixData *)mixAddress(tgt_idx); + uint8_t destCh = ((MixData *)x)->destCh; + if(!((MixData *)y)->srcRaw || destCh != ((MixData *)y)->destCh) { + if (up) { + if (destCh>0) ((MixData *)x)->destCh--; + else return false; + } + else { + if (destChdestCh++; + else return false; + } + return true; + } + + size = sizeof(MixData); + } + + pauseMixerCalculations(); + memswap(x, y, size); + resumeMixerCalculations(); + + idx = tgt_idx; + return true; +} + +enum ExposFields { + EXPO_FIELD_INPUT_NAME, + EXPO_FIELD_NAME, + EXPO_FIELD_SOURCE, + EXPO_FIELD_WEIGHT, + EXPO_FIELD_OFFSET, + CASE_CURVES(EXPO_FIELD_CURVE) + CASE_FLIGHT_MODES(EXPO_FIELD_FLIGHT_MODES) + EXPO_FIELD_SWITCH, + EXPO_FIELD_SIDE, + EXPO_FIELD_TRIM, + EXPO_FIELD_MAX +}; + +#define CURVE_ROWS 1 + +bool menuModelExpoOne(evt_t event) +{ + ExpoData *ed = expoAddress(s_currIdx); + + SUBMENU(STR_MENUINPUTS, EXPO_FIELD_MAX, 0, { 0, 0, (ed->srcRaw >= MIXSRC_FIRST_TELEM ? (uint8_t)1 : (uint8_t)0), 0, 0, CASE_CURVES(CURVE_ROWS) CASE_FLIGHT_MODES((MAX_FLIGHT_MODES-1) | NAVIGATION_LINE_BY_LINE) 0 /*, ...*/}); + + int sub = m_posVert; + + coord_t y = MENU_CONTENT_TOP; + + DrawFunction(expoFn); + + { + char textx[5]; + char texty[5]; + int x = getValue(ed->srcRaw); + if (ed->srcRaw >= MIXSRC_FIRST_TELEM) { + sprintf(textx, "%d", calcRESXto100(x)); + // TODO putsTelemetryChannelValue(LCD_W-8, 6*FH, ed->srcRaw - MIXSRC_FIRST_TELEM, x); + if (ed->scale > 0) x = (x * 1024) / convertTelemValue(ed->srcRaw - MIXSRC_FIRST_TELEM + 1, ed->scale); + } + else { + sprintf(textx, "%d", calcRESXto100(x)); + } + + x = limit(-1024, x, 1024); + int y = limit(-1024, expoFn(x), 1024); + sprintf(texty, "%d", calcRESXto100(y)); + + x = divRound(x*CURVE_SIDE_WIDTH, RESX); + y = getYCoord(expoFn, x); + + lcdDrawSolidFilledRect(CURVE_CENTER_X+x, CURVE_CENTER_Y-CURVE_SIDE_WIDTH, 2, 2*CURVE_SIDE_WIDTH+2, CURVE_CURSOR_COLOR); + lcdDrawSolidFilledRect(CURVE_CENTER_X-CURVE_SIDE_WIDTH-2, y-1, 2*CURVE_SIDE_WIDTH+2, 2, CURVE_CURSOR_COLOR); + lcdDrawBitmapPattern(CURVE_CENTER_X+x-4, y-4, LBM_CURVE_POINT, CURVE_CURSOR_COLOR); + lcdDrawBitmapPattern(CURVE_CENTER_X+x-4, y-4, LBM_CURVE_POINT_CENTER, TEXT_BGCOLOR); + + int left = (x < -30 ? CURVE_CENTER_X+x : (x > 30 ? CURVE_CENTER_X+x-34 : CURVE_CENTER_X-17+x/2)); + lcdDrawSolidFilledRect(left, CURVE_CENTER_Y+CURVE_SIDE_WIDTH+2, 36, 17, CURVE_CURSOR_COLOR); + lcdDrawText(left+3+(35-getTextWidth(textx, SMLSIZE))/2, CURVE_CENTER_Y+CURVE_SIDE_WIDTH+3, textx, LEFT|SMLSIZE|TEXT_BGCOLOR); + int top = (y < CURVE_CENTER_Y-8 ? y-1 : (y > CURVE_CENTER_Y+8 ? y-16 : CURVE_CENTER_Y-8+(y-CURVE_CENTER_Y)/2)); + lcdDrawSolidFilledRect(CURVE_CENTER_X-CURVE_SIDE_WIDTH-37, top, 36, 17, CURVE_CURSOR_COLOR); + lcdDrawText(CURVE_CENTER_X-CURVE_SIDE_WIDTH-34+(35-getTextWidth(texty, SMLSIZE))/2, top+1, texty, LEFT|SMLSIZE|TEXT_BGCOLOR); + } + + for (int i=0; i0 ? BLINK|INVERS : INVERS) : 0); + switch (i) { + case EXPO_FIELD_INPUT_NAME: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_INPUTNAME); + editName(EXPO_ONE_2ND_COLUMN, y, g_model.inputNames[ed->chn], sizeof(g_model.inputNames[ed->chn]), event, attr); + break; + + case EXPO_FIELD_NAME: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_EXPONAME); + editName(EXPO_ONE_2ND_COLUMN, y, ed->name, sizeof(ed->name), event, attr); + break; + + case EXPO_FIELD_SOURCE: + lcdDrawText(MENUS_MARGIN_LEFT, y, NO_INDENT(STR_SOURCE)); + putsMixerSource(EXPO_ONE_2ND_COLUMN, y, ed->srcRaw, STREXPANDED|(m_posHorz==0?attr:0)); + if (attr && m_posHorz==0) ed->srcRaw = checkIncDec(event, ed->srcRaw, INPUTSRC_FIRST, INPUTSRC_LAST, EE_MODEL|INCDEC_SOURCE|NO_INCDEC_MARKS, isInputSourceAvailable); + if (ed->srcRaw >= MIXSRC_FIRST_TELEM) { + putsTelemetryChannelValue(EXPO_ONE_2ND_COLUMN+60, y, (ed->srcRaw - MIXSRC_FIRST_TELEM)/3, convertTelemValue(ed->srcRaw - MIXSRC_FIRST_TELEM + 1, ed->scale), LEFT|(m_posHorz==1?attr:0)); + if (attr && m_posHorz == 1) ed->scale = checkIncDec(event, ed->scale, 0, maxTelemValue(ed->srcRaw - MIXSRC_FIRST_TELEM + 1), EE_MODEL); + } + else if (attr) { + m_posHorz = 0; + } + break; + + case EXPO_FIELD_WEIGHT: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_WEIGHT); + ed->weight = GVAR_MENU_ITEM(EXPO_ONE_2ND_COLUMN, y, ed->weight, MIN_EXPO_WEIGHT, 100, LEFT|attr, 0, event); + break; + + case EXPO_FIELD_OFFSET: + lcdDrawText(MENUS_MARGIN_LEFT, y, NO_INDENT(STR_OFFSET)); + ed->offset = GVAR_MENU_ITEM(EXPO_ONE_2ND_COLUMN, y, ed->offset, -100, 100, LEFT|attr, 0, event); + break; + +#if defined(CURVES) + case EXPO_FIELD_CURVE: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_CURVE); + editCurveRef(EXPO_ONE_2ND_COLUMN, y, ed->curve, event, attr); + break; +#endif + +#if defined(FLIGHT_MODES) + case EXPO_FIELD_FLIGHT_MODES: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_FLMODE); + ed->flightModes = editFlightModes(EXPO_ONE_2ND_COLUMN, y, event, ed->flightModes, attr); + break; +#endif + + case EXPO_FIELD_SWITCH: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_SWITCH); + ed->swtch = switchMenuItem(EXPO_ONE_2ND_COLUMN, y, ed->swtch, attr, event); + break; + + case EXPO_FIELD_SIDE: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_SIDE); + ed->mode = 4 - selectMenuItem(EXPO_ONE_2ND_COLUMN, y, STR_VSIDE, 4-ed->mode, 1, 3, attr, event); + break; + + case EXPO_FIELD_TRIM: + uint8_t not_stick = (ed->srcRaw > MIXSRC_Ail); + int8_t carryTrim = -ed->carryTrim; + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_TRIM); + lcdDrawTextAtIndex(EXPO_ONE_2ND_COLUMN, y, STR_VMIXTRIMS, (not_stick && carryTrim == 0) ? 0 : carryTrim+1, m_posHorz==0 ? attr : 0); + if (attr) ed->carryTrim = -checkIncDecModel(event, carryTrim, not_stick ? TRIM_ON : -TRIM_OFF, -TRIM_AIL); + break; + } + y += FH; + } + + return true; +} + +enum MixFields { + MIX_FIELD_NAME, + MIX_FIELD_SOURCE, + MIX_FIELD_WEIGHT, + MIX_FIELD_OFFSET, + MIX_FIELD_TRIM, + CASE_CURVES(MIX_FIELD_CURVE) + CASE_FLIGHT_MODES(MIX_FIELD_FLIGHT_PHASE) + MIX_FIELD_SWITCH, + // MIX_FIELD_WARNING, + MIX_FIELD_MLTPX, + MIX_FIELD_DELAY_UP, + MIX_FIELD_DELAY_DOWN, + MIX_FIELD_SLOW_UP, + MIX_FIELD_SLOW_DOWN, + MIX_FIELD_COUNT +}; + +void gvarWeightItem(coord_t x, coord_t y, MixData *md, uint8_t attr, evt_t event) +{ + u_int8int16_t weight; + MD_WEIGHT_TO_UNION(md, weight); + weight.word = GVAR_MENU_ITEM(x, y, weight.word, GV_RANGELARGE_WEIGHT_NEG, GV_RANGELARGE_WEIGHT, attr, 0, event); + MD_UNION_TO_WEIGHT(weight, md); +} + +#if 0 +#define GAUGE_WIDTH 33 +#define GAUGE_HEIGHT 6 +void drawOffsetBar(uint8_t x, uint8_t y, MixData * md) +{ + int offset = GET_GVAR(MD_OFFSET(md), GV_RANGELARGE_NEG, GV_RANGELARGE, mixerCurrentFlightMode); + int weight = abs(GET_GVAR(MD_WEIGHT(md), GV_RANGELARGE_NEG, GV_RANGELARGE, mixerCurrentFlightMode)); + int barMin = offset - weight; + int barMax = offset + weight; + if (y > 15) { + lcdDrawNumber(x-((barMin >= 0) ? 2 : 3), y-6, barMin, TINSIZE|LEFT); + lcdDrawNumber(x+GAUGE_WIDTH+1, y-6, barMax, TINSIZE); + } + if (barMin < -101) + barMin = -101; + if (barMax > 101) + barMax = 101; + lcdDrawHorizontalLine(x-2, y, GAUGE_WIDTH+2, DOTTED); + lcdDrawHorizontalLine(x-2, y+GAUGE_HEIGHT, GAUGE_WIDTH+2, DOTTED); + lcdDrawSolidVerticalLine(x-2, y+1, GAUGE_HEIGHT-1); + lcdDrawSolidVerticalLine(x+GAUGE_WIDTH-1, y+1, GAUGE_HEIGHT-1); + if (barMin <= barMax) { + int8_t right = (barMax * GAUGE_WIDTH) / 200; + int8_t left = ((barMin * GAUGE_WIDTH) / 200)-1; + lcdDrawSolidFilledRect(x+GAUGE_WIDTH/2+left, y+2, right-left, GAUGE_HEIGHT-3); + } + lcdDrawSolidVerticalLine(x+GAUGE_WIDTH/2-1, y, GAUGE_HEIGHT+1); + if (barMin == -101) { + for (uint8_t i=0; i<3; ++i) { + lcdDrawPoint(x+i, y+4-i); + lcdDrawPoint(x+3+i, y+4-i); + } + } + if (barMax == 101) { + for (uint8_t i=0; i<3; ++i) { + lcdDrawPoint(x+GAUGE_WIDTH-8+i, y+4-i); + lcdDrawPoint(x+GAUGE_WIDTH-5+i, y+4-i); + } + } +} +#undef GAUGE_WIDTH +#undef GAUGE_HEIGHT +#endif + +bool menuModelMixOne(evt_t event) +{ + MixData *md2 = mixAddress(s_currIdx) ; + + SUBMENU(s_currCh ? STR_INSERTMIX : STR_EDITMIX, MIX_FIELD_COUNT, 0, { 0, 0, 0, 0, 0, CASE_CURVES(1) CASE_FLIGHT_MODES((MAX_FLIGHT_MODES-1) | NAVIGATION_LINE_BY_LINE) 0 /*, ...*/ }); + + putsChn(MENU_TITLE_NEXT_POS, MENU_TITLE_TOP+1, md2->destCh+1, TEXT_COLOR); + + // The separation line between 2 columns + lcdDrawSolidVerticalLine(MENU_COLUMN2_X-20, DEFAULT_SCROLLBAR_Y, DEFAULT_SCROLLBAR_H+5, TEXT_COLOR); + + int8_t sub = m_posVert; + int8_t editMode = s_editMode; + + for (int k=0; k<2*NUM_BODY_LINES; k++) { + coord_t y; + if (k >= NUM_BODY_LINES) { + y = MENU_CONTENT_TOP + (k-NUM_BODY_LINES)*FH + 2; + } + else { + y = MENU_CONTENT_TOP + k*FH + 2; + } + int8_t i = k; + + LcdFlags attr = (sub==i ? (editMode>0 ? BLINK|INVERS : INVERS) : 0); + switch(i) { + case MIX_FIELD_NAME: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_MIXNAME); + editName(MIXES_2ND_COLUMN, y, md2->name, sizeof(md2->name), event, attr); + break; + case MIX_FIELD_SOURCE: + lcdDrawText(MENUS_MARGIN_LEFT, y, NO_INDENT(STR_SOURCE)); + putsMixerSource(MIXES_2ND_COLUMN, y, md2->srcRaw, STREXPANDED|attr); + if (attr) CHECK_INCDEC_MODELSOURCE(event, md2->srcRaw, 1, MIXSRC_LAST); + break; + case MIX_FIELD_WEIGHT: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_WEIGHT); + gvarWeightItem(MIXES_2ND_COLUMN, y, md2, attr|LEFT, event); + break; + case MIX_FIELD_OFFSET: + { + lcdDrawText(MENUS_MARGIN_LEFT, y, NO_INDENT(STR_OFFSET)); + u_int8int16_t offset; + MD_OFFSET_TO_UNION(md2, offset); + offset.word = GVAR_MENU_ITEM(MIXES_2ND_COLUMN, y, offset.word, GV_RANGELARGE_OFFSET_NEG, GV_RANGELARGE_OFFSET, attr|LEFT, 0, event); + MD_UNION_TO_OFFSET(offset, md2); +#if 0 + drawOffsetBar(x+MIXES_2ND_COLUMN+22, y, md2); +#endif + break; + } + case MIX_FIELD_TRIM: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_TRIM); + drawCheckBox(MIXES_2ND_COLUMN, y, !md2->carryTrim, attr); + if (attr) md2->carryTrim = !checkIncDecModel(event, !md2->carryTrim, 0, 1); + break; +#if defined(CURVES) + case MIX_FIELD_CURVE: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_CURVE); + editCurveRef(MIXES_2ND_COLUMN, y, md2->curve, event, attr); + break; +#endif +#if defined(FLIGHT_MODES) + case MIX_FIELD_FLIGHT_PHASE: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_FLMODE); + md2->flightModes = editFlightModes(MIXES_2ND_COLUMN, y, event, md2->flightModes, attr); + break; +#endif + case MIX_FIELD_SWITCH: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_SWITCH); + md2->swtch = switchMenuItem(MIXES_2ND_COLUMN, y, md2->swtch, attr, event); + break; + case MIX_FIELD_MLTPX: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_MULTPX); + md2->mltpx = selectMenuItem(MIXES_2ND_COLUMN, y, STR_VMLTPX, md2->mltpx, 0, 2, attr, event); + break; + case MIX_FIELD_DELAY_UP: + lcdDrawText(MENU_COLUMN2_X+MENUS_MARGIN_LEFT, y, STR_DELAYUP); + md2->delayUp = editDelay(MENU_COLUMN2_X, y, event, attr, md2->delayUp); + break; + case MIX_FIELD_DELAY_DOWN: + lcdDrawText(MENU_COLUMN2_X+MENUS_MARGIN_LEFT, y, STR_DELAYDOWN); + md2->delayDown = editDelay(MENU_COLUMN2_X, y, event, attr, md2->delayDown); + break; + case MIX_FIELD_SLOW_UP: + lcdDrawText(MENU_COLUMN2_X+MENUS_MARGIN_LEFT, y, STR_SLOWUP); + md2->speedUp = editDelay(MENU_COLUMN2_X, y, event, attr, md2->speedUp); + break; + case MIX_FIELD_SLOW_DOWN: + lcdDrawText(MENU_COLUMN2_X+MENUS_MARGIN_LEFT, y, STR_SLOWDOWN); + md2->speedDown = editDelay(MENU_COLUMN2_X, y, event, attr, md2->speedDown); + break; + } + } + + return true; +} + +static uint8_t s_copySrcIdx; +static uint8_t s_copySrcCh; + +#define _STR_MAX(x) PSTR("/" #x) +#define STR_MAX(x) _STR_MAX(x) + +#define EXPO_LINE_WEIGHT_POS 92 +#define EXPO_LINE_SRC_POS 115 +#define EXPO_LINE_CURVE_POS 162 +#define EXPO_LINE_SWITCH_POS 210 +#define EXPO_LINE_SIDE_POS 250 +#define EXPO_LINE_FM_POS 270 +#define EXPO_LINE_NAME_POS 380 +#define EXPO_LINE_SELECT_POS 50 +#define EXPO_LINE_SELECT_WIDTH (LCD_W-EXPO_LINE_SELECT_POS-5) + +#define MIX_LINE_WEIGHT_POS 92 +#define MIX_LINE_SRC_POS 115 +#define MIX_LINE_CURVE_POS 162 +#define MIX_LINE_SWITCH_POS 210 +#define MIX_LINE_DELAY_POS 255 +#define MIX_LINE_FM_POS 270 +#define MIX_LINE_NAME_POS 380 +#define MIX_LINE_SELECT_POS 50 +#define MIX_LINE_SELECT_WIDTH (LCD_W-EXPO_LINE_SELECT_POS-5) + +void lineSurround(bool expo, coord_t y, LcdFlags flags=CURVE_AXIS_COLOR) +{ + lcdDrawRect(expo ? EXPO_LINE_SELECT_POS : MIX_LINE_SELECT_POS, y-INVERT_VERT_MARGIN, expo ? EXPO_LINE_SELECT_WIDTH : MIX_LINE_SELECT_WIDTH, INVERT_LINE_HEIGHT, (s_copyMode == COPY_MODE ? SOLID : DOTTED), flags); +} + +void onExpoMixMenu(const char *result) +{ + bool expo = (g_menuStack[g_menuStackPtr] == menuModelExposAll); + uint8_t chn = (expo ? expoAddress(s_currIdx)->chn+1 : mixAddress(s_currIdx)->destCh+1); + + if (result == STR_EDIT) { + pushMenu(expo ? menuModelExpoOne : menuModelMixOne); + } + else if (result == STR_INSERT_BEFORE || result == STR_INSERT_AFTER) { + if (!reachExpoMixCountLimit(expo)) { + s_currCh = chn; + if (result == STR_INSERT_AFTER) { s_currIdx++; m_posVert++; } + insertExpoMix(expo, s_currIdx); + pushMenu(expo ? menuModelExpoOne : menuModelMixOne); + } + } + else if (result == STR_COPY || result == STR_MOVE) { + s_copyMode = (result == STR_COPY ? COPY_MODE : MOVE_MODE); + s_copySrcIdx = s_currIdx; + s_copySrcCh = chn; + s_copySrcRow = m_posVert; + } + else if (result == STR_DELETE) { + deleteExpoMix(expo, s_currIdx); + } +} + +void displayHeaderChannelName(uint8_t ch) +{ + uint8_t len = zlen(g_model.limitData[ch-1].name, sizeof(g_model.limitData[ch-1].name)); + if (len) { + lcdDrawTextWithLen(COLUMN_HEADER_X, MENU_FOOTER_TOP, g_model.limitData[ch-1].name, len, HEADER_COLOR|ZCHAR); + } +} + +void displayMixInfos(coord_t y, MixData *md) +{ + putsCurveRef(MIX_LINE_CURVE_POS, y, md->curve); + + if (md->swtch) { + putsSwitches(MIX_LINE_SWITCH_POS, y, md->swtch); + } +} + +void displayMixLine(coord_t y, MixData *md) +{ + if (md->name[0]) + lcdDrawTextWithLen(EXPO_LINE_NAME_POS, y, md->name, sizeof(md->name), ZCHAR); + displayMixInfos(y, md); + displayFlightModes(MIX_LINE_FM_POS, y, md->flightModes, 0); +} + +void displayExpoInfos(coord_t y, ExpoData *ed) +{ + putsCurveRef(EXPO_LINE_CURVE_POS, y, ed->curve); + if (ed->swtch) { + putsSwitches(EXPO_LINE_SWITCH_POS, y, ed->swtch); + } + if (ed->mode != 3) { + lcdDrawText(EXPO_LINE_SIDE_POS, y, ed->mode == 2 ? "\176" : "\177"); + } +} + +void displayExpoLine(coord_t y, ExpoData *ed) +{ + putsMixerSource(EXPO_LINE_SRC_POS, y, ed->srcRaw); + + displayExpoInfos(y, ed); + displayFlightModes(EXPO_LINE_FM_POS, y, ed->flightModes, 0); + + if (ed->name[0]) { + lcdDrawTextWithLen(EXPO_LINE_NAME_POS, y, ed->name, sizeof(ed->name), ZCHAR); + } +} + +bool menuModelExpoMix(uint8_t expo, evt_t event) +{ + int sub = m_posVert; + + if (s_editMode > 0) + s_editMode = 0; + + uint8_t chn = (expo ? expoAddress(s_currIdx)->chn+1 : mixAddress(s_currIdx)->destCh+1); + + int linesCount = getLinesCount(expo); + SIMPLE_MENU(expo ? STR_MENUINPUTS : STR_MIXER, menuTabModel, expo ? e_InputsAll : e_MixAll, linesCount, DEFAULT_SCROLLBAR_X); + + switch (event) + { + case EVT_ENTRY: + case EVT_ENTRY_UP: + s_copyMode = 0; + s_copyTgtOfs = 0; + break; + case EVT_KEY_LONG(KEY_EXIT): + if (s_copyMode && s_copyTgtOfs == 0) { + deleteExpoMix(expo, s_currIdx); + killEvents(event); + event = 0; + } + // no break + case EVT_KEY_BREAK(KEY_EXIT): + if (s_copyMode) { + if (s_copyTgtOfs) { + // cancel the current copy / move operation + if (s_copyMode == COPY_MODE) { + deleteExpoMix(expo, s_currIdx); + } + else { + do { + swapExpoMix(expo, s_currIdx, s_copyTgtOfs > 0); + s_copyTgtOfs += (s_copyTgtOfs < 0 ? +1 : -1); + } while (s_copyTgtOfs != 0); + storageDirty(EE_MODEL); + } + m_posVert = s_copySrcRow; + s_copyTgtOfs = 0; + } + s_copyMode = 0; + event = 0; + } + break; + case EVT_KEY_BREAK(KEY_ENTER): + if ((!s_currCh || (s_copyMode && !s_copyTgtOfs)) && !READ_ONLY()) { + s_copyMode = (s_copyMode == COPY_MODE ? MOVE_MODE : COPY_MODE); + s_copySrcIdx = s_currIdx; + s_copySrcCh = chn; + s_copySrcRow = sub; + break; + } + // no break + + case EVT_KEY_LONG(KEY_ENTER): + killEvents(event); + if (s_copyTgtOfs) { + s_copyMode = 0; + s_copyTgtOfs = 0; + } + else { + if (READ_ONLY()) { + if (!s_currCh) { + pushMenu(expo ? menuModelExpoOne : menuModelMixOne); + } + } + else { + if (s_copyMode) s_currCh = 0; + if (s_currCh) { + if (reachExpoMixCountLimit(expo)) break; + insertExpoMix(expo, s_currIdx); + pushMenu(expo ? menuModelExpoOne : menuModelMixOne); + s_copyMode = 0; + } + else { + event = 0; + s_copyMode = 0; + MENU_ADD_ITEM(STR_EDIT); + MENU_ADD_ITEM(STR_INSERT_BEFORE); + MENU_ADD_ITEM(STR_INSERT_AFTER); + MENU_ADD_ITEM(STR_COPY); + MENU_ADD_ITEM(STR_MOVE); + MENU_ADD_ITEM(STR_DELETE); + menuHandler = onExpoMixMenu; + } + } + } + break; + case EVT_KEY_LONG(KEY_LEFT): + case EVT_KEY_LONG(KEY_RIGHT): + if (s_copyMode && !s_copyTgtOfs) { + if (reachExpoMixCountLimit(expo)) break; + s_currCh = chn; + if (event == EVT_KEY_LONG(KEY_RIGHT)) { s_currIdx++; m_posVert++; } + insertExpoMix(expo, s_currIdx); + pushMenu(expo ? menuModelExpoOne : menuModelMixOne); + s_copyMode = 0; + killEvents(event); + } + break; + case EVT_KEY_FIRST(KEY_UP): + case EVT_KEY_REPT(KEY_UP): + case EVT_KEY_FIRST(KEY_DOWN): + case EVT_KEY_REPT(KEY_DOWN): + if (s_copyMode) { + uint8_t key = (event & 0x1f); + uint8_t next_ofs = ((event==EVT_ROTARY_LEFT || key==KEY_UP) ? s_copyTgtOfs - 1 : s_copyTgtOfs + 1); + + if (s_copyTgtOfs==0 && s_copyMode==COPY_MODE) { + // insert a mix on the same channel (just above / just below) + if (reachExpoMixCountLimit(expo)) break; + copyExpoMix(expo, s_currIdx); + if (event==EVT_ROTARY_RIGHT || key==KEY_DOWN) s_currIdx++; + else if (sub-s_pgOfs >= 6) s_pgOfs++; + } + else if (next_ofs==0 && s_copyMode==COPY_MODE) { + // delete the mix + deleteExpoMix(expo, s_currIdx); + if (event==EVT_ROTARY_LEFT || key==KEY_UP) s_currIdx--; + } + else { + // only swap the mix with its neighbor + if (!swapExpoMix(expo, s_currIdx, event==EVT_ROTARY_LEFT || key==KEY_UP)) break; + storageDirty(EE_MODEL); + } + + s_copyTgtOfs = next_ofs; + } + break; + } + + char str[6]; + sprintf(str, "%d/%d", getExpoMixCount(expo), expo ? MAX_EXPOS : MAX_MIXERS); + lcdDrawText(MENU_TITLE_NEXT_POS, MENU_TITLE_TOP+2, str, HEADER_COLOR); + + sub = m_posVert; + s_currCh = 0; + int cur = 0; + int i = 0; + + for (int ch=1; ch<=(expo ? NUM_INPUTS : NUM_CHNOUT); ch++) { + void *pointer = NULL; MixData * &md = (MixData * &)pointer; ExpoData * &ed = (ExpoData * &)pointer; + coord_t y = MENU_CONTENT_TOP + (cur-s_pgOfs)*FH; + if (expo ? (ichn+1 == ch && EXPO_VALID(ed)) : (isrcRaw && md->destCh+1 == ch)) { + if (cur-s_pgOfs >= 0 && cur-s_pgOfs < NUM_BODY_LINES) { + if (expo) { + putsMixerSource(MENUS_MARGIN_LEFT, y, ch); + } + else { + putsChn(MENUS_MARGIN_LEFT, y, ch, 0); // show CHx + } + } + uint8_t mixCnt = 0; + do { + if (s_copyMode) { + if (s_copyMode == MOVE_MODE && cur-s_pgOfs >= 0 && cur-s_pgOfs < NUM_BODY_LINES && s_copySrcCh == ch && s_copyTgtOfs != 0 && i == (s_copySrcIdx + (s_copyTgtOfs<0))) { + lineSurround(expo, y); + cur++; y+=FH; + } + if (s_currIdx == i) { + sub = m_posVert = cur; + s_currCh = ch; + } + } + else if (sub == cur) { + s_currIdx = i; + } + if (cur-s_pgOfs >= 0 && cur-s_pgOfs < NUM_BODY_LINES) { + LcdFlags attr = ((s_copyMode || sub != cur) ? 0 : INVERS); + if (expo) { + GVAR_MENU_ITEM(EXPO_LINE_WEIGHT_POS, y, ed->weight, MIN_EXPO_WEIGHT, 100, attr | (isExpoActive(i) ? BOLD : 0), 0, 0); + displayExpoLine(y, ed); + } + else { + if (attr) { + displayHeaderChannelName(ch); + } + + if (mixCnt > 0) lcdDrawTextAtIndex(6, y, STR_VMLTPX2, md->mltpx, 0); + + putsMixerSource(MIX_LINE_SRC_POS, y, md->srcRaw); + + gvarWeightItem(MIX_LINE_WEIGHT_POS, y, md, attr | (isMixActive(i) ? BOLD : 0), event); + + displayMixLine(y, md); + + char cs[] = " "; + if (md->speedDown || md->speedUp) + cs[0] = 'S'; + if (md->delayUp || md->delayDown) + cs[0] = (cs[0] =='S' ? '*' : 'D'); + lcdDrawText(MIX_LINE_DELAY_POS, y, cs); + } + if (s_copyMode) { + if ((s_copyMode==COPY_MODE || s_copyTgtOfs == 0) && s_copySrcCh == ch && i == (s_copySrcIdx + (s_copyTgtOfs<0))) { + /* draw a border around the raw on selection mode (copy/move) */ + lineSurround(expo, y); + } + if (cur == sub) { + /* invert the raw when it's the current one */ + lineSurround(expo, y, ALARM_COLOR); + } + } + } + cur++; y+=FH; mixCnt++; i++; if (expo) ed++; else md++; + } while (expo ? (ichn+1 == ch && EXPO_VALID(ed)) : (isrcRaw && md->destCh+1 == ch)); + if (s_copyMode == MOVE_MODE && cur-s_pgOfs >= 0 && cur-s_pgOfs < NUM_BODY_LINES && s_copySrcCh == ch && i == (s_copySrcIdx + (s_copyTgtOfs<0))) { + lineSurround(expo, y); + cur++; y+=FH; + } + } + else { + uint8_t attr = 0; + if (sub == cur) { + s_currIdx = i; + s_currCh = ch; + if (!s_copyMode) { + attr = INVERS; + } + } + if (cur-s_pgOfs >= 0 && cur-s_pgOfs < NUM_BODY_LINES) { + if (expo) { + putsMixerSource(MENUS_MARGIN_LEFT, y, ch, attr); + } + else { + putsChn(MENUS_MARGIN_LEFT, y, ch, attr); // show CHx + if (attr) { + displayHeaderChannelName(ch); + } + } + if (s_copyMode == MOVE_MODE && s_copySrcCh == ch) { + lineSurround(expo, y); + } + } + cur++; y+=FH; + } + } + + if (sub >= linesCount-1) m_posVert = linesCount-1; + + return true; +} + +bool menuModelExposAll(evt_t event) +{ + return menuModelExpoMix(1, event); +} + +bool menuModelMixAll(evt_t event) +{ + return menuModelExpoMix(0, event); +} diff --git a/radio/src/gui/Horus/menu_model_limits.cpp b/radio/src/gui/Horus/menu_model_limits.cpp new file mode 100644 index 000000000..9bfbd447b --- /dev/null +++ b/radio/src/gui/Horus/menu_model_limits.cpp @@ -0,0 +1,292 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../../opentx.h" + +bool isThrottleOutput(uint8_t ch) +{ + for (uint8_t i=0; idestCh==ch && mix->srcRaw==MIXSRC_Thr) + return true; + } + return false; +} + +enum LimitsItems { + ITEM_LIMITS_CH_NAME, + ITEM_LIMITS_OFFSET, + ITEM_LIMITS_MIN, + ITEM_LIMITS_MAX, + ITEM_LIMITS_DIRECTION, +#if defined(CURVES) + ITEM_LIMITS_CURVE, +#endif +#if defined(PPM_CENTER_ADJUSTABLE) + ITEM_LIMITS_PPM_CENTER, +#endif +#if defined(PPM_LIMITS_SYMETRICAL) + ITEM_LIMITS_SYMETRICAL, +#endif + ITEM_LIMITS_COUNT, + ITEM_LIMITS_MAXROW = ITEM_LIMITS_COUNT-1 +}; + +#if defined(PPM_CENTER_ADJUSTABLE) + #define LIMITS_NAME_POS 52 + #define LIMITS_OFFSET_POS 160 + #define LIMITS_MIN_POS 220 + #define LIMITS_DIRECTION_POS 240 + #define LIMITS_MAX_POS 300 + #define LIMITS_REVERT_POS 320 + #define LIMITS_CURVE_POS 350 + #define LIMITS_PPM_CENTER_POS 440 + #define LIMITS_SYMETRICAL_POS 450 +#else + #define LIMITS_NAME_POS 44 + #define LIMITS_OFFSET_POS 136 + #define LIMITS_MIN_POS 178 + #define LIMITS_DIRECTION_POS 181 + #define LIMITS_MAX_POS 218 + #define LIMITS_REVERT_POS 228 + #define LIMITS_CURVE_POS 258 + #define LIMITS_SYMETRICAL_POS 294 +#endif + +#define LIMITS_MIN_MAX_OFFSET 1000 +#define CONVERT_US_MIN_MAX(x) (((x)*1280)/250) + +#if defined(PPM_UNIT_US) + #define SET_MIN_MAX(x, val) x = ((val)*250)/128 + #define MIN_MAX_DISPLAY(x) CONVERT_US_MIN_MAX(x) +#else + #define MIN_MAX_DISPLAY(x) (x) + #define SET_MIN_MAX(x, val) x = (val) +#endif + +void onLimitsMenu(const char *result) +{ + uint8_t ch = m_posVert - 1; + + if (result == STR_RESET) { + LimitData *ld = limitAddress(ch); + ld->min = 0; + ld->max = 0; + ld->offset = 0; + ld->ppmCenter = 0; + ld->revert = false; + ld->curve = 0; + } + else if (result == STR_COPY_STICKS_TO_OFS) { + copySticksToOffset(ch); + } + else if (result == STR_COPY_TRIMS_TO_OFS) { + copyTrimsToOffset(ch); + } +} + +bool menuModelLimits(evt_t event) +{ + MENU(STR_MENULIMITS, menuTabModel, e_Limits, NUM_CHNOUT+1, DEFAULT_SCROLLBAR_X, + { NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, + NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, + NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, + NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, NAVIGATION_LINE_BY_LINE|ITEM_LIMITS_MAXROW, + 0 }); + + uint32_t sub = m_posVert; + + if (sub < NUM_CHNOUT) { +#if defined(PPM_CENTER_ADJUSTABLE) || defined(PPM_UNIT_US) + lcdDrawNumber(100, MENU_FOOTER_TOP, PPM_CH_CENTER(sub)+channelOutputs[sub]/2, HEADER_COLOR, 0, NULL, STR_US); +#else + lcdDrawNumber(100, MENU_FOOTER_TOP, calcRESXto1000(channelOutputs[sub]), HEADER_COLOR|PREC1); +#endif + } + + if (sub=0) { + displayColumnHeader(STR_LIMITS_HEADERS, m_posHorz); + } + + if (s_warning_result) { + s_warning_result = 0; + LimitData *ld = limitAddress(sub); + ld->revert = !ld->revert; + storageDirty(EE_MODEL); + } + + for (int i=0; irevert) ? -LIMIT_OFS(ld) : LIMIT_OFS(ld); + char swVal[2] = "-"; // '-', '<', '>' + if ((channelOutputs[k] - v) > 50) swVal[0] = (ld->revert ? 127 : 126); // Switch to raw inputs? - remove trim! + if ((channelOutputs[k] - v) < -50) swVal[0] = (ld->revert ? 126 : 127); + lcdDrawText(LIMITS_DIRECTION_POS, y, swVal); + + int limit = (g_model.extendedLimits ? LIMIT_EXT_MAX : 1000); + + putsChn(MENUS_MARGIN_LEFT, y, k+1, (sub==k && m_posHorz < 0) ? INVERS : 0); + if (sub==k && m_posHorz < 0 && event==EVT_KEY_LONG(KEY_ENTER) && !READ_ONLY()) { + killEvents(event); + MENU_ADD_ITEM(STR_RESET); + MENU_ADD_ITEM(STR_COPY_TRIMS_TO_OFS); + MENU_ADD_ITEM(STR_COPY_STICKS_TO_OFS); + menuHandler = onLimitsMenu; + } + + for (uint8_t j=0; j0) ? BLINK|INVERS : INVERS) : 0); + uint8_t active = (attr && s_editMode>0) ; + if (active) STICK_SCROLL_DISABLE(); + switch(j) + { + case ITEM_LIMITS_CH_NAME: + editName(LIMITS_NAME_POS, y, ld->name, sizeof(ld->name), event, attr); + break; + + case ITEM_LIMITS_OFFSET: + if (GV_IS_GV_VALUE(ld->offset, -1000, 1000) || (attr && event == EVT_KEY_LONG(KEY_ENTER))) { + ld->offset = GVAR_MENU_ITEM(LIMITS_OFFSET_POS, y, ld->offset, -1000, 1000, attr|PREC1, 0, event); + break; + } + +#if defined(PPM_UNIT_US) + lcdDrawNumber(LIMITS_OFFSET_POS, y, ((int32_t)ld->offset*128) / 25, attr|PREC1); +#else + lcdDrawNumber(LIMITS_OFFSET_POS, y, ld->offset, attr|PREC1); +#endif + if (active) { + ld->offset = checkIncDec(event, ld->offset, -1000, 1000, EE_MODEL, NULL, stops1000); + } + else if (attr && event==EVT_KEY_LONG(KEY_MENU)) { + copySticksToOffset(k); + s_editMode = 0; + } + break; + + case ITEM_LIMITS_MIN: + if (GV_IS_GV_VALUE(ld->min, -GV_RANGELARGE, GV_RANGELARGE) || (attr && event == EVT_KEY_LONG(KEY_ENTER))) { + ld->min = GVAR_MENU_ITEM(LIMITS_MIN_POS, y, ld->min, -LIMIT_EXT_MAX, LIMIT_EXT_MAX, attr|PREC1, 0, event); + break; + } + lcdDrawNumber(LIMITS_MIN_POS, y, MIN_MAX_DISPLAY(ld->min-LIMITS_MIN_MAX_OFFSET), attr|PREC1); + if (active) ld->min = LIMITS_MIN_MAX_OFFSET + checkIncDec(event, ld->min-LIMITS_MIN_MAX_OFFSET, -limit, 0, EE_MODEL, NULL, stops1000); + break; + + case ITEM_LIMITS_MAX: + if (GV_IS_GV_VALUE(ld->max, -GV_RANGELARGE, GV_RANGELARGE) || (attr && event == EVT_KEY_LONG(KEY_ENTER))) { + ld->max = GVAR_MENU_ITEM(LIMITS_MAX_POS, y, ld->max, -LIMIT_EXT_MAX, LIMIT_EXT_MAX, attr|PREC1, 0, event); + break; + } + lcdDrawNumber(LIMITS_MAX_POS, y, MIN_MAX_DISPLAY(ld->max+LIMITS_MIN_MAX_OFFSET), attr|PREC1); + if (active) ld->max = -LIMITS_MIN_MAX_OFFSET + checkIncDec(event, ld->max+LIMITS_MIN_MAX_OFFSET, 0, +limit, EE_MODEL, NULL, stops1000); + break; + + case ITEM_LIMITS_DIRECTION: + { + uint8_t revert = ld->revert; +#if defined(PPM_CENTER_ADJUSTABLE) + lcdDrawText(LIMITS_REVERT_POS, y, revert ? "\177" : "\176", attr); +#else + lcdDrawTextAtIndex(LIMITS_REVERT_POS, y, STR_MMMINV, revert, attr); +#endif + if (active) { + uint8_t revert_new = checkIncDecModel(event, revert, 0, 1); + if (checkIncDec_Ret && isThrottleOutput(k)) { + POPUP_CONFIRMATION(STR_INVERT_THR); + } + else { + ld->revert = revert_new; + } + } + break; + } + +#if defined(CURVES) + case ITEM_LIMITS_CURVE: + putsCurve(LIMITS_CURVE_POS, y, ld->curve, attr); + if (attr && event==EVT_KEY_LONG(KEY_ENTER) && ld->curve>0) { + s_curveChan = (ld->curve<0 ? -ld->curve-1 : ld->curve-1); + pushMenu(menuModelCurveOne); + } + if (active) { + CHECK_INCDEC_MODELVAR(event, ld->curve, -MAX_CURVES, +MAX_CURVES); + } + break; +#endif + +#if defined(PPM_CENTER_ADJUSTABLE) + case ITEM_LIMITS_PPM_CENTER: + lcdDrawNumber(LIMITS_PPM_CENTER_POS, y, PPM_CENTER+ld->ppmCenter, attr); + if (active) { + CHECK_INCDEC_MODELVAR(event, ld->ppmCenter, -PPM_CENTER_MAX, +PPM_CENTER_MAX); + } + break; +#endif + +#if defined(PPM_LIMITS_SYMETRICAL) + case ITEM_LIMITS_SYMETRICAL: + lcdDrawText(LIMITS_SYMETRICAL_POS, y, ld->symetrical ? "=" : "\306", attr); + if (active) { + CHECK_INCDEC_MODELVAR_ZERO(event, ld->symetrical, 1); + } + break; +#endif + } + } + } + + return true; +} diff --git a/radio/src/gui/Horus/menu_model_logical_switches.cpp b/radio/src/gui/Horus/menu_model_logical_switches.cpp new file mode 100644 index 000000000..cad4a33b2 --- /dev/null +++ b/radio/src/gui/Horus/menu_model_logical_switches.cpp @@ -0,0 +1,277 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../../opentx.h" + +enum LogicalSwitchFields { + LS_FIELD_FUNCTION, + LS_FIELD_V1, + LS_FIELD_V2, + LS_FIELD_V3, + LS_FIELD_ANDSW, + LS_FIELD_DURATION, + LS_FIELD_DELAY, + LS_FIELD_COUNT, + LS_FIELD_LAST = LS_FIELD_COUNT-1 +}; + +#define CSW_1ST_COLUMN 42 +#define CSW_2ND_COLUMN 90 +#define CSW_3RD_COLUMN 140 +#define CSW_4TH_COLUMN 200 +#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]; + div_t left = div(lswTimerValue(cs->v2), 10); + char sleft[10]; + sprintf(sleft, "%d.%d", left.quot, left.rem); + div_t right = div(lswTimerValue(cs->v2+cs->v3), 10); + char sright[10]; + sprintf(sright, "%d.%d", right.quot, right.rem); + sprintf(s, "[%s:%s]", sleft, sright); + lcdDrawText(x-4, y, s); + /* if (cs->v3 < 0) + lcdDrawText(lcdLastPos+3, y, "<<", rattr); + else if (cs->v3 == 0) + lcdDrawText(lcdLastPos+3, y, "--", rattr); */ +} + +void onLogicalSwitchesMenu(const char *result) +{ + int8_t sub = m_posVert; + LogicalSwitchData * cs = lswAddress(sub); + + if (result == STR_COPY) { + clipboard.type = CLIPBOARD_TYPE_CUSTOM_SWITCH; + clipboard.data.csw = *cs; + } + else if (result == STR_PASTE) { + *cs = clipboard.data.csw; + storageDirty(EE_MODEL); + } + else if (result == STR_CLEAR) { + memset(cs, 0, sizeof(LogicalSwitchData)); + storageDirty(EE_MODEL); + } +} + +bool menuModelLogicalSwitches(evt_t event) +{ + INCDEC_DECLARE_VARS(EE_MODEL); + + MENU(STR_MENULOGICALSWITCHES, menuTabModel, e_LogicalSwitches, NUM_LOGICAL_SWITCH, DEFAULT_SCROLLBAR_X, { NAVIGATION_LINE_BY_LINE|LS_FIELD_LAST/*repeated...*/} ); + + int k = 0; + int sub = m_posVert; + horzpos_t horz = m_posHorz; + + if (sub>= 0 && horz>=0) { + displayColumnHeader(STR_CSW_HEADERS, horz); + } + + if (horz<0 && event==EVT_KEY_LONG(KEY_ENTER) && !READ_ONLY()) { + killEvents(event); + LogicalSwitchData * cs = lswAddress(sub); + if (cs->func) + MENU_ADD_ITEM(STR_COPY); + if (clipboard.type == CLIPBOARD_TYPE_CUSTOM_SWITCH) + MENU_ADD_ITEM(STR_PASTE); + if (cs->func || cs->v1 || cs->v2 || cs->delay || cs->duration || cs->andsw) + MENU_ADD_ITEM(STR_CLEAR); + menuHandler = onLogicalSwitchesMenu; + } + + for (int i=0; i0) ? BLINK|INVERS : INVERS) : 0); + LcdFlags attr1 = (horz==1 ? attr : 0); + LcdFlags attr2 = (horz==2 ? attr : 0); + LogicalSwitchData * cs = lswAddress(k); + + // CSW name + unsigned int sw = SWSRC_SW1+k; + putsSwitches(MENUS_MARGIN_LEFT, y, sw, (getSwitch(sw) ? 0/*BOLD*/ : 0) | ((sub==k && CURSOR_ON_LINE()) ? INVERS : 0)); + + // CSW func + lcdDrawTextAtIndex(CSW_1ST_COLUMN, y, STR_VCSWFUNC, cs->func, horz==0 ? attr : 0); + + // CSW params + unsigned int cstate = lswFamily(cs->func); + int v1_val=cs->v1, v1_min=0, v1_max=MIXSRC_LAST_TELEM; + int v2_min=0, v2_max=MIXSRC_LAST_TELEM; + int v3_min=-1, v3_max=100; + + if (cstate == LS_FAMILY_BOOL || cstate == LS_FAMILY_STICKY) { + putsSwitches(CSW_2ND_COLUMN, y, cs->v1, attr1); + putsSwitches(CSW_3RD_COLUMN, y, cs->v2, attr2); + v1_min = SWSRC_FIRST_IN_LOGICAL_SWITCHES; v1_max = SWSRC_LAST_IN_LOGICAL_SWITCHES; + v2_min = SWSRC_FIRST_IN_LOGICAL_SWITCHES; v2_max = SWSRC_LAST_IN_LOGICAL_SWITCHES; + INCDEC_SET_FLAG(EE_MODEL | INCDEC_SWITCH); + INCDEC_ENABLE_CHECK(isSwitchAvailableInLogicalSwitches); + } + else if (cstate == LS_FAMILY_EDGE) { + putsSwitches(CSW_2ND_COLUMN, y, cs->v1, attr1); + putsEdgeDelayParam(CSW_3RD_COLUMN, y, cs, attr2, (horz==LS_FIELD_V3 ? attr : 0)); + v1_min = SWSRC_FIRST_IN_LOGICAL_SWITCHES; v1_max = SWSRC_LAST_IN_LOGICAL_SWITCHES; + v2_min=-129; v2_max = 122; + v3_max = 222 - cs->v2; + if (horz == 1) { + INCDEC_SET_FLAG(EE_MODEL | INCDEC_SWITCH); + INCDEC_ENABLE_CHECK(isSwitchAvailableInLogicalSwitches); + } + else { + INCDEC_SET_FLAG(EE_MODEL); + INCDEC_ENABLE_CHECK(NULL); + } + } + else if (cstate == LS_FAMILY_COMP) { + v1_val = (uint8_t)cs->v1; + putsMixerSource(CSW_2ND_COLUMN, y, v1_val, attr1); + putsMixerSource(CSW_3RD_COLUMN, y, cs->v2, attr2); + INCDEC_SET_FLAG(EE_MODEL | INCDEC_SOURCE); + INCDEC_ENABLE_CHECK(isSourceAvailable); + } + else if (cstate == LS_FAMILY_TIMER) { + lcdDrawNumber(CSW_2ND_COLUMN, y, lswTimerValue(cs->v1), LEFT|PREC1|attr1); + lcdDrawNumber(CSW_3RD_COLUMN, y, lswTimerValue(cs->v2), LEFT|PREC1|attr2); + v1_min = v2_min = -128; + v1_max = v2_max = 122; + INCDEC_SET_FLAG(EE_MODEL); + INCDEC_ENABLE_CHECK(NULL); + } + else { + v1_val = (uint8_t)cs->v1; + putsMixerSource(CSW_2ND_COLUMN, y, v1_val, attr1); + if (horz == 1) { + INCDEC_SET_FLAG(EE_MODEL | INCDEC_SOURCE); + INCDEC_ENABLE_CHECK(isSourceAvailableInCustomSwitches); + } + else { + INCDEC_SET_FLAG(EE_MODEL); + INCDEC_ENABLE_CHECK(NULL); + } + v2_max = getMaximumValue(v1_val); + v2_min = - v2_min; + putsChannelValue(CSW_3RD_COLUMN, y, v1_val, v1_val <= MIXSRC_LAST_CH ? calc100toRESX(cs->v2) : cs->v2, LEFT|attr2); + } + + // CSW AND switch + putsSwitches(CSW_4TH_COLUMN, y, cs->andsw, horz==LS_FIELD_ANDSW ? attr : 0); + + // CSW duration + if (cs->duration > 0) + lcdDrawNumber(CSW_5TH_COLUMN, y, cs->duration, (horz==LS_FIELD_DURATION ? attr : 0)|PREC1|LEFT); + else + lcdDrawTextAtIndex(CSW_5TH_COLUMN, y, STR_MMMINV, 0, horz==LS_FIELD_DURATION ? attr : 0); + + // CSW delay + if (cstate == LS_FAMILY_EDGE) { + lcdDrawText(CSW_6TH_COLUMN, y, STR_NA); + if (attr && horz == LS_FIELD_DELAY) { + REPEAT_LAST_CURSOR_MOVE(); + } + } + else if (cs->delay > 0) { + lcdDrawNumber(CSW_6TH_COLUMN, y, cs->delay, (horz==LS_FIELD_DELAY ? attr : 0)|PREC1|LEFT); + } + else { + lcdDrawTextAtIndex(CSW_6TH_COLUMN, y, STR_MMMINV, 0, horz==LS_FIELD_DELAY ? attr : 0); + } + + if (attr && horz == LS_FIELD_V3 && cstate != LS_FAMILY_EDGE) { + REPEAT_LAST_CURSOR_MOVE(); + } + + if (s_editMode>0 && attr) { + switch (horz) { + case LS_FIELD_FUNCTION: + { + cs->func = checkIncDec(event, cs->func, 0, LS_FUNC_MAX, EE_MODEL, isLogicalSwitchFunctionAvailable); + uint8_t new_cstate = lswFamily(cs->func); + if (cstate != new_cstate) { + if (new_cstate == LS_FAMILY_TIMER) { + cs->v1 = cs->v2 = -119; + } + else if (new_cstate == LS_FAMILY_EDGE) { + cs->v1 = 0; cs->v2 = -129; cs->v3 = 0; + } + else { + cs->v1 = cs->v2 = 0; + } + } + break; + } + case LS_FIELD_V1: + cs->v1 = CHECK_INCDEC_PARAM(event, v1_val, v1_min, v1_max); + break; + case LS_FIELD_V2: + cs->v2 = CHECK_INCDEC_PARAM(event, cs->v2, v2_min, v2_max); + if (cstate==LS_FAMILY_OFS && cs->v1!=0 && event==EVT_KEY_LONG(KEY_ENTER)) { + killEvents(event); + getvalue_t x = getValue(v1_val); + if (v1_val <= MIXSRC_LAST_CH) + cs->v2 = calcRESXto100(x); + storageDirty(EE_MODEL); + } + break; + case LS_FIELD_V3: + cs->v3 = CHECK_INCDEC_PARAM(event, cs->v3, v3_min, v3_max); + break; + case LS_FIELD_ANDSW: + INCDEC_SET_FLAG(EE_MODEL | INCDEC_SWITCH); + INCDEC_ENABLE_CHECK(isSwitchAvailableInLogicalSwitches); + cs->andsw = CHECK_INCDEC_PARAM(event, cs->andsw, -MAX_LS_ANDSW, MAX_LS_ANDSW); + break; + case LS_FIELD_DURATION: + CHECK_INCDEC_MODELVAR_ZERO(event, cs->duration, MAX_LS_DURATION); + break; + case LS_FIELD_DELAY: + CHECK_INCDEC_MODELVAR_ZERO(event, cs->delay, MAX_LS_DELAY); + break; + } + } + } + + return true; +} diff --git a/radio/src/gui/Horus/menu_model_select.cpp b/radio/src/gui/Horus/menu_model_select.cpp new file mode 100644 index 000000000..0691ac5de --- /dev/null +++ b/radio/src/gui/Horus/menu_model_select.cpp @@ -0,0 +1,254 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../../opentx.h" + +#define CATEGORIES_WIDTH 140 + +#define MODELCELL_WIDTH 153 +#define MODELCELL_HEIGHT 61 + +enum ModelSelectMode { + MODE_SELECT_CATEGORY, + MODE_SELECT_MODEL, +}; + +uint8_t selectMode; +uint8_t currentCategory; +char selectedFilename[LEN_MODEL_FILENAME+1]; + +void drawCategory(coord_t y, const char * name, bool selected) +{ + if (selected) { + lcdDrawSolidFilledRect(0, y-INVERT_VERT_MARGIN, CATEGORIES_WIDTH, INVERT_LINE_HEIGHT, HEADER_BGCOLOR); + lcdDrawBitmapPattern(CATEGORIES_WIDTH-12, y, LBM_LIBRARY_CURSOR, MENU_TITLE_COLOR); + if (selectMode == MODE_SELECT_CATEGORY) { + drawShadow(0, y-INVERT_VERT_MARGIN, CATEGORIES_WIDTH, INVERT_LINE_HEIGHT); + } + } + lcdDrawText(MENUS_MARGIN_LEFT, y, name, MENU_TITLE_COLOR); +} + +void drawModel(coord_t x, coord_t y, const char * name, bool selected) +{ + ModelHeader header; + const char * error = readModel(name, (uint8_t *)&header, sizeof(header)); + if (error) { + lcdDrawText(x+5, y+2, "(Invalid Model)", TEXT_COLOR); + lcdDrawBitmapPattern(x+5, y+23, LBM_LIBRARY_SLOT, TEXT_COLOR); + } + else { + lcdDrawTextWithLen(x+5, y+2, header.name, LEN_MODEL_NAME, ZCHAR|TEXT_COLOR); + putsTimer(x+104, y+41, 0, TEXT_COLOR|LEFT); + for (int i=0; i<4; i++) { + lcdDrawBitmapPattern(x+104+i*11, y+25, LBM_SCORE0, TITLE_BGCOLOR); + } + loadModelBitmap(header.bitmap, modelBitmap); + lcdDrawBitmap(x+5, y+24, modelBitmap, 0, 0, getBitmapScale(modelBitmap, 64, 32)); + } + lcdDrawSolidHorizontalLine(x+5, y+19, 143, LINE_COLOR); + if (selectMode == MODE_SELECT_MODEL && selected) { + lcdDrawSolidRect(x, y, MODELCELL_WIDTH, MODELCELL_HEIGHT, TITLE_BGCOLOR); + drawShadow(x, y, MODELCELL_WIDTH, MODELCELL_HEIGHT); + } +} + +void onModelSelectMenu(const char * result) +{ + if (result == STR_SELECT_MODEL) { + memcpy(g_eeGeneral.currModelFilename, selectedFilename, LEN_MODEL_FILENAME); + storageDirty(EE_GENERAL); + loadModel(g_eeGeneral.currModelFilename); + chainMenu(menuMainView); + } + else if (result == STR_DELETE_MODEL) { + POPUP_CONFIRMATION(STR_DELETEMODEL); + SET_WARNING_INFO(selectedFilename, LEN_MODEL_FILENAME, 0); + } + else if (result == STR_DUPLICATE_MODEL) { + char duplicatedFilename[LEN_MODEL_FILENAME+1]; + memcpy(duplicatedFilename, selectedFilename, sizeof(duplicatedFilename)); + if (findNextFileIndex(duplicatedFilename, MODELS_PATH)) { + sdCopyFile(selectedFilename, MODELS_PATH, duplicatedFilename, MODELS_PATH); + storageInsertModel(duplicatedFilename, currentCategory, -1); + } + else { + POPUP_WARNING("Invalid Filename"); + } + } +} + +#define MODEL_INDEX() (m_posVert*2+m_posHorz) + +bool menuModelSelect(evt_t event) +{ + if (s_warning_result) { + s_warning_result = 0; + int modelIndex = MODEL_INDEX(); + storageRemoveModel(currentCategory, modelIndex); + s_copyMode = 0; + event = EVT_REFRESH; + if (modelIndex > 0) { + modelIndex--; + m_posVert = modelIndex / 2; + m_posHorz = modelIndex & 1; + } + } + + switch(event) { + case 0: + // no need to refresh the screen + return false; + + case EVT_ENTRY: + selectMode = MODE_SELECT_CATEGORY; + currentCategory = m_posVert = 0; + break; + + case EVT_KEY_FIRST(KEY_EXIT): + switch (selectMode) { + case MODE_SELECT_CATEGORY: + chainMenu(menuMainView); + return false; + case MODE_SELECT_MODEL: + selectMode = MODE_SELECT_CATEGORY; + m_posVert = currentCategory; + break; + } + break; + + case EVT_KEY_BREAK(KEY_ENTER): + case EVT_KEY_BREAK(KEY_RIGHT): + switch (selectMode) { + case MODE_SELECT_CATEGORY: + selectMode = MODE_SELECT_MODEL; + m_posVert = 0; + break; + } + break; + + case EVT_KEY_LONG(KEY_ENTER): + killEvents(event); + if (selectMode == MODE_SELECT_MODEL) { + ModelHeader header; + const char * error = readModel(selectedFilename, (uint8_t *)&header, sizeof(header)); + if (!error) { + MENU_ADD_ITEM(STR_SELECT_MODEL); + MENU_ADD_ITEM(STR_DUPLICATE_MODEL); + } + // MENU_ADD_SD_ITEM(STR_BACKUP_MODEL); + // MENU_ADD_ITEM(STR_MOVE_MODEL); + MENU_ADD_ITEM(STR_DELETE_MODEL); + // MENU_ADD_ITEM(STR_CREATE_MODEL); + // MENU_ADD_ITEM(STR_RESTORE_MODEL); + menuHandler = onModelSelectMenu; + } + break; + } + + // Header + lcdDrawSolidFilledRect(0, 0, LCD_W, MENU_HEADER_HEIGHT, HEADER_BGCOLOR); + lcdDrawBitmapPattern(0, 0, LBM_TOPMENU_POLYGON, TITLE_BGCOLOR); + lcdDrawBitmapPattern(5, 7, LBM_LIBRARY_ICON, MENU_TITLE_COLOR); + drawTopmenuDatetime(); + + // Body + lcdDrawSolidFilledRect(0, MENU_HEADER_HEIGHT, CATEGORIES_WIDTH, LCD_H-MENU_HEADER_HEIGHT-MENU_FOOTER_HEIGHT, TITLE_BGCOLOR); + lcdDrawSolidFilledRect(CATEGORIES_WIDTH, MENU_HEADER_HEIGHT, LCD_W-CATEGORIES_WIDTH, LCD_H-MENU_HEADER_HEIGHT-MENU_FOOTER_HEIGHT, TEXT_BGCOLOR); + + // Footer + lcdDrawSolidFilledRect(0, MENU_FOOTER_TOP, LCD_W, MENU_FOOTER_HEIGHT, HEADER_BGCOLOR); + + // Categories + StorageModelsList storage; + const char * error = storageOpenModelsList(&storage); + if (!error) { + bool result = true; + coord_t y = MENU_HEADER_HEIGHT+10; + int index = 0; + while (1) { + char line[LEN_MODEL_FILENAME+1]; + result = storageReadNextCategory(&storage, line, LEN_MODEL_FILENAME); + if (!result) + break; + if (y < LCD_H) { + drawCategory(y, line, currentCategory==index); + } + y += FH; + index++; + } + if (selectMode == MODE_SELECT_CATEGORY) { + if (navigate(event, index, 9)) { + putEvent(EVT_REFRESH); + currentCategory = m_posVert; + } + } + } + + // Models + if (!error) { + bool result = storageSeekCategory(&storage, currentCategory); + coord_t y = MENU_HEADER_HEIGHT+7; + int index = 0; + while (result) { + char line[LEN_MODEL_FILENAME+1]; + result = storageReadNextModel(&storage, line, LEN_MODEL_FILENAME); + if (!result) + break; + if (index >= s_pgOfs*2 && index < (s_pgOfs+3)*2) { + bool selected = (m_posVert*2+m_posHorz==index); + if (index & 1) { + drawModel(CATEGORIES_WIDTH+MENUS_MARGIN_LEFT+162, y, line, selected); + y += 66; + } + else { + drawModel(CATEGORIES_WIDTH+MENUS_MARGIN_LEFT+1, y, line, selected); + } + if (selected) { + memcpy(selectedFilename, line, sizeof(selectedFilename)); + } + } + index++; + } + if (selectMode == MODE_SELECT_MODEL) { + if (navigate(event, index, 3, 2)) { + putEvent(EVT_REFRESH); + } + } + drawScrollbar(DEFAULT_SCROLLBAR_X, MENU_HEADER_HEIGHT+7, MENU_FOOTER_TOP-MENU_HEADER_HEIGHT-15, s_pgOfs, (index+1)/2, 3); + } + + return true; +} diff --git a/radio/src/gui/Horus/menu_model_setup.cpp b/radio/src/gui/Horus/menu_model_setup.cpp new file mode 100644 index 000000000..c78429f61 --- /dev/null +++ b/radio/src/gui/Horus/menu_model_setup.cpp @@ -0,0 +1,780 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../../opentx.h" + +uint8_t g_moduleIdx; +bool menuModelFailsafe(evt_t event); + +enum menuModelSetupItems { + ITEM_MODEL_NAME, + ITEM_MODEL_BITMAP, + ITEM_MODEL_TIMER1, + ITEM_MODEL_TIMER1_NAME, + ITEM_MODEL_TIMER1_PERSISTENT, + ITEM_MODEL_TIMER1_MINUTE_BEEP, + ITEM_MODEL_TIMER1_COUNTDOWN_BEEP, +#if TIMERS > 1 + ITEM_MODEL_TIMER2, + ITEM_MODEL_TIMER2_NAME, + ITEM_MODEL_TIMER2_PERSISTENT, + ITEM_MODEL_TIMER2_MINUTE_BEEP, + ITEM_MODEL_TIMER2_COUNTDOWN_BEEP, +#endif +#if TIMERS > 2 + ITEM_MODEL_TIMER3, + ITEM_MODEL_TIMER3_NAME, + ITEM_MODEL_TIMER3_PERSISTENT, + ITEM_MODEL_TIMER3_MINUTE_BEEP, + ITEM_MODEL_TIMER3_COUNTDOWN_BEEP, +#endif + ITEM_MODEL_EXTENDED_LIMITS, + ITEM_MODEL_EXTENDED_TRIMS, + ITEM_MODEL_DISPLAY_TRIMS, + ITEM_MODEL_TRIM_INC, + ITEM_MODEL_THROTTLE_LABEL, + // ITEM_MODEL_THROTTLE_REVERSED, + ITEM_MODEL_THROTTLE_TRACE, + ITEM_MODEL_THROTTLE_TRIM, + ITEM_MODEL_PREFLIGHT_LABEL, + ITEM_MODEL_CHECKLIST_DISPLAY, + ITEM_MODEL_THROTTLE_WARNING, + ITEM_MODEL_SWITCHES_WARNING, + ITEM_MODEL_POT_WARNING, + ITEM_MODEL_BEEP_CENTER, + ITEM_MODEL_USE_GLOBAL_FUNCTIONS, + ITEM_MODEL_EXTERNAL_MODULE_LABEL, + ITEM_MODEL_EXTERNAL_MODULE_MODE, + ITEM_MODEL_EXTERNAL_MODULE_CHANNELS, + ITEM_MODEL_EXTERNAL_MODULE_BIND, + ITEM_MODEL_EXTERNAL_MODULE_FAILSAFE, + ITEM_MODEL_TRAINER_LABEL, + ITEM_MODEL_TRAINER_MODE, + ITEM_MODEL_TRAINER_CHANNELS, + ITEM_MODEL_TRAINER_SETTINGS, + ITEM_MODEL_SETUP_MAX +}; + +#define FIELD_PROTOCOL_MAX 1 + +#define MODEL_SETUP_2ND_COLUMN 200 +#define MODEL_SETUP_BIND_OFS 20 +#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) { + if (!sdListFiles(BITMAPS_PATH, BITMAPS_EXT, sizeof(g_model.header.bitmap), NULL)) { + POPUP_WARNING(STR_NO_BITMAPS_ON_SD); + s_menu_flags = 0; + } + } + else { + // The user choosed a bmp file in the list + copySelection(g_model.header.bitmap, result, sizeof(g_model.header.bitmap)); + loadModelBitmap(g_model.header.bitmap, modelBitmap); + storageDirty(EE_MODEL); + } +} + +void editTimerMode(int timerIdx, coord_t y, LcdFlags attr, evt_t event) +{ + TimerData * timer = &g_model.timers[timerIdx]; + if (attr && m_posHorz < 0) { + lcdDrawSolidFilledRect(MODEL_SETUP_2ND_COLUMN-INVERT_HORZ_MARGIN, y-INVERT_VERT_MARGIN+1, 90+2*INVERT_HORZ_MARGIN, INVERT_LINE_HEIGHT, TEXT_INVERTED_BGCOLOR); + } + putsStrIdx(MENUS_MARGIN_LEFT, y, STR_TIMER, timerIdx+1); + putsTimerMode(MODEL_SETUP_2ND_COLUMN, y, timer->mode, (m_posHorz<=0 ? attr : 0)); + putsTimer(MODEL_SETUP_2ND_COLUMN+50, y, timer->start, (m_posHorz!=0 ? attr : 0)); + if (attr && s_editMode>0) { + switch (m_posHorz) { + case 0: + { + int8_t timerMode = timer->mode; + if (timerMode < 0) timerMode -= TMRMODE_COUNT-1; + CHECK_INCDEC_MODELVAR_CHECK(event, timerMode, -TMRMODE_COUNT-SWSRC_LAST+1, TMRMODE_COUNT+SWSRC_LAST-1, isSwitchAvailableInTimers); + if (timerMode < 0) timerMode += TMRMODE_COUNT-1; + timer->mode = timerMode; +#if defined(AUTOSWITCH) + if (s_editMode>0) { + int8_t val = timer->mode - (TMRMODE_COUNT-1); + int8_t switchVal = checkIncDecMovedSwitch(val); + if (val != switchVal) { + timer->mode = switchVal + (TMRMODE_COUNT-1); + storageDirty(EE_MODEL); + } + } +#endif + break; + } + case 1: + { + const int stopsMinutes[] = { 8, 60, 120, 180, 240, 300, 600, 900, 1200 }; + timer->start = checkIncDec(event, timer->start, 0, 60*60, EE_MODEL, NULL, (const CheckIncDecStops&)stopsMinutes); + break; + } + } + } +} + +#define CURRENT_MODULE_EDITED(k) (k>=ITEM_MODEL_TRAINER_LABEL ? TRAINER_MODULE : EXTERNAL_MODULE) + +int getSwitchWarningsCount() +{ + int count = 0; + for (int i=0; i> 6) ? (uint8_t)NUM_POTS : (uint8_t)0) + #define TIMER_ROWS NAVIGATION_LINE_BY_LINE|1, 0, CASE_PERSISTENT_TIMERS(0) 0, 0 + #if TIMERS == 1 + #define TIMERS_ROWS TIMER_ROWS + #elif TIMERS == 2 + #define TIMERS_ROWS TIMER_ROWS, TIMER_ROWS + #elif TIMERS == 3 + #define TIMERS_ROWS TIMER_ROWS, TIMER_ROWS, TIMER_ROWS + #endif + bool CURSOR_ON_CELL = (m_posHorz >= 0); + + MENU(STR_MENUSETUP, menuTabModel, e_ModelSetup, ITEM_MODEL_SETUP_MAX, DEFAULT_SCROLLBAR_X, { 0, 0, TIMERS_ROWS, 0, 1, 0, 0, LABEL(Throttle), 0, 0, LABEL(PreflightCheck), 0, 0, uint8_t(NAVIGATION_LINE_BY_LINE|(getSwitchWarningsCount()-1)), POT_WARN_ITEMS(), NAVIGATION_LINE_BY_LINE|(NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS-1), 0, LABEL(ExternalModule), (IS_MODULE_XJT(EXTERNAL_MODULE) || IS_MODULE_DSM2(EXTERNAL_MODULE)) ? (uint8_t)1 : (uint8_t)0, EXTERNAL_MODULE_CHANNELS_ROWS(), (IS_MODULE_XJT(EXTERNAL_MODULE) && IS_D8_RX(EXTERNAL_MODULE)) ? (uint8_t)1 : (IS_MODULE_PPM(EXTERNAL_MODULE) || IS_MODULE_XJT(EXTERNAL_MODULE) || IS_MODULE_DSM2(EXTERNAL_MODULE)) ? (uint8_t)2 : HIDDEN_ROW, IF_EXTERNAL_MODULE_XJT(FAILSAFE_ROWS(EXTERNAL_MODULE)), LABEL(Trainer), 0, TRAINER_CHANNELS_ROWS(), IF_TRAINER_ON(2) }); + +#if (defined(DSM2) || defined(PXX)) + if (menuEvent) { + moduleFlag[0] = 0; +#if NUM_MODULES > 1 + moduleFlag[1] = 0; +#endif + } +#endif + + int sub = m_posVert; + + for (int i=0; i0) ? BLINK|INVERS : INVERS); + LcdFlags attr = (sub == k ? blink : 0); + + switch(k) { + case ITEM_MODEL_NAME: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_MODELNAME); + editName(MODEL_SETUP_2ND_COLUMN, y, g_model.header.name, sizeof(g_model.header.name), event, attr); + break; + + case ITEM_MODEL_BITMAP: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_BITMAP); + if (ZEXIST(g_model.header.bitmap)) + lcdDrawTextWithLen(MODEL_SETUP_2ND_COLUMN, y, g_model.header.bitmap, sizeof(g_model.header.bitmap), attr); + else + lcdDrawTextAtIndex(MODEL_SETUP_2ND_COLUMN, y, STR_VCSWFUNC, 0, attr); + if (attr && event==EVT_KEY_BREAK(KEY_ENTER) && READ_ONLY_UNLOCKED()) { + s_editMode = 0; + if (sdListFiles(BITMAPS_PATH, BITMAPS_EXT, sizeof(g_model.header.bitmap), g_model.header.bitmap, LIST_NONE_SD_FILE)) { + menuHandler = onModelSetupBitmapMenu; + } + else { + POPUP_WARNING(STR_NO_BITMAPS_ON_SD); + s_menu_flags = 0; + } + } + break; + + case ITEM_MODEL_TIMER1: + editTimerMode(0, y, attr, event); + break; + + case ITEM_MODEL_TIMER1_NAME: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_TIMER_NAME); + editName(MODEL_SETUP_2ND_COLUMN, y, g_model.timers[0].name, LEN_TIMER_NAME, event, attr); + break; + + case ITEM_MODEL_TIMER1_MINUTE_BEEP: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_MINUTEBEEP); + g_model.timers[0].minuteBeep = onoffMenuItem(g_model.timers[0].minuteBeep, MODEL_SETUP_2ND_COLUMN, y, attr, event); + break; + + case ITEM_MODEL_TIMER1_COUNTDOWN_BEEP: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_BEEPCOUNTDOWN); + g_model.timers[0].countdownBeep = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_VBEEPCOUNTDOWN, g_model.timers[0].countdownBeep, 0, 2, attr, event); + break; + + case ITEM_MODEL_TIMER1_PERSISTENT: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_PERSISTENT); + g_model.timers[0].persistent = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_VPERSISTENT, g_model.timers[0].persistent, 0, 2, attr, event); + break; + +#if TIMERS > 1 + case ITEM_MODEL_TIMER2: + editTimerMode(1, y, attr, event); + break; + + case ITEM_MODEL_TIMER2_NAME: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_TIMER_NAME); + editName(MODEL_SETUP_2ND_COLUMN, y, g_model.timers[1].name, LEN_TIMER_NAME, event, attr); + break; + + case ITEM_MODEL_TIMER2_MINUTE_BEEP: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_MINUTEBEEP); + g_model.timers[1].minuteBeep = onoffMenuItem(g_model.timers[1].minuteBeep, MODEL_SETUP_2ND_COLUMN, y, attr, event); + break; + + case ITEM_MODEL_TIMER2_COUNTDOWN_BEEP: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_BEEPCOUNTDOWN); + g_model.timers[1].countdownBeep = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_VBEEPCOUNTDOWN, g_model.timers[1].countdownBeep, 0, 2, attr, event); + break; + + case ITEM_MODEL_TIMER2_PERSISTENT: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_PERSISTENT); + g_model.timers[1].persistent = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_VPERSISTENT, g_model.timers[1].persistent, 0, 2, attr, event); + break; +#endif + +#if TIMERS > 2 + case ITEM_MODEL_TIMER3: + editTimerMode(2, y, attr, event); + break; + + case ITEM_MODEL_TIMER3_NAME: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_TIMER_NAME); + editName(MODEL_SETUP_2ND_COLUMN, y, g_model.timers[2].name, LEN_TIMER_NAME, event, attr); + break; + + case ITEM_MODEL_TIMER3_MINUTE_BEEP: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_MINUTEBEEP); + g_model.timers[2].minuteBeep = onoffMenuItem(g_model.timers[2].minuteBeep, MODEL_SETUP_2ND_COLUMN, y, attr, event); + break; + + case ITEM_MODEL_TIMER3_COUNTDOWN_BEEP: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_BEEPCOUNTDOWN); + g_model.timers[2].countdownBeep = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_VBEEPCOUNTDOWN, g_model.timers[2].countdownBeep, 0, 2, attr, event); + break; + + case ITEM_MODEL_TIMER3_PERSISTENT: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_PERSISTENT); + g_model.timers[2].persistent = selectMenuItem(MODEL_SETUP_2ND_COLUMN, y, STR_VPERSISTENT, g_model.timers[2].persistent, 0, 2, attr, event); + break; +#endif + + case ITEM_MODEL_EXTENDED_LIMITS: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_ELIMITS); + onoffMenuItem(g_model.extendedLimits, MODEL_SETUP_2ND_COLUMN, y, attr, event); + break; + + case ITEM_MODEL_EXTENDED_TRIMS: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_ETRIMS); + onoffMenuItem(g_model.extendedTrims, MODEL_SETUP_2ND_COLUMN, y, m_posHorz<=0 ? attr : 0, event==EVT_KEY_BREAK(KEY_ENTER) ? event : 0); + lcdDrawText(MODEL_SETUP_2ND_COLUMN+18, y, STR_RESET_BTN, m_posHorz>0 && !s_noHi ? attr : 0); + if (attr && m_posHorz>0) { + s_editMode = 0; + if (event==EVT_KEY_LONG(KEY_ENTER)) { + s_noHi = NO_HI_LEN; + for (uint8_t i=0; i MIXSRC_Thr) + idx += 1; + if (idx >= MIXSRC_FIRST_POT+NUM_POTS) + idx += MIXSRC_CH1 - MIXSRC_FIRST_POT - NUM_POTS; + putsMixerSource(MODEL_SETUP_2ND_COLUMN, y, idx, attr); + break; + } + + case ITEM_MODEL_THROTTLE_TRIM: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_TTRIM); + onoffMenuItem(g_model.thrTrim, MODEL_SETUP_2ND_COLUMN, y, attr, event); + break; + + case ITEM_MODEL_PREFLIGHT_LABEL: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_PREFLIGHT); + break; + + case ITEM_MODEL_CHECKLIST_DISPLAY: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_CHECKLIST); + onoffMenuItem(g_model.displayChecklist, MODEL_SETUP_2ND_COLUMN, y, attr, event); + break; + + case ITEM_MODEL_THROTTLE_WARNING: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_THROTTLEWARNING); + g_model.disableThrottleWarning = !onoffMenuItem(!g_model.disableThrottleWarning, MODEL_SETUP_2ND_COLUMN, y, attr, event); + break; + + case ITEM_MODEL_SWITCHES_WARNING: + { + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_SWITCHWARNING); + if (!READ_ONLY() && attr && m_posHorz<0 && event==EVT_KEY_LONG(KEY_ENTER)) { + killEvents(event); + s_noHi = NO_HI_LEN; + getMovedSwitch(); + g_model.switchWarningState = switches_states; + AUDIO_WARNING1(); + storageDirty(EE_MODEL); + } + + if (attr && m_posHorz < 0) { + lcdDrawSolidFilledRect(MODEL_SETUP_2ND_COLUMN-INVERT_HORZ_MARGIN, y-INVERT_VERT_MARGIN, NUM_SWITCHES*18+INVERT_HORZ_MARGIN, INVERT_LINE_HEIGHT, TEXT_INVERTED_BGCOLOR); + } + + unsigned int newStates = 0; + for (int i=0, current=0; i> (3*i)) & 0x07); + LcdFlags color = (state > 0 ? TEXT_COLOR : TEXT_DISABLE_COLOR); + if (attr && m_posHorz < 0) { + color |= INVERS; + } + char s[3]; + s[0] = 'A' + i + (i >= 3 ? 1 : 0 /* skip SD which is a POT*/); + int max; + if (state == 0) { + s[1] = 'x'; + max = 2; + } + else if (i == 2) { + s[1] = '0' + state; + max = 6; + } + else if (IS_3POS(i)) { + s[1] = "\300-\301"[state-1]; + max = 3; + } + else { + s[1] = "\300\301"[state-1]; + max = 2; + } + s[2] = '\0'; + lcdDrawText(MODEL_SETUP_2ND_COLUMN+i*18, y, s, color|(m_posHorz==current ? attr : 0)); + if (attr && m_posHorz==current) CHECK_INCDEC_MODELVAR_ZERO(event, state, max); + newStates |= (state << (3*i)); + ++current; + } + } + g_model.switchWarningState = newStates; + break; + } + + case ITEM_MODEL_POT_WARNING: + { + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_POTWARNING); + if (attr) { + if (m_posHorz) s_editMode = 0; + if (!READ_ONLY() && m_posHorz) { + switch (event) { + case EVT_KEY_LONG(KEY_ENTER): + killEvents(event); + if (g_model.potsWarnMode == POTS_WARN_MANUAL) { + SAVE_POT_POSITION(m_posHorz-1); + AUDIO_WARNING1(); + storageDirty(EE_MODEL); + } + break; + case EVT_KEY_BREAK(KEY_ENTER): + g_model.potsWarnEnabled ^= (1 << (m_posHorz-1)); + storageDirty(EE_MODEL); + break; + } + } + } + lcdDrawTextAtIndex(MODEL_SETUP_2ND_COLUMN, y, PSTR("\004""OFF\0""Man\0""Auto"), g_model.potsWarnMode, (m_posHorz == 0) ? attr : 0); + if (g_model.potsWarnMode) { + coord_t x = MODEL_SETUP_2ND_COLUMN+30; + for (int i=0; i0) { + switch (m_posHorz) { + case 0: + g_model.moduleData[EXTERNAL_MODULE].type = checkIncDec(event, g_model.moduleData[EXTERNAL_MODULE].type, MODULE_TYPE_NONE, MODULE_TYPE_COUNT-1, EE_MODEL, isModuleAvailable); + if (checkIncDec_Ret) { + g_model.moduleData[EXTERNAL_MODULE].rfProtocol = 0; + g_model.moduleData[EXTERNAL_MODULE].channelsStart = 0; + if (g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_PPM) + g_model.moduleData[EXTERNAL_MODULE].channelsCount = 0; + else + g_model.moduleData[EXTERNAL_MODULE].channelsCount = MAX_EXTERNAL_MODULE_CHANNELS(); + } + break; + case 1: + if (IS_MODULE_DSM2(EXTERNAL_MODULE)) + CHECK_INCDEC_MODELVAR(event, g_model.moduleData[EXTERNAL_MODULE].rfProtocol, DSM2_PROTO_LP45, DSM2_PROTO_DSMX); + else + CHECK_INCDEC_MODELVAR(event, g_model.moduleData[EXTERNAL_MODULE].rfProtocol, RF_PROTO_X16, RF_PROTO_LAST); + if (checkIncDec_Ret) { + g_model.moduleData[EXTERNAL_MODULE].channelsStart = 0; + g_model.moduleData[EXTERNAL_MODULE].channelsCount = MAX_EXTERNAL_MODULE_CHANNELS(); + } + } + } + break; + + case ITEM_MODEL_TRAINER_LABEL: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_TRAINER); + break; + + case ITEM_MODEL_EXTERNAL_MODULE_CHANNELS: + case ITEM_MODEL_TRAINER_CHANNELS: + { + uint8_t moduleIdx = CURRENT_MODULE_EDITED(k); + ModuleData & moduleData = g_model.moduleData[moduleIdx]; + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_CHANNELRANGE); + if ((int8_t)PORT_CHANNELS_ROWS(moduleIdx) >= 0) { + putsStrIdx(MODEL_SETUP_2ND_COLUMN, y, STR_CH, moduleData.channelsStart+1, m_posHorz==0 ? attr : 0); + lcdDrawText(MODEL_SETUP_2ND_COLUMN+30, y, "-"); + putsStrIdx(MODEL_SETUP_2ND_COLUMN+40, y, STR_CH, moduleData.channelsStart+NUM_CHANNELS(moduleIdx), m_posHorz==1 ? attr : 0); + if (attr && s_editMode>0) { + switch (m_posHorz) { + case 0: + CHECK_INCDEC_MODELVAR_ZERO(event, moduleData.channelsStart, 32-8-moduleData.channelsCount); + break; + case 1: + CHECK_INCDEC_MODELVAR(event, moduleData.channelsCount, -4, min(MAX_CHANNELS(moduleIdx), 32-8-moduleData.channelsStart)); + if ((k == ITEM_MODEL_EXTERNAL_MODULE_CHANNELS && g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_PPM) + || (k == ITEM_MODEL_TRAINER_CHANNELS) + ) + SET_DEFAULT_PPM_FRAME_LENGTH(moduleIdx); + break; + } + } + } + break; + } + + case ITEM_MODEL_EXTERNAL_MODULE_BIND: + case ITEM_MODEL_TRAINER_SETTINGS: + { + uint8_t moduleIdx = CURRENT_MODULE_EDITED(k); + ModuleData & moduleData = g_model.moduleData[moduleIdx]; + if (IS_MODULE_PPM(moduleIdx)) { + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_PPMFRAME); + lcdDrawNumber(MODEL_SETUP_2ND_COLUMN, y, (int16_t)moduleData.ppmFrameLength*5 + 225, (m_posHorz<=0 ? attr : 0) | PREC1|LEFT, 0, NULL, STR_MS); + lcdDrawNumber(MODEL_SETUP_2ND_COLUMN+70, y, (moduleData.ppmDelay*50)+300, (CURSOR_ON_LINE() || m_posHorz==1) ? attr : 0, 0, NULL, "us"); + lcdDrawText(MODEL_SETUP_2ND_COLUMN+90, y, moduleData.ppmPulsePol ? "+" : "-", (CURSOR_ON_LINE() || m_posHorz==2) ? attr : 0); + + if (attr && s_editMode>0) { + switch (m_posHorz) { + case 0: + CHECK_INCDEC_MODELVAR(event, moduleData.ppmFrameLength, -20, 35); + break; + case 1: + CHECK_INCDEC_MODELVAR(event, moduleData.ppmDelay, -4, 10); + break; + case 2: + CHECK_INCDEC_MODELVAR_ZERO(event, moduleData.ppmPulsePol, 1); + break; + } + } + } + else { + horzpos_t l_posHorz = m_posHorz; + coord_t xOffsetBind = MODEL_SETUP_BIND_OFS; + if (IS_MODULE_XJT(moduleIdx) && IS_D8_RX(moduleIdx)) { + xOffsetBind = 0; + lcdDrawText(MENUS_MARGIN_LEFT, y, INDENT "Receiver"); + if (attr) l_posHorz += 1; + } + else { + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_RXNUM); + } + if (IS_MODULE_XJT(moduleIdx) || IS_MODULE_DSM2(moduleIdx)) { + if (xOffsetBind) lcdDrawNumber(MODEL_SETUP_2ND_COLUMN, y, g_model.header.modelId[moduleIdx], (l_posHorz==0 ? attr : 0) | LEADING0|LEFT, 2); + if (attr && l_posHorz==0 && s_editMode>0) { + CHECK_INCDEC_MODELVAR_ZERO(event, g_model.header.modelId[moduleIdx], IS_MODULE_DSM2(moduleIdx) ? 20 : 63); + } + lcdDrawText(MODEL_SETUP_2ND_COLUMN+xOffsetBind, y, STR_MODULE_BIND, l_posHorz==1 ? attr : 0); + lcdDrawText(MODEL_SETUP_2ND_COLUMN+MODEL_SETUP_RANGE_OFS+xOffsetBind, y, STR_MODULE_RANGE, l_posHorz==2 ? attr : 0); + uint8_t newFlag = 0; + if (attr && l_posHorz>0 && s_editMode>0) { + if (l_posHorz == 1) + newFlag = MODULE_BIND; + else if (l_posHorz == 2) { + newFlag = MODULE_RANGECHECK; + } + } + moduleFlag[moduleIdx] = newFlag; + } + } + break; + } + + case ITEM_MODEL_EXTERNAL_MODULE_FAILSAFE: + { + uint8_t moduleIdx = CURRENT_MODULE_EDITED(k); + ModuleData & moduleData = g_model.moduleData[moduleIdx]; + lcdDrawText(MENUS_MARGIN_LEFT, y, TR_FAILSAFE); + if (IS_MODULE_XJT(moduleIdx)) { + lcdDrawTextAtIndex(MODEL_SETUP_2ND_COLUMN, y, STR_VFAILSAFE, moduleData.failsafeMode, m_posHorz==0 ? attr : 0); + if (moduleData.failsafeMode == FAILSAFE_CUSTOM) lcdDrawText(MODEL_SETUP_2ND_COLUMN + MODEL_SETUP_SET_FAILSAFE_OFS, y, STR_SET, m_posHorz==1 ? attr : 0); + if (attr) { + if (moduleData.failsafeMode != FAILSAFE_CUSTOM) + m_posHorz = 0; + if (m_posHorz==0) { + if (s_editMode>0) { + CHECK_INCDEC_MODELVAR_ZERO(event, moduleData.failsafeMode, FAILSAFE_LAST); + if (checkIncDec_Ret) SEND_FAILSAFE_NOW(moduleIdx); + } + } + else if (m_posHorz==1) { + s_editMode = 0; + if (moduleData.failsafeMode==FAILSAFE_CUSTOM && event==EVT_KEY_FIRST(KEY_ENTER)) { + g_moduleIdx = moduleIdx; + pushMenu(menuModelFailsafe); + } + } + else { + lcdDrawSolidFilledRect(MODEL_SETUP_2ND_COLUMN, y, LCD_W-MODEL_SETUP_2ND_COLUMN-2, 8, TEXT_COLOR); + } + } + } + break; + } + } + } + + if (IS_RANGECHECK_ENABLE()) { + displayPopup("RSSI :"); + lcdDrawNumber(WARNING_LINE_X, WARNING_INFOLINE_Y, TELEMETRY_RSSI(), DBLSIZE|LEFT); + } + + return true; +} + +bool menuModelFailsafe(evt_t event) +{ + static bool longNames = false; + bool newLongNames = false; + uint8_t ch = 0; + + if (event == EVT_KEY_LONG(KEY_ENTER) && s_editMode) { + s_noHi = NO_HI_LEN; + g_model.moduleData[g_moduleIdx].failsafeChannels[m_posVert] = channelOutputs[m_posVert]; + storageDirty(EE_MODEL); + AUDIO_WARNING1(); + SEND_FAILSAFE_NOW(g_moduleIdx); + } + + SIMPLE_SUBMENU_NOTITLE(NUM_CHNOUT); + + #define COL_W (LCD_W/2) + const uint8_t SLIDER_W = 64; + // Column separator + // TODO lcd_vline(LCD_W/2, FH, LCD_H-FH); + + if (m_posVert >= 16) { + ch = 16; + } + + // TODO lcd_putsCenter(0, FAILSAFESET); + // TODO lcd_invert_line(0); + + for (int col=0; col<2; col++) { + coord_t x = col*COL_W+1; + + // Channels + for (int line=0; line<8; line++) { + coord_t y = 9+line*7; + int32_t val; + int ofs = (col ? 0 : 1); + + if (ch < g_model.moduleData[g_moduleIdx].channelsStart || ch >= NUM_CHANNELS(g_moduleIdx) + g_model.moduleData[g_moduleIdx].channelsStart) + val = 0; + else if (s_editMode && m_posVert == ch) + val = channelOutputs[ch]; + else + val = g_model.moduleData[g_moduleIdx].failsafeChannels[8*col+line]; + + // Channel name if present, number if not + uint8_t lenLabel = ZLEN(g_model.limitData[ch].name); + if (lenLabel > 4) { + newLongNames = longNames = true; + } + + if (lenLabel > 0) + lcdDrawTextWithLen(x+1-ofs, y, g_model.limitData[ch].name, sizeof(g_model.limitData[ch].name), ZCHAR | SMLSIZE); + else + putsChn(x+1-ofs, y, ch+1, SMLSIZE); + + // Value + LcdFlags flags = TINSIZE; + if (m_posVert == ch && !s_noHi) { + flags |= INVERS; + if (s_editMode) + flags |= BLINK; + } +#if defined(PPM_UNIT_US) + uint8_t wbar = (longNames ? SLIDER_W-10 : SLIDER_W); + lcdDrawNumber(x+COL_W-4-wbar-ofs, y, PPM_CH_CENTER(ch)+val/2, flags); +#elif defined(PPM_UNIT_PERCENT_PREC1) + uint8_t wbar = (longNames ? SLIDER_W-16 : SLIDER_W-6); + lcdDrawNumber(x+COL_W-4-wbar-ofs, y, calcRESXto1000(val), PREC1|flags); +#else + uint8_t wbar = (longNames ? SLIDER_W-10 : SLIDER_W); + lcdDrawNumber(x+COL_W-4-wbar-ofs, y, calcRESXto1000(val)/10, flags); +#endif + + // Gauge + lcdDrawRect(x+COL_W-3-wbar-ofs, y, wbar+1, 6); + uint16_t lim = g_model.extendedLimits ? 640*2 : 512*2; + uint8_t len = limit((uint8_t)1, uint8_t((abs(val) * wbar/2 + lim/2) / lim), uint8_t(wbar/2)); + coord_t x0 = (val>0) ? x+COL_W-ofs-3-wbar/2 : x+COL_W-ofs-2-wbar/2-len; + lcdDrawSolidFilledRect(x0, y+1, len, 4, LINE_COLOR); + ch++; + } + } + + longNames = newLongNames; + + return true; +} diff --git a/radio/src/gui/Horus/menu_model_telemetry.cpp b/radio/src/gui/Horus/menu_model_telemetry.cpp new file mode 100644 index 000000000..8d5897e8e --- /dev/null +++ b/radio/src/gui/Horus/menu_model_telemetry.cpp @@ -0,0 +1,859 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../../opentx.h" + +enum menuModelTelemetryItems { + ITEM_TELEMETRY_PROTOCOL_TYPE, + ITEM_TELEMETRY_RSSI_LABEL, + ITEM_TELEMETRY_RSSI_ALARM1, + ITEM_TELEMETRY_RSSI_ALARM2, + ITEM_TELEMETRY_SENSORS_LABEL, + ITEM_TELEMETRY_SENSOR1, + ITEM_TELEMETRY_SENSOR2, + ITEM_TELEMETRY_SENSOR3, + ITEM_TELEMETRY_SENSOR4, + ITEM_TELEMETRY_SENSOR5, + ITEM_TELEMETRY_SENSOR6, + ITEM_TELEMETRY_SENSOR7, + ITEM_TELEMETRY_SENSOR8, + ITEM_TELEMETRY_SENSOR9, + ITEM_TELEMETRY_SENSOR10, + ITEM_TELEMETRY_SENSOR11, + ITEM_TELEMETRY_SENSOR12, + ITEM_TELEMETRY_SENSOR13, + ITEM_TELEMETRY_SENSOR14, + ITEM_TELEMETRY_SENSOR15, + ITEM_TELEMETRY_SENSOR16, + ITEM_TELEMETRY_SENSOR17, + ITEM_TELEMETRY_SENSOR18, + ITEM_TELEMETRY_SENSOR19, + ITEM_TELEMETRY_SENSOR20, + ITEM_TELEMETRY_SENSOR21, + ITEM_TELEMETRY_SENSOR22, + ITEM_TELEMETRY_SENSOR23, + ITEM_TELEMETRY_SENSOR24, + ITEM_TELEMETRY_SENSOR25, + ITEM_TELEMETRY_SENSOR26, + ITEM_TELEMETRY_SENSOR27, + ITEM_TELEMETRY_SENSOR28, + ITEM_TELEMETRY_SENSOR29, + ITEM_TELEMETRY_SENSOR30, + ITEM_TELEMETRY_SENSOR31, + ITEM_TELEMETRY_SENSOR32, + ITEM_TELEMETRY_DISCOVER_SENSORS, + ITEM_TELEMETRY_NEW_SENSOR, + ITEM_TELEMETRY_DELETE_ALL_SENSORS, + ITEM_TELEMETRY_IGNORE_SENSOR_INSTANCE, +#if defined(VARIO) + ITEM_TELEMETRY_VARIO_LABEL, + ITEM_TELEMETRY_VARIO_SOURCE, + ITEM_TELEMETRY_VARIO_RANGE, + ITEM_TELEMETRY_VARIO_CENTER, +#endif + ITEM_TELEMETRY_TOP_BAR_LABEL, + ITEM_TELEMETRY_TOP_BAR_VOLTAGE, + ITEM_TELEMETRY_TOP_BAR_ALTITUDE, + ITEM_TELEMETRY_SCREEN_LABEL1, + ITEM_TELEMETRY_SCREEN_LINE1, + ITEM_TELEMETRY_SCREEN_LINE2, + ITEM_TELEMETRY_SCREEN_LINE3, + ITEM_TELEMETRY_SCREEN_LINE4, + ITEM_TELEMETRY_SCREEN_LABEL2, + ITEM_TELEMETRY_SCREEN_LINE5, + ITEM_TELEMETRY_SCREEN_LINE6, + ITEM_TELEMETRY_SCREEN_LINE7, + ITEM_TELEMETRY_SCREEN_LINE8, + ITEM_TELEMETRY_SCREEN_LABEL3, + ITEM_TELEMETRY_SCREEN_LINE9, + ITEM_TELEMETRY_SCREEN_LINE10, + ITEM_TELEMETRY_SCREEN_LINE11, + ITEM_TELEMETRY_SCREEN_LINE12, + ITEM_TELEMETRY_SCREEN_LABEL4, + ITEM_TELEMETRY_SCREEN_LINE13, + ITEM_TELEMETRY_SCREEN_LINE14, + ITEM_TELEMETRY_SCREEN_LINE15, + ITEM_TELEMETRY_SCREEN_LINE16, + ITEM_TELEMETRY_MAX +}; + +#define TELEM_COL1 10 +#define TELEM_COL2 150 +#define TELEM_COL3 300 +#define TELEM_BARS_COLMIN TELEM_COL2 +#define TELEM_BARS_COLMAX TELEM_COL3 +#define TELEM_SCRTYPE_COL TELEM_COL2 + +#define IF_FAS_OFFSET(x) x, +#define IS_RANGE_DEFINED(k) (g_model.frsky.channels[k].ratio > 0) + +#define SENSOR_ROWS(x) (isTelemetryFieldAvailable(x) ? (uint8_t)0 : HIDDEN_ROW) +#define SENSORS_ROWS LABEL(Sensors), SENSOR_ROWS(0), SENSOR_ROWS(1), SENSOR_ROWS(2), SENSOR_ROWS(3), SENSOR_ROWS(4), SENSOR_ROWS(5), SENSOR_ROWS(6), SENSOR_ROWS(7), SENSOR_ROWS(8), SENSOR_ROWS(9), SENSOR_ROWS(10), SENSOR_ROWS(11), SENSOR_ROWS(12), SENSOR_ROWS(13), SENSOR_ROWS(14), SENSOR_ROWS(15), SENSOR_ROWS(16), SENSOR_ROWS(17), SENSOR_ROWS(18), SENSOR_ROWS(19), SENSOR_ROWS(20), SENSOR_ROWS(21), SENSOR_ROWS(22), SENSOR_ROWS(23), SENSOR_ROWS(24), SENSOR_ROWS(25), SENSOR_ROWS(26), SENSOR_ROWS(27), SENSOR_ROWS(28), SENSOR_ROWS(29), SENSOR_ROWS(30), SENSOR_ROWS(31), 0, 0, 0, 0, +#if defined(VARIO) + #define VARIO_ROWS LABEL(Vario), 0, 1, 2, +#else + #define VARIO_ROWS +#endif +#define RSSI_ROWS LABEL(RSSI), 0, 0, +#if defined(LUA) + #define SCREEN_TYPE_ROWS 1 +#else + #define SCREEN_TYPE_ROWS 0 +#endif +#define VARIO_RANGE_ROWS 3 +#define TELEMETRY_TYPE_ROWS (g_model.moduleData[INTERNAL_MODULE].rfProtocol == RF_PROTO_OFF && g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_PPM) ? (uint8_t)0 : HIDDEN_ROW, + +#if defined(LUA) + #define TELEMETRY_SCREEN_LINE(x) ((TELEMETRY_SCREEN_TYPE(x) == TELEMETRY_SCREEN_TYPE_NONE || TELEMETRY_SCREEN_TYPE(x) == TELEMETRY_SCREEN_TYPE_SCRIPT) ? HIDDEN_ROW : (uint8_t)2) +#else + #define TELEMETRY_SCREEN_LINE(x) (TELEMETRY_SCREEN_TYPE(x) == TELEMETRY_SCREEN_TYPE_NONE ? HIDDEN_ROW : (uint8_t)2) +#endif +#define TELEMETRY_SCREEN_ROWS(x) SCREEN_TYPE_ROWS, TELEMETRY_SCREEN_LINE(x), TELEMETRY_SCREEN_LINE(x), TELEMETRY_SCREEN_LINE(x), TELEMETRY_SCREEN_LINE(x) +#define TELEMETRY_CURRENT_SCREEN(k) (k < ITEM_TELEMETRY_SCREEN_LABEL2 ? 0 : (k < ITEM_TELEMETRY_SCREEN_LABEL3 ? 1 : (k < ITEM_TELEMETRY_SCREEN_LABEL4 ? 2 : 3))) + +enum SensorFields { + SENSOR_FIELD_NAME, + SENSOR_FIELD_TYPE, + SENSOR_FIELD_ID, + SENSOR_FIELD_FORMULA=SENSOR_FIELD_ID, + SENSOR_FIELD_UNIT, + SENSOR_FIELD_PRECISION, + SENSOR_FIELD_PARAM1, + SENSOR_FIELD_PARAM2, + SENSOR_FIELD_PARAM3, + SENSOR_FIELD_PARAM4, + SENSOR_FIELD_AUTOOFFSET, + SENSOR_FIELD_ONLYPOSITIVE, + SENSOR_FIELD_FILTER, + SENSOR_FIELD_PERSISTENT, + SENSOR_FIELD_LOGS, + SENSOR_FIELD_MAX +}; + +bool isSensorUnit(int sensor, uint8_t unit) +{ + if (sensor <= 0 || sensor > MAX_SENSORS ) return true; + return g_model.telemetrySensors[--sensor].unit == unit; +} + +bool isCellsSensor(int sensor) +{ + return isSensorUnit(sensor, UNIT_CELLS); +} + +bool isGPSSensor(int sensor) +{ + return isSensorUnit(sensor, UNIT_GPS); +} + +bool isAltSensor(int sensor) +{ + return isSensorUnit(sensor, UNIT_DIST) || isSensorUnit(sensor, UNIT_FEET); +} + +bool isVoltsSensor(int sensor) +{ + return isSensorUnit(sensor, UNIT_VOLTS) || isSensorUnit(sensor, UNIT_CELLS); +} + +bool isCurrentSensor(int sensor) +{ + return isSensorUnit(sensor, UNIT_AMPS); +} + +bool isSensorAvailable(int sensor) +{ + if (sensor == 0) + return true; + else + return isTelemetryFieldAvailable(abs(sensor) - 1); +} + +#define SENSOR_2ND_COLUMN 140 +#define SENSOR_3RD_COLUMN 180 + +#define SENSOR_UNIT_ROWS ((sensor->type == TELEM_TYPE_CALCULATED && (sensor->formula == TELEM_FORMULA_DIST)) || sensor->isConfigurable() ? (uint8_t)0 : HIDDEN_ROW) +#define SENSOR_PREC_ROWS (sensor->isPrecConfigurable() && sensor->unit != UNIT_FAHRENHEIT ? (uint8_t)0 : HIDDEN_ROW) +#define SENSOR_PARAM1_ROWS (sensor->unit >= UNIT_FIRST_VIRTUAL ? HIDDEN_ROW : (uint8_t)0) +#define SENSOR_PARAM2_ROWS (sensor->unit == UNIT_GPS || sensor->unit == UNIT_DATETIME || sensor->unit == UNIT_CELLS || (sensor->type==TELEM_TYPE_CALCULATED && (sensor->formula==TELEM_FORMULA_CONSUMPTION || sensor->formula==TELEM_FORMULA_TOTALIZE)) ? HIDDEN_ROW : (uint8_t)0) +#define SENSOR_PARAM3_ROWS (sensor->type == TELEM_TYPE_CALCULATED && sensor->formula < TELEM_FORMULA_MULTIPLY) ? (uint8_t)0 : HIDDEN_ROW +#define SENSOR_PARAM4_ROWS (sensor->type == TELEM_TYPE_CALCULATED && sensor->formula < TELEM_FORMULA_MULTIPLY) ? (uint8_t)0 : HIDDEN_ROW +#define SENSOR_AUTOOFFSET_ROWS (sensor->unit != UNIT_RPMS && sensor->isConfigurable() ? (uint8_t)0 : HIDDEN_ROW) +#define SENSOR_ONLYPOS_ROWS (sensor->isConfigurable() ? (uint8_t)0 : HIDDEN_ROW) +#define SENSOR_FILTER_ROWS (sensor->isConfigurable() ? (uint8_t)0 : HIDDEN_ROW) +#define SENSOR_PERSISTENT_ROWS ((sensor->type == TELEM_TYPE_CALCULATED && sensor->formula == TELEM_FORMULA_CONSUMPTION) || sensor->isConfigurable() ? (uint8_t)0 : HIDDEN_ROW) + +bool menuModelSensor(evt_t event) +{ + TelemetrySensor * sensor = &g_model.telemetrySensors[s_currIdx]; + + SUBMENU(STR_MENUSENSOR, SENSOR_FIELD_MAX, DEFAULT_SCROLLBAR_X, { 0, 0, sensor->type == TELEM_TYPE_CALCULATED ? (uint8_t)0 : (uint8_t)1, SENSOR_UNIT_ROWS, SENSOR_PREC_ROWS, SENSOR_PARAM1_ROWS, SENSOR_PARAM2_ROWS, SENSOR_PARAM3_ROWS, SENSOR_PARAM4_ROWS, 0 }); + + // lcdDrawNumber(MENUS_MARGIN_LEFT+getTextWidth(TR_MENUSENSOR)+5, MENU_FOOTER_TOP, s_currIdx+1, HEADER_COLOR|LEFT); + // putsTelemetryChannelValue(SENSOR_2ND_COLUMN, MENU_FOOTER_TOP, s_currIdx, getValue(MIXSRC_FIRST_TELEM+3*s_currIdx), HEADER_COLOR|LEFT); + + int sub = m_posVert; + + for (unsigned int i=0; i= (int)DIM(mstate_tab)) { + return true; + } + } + } + + LcdFlags attr = (sub==k ? (s_editMode>0 ? BLINK|INVERS : INVERS) : 0); + + switch (k) { + + case SENSOR_FIELD_NAME: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_NAME); + editName(SENSOR_2ND_COLUMN, y, sensor->label, TELEM_LABEL_LEN, event, attr); + break; + + case SENSOR_FIELD_TYPE: + lcdDrawText(MENUS_MARGIN_LEFT, y, NO_INDENT(STR_TYPE)); + sensor->type = selectMenuItem(SENSOR_2ND_COLUMN, y, STR_VSENSORTYPES, sensor->type, 0, 1, attr, event); + if (attr && checkIncDec_Ret) { + sensor->instance = 0; + if (sensor->type == TELEM_TYPE_CALCULATED) { + sensor->param = 0; + sensor->filter = 0; + sensor->autoOffset = 0; + } + } + break; + + case SENSOR_FIELD_ID: + if (sensor->type == TELEM_TYPE_CUSTOM) { + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_ID); + lcd_outhex4(SENSOR_2ND_COLUMN, y, sensor->id, LEFT|(m_posHorz==0 ? attr : 0)); + lcdDrawNumber(SENSOR_3RD_COLUMN, y, sensor->instance, LEFT|(m_posHorz==1 ? attr : 0)); + if (attr) { + switch (m_posHorz) { + case 0: + sensor->id = checkIncDec(event, sensor->id, 0x0000, 0xffff, INCDEC_REP10|NO_INCDEC_MARKS); + break; + + case 1: + CHECK_INCDEC_MODELVAR_ZERO(event, sensor->instance, 0xff); + break; + } + } + } + else { + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_FORMULA); + sensor->formula = selectMenuItem(SENSOR_2ND_COLUMN, y, STR_VFORMULAS, sensor->formula, 0, TELEM_FORMULA_LAST, attr, event); + if (attr && checkIncDec_Ret) { + sensor->param = 0; + if (sensor->formula == TELEM_FORMULA_CELL) { + sensor->unit = UNIT_VOLTS; + sensor->prec = 2; + } + else if (sensor->formula == TELEM_FORMULA_DIST) { + sensor->unit = UNIT_DIST; + sensor->prec = 0; + } + else if (sensor->formula == TELEM_FORMULA_CONSUMPTION) { + sensor->unit = UNIT_MAH; + sensor->prec = 0; + } + } + } + break; + + case SENSOR_FIELD_UNIT: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_UNIT); + // TODO flash saving with selectMenuItem where I copied those 2 lines? + lcdDrawTextAtIndex(SENSOR_2ND_COLUMN, y, STR_VTELEMUNIT, sensor->unit, attr); + if (attr) { + CHECK_INCDEC_MODELVAR_ZERO(event, sensor->unit, UNIT_MAX); + if (checkIncDec_Ret) { + if (sensor->unit == UNIT_FAHRENHEIT) { + sensor->prec = 0; + } + telemetryItems[s_currIdx].clear(); + } + } + break; + + case SENSOR_FIELD_PRECISION: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_PRECISION); + sensor->prec = selectMenuItem(SENSOR_2ND_COLUMN, y, STR_VPREC, sensor->prec, 0, 2, attr, event); + if (attr && checkIncDec_Ret) { + telemetryItems[s_currIdx].clear(); + } + break; + + case SENSOR_FIELD_PARAM1: + if (sensor->type == TELEM_TYPE_CALCULATED) { + if (sensor->formula == TELEM_FORMULA_CELL) { + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_CELLSENSOR); + putsMixerSource(SENSOR_2ND_COLUMN, y, sensor->cell.source ? MIXSRC_FIRST_TELEM+3*(sensor->cell.source-1) : 0, attr); + if (attr) { + sensor->cell.source = checkIncDec(event, sensor->cell.source, 0, MAX_SENSORS, EE_MODEL|NO_INCDEC_MARKS, isCellsSensor); + } + break; + } + else if (sensor->formula == TELEM_FORMULA_DIST) { + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_GPSSENSOR); + putsMixerSource(SENSOR_2ND_COLUMN, y, sensor->dist.gps ? MIXSRC_FIRST_TELEM+3*(sensor->dist.gps-1) : 0, attr); + if (attr) { + sensor->dist.gps = checkIncDec(event, sensor->dist.gps, 0, MAX_SENSORS, EE_MODEL|NO_INCDEC_MARKS, isGPSSensor); + } + break; + } + else if (sensor->formula == TELEM_FORMULA_CONSUMPTION) { + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_CURRENTSENSOR); + putsMixerSource(SENSOR_2ND_COLUMN, y, sensor->consumption.source ? MIXSRC_FIRST_TELEM+3*(sensor->consumption.source-1) : 0, attr); + if (attr) { + sensor->consumption.source = checkIncDec(event, sensor->consumption.source, 0, MAX_SENSORS, EE_MODEL|NO_INCDEC_MARKS, isTelemetryFieldAvailable); + } + break; + } + else if (sensor->formula == TELEM_FORMULA_TOTALIZE) { + lcdDrawText(MENUS_MARGIN_LEFT, y, NO_INDENT(STR_SOURCE)); + putsMixerSource(SENSOR_2ND_COLUMN, y, sensor->consumption.source ? MIXSRC_FIRST_TELEM+3*(sensor->consumption.source-1) : 0, attr); + if (attr) { + sensor->consumption.source = checkIncDec(event, sensor->consumption.source, 0, MAX_SENSORS, EE_MODEL|NO_INCDEC_MARKS, isTelemetryFieldComparisonAvailable); + } + break; + } + } + else { + if (sensor->unit == UNIT_RPMS) { + lcdDrawText(MENUS_MARGIN_LEFT, y, NO_INDENT(STR_BLADES)); + if (attr) sensor->custom.ratio = checkIncDec(event, sensor->custom.ratio, 1, 30000, EE_MODEL|NO_INCDEC_MARKS|INCDEC_REP10); + lcdDrawNumber(SENSOR_2ND_COLUMN, y, sensor->custom.ratio, LEFT|attr); + break; + } + else { + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_RATIO); + if (attr) sensor->custom.ratio = checkIncDec(event, sensor->custom.ratio, 0, 30000, EE_MODEL|NO_INCDEC_MARKS|INCDEC_REP10); + if (sensor->custom.ratio == 0) + lcdDrawText(SENSOR_2ND_COLUMN, y, "-", attr); + else + lcdDrawNumber(SENSOR_2ND_COLUMN, y, sensor->custom.ratio, LEFT|attr|PREC1); + break; + } + } + // no break + + case SENSOR_FIELD_PARAM2: + if (sensor->type == TELEM_TYPE_CALCULATED) { + if (sensor->formula == TELEM_FORMULA_CELL) { + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_CELLINDEX); + sensor->cell.index = selectMenuItem(SENSOR_2ND_COLUMN, y, STR_VCELLINDEX, sensor->cell.index, 0, 8, attr, event); + break; + } + else if (sensor->formula == TELEM_FORMULA_DIST) { + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_ALTSENSOR); + putsMixerSource(SENSOR_2ND_COLUMN, y, sensor->dist.alt ? MIXSRC_FIRST_TELEM+3*(sensor->dist.alt-1) : 0, attr); + if (attr) { + sensor->dist.alt = checkIncDec(event, sensor->dist.alt, 0, MAX_SENSORS, EE_MODEL|NO_INCDEC_MARKS, isAltSensor); + } + break; + } + } + else if (sensor->unit == UNIT_RPMS) { + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_MULTIPLIER); + if (attr) sensor->custom.offset = checkIncDec(event, sensor->custom.offset, 1, 30000, EE_MODEL|NO_INCDEC_MARKS|INCDEC_REP10); + lcdDrawNumber(SENSOR_2ND_COLUMN, y, sensor->custom.offset, LEFT|attr); + break; + } + else { + lcdDrawText(MENUS_MARGIN_LEFT, y, NO_INDENT(STR_OFFSET)); + if (attr) sensor->custom.offset = checkIncDec(event, sensor->custom.offset, -30000, +30000, EE_MODEL|NO_INCDEC_MARKS|INCDEC_REP10); + if (sensor->prec > 0) attr |= (sensor->prec == 2 ? PREC2 : PREC1); + lcdDrawNumber(SENSOR_2ND_COLUMN, y, sensor->custom.offset, LEFT|attr); + break; + } + // no break + + case SENSOR_FIELD_PARAM3: + // no break + + case SENSOR_FIELD_PARAM4: + { + putsStrIdx(MENUS_MARGIN_LEFT, y, NO_INDENT(STR_SOURCE), k-SENSOR_FIELD_PARAM1+1); + int8_t & source = sensor->calc.sources[k-SENSOR_FIELD_PARAM1]; + if (attr) { + source = checkIncDec(event, source, -MAX_SENSORS, MAX_SENSORS, EE_MODEL|NO_INCDEC_MARKS, isSensorAvailable); + } + if (source < 0) { + lcdDrawText(SENSOR_2ND_COLUMN, y, "-", attr); + putsMixerSource(SENSOR_2ND_COLUMN+5, y, MIXSRC_FIRST_TELEM+3*(-1-source), attr); + } + else { + putsMixerSource(SENSOR_2ND_COLUMN, y, source ? MIXSRC_FIRST_TELEM+3*(source-1) : 0, attr); + } + break; + } + + case SENSOR_FIELD_AUTOOFFSET: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_AUTOOFFSET); + onoffMenuItem(sensor->autoOffset, SENSOR_2ND_COLUMN, y, attr, event); + break; + + case SENSOR_FIELD_ONLYPOSITIVE: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_ONLYPOSITIVE); + onoffMenuItem(sensor->onlyPositive, SENSOR_2ND_COLUMN, y, attr, event); + break; + + case SENSOR_FIELD_FILTER: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_FILTER); + onoffMenuItem(sensor->filter, SENSOR_2ND_COLUMN, y, attr, event); + break; + + case SENSOR_FIELD_PERSISTENT: + lcdDrawText(MENUS_MARGIN_LEFT, y, NO_INDENT(STR_PERSISTENT)); + onoffMenuItem(sensor->persistent, SENSOR_2ND_COLUMN, y, attr, event); + break; + + case SENSOR_FIELD_LOGS: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_LOGS); + onoffMenuItem(sensor->logs, SENSOR_2ND_COLUMN, y, attr, event); + if (attr && checkIncDec_Ret) { + closeLogs(); + } + break; + + } + } + + return true; +} + +void onSensorMenu(const char *result) +{ + int index = m_posVert - ITEM_TELEMETRY_SENSOR1; + + if (index < MAX_SENSORS) { + if (result == STR_EDIT) { + pushMenu(menuModelSensor); + } + else if (result == STR_DELETE) { + delTelemetryIndex(index); + index += 1; + if (index= 0) { + TelemetrySensor & sourceSensor = g_model.telemetrySensors[index]; + TelemetrySensor & newSensor = g_model.telemetrySensors[newIndex]; + newSensor = sourceSensor; + TelemetryItem & sourceItem = telemetryItems[index]; + TelemetryItem & newItem = telemetryItems[newIndex]; + newItem = sourceItem; + storageDirty(EE_MODEL); + } + else { + POPUP_WARNING(STR_TELEMETRYFULL); + } + } + } +} + +#if defined(LUA) +void onTelemetryScriptFileSelectionMenu(const char *result) +{ + int sub = m_posVert; + int screenIndex = TELEMETRY_CURRENT_SCREEN(sub); + + if (result == STR_UPDATE_LIST) { + if (!sdListFiles(SCRIPTS_TELEM_PATH, SCRIPTS_EXT, sizeof(g_model.frsky.screens[screenIndex].script.file), NULL)) { + POPUP_WARNING(STR_NO_SCRIPTS_ON_SD); + s_menu_flags = 0; + } + } + else { + // The user choosed a file in the list + memcpy(g_model.frsky.screens[screenIndex].script.file, result, sizeof(g_model.frsky.screens[screenIndex].script.file)); + storageDirty(EE_MODEL); + LUA_LOAD_MODEL_SCRIPTS(); + } +} +#endif + +bool menuModelTelemetry(evt_t event) +{ + if (s_warning_result) { + s_warning_result = 0; + for (int i=0; i0) ? BLINK|INVERS : INVERS); + LcdFlags attr = (sub == k ? blink : 0); + + if (k>=ITEM_TELEMETRY_SENSOR1 && ktype == TELEM_TYPE_CUSTOM && !g_model.ignoreSensorIds) { + lcdDrawNumber(TELEM_COL3, y, sensor->instance, LEFT); + } + if (attr) { + s_editMode = 0; + s_currIdx = index; + if (event == EVT_KEY_LONG(KEY_ENTER)) { + killEvents(event); + MENU_ADD_ITEM(STR_EDIT); + MENU_ADD_ITEM(STR_COPY); + MENU_ADD_ITEM(STR_DELETE); + menuHandler = onSensorMenu; + } + else if (event == EVT_KEY_BREAK(KEY_ENTER)) { + pushMenu(menuModelSensor); + } + } + } + else + + switch (k) { + case ITEM_TELEMETRY_PROTOCOL_TYPE: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_TELEMETRY_TYPE); + g_model.telemetryProtocol = selectMenuItem(TELEM_COL2, y, "\017FrSky S.PORT\0 FrSky D\0 FrSky D (cable)", g_model.telemetryProtocol, PROTOCOL_TELEMETRY_FIRST, PROTOCOL_FRSKY_D, attr, event); + break; + + case ITEM_TELEMETRY_SENSORS_LABEL: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_TELEMETRY_SENSORS); + lcdDrawText(TELEM_COL2, y, STR_VALUE, 0); + if (!g_model.ignoreSensorIds) { + lcdDrawText(TELEM_COL3, y, STR_ID, 0); + } + break; + + case ITEM_TELEMETRY_DISCOVER_SENSORS: + lcdDrawText(MENUS_MARGIN_LEFT, y, allowNewSensors ? STR_STOP_DISCOVER_SENSORS : STR_DISCOVER_SENSORS, attr); + if (attr && event==EVT_KEY_BREAK(KEY_ENTER)) { + s_editMode = 0; + allowNewSensors = !allowNewSensors; + } + break; + + case ITEM_TELEMETRY_NEW_SENSOR: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_TELEMETRY_NEWSENSOR, attr); + if (attr && event==EVT_KEY_BREAK(KEY_ENTER)) { + s_editMode = 0; + int res = availableTelemetryIndex(); + if (res >= 0) { + s_currIdx = res; + pushMenu(menuModelSensor); + } + else { + POPUP_WARNING(STR_TELEMETRYFULL); + } + } + break; + + case ITEM_TELEMETRY_DELETE_ALL_SENSORS: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_DELETE_ALL_SENSORS, attr); + if (attr) + s_editMode = 0; + if (attr && event==EVT_KEY_LONG(KEY_ENTER)) { + killEvents(KEY_ENTER); + POPUP_CONFIRMATION(STR_CONFIRMDELETE); + } + break; + + case ITEM_TELEMETRY_IGNORE_SENSOR_INSTANCE: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_IGNORE_INSTANCE); + onoffMenuItem(g_model.ignoreSensorIds, TELEM_COL2, y, attr, event); + break; + + case ITEM_TELEMETRY_RSSI_LABEL: + lcdDrawText(MENUS_MARGIN_LEFT, y, PSTR("RSSI")); + break; + + case ITEM_TELEMETRY_RSSI_ALARM1: + case ITEM_TELEMETRY_RSSI_ALARM2: { + uint8_t alarm = k-ITEM_TELEMETRY_RSSI_ALARM1; + lcdDrawText(MENUS_MARGIN_LEFT, y, (alarm==0 ? STR_LOWALARM : STR_CRITICALALARM)); + lcdDrawNumber(TELEM_COL2, y, getRssiAlarmValue(alarm), LEFT|attr, 3); + if (attr && s_editMode>0) { + CHECK_INCDEC_MODELVAR(event, g_model.frsky.rssiAlarms[alarm].value, -30, 30); + } + break; + } + +#if defined(VARIO) + case ITEM_TELEMETRY_VARIO_LABEL: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_VARIO); + break; + + case ITEM_TELEMETRY_VARIO_SOURCE: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_SOURCE); + putsMixerSource(TELEM_COL2, y, g_model.frsky.varioSource ? MIXSRC_FIRST_TELEM+3*(g_model.frsky.varioSource-1) : 0, attr); + if (attr) { + g_model.frsky.varioSource = checkIncDec(event, g_model.frsky.varioSource, 0, MAX_SENSORS, EE_MODEL|NO_INCDEC_MARKS, isSensorAvailable); + } + break; + + case ITEM_TELEMETRY_VARIO_RANGE: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_RANGE); + lcdDrawNumber(TELEM_COL2, y, -10+g_model.frsky.varioMin, (m_posHorz==0 ? attr : 0)|LEFT); + lcdDrawNumber(TELEM_COL2+100, y, 10+g_model.frsky.varioMax, (m_posHorz==1 ? attr : 0)|LEFT); + if (attr && s_editMode>0) { + switch (m_posHorz) { + case 0: + CHECK_INCDEC_MODELVAR(event, g_model.frsky.varioMin, -7, 7); + break; + case 1: + CHECK_INCDEC_MODELVAR(event, g_model.frsky.varioMax, -7, 7); + break; + } + } + break; + + case ITEM_TELEMETRY_VARIO_CENTER: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_CENTER); + lcdDrawNumber(TELEM_COL2, y, -5+g_model.frsky.varioCenterMin, (m_posHorz==0 ? attr : 0)|PREC1|LEFT); + lcdDrawNumber(TELEM_COL2+100, y, 5+g_model.frsky.varioCenterMax, (m_posHorz==1 ? attr : 0)|PREC1|LEFT); + lcdDrawTextAtIndex(TELEM_COL3, y, STR_VVARIOCENTER, g_model.frsky.varioCenterSilent, (m_posHorz==2 ? attr : 0)); + if (attr && s_editMode>0) { + switch (m_posHorz) { + case 0: + CHECK_INCDEC_MODELVAR(event, g_model.frsky.varioCenterMin, -16, 5+min(10, g_model.frsky.varioCenterMax+5)); + break; + case 1: + CHECK_INCDEC_MODELVAR(event, g_model.frsky.varioCenterMax, -5+max(-10, g_model.frsky.varioCenterMin-5), +15); + break; + case 2: + CHECK_INCDEC_MODELVAR_ZERO(event, g_model.frsky.varioCenterSilent, 1); + break; + } + } + break; +#endif + + case ITEM_TELEMETRY_TOP_BAR_LABEL: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_TOP_BAR); + break; + + case ITEM_TELEMETRY_TOP_BAR_VOLTAGE: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_VOLTAGE); + putsMixerSource(TELEM_COL2, y, g_model.frsky.voltsSource ? MIXSRC_FIRST_TELEM+3*(g_model.frsky.voltsSource-1) : 0, attr); + if (attr) { + g_model.frsky.voltsSource = checkIncDec(event, g_model.frsky.voltsSource, 0, MAX_SENSORS, EE_MODEL|NO_INCDEC_MARKS, isVoltsSensor); + } + break; + + case ITEM_TELEMETRY_TOP_BAR_ALTITUDE: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_ALTITUDE); + putsMixerSource(TELEM_COL2, y, g_model.frsky.altitudeSource ? MIXSRC_FIRST_TELEM+3*(g_model.frsky.altitudeSource-1) : 0, attr); + if (attr) { + g_model.frsky.altitudeSource = checkIncDec(event, g_model.frsky.altitudeSource, 0, MAX_SENSORS, EE_MODEL|NO_INCDEC_MARKS, isAltSensor); + } + break; + + case ITEM_TELEMETRY_SCREEN_LABEL1: + case ITEM_TELEMETRY_SCREEN_LABEL2: + case ITEM_TELEMETRY_SCREEN_LABEL3: + case ITEM_TELEMETRY_SCREEN_LABEL4: + { + uint8_t screenIndex = TELEMETRY_CURRENT_SCREEN(k); + putsStrIdx(MENUS_MARGIN_LEFT, y, STR_SCREEN, screenIndex+1); + TelemetryScreenType oldScreenType = TELEMETRY_SCREEN_TYPE(screenIndex); + TelemetryScreenType newScreenType = (TelemetryScreenType)selectMenuItem(TELEM_SCRTYPE_COL, y, STR_VTELEMSCREENTYPE, oldScreenType, 0, TELEMETRY_SCREEN_TYPE_MAX, (m_posHorz==0 ? attr : 0), event); + if (newScreenType != oldScreenType) { + g_model.frsky.screensType = (g_model.frsky.screensType & (~(0x03 << (2*screenIndex)))) | (newScreenType << (2*screenIndex)); + memset(&g_model.frsky.screens[screenIndex], 0, sizeof(g_model.frsky.screens[screenIndex])); + } +#if defined(LUA) + if (newScreenType == TELEMETRY_SCREEN_TYPE_SCRIPT) { + TelemetryScriptData & scriptData = g_model.frsky.screens[screenIndex].script; + + // TODO better function name for --- + // TODO function for these lines + if (ZEXIST(scriptData.file)) + lcdDrawTextWithLen(TELEM_SCRTYPE_COL+70, y, scriptData.file, sizeof(scriptData.file), (m_posHorz==1 ? attr : 0)); + else + lcdDrawTextAtIndex(TELEM_SCRTYPE_COL+70, y, STR_VCSWFUNC, 0, (m_posHorz==1 ? attr : 0)); + + if (m_posHorz==1 && attr && event==EVT_KEY_BREAK(KEY_ENTER) && READ_ONLY_UNLOCKED()) { + s_editMode = 0; + if (sdListFiles(SCRIPTS_TELEM_PATH, SCRIPTS_EXT, sizeof(g_model.frsky.screens[screenIndex].script.file), g_model.frsky.screens[screenIndex].script.file)) { + menuHandler = onTelemetryScriptFileSelectionMenu; + } + else { + POPUP_WARNING(STR_NO_SCRIPTS_ON_SD); + s_menu_flags = 0; + } + } + } + else if (attr) { + MOVE_CURSOR_FROM_HERE(); + } +#endif + break; + } + + case ITEM_TELEMETRY_SCREEN_LINE1: + case ITEM_TELEMETRY_SCREEN_LINE2: + case ITEM_TELEMETRY_SCREEN_LINE3: + case ITEM_TELEMETRY_SCREEN_LINE4: + case ITEM_TELEMETRY_SCREEN_LINE5: + case ITEM_TELEMETRY_SCREEN_LINE6: + case ITEM_TELEMETRY_SCREEN_LINE7: + case ITEM_TELEMETRY_SCREEN_LINE8: + case ITEM_TELEMETRY_SCREEN_LINE9: + case ITEM_TELEMETRY_SCREEN_LINE10: + case ITEM_TELEMETRY_SCREEN_LINE11: + case ITEM_TELEMETRY_SCREEN_LINE12: + case ITEM_TELEMETRY_SCREEN_LINE13: + case ITEM_TELEMETRY_SCREEN_LINE14: + case ITEM_TELEMETRY_SCREEN_LINE15: + case ITEM_TELEMETRY_SCREEN_LINE16: + { + uint8_t screenIndex, lineIndex; + if (k < ITEM_TELEMETRY_SCREEN_LABEL2) { + screenIndex = 0; + lineIndex = k-ITEM_TELEMETRY_SCREEN_LINE1; + } + else if (k >= ITEM_TELEMETRY_SCREEN_LABEL4) { + screenIndex = 3; + lineIndex = k-ITEM_TELEMETRY_SCREEN_LINE13; + } + else if (k >= ITEM_TELEMETRY_SCREEN_LABEL3) { + screenIndex = 2; + lineIndex = k-ITEM_TELEMETRY_SCREEN_LINE9; + } + else { + screenIndex = 1; + lineIndex = k-ITEM_TELEMETRY_SCREEN_LINE5; + } + +#if defined(GAUGES) + if (IS_BARS_SCREEN(screenIndex)) { + FrSkyBarData & bar = g_model.frsky.screens[screenIndex].bars[lineIndex]; + source_t barSource = bar.source; + putsMixerSource(MENUS_MARGIN_LEFT+INDENT_WIDTH, y, barSource, (m_posHorz==0 ? attr : 0)); + int barMax = getMaximumValue(barSource); + int barMin = -barMax; + if (barSource) { + if (barSource <= MIXSRC_LAST_CH) { + putsChannelValue(MENUS_MARGIN_LEFT+INDENT_WIDTH+100, y, barSource, calc100toRESX(bar.barMin), (m_posHorz==1 ? attr : 0) | LEFT); + putsChannelValue(MENUS_MARGIN_LEFT+INDENT_WIDTH+200, y, barSource, calc100toRESX(bar.barMax), (m_posHorz==2 ? attr : 0) | LEFT); + } + else { + putsChannelValue(MENUS_MARGIN_LEFT+INDENT_WIDTH+100, y, barSource, bar.barMin, (m_posHorz==1 ? attr : 0) | LEFT); + putsChannelValue(MENUS_MARGIN_LEFT+INDENT_WIDTH+200, y, barSource, bar.barMax, (m_posHorz==2 ? attr : 0) | LEFT); + } + } + else if (attr) { + MOVE_CURSOR_FROM_HERE(); + } + if (attr && s_editMode>0) { + switch (m_posHorz) { + case 0: + bar.source = checkIncDec(event, barSource, 0, MIXSRC_LAST_TELEM, EE_MODEL|INCDEC_SOURCE|NO_INCDEC_MARKS, isSourceAvailable); + if (checkIncDec_Ret) { + if (barSource <= MIXSRC_LAST_CH) { + bar.barMin = -100; + bar.barMax = 100; + } + else { + bar.barMin = 0; + bar.barMax = 0; + } + } + break; + case 1: + bar.barMin = checkIncDec(event, bar.barMin, barMin, bar.barMax, EE_MODEL|NO_INCDEC_MARKS); + break; + case 2: + bar.barMax = checkIncDec(event, bar.barMax, bar.barMin, barMax, EE_MODEL|NO_INCDEC_MARKS); + break; + } + } + } + else +#endif + { + for (int c=0; c0) { + value = checkIncDec(event, value, 0, MIXSRC_LAST_TELEM, EE_MODEL|INCDEC_SOURCE|NO_INCDEC_MARKS, isSourceAvailable); + } + } + if (attr && m_posHorz == NUM_LINE_ITEMS) { + REPEAT_LAST_CURSOR_MOVE(); + } + } + break; + } + } + } + + return true; +} diff --git a/radio/src/gui/Horus/menus.cpp b/radio/src/gui/Horus/menus.cpp new file mode 100644 index 000000000..a0bbf645b --- /dev/null +++ b/radio/src/gui/Horus/menus.cpp @@ -0,0 +1,93 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../../opentx.h" + +MenuFuncP g_menuStack[5]; +evt_t menuEvent = 0; +uint8_t g_menuPos[4]; +uint8_t g_menuStackPtr = 0; + +void popMenu() +{ + assert(g_menuStackPtr>0); + g_menuStackPtr = g_menuStackPtr-1; + menuEvent = EVT_ENTRY_UP; +} + +void chainMenu(MenuFuncP newMenu) +{ + g_menuStack[g_menuStackPtr] = newMenu; + menuEvent = EVT_ENTRY; +} + +void pushMenu(MenuFuncP newMenu) +{ + killEvents(KEY_ENTER); + + if (g_menuStackPtr == 0) { + if (newMenu == menuGeneralSetup) + g_menuPos[0] = 1; + if (newMenu == menuModelSetup) + g_menuPos[0] = 0; + } + else { + g_menuPos[g_menuStackPtr] = m_posVert; + } + + g_menuStackPtr++; + + assert(g_menuStackPtr < DIM(g_menuStack)); + + g_menuStack[g_menuStackPtr] = newMenu; + menuEvent = EVT_ENTRY; +} + +bool menuModelNotes(evt_t event) +{ + if (event == EVT_ENTRY) { + strcpy(s_text_file, MODELS_PATH "/"); + char *buf = strcat_currentmodelname(&s_text_file[sizeof(MODELS_PATH)]); + strcpy(buf, TEXT_EXT); + } + + return menuTextView(event); +} + +void pushModelNotes() +{ + pushMenu(menuModelNotes); +} diff --git a/radio/src/gui/Horus/menus.h b/radio/src/gui/Horus/menus.h new file mode 100644 index 000000000..083bcabd7 --- /dev/null +++ b/radio/src/gui/Horus/menus.h @@ -0,0 +1,323 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#ifndef _MENUS_H_ +#define _MENUS_H_ + +#include "../../keys.h" + +#define NO_HI_LEN 25 + +#if defined(TRANSLATIONS_FR) + #define MENU_COLUMNS 1 + #define COLUMN_X 0 +#else + #define MENU_COLUMNS 2 +#endif + +#define MENU_COLUMN2_X 280 + +typedef int16_t vertpos_t; + +typedef evt_t & check_event_t; +#define horzpos_t int8_t + +extern uint8_t menuPageIndex; +extern uint8_t menuPageCount; +extern uint16_t linesCount; +extern vertpos_t m_posVert; +extern horzpos_t m_posHorz; +extern vertpos_t s_pgOfs; +extern uint8_t s_noHi; +extern uint8_t calibrationState; + +void drawCheckBox(coord_t x, coord_t y, uint8_t value, LcdFlags attr); + +typedef bool (*MenuFuncP)(evt_t event); +extern const MenuFuncP menuTabModel[]; +extern const MenuFuncP menuTabGeneral[]; + +extern MenuFuncP g_menuStack[5]; +extern uint8_t g_menuPos[4]; +extern uint8_t g_menuStackPtr; +extern evt_t menuEvent; + +/// goto given Menu, but substitute current menu in menuStack +void chainMenu(MenuFuncP newMenu); +/// goto given Menu, store current menu in menuStack +void pushMenu(MenuFuncP newMenu); +/// return to last menu in menustack +void popMenu(); + +bool menuFirstCalib(evt_t event); + +bool menuMainView(evt_t event); +bool menuGeneralDiagAna(evt_t event); +bool menuGeneralSetup(evt_t event); +bool menuGeneralCalib(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); +bool menuMainViewChannelsMonitor(evt_t event); +bool menuChannelsView(evt_t event); +bool menuChannelsView(evt_t event); +bool menuTextView(evt_t event); + +#if defined(DEBUG_TRACE_BUFFER) +void menuTraceBuffer(evt_t event); +#endif + +extern int8_t checkIncDec_Ret; // global helper vars + +#define EDIT_SELECT_MENU -1 +#define EDIT_SELECT_FIELD 0 +#define EDIT_MODIFY_FIELD 1 +#define EDIT_MODIFY_STRING 2 +extern int8_t s_editMode; // global editmode + +// checkIncDec flags +#define EE_GENERAL 0x01 +#define EE_MODEL 0x02 +#define NO_INCDEC_MARKS 0x04 +#define INCDEC_SWITCH 0x08 +#define INCDEC_SOURCE 0x10 +#define INCDEC_REP10 0x40 +#define NO_DBLKEYS 0x80 + +// mawrow special values +#define TITLE_ROW ((uint8_t)-1) +#define HIDDEN_ROW ((uint8_t)-2) + +struct CheckIncDecStops { + const int count; + const int stops[]; + int min() const + { + return stops[0]; + } + int max() const + { + return stops[count-1]; + } + bool contains(int value) const + { + for (int i=0; i 0) REPEAT_LAST_CURSOR_MOVE() + +#define MENU_FIRST_LINE_EDIT (MAXCOL((uint16_t)0) >= HIDDEN_ROW ? (MAXCOL((uint16_t)1) >= HIDDEN_ROW ? 2 : 1) : 0) +#define POS_HORZ_INIT(posVert) ((COLATTR(posVert) & NAVIGATION_LINE_BY_LINE) ? -1 : 0) +#define EDIT_MODE_INIT 0 // TODO enum + +typedef int (*FnFuncP) (int x); +void DrawFunction(FnFuncP fn, int offset=0); + +#endif // _MENUS_H_ diff --git a/radio/src/gui/Horus/navigation.cpp b/radio/src/gui/Horus/navigation.cpp new file mode 100644 index 000000000..a8aca4edd --- /dev/null +++ b/radio/src/gui/Horus/navigation.cpp @@ -0,0 +1,555 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../../opentx.h" + +vertpos_t s_pgOfs; +vertpos_t m_posVert; +horzpos_t m_posHorz; +int8_t s_editMode; +uint8_t s_noHi; +uint8_t calibrationState; // TODO rename this variable + +#if defined(AUTOSWITCH) +int8_t checkIncDecMovedSwitch(int8_t val) +{ + if (s_editMode>0) { + int8_t swtch = getMovedSwitch(); + if (swtch) { + div_t info = switchInfo(swtch); + if (IS_TOGGLE(info.quot)) { + if (info.rem != 0) { + val = (val == swtch ? swtch+2 : swtch); + } + } + else { + val = swtch; + } + } + } + return val; +} +#endif + +int8_t checkIncDec_Ret; + +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) + +int checkIncDec(evt_t event, int val, int i_min, int i_max, unsigned int i_flags, IsValueAvailable isValueAvailable, const CheckIncDecStops &stops) +{ + int newval = val; + +#if defined(DBLKEYS) + uint32_t in = KEYS_PRESSED(); + if (!(i_flags & NO_DBLKEYS) && (EVT_KEY_MASK(event))) { + bool dblkey = true; + if (DBLKEYS_PRESSED_RGT_LFT(in)) { + if (!isValueAvailable || isValueAvailable(-val)) + newval = -val; + } + else if (DBLKEYS_PRESSED_RGT_UP(in)) { + newval = (i_max > stops.max() ? stops.max() : i_max); + while (isValueAvailable && !isValueAvailable(newval) && newval>i_min) { + --newval; + } + } + else if (DBLKEYS_PRESSED_LFT_DWN(in)) { + newval = (i_min < stops.min() ? stops.min() : i_min); + while (isValueAvailable && !isValueAvailable(newval) && newval0 && event==EVT_ROTARY_RIGHT) { + do { + if (IS_KEY_REPT(event) && (i_flags & INCDEC_REP10)) { + newval += min(10, i_max-val); + } + else { + newval++; + } + } while (isValueAvailable && !isValueAvailable(newval) && newval<=i_max); + + if (newval > i_max) { + newval = val; + killEvents(event); + AUDIO_WARNING2(); + } + else { + AUDIO_KEYPAD_UP(); + } + } + else if (s_editMode>0 && event==EVT_ROTARY_LEFT) { + do { + if (IS_KEY_REPT(event) && (i_flags & INCDEC_REP10)) { + newval -= min(10, val-i_min); + } + else { + newval--; + } + } while (isValueAvailable && !isValueAvailable(newval) && newval>=i_min); + + if (newval < i_min) { + newval = val; + killEvents(event); + AUDIO_WARNING2(); + } + else { + AUDIO_KEYPAD_DOWN(); + } + } + + if (!READ_ONLY() && i_min==0 && i_max==1 && event==EVT_KEY_BREAK(KEY_ENTER)) { + s_editMode = 0; + newval = !val; + } + +#if defined(AUTOSWITCH) + if (i_flags & INCDEC_SWITCH) { + newval = checkIncDecMovedSwitch(newval); + } +#endif + +#if defined(AUTOSOURCE) + if (i_flags & INCDEC_SOURCE) { + if (s_editMode>0) { + int source = GET_MOVED_SOURCE(i_min, i_max); + if (source) { + newval = source; + } +#if defined(AUTOSWITCH) + else { + unsigned int swtch = abs(getMovedSwitch()); + if (swtch) { + newval = switchToMix(swtch); + } + } +#endif + } + } +#endif + + if (newval > i_max || newval < i_min) { + newval = (newval > i_max ? i_max : i_min); + killEvents(event); + AUDIO_WARNING2(); + } + + if (newval != val) { +#if 0 + if (!(i_flags & NO_INCDEC_MARKS) && (newval != i_max) && (newval != i_min) && stops.contains(newval) && !IS_ROTARY_EVENT(event)) { + bool pause = (newval > val ? !stops.contains(newval+1) : !stops.contains(newval-1)); + if (pause) { + pauseEvents(event); // delay before auto-repeat continues + if (newval>val) // without AUDIO it's optimized, because the 2 sounds are the same + AUDIO_KEYPAD_UP(); + else + AUDIO_KEYPAD_DOWN(); + } + } +#endif + storageDirty(i_flags & (EE_GENERAL|EE_MODEL)); + checkIncDec_Ret = (newval > val ? 1 : -1); + } + else { + checkIncDec_Ret = 0; + } + return newval; +} + +#define CURSOR_NOT_ALLOWED_IN_ROW(row) ((int8_t)MAXCOL(row) < 0) +#define MAXCOL_RAW(row) (horTab ? pgm_read_byte(horTab+min(row, (vertpos_t)horTabMax)) : (const uint8_t)0) +#define MAXCOL(row) (MAXCOL_RAW(row) >= HIDDEN_ROW ? MAXCOL_RAW(row) : (const uint8_t)(MAXCOL_RAW(row) & (~NAVIGATION_LINE_BY_LINE))) +#define COLATTR(row) (MAXCOL_RAW(row) == (uint8_t)-1 ? (const uint8_t)0 : (const uint8_t)(MAXCOL_RAW(row) & NAVIGATION_LINE_BY_LINE)) +#define INC(val, min, max) if (valmin) {val--;} else {val=max;} + +uint8_t menuPageIndex; +uint8_t menuPageCount; +uint16_t linesCount; + +bool navigate(evt_t event, int count, int rows, int columns) +{ + int prevPosHorz = m_posHorz; + int prevPosVert = m_posVert; + + int maxrow = ((count+columns-1) / columns) - 1; + int maxlastcol = count-maxrow*columns-1; + int maxcol = (m_posVert != maxrow ? columns-1 : maxlastcol); + + switch (event) { + case EVT_KEY_FIRST(KEY_RIGHT): + case EVT_KEY_REPT(KEY_RIGHT): + INC(m_posHorz, 0, maxcol); + break; + + case EVT_KEY_FIRST(KEY_LEFT): + case EVT_KEY_REPT(KEY_LEFT): + DEC(m_posHorz, 0, maxcol); + break; + + case EVT_KEY_FIRST(KEY_DOWN): + case EVT_KEY_REPT(KEY_DOWN): + INC(m_posVert, 0, maxrow); + if (m_posVert == maxrow && m_posHorz > maxlastcol) { + m_posHorz = maxlastcol; + } + break; + + case EVT_KEY_FIRST(KEY_UP): + case EVT_KEY_REPT(KEY_UP): + DEC(m_posVert, 0, maxrow); + if (m_posVert == maxrow && m_posHorz > maxlastcol) { + m_posHorz = maxlastcol; + } + break; + + case EVT_ROTARY_LEFT: + if (m_posHorz > 0) { + m_posHorz--; + } + else { + DEC(m_posVert, 0, maxrow); + m_posHorz = (m_posVert != maxrow ? columns-1 : maxlastcol); + } + break; + + case EVT_ROTARY_RIGHT: + if (m_posHorz < maxcol) { + m_posHorz++; + } + else { + INC(m_posVert, 0, maxrow); + m_posHorz = 0; + } + break; + } + + if (s_pgOfs > m_posVert) { + s_pgOfs = m_posVert; + } + else if (s_pgOfs <= m_posVert - rows) { + s_pgOfs = m_posVert - rows + 1; + } + + return (prevPosHorz != m_posHorz || prevPosVert != m_posVert); +} + +bool check(check_event_t event, uint8_t curr, const MenuFuncP * menuTab, uint8_t menuTabSize, const pm_uint8_t * horTab, uint8_t horTabMax, vertpos_t rowcount, uint8_t flags) +{ + uint8_t maxcol = MAXCOL(m_posVert); + + if (menuTab && !calibrationState && m_posVert<0) { + int cc = curr; + switch (event) { + case EVT_KEY_BREAK(KEY_RIGHT): + case EVT_ROTARY_RIGHT: + if (++cc == menuTabSize) + cc = 0; + break; + + case EVT_KEY_BREAK(KEY_LEFT): + case EVT_ROTARY_LEFT: + if (cc-- == 0) + cc = menuTabSize-1; + break; + + case EVT_KEY_BREAK(KEY_ENTER): + if (rowcount > 0) { + m_posVert = MENU_FIRST_LINE_EDIT; + event = 0; + } + break; + + case EVT_KEY_BREAK(KEY_DOWN): + case EVT_KEY_BREAK(KEY_UP): + m_posHorz = -1; + break; + } + + if (cc != curr) { + chainMenu((MenuFuncP)pgm_read_adr(&menuTab[cc])); + return false; + } + + menuPageIndex = curr; + menuPageCount = menuTabSize; + } + + switch(event) + { + case EVT_ENTRY: + m_posVert = (menuTab ? -1 : MENU_FIRST_LINE_EDIT); + m_posHorz = POS_HORZ_INIT(0); + s_editMode = EDIT_MODE_INIT; + break; + + case EVT_ENTRY_UP: + s_editMode = 0; + m_posHorz = POS_HORZ_INIT(m_posVert); + break; + + case EVT_ROTARY_BREAK: + if (s_editMode > 1) break; + if (m_posHorz < 0 && maxcol > 0 && READ_ONLY_UNLOCKED()) { + m_posHorz = 0; + } + else if (READ_ONLY_UNLOCKED()) { + s_editMode = (s_editMode<=0); + } + break; + + case EVT_KEY_LONG(KEY_EXIT): + s_editMode = 0; // TODO needed? we call ENTRY_UP after which does the same + popMenu(); + break; + + case EVT_KEY_BREAK(KEY_EXIT): + if (s_editMode > 0) { + s_editMode = 0; + break; + } + + if (m_posHorz >= 0 && (COLATTR(m_posVert) & NAVIGATION_LINE_BY_LINE)) { + m_posHorz = -1; + } + else if (menuTab && m_posVert >= 0) { + m_posVert = -1; + m_posHorz = 0; +#if 0 + int posVertInit = -1; + if (s_pgOfs != 0 || m_posVert != posVertInit) { + s_pgOfs = 0; + m_posVert = posVertInit; + m_posHorz = POS_HORZ_INIT(m_posVert); + } +#endif + } + else { + popMenu(); + } + break; + + case EVT_KEY_FIRST(KEY_RIGHT): + case EVT_KEY_REPT(KEY_RIGHT): + if (s_editMode != 0) break; + INC(m_posHorz, 0, maxcol); + break; + + case EVT_KEY_FIRST(KEY_LEFT): + case EVT_KEY_REPT(KEY_LEFT): + if (s_editMode != 0) break; + DEC(m_posHorz, 0, maxcol); + break; + + case EVT_ROTARY_RIGHT: + if (s_editMode != 0) break; + if ((COLATTR(m_posVert) & NAVIGATION_LINE_BY_LINE)) { + if (m_posHorz >= 0) { + INC(m_posHorz, 0, maxcol); + break; + } + } + else if (m_posHorz < maxcol) { + m_posHorz++; + break; + } + do { + INC(m_posVert, MENU_FIRST_LINE_EDIT, rowcount-1); + } while (CURSOR_NOT_ALLOWED_IN_ROW(m_posVert)); + m_posHorz = POS_HORZ_INIT(m_posVert); + break; + + case EVT_KEY_FIRST(KEY_DOWN): + case EVT_KEY_REPT(KEY_DOWN): + { + do { + INC(m_posVert, MENU_FIRST_LINE_EDIT, rowcount-1); + } while (CURSOR_NOT_ALLOWED_IN_ROW(m_posVert)); + s_editMode = 0; // if we go down, we must be in this mode + uint8_t newmaxcol = MAXCOL(m_posVert); + if (COLATTR(m_posVert) & NAVIGATION_LINE_BY_LINE) { + m_posHorz = -1; + } + else if (m_posHorz < 0 || m_posHorz > newmaxcol) { + m_posHorz = POS_HORZ_INIT(m_posVert); + } + break; + } + + case EVT_ROTARY_LEFT: + if (s_editMode != 0) break; + if ((COLATTR(m_posVert) & NAVIGATION_LINE_BY_LINE)) { + if (m_posHorz >= 0) { + DEC(m_posHorz, 0, maxcol); + break; + } + } + else if (m_posHorz > 0) { + m_posHorz--; + break; + } + do { + DEC(m_posVert, MENU_FIRST_LINE_EDIT, rowcount-1); + } while (CURSOR_NOT_ALLOWED_IN_ROW(m_posVert)); + if (COLATTR(m_posVert) & NAVIGATION_LINE_BY_LINE) + m_posHorz = -1; + else + m_posHorz = min((uint8_t)m_posHorz, MAXCOL(m_posVert)); + break; + + case EVT_KEY_FIRST(KEY_UP): + case EVT_KEY_REPT(KEY_UP): + { + do { + DEC(m_posVert, MENU_FIRST_LINE_EDIT, rowcount-1); + } while (CURSOR_NOT_ALLOWED_IN_ROW(m_posVert)); + s_editMode = 0; // if we go up, we must be in this mode + uint8_t newmaxcol = MAXCOL(m_posVert); + if ((COLATTR(m_posVert) & NAVIGATION_LINE_BY_LINE)) { + m_posHorz = -1; + } + else if (m_posHorz < 0) { + m_posHorz = POS_HORZ_INIT(m_posVert); + } + else if (m_posHorz > newmaxcol) { + m_posHorz = min((uint8_t)m_posHorz, newmaxcol); + } + break; + } + } + + linesCount = rowcount; + int maxBodyLines = (menuTab ? NUM_BODY_LINES : NUM_BODY_LINES+1); + + if (m_posVert <= MENU_FIRST_LINE_EDIT) { + s_pgOfs = 0; + if (horTab) { + linesCount = 0; + for (int i=0; ihorTabMax || horTab[i] != HIDDEN_ROW) { + linesCount++; + } + } + } + } + else if (horTab) { + if (rowcount > maxBodyLines) { + while (1) { + vertpos_t firstLine = 0; + for (int numLines=0; firstLine=horTabMax || horTab[firstLine] != HIDDEN_ROW) { + numLines++; + } + } + if (m_posVert < firstLine) { + s_pgOfs--; + } + else { + vertpos_t lastLine = firstLine; + for (int numLines=0; lastLine= horTabMax || horTab[lastLine] != HIDDEN_ROW) { + numLines++; + } + } + if (m_posVert >= lastLine) { + s_pgOfs++; + } + else { + linesCount = s_pgOfs + maxBodyLines; + for (int i=lastLine; i horTabMax || horTab[i] != HIDDEN_ROW) { + linesCount++; + } + } + break; + } + } + } + } + } + else { + if (m_posVert >= maxBodyLines + s_pgOfs) { + s_pgOfs = m_posVert-maxBodyLines+1; + } + else if (m_posVert < s_pgOfs) { + s_pgOfs = m_posVert; + } + } + + return true; +} + +bool check_simple(check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTabSize, vertpos_t rowcount) +{ + return check(event, curr, menuTab, menuTabSize, NULL, 0, rowcount); +} + +bool check_submenu_simple(check_event_t event, uint8_t rowcount) +{ + return check_simple(event, 0, NULL, 0, rowcount); +} + +void repeatLastCursorMove(evt_t event) +{ + if (CURSOR_MOVED_LEFT(event) || CURSOR_MOVED_RIGHT(event)) { + putEvent(event); + } + else { + m_posHorz = 0; + } +} diff --git a/radio/src/gui/Horus/popups.cpp b/radio/src/gui/Horus/popups.cpp new file mode 100644 index 000000000..dca15ec49 --- /dev/null +++ b/radio/src/gui/Horus/popups.cpp @@ -0,0 +1,220 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../../opentx.h" + +const char *s_warning = NULL; +const char *s_warning_info; +uint8_t s_warning_info_len; +uint8_t s_warning_type; +uint8_t s_warning_result = 0; +uint8_t s_warning_info_flags = ZCHAR; +int16_t s_warning_input_value; +int16_t s_warning_input_min; +int16_t s_warning_input_max; + +void displayAlertBox() +{ + lcdClear(); + lcdDrawSolidFilledRect(POPUP_X, POPUP_Y, POPUP_W, POPUP_H, TEXT_BGCOLOR); + lcdDrawSolidRect(POPUP_X, POPUP_Y, POPUP_W, POPUP_H, ALARM_COLOR); + lcdDrawSolidRect(POPUP_X+1, POPUP_Y+1, POPUP_W-2, POPUP_H-2, ALARM_COLOR); + lcdDrawBitmap(POPUP_X-80, POPUP_Y-30, LBM_ASTERISK); +} + +void displayWarningBox() +{ + // lcdDrawBlackOverlay(); + lcdDrawSolidFilledRect(POPUP_X, POPUP_Y, POPUP_W, POPUP_H, TEXT_BGCOLOR); + lcdDrawSolidRect(POPUP_X, POPUP_Y, POPUP_W, POPUP_H, ALARM_COLOR); + lcdDrawSolidRect(POPUP_X+1, POPUP_Y+1, POPUP_W-2, POPUP_H-2, ALARM_COLOR); + // lcdDrawBitmap(POPUP_X+15, POPUP_Y+20, LBM_WARNING); +} + +void displayMessageBox() +{ + // lcdDrawBlackOverlay(); + lcdDrawSolidFilledRect(POPUP_X, POPUP_Y, POPUP_W, POPUP_H, TEXT_BGCOLOR); + lcdDrawSolidRect(POPUP_X, POPUP_Y, POPUP_W, POPUP_H, WARNING_COLOR); + lcdDrawSolidRect(POPUP_X+1, POPUP_Y+1, POPUP_W-2, POPUP_H-2, WARNING_COLOR); + // lcdDrawBitmap(POPUP_X+15, POPUP_Y+20, LBM_MESSAGE); +} + +void message(const pm_char *title, const pm_char *t, const char *last MESSAGE_SOUND_ARG) +{ + displayAlertBox(); + +#if defined(TRANSLATIONS_FR) || defined(TRANSLATIONS_IT) || defined(TRANSLATIONS_CZ) + lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y, STR_WARNING, ALARM_COLOR|DBLSIZE); + lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y+25, title, ALARM_COLOR|DBLSIZE); +#else + lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y, title, ALARM_COLOR|DBLSIZE); + lcdDrawText(WARNING_LINE_X, WARNING_LINE_Y+25, STR_WARNING, ALARM_COLOR|DBLSIZE); +#endif + + if (t) lcdDrawText(WARNING_LINE_X, WARNING_INFOLINE_Y, t); + if (last) { + lcdDrawText(WARNING_LINE_X, WARNING_INFOLINE_Y+16, last); + AUDIO_ERROR_MESSAGE(sound); + } + + lcdRefresh(); + lcdSetContrast(); + clearKeyEvents(); +} + +void displayPopup(const char *title) +{ + // displayMessageBox(); + lcdDrawTextWithLen(WARNING_LINE_X, WARNING_LINE_Y, title, WARNING_LINE_LEN, DBLSIZE|WARNING_COLOR); + lcdRefresh(); +} + +void displayWarning(evt_t event) +{ + s_warning_result = false; + if (s_warning_type == WARNING_TYPE_INPUT) + displayMessageBox(); + else + displayWarningBox(); + lcdDrawTextWithLen(WARNING_LINE_X, WARNING_LINE_Y, s_warning, WARNING_LINE_LEN, DBLSIZE | (s_warning_type == WARNING_TYPE_INPUT ? WARNING_COLOR : ALARM_COLOR)); + if (s_warning_info) { + lcdDrawTextWithLen(WARNING_LINE_X, WARNING_INFOLINE_Y, s_warning_info, s_warning_info_len, WARNING_INFO_FLAGS); + } + lcdDrawText(WARNING_LINE_X, WARNING_INFOLINE_Y+20, s_warning_type == WARNING_TYPE_ASTERISK ? STR_EXIT : STR_POPUPS); + switch (event) { + case EVT_KEY_BREAK(KEY_ENTER): + if (s_warning_type == WARNING_TYPE_ASTERISK) + break; + s_warning_result = true; + // no break + case EVT_KEY_BREAK(KEY_EXIT): + s_warning = NULL; + s_warning_type = WARNING_TYPE_ASTERISK; + break; + default: + if (s_warning_type != WARNING_TYPE_INPUT) break; + s_editMode = EDIT_MODIFY_FIELD; + s_warning_input_value = checkIncDec(event, s_warning_input_value, s_warning_input_min, s_warning_input_max); + s_editMode = EDIT_SELECT_FIELD; + break; + } +} + +void (*popupFunc)(evt_t event) = NULL; + +const char *s_menu[MENU_MAX_LINES]; +uint8_t s_menu_item = 0; +uint16_t s_menu_count = 0; +uint8_t s_menu_flags = 0; +uint16_t s_menu_offset = 0; +void (*menuHandler)(const char *result); +const char * displayMenu(evt_t event) +{ + const char * result = NULL; + uint8_t display_count = min(s_menu_count, (uint16_t)MENU_MAX_LINES); + + switch (event) { + case EVT_ROTARY_LEFT: + case EVT_KEY_FIRST(KEY_UP): + case EVT_KEY_REPT(KEY_UP): + if (s_menu_item > 0) { + s_menu_item--; + } + else if (s_menu_offset > 0) { + s_menu_offset--; + result = STR_UPDATE_LIST; + } + else { + s_menu_item = display_count - 1; + if (s_menu_count > MENU_MAX_LINES) { + s_menu_offset = s_menu_count - display_count; + result = STR_UPDATE_LIST; + } + } + break; + + case EVT_ROTARY_RIGHT: + case EVT_KEY_FIRST(KEY_DOWN): + case EVT_KEY_REPT(KEY_DOWN): + if (s_menu_item < display_count - 1 && s_menu_offset + s_menu_item + 1 < s_menu_count) { + s_menu_item++; + } + else if (s_menu_count > s_menu_offset + display_count) { + s_menu_offset++; + result = STR_UPDATE_LIST; + } + else { + s_menu_item = 0; + if (s_menu_offset) { + s_menu_offset = 0; + result = STR_UPDATE_LIST; + } + } + break; + case EVT_KEY_BREAK(KEY_ENTER): + result = s_menu[s_menu_item]; + // no break + case EVT_KEY_BREAK(KEY_EXIT): + s_menu_count = 0; + s_menu_item = 0; + s_menu_flags = 0; + s_menu_offset = 0; + break; + } + + int y = (LCD_H - (display_count*(FH+1))) / 2; + + // lcdDrawBlackOverlay(); + lcdDrawSolidFilledRect(MENU_X, y, MENU_W, display_count * (FH+1), TEXT_BGCOLOR); + lcdDrawSolidRect(MENU_X, y, MENU_W, display_count * (FH+1) + 1, ALARM_COLOR); + + for (uint8_t i=0; i display_count) { + drawScrollbar(MENU_X+MENU_W-1, y+1, MENU_MAX_LINES * (FH+1), s_menu_offset, s_menu_count, MENU_MAX_LINES); + } + + return result; +} diff --git a/radio/src/gui/Horus/splash.cpp b/radio/src/gui/Horus/splash.cpp new file mode 100644 index 000000000..58c5d61be --- /dev/null +++ b/radio/src/gui/Horus/splash.cpp @@ -0,0 +1,59 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../../opentx.h" + +const uint8_t LBM_SPLASH[] = { +#include "../../bitmaps/Horus/splash.lbm" +}; + +#if defined(SPLASH) +void displaySplash() +{ + lcdClear(); + + lcdDrawBitmap((LCD_W-256)/2, (LCD_H-256)/2, LBM_SPLASH); + +#if MENUS_LOCK == 1 + if (readonly == false) { + lcdDrawSolidFilledRect((LCD_W-(sizeof(TR_UNLOCKED)-1)*FW)/2 - 9, 50, (sizeof(TR_UNLOCKED)-1)*FW+16, 11, SOLID, ERASE|ROUND); + lcdDrawText((LCD_W-(sizeof(TR_UNLOCKED)-1)*FW)/2 , 53, STR_UNLOCKED); + } +#endif + + lcdRefresh(); +} +#endif diff --git a/radio/src/gui/Horus/view_about.cpp b/radio/src/gui/Horus/view_about.cpp new file mode 100644 index 000000000..8d0fcb36f --- /dev/null +++ b/radio/src/gui/Horus/view_about.cpp @@ -0,0 +1,161 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../../opentx.h" + +enum AboutScreens { + ABOUT_OPENTX, + ABOUT_BERTRAND, + ABOUT_ANDRE, + ABOUT_MIKE, + ABOUT_KJELL, + ABOUT_MARTIN, + ABOUT_ROMOLO, + ABOUT_ROB, + ABOUT_HARDWARE, + ABOUT_PARENTS, + ABOUT_END, + ABOUT_COUNT, +}; + +#define ABOUT_X 62 +#define ABOUT_INDENT 16 + +bool menuAboutView(evt_t event) +{ + static uint8_t screenIndex = 0; + static uint8_t greyIndex = 0; + + switch(event) + { + case EVT_ENTRY: + screenIndex = 0; + greyIndex = 0; + break; + case EVT_KEY_FIRST(KEY_DOWN): + screenIndex < ABOUT_PARENTS ? screenIndex++ : screenIndex = ABOUT_OPENTX; + greyIndex = 0; + break; + case EVT_KEY_FIRST(KEY_UP): + screenIndex > ABOUT_OPENTX ? screenIndex-- : screenIndex = ABOUT_PARENTS; + greyIndex = 0; + break; + case EVT_KEY_FIRST(KEY_EXIT): + chainMenu(menuMainView); + break; + } + + drawScreenTemplate("About"); + + uint8_t screenDuration = 150; + + switch (screenIndex) { + case ABOUT_OPENTX: + case ABOUT_END: + lcdDrawText(ABOUT_X, MENU_CONTENT_TOP, STR_ABOUT_OPENTX_1); + lcdDrawText(ABOUT_X, MENU_CONTENT_TOP + FH, STR_ABOUT_OPENTX_2); + lcdDrawText(ABOUT_X, MENU_CONTENT_TOP + 2*FH, STR_ABOUT_OPENTX_3); + lcdDrawText(ABOUT_X, MENU_CONTENT_TOP + 3*FH, STR_ABOUT_OPENTX_4); + lcdDrawText(ABOUT_X, MENU_CONTENT_TOP + 4*FH, STR_ABOUT_OPENTX_5); + screenDuration = 255; + break; + + case ABOUT_BERTRAND: + lcdDrawText(ABOUT_X, MENU_CONTENT_TOP, STR_ABOUT_BERTRAND_1, INVERS); + lcdDrawText(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + FH, STR_ABOUT_BERTRAND_2); + lcdDrawText(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + 2*FH, STR_ABOUT_BERTRAND_3); + break; + + case ABOUT_ANDRE: + lcdDrawText(ABOUT_X, MENU_CONTENT_TOP, STR_ABOUT_ANDRE_1, INVERS); + lcdDrawText(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + FH, STR_ABOUT_ANDRE_2); + lcdDrawText(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + 2*FH, STR_ABOUT_ANDRE_3); + break; + + case ABOUT_MIKE: + lcdDrawText(ABOUT_X, MENU_CONTENT_TOP, STR_ABOUT_MIKE_1, INVERS); + lcdDrawText(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + FH, STR_ABOUT_MIKE_2); + lcdDrawText(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + 2*FH, STR_ABOUT_MIKE_3); + lcdDrawText(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + 3*FH, STR_ABOUT_MIKE_4); + break; + + case ABOUT_KJELL: + lcdDrawText(ABOUT_X, MENU_CONTENT_TOP, STR_ABOUT_KJELL_1, INVERS); + lcdDrawText(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + FH, STR_ABOUT_KJELL_2); + lcdDrawText(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + 2*FH, STR_ABOUT_KJELL_3); + lcdDrawText(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + 3*FH, STR_ABOUT_KJELL_4); + break; + + case ABOUT_MARTIN: + lcdDrawText(ABOUT_X, MENU_CONTENT_TOP, STR_ABOUT_MARTIN_1, INVERS); + lcdDrawText(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + FH, STR_ABOUT_MARTIN_2); + break; + + case ABOUT_ROMOLO: + lcdDrawText(ABOUT_X, MENU_CONTENT_TOP, STR_ABOUT_ROMOLO_1, INVERS); + lcdDrawText(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + FH, STR_ABOUT_ROMOLO_2); + lcdDrawText(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + 2*FH, STR_ABOUT_ROMOLO_3); + break; + + case ABOUT_ROB: + lcdDrawText(ABOUT_X, MENU_CONTENT_TOP, STR_ABOUT_ROB_1, INVERS); + lcdDrawText(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + FH, STR_ABOUT_ROB_2); + break; + + case ABOUT_HARDWARE: + lcdDrawText(ABOUT_X, MENU_CONTENT_TOP, "FrSky", INVERS); + lcdDrawText(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + FH, STR_ABOUT_HARDWARE_2); + lcdDrawText(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + 2*FH, STR_ABOUT_HARDWARE_3); + break; + + case ABOUT_PARENTS: + lcdDrawText(ABOUT_X, MENU_CONTENT_TOP, STR_ABOUT_PARENTS_1, INVERS); + lcdDrawText(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + FH, STR_ABOUT_PARENTS_2); + lcdDrawText(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + 2*FH, STR_ABOUT_PARENTS_3); + lcdDrawText(ABOUT_X+ABOUT_INDENT, MENU_CONTENT_TOP + 3*FH, STR_ABOUT_PARENTS_4); + screenDuration = 255; + break; + } + + if (++greyIndex == screenDuration) { + greyIndex = 0; + if (++screenIndex == ABOUT_COUNT) { + chainMenu(menuMainView); + } + } + + return true; +} diff --git a/radio/src/gui/Horus/view_channels.cpp b/radio/src/gui/Horus/view_channels.cpp new file mode 100644 index 000000000..6188085df --- /dev/null +++ b/radio/src/gui/Horus/view_channels.cpp @@ -0,0 +1,124 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../../opentx.h" + +bool isChannelUsed(int channel); +int getChannelsUsed(); + +bool menuChannelsView(evt_t event) +{ + const int CHANNEL_MARGIN = 16; + const int CHANNEL_HEIGHT = 25; + const int CHANNEL_WIDTH = (LCD_W - 3*CHANNEL_MARGIN) / 2; + const int CHANNEL_PADDING_HORZ = 4; + const int CHANNEL_PADDING_VERT = 2; + const int BAR_WIDTH = CHANNEL_WIDTH-2*CHANNEL_PADDING_HORZ; + + static int view = 0; + int x=CHANNEL_MARGIN, y=CHANNEL_MARGIN; + + int viewMax = (getChannelsUsed() - 1) / 8; + if (viewMax <= 0 || view > viewMax) { + view = 0; + } + else { + switch (event) { + case EVT_KEY_FIRST(KEY_RIGHT): + if (++view > viewMax) + view = 0; + break; + case EVT_KEY_FIRST(KEY_LEFT): + if (--view < 0) + view = viewMax; + break; + } + } + + int skipCount = view*8; + for (int ch=0, index=0; index skipCount) { + // The black background + lcdDrawSolidFilledRect(x, y, CHANNEL_WIDTH, CHANNEL_HEIGHT, TEXT_BGCOLOR); + + // The label + unsigned int lenLabel = ZLEN(g_model.limitData[ch].name); + if (lenLabel > 0) + lcdDrawTextWithLen(x+CHANNEL_PADDING_HORZ, y+CHANNEL_PADDING_VERT, g_model.limitData[ch].name, sizeof(g_model.limitData[ch].name), ZCHAR); + else + putsChn(x+CHANNEL_PADDING_HORZ, y+CHANNEL_PADDING_VERT, ch+1, 0); + + int32_t val = channelOutputs[ch]; + + // The bar + lcdDrawSolidFilledRect(x+CHANNEL_PADDING_HORZ, y+15, BAR_WIDTH, 6, TEXT_INVERTED_BGCOLOR); + unsigned int lim = g_model.extendedLimits ? 640*2 : 512*2; + unsigned int len = limit(1, (abs(val) * BAR_WIDTH/2 + lim/2) / lim, BAR_WIDTH/2); + unsigned int x0 = (val>0) ? x+CHANNEL_PADDING_HORZ-1+BAR_WIDTH/2 : x+CHANNEL_PADDING_HORZ+BAR_WIDTH/2+1-len; + lcdDrawSolidFilledRect(x0, y+16, len, 4, TEXT_BGCOLOR); + + y += CHANNEL_HEIGHT + CHANNEL_MARGIN; + if (y >= 4*(CHANNEL_HEIGHT + CHANNEL_MARGIN)) { + x += CHANNEL_WIDTH + CHANNEL_MARGIN; + y = CHANNEL_MARGIN; + } + } + } + } + +#if 0 + +#if defined(CHANNELS_MONITOR_INV_HIDE) + //if channel output is inverted, show it with oposite sign + if (g_model.limitData[ch].revert) val = -val; +#endif + + // Value +#if defined(PPM_UNIT_US) + uint8_t wbar = (longNames ? 54 : 64); + lcdDrawNumber(x+LCD_W/2-3-wbar-ofs, y+1, PPM_CH_CENTER(ch)+val/2, TINSIZE); +#elif defined(PPM_UNIT_PERCENT_PREC1) + uint8_t wbar = (longNames ? 48 : 58); + lcdDrawNumber(x+LCD_W/2-3-wbar-ofs, y+1, calcRESXto1000(val), PREC1|TINSIZE); +#else + uint8_t wbar = (longNames ? 54 : 64); + lcdDrawNumber(x+LCD_W/2-3-wbar-ofs, y+1, calcRESXto1000(val)/10, TINSIZE); // G: Don't like the decimal part* +#endif +#endif + + return true; +} diff --git a/radio/src/gui/Horus/view_main.cpp b/radio/src/gui/Horus/view_main.cpp new file mode 100644 index 000000000..38b811eb6 --- /dev/null +++ b/radio/src/gui/Horus/view_main.cpp @@ -0,0 +1,429 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../../opentx.h" + +#define TRIM_LH_X 90 +#define TRIM_LV_X 24 +#define TRIM_RV_X (LCD_W-35) +#define TRIM_RH_X (LCD_W-95) +#define TRIM_V_Y 135 +#define TRIM_H_Y 235 +#define TRIM_LEN 80 + +#define MODELPANEL_LEFT 240 +#define MODELPANEL_TOP 68 +#define MODELPANEL_WIDTH MODEL_BITMAP_WIDTH +#define MODELPANEL_HEIGHT 135 + +#define TIMER1PANEL_LEFT 46 +#define TIMER1PANEL_TOP 55 +#define TIMER2PANEL_LEFT TIMER1PANEL_LEFT +#define TIMER2PANEL_TOP 134 + +void drawTrimSquare(coord_t x, coord_t y) +{ + lcdDrawSolidFilledRect(x-2, y, 15, 15, TITLE_BGCOLOR); + lcdDrawBitmapPattern(x-2, y, LBM_TRIM_SHADOW, TEXT_COLOR); +} + +void drawHorizontalTrimPosition(coord_t x, coord_t y, int16_t dir) +{ + drawTrimSquare(x, y); + if (dir >= 0) { + lcdDrawSolidVerticalLine(x+8, y+3, 9, TEXT_INVERTED_COLOR); + } + if (dir <= 0) { + lcdDrawSolidVerticalLine(x+2, y+3, 9, TEXT_INVERTED_COLOR); + } + // if (exttrim) { + // lcdDrawSolidVerticalLine(xm, ym, 9, TEXT_INVERTED_COLOR); + // } +} + +void drawVerticalTrimPosition(coord_t x, coord_t y, int16_t dir) +{ + drawTrimSquare(x, y); + if (dir >= 0) { + lcdDrawSolidHorizontalLine(x+1, y+4, 9, TEXT_INVERTED_COLOR); + } + if (dir <= 0) { + lcdDrawSolidHorizontalLine(x+1, y+10, 9, TEXT_INVERTED_COLOR); + } + // if (exttrim) { + // lcdDrawSolidHorizontalLine(xm-1, ym, 3, TEXT_INVERTED_COLOR); + // } +} + +void drawHorizontalStick(coord_t x, int val) +{ + for (int i=0; i<=160; i+=4) { + if (i==0 || i==80 || i==160) + lcdDrawSolidVerticalLine(x+i, 250, 13, TEXT_COLOR); + else + lcdDrawSolidVerticalLine(x+i, 252, 9, TEXT_COLOR); + } + drawHorizontalTrimPosition(x+TRIM_LEN+val*TRIM_LEN/RESX-5, TRIM_H_Y+16, val); +} + +void drawVerticalStick(coord_t x, int val) +{ + for (int i=0; i<=160; i+=4) { + if (i==0 || i==80 || i==160) + lcdDrawSolidHorizontalLine(x, 56+i, 13, TEXT_COLOR); + else + lcdDrawSolidHorizontalLine(x+2, 56+i, 9, TEXT_COLOR); + } + drawVerticalTrimPosition(x, TRIM_V_Y+val*TRIM_LEN/RESX-6, val); +} + +void drawSticks() +{ + drawVerticalStick(6, calibratedStick[1]); + drawHorizontalStick(TRIM_LH_X-TRIM_LEN+1, calibratedStick[0]); + drawVerticalStick(LCD_W-18, calibratedStick[2]); + drawHorizontalStick(TRIM_RH_X-TRIM_LEN+1, calibratedStick[3]); +} + +void drawTrims(uint8_t flightMode) +{ + g_model.displayTrims = DISPLAY_TRIMS_ALWAYS; + + for (uint8_t i=0; i<4; i++) { + static coord_t x[4] = {TRIM_LH_X, TRIM_LV_X, TRIM_RV_X, TRIM_RH_X}; + static uint8_t vert[4] = {0, 1, 1, 0}; + unsigned int stickIndex = CONVERT_MODE(i); + coord_t xm = x[stickIndex]; + + int32_t trim = getTrimValue(flightMode, i); + int32_t val = trim * TRIM_LEN / 125; + bool exttrim = false; + if (val < -(TRIM_LEN+1)) { + val = -(TRIM_LEN+1); + exttrim = true; + } + else if (val > (TRIM_LEN+1)) { + val = TRIM_LEN+1; + exttrim = true; + } + + if (vert[i]) { + coord_t ym = TRIM_V_Y; + lcdDrawBitmapPattern(xm, ym-TRIM_LEN, LBM_VTRIM_FRAME, TEXT_COLOR); + if (i!=2 || !g_model.thrTrim) { + // TODO + } + ym -= val; + drawVerticalTrimPosition(xm-1, ym-6, val); + if (g_model.displayTrims != DISPLAY_TRIMS_NEVER && trim != 0) { + if (g_model.displayTrims == DISPLAY_TRIMS_ALWAYS || (trimsDisplayTimer > 0 && (trimsDisplayMask & (1<0 ? 100 : 200, xm-2, trim, TINSIZE|VERTICAL); + } + } + } + else { + coord_t ym = TRIM_H_Y; + lcdDrawBitmapPattern(xm-TRIM_LEN, ym, LBM_HTRIM_FRAME, TEXT_COLOR); + xm += val; + drawHorizontalTrimPosition(xm-3, ym-2, val); + if (g_model.displayTrims != DISPLAY_TRIMS_NEVER && trim != 0) { + if (g_model.displayTrims == DISPLAY_TRIMS_ALWAYS || (trimsDisplayTimer > 0 && (trimsDisplayMask & (1<0 ? -20 : 50), ym+2, trim, TINSIZE); + } + } + } + } +} + +void drawTimer(coord_t x, coord_t y, int index) +{ + TimerData & timerData = g_model.timers[index]; + TimerState & timerState = timersStates[index]; + lcdDrawBitmapPattern(x, y, LBM_TIMER_BACKGROUND, TEXT_BGCOLOR); + if (timerData.start) { + lcdDrawBitmapPatternPie(x+2, y+3, LBM_RSCALE, TITLE_BGCOLOR, 0, timerState.val <= 0 ? 360 : 360*(timerData.start-timerState.val)/timerData.start); + } + putsTimer(x+76, y+31, abs(timerState.val), TEXT_COLOR|DBLSIZE|LEFT); + if (ZLEN(timerData.name) > 0) { + lcdDrawTextWithLen(x+78, y+20, timerData.name, LEN_TIMER_NAME, ZCHAR|SMLSIZE|TEXT_COLOR); + } + putsStrIdx(x+137, y+17, "TMR", index+1, SMLSIZE|TEXT_COLOR); +} + + +void displayMainTelemetryFields() +{ + const int ALTITUDE_Y = 16; + const int VOLTS_Y = 16+16+30; + const int ALTITUDE_W = 56; + const int ALTITUDE_X = LCD_W-ALTITUDE_Y-ALTITUDE_W; + const int ALTITUDE_H = 30; + const int PADDING = 4; + + if (g_model.frsky.voltsSource) { + TelemetryItem & item = telemetryItems[g_model.frsky.voltsSource-1]; + if (item.isAvailable()) { + int32_t value = item.value; + TelemetrySensor & sensor = g_model.telemetrySensors[g_model.frsky.altitudeSource-1]; + LcdFlags att = 0; + if (sensor.prec == 2) { + att |= PREC1; + value /= 10; + } + else if (sensor.prec == 1) { + att |= PREC1; + } + att |= (item.isOld() ? ALARM_COLOR : TEXT_COLOR); + lcdDrawSolidFilledRect(ALTITUDE_X, VOLTS_Y, ALTITUDE_W, ALTITUDE_H, TEXT_BGCOLOR); + lcdDrawText(ALTITUDE_X+PADDING, VOLTS_Y+2, "Voltage", att); + putsValueWithUnit(ALTITUDE_X+PADDING, VOLTS_Y+12, value, UNIT_VOLTS, DBLSIZE|LEFT|att); + } + } + + if (g_model.frsky.altitudeSource) { + TelemetryItem & item = telemetryItems[g_model.frsky.altitudeSource-1]; + if (item.isAvailable()) { + int32_t value = item.value; + TelemetrySensor & sensor = g_model.telemetrySensors[g_model.frsky.altitudeSource-1]; + if (sensor.prec) value /= sensor.prec == 2 ? 100 : 10; + LcdFlags att = (item.isOld() ? ALARM_COLOR : TEXT_COLOR); + lcdDrawSolidFilledRect(ALTITUDE_X, ALTITUDE_Y, ALTITUDE_W, ALTITUDE_H, TEXT_BGCOLOR); + lcdDrawText(ALTITUDE_X+PADDING, ALTITUDE_Y+2, "Alt", att); + putsValueWithUnit(ALTITUDE_X+PADDING, ALTITUDE_Y+12, value, UNIT_METERS, DBLSIZE|LEFT|att); + } + } +} + +bool isViewAvailable(int index) +{ + if (index <= VIEW_CHANNELS) + return true; + else + return TELEMETRY_SCREEN_TYPE(index-VIEW_TELEM1) != TELEMETRY_SCREEN_TYPE_NONE; +} + +void displayMainViewIndex() +{ + int x = LCD_W - 14; + + for (int i=VIEW_COUNT; i>=0; --i) { + if (isViewAvailable(i)) { + if (g_eeGeneral.view == i) { + lcdDrawSolidFilledRect(x, MENU_FOOTER_TOP+17, 9, 9, TEXT_INVERTED_BGCOLOR); + } + else { + lcdDrawSolidRect(x+1, MENU_FOOTER_TOP+18, 7, 7, TEXT_COLOR); + } + x -= 11; + } + } +} + +void onMainViewMenu(const char *result) +{ + if (result == STR_MODEL_SELECT) { + chainMenu(menuModelSelect); + } + else if (result == STR_RESET_TIMER1) { + timerReset(0); + } + else if (result == STR_RESET_TIMER2) { + timerReset(1); + } + else if (result == STR_RESET_TIMER3) { + timerReset(2); + } + else if (result == STR_VIEW_NOTES) { + pushModelNotes(); + } + else if (result == STR_RESET_SUBMENU) { + MENU_ADD_ITEM(STR_RESET_FLIGHT); + MENU_ADD_ITEM(STR_RESET_TIMER1); + MENU_ADD_ITEM(STR_RESET_TIMER2); + MENU_ADD_ITEM(STR_RESET_TIMER3); + MENU_ADD_ITEM(STR_RESET_TELEMETRY); + } + else if (result == STR_RESET_TELEMETRY) { + telemetryReset(); + } + else if (result == STR_RESET_FLIGHT) { + flightReset(); + } + else if (result == STR_STATISTICS) { + chainMenu(menuStatisticsView); + } + else if (result == STR_ABOUT_US) { + chainMenu(menuAboutView); + } +} + +bool menuMainView(evt_t event) +{ + switch (event) { + case EVT_ENTRY: + killEvents(KEY_EXIT); + killEvents(KEY_UP); + killEvents(KEY_DOWN); + break; + + case EVT_ENTRY_UP: + LOAD_MODEL_BITMAP(); + break; + + case EVT_KEY_LONG(KEY_ENTER): + killEvents(event); + MENU_ADD_ITEM(STR_MODEL_SELECT); + if (modelHasNotes()) { + MENU_ADD_ITEM(STR_VIEW_NOTES); + } + MENU_ADD_ITEM(STR_RESET_SUBMENU); + MENU_ADD_ITEM(STR_STATISTICS); + MENU_ADD_ITEM(STR_ABOUT_US); + menuHandler = onMainViewMenu; + break; + + case EVT_KEY_BREAK(KEY_MENU): + pushMenu(menuModelSetup); + break; + + case EVT_KEY_LONG(KEY_MENU): + killEvents(event); + pushMenu(menuGeneralSetup); + break; + + case EVT_KEY_BREAK(KEY_DOWN): + storageDirty(EE_GENERAL); + g_eeGeneral.view = circularIncDec(g_eeGeneral.view, +1, 0, VIEW_COUNT-1, isViewAvailable); + break; + + case EVT_KEY_BREAK(KEY_UP): + killEvents(event); + storageDirty(EE_GENERAL); + g_eeGeneral.view = circularIncDec(g_eeGeneral.view, -1, 0, VIEW_COUNT-1, isViewAvailable); + break; + + case EVT_KEY_FIRST(KEY_EXIT): +#if defined(GVARS) + if (s_gvar_timer > 0) { + s_gvar_timer = 0; + } +#endif + AUDIO_KEYPAD_UP(); + break; + } + + // 23ms if 24bits per pixel (with transparency) 5/6/5/8 + // 6ms if 16bits per pixel 5/6/5 no DMA + // 1.2ms with the DMA + TIME_MEASURE_START(backgroundbitmap); + lcdDrawBitmap(0, 0, LBM_MAINVIEW_BACKGROUND); + TIME_MEASURE_STOP(backgroundbitmap); + + // Header + lcdDrawSolidFilledRect(0, 0, LCD_W, MENU_HEADER_HEIGHT, HEADER_BGCOLOR); + lcdDrawBitmapPattern(0, 0, LBM_TOPMENU_POLYGON, TITLE_BGCOLOR); + lcdDrawBitmapPattern(4, 10, LBM_TOPMENU_OPENTX, MENU_TITLE_COLOR); + drawTopmenuDatetime(); + if (usbPlugged()) { + lcdDrawBitmapPattern(378, 8, LBM_TOPMENU_USB, MENU_TITLE_COLOR); + } + const uint8_t rssiBarsValue[] = { 30, 40, 50, 60, 80 }; + const uint8_t rssiBarsHeight[] = { 5, 10, 15, 21, 31 }; + for (unsigned int i=0; i= rssiBarsValue[i] ? MENU_TITLE_COLOR : MENU_TITLE_DISABLE_COLOR); + } + + // Flight Mode Name + int mode = mixerCurrentFlightMode; + for (int i=0; i 0) { + s_gvar_timer--; + displayMessageBox(); + putsStrIdx(WARNING_LINE_X, WARNING_LINE_Y, STR_GV, s_gvar_last+1, DBLSIZE|YELLOW); + lcdDrawTextWithLen(WARNING_LINE_X+45, WARNING_LINE_Y, g_model.gvars[s_gvar_last].name, LEN_GVAR_NAME, DBLSIZE|YELLOW|ZCHAR); + lcdDrawNumber(WARNING_LINE_X, WARNING_INFOLINE_Y, GVAR_VALUE(s_gvar_last, getGVarFlightPhase(mixerCurrentFlightMode, s_gvar_last)), DBLSIZE|LEFT); + } +#endif + + return true; +} + +bool menuMainViewChannelsMonitor(evt_t event) +{ + switch (event) { + case EVT_KEY_BREAK(KEY_EXIT): + chainMenu(menuMainView); + event = 0; + return false; + } + + return menuChannelsView(event); +} diff --git a/radio/src/gui/Horus/view_statistics.cpp b/radio/src/gui/Horus/view_statistics.cpp new file mode 100644 index 000000000..07de7d819 --- /dev/null +++ b/radio/src/gui/Horus/view_statistics.cpp @@ -0,0 +1,218 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../../opentx.h" + +bool menuStatisticsView(evt_t event) +{ + switch(event) { + case EVT_KEY_FIRST(KEY_UP): + chainMenu(menuStatisticsDebug); + return false; + + case EVT_KEY_LONG(KEY_MENU): + g_eeGeneral.globalTimer = 0; + storageDirty(EE_GENERAL); + sessionTimer = 0; + break; + + case EVT_KEY_FIRST(KEY_EXIT): + chainMenu(menuMainView); + return false; + } + + drawScreenTemplate("Statistics"); + + lcdDrawText( 10, MENU_CONTENT_TOP + FH*0, "\037\145TOT:\037\317BATT:", HEADER_COLOR); + lcdDrawText( 10, MENU_CONTENT_TOP + FH*1, "TM1:\037\145TM2:", HEADER_COLOR); + lcdDrawText( 10, MENU_CONTENT_TOP + FH*2, "THR:\037\145TH%:", HEADER_COLOR); + + putsTimer( 45, MENU_CONTENT_TOP + FH*1, timersStates[0].val); + putsTimer( 140, MENU_CONTENT_TOP + FH*1, timersStates[1].val); + putsTimer( 45, MENU_CONTENT_TOP + FH*2, s_timeCumThr); + putsTimer( 140, MENU_CONTENT_TOP + FH*2, s_timeCum16ThrP/16); + putsTimer( 140, MENU_CONTENT_TOP + FH*0, sessionTimer); + putsTimer( 250, MENU_CONTENT_TOP + 0*FH, g_eeGeneral.globalTimer+sessionTimer, TIMEHOUR); + +#if defined(THRTRACE) + coord_t traceRd = (s_traceCnt < 0 ? s_traceWr : 0); + const coord_t x = 4; + const coord_t y = 200; + lcdDrawHorizontalLine(x-3, y, MAXTRACE+3+3, SOLID, TEXT_COLOR); + lcdDrawVerticalLine(x, y-96, 96+3, SOLID, TEXT_COLOR); + + for (coord_t i=0; i=MAXTRACE) traceRd = 0; + if (traceRd==s_traceWr) break; + } +#endif + + return true; +} + +#define MENU_DEBUG_COL1_OFS (11*10-2) +#define MENU_DEBUG_Y_MIXMAX (MENU_CONTENT_TOP + 2*FH) +#define MENU_DEBUG_Y_LUA (MENU_CONTENT_TOP + 3*FH) +#define MENU_DEBUG_Y_FREE_RAM (MENU_CONTENT_TOP + 4*FH) +#define MENU_DEBUG_Y_STACK (MENU_CONTENT_TOP + 5*FH) +#define MENU_DEBUG_Y_RTOS (MENU_CONTENT_TOP + 6*FH) + +bool menuStatisticsDebug(evt_t event) +{ + switch(event) + { + case EVT_KEY_LONG(KEY_ENTER): + g_eeGeneral.mAhUsed = 0; + g_eeGeneral.globalTimer = 0; + storageDirty(EE_GENERAL); + sessionTimer = 0; + killEvents(event); + AUDIO_KEYPAD_UP(); + break; + + case EVT_KEY_FIRST(KEY_ENTER): +#if defined(LUA) + maxLuaInterval = 0; + maxLuaDuration = 0; +#endif + maxMixerDuration = 0; + AUDIO_KEYPAD_UP(); + break; + +#if defined(DEBUG_TRACE_BUFFER) + case EVT_KEY_FIRST(KEY_UP): + pushMenu(menuTraceBuffer); + return false; +#endif + + case EVT_KEY_FIRST(KEY_DOWN): + chainMenu(menuStatisticsView); + return false; + + case EVT_KEY_FIRST(KEY_EXIT): + chainMenu(menuMainView); + return false; + } + + drawScreenTemplate(STR_MENUDEBUG); + + lcdDrawText(MENUS_MARGIN_LEFT, MENU_DEBUG_Y_FREE_RAM, "Free Mem"); + lcdDrawNumber(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_FREE_RAM, availableMemory(), LEFT, 0, NULL, "b"); + +#if defined(LUA) + lcdDrawText(MENUS_MARGIN_LEFT, MENU_DEBUG_Y_LUA, "Lua scripts"); + lcdDrawText(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_LUA+1, "[Duration]", HEADER_COLOR|SMLSIZE); + lcdDrawNumber(MENU_DEBUG_COL1_OFS+30, MENU_DEBUG_Y_LUA, 10*maxLuaDuration, LEFT); + lcdDrawText(MENU_DEBUG_COL1_OFS+60, MENU_DEBUG_Y_LUA+1, "[Interval]", HEADER_COLOR|SMLSIZE); + lcdDrawNumber(MENU_DEBUG_COL1_OFS+90, MENU_DEBUG_Y_LUA, 10*maxLuaInterval, LEFT); +#endif + + lcdDrawText(MENUS_MARGIN_LEFT, MENU_DEBUG_Y_MIXMAX, STR_TMIXMAXMS); + lcdDrawNumber(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_MIXMAX, DURATION_MS_PREC2(maxMixerDuration), PREC2|LEFT, 0, NULL, "ms"); + + lcdDrawText(MENUS_MARGIN_LEFT, MENU_DEBUG_Y_RTOS, STR_FREESTACKMINB); + lcdDrawText(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_RTOS+1, "[Menus]", HEADER_COLOR|SMLSIZE); + lcdDrawNumber(MENU_DEBUG_COL1_OFS+30, MENU_DEBUG_Y_RTOS, menusStack.available(), LEFT); + lcdDrawText(MENU_DEBUG_COL1_OFS+60, MENU_DEBUG_Y_RTOS+1, "[Mix]", HEADER_COLOR|SMLSIZE); + lcdDrawNumber(MENU_DEBUG_COL1_OFS+90, MENU_DEBUG_Y_RTOS, mixerStack.available(), LEFT); + lcdDrawText(MENU_DEBUG_COL1_OFS+120, MENU_DEBUG_Y_RTOS+1, "[Audio]", HEADER_COLOR|SMLSIZE); + lcdDrawNumber(MENU_DEBUG_COL1_OFS+150, MENU_DEBUG_Y_RTOS, audioStack.available(), LEFT); + + lcd_putsCenter(7*FH+1, STR_MENUTORESET); + // lcd_status_line(); + + return true; +} + +#if defined(DEBUG_TRACE_BUFFER) +#include "stamp-opentx.h" + +bool menuTraceBuffer(evt_t event) +{ + switch(event) + { + case EVT_KEY_LONG(KEY_ENTER): + dumpTraceBuffer(); + killEvents(event); + break; + } + + SIMPLE_SUBMENU("Trace Buffer " VERS_STR, TRACE_BUFFER_LEN); + + /* RTC time */ + struct gtm t; + gettime(&t); + putsTime(LCD_W+1, 0, t, TIMEBLINK); + + uint8_t y = 0; + uint8_t k = 0; + int8_t sub = m_posVert; + + lcdDrawChar(0, FH, '#', TEXT_COLOR); + lcdDrawText(4*10, FH, "Time"); + lcdDrawText(14*10, FH, "Event"); + lcdDrawText(20*10, FH, "Data"); + + for (uint8_t i=0; itime % SECS_PER_DAY; + putsTimer(4*10, y, tme, TIMEHOUR|LEFT); + //event + lcdDrawNumber(14*10, y, te->event, LEADING0|LEFT, 3); + //data + lcd_putsn (20*10, y, "0x", 2); + lcd_outhex4(22*10-2, y, (uint16_t)(te->data >> 16)); + lcd_outhex4(25*10, y, (uint16_t)(te->data & 0xFFFF)); + } + + } + + return true; +} +#endif // defined(DEBUG_TRACE_BUFFER) diff --git a/radio/src/gui/Horus/view_telemetry.cpp b/radio/src/gui/Horus/view_telemetry.cpp new file mode 100644 index 000000000..d4ed7eab7 --- /dev/null +++ b/radio/src/gui/Horus/view_telemetry.cpp @@ -0,0 +1,202 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../../opentx.h" + +#define STATUS_BAR_Y (7*FH+1) +#define TELEM_2ND_COLUMN (11*10) + +#if defined(FRSKY_HUB) && defined(GAUGES) +bar_threshold_t barsThresholds[THLD_MAX]; +#endif + +NOINLINE uint8_t getRssiAlarmValue(uint8_t alarm) +{ + return (45 - 3*alarm + g_model.frsky.rssiAlarms[alarm].value); +} + +int barCoord(int value, int min, int max, int width) +{ + if (value <= min) + return 0; + else if (value >= max) + return width; + else + return (width * (value - min) + (max - min)/2) / (max - min); +} + +void displayGaugesTelemetryScreen(FrSkyScreenData & screen) +{ + const int GAUGE_MARGIN = 16; + const int GAUGE_HEIGHT = 25; + const int GAUGE_WIDTH = LCD_W - 2*GAUGE_MARGIN; + const int GAUGE_PADDING_HORZ = 4; + const int GAUGE_PADDING_VERT = 2; + const int VAL_WIDTH = 50; + const int BAR_WIDTH = GAUGE_WIDTH-2*GAUGE_PADDING_HORZ-VAL_WIDTH; + + for (int i=0; i<4; ++i) { + FrSkyBarData & bar = screen.bars[i]; + source_t source = bar.source; + getvalue_t barMin = bar.barMin; + getvalue_t barMax = bar.barMax; + if (source <= MIXSRC_LAST_CH) { + barMin = calc100toRESX(barMin); + barMax = calc100toRESX(barMax); + } + if (source && barMax > barMin) { + int y = GAUGE_MARGIN + i*(GAUGE_HEIGHT+GAUGE_MARGIN); + + // The black background + lcdDrawSolidFilledRect(GAUGE_MARGIN, y, GAUGE_WIDTH, GAUGE_HEIGHT, TEXT_BGCOLOR); + + getvalue_t value = getValue(source); + LcdFlags color = TEXT_COLOR; + if (source >= MIXSRC_FIRST_TELEM) { + TelemetryItem & telemetryItem = telemetryItems[(source-MIXSRC_FIRST_TELEM)/3]; // TODO macro to convert a source to a telemetry index + if (!telemetryItem.isAvailable()) { + continue; + } + else if (telemetryItem.isOld()) { + color = ALARM_COLOR; + } + } + else if (source >= MIXSRC_FIRST_TIMER && source <= MIXSRC_LAST_TIMER) { + if (value < 0) { + putsMixerSource(GAUGE_MARGIN+GAUGE_PADDING_HORZ, y+GAUGE_PADDING_VERT, source, ALARM_COLOR); + putsTimer(GAUGE_MARGIN+GAUGE_WIDTH-VAL_WIDTH, y+GAUGE_PADDING_VERT+3, -value, LEFT|DBLSIZE|ALARM_COLOR); + // TODO lcdDrawSolidFilledRect(GAUGE_MARGIN+GAUGE_PADDING_HORZ, y+15, BAR_WIDTH, 6, ALARM_BGCOLOR); + continue; + } + } + + // The label + putsMixerSource(GAUGE_MARGIN+GAUGE_PADDING_HORZ, y+GAUGE_PADDING_VERT, source, color); + + // The value + putsChannel(GAUGE_MARGIN+GAUGE_WIDTH-VAL_WIDTH, y+GAUGE_PADDING_VERT+3, source, LEFT|DBLSIZE|NO_UNIT|color); + + // The bar + // TODO lcdDrawSolidFilledRect(GAUGE_MARGIN+GAUGE_PADDING_HORZ, y+15, BAR_WIDTH, 6, SOLID, color); + //uint8_t thresholdX = 0; + int width = barCoord(value, barMin, barMax, BAR_WIDTH-2); + //uint8_t barShade = SOLID; + lcdDrawSolidFilledRect(GAUGE_MARGIN+GAUGE_PADDING_HORZ+1, y+16, width, 4, TEXT_BGCOLOR); +/* for (uint8_t j=24; j<99; j+=25) { + if (j>thresholdX || j>width) { + lcd_vline(j*BAR_WIDTH/100+BAR_LEFT+1, y+1, barHeight); + } + } + if (thresholdX) { + lcdDrawVerticalLine(BAR_LEFT+1+thresholdX, y-2, barHeight+3, DOTTED); + lcdDrawSolidHorizontalLine(BAR_LEFT+thresholdX, y-2, 3); + } + */ + } + } +} + +void displayNumbersTelemetryScreen(FrSkyScreenData & screen) +{ + const int NUMBERS_W = 56; + const int NUMBERS_H = 30; + const int NUMBERS_MARGIN = 16; + const int NUMBERS_PADDING = 4; + + for (int i=0; i<4; i++) { + for (int j=0; j= MIXSRC_FIRST_TELEM) { + TelemetryItem & telemetryItem = telemetryItems[(field-MIXSRC_FIRST_TELEM)/3]; // TODO macro to convert a source to a telemetry index + if (!telemetryItem.isAvailable()) { + continue; + } + else if (telemetryItem.isOld()) { + color = RED; + } + } + else if (field >= MIXSRC_FIRST_TIMER && field <= MIXSRC_LAST_TIMER) { + TimerState & timerState = timersStates[field-MIXSRC_FIRST_TIMER]; + if (timerState.val < 0) { + color = RED; + } + putsMixerSource(x+NUMBERS_PADDING, y+2, field, color); + putsTimer(x+NUMBERS_PADDING, y+12, abs(timerState.val), LEFT|DBLSIZE|color); + continue; + } + putsMixerSource(x+NUMBERS_PADDING, y+2, field, color); + putsChannel(x+NUMBERS_PADDING, y+12, field, LEFT|DBLSIZE|NO_UNIT|color); + } + } + } +} + +void displayCustomTelemetryScreen(uint8_t index) +{ + FrSkyScreenData & screen = g_model.frsky.screens[index]; + +#if defined(GAUGES) + if (IS_BARS_SCREEN(index)) { + return displayGaugesTelemetryScreen(screen); + } +#endif + + displayNumbersTelemetryScreen(screen); +} + +void displayTelemetryScreen(int index, unsigned int evt) +{ +#if defined(LUA) + if (TELEMETRY_SCREEN_TYPE(index) == TELEMETRY_SCREEN_TYPE_SCRIPT) { + luaTask(evt, RUN_TELEM_FG_SCRIPT, true); + return; + } +#endif + + if (TELEMETRY_SCREEN_TYPE(index) == TELEMETRY_SCREEN_TYPE_NONE) { + return; + } + + if (index < MAX_TELEMETRY_SCREENS) { + return displayCustomTelemetryScreen(index); + } +} diff --git a/radio/src/gui/Horus/view_text.cpp b/radio/src/gui/Horus/view_text.cpp new file mode 100644 index 000000000..db12a6d69 --- /dev/null +++ b/radio/src/gui/Horus/view_text.cpp @@ -0,0 +1,161 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../../opentx.h" + +#define TEXT_FILE_MAXSIZE 2048 + +char s_text_file[TEXT_FILENAME_MAXLEN]; +char s_text_screen[NUM_BODY_LINES][LCD_COLS+1]; + +void readTextFile(int & lines_count) +{ + FIL file; + int result; + char c; + unsigned int sz; + int line_length = 0; + int escape = 0; + char escape_chars[2]; + int current_line = 0; + + memset(s_text_screen, 0, sizeof(s_text_screen)); + + result = f_open(&file, s_text_file, FA_OPEN_EXISTING | FA_READ); + if (result == FR_OK) { + for (int i=0; i=s_pgOfs && current_line-s_pgOfs0 && escape<3) { + escape_chars[escape-1] = c; + if (escape == 2 && !strncmp(escape_chars, "up", 2)) { + c = '\300'; + escape = 0; + } + else if (escape == 2 && !strncmp(escape_chars, "dn", 2)) { + c = '\301'; + escape = 0; + } + else { + escape++; + continue; + } + } + else if (c=='~') { + c = 'z'+1; + } + else if (c=='\t') { + c = 0x1D; //tab + } + escape = 0; + s_text_screen[current_line-s_pgOfs][line_length++] = c; + } + } + if (c != '\n') { + current_line += 1; + } + f_close(&file); + } + + if (lines_count == 0) { + lines_count = current_line; + } +} + +bool menuTextView(evt_t event) +{ + static int lines_count; + + drawMenuTemplate("TEXT VIEWER"); + + switch (event) { + case EVT_ENTRY: + s_pgOfs = 0; + lines_count = 0; + readTextFile(lines_count); + break; + + case EVT_KEY_FIRST(KEY_UP): + if (s_pgOfs == 0) + break; + else + s_pgOfs--; + readTextFile(lines_count); + break; + + case EVT_KEY_FIRST(KEY_DOWN): + if (s_pgOfs+NUM_BODY_LINES >= lines_count) + break; + else + ++s_pgOfs; + readTextFile(lines_count); + break; + + case EVT_KEY_BREAK(KEY_EXIT): + popMenu(); + break; + } + + for (int i=0; i + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../../opentx.h" +#include + +#define COLUMN_HEADER_X 150 + +void displayHeader(const char *header) +{ + // TODO ? lcdDrawText(COLUMN_HEADER_X, MENU_FOOTER_TOP, header, HEADER_COLOR); +} + +void displayColumnHeader(const char * const *headers, uint8_t index) +{ + // TODO ? displayHeader(headers[index]); +} + +const char * STR_MONTHS[] = { "Jan", "Fev", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; + +#define DATETIME_SEPARATOR_X 425 +#define DATETIME_LINE1 9 +#define DATETIME_LINE2 23 +#define DATETIME_LEFT(s) (LCD_W+DATETIME_SEPARATOR_X+8-getTextWidth(s, SMLSIZE))/2 + +void drawTopmenuDatetime() +{ + lcdDrawSolidVerticalLine(DATETIME_SEPARATOR_X, 7, 31, TEXT_INVERTED_COLOR); + + struct gtm t; + gettime(&t); + char str[10]; + sprintf(str, "%d %s", t.tm_mday, STR_MONTHS[t.tm_mon]); + lcdDrawText(DATETIME_LEFT(str), DATETIME_LINE1, str, SMLSIZE|TEXT_INVERTED_COLOR); + + getTimerString(str, getValue(MIXSRC_TX_TIME)); + lcdDrawText(DATETIME_LEFT(str), DATETIME_LINE2, str, SMLSIZE|TEXT_INVERTED_COLOR); +} + +void drawStick(coord_t centrex, int16_t xval, int16_t yval) +{ +#define BOX_CENTERY (220 - FH - BOX_WIDTH/2) +#define MARKER_WIDTH 5 + + lcdDrawSquare(centrex-BOX_WIDTH/2, BOX_CENTERY-BOX_WIDTH/2, BOX_WIDTH, TEXT_COLOR); + lcdDrawVerticalLine(centrex, BOX_CENTERY-1, 3, SOLID, TEXT_COLOR); + lcdDrawHorizontalLine(centrex-1, BOX_CENTERY, 3, SOLID, TEXT_COLOR); + lcdDrawSquare(centrex + (xval/((2*RESX)/(BOX_WIDTH-MARKER_WIDTH))) - MARKER_WIDTH/2, BOX_CENTERY - (yval/((2*RESX)/(BOX_WIDTH-MARKER_WIDTH))) - MARKER_WIDTH/2, MARKER_WIDTH, ROUND|TEXT_COLOR); + +#undef BOX_CENTERY +#undef MARKER_WIDTH +} + +void drawCheckBox(coord_t x, coord_t y, uint8_t value, LcdFlags attr) +{ + if (attr) { + lcdDrawSolidFilledRect(x-1, y+2, 13, 13, TEXT_INVERTED_BGCOLOR); + lcdDrawSolidFilledRect(x+1, y+4, 9, 9, TEXT_BGCOLOR); + if (value) { + lcdDrawSolidFilledRect(x+2, y+5, 7, 7, TEXT_INVERTED_BGCOLOR); + } + } + else { + if (value) { + lcdDrawSolidFilledRect(x+2, y+5, 7, 7, SCROLLBOX_COLOR); + lcdDrawSolidRect(x, y+3, 11, 11, LINE_COLOR); + } + else { + lcdDrawSolidRect(x, y+3, 11, 11, LINE_COLOR); + } + } +} + +void drawScrollbar(coord_t x, coord_t y, coord_t h, uint16_t offset, uint16_t count, uint8_t visible) +{ + if (visible < count) { + lcdDrawSolidVerticalLine(x, y, h, LINE_COLOR); + coord_t yofs = (h*offset + count/2) / count; + coord_t yhgt = (h*visible + count/2) / count; + if (yhgt + yofs > h) + yhgt = h - yofs; + lcdDrawSolidFilledRect(x-1, y + yofs, 3, yhgt, SCROLLBOX_COLOR); + } +} + +void drawProgressBar(const char *label) +{ + lcdDrawText(MENUS_MARGIN_LEFT, 4*FH, label); + lcdDrawRect(3, 6*FH+4, 204, 7); + lcdRefresh(); +} + +void updateProgressBar(int num, int den) +{ + if (num > 0 && den > 0) { + int width = (200*num)/den; + lcdDrawSolidFilledRect(5, 6*FH+6, width, 3, LINE_COLOR); + lcdRefresh(); + } +} + +void drawShadow(coord_t x, coord_t y, coord_t w, coord_t h) +{ + lcdDrawSolidVerticalLine(x+w, y+1, h, TEXT_COLOR); + lcdDrawSolidHorizontalLine(x+1, y+h, w, TEXT_COLOR); + lcdDrawSolidVerticalLine(x+w+1, y+2, h, LINE_COLOR); + lcdDrawSolidHorizontalLine(x+2, y+h+1, w, LINE_COLOR); +} + +void drawScreenTemplate(const char * title) +{ + // Header + lcdDrawSolidFilledRect(0, 0, LCD_W, MENU_HEADER_HEIGHT, HEADER_BGCOLOR); + lcdDrawBitmapPattern(0, 0, LBM_TOPMENU_POLYGON, TITLE_BGCOLOR); + drawTopmenuDatetime(); + + lcdDrawBitmapPattern(4, 10, LBM_TOPMENU_OPENTX, MENU_TITLE_COLOR); + + if (title) { + // must be done at the end so that we can write something at the right of the menu title + lcdDrawText(50, 3, title, MENU_TITLE_COLOR|DBLSIZE); + } + + // Body + lcdDrawSolidFilledRect(0, MENU_HEADER_HEIGHT, LCD_W, LCD_H-MENU_HEADER_HEIGHT-MENU_FOOTER_HEIGHT, TEXT_BGCOLOR); + + // Footer + lcdDrawSolidFilledRect(0, MENU_FOOTER_TOP, LCD_W, MENU_FOOTER_HEIGHT, HEADER_BGCOLOR); +} + +#define MENU_ICONS_SPACING 31 + +void drawSubmenuTemplate(const char * name, uint16_t scrollbar_X) +{ + // clear the screen + lcdDrawSolidFilledRect(0, 0, LCD_W, MENU_HEADER_HEIGHT, HEADER_BGCOLOR); + lcdDrawSolidFilledRect(0, MENU_HEADER_HEIGHT, LCD_W, MENU_TITLE_TOP-MENU_HEADER_HEIGHT, TEXT_BGCOLOR); + lcdDrawSolidFilledRect(0, MENU_TITLE_TOP, LCD_W, LCD_H-MENU_TITLE_TOP, TEXT_BGCOLOR); + + lcdDrawBitmapPattern(0, 0, LBM_TOPMENU_POLYGON, TITLE_BGCOLOR); + + lcdDrawSolidFilledRect(58+menuPageIndex*MENU_ICONS_SPACING-9, 0, 32, MENU_HEADER_HEIGHT, TITLE_BGCOLOR); + + const uint8_t * const * icons = (g_menuPos[0] == 0 ? LBM_MODEL_ICONS : LBM_RADIO_ICONS); + + lcdDrawBitmapPattern(5, 7, icons[0], MENU_TITLE_COLOR); + + for (int i=0; i NUM_BODY_LINES) { + drawScrollbar(scrollbar_X, DEFAULT_SCROLLBAR_Y, DEFAULT_SCROLLBAR_H, s_pgOfs, linesCount, NUM_BODY_LINES); + } +} + +void drawMenuTemplate(const char * name, uint16_t scrollbar_X) +{ + // clear the screen + lcdDrawSolidFilledRect(0, 0, LCD_W, MENU_HEADER_HEIGHT, HEADER_BGCOLOR); + lcdDrawSolidFilledRect(0, MENU_HEADER_HEIGHT, LCD_W, MENU_TITLE_TOP-MENU_HEADER_HEIGHT, TEXT_BGCOLOR); + lcdDrawSolidFilledRect(0, MENU_TITLE_TOP, LCD_W, MENU_TITLE_HEIGHT, TITLE_BGCOLOR); + lcdDrawSolidFilledRect(0, MENU_BODY_TOP, LCD_W, MENU_BODY_HEIGHT, TEXT_BGCOLOR); + lcdDrawSolidFilledRect(0, MENU_FOOTER_TOP, LCD_W, MENU_FOOTER_HEIGHT, HEADER_BGCOLOR); + + lcdDrawBitmapPattern(0, 0, LBM_TOPMENU_POLYGON, TITLE_BGCOLOR); + + if (m_posVert < 0) { + lcdDrawBitmapPattern(58+menuPageIndex*MENU_ICONS_SPACING-10, 0, LBM_CURRENT_BG, TITLE_BGCOLOR); + } + else { + lcdDrawSolidFilledRect(58+menuPageIndex*MENU_ICONS_SPACING-9, 0, 32, MENU_HEADER_HEIGHT, TITLE_BGCOLOR); + lcdDrawBitmapPattern(58+menuPageIndex*MENU_ICONS_SPACING, MENU_TITLE_TOP-9, LBM_DOT, MENU_TITLE_COLOR); + } + + const uint8_t * const * icons = (g_menuPos[0] == 0 ? LBM_MODEL_ICONS : LBM_RADIO_ICONS); + + lcdDrawBitmapPattern(5, 7, icons[0], MENU_TITLE_COLOR); + + for (int i=0; i NUM_BODY_LINES) { + drawScrollbar(scrollbar_X, DEFAULT_SCROLLBAR_Y, DEFAULT_SCROLLBAR_H, s_pgOfs, linesCount, NUM_BODY_LINES); + } +} + +select_menu_value_t selectMenuItem(coord_t x, coord_t y, const pm_char * values, select_menu_value_t value, select_menu_value_t min, select_menu_value_t max, LcdFlags attr, evt_t event) +{ + if (attr) value = checkIncDec(event, value, min, max, (g_menuPos[0] == 0) ? EE_MODEL : EE_GENERAL); + if (values) lcdDrawTextAtIndex(x, y, values, value-min, attr); + return value; +} + +uint8_t onoffMenuItem(uint8_t value, coord_t x, coord_t y, LcdFlags attr, evt_t event ) +{ + drawCheckBox(x, y, value, attr); + return selectMenuItem(x, y, NULL, value, 0, 1, attr, event); +} + +int8_t switchMenuItem(coord_t x, coord_t y, int8_t value, LcdFlags attr, evt_t event) +{ + if (attr) CHECK_INCDEC_MODELSWITCH(event, value, SWSRC_FIRST_IN_MIXES, SWSRC_LAST_IN_MIXES, isSwitchAvailableInMixes); + putsSwitches(x, y, value, attr); + return value; +} + +void drawSlider(coord_t x, coord_t y, uint8_t value, uint8_t max, uint8_t attr) +{ + const int width = 50; + lcdDrawHorizontalLine(x, y+5, width, SOLID, TEXT_COLOR); + if (attr && (!(attr & BLINK) || !BLINK_ON_PHASE)) { + lcdDrawSolidFilledRect(x+value*(width-5)/max, y, 5, 11, TEXT_INVERTED_BGCOLOR); + } + else { + lcdDrawSolidFilledRect(x+value*(width-5)/max, y, 5, 11, LINE_COLOR); + } +} + +#if defined(GVARS) +bool noZero(int val) +{ + return val != 0; +} + +int16_t gvarMenuItem(coord_t x, coord_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, uint8_t editflags, evt_t event) +{ + uint16_t delta = GV_GET_GV1_VALUE(max); + bool invers = (attr & INVERS); + + // TRACE("gvarMenuItem(val=%d min=%d max=%d)", value, min, max); + + if (invers && event == EVT_KEY_LONG(KEY_ENTER)) { + s_editMode = !s_editMode; + if (attr & PREC1) + value = (GV_IS_GV_VALUE(value, min, max) ? GET_GVAR(value, min, max, mixerCurrentFlightMode)*10 : delta); + else + value = (GV_IS_GV_VALUE(value, min, max) ? GET_GVAR(value, min, max, mixerCurrentFlightMode) : delta); + storageDirty(EE_MODEL); + } + + if (GV_IS_GV_VALUE(value, min, max)) { + if (attr & LEFT) + attr -= LEFT; /* because of ZCHAR */ + else + x -= 20; + + attr &= ~PREC1; + + int8_t idx = (int16_t) GV_INDEX_CALC_DELTA(value, delta); + if (idx >= 0) ++idx; // transform form idx=0=GV1 to idx=1=GV1 in order to handle double keys invert + if (invers) { + CHECK_INCDEC_MODELVAR_CHECK(event, idx, -MAX_GVARS, MAX_GVARS, noZero); + if (idx == 0) idx = 1; // handle reset to zero, map to GV1 + } + if (idx < 0) { + value = (int16_t) GV_CALC_VALUE_IDX_NEG(idx, delta); + idx = -idx; + putsStrIdx(x, y, STR_GV, idx, attr, "-"); + } + else { + putsStrIdx(x, y, STR_GV, idx, attr); + value = (int16_t) GV_CALC_VALUE_IDX_POS(idx-1, delta); + } + } + else { + lcdDrawNumber(x, y, value, attr, 0, NULL, "%"); + if (invers) value = checkIncDec(event, value, min, max, EE_MODEL | editflags); + } + return value; +} +#else +int16_t gvarMenuItem(coord_t x, coord_t y, int16_t value, int16_t min, int16_t max, LcdFlags attr, evt_t event) +{ + if (attr & INVERS) value = checkIncDec(event, value, min, max, EE_MODEL); + lcdDrawNumber(x, y, value, attr, 0, NULL, "%"); + return value; +} +#endif diff --git a/radio/src/gui/Taranis/gui.h b/radio/src/gui/Taranis/gui.h index 5fd2f75eb..c11c1662a 100644 --- a/radio/src/gui/Taranis/gui.h +++ b/radio/src/gui/Taranis/gui.h @@ -40,6 +40,7 @@ #define DEFAULT_SCROLLBAR_X (LCD_W-1) #define NUM_BODY_LINES (LCD_LINES-1) #define MENU_HEADER_HEIGHT FH +#define MENU_INIT_VPOS 0 struct MenuItem { const char *name; @@ -49,9 +50,9 @@ struct MenuItem { int circularIncDec(int current, int inc, int min, int max, IsValueAvailable isValueAvailable=NULL); void displaySplash(); void displayScreenIndex(uint8_t index, uint8_t count, uint8_t attr); -void displayScrollbar(coord_t x, coord_t y, coord_t h, uint16_t offset, uint16_t count, uint8_t visible); +void drawScrollbar(coord_t x, coord_t y, coord_t h, uint16_t offset, uint16_t count, uint8_t visible); void displayMenuBar(const MenuItem *menu, int index); -void displayProgressBar(const char *label); +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); diff --git a/radio/src/gui/Taranis/helpers.cpp b/radio/src/gui/Taranis/helpers.cpp index e364d394f..58de6d51d 100644 --- a/radio/src/gui/Taranis/helpers.cpp +++ b/radio/src/gui/Taranis/helpers.cpp @@ -41,372 +41,3 @@ uint8_t switchToMix(uint8_t source) div_t qr = div(source-1, 3); return qr.quot+MIXSRC_FIRST_SWITCH; } - -int circularIncDec(int current, int inc, int min, int max, IsValueAvailable isValueAvailable) -{ - do { - current += inc; - if (current < min) - current = max; - else if (current > max) - current = min; - if (!isValueAvailable || isValueAvailable(current)) - return current; - } while(1); - return 0; -} - -bool isInputAvailable(int input) -{ - for (int i=0; ichn == input) - return true; - } - return false; -} - -bool isSourceAvailable(int source) -{ - if (source>=MIXSRC_FIRST_INPUT && source<=MIXSRC_LAST_INPUT) { - return isInputAvailable(source - MIXSRC_FIRST_INPUT); - } - -#if defined(LUA_MODEL_SCRIPTS) - if (source>=MIXSRC_FIRST_LUA && source<=MIXSRC_LAST_LUA) { - div_t qr = div(source-MIXSRC_FIRST_LUA, MAX_SCRIPT_OUTPUTS); - return (qr.rem=MIXSRC_FIRST_LUA && source<=MIXSRC_LAST_LUA) - return false; -#endif - - if (source>=MIXSRC_FIRST_POT && source<=MIXSRC_LAST_POT) { - return IS_POT_AVAILABLE(POT1+source-MIXSRC_FIRST_POT); - } - - if (source>=MIXSRC_FIRST_SWITCH && source<=MIXSRC_LAST_SWITCH) { - return SWITCH_EXISTS(source-MIXSRC_FIRST_SWITCH); - } - -#if !defined(HELI) - if (source>=MIXSRC_CYC1 && source<=MIXSRC_CYC3) - return false; -#endif - - if (source>=MIXSRC_CH1 && source<=MIXSRC_LAST_CH) { - uint8_t destCh = source-MIXSRC_CH1; - for (uint8_t i = 0; i < MAX_MIXERS; i++) { - MixData *md = mixAddress(i); - if (md->srcRaw == 0) return false; - if (md->destCh==destCh) return true; - } - return false; - } - - if (source>=MIXSRC_FIRST_LOGICAL_SWITCH && source<=MIXSRC_LAST_LOGICAL_SWITCH) { - LogicalSwitchData * cs = lswAddress(source-MIXSRC_SW1); - return (cs->func != LS_FUNC_NONE); - } - -#if !defined(GVARS) - if (source>=MIXSRC_GVAR1 && source<=MIXSRC_LAST_GVAR) - return false; -#endif - - if (source>=MIXSRC_RESERVE1 && source<=MIXSRC_RESERVE5) - return false; - - if (source>=MIXSRC_FIRST_TELEM && source<=MIXSRC_LAST_TELEM) { - div_t qr = div(source-MIXSRC_FIRST_TELEM, 3); - if (qr.rem == 0) - return isTelemetryFieldAvailable(qr.quot); - else - return isTelemetryFieldComparisonAvailable(qr.quot); - } - - return true; -} - -bool isSourceAvailableInGlobalFunctions(int source) -{ - if (source>=MIXSRC_FIRST_TELEM && source<=MIXSRC_LAST_TELEM) { - return false; - } - return isSourceAvailable(source); -} - -bool isSourceAvailableInCustomSwitches(int source) -{ - bool result = isSourceAvailable(source); - -#if defined(FRSKY) - if (result && source>=MIXSRC_FIRST_TELEM && source<=MIXSRC_LAST_TELEM) { - div_t qr = div(source-MIXSRC_FIRST_TELEM, 3); - result = isTelemetryFieldComparisonAvailable(qr.quot); - } -#endif - - return result; -} - -bool isInputSourceAvailable(int source) -{ - if (source>=MIXSRC_FIRST_POT && source<=MIXSRC_LAST_POT) { - return IS_POT_AVAILABLE(POT1+source-MIXSRC_FIRST_POT); - } - - if (source>=MIXSRC_Rud && source<=MIXSRC_MAX) - return true; - - if (source>=MIXSRC_FIRST_TRIM && source<=MIXSRC_LAST_TRIM) - return true; - - if (source>=MIXSRC_FIRST_SWITCH && source<=MIXSRC_LAST_SWITCH) - return SWITCH_EXISTS(source-MIXSRC_FIRST_SWITCH); - - if (source>=MIXSRC_FIRST_CH && source<=MIXSRC_LAST_CH) - return true; - - if (source>=MIXSRC_FIRST_TRAINER && source<=MIXSRC_LAST_TRAINER) - return true; - - if (source>=MIXSRC_FIRST_TELEM && source<=MIXSRC_LAST_TELEM) { - div_t qr = div(source-MIXSRC_FIRST_TELEM, 3); - return isTelemetryFieldAvailable(qr.quot) && isTelemetryFieldComparisonAvailable(qr.quot); - } - - return false; -} - -enum SwitchContext -{ - LogicalSwitchesContext, - ModelCustomFunctionsContext, - GeneralCustomFunctionsContext, - TimersContext, - MixesContext -}; - -bool isLogicalSwitchAvailable(int index) -{ - LogicalSwitchData * lsw = lswAddress(index); - return (lsw->func != LS_FUNC_NONE); -} - -bool isSwitchAvailable(int swtch, SwitchContext context) -{ - bool negative = false; - - if (swtch < 0) { - negative = true; - if (swtch == -SWSRC_ON || swtch == -SWSRC_ONE) { - return false; - } - swtch = -swtch; - } - - if (swtch >= SWSRC_SA0 && swtch <= SWSRC_LAST_SWITCH) { - div_t swinfo = switchInfo(swtch); - if (!SWITCH_EXISTS(swinfo.quot)) { - return false; - } - if (!IS_3POS(swinfo.quot)) { - if (negative) { - return false; - } - if (IS_3POS_MIDDLE(swinfo.rem)) { - return false; - } - } - return true; - } - - if (swtch >= SWSRC_FIRST_MULTIPOS_SWITCH && swtch <= SWSRC_LAST_MULTIPOS_SWITCH) { - int index = (swtch - SWSRC_FIRST_MULTIPOS_SWITCH) / XPOTS_MULTIPOS_COUNT; - if (IS_POT_MULTIPOS(POT1+index)) { - StepsCalibData * calib = (StepsCalibData *) &g_eeGeneral.calib[POT1+index]; - return (calib->count >= ((swtch - SWSRC_FIRST_MULTIPOS_SWITCH) % XPOTS_MULTIPOS_COUNT)); - } - else { - return false; - } - } - - if (swtch >= SWSRC_FIRST_LOGICAL_SWITCH && swtch <= SWSRC_LAST_LOGICAL_SWITCH) { - if (context == GeneralCustomFunctionsContext) { - return false; - } - else if (context != LogicalSwitchesContext) { - return isLogicalSwitchAvailable(swtch - SWSRC_FIRST_LOGICAL_SWITCH); - } - } - - if (context != ModelCustomFunctionsContext && context != GeneralCustomFunctionsContext && (swtch == SWSRC_ON || swtch == SWSRC_ONE)) { - return false; - } - - if (swtch >= SWSRC_FIRST_FLIGHT_MODE && swtch <= SWSRC_LAST_FLIGHT_MODE) { - if (context == MixesContext || context == GeneralCustomFunctionsContext) { - return false; - } - else { - swtch -= SWSRC_FIRST_FLIGHT_MODE; - if (swtch == 0) { - return true; - } - FlightModeData * fm = flightModeAddress(swtch); - return (fm->swtch != SWSRC_NONE); - } - } - - if (swtch >= SWSRC_FIRST_SENSOR && swtch <= SWSRC_LAST_SENSOR) { - return isTelemetryFieldAvailable(swtch - SWSRC_FIRST_SENSOR); - } - - return true; -} - -bool isSwitchAvailableInLogicalSwitches(int swtch) -{ - return isSwitchAvailable(swtch, LogicalSwitchesContext); -} - -bool isSwitchAvailableInCustomFunctions(int swtch) -{ - if (g_menuStack[g_menuStackPtr] == menuModelCustomFunctions) - return isSwitchAvailable(swtch, ModelCustomFunctionsContext); - else - return isSwitchAvailable(swtch, GeneralCustomFunctionsContext); -} - -bool isSwitchAvailableInMixes(int swtch) -{ - return isSwitchAvailable(swtch, MixesContext); -} - -bool isSwitchAvailableInTimers(int swtch) -{ - if (swtch >= 0) { - if (swtch < TMRMODE_COUNT) - return true; - else - swtch -= TMRMODE_COUNT-1; - } - else { - if (swtch > -TMRMODE_COUNT) - return false; - else - swtch += TMRMODE_COUNT-1; - } - - return isSwitchAvailable(swtch, TimersContext); -} - -bool isThrottleSourceAvailable(int source) -{ - if (source >= THROTTLE_SOURCE_FIRST_POT && source < THROTTLE_SOURCE_FIRST_POT+NUM_POTS && !IS_POT_AVAILABLE(POT1+source-THROTTLE_SOURCE_FIRST_POT)) - return false; - else - return true; -} - -bool isLogicalSwitchFunctionAvailable(int function) -{ - return function != LS_FUNC_RANGE; -} - -bool isAssignableFunctionAvailable(int function) -{ -#if defined(OVERRIDE_CHANNEL_FUNCTION) || defined(GVARS) - bool modelFunctions = (g_menuStack[g_menuStackPtr] == menuModelCustomFunctions); -#endif - - switch (function) { - case FUNC_OVERRIDE_CHANNEL: -#if defined(OVERRIDE_CHANNEL_FUNCTION) - return modelFunctions; -#else - return false; -#endif - case FUNC_ADJUST_GVAR: -#if defined(GVARS) - return modelFunctions; -#else - return false; -#endif -#if !defined(HAPTIC) - case FUNC_HAPTIC: -#endif - case FUNC_RESERVE4: -#if !defined(DANGEROUS_MODULE_FUNCTIONS) - case FUNC_RANGECHECK: - case FUNC_BIND: -#endif -#if !defined(LUA) - case FUNC_PLAY_SCRIPT: -#endif - case FUNC_RESERVE5: - return false; - - default: - return true; - } -} - -bool isSourceAvailableInGlobalResetSpecialFunction(int index) -{ - if (index >= FUNC_RESET_PARAM_FIRST_TELEM) - return false; - else - return isSourceAvailableInResetSpecialFunction(index); -} - -bool isSourceAvailableInResetSpecialFunction(int index) -{ - if (index >= FUNC_RESET_PARAM_FIRST_TELEM) { - TelemetrySensor & telemetrySensor = g_model.telemetrySensors[index-FUNC_RESET_PARAM_FIRST_TELEM]; - return telemetrySensor.isAvailable(); - } -#if TIMERS < 3 - else if (index == FUNC_RESET_TIMER3) { - return false; - } -#endif -#if TIMERS < 2 - else if (index == FUNC_RESET_TIMER2) { - return false; - } -#endif - else { - return true; - } -} - -bool isModuleAvailable(int module) -{ - return true; -} - -bool modelHasNotes() -{ - char filename[sizeof(MODELS_PATH)+1+sizeof(g_model.header.name)+sizeof(TEXT_EXT)] = MODELS_PATH "/"; - char *buf = strcat_modelname(&filename[sizeof(MODELS_PATH)], g_eeGeneral.currModel); - strcpy(buf, TEXT_EXT); - return isFileAvailable(filename); -} - -int getFirstAvailable(int min, int max, bool (*func)(int)) -{ - int retval = 0; - for (int i = min; i <= max; i++) { - if ((*func)(i)) { - retval = i; - break; - } - } - return retval; -} diff --git a/radio/src/gui/Taranis/lcd.cpp b/radio/src/gui/Taranis/lcd.cpp index 34ec0c038..a4303b53d 100644 --- a/radio/src/gui/Taranis/lcd.cpp +++ b/radio/src/gui/Taranis/lcd.cpp @@ -38,11 +38,11 @@ #include "../../timers.h" #if defined(REVPLUS) && defined(LCD_DUAL_BUFFER) - display_t displayBuf1[DISPLAY_BUF_SIZE] __DMA; - display_t displayBuf2[DISPLAY_BUF_SIZE] __DMA; + display_t displayBuf1[DISPLAY_BUFFER_SIZE] __DMA; + display_t displayBuf2[DISPLAY_BUFFER_SIZE] __DMA; display_t * displayBuf = displayBuf1; #else - display_t displayBuf[DISPLAY_BUF_SIZE] __DMA; + display_t displayBuf[DISPLAY_BUFFER_SIZE] __DMA; #endif inline bool lcdIsPointOutside(coord_t x, coord_t y) @@ -50,9 +50,9 @@ inline bool lcdIsPointOutside(coord_t x, coord_t y) return (x<0 || x>=LCD_W || y<0 || y>=LCD_H); } -void lcd_clear() +void lcdClear() { - memset(displayBuf, 0, DISPLAY_BUFER_SIZE); + memset(displayBuf, 0, DISPLAY_BUFFER_SIZE); } coord_t lcdLastPos; @@ -143,7 +143,7 @@ void lcdPutPattern(coord_t x, coord_t y, const uint8_t * pattern, uint8_t width, } } -void lcd_putcAtt(coord_t x, coord_t y, const unsigned char c, LcdFlags flags) +void lcdDrawChar(coord_t x, coord_t y, const unsigned char c, LcdFlags flags) { const pm_uchar * q; @@ -215,10 +215,10 @@ void lcd_putcAtt(coord_t x, coord_t y, const unsigned char c, LcdFlags flags) void lcd_putc(coord_t x, coord_t y, const unsigned char c) { - lcd_putcAtt(x, y, c, 0); + lcdDrawChar(x, y, c, 0); } -void lcd_putsnAtt(coord_t x, coord_t y, const pm_char * s, uint8_t len, LcdFlags flags) +void lcdDrawTextWithLen(coord_t x, coord_t y, const pm_char * s, uint8_t len, LcdFlags flags) { const coord_t orig_x = x; const uint8_t orig_len = len; @@ -248,7 +248,7 @@ void lcd_putsnAtt(coord_t x, coord_t y, const pm_char * s, uint8_t len, LcdFlags break; } else if (c >= 0x20) { - lcd_putcAtt(x, y, c, flags); + lcdDrawChar(x, y, c, flags); x = lcdNextPos; } else if (c == 0x1F) { //X-coord prefix @@ -283,17 +283,17 @@ void lcd_putsnAtt(coord_t x, coord_t y, const pm_char * s, uint8_t len, LcdFlags void lcd_putsn(coord_t x, coord_t y, const pm_char * s, uint8_t len) { - lcd_putsnAtt(x, y, s, len, 0); + lcdDrawTextWithLen(x, y, s, len, 0); } -void lcd_putsAtt(coord_t x, coord_t y, const pm_char * s, LcdFlags flags) +void lcdDrawText(coord_t x, coord_t y, const pm_char * s, LcdFlags flags) { - lcd_putsnAtt(x, y, s, 255, flags); + lcdDrawTextWithLen(x, y, s, 255, flags); } void lcd_puts(coord_t x, coord_t y, const pm_char * s) { - lcd_putsAtt(x, y, s, 0); + lcdDrawText(x, y, s, 0); } void lcd_putsLeft(coord_t y, const pm_char * s) @@ -302,10 +302,10 @@ void lcd_putsLeft(coord_t y, const pm_char * s) } #if !defined(BOOT) -void lcd_putsiAtt(coord_t x, coord_t y, const pm_char * s,uint8_t idx, LcdFlags flags) +void lcdDrawTextAtIndex(coord_t x, coord_t y, const pm_char * s,uint8_t idx, LcdFlags flags) { uint8_t length = pgm_read_byte(s++); - lcd_putsnAtt(x, y, s+length*idx, length, flags & ~(BSS|ZCHAR)); + lcdDrawTextWithLen(x, y, s+length*idx, length, flags & ~(BSS|ZCHAR)); } void lcd_outhex4(coord_t x, coord_t y, uint32_t val, LcdFlags flags) @@ -315,7 +315,7 @@ void lcd_outhex4(coord_t x, coord_t y, uint32_t val, LcdFlags flags) x -= FWNUM; char c = val & 0xf; c = c>9 ? c+'A'-10 : c+'0'; - lcd_putcAtt(x, y, c, flags|(c>='A' ? CONDENSED : 0)); + lcdDrawChar(x, y, c, flags|(c>='A' ? CONDENSED : 0)); val >>= 4; } } @@ -325,12 +325,12 @@ void lcd_outdez8(coord_t x, coord_t y, int8_t val) lcd_outdezAtt(x, y, val); } -void lcd_outdezAtt(coord_t x, coord_t y, lcdint_t val, LcdFlags flags) +void lcd_outdezAtt(coord_t x, coord_t y, int32_t val, LcdFlags flags) { lcd_outdezNAtt(x, y, val, flags); } -void lcd_outdezNAtt(coord_t x, coord_t y, lcdint_t val, LcdFlags flags, uint8_t len) +void lcd_outdezNAtt(coord_t x, coord_t y, int32_t val, LcdFlags flags, uint8_t len) { uint8_t fw = FWNUM; int8_t mode = MODE(flags); @@ -356,7 +356,7 @@ void lcd_outdezNAtt(coord_t x, coord_t y, lcdint_t val, LcdFlags flags, uint8_t if (mode != MODE(LEADING0)) { len = 1; - lcduint_t tmp = ((lcduint_t)val) / 10; + int32_t tmp = val / 10; while (tmp) { len++; tmp /= 10; @@ -400,10 +400,10 @@ void lcd_outdezNAtt(coord_t x, coord_t y, lcdint_t val, LcdFlags flags, uint8_t if (dblsize) x++; for (uint8_t i=1; i<=len; i++) { - div_t qr = div((lcduint_t)val, 10); + div_t qr = div(val, 10); char c = qr.rem + '0'; LcdFlags f = flags; - lcd_putcAtt(x, y, c, f); + lcdDrawChar(x, y, c, f); if (mode == i) { flags &= ~PREC2; // TODO not needed but removes 20bytes, could be improved for sure, check asm if (dblsize) { @@ -422,7 +422,7 @@ void lcd_outdezNAtt(coord_t x, coord_t y, lcdint_t val, LcdFlags flags, uint8_t } else if (xxlsize) { x -= 17; - lcd_putcAtt(x+2, y, '.', f); + lcdDrawChar(x+2, y, '.', f); } else if (midsize) { x -= 3; @@ -445,7 +445,7 @@ void lcd_outdezNAtt(coord_t x, coord_t y, lcdint_t val, LcdFlags flags, uint8_t } else { x -= 2; - lcd_putcAtt(x, y, '.', f); + lcdDrawChar(x, y, '.', f); } } val = qr.quot; @@ -469,17 +469,17 @@ void lcd_outdezNAtt(coord_t x, coord_t y, lcdint_t val, LcdFlags flags, uint8_t drawFilledRect(xn, y+2*FH-3, ln, 2); } } - if (neg) lcd_putcAtt(x, y, '-', flags); + if (neg) lcdDrawChar(x, y, '-', flags); } #endif void lcd_hline(coord_t x, coord_t y, coord_t w, LcdFlags att) { - lcd_hlineStip(x, y, w, 0xff, att); + lcdDrawHorizontalLine(x, y, w, 0xff, att); } #if !defined(BOOT) -void lcd_line(coord_t x1, coord_t y1, coord_t x2, coord_t y2, uint8_t pat, LcdFlags att) +void lcdDrawLine(coord_t x1, coord_t y1, coord_t x2, coord_t y2, uint8_t pat, LcdFlags att) { if (lcdIsPointOutside(x1, y1) || lcdIsPointOutside(x2, y2)) return; @@ -526,17 +526,17 @@ void lcd_line(coord_t x1, coord_t y1, coord_t x2, coord_t y2, uint8_t pat, LcdFl void lcd_vline(coord_t x, scoord_t y, scoord_t h) { - lcd_vlineStip(x, y, h, SOLID); + lcdDrawVerticalLine(x, y, h, SOLID); } #endif -void lcd_rect(coord_t x, coord_t y, coord_t w, coord_t h, uint8_t pat, LcdFlags att) +void lcdDrawRect(coord_t x, coord_t y, coord_t w, coord_t h, uint8_t pat, LcdFlags att) { - lcd_vlineStip(x, y, h, pat, att); - lcd_vlineStip(x+w-1, y, h, pat, att); + lcdDrawVerticalLine(x, y, h, pat, att); + lcdDrawVerticalLine(x+w-1, y, h, pat, att); if (~att & ROUND) { x+=1; w-=2; } - lcd_hlineStip(x, y+h-1, w, pat, att); - lcd_hlineStip(x, y, w, pat, att); + lcdDrawHorizontalLine(x, y+h-1, w, pat, att); + lcdDrawHorizontalLine(x, y, w, pat, att); } #if !defined(BOOT) @@ -544,9 +544,9 @@ void drawFilledRect(coord_t x, scoord_t y, coord_t w, coord_t h, uint8_t pat, Lc { for (scoord_t i=y; i> 1) + ((pat & 1) << 7); } } @@ -588,7 +588,7 @@ void putsTimer(coord_t x, coord_t y, putstime_t tme, LcdFlags att, LcdFlags att2 } if (tme < 0) { - lcd_putcAtt(x - ((att & DBLSIZE) ? FW+2 : ((att & MIDSIZE) ? FW+0 : FWNUM)), y, '-', att); + lcdDrawChar(x - ((att & DBLSIZE) ? FW+2 : ((att & MIDSIZE) ? FW+0 : FWNUM)), y, '-', att); tme = -tme; } @@ -598,7 +598,7 @@ void putsTimer(coord_t x, coord_t y, putstime_t tme, LcdFlags att, LcdFlags att2 if (att & TIMEHOUR) { div_t qr2 = div(qr.quot, 60); lcd_outdezNAtt(x, y, qr2.quot, att|LEADING0|LEFT, 2); - lcd_putcAtt(lcdLastPos, y, separator, att&att2); + lcdDrawChar(lcdLastPos, y, separator, att&att2); qr.quot = qr2.rem; if (att & MIDSIZE) x += 17; @@ -607,9 +607,9 @@ void putsTimer(coord_t x, coord_t y, putstime_t tme, LcdFlags att, LcdFlags att2 } lcd_outdezNAtt(x, y, qr.quot, att|LEADING0|LEFT, 2); if (att&TIMEBLINK) - lcd_putcAtt(lcdLastPos, y, separator, BLINK); + lcdDrawChar(lcdLastPos, y, separator, BLINK); else - lcd_putcAtt(lcdLastPos, y, separator, att&att2); + lcdDrawChar(lcdLastPos, y, separator, att&att2); lcd_outdezNAtt(lcdNextPos, y, qr.rem, att2|LEADING0|LEFT, 2); } @@ -617,7 +617,7 @@ void putsTimer(coord_t x, coord_t y, putstime_t tme, LcdFlags att, LcdFlags att2 void putsVolts(coord_t x, coord_t y, uint16_t volts, LcdFlags att) { lcd_outdezAtt(x, y, (int16_t)volts, (~NO_UNIT) & (att | ((att&PREC2)==PREC2 ? 0 : PREC1))); - if (~att & NO_UNIT) lcd_putcAtt(lcdLastPos, y, 'V', att); + if (~att & NO_UNIT) lcdDrawChar(lcdLastPos, y, 'V', att); } void putsVBat(coord_t x, coord_t y, LcdFlags att) @@ -627,26 +627,26 @@ void putsVBat(coord_t x, coord_t y, LcdFlags att) void putsStrIdx(coord_t x, coord_t y, const pm_char *str, uint8_t idx, LcdFlags att) { - lcd_putsAtt(x, y, str, att & ~LEADING0); + lcdDrawText(x, y, str, att & ~LEADING0); lcd_outdezNAtt(lcdNextPos, y, idx, att|LEFT, 2); } void putsStickName(coord_t x, coord_t y, uint8_t idx, LcdFlags att) { uint8_t length = STR_VSRCRAW[0]; - lcd_putsnAtt(x, y, STR_VSRCRAW+2+length*(idx+1), length-1, att); + lcdDrawTextWithLen(x, y, STR_VSRCRAW+2+length*(idx+1), length-1, att); } void putsMixerSource(coord_t x, coord_t y, uint32_t idx, LcdFlags att) { - if (idx == 0) { - lcd_putsiAtt(x, y, STR_VSRCRAW, 0, att); // TODO macro + if (idx == MIXSRC_NONE) { + lcdDrawTextAtIndex(x, y, STR_VSRCRAW, 0, att); // TODO macro } else if (idx <= MIXSRC_LAST_INPUT) { - lcd_putcAtt(x+2, y+1, CHR_INPUT, TINSIZE); + lcdDrawChar(x+2, y+1, CHR_INPUT, TINSIZE); drawFilledRect(x, y, 7, 7); if (ZEXIST(g_model.inputNames[idx-MIXSRC_FIRST_INPUT])) - lcd_putsnAtt(x+8, y, g_model.inputNames[idx-MIXSRC_FIRST_INPUT], LEN_INPUT_NAME, ZCHAR|att); + lcdDrawTextWithLen(x+8, y, g_model.inputNames[idx-MIXSRC_FIRST_INPUT], LEN_INPUT_NAME, ZCHAR|att); else lcd_outdezNAtt(x+8, y, idx, att|LEADING0|LEFT, 2); } @@ -655,15 +655,15 @@ void putsMixerSource(coord_t x, coord_t y, uint32_t idx, LcdFlags att) div_t qr = div(idx-MIXSRC_FIRST_LUA, MAX_SCRIPT_OUTPUTS); #if defined(LUA_MODEL_SCRIPTS) if (qr.quot < MAX_SCRIPTS && qr.rem < scriptInputsOutputs[qr.quot].outputsCount) { - lcd_putcAtt(x+2, y+1, '1'+qr.quot, TINSIZE); + lcdDrawChar(x+2, y+1, '1'+qr.quot, TINSIZE); drawFilledRect(x, y, 7, 7); - lcd_putsnAtt(x+8, y, scriptInputsOutputs[qr.quot].outputs[qr.rem].name, att & STREXPANDED ? 9 : 4, att); + lcdDrawTextWithLen(x+8, y, scriptInputsOutputs[qr.quot].outputs[qr.rem].name, att & STREXPANDED ? 9 : 4, att); } else #endif { putsStrIdx(x, y, "LUA", qr.quot+1, att); - lcd_putcAtt(lcdLastPos, y, 'a'+qr.rem, att); + lcdDrawChar(lcdLastPos, y, 'a'+qr.rem, att); } } @@ -671,27 +671,27 @@ void putsMixerSource(coord_t x, coord_t y, uint32_t idx, LcdFlags att) idx = idx-MIXSRC_Rud; if (ZEXIST(g_eeGeneral.anaNames[idx])) { if (idx < MIXSRC_FIRST_POT-MIXSRC_Rud ) - lcd_putcAtt(x, y, '\307', att); //stick symbol + lcdDrawChar(x, y, '\307', att); //stick symbol else if (idx < MIXSRC_FIRST_SLIDER-MIXSRC_Rud ) - lcd_putcAtt(x, y, '\310', att); //pot symbol + lcdDrawChar(x, y, '\310', att); //pot symbol else - lcd_putcAtt(x, y, '\311', att); //slider symbol - lcd_putsnAtt(lcdNextPos, y, g_eeGeneral.anaNames[idx], LEN_ANA_NAME, ZCHAR|att); + lcdDrawChar(x, y, '\311', att); //slider symbol + lcdDrawTextWithLen(lcdNextPos, y, g_eeGeneral.anaNames[idx], LEN_ANA_NAME, ZCHAR|att); } else - lcd_putsiAtt(x, y, STR_VSRCRAW, idx+1, att); + lcdDrawTextAtIndex(x, y, STR_VSRCRAW, idx+1, att); } else if (idx >= MIXSRC_FIRST_SWITCH && idx <= MIXSRC_LAST_SWITCH) { idx = idx-MIXSRC_FIRST_SWITCH; if (ZEXIST(g_eeGeneral.switchNames[idx])) { - lcd_putcAtt(x, y, '\312', att); //switch symbol - lcd_putsnAtt(lcdNextPos, y, g_eeGeneral.switchNames[idx], LEN_SWITCH_NAME, ZCHAR|att); + lcdDrawChar(x, y, '\312', att); //switch symbol + lcdDrawTextWithLen(lcdNextPos, y, g_eeGeneral.switchNames[idx], LEN_SWITCH_NAME, ZCHAR|att); } else - lcd_putsiAtt(x, y, STR_VSRCRAW, idx+MIXSRC_FIRST_SWITCH-MIXSRC_Rud+1, att); + lcdDrawTextAtIndex(x, y, STR_VSRCRAW, idx+MIXSRC_FIRST_SWITCH-MIXSRC_Rud+1, att); } else if (idx < MIXSRC_SW1) - lcd_putsiAtt(x, y, STR_VSRCRAW, idx-MIXSRC_Rud+1, att); + lcdDrawTextAtIndex(x, y, STR_VSRCRAW, idx-MIXSRC_Rud+1, att); else if (idx <= MIXSRC_LAST_LOGICAL_SWITCH) putsSwitches(x, y, SWSRC_SW1+idx-MIXSRC_SW1, att); else if (idx < MIXSRC_CH1) @@ -699,27 +699,27 @@ void putsMixerSource(coord_t x, coord_t y, uint32_t idx, LcdFlags att) else if (idx <= MIXSRC_LAST_CH) { putsStrIdx(x, y, STR_CH, idx-MIXSRC_CH1+1, att); if (ZEXIST(g_model.limitData[idx-MIXSRC_CH1].name) && (att & STREXPANDED)) { - lcd_putcAtt(lcdLastPos, y, ' ', att|SMLSIZE); - lcd_putsnAtt(lcdLastPos+3, y, g_model.limitData[idx-MIXSRC_CH1].name, LEN_CHANNEL_NAME, ZCHAR|att|SMLSIZE); + lcdDrawChar(lcdLastPos, y, ' ', att|SMLSIZE); + lcdDrawTextWithLen(lcdLastPos+3, y, g_model.limitData[idx-MIXSRC_CH1].name, LEN_CHANNEL_NAME, ZCHAR|att|SMLSIZE); } } else if (idx <= MIXSRC_LAST_GVAR) { putsStrIdx(x, y, STR_GV, idx-MIXSRC_GVAR1+1, att); } else if (idx < MIXSRC_FIRST_TELEM) { - lcd_putsiAtt(x, y, STR_VSRCRAW, idx-MIXSRC_Rud+1-NUM_LOGICAL_SWITCH-NUM_TRAINER-NUM_CHNOUT-MAX_GVARS, att); + lcdDrawTextAtIndex(x, y, STR_VSRCRAW, idx-MIXSRC_Rud+1-NUM_LOGICAL_SWITCH-NUM_TRAINER-NUM_CHNOUT-MAX_GVARS, att); } else { idx -= MIXSRC_FIRST_TELEM; div_t qr = div(idx, 3); - lcd_putsnAtt(x, y, g_model.telemetrySensors[qr.quot].label, TELEM_LABEL_LEN, ZCHAR|att); - if (qr.rem) lcd_putcAtt(lcdLastPos, y, qr.rem==2 ? '+' : '-', att); + lcdDrawTextWithLen(x, y, g_model.telemetrySensors[qr.quot].label, TELEM_LABEL_LEN, ZCHAR|att); + if (qr.rem) lcdDrawChar(lcdLastPos, y, qr.rem==2 ? '+' : '-', att); } } void putsChnLetter(coord_t x, coord_t y, uint8_t idx, LcdFlags att) { - lcd_putsiAtt(x, y, STR_RETA123, idx-1, att); + lcdDrawTextAtIndex(x, y, STR_RETA123, idx-1, att); } void putsModelName(coord_t x, coord_t y, char *name, uint8_t id, LcdFlags att) @@ -730,65 +730,71 @@ void putsModelName(coord_t x, coord_t y, char *name, uint8_t id, LcdFlags att) putsStrIdx(x, y, STR_MODEL, id+1, att|LEADING0); } else { - lcd_putsnAtt(x, y, name, sizeof(g_model.header.name), ZCHAR|att); + lcdDrawTextWithLen(x, y, name, sizeof(g_model.header.name), ZCHAR|att); } } void putsSwitches(coord_t x, coord_t y, int32_t idx, LcdFlags att) { if (idx == SWSRC_NONE) { - return lcd_putsiAtt(x, y, STR_VSWITCHES, 0, att); + return lcdDrawTextAtIndex(x, y, STR_VSWITCHES, 0, att); } else if (idx == SWSRC_OFF) { - return lcd_putsiAtt(x, y, STR_OFFON, 0, att); + return lcdDrawTextAtIndex(x, y, STR_OFFON, 0, att); } if (idx < 0) { - lcd_putcAtt(x-2, y, '!', att); + lcdDrawChar(x-2, y, '!', att); idx = -idx; } if (idx <= SWSRC_LAST_SWITCH) { div_t swinfo = switchInfo(idx); if (ZEXIST(g_eeGeneral.switchNames[swinfo.quot])) { - lcd_putsnAtt(x, y, g_eeGeneral.switchNames[swinfo.quot], LEN_SWITCH_NAME, ZCHAR|att); + lcdDrawTextWithLen(x, y, g_eeGeneral.switchNames[swinfo.quot], LEN_SWITCH_NAME, ZCHAR|att); } else { - lcd_putcAtt(x, y, 'S', att); - lcd_putcAtt(lcdNextPos, y, 'A'+swinfo.quot, att); + lcdDrawChar(x, y, 'S', att); + lcdDrawChar(lcdNextPos, y, 'A'+swinfo.quot, att); } char c = "\300-\301"[swinfo.rem]; - lcd_putcAtt(lcdNextPos, y, c, att); + lcdDrawChar(lcdNextPos, y, c, att); } else if (idx <= SWSRC_LAST_MULTIPOS_SWITCH) { div_t swinfo = div(idx - SWSRC_FIRST_MULTIPOS_SWITCH, XPOTS_MULTIPOS_COUNT); putsStrIdx(x, y, "S", swinfo.quot*10+swinfo.rem+11, att); } else if (idx <= SWSRC_LAST_TRIM) { - lcd_putsiAtt(x, y, STR_VSWITCHES, idx-SWSRC_FIRST_TRIM+1, att); + lcdDrawTextAtIndex(x, y, STR_VSWITCHES, idx-SWSRC_FIRST_TRIM+1, att); } else if (idx <= SWSRC_LAST_LOGICAL_SWITCH) { putsStrIdx(x, y, "L", idx-SWSRC_FIRST_LOGICAL_SWITCH+1, att); } else if (idx <= SWSRC_ONE) { - lcd_putsiAtt(x, y, STR_VSWITCHES, idx-SWSRC_ON+1+(2*NUM_STICKS), att); + lcdDrawTextAtIndex(x, y, STR_VSWITCHES, idx-SWSRC_ON+1+(2*NUM_STICKS), att); } else if (idx <= SWSRC_LAST_FLIGHT_MODE) { putsStrIdx(x, y, STR_FP, idx-SWSRC_FIRST_FLIGHT_MODE, att); } else if (idx == SWSRC_TELEMETRY_STREAMING) { - lcd_putsAtt(x, y, "Tele", att); + lcdDrawText(x, y, "Tele", att); + } + else if (idx <= SWSRC_LAST_FLIGHT_MODE) { + putsStrIdx(x, y, STR_FP, idx-SWSRC_FIRST_FLIGHT_MODE, att); + } + else if (idx == SWSRC_TELEMETRY_STREAMING) { + lcdDrawText(x, y, "Tele", att); } else { - lcd_putsnAtt(x, y, g_model.telemetrySensors[idx-SWSRC_FIRST_SENSOR].label, TELEM_LABEL_LEN, ZCHAR|att); + lcdDrawTextWithLen(x, y, g_model.telemetrySensors[idx-SWSRC_FIRST_SENSOR].label, TELEM_LABEL_LEN, ZCHAR|att); } } #if defined(FLIGHT_MODES) void putsFlightMode(coord_t x, coord_t y, int8_t idx, LcdFlags att) { - if (idx==0) { lcd_putsiAtt(x, y, STR_MMMINV, 0, att); return; } - if (idx < 0) { lcd_putcAtt(x-2, y, '!', att); idx = -idx; } + if (idx==0) { lcdDrawTextAtIndex(x, y, STR_MMMINV, 0, att); return; } + if (idx < 0) { lcdDrawChar(x-2, y, '!', att); idx = -idx; } if (att & CONDENSED) lcd_outdezNAtt(x+FW*1, y, idx-1, (att & ~CONDENSED), 1); else @@ -801,17 +807,17 @@ void putsCurveRef(coord_t x, coord_t y, CurveRef &curve, LcdFlags att) if (curve.value != 0) { switch (curve.type) { case CURVE_REF_DIFF: - lcd_putcAtt(x, y, 'D', att); + lcdDrawChar(x, y, 'D', att); GVAR_MENU_ITEM(x+FW, y, curve.value, -100, 100, LEFT|att, 0, 0); break; case CURVE_REF_EXPO: - lcd_putcAtt(x, y, 'E', att); + lcdDrawChar(x, y, 'E', att); GVAR_MENU_ITEM(x+FW, y, curve.value, -100, 100, LEFT|att, 0, 0); break; case CURVE_REF_FUNC: - lcd_putsiAtt(x, y, STR_VCURVEFUNC, curve.value, att); + lcdDrawTextAtIndex(x, y, STR_VCURVEFUNC, curve.value, att); break; case CURVE_REF_CUSTOM: @@ -824,11 +830,11 @@ void putsCurveRef(coord_t x, coord_t y, CurveRef &curve, LcdFlags att) void putsCurve(coord_t x, coord_t y, int8_t idx, LcdFlags att) { if (idx == 0) { - return lcd_putsiAtt(x, y, STR_MMMINV, 0, att); + return lcdDrawTextAtIndex(x, y, STR_MMMINV, 0, att); } if (idx < 0) { - lcd_putcAtt(x-3, y, '!', att); + lcdDrawChar(x-3, y, '!', att); idx = -idx; } @@ -839,7 +845,7 @@ void putsTimerMode(coord_t x, coord_t y, int32_t mode, LcdFlags att) { if (mode >= 0) { if (mode < TMRMODE_COUNT) - return lcd_putsiAtt(x, y, STR_VTMRMODES, mode, att); + return lcdDrawTextAtIndex(x, y, STR_VTMRMODES, mode, att); else mode -= (TMRMODE_COUNT-1); } @@ -853,14 +859,14 @@ void putsTrimMode(coord_t x, coord_t y, uint8_t phase, uint8_t idx, LcdFlags att unsigned int p = mode >> 1; if (mode == TRIM_MODE_NONE) { - lcd_putsAtt(x, y, "--", att); + lcdDrawText(x, y, "--", att); } else { if (mode % 2 == 0) - lcd_putcAtt(x, y, ':', att|FIXEDWIDTH); + lcdDrawChar(x, y, ':', att|FIXEDWIDTH); else - lcd_putcAtt(x, y, '+', att|FIXEDWIDTH); - lcd_putcAtt(lcdNextPos, y, '0'+p, att); + lcdDrawChar(x, y, '+', att|FIXEDWIDTH); + lcdDrawChar(lcdNextPos, y, '0'+p, att); } } @@ -875,12 +881,12 @@ const pm_uint8_t bchunit_ar[] PROGMEM = { UNIT_DIST, // GPS Alt }; -void putsValueWithUnit(coord_t x, coord_t y, lcdint_t val, uint8_t unit, LcdFlags att) +void putsValueWithUnit(coord_t x, coord_t y, int32_t val, uint8_t unit, LcdFlags att) { // convertUnit(val, unit); lcd_outdezAtt(x, y, val, att & (~NO_UNIT)); if (!(att & NO_UNIT) && unit != UNIT_RAW) { - lcd_putsiAtt(lcdLastPos/*+1*/, y, STR_VTELEMUNIT, unit, 0); + lcdDrawTextAtIndex(lcdLastPos/*+1*/, y, STR_VTELEMUNIT, unit, 0); } } @@ -888,7 +894,7 @@ void displayGpsCoord(coord_t x, coord_t y, char direction, int16_t bp, int16_t a { if (!direction) direction = '-'; lcd_outdezAtt(x, y, bp / 100, att); // ddd before '.' - lcd_putcAtt(lcdLastPos, y, '@', att); + lcdDrawChar(lcdLastPos, y, '@', att); uint8_t mn = bp % 100; // TODO div_t if (g_eeGeneral.gpsFormat == 0) { lcd_outdezNAtt(lcdNextPos, y, mn, att|LEFT|LEADING0, 2); // mm before '.' @@ -917,27 +923,27 @@ void displayDate(coord_t x, coord_t y, TelemetryItem & telemetryItem, LcdFlags a x -= 42; att &= ~0x0F00; // TODO constant lcd_outdezNAtt(x, y, telemetryItem.datetime.day, att|LEADING0|LEFT, 2); - lcd_putcAtt(lcdLastPos-1, y, '-', att); + lcdDrawChar(lcdLastPos-1, y, '-', att); lcd_outdezNAtt(lcdNextPos-1, y, telemetryItem.datetime.month, att|LEFT, 2); - lcd_putcAtt(lcdLastPos-1, y, '-', att); + lcdDrawChar(lcdLastPos-1, y, '-', att); lcd_outdezAtt(lcdNextPos-1, y, telemetryItem.datetime.year, att|LEFT); y += FH; lcd_outdezNAtt(x, y, telemetryItem.datetime.hour, att|LEADING0|LEFT, 2); - lcd_putcAtt(lcdLastPos, y, ':', att); + lcdDrawChar(lcdLastPos, y, ':', att); lcd_outdezNAtt(lcdNextPos, y, telemetryItem.datetime.min, att|LEADING0|LEFT, 2); - lcd_putcAtt(lcdLastPos, y, ':', att); + lcdDrawChar(lcdLastPos, y, ':', att); lcd_outdezNAtt(lcdNextPos, y, telemetryItem.datetime.sec, att|LEADING0|LEFT, 2); } else { lcd_outdezNAtt(x, y, telemetryItem.datetime.day, att|LEADING0|LEFT, 2); - lcd_putcAtt(lcdLastPos-1, y, '-', att); + lcdDrawChar(lcdLastPos-1, y, '-', att); lcd_outdezNAtt(lcdNextPos, y, telemetryItem.datetime.month, att|LEFT, 2); - lcd_putcAtt(lcdLastPos-1, y, '-', att); + lcdDrawChar(lcdLastPos-1, y, '-', att); lcd_outdezAtt(lcdNextPos, y, telemetryItem.datetime.year, att|LEFT); lcd_outdezNAtt(lcdNextPos+FW+1, y, telemetryItem.datetime.hour, att|LEADING0|LEFT, 2); - lcd_putcAtt(lcdLastPos, y, ':', att); + lcdDrawChar(lcdLastPos, y, ':', att); lcd_outdezNAtt(lcdNextPos, y, telemetryItem.datetime.min, att|LEADING0|LEFT, 2); - lcd_putcAtt(lcdLastPos, y, ':', att); + lcdDrawChar(lcdLastPos, y, ':', att); lcd_outdezNAtt(lcdNextPos, y, telemetryItem.datetime.sec, att|LEADING0|LEFT, 2); } } @@ -956,7 +962,7 @@ void displayGpsCoords(coord_t x, coord_t y, TelemetryItem & telemetryItem, LcdFl } } -void putsTelemetryChannelValue(coord_t x, coord_t y, uint8_t channel, lcdint_t value, LcdFlags att) +void putsTelemetryChannelValue(coord_t x, coord_t y, uint8_t channel, int32_t value, LcdFlags att) { if (channel >= MAX_SENSORS) return; //Lua luaLcdDrawChannel() can call us with a bad value TelemetryItem & telemetryItem = telemetryItems[channel]; @@ -977,7 +983,7 @@ void putsTelemetryChannelValue(coord_t x, coord_t y, uint8_t channel, lcdint_t v } } -void putsChannelValue(coord_t x, coord_t y, source_t channel, lcdint_t value, LcdFlags att) +void putsChannelValue(coord_t x, coord_t y, source_t channel, int32_t value, LcdFlags att) { if (channel >= MIXSRC_FIRST_TELEM) { channel = (channel-MIXSRC_FIRST_TELEM) / 3; @@ -1049,7 +1055,7 @@ void lcd_plot(coord_t x, coord_t y, LcdFlags att) lcd_mask(p, mask, att); } -void lcd_hlineStip(coord_t x, coord_t y, coord_t w, uint8_t pat, LcdFlags att) +void lcdDrawHorizontalLine(coord_t x, coord_t y, coord_t w, uint8_t pat, LcdFlags att) { if (y < 0 || y >= LCD_H) return; if (x+w > LCD_W) { @@ -1071,7 +1077,7 @@ void lcd_hlineStip(coord_t x, coord_t y, coord_t w, uint8_t pat, LcdFlags att) } } -void lcd_vlineStip(coord_t x, scoord_t y, scoord_t h, uint8_t pat, LcdFlags att) +void lcdDrawVerticalLine(coord_t x, scoord_t y, scoord_t h, uint8_t pat, LcdFlags att) { if (x >= LCD_W) return; if (y >= LCD_H) return; diff --git a/radio/src/gui/Taranis/lcd.h b/radio/src/gui/Taranis/lcd.h index a5342efb8..ede2df64a 100644 --- a/radio/src/gui/Taranis/lcd.h +++ b/radio/src/gui/Taranis/lcd.h @@ -48,7 +48,6 @@ #define CONTRAST_MAX 45 #define lcdint_t int32_t -#define lcduint_t uint32_t #define FW 6 #define FWNUM 5 @@ -74,11 +73,7 @@ /* lcd puts flags */ /* no 0x80 here because of "GV"1 which is aligned LEFT */ /* no 0x10 here because of "MODEL"01 which uses LEADING0 */ -#if defined(CPUARM) - #define BSS 0x00 -#else - #define BSS 0x20 -#endif +#define BSS 0x00 #define ZCHAR 0x80 /* lcd outdez flags */ @@ -119,14 +114,14 @@ #define LcdFlags uint32_t #define display_t uint8_t -#define DISPLAY_BUF_SIZE (LCD_W*LCD_H*4/8) +#define DISPLAY_BUFFER_SIZE (LCD_W*LCD_H*4/8) #if defined(REVPLUS) && defined(LCD_DUAL_BUFFER) - extern display_t displayBuf1[DISPLAY_BUF_SIZE]; - extern display_t displayBuf2[DISPLAY_BUF_SIZE]; + extern display_t displayBuf1[DISPLAY_BUFFER_SIZE]; + extern display_t displayBuf2[DISPLAY_BUFFER_SIZE]; extern display_t * displayBuf; #else - extern display_t displayBuf[DISPLAY_BUF_SIZE]; + extern display_t displayBuf[DISPLAY_BUFFER_SIZE]; #endif #if defined(REVPLUS) && !defined(LCD_DUAL_BUFFER) && !defined(SIMU) @@ -138,8 +133,7 @@ extern coord_t lcdLastPos; extern coord_t lcdNextPos; -#define DISPLAY_BUFER_SIZE (sizeof(display_t)*DISPLAY_BUF_SIZE) -#define DISPLAY_END (displayBuf + DISPLAY_BUF_SIZE) +#define DISPLAY_END (displayBuf + DISPLAY_BUFFER_SIZE) #define ASSERT_IN_DISPLAY(p) assert((p) >= displayBuf && (p) < DISPLAY_END) #if defined(BOOT) @@ -149,10 +143,10 @@ typedef const char pm_char; #endif void lcd_putc(coord_t x, coord_t y, const unsigned char c); -void lcd_putcAtt(coord_t x, coord_t y, const unsigned char c, LcdFlags mode); -void lcd_putsAtt(coord_t x, coord_t y, const pm_char * s, LcdFlags mode); -void lcd_putsiAtt(coord_t x, coord_t y, const pm_char * s,uint8_t idx, LcdFlags mode); -void lcd_putsnAtt(coord_t x, coord_t y, const pm_char * s,unsigned char len, LcdFlags mode); +void lcdDrawChar(coord_t x, coord_t y, const unsigned char c, LcdFlags mode); +void lcdDrawText(coord_t x, coord_t y, const pm_char * s, LcdFlags mode); +void lcdDrawTextAtIndex(coord_t x, coord_t y, const pm_char * s,uint8_t idx, LcdFlags mode); +void lcdDrawTextWithLen(coord_t x, coord_t y, const pm_char * s,unsigned char len, LcdFlags mode); void lcd_puts(coord_t x, coord_t y, const pm_char * s); void lcd_putsn(coord_t x, coord_t y, const pm_char * s, unsigned char len); void lcd_putsLeft(coord_t y, const pm_char * s); @@ -161,8 +155,8 @@ void lcd_putsLeft(coord_t y, const pm_char * s); void lcd_outhex4(coord_t x, coord_t y, uint32_t val, LcdFlags mode=0); -void lcd_outdezNAtt(coord_t x, coord_t y, lcdint_t val, LcdFlags mode=0, uint8_t len=0); -void lcd_outdezAtt(coord_t x, coord_t y, lcdint_t val, LcdFlags mode=0); +void lcd_outdezNAtt(coord_t x, coord_t y, int32_t val, LcdFlags mode=0, uint8_t len=0); +void lcd_outdezAtt(coord_t x, coord_t y, int32_t val, LcdFlags mode=0); void lcd_outdez8(coord_t x, coord_t y, int8_t val); void putsStrIdx(coord_t x, coord_t y, const pm_char *str, uint8_t idx, LcdFlags att=0); @@ -185,9 +179,9 @@ void putsVolts(coord_t x, coord_t y, uint16_t volts, LcdFlags att); void putsVBat(coord_t x, coord_t y, LcdFlags att); #if !defined(BOOT) -void putsChannelValue(coord_t x, coord_t y, source_t channel, lcdint_t val, LcdFlags att=0); +void putsChannelValue(coord_t x, coord_t y, source_t channel, int32_t val, LcdFlags att=0); void putsChannel(coord_t x, coord_t y, source_t channel, LcdFlags att=0); -void putsTelemetryChannelValue(coord_t x, coord_t y, uint8_t channel, lcdint_t val, LcdFlags att=0); +void putsTelemetryChannelValue(coord_t x, coord_t y, uint8_t channel, int32_t val, LcdFlags att=0); #endif #define putstime_t int32_t @@ -201,17 +195,17 @@ void putsTimer(coord_t x, coord_t y, putstime_t tme, LcdFlags att, LcdFlags att2 void lcd_plot(coord_t x, coord_t y, LcdFlags att=0); void lcd_mask(uint8_t *p, uint8_t mask, LcdFlags att=0); void lcd_hline(coord_t x, coord_t y, coord_t w, LcdFlags att=0); -void lcd_hlineStip(coord_t x, coord_t y, coord_t w, uint8_t pat, LcdFlags att=0); +void lcdDrawHorizontalLine(coord_t x, coord_t y, coord_t w, uint8_t pat, LcdFlags att=0); void lcd_vline(coord_t x, scoord_t y, scoord_t h); -void lcd_vlineStip(coord_t x, scoord_t y, scoord_t h, uint8_t pat, LcdFlags att=0); -void lcd_line(coord_t x1, coord_t y1, coord_t x2, coord_t y2, uint8_t pat=SOLID, LcdFlags att=0); +void lcdDrawVerticalLine(coord_t x, scoord_t y, scoord_t h, uint8_t pat, LcdFlags att=0); +void lcdDrawLine(coord_t x1, coord_t y1, coord_t x2, coord_t y2, uint8_t pat=SOLID, LcdFlags att=0); void drawFilledRect(coord_t x, scoord_t y, coord_t w, coord_t h, uint8_t pat=SOLID, LcdFlags att=0); -void lcd_rect(coord_t x, coord_t y, coord_t w, coord_t h, uint8_t pat=SOLID, LcdFlags att=0); +void lcdDrawRect(coord_t x, coord_t y, coord_t w, coord_t h, uint8_t pat=SOLID, LcdFlags att=0); void lcd_invert_line(int8_t line); #define lcd_status_line() lcd_invert_line(LCD_LINES-1) -inline void lcd_square(coord_t x, coord_t y, coord_t w, LcdFlags att=0) { lcd_rect(x, y, w, w, SOLID, att); } +inline void lcd_square(coord_t x, coord_t y, coord_t w, LcdFlags att=0) { lcdDrawRect(x, y, w, w, SOLID, att); } void displaySleepBitmap(); @@ -228,7 +222,7 @@ void lcd_bmp(coord_t x, coord_t y, const uint8_t * img, coord_t offset=0, coord_ #define LCD_ICON(x, y, icon) lcd_bmp(x, y, icons, icon) void lcdSetRefVolt(unsigned char val); -void lcd_clear(); +void lcdClear(); void lcdSetContrast(); #if defined(REVPLUS) && !defined(SIMU) @@ -237,8 +231,8 @@ void lcdSetContrast(); void lcdRefresh(); #endif -const char *bmpLoad(uint8_t *dest, const char *filename, const unsigned int width, const unsigned int height); -const char *writeScreenshot(); +const char * bmpLoad(uint8_t * dest, const char * filename, uint16_t width, uint16_t height); +const char * writeScreenshot(); #if defined(BOOT) #define BLINK_ON_PHASE (0) @@ -246,14 +240,4 @@ const char *writeScreenshot(); #define BLINK_ON_PHASE (g_blinkTmr10ms & (1<<6)) #endif -#if defined(SIMU) - extern bool lcd_refresh; - extern display_t lcd_buf[DISPLAY_BUF_SIZE]; -#endif - -char *strAppend(char * dest, const char * source, int len=0); -char *strSetCursor(char *dest, int position); -char *strAppendDate(char * str, bool time=false); -char *strAppendFilename(char * dest, const char * filename, const int size); - #endif // _LCD_H_ diff --git a/radio/src/gui/Taranis/menu_general.cpp b/radio/src/gui/Taranis/menu_general.cpp index a3534ca57..8f64fc4e1 100644 --- a/radio/src/gui/Taranis/menu_general.cpp +++ b/radio/src/gui/Taranis/menu_general.cpp @@ -88,7 +88,7 @@ enum EnumTabDiag { e_Calib }; -const MenuFuncP_PROGMEM menuTabGeneral[] PROGMEM = { +const MenuFuncP menuTabGeneral[] = { menuGeneralSetup, menuGeneralSdManager, menuGeneralCustomFunctions, diff --git a/radio/src/gui/Taranis/menu_general_calib.cpp b/radio/src/gui/Taranis/menu_general_calib.cpp index 2dfb41718..1f0216e53 100644 --- a/radio/src/gui/Taranis/menu_general_calib.cpp +++ b/radio/src/gui/Taranis/menu_general_calib.cpp @@ -119,7 +119,7 @@ void menuCommonCalib(uint8_t event) case 1: // SET MIDPOINT - lcd_putsAtt(0*FW, MENU_HEADER_HEIGHT+FH, STR_SETMIDPOINT, INVERS); + lcdDrawText(0*FW, MENU_HEADER_HEIGHT+FH, STR_SETMIDPOINT, INVERS); lcd_putsLeft(MENU_HEADER_HEIGHT+2*FH, STR_MENUWHENDONE); for (uint8_t i=0; i> idx; potType = selectMenuItem(HW_SETTINGS_COLUMN+5*FW, y, "", STR_SLIDERTYPES, potType, SLIDER_NONE, SLIDER_WITH_DETENT, m_posHorz == 1 ? attr : 0, event); g_eeGeneral.slidersConfig &= ~mask; @@ -162,11 +162,11 @@ void menuGeneralHardware(uint8_t event) int idx = k - ITEM_SETUP_HW_POT1; uint8_t shift = (2*idx); uint8_t mask = (0x03 << shift); - lcd_putsiAtt(INDENT_WIDTH, y, STR_VSRCRAW, NUM_STICKS+idx+1, m_posHorz < 0 ? attr : 0); + lcdDrawTextAtIndex(INDENT_WIDTH, y, STR_VSRCRAW, NUM_STICKS+idx+1, m_posHorz < 0 ? attr : 0); if (ZEXIST(g_eeGeneral.anaNames[NUM_STICKS+idx]) || (attr && m_posHorz == 0)) editName(HW_SETTINGS_COLUMN, y, g_eeGeneral.anaNames[NUM_STICKS+idx], LEN_ANA_NAME, event, attr && m_posHorz == 0); else - lcd_putsiAtt(HW_SETTINGS_COLUMN, y, STR_MMMINV, 0, 0); + lcdDrawTextAtIndex(HW_SETTINGS_COLUMN, y, STR_MMMINV, 0, 0); uint8_t potType = (g_eeGeneral.potsConfig & mask) >> shift; potType = selectMenuItem(HW_SETTINGS_COLUMN+5*FW, y, "", STR_POTTYPES, potType, POT_NONE, POT_WITHOUT_DETENT, m_posHorz == 1 ? attr : 0, event); g_eeGeneral.potsConfig &= ~mask; @@ -199,11 +199,11 @@ void menuGeneralHardware(uint8_t event) { int index = k-ITEM_SETUP_HW_SA; int config = SWITCH_CONFIG(index); - lcd_putsiAtt(INDENT_WIDTH, y, STR_VSRCRAW, MIXSRC_FIRST_SWITCH-MIXSRC_Rud+index+1, m_posHorz < 0 ? attr : 0); + lcdDrawTextAtIndex(INDENT_WIDTH, y, STR_VSRCRAW, MIXSRC_FIRST_SWITCH-MIXSRC_Rud+index+1, m_posHorz < 0 ? attr : 0); if (ZEXIST(g_eeGeneral.switchNames[index]) || (attr && m_posHorz == 0)) editName(HW_SETTINGS_COLUMN, y, g_eeGeneral.switchNames[index], LEN_SWITCH_NAME, event, m_posHorz == 0 ? attr : 0); else - lcd_putsiAtt(HW_SETTINGS_COLUMN, y, STR_MMMINV, 0, 0); + lcdDrawTextAtIndex(HW_SETTINGS_COLUMN, y, STR_MMMINV, 0, 0); config = selectMenuItem(HW_SETTINGS_COLUMN+5*FW, y, "", STR_SWTYPES, config, SWITCH_NONE, SWITCH_TYPE_MAX(index), m_posHorz == 1 ? attr : 0, event); if (attr && checkIncDec_Ret) { swconfig_t mask = (swconfig_t)0x03 << (2*index); diff --git a/radio/src/gui/Taranis/menu_general_sdmanager.cpp b/radio/src/gui/Taranis/menu_general_sdmanager.cpp index 4dfc3f4db..c0bceee47 100644 --- a/radio/src/gui/Taranis/menu_general_sdmanager.cpp +++ b/radio/src/gui/Taranis/menu_general_sdmanager.cpp @@ -41,7 +41,7 @@ #define IS_DIRECTORY(fname) ((bool)(!NODE_TYPE(fname))) #define IS_FILE(fname) ((bool)(NODE_TYPE(fname))) -void menuGeneralSdManagerInfo(uint8_t event) +void menuGeneralSdManagerInfo(evt_t event) { SIMPLE_SUBMENU(STR_SD_INFO_TITLE, 1); @@ -98,8 +98,8 @@ void flashBootloader(const char * filename) uint8_t buffer[1024]; UINT count; - lcd_clear(); - displayProgressBar(STR_WRITING); + lcdClear(); + drawProgressBar(STR_WRITING); static uint8_t unlocked = 0; if (!unlocked) { @@ -137,8 +137,8 @@ void flashSportDevice(ModuleIndex module, const char *filename) pausePulses(); watchdogSetTimeout(60*60*100/*1h*/); - lcd_clear(); - displayProgressBar(STR_WRITING); + lcdClear(); + drawProgressBar(STR_WRITING); sportFirmwareUpdate(module, filename); @@ -181,13 +181,13 @@ void onSdManagerMenu(const char *result) strcat(lfn, line); } if (strcmp(clipboard.data.sd.directory, lfn)) { // prevent copying to the same directory - POPUP_WARNING(fileCopy(clipboard.data.sd.filename, clipboard.data.sd.directory, lfn)); + POPUP_WARNING(sdCopyFile(clipboard.data.sd.filename, clipboard.data.sd.directory, clipboard.data.sd.filename, lfn)); REFRESH_FILES(); } } else if (result == STR_RENAME_FILE) { memcpy(reusableBuffer.sdmanager.originalName, line, sizeof(reusableBuffer.sdmanager.originalName)); - char *ext = getFileExtension(line, SD_SCREEN_FILE_LENGTH+1); + char * ext = getFileExtension(line, SD_SCREEN_FILE_LENGTH+1); if (ext) { // write spaces to allow a longer filename memset(ext, ' ', SD_SCREEN_FILE_LENGTH-LEN_FILE_EXTENSION-(ext-line)); @@ -217,7 +217,7 @@ void onSdManagerMenu(const char *result) else if (result == STR_ASSIGN_BITMAP) { strAppendFilename(g_model.header.bitmap, line, sizeof(g_model.header.bitmap)); memcpy(modelHeaders[g_eeGeneral.currModel].bitmap, g_model.header.bitmap, sizeof(g_model.header.bitmap)); - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } else if (result == STR_VIEW_TEXT) { getSelectionFullPath(lfn); @@ -243,7 +243,7 @@ void onSdManagerMenu(const char *result) #endif } -void menuGeneralSdManager(uint8_t _event) +void menuGeneralSdManager(evt_t _event) { if (s_warning_result) { s_warning_result = 0; @@ -261,7 +261,7 @@ void menuGeneralSdManager(uint8_t _event) int lastPos = m_posVert; - uint8_t event = (EVT_KEY_MASK(_event) == KEY_ENTER ? 0 : _event); + evt_t event = (EVT_KEY_MASK(_event) == KEY_ENTER ? 0 : _event); SIMPLE_MENU(SD_IS_HC() ? STR_SDHC_CARD : STR_SD_CARD, menuTabGeneral, e_Sd, reusableBuffer.sdmanager.count); int index = m_posVert-s_pgOfs; @@ -306,8 +306,8 @@ void menuGeneralSdManager(uint8_t _event) case EVT_KEY_LONG(KEY_ENTER): if (s_editMode == 0) { killEvents(_event); - char *line = reusableBuffer.sdmanager.lines[index]; - char *ext = getFileExtension(line, SD_SCREEN_FILE_LENGTH+1); + char * line = reusableBuffer.sdmanager.lines[index]; + char * ext = getFileExtension(line, SD_SCREEN_FILE_LENGTH+1); if (!strcmp(line, "..")) { break; // no menu for parent dir } @@ -341,7 +341,7 @@ void menuGeneralSdManager(uint8_t _event) } } if (!READ_ONLY()) { - if (IS_FILE(line)) // it's a file + if (IS_FILE(line)) MENU_ADD_ITEM(STR_COPY_FILE); if (clipboard.type == CLIPBOARD_TYPE_SD_FILE) MENU_ADD_ITEM(STR_PASTE); @@ -366,17 +366,17 @@ void menuGeneralSdManager(uint8_t _event) reusableBuffer.sdmanager.offset = 0; memset(reusableBuffer.sdmanager.lines, 0, sizeof(reusableBuffer.sdmanager.lines)); } - else if (s_pgOfs == reusableBuffer.sdmanager.count-7) { + else if (s_pgOfs == reusableBuffer.sdmanager.count-NUM_BODY_LINES) { reusableBuffer.sdmanager.offset = s_pgOfs; memset(reusableBuffer.sdmanager.lines, 0, sizeof(reusableBuffer.sdmanager.lines)); } else if (s_pgOfs > reusableBuffer.sdmanager.offset) { - memmove(reusableBuffer.sdmanager.lines[0], reusableBuffer.sdmanager.lines[1], 6*sizeof(reusableBuffer.sdmanager.lines[0])); - memset(reusableBuffer.sdmanager.lines[6], 0xff, SD_SCREEN_FILE_LENGTH); - NODE_TYPE(reusableBuffer.sdmanager.lines[6]) = 1; + memmove(reusableBuffer.sdmanager.lines[0], reusableBuffer.sdmanager.lines[1], (NUM_BODY_LINES-1)*sizeof(reusableBuffer.sdmanager.lines[0])); + memset(reusableBuffer.sdmanager.lines[NUM_BODY_LINES-1], 0xff, SD_SCREEN_FILE_LENGTH); + NODE_TYPE(reusableBuffer.sdmanager.lines[NUM_BODY_LINES-1]) = 1; } else { - memmove(reusableBuffer.sdmanager.lines[1], reusableBuffer.sdmanager.lines[0], 6*sizeof(reusableBuffer.sdmanager.lines[0])); + memmove(reusableBuffer.sdmanager.lines[1], reusableBuffer.sdmanager.lines[0], (NUM_BODY_LINES-1)*sizeof(reusableBuffer.sdmanager.lines[0])); memset(reusableBuffer.sdmanager.lines[0], 0, sizeof(reusableBuffer.sdmanager.lines[0])); } @@ -403,7 +403,7 @@ void menuGeneralSdManager(uint8_t _event) for (int i=0; i=0; i--) { + for (int8_t i=NUM_BODY_LINES-1; i>=0; i--) { char *line = reusableBuffer.sdmanager.lines[i]; if (line[0] == '\0' || isFilenameGreater(isfile, fn, line)) { if (i > 0) memmove(reusableBuffer.sdmanager.lines[0], reusableBuffer.sdmanager.lines[1], sizeof(reusableBuffer.sdmanager.lines[0]) * i); @@ -424,10 +424,10 @@ void menuGeneralSdManager(uint8_t _event) } } else if (s_pgOfs > reusableBuffer.sdmanager.offset) { - if (isFilenameGreater(isfile, fn, reusableBuffer.sdmanager.lines[5]) && isFilenameLower(isfile, fn, reusableBuffer.sdmanager.lines[6])) { - memset(reusableBuffer.sdmanager.lines[6], 0, sizeof(reusableBuffer.sdmanager.lines[0])); - strcpy(reusableBuffer.sdmanager.lines[6], fn); - NODE_TYPE(reusableBuffer.sdmanager.lines[6]) = isfile; + if (isFilenameGreater(isfile, fn, reusableBuffer.sdmanager.lines[NUM_BODY_LINES-2]) && isFilenameLower(isfile, fn, reusableBuffer.sdmanager.lines[NUM_BODY_LINES-1])) { + memset(reusableBuffer.sdmanager.lines[NUM_BODY_LINES-1], 0, sizeof(reusableBuffer.sdmanager.lines[0])); + strcpy(reusableBuffer.sdmanager.lines[NUM_BODY_LINES-1], fn); + NODE_TYPE(reusableBuffer.sdmanager.lines[NUM_BODY_LINES-1]) = isfile; } } else { @@ -448,7 +448,7 @@ void menuGeneralSdManager(uint8_t _event) lcdNextPos = 0; LcdFlags attr = (index == i ? BSS|INVERS : BSS); if (reusableBuffer.sdmanager.lines[i][0]) { - if (IS_DIRECTORY(reusableBuffer.sdmanager.lines[i])) { lcd_putcAtt(0, y, '[', s_editMode == EDIT_MODIFY_STRING ? 0 : attr); } + if (IS_DIRECTORY(reusableBuffer.sdmanager.lines[i])) { lcdDrawChar(0, y, '[', s_editMode == EDIT_MODIFY_STRING ? 0 : attr); } if (s_editMode == EDIT_MODIFY_STRING && attr) { editName(lcdNextPos, y, reusableBuffer.sdmanager.lines[i], SD_SCREEN_FILE_LENGTH-4, _event, attr, 0); if (s_editMode == 0) { @@ -465,13 +465,13 @@ void menuGeneralSdManager(uint8_t _event) } } else { - lcd_putsAtt(lcdNextPos, y, reusableBuffer.sdmanager.lines[i], attr); + lcdDrawText(lcdNextPos, y, reusableBuffer.sdmanager.lines[i], attr); } - if (IS_DIRECTORY(reusableBuffer.sdmanager.lines[i])) { lcd_putcAtt(lcdNextPos, y, ']', s_editMode == EDIT_MODIFY_STRING ? 0 : attr); } + if (IS_DIRECTORY(reusableBuffer.sdmanager.lines[i])) { lcdDrawChar(lcdNextPos, y, ']', s_editMode == EDIT_MODIFY_STRING ? 0 : attr); } } } - char *ext = getFileExtension(reusableBuffer.sdmanager.lines[index], SD_SCREEN_FILE_LENGTH+1); + char * ext = getFileExtension(reusableBuffer.sdmanager.lines[index], SD_SCREEN_FILE_LENGTH+1); if (ext && !strcasecmp(ext, BITMAPS_EXT)) { if (lastPos != m_posVert) { if (bmpLoad(modelBitmap, reusableBuffer.sdmanager.lines[index], MODEL_BITMAP_WIDTH, MODEL_BITMAP_HEIGHT)) { diff --git a/radio/src/gui/Taranis/menu_general_setup.cpp b/radio/src/gui/Taranis/menu_general_setup.cpp index f3b7864a6..ea645d275 100644 --- a/radio/src/gui/Taranis/menu_general_setup.cpp +++ b/radio/src/gui/Taranis/menu_general_setup.cpp @@ -46,7 +46,7 @@ const pm_uchar sticks[] PROGMEM = { #define SLIDER_5POS(y, value, label, event, attr) { \ int8_t tmp = value; \ - displaySlider(RADIO_SETUP_2ND_COLUMN, y, 2+tmp, 4, attr); \ + drawSlider(RADIO_SETUP_2ND_COLUMN, y, 2+tmp, 4, attr); \ value = selectMenuItem(RADIO_SETUP_2ND_COLUMN, y, label, NULL, tmp, -2, +2, attr, event); \ } @@ -68,11 +68,11 @@ enum menuGeneralSetupItems { ITEM_SETUP_SPEAKER_PITCH, ITEM_SETUP_WAV_VOLUME, ITEM_SETUP_BACKGROUND_VOLUME, - CASE_VARIO_CPUARM(ITEM_SETUP_VARIO_LABEL) - CASE_VARIO_CPUARM(ITEM_SETUP_VARIO_VOLUME) - CASE_VARIO_CPUARM(ITEM_SETUP_VARIO_PITCH) - CASE_VARIO_CPUARM(ITEM_SETUP_VARIO_RANGE) - CASE_VARIO_CPUARM(ITEM_SETUP_VARIO_REPEAT) + CASE_VARIO(ITEM_SETUP_VARIO_LABEL) + CASE_VARIO(ITEM_SETUP_VARIO_VOLUME) + CASE_VARIO(ITEM_SETUP_VARIO_PITCH) + CASE_VARIO(ITEM_SETUP_VARIO_RANGE) + CASE_VARIO(ITEM_SETUP_VARIO_REPEAT) CASE_HAPTIC(ITEM_SETUP_HAPTIC_LABEL) CASE_HAPTIC(ITEM_SETUP_HAPTIC_MODE) CASE_HAPTIC(ITEM_SETUP_HAPTIC_LENGTH) @@ -114,7 +114,7 @@ void menuGeneralSetup(uint8_t event) if ((m_posVert==ITEM_SETUP_DATE || m_posVert==ITEM_SETUP_TIME) && (s_editMode>0) && - (event==EVT_KEY_FIRST(KEY_ENTER) || event==EVT_KEY_FIRST(KEY_EXIT) || IS_ROTARY_BREAK(event) || IS_ROTARY_LONG(event))) { + (event==EVT_KEY_FIRST(KEY_ENTER) || event==EVT_KEY_BREAK(KEY_ENTER) || event==EVT_KEY_LONG(KEY_ENTER) || event==EVT_KEY_FIRST(KEY_EXIT))) { // set the date and time into RTC chip rtcSetTime(&t); } @@ -124,11 +124,11 @@ void menuGeneralSetup(uint8_t event) if (s_warning_result) { s_warning_result = 0; g_eeGeneral.fai = true; - eeDirty(EE_GENERAL); + storageDirty(EE_GENERAL); } #endif - MENU(STR_MENURADIOSETUP, menuTabGeneral, e_Setup, ITEM_SETUP_MAX, { 2, 2, 1, LABEL(SOUND), 0, 0, 0, 0, 0, 0, 0, CASE_VARIO_CPUARM(LABEL(VARIO)) CASE_VARIO_CPUARM(0) CASE_VARIO_CPUARM(0) CASE_VARIO_CPUARM(0) CASE_VARIO_CPUARM(0) CASE_HAPTIC(LABEL(HAPTIC)) CASE_HAPTIC(0) CASE_HAPTIC(0) CASE_HAPTIC(0) 0, LABEL(ALARMS), 0, 0, 0, 0, IF_ROTARY_ENCODERS(0) LABEL(BACKLIGHT), 0, 0, 0, CASE_REVPLUS(0) CASE_PWM_BACKLIGHT(0) CASE_PWM_BACKLIGHT(0) 0, CASE_SPLASH_PARAM(0) CASE_GPS(LABEL(GPS)) CASE_GPS(0) CASE_GPS(0) CASE_GPS(0) CASE_PXX(0) 0, 0, IF_FAI_CHOICE(0) CASE_MAVLINK(0) 0, 0, LABEL(TX_MODE), 0, 1/*to force edit mode*/ }); + MENU(STR_MENURADIOSETUP, menuTabGeneral, e_Setup, ITEM_SETUP_MAX, { 2, 2, 1, LABEL(SOUND), 0, 0, 0, 0, 0, 0, 0, CASE_VARIO(LABEL(VARIO)) CASE_VARIO(0) CASE_VARIO(0) CASE_VARIO(0) CASE_VARIO(0) CASE_HAPTIC(LABEL(HAPTIC)) CASE_HAPTIC(0) CASE_HAPTIC(0) CASE_HAPTIC(0) 0, LABEL(ALARMS), 0, 0, 0, 0, IF_ROTARY_ENCODERS(0) LABEL(BACKLIGHT), 0, 0, 0, CASE_REVPLUS(0) CASE_PWM_BACKLIGHT(0) CASE_PWM_BACKLIGHT(0) 0, CASE_SPLASH_PARAM(0) CASE_GPS(LABEL(GPS)) CASE_GPS(0) CASE_GPS(0) CASE_GPS(0) CASE_PXX(0) 0, 0, IF_FAI_CHOICE(0) CASE_MAVLINK(0) 0, 0, LABEL(TX_MODE), 0, 1/*to force edit mode*/ }); int sub = m_posVert; @@ -225,7 +225,7 @@ void menuGeneralSetup(uint8_t event) { lcd_putsLeft(y, STR_SPEAKER_VOLUME); uint8_t b = g_eeGeneral.speakerVolume+VOLUME_LEVEL_DEF; - displaySlider(RADIO_SETUP_2ND_COLUMN, y, b, VOLUME_LEVEL_MAX, attr); + drawSlider(RADIO_SETUP_2ND_COLUMN, y, b, VOLUME_LEVEL_MAX, attr); if (attr) { CHECK_INCDEC_GENVAR(event, b, 0, VOLUME_LEVEL_MAX); if (checkIncDec_Ret) { @@ -251,9 +251,9 @@ void menuGeneralSetup(uint8_t event) case ITEM_SETUP_SPEAKER_PITCH: lcd_putsLeft( y, STR_SPKRPITCH); - lcd_putcAtt(RADIO_SETUP_2ND_COLUMN, y, '+', attr); + lcdDrawChar(RADIO_SETUP_2ND_COLUMN, y, '+', attr); lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN+FW, y, g_eeGeneral.speakerPitch*15, attr|LEFT); - lcd_putsAtt(lcdLastPos, y, "Hz", attr); + lcdDrawText(lcdLastPos, y, "Hz", attr); if (attr) { CHECK_INCDEC_GENVAR(event, g_eeGeneral.speakerPitch, 0, 20); } @@ -269,19 +269,19 @@ void menuGeneralSetup(uint8_t event) case ITEM_SETUP_VARIO_PITCH: lcd_putsLeft(y, STR_PITCH_AT_ZERO); lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, VARIO_FREQUENCY_ZERO+(g_eeGeneral.varioPitch*10), attr|LEFT); - lcd_putsAtt(lcdLastPos, y, "Hz", attr); + lcdDrawText(lcdLastPos, y, "Hz", attr); if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.varioPitch, -40, 40); break; case ITEM_SETUP_VARIO_RANGE: lcd_putsLeft(y, STR_PITCH_AT_MAX); lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, VARIO_FREQUENCY_ZERO+(g_eeGeneral.varioPitch*10)+VARIO_FREQUENCY_RANGE+(g_eeGeneral.varioRange*10), attr|LEFT); - lcd_putsAtt(lcdLastPos, y, "Hz", attr); + lcdDrawText(lcdLastPos, y, "Hz", attr); if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.varioRange, -80, 80); break; case ITEM_SETUP_VARIO_REPEAT: lcd_putsLeft(y, STR_REPEAT_AT_ZERO); lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, VARIO_REPEAT_ZERO+(g_eeGeneral.varioRepeat*10), attr|LEFT); - lcd_putsAtt(lcdLastPos, y, STR_MS, attr); + lcdDrawText(lcdLastPos, y, STR_MS, attr); if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.varioRepeat, -30, 50); break; #endif @@ -376,7 +376,7 @@ void menuGeneralSetup(uint8_t event) #if defined(REVPLUS) case ITEM_SETUP_BACKLIGHT_COLOR: lcd_putsLeft(y, STR_BLCOLOR); - displaySlider(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.backlightColor, 20, attr); + drawSlider(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.backlightColor, 20, attr); if (attr) g_eeGeneral.backlightColor = checkIncDec(event, g_eeGeneral.backlightColor, 0, 20, EE_GENERAL | NO_INCDEC_MARKS); break; #endif @@ -390,7 +390,7 @@ void menuGeneralSetup(uint8_t event) lcd_putc(lcdLastPos, y, 's'); } else { - lcd_putsiAtt(RADIO_SETUP_2ND_COLUMN, y, STR_MMMINV, 0, attr); // TODO define + lcdDrawTextAtIndex(RADIO_SETUP_2ND_COLUMN, y, STR_MMMINV, 0, attr); // TODO define } if (attr) g_eeGeneral.splashMode = -checkIncDecGen(event, -g_eeGeneral.splashMode, -3, 4); break; @@ -425,7 +425,7 @@ void menuGeneralSetup(uint8_t event) case ITEM_SETUP_LANGUAGE: lcd_putsLeft(y, STR_VOICELANG); - lcd_putsAtt(RADIO_SETUP_2ND_COLUMN, y, currentLanguagePack->name, attr); + lcdDrawText(RADIO_SETUP_2ND_COLUMN, y, currentLanguagePack->name, attr); if (attr) { currentLanguagePackIdx = checkIncDec(event, currentLanguagePackIdx, 0, DIM(languagePacks)-2, EE_GENERAL); if (checkIncDec_Ret) { @@ -460,7 +460,7 @@ void menuGeneralSetup(uint8_t event) case ITEM_SETUP_SWITCHES_DELAY: lcd_putsLeft(y, STR_SWITCHES_DELAY); lcd_outdezAtt(RADIO_SETUP_2ND_COLUMN, y, 10*SWITCHES_DELAY(), attr|LEFT); - lcd_putsAtt(lcdLastPos, y, STR_MS, attr); + lcdDrawText(lcdLastPos, y, STR_MS, attr); if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.switchesDelay, -15, 100-15); break; @@ -486,13 +486,13 @@ void menuGeneralSetup(uint8_t event) if (attr) { s_editMode = 0; CHECK_INCDEC_GENVAR(event, g_eeGeneral.stickReverse, 0, 15); - lcd_rect(6*FW-1, y-1, 15*FW+2, 9); + lcdDrawRect(6*FW-1, y-1, 15*FW+2, 9); } #endif break; case ITEM_SETUP_STICK_MODE: - lcd_putcAtt(2*FW, y, '1'+g_eeGeneral.stickMode, attr); + lcdDrawChar(2*FW, y, '1'+g_eeGeneral.stickMode, attr); for (uint8_t i=0; i<4; i++) { putsStickName((6+4*i)*FW, y, pgm_read_byte(modn12x3 + 4*g_eeGeneral.stickMode + i), 0); } diff --git a/radio/src/gui/Taranis/menu_general_trainer.cpp b/radio/src/gui/Taranis/menu_general_trainer.cpp index aed419c09..81e0d0ae2 100644 --- a/radio/src/gui/Taranis/menu_general_trainer.cpp +++ b/radio/src/gui/Taranis/menu_general_trainer.cpp @@ -70,7 +70,7 @@ void menuGeneralTrainer(uint8_t event) switch(j) { case 0: - lcd_putsiAtt(4*FW, y, STR_TRNMODE, td->mode, attr); + lcdDrawTextAtIndex(4*FW, y, STR_TRNMODE, td->mode, attr); if (attr&BLINK) CHECK_INCDEC_GENVAR(event, td->mode, 0, 2); break; @@ -80,7 +80,7 @@ void menuGeneralTrainer(uint8_t event) break; case 2: - lcd_putsiAtt(12*FW, y, STR_TRNCHN, td->srcChn, attr); + lcdDrawTextAtIndex(12*FW, y, STR_TRNCHN, td->srcChn, attr); if (attr&BLINK) CHECK_INCDEC_GENVAR(event, td->srcChn, 0, 3); break; } @@ -95,7 +95,7 @@ void menuGeneralTrainer(uint8_t event) attr = (sub==6) ? INVERS : 0; if (attr) s_editMode = 0; - lcd_putsAtt(0*FW, MENU_HEADER_HEIGHT+1+6*FH, STR_CAL, attr); + lcdDrawText(0*FW, MENU_HEADER_HEIGHT+1+6*FH, STR_CAL, attr); for (int i=0; i<4; i++) { uint8_t x = (i*TRAINER_CALIB_POS+16)*FW/2; #if defined (PPM_UNIT_PERCENT_PREC1) @@ -108,7 +108,7 @@ void menuGeneralTrainer(uint8_t event) if (attr) { if (event==EVT_KEY_LONG(KEY_ENTER)){ memcpy(g_eeGeneral.trainer.calib, ppmInput, sizeof(g_eeGeneral.trainer.calib)); - eeDirty(EE_GENERAL); + storageDirty(EE_GENERAL); AUDIO_WARNING1(); } } diff --git a/radio/src/gui/Taranis/menu_general_version.cpp b/radio/src/gui/Taranis/menu_general_version.cpp index ca1154d88..0e9c467ff 100644 --- a/radio/src/gui/Taranis/menu_general_version.cpp +++ b/radio/src/gui/Taranis/menu_general_version.cpp @@ -42,24 +42,19 @@ void backupEeprom() uint8_t buffer[1024]; FIL file; - lcd_clear(); - displayProgressBar(STR_WRITING); + lcdClear(); + drawProgressBar(STR_WRITING); // reset unexpectedShutdown to prevent warning when user restores EEPROM backup g_eeGeneral.unexpectedShutdown = 0; - eeDirty(EE_GENERAL); - eeCheck(true); + storageDirty(EE_GENERAL); + storageCheck(true); // create the directory if needed... - DIR folder; - FRESULT result = f_opendir(&folder, EEPROMS_PATH); - if (result != FR_OK) { - if (result == FR_NO_PATH) - result = f_mkdir(EEPROMS_PATH); - if (result != FR_OK) { - POPUP_WARNING(SDCARD_ERROR(result)); - return; - } + const char * error = sdCheckAndCreateDirectory(EEPROMS_PATH); + if (error) { + POPUP_WARNING(error); + return; } // prepare the filename... @@ -82,16 +77,16 @@ void backupEeprom() //set back unexpectedShutdown g_eeGeneral.unexpectedShutdown = 1; - eeDirty(EE_GENERAL); - eeCheck(true); + storageDirty(EE_GENERAL); + storageCheck(true); } void menuGeneralVersion(uint8_t event) { if (s_warning_result) { s_warning_result = 0; - displayPopup(STR_EEPROMFORMATTING); - eeErase(false); + displayPopup(STR_STORAGE_FORMAT); + storageEraseAll(false); #if !defined(SIMU) NVIC_SystemReset(); #else diff --git a/radio/src/gui/Taranis/menu_model.cpp b/radio/src/gui/Taranis/menu_model.cpp index 733651119..53516d1dc 100644 --- a/radio/src/gui/Taranis/menu_model.cpp +++ b/radio/src/gui/Taranis/menu_model.cpp @@ -108,7 +108,7 @@ uint8_t editDelay(const coord_t y, const uint8_t event, const uint8_t attr, cons #define EDIT_DELAY(x, y, event, attr, str, delay) editDelay(y, event, attr, str, delay) #endif -const MenuFuncP_PROGMEM menuTabModel[] PROGMEM = { +const MenuFuncP menuTabModel[] = { menuModelSelect, menuModelSetup, CASE_HELI(menuModelHeli) @@ -148,7 +148,7 @@ void editName(coord_t x, coord_t y, char *name, uint8_t size, uint8_t event, uin mode = FIXEDWIDTH; } - lcd_putsnAtt(x, y, name, size, attr | mode); + lcdDrawTextWithLen(x, y, name, size, attr | mode); coord_t backupNextPos = lcdNextPos; if (active) { @@ -157,8 +157,7 @@ void editName(coord_t x, coord_t y, char *name, uint8_t size, uint8_t event, uin int8_t c = name[cur]; int8_t v = c; - if (IS_ROTARY_RIGHT(event) || IS_ROTARY_LEFT(event) || event==EVT_KEY_FIRST(KEY_DOWN) || event==EVT_KEY_FIRST(KEY_UP) - || event==EVT_KEY_REPT(KEY_DOWN) || event==EVT_KEY_REPT(KEY_UP)) { + if (event==EVT_KEY_FIRST(KEY_DOWN) || event==EVT_KEY_FIRST(KEY_UP) || event==EVT_KEY_REPT(KEY_DOWN) || event==EVT_KEY_REPT(KEY_UP)) { if (attr == ZCHAR) { v = checkIncDec(event, abs(v), 0, ZCHAR_MAX, 0); if (c <= 0) v = -v; @@ -209,14 +208,14 @@ void editName(coord_t x, coord_t y, char *name, uint8_t size, uint8_t event, uin if (c != v) { name[cur] = v; - eeDirty(g_menuPos[0] == 0 ? EE_MODEL : EE_GENERAL); + storageDirty(g_menuPos[0] == 0 ? EE_MODEL : EE_GENERAL); } if (attr == ZCHAR) { - lcd_putcAtt(x+editNameCursorPos*FW, y, idx2char(v), ERASEBG|INVERS|FIXEDWIDTH); + lcdDrawChar(x+editNameCursorPos*FW, y, idx2char(v), ERASEBG|INVERS|FIXEDWIDTH); } else { - lcd_putcAtt(x+editNameCursorPos*FW, y, v, ERASEBG|INVERS|FIXEDWIDTH); + lcdDrawChar(x+editNameCursorPos*FW, y, v, ERASEBG|INVERS|FIXEDWIDTH); } } else { diff --git a/radio/src/gui/Taranis/menu_model_curves.cpp b/radio/src/gui/Taranis/menu_model_curves.cpp index bad8fc69d..7ae939673 100644 --- a/radio/src/gui/Taranis/menu_model_curves.cpp +++ b/radio/src/gui/Taranis/menu_model_curves.cpp @@ -91,7 +91,7 @@ bool moveCurve(uint8_t index, int8_t shift) curveEnd[index++] += shift; } - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); return true; } @@ -99,7 +99,7 @@ void displayPresetChoice(uint8_t event) { displayWarning(event); lcd_outdezAtt(WARNING_LINE_X+FW*7, WARNING_LINE_Y, 45*s_warning_input_value/4, LEFT|INVERS); - lcd_putcAtt(lcdLastPos, WARNING_LINE_Y, '@', INVERS); + lcdDrawChar(lcdLastPos, WARNING_LINE_Y, '@', INVERS); if (s_warning_result) { s_warning_result = 0; @@ -154,7 +154,7 @@ void menuModelCurveOne(uint8_t event) uint8_t attr = (m_posVert==1 ? (s_editMode>0 ? INVERS|BLINK : INVERS) : 0); lcd_putsLeft(3*FH+1, STR_TYPE); - lcd_putsiAtt(INDENT_WIDTH, 4*FH+1, STR_CURVE_TYPES, crv.type, attr); + lcdDrawTextAtIndex(INDENT_WIDTH, 4*FH+1, STR_CURVE_TYPES, crv.type, attr); if (attr) { uint8_t newType = checkIncDecModelZero(event, crv.type, CURVE_TYPE_LAST); if (newType != crv.type) { @@ -172,7 +172,7 @@ void menuModelCurveOne(uint8_t event) attr = (m_posVert==2 ? (s_editMode>0 ? INVERS|BLINK : INVERS) : 0); lcd_putsLeft(5*FH+1, STR_COUNT); lcd_outdezAtt(INDENT_WIDTH, 6*FH+1, 5+crv.points, LEFT|attr); - lcd_putsAtt(lcdLastPos, 6*FH+1, STR_PTS, attr); + lcdDrawText(lcdLastPos, 6*FH+1, STR_PTS, attr); if (attr) { int8_t count = checkIncDecModel(event, crv.points, -3, 12); // 2pts - 17pts if (checkIncDec_Ret) { @@ -260,7 +260,7 @@ void menuModelCurveOne(uint8_t event) void editCurveRef(coord_t x, coord_t y, CurveRef & curve, uint8_t event, uint8_t attr) { - lcd_putsiAtt(x, y, "\004DiffExpoFuncCstm", curve.type, m_posHorz==0 ? attr : 0); + lcdDrawTextAtIndex(x, y, "\004DiffExpoFuncCstm", curve.type, m_posHorz==0 ? attr : 0); if (attr && m_posHorz==0) { CHECK_INCDEC_MODELVAR_ZERO(event, curve.type, CURVE_REF_CUSTOM); if (checkIncDec_Ret) curve.value = 0; @@ -271,7 +271,7 @@ void editCurveRef(coord_t x, coord_t y, CurveRef & curve, uint8_t event, uint8_t curve.value = GVAR_MENU_ITEM(x+5*FW, y, curve.value, -100, 100, m_posHorz==1 ? LEFT|attr : LEFT, 0, event); break; case CURVE_REF_FUNC: - lcd_putsiAtt(x+5*FW, y, STR_VCURVEFUNC, curve.value, m_posHorz==1 ? attr : 0); + lcdDrawTextAtIndex(x+5*FW, y, STR_VCURVEFUNC, curve.value, m_posHorz==1 ? attr : 0); if (attr && m_posHorz==1) CHECK_INCDEC_MODELVAR_ZERO(event, curve.value, CURVE_BASE-1); break; case CURVE_REF_CUSTOM: @@ -313,7 +313,7 @@ void menuModelCurvesAll(uint8_t event) editName(4*FW, y, g_model.curveNames[k], sizeof(g_model.curveNames[k]), 0, 0); CurveInfo & crv = g_model.curves[k]; lcd_outdezAtt(11*FW, y, 5+crv.points, LEFT); - lcd_putsAtt(lcdLastPos, y, STR_PTS, 0); + lcdDrawText(lcdLastPos, y, STR_PTS, 0); } } diff --git a/radio/src/gui/Taranis/menu_model_custom_functions.cpp b/radio/src/gui/Taranis/menu_model_custom_functions.cpp index 117ed9745..18fb74f9e 100644 --- a/radio/src/gui/Taranis/menu_model_custom_functions.cpp +++ b/radio/src/gui/Taranis/menu_model_custom_functions.cpp @@ -67,7 +67,7 @@ void onCustomFunctionsFileSelectionMenu(const char *result) strcpy(directory, SOUNDS_PATH); strncpy(directory+SOUNDS_PATH_LNG_OFS, currentLanguagePack->id, 2); } - if (!listSdFiles(directory, func==FUNC_PLAY_SCRIPT ? SCRIPTS_EXT : SOUNDS_EXT, sizeof(cfn->play.name), NULL)) { + if (!sdListFiles(directory, func==FUNC_PLAY_SCRIPT ? SCRIPTS_EXT : SOUNDS_EXT, sizeof(cfn->play.name), NULL)) { POPUP_WARNING(func==FUNC_PLAY_SCRIPT ? STR_NO_SCRIPTS_ON_SD : STR_NO_SOUNDS_ON_SD); s_menu_flags = 0; } @@ -75,7 +75,7 @@ void onCustomFunctionsFileSelectionMenu(const char *result) else { // The user choosed a file in the list memcpy(cfn->play.name, result, sizeof(cfn->play.name)); - eeDirty(eeFlags); + storageDirty(eeFlags); if (func == FUNC_PLAY_SCRIPT) { LUA_LOAD_MODEL_SCRIPTS(); } @@ -103,21 +103,21 @@ void onCustomFunctionsMenu(const char *result) } else if (result == STR_PASTE) { *cfn = clipboard.data.cfn; - eeDirty(eeFlags); + storageDirty(eeFlags); } else if (result == STR_CLEAR) { memset(cfn, 0, sizeof(CustomFunctionData)); - eeDirty(eeFlags); + storageDirty(eeFlags); } else if (result == STR_INSERT) { memmove(cfn+1, cfn, (NUM_CFN-sub-1)*sizeof(CustomFunctionData)); memset(cfn, 0, sizeof(CustomFunctionData)); - eeDirty(eeFlags); + storageDirty(eeFlags); } else if (result == STR_DELETE) { memmove(cfn, cfn+1, (NUM_CFN-sub-1)*sizeof(CustomFunctionData)); memset(&g_model.customFn[NUM_CFN-1], 0, sizeof(CustomFunctionData)); - eeDirty(eeFlags); + storageDirty(eeFlags); } } @@ -128,22 +128,22 @@ void onAdjustGvarSourceLongEnterPress(const char * result) if (result == STR_CONSTANT) { CFN_GVAR_MODE(cfn) = FUNC_ADJUST_GVAR_CONSTANT; CFN_PARAM(cfn) = 0; - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } else if (result == STR_MIXSOURCE) { CFN_GVAR_MODE(cfn) = FUNC_ADJUST_GVAR_SOURCE; CFN_PARAM(cfn) = 0; - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } else if (result == STR_GLOBALVAR) { CFN_GVAR_MODE(cfn) = FUNC_ADJUST_GVAR_GVAR; CFN_PARAM(cfn) = 0; - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } else if (result == STR_INCDEC) { CFN_GVAR_MODE(cfn) = FUNC_ADJUST_GVAR_INC; CFN_PARAM(cfn) = 0; - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } else { onSourceLongEnterPress(result); @@ -196,7 +196,7 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu case 1: if (CFN_SWITCH(cfn)) { - lcd_putsiAtt(MODEL_CUSTOM_FUNC_2ND_COLUMN, y, STR_VFSWFUNC, func, attr); + lcdDrawTextAtIndex(MODEL_CUSTOM_FUNC_2ND_COLUMN, y, STR_VFSWFUNC, func, attr); if (active) { func = CFN_FUNC(cfn) = checkIncDec(event, CFN_FUNC(cfn), 0, FUNC_MAX-1, eeFlags, isAssignableFunctionAvailable); if (checkIncDec_Ret) CFN_RESET(cfn); @@ -254,11 +254,11 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu val_max = FUNC_RESET_PARAM_FIRST_TELEM+lastUsedTelemetryIndex(); int param = CFN_PARAM(cfn); if (param < FUNC_RESET_PARAM_FIRST_TELEM) { - lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_VFSWRESET, param, attr); + lcdDrawTextAtIndex(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_VFSWRESET, param, attr); } else { TelemetrySensor * sensor = & g_model.telemetrySensors[param-FUNC_RESET_PARAM_FIRST_TELEM]; - lcd_putsnAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, sensor->label, TELEM_LABEL_LEN, attr|ZCHAR); + lcdDrawTextWithLen(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, sensor->label, TELEM_LABEL_LEN, attr|ZCHAR); } if (active) INCDEC_ENABLE_CHECK(functionsContext == &globalFunctionsContext ? isSourceAvailableInGlobalResetSpecialFunction : isSourceAvailableInResetSpecialFunction); } @@ -270,7 +270,7 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu #endif else if (func >= FUNC_SET_FAILSAFE && func <= FUNC_BIND) { val_max = NUM_MODULES-1; - lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, "\004Int.Ext.", CFN_PARAM(cfn), attr); + lcdDrawTextAtIndex(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, "\004Int.Ext.", CFN_PARAM(cfn), attr); } else if (func == FUNC_SET_TIMER) { val_max = 59*60+59; @@ -278,7 +278,7 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu } else if (func == FUNC_PLAY_SOUND) { val_max = AU_FRSKY_LAST-AU_FRSKY_FIRST-1; - lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_FUNCSOUNDS, val_displayed, attr); + lcdDrawTextAtIndex(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_FUNCSOUNDS, val_displayed, attr); } #if defined(HAPTIC) else if (func == FUNC_HAPTIC) { @@ -290,9 +290,9 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu else if (func == FUNC_PLAY_TRACK || func == FUNC_BACKGND_MUSIC || func == FUNC_PLAY_SCRIPT) { coord_t x = MODEL_CUSTOM_FUNC_3RD_COLUMN; if (ZEXIST(cfn->play.name)) - lcd_putsnAtt(x, y, cfn->play.name, sizeof(cfn->play.name), attr); + lcdDrawTextWithLen(x, y, cfn->play.name, sizeof(cfn->play.name), attr); else - lcd_putsiAtt(x, y, STR_VCSWFUNC, 0, attr); + lcdDrawTextAtIndex(x, y, STR_VCSWFUNC, 0, attr); if (active && event==EVT_KEY_BREAK(KEY_ENTER)) { s_editMode = 0; char directory[256]; @@ -303,7 +303,7 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu strcpy(directory, SOUNDS_PATH); strncpy(directory+SOUNDS_PATH_LNG_OFS, currentLanguagePack->id, 2); } - if (listSdFiles(directory, func==FUNC_PLAY_SCRIPT ? SCRIPTS_EXT : SOUNDS_EXT, sizeof(cfn->play.name), cfn->play.name)) { + if (sdListFiles(directory, func==FUNC_PLAY_SCRIPT ? SCRIPTS_EXT : SOUNDS_EXT, sizeof(cfn->play.name), cfn->play.name)) { menuHandler = onCustomFunctionsFileSelectionMenu; } else { @@ -336,12 +336,12 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu lcd_putc(lcdLastPos, y, 's'); } else { - lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_MMMINV, 0, attr); + lcdDrawTextAtIndex(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, STR_MMMINV, 0, attr); } } #if defined(REVPLUS) else if (func == FUNC_BACKLIGHT) { - displaySlider(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, CFN_PARAM(cfn), 100, attr); + drawSlider(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, CFN_PARAM(cfn), 100, attr); if (active) INCDEC_SET_FLAG(eeFlags | NO_INCDEC_MARKS); val_min = 0; val_max = 100; @@ -371,13 +371,13 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu #if 0 // TODO 2.2.X val_min = -100; val_max = +100; if (val_displayed < 0) - lcd_putsAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, "-=", attr); + lcdDrawText(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, "-=", attr); else - lcd_putsAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, "+=", attr); + lcdDrawText(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, "+=", attr); lcd_outdezAtt(lcdNextPos, y, abs(val_displayed), attr|LEFT); #endif val_max = 1; - lcd_putsiAtt(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, PSTR("\003-=1+=1"), val_displayed, attr); + lcdDrawTextAtIndex(MODEL_CUSTOM_FUNC_3RD_COLUMN, y, PSTR("\003-=1+=1"), val_displayed, attr); break; } } @@ -412,15 +412,15 @@ void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFu } else if (HAS_REPEAT_PARAM(func)) { if (CFN_PLAY_REPEAT(cfn) == 0) { - lcd_putsAtt(MODEL_CUSTOM_FUNC_4TH_COLUMN+2, y, "1x", attr); + lcdDrawText(MODEL_CUSTOM_FUNC_4TH_COLUMN+2, y, "1x", attr); } else if (CFN_PLAY_REPEAT(cfn) == CFN_PLAY_REPEAT_NOSTART) { - lcd_putcAtt(MODEL_CUSTOM_FUNC_4TH_COLUMN-1, y, '!', attr); - lcd_putsAtt(MODEL_CUSTOM_FUNC_4TH_COLUMN+2, y, "1x", attr); + lcdDrawChar(MODEL_CUSTOM_FUNC_4TH_COLUMN-1, y, '!', attr); + lcdDrawText(MODEL_CUSTOM_FUNC_4TH_COLUMN+2, y, "1x", attr); } else { lcd_outdezAtt(MODEL_CUSTOM_FUNC_4TH_COLUMN+2+FW, y, CFN_PLAY_REPEAT(cfn)*CFN_PLAY_REPEAT_MUL, attr); - lcd_putcAtt(MODEL_CUSTOM_FUNC_4TH_COLUMN+2+FW, y, 's', attr); + lcdDrawChar(MODEL_CUSTOM_FUNC_4TH_COLUMN+2+FW, y, 's', attr); } if (active) CFN_PLAY_REPEAT(cfn) = checkIncDec(event, CFN_PLAY_REPEAT(cfn)==CFN_PLAY_REPEAT_NOSTART?-1:CFN_PLAY_REPEAT(cfn), -1, 60/CFN_PLAY_REPEAT_MUL, eeFlags); } diff --git a/radio/src/gui/Taranis/menu_model_custom_scripts.cpp b/radio/src/gui/Taranis/menu_model_custom_scripts.cpp index e72f48fde..f2ce148b1 100644 --- a/radio/src/gui/Taranis/menu_model_custom_scripts.cpp +++ b/radio/src/gui/Taranis/menu_model_custom_scripts.cpp @@ -40,7 +40,7 @@ void onModelCustomScriptMenu(const char *result) ScriptData &sd = g_model.scriptsData[s_currIdx]; if (result == STR_UPDATE_LIST) { - if (!listSdFiles(SCRIPTS_MIXES_PATH, SCRIPTS_EXT, sizeof(sd.file), NULL)) { + if (!sdListFiles(SCRIPTS_MIXES_PATH, SCRIPTS_EXT, sizeof(sd.file), NULL)) { POPUP_WARNING(STR_NO_SCRIPTS_ON_SD); s_menu_flags = 0; } @@ -49,7 +49,7 @@ void onModelCustomScriptMenu(const char *result) // The user choosed a lua file in the list copySelection(sd.file, result, sizeof(sd.file)); memset(sd.inputs, 0, sizeof(sd.inputs)); - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); LUA_LOAD_MODEL_SCRIPT(s_currIdx); } } @@ -83,12 +83,12 @@ void menuModelCustomScriptOne(uint8_t event) if (i == ITEM_MODEL_CUSTOMSCRIPT_FILE) { lcd_putsLeft(y, STR_SCRIPT); if (ZEXIST(sd.file)) - lcd_putsnAtt(SCRIPT_ONE_2ND_COLUMN_POS, y, sd.file, sizeof(sd.file), attr); + lcdDrawTextWithLen(SCRIPT_ONE_2ND_COLUMN_POS, y, sd.file, sizeof(sd.file), attr); else - lcd_putsiAtt(SCRIPT_ONE_2ND_COLUMN_POS, y, STR_VCSWFUNC, 0, attr); + lcdDrawTextAtIndex(SCRIPT_ONE_2ND_COLUMN_POS, y, STR_VCSWFUNC, 0, attr); if (attr && event==EVT_KEY_BREAK(KEY_ENTER) && !READ_ONLY()) { s_editMode = 0; - if (listSdFiles(SCRIPTS_MIXES_PATH, SCRIPTS_EXT, sizeof(sd.file), sd.file, LIST_NONE_SD_FILE)) { + if (sdListFiles(SCRIPTS_MIXES_PATH, SCRIPTS_EXT, sizeof(sd.file), sd.file, LIST_NONE_SD_FILE)) { menuHandler = onModelCustomScriptMenu; } else { @@ -106,7 +106,7 @@ void menuModelCustomScriptOne(uint8_t event) } else if (i <= ITEM_MODEL_CUSTOMSCRIPT_PARAMS_LABEL+scriptInputsOutputs[s_currIdx].inputsCount) { int inputIdx = i-ITEM_MODEL_CUSTOMSCRIPT_PARAMS_LABEL-1; - lcd_putsnAtt(INDENT_WIDTH, y, scriptInputsOutputs[s_currIdx].inputs[inputIdx].name, 10, 0); + lcdDrawTextWithLen(INDENT_WIDTH, y, scriptInputsOutputs[s_currIdx].inputs[inputIdx].name, 10, 0); if (scriptInputsOutputs[s_currIdx].inputs[inputIdx].type == 0) { lcd_outdezAtt(SCRIPT_ONE_2ND_COLUMN_POS, y, g_model.scriptsData[s_currIdx].inputs[inputIdx]+scriptInputsOutputs[s_currIdx].inputs[inputIdx].def, attr|LEFT); if (attr) { @@ -159,7 +159,7 @@ void menuModelCustomScripts(uint8_t event) // LUA script if (ZEXIST(sd.file)) { - lcd_putsnAtt(5*FW, y, sd.file, sizeof(sd.file), 0); + lcdDrawTextWithLen(5*FW, y, sd.file, sizeof(sd.file), 0); switch (scriptInternalData[scriptIndex].state) { case SCRIPT_SYNTAX_ERROR: lcd_puts(30*FW+2, y, "(error)"); @@ -175,10 +175,10 @@ void menuModelCustomScripts(uint8_t event) scriptIndex++; } else { - lcd_putsiAtt(5*FW, y, STR_VCSWFUNC, 0, 0); + lcdDrawTextAtIndex(5*FW, y, STR_VCSWFUNC, 0, 0); } // Script name - lcd_putsnAtt(16*FW, y, sd.name, sizeof(sd.name), ZCHAR); + lcdDrawTextWithLen(16*FW, y, sd.name, sizeof(sd.name), ZCHAR); } } diff --git a/radio/src/gui/Taranis/menu_model_gvars.cpp b/radio/src/gui/Taranis/menu_model_gvars.cpp index fc4aff11c..f37743cbb 100644 --- a/radio/src/gui/Taranis/menu_model_gvars.cpp +++ b/radio/src/gui/Taranis/menu_model_gvars.cpp @@ -41,17 +41,17 @@ void onGVARSMenu(const char *result) if (result == STR_ENABLE_POPUP) { g_model.gvars[sub].popup = true; - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } else if (result == STR_DISABLE_POPUP) { g_model.gvars[sub].popup = false; - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } else if (result == STR_CLEAR) { for (int i=0; i GVAR_MAX ? 0 : GVAR_MAX+1); - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } else if (s_editMode>0) { v = checkIncDec(event, v, vmin, vmax, EE_MODEL); diff --git a/radio/src/gui/Taranis/menu_model_inputs_mixes.cpp b/radio/src/gui/Taranis/menu_model_inputs_mixes.cpp index 38eb02c88..7750d6ee2 100644 --- a/radio/src/gui/Taranis/menu_model_inputs_mixes.cpp +++ b/radio/src/gui/Taranis/menu_model_inputs_mixes.cpp @@ -53,9 +53,9 @@ FlightModesType editFlightModes(coord_t x, coord_t y, uint8_t event, FlightModes if (posHorz==p) flags |= BLINK; } if (value & (1<weight = 100; } resumeMixerCalculations(); - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } void copyExpoMix(uint8_t expo, uint8_t idx) @@ -193,7 +193,7 @@ void copyExpoMix(uint8_t expo, uint8_t idx) memmove(mix+1, mix, (MAX_MIXERS-(idx+1))*sizeof(MixData)); } resumeMixerCalculations(); - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } void memswap(void *a, void *b, uint8_t size) @@ -389,7 +389,7 @@ void menuModelExpoOne(uint8_t event) uint8_t not_stick = (ed->srcRaw > MIXSRC_Ail); int8_t carryTrim = -ed->carryTrim; lcd_putsLeft(y, STR_TRIM); - lcd_putsiAtt(EXPO_ONE_2ND_COLUMN, y, STR_VMIXTRIMS, (not_stick && carryTrim == 0) ? 0 : carryTrim+1, m_posHorz==0 ? attr : 0); + lcdDrawTextAtIndex(EXPO_ONE_2ND_COLUMN, y, STR_VMIXTRIMS, (not_stick && carryTrim == 0) ? 0 : carryTrim+1, m_posHorz==0 ? attr : 0); if (attr) ed->carryTrim = -checkIncDecModel(event, carryTrim, not_stick ? TRIM_ON : -TRIM_OFF, -TRIM_AIL); break; } @@ -460,8 +460,8 @@ void drawOffsetBar(uint8_t x, uint8_t y, MixData * md) barMin = -101; if (barMax > 101) barMax = 101; - lcd_hlineStip(x-2, y, GAUGE_WIDTH+2, DOTTED); - lcd_hlineStip(x-2, y+GAUGE_HEIGHT, GAUGE_WIDTH+2, DOTTED); + lcdDrawHorizontalLine(x-2, y, GAUGE_WIDTH+2, DOTTED); + lcdDrawHorizontalLine(x-2, y+GAUGE_HEIGHT, GAUGE_WIDTH+2, DOTTED); lcd_vline(x-2, y+1, GAUGE_HEIGHT-1); lcd_vline(x+GAUGE_WIDTH-1, y+1, GAUGE_HEIGHT-1); if (barMin <= barMax) { @@ -576,7 +576,7 @@ void menuModelMixOne(uint8_t event) if (md2->mixWarn) lcd_outdezAtt(COLUMN_X+MIXES_2ND_COLUMN, y, md2->mixWarn, attr|LEFT); else - lcd_putsAtt(COLUMN_X+MIXES_2ND_COLUMN, y, STR_OFF, attr); + lcdDrawText(COLUMN_X+MIXES_2ND_COLUMN, y, STR_OFF, attr); if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, md2->mixWarn, 3); break; case MIX_FIELD_MLTPX: @@ -652,7 +652,7 @@ void displayHeaderChannelName(uint8_t ch) { uint8_t len = zlen(g_model.limitData[ch].name, sizeof(g_model.limitData[ch].name)); if (len) { - lcd_putsnAtt(80, 1, g_model.limitData[ch].name, len, ZCHAR|SMLSIZE); + lcdDrawTextWithLen(80, 1, g_model.limitData[ch].name, len, ZCHAR|SMLSIZE); } } @@ -668,7 +668,7 @@ void displayMixInfos(coord_t y, MixData *md) void displayMixLine(coord_t y, MixData *md) { if (md->name[0]) - lcd_putsnAtt(EXPO_LINE_NAME_POS, y, md->name, sizeof(md->name), ZCHAR); + lcdDrawTextWithLen(EXPO_LINE_NAME_POS, y, md->name, sizeof(md->name), ZCHAR); if (!md->flightModes || ((md->curve.value || md->swtch) && ((get_tmr10ms() / 200) & 1))) displayMixInfos(y, md); else @@ -695,7 +695,7 @@ void displayExpoLine(coord_t y, ExpoData *ed) displayFlightModes(EXPO_LINE_FM_POS, y, ed->flightModes); if (ed->name[0]) { - lcd_putsnAtt(EXPO_LINE_NAME_POS, y, ed->name, sizeof(ed->name), ZCHAR); + lcdDrawTextWithLen(EXPO_LINE_NAME_POS, y, ed->name, sizeof(ed->name), ZCHAR); } } @@ -734,7 +734,7 @@ void menuModelExpoMix(uint8_t expo, uint8_t event) swapExpoMix(expo, s_currIdx, s_copyTgtOfs > 0); s_copyTgtOfs += (s_copyTgtOfs < 0 ? +1 : -1); } while (s_copyTgtOfs != 0); - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } m_posVert = s_copySrcRow; s_copyTgtOfs = 0; @@ -799,30 +799,30 @@ void menuModelExpoMix(uint8_t expo, uint8_t event) killEvents(event); } break; - case EVT_KEY_FIRST(KEY_MOVE_UP): - case EVT_KEY_REPT(KEY_MOVE_UP): - case EVT_KEY_FIRST(KEY_MOVE_DOWN): - case EVT_KEY_REPT(KEY_MOVE_DOWN): + case EVT_KEY_FIRST(KEY_UP): + case EVT_KEY_REPT(KEY_UP): + case EVT_KEY_FIRST(KEY_DOWN): + case EVT_KEY_REPT(KEY_DOWN): if (s_copyMode) { uint8_t key = (event & 0x1f); - uint8_t next_ofs = (key==KEY_MOVE_UP ? s_copyTgtOfs - 1 : s_copyTgtOfs + 1); + uint8_t next_ofs = (key==KEY_UP ? s_copyTgtOfs - 1 : s_copyTgtOfs + 1); if (s_copyTgtOfs==0 && s_copyMode==COPY_MODE) { // insert a mix on the same channel (just above / just below) if (reachExpoMixCountLimit(expo)) break; copyExpoMix(expo, s_currIdx); - if (key==KEY_MOVE_DOWN) s_currIdx++; + if (key==KEY_DOWN) s_currIdx++; else if (sub-s_pgOfs >= 6) s_pgOfs++; } else if (next_ofs==0 && s_copyMode==COPY_MODE) { // delete the mix deleteExpoMix(expo, s_currIdx); - if (key==KEY_MOVE_UP) s_currIdx--; + if (key==KEY_UP) s_currIdx--; } else { // only swap the mix with its neighbor - if (!swapExpoMix(expo, s_currIdx, key==KEY_MOVE_UP)) break; - eeDirty(EE_MODEL); + if (!swapExpoMix(expo, s_currIdx, key==KEY_UP)) break; + storageDirty(EE_MODEL); } s_copyTgtOfs = next_ofs; @@ -887,7 +887,7 @@ void menuModelExpoMix(uint8_t expo, uint8_t event) do { if (s_copyMode) { if (s_copyMode == MOVE_MODE && cur-s_pgOfs >= 0 && cur-s_pgOfs < NUM_BODY_LINES && s_copySrcCh == ch && s_copyTgtOfs != 0 && i == (s_copySrcIdx + (s_copyTgtOfs<0))) { - lcd_rect(expo ? 18 : 22, y-1, expo ? LCD_W-18 : LCD_W-22, 9, DOTTED); + lcdDrawRect(expo ? 18 : 22, y-1, expo ? LCD_W-18 : LCD_W-22, 9, DOTTED); cur++; y+=FH; } if (s_currIdx == i) { @@ -908,7 +908,7 @@ void menuModelExpoMix(uint8_t expo, uint8_t event) } } else { - if (mixCnt > 0) lcd_putsiAtt(FW, y, STR_VMLTPX2, md->mltpx, 0); + if (mixCnt > 0) lcdDrawTextAtIndex(FW, y, STR_VMLTPX2, md->mltpx, 0); putsMixerSource(MIX_LINE_SRC_POS, y, md->srcRaw, 0); @@ -926,7 +926,7 @@ void menuModelExpoMix(uint8_t expo, uint8_t event) if (s_copyMode) { if ((s_copyMode==COPY_MODE || s_copyTgtOfs == 0) && s_copySrcCh == ch && i == (s_copySrcIdx + (s_copyTgtOfs<0))) { /* draw a border around the raw on selection mode (copy/move) */ - lcd_rect(expo ? EXPO_LINE_SELECT_POS : 22, y-1, expo ? (LCD_W-EXPO_LINE_SELECT_POS) : (LCD_W-22), 9, s_copyMode == COPY_MODE ? SOLID : DOTTED); + lcdDrawRect(expo ? EXPO_LINE_SELECT_POS : 22, y-1, expo ? (LCD_W-EXPO_LINE_SELECT_POS) : (LCD_W-22), 9, s_copyMode == COPY_MODE ? SOLID : DOTTED); } if (cur == sub) { /* invert the raw when it's the current one */ @@ -937,7 +937,7 @@ void menuModelExpoMix(uint8_t expo, uint8_t event) cur++; y+=FH; mixCnt++; i++; if (expo) ed++; else md++; } while (expo ? (ichn+1 == ch && EXPO_VALID(ed)) : (isrcRaw && md->destCh+1 == ch)); if (s_copyMode == MOVE_MODE && cur-s_pgOfs >= 0 && cur-s_pgOfs < NUM_BODY_LINES && s_copySrcCh == ch && i == (s_copySrcIdx + (s_copyTgtOfs<0))) { - lcd_rect(expo ? EXPO_LINE_SELECT_POS : 22, y-1, expo ? LCD_W-EXPO_LINE_SELECT_POS : LCD_W-22, 9, DOTTED); + lcdDrawRect(expo ? EXPO_LINE_SELECT_POS : 22, y-1, expo ? LCD_W-EXPO_LINE_SELECT_POS : LCD_W-22, 9, DOTTED); cur++; y+=FH; } } @@ -958,7 +958,7 @@ void menuModelExpoMix(uint8_t expo, uint8_t event) putsChn(0, y, ch, attr); // show CHx } if (s_copyMode == MOVE_MODE && s_copySrcCh == ch) { - lcd_rect(expo ? EXPO_LINE_SELECT_POS : 22, y-1, expo ? (LCD_W-EXPO_LINE_SELECT_POS) : (LCD_W-22), 9, DOTTED); + lcdDrawRect(expo ? EXPO_LINE_SELECT_POS : 22, y-1, expo ? (LCD_W-EXPO_LINE_SELECT_POS) : (LCD_W-22), 9, DOTTED); } } cur++; y+=FH; diff --git a/radio/src/gui/Taranis/menu_model_limits.cpp b/radio/src/gui/Taranis/menu_model_limits.cpp index d5a653660..0cdc8fbc3 100644 --- a/radio/src/gui/Taranis/menu_model_limits.cpp +++ b/radio/src/gui/Taranis/menu_model_limits.cpp @@ -136,7 +136,7 @@ void menuModelLimits(uint8_t event) s_warning_result = 0; LimitData *ld = limitAddress(sub); ld->revert = !ld->revert; - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } for (int i=0; irevert; #if defined(PPM_CENTER_ADJUSTABLE) - lcd_putcAtt(LIMITS_REVERT_POS, y, revert ? 127 : 126, attr); + lcdDrawChar(LIMITS_REVERT_POS, y, revert ? 127 : 126, attr); #else - lcd_putsiAtt(LIMITS_REVERT_POS, y, STR_MMMINV, revert, attr); + lcdDrawTextAtIndex(LIMITS_REVERT_POS, y, STR_MMMINV, revert, attr); #endif if (active) { uint8_t revert_new = checkIncDecModel(event, revert, 0, 1); @@ -269,7 +269,7 @@ void menuModelLimits(uint8_t event) #if defined(PPM_LIMITS_SYMETRICAL) case ITEM_LIMITS_SYMETRICAL: - lcd_putcAtt(LCD_W-FW-MENUS_SCROLLBAR_WIDTH, y, ld->symetrical ? '=' : '\306', attr); + lcdDrawChar(LCD_W-FW-MENUS_SCROLLBAR_WIDTH, y, ld->symetrical ? '=' : '\306', attr); if (active) { CHECK_INCDEC_MODELVAR_ZERO(event, ld->symetrical, 1); } diff --git a/radio/src/gui/Taranis/menu_model_logical_switches.cpp b/radio/src/gui/Taranis/menu_model_logical_switches.cpp index 420b341f1..64c825047 100644 --- a/radio/src/gui/Taranis/menu_model_logical_switches.cpp +++ b/radio/src/gui/Taranis/menu_model_logical_switches.cpp @@ -65,9 +65,9 @@ void putsEdgeDelayParam(coord_t x, coord_t y, LogicalSwitchData *cs, uint8_t lat lcd_outdezAtt(x, y, lswTimerValue(cs->v2), LEFT|PREC1|lattr); lcd_putc(lcdLastPos, y, ':'); if (cs->v3 < 0) - lcd_putsAtt(lcdLastPos+3, y, "<<", rattr); + lcdDrawText(lcdLastPos+3, y, "<<", rattr); else if (cs->v3 == 0) - lcd_putsAtt(lcdLastPos+3, y, "--", rattr); + lcdDrawText(lcdLastPos+3, y, "--", rattr); else lcd_outdezAtt(lcdLastPos+3, y, lswTimerValue(cs->v2+cs->v3), LEFT|PREC1|rattr); lcd_putc(lcdLastPos, y, ']'); @@ -84,11 +84,11 @@ void onLogicalSwitchesMenu(const char *result) } else if (result == STR_PASTE) { *cs = clipboard.data.csw; - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } else if (result == STR_CLEAR) { memset(cs, 0, sizeof(LogicalSwitchData)); - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } } @@ -131,7 +131,7 @@ void menuModelLogicalSwitches(uint8_t event) putsSwitches(0, y, sw, (getSwitch(sw) ? BOLD : 0) | ((sub==k && CURSOR_ON_LINE()) ? INVERS : 0)); // CSW func - lcd_putsiAtt(CSW_1ST_COLUMN, y, STR_VCSWFUNC, cs->func, horz==0 ? attr : 0); + lcdDrawTextAtIndex(CSW_1ST_COLUMN, y, STR_VCSWFUNC, cs->func, horz==0 ? attr : 0); // CSW params unsigned int cstate = lswFamily(cs->func); @@ -205,7 +205,7 @@ void menuModelLogicalSwitches(uint8_t event) if (cs->duration > 0) lcd_outdezAtt(CSW_5TH_COLUMN, y, cs->duration, (horz==LS_FIELD_DURATION ? attr : 0)|PREC1|LEFT); else - lcd_putsiAtt(CSW_5TH_COLUMN, y, STR_MMMINV, 0, horz==LS_FIELD_DURATION ? attr : 0); + lcdDrawTextAtIndex(CSW_5TH_COLUMN, y, STR_MMMINV, 0, horz==LS_FIELD_DURATION ? attr : 0); // CSW delay if (cstate == LS_FAMILY_EDGE) { @@ -218,7 +218,7 @@ void menuModelLogicalSwitches(uint8_t event) lcd_outdezAtt(CSW_6TH_COLUMN, y, cs->delay, (horz==LS_FIELD_DELAY ? attr : 0)|PREC1|LEFT); } else { - lcd_putsiAtt(CSW_6TH_COLUMN, y, STR_MMMINV, 0, horz==LS_FIELD_DELAY ? attr : 0); + lcdDrawTextAtIndex(CSW_6TH_COLUMN, y, STR_MMMINV, 0, horz==LS_FIELD_DELAY ? attr : 0); } if (attr && horz == LS_FIELD_V3 && cstate != LS_FAMILY_EDGE) { @@ -258,7 +258,7 @@ void menuModelLogicalSwitches(uint8_t event) if (v1_val <= MIXSRC_LAST_CH) { cs->v2 = calcRESXto100(x); } - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } break; case LS_FIELD_V3: diff --git a/radio/src/gui/Taranis/menu_model_select.cpp b/radio/src/gui/Taranis/menu_model_select.cpp index 0c3882a02..dec64bf3d 100644 --- a/radio/src/gui/Taranis/menu_model_select.cpp +++ b/radio/src/gui/Taranis/menu_model_select.cpp @@ -56,11 +56,11 @@ void onModelSelectMenu(const char *result) s_copySrcRow = -1; } else if (result == STR_BACKUP_MODEL) { - eeCheck(true); // force writing of current model data before this is changed + storageCheck(true); // force writing of current model data before this is changed POPUP_WARNING(eeBackupModel(sub)); } else if (result == STR_RESTORE_MODEL || result == STR_UPDATE_LIST) { - if (!listSdFiles(MODELS_PATH, MODELS_EXT, MENU_LINE_LENGTH-1, NULL)) { + if (!sdListFiles(MODELS_PATH, MODELS_EXT, MENU_LINE_LENGTH-1, NULL)) { POPUP_WARNING(STR_NO_MODELS_ON_SD); s_menu_flags = 0; } @@ -71,7 +71,7 @@ void onModelSelectMenu(const char *result) } else { // The user choosed a file on SD to restore - eeCheck(true); + storageCheck(true); POPUP_WARNING(eeRestoreModel(sub, (char *)result)); if (!s_warning && g_eeGeneral.currModel == sub) { eeLoadModel(sub); @@ -83,13 +83,13 @@ void menuModelSelect(uint8_t event) { if (s_warning_result) { s_warning_result = 0; - eeCheck(true); + storageCheck(true); eeDeleteModel(m_posVert); // delete file s_copyMode = 0; event = EVT_ENTRY_UP; } - uint8_t _event_ = (IS_ROTARY_BREAK(event) || IS_ROTARY_LONG(event) ? 0 : event); + uint8_t _event_ = ((event==EVT_KEY_BREAK(KEY_ENTER) || event==EVT_KEY_LONG(KEY_ENTER)) ? 0 : event); if ((s_copyMode && EVT_KEY_MASK(event) == KEY_EXIT) || event == EVT_KEY_BREAK(KEY_EXIT)) { _event_ -= KEY_EXIT; @@ -145,7 +145,7 @@ void menuModelSelect(uint8_t event) } else if (s_copyMode && (s_copyTgtOfs || s_copySrcRow>=0)) { displayPopup(s_copyMode==COPY_MODE ? STR_COPYINGMODEL : STR_MOVINGMODEL); - eeCheck(true); // force writing of current model data before this is changed + storageCheck(true); // force writing of current model data before this is changed uint8_t cur = (MAX_MODELS + sub + s_copyTgtOfs) % MAX_MODELS; @@ -167,7 +167,7 @@ void menuModelSelect(uint8_t event) if (s_copySrcRow != g_eeGeneral.currModel) { g_eeGeneral.currModel = s_copySrcRow; - eeDirty(EE_GENERAL); + storageDirty(EE_GENERAL); } s_copyMode = 0; @@ -209,10 +209,10 @@ void menuModelSelect(uint8_t event) killEvents(event); break; - case EVT_KEY_FIRST(KEY_MOVE_UP): - case EVT_KEY_REPT(KEY_MOVE_UP): - case EVT_KEY_FIRST(KEY_MOVE_DOWN): - case EVT_KEY_REPT(KEY_MOVE_DOWN): + case EVT_KEY_FIRST(KEY_UP): + case EVT_KEY_REPT(KEY_UP): + case EVT_KEY_FIRST(KEY_DOWN): + case EVT_KEY_REPT(KEY_DOWN): if (s_copyMode) { int8_t next_ofs = s_copyTgtOfs + oldSub - m_posVert; if (next_ofs == MAX_MODELS || next_ofs == -MAX_MODELS) @@ -221,7 +221,7 @@ void menuModelSelect(uint8_t event) if (s_copySrcRow < 0 && s_copyMode==COPY_MODE) { s_copySrcRow = oldSub; // find a hole (in the first empty slot above / below) - sub = eeFindEmptyModel(s_copySrcRow, IS_ROTARY_DOWN(event) || event==EVT_KEY_FIRST(KEY_MOVE_DOWN)); + sub = eeFindEmptyModel(s_copySrcRow, event==EVT_KEY_FIRST(KEY_DOWN) || event==EVT_KEY_REPT(KEY_DOWN)); if (sub < 0) { // no free room for duplicating the model AUDIO_ERROR(); @@ -278,7 +278,7 @@ void menuModelSelect(uint8_t event) if (s_copyMode && (vertpos_t)sub==i+s_pgOfs) { drawFilledRect(9, y, MODELSEL_W-1-9, 7); - lcd_rect(8, y-1, MODELSEL_W-1-7, 9, s_copyMode == COPY_MODE ? SOLID : DOTTED); + lcdDrawRect(8, y-1, MODELSEL_W-1-7, 9, s_copyMode == COPY_MODE ? SOLID : DOTTED); } } diff --git a/radio/src/gui/Taranis/menu_model_setup.cpp b/radio/src/gui/Taranis/menu_model_setup.cpp index f8d189eda..f79f0e9c8 100644 --- a/radio/src/gui/Taranis/menu_model_setup.cpp +++ b/radio/src/gui/Taranis/menu_model_setup.cpp @@ -120,7 +120,7 @@ void copySelection(char *dst, const char *src, uint8_t size) void onModelSetupBitmapMenu(const char *result) { if (result == STR_UPDATE_LIST) { - if (!listSdFiles(BITMAPS_PATH, BITMAPS_EXT, sizeof(g_model.header.bitmap), NULL)) { + if (!sdListFiles(BITMAPS_PATH, BITMAPS_EXT, sizeof(g_model.header.bitmap), NULL)) { POPUP_WARNING(STR_NO_BITMAPS_ON_SD); s_menu_flags = 0; } @@ -129,7 +129,7 @@ void onModelSetupBitmapMenu(const char *result) // The user choosed a bmp file in the list copySelection(g_model.header.bitmap, result, sizeof(g_model.header.bitmap)); memcpy(modelHeaders[g_eeGeneral.currModel].bitmap, g_model.header.bitmap, sizeof(g_model.header.bitmap)); - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } } @@ -157,7 +157,7 @@ void editTimerMode(int timerIdx, coord_t y, LcdFlags attr, uint8_t event) swsrc_t switchVal = checkIncDecMovedSwitch(val); if (val != switchVal) { timer->mode = switchVal + (TMRMODE_COUNT-1); - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } } #endif @@ -299,12 +299,12 @@ void menuModelSetup(uint8_t event) case ITEM_MODEL_BITMAP: lcd_putsLeft(y, STR_BITMAP); if (ZEXIST(g_model.header.bitmap)) - lcd_putsnAtt(MODEL_SETUP_2ND_COLUMN, y, g_model.header.bitmap, sizeof(g_model.header.bitmap), attr); + lcdDrawTextWithLen(MODEL_SETUP_2ND_COLUMN, y, g_model.header.bitmap, sizeof(g_model.header.bitmap), attr); else - lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN, y, STR_VCSWFUNC, 0, attr); + lcdDrawTextAtIndex(MODEL_SETUP_2ND_COLUMN, y, STR_VCSWFUNC, 0, attr); if (attr && event==EVT_KEY_BREAK(KEY_ENTER) && READ_ONLY_UNLOCKED()) { s_editMode = 0; - if (listSdFiles(BITMAPS_PATH, BITMAPS_EXT, sizeof(g_model.header.bitmap), g_model.header.bitmap, LIST_NONE_SD_FILE)) { + if (sdListFiles(BITMAPS_PATH, BITMAPS_EXT, sizeof(g_model.header.bitmap), g_model.header.bitmap, LIST_NONE_SD_FILE)) { menuHandler = onModelSetupBitmapMenu; } else { @@ -381,9 +381,9 @@ void menuModelSetup(uint8_t event) #if defined(REV9E) case ITEM_MODEL_TOP_LCD_TIMER: lcd_putsLeft(y, STR_TOPLCDTIMER); - putsStrIdx(MODEL_SETUP_2ND_COLUMN, y, STR_TIMER, g_model.topLcdTimer+1, attr); + putsStrIdx(MODEL_SETUP_2ND_COLUMN, y, STR_TIMER, g_model.toplcdTimer+1, attr); if (attr) { - g_model.topLcdTimer = checkIncDec(event, g_model.topLcdTimer, 0, TIMERS-1, EE_MODEL); + g_model.toplcdTimer = checkIncDec(event, g_model.toplcdTimer, 0, TIMERS-1, EE_MODEL); } break; #endif @@ -394,7 +394,7 @@ void menuModelSetup(uint8_t event) case ITEM_MODEL_EXTENDED_TRIMS: ON_OFF_MENU_ITEM(g_model.extendedTrims, MODEL_SETUP_2ND_COLUMN, y, STR_ETRIMS, m_posHorz<=0 ? attr : 0, event==EVT_KEY_BREAK(KEY_ENTER) ? event : 0); - lcd_putsAtt(MODEL_SETUP_2ND_COLUMN+3*FW, y, STR_RESET_BTN, m_posHorz>0 && !s_noHi ? attr : 0); + lcdDrawText(MODEL_SETUP_2ND_COLUMN+3*FW, y, STR_RESET_BTN, m_posHorz>0 && !s_noHi ? attr : 0); if (attr && m_posHorz>0) { s_editMode = 0; if (event==EVT_KEY_LONG(KEY_ENTER)) { @@ -402,7 +402,7 @@ void menuModelSetup(uint8_t event) for (uint8_t i=0; i0) { switch (m_posHorz) { case 0: @@ -661,7 +660,7 @@ void menuModelSetup(uint8_t event) #else case ITEM_MODEL_INTERNAL_MODULE_MODE: lcd_putsLeft(y, STR_MODE); - lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN, y, STR_XJT_PROTOCOLS, 1+g_model.moduleData[0].rfProtocol, attr); + lcdDrawTextAtIndex(MODEL_SETUP_2ND_COLUMN, y, STR_XJT_PROTOCOLS, 1+g_model.moduleData[0].rfProtocol, attr); if (attr) { CHECK_INCDEC_MODELVAR(event, g_model.moduleData[0].rfProtocol, RF_PROTO_OFF, RF_PROTO_LAST); if (checkIncDec_Ret) { @@ -682,11 +681,11 @@ void menuModelSetup(uint8_t event) case ITEM_MODEL_EXTERNAL_MODULE_MODE: lcd_putsLeft(y, STR_MODE); - lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN, y, STR_TARANIS_PROTOCOLS, g_model.moduleData[EXTERNAL_MODULE].type, m_posHorz==0 ? attr : 0); + lcdDrawTextAtIndex(MODEL_SETUP_2ND_COLUMN, y, STR_TARANIS_PROTOCOLS, g_model.moduleData[EXTERNAL_MODULE].type, m_posHorz==0 ? attr : 0); if (IS_MODULE_XJT(EXTERNAL_MODULE)) - lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN+5*FW, y, STR_XJT_PROTOCOLS, 1+g_model.moduleData[EXTERNAL_MODULE].rfProtocol, m_posHorz==1 ? attr : 0); + lcdDrawTextAtIndex(MODEL_SETUP_2ND_COLUMN+5*FW, y, STR_XJT_PROTOCOLS, 1+g_model.moduleData[EXTERNAL_MODULE].rfProtocol, m_posHorz==1 ? attr : 0); else if (IS_MODULE_DSM2(EXTERNAL_MODULE)) - lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN+5*FW, y, STR_DSM_PROTOCOLS, g_model.moduleData[EXTERNAL_MODULE].rfProtocol, m_posHorz==1 ? attr : 0); + lcdDrawTextAtIndex(MODEL_SETUP_2ND_COLUMN+5*FW, y, STR_DSM_PROTOCOLS, g_model.moduleData[EXTERNAL_MODULE].rfProtocol, m_posHorz==1 ? attr : 0); if (attr && s_editMode>0) { switch (m_posHorz) { case 0: @@ -723,7 +722,7 @@ void menuModelSetup(uint8_t event) ModuleData & moduleData = g_model.moduleData[moduleIdx]; lcd_putsLeft(y, STR_CHANNELRANGE); if ((int8_t)PORT_CHANNELS_ROWS(moduleIdx) >= 0) { - lcd_putsAtt(MODEL_SETUP_2ND_COLUMN, y, STR_CH, m_posHorz==0 ? attr : 0); + lcdDrawText(MODEL_SETUP_2ND_COLUMN, y, STR_CH, m_posHorz==0 ? attr : 0); lcd_outdezAtt(lcdLastPos, y, moduleData.channelsStart+1, LEFT | (m_posHorz==0 ? attr : 0)); lcd_putc(lcdLastPos, y, '-'); lcd_outdezAtt(lcdLastPos + FW+1, y, moduleData.channelsStart+NUM_CHANNELS(moduleIdx), LEFT | (m_posHorz==1 ? attr : 0)); @@ -763,7 +762,7 @@ void menuModelSetup(uint8_t event) lcd_outdezAtt(MODEL_SETUP_2ND_COLUMN, y, (int16_t)moduleData.ppmFrameLength*5 + 225, (m_posHorz<=0 ? attr : 0) | PREC1|LEFT); lcd_putc(MODEL_SETUP_2ND_COLUMN+8*FW+2, y, 'u'); lcd_outdezAtt(MODEL_SETUP_2ND_COLUMN+8*FW+2, y, (moduleData.ppmDelay*50)+300, (CURSOR_ON_LINE() || m_posHorz==1) ? attr : 0); - lcd_putcAtt(MODEL_SETUP_2ND_COLUMN+10*FW, y, moduleData.ppmPulsePol ? '+' : '-', (CURSOR_ON_LINE() || m_posHorz==2) ? attr : 0); + lcdDrawChar(MODEL_SETUP_2ND_COLUMN+10*FW, y, moduleData.ppmPulsePol ? '+' : '-', (CURSOR_ON_LINE() || m_posHorz==2) ? attr : 0); if (attr && s_editMode>0) { switch (m_posHorz) { @@ -803,8 +802,8 @@ void menuModelSetup(uint8_t event) checkModelIdUnique(g_eeGeneral.currModel, moduleIdx); } } - lcd_putsAtt(MODEL_SETUP_2ND_COLUMN+xOffsetBind, y, STR_MODULE_BIND, l_posHorz==1 ? attr : 0); - lcd_putsAtt(MODEL_SETUP_2ND_COLUMN+MODEL_SETUP_RANGE_OFS+xOffsetBind, y, STR_MODULE_RANGE, l_posHorz==2 ? attr : 0); + lcdDrawText(MODEL_SETUP_2ND_COLUMN+xOffsetBind, y, STR_MODULE_BIND, l_posHorz==1 ? attr : 0); + lcdDrawText(MODEL_SETUP_2ND_COLUMN+MODEL_SETUP_RANGE_OFS+xOffsetBind, y, STR_MODULE_RANGE, l_posHorz==2 ? attr : 0); uint8_t newFlag = 0; if (attr && l_posHorz>0 && s_editMode>0) { if (l_posHorz == 1) @@ -826,8 +825,8 @@ void menuModelSetup(uint8_t event) ModuleData & moduleData = g_model.moduleData[moduleIdx]; lcd_putsLeft(y, TR_FAILSAFE); if (IS_MODULE_XJT(moduleIdx)) { - lcd_putsiAtt(MODEL_SETUP_2ND_COLUMN, y, STR_VFAILSAFE, moduleData.failsafeMode, m_posHorz==0 ? attr : 0); - if (moduleData.failsafeMode == FAILSAFE_CUSTOM) lcd_putsAtt(MODEL_SETUP_2ND_COLUMN + MODEL_SETUP_SET_FAILSAFE_OFS, y, STR_SET, m_posHorz==1 ? attr : 0); + lcdDrawTextAtIndex(MODEL_SETUP_2ND_COLUMN, y, STR_VFAILSAFE, moduleData.failsafeMode, m_posHorz==0 ? attr : 0); + if (moduleData.failsafeMode == FAILSAFE_CUSTOM) lcdDrawText(MODEL_SETUP_2ND_COLUMN + MODEL_SETUP_SET_FAILSAFE_OFS, y, STR_SET, m_posHorz==1 ? attr : 0); if (attr) { if (moduleData.failsafeMode != FAILSAFE_CUSTOM) { m_posHorz = 0; @@ -875,7 +874,7 @@ void menuModelFailsafe(uint8_t event) event = 0; if (s_editMode) { g_model.moduleData[g_moduleIdx].failsafeChannels[m_posVert] = channelOutputs[m_posVert+channelStart]; - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); AUDIO_WARNING1(); s_editMode = 0; SEND_FAILSAFE_NOW(g_moduleIdx); @@ -888,7 +887,7 @@ void menuModelFailsafe(uint8_t event) failsafe = FAILSAFE_CHANNEL_NOPULSE; else failsafe = 0; - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); AUDIO_WARNING1(); SEND_FAILSAFE_NOW(g_moduleIdx); } @@ -930,12 +929,12 @@ void menuModelFailsafe(uint8_t event) if (lenLabel > 4) { newLongNames = longNames = true; } - + if (lenLabel > 0) - lcd_putsnAtt(x+1-ofs, y, g_model.limitData[ch+channelStart].name, sizeof(g_model.limitData[ch+channelStart].name), ZCHAR | SMLSIZE); + lcdDrawTextWithLen(x+1-ofs, y, g_model.limitData[ch+channelStart].name, sizeof(g_model.limitData[ch+channelStart].name), ZCHAR | SMLSIZE); else putsChn(x+1-ofs, y, ch+1, SMLSIZE); - + // Value LcdFlags flags = TINSIZE; if (m_posVert == ch) { @@ -956,13 +955,13 @@ void menuModelFailsafe(uint8_t event) #else uint8_t wbar = (longNames ? SLIDER_W-10 : SLIDER_W); #endif - + if (failsafeValue == FAILSAFE_CHANNEL_HOLD) { - lcd_putsAtt(x+COL_W-4-wbar-ofs-16, y, "HOLD", flags); + lcdDrawText(x+COL_W-4-wbar-ofs-16, y, "HOLD", flags); failsafeValue = 0; } else if (failsafeValue == FAILSAFE_CHANNEL_NOPULSE) { - lcd_putsAtt(x+COL_W-4-wbar-ofs-16, y, "NONE", flags); + lcdDrawText(x+COL_W-4-wbar-ofs-16, y, "NONE", flags); failsafeValue = 0; } else { @@ -976,16 +975,16 @@ void menuModelFailsafe(uint8_t event) } // Gauge - lcd_rect(x+COL_W-3-wbar-ofs, y, wbar+1, 6); + lcdDrawRect(x+COL_W-3-wbar-ofs, y, wbar+1, 6); unsigned int lenChannel = limit((uint8_t)1, uint8_t((abs(channelValue) * wbar/2 + lim/2) / lim), uint8_t(wbar/2)); unsigned int lenFailsafe = limit((uint8_t)1, uint8_t((abs(failsafeValue) * wbar/2 + lim/2) / lim), uint8_t(wbar/2)); coord_t xChannel = (channelValue>0) ? x+COL_W-ofs-3-wbar/2 : x+COL_W-ofs-2-wbar/2-lenChannel; coord_t xFailsafe = (failsafeValue>0) ? x+COL_W-ofs-3-wbar/2 : x+COL_W-ofs-2-wbar/2-lenFailsafe; - lcd_hlineStip(xChannel, y+1, lenChannel, DOTTED, 0); - lcd_hlineStip(xChannel, y+2, lenChannel, DOTTED, 0); + lcdDrawHorizontalLine(xChannel, y+1, lenChannel, DOTTED, 0); + lcdDrawHorizontalLine(xChannel, y+2, lenChannel, DOTTED, 0); lcd_hline(xFailsafe, y+3, lenFailsafe); lcd_hline(xFailsafe, y+4, lenFailsafe); - } + } ch++; } } diff --git a/radio/src/gui/Taranis/menu_model_telemetry.cpp b/radio/src/gui/Taranis/menu_model_telemetry.cpp index 2fa9db275..0c48ef463 100644 --- a/radio/src/gui/Taranis/menu_model_telemetry.cpp +++ b/radio/src/gui/Taranis/menu_model_telemetry.cpp @@ -201,8 +201,8 @@ bool isSensorAvailable(int sensor) return isTelemetryFieldAvailable(abs(sensor) - 1); } -#define SENSOR_2ND_COLUMN (12*FW) -#define SENSOR_3RD_COLUMN (18*FW) +#define SENSOR_2ND_COLUMN (12*FW) +#define SENSOR_3RD_COLUMN (18*FW) #define SENSOR_UNIT_ROWS ((sensor->type == TELEM_TYPE_CALCULATED && (sensor->formula == TELEM_FORMULA_DIST)) || sensor->isConfigurable() ? (uint8_t)0 : HIDDEN_ROW) #define SENSOR_PREC_ROWS (sensor->isPrecConfigurable() && sensor->unit != UNIT_FAHRENHEIT ? (uint8_t)0 : HIDDEN_ROW) @@ -217,7 +217,7 @@ bool isSensorAvailable(int sensor) void menuModelSensor(uint8_t event) { - TelemetrySensor * sensor = & g_model.telemetrySensors[s_currIdx]; + TelemetrySensor * sensor = &g_model.telemetrySensors[s_currIdx]; SUBMENU(STR_MENUSENSOR, SENSOR_FIELD_MAX, { 0, 0, sensor->type == TELEM_TYPE_CALCULATED ? (uint8_t)0 : (uint8_t)1, SENSOR_UNIT_ROWS, SENSOR_PREC_ROWS, SENSOR_PARAM1_ROWS, SENSOR_PARAM2_ROWS, SENSOR_PARAM3_ROWS, SENSOR_PARAM4_ROWS, SENSOR_AUTOOFFSET_ROWS, SENSOR_ONLYPOS_ROWS, SENSOR_FILTER_ROWS, SENSOR_PERSISTENT_ROWS, 0 }); lcd_outdezAtt(PSIZE(TR_MENUSENSOR)*FW+1, 0, s_currIdx+1, INVERS|LEFT); @@ -298,7 +298,7 @@ void menuModelSensor(uint8_t event) case SENSOR_FIELD_UNIT: lcd_putsLeft(y, STR_UNIT); // TODO flash saving with selectMenuItem where I copied those 2 lines? - lcd_putsiAtt(SENSOR_2ND_COLUMN, y, STR_VTELEMUNIT, sensor->unit, attr); + lcdDrawTextAtIndex(SENSOR_2ND_COLUMN, y, STR_VTELEMUNIT, sensor->unit, attr); if (attr) { CHECK_INCDEC_MODELVAR_ZERO(event, sensor->unit, UNIT_MAX); if (checkIncDec_Ret) { @@ -363,7 +363,7 @@ void menuModelSensor(uint8_t event) lcd_putsLeft(y, STR_RATIO); if (attr) sensor->custom.ratio = checkIncDec(event, sensor->custom.ratio, 0, 30000, EE_MODEL|NO_INCDEC_MARKS|INCDEC_REP10); if (sensor->custom.ratio == 0) - lcd_putcAtt(SENSOR_2ND_COLUMN, y, '-', attr); + lcdDrawChar(SENSOR_2ND_COLUMN, y, '-', attr); else lcd_outdezAtt(SENSOR_2ND_COLUMN, y, sensor->custom.ratio, LEFT|attr|PREC1); break; @@ -412,7 +412,7 @@ void menuModelSensor(uint8_t event) source = checkIncDec(event, source, -MAX_SENSORS, MAX_SENSORS, EE_MODEL|NO_INCDEC_MARKS, isSensorAvailable); } if (source < 0) { - lcd_putcAtt(SENSOR_2ND_COLUMN, y, '-', attr); + lcdDrawChar(SENSOR_2ND_COLUMN, y, '-', attr); putsMixerSource(lcdNextPos, y, MIXSRC_FIRST_TELEM+3*(-1-source), attr); } else { @@ -474,7 +474,7 @@ void onSensorMenu(const char *result) TelemetryItem & sourceItem = telemetryItems[index]; TelemetryItem & newItem = telemetryItems[newIndex]; newItem = sourceItem; - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } else { POPUP_WARNING(STR_TELEMETRYFULL); @@ -490,7 +490,7 @@ void onTelemetryScriptFileSelectionMenu(const char *result) int screenIndex = TELEMETRY_CURRENT_SCREEN(sub); if (result == STR_UPDATE_LIST) { - if (!listSdFiles(SCRIPTS_TELEM_PATH, SCRIPTS_EXT, sizeof(g_model.frsky.screens[screenIndex].script.file), NULL)) { + if (!sdListFiles(SCRIPTS_TELEM_PATH, SCRIPTS_EXT, sizeof(g_model.frsky.screens[screenIndex].script.file), NULL)) { POPUP_WARNING(STR_NO_SCRIPTS_ON_SD); s_menu_flags = 0; } @@ -498,7 +498,7 @@ void onTelemetryScriptFileSelectionMenu(const char *result) else { // The user choosed a file in the list memcpy(g_model.frsky.screens[screenIndex].script.file, result, sizeof(g_model.frsky.screens[screenIndex].script.file)); - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); LUA_LOAD_MODEL_SCRIPTS(); } } @@ -513,7 +513,7 @@ void menuModelTelemetry(uint8_t event) } } - MENU(STR_MENUTELEMETRY, menuTabModel, e_Telemetry, ITEM_TELEMETRY_MAX, { TELEMETRY_TYPE_ROWS RSSI_ROWS SENSORS_ROWS VARIO_ROWS LABEL(TopBar), 0, 0, TELEMETRY_SCREEN_ROWS(0), TELEMETRY_SCREEN_ROWS(1), CASE_CPUARM(TELEMETRY_SCREEN_ROWS(2)) CASE_CPUARM(TELEMETRY_SCREEN_ROWS(3)) }); + MENU(STR_MENUTELEMETRY, menuTabModel, e_Telemetry, ITEM_TELEMETRY_MAX, { TELEMETRY_TYPE_ROWS RSSI_ROWS SENSORS_ROWS VARIO_ROWS LABEL(TopBar), 0, 0, TELEMETRY_SCREEN_ROWS(0), TELEMETRY_SCREEN_ROWS(1), TELEMETRY_SCREEN_ROWS(2), TELEMETRY_SCREEN_ROWS(3) }); int sub = m_posVert; @@ -531,8 +531,8 @@ void menuModelTelemetry(uint8_t event) if (k>=ITEM_TELEMETRY_SENSOR1 && ktype == TELEM_TYPE_CUSTOM && !g_model.ignoreSensorIds) { @@ -575,14 +575,14 @@ void menuModelTelemetry(uint8_t event) case ITEM_TELEMETRY_SENSORS_LABEL: lcd_putsLeft(y, STR_TELEMETRY_SENSORS); - lcd_putsAtt(TELEM_COL2, y, STR_VALUE, 0); + lcdDrawText(TELEM_COL2, y, STR_VALUE, 0); if (!g_model.ignoreSensorIds) { - lcd_putsAtt(TELEM_COL3, y, STR_ID, 0); + lcdDrawText(TELEM_COL3, y, STR_ID, 0); } break; case ITEM_TELEMETRY_DISCOVER_SENSORS: - lcd_putsAtt(0, y, allowNewSensors ? STR_STOP_DISCOVER_SENSORS : STR_DISCOVER_SENSORS, attr); + lcdDrawText(0, y, allowNewSensors ? STR_STOP_DISCOVER_SENSORS : STR_DISCOVER_SENSORS, attr); if (attr && event==EVT_KEY_BREAK(KEY_ENTER)) { s_editMode = 0; allowNewSensors = !allowNewSensors; @@ -590,7 +590,7 @@ void menuModelTelemetry(uint8_t event) break; case ITEM_TELEMETRY_NEW_SENSOR: - lcd_putsAtt(0, y, STR_TELEMETRY_NEWSENSOR, attr); + lcdDrawText(0, y, STR_TELEMETRY_NEWSENSOR, attr); if (attr && event==EVT_KEY_BREAK(KEY_ENTER)) { s_editMode = 0; int res = availableTelemetryIndex(); @@ -605,7 +605,7 @@ void menuModelTelemetry(uint8_t event) break; case ITEM_TELEMETRY_DELETE_ALL_SENSORS: - lcd_putsAtt(0, y, STR_DELETE_ALL_SENSORS, attr); + lcdDrawText(0, y, STR_DELETE_ALL_SENSORS, attr); if (attr) s_editMode = 0; if (attr && event==EVT_KEY_LONG(KEY_ENTER)) { @@ -666,7 +666,7 @@ void menuModelTelemetry(uint8_t event) lcd_putsLeft(y, STR_CENTER); lcd_outdezAtt(TELEM_COL2, y, -5+g_model.frsky.varioCenterMin, (m_posHorz==0 ? attr : 0)|PREC1|LEFT); lcd_outdezAtt(TELEM_COL2+7*FW, y, 5+g_model.frsky.varioCenterMax, (m_posHorz==1 ? attr : 0)|PREC1|LEFT); - lcd_putsiAtt(TELEM_COL3, y, STR_VVARIOCENTER, g_model.frsky.varioCenterSilent, (m_posHorz==2 ? attr : 0)); + lcdDrawTextAtIndex(TELEM_COL3, y, STR_VVARIOCENTER, g_model.frsky.varioCenterSilent, (m_posHorz==2 ? attr : 0)); if (attr && s_editMode>0) { switch (m_posHorz) { case 0: @@ -681,7 +681,6 @@ void menuModelTelemetry(uint8_t event) } } break; - #endif case ITEM_TELEMETRY_TOP_BAR_LABEL: @@ -724,13 +723,13 @@ void menuModelTelemetry(uint8_t event) // TODO better function name for --- // TODO function for these lines if (ZEXIST(scriptData.file)) - lcd_putsnAtt(TELEM_SCRTYPE_COL+7*FW, y, scriptData.file, sizeof(scriptData.file), (m_posHorz==1 ? attr : 0)); + lcdDrawTextWithLen(TELEM_SCRTYPE_COL+7*FW, y, scriptData.file, sizeof(scriptData.file), (m_posHorz==1 ? attr : 0)); else - lcd_putsiAtt(TELEM_SCRTYPE_COL+7*FW, y, STR_VCSWFUNC, 0, (m_posHorz==1 ? attr : 0)); + lcdDrawTextAtIndex(TELEM_SCRTYPE_COL+7*FW, y, STR_VCSWFUNC, 0, (m_posHorz==1 ? attr : 0)); if (m_posHorz==1 && attr && event==EVT_KEY_BREAK(KEY_ENTER) && READ_ONLY_UNLOCKED()) { s_editMode = 0; - if (listSdFiles(SCRIPTS_TELEM_PATH, SCRIPTS_EXT, sizeof(g_model.frsky.screens[screenIndex].script.file), g_model.frsky.screens[screenIndex].script.file)) { + if (sdListFiles(SCRIPTS_TELEM_PATH, SCRIPTS_EXT, sizeof(g_model.frsky.screens[screenIndex].script.file), g_model.frsky.screens[screenIndex].script.file)) { menuHandler = onTelemetryScriptFileSelectionMenu; } else { diff --git a/radio/src/gui/Taranis/menus.h b/radio/src/gui/Taranis/menus.h index c47e2d052..3931fbab8 100644 --- a/radio/src/gui/Taranis/menus.h +++ b/radio/src/gui/Taranis/menus.h @@ -37,17 +37,17 @@ #ifndef _MENUS_H_ #define _MENUS_H_ -#define NO_HI_LEN 25 +#define NO_HI_LEN 25 #if defined(TRANSLATIONS_FR) - #define MENU_COLUMNS 1 + #define MENU_COLUMNS 1 #else - #define MENU_COLUMNS 2 + #define MENU_COLUMNS 2 #endif -#define MENUS_SCROLLBAR_WIDTH 2 -#define MENU_COLUMN2_X (8 + LCD_W / 2) -#define lcd_putsColumnLeft(x, y, str) lcd_puts((x > (LCD_W-10*FW-MENUS_SCROLLBAR_WIDTH)) ? MENU_COLUMN2_X : 0, y, str) +#define MENUS_SCROLLBAR_WIDTH 2 +#define MENU_COLUMN2_X (8 + LCD_W / 2) +#define lcd_putsColumnLeft(x, y, str) lcd_puts((x > (LCD_W-10*FW-MENUS_SCROLLBAR_WIDTH)) ? MENU_COLUMN2_X : 0, y, str) // Menus related stuff ... typedef uint16_t vertpos_t; @@ -66,11 +66,8 @@ extern uint8_t calibrationState; void menu_lcd_onoff(coord_t x, coord_t y, uint8_t value, LcdFlags attr); typedef void (*MenuFuncP)(uint8_t event); -typedef void (*MenuFuncP_PROGMEM)(uint8_t event); -extern const MenuFuncP_PROGMEM menuTabModel[]; -extern const MenuFuncP_PROGMEM menuTabGeneral[]; -extern const MenuFuncP_PROGMEM menuTabFPV[]; -extern const MenuFuncP_PROGMEM menuTabTelemetry[]; +extern const MenuFuncP menuTabModel[]; +extern const MenuFuncP menuTabGeneral[]; extern MenuFuncP g_menuStack[5]; extern uint8_t g_menuPos[4]; @@ -83,11 +80,6 @@ void chainMenu(MenuFuncP newMenu); void pushMenu(MenuFuncP newMenu); /// return to last menu in menustack void popMenu(); -///deliver address of last menu which was popped from -inline MenuFuncP lastPopMenu() -{ - return g_menuStack[g_menuStackPtr+1]; -} void doMainScreenGraphics(); void menuFirstCalib(uint8_t event); @@ -115,33 +107,32 @@ void menuAboutView(uint8_t event); void menuTraceBuffer(uint8_t event); #endif -void displaySlider(coord_t x, coord_t y, uint8_t value, uint8_t max, uint8_t attr); +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); extern int8_t checkIncDec_Ret; // global helper vars -#define EDIT_SELECT_MENU -1 -#define EDIT_SELECT_FIELD 0 -#define EDIT_MODIFY_FIELD 1 -#define EDIT_MODIFY_STRING 2 -extern int8_t s_editMode; // global editmode +#define EDIT_SELECT_MENU -1 +#define EDIT_SELECT_FIELD 0 +#define EDIT_MODIFY_FIELD 1 +#define EDIT_MODIFY_STRING 2 +extern int8_t s_editMode; // global editmode // checkIncDec flags -#define EE_GENERAL 0x01 -#define EE_MODEL 0x02 -#define NO_INCDEC_MARKS 0x04 -#define INCDEC_SWITCH 0x08 -#define INCDEC_SOURCE 0x10 -#define INCDEC_REP10 0x40 -#define NO_DBLKEYS 0x80 +#define EE_GENERAL 0x01 +#define EE_MODEL 0x02 +#define NO_INCDEC_MARKS 0x04 +#define INCDEC_SWITCH 0x08 +#define INCDEC_SOURCE 0x10 +#define INCDEC_REP10 0x40 +#define NO_DBLKEYS 0x80 // mawrow special values -#define TITLE_ROW ((uint8_t)-1) -#define HIDDEN_ROW ((uint8_t)-2) +#define TITLE_ROW ((uint8_t)-1) +#define HIDDEN_ROW ((uint8_t)-2) -typedef bool (*IsValueAvailable)(int); struct CheckIncDecStops { const int count; const int stops[]; @@ -193,29 +184,12 @@ swsrc_t checkIncDecMovedSwitch(swsrc_t val); #define CHECK_INCDEC_MODELVAR_ZERO_CHECK(event, var, max, check) \ var = checkIncDec(event, var, 0, max, EE_MODEL, check) -bool isThrottleSourceAvailable(int source); -bool isLogicalSwitchFunctionAvailable(int function); -bool isAssignableFunctionAvailable(int function); -bool isSourceAvailableInResetSpecialFunction(int index); -bool isSourceAvailableInGlobalResetSpecialFunction(int index); -bool isLogicalSwitchAvailable(int index); -bool isSwitchAvailableInLogicalSwitches(int swtch); -bool isSwitchAvailableInCustomFunctions(int swtch); -bool isSwitchAvailableInMixes(int swtch); -bool isSwitchAvailableInTimers(int swtch); -bool isModuleAvailable(int module); -int getFirstAvailable(int min, int max, bool (*func)(int)); #define AUTOSWITCH_ENTER_LONG() (attr && event==EVT_KEY_LONG(KEY_ENTER)) #define CHECK_INCDEC_SWITCH(event, var, min, max, flags, available) \ var = checkIncDec(event, var, min, max, (flags)|INCDEC_SWITCH, available) #define CHECK_INCDEC_MODELSWITCH(event, var, min, max, available) \ CHECK_INCDEC_SWITCH(event, var, min, max, EE_MODEL, available) -bool isInputAvailable(int input); -bool isSourceAvailable(int source); -bool isSourceAvailableInGlobalFunctions(int source); -bool isSourceAvailableInCustomSwitches(int source); -bool isInputSourceAvailable(int source); #define CHECK_INCDEC_MODELSOURCE(event, var, min, max) \ var = checkIncDec(event,var,min,max,EE_MODEL|INCDEC_SOURCE|NO_INCDEC_MARKS, isSourceAvailable) @@ -249,9 +223,6 @@ void title(const pm_char * s); MENU_TAB(__VA_ARGS__); \ MENU_CHECK_FLAGS(title, tab, menu, flags, lines_count) -#define SIMPLE_MENU_NOTITLE(tab, menu, lines_count) \ - check_simple(NULL, event, menu, tab, DIM(tab), lines_count); - #define SIMPLE_MENU(title, tab, menu, lines_count) \ check_simple(title, event, menu, tab, DIM(tab), lines_count) @@ -294,9 +265,9 @@ swsrc_t switchMenuItem(coord_t x, coord_t y, swsrc_t value, LcdFlags attr, uint8 void editName(coord_t x, coord_t y, char *name, uint8_t size, uint8_t event, uint8_t active, uint8_t attr=ZCHAR); -#define WARNING_TYPE_ASTERISK 0 -#define WARNING_TYPE_CONFIRM 1 -#define WARNING_TYPE_INPUT 2 +#define WARNING_TYPE_ASTERISK 0 +#define WARNING_TYPE_CONFIRM 1 +#define WARNING_TYPE_INPUT 2 extern const pm_char * s_warning; extern const pm_char * s_warning_info; @@ -304,12 +275,12 @@ extern uint8_t s_warning_info_len; extern uint8_t s_warning_result; extern uint8_t s_warning_type; -#define MENU_X 30 -#define MENU_Y 16 -#define MENU_W LCD_W-(2*MENU_X) -#define WARNING_LINE_LEN 32 -#define WARNING_LINE_X 16 -#define WARNING_LINE_Y 3*FH +#define MENU_X 30 +#define MENU_Y 16 +#define MENU_W LCD_W-(2*MENU_X) +#define WARNING_LINE_LEN 32 +#define WARNING_LINE_X 16 +#define WARNING_LINE_Y 3*FH void displayBox(const char *title); void displayPopup(const char *title); @@ -321,19 +292,19 @@ extern int16_t s_warning_input_min; extern int16_t s_warning_input_max; extern uint8_t s_warning_info_flags; -#define DISPLAY_WARNING (*popupFunc) -#define POPUP_WARNING(s) (s_warning = s, s_warning_info = 0, popupFunc = displayWarning) -#define POPUP_CONFIRMATION(s) (s_warning = s, s_warning_type = WARNING_TYPE_CONFIRM, s_warning_info = 0, popupFunc = displayWarning) +#define DISPLAY_WARNING (*popupFunc) +#define POPUP_WARNING(s) (s_warning = s, s_warning_info = 0, popupFunc = displayWarning) +#define POPUP_CONFIRMATION(s) (s_warning = s, s_warning_type = WARNING_TYPE_CONFIRM, s_warning_info = 0, popupFunc = displayWarning) #define POPUP_INPUT(s, func, start, min, max) (s_warning = s, s_warning_type = WARNING_TYPE_INPUT, popupFunc = func, s_warning_input_value = start, s_warning_input_min = min, s_warning_input_max = max) -#define WARNING_INFO_FLAGS s_warning_info_flags +#define WARNING_INFO_FLAGS s_warning_info_flags #define SET_WARNING_INFO(info, len, flags) (s_warning_info = info, s_warning_info_len = len, s_warning_info_flags = flags) #define NAVIGATION_MENUS -#define MENU_ADD_ITEM(s) do { s_menu_offset_type = MENU_OFFSET_INTERNAL; if (s_menu_count < MENU_MAX_LINES) s_menu[s_menu_count++] = s; } while (0) -#define MENU_MAX_LINES 12 -#define MENU_MAX_DISPLAY_LINES 6 -#define MENU_ADD_SD_ITEM(s) MENU_ADD_ITEM(s) -#define MENU_LINE_LENGTH (LEN_MODEL_NAME+12) +#define MENU_ADD_ITEM(s) do { s_menu_offset_type = MENU_OFFSET_INTERNAL; if (s_menu_count < MENU_MAX_LINES) s_menu[s_menu_count++] = s; } while (0) +#define MENU_MAX_LINES 12 +#define MENU_MAX_DISPLAY_LINES 6 +#define MENU_ADD_SD_ITEM(s) MENU_ADD_ITEM(s) +#define MENU_LINE_LENGTH (LEN_MODEL_NAME+12) extern const char *s_menu[MENU_MAX_LINES]; extern uint16_t s_menu_count; extern uint8_t s_menu_flags; @@ -346,16 +317,15 @@ extern uint8_t s_menu_offset_type; const char * displayMenu(uint8_t event); extern void (*menuHandler)(const char *result); -#define STATUS_LINE_LENGTH 32 +#define STATUS_LINE_LENGTH 32 extern char statusLineMsg[STATUS_LINE_LENGTH]; void showStatusLine(); void drawStatusLine(); -#define TEXT_FILENAME_MAXLEN 40 +#define TEXT_FILENAME_MAXLEN 40 extern char s_text_file[TEXT_FILENAME_MAXLEN]; void menuTextView(uint8_t event); void pushMenuTextView(const char *filename); -bool modelHasNotes(); void pushModelNotes(); void menuChannelsView(uint8_t event); @@ -363,31 +333,27 @@ void menuChannelsView(uint8_t event); #define LABEL(...) (uint8_t)-1 #if defined(REV9E) && !defined(SIMU) - #define KEY_MOVE_UP KEY_MINUS - #define KEY_MOVE_DOWN KEY_PLUS - #define CURSOR_MOVED_LEFT(event) (EVT_KEY_MASK(event) == KEY_MINUS) - #define CURSOR_MOVED_RIGHT(event) (EVT_KEY_MASK(event) == KEY_PLUS) - #define CASE_EVT_ROTARY_MOVE_RIGHT CASE_EVT_ROTARY_RIGHT - #define CASE_EVT_ROTARY_MOVE_LEFT CASE_EVT_ROTARY_LEFT - #define IS_ROTARY_MOVE_RIGHT IS_ROTARY_RIGHT - #define IS_ROTARY_MOVE_LEFT IS_ROTARY_LEFT + #define KEY_UP KEY_MINUS + #define KEY_DOWN KEY_PLUS + #define KEY_RIGHT KEY_PLUS + #define KEY_LEFT KEY_MINUS + #define CURSOR_MOVED_LEFT(event) (EVT_KEY_MASK(event) == KEY_LEFT) + #define CURSOR_MOVED_RIGHT(event) (EVT_KEY_MASK(event) == KEY_RIGHT) #else - #define KEY_MOVE_UP KEY_PLUS - #define KEY_MOVE_DOWN KEY_MINUS - #define CURSOR_MOVED_LEFT(event) (EVT_KEY_MASK(event) == KEY_PLUS) - #define CURSOR_MOVED_RIGHT(event) (EVT_KEY_MASK(event) == KEY_MINUS) - #define CASE_EVT_ROTARY_MOVE_RIGHT CASE_EVT_ROTARY_LEFT - #define CASE_EVT_ROTARY_MOVE_LEFT CASE_EVT_ROTARY_RIGHT - #define IS_ROTARY_MOVE_RIGHT IS_ROTARY_LEFT - #define IS_ROTARY_MOVE_LEFT IS_ROTARY_RIGHT + #define KEY_UP KEY_PLUS + #define KEY_DOWN KEY_MINUS + #define KEY_RIGHT KEY_MINUS + #define KEY_LEFT KEY_PLUS + #define CURSOR_MOVED_LEFT(event) (EVT_KEY_MASK(event) == KEY_LEFT) + #define CURSOR_MOVED_RIGHT(event) (EVT_KEY_MASK(event) == KEY_RIGHT) #endif -#define REPEAT_LAST_CURSOR_MOVE() { if (CURSOR_MOVED_LEFT(event) || CURSOR_MOVED_RIGHT(event)) putEvent(event); else m_posHorz = 0; } -#define MOVE_CURSOR_FROM_HERE() if (m_posHorz > 0) REPEAT_LAST_CURSOR_MOVE() +#define REPEAT_LAST_CURSOR_MOVE() { if (CURSOR_MOVED_LEFT(event) || CURSOR_MOVED_RIGHT(event)) putEvent(event); else m_posHorz = 0; } +#define MOVE_CURSOR_FROM_HERE() if (m_posHorz > 0) REPEAT_LAST_CURSOR_MOVE() -#define POS_VERT_INIT (menuTab ? (MAXCOL((uint16_t)0) >= HIDDEN_ROW ? (MAXCOL((uint16_t)1) >= HIDDEN_ROW ? 2 : 1) : 0) : 0) -#define POS_HORZ_INIT(posVert) ((COLATTR(posVert) & NAVIGATION_LINE_BY_LINE) ? -1 : 0) -#define EDIT_MODE_INIT 0 // TODO enum +#define MENU_FIRST_LINE_EDIT (menuTab ? (MAXCOL((uint16_t)0) >= HIDDEN_ROW ? (MAXCOL((uint16_t)1) >= HIDDEN_ROW ? 2 : 1) : 0) : 0) +#define POS_HORZ_INIT(posVert) ((COLATTR(posVert) & NAVIGATION_LINE_BY_LINE) ? -1 : 0) +#define EDIT_MODE_INIT 0 // TODO enum typedef int16_t (*FnFuncP) (int16_t x); void DrawFunction(FnFuncP fn, uint8_t offset=0); diff --git a/radio/src/gui/Taranis/navigation.cpp b/radio/src/gui/Taranis/navigation.cpp index da6a4dfcf..4e0ca0d2a 100644 --- a/radio/src/gui/Taranis/navigation.cpp +++ b/radio/src/gui/Taranis/navigation.cpp @@ -173,7 +173,7 @@ int checkIncDec(unsigned int event, int val, int i_min, int i_max, unsigned int } #endif - if (s_editMode>0 && (IS_ROTARY_RIGHT(event) || event==EVT_KEY_FIRST(KEY_UP) || event==EVT_KEY_REPT(KEY_UP))) { + if (s_editMode>0 && (event==EVT_KEY_FIRST(KEY_PLUS) || event==EVT_KEY_REPT(KEY_PLUS))) { do { if (IS_KEY_REPT(event) && (i_flags & INCDEC_REP10)) { newval += min(10, i_max-val); @@ -192,7 +192,7 @@ int checkIncDec(unsigned int event, int val, int i_min, int i_max, unsigned int AUDIO_KEYPAD_UP(); } } - else if (s_editMode>0 && (IS_ROTARY_LEFT(event) || event==EVT_KEY_FIRST(KEY_DOWN) || event==EVT_KEY_REPT(KEY_DOWN))) { + else if (s_editMode>0 && (event==EVT_KEY_FIRST(KEY_MINUS) || event==EVT_KEY_REPT(KEY_MINUS))) { do { if (IS_KEY_REPT(event) && (i_flags & INCDEC_REP10)) { newval -= min(10, val-i_min); @@ -212,7 +212,7 @@ int checkIncDec(unsigned int event, int val, int i_min, int i_max, unsigned int } } - if (!READ_ONLY() && i_min==0 && i_max==1 && (event==EVT_KEY_BREAK(KEY_ENTER) || IS_ROTARY_BREAK(event))) { + if (!READ_ONLY() && i_min==0 && i_max==1 && event==EVT_KEY_BREAK(KEY_ENTER)) { s_editMode = 0; newval = !val; } @@ -249,7 +249,7 @@ int checkIncDec(unsigned int event, int val, int i_min, int i_max, unsigned int } if (newval != val) { - if (!(i_flags & NO_INCDEC_MARKS) && (newval != i_max) && (newval != i_min) && stops.contains(newval) && !IS_ROTARY_EVENT(event)) { + if (!(i_flags & NO_INCDEC_MARKS) && (newval != i_max) && (newval != i_min) && stops.contains(newval)) { bool pause = (newval > val ? !stops.contains(newval+1) : !stops.contains(newval-1)); if (pause) { pauseEvents(event); // delay before auto-repeat continues @@ -259,7 +259,7 @@ int checkIncDec(unsigned int event, int val, int i_min, int i_max, unsigned int AUDIO_KEYPAD_DOWN(); } } - eeDirty(i_flags & (EE_GENERAL|EE_MODEL)); + storageDirty(i_flags & (EE_GENERAL|EE_MODEL)); checkIncDec_Ret = (newval > val ? 1 : -1); } else { @@ -422,7 +422,7 @@ void check(const char *name, check_event_t event, uint8_t curr, const MenuFuncP { case EVT_ENTRY: menuEntryTime = get_tmr10ms(); - l_posVert = POS_VERT_INIT; + l_posVert = MENU_FIRST_LINE_EDIT; l_posHorz = POS_HORZ_INIT(l_posVert); SET_SCROLLBAR_X(LCD_W-1); s_editMode = EDIT_MODE_INIT; @@ -462,7 +462,7 @@ void check(const char *name, check_event_t event, uint8_t curr, const MenuFuncP } else { - uint8_t posVertInit = POS_VERT_INIT; + uint8_t posVertInit = MENU_FIRST_LINE_EDIT; if (s_pgOfs != 0 || l_posVert != posVertInit) { s_pgOfs = 0; l_posVert = posVertInit; @@ -474,7 +474,8 @@ void check(const char *name, check_event_t event, uint8_t curr, const MenuFuncP } break; - CASE_EVT_ROTARY_MOVE_RIGHT + case EVT_KEY_FIRST(KEY_RIGHT): + case EVT_KEY_REPT(KEY_RIGHT): if (s_editMode != 0) break; if ((COLATTR(l_posVert) & NAVIGATION_LINE_BY_LINE)) { if (l_posHorz >= 0) { @@ -489,13 +490,11 @@ void check(const char *name, check_event_t event, uint8_t curr, const MenuFuncP } else { l_posHorz = 0; - if (!IS_ROTARY_MOVE_RIGHT(event)) - break; } } do { - INC(l_posVert, POS_VERT_INIT, rowcount-1); + INC(l_posVert, MENU_FIRST_LINE_EDIT, rowcount-1); } while (CURSOR_NOT_ALLOWED_IN_ROW(l_posVert)); s_editMode = 0; // if we go down, we must be in this mode @@ -503,7 +502,8 @@ void check(const char *name, check_event_t event, uint8_t curr, const MenuFuncP l_posHorz = POS_HORZ_INIT(l_posVert); break; - CASE_EVT_ROTARY_MOVE_LEFT + case EVT_KEY_FIRST(KEY_LEFT): + case EVT_KEY_REPT(KEY_LEFT): if (s_editMode != 0) break; if ((COLATTR(l_posVert) & NAVIGATION_LINE_BY_LINE)) { if (l_posHorz >= 0) { @@ -511,22 +511,13 @@ void check(const char *name, check_event_t event, uint8_t curr, const MenuFuncP break; } } - else { - if (l_posHorz > 0) { - l_posHorz--; - break; - } - else if (IS_ROTARY_MOVE_LEFT(event) && s_editMode == 0) { - l_posHorz = 0xff; - } - else { - l_posHorz = maxcol; - break; - } + else if (l_posHorz > 0) { + l_posHorz--; + break; } do { - DEC(l_posVert, POS_VERT_INIT, rowcount-1); + DEC(l_posVert, MENU_FIRST_LINE_EDIT, rowcount-1); } while (CURSOR_NOT_ALLOWED_IN_ROW(l_posVert)); s_editMode = 0; // if we go up, we must be in this mode @@ -597,24 +588,24 @@ void check(const char *name, check_event_t event, uint8_t curr, const MenuFuncP } if (scrollbar_X && linesCount > NUM_BODY_LINES) { - displayScrollbar(scrollbar_X, MENU_HEADER_HEIGHT, LCD_H-MENU_HEADER_HEIGHT, s_pgOfs, linesCount, NUM_BODY_LINES); + drawScrollbar(scrollbar_X, MENU_HEADER_HEIGHT, LCD_H-MENU_HEADER_HEIGHT, s_pgOfs, linesCount, NUM_BODY_LINES); } if (name) { title(name); } - + m_posVert = l_posVert; m_posHorz = l_posHorz; } -void check_simple(const char *name, check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTabSize, vertpos_t rowcount) +void check_simple(const char * name, check_event_t event, uint8_t curr, const MenuFuncP *menuTab, uint8_t menuTabSize, vertpos_t rowcount) { check(name, event, curr, menuTab, menuTabSize, 0, 0, rowcount); } -void check_submenu_simple(const char *name, check_event_t event, uint8_t rowcount) +void check_submenu_simple(const char * name, check_event_t event, uint8_t rowcount) { check_simple(name, event, 0, 0, 0, rowcount); } diff --git a/radio/src/gui/Taranis/popups.cpp b/radio/src/gui/Taranis/popups.cpp index 9eb322a37..aac4461c5 100644 --- a/radio/src/gui/Taranis/popups.cpp +++ b/radio/src/gui/Taranis/popups.cpp @@ -57,7 +57,7 @@ void (*menuHandler)(const char *result); void displayBox(const char *title) { drawFilledRect(10, 16, LCD_W-20, 40, SOLID, ERASE); - lcd_rect(10, 16, LCD_W-20, 40); + lcdDrawRect(10, 16, LCD_W-20, 40); lcd_putsn(WARNING_LINE_X, WARNING_LINE_Y, title, WARNING_LINE_LEN); // could be a place for a s_warning_info } @@ -70,17 +70,17 @@ void displayPopup(const char *title) void message(const pm_char *title, const pm_char *t, const char *last MESSAGE_SOUND_ARG) { - lcd_clear(); + lcdClear(); lcd_bmp(0, 0, asterisk_lbm); #define MESSAGE_LCD_OFFSET 60 #if defined(TRANSLATIONS_FR) || defined(TRANSLATIONS_IT) || defined(TRANSLATIONS_CZ) - lcd_putsAtt(MESSAGE_LCD_OFFSET, 0, STR_WARNING, DBLSIZE); - lcd_putsAtt(MESSAGE_LCD_OFFSET, 2*FH, title, DBLSIZE); + lcdDrawText(MESSAGE_LCD_OFFSET, 0, STR_WARNING, DBLSIZE); + lcdDrawText(MESSAGE_LCD_OFFSET, 2*FH, title, DBLSIZE); #else - lcd_putsAtt(MESSAGE_LCD_OFFSET, 0, title, DBLSIZE); - lcd_putsAtt(MESSAGE_LCD_OFFSET, 2*FH, STR_WARNING, DBLSIZE); + lcdDrawText(MESSAGE_LCD_OFFSET, 0, title, DBLSIZE); + lcdDrawText(MESSAGE_LCD_OFFSET, 2*FH, STR_WARNING, DBLSIZE); #endif drawFilledRect(MESSAGE_LCD_OFFSET, 0, LCD_W-MESSAGE_LCD_OFFSET, 32); @@ -102,7 +102,7 @@ void displayWarning(uint8_t event) s_warning_result = false; displayBox(s_warning); if (s_warning_info) { - lcd_putsnAtt(WARNING_LINE_X, WARNING_LINE_Y+FH, s_warning_info, s_warning_info_len, WARNING_INFO_FLAGS); + lcdDrawTextWithLen(WARNING_LINE_X, WARNING_LINE_Y+FH, s_warning_info, s_warning_info_len, WARNING_INFO_FLAGS); } lcd_puts(WARNING_LINE_X, WARNING_LINE_Y+2*FH, s_warning_type == WARNING_TYPE_ASTERISK ? STR_EXIT : STR_POPUPS); switch (event) { @@ -131,20 +131,20 @@ const char * displayMenu(uint8_t event) uint8_t display_count = min(s_menu_count, MENU_MAX_DISPLAY_LINES); uint8_t y = (display_count >= 5 ? MENU_Y - FH - 1 : MENU_Y); drawFilledRect(MENU_X, y, MENU_W, display_count * (FH+1) + 2, SOLID, ERASE); - lcd_rect(MENU_X, y, MENU_W, display_count * (FH+1) + 2); + lcdDrawRect(MENU_X, y, MENU_W, display_count * (FH+1) + 2); for (uint8_t i=0; i display_count) { - displayScrollbar(MENU_X+MENU_W-1, y+1, MENU_MAX_DISPLAY_LINES * (FH+1), s_menu_offset, s_menu_count, display_count); + drawScrollbar(MENU_X+MENU_W-1, y+1, MENU_MAX_DISPLAY_LINES * (FH+1), s_menu_offset, s_menu_count, display_count); } switch(event) { - case EVT_KEY_FIRST(KEY_MOVE_UP): - case EVT_KEY_REPT(KEY_MOVE_UP): + case EVT_KEY_FIRST(KEY_UP): + case EVT_KEY_REPT(KEY_UP): if (s_menu_item > 0) { s_menu_item--; } @@ -161,8 +161,8 @@ const char * displayMenu(uint8_t event) } break; - case EVT_KEY_FIRST(KEY_MOVE_DOWN): - case EVT_KEY_REPT(KEY_MOVE_DOWN): + case EVT_KEY_FIRST(KEY_DOWN): + case EVT_KEY_REPT(KEY_DOWN): if (s_menu_item < display_count - 1 && s_menu_offset + s_menu_item + 1 < s_menu_count) { s_menu_item++; } @@ -178,7 +178,6 @@ const char * displayMenu(uint8_t event) } } break; - CASE_EVT_ROTARY_BREAK case EVT_KEY_BREAK(KEY_ENTER): result = s_menu[s_menu_item + (s_menu_offset_type == MENU_OFFSET_INTERNAL ? s_menu_offset : 0)]; // no break diff --git a/radio/src/gui/Taranis/splash.cpp b/radio/src/gui/Taranis/splash.cpp index 4f0e88d7d..d9045b6bf 100644 --- a/radio/src/gui/Taranis/splash.cpp +++ b/radio/src/gui/Taranis/splash.cpp @@ -45,7 +45,7 @@ const pm_uchar * const splash_lbm = splashdata+4; void displaySplash() { - lcd_clear(); + lcdClear(); lcd_bmp(0, 0, splash_lbm); #if MENUS_LOCK == 1 diff --git a/radio/src/gui/Taranis/view_about.cpp b/radio/src/gui/Taranis/view_about.cpp index 05c92a86a..c76138fb1 100644 --- a/radio/src/gui/Taranis/view_about.cpp +++ b/radio/src/gui/Taranis/view_about.cpp @@ -83,7 +83,7 @@ void menuAboutView(uint8_t event) } lcd_bmp(0, 0, about_bmp); - lcd_putsAtt(64, 0, STR_ABOUTUS, DBLSIZE); + lcdDrawText(64, 0, STR_ABOUTUS, DBLSIZE); lcd_hline(ABOUT_X, 18, 120); lcd_hline(ABOUT_X, 19, 130, GREY_DEFAULT); LcdFlags att = GREY(max(0, 15-greyIndex/2)); @@ -93,67 +93,67 @@ void menuAboutView(uint8_t event) switch (screenIndex) { case ABOUT_OPENTX: case ABOUT_END: - lcd_putsAtt(ABOUT_X, 22, STR_ABOUT_OPENTX_1, SMLSIZE); - lcd_putsAtt(ABOUT_X, 30, STR_ABOUT_OPENTX_2, SMLSIZE); - lcd_putsAtt(ABOUT_X, 38, STR_ABOUT_OPENTX_3, SMLSIZE); - lcd_putsAtt(ABOUT_X, 46, STR_ABOUT_OPENTX_4, SMLSIZE); - lcd_putsAtt(ABOUT_X, 54, STR_ABOUT_OPENTX_5, SMLSIZE); + lcdDrawText(ABOUT_X, 22, STR_ABOUT_OPENTX_1, SMLSIZE); + lcdDrawText(ABOUT_X, 30, STR_ABOUT_OPENTX_2, SMLSIZE); + lcdDrawText(ABOUT_X, 38, STR_ABOUT_OPENTX_3, SMLSIZE); + lcdDrawText(ABOUT_X, 46, STR_ABOUT_OPENTX_4, SMLSIZE); + lcdDrawText(ABOUT_X, 54, STR_ABOUT_OPENTX_5, SMLSIZE); screenDuration = 255; break; case ABOUT_BERTRAND: - lcd_putsAtt(ABOUT_X, 24, STR_ABOUT_BERTRAND_1, att); - lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_BERTRAND_2, att|SMLSIZE); - lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_BERTRAND_3, att|SMLSIZE); + lcdDrawText(ABOUT_X, 24, STR_ABOUT_BERTRAND_1, att); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_BERTRAND_2, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_BERTRAND_3, att|SMLSIZE); break; case ABOUT_ANDRE: - lcd_putsAtt(ABOUT_X, 24, STR_ABOUT_ANDRE_1, att); - lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_ANDRE_2, att|SMLSIZE); - lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_ANDRE_3, att|SMLSIZE); + lcdDrawText(ABOUT_X, 24, STR_ABOUT_ANDRE_1, att); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_ANDRE_2, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_ANDRE_3, att|SMLSIZE); break; case ABOUT_MIKE: - lcd_putsAtt(ABOUT_X, 24, STR_ABOUT_MIKE_1, att); - lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_MIKE_2, att|SMLSIZE); - lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_MIKE_3, att|SMLSIZE); - lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 52, STR_ABOUT_MIKE_4, att|SMLSIZE); + lcdDrawText(ABOUT_X, 24, STR_ABOUT_MIKE_1, att); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_MIKE_2, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_MIKE_3, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 52, STR_ABOUT_MIKE_4, att|SMLSIZE); break; case ABOUT_KJELL: - lcd_putsAtt(ABOUT_X, 24, STR_ABOUT_KJELL_1, att); - lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_KJELL_2, att|SMLSIZE); - lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_KJELL_3, att|SMLSIZE); - lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 52, STR_ABOUT_KJELL_4, att|SMLSIZE); + lcdDrawText(ABOUT_X, 24, STR_ABOUT_KJELL_1, att); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_KJELL_2, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_KJELL_3, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 52, STR_ABOUT_KJELL_4, att|SMLSIZE); break; case ABOUT_MARTIN: - lcd_putsAtt(ABOUT_X, 24, STR_ABOUT_MARTIN_1, att); - lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_MARTIN_2, att|SMLSIZE); + lcdDrawText(ABOUT_X, 24, STR_ABOUT_MARTIN_1, att); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_MARTIN_2, att|SMLSIZE); break; case ABOUT_ROMOLO: - lcd_putsAtt(ABOUT_X, 24, STR_ABOUT_ROMOLO_1, att); - lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_ROMOLO_2, att|SMLSIZE); - lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_ROMOLO_3, att|SMLSIZE); + lcdDrawText(ABOUT_X, 24, STR_ABOUT_ROMOLO_1, att); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_ROMOLO_2, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_ROMOLO_3, att|SMLSIZE); break; case ABOUT_ROB: - lcd_putsAtt(ABOUT_X, 24, STR_ABOUT_ROB_1, att); - lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_ROB_2, att|SMLSIZE); + lcdDrawText(ABOUT_X, 24, STR_ABOUT_ROB_1, att); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_ROB_2, att|SMLSIZE); break; case ABOUT_HARDWARE: - lcd_putsAtt(ABOUT_X, 24, STR_ABOUT_HARDWARE_1, att); - lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_HARDWARE_2, att|SMLSIZE); - lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_HARDWARE_3, att|SMLSIZE); + lcdDrawText(ABOUT_X, 24, STR_ABOUT_HARDWARE_1, att); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_HARDWARE_2, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_HARDWARE_3, att|SMLSIZE); break; case ABOUT_PARENTS: - lcd_putsAtt(ABOUT_X, 24, STR_ABOUT_PARENTS_1, att); - lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_PARENTS_2, att|SMLSIZE); - lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_PARENTS_3, att|SMLSIZE); - lcd_putsAtt(ABOUT_X+ABOUT_INDENT, 52, STR_ABOUT_PARENTS_4, att|SMLSIZE); + lcdDrawText(ABOUT_X, 24, STR_ABOUT_PARENTS_1, att); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 36, STR_ABOUT_PARENTS_2, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 44, STR_ABOUT_PARENTS_3, att|SMLSIZE); + lcdDrawText(ABOUT_X+ABOUT_INDENT, 52, STR_ABOUT_PARENTS_4, att|SMLSIZE); screenDuration = 255; break; } diff --git a/radio/src/gui/Taranis/view_channels.cpp b/radio/src/gui/Taranis/view_channels.cpp index b5e48aea0..9dd22de26 100644 --- a/radio/src/gui/Taranis/view_channels.cpp +++ b/radio/src/gui/Taranis/view_channels.cpp @@ -100,7 +100,7 @@ void menuChannelsView(uint8_t event) } if (lenLabel > 0) - lcd_putsnAtt(x+1-ofs, y, g_model.limitData[ch].name, sizeof(g_model.limitData[ch].name), ZCHAR | SMLSIZE); + lcdDrawTextWithLen(x+1-ofs, y, g_model.limitData[ch].name, sizeof(g_model.limitData[ch].name), ZCHAR | SMLSIZE); else putsChn(x+1-ofs, y, ch+1, SMLSIZE); diff --git a/radio/src/gui/Taranis/view_main.cpp b/radio/src/gui/Taranis/view_main.cpp index a4d7e7cb2..6d9526d59 100644 --- a/radio/src/gui/Taranis/view_main.cpp +++ b/radio/src/gui/Taranis/view_main.cpp @@ -176,7 +176,7 @@ void displayTrims(uint8_t phase) } } -void displaySliders() +void drawSliders() { for (uint8_t i=NUM_STICKS; i 0) { - lcd_putsnAtt(TIMERS_X, y-7, timerData.name, LEN_TIMER_NAME, ZCHAR|SMLSIZE); + if (ZLEN(timerData.name) > 0) { + lcdDrawTextWithLen(TIMERS_X, y-7, timerData.name, LEN_TIMER_NAME, ZCHAR|SMLSIZE); } else { putsTimerMode(TIMERS_X, y-7, timerData.mode, SMLSIZE); } putsTimer(TIMERS_X, y, timerState.val, TIMEHOUR|MIDSIZE|LEFT, TIMEHOUR|MIDSIZE|LEFT); if (timerData.persistent) { - lcd_putcAtt(TIMERS_R, y+1, 'P', SMLSIZE); + lcdDrawChar(TIMERS_R, y+1, 'P', SMLSIZE); } if (timerState.val < 0) { if (BLINK_ON_PHASE) { @@ -404,7 +406,7 @@ void displaySwitch(coord_t x, coord_t y, int width, unsigned int index) } } - lcd_putcAtt(width==5 ? x+1 : x, y, 'A'+index, TINSIZE); + lcdDrawChar(width==5 ? x+1 : x, y, 'A'+index, TINSIZE); y += 6; if (val <= 0) { @@ -512,7 +514,7 @@ void menuMainView(uint8_t event) #endif case EVT_KEY_BREAK(KEY_PAGE): - eeDirty(EE_GENERAL); + storageDirty(EE_GENERAL); g_eeGeneral.view += 1; if (g_eeGeneral.view >= VIEW_COUNT) { g_eeGeneral.view = 0; @@ -541,7 +543,7 @@ void menuMainView(uint8_t event) // Flight Mode Name int mode = mixerCurrentFlightMode; - lcd_putsnAtt(PHASE_X, PHASE_Y, g_model.flightModeData[mode].name, sizeof(g_model.flightModeData[mode].name), ZCHAR|PHASE_FLAGS); + lcdDrawTextWithLen(PHASE_X, PHASE_Y, g_model.flightModeData[mode].name, sizeof(g_model.flightModeData[mode].name), ZCHAR|PHASE_FLAGS); // Model Name putsModelName(MODELNAME_X, MODELNAME_Y, g_model.header.name, g_eeGeneral.currModel, BIGSIZE); @@ -553,7 +555,7 @@ void menuMainView(uint8_t event) displayTopBar(); // Sliders (Pots / Sliders) - displaySliders(); + drawSliders(); lcd_bmp(BITMAP_X, BITMAP_Y, modelBitmap); @@ -608,7 +610,7 @@ void menuMainView(uint8_t event) drawFilledRect(x, y, 4, 8); } else { - lcd_rect(x, y, 4, 8); + lcdDrawRect(x, y, 4, 8); } } } @@ -617,10 +619,10 @@ void menuMainView(uint8_t event) if (s_gvar_timer > 0) { s_gvar_timer--; drawFilledRect(BITMAP_X, BITMAP_Y, 64, 32, SOLID, ERASE); - lcd_rect(BITMAP_X, BITMAP_Y, 64, 32); + lcdDrawRect(BITMAP_X, BITMAP_Y, 64, 32); putsStrIdx(BITMAP_X+FW, BITMAP_Y+FH-1, STR_GV, s_gvar_last+1); - lcd_putsnAtt(BITMAP_X+4*FW+FW/2, BITMAP_Y+FH-1, g_model.gvars[s_gvar_last].name, LEN_GVAR_NAME, ZCHAR); - lcd_putsAtt(BITMAP_X+FW, BITMAP_Y+2*FH+3, PSTR("[\010]"), BOLD); + lcdDrawTextWithLen(BITMAP_X+4*FW+FW/2, BITMAP_Y+FH-1, g_model.gvars[s_gvar_last].name, LEN_GVAR_NAME, ZCHAR); + lcdDrawText(BITMAP_X+FW, BITMAP_Y+2*FH+3, PSTR("[\010]"), BOLD); lcd_outdezAtt(BITMAP_X+5*FW+FW/2, BITMAP_Y+2*FH+3, GVAR_VALUE(s_gvar_last, getGVarFlightPhase(mixerCurrentFlightMode, s_gvar_last)), BOLD); } #endif diff --git a/radio/src/gui/Taranis/view_statistics.cpp b/radio/src/gui/Taranis/view_statistics.cpp index 575a45f0b..7d8dc0da7 100644 --- a/radio/src/gui/Taranis/view_statistics.cpp +++ b/radio/src/gui/Taranis/view_statistics.cpp @@ -49,7 +49,7 @@ void menuStatisticsView(uint8_t event) case EVT_KEY_LONG(KEY_MENU): g_eeGeneral.globalTimer = 0; - eeDirty(EE_GENERAL); + storageDirty(EE_GENERAL); sessionTimer = 0; break; @@ -125,7 +125,7 @@ void menuStatisticsDebug(uint8_t event) case EVT_KEY_LONG(KEY_ENTER): g_eeGeneral.mAhUsed = 0; g_eeGeneral.globalTimer = 0; - eeDirty(EE_GENERAL); + storageDirty(EE_GENERAL); sessionTimer = 0; killEvents(event); AUDIO_KEYPAD_UP(); @@ -168,9 +168,9 @@ void menuStatisticsDebug(uint8_t event) #if defined(LUA) lcd_putsLeft(MENU_DEBUG_Y_LUA, "Lua scripts"); - lcd_putsAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_LUA+1, "[Duration]", SMLSIZE); + lcdDrawText(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_LUA+1, "[Duration]", SMLSIZE); lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_LUA, 10*maxLuaDuration, LEFT); - lcd_putsAtt(lcdLastPos+2, MENU_DEBUG_Y_LUA+1, "[Interval]", SMLSIZE); + lcdDrawText(lcdLastPos+2, MENU_DEBUG_Y_LUA+1, "[Interval]", SMLSIZE); lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_LUA, 10*maxLuaInterval, LEFT); #endif @@ -188,13 +188,13 @@ void menuStatisticsDebug(uint8_t event) #endif lcd_putsLeft(MENU_DEBUG_Y_RTOS, STR_FREESTACKMINB); - lcd_putsAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_RTOS+1, "[M]", SMLSIZE); + lcdDrawText(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_RTOS+1, "[M]", SMLSIZE); lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_RTOS, menusStack.available(), UNSIGN|LEFT); - lcd_putsAtt(lcdLastPos+2, MENU_DEBUG_Y_RTOS+1, "[X]", SMLSIZE); + lcdDrawText(lcdLastPos+2, MENU_DEBUG_Y_RTOS+1, "[X]", SMLSIZE); lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_RTOS, mixerStack.available(), UNSIGN|LEFT); - lcd_putsAtt(lcdLastPos+2, MENU_DEBUG_Y_RTOS+1, "[A]", SMLSIZE); + lcdDrawText(lcdLastPos+2, MENU_DEBUG_Y_RTOS+1, "[A]", SMLSIZE); lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_RTOS, audioStack.available(), UNSIGN|LEFT); - lcd_putsAtt(lcdLastPos+2, MENU_DEBUG_Y_RTOS+1, "[I]", SMLSIZE); + lcdDrawText(lcdLastPos+2, MENU_DEBUG_Y_RTOS+1, "[I]", SMLSIZE); lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_RTOS, stackAvailable(), UNSIGN|LEFT); lcd_puts(3*FW, 7*FH+1, STR_MENUTORESET); diff --git a/radio/src/gui/Taranis/view_telemetry.cpp b/radio/src/gui/Taranis/view_telemetry.cpp index d35a04a91..c2a212eba 100644 --- a/radio/src/gui/Taranis/view_telemetry.cpp +++ b/radio/src/gui/Taranis/view_telemetry.cpp @@ -54,11 +54,11 @@ void displayRssiLine() lcd_hline(0, 55, 212, 0); // separator uint8_t rssi = min((uint8_t)99, TELEMETRY_RSSI()); lcd_putsn(0, STATUS_BAR_Y, STR_RX, 2); lcd_outdezNAtt(4*FW, STATUS_BAR_Y, rssi, LEADING0, 2); - lcd_rect(BAR_LEFT, 57, 78, 7); + lcdDrawRect(BAR_LEFT, 57, 78, 7); drawFilledRect(BAR_LEFT+1, 58, 19*rssi/25, 5, (rssi < getRssiAlarmValue(0)) ? DOTTED : SOLID); } else { - lcd_putsAtt(7*FW, STATUS_BAR_Y, STR_NODATA, BLINK); + lcdDrawText(7*FW, STATUS_BAR_Y, STR_NODATA, BLINK); lcd_status_line(); } } @@ -94,7 +94,7 @@ void displayGaugesTelemetryScreen(FrSkyScreenData & screen) if (source && barMax > barMin) { int y = barHeight+6+i*(barHeight+6); putsMixerSource(0, y+barHeight-5, source, 0); - lcd_rect(BAR_LEFT, y, BAR_WIDTH+1, barHeight+2); + lcdDrawRect(BAR_LEFT, y, BAR_WIDTH+1, barHeight+2); getvalue_t value = getValue(source); putsChannel(BAR_LEFT+2+BAR_WIDTH, y+barHeight-5, source, LEFT); uint8_t thresholdX = 0; @@ -107,7 +107,7 @@ void displayGaugesTelemetryScreen(FrSkyScreenData & screen) } } if (thresholdX) { - lcd_vlineStip(BAR_LEFT+1+thresholdX, y-2, barHeight+3, DOTTED); + lcdDrawVerticalLine(BAR_LEFT+1+thresholdX, y-2, barHeight+3, DOTTED); lcd_hline(BAR_LEFT+thresholdX, y-2, 3); } } diff --git a/radio/src/gui/Taranis/view_text.cpp b/radio/src/gui/Taranis/view_text.cpp index 807a1a545..a79532f19 100644 --- a/radio/src/gui/Taranis/view_text.cpp +++ b/radio/src/gui/Taranis/view_text.cpp @@ -136,7 +136,7 @@ void menuTextView(uint8_t event) } for (int i=0; i LCD_LINES-1) { - displayScrollbar(LCD_W-1, FH, LCD_H-FH, s_pgOfs, lines_count, LCD_LINES-1); + drawScrollbar(LCD_W-1, FH, LCD_H-FH, s_pgOfs, lines_count, LCD_LINES-1); } } diff --git a/radio/src/gui/Taranis/widgets.cpp b/radio/src/gui/Taranis/widgets.cpp index b9ed8bd23..255c06737 100644 --- a/radio/src/gui/Taranis/widgets.cpp +++ b/radio/src/gui/Taranis/widgets.cpp @@ -42,7 +42,7 @@ const pm_uchar bmp_sleep[] PROGMEM = { void displaySleepBitmap() { - lcd_clear(); + lcdClear(); lcd_bmp(76, 2, bmp_sleep, 0, 60); lcdRefresh(); } @@ -61,7 +61,7 @@ void drawStick(coord_t centrex, int16_t xval, int16_t yval) void displayColumnHeader(const char * const *headers, uint8_t index) { - lcd_putsAtt(17*FW, 0, headers[index], 0); + lcdDrawText(17*FW, 0, headers[index], 0); } void menu_lcd_onoff(coord_t x, coord_t y, uint8_t value, LcdFlags attr) @@ -78,18 +78,18 @@ void displayScreenIndex(uint8_t index, uint8_t count, uint8_t attr) { lcd_outdezAtt(LCD_W, 0, count, attr); coord_t x = 1+LCD_W-FW*(count>9 ? 3 : 2); - lcd_putcAtt(x, 0, '/', attr); + lcdDrawChar(x, 0, '/', attr); lcd_outdezAtt(x, 0, index+1, attr); } -void displayScrollbar(coord_t x, coord_t y, coord_t h, uint16_t offset, uint16_t count, uint8_t visible) +void drawScrollbar(coord_t x, coord_t y, coord_t h, uint16_t offset, uint16_t count, uint8_t visible) { - lcd_vlineStip(x, y, h, DOTTED); + lcdDrawVerticalLine(x, y, h, DOTTED); coord_t yofs = (h * offset) / count; coord_t yhgt = (h * visible) / count; if (yhgt + yofs > h) yhgt = h - yofs; - lcd_vlineStip(x, y + yofs, yhgt, SOLID, FORCE); + lcdDrawVerticalLine(x, y + yofs, yhgt, SOLID, FORCE); } const pm_uchar MAINMENU_LBM[] PROGMEM = { @@ -101,15 +101,15 @@ void displayMenuBar(const MenuItem *menu, int index) drawFilledRect(0, 0, LCD_W, 32, SOLID, ERASE); drawFilledRect(0, 24, LCD_W, 7, SOLID, GREY_DEFAULT); lcd_bmp(1, 0, MAINMENU_LBM); - lcd_putsAtt(0, 24, menu[index].name, INVERS); - lcd_rect(index*24, 0, 26, 24, SOLID, FORCE); - lcd_hlineStip(0, 31, LCD_W, SOLID, FORCE); + lcdDrawText(0, 24, menu[index].name, INVERS); + lcdDrawRect(index*24, 0, 26, 24, SOLID, FORCE); + lcdDrawHorizontalLine(0, 31, LCD_W, SOLID, FORCE); } -void displayProgressBar(const char *label) +void drawProgressBar(const char *label) { lcd_putsLeft(4*FH, label); - lcd_rect(3, 6*FH+4, 204, 7); + lcdDrawRect(3, 6*FH+4, 204, 7); lcdRefresh(); } @@ -126,7 +126,7 @@ 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) { - lcd_rect(x, y, w+1, h); + lcdDrawRect(x, y, w+1, h); drawFilledRect(x+1, y+1, w-1, 4, SOLID, ERASE); coord_t len = limit((uint8_t)1, uint8_t((abs(val) * w/2 + max/2) / max), uint8_t(w/2)); coord_t x0 = (val>0) ? x+w/2 : x+1+w/2-len; @@ -137,13 +137,13 @@ void drawGauge(coord_t x, coord_t y, coord_t w, coord_t h, int32_t val, int32_t void title(const pm_char * s) { - lcd_putsAtt(0, 0, s, INVERS); + lcdDrawText(0, 0, s, INVERS); } select_menu_value_t selectMenuItem(coord_t x, coord_t y, const pm_char *label, const pm_char *values, select_menu_value_t value, select_menu_value_t min, select_menu_value_t max, LcdFlags attr, uint8_t event) { lcd_putsColumnLeft(x, y, label); - if (values) lcd_putsiAtt(x, y, values, value-min, attr); + if (values) lcdDrawTextAtIndex(x, y, values, value-min, attr); if (attr) value = checkIncDec(event, value, min, max, (g_menuPos[0] == 0) ? EE_MODEL : EE_GENERAL); return value; } @@ -162,7 +162,7 @@ swsrc_t switchMenuItem(coord_t x, coord_t y, swsrc_t value, LcdFlags attr, uint8 return value; } -void displaySlider(coord_t x, coord_t y, uint8_t value, uint8_t max, uint8_t attr) +void drawSlider(coord_t x, coord_t y, uint8_t value, uint8_t max, uint8_t attr) { lcd_putc(x+(value*4*FW)/max, y, '$'); lcd_hline(x, y+3, 5*FW-1, FORCE); @@ -188,7 +188,7 @@ int16_t gvarMenuItem(coord_t x, coord_t y, int16_t value, int16_t min, int16_t m value = (GV_IS_GV_VALUE(value, min, max) ? GET_GVAR(value, min, max, mixerCurrentFlightMode)*10 : delta); else value = (GV_IS_GV_VALUE(value, min, max) ? GET_GVAR(value, min, max, mixerCurrentFlightMode) : delta); - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } if (GV_IS_GV_VALUE(value, min, max)) { @@ -208,7 +208,7 @@ int16_t gvarMenuItem(coord_t x, coord_t y, int16_t value, int16_t min, int16_t m if (idx < 0) { value = (int16_t) GV_CALC_VALUE_IDX_NEG(idx, delta); idx = -idx; - lcd_putcAtt(x-6, y, '-', attr); + lcdDrawChar(x-6, y, '-', attr); } else { value = (int16_t) GV_CALC_VALUE_IDX_POS(idx-1, delta); @@ -255,7 +255,7 @@ void drawStatusLine() } drawFilledRect(0, LCD_H-statusLineHeight, LCD_W, FH, SOLID, ERASE); - lcd_putsAtt(5, LCD_H+1-statusLineHeight, statusLineMsg, BSS); + lcdDrawText(5, LCD_H+1-statusLineHeight, statusLineMsg, BSS); drawFilledRect(0, LCD_H-statusLineHeight, LCD_W, FH, SOLID); } } diff --git a/radio/src/gui/gui.h b/radio/src/gui/gui.h index 6b2f02df6..cee4cdb63 100644 --- a/radio/src/gui/gui.h +++ b/radio/src/gui/gui.h @@ -37,10 +37,23 @@ #ifndef _GUI_H_ #define _GUI_H_ -#if defined(PCBTARANIS) +#if defined(CPUARM) +#include "gui_helpers.h" +#endif + +#if defined(PCBHORUS) + #include "Horus/gui.h" +#elif defined(PCBFLAMENCO) + #include "Flamenco/gui.h" +#elif defined(PCBTARANIS) #include "Taranis/gui.h" #else #include "9X/gui.h" #endif +#if defined(SIMU) +extern bool simuLcdRefresh; +extern display_t simuLcdBuf[DISPLAY_BUFFER_SIZE]; +#endif + #endif // _GUI_H_ diff --git a/radio/src/gui/gui_helpers.cpp b/radio/src/gui/gui_helpers.cpp new file mode 100644 index 000000000..8402c5520 --- /dev/null +++ b/radio/src/gui/gui_helpers.cpp @@ -0,0 +1,436 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../opentx.h" + +int circularIncDec(int current, int inc, int min, int max, IsValueAvailable isValueAvailable) +{ + do { + current += inc; + if (current < min) + current = max; + else if (current > max) + current = min; + if (!isValueAvailable || isValueAvailable(current)) + return current; + } while(1); + return 0; +} + +#if defined(VIRTUALINPUTS) +bool isInputAvailable(int input) +{ + for (int i=0; ichn == input) + return true; + } + return false; +} +#endif + +bool isChannelUsed(int channel) +{ + for (int i=0; isrcRaw == 0) return false; + if (md->destCh == channel) return true; + if (md->destCh > channel) return false; + } + return false; +} + +int getChannelsUsed() +{ + int result = 0; + int lastCh = -1; + for (int i=0; isrcRaw == 0) return result; + if (md->destCh != lastCh) { ++result; lastCh = md->destCh; } + } + return result; +} + +bool isSourceAvailable(int source) +{ +#if defined(VIRTUALINPUTS) + if (source>=MIXSRC_FIRST_INPUT && source<=MIXSRC_LAST_INPUT) { + return isInputAvailable(source - MIXSRC_FIRST_INPUT); + } +#endif + +#if defined(LUA_MODEL_SCRIPTS) + if (source>=MIXSRC_FIRST_LUA && source<=MIXSRC_LAST_LUA) { + div_t qr = div(source-MIXSRC_FIRST_LUA, MAX_SCRIPT_OUTPUTS); + return (qr.rem=MIXSRC_FIRST_LUA && source<=MIXSRC_LAST_LUA) + return false; +#endif + + if (source>=MIXSRC_FIRST_POT && source<=MIXSRC_LAST_POT) { + return IS_POT_AVAILABLE(POT1+source-MIXSRC_FIRST_POT); + } + + if (source>=MIXSRC_FIRST_SWITCH && source<=MIXSRC_LAST_SWITCH) { + return SWITCH_EXISTS(source-MIXSRC_FIRST_SWITCH); + } + +#if !defined(HELI) + if (source>=MIXSRC_CYC1 && source<=MIXSRC_CYC3) + return false; +#endif + + if (source>=MIXSRC_FIRST_CH && source<=MIXSRC_LAST_CH) { + return isChannelUsed(source-MIXSRC_FIRST_CH); + } + + if (source>=MIXSRC_FIRST_LOGICAL_SWITCH && source<=MIXSRC_LAST_LOGICAL_SWITCH) { + LogicalSwitchData * cs = lswAddress(source-MIXSRC_FIRST_LOGICAL_SWITCH); + return (cs->func != LS_FUNC_NONE); + } + +#if !defined(GVARS) + if (source>=MIXSRC_GVAR1 && source<=MIXSRC_LAST_GVAR) + return false; +#endif + + if (source>=MIXSRC_RESERVE1 && source<=MIXSRC_RESERVE5) + return false; + + if (source>=MIXSRC_FIRST_TELEM && source<=MIXSRC_LAST_TELEM) { + div_t qr = div(source-MIXSRC_FIRST_TELEM, 3); + if (qr.rem == 0) + return isTelemetryFieldAvailable(qr.quot); + else + return isTelemetryFieldComparisonAvailable(qr.quot); + } + + return true; +} + +bool isSourceAvailableInGlobalFunctions(int source) +{ + if (source>=MIXSRC_FIRST_TELEM && source<=MIXSRC_LAST_TELEM) { + return false; + } + return isSourceAvailable(source); +} + +bool isSourceAvailableInCustomSwitches(int source) +{ + bool result = isSourceAvailable(source); + +#if defined(FRSKY) + if (result && source>=MIXSRC_FIRST_TELEM && source<=MIXSRC_LAST_TELEM) { + div_t qr = div(source-MIXSRC_FIRST_TELEM, 3); + result = isTelemetryFieldComparisonAvailable(qr.quot); + } +#endif + + return result; +} + +bool isInputSourceAvailable(int source) +{ + if (source>=MIXSRC_FIRST_POT && source<=MIXSRC_LAST_POT) { + return IS_POT_AVAILABLE(POT1+source-MIXSRC_FIRST_POT); + } + + if (source>=MIXSRC_Rud && source<=MIXSRC_MAX) + return true; + + if (source>=MIXSRC_FIRST_TRIM && source<=MIXSRC_LAST_TRIM) + return true; + + if (source>=MIXSRC_FIRST_SWITCH && source<=MIXSRC_LAST_SWITCH) + return SWITCH_EXISTS(source-MIXSRC_FIRST_SWITCH); + + if (source>=MIXSRC_FIRST_CH && source<=MIXSRC_LAST_CH) + return true; + + if (source>=MIXSRC_FIRST_TRAINER && source<=MIXSRC_LAST_TRAINER) + return true; + + if (source>=MIXSRC_FIRST_TELEM && source<=MIXSRC_LAST_TELEM) { + div_t qr = div(source-MIXSRC_FIRST_TELEM, 3); + return isTelemetryFieldAvailable(qr.quot) && isTelemetryFieldComparisonAvailable(qr.quot); + } + + return false; +} + +enum SwitchContext +{ + LogicalSwitchesContext, + ModelCustomFunctionsContext, + GeneralCustomFunctionsContext, + TimersContext, + MixesContext +}; + +bool isLogicalSwitchAvailable(int index) +{ + LogicalSwitchData * lsw = lswAddress(index); + return (lsw->func != LS_FUNC_NONE); +} + +bool isSwitchAvailable(int swtch, SwitchContext context) +{ + bool negative = false; + + if (swtch < 0) { + negative = true; + if (swtch == -SWSRC_ON || swtch == -SWSRC_ONE) { + return false; + } + swtch = -swtch; + } + +#if defined(PCBSKY9X) + if (swtch >= SWSRC_FIRST_SWITCH && swtch <= SWSRC_LAST_SWITCH) { + negative = negative; + return true; + } +#else + if (swtch >= SWSRC_FIRST_SWITCH && swtch <= SWSRC_LAST_SWITCH) { + div_t swinfo = switchInfo(swtch); + if (!SWITCH_EXISTS(swinfo.quot)) { + return false; + } + if (!IS_3POS(swinfo.quot)) { + if (negative) { + return false; + } + if (IS_3POS_MIDDLE(swinfo.rem)) { + return false; + } + } + return true; + } +#endif + +#if NUM_XPOTS > 0 + if (swtch >= SWSRC_FIRST_MULTIPOS_SWITCH && swtch <= SWSRC_LAST_MULTIPOS_SWITCH) { + int index = (swtch - SWSRC_FIRST_MULTIPOS_SWITCH) / XPOTS_MULTIPOS_COUNT; + if (IS_POT_MULTIPOS(POT1+index)) { + StepsCalibData * calib = (StepsCalibData *) &g_eeGeneral.calib[POT1+index]; + return (calib->count >= ((swtch - SWSRC_FIRST_MULTIPOS_SWITCH) % XPOTS_MULTIPOS_COUNT)); + } + else { + return false; + } + } +#endif + + if (swtch >= SWSRC_FIRST_LOGICAL_SWITCH && swtch <= SWSRC_LAST_LOGICAL_SWITCH) { + if (context == GeneralCustomFunctionsContext) { + return false; + } + else if (context != LogicalSwitchesContext) { + return isLogicalSwitchAvailable(swtch - SWSRC_FIRST_LOGICAL_SWITCH); + } + } + + if (context != ModelCustomFunctionsContext && context != GeneralCustomFunctionsContext && (swtch == SWSRC_ON || swtch == SWSRC_ONE)) { + return false; + } + + if (swtch >= SWSRC_FIRST_FLIGHT_MODE && swtch <= SWSRC_LAST_FLIGHT_MODE) { + if (context == MixesContext || context == GeneralCustomFunctionsContext) { + return false; + } + else { + swtch -= SWSRC_FIRST_FLIGHT_MODE; + if (swtch == 0) { + return true; + } + FlightModeData * fm = flightModeAddress(swtch); + return (fm->swtch != SWSRC_NONE); + } + } + + if (swtch >= SWSRC_FIRST_SENSOR && swtch <= SWSRC_LAST_SENSOR) { + return isTelemetryFieldAvailable(swtch - SWSRC_FIRST_SENSOR); + } + + return true; +} + +bool isSwitchAvailableInLogicalSwitches(int swtch) +{ + return isSwitchAvailable(swtch, LogicalSwitchesContext); +} + +bool isSwitchAvailableInCustomFunctions(int swtch) +{ + if (g_menuStack[g_menuStackPtr] == menuModelCustomFunctions) + return isSwitchAvailable(swtch, ModelCustomFunctionsContext); + else + return isSwitchAvailable(swtch, GeneralCustomFunctionsContext); +} + +bool isSwitchAvailableInMixes(int swtch) +{ + return isSwitchAvailable(swtch, MixesContext); +} + +bool isSwitchAvailableInTimers(int swtch) +{ + if (swtch >= 0) { + if (swtch < TMRMODE_COUNT) + return true; + else + swtch -= TMRMODE_COUNT-1; + } + else { + if (swtch > -TMRMODE_COUNT) + return false; + else + swtch += TMRMODE_COUNT-1; + } + + return isSwitchAvailable(swtch, TimersContext); +} + +bool isThrottleSourceAvailable(int source) +{ + if (source >= THROTTLE_SOURCE_FIRST_POT && source < THROTTLE_SOURCE_FIRST_POT+NUM_POTS && !IS_POT_AVAILABLE(POT1+source-THROTTLE_SOURCE_FIRST_POT)) + return false; + else + return true; +} + +bool isLogicalSwitchFunctionAvailable(int function) +{ + return function != LS_FUNC_RANGE; +} + +bool isAssignableFunctionAvailable(int function) +{ +#if defined(OVERRIDE_CHANNEL_FUNCTION) || defined(GVARS) + bool modelFunctions = (g_menuStack[g_menuStackPtr] == menuModelCustomFunctions); +#endif + + switch (function) { + case FUNC_OVERRIDE_CHANNEL: +#if defined(OVERRIDE_CHANNEL_FUNCTION) + return modelFunctions; +#else + return false; +#endif + case FUNC_ADJUST_GVAR: +#if defined(GVARS) + return modelFunctions; +#else + return false; +#endif +#if !defined(HAPTIC) + case FUNC_HAPTIC: +#endif + case FUNC_RESERVE4: +#if !defined(DANGEROUS_MODULE_FUNCTIONS) + case FUNC_RANGECHECK: + case FUNC_BIND: +#endif +#if !defined(LUA) + case FUNC_PLAY_SCRIPT: +#endif + case FUNC_RESERVE5: + return false; + + default: + return true; + } +} + +bool isSourceAvailableInGlobalResetSpecialFunction(int index) +{ + if (index >= FUNC_RESET_PARAM_FIRST_TELEM) + return false; + else + return isSourceAvailableInResetSpecialFunction(index); +} + +bool isSourceAvailableInResetSpecialFunction(int index) +{ + if (index >= FUNC_RESET_PARAM_FIRST_TELEM) { + TelemetrySensor & telemetrySensor = g_model.telemetrySensors[index-FUNC_RESET_PARAM_FIRST_TELEM]; + return telemetrySensor.isAvailable(); + } +#if TIMERS < 3 + else if (index == FUNC_RESET_TIMER3) { + return false; + } +#endif +#if TIMERS < 2 + else if (index == FUNC_RESET_TIMER2) { + return false; + } +#endif + else { + return true; + } +} + +bool isModuleAvailable(int module) +{ + return true; +} + +bool modelHasNotes() +{ + char filename[sizeof(MODELS_PATH)+1+sizeof(g_model.header.name)+sizeof(TEXT_EXT)] = MODELS_PATH "/"; + char *buf = strcat_currentmodelname(&filename[sizeof(MODELS_PATH)]); + strcpy(buf, TEXT_EXT); + return isFileAvailable(filename); +} + +int getFirstAvailable(int min, int max, IsValueAvailable isValueAvailable) +{ + int retval = 0; + for (int i = min; i <= max; i++) { + if (isValueAvailable(i)) { + retval = i; + break; + } + } + return retval; +} diff --git a/radio/src/gui/gui_helpers.h b/radio/src/gui/gui_helpers.h new file mode 100644 index 000000000..abb1a3545 --- /dev/null +++ b/radio/src/gui/gui_helpers.h @@ -0,0 +1,66 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#ifndef _GUI_HELPERS_H_ +#define _GUI_HELPERS_H_ + +typedef bool (*IsValueAvailable)(int); + +int circularIncDec(int current, int inc, int min, int max, IsValueAvailable isValueAvailable); +int getFirstAvailable(int min, int max, IsValueAvailable isValueAvailable); + +#if defined(VIRTUALINPUTS) +bool isInputAvailable(int input); +#endif +bool isInputSourceAvailable(int source); +bool isThrottleSourceAvailable(int source); +bool isLogicalSwitchFunctionAvailable(int function); +bool isLogicalSwitchAvailable(int index); +bool isAssignableFunctionAvailable(int function); +bool isSourceAvailable(int source); +bool isSourceAvailableInGlobalFunctions(int source); +bool isSourceAvailableInCustomSwitches(int source); +bool isSourceAvailableInResetSpecialFunction(int index); +bool isSourceAvailableInGlobalResetSpecialFunction(int index); +bool isSwitchAvailableInLogicalSwitches(int swtch); +bool isSwitchAvailableInCustomFunctions(int swtch); +bool isSwitchAvailableInMixes(int swtch); +bool isSwitchAvailableInTimers(int swtch); +bool isModuleAvailable(int module); + +bool modelHasNotes(); + +#endif // _GUI_HELPERS_H_ diff --git a/radio/src/haptic.cpp b/radio/src/haptic.cpp index 2a8e661bd..3856f0d9a 100644 --- a/radio/src/haptic.cpp +++ b/radio/src/haptic.cpp @@ -54,7 +54,8 @@ void hapticQueue::heartbeat() #else if (buzzTimeLeft > 0) { buzzTimeLeft--; // time gets counted down -#if defined(PCBSKY9X) || (defined(PCBTARANIS) && defined(REVPLUS)) +#if defined(PCBSKY9X) || (defined(PCBTARANIS) && defined(REVPLUS)) || defined(PCBFLAMENCO) || defined(PCBHORUS) + // TODO define HAPTIC_PWM option hapticOn(HAPTIC_STRENGTH() * 20); #else if (hapticTick-- > 0) { diff --git a/radio/src/keys.cpp b/radio/src/keys.cpp index a6adb6e91..f4bfa790a 100644 --- a/radio/src/keys.cpp +++ b/radio/src/keys.cpp @@ -36,15 +36,15 @@ #include "opentx.h" -uint8_t s_evt; +evt_t s_evt; struct t_inactivity inactivity = {0}; #if defined(CPUARM) -uint8_t getEvent(bool trim) +evt_t getEvent(bool trim) { - uint8_t evt = s_evt; + evt_t evt = s_evt; int8_t k = EVT_KEY_MASK(s_evt) - TRM_BASE; - bool trim_evt = (k>=0 && k<8); + bool trim_evt = (k>=0 && k 0 || defined(ROTARY_ENCODER_NAVIGATION) BTN_REa, #endif @@ -72,7 +92,24 @@ enum EnumKeys { NUM_KEYS, SW_BASE=NUM_KEYS, -#if defined(PCBTARANIS) +#if defined(PCBFLAMENCO) + SW_SA0=SW_BASE, + SW_SA1, + SW_SA2, + SW_SB0, + SW_SB2, + SW_SC0, + SW_SC1, + SW_SC2, + SW_SC3, + SW_SC4, + SW_SC5, + SW_SE0, + SW_SE2, + SW_SF0, + SW_SF1, + SW_SF2, +#elif defined(PCBTARANIS) || defined(PCBHORUS) SW_SA0=SW_BASE, SW_SA1, SW_SA2, @@ -145,26 +182,40 @@ enum EnumKeys { #define EVT_KEY_MASK(e) ((e) & 0x1f) +#if defined(PCBHORUS) +#define _MSK_KEY_BREAK 0x0200 +#define _MSK_KEY_REPT 0x0400 +#define _MSK_KEY_FIRST 0x0600 +#define _MSK_KEY_LONG 0x0800 +#define _MSK_KEY_FLAGS 0x0e00 +#define EVT_ENTRY 0x1000 +#define EVT_ENTRY_UP 0x2000 +#else #define _MSK_KEY_BREAK 0x20 #define _MSK_KEY_REPT 0x40 #define _MSK_KEY_FIRST 0x60 #define _MSK_KEY_LONG 0x80 +#define _MSK_KEY_FLAGS 0xe0 +#define EVT_ENTRY 0xbf +#define EVT_ENTRY_UP 0xbe +#endif #define EVT_KEY_BREAK(key) ((key)|_MSK_KEY_BREAK) #define EVT_KEY_FIRST(key) ((key)|_MSK_KEY_FIRST) #define EVT_KEY_REPT(key) ((key)|_MSK_KEY_REPT) #define EVT_KEY_LONG(key) ((key)|_MSK_KEY_LONG) -#define IS_KEY_BREAK(evt) (((evt)&0xe0) == _MSK_KEY_BREAK) -#define IS_KEY_FIRST(evt) (((evt)&0xe0) == _MSK_KEY_FIRST) -#define IS_KEY_LONG(evt) (((evt)&0xe0) == _MSK_KEY_LONG) -#define IS_KEY_REPT(evt) (((evt)&0xe0) == _MSK_KEY_REPT) +#define IS_KEY_BREAK(evt) (((evt) & _MSK_KEY_FLAGS) == _MSK_KEY_BREAK) +#define IS_KEY_FIRST(evt) (((evt) & _MSK_KEY_FLAGS) == _MSK_KEY_FIRST) +#define IS_KEY_LONG(evt) (((evt) & _MSK_KEY_FLAGS) == _MSK_KEY_LONG) +#define IS_KEY_REPT(evt) (((evt) & _MSK_KEY_FLAGS) == _MSK_KEY_REPT) -#define EVT_ENTRY 0xbf -#define EVT_ENTRY_UP 0xbe -#define EVT_MENU_UP 0xbd - -#if defined(PCBTARANIS) +#if defined(PCBHORUS) + #define EVT_ROTARY_BREAK EVT_KEY_BREAK(KEY_ENTER) + #define EVT_ROTARY_LONG EVT_KEY_LONG(KEY_ENTER) + #define EVT_ROTARY_LEFT 0xDF00 + #define EVT_ROTARY_RIGHT 0xDE00 +#elif defined(PCBTARANIS) || defined(PCBFLAMENCO) #define EVT_ROTARY_BREAK EVT_KEY_BREAK(KEY_ENTER) #define EVT_ROTARY_LONG EVT_KEY_LONG(KEY_ENTER) #else @@ -174,47 +225,8 @@ enum EnumKeys { #define EVT_ROTARY_RIGHT 0xde #endif -#if defined(PCBTARANIS) - #define IS_ROTARY_LEFT(evt) (evt==EVT_KEY_FIRST(KEY_MINUS) || evt==EVT_KEY_REPT(KEY_MINUS)) - #define IS_ROTARY_RIGHT(evt) (evt==EVT_KEY_FIRST(KEY_PLUS) || evt==EVT_KEY_REPT(KEY_PLUS)) - #define IS_ROTARY_UP(evt) (evt==EVT_KEY_FIRST(KEY_PLUS) || evt==EVT_KEY_REPT(KEY_PLUS)) - #define IS_ROTARY_DOWN(evt) (evt==EVT_KEY_FIRST(KEY_MINUS) || evt==EVT_KEY_REPT(KEY_MINUS)) - #define IS_ROTARY_BREAK(evt) (evt==EVT_KEY_BREAK(KEY_ENTER)) - #define IS_ROTARY_LONG(evt) (evt==EVT_KEY_LONG(KEY_ENTER)) - #define IS_ROTARY_EVENT(evt) (0) - #define CASE_EVT_ROTARY_BREAK /*case EVT_KEY_BREAK(KEY_ENTER):*/ - #define CASE_EVT_ROTARY_LONG /*case EVT_KEY_LONG(KEY_ENTER):*/ - #if defined(REV9E) && !defined(SIMU) - #define CASE_EVT_ROTARY_LEFT case EVT_KEY_FIRST(KEY_MOVE_UP): case EVT_KEY_REPT(KEY_MOVE_UP): - #define CASE_EVT_ROTARY_RIGHT case EVT_KEY_FIRST(KEY_MOVE_DOWN): case EVT_KEY_REPT(KEY_MOVE_DOWN): - #else - #define CASE_EVT_ROTARY_LEFT case EVT_KEY_FIRST(KEY_MOVE_DOWN): case EVT_KEY_REPT(KEY_MOVE_DOWN): - #define CASE_EVT_ROTARY_RIGHT case EVT_KEY_FIRST(KEY_MOVE_UP): case EVT_KEY_REPT(KEY_MOVE_UP): - #endif -#elif defined(ROTARY_ENCODER_NAVIGATION) - #define IS_ROTARY_LEFT(evt) (evt == EVT_ROTARY_LEFT) - #define IS_ROTARY_RIGHT(evt) (evt == EVT_ROTARY_RIGHT) - #define IS_ROTARY_UP(evt) IS_ROTARY_LEFT(evt) - #define IS_ROTARY_DOWN(evt) IS_ROTARY_RIGHT(evt) - #define IS_ROTARY_BREAK(evt) (evt == EVT_ROTARY_BREAK) - #define IS_ROTARY_LONG(evt) (evt == EVT_ROTARY_LONG) - #define IS_ROTARY_EVENT(evt) (EVT_KEY_MASK(evt) >= 0x0e) - #define CASE_EVT_ROTARY_BREAK case EVT_ROTARY_BREAK: - #define CASE_EVT_ROTARY_LONG case EVT_ROTARY_LONG: - #define CASE_EVT_ROTARY_LEFT case EVT_ROTARY_LEFT: - #define CASE_EVT_ROTARY_RIGHT case EVT_ROTARY_RIGHT: -#else - #define IS_ROTARY_LEFT(evt) (0) - #define IS_ROTARY_RIGHT(evt) (0) - #define IS_ROTARY_UP(evt) (0) - #define IS_ROTARY_DOWN(evt) (0) - #define IS_ROTARY_BREAK(evt) (0) - #define IS_ROTARY_LONG(evt) (0) - #define IS_ROTARY_EVENT(evt) (0) - #define CASE_EVT_ROTARY_BREAK - #define CASE_EVT_ROTARY_LONG - #define CASE_EVT_ROTARY_LEFT - #define CASE_EVT_ROTARY_RIGHT +#if defined(COLORLCD) + #define EVT_REFRESH 0xDD00 #endif class Key @@ -247,7 +259,13 @@ class Key extern Key keys[NUM_KEYS]; -extern uint8_t s_evt; +#if defined(PCBHORUS) +typedef uint16_t evt_t; +#else +typedef uint8_t evt_t; +#endif + +extern evt_t s_evt; #define putEvent(evt) s_evt = evt @@ -256,12 +274,12 @@ void killEvents(uint8_t enuk); #if defined(CPUARM) bool clearKeyEvents(); - uint8_t getEvent(bool trim=false); + evt_t getEvent(bool trim=false); #else void clearKeyEvents(); - uint8_t getEvent(); + evt_t getEvent(); #endif uint8_t keyDown(); -#endif +#endif // _KEYS_H_ diff --git a/radio/src/loadboot.cpp b/radio/src/loadboot.cpp index affa37fd6..7acffce10 100644 --- a/radio/src/loadboot.cpp +++ b/radio/src/loadboot.cpp @@ -52,7 +52,7 @@ #if defined(PCBSKY9X) #include "AT91SAM3S4.h" #else - #include "board_taranis.h" + #include "targets/Taranis/board_taranis.h" #endif #if defined(PCBTARANIS) diff --git a/radio/src/logs.cpp b/radio/src/logs.cpp index 6d0ee2aac..9971c4132 100644 --- a/radio/src/logs.cpp +++ b/radio/src/logs.cpp @@ -41,7 +41,7 @@ FIL g_oLogFile = {0}; const pm_char * g_logError = NULL; uint8_t logDelay; -#if defined(PCBTARANIS) +#if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS) #define get2PosState(sw) (switchState(SW_ ## sw ## 0) ? -1 : 1) #else #define get2PosState(sw) (switchState(SW_ ## sw) ? -1 : 1) @@ -49,11 +49,10 @@ uint8_t logDelay; #define get3PosState(sw) (switchState(SW_ ## sw ## 0) ? -1 : (switchState(SW_ ## sw ## 2) ? 1 : 0)) -const pm_char *openLogs() +const pm_char * openLogs() { // Determine and set log file filename FRESULT result; - DIR folder; char filename[34]; // /LOGS/modelnamexxx-2013-01-01.log if (!sdMounted()) @@ -64,12 +63,9 @@ const pm_char *openLogs() // check and create folder here strcpy_P(filename, STR_LOGS_PATH); - result = f_opendir(&folder, filename); - if (result != FR_OK) { - if (result == FR_NO_PATH) - result = f_mkdir(filename); - if (result != FR_OK) - return SDCARD_ERROR(result); + const char * error = sdCheckAndCreateDirectory(filename); + if (error) { + return error; } filename[sizeof(LOGS_PATH)-1] = '/'; @@ -330,7 +326,14 @@ void writeLogs() f_printf(&g_oLogFile, "%d,", calibratedStick[i]); } -#if defined(PCBTARANIS) +#if defined(PCBFLAMENCO) + int result = f_printf(&g_oLogFile, "%d,%d,%d,%d\n", + get3PosState(SA), + get3PosState(SB), + // get3PosState(SC), + get2PosState(SE), + get3PosState(SF)); +#elif defined(PCBTARANIS) || defined(PCBHORUS) int result = f_printf(&g_oLogFile, "%d,%d,%d,%d,%d,%d,%d,%d\n", get3PosState(SA), get3PosState(SB), diff --git a/radio/src/lua/.gitignore b/radio/src/lua/.gitignore new file mode 100644 index 000000000..38bbdd34f --- /dev/null +++ b/radio/src/lua/.gitignore @@ -0,0 +1 @@ +/lua_exports_*.inc diff --git a/radio/src/lua/api_general.cpp b/radio/src/lua/api_general.cpp index 032962156..19ca96d79 100644 --- a/radio/src/lua/api_general.cpp +++ b/radio/src/lua/api_general.cpp @@ -40,7 +40,13 @@ #include "stamp-opentx.h" #include "lua/lua_api.h" -#include "lua/lua_exports.inc" // this line must be after lua headers +#if defined(PCBHORUS) +#include "lua/lua_exports_horus.inc" // this line must be after lua headers +#elif defined(PCBFLAMENCO) +#include "lua/lua_exports_flamenco.inc" +#elif defined(PCBTARANIS) +#include "lua/lua_exports_taranis.inc" +#endif #if defined(PCBTARANIS) && defined(REV9E) #define RADIO "taranisx9e" diff --git a/radio/src/lua/api_lcd.cpp b/radio/src/lua/api_lcd.cpp index 450ca4604..51f9b6d06 100644 --- a/radio/src/lua/api_lcd.cpp +++ b/radio/src/lua/api_lcd.cpp @@ -60,7 +60,7 @@ Erases all contents of LCD. */ static int luaLcdClear(lua_State *L) { - if (luaLcdAllowed) lcd_clear(); + if (luaLcdAllowed) lcdClear(); return 0; } @@ -109,7 +109,7 @@ static int luaLcdDrawLine(lua_State *L) int y2 = luaL_checkinteger(L, 4); int pat = luaL_checkinteger(L, 5); int flags = luaL_checkinteger(L, 6); - lcd_line(x1, y1, x2, y2, pat, flags); + lcdDrawLine(x1, y1, x2, y2, pat, flags); return 0; } @@ -126,7 +126,7 @@ static int luaLcdDrawText(lua_State *L) int y = luaL_checkinteger(L, 2); const char * s = luaL_checkstring(L, 3); unsigned int att = luaL_optunsigned(L, 4, 0); - lcd_putsAtt(x, y, s, att); + lcdDrawText(x, y, s, att); return 0; } @@ -137,7 +137,11 @@ static int luaLcdDrawTimer(lua_State *L) int y = luaL_checkinteger(L, 2); int seconds = luaL_checkinteger(L, 3); unsigned int att = luaL_optunsigned(L, 4, 0); +#if defined(PCBFLAMENCO) + putsTimer(x, y, seconds, att|LEFT); +#else putsTimer(x, y, seconds, att|LEFT, att); +#endif return 0; } @@ -204,6 +208,7 @@ static int luaLcdDrawSource(lua_State *L) return 0; } +#if !defined(COLORLCD) static int luaLcdDrawPixmap(lua_State *L) { if (!luaLcdAllowed) return 0; @@ -217,6 +222,7 @@ static int luaLcdDrawPixmap(lua_State *L) } return 0; } +#endif static int luaLcdDrawRectangle(lua_State *L) { @@ -226,7 +232,7 @@ static int luaLcdDrawRectangle(lua_State *L) int w = luaL_checkinteger(L, 3); int h = luaL_checkinteger(L, 4); unsigned int flags = luaL_optunsigned(L, 5, 0); - lcd_rect(x, y, w, h, 0xff, flags); + lcdDrawRect(x, y, w, h, 0xff, flags); return 0; } @@ -252,7 +258,7 @@ static int luaLcdDrawGauge(lua_State *L) int num = luaL_checkinteger(L, 5); int den = luaL_checkinteger(L, 6); // int flags = luaL_checkinteger(L, 7); - lcd_rect(x, y, w, h); + lcdDrawRect(x, y, w, h); uint8_t len = limit((uint8_t)1, uint8_t(w*num/den), uint8_t(w)); for (int i=1; iduration = luaL_checkinteger(L, -1); } } - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } return 0; @@ -679,7 +679,7 @@ static int luaModelSetCustomFunction(lua_State *L) CFN_ACTIVE(cfn) = luaL_checkinteger(L, -1); } } - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } return 0; @@ -764,7 +764,7 @@ static int luaModelSetOutput(lua_State *L) limit->curve = luaL_checkinteger(L, -1) + 1; } } - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } return 0; @@ -827,7 +827,7 @@ static int luaModelSetGlobalVariable(lua_State *L) int value = luaL_checkinteger(L, 3); if (phase < MAX_FLIGHT_MODES && idx < MAX_GVARS && value >= -GVAR_MAX && value <= GVAR_MAX) { g_model.flightModeData[phase].gvars[idx] = value; - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } return 0; } diff --git a/radio/src/lua/interface.cpp b/radio/src/lua/interface.cpp index 070f51401..99075a7d4 100644 --- a/radio/src/lua/interface.cpp +++ b/radio/src/lua/interface.cpp @@ -48,7 +48,7 @@ #define PERMANENT_SCRIPTS_MAX_INSTRUCTIONS (10000/100) #define MANUAL_SCRIPTS_MAX_INSTRUCTIONS (20000/100) #define SET_LUA_INSTRUCTIONS_COUNT(x) (instructionsPercent=0, lua_sethook(L, hook, LUA_MASKCOUNT, x)) -#define LUA_WARNING_INFO_LEN 64 +#define LUA_WARNING_INFO_LEN 64 lua_State *L = NULL; uint8_t luaState = 0; @@ -59,7 +59,7 @@ ScriptInternalData standaloneScript = { SCRIPT_NOFILE, 0 }; uint16_t maxLuaInterval = 0; uint16_t maxLuaDuration = 0; bool luaLcdAllowed; -static int instructionsPercent = 0; +int instructionsPercent = 0; char lua_warning_info[LUA_WARNING_INFO_LEN+1]; struct our_longjmp * global_lj = 0; @@ -464,15 +464,17 @@ void luaLoadPermanentScripts() void displayLuaError(const char * title) { +#if !defined(COLORLCD) displayBox(title); +#endif if (lua_warning_info[0]) { char * split = strstr(lua_warning_info, ": "); if (split) { - lcd_putsnAtt(WARNING_LINE_X, WARNING_LINE_Y+FH+3, lua_warning_info, split-lua_warning_info, SMLSIZE); - lcd_putsnAtt(WARNING_LINE_X, WARNING_LINE_Y+2*FH+2, split+2, lua_warning_info+LUA_WARNING_INFO_LEN-split, SMLSIZE); + lcdDrawTextWithLen(WARNING_LINE_X, WARNING_LINE_Y+FH+3, lua_warning_info, split-lua_warning_info, SMLSIZE); + lcdDrawTextWithLen(WARNING_LINE_X, WARNING_LINE_Y+2*FH+2, split+2, lua_warning_info+LUA_WARNING_INFO_LEN-split, SMLSIZE); } else { - lcd_putsnAtt(WARNING_LINE_X, WARNING_LINE_Y+FH+3, lua_warning_info, 40, SMLSIZE); + lcdDrawTextWithLen(WARNING_LINE_X, WARNING_LINE_Y+FH+3, lua_warning_info, 40, SMLSIZE); } } } @@ -581,12 +583,12 @@ void luaDoOneRunStandalone(uint8_t evt) return; } else if (luaDisplayStatistics) { - lcd_hline(0, 7*FH-1, lcdLastPos+FW, ERASE); + lcd_hline(0, 7*FH-1, lcdLastPos+6, ERASE); lcd_puts(0, 7*FH, "GV Use: "); lcd_outdezAtt(lcdLastPos, 7*FH, luaGetMemUsed(), LEFT); lcd_putc(lcdLastPos, 7*FH, 'b'); - lcd_hline(0, 7*FH-2, lcdLastPos+FW, FORCE); - lcd_vlineStip(lcdLastPos+FW, 7*FH-2, FH+2, SOLID, FORCE); + lcd_hline(0, 7*FH-2, lcdLastPos+6, FORCE); + lcdDrawVerticalLine(lcdLastPos+6, 7*FH-2, FH+2, SOLID, FORCE); } } } @@ -657,8 +659,12 @@ bool luaDoOneRunPermanentScript(uint8_t evt, int i, uint32_t scriptType) TelemetryScriptData & script = g_model.frsky.screens[sid.reference-SCRIPT_TELEMETRY_FIRST].script; filename = script.file; #endif - if ((scriptType & RUN_TELEM_FG_SCRIPT) && + if ((scriptType & RUN_TELEM_FG_SCRIPT) && +#if defined(PCBFLAMENCO) + (g_menuStack[0]==menuMainView && sid.reference==SCRIPT_TELEMETRY_FIRST+g_eeGeneral.view-VIEW_TELEM1)) { +#else (g_menuStack[0]==menuTelemetryFrsky && sid.reference==SCRIPT_TELEMETRY_FIRST+s_frsky_view)) { +#endif lua_rawgeti(L, LUA_REGISTRYINDEX, sid.run); lua_pushinteger(L, evt); inputsCount = 1; diff --git a/radio/src/main_arm.cpp b/radio/src/main_arm.cpp index bed1ce257..fe9684d41 100644 --- a/radio/src/main_arm.cpp +++ b/radio/src/main_arm.cpp @@ -42,7 +42,7 @@ uint8_t requestScreenshot = false; void handleUsbConnection() { -#if defined(PCBTARANIS) && !defined(SIMU) +#if defined(CPUSTM32) && !defined(SIMU) static bool usbStarted = false; if (!usbStarted && usbPlugged()) { @@ -78,7 +78,7 @@ void handleUsbConnection() } #endif -#endif //#if defined(PCBTARANIS) && !defined(SIMU) +#endif // defined(CPUSTM32) && !defined(SIMU) } void checkSpeakerVolume() @@ -89,46 +89,28 @@ void checkSpeakerVolume() } } +#if defined(EEPROM) void checkEeprom() { if (!usbPlugged()) { if (eepromIsWriting()) eepromWriteProcess(); else if (TIME_TO_WRITE()) - eeCheck(false); + storageCheck(false); } } - -void perMain() +#else +void checkEeprom() { -#if defined(PCBSKY9X) && !defined(REVA) - calcConsumption(); -#endif - checkSpeakerVolume(); - checkEeprom(); - sdMountPoll(); - writeLogs(); - handleUsbConnection(); - checkTrainerSettings(); - checkBattery(); - - uint8_t evt = getEvent(false); - if (evt && (g_eeGeneral.backlightMode & e_backlight_mode_keys)) backlightOn(); // on keypress turn the light on - checkBacklight(); -#if defined(NAVIGATION_STICKS) - uint8_t sticks_evt = getSticksNavigationEvent(); - if (sticks_evt) evt = sticks_evt; + if (TIME_TO_WRITE()) + storageCheck(false); +} #endif -#if defined(USB_MASS_STORAGE) - if (usbPlugged()) { - // disable access to menus - lcd_clear(); - menuMainView(0); - lcdRefresh(); - return; - } -#endif +#if defined(GUI) && defined(COLORLCD) +void guiMain(evt_t evt) +{ + bool refreshNeeded = false; #if defined(LUA) uint32_t t0 = get_tmr10ms(); @@ -153,28 +135,122 @@ void perMain() // run Lua scripts that use LCD bool standaloneScriptWasRun = luaTask(evt, RUN_STNDAL_SCRIPT, true); - bool refreshScreen = true; if (!standaloneScriptWasRun) { - refreshScreen = !luaTask(evt, RUN_TELEM_FG_SCRIPT, true); + luaTask(evt, RUN_TELEM_FG_SCRIPT, true); + refreshNeeded = true; } t0 = get_tmr10ms() - t0; if (t0 > maxLuaDuration) { maxLuaDuration = t0; } - - if (!standaloneScriptWasRun) #else lcdRefreshWait(); // WARNING: make sure no code above this line does any change to the LCD display buffer! - const bool refreshScreen = true; + const bool standaloneScriptWasRun = false; #endif - { - // normal GUI from menus - const char *warn = s_warning; - uint8_t menu = s_menu_count; - if (refreshScreen) { - lcd_clear(); + + if (!standaloneScriptWasRun) { + while (1) { + // normal GUI from menus + const char * warn = s_warning; + uint8_t menu = s_menu_count; + + static bool popupDisplayed = false; + if (warn || menu) { + if (popupDisplayed == false) { + g_menuStack[g_menuStackPtr](EVT_REFRESH); + lcdDrawBlackOverlay(); + TIME_MEASURE_START(storebackup); + lcdStoreBackupBuffer(); + TIME_MEASURE_STOP(storebackup); + } + if (popupDisplayed == false || evt) { + lcdRestoreBackupBuffer(); + if (warn) DISPLAY_WARNING(evt); + if (menu) { + const char * result = displayMenu(evt); + if (result) { + menuHandler(result); + evt = EVT_REFRESH; + continue; + } + } + refreshNeeded = true; + popupDisplayed = true; + } + } + else { + popupDisplayed = false; + refreshNeeded = g_menuStack[g_menuStackPtr](evt); + } + + if (menuEvent == EVT_ENTRY) { + m_posVert = -1; + m_posHorz = 0; + evt = menuEvent; + menuEvent = 0; + } + else if (menuEvent == EVT_ENTRY_UP) { + m_posVert = g_menuPos[g_menuStackPtr]; + m_posHorz = 0; + evt = menuEvent; + menuEvent = 0; + } + else { + break; + } } + } + + if (refreshNeeded) { + lcdRefresh(); + } +} +#elif defined(GUI) +void guiMain(evt_t evt) +{ +#if defined(LUA) + uint32_t t0 = get_tmr10ms(); + static uint32_t lastLuaTime = 0; + uint16_t interval = (lastLuaTime == 0 ? 0 : (t0 - lastLuaTime)); + lastLuaTime = t0; + if (interval > maxLuaInterval) { + maxLuaInterval = interval; + } + + // run Lua scripts that don't use LCD (to use CPU time while LCD DMA is running) + luaTask(0, RUN_MIX_SCRIPT | RUN_FUNC_SCRIPT | RUN_TELEM_BG_SCRIPT, false); + + // wait for LCD DMA to finish before continuing, because code from this point + // is allowed to change the contents of LCD buffer + // + // WARNING: make sure no code above this line does any change to the LCD display buffer! + // + lcdRefreshWait(); + + // draw LCD from menus or from Lua script + // run Lua scripts that use LCD + + bool standaloneScriptWasRun = luaTask(evt, RUN_STNDAL_SCRIPT, true); + if (!standaloneScriptWasRun) { + luaTask(evt, RUN_TELEM_FG_SCRIPT, true); + } + + t0 = get_tmr10ms() - t0; + if (t0 > maxLuaDuration) { + maxLuaDuration = t0; + } +#else + lcdRefreshWait(); // WARNING: make sure no code above this line does any change to the LCD display buffer! + const bool standaloneScriptWasRun = false; +#endif + + if (!standaloneScriptWasRun) { + lcdClear(); + + // normal GUI from menus + const char * warn = s_warning; + uint8_t menu = s_menu_count; if (menuEvent) { m_posVert = menuEvent == EVT_ENTRY_UP ? g_menuPos[g_menuStackPtr] : 0; m_posHorz = 0; @@ -182,32 +258,56 @@ void perMain() menuEvent = 0; AUDIO_MENUS(); } + g_menuStack[g_menuStackPtr]((warn || menu) ? 0 : evt); if (warn) DISPLAY_WARNING(evt); if (menu) { const char * result = displayMenu(evt); if (result) { menuHandler(result); - putEvent(EVT_MENU_UP); } } + drawStatusLine(); } lcdRefresh(); - -#if defined(REV9E) && !defined(SIMU) - topLcdRefreshStart(); - setTopFirstTimer(getValue(MIXSRC_FIRST_TIMER+g_model.topLcdTimer)); - setTopSecondTimer(g_eeGeneral.globalTimer + sessionTimer); - setTopRssi(TELEMETRY_RSSI()); - setTopBatteryValue(g_vbat100mV); - setTopBatteryState(GET_TXBATT_BARS(), IS_TXBATT_WARNING()); - topLcdRefreshEnd(); +} #endif -#if defined(REV9E) && !defined(SIMU) - bluetoothWakeup(); +void perMain() +{ +#if defined(PCBSKY9X) && !defined(REVA) + calcConsumption(); +#endif + checkSpeakerVolume(); + checkEeprom(); + sdMountPoll(); + writeLogs(); + handleUsbConnection(); + checkTrainerSettings(); + checkBattery(); + + evt_t evt = getEvent(false); + if (evt && (g_eeGeneral.backlightMode & e_backlight_mode_keys)) backlightOn(); // on keypress turn the light on + doLoopCommonActions(); +#if defined(NAVIGATION_STICKS) + uint8_t sticks_evt = getSticksNavigationEvent(); + if (sticks_evt) evt = sticks_evt; +#endif + +#if defined(USB_MASS_STORAGE) + if (usbPlugged()) { + // disable access to menus + lcdClear(); + menuMainView(0); + lcdRefresh(); + return; + } +#endif + +#if defined(GUI) + guiMain(evt); #endif #if defined(PCBTARANIS) @@ -217,4 +317,18 @@ void perMain() } #endif +#if defined(PCBTARANIS) && defined(REV9E) && !defined(SIMU) + toplcdRefreshStart(); + setTopFirstTimer(getValue(MIXSRC_FIRST_TIMER+g_model.toplcdTimer)); + setTopSecondTimer(g_eeGeneral.globalTimer + sessionTimer); + setTopRssi(TELEMETRY_RSSI()); + setTopBatteryValue(g_vbat100mV); + setTopBatteryState(GET_TXBATT_BARS(), IS_TXBATT_WARNING()); + toplcdRefreshEnd(); +#endif + +#if defined(PCBTARANIS) && defined(REV9E) && !defined(SIMU) + bluetoothWakeup(); +#endif + } diff --git a/radio/src/main_avr.cpp b/radio/src/main_avr.cpp index 0423d5ea4..703586f81 100644 --- a/radio/src/main_avr.cpp +++ b/radio/src/main_avr.cpp @@ -105,7 +105,7 @@ void perMain() if (theFile.isWriting()) theFile.nextWriteStep(); else if (TIME_TO_WRITE()) - eeCheck(false); + storageCheck(false); } #if defined(SDCARD) @@ -113,11 +113,11 @@ void perMain() writeLogs(); #endif - uint8_t evt = getEvent(); + evt_t evt = getEvent(); evt = checkTrim(evt); if (evt && (g_eeGeneral.backlightMode & e_backlight_mode_keys)) backlightOn(); // on keypress turn the light on - checkBacklight(); + doLoopCommonActions(); #if defined(FRSKY) || defined(MAVLINK) telemetryWakeup(); @@ -132,37 +132,36 @@ void perMain() const char *warn = s_warning; uint8_t menu = s_menu_count; - if(IS_LCD_REFRESH_ALLOWED()){//No need to redraw until lcdRefresh_ST7920(0) below completely refreshes the display. - lcd_clear(); - if (menuEvent) { - m_posVert = menuEvent == EVT_ENTRY_UP ? g_menuPos[g_menuStackPtr] : 0; - m_posHorz = 0; - evt = menuEvent; - menuEvent = 0; - AUDIO_MENUS(); - } - g_menuStack[g_menuStackPtr]((warn || menu) ? 0 : evt); + if (IS_LCD_REFRESH_ALLOWED()) { // No need to redraw until lcdRefresh_ST7920(0) below completely refreshes the display. + lcdClear(); + if (menuEvent) { + m_posVert = menuEvent == EVT_ENTRY_UP ? g_menuPos[g_menuStackPtr] : 0; + m_posHorz = 0; + evt = menuEvent; + menuEvent = 0; + AUDIO_MENUS(); + } + g_menuStack[g_menuStackPtr]((warn || menu) ? 0 : evt); - - if (warn) DISPLAY_WARNING(evt); + if (warn) DISPLAY_WARNING(evt); #if defined(NAVIGATION_MENUS) - if (menu) { - const char * result = displayMenu(evt); - if (result) { - menuHandler(result); - putEvent(EVT_MENU_UP); - } + if (menu) { + const char * result = displayMenu(evt); + if (result) { + menuHandler(result); } + } #endif - drawStatusLine(); + drawStatusLine(); } + #if defined(LCD_ST7920) - lcdstate=lcdRefresh_ST7920(0); + lcdstate = lcdRefresh_ST7920(0); #else lcdRefresh(); #endif -#endif +#endif // defined(GUI) if (SLAVE_MODE()) { JACK_PPM_OUT(); diff --git a/radio/src/mixer.cpp b/radio/src/mixer.cpp index ea2cb74f4..29972eca6 100644 --- a/radio/src/mixer.cpp +++ b/radio/src/mixer.cpp @@ -282,7 +282,14 @@ getvalue_t getValue(mixsrc_t i) else if (i<=MIXSRC_TrimAil) return calc1000toRESX((int16_t)8 * getTrimValue(mixerCurrentFlightMode, i-MIXSRC_TrimRud)); -#if defined(PCBTARANIS) +#if defined(PCBFLAMENCO) + else if (i==MIXSRC_SA) return (switchState(SW_SA0) ? -1024 : (switchState(SW_SA1) ? 0 : 1024)); + else if (i==MIXSRC_SB) return (switchState(SW_SB0) ? -1024 : 1024); + else if (i==MIXSRC_SC) return (switchState(SW_SC0) ? -1024 : (switchState(SW_SC1) ? 0 : 1024)); + // else if (i==MIXSRC_SD) return (switchState(SW_SD0) ? -1024 : 1024); + else if (i==MIXSRC_SE) return (switchState(SW_SE0) ? -1024 : 1024); + else if (i==MIXSRC_SF) return (switchState(SW_SF0) ? -1024 : (switchState(SW_SF1) ? 0 : 1024)); +#elif defined(PCBTARANIS) || defined(PCBHORUS) else if ((i >= MIXSRC_FIRST_SWITCH) && (i <= MIXSRC_LAST_SWITCH)) { mixsrc_t sw = i-MIXSRC_FIRST_SWITCH; if (SWITCH_EXISTS(sw)) { diff --git a/radio/src/myeeprom.h b/radio/src/myeeprom.h index 34a53cdd3..93c8bb722 100644 --- a/radio/src/myeeprom.h +++ b/radio/src/myeeprom.h @@ -47,7 +47,7 @@ #define LUA_EXPORT(...) #define LUA_EXPORT_MULTIPLE(...) #define LUA_EXPORT_EXTRA(...) -#endif +#endif #define WARN_THR_BIT 0x01 #define WARN_BEP_BIT 0x80 @@ -61,10 +61,7 @@ #define WARN_MEM (!(g_eeGeneral.warnOpts & WARN_MEM_BIT)) #define BEEP_VAL ( (g_eeGeneral.warnOpts & WARN_BVAL_BIT) >>3 ) -#if defined(PCBTARANIS) - #define EEPROM_VER 218 - #define FIRST_CONV_EEPROM_VER 216 -#elif defined(PCBSKY9X) +#if defined(CPUARM) #define EEPROM_VER 218 #define FIRST_CONV_EEPROM_VER 216 #elif defined(CPUM2560) || defined(CPUM2561) @@ -110,7 +107,35 @@ #define NUM_STICKS 4 -#if defined(PCBTARANIS) +#if defined(PCBHORUS) + #define MAX_MODELS 60 + #define NUM_CHNOUT 32 // number of real output channels CH1-CH32 + #define MAX_FLIGHT_MODES 9 + #define MAX_MIXERS 64 + #define MAX_EXPOS 64 + #define NUM_LOGICAL_SWITCH 32 // number of custom switches + #define NUM_CFN 64 // number of functions assigned to switches + #define MAX_SCRIPTS 7 + #define MAX_INPUTS 32 + #define NUM_TRAINER 16 + #define NUM_POTS 7 + #define NUM_XPOTS 3 + #define MAX_SENSORS 32 +#elif defined(PCBFLAMENCO) + #define MAX_MODELS 60 + #define NUM_CHNOUT 32 // number of real output channels CH1-CH32 + #define MAX_FLIGHT_MODES 9 + #define MAX_MIXERS 64 + #define MAX_EXPOS 64 + #define NUM_LOGICAL_SWITCH 32 // number of custom switches + #define NUM_CFN 64 // number of functions assigned to switches + #define MAX_SCRIPTS 7 + #define MAX_INPUTS 32 + #define NUM_TRAINER 16 + #define NUM_POTS 3 + #define NUM_XPOTS 0 + #define MAX_SENSORS 32 +#elif defined(PCBTARANIS) #define MAX_MODELS 60 #define NUM_CHNOUT 32 // number of real output channels CH1-CH32 #define MAX_FLIGHT_MODES 9 @@ -210,7 +235,28 @@ struct CurveInfo { extern CurveInfo curveInfo(uint8_t idx); #endif -#if defined(PCBTARANIS) +#if defined(PCBHORUS) + #define LEN_MODEL_NAME 15 + #define LEN_TIMER_NAME 8 + #define LEN_FLIGHT_MODE_NAME 10 + #define LEN_BITMAP_NAME 10 + #define LEN_EXPOMIX_NAME 6 + #define LEN_CHANNEL_NAME 6 + #define LEN_INPUT_NAME 4 + #define MAX_CURVES 32 + #define NUM_POINTS 512 + #define CURVDATA CurveInfo +#elif defined(PCBFLAMENCO) + #define LEN_MODEL_NAME 12 + #define LEN_TIMER_NAME 8 + #define LEN_FLIGHT_MODE_NAME 10 + #define LEN_EXPOMIX_NAME 6 + #define LEN_CHANNEL_NAME 6 + #define LEN_INPUT_NAME 4 + #define MAX_CURVES 32 + #define NUM_POINTS 512 + #define CURVDATA CurveInfo +#elif defined(PCBTARANIS) #define LEN_MODEL_NAME 12 #define LEN_TIMER_NAME 8 #define LEN_FLIGHT_MODE_NAME 10 @@ -301,7 +347,18 @@ PACK(typedef struct { int8_t value:6; }) FrSkyRSSIAlarm; -#if defined(PCBTARANIS) +#if defined(PCBFLAMENCO) || defined(PCBHORUS) +enum MainViews { + VIEW_BLANK, + VIEW_TIMERS_ALTITUDE, + VIEW_CHANNELS, + VIEW_TELEM1, + VIEW_TELEM2, + VIEW_TELEM3, + VIEW_TELEM4, + VIEW_COUNT +}; +#elif defined(PCBTARANIS) enum MainViews { VIEW_TIMERS, VIEW_INPUTS, @@ -365,20 +422,47 @@ enum BeeperMode { #define swarnenable_t uint8_t #endif -#if defined(PCBTARANIS) - enum UartModes { - UART_MODE_NONE, - UART_MODE_TELEMETRY_MIRROR, - UART_MODE_TELEMETRY, - UART_MODE_SBUS_TRAINER, - // UART_MODE_CPPM_TRAINER, - #if defined(DEBUG) - UART_MODE_DEBUG, - #endif - UART_MODE_COUNT, - UART_MODE_MAX = UART_MODE_COUNT-1 - }; +enum UartModes { +#if defined(CLI) || defined(DEBUG) + UART_MODE_DEBUG, +#else + UART_MODE_NONE, +#endif + UART_MODE_TELEMETRY_MIRROR, + UART_MODE_TELEMETRY, + UART_MODE_SBUS_TRAINER, + // UART_MODE_CPPM_TRAINER, + UART_MODE_COUNT, + UART_MODE_MAX = UART_MODE_COUNT-1 +}; +#if defined(PCBHORUS) + #define LEN_SWITCH_NAME 3 + #define LEN_ANA_NAME 3 + #define LEN_MODEL_FILENAME 16 + #define EXTRA_GENERAL_FIELDS \ + EXTRA_GENERAL_FIELDS_ARM \ + uint8_t serial2Mode:6; \ + uint8_t spare:2; \ + CustomFunctionData customFn[NUM_CFN]; \ + uint32_t switchConfig; \ + uint8_t potsType; /*two bits for every pot*/\ + char switchNames[NUM_SWITCHES][LEN_SWITCH_NAME]; \ + char anaNames[NUM_STICKS+NUM_POTS][LEN_ANA_NAME]; \ + char currModelFilename[LEN_MODEL_FILENAME+1]; +#elif defined(PCBFLAMENCO) + #define LEN_SWITCH_NAME 3 + #define LEN_ANA_NAME 3 + #define EXTRA_GENERAL_FIELDS \ + EXTRA_GENERAL_FIELDS_ARM \ + uint8_t serial2Mode:6; \ + uint8_t spare:2; \ + CustomFunctionData customFn[NUM_CFN]; \ + uint32_t switchConfig; \ + uint8_t potsType; /*two bits for every pot*/\ + char switchNames[NUM_SWITCHES][LEN_SWITCH_NAME]; \ + char anaNames[NUM_STICKS+NUM_POTS][LEN_ANA_NAME]; +#elif defined(PCBTARANIS) #define LEN_SWITCH_NAME 3 #define LEN_ANA_NAME 3 #define LEN_BLUETOOTH_NAME 10 @@ -391,7 +475,6 @@ enum BeeperMode { #else #define BLUETOOTH_FIELDS #endif - #define EXTRA_GENERAL_FIELDS \ EXTRA_GENERAL_FIELDS_ARM \ uint8_t serial2Mode:6; \ @@ -442,7 +525,36 @@ PACK(typedef struct { int8_t inputs[MAX_SCRIPT_INPUTS]; }) ScriptData; -#if defined(PCBTARANIS) +enum PotsWarnMode { + POTS_WARN_OFF, + POTS_WARN_MANUAL, + POTS_WARN_AUTO +}; + +#if defined(PCBHORUS) + enum ModuleIndex { + INTERNAL_MODULE, + EXTERNAL_MODULE, + TRAINER_MODULE, + }; + enum TrainerMode { + TRAINER_MODE_MASTER, + TRAINER_MODE_SLAVE + }; + #define MODELDATA_BITMAP char bitmap[LEN_BITMAP_NAME]; + #define MODELDATA_EXTRA uint8_t spare:3; uint8_t trainerMode:3; uint8_t potsWarnMode:2; ModuleData moduleData[NUM_MODULES+1]; char curveNames[MAX_CURVES][6]; ScriptData scriptsData[MAX_SCRIPTS]; char inputNames[MAX_INPUTS][LEN_INPUT_NAME]; uint8_t potsWarnEnabled; int8_t potsWarnPosition[NUM_POTS]; +#elif defined(PCBFLAMENCO) + enum ModuleIndex { + EXTERNAL_MODULE, + TRAINER_MODULE, + }; + enum TrainerMode { + TRAINER_MODE_MASTER, + TRAINER_MODE_SLAVE + }; + #define MODELDATA_BITMAP uint8_t bitmap; + #define MODELDATA_EXTRA uint8_t spare:3; uint8_t trainerMode:3; uint8_t potsWarnMode:2; ModuleData moduleData[NUM_MODULES+1]; char curveNames[MAX_CURVES][6]; ScriptData scriptsData[MAX_SCRIPTS]; char inputNames[MAX_INPUTS][LEN_INPUT_NAME]; uint8_t potsWarnEnabled; int8_t potsWarnPosition[NUM_POTS]; +#elif defined(PCBTARANIS) enum ModuleIndex { INTERNAL_MODULE, EXTERNAL_MODULE, @@ -455,11 +567,6 @@ PACK(typedef struct { TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE, TRAINER_MODE_MASTER_BATTERY_COMPARTMENT, }; - enum PotsWarnMode { - POTS_WARN_OFF, - POTS_WARN_MANUAL, - POTS_WARN_AUTO - }; #define IS_TRAINER_EXTERNAL_MODULE() (g_model.trainerMode == TRAINER_MODE_MASTER_SBUS_EXTERNAL_MODULE || g_model.trainerMode == TRAINER_MODE_MASTER_CPPM_EXTERNAL_MODULE) #define MODELDATA_BITMAP char bitmap[LEN_BITMAP_NAME]; #define MODELDATA_EXTRA uint8_t spare:3; uint8_t trainerMode:3; uint8_t potsWarnMode:2; ModuleData moduleData[NUM_MODULES+1]; char curveNames[MAX_CURVES][6]; ScriptData scriptsData[MAX_SCRIPTS]; char inputNames[MAX_INPUTS][LEN_INPUT_NAME]; uint8_t potsWarnEnabled; int8_t potsWarnPosition[NUM_POTS]; @@ -494,7 +601,7 @@ enum BacklightMode { #define XPOTS_MULTIPOS_COUNT 6 -#if defined(PCBTARANIS) +#if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS) PACK(typedef struct { uint8_t count; uint8_t steps[XPOTS_MULTIPOS_COUNT-1]; @@ -720,7 +827,7 @@ PACK(typedef struct { #define CFN_GVAR_CST_MAX 125 #endif -#if defined(PCBTARANIS) +#if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS) enum SwitchConfig { SWITCH_NONE, SWITCH_TOGGLE, @@ -743,6 +850,9 @@ PACK(typedef struct { #define IS_TOGGLE(x) (SWITCH_CONFIG(x) == SWITCH_TOGGLE) #define IS_3POS_MIDDLE(x) ((x) == 1) #define SWITCH_WARNING_ALLOWED(x) (SWITCH_EXISTS(x) && !IS_TOGGLE(x)) +#else + #define switchInfo(x) ((x) >= 3 ? (x)-2 : 0) + #define SWITCH_EXISTS(x) true #endif #define ALTERNATE_VIEW 0x10 @@ -815,7 +925,7 @@ PACK(typedef struct { #define MODE_CURVE 1 #endif -#if defined(PCBTARANIS) +#if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS) PACK(typedef struct { uint16_t mode:2; uint16_t scale:14; @@ -876,7 +986,7 @@ PACK(typedef struct { #define EXPO_MODE_ENABLE(ed, v) (((v)<0 && ((ed)->mode&1)) || ((v)>=0 && ((ed)->mode&2))) #endif -#if defined(PCBTARANIS) +#if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS) #define limit_min_max_t int16_t #define LIMIT_EXT_PERCENT 150 #define LIMIT_EXT_MAX (LIMIT_EXT_PERCENT*10) @@ -900,7 +1010,7 @@ PACK(typedef struct { #define LIMIT_OFS_RESX(lim) calc1000toRESX(LIMIT_OFS(lim)) #endif -#if defined(PCBTARANIS) +#if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS) PACK(typedef struct { int32_t min:11; int32_t max:11; @@ -943,7 +1053,7 @@ PACK(typedef struct { #define SLOW_STEP 10 #define DELAY_MAX (25*DELAY_STEP) /* 25 seconds */ #define SLOW_MAX (25*SLOW_STEP) /* 25 seconds */ -#if defined(PCBTARANIS) +#if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS) PACK(typedef struct { int16_t weight:11; // GV1=-1024, -GV1=1023 uint16_t destCh:5; @@ -1424,7 +1534,7 @@ PACK(typedef struct { ls_telemetry_value_t barMax; // ditto for max display (would usually = ratio) }) FrSkyBarData; -#if defined(PCBTARANIS) +#if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS) #define NUM_LINE_ITEMS 3 #else #define NUM_LINE_ITEMS 2 @@ -1434,7 +1544,7 @@ PACK(typedef struct { source_t sources[NUM_LINE_ITEMS]; }) FrSkyLineData; -#if defined(PCBTARANIS) +#if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS) #define MAX_TELEM_SCRIPT_INPUTS 8 PACK(typedef struct { char file[LEN_SCRIPT_FILENAME]; @@ -1445,7 +1555,7 @@ PACK(typedef struct { typedef union { FrSkyBarData bars[4]; FrSkyLineData lines[4]; -#if defined(PCBTARANIS) +#if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS) TelemetryScriptData script; #endif } FrSkyScreenData; @@ -1604,7 +1714,7 @@ PACK(typedef struct { #define TRIMS_ARRAY_SIZE 5 #define trim_t int16_t #else - #if defined(PCBTARANIS) + #if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS) PACK(typedef struct { int16_t value:11; uint16_t mode:5; @@ -1645,7 +1755,25 @@ enum SwitchSources { SWSRC_FIRST_SWITCH, -#if defined(PCBTARANIS) +#if defined(PCBFLAMENCO) + SWSRC_SA0 = SWSRC_FIRST_SWITCH, + SWSRC_SA1, + SWSRC_SA2, + SWSRC_SB0, + SWSRC_SB2, + SWSRC_SC0, + SWSRC_SC1, + SWSRC_SC2, + SWSRC_SC3, + SWSRC_SC4, + SWSRC_SC5, + SWSRC_SE0, + SWSRC_SE2, + SWSRC_SF0, + SWSRC_SF1, + SWSRC_SF2, + SWSRC_LAST_SWITCH = SWSRC_SF2, +#elif defined(PCBTARANIS) || defined(PCBHORUS) SWSRC_SA0 = SWSRC_FIRST_SWITCH, SWSRC_SA1, SWSRC_SA2, @@ -1811,7 +1939,22 @@ enum MixSources { MIXSRC_Ail, LUA_EXPORT("ail", "Aileron") MIXSRC_FIRST_POT, -#if defined(PCBTARANIS) +#if defined(PCBHORUS) + MIXSRC_POT1 = MIXSRC_FIRST_POT, LUA_EXPORT("s1", "Potentiometer 1") + MIXSRC_POT2, LUA_EXPORT("s2", "Potentiometer 2") + MIXSRC_POT3, LUA_EXPORT("s3", "Potentiometer 3") + MIXSRC_FIRST_SLIDER, + MIXSRC_SLIDER1 = MIXSRC_FIRST_SLIDER, LUA_EXPORT("ls", "Left slider") + MIXSRC_SLIDER2, LUA_EXPORT("rs", "Right slider") + MIXSRC_SLIDER3, LUA_EXPORT("lcs", "Left center slider") + MIXSRC_SLIDER4, LUA_EXPORT("rcs", "Right center slider") + MIXSRC_LAST_POT = MIXSRC_SLIDER4, +#elif defined(PCBFLAMENCO) + MIXSRC_POT1 = MIXSRC_FIRST_POT, LUA_EXPORT("sd", "Potentiometer D") + MIXSRC_SLIDER1, LUA_EXPORT("ls", "Left slider") + MIXSRC_SLIDER2, LUA_EXPORT("rs", "Right slider") + MIXSRC_LAST_POT = MIXSRC_SLIDER2, +#elif defined(PCBTARANIS) MIXSRC_POT1 = MIXSRC_FIRST_POT, LUA_EXPORT("s1", "Potentiometer 1") MIXSRC_POT2, LUA_EXPORT("s2", "Potentiometer 2") MIXSRC_POT3, LUA_EXPORT("s3", "Potentiometer 3") @@ -1833,7 +1976,7 @@ enum MixSources { MIXSRC_P2, MIXSRC_P3, MIXSRC_LAST_POT = MIXSRC_P3, - #endif +#endif #if defined(PCBSKY9X) MIXSRC_REa, @@ -1866,7 +2009,13 @@ enum MixSources { MIXSRC_FIRST_SWITCH, -#if defined(PCBTARANIS) +#if defined(PCBFLAMENCO) + MIXSRC_SA = MIXSRC_FIRST_SWITCH, LUA_EXPORT("sa", "Switch A") + MIXSRC_SB, LUA_EXPORT("sb", "Switch B") + MIXSRC_SC, LUA_EXPORT("sc", "Switch C") + MIXSRC_SE, LUA_EXPORT("se", "Switch E") + MIXSRC_SF, LUA_EXPORT("sf", "Switch F") +#elif defined(PCBTARANIS) || defined(PCBHORUS) MIXSRC_SA = MIXSRC_FIRST_SWITCH, LUA_EXPORT("sa", "Switch A") MIXSRC_SB, LUA_EXPORT("sb", "Switch B") MIXSRC_SC, LUA_EXPORT("sc", "Switch C") @@ -2107,7 +2256,11 @@ PACK(typedef struct { enum ThrottleSources { THROTTLE_SOURCE_THR, THROTTLE_SOURCE_FIRST_POT, -#if defined(PCBTARANIS) && defined(REV9E) +#if defined(PCBFLAMENCO) + THROTTLE_SOURCE_SD, + THROTTLE_SOURCE_LS, + THROTTLE_SOURCE_RS, +#elif defined(PCBTARANIS) && defined(REV9E) THROTTLE_SOURCE_F1 = THROTTLE_SOURCE_FIRST_POT, THROTTLE_SOURCE_F2, THROTTLE_SOURCE_F3, @@ -2191,7 +2344,7 @@ PACK(typedef struct { ARM_FIELD(TelemetrySensor telemetrySensors[MAX_SENSORS]) - TARANIS_REV9E_FIELD(uint8_t topLcdTimer) + TARANIS_REV9E_FIELD(uint8_t toplcdTimer) }) ModelData; extern EEGeneral g_eeGeneral; diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 720ae0cf4..c5b4e81d8 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -55,9 +55,9 @@ ModelData g_model; Clipboard clipboard; #endif -#if defined(PCBTARANIS) && defined(SDCARD) +#if (defined(PCBTARANIS) || defined(PCBHORUS)) && defined(SDCARD) uint8_t modelBitmap[MODEL_BITMAP_SIZE]; -void loadModelBitmap(char *name, uint8_t *bitmap) +void loadModelBitmap(char * name, uint8_t * bitmap) { uint8_t len = zlen(name, LEN_BITMAP_NAME); if (len > 0) { @@ -262,7 +262,11 @@ void generalDefault() g_eeGeneral.variant = EEPROM_VARIANT; g_eeGeneral.contrast = 25; -#if defined(PCBTARANIS) +#if defined(PCBFLAMENCO) + g_eeGeneral.vBatWarn = 33; + g_eeGeneral.vBatMin = -60; // 0 is 9.0V + g_eeGeneral.vBatMax = -78; // 0 is 12.0V +#elif defined(PCBTARANIS) g_eeGeneral.potsConfig = 0x05; // S1 and S2 = pots with detent g_eeGeneral.slidersConfig = 0x03; // LS and RS = sliders with detent #endif @@ -289,11 +293,15 @@ void generalDefault() g_eeGeneral.stickMode = DEFAULT_MODE-1; #endif -#if defined(PCBTARANIS) +#if defined(PCBFLAMENCO) + g_eeGeneral.templateSetup = 21; /* AETR */ +#elif defined(PCBTARANIS) g_eeGeneral.templateSetup = 17; /* TAER */ #endif -#if !defined(CPUM64) +#if defined(PCBFLAMENCO) + g_eeGeneral.inactivityTimer = 50; +#elif !defined(CPUM64) g_eeGeneral.backlightMode = e_backlight_mode_all; g_eeGeneral.lightAutoOff = 2; g_eeGeneral.inactivityTimer = 10; @@ -317,6 +325,10 @@ void generalDefault() memcpy(g_eeGeneral.bluetoothName, defaultName, sizeof(defaultName)); #endif +#if !defined(EEPROM) + strcpy(g_eeGeneral.currModelFilename, DEFAULT_MODEL_FILENAME); +#endif + g_eeGeneral.chkSum = 0xFFFF; } @@ -359,22 +371,22 @@ void defaultInputs() g_model.inputNames[i][3] = '\0'; #endif } - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } #endif #if defined(TEMPLATES) inline void applyDefaultTemplate() { - applyTemplate(TMPL_SIMPLE_4CH); // calls eeDirty internally + applyTemplate(TMPL_SIMPLE_4CH); // calls storageDirty internally } #else void applyDefaultTemplate() { #if defined(VIRTUALINPUTS) - defaultInputs(); // calls eeDirty internally + defaultInputs(); // calls storageDirty internally #else - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); #endif for (int i=0; itrim[idx] = trim; #endif - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } #endif @@ -649,7 +658,7 @@ void incRotaryEncoder(uint8_t idx, int8_t inc) g_rotenc[idx] += inc; int16_t *value = &(flightModeAddress(getRotaryEncoderFlightPhase(idx))->rotaryEncoders[idx]); *value = limit((int16_t)-1024, (int16_t)(*value + (inc * 8)), (int16_t)+1024); - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } #endif @@ -657,11 +666,11 @@ void incRotaryEncoder(uint8_t idx, int8_t inc) #if defined(PCBSTD) #define SET_GVAR_VALUE(idx, phase, value) \ - (GVAR_VALUE(idx, phase) = value, eeDirty(EE_MODEL)) + (GVAR_VALUE(idx, phase) = value, storageDirty(EE_MODEL)) #else #define SET_GVAR_VALUE(idx, phase, value) \ GVAR_VALUE(idx, phase) = value; \ - eeDirty(EE_MODEL); \ + storageDirty(EE_MODEL); \ if (g_model.gvars[idx].popup) { \ s_gvar_last = idx; \ s_gvar_timer = GVAR_DISPLAY_TIME; \ @@ -959,6 +968,25 @@ void checkBacklight() } } +#if defined(PCBFLAMENCO) +void checkUsbChip() +{ + uint8_t reg = i2cReadBQ24195(0x00); + if (reg & 0x80) { + i2cWriteBQ24195(0x00, reg & 0x7F); + } +} +#endif + +void doLoopCommonActions() +{ + checkBacklight(); + +#if defined(PCBFLAMENCO) + checkUsbChip(); +#endif +} + void backlightOn() { lightOffCounter = ((uint16_t)g_eeGeneral.lightAutoOff*250) << 1; @@ -1020,7 +1048,11 @@ void doSplash() if (!(g_eeGeneral.splashMode & 0x04)) { #endif +#if defined(COLORLCD) + if (keyDown()) return; +#else if (keyDown() || inputsMoved()) return; +#endif #if defined(FSPLASH) } @@ -1054,7 +1086,7 @@ void doSplash() } #endif - checkBacklight(); + doLoopCommonActions(); } } } @@ -1090,7 +1122,9 @@ void checkAll() #if defined(MODULE_ALWAYS_SEND_PULSES) startupWarningState = STARTUP_WARNING_THROTTLE; #else - checkTHR(); + if (g_eeGeneral.chkSum == evalChkSum()) { + checkTHR(); + } checkSwitches(); checkFailsafe(); #endif @@ -1139,7 +1173,7 @@ void checkLowEEPROM() { if (g_eeGeneral.disableMemoryWarning) return; if (EeFsGetFree() < 100) { - ALERT(STR_EEPROMWARN, STR_EEPROMLOWMEM, AU_ERROR); + ALERT(STR_STORAGE_WARNING, STR_EEPROMLOWMEM, AU_ERROR); } } #endif @@ -1219,7 +1253,7 @@ void checkTHR() break; } - checkBacklight(); + doLoopCommonActions(); wdt_reset(); } @@ -1251,7 +1285,7 @@ void alert(const pm_char * t, const pm_char *s MESSAGE_SOUND_ARG) if (keyDown()) return; // wait for key release - checkBacklight(); + doLoopCommonActions(); wdt_reset(); @@ -1282,7 +1316,7 @@ int8_t trimGvar[NUM_STICKS] = { -1, -1, -1, -1 }; #if defined(CPUARM) void checkTrims() { - uint8_t event = getEvent(true); + evt_t event = getEvent(true); if (event && !IS_KEY_BREAK(event)) { int8_t k = EVT_KEY_MASK(event) - TRM_BASE; #else @@ -1822,10 +1856,6 @@ void opentxStart() } #endif -#if defined(CPUARM) - eeLoadModel(g_eeGeneral.currModel); -#endif - #if defined(GUI) checkAlarm(); checkAll(); @@ -1836,7 +1866,6 @@ void opentxStart() chainMenu(menuFirstCalib); } #endif - } #if defined(CPUARM) || defined(CPUM2560) @@ -1868,11 +1897,11 @@ void opentxClose() if (sensor.type == TELEM_TYPE_CALCULATED) { if (sensor.persistent && sensor.persistentValue != telemetryItems[i].value) { sensor.persistentValue = telemetryItems[i].value; - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } else if (!sensor.persistent) { sensor.persistentValue = 0; - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } } } @@ -1892,20 +1921,20 @@ void opentxClose() SAVE_POT_POSITION(i); } } - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } #endif #if !defined(PCBTARANIS) - if (s_eeDirtyMsk & EE_MODEL) { + if (storageDirtyMsk & EE_MODEL) { displayPopup(STR_SAVEMODEL); } #endif g_eeGeneral.unexpectedShutdown = 0; - eeDirty(EE_GENERAL); - eeCheck(true); + storageDirty(EE_GENERAL); + storageCheck(true); #if defined(CPUARM) while (IS_PLAYING(ID_PLAY_BYE)) { @@ -2005,7 +2034,7 @@ void checkBattery() if (counter-- == 0) { counter = 10; int32_t instant_vbat = anaIn(TX_VOLTAGE); -#if defined(PCBTARANIS) +#if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS) instant_vbat = (instant_vbat + instant_vbat*(g_eeGeneral.txVoltageCalibration)/128) * BATT_SCALE; instant_vbat >>= 11; instant_vbat += 2; // because of the diode @@ -2234,7 +2263,7 @@ void instantTrim() } } - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); AUDIO_WARNING2(); } @@ -2258,7 +2287,7 @@ void copySticksToOffset(uint8_t ch) #endif ld->offset = (ld->revert ? -zero : zero); resumeMixerCalculations(); - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } void copyTrimsToOffset(uint8_t ch) @@ -2283,7 +2312,7 @@ void copyTrimsToOffset(uint8_t ch) g_model.limitData[ch].offset = limit((int16_t)-1000, (int16_t)v, (int16_t)1000); // make sure the offset doesn't go haywire resumeMixerCalculations(); - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } void moveTrimsToOffsets() // copy state of 3 primary to subtrim @@ -2331,7 +2360,7 @@ void moveTrimsToOffsets() // copy state of 3 primary to subtrim resumeMixerCalculations(); - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); AUDIO_WARNING2(); } @@ -2378,7 +2407,9 @@ uint16_t stackAvailable() void opentxInit(OPENTX_INIT_ARGS) { - eeReadAll(); + TRACE("opentxInit()"); + + storageReadAll(); #if defined(CPUARM) if (UNEXPECTED_SHUTDOWN()) { @@ -2425,9 +2456,6 @@ void opentxInit(OPENTX_INIT_ARGS) #if !defined(CPUARM) // is done above on ARM unexpectedShutdown = 1; -#endif -#if defined(CPUARM) - eeLoadModel(g_eeGeneral.currModel); #endif } else { @@ -2437,7 +2465,7 @@ void opentxInit(OPENTX_INIT_ARGS) #if defined(CPUARM) || defined(CPUM2560) if (!g_eeGeneral.unexpectedShutdown) { g_eeGeneral.unexpectedShutdown = 1; - eeDirty(EE_GENERAL); + storageDirty(EE_GENERAL); } #endif @@ -2446,7 +2474,7 @@ void opentxInit(OPENTX_INIT_ARGS) #endif backlightOn(); -#if defined(PCBTARANIS) +#if defined(PCBTARANIS) || defined(PCBFLAMENCO) serial2Init(g_eeGeneral.serial2Mode, MODEL_TELEMETRY_PROTOCOL()); #endif @@ -2484,10 +2512,15 @@ int main(void) boardInit(); -#if defined(GUI) && !defined(PCBTARANIS) +#if defined(GUI) && !defined(PCBTARANIS) && !defined(PCBFLAMENCO) && !defined(PCBHORUS) + // TODO remove this lcdInit(); #endif +#if defined(COLORLCD) + lcdColorsInit(); +#endif + stackPaint(); #if defined(GUI) @@ -2498,14 +2531,14 @@ int main(void) #endif #if defined(GUI) && !defined(PCBTARANIS) - lcdSetRefVolt(25); + // lcdSetRefVolt(25); #endif #if defined(PCBTARANIS) displaySplash(); #endif - sei(); // interrupts needed for telemetryInit and eeReadAll. + sei(); // interrupts needed now #if defined(FRSKY) && !defined(DSM2_SERIAL) telemetryInit(); @@ -2546,6 +2579,10 @@ int main(void) uint8_t shutdown_state = 0; #endif +#if defined(PCBFLAMENCO) + menuEntryTime = get_tmr10ms() - 200; +#endif + while (1) { #if defined(CPUM2560) if ((shutdown_state=pwrCheck()) > e_power_trainer) @@ -2563,10 +2600,10 @@ int main(void) #if defined(CPUM2560) // Time to switch off - lcd_clear(); + lcdClear(); displayPopup(STR_SHUTDOWN); opentxClose(); - lcd_clear() ; + lcdClear() ; lcdRefresh() ; boardOff(); // Only turn power off if necessary wdt_disable(); @@ -2619,9 +2656,9 @@ uint32_t pwrCheck() #if defined(SHUTDOWN_CONFIRMATION) while (1) { lcdRefreshWait(); - lcd_clear(); + lcdClear(); POPUP_CONFIRMATION("Confirm Shutdown"); - uint8_t evt = getEvent(false); + evt_t evt = getEvent(false); DISPLAY_WARNING(evt); lcdRefresh(); if (s_warning_result == true) { @@ -2643,7 +2680,7 @@ uint32_t pwrCheck() else { lcdRefreshWait(); unsigned index = pwrPressedDuration() / (PWR_PRESS_SHUTDOWN / 4); - lcd_clear(); + lcdClear(); lcd_bmp(76, 2, bmp_shutdown, index*60, 60); lcdRefresh(); return e_power_press; diff --git a/radio/src/opentx.h b/radio/src/opentx.h index b9a1fa2fa..f5f72af69 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -257,14 +257,12 @@ #endif #define CONVERT_PTR_UINT(x) ((uint32_t)(uint64_t)(x)) #define CONVERT_UINT_PTR(x) ((uint32_t*)(uint64_t)(x)) - char *convertSimuPath(const char *path); #else #define FORCEINLINE inline __attribute__ ((always_inline)) #define NOINLINE __attribute__ ((noinline)) #define SIMU_SLEEP(x) #define CONVERT_PTR_UINT(x) ((uint32_t)(x)) #define CONVERT_UINT_PTR(x) ((uint32_t *)(x)) - #define convertSimuPath(x) (x) #endif #if !defined(CPUM64) && !defined(ACCURAT_THROTTLE_TIMER) @@ -283,16 +281,20 @@ #define RESXul 1024ul #define RESXl 1024l -#if defined(PCBTARANIS) - #include "targets/taranis/board_taranis.h" +#if defined(PCBHORUS) + #include "targets/Horus/board_horus.h" +#elif defined(PCBFLAMENCO) + #include "targets/Flamenco/board_flamenco.h" +#elif defined(PCBTARANIS) + #include "targets/Taranis/board_taranis.h" #elif defined(PCBSKY9X) - #include "targets/sky9x/board_sky9x.h" + #include "targets/Sky9x/board_sky9x.h" #elif defined(PCBGRUVIN9X) - #include "targets/gruvin9x/board_gruvin9x.h" + #include "targets/Gruvin9x/board_gruvin9x.h" #elif defined(PCBMEGA2560) - #include "targets/mega2560/board_mega2560.h" + #include "targets/Mega2560/board_mega2560.h" #else - #include "targets/stock/board_stock.h" + #include "targets/9x/board_stock.h" #endif #include "debug.h" @@ -333,41 +335,29 @@ #include #endif -#if defined(PCBTARANIS) +#if defined(PCBFLAMENCO) + #define NUM_SWITCHES 5 +#elif defined(PCBTARANIS) || defined(PCBHORUS) #if defined(REV9E) #define NUM_SWITCHES 18 // yes, it's a lot! #else #define NUM_SWITCHES 8 #endif - #define NUM_SW_SRCRAW 8 #define SWSRC_THR SWSRC_SF2 #define SWSRC_GEA SWSRC_SG2 #define SWSRC_ID0 SWSRC_SA0 #define SWSRC_ID1 SWSRC_SA1 #define SWSRC_ID2 SWSRC_SA2 - #define SW_DSM2_BIND SW_SH2 #else #define NUM_SWITCHES 7 #define IS_3POS(sw) ((sw) == 0) #define IS_MOMENTARY(sw) (sw == SWSRC_TRN) - #define NUM_SW_SRCRAW 1 #define SW_DSM2_BIND SW_TRN #endif #define NUM_PSWITCH (SWSRC_LAST_SWITCH-SWSRC_FIRST_SWITCH+1) #define NUM_POTSSW (NUM_XPOTS*6) -#if defined(PCBTARANIS) - #define KEY_RIGHT KEY_PLUS - #define KEY_LEFT KEY_MINUS - #define KEY_UP KEY_PLUS - #define KEY_DOWN KEY_MINUS -#else - #define KEY_ENTER KEY_MENU - #define KEY_PLUS KEY_RIGHT - #define KEY_MINUS KEY_LEFT -#endif - #include "myeeprom.h" #if defined(CPUM64) @@ -376,7 +366,15 @@ #define memclear(p, s) memset(p, 0, s) #endif -#if defined(PCBTARANIS) && defined(REV9E) +#if defined(PCBHORUS) + #define IS_POT_AVAILABLE(x) (true) + #define IS_POT_MULTIPOS(x) (x==0) + #define IS_POT_WITHOUT_DETENT(x) (x==0) +#elif defined(PCBFLAMENCO) + #define IS_POT_AVAILABLE(x) (true) + #define IS_POT_MULTIPOS(x) (x==0) + #define IS_POT_WITHOUT_DETENT(x) (x==0) +#elif defined(PCBTARANIS) && defined(REV9E) #define IS_SLIDER_AVAILABLE(x) ((x)==SLIDER1 || (x)==SLIDER2 || (g_eeGeneral.slidersConfig & (0x01 << ((x)-SLIDER3)))) #define IS_POT_AVAILABLE(x) ((x)=SLIDER1 && IS_SLIDER_AVAILABLE(x))) #define IS_POT_MULTIPOS(x) ((x)>=POT1 && (x)<=POT_LAST && ((g_eeGeneral.potsConfig>>(2*((x)-POT1)))&0x03)==POT_MULTIPOS_SWITCH) @@ -450,23 +448,29 @@ #define STICK_SCROLL_DISABLE() #endif -#include "eeprom_common.h" - -#if defined(EEPROM_RLC) - #include "eeprom_rlc.h" -#else - #include "eeprom_raw.h" +#if defined(CLI) +#include "cli.h" #endif +#include "timers.h" +#include "storage/storage.h" #include "pulses/pulses.h" -#if defined(PCBTARANIS) - #define BITMAP_BUFFER_SIZE(width, height) (2 + width * ((height+7)/8)*4) +#if defined(PCBHORUS) + #define BITMAP_BUFFER_SIZE(width, height) (4 + (width)*(height)*3) + #define MODEL_BITMAP_WIDTH (3*64) // 171 + #define MODEL_BITMAP_HEIGHT (3*32) // 101 + #define MODEL_BITMAP_SIZE BITMAP_BUFFER_SIZE(MODEL_BITMAP_WIDTH, MODEL_BITMAP_HEIGHT) + extern uint8_t modelBitmap[MODEL_BITMAP_SIZE]; + void loadModelBitmap(char * name, uint8_t * bitmap); + #define LOAD_MODEL_BITMAP() loadModelBitmap(g_model.header.bitmap, modelBitmap) +#elif defined(PCBTARANIS) + #define BITMAP_BUFFER_SIZE(width, height) (2 + (width) * (((height)+7)/8)*4) #define MODEL_BITMAP_WIDTH 64 #define MODEL_BITMAP_HEIGHT 32 #define MODEL_BITMAP_SIZE BITMAP_BUFFER_SIZE(MODEL_BITMAP_WIDTH, MODEL_BITMAP_HEIGHT) extern uint8_t modelBitmap[MODEL_BITMAP_SIZE]; - void loadModelBitmap(char *name, uint8_t *bitmap); + void loadModelBitmap(char * name, uint8_t * bitmap); #define LOAD_MODEL_BITMAP() loadModelBitmap(g_model.header.bitmap, modelBitmap) #else #define LOAD_MODEL_BITMAP() @@ -486,7 +490,17 @@ #define MAX_TRAINER_CHANNELS() (8) #endif -#if defined(PCBTARANIS) +#if defined(PCBFLAMENCO) + #define IS_MODULE_PPM(idx) (idx==TRAINER_MODULE || (idx==EXTERNAL_MODULE && g_model.moduleData[EXTERNAL_MODULE].type==MODULE_TYPE_PPM)) + #define IS_MODULE_XJT(idx) ((g_model.moduleData[EXTERNAL_MODULE].type==MODULE_TYPE_XJT) && (g_model.moduleData[idx].rfProtocol != RF_PROTO_OFF)) + #if defined(DSM2) + #define IS_MODULE_DSM2(idx) (idx==EXTERNAL_MODULE && g_model.moduleData[EXTERNAL_MODULE].type==MODULE_TYPE_DSM2) + #else + #define IS_MODULE_DSM2(idx) (false) + #endif + #define MAX_EXTERNAL_MODULE_CHANNELS() ((g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_XJT) ? maxChannelsXJT[1+g_model.moduleData[1].rfProtocol] : maxChannelsModules[g_model.externalModule]) + #define MAX_CHANNELS(idx) (idx==EXTERNAL_MODULE ? MAX_EXTERNAL_MODULE_CHANNELS() : MAX_TRAINER_CHANNELS()) +#elif defined(PCBTARANIS) #if defined(TARANIS_INTERNAL_PPM) #define IS_MODULE_PPM(idx) (idx==TRAINER_MODULE || (idx==INTERNAL_MODULE && g_model.moduleData[INTERNAL_MODULE].type==MODULE_TYPE_PPM)|| (idx==EXTERNAL_MODULE && g_model.moduleData[EXTERNAL_MODULE].type==MODULE_TYPE_PPM)) #define IS_MODULE_XJT(idx) (((idx==INTERNAL_MODULE && g_model.moduleData[INTERNAL_MODULE].type==MODULE_TYPE_XJT)|| (idx==EXTERNAL_MODULE && g_model.moduleData[EXTERNAL_MODULE].type==MODULE_TYPE_XJT)) && (g_model.moduleData[idx].rfProtocol != RF_PROTO_OFF)) @@ -548,6 +562,7 @@ typedef struct { } } CustomFunctionsContext; +#include "strhelpers.h" #include "gui/gui.h" #if defined(TEMPLATES) @@ -589,7 +604,9 @@ enum BaseCurves { #define THRCHK_DEADBAND 16 -#if defined(PCBTARANIS) +#if defined(COLORLCD) + #define SPLASH_NEEDED() (true) +#elif defined(PCBTARANIS) #define SPLASH_NEEDED() (g_eeGeneral.splashMode != 3) #elif defined(CPUARM) #define SPLASH_NEEDED() (g_model.moduleData[EXTERNAL_MODULE].type != MODULE_TYPE_DSM2 && !g_eeGeneral.splashMode) @@ -599,13 +616,13 @@ enum BaseCurves { #if defined(FSPLASH) #define SPLASH_TIMEOUT (g_eeGeneral.splashMode == 0 ? 60000/*infinite=10mn*/ : ((4*100) * (g_eeGeneral.splashMode & 0x03))) -#elif defined(PCBTARANIS) +#elif defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS) #define SPLASH_TIMEOUT (g_eeGeneral.splashMode==-4 ? 1500 : (g_eeGeneral.splashMode<=0 ? (400-g_eeGeneral.splashMode*200) : (400-g_eeGeneral.splashMode*100))) #else #define SPLASH_TIMEOUT (4*100) // 4 seconds #endif -#if defined(PCBTARANIS) +#if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS) #define IS_RE_NAVIGATION_ENABLE() true #define NAVIGATION_RE_IDX() 0 #elif defined(ROTARY_ENCODERS) @@ -618,7 +635,7 @@ enum BaseCurves { #define HEART_TIMER_10MS 1 #define HEART_TIMER_PULSES 2 // when multiple modules this is the first one -#if defined(PCBTARANIS) +#if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS) #define HEART_WDT_CHECK (HEART_TIMER_10MS + (HEART_TIMER_PULSES << 0) + (HEART_TIMER_PULSES << 1)) #else #define HEART_WDT_CHECK (HEART_TIMER_10MS + HEART_TIMER_PULSES) @@ -658,7 +675,7 @@ int zchar2str(char *dest, const char *src, int size); #include "keys.h" #include "pwr.h" -#if defined(PCBTARANIS) +#if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS) div_t switchInfo(int switchPosition); #endif @@ -768,7 +785,7 @@ void logicalSwitchesReset(); #define LS_RECURSIVE_EVALUATION_RESET() s_last_switch_used = 0 #endif -#if defined(PCBTARANIS) +#if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS) void getSwitchesPosition(bool startup); #else #define getSwitchesPosition(...) @@ -777,7 +794,7 @@ void logicalSwitchesReset(); extern swarnstate_t switches_states; swsrc_t getMovedSwitch(); -#if defined(PCBTARANIS) +#if defined(VIRTUALINPUTS) #define GET_MOVED_SOURCE_PARAMS uint8_t min int8_t getMovedSource(GET_MOVED_SOURCE_PARAMS); #define GET_MOVED_SOURCE(min, max) getMovedSource(min) @@ -793,7 +810,7 @@ swsrc_t getMovedSwitch(); #define getFlightMode() 0 #endif -#if !defined(PCBTARANIS) +#if !defined(VIRTUALINPUTS) uint8_t getTrimFlightPhase(uint8_t phase, uint8_t idx); #else #define getTrimFlightPhase(phase, idx) (phase) @@ -809,7 +826,7 @@ swsrc_t getMovedSwitch(); trim_t getRawTrimValue(uint8_t phase, uint8_t idx); int getTrimValue(uint8_t phase, uint8_t idx); -#if defined(PCBTARANIS) +#if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS) bool setTrimValue(uint8_t phase, uint8_t idx, int trim); #else void setTrimValue(uint8_t phase, uint8_t idx, int trim); @@ -988,7 +1005,26 @@ enum Analogs { STICK2, STICK3, STICK4, -#if defined(PCBTARANIS) +#if defined(PCBHORUS) + POT1, + POT2, + POT3, + POT_LAST=POT3, + SLIDER1, + SLIDER2, + SLIDER3, + SLIDER4, +#elif defined(PCBFLAMENCO) + POT1, + POT2, + POT_LAST = POT2, + SLIDER1, + SLIDER2, + SWITCHES1, + SWITCHES2, + SWITCHES3, + SWITCHES4, +#elif defined(PCBTARANIS) POT1, POT2, POT3, @@ -1022,11 +1058,16 @@ enum Analogs { TX_VOLTAGE, #if defined(PCBSKY9X) && !defined(REVA) TX_CURRENT, +#endif +#if defined(PCBHORUS) + MOUSE1, + MOUSE2, #endif NUMBER_ANALOG }; void checkBacklight(); +void doLoopCommonActions(); #if defined(PCBSTD) && defined(VOICE) && !defined(SIMU) #define BACKLIGHT_ON() (Voice.Backlight = 1) @@ -1074,7 +1115,6 @@ void generalDefault(); void modelDefault(uint8_t id); #if defined(CPUARM) -bool isFileAvailable(const char * filename); void checkModelIdUnique(uint8_t index, uint8_t module); #endif @@ -1389,8 +1429,8 @@ enum AUDIO_SOUNDS { #if defined(VOICE) AU_THROTTLE_ALERT, AU_SWITCH_ALERT, - AU_BAD_EEPROM, - AU_EEPROM_FORMATTING, + AU_BAD_RADIODATA, + AU_STORAGE_FORMAT, #endif AU_TX_BATTERY_LOW, AU_INACTIVITY, @@ -1427,7 +1467,7 @@ enum AUDIO_SOUNDS { #if defined(CPUARM) AU_TRIM_END, #endif -#if defined(PCBTARANIS) +#if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS) AU_STICK1_MIDDLE, AU_STICK2_MIDDLE, AU_STICK3_MIDDLE, @@ -1488,11 +1528,11 @@ enum AUDIO_SOUNDS { #include "buzzer.h" #if defined(PCBSTD) && defined(VOICE) -#include "targets/stock/voice.h" +#include "targets/9x/voice.h" #endif #if defined(PCBGRUVIN9X) && defined(VOICE) -#include "targets/gruvin9x/somo14d.h" +#include "targets/Gruvin9x/somo14d.h" #endif #include "translations.h" @@ -1523,13 +1563,13 @@ extern void opentxClose(); extern void opentxInit(); // Re-useable byte array to save having multiple buffers -#define SD_SCREEN_FILE_LENGTH (32) +#define SD_SCREEN_FILE_LENGTH (64) union ReusableBuffer { // 275 bytes struct { - char listnames[LCD_LINES-1][LEN_MODEL_NAME]; + char listnames[NUM_BODY_LINES][LEN_MODEL_NAME]; #if !defined(CPUARM) uint16_t eepromfree; #endif @@ -1549,7 +1589,7 @@ union ReusableBuffer int16_t loVals[NUM_STICKS+NUM_POTS]; int16_t hiVals[NUM_STICKS+NUM_POTS]; uint8_t state; -#if defined(PCBTARANIS) +#if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS) struct { uint8_t stepsCount; int16_t steps[XPOTS_MULTIPOS_COUNT]; @@ -1563,7 +1603,7 @@ union ReusableBuffer // 274 bytes struct { - char lines[LCD_LINES-1][SD_SCREEN_FILE_LENGTH+1+1]; // the last char is used to store the flags (directory) of the line + char lines[NUM_BODY_LINES][SD_SCREEN_FILE_LENGTH+1+1]; // the last char is used to store the flags (directory) of the line uint32_t available; uint16_t offset; uint16_t count; @@ -1577,7 +1617,7 @@ extern union ReusableBuffer reusableBuffer; void checkFlashOnBeep(); #if defined(CPUARM) -void putsValueWithUnit(coord_t x, coord_t y, lcdint_t val, uint8_t unit, LcdFlags att); +void putsValueWithUnit(coord_t x, coord_t y, int32_t val, uint8_t unit, LcdFlags att); #elif defined(FRSKY) void convertUnit(getvalue_t & val, uint8_t & unit); // TODO check FORCEINLINE on stock #else @@ -1588,8 +1628,13 @@ void convertUnit(getvalue_t & val, uint8_t & unit); // TODO check FORCEINLINE on uint8_t zlen(const char *str, uint8_t size); bool zexist(const char *str, uint8_t size); char * strcat_zchar(char *dest, const char *name, uint8_t size, const char *defaultName=NULL, uint8_t defaultNameSize=0, uint8_t defaultIdx=0); -#define strcat_modelname(dest, idx) strcat_zchar(dest, modelHeaders[idx].name, LEN_MODEL_NAME, STR_MODEL, PSIZE(TR_MODEL), idx+1) #define strcat_phasename(dest, idx) strcat_zchar(dest, g_model.flightModeData[idx].name, LEN_FLIGHT_MODE_NAME, STR_FP, PSIZE(TR_FP), idx+1) +#if defined(EEPROM) +#define strcat_modelname(dest, idx) strcat_zchar(dest, modelHeaders[idx].name, LEN_MODEL_NAME, STR_MODEL, PSIZE(TR_MODEL), idx+1) +#define strcat_currentmodelname(dest) strcat_modelname(dest, g_eeGeneral.currModel) +#else +#define strcat_currentmodelname(dest) strcat_zchar(dest, g_model.header.name, LEN_MODEL_NAME) +#endif #define ZLEN(s) zlen(s, sizeof(s)) #define ZEXIST(s) zexist(s, sizeof(s)) #endif @@ -1698,7 +1743,7 @@ extern uint8_t s_frsky_view; #define EARTH_RADIUSKM ((uint32_t)6371) #define EARTH_RADIUS ((uint32_t)111194) -#if defined(PCBTARANIS) +#if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS) double gpsToDouble(bool neg, int16_t bp, int16_t ap); #endif void getGpsPilotPosition(); diff --git a/radio/src/pulses/dsm2_arm.cpp b/radio/src/pulses/dsm2_arm.cpp index de4739f27..774a5caf8 100644 --- a/radio/src/pulses/dsm2_arm.cpp +++ b/radio/src/pulses/dsm2_arm.cpp @@ -51,7 +51,7 @@ uint8_t dsm2BindTimer = DSM2_BIND_TIMEOUT; #define BITLEN_DSM2 (8*2) //125000 Baud => 8uS per bit -#if defined(PCBTARANIS) +#if !defined(PPM_PIN_HW_SERIAL) void _send_1(uint8_t v) { if (modulePulsesData[EXTERNAL_MODULE].dsm2.index == 0) @@ -129,7 +129,7 @@ void setupPulsesDSM2(unsigned int port) { static uint8_t dsmDat[2+6*2]={0xFF,0x00, 0x00,0xAA, 0x05,0xFF, 0x09,0xFF, 0x0D,0xFF, 0x13,0x54, 0x14,0xAA}; -#if defined(PCBSKY9X) +#if defined(PPM_PIN_HW_SERIAL) modulePulsesData[EXTERNAL_MODULE].dsm2.serialByte = 0 ; modulePulsesData[EXTERNAL_MODULE].dsm2.serialBitCount = 0 ; #else @@ -139,7 +139,7 @@ void setupPulsesDSM2(unsigned int port) modulePulsesData[EXTERNAL_MODULE].dsm2.ptr = modulePulsesData[EXTERNAL_MODULE].dsm2.pulses; -#if defined(PCBTARANIS) +#if !defined(PPM_PIN_HW_SERIAL) modulePulsesData[EXTERNAL_MODULE].dsm2.value = 100; *modulePulsesData[EXTERNAL_MODULE].dsm2.ptr++ = modulePulsesData[EXTERNAL_MODULE].dsm2.value; #endif @@ -156,7 +156,7 @@ void setupPulsesDSM2(unsigned int port) break; } -#if defined(PCBTARANIS) +#if !defined(PPM_PIN_HW_SERIAL) if (moduleFlag[port] == MODULE_BIND) dsmDat[0] |= DSM2_SEND_BIND; else if (moduleFlag[port] == MODULE_RANGECHECK) diff --git a/radio/src/pulses/ppm_arm.cpp b/radio/src/pulses/ppm_arm.cpp index edd21c5fb..44dc5cb04 100644 --- a/radio/src/pulses/ppm_arm.cpp +++ b/radio/src/pulses/ppm_arm.cpp @@ -61,7 +61,7 @@ void setupPulsesPPM(unsigned int port) // Don't enable interru PpmPulsesData * ppmPulsesData = (port == TRAINER_MODULE ? &trainerPulsesData.ppm : &modulePulsesData[port].ppm); uint16_t * ptr = ppmPulsesData->pulses; -#if defined(PCBSKY9X) +#if defined(PPM_PIN_HW_SERIAL) ppmPulsesData->index = 0; #else ppmPulsesData->ptr = ptr; diff --git a/radio/src/pulses/pulses.h b/radio/src/pulses/pulses.h index ad88fe702..9c7ef11f2 100644 --- a/radio/src/pulses/pulses.h +++ b/radio/src/pulses/pulses.h @@ -55,7 +55,7 @@ enum ModuleFlag #define IS_RANGECHECK_ENABLE() (moduleFlag[0] == MODULE_RANGECHECK) #endif -#if defined(DSM2) && !defined(PCBTARANIS) +#if defined(DSM2) && !defined(PCBTARANIS) && !defined(PCBFLAMENCO) #define DSM2_BIND_TIMEOUT 255 // 255*11ms extern uint8_t dsm2BindTimer; #endif diff --git a/radio/src/pulses/pulses_arm.h b/radio/src/pulses/pulses_arm.h index 9c9927a1a..118b45db2 100644 --- a/radio/src/pulses/pulses_arm.h +++ b/radio/src/pulses/pulses_arm.h @@ -47,7 +47,7 @@ extern uint8_t s_current_protocol[NUM_MODULES]; extern uint8_t s_pulses_paused; extern uint16_t failsafeCounter[NUM_MODULES]; -#if defined(PCBSKY9X) +#if defined(PPM_PIN_HW_SERIAL) PACK(struct PpmPulsesData { uint16_t pulses[20]; uint32_t index; diff --git a/radio/src/pulses/pxx_arm.cpp b/radio/src/pulses/pxx_arm.cpp index 2200697c1..58f0b9719 100644 --- a/radio/src/pulses/pxx_arm.cpp +++ b/radio/src/pulses/pxx_arm.cpp @@ -81,7 +81,7 @@ void crc(uint8_t data, unsigned int port) modulePulsesData[port].pxx.pcmCrc = (modulePulsesData[port].pxx.pcmCrc<<8) ^ (CRCTable[((modulePulsesData[port].pxx.pcmCrc>>8)^data) & 0xFF]); } -#if defined(PCBTARANIS) +#if !defined(PPM_PIN_HW_SERIAL) void putPcmPart(uint8_t value, unsigned int port) { @@ -231,8 +231,7 @@ void setupPulsesPXX(unsigned int port) } else { if (i < sendUpperChannels) { - int channel = 8 + i; - int16_t failsafeValue = g_model.moduleData[port].failsafeChannels[channel]; + int16_t failsafeValue = g_model.moduleData[port].failsafeChannels[8+i]; if (failsafeValue == FAILSAFE_CHANNEL_HOLD) { pulseValue = 4095; } @@ -240,7 +239,7 @@ void setupPulsesPXX(unsigned int port) pulseValue = 2048; } else { - failsafeValue += 2*PPM_CH_CENTER(channel) - 2*PPM_CENTER; + failsafeValue += 2*PPM_CH_CENTER(8+g_model.moduleData[port].channelsStart+i) - 2*PPM_CENTER; pulseValue = limit(2049, (failsafeValue * 512 / 682) + 3072, 4094); } } @@ -253,7 +252,7 @@ void setupPulsesPXX(unsigned int port) pulseValue = 0; } else { - failsafeValue += 2*PPM_CH_CENTER(i) - 2*PPM_CENTER; + failsafeValue += 2*PPM_CH_CENTER(g_model.moduleData[port].channelsStart+i) - 2*PPM_CENTER; pulseValue = limit(1, (failsafeValue * 512 / 682) + 1024, 2046); } } diff --git a/radio/src/sdcard.cpp b/radio/src/sdcard.cpp index b67dabbaa..39bb2fa74 100644 --- a/radio/src/sdcard.cpp +++ b/radio/src/sdcard.cpp @@ -40,7 +40,89 @@ #define LIST_NONE_SD_FILE 1 -bool listSdFiles(const char *path, const char *extension, const uint8_t maxlen, const char *selection, uint8_t flags=0) +const char * sdCheckAndCreateDirectory(const char * path) +{ + DIR archiveFolder; + + FRESULT result = f_opendir(&archiveFolder, path); + if (result != FR_OK) { + if (result == FR_NO_PATH) + result = f_mkdir(path); + if (result != FR_OK) + return SDCARD_ERROR(result); + } + else { + f_closedir(&archiveFolder); + } + + return NULL; +} + +bool isFileAvailable(const char * path) +{ + return f_stat(path, 0) == FR_OK; +} + +bool isFileAvailable(const char * filename, const char * directory) +{ + char path[256]; + char * pos = strAppend(path, directory); + *pos = '/'; + strAppend(pos+1, filename); + return isFileAvailable(path); +} + +#define LEN_FILE_EXTENSION 4 +char * getFileExtension(char * filename, int size=0) +{ + int len = strlen(filename); + if (size != 0 && size < len) { + len = size; + } + for (int i=len; i>=len-LEN_FILE_EXTENSION; --i) { + if (filename[i] == '.') { + return &filename[i]; + } + } + return NULL; +} + +char * getFileIndex(char * filename, unsigned int & value) +{ + value = 0; + char * pos = getFileExtension(filename); + if (!pos || pos == filename) + return NULL; + while (pos > filename) { + pos--; + char c = *pos; + if (c >= '0' && c <= '9') { + value = (value * 10) + (c - '\0'); + } + else { + return pos+1; + } + } + return filename; +} + +bool findNextFileIndex(char * filename, const char * directory) +{ + unsigned int index; + char * pos = getFileIndex(filename, index); + char extension[LEN_FILE_EXTENSION+1]; + strncpy(extension, getFileExtension(filename), sizeof(extension)); + do { + pos = strAppendNumber(pos, ++index); + strAppend(pos, extension); + if (!isFileAvailable(filename, directory)) { + return true; + } + } while (index < 99); + return false; +} + +bool sdListFiles(const char *path, const char *extension, const uint8_t maxlen, const char *selection, uint8_t flags=0) { FILINFO fno; DIR dir; @@ -189,29 +271,20 @@ bool listSdFiles(const char *path, const char *extension, const uint8_t maxlen, } #if defined(CPUARM) && defined(SDCARD) -const char *fileCopy(const char *filename, const char *srcDir, const char *destDir) +const char * sdCopyFile(const char * srcPath, const char * destPath) { FIL srcFile; - FIL dstFile; + FIL destFile; char buf[256]; UINT read = sizeof(buf); UINT written = sizeof(buf); - char path[2*CLIPBOARD_PATH_LEN+1]; - char *tmp = strAppend(path, srcDir, CLIPBOARD_PATH_LEN); - *tmp++ = '/'; - strAppend(tmp, filename, CLIPBOARD_PATH_LEN); - - FRESULT result = f_open(&srcFile, path, FA_OPEN_EXISTING | FA_READ); + FRESULT result = f_open(&srcFile, srcPath, FA_OPEN_EXISTING | FA_READ); if (result != FR_OK) { return SDCARD_ERROR(result); } - tmp = strAppend(path, destDir, CLIPBOARD_PATH_LEN); - *tmp++ = '/'; - strAppend(tmp, filename, CLIPBOARD_PATH_LEN); - - result = f_open(&dstFile, path, FA_CREATE_ALWAYS | FA_WRITE); + result = f_open(&destFile, destPath, FA_CREATE_ALWAYS | FA_WRITE); if (result != FR_OK) { f_close(&srcFile); return SDCARD_ERROR(result); @@ -220,11 +293,11 @@ const char *fileCopy(const char *filename, const char *srcDir, const char *destD while (result==FR_OK && read==sizeof(buf) && written==sizeof(buf)) { result = f_read(&srcFile, buf, sizeof(buf), &read); if (result == FR_OK) { - result = f_write(&dstFile, buf, read, &written); + result = f_write(&destFile, buf, read, &written); } } - f_close(&dstFile); + f_close(&destFile); f_close(&srcFile); if (result != FR_OK) { @@ -233,7 +306,22 @@ const char *fileCopy(const char *filename, const char *srcDir, const char *destD return NULL; } -#endif // #if defined(PCBTARANIS) + +const char * sdCopyFile(const char * srcFilename, const char * srcDir, const char * destFilename, const char * destDir) +{ + char srcPath[2*CLIPBOARD_PATH_LEN+1]; + char * tmp = strAppend(srcPath, srcDir, CLIPBOARD_PATH_LEN); + *tmp++ = '/'; + strAppend(tmp, srcFilename, CLIPBOARD_PATH_LEN); + + char destPath[2*CLIPBOARD_PATH_LEN+1]; + tmp = strAppend(destPath, destDir, CLIPBOARD_PATH_LEN); + *tmp++ = '/'; + strAppend(tmp, destFilename, CLIPBOARD_PATH_LEN); + + return sdCopyFile(srcPath, destPath); +} +#endif // defined(CPUARM) && defined(SDCARD) #if !defined(SIMU) || defined(SIMU_DISKIO) diff --git a/radio/src/sdcard.h b/radio/src/sdcard.h index 5f269d7ec..cc21ebf40 100644 --- a/radio/src/sdcard.h +++ b/radio/src/sdcard.h @@ -41,6 +41,7 @@ #define ROOT_PATH "/" #define MODELS_PATH ROOT_PATH "MODELS" // no trailing slash = important +#define RADIO_PATH ROOT_PATH "RADIO" // no trailing slash = important #define LOGS_PATH ROOT_PATH "LOGS" #define SCREENSHOTS_PATH ROOT_PATH "SCREENSHOTS" #define SOUNDS_PATH ROOT_PATH "SOUNDS/en" @@ -79,9 +80,10 @@ void writeLogs(); uint32_t sdGetNoSectors(); uint32_t sdGetSize(); uint32_t sdGetFreeSectors(); +const char * sdCheckAndCreateDirectory(const char * path); #if !defined(BOOT) -inline const pm_char *SDCARD_ERROR(FRESULT result) +inline const pm_char * SDCARD_ERROR(FRESULT result) { if (result == FR_NOT_READY) return STR_NO_SDCARD; @@ -98,7 +100,11 @@ inline const pm_char *SDCARD_ERROR(FRESULT result) #define O9X_FOURCC 0x3178396F // o9x for gruvin9x/MEGA2560 #endif -const char *fileCopy(const char *filename, const char *srcDir, const char *destDir); +bool isFileAvailable(const char * filename); +bool 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); #endif diff --git a/radio/src/serial.cpp b/radio/src/serial.cpp index e64e0ec6d..1baf5bb75 100644 --- a/radio/src/serial.cpp +++ b/radio/src/serial.cpp @@ -39,7 +39,7 @@ #include #include -#define PRINTF_BUFFER_SIZE 256 +#define PRINTF_BUFFER_SIZE 128 void serialPutc(char c) { @@ -53,10 +53,11 @@ void serialPutc(char c) void serialPrintf(const char * format, ...) { va_list arglist; - char tmp[PRINTF_BUFFER_SIZE]; + char tmp[PRINTF_BUFFER_SIZE+1]; va_start(arglist, format); vsnprintf(tmp, PRINTF_BUFFER_SIZE, format, arglist); + tmp[PRINTF_BUFFER_SIZE] = '\0'; va_end(arglist); const char *t = tmp; diff --git a/radio/src/simu.cpp b/radio/src/simu.cpp index e8b9a2bf8..04e4847c8 100644 --- a/radio/src/simu.cpp +++ b/radio/src/simu.cpp @@ -63,8 +63,10 @@ class Open9xSim: public FXMainWindow Open9xSim(){}; Open9xSim(FXApp* a); ~Open9xSim(); + void updateKeysAndSwitches(bool start=false); long onKeypress(FXObject*,FXSelector,void*); long onTimeout(FXObject*,FXSelector,void*); + void createBitmap(int index, uint16_t *data, int x, int y, int w, int h); void makeSnapshot(const FXDrawable* drawable); void doEvents(); void refreshDisplay(); @@ -93,7 +95,7 @@ Open9xSim::Open9xSim(FXApp* a): FXMainWindow(a, "OpenTX Simu", NULL, NULL, DECOR_ALL, 20, 90, 0, 0) { firstTime = true; - memset(displayBuf, 0, DISPLAY_BUFER_SIZE); + memset(displayBuf, 0, DISPLAY_BUFFER_SIZE); bmp = new FXPPMImage(getApp(),NULL,IMAGE_OWNED|IMAGE_KEEP|IMAGE_SHMI|IMAGE_SHMP, W2, H2); #if defined(SIMU_AUDIO) @@ -137,7 +139,9 @@ Open9xSim::Open9xSim(FXApp* a): bmf = new FXImageFrame(this,bmp); - getApp()->addTimeout(this,2,100); + updateKeysAndSwitches(true); + + getApp()->addTimeout(this, 2, 100); } Open9xSim::~Open9xSim() @@ -163,6 +167,31 @@ Open9xSim::~Open9xSim() #endif } +void Open9xSim::createBitmap(int index, uint16_t *data, int x, int y, int w, int h) +{ + FXPNGImage snapshot(getApp(), NULL, IMAGE_OWNED, w, h); + + for (int i=0; i>8)/0x0f, 255*((z&0x0F0)>>4)/0x0f, 255*(z&0x00F)/0x0f); + snapshot.setPixel(i, j, color); + } + } + + FXFileStream stream; + char buf[32]; + sprintf(buf,"%02d.png", index); + if (stream.open(buf, FXStreamSave)) { + snapshot.savePixels(stream); + stream.close(); + TRACE("Bitmap %d (w=%d, h=%d) created", index, w, h); + } + else { + TRACE("Bitmap %d (w=%d, h=%d) error", index, w, h); + } +} + void Open9xSim::makeSnapshot(const FXDrawable* drawable) { // Construct and create an FXImage object @@ -215,30 +244,120 @@ long Open9xSim::onKeypress(FXObject*,FXSelector,void*v) return 0; } +void Open9xSim::updateKeysAndSwitches(bool start) +{ + static int keys1[] = { +#if defined(PCBHORUS) + KEY_Page_Up, KEY_MENU, + KEY_Return, KEY_ENTER, + KEY_BackSpace, KEY_EXIT, + KEY_Up, KEY_UP, + KEY_Down, KEY_DOWN, + KEY_Right, KEY_RIGHT, + KEY_Left, KEY_LEFT, +#elif defined(PCBTARANIS) || defined(PCBFLAMENCO) + KEY_Page_Up, KEY_MENU, + KEY_Page_Down, KEY_PAGE, + KEY_Return, KEY_ENTER, + KEY_BackSpace, KEY_EXIT, + KEY_Up, KEY_PLUS, + KEY_Down, KEY_MINUS, +#else + KEY_Return, KEY_MENU, + KEY_BackSpace, KEY_EXIT, + KEY_Right, KEY_RIGHT, + KEY_Left, KEY_LEFT, + KEY_Up, KEY_UP, + KEY_Down, KEY_DOWN, +#if defined(ROTARY_ENCODER_NAVIGATION) + KEY_F, BTN_REa, +#endif +#endif + }; + + for (unsigned int i=0; igetKeyState(keys1[i])); + } + +#ifdef __APPLE__ + // gruvin: Can't use Function keys on the Mac -- too many other app conflicts. + // The ordering of these keys, Q/W,E/R,T/Y,U/I matches the on screen + // order of trim sliders + static FXuint trimKeys[] = { KEY_E, KEY_R, KEY_U, KEY_I, KEY_R, KEY_E, KEY_Y, KEY_T, KEY_Q, KEY_W }; +#else + static FXuint trimKeys[] = { KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8 }; +#endif + + for (unsigned i=0; igetKeyState(trimKeys[i])); + } + +#define SWITCH_KEY(key, swtch, states) \ + static bool state##key = 0; \ + static int8_t state_##swtch = 2; \ + static int8_t inc_##swtch = 1; \ + if (getApp()->getKeyState(KEY_##key)) { \ + if (!state##key) { \ + state_##swtch = (state_##swtch+inc_##swtch); \ + if (state_##swtch == 1+states) inc_##swtch = -1; \ + else if (state_##swtch == 2) inc_##swtch = 1; \ + state##key = true; \ + } \ + } \ + else { \ + state##key = false; \ + } \ + simuSetSwitch(swtch, state_##swtch-states); + +#if defined(PCBFLAMENCO) + SWITCH_KEY(A, 0, 3); + SWITCH_KEY(B, 1, 2); + // SWITCH_KEY(C, 2, 3); + // SWITCH_KEY(D, 3, 3); + SWITCH_KEY(E, 4, 2); + SWITCH_KEY(F, 5, 3); +#elif defined(PCBTARANIS) && defined(REV9E) + SWITCH_KEY(A, 0, 3); + SWITCH_KEY(B, 1, 3); + SWITCH_KEY(C, 2, 3); + SWITCH_KEY(D, 3, 3); + SWITCH_KEY(E, 4, 3); + SWITCH_KEY(F, 5, 3); + SWITCH_KEY(G, 6, 3); + SWITCH_KEY(H, 7, 3); + SWITCH_KEY(I, 8, 3); + SWITCH_KEY(J, 9, 3); + SWITCH_KEY(K, 10, 3); + SWITCH_KEY(L, 11, 3); + SWITCH_KEY(M, 12, 3); + SWITCH_KEY(N, 13, 3); + SWITCH_KEY(O, 14, 3); + SWITCH_KEY(P, 15, 3); + SWITCH_KEY(Q, 16, 3); + SWITCH_KEY(R, 17, 3); +#elif defined(PCBTARANIS) + SWITCH_KEY(A, 0, 3); + SWITCH_KEY(B, 1, 3); + SWITCH_KEY(C, 2, 3); + SWITCH_KEY(D, 3, 3); + SWITCH_KEY(E, 4, 3); + SWITCH_KEY(F, 5, 2); + SWITCH_KEY(G, 6, 3); + SWITCH_KEY(H, 7, 2); +#else + SWITCH_KEY(1, 0, 2); + SWITCH_KEY(2, 1, 2); + SWITCH_KEY(3, 2, 2); + SWITCH_KEY(4, 3, 3); + SWITCH_KEY(5, 4, 2); + SWITCH_KEY(6, 5, 2); + SWITCH_KEY(7, 6, 2); +#endif +} + long Open9xSim::onTimeout(FXObject*, FXSelector, void*) { - if(hasFocus()) { - static int keys1[]={ -#if defined(PCBTARANIS) - KEY_Page_Up, KEY_MENU, - KEY_Page_Down, KEY_PAGE, - KEY_Return, KEY_ENTER, - KEY_BackSpace, KEY_EXIT, - KEY_Up, KEY_PLUS, - KEY_Down, KEY_MINUS, -#else - KEY_Return, KEY_MENU, - KEY_BackSpace, KEY_EXIT, - KEY_Right, KEY_RIGHT, - KEY_Left, KEY_LEFT, - KEY_Up, KEY_UP, - KEY_Down, KEY_DOWN, -#endif -#if defined(ROTARY_ENCODER_NAVIGATION) - KEY_F, BTN_REa, -#endif - }; - + if (hasFocus()) { #if defined(PCBSKY9X) && !defined(REVX) Coproc_temp = 23; Coproc_maxtemp = 28; @@ -249,31 +368,23 @@ long Open9xSim::onTimeout(FXObject*, FXSelector, void*) maxTemperature = 42; #endif - for (unsigned int i=0; igetKeyState(keys1[i])); - } + updateKeysAndSwitches(); -#ifdef __APPLE__ - // gruvin: Can't use Function keys on the Mac -- too many other app conflicts. - // The ordering of these keys, Q/W,E/R,T/Y,U/I matches the on screen - // order of trim sliders - static FXuint trimKeys[] = { KEY_E, KEY_R, KEY_U, KEY_I, KEY_R, KEY_E, KEY_Y, KEY_T, KEY_Q, KEY_W }; +#if defined(PCBHORUS) + extern rotenc_t rotencValue; + #define ROTENC_VALUE rotencValue #else - static FXuint trimKeys[] = { KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8 }; + #define ROTENC_VALUE g_rotenc[0] #endif - - for (unsigned i=0; igetKeyState(trimKeys[i])); - } - -#if defined(ROTARY_ENCODER_NAVIGATION) + +#if defined(ROTARY_ENCODER_NAVIGATION) || defined(PCBHORUS) static bool rotencAction = false; if (getApp()->getKeyState(KEY_G)) { - if (!rotencAction) g_rotenc[0] += ROTARY_ENCODER_GRANULARITY; + if (!rotencAction) ROTENC_VALUE += ROTARY_ENCODER_GRANULARITY; rotencAction = true; } else if (getApp()->getKeyState(KEY_D)) { - if (!rotencAction) g_rotenc[0] -= ROTARY_ENCODER_GRANULARITY; + if (!rotencAction) ROTENC_VALUE -= ROTARY_ENCODER_GRANULARITY; rotencAction = true; } else { @@ -281,24 +392,6 @@ long Open9xSim::onTimeout(FXObject*, FXSelector, void*) } #endif -#define SWITCH_KEY(key, swtch, states) \ - static bool state##key = 0; \ - static int8_t state_##swtch = 2; \ - static int8_t inc_##swtch = 1; \ - if (getApp()->getKeyState(KEY_##key)) { \ - if (!state##key) { \ - state_##swtch = (state_##swtch+inc_##swtch); \ - if (state_##swtch >= 1+states) inc_##swtch = -1; \ - else if (state_##swtch <= 2) inc_##swtch = 1; \ - /* TRACE("switch " #swtch ": state: %d, inc: %d", state_##swtch, inc_##swtch); */ \ - state##key = true; \ - } \ - } \ - else { \ - state##key = false; \ - } \ - simuSetSwitch(swtch, state_##swtch-states); - #if defined(PCBTARANIS) && defined(REV9E) SWITCH_KEY(A, 0, 3); SWITCH_KEY(B, 1, 3); @@ -337,7 +430,7 @@ long Open9xSim::onTimeout(FXObject*, FXSelector, void*) SWITCH_KEY(7, 6, 2); #endif } - + per10ms(); refreshDisplay(); getApp()->addTimeout(this, 2, 10); @@ -361,16 +454,28 @@ void Open9xSim::setPixel(int x, int y, FXColor color) void Open9xSim::refreshDisplay() { - if (lcd_refresh) { - lcd_refresh = false; + if (simuLcdRefresh) { + simuLcdRefresh = false; FXColor offColor = isBacklightEnable() ? BL_COLOR : FXRGB(200, 200, 200); #if LCD_W == 128 FXColor onColor = FXRGB(0, 0, 0); #endif for (int x=0; x>11)/0x1f, 255*((z&0x07E0)>>5)/0x3F, 255*(z&0x001F)/0x01F); + setPixel(x, y, color); + } +#elif defined(PCBFLAMENCO) + display_t z = simuLcdBuf[y * LCD_W + x]; + if (1) { + FXColor color = FXRGB(255*((z&0xF00)>>8)/0x0f, 255*((z&0x0F0)>>4)/0x0f, 255*(z&0x00F)/0x0f); + setPixel(x, y, color); + } +#elif defined(PCBTARANIS) + display_t * p = &simuLcdBuf[y / 2 * LCD_W + x]; uint8_t z = (y & 1) ? (*p >> 4) : (*p & 0x0F); if (z) { FXColor color; @@ -381,7 +486,7 @@ void Open9xSim::refreshDisplay() setPixel(x, y, color); } #else - if (lcd_buf[x+(y/8)*LCD_W] & (1<<(y%8))) { + if (simuLcdBuf[x+(y/8)*LCD_W] & (1<<(y%8))) { setPixel(x, y, onColor); } #endif @@ -459,7 +564,7 @@ uint16_t anaIn(uint8_t chan) return th9xSim->sliders[chan]->getValue(); else if (chanknobs[chan-NUM_STICKS]->getValue(); -#if defined(PCBTARANIS) +#if defined(PCBTARANIS) || defined(PCBFLAMENCO) else if (chan == TX_VOLTAGE) return 1000; #elif defined(PCBSKY9X) @@ -477,3 +582,8 @@ uint16_t anaIn(uint8_t chan) else return 0; } + +void createBitmap(int index, uint16_t *data, int x, int y, int w, int h) +{ + th9xSim->createBitmap(index, data, x, y, w, h); +} diff --git a/radio/src/stamp.cpp b/radio/src/stamp.cpp index a99d289c0..ab235b38b 100644 --- a/radio/src/stamp.cpp +++ b/radio/src/stamp.cpp @@ -46,11 +46,17 @@ #define EEPROM_STR DEFNUMSTR(EEPROM_VER); #endif +#if defined(PCBHORUS) +#define TAB "\037\075" +#elif defined(PCBFLAMENCO) +#define TAB "\037\050" +#endif + #if defined(COLORLCD) - const pm_char vers_stamp[] PROGMEM = "VERS\037\050: " "opentx-" FLAVOUR "-" VERS_STR; - const pm_char date_stamp[] PROGMEM = "DATE\037\050: " DATE_STR; - const pm_char time_stamp[] PROGMEM = "TIME\037\050: " TIME_STR; - const pm_char eeprom_stamp[] PROGMEM = "EEPR\037\050: " EEPROM_STR; + const pm_char vers_stamp[] PROGMEM = "VERS" TAB ": " "opentx-" FLAVOUR "-" VERS_STR; + const pm_char date_stamp[] PROGMEM = "DATE" TAB ": " DATE_STR; + const pm_char time_stamp[] PROGMEM = "TIME" TAB ": " TIME_STR; + const pm_char eeprom_stamp[] PROGMEM = "EEPR" TAB ": " EEPROM_STR; #else const pm_char vers_stamp[] PROGMEM = "FW\037\033: " "opentx-" FLAVOUR "\036VERS\037\033: " VERS_STR "\036DATE\037\033: " DATE_STR"\036TIME\037\033: " TIME_STR "\036EEPR\037\033: " EEPROM_STR; #endif diff --git a/radio/src/eeprom_common.cpp b/radio/src/storage/eeprom_common.cpp similarity index 68% rename from radio/src/eeprom_common.cpp rename to radio/src/storage/eeprom_common.cpp index bb5049dcf..d9dc71774 100644 --- a/radio/src/eeprom_common.cpp +++ b/radio/src/storage/eeprom_common.cpp @@ -40,13 +40,35 @@ #include "opentx.h" #include "timers.h" -uint8_t s_eeDirtyMsk; -tmr10ms_t s_eeDirtyTime10ms; - -void eeDirty(uint8_t msk) +void eeLoadModel(uint8_t index) { - s_eeDirtyMsk |= msk; - s_eeDirtyTime10ms = get_tmr10ms() ; + if (index < MAX_MODELS) { + + preModelLoad(); + + uint16_t size = eeLoadModelData(index); + +#if defined(SIMU) && defined(EEPROM_ZONE_SIZE) + if (sizeof(uint16_t) + sizeof(g_model) > EEPROM_ZONE_SIZE) { + TRACE("Model data size can't exceed %d bytes (%d bytes)", int(EEPROM_ZONE_SIZE-sizeof(uint16_t)), (int)sizeof(g_model)); + } +#endif + +#if defined(SIMU) + if (size > 0 && size != sizeof(g_model)) { + TRACE("Model data read=%d bytes vs %d bytes\n", size, (int)sizeof(ModelData)); + } +#endif + + bool newModel = false; + if (size < EEPROM_MIN_MODEL_SIZE) { // if not loaded a fair amount + modelDefault(index) ; + storageCheck(true); + newModel = true; + } + + postModelLoad(newModel); + } } uint8_t eeFindEmptyModel(uint8_t id, bool down) @@ -66,9 +88,9 @@ void selectModel(uint8_t sub) displayPopup(STR_LOADINGMODEL); #endif saveTimers(); - eeCheck(true); // force writing of current model data before this is changed + storageCheck(true); // force writing of current model data before this is changed g_eeGeneral.currModel = sub; - eeDirty(EE_GENERAL); + storageDirty(EE_GENERAL); eeLoadModel(sub); } @@ -82,10 +104,10 @@ void eeLoadModelHeaders() } #endif -void eeReadAll() +void storageReadAll() { if (!eepromOpen() || !eeLoadGeneral()) { - eeErase(true); + storageEraseAll(true); } else { eeLoadModelHeaders(); @@ -102,7 +124,5 @@ void eeReadAll() } #endif -#if !defined(CPUARM) eeLoadModel(g_eeGeneral.currModel); -#endif } diff --git a/radio/src/eeprom_common.h b/radio/src/storage/eeprom_common.h similarity index 70% rename from radio/src/eeprom_common.h rename to radio/src/storage/eeprom_common.h index a54e6a9c8..81690d4a4 100644 --- a/radio/src/eeprom_common.h +++ b/radio/src/storage/eeprom_common.h @@ -34,30 +34,14 @@ * */ -#if defined(SIMU) - #define WRITE_DELAY_10MS 200 -#elif defined(PCBTARANIS) - #define WRITE_DELAY_10MS 500 -#elif defined(PCBSKY9X) && !defined(REV0) - #define WRITE_DELAY_10MS 500 -#elif defined(PCBGRUVIN9X) && !defined(REV0) - #define WRITE_DELAY_10MS 500 -#else - #define WRITE_DELAY_10MS 200 -#endif +#define EEPROM_MIN_MODEL_SIZE 256 -#define TIME_TO_WRITE() (s_eeDirtyMsk && (tmr10ms_t)(get_tmr10ms() - s_eeDirtyTime10ms) >= (tmr10ms_t)WRITE_DELAY_10MS) +uint16_t eeLoadModelData(uint8_t id); +uint16_t eeLoadGeneralSettingsData(); -extern uint8_t s_eeDirtyMsk; -extern tmr10ms_t s_eeDirtyTime10ms; - -void eeDirty(uint8_t msk); -void eeCheck(bool immediately); -void eeReadAll(); bool eeModelExists(uint8_t id); void eeLoadModel(uint8_t id); bool eeConvert(); -void eeErase(bool warn); void ConvertModel(int id, int version); uint8_t eeFindEmptyModel(uint8_t id, bool down); void selectModel(uint8_t sub); diff --git a/radio/src/eeprom_conversions.cpp b/radio/src/storage/eeprom_conversions.cpp similarity index 95% rename from radio/src/eeprom_conversions.cpp rename to radio/src/storage/eeprom_conversions.cpp index 5d7fafbc6..5ad37e5c1 100644 --- a/radio/src/eeprom_conversions.cpp +++ b/radio/src/storage/eeprom_conversions.cpp @@ -747,7 +747,7 @@ PACK(typedef struct { TelemetrySensor telemetrySensors[MAX_SENSORS]; - TARANIS_REV9E_FIELD(uint8_t topLcdTimer) + TARANIS_REV9E_FIELD(uint8_t toplcdTimer) }) ModelData_v217; #if defined(PCBTARANIS) @@ -1356,13 +1356,13 @@ void ConvertModel_217_to_218(ModelData & model) newModel.telemetrySensors[i] = oldModel.telemetrySensors[i]; } #if defined(PCBTARANIS) && defined(REV9E) - newModel.topLcdTimer = oldModel.topLcdTimer; + newModel.toplcdTimer = oldModel.toplcdTimer; #endif } void ConvertModel(int id, int version) { - loadModel(id); + eeLoadModelData(id); if (version == 216) { version = 217; @@ -1375,8 +1375,8 @@ void ConvertModel(int id, int version) uint8_t currModel = g_eeGeneral.currModel; g_eeGeneral.currModel = id; - s_eeDirtyMsk = EE_MODEL; - eeCheck(true); + storageDirty(EE_MODEL); + storageCheck(true); g_eeGeneral.currModel = currModel; } @@ -1401,13 +1401,13 @@ bool eeConvert() g_eeGeneral.backlightMode = e_backlight_mode_on; g_eeGeneral.backlightBright = 0; g_eeGeneral.contrast = 25; - ALERT(STR_EEPROMWARN, msg, AU_BAD_EEPROM); + ALERT(STR_STORAGE_WARNING, msg, AU_BAD_RADIODATA); // Message - MESSAGE(STR_EEPROMWARN, STR_EEPROM_CONVERTING, NULL, AU_EEPROM_FORMATTING); // TODO translations + MESSAGE(STR_STORAGE_WARNING, STR_EEPROM_CONVERTING, NULL, AU_STORAGE_FORMAT); // TODO translations // General Settings conversion - loadGeneralSettings(); + eeLoadGeneralSettingsData(); int version = conversionVersionStart; if (version == 215) { version = 216; @@ -1421,14 +1421,14 @@ bool eeConvert() version = 218; ConvertGeneralSettings_217_to_218(g_eeGeneral); } - s_eeDirtyMsk = EE_GENERAL; - eeCheck(true); + storageDirty(EE_GENERAL); + storageCheck(true); #if defined(COLORLCD) #elif LCD_W >= 212 - lcd_rect(60, 6*FH+4, 132, 3); + lcdDrawRect(60, 6*FH+4, 132, 3); #else - lcd_rect(10, 6*FH+4, 102, 3); + lcdDrawRect(10, 6*FH+4, 102, 3); #endif // Models conversion diff --git a/radio/src/eeprom_raw.cpp b/radio/src/storage/eeprom_raw.cpp similarity index 85% rename from radio/src/eeprom_raw.cpp rename to radio/src/storage/eeprom_raw.cpp index d97787f52..022c07cdd 100644 --- a/radio/src/eeprom_raw.cpp +++ b/radio/src/storage/eeprom_raw.cpp @@ -69,15 +69,15 @@ PACK(struct EepromFileHeader uint16_t size; }); -EepromHeader eepromHeader; -EepromWriteState eepromWriteState = EEPROM_IDLE; +EepromHeader eepromHeader __DMA; +volatile EepromWriteState eepromWriteState = EEPROM_IDLE; uint8_t eepromWriteZoneIndex = FIRST_FILE_AVAILABLE; uint8_t eepromWriteFileIndex; uint16_t eepromWriteSize; uint8_t * eepromWriteSourceAddr; uint32_t eepromWriteDestinationAddr; uint16_t eepromFatAddr = 0; -uint8_t eepromWriteBuffer[EEPROM_BUFFER_SIZE]; +uint8_t eepromWriteBuffer[EEPROM_BUFFER_SIZE] __DMA; void eepromWaitSpiComplete() { @@ -238,7 +238,7 @@ void writeFile(int index, uint8_t * data, uint32_t size) void eeDeleteModel(uint8_t index) { - eeCheck(true); + storageCheck(true); memclear(&modelHeaders[index], sizeof(ModelHeader)); writeFile(index+1, (uint8_t *)&g_model, 0); eepromWriteWait(); @@ -246,7 +246,7 @@ void eeDeleteModel(uint8_t index) bool eeCopyModel(uint8_t dst, uint8_t src) { - eeCheck(true); + storageCheck(true); uint32_t eepromWriteSourceAddr = eepromHeader.files[src+1].zoneIndex * EEPROM_ZONE_SIZE; uint32_t eepromWriteDestinationAddr = eepromHeader.files[dst+1].zoneIndex * EEPROM_ZONE_SIZE; @@ -274,7 +274,7 @@ bool eeCopyModel(uint8_t dst, uint8_t src) void eeSwapModels(uint8_t id1, uint8_t id2) { - eeCheck(true); + storageCheck(true); { EepromHeaderFile tmp = eepromHeader.files[id1+1]; eepromHeader.files[id1+1] = eepromHeader.files[id2+1]; @@ -292,12 +292,12 @@ void eeSwapModels(uint8_t id1, uint8_t id2) } // For conversions ... -uint32_t loadGeneralSettings() +uint16_t eeLoadGeneralSettingsData() { return readFile(0, (uint8_t *)&g_eeGeneral, sizeof(g_eeGeneral)); } -uint32_t loadModel(uint32_t index) +uint16_t eeLoadModelData(uint8_t index) { return readFile(index+1, (uint8_t *)&g_model, sizeof(g_model)); } @@ -314,7 +314,7 @@ void writeModel(int index) bool eeLoadGeneral() { - loadGeneralSettings(); + eeLoadGeneralSettingsData(); if (g_eeGeneral.version != EEPROM_VER) { TRACE("EEPROM version %d instead of %d", g_eeGeneral.version, EEPROM_VER); @@ -329,75 +329,6 @@ bool eeLoadGeneral() return true; } -void eeLoadModel(uint8_t id) -{ - if (id EEPROM_ZONE_SIZE) - TRACE("Model data size can't exceed %d bytes (%d bytes)", int(EEPROM_ZONE_SIZE-sizeof(uint16_t)), (int)sizeof(g_model)); - if (size > 0 && size != sizeof(g_model)) - TRACE("Model data read=%d bytes vs %d bytes\n", size, (int)sizeof(ModelData)); -#endif - - if (size < EEPROM_BUFFER_SIZE) { // if not loaded a fair amount - modelDefault(id) ; - eeCheck(true); - } - - AUDIO_FLUSH(); - flightReset(); - logicalSwitchesReset(); - - if (pulsesStarted()) { - checkAll(); - resumePulses(); - } - - customFunctionsReset(); - - restoreTimers(); - -#if defined(CPUARM) - for (int i=0; i 0 && sz != sizeof(g_model)) { - printf("Model data read=%d bytes vs %d bytes\n", sz, (int)sizeof(ModelData)); - } -#endif - - bool newModel = false; - - if (sz < 256) { - modelDefault(id); - eeCheck(true); - newModel = true; - } - - AUDIO_FLUSH(); - flightReset(); - logicalSwitchesReset(); - - if (pulsesStarted()) { -#if defined(GUI) - if (!newModel) { - checkAll(); - } -#endif - resumePulses(); - } - - customFunctionsReset(); - - restoreTimers(); - -#if defined(CPUARM) - for (int i=0; i +#ifndef _EEPROM_RLC_H_ +#define _EEPROM_RLC_H_ // TODO duplicated #ifndef PACK @@ -116,7 +114,6 @@ extern EeFs eeFs; #define BLOCKS_OFFSET (RESV-BS) #endif -void eepromFormat(); uint16_t EeFsGetFree(); #if !defined(CPUARM) @@ -211,7 +208,7 @@ class RlcFile: public EFile uint16_t readRlc(uint8_t *buf, uint16_t i_len); #if defined (EEPROM_PROGRESS_BAR) - void DisplayProgressBar(uint8_t x); + void drawProgressBar(uint8_t x); #endif }; @@ -233,7 +230,7 @@ inline void eepromWriteProcess() } #if defined (EEPROM_PROGRESS_BAR) -#define DISPLAY_PROGRESS_BAR(x) theFile.DisplayProgressBar(x) +#define DISPLAY_PROGRESS_BAR(x) theFile.drawProgressBar(x) #else #define DISPLAY_PROGRESS_BAR(x) #endif diff --git a/radio/src/storage/sdcard_raw.cpp b/radio/src/storage/sdcard_raw.cpp new file mode 100644 index 000000000..9d79ffc45 --- /dev/null +++ b/radio/src/storage/sdcard_raw.cpp @@ -0,0 +1,416 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../opentx.h" + +const char * writeFile(const char * filename, const uint8_t * data, uint16_t size) +{ + FIL file; + char buf[8]; + UINT written; + + FRESULT result = f_open(&file, filename, FA_CREATE_ALWAYS | FA_WRITE); + if (result != FR_OK) { + return SDCARD_ERROR(result); + } + + *(uint32_t*)&buf[0] = O9X_FOURCC; + buf[4] = EEPROM_VER; + buf[5] = 'M'; + *(uint16_t*)&buf[6] = size; + + result = f_write(&file, buf, 8, &written); + if (result != FR_OK || written != 8) { + f_close(&file); + return SDCARD_ERROR(result); + } + + result = f_write(&file, data, size, &written); + if (result != FR_OK || written != size) { + f_close(&file); + return SDCARD_ERROR(result); + } + + f_close(&file); + return NULL; +} + +const char * writeModel() +{ + char path[256]; + strcpy(path, STR_MODELS_PATH); + path[sizeof(MODELS_PATH)-1] = '/'; + strAppend(&path[sizeof(MODELS_PATH)], g_eeGeneral.currModelFilename, sizeof(g_eeGeneral.currModelFilename)); + return writeFile(path, (uint8_t *)&g_model, sizeof(g_model)); +} + +const char * loadFile(const char * filename, uint8_t * data, uint16_t maxsize) +{ + FIL file; + char buf[8]; + UINT read; + + FRESULT result = f_open(&file, filename, FA_OPEN_EXISTING | FA_READ); + if (result != FR_OK) { + return SDCARD_ERROR(result); + } + + if (f_size(&file) < 8) { + f_close(&file); + return STR_INCOMPATIBLE; + } + + result = f_read(&file, (uint8_t *)buf, 8, &read); + if (result != FR_OK || read != 8) { + f_close(&file); + return SDCARD_ERROR(result); + } + + uint8_t version = (uint8_t)buf[4]; + if (*(uint32_t*)&buf[0] != O9X_FOURCC || version < FIRST_CONV_EEPROM_VER || version > EEPROM_VER || buf[5] != 'M') { + f_close(&file); + return STR_INCOMPATIBLE; + } + + uint16_t size = min(maxsize, *(uint16_t*)&buf[6]); + result = f_read(&file, data, size, &read); + if (result != FR_OK || read != size) { + f_close(&file); + return SDCARD_ERROR(result); + } + + f_close(&file); + return NULL; +} + +void getModelPath(char * path, const char * filename) +{ + strcpy(path, STR_MODELS_PATH); + path[sizeof(MODELS_PATH)-1] = '/'; + strcpy(&path[sizeof(MODELS_PATH)], filename); +} + +const char * readModel(const char * filename, uint8_t * buffer, uint32_t size) +{ + char path[256]; + getModelPath(path, filename); + return loadFile(path, buffer, size); +} + +const char * loadModel(const char * filename) +{ + preModelLoad(); + + const char * error = readModel(filename, (uint8_t *)&g_model, sizeof(g_model)); + if (error) { + TRACE("loadModel error=%s", error); + } + + bool newModel = false; + if (error) { + modelDefault(0) ; + storageCheck(true); + newModel = true; + } + + postModelLoad(newModel); + + return error; +} + +const char RADIO_SETTINGS_PATH[] = RADIO_PATH "/radio.bin"; +const char RADIO_MODELSLIST_PATH[] = RADIO_PATH "/models.txt"; + +const char * loadGeneralSettings() +{ + const char * error = loadFile(RADIO_SETTINGS_PATH, (uint8_t *)&g_eeGeneral, sizeof(g_eeGeneral)); + if (error) { + TRACE("loadGeneralSettings error=%s", error); + } + // TODO this is temporary, we only have one model for now + return error; +} + +const char * writeGeneralSettings() +{ + return writeFile(RADIO_SETTINGS_PATH, (uint8_t *)&g_eeGeneral, sizeof(g_eeGeneral)); +} + +void storageCheck(bool immediately) +{ + // if (immediately) { + // eepromWriteWait(); + // } + + if (storageDirtyMsk & EE_GENERAL) { + TRACE("eeprom write general"); + storageDirtyMsk -= EE_GENERAL; + writeGeneralSettings(); + // if (immediately) + // eepromWriteWait(); + // else + return; + } + + if (storageDirtyMsk & EE_MODEL) { + TRACE("eeprom write model"); + storageDirtyMsk -= EE_MODEL; + const char * error = writeModel(); + if (error) { + TRACE("writeModel error=%s", error); + } + // if (immediately) + // eepromWriteWait(); + } +} + +void storageReadAll() +{ + sdInit(); + + if (loadGeneralSettings() != NULL) { + storageEraseAll(true); + } + + stickMode = g_eeGeneral.stickMode; + +#if defined(CPUARM) + for (uint8_t i=0; languagePacks[i]!=NULL; i++) { + if (!strncmp(g_eeGeneral.ttsLanguage, languagePacks[i]->id, 2)) { + currentLanguagePackIdx = i; + currentLanguagePack = languagePacks[i]; + } + } +#endif + + loadModel(g_eeGeneral.currModelFilename); +} + +void storageCreateModelsList() +{ + FIL file; + + FRESULT result = f_open(&file, RADIO_MODELSLIST_PATH, FA_CREATE_ALWAYS | FA_WRITE); + if (result == FR_OK) { + f_puts("[" DEFAULT_CATEGORY "]\n" DEFAULT_MODEL_FILENAME "\n", &file); + f_close(&file); + } +} + +void storageFormat() +{ + sdCheckAndCreateDirectory(RADIO_PATH); + sdCheckAndCreateDirectory(MODELS_PATH); + storageCreateModelsList(); +} + +struct StorageModelsList { + FIL file; +}; + +const char * storageOpenModelsList(StorageModelsList * storage) +{ + FRESULT result = f_open(&storage->file, RADIO_MODELSLIST_PATH, FA_OPEN_EXISTING | FA_READ); + if (result != FR_OK) { + return SDCARD_ERROR(result); + } + return NULL; +} + +bool storageReadNextLine(StorageModelsList * storage, char * line, int maxlen) +{ + char c; + unsigned int read; + int len=0; + while (1) { + FRESULT result = f_read(&storage->file, (uint8_t *)&c, 1, &read); + if (result != FR_OK || read != 1) { + line[len] = '\0'; + return false; + } + if (c == '\n') { + if (len > 0) { + // we skip empty lines + line[len] = '\0'; + return true; + } + } + else if (c != '\r' && len < maxlen) { + line[len++] = c; + } + } +} + +int storageGetCategoryLength(const char * line) +{ + int len = strlen(line); + if (len > 2 && line[0] == '[' && line[len-1] == ']') { + return len-2; + } + else { + return 0; + } +} + +bool storageReadNextCategory(StorageModelsList * storage, char * line, int maxlen) +{ + bool result = true; + while (result) { + result = storageReadNextLine(storage, line, maxlen); + int len = storageGetCategoryLength(line); + if (len > 0) { + memmove(line, &line[1], len); + line[len] = '\0'; + return result; + } + } + line[0] = '\0'; + return false; +} + +bool storageSeekCategory(StorageModelsList * storage, int category) +{ + f_lseek(&storage->file, 0); + char line[256] = ""; + int result = true; + for (int i=0; result && i<=category; i++) { + result = storageReadNextCategory(storage, line, sizeof(line)-1); + } + return line[0] != '\0'; +} + +bool storageReadNextModel(StorageModelsList * storage, char * line, int maxlen) +{ + bool result = true; + while (result) { + result = storageReadNextLine(storage, line, maxlen); + if (line[0] == '[') + return false; + else if (line[0] != '\0') + return result; + } + line[0] = '\0'; + return false; +} + +#define STORAGE_INSERT 1 +#define STORAGE_REMOVE 2 +#define STORAGE_RENAME 3 + +const char * storageModifyModel(unsigned int operation, int category, int position, const char * name="") +{ + StorageModelsList storage; + FIL file; + const char * error = storageOpenModelsList(&storage); + if (error) { + return error; + } + + { + FRESULT result = f_open(&file, RADIO_PATH "/models.tmp", FA_CREATE_ALWAYS | FA_WRITE); + if (result != FR_OK) { + return SDCARD_ERROR(result); + } + } + + bool operationdone = false; + bool result = true; + int categoryindex = -1; + int modelindex = 0; + + while (result) { + char line[256]; + result = storageReadNextLine(&storage, line, sizeof(line)-1); + if (!operationdone) { + int len = storageGetCategoryLength(line); + if (len > 0) { + if (categoryindex++ == category) { + operationdone = true; + if (operation == STORAGE_INSERT) { + f_puts(name, &file); + f_putc('\n', &file); + } + } + } + else if (categoryindex == category) { + if (modelindex++ == position) { + operationdone = true; + if (operation == STORAGE_INSERT) { + f_puts(name, &file); + f_putc('\n', &file); + } + else if (operation == STORAGE_RENAME) { + f_puts(name, &file); + f_putc('\n', &file); + continue; + } + else if (operation == STORAGE_REMOVE) { + TRACE("skip %s", line); + continue; + } + } + } + } + f_puts(line, &file); + f_putc('\n', &file); + } + + if (!operationdone && categoryindex>=0 && operation==STORAGE_INSERT) { + f_puts(name, &file); + f_putc('\n', &file); + } + + f_close(&file); + f_unlink(RADIO_PATH "/models.old"); + f_rename(RADIO_MODELSLIST_PATH, RADIO_PATH "/models.old"); + f_rename(RADIO_PATH "/models.tmp", RADIO_MODELSLIST_PATH); + return NULL; +} + +const char * storageInsertModel(const char * name, int category, int position) +{ + return storageModifyModel(STORAGE_INSERT, category, position, name); +} + +const char * storageRemoveModel(int category, int position) +{ + return storageModifyModel(STORAGE_REMOVE, category, position); +} + +const char * storageRenameModel(const char * name, int category, int position) +{ + return storageModifyModel(STORAGE_RENAME, category, position, name); +} diff --git a/radio/src/storage/sdcard_raw.h b/radio/src/storage/sdcard_raw.h new file mode 100644 index 000000000..f56163159 --- /dev/null +++ b/radio/src/storage/sdcard_raw.h @@ -0,0 +1,43 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#define DEFAULT_CATEGORY "Models" +#define DEFAULT_MODEL_FILENAME "model01.bin" + +const char * readModel(const char * filename, uint8_t * buffer, uint32_t size); +const char * loadModel(const char * filename); + + diff --git a/radio/src/storage/storage.h b/radio/src/storage/storage.h new file mode 100644 index 000000000..71af54093 --- /dev/null +++ b/radio/src/storage/storage.h @@ -0,0 +1,76 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#ifndef _STORAGE_H_ +#define _STORAGE_H_ + +#if defined(SIMU) + #define WRITE_DELAY_10MS 200 +#elif defined(PCBTARANIS) + #define WRITE_DELAY_10MS 500 +#elif defined(PCBSKY9X) && !defined(REV0) + #define WRITE_DELAY_10MS 500 +#elif defined(PCBGRUVIN9X) && !defined(REV0) + #define WRITE_DELAY_10MS 500 +#else + #define WRITE_DELAY_10MS 200 +#endif + +extern uint8_t storageDirtyMsk; +extern tmr10ms_t storageDirtyTime10ms; + +#define TIME_TO_WRITE() (storageDirtyMsk && (tmr10ms_t)(get_tmr10ms() - storageDirtyTime10ms) >= (tmr10ms_t)WRITE_DELAY_10MS) + +void storageEraseAll(bool warn); +void storageFormat(); +void storageReadAll(); +void storageDirty(uint8_t msk); +void storageCheck(bool immediately); + +void preModelLoad(); +void postModelLoad(bool newModel); + +#if defined(EEPROM_RLC) +#include "eeprom_common.h" +#include "eeprom_rlc.h" +#elif defined(EEPROM) +#include "eeprom_common.h" +#include "eeprom_raw.h" +#elif defined(SDCARD) +#include "sdcard_raw.h" +#endif + +#endif diff --git a/radio/src/storage/storage_common.cpp b/radio/src/storage/storage_common.cpp new file mode 100644 index 000000000..05bdfb692 --- /dev/null +++ b/radio/src/storage/storage_common.cpp @@ -0,0 +1,129 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "../opentx.h" + +uint8_t storageDirtyMsk; +tmr10ms_t storageDirtyTime10ms; + +void storageDirty(uint8_t msk) +{ + storageDirtyMsk |= msk; + storageDirtyTime10ms = get_tmr10ms() ; +} + +void preModelLoad() +{ +#if defined(CPUARM) + watchdogSetTimeout(500/*5s*/); +#endif + +#if defined(SDCARD) + closeLogs(); +#endif + + if (pulsesStarted()) { + pausePulses(); + } + + pauseMixerCalculations(); +} + +void postModelLoad(bool newModel) +{ + AUDIO_FLUSH(); + flightReset(); + logicalSwitchesReset(); + + if (pulsesStarted()) { +#if defined(GUI) + if (!newModel) { + checkAll(); + } +#endif + resumePulses(); + } + + customFunctionsReset(); + + restoreTimers(); + +#if defined(CPUARM) + for (int i=0; i 0) { if (str[size-1] != ' ') @@ -107,7 +107,7 @@ unsigned int effectiveLen(const char *str, unsigned int size) return 0; } -bool zexist(const char *str, uint8_t size) +bool zexist(const char * str, uint8_t size) { for (int i=0; i 0) { if (str[size-1] != 0) @@ -161,8 +161,7 @@ char *strcat_zchar(char * dest, const char * name, uint8_t size, const char *def #endif #endif -#if defined(COLORLCD) -char *strAppendDigits(char *dest, int value) +char * strAppendNumber(char * dest, unsigned int value) { div_t qr = div(value, 10); *dest++ = '0' + qr.quot; @@ -170,10 +169,9 @@ char *strAppendDigits(char *dest, int value) *dest = '\0'; return dest; } -#endif #if defined(CPUARM) || defined(SDCARD) -char *strAppend(char *dest, const char *source, int len) +char * strAppend(char * dest, const char * source, int len) { while ((*dest++ = *source++)) { if (--len == 0) { @@ -184,7 +182,7 @@ char *strAppend(char *dest, const char *source, int len) return dest - 1; } -char *strSetCursor(char *dest, int position) +char * strSetCursor(char * dest, int position) { *dest++ = 0x1F; *dest++ = position; @@ -192,7 +190,7 @@ char *strSetCursor(char *dest, int position) return dest; } -char *strAppendFilename(char *dest, const char *filename, const int size) +char * strAppendFilename(char *dest, const char *filename, const int size) { memset(dest, 0, size); for (int i=0; i(size, strlen(filename)); - for (int i=len; i>=len-LEN_FILE_EXTENSION; --i) { - if (filename[i] == '.') { - return &filename[i]; - } - } - return NULL; -} - #if defined(RTCLOCK) #include "rtc.h" diff --git a/radio/src/strhelpers.h b/radio/src/strhelpers.h new file mode 100644 index 000000000..d53033736 --- /dev/null +++ b/radio/src/strhelpers.h @@ -0,0 +1,41 @@ +/* + * Authors (alphabetical order) + * - Andre Bernet + * - Andreas Weitl + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Gabriel Birkus + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * opentx is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +char * strAppend(char * dest, const char * source, int len=0); +char * strAppendNumber(char * dest, unsigned int number); +char * strSetCursor(char * dest, int position); +char * strAppendDate(char * str, bool time=false); +char * strAppendFilename(char * dest, const char * filename, const int size); diff --git a/radio/src/switches.cpp b/radio/src/switches.cpp index 8ab5ebf58..e59cad714 100644 --- a/radio/src/switches.cpp +++ b/radio/src/switches.cpp @@ -71,7 +71,114 @@ volatile GETSWITCH_RECURSIVE_TYPE s_last_switch_value = 0; #endif -#if defined(PCBTARANIS) +#if defined(PCBFLAMENCO) +tmr10ms_t potsLastposStart[1]; +uint8_t potsPos[1]; +tmr10ms_t switchesMidposStart[2]; +uint64_t switchesPos = 0; +div_t switchInfo(int switchPosition) +{ + const div_t infos[] = { + { 0, 0 }, { 0, 1 }, { 0, 2 }, + { 1, 0 }, { 1, 1 }, + { 2, 0 }, { 2, 1 }, { 2, 2 }, { 2, 3 }, { 2, 4 }, { 2, 5 }, + { 4, 0 }, { 4, 1 }, + { 5, 0 }, { 5, 1 }, { 5, 2 }, + }; + return infos[switchPosition-SWSRC_FIRST_SWITCH]; +} + +uint32_t check2PosSwitchPosition(EnumKeys sw) +{ + uint32_t result; + uint32_t index; + + if (switchState(sw)) + index = sw - SW_SA0; + else + index = sw - SW_SA0 + 1; + + result = ((uint32_t)1 << index); + + if (!(switchesPos & result)) { + PLAY_SWITCH_MOVED(index); + } + + return result; +} + +uint32_t check3PosSwitchPosition(int idx, EnumKeys sw, bool startup) +{ + uint32_t result; + uint32_t index; + + if (switchState(sw)) { + index = sw - SW_SA0; + result = (1 << index); + switchesMidposStart[idx] = 0; + } + else if (switchState(EnumKeys(sw+2))) { + index = sw - SW_SA0 + 2; + result = (1 << index); + switchesMidposStart[idx] = 0; + } + else if (startup || (switchesPos & (1 << (sw - SW_SA0 + 1))) || g_eeGeneral.switchesDelay==SWITCHES_DELAY_NONE || (switchesMidposStart[idx] && (tmr10ms_t)(get_tmr10ms() - switchesMidposStart[idx]) > SWITCHES_DELAY())) { + index = sw - SW_SA0 + 1; + result = (1 << index); + switchesMidposStart[idx] = 0; + } + else { + index = sw - SW_SA0 + 1; + if (!switchesMidposStart[idx]) { + switchesMidposStart[idx] = get_tmr10ms(); + } + result = (switchesPos & (0x7 << (sw - SW_SA0))); + } + + if (!(switchesPos & result)) { + PLAY_SWITCH_MOVED(index); + } + + return result; +} + +#define CHECK_2POS(sw) newPos |= check2PosSwitchPosition(sw ## 0) +#define CHECK_3POS(idx, sw) newPos |= check3PosSwitchPosition(idx, sw ## 0, startup) + +void getSwitchesPosition(bool startup) +{ + uint64_t newPos = 0; + CHECK_3POS(0, SW_SA); + CHECK_2POS(SW_SB); + CHECK_2POS(SW_SE); + CHECK_3POS(1, SW_SF); + switchesPos = newPos; + + int i = 0; + StepsCalibData * calib = (StepsCalibData *) &g_eeGeneral.calib[POT1+i]; + if (calib->count>0 && calib->countcount); + uint8_t previousPos = potsPos[i] >> 4; + uint8_t previousStoredPos = potsPos[i] & 0x0F; + if (startup) { + potsPos[i] = (pos << 4) | pos; + } + else if (pos != previousPos) { + potsLastposStart[i] = get_tmr10ms(); + potsPos[i] = (pos << 4) | previousStoredPos; + } + else if (g_eeGeneral.switchesDelay==SWITCHES_DELAY_NONE || (tmr10ms_t)(get_tmr10ms() - potsLastposStart[i]) > SWITCHES_DELAY()) { + potsLastposStart[i] = 0; + potsPos[i] = (pos << 4) | pos; + if (previousStoredPos != pos) { + PLAY_SWITCH_MOVED(SWSRC_LAST_SWITCH+i*XPOTS_MULTIPOS_COUNT+pos); + } + } + } +} +#endif + +#if defined(PCBTARANIS) || defined(PCBHORUS) #if defined(REV9E) tmr10ms_t switchesMidposStart[16]; #else @@ -200,6 +307,7 @@ void getSwitchesPosition(bool startup) } } + getvalue_t getValueForLogicalSwitch(mixsrc_t i) { getvalue_t result = getValue(i); @@ -462,7 +570,7 @@ bool getSwitch(swsrc_t swtch) result = true; } else if (cs_idx <= SWSRC_LAST_SWITCH) { -#if defined(PCBTARANIS) +#if defined(PCBTARANIS) // TODO || defined(PCBFLAMENCO) if (flags & GETSWITCH_MIDPOS_DELAY) result = SWITCH_POSITION(cs_idx-SWSRC_FIRST_SWITCH); else @@ -486,7 +594,7 @@ bool getSwitch(swsrc_t swtch) } #endif } -#if defined(PCBTARANIS) +#if NUM_XPOTS > 0 else if (cs_idx <= SWSRC_LAST_MULTIPOS_SWITCH) { result = POT_POSITION(cs_idx-SWSRC_FIRST_MULTIPOS_SWITCH); } @@ -568,7 +676,28 @@ swsrc_t getMovedSwitch() static tmr10ms_t s_move_last_time = 0; swsrc_t result = 0; -#if defined(PCBTARANIS) +#if defined(PCBFLAMENCO) +#if 0 + for (int i=0; i> (i*3); + uint8_t next = (1024+getValue(MIXSRC_SA+i)) / 1024; + if (prev != next) { + switches_states = (switches_states & (~mask)) | ((swarnstate_t)next << (i*3)); + if (i == 0) + result = 1+next; + else if (i == 1) + result = 1+(3*1)+(next!=0); + else if (i == 3) + result = 12+(next!=0); + else if (i == 4) + result = 14+next; + else + result = 0; + } + } +#endif +#elif defined(PCBTARANIS) || defined(PCBHORUS) for (int i=0; i 1)) { @@ -692,25 +817,44 @@ void checkSwitches() } // first - display warning -#if defined(PCBTARANIS) +#if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS) +#if defined(COLORLCD) + if ((last_bad_switches != switches_states) || (last_bad_pots != bad_pots)) { + int x = WARNING_LINE_X, y = WARNING_INFOLINE_Y-5; +#elif defined(PCBTARANIS) if ((last_bad_switches != switches_states) || (last_bad_pots != bad_pots)) { MESSAGE(STR_SWITCHWARN, NULL, STR_PRESSANYKEYTOSKIP, ((last_bad_switches == 0xff) || (last_bad_pots == 0xff)) ? AU_SWITCH_ALERT : AU_NONE); int x = 60, y = 4*FH+3; +#endif int numWarnings = 0; for (int i=0; i 5) { - lcd_putsAtt(x, y, "...", 0); - break; + if (++numWarnings < 6) { + putsSwitches(x, y, SWSRC_FIRST_SWITCH+i*3, attr); + x += 20; + } + else if (numWarnings == 6) { + lcdDrawText(x, y, "...", ALARM_COLOR); } - char c = "\300-\301"[(states & mask) >> (i*2)]; - putsMixerSource(x, y, MIXSRC_FIRST_SWITCH+i, attr); - lcd_putcAtt(lcdNextPos, y, c, attr); - x = lcdNextPos + 3; } +#else + LcdFlags attr = ((states & mask) == (switches_states & mask)) ? 0 : INVERS; + if (attr) { + if (++numWarnings < 7) { + char c = "\300-\301"[(states & mask) >> (i*2)]; + putsMixerSource(x, y, MIXSRC_FIRST_SWITCH+i, attr); + lcdDrawChar(lcdNextPos, y, c, attr); + x = lcdNextPos + 3; + } + else if (numWarnings == 7) { + lcdDrawText(x, y, "...", 0); + } + } +#endif } } if (g_model.potsWarnMode) { @@ -719,17 +863,34 @@ void checkSwitches() x = 60; } for (int i=0; i 1) { - lcd_putsiAtt(x, y, STR_VSRCRAW, NUM_STICKS+1+i, INVERS); +#if defined(COLORLCD) + char s[8]; + // TODO add an helper + strncpy(s, &STR_VSRCRAW[1+(NUM_STICKS+1+i)*STR_VSRCRAW[0]], STR_VSRCRAW[0]); + s[int(STR_VSRCRAW[0])] = '\0'; +#else + lcdDrawTextAtIndex(x, y, STR_VSRCRAW, NUM_STICKS+1+i, INVERS); if (IS_POT(POT1+i)) - lcd_putcAtt(lcdNextPos, y, g_model.potsWarnPosition[i] > GET_LOWRES_POT_POSITION(i) ? 126 : 127, INVERS); + lcdDrawChar(lcdNextPos, y, g_model.potsWarnPosition[i] > GET_LOWRES_POT_POSITION(i) ? 126 : 127, INVERS); else - lcd_putcAtt(lcdNextPos, y, g_model.potsWarnPosition[i] > GET_LOWRES_POT_POSITION(i) ? '\300' : '\301', INVERS); + lcdDrawChar(lcdNextPos, y, g_model.potsWarnPosition[i] > GET_LOWRES_POT_POSITION(i) ? '\300' : '\301', INVERS); +#endif +#if defined(COLORLCD) + if (++numWarnings < 6) { + lcdDrawText(x, y, s, ALARM_COLOR); + } + else if (numWarnings == 6) { + lcdDrawText(x, y, "...", ALARM_COLOR); + } + x += 20; +#else x = lcdNextPos + 3; +#endif } } @@ -761,30 +922,9 @@ void checkSwitches() last_bad_switches = 0xff; } #else + if (pwrCheck()==e_power_off || keyDown()) return; - if (keyDown()) { - return; - } - -#if defined(PCBTARANIS) && defined(REV9E) - uint32_t pwr_check = pwrCheck(); - if (pwr_check == e_power_off) { - return; - } - else if (pwr_check == e_power_press) { - refresh = true; - } - else if (pwr_check == e_power_on && refresh) { - last_bad_switches = 0xff; - refresh = false; - } -#else - if (pwrCheck() == e_power_off) { - return; - } -#endif - - checkBacklight(); + doLoopCommonActions(); wdt_reset(); diff --git a/radio/src/targets/stock/board_stock.cpp b/radio/src/targets/9x/board_stock.cpp similarity index 100% rename from radio/src/targets/stock/board_stock.cpp rename to radio/src/targets/9x/board_stock.cpp diff --git a/radio/src/targets/stock/board_stock.h b/radio/src/targets/9x/board_stock.h similarity index 100% rename from radio/src/targets/stock/board_stock.h rename to radio/src/targets/9x/board_stock.h diff --git a/radio/src/targets/stock/lcd_driver.cpp b/radio/src/targets/9x/lcd_driver.cpp similarity index 100% rename from radio/src/targets/stock/lcd_driver.cpp rename to radio/src/targets/9x/lcd_driver.cpp diff --git a/radio/src/targets/stock/voice.cpp b/radio/src/targets/9x/voice.cpp similarity index 100% rename from radio/src/targets/stock/voice.cpp rename to radio/src/targets/9x/voice.cpp diff --git a/radio/src/targets/stock/voice.h b/radio/src/targets/9x/voice.h similarity index 100% rename from radio/src/targets/stock/voice.h rename to radio/src/targets/9x/voice.h diff --git a/radio/src/targets/gruvin9x/board_gruvin9x.cpp b/radio/src/targets/Gruvin9x/board_gruvin9x.cpp similarity index 100% rename from radio/src/targets/gruvin9x/board_gruvin9x.cpp rename to radio/src/targets/Gruvin9x/board_gruvin9x.cpp diff --git a/radio/src/targets/gruvin9x/board_gruvin9x.h b/radio/src/targets/Gruvin9x/board_gruvin9x.h similarity index 100% rename from radio/src/targets/gruvin9x/board_gruvin9x.h rename to radio/src/targets/Gruvin9x/board_gruvin9x.h diff --git a/radio/src/targets/gruvin9x/diskio.cpp b/radio/src/targets/Gruvin9x/diskio.cpp similarity index 100% rename from radio/src/targets/gruvin9x/diskio.cpp rename to radio/src/targets/Gruvin9x/diskio.cpp diff --git a/radio/src/targets/gruvin9x/fuses_2561.txt b/radio/src/targets/Gruvin9x/fuses_2561.txt similarity index 100% rename from radio/src/targets/gruvin9x/fuses_2561.txt rename to radio/src/targets/Gruvin9x/fuses_2561.txt diff --git a/radio/src/targets/gruvin9x/rtc_driver.cpp b/radio/src/targets/Gruvin9x/rtc_driver.cpp similarity index 100% rename from radio/src/targets/gruvin9x/rtc_driver.cpp rename to radio/src/targets/Gruvin9x/rtc_driver.cpp diff --git a/radio/src/targets/gruvin9x/somo14d.cpp b/radio/src/targets/Gruvin9x/somo14d.cpp similarity index 100% rename from radio/src/targets/gruvin9x/somo14d.cpp rename to radio/src/targets/Gruvin9x/somo14d.cpp diff --git a/radio/src/targets/gruvin9x/somo14d.h b/radio/src/targets/Gruvin9x/somo14d.h similarity index 100% rename from radio/src/targets/gruvin9x/somo14d.h rename to radio/src/targets/Gruvin9x/somo14d.h diff --git a/radio/src/targets/Horus/adc_driver.cpp b/radio/src/targets/Horus/adc_driver.cpp index e6f46ff9e..960708dab 100644 --- a/radio/src/targets/Horus/adc_driver.cpp +++ b/radio/src/targets/Horus/adc_driver.cpp @@ -36,83 +36,186 @@ #include "../../opentx.h" -#define STICK_LV 3 -#define STICK_LH 2 -#define STICK_RV 0 -#define STICK_RH 1 -#define POT_L 13 -#define POT_R 5 -#define SLIDE_L 9 -#define SLIDE_R 8 -#define SWITCHES1 11 -#define SWITCHES2 7 -#define SWITCHES3 10 -#define SWITCHES4 6 -#define BATTERY 14 +#define ADC_CS_HIGH() (ADC_SPI_GPIO->BSRRL = ADC_SPI_PIN_CS) +#define ADC_CS_LOW() (ADC_SPI_GPIO->BSRRH = ADC_SPI_PIN_CS) -// Sample time should exceed 1uS -#define SAMPTIME 2 // sample time = 28 cycles +#define RESETCMD 0x4000 +#define MANUAL_MODE 0x1000 // manual mode channel 0 -uint16_t Analog_values[NUMBER_ANALOG] __DMA; +#define SAMPTIME 2 // sample time = 28 cycles -#define NUMBER_ANALOG_ADC1 13 +uint16_t adcValues[NUMBER_ANALOG] __DMA; -#if 0 -const int8_t ana_direction[NUMBER_ANALOG] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; -#endif +static u16 SPIx_ReadWriteByte(uint16_t value) +{ + while(SPI_I2S_GetFlagStatus(ADC_SPI,SPI_I2S_FLAG_TXE) == RESET); + SPI_I2S_SendData(ADC_SPI,value); + + while(SPI_I2S_GetFlagStatus(ADC_SPI,SPI_I2S_FLAG_RXNE) ==RESET); + return SPI_I2S_ReceiveData(ADC_SPI); +} + +static void ADS7952_Init() +{ + GPIO_InitTypeDef GPIO_InitStructure; + SPI_InitTypeDef SPI_InitStructure; + + GPIO_InitStructure.GPIO_Pin = ADC_SPI_PIN_MISO|ADC_SPI_PIN_SCK|ADC_SPI_PIN_MOSI; + GPIO_InitStructure.GPIO_Speed =GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; + GPIO_Init(ADC_SPI_GPIO, &GPIO_InitStructure); + + GPIO_InitStructure.GPIO_Pin = ADC_SPI_PIN_CS; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; + GPIO_Init(ADC_SPI_GPIO, &GPIO_InitStructure); + + GPIO_PinAFConfig(ADC_SPI_GPIO, ADC_SPI_PinSource_SCK, ADC_GPIO_AF); + GPIO_PinAFConfig(ADC_SPI_GPIO, ADC_SPI_PinSource_MISO, ADC_GPIO_AF); + GPIO_PinAFConfig(ADC_SPI_GPIO, ADC_SPI_PinSource_MOSI, ADC_GPIO_AF); + + SPI_I2S_DeInit(ADC_SPI); + + SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; + SPI_InitStructure.SPI_Mode = SPI_Mode_Master; + SPI_InitStructure.SPI_DataSize = SPI_DataSize_16b; + SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low; + SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge; + SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; + SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_8; + SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; + SPI_InitStructure.SPI_CRCPolynomial = 7; + SPI_Init(ADC_SPI,&SPI_InitStructure); + SPI_Cmd(ADC_SPI,ENABLE); + SPI_I2S_ITConfig(ADC_SPI,SPI_I2S_IT_TXE,DISABLE); + SPI_I2S_ITConfig(ADC_SPI,SPI_I2S_IT_RXNE,DISABLE); + + ADC_CS_HIGH(); + delay_01us(1); + ADC_CS_LOW(); + SPIx_ReadWriteByte(RESETCMD); + ADC_CS_HIGH(); + delay_01us(1); + ADC_CS_LOW(); + SPIx_ReadWriteByte(MANUAL_MODE); + ADC_CS_HIGH(); + +// SPIx_ReadWriteByte(ProgramReg_Auto2 ); +// ADC_CS_HIGH(); + +// asm("nop"); +// ADC_CS_LOW(); +// SPIx_ReadWriteByte(AutoMode_2); +// ADC_CS_HIGH(); + +// asm("nop"); +// ADC_CS_LOW(); +// SPIx_ReadWriteByte(ContinuedSelectMode); +// ADC_CS_HIGH(); +// asm("nop"); +} void adcInit() { - // Enable clocks - RCC->APB2ENR |= RCC_APB2ENR_ADC1EN; - RCC->AHB1ENR |= ADC_RCC_AHB1Periph_GPIO | RCC_AHB1ENR_DMA2EN; + ADS7952_Init(); - configure_pins(ADC_GPIO_PIN_STICK_LV | ADC_GPIO_PIN_STICK_LH | ADC_GPIO_PIN_STICK_RV | ADC_GPIO_PIN_STICK_RH | - ADC_GPIO_PIN_POT_R1 | ADC_GPIO_SWITCHES_PIN_R3 | ADC_GPIO_SWITCHES_PIN_R4, PIN_ANALOG | PIN_PORTA); - - configure_pins(ADC_GPIO_PIN_POT_R2 | ADC_GPIO_PIN_POT_L2, PIN_ANALOG | PIN_PORTB); - - configure_pins(ADC_GPIO_PIN_POT_L1 | ADC_GPIO_SWITCHES_PIN_L3 | ADC_GPIO_SWITCHES_PIN_L4 | ADC_GPIO_PIN_BATT, PIN_ANALOG | PIN_PORTC); - - ADC1->CR1 = ADC_CR1_SCAN; - ADC1->CR2 = ADC_CR2_ADON | ADC_CR2_DMA | ADC_CR2_DDS; - ADC1->SQR1 = (BATTERY<<0) + ((NUMBER_ANALOG_ADC1-1) << 20); // bits 23:20 = number of conversions - ADC1->SQR2 = (SLIDE_L<<0) + (SLIDE_R<<5) + (SWITCHES1<<10) + (SWITCHES2<<15) + (SWITCHES3<<20) + (SWITCHES4<<25); // conversions 7 to 12 - ADC1->SQR3 = (STICK_LH<<0) + (STICK_LV<<5) + (STICK_RV<<10) + (STICK_RH<<15) + (POT_L<<20) + (POT_R<<25); // conversions 1 to 6 - ADC1->SMPR1 = SAMPTIME + (SAMPTIME<<3) + (SAMPTIME<<6) + (SAMPTIME<<9) + (SAMPTIME<<12) + (SAMPTIME<<15) + (SAMPTIME<<18) + (SAMPTIME<<21) + (SAMPTIME<<24); - ADC1->SMPR2 = SAMPTIME + (SAMPTIME<<3) + (SAMPTIME<<6) + (SAMPTIME<<9) + (SAMPTIME<<12) + (SAMPTIME<<15) + (SAMPTIME<<18) + (SAMPTIME<<21) + (SAMPTIME<<24) + (SAMPTIME<<27) ; - - ADC->CCR = 0 ; //ADC_CCR_ADCPRE_0 ; // Clock div 2 - - DMA2_Stream0->CR = DMA_SxCR_PL | DMA_SxCR_MSIZE_0 | DMA_SxCR_PSIZE_0 | DMA_SxCR_MINC; - DMA2_Stream0->PAR = CONVERT_PTR_UINT(&ADC1->DR); - DMA2_Stream0->M0AR = CONVERT_PTR_UINT(Analog_values); - DMA2_Stream0->NDTR = NUMBER_ANALOG_ADC1; - DMA2_Stream0->FCR = DMA_SxFCR_DMDIS | DMA_SxFCR_FTH_0 ; + configure_pins( ADC_GPIO_PIN_MOUSE1 | ADC_GPIO_PIN_MOUSE2, PIN_ANALOG | PIN_PORTF ); + + ADC3->CR1 = ADC_CR1_SCAN; + ADC3->CR2 = ADC_CR2_ADON | ADC_CR2_DMA | ADC_CR2_DDS; + ADC3->SQR1 = (2-1) << 20; // NUMBER_ANALOG Channels + ADC3->SQR3 = ADC_IN_MOUSE1 + (ADC_IN_MOUSE2<<5); + ADC3->SMPR1 = SAMPTIME + (SAMPTIME<<3) + (SAMPTIME<<6) + (SAMPTIME<<9) + (SAMPTIME<<12) + + (SAMPTIME<<15) + (SAMPTIME<<18) + (SAMPTIME<<21) + (SAMPTIME<<24); + ADC3->SMPR2 = SAMPTIME + (SAMPTIME<<3) + (SAMPTIME<<6) + (SAMPTIME<<9) + (SAMPTIME<<12) + + (SAMPTIME<<15) + (SAMPTIME<<18) + (SAMPTIME<<21) + (SAMPTIME<<24) + (SAMPTIME<<27); + ADC->CCR = 0; // ADC_CCR_ADCPRE_0; Clock div 2 + + // Enable the DMA channel here, DMA2 stream 1, channel 2 + DMA2_Stream1->CR = DMA_SxCR_PL | DMA_SxCR_CHSEL_1 | DMA_SxCR_MSIZE_0 | DMA_SxCR_PSIZE_0 | DMA_SxCR_MINC; + DMA2_Stream1->PAR = CONVERT_PTR_UINT(&ADC3->DR); + DMA2_Stream1->M0AR = CONVERT_PTR_UINT(&adcValues[MOUSE1]); + DMA2_Stream1->FCR = DMA_SxFCR_DMDIS | DMA_SxFCR_FTH_0; } +#define SPI_STICK1 0 +#define SPI_STICK2 1 +#define SPI_STICK3 2 +#define SPI_STICK4 3 +#define SPI_POT1 4 +#define SPI_POT2 5 +#define SPI_POT3 6 +#define SPI_SLIDER1 7 +#define SPI_SLIDER2 8 +#define SPI_TX_VOLTAGE 9 +#define SPI_SLIDER3 10 +#define SPI_SLIDER4 11 + +const uint16_t adcCommands[MOUSE1+2] = +{ + MANUAL_MODE | ( SPI_STICK1 << 7 ), + MANUAL_MODE | ( SPI_STICK2 << 7 ), + MANUAL_MODE | ( SPI_STICK3 << 7 ), + MANUAL_MODE | ( SPI_STICK4 << 7 ), + MANUAL_MODE | ( SPI_POT1 << 7 ), + MANUAL_MODE | ( SPI_POT2 << 7 ), + MANUAL_MODE | ( SPI_POT3 << 7 ), + MANUAL_MODE | ( SPI_SLIDER1 << 7 ), + MANUAL_MODE | ( SPI_SLIDER2 << 7 ), + MANUAL_MODE | ( SPI_SLIDER3 << 7 ), + MANUAL_MODE | ( SPI_SLIDER4 << 7 ), + MANUAL_MODE | ( SPI_TX_VOLTAGE << 7 ), + MANUAL_MODE | ( 0 << 7 ), + MANUAL_MODE | ( 0 << 7 ) +}; + void adcRead() { - DMA2_Stream0->CR &= ~DMA_SxCR_EN ; // Disable DMA - ADC1->SR &= ~(uint32_t) ( ADC_SR_EOC | ADC_SR_STRT | ADC_SR_OVR ) ; - DMA2->LIFCR = DMA_LIFCR_CTCIF0 | DMA_LIFCR_CHTIF0 |DMA_LIFCR_CTEIF0 | DMA_LIFCR_CDMEIF0 | DMA_LIFCR_CFEIF0 ; // Write ones to clear bits - DMA2_Stream0->CR |= DMA_SxCR_EN ; // Enable DMA - ADC1->CR2 |= (uint32_t)ADC_CR2_SWSTART ; - for (unsigned int i=0; i<10000; i++) { - if (DMA2->LISR & DMA_LISR_TCIF0) { + const uint16_t * command = adcCommands; + + // Start on chip ADC read + DMA2_Stream1->CR &= ~DMA_SxCR_EN; // Disable DMA + ADC3->SR &= ~(uint32_t) ( ADC_SR_EOC | ADC_SR_STRT | ADC_SR_OVR ); + DMA2->LIFCR = DMA_LIFCR_CTCIF1 | DMA_LIFCR_CHTIF1 |DMA_LIFCR_CTEIF1 | DMA_LIFCR_CDMEIF1 | DMA_LIFCR_CFEIF1; // Write ones to clear bits + DMA2_Stream1->M0AR = CONVERT_PTR_UINT(&adcValues[MOUSE1]); + DMA2_Stream1->NDTR = 2; + DMA2_Stream1->CR |= DMA_SxCR_EN; // Enable DMA + ADC3->CR2 |= (uint32_t)ADC_CR2_SWSTART; + + ADC_CS_LOW(); + delay_01us(1); + SPIx_ReadWriteByte(*command++); // Discard + ADC_CS_HIGH(); + delay_01us(1); + + ADC_CS_LOW(); + delay_01us(1); + SPIx_ReadWriteByte(*command++); // Discard + ADC_CS_HIGH(); + delay_01us(1); + + for (uint32_t adcIndex=0; adcIndexLISR & DMA_LISR_TCIF1) { break; } } - DMA2_Stream0->CR &= ~DMA_SxCR_EN ; // Disable DMA -} -// TODO -void adcStop() -{ + // On chip ADC read should have finished } uint16_t getAnalogValue(uint32_t value) { - // return Analog_values[ana_mapping[value]]; - return 0; // Analog_values[value]; + return adcValues[value]; } diff --git a/radio/src/targets/Horus/board_horus.cpp b/radio/src/targets/Horus/board_horus.cpp index 0e0fe3a35..18a7b73b7 100644 --- a/radio/src/targets/Horus/board_horus.cpp +++ b/radio/src/targets/Horus/board_horus.cpp @@ -58,27 +58,22 @@ void watchdogInit(unsigned int duration) // Start TIMER7 at 2000000Hz void init2MhzTimer() { - // Now for timer 7 - RCC->APB1ENR |= RCC_APB1ENR_TIM7EN ; // Enable clock - - TIM7->PSC = (PERI1_FREQUENCY * TIMER_MULT_APB1) / 2000000 - 1 ; // 0.5 uS, 2 MHz - TIM7->ARR = 65535; - TIM7->CR2 = 0; - TIM7->CR1 = TIM_CR1_CEN; + TIMER_2MHz_TIMER->PSC = (PERI1_FREQUENCY * TIMER_MULT_APB1) / 2000000 - 1 ; // 0.5 uS, 2 MHz + TIMER_2MHz_TIMER->ARR = 65535; + TIMER_2MHz_TIMER->CR2 = 0; + TIMER_2MHz_TIMER->CR1 = TIM_CR1_CEN; } // Starts TIMER at 200Hz, 5mS period void init5msTimer() { - // Timer14 - RCC->APB1ENR |= RCC_APB1ENR_TIM14EN ; // Enable clock - TIM14->ARR = 4999 ; // 5mS - TIM14->PSC = (PERI1_FREQUENCY * TIMER_MULT_APB1) / 1000000 - 1 ; // 1uS from 30MHz - TIM14->CCER = 0 ; - TIM14->CCMR1 = 0 ; - TIM14->EGR = 0 ; - TIM14->CR1 = 5 ; - TIM14->DIER |= 1 ; + INTERRUPT_5MS_TIMER->ARR = 999 ; // 5mS + INTERRUPT_5MS_TIMER->PSC = (PERI1_FREQUENCY * TIMER_MULT_APB1) / 1000000 - 1 ; // 1uS from 30MHz + INTERRUPT_5MS_TIMER->CCER = 0 ; + INTERRUPT_5MS_TIMER->CCMR1 = 0 ; + INTERRUPT_5MS_TIMER->EGR = 0 ; + INTERRUPT_5MS_TIMER->CR1 = 5 ; + INTERRUPT_5MS_TIMER->DIER |= 1 ; NVIC_EnableIRQ(TIM8_TRG_COM_TIM14_IRQn) ; NVIC_SetPriority(TIM8_TRG_COM_TIM14_IRQn, 7); } @@ -95,13 +90,18 @@ void interrupt5ms() { static uint32_t pre_scale ; // Used to get 10 Hz counter - AUDIO_HEARTBEAT(); + ++pre_scale; + + if (pre_scale == 5 || pre_scale == 10) { + AUDIO_HEARTBEAT(); #if defined(HAPTIC) - HAPTIC_HEARTBEAT(); + HAPTIC_HEARTBEAT(); #endif - if ( ++pre_scale >= 2 ) { + } + + if ( pre_scale >= 10 ) { pre_scale = 0 ; per10ms(); } @@ -116,6 +116,7 @@ extern "C" void TIM8_TRG_COM_TIM14_IRQHandler() interrupt5ms() ; } +#if 0 void pinCheck(GPIO_TypeDef * gpio, uint32_t pin, uint32_t RCC_AHB1Periph) { GPIO_InitTypeDef GPIO_InitStruct; @@ -136,16 +137,20 @@ void pinCheck(GPIO_TypeDef * gpio, uint32_t pin, uint32_t RCC_AHB1Periph) delay_01us(10); } } +#endif void boardInit() { + RCC_AHB1PeriphClockCmd(PWR_RCC_AHB1Periph | LCD_RCC_AHB1Periph | KEYS_RCC_AHB1Periph_GPIO | ADC_RCC_AHB1Periph | I2C_RCC_AHB1Periph | SERIAL_RCC_AHB1Periph | TELEMETRY_RCC_AHB1Periph | HAPTIC_RCC_AHB1Periph, ENABLE); + RCC_APB1PeriphClockCmd(INTERRUPT_5MS_APB1Periph | TIMER_2MHz_APB1Periph | I2C_RCC_APB1Periph | SERIAL_RCC_APB1Periph | TELEMETRY_RCC_APB1Periph, ENABLE); + RCC_APB2PeriphClockCmd(LCD_RCC_APB2Periph | ADC_RCC_APB2Periph | HAPTIC_RCC_APB2Periph, ENABLE); + pwrInit(); ledInit(); delaysInit(); ledRed(); - if (0) { // pinCheck(SERIAL_GPIO, SERIAL_GPIO_PIN_TX, SERIAL_RCC_AHB1Periph_GPIO); // pinCheck(EEPROM_GPIO, EEPROM_GPIO_PIN_SCK, RCC_AHB1Periph_GPIOB); @@ -162,7 +167,7 @@ void boardInit() TRACE("Horus started :)"); keysInit(); - // adcInit(); + adcInit(); lcdInit(); audioInit(); i2cInit(); @@ -244,21 +249,3 @@ void checkTrainerSettings() } } } - -// TODO -void eeDirty(uint8_t msk) { } -uint8_t s_eeDirtyMsk; -tmr10ms_t s_eeDirtyTime10ms; -void eeCheck(bool) { } -ModelHeader modelHeaders[MAX_MODELS]; -void eeLoadModelHeaders() { } -void eeLoadModelHeader(uint8_t id, ModelHeader *header) { } -bool eeCopyModel(uint8_t dst, uint8_t src) { } -void eeSwapModels(uint8_t id1, uint8_t id2) { } -void eeDeleteModel(uint8_t idx) { } -uint8_t eeFindEmptyModel(uint8_t id, bool down) { return 0; }; -void eeLoadModel(uint8_t id) { } -bool eeModelExists(uint8_t id) { return true; } -const pm_char * eeBackupModel(uint8_t i_fileSrc) { return NULL; } -const pm_char * eeRestoreModel(uint8_t i_fileDst, char *model_name) { return NULL; } -void selectModel(uint8_t sub) { } diff --git a/radio/src/targets/Horus/board_horus.h b/radio/src/targets/Horus/board_horus.h index 7fe8a0ce7..867b293a9 100644 --- a/radio/src/targets/Horus/board_horus.h +++ b/radio/src/targets/Horus/board_horus.h @@ -77,45 +77,40 @@ extern "C" { } #endif -#define FLASHSIZE 0x80000 -#define BOOTLOADER_SIZE 0x8000 -#define FIRMWARE_ADDRESS 0x08000000 +#define FLASHSIZE 0x80000 +#define BOOTLOADER_SIZE 0x8000 +#define FIRMWARE_ADDRESS 0x08000000 -#define PERI1_FREQUENCY 45000000 -#define PERI2_FREQUENCY 90000000 -#define TIMER_MULT_APB1 4 -#define TIMER_MULT_APB2 2 +#define PERI1_FREQUENCY 45000000 +#define PERI2_FREQUENCY 90000000 +#define TIMER_MULT_APB1 4 +#define TIMER_MULT_APB2 2 -#define PIN_MODE_MASK 0x0003 -#define PIN_INPUT 0x0000 -#define PIN_OUTPUT 0x0001 -#define PIN_PERIPHERAL 0x0002 -#define PIN_ANALOG 0x0003 -#define PIN_PULL_MASK 0x000C -#define PIN_PULLUP 0x0004 -#define PIN_NO_PULLUP 0x0000 -#define PIN_PULLDOWN 0x0008 -#define PIN_NO_PULLDOWN 0x0000 -#define PIN_PERI_MASK 0x00F0 -#define PIN_PUSHPULL 0x0000 -#define PIN_ODRAIN 0x8000 -#define PIN_PORT_MASK 0x0700 -#define PIN_SPEED_MASK 0x6000 -#define PIN_PORTA 0x0000 -#define PIN_PORTB 0x0100 -#define PIN_PORTC 0x0200 -#define PIN_PORTD 0x0300 -#define PIN_PORTE 0x0400 -#define PIN_PORTF 0x0500 -#define PIN_PER_1 0x0010 -#define PIN_PER_2 0x0020 -#define PIN_PER_3 0x0030 -#define PIN_PER_5 0x0050 -#define PIN_PER_6 0x0060 -#define PIN_PER_8 0x0080 -#define PIN_OS25 0x2000 -#define PIN_OS50 0x4000 -#define PIN_OS100 0x6000 +#define PIN_MODE_MASK 0x0003 +#define PIN_INPUT 0x0000 +#define PIN_OUTPUT 0x0001 +#define PIN_PERIPHERAL 0x0002 +#define PIN_ANALOG 0x0003 +#define PIN_PULL_MASK 0x000C +#define PIN_PULLUP 0x0004 +#define PIN_NO_PULLUP 0x0000 +#define PIN_PULLDOWN 0x0008 +#define PIN_NO_PULLDOWN 0x0000 +#define PIN_PERI_MASK 0x00F0 +#define PIN_PUSHPULL 0x0000 +#define PIN_ODRAIN 0x8000 +#define PIN_PORT_MASK 0x0700 +#define PIN_SPEED_MASK 0x6000 +#define PIN_PORTA 0x0000 +#define PIN_PORTB 0x0100 +#define PIN_PORTC 0x0200 +#define PIN_PORTF 0x0500 +#define PIN_PER_1 0x0010 +#define PIN_PER_2 0x0020 +#define PIN_PER_3 0x0030 +#define PIN_OS25 0x2000 +#define PIN_OS50 0x4000 +#define PIN_OS100 0x6000 void configure_pins( uint32_t pins, uint16_t config ); @@ -241,7 +236,7 @@ void pwrOn(void); void pwrOff(void); uint32_t pwrPressed(void); uint32_t pwrPressedDuration(void); -#define UNEXPECTED_SHUTDOWN() (g_eeGeneral.unexpectedShutdown) +#define UNEXPECTED_SHUTDOWN() (false) // (g_eeGeneral.unexpectedShutdown) // Led driver void ledInit(void); @@ -250,6 +245,12 @@ void ledRed(void); void ledBlue(void); // LCD driver +void lcdInit(void); +void lcdRefresh(void); +void lcdDrawSolidFilledRectDMA(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color); +void lcdDrawBitmapDMA(uint16_t x, uint16_t y, uint16_t w, uint16_t h, const uint8_t * bitmap); +void lcdStoreBackupBuffer(void); +void lcdRestoreBackupBuffer(void); // Backlight driver #define setBacklight(xx) diff --git a/radio/src/targets/Horus/diskio.cpp b/radio/src/targets/Horus/diskio.cpp index 3da1d09c4..0c5d122e8 100644 --- a/radio/src/targets/Horus/diskio.cpp +++ b/radio/src/targets/Horus/diskio.cpp @@ -17,8 +17,7 @@ /*-----------------------------------------------------------------------*/ #if !defined(BOOT) static OS_MutexID ioMutex; -volatile int mutexCheck = 0; - +unsigned int ioMutexReq = 0, ioMutexRel = 0; int ff_cre_syncobj (BYTE vol, _SYNC_t *mutex) { *mutex = ioMutex; @@ -27,11 +26,13 @@ int ff_cre_syncobj (BYTE vol, _SYNC_t *mutex) int ff_req_grant (_SYNC_t mutex) { + ioMutexReq += 1; return CoEnterMutexSection(mutex) == E_OK; } void ff_rel_grant (_SYNC_t mutex) { + ioMutexRel += 1; CoLeaveMutexSection(mutex); } @@ -87,7 +88,7 @@ DSTATUS disk_status ( return(stat); } - +unsigned int sdReadRetries = 0; /*-----------------------------------------------------------------------*/ /* Read Sector(s) */ @@ -99,56 +100,78 @@ DRESULT disk_read ( UINT count /* Number of sectors to read (1..255) */ ) { - SD_Error Status; + DRESULT res = RES_OK; + SD_Error Status; - // TRACE("disk_read %d %p %10d %d\n",drv,buff,sector,count); + // TRACE("disk_read %d %p %10d %d", drv, buff, sector, count); - if (SD_Detect() != SD_PRESENT) - return(RES_NOTRDY); + if (SD_Detect() != SD_PRESENT) { + TRACE("SD_Detect() != SD_PRESENT"); + return RES_NOTRDY; + } - if ((DWORD)buff & 3) // DMA Alignment failure, do single up to aligned buffer - { - DRESULT res = RES_OK; - DWORD scratch[BLOCK_SIZE / 4]; // Alignment assured, you'll need a sufficiently big stack + if ((DWORD)buff & 3) // DMA Alignment failure, do single up to aligned buffer + { + TRACE("DMA Alignment failure, align buffer"); - while(count--) - { - res = disk_read(drv, (BYTE *)scratch, sector++, 1); + DWORD scratch[BLOCK_SIZE / 4]; // Alignment assured, you'll need a sufficiently big stack - if (res != RES_OK) { - TRACE("disk_read() status=%d", res); - break; - } + while(count--) { + res = disk_read(drv, (BYTE *)scratch, sector++, 1); - memcpy(buff, scratch, BLOCK_SIZE); + if (res != RES_OK) { + TRACE("disk_read() status=%d", res); + break; + } - buff += BLOCK_SIZE; - } + memcpy(buff, scratch, BLOCK_SIZE); - return(res); - } + buff += BLOCK_SIZE; + } - Status = SD_ReadMultiBlocksFIXED(buff, sector, BLOCK_SIZE, count); // 4GB Compliant + return res; + } - if (Status == SD_OK) - { - SDTransferState State; + for (int retry=0; retry<3; retry++) { + res = RES_OK; - Status = SD_WaitReadOperation(); // Check if the Transfer is finished + if (count == 1) { + Status = SD_ReadBlock(buff, sector, BLOCK_SIZE); // 4GB Compliant + } + else { + Status = SD_ReadMultiBlocks(buff, sector, BLOCK_SIZE, count); // 4GB Compliant + } - while((State = SD_GetStatus()) == SD_TRANSFER_BUSY); // BUSY, OK (DONE), ERROR (FAIL) +#if defined(SD_DMA_MODE) + if (Status == SD_OK) { + SDTransferState State; - if ((State == SD_TRANSFER_ERROR) || (Status != SD_OK)) { - TRACE("SD_ReadMultiBlocksFIXED() wait error (State=%d Status=%d)", State, Status); - return(RES_ERROR); - } - else - return(RES_OK); - } - else { - TRACE("SD_ReadMultiBlocksFIXED() error (Status=%d)", Status); - return(RES_ERROR); - } + Status = SD_WaitReadOperation(); // Check if the Transfer is finished + + while ((State = SD_GetStatus()) == SD_TRANSFER_BUSY); // BUSY, OK (DONE), ERROR (FAIL) + + if (State == SD_TRANSFER_ERROR) { + TRACE("State=SD_TRANSFER_ERROR"); + res = RES_ERROR; + } + else if (Status != SD_OK) { + TRACE("Status(WaitRead)=%d", Status); + res = RES_ERROR; + } + } + else { + TRACE("Status(ReadBlock)=%d", Status); + res = RES_ERROR; + } +#endif + + if (res == RES_OK) + break; + + sdReadRetries += 1; + } + + return res; } /*-----------------------------------------------------------------------*/ @@ -163,15 +186,15 @@ DRESULT disk_write ( ) { SD_Error Status; + DRESULT res = RES_OK; - // TRACE("disk_write %d %p %10d %d\n",drv,buff,sector,count); + // TRACE("disk_write %d %p %10d %d", drv, buff, sector, count); if (SD_Detect() != SD_PRESENT) return(RES_NOTRDY); if ((DWORD)buff & 3) // DMA Alignment failure, do single up to aligned buffer { - DRESULT res = RES_OK; DWORD scratch[BLOCK_SIZE / 4]; // Alignment assured, you'll need a sufficiently big stack while(count--) @@ -181,7 +204,7 @@ DRESULT disk_write ( res = disk_write(drv, (BYTE *)scratch, sector++, 1); if (res != RES_OK) - break; + break; buff += BLOCK_SIZE; } @@ -189,7 +212,12 @@ DRESULT disk_write ( return(res); } - Status = SD_WriteMultiBlocksFIXED((uint8_t *)buff, sector, BLOCK_SIZE, count); // 4GB Compliant + if (count == 1) { + Status = SD_WriteBlock((uint8_t *)buff, sector*BLOCK_SIZE, BLOCK_SIZE); // 4GB Compliant + } + else { + Status = SD_WriteMultiBlocks((uint8_t *)buff, sector, BLOCK_SIZE, count); // 4GB Compliant + } if (Status == SD_OK) { @@ -200,12 +228,14 @@ DRESULT disk_write ( while((State = SD_GetStatus()) == SD_TRANSFER_BUSY); // BUSY, OK (DONE), ERROR (FAIL) if ((State == SD_TRANSFER_ERROR) || (Status != SD_OK)) - return(RES_ERROR); - else - return(RES_OK); + res = RES_ERROR; } - else - return(RES_ERROR); + else { + res = RES_ERROR; + } + + // TRACE("result=%d", res); + return res; } #endif /* _READONLY */ @@ -221,7 +251,25 @@ DRESULT disk_ioctl ( void *buff /* Buffer to send/receive control data */ ) { - return RES_OK; + DRESULT res; + + if (drv) return RES_PARERR; + + res = RES_ERROR; + + switch (ctrl) { + case GET_SECTOR_COUNT : /* Get number of sectors on the disk (DWORD) */ + *(DWORD*)buff = SDCardInfo.CardCapacity / SDCardInfo.CardBlockSize; + res = RES_OK; + break; + + case GET_SECTOR_SIZE : /* Get R/W sector size (WORD) */ + *(WORD*)buff = SDCardInfo.CardBlockSize; + res = RES_OK; + break; + } + + return res; } // TODO everything here should not be in the driver layer ... @@ -231,15 +279,6 @@ FATFS g_FATFS_Obj; FIL g_telemetryFile = {0}; #endif -#if defined(BOOT) -void sdInit(void) -{ - if (f_mount(&g_FATFS_Obj, "", 1) == FR_OK) { - f_chdir("/"); - } -} -#else -// TODO shouldn't be there! void sdInit(void) { ioMutex = CoCreateMutex(); @@ -248,9 +287,7 @@ void sdInit(void) return; } - TRACE("AVANT F_MOUNT"); if (f_mount(&g_FATFS_Obj, "", 1) == FR_OK) { - TRACE("APRES F_MOUNT"); // call sdGetFreeSectors() now because f_getfree() takes a long time first time it's called sdGetFreeSectors(); @@ -278,7 +315,6 @@ void sdDone() f_mount(NULL, "", 0); // unmount SD } } -#endif uint32_t sdMounted() { diff --git a/radio/src/targets/Horus/hal.h b/radio/src/targets/Horus/hal.h index 30b5a8f7a..aff6f574e 100644 --- a/radio/src/targets/Horus/hal.h +++ b/radio/src/targets/Horus/hal.h @@ -54,22 +54,22 @@ #define SWITCHES_GPIO_PIN_H GPIO_Pin_7 // PG.07 // Trims -#define TRIMS_GPIO_REG_LHL GPIOC->IDR -#define TRIMS_GPIO_PIN_LHL GPIO_Pin_0 // PC.00 -#define TRIMS_GPIO_REG_LHR GPIOI->IDR -#define TRIMS_GPIO_PIN_LHR GPIO_Pin_4 // PI.04 -#define TRIMS_GPIO_REG_LVD GPIOG->IDR -#define TRIMS_GPIO_PIN_LVD GPIO_Pin_12 // PG.12 -#define TRIMS_GPIO_REG_LVU GPIOJ->IDR -#define TRIMS_GPIO_PIN_LVU GPIO_Pin_14 // PJ.14 -#define TRIMS_GPIO_REG_RVD GPIOJ->IDR -#define TRIMS_GPIO_PIN_RVD GPIO_Pin_13 // PJ.13 -#define TRIMS_GPIO_REG_RHL GPIOD->IDR -#define TRIMS_GPIO_PIN_RHL GPIO_Pin_3 // PD.03 +#define TRIMS_GPIO_REG_RHL GPIOC->IDR +#define TRIMS_GPIO_PIN_RHL GPIO_Pin_0 // PC.00 +#define TRIMS_GPIO_REG_RHR GPIOI->IDR +#define TRIMS_GPIO_PIN_RHR GPIO_Pin_4 // PI.04 +#define TRIMS_GPIO_REG_RVD GPIOG->IDR +#define TRIMS_GPIO_PIN_RVD GPIO_Pin_12 // PG.12 #define TRIMS_GPIO_REG_RVU GPIOJ->IDR -#define TRIMS_GPIO_PIN_RVU GPIO_Pin_12 // PJ.12 -#define TRIMS_GPIO_REG_RHR GPIOD->IDR -#define TRIMS_GPIO_PIN_RHR GPIO_Pin_7 // PD.07 +#define TRIMS_GPIO_PIN_RVU GPIO_Pin_14 // PJ.14 +#define TRIMS_GPIO_REG_LVD GPIOJ->IDR +#define TRIMS_GPIO_PIN_LVD GPIO_Pin_13 // PJ.13 +#define TRIMS_GPIO_REG_LHL GPIOD->IDR +#define TRIMS_GPIO_PIN_LHL GPIO_Pin_3 // PD.03 +#define TRIMS_GPIO_REG_LVU GPIOJ->IDR +#define TRIMS_GPIO_PIN_LVU GPIO_Pin_12 // PJ.12 +#define TRIMS_GPIO_REG_LHR GPIOD->IDR +#define TRIMS_GPIO_PIN_LHR GPIO_Pin_7 // PD.07 #define TRIMS_GPIO_REG_RSD GPIOJ->IDR #define TRIMS_GPIO_PIN_RSD GPIO_Pin_8 // PJ.08 #define TRIMS_GPIO_REG_RSU GPIOD->IDR @@ -81,54 +81,46 @@ // Index of all keys #define KEYS_GPIOB_PINS (SWITCHES_GPIO_PIN_B_L | SWITCHES_GPIO_PIN_C_H | TRIMS_GPIO_PIN_LSD | TRIMS_GPIO_PIN_LSU) -#define KEYS_GPIOC_PINS (KEYS_GPIO_PIN_MENU | KEYS_GPIO_PIN_ENTER | KEYS_GPIO_PIN_RIGHT | TRIMS_GPIO_PIN_LHL) -#define KEYS_GPIOD_PINS (SWITCHES_GPIO_PIN_C_L | TRIMS_GPIO_PIN_RHL | TRIMS_GPIO_PIN_RHR | TRIMS_GPIO_PIN_RSU) +#define KEYS_GPIOC_PINS (KEYS_GPIO_PIN_MENU | KEYS_GPIO_PIN_ENTER | KEYS_GPIO_PIN_RIGHT | TRIMS_GPIO_PIN_RHL) +#define KEYS_GPIOD_PINS (SWITCHES_GPIO_PIN_C_L | TRIMS_GPIO_PIN_LHL | TRIMS_GPIO_PIN_LHR | TRIMS_GPIO_PIN_RSU) #define KEYS_GPIOE_PINS (SWITCHES_GPIO_PIN_E_L) -#define KEYS_GPIOG_PINS (KEYS_GPIO_PIN_UP | SWITCHES_GPIO_PIN_D_L | SWITCHES_GPIO_PIN_G_H | SWITCHES_GPIO_PIN_G_L | SWITCHES_GPIO_PIN_H | TRIMS_GPIO_PIN_LVD) +#define KEYS_GPIOG_PINS (KEYS_GPIO_PIN_UP | SWITCHES_GPIO_PIN_D_L | SWITCHES_GPIO_PIN_G_H | SWITCHES_GPIO_PIN_G_L | SWITCHES_GPIO_PIN_H | TRIMS_GPIO_PIN_RVD) #define KEYS_GPIOH_PINS (SWITCHES_GPIO_PIN_A_L | SWITCHES_GPIO_PIN_B_H | SWITCHES_GPIO_PIN_E_H | SWITCHES_GPIO_PIN_F | ENC_GPIO_PIN_A | ENC_GPIO_PIN_B) -#define KEYS_GPIOI_PINS (KEYS_GPIO_PIN_EXIT | KEYS_GPIO_PIN_LEFT | KEYS_GPIO_PIN_DOWN | SWITCHES_GPIO_PIN_A_H | TRIMS_GPIO_PIN_LHR) -#define KEYS_GPIOJ_PINS (SWITCHES_GPIO_PIN_D_H | TRIMS_GPIO_PIN_LVU | TRIMS_GPIO_PIN_RVD | TRIMS_GPIO_PIN_RVU | TRIMS_GPIO_PIN_RSD) +#define KEYS_GPIOI_PINS (KEYS_GPIO_PIN_EXIT | KEYS_GPIO_PIN_LEFT | KEYS_GPIO_PIN_DOWN | SWITCHES_GPIO_PIN_A_H | TRIMS_GPIO_PIN_RHR) +#define KEYS_GPIOJ_PINS (SWITCHES_GPIO_PIN_D_H | TRIMS_GPIO_PIN_RVU | TRIMS_GPIO_PIN_LVD | TRIMS_GPIO_PIN_LVU | TRIMS_GPIO_PIN_RSD) // ADC -#define ADC_RCC_AHB1Periph_GPIO (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC) -#define ADC_GPIO_STICKS GPIOA -#define ADC_GPIO_PIN_STICK_LV GPIO_Pin_0 // PA.00 -#define ADC_GPIO_PIN_STICK_LH GPIO_Pin_1 // PA.01 -#define ADC_GPIO_PIN_STICK_RV GPIO_Pin_2 // PA.02 -#define ADC_GPIO_PIN_STICK_RH GPIO_Pin_3 // PA.03 -#define ADC_GPIO_POT_L1 GPIOC -#define ADC_GPIO_PIN_POT_L1 GPIO_Pin_3 // PC.03 -#define ADC_GPIO_POT_R1 GPIOA -#define ADC_GPIO_PIN_POT_R1 GPIO_Pin_5 // PA.05 -#define ADC_GPIO_POT_L2 GPIOB -#define ADC_GPIO_PIN_POT_L2 GPIO_Pin_1 // PB.01 -#define ADC_GPIO_POT_R2 GPIOB -#define ADC_GPIO_PIN_POT_R2 GPIO_Pin_0 // PB.00 -#define ADC_GPIO_SWITCHES_L3 GPIOC -#define ADC_GPIO_SWITCHES_PIN_L3 GPIO_Pin_1 // PC.01 -#define ADC_GPIO_SWITCHES_R3 GPIOA -#define ADC_GPIO_SWITCHES_PIN_R3 GPIO_Pin_7 // PA.07 -#define ADC_GPIO_SWITCHES_L4 GPIOC -#define ADC_GPIO_SWITCHES_PIN_L4 GPIO_Pin_0 // PC.00 -#define ADC_GPIO_SWITCHES_R4 GPIOA -#define ADC_GPIO_SWITCHES_PIN_R4 GPIO_Pin_6 // PA.06 -#define ADC_GPIO_BATT GPIOC -#define ADC_GPIO_PIN_BATT GPIO_Pin_4 // PC.04 +#define ADC_RCC_AHB1Periph (RCC_AHB1Periph_GPIOE | RCC_AHB1Periph_GPIOF | RCC_AHB1Periph_DMA2) +#define ADC_RCC_APB2Periph (RCC_APB2Periph_SPI4 | RCC_APB2Periph_ADC3) +#define ADC_SPI SPI4 +#define ADC_GPIO_AF GPIO_AF_SPI4 +#define ADC_SPI_GPIO GPIOE +#define ADC_SPI_PIN_SCK GPIO_Pin_2 +#define ADC_SPI_PIN_CS GPIO_Pin_4 +#define ADC_SPI_PIN_MOSI GPIO_Pin_6 +#define ADC_SPI_PIN_MISO GPIO_Pin_5 +#define ADC_SPI_PinSource_SCK GPIO_PinSource2 +#define ADC_SPI_PinSource_MISO GPIO_PinSource5 +#define ADC_SPI_PinSource_MOSI GPIO_PinSource6 +#define ADC_GPIO_PIN_MOUSE1 GPIO_Pin_8 // PF.8 ADC3_IN6 J5 MOUSE_X +#define ADC_GPIO_PIN_MOUSE2 GPIO_Pin_9 // PF.9 ADC3_IN7 J6 MOUSE_Y +#define ADC_IN_MOUSE1 6 +#define ADC_IN_MOUSE2 7 // Power -#define PWR_RCC_AHB1Periph_GPIO RCC_AHB1Periph_GPIOJ +#define PWR_RCC_AHB1Periph RCC_AHB1Periph_GPIOJ #define PWR_GPIO GPIOJ #define PWR_GPIO_PIN_ON GPIO_Pin_0 // PJ.00 #define PWR_GPIO_PIN_SWITCH GPIO_Pin_1 // PJ.01 // Led -#define LED_RCC_AHB1Periph_GPIO RCC_AHB1Periph_GPIOI +#define LED_RCC_AHB1Periph RCC_AHB1Periph_GPIOI #define LED_GPIO GPIOI #define LED_GPIO_PIN GPIO_Pin_5 // PI.05 // Serial Port (DEBUG) -#define SERIAL_RCC_AHB1Periph_GPIO RCC_AHB1Periph_GPIOB -#define SERIAL_RCC_APB1Periph_USART RCC_APB1Periph_USART3 +#define SERIAL_RCC_AHB1Periph RCC_AHB1Periph_GPIOB +#define SERIAL_RCC_APB1Periph RCC_APB1Periph_USART3 #define SERIAL_GPIO GPIOB #define SERIAL_GPIO_PIN_TX GPIO_Pin_10 // PB.10 #define SERIAL_GPIO_PIN_RX GPIO_Pin_11 // PB.11 @@ -140,8 +132,8 @@ #define SERIAL_USART_IRQn USART3_IRQn // Telemetry -#define TELEMETRY_RCC_AHB1Periph_GPIO RCC_AHB1Periph_GPIOD -#define TELEMETRY_RCC_APB1Periph_USART RCC_APB1Periph_USART2 +#define TELEMETRY_RCC_AHB1Periph RCC_AHB1Periph_GPIOD +#define TELEMETRY_RCC_APB1Periph RCC_APB1Periph_USART2 #define TELEMETRY_GPIO_DIR GPIOD #define TELEMETRY_GPIO_PIN_DIR GPIO_Pin_4 // PD.04 #define TELEMETRY_GPIO GPIOD @@ -197,8 +189,8 @@ // Audio // I2C Bus: CAT5137 -#define I2C_RCC_AHB1Periph_GPIO RCC_AHB1Periph_GPIOB -#define I2C_RCC_APB1Periph_I2C RCC_APB1Periph_I2C1 +#define I2C_RCC_AHB1Periph RCC_AHB1Periph_GPIOB +#define I2C_RCC_APB1Periph RCC_APB1Periph_I2C1 #define I2C I2C1 #define I2C_GPIO GPIOB #define I2C_GPIO_PIN_SCL GPIO_Pin_8 // PB.08 @@ -210,10 +202,10 @@ #define I2C_ADDRESS_CAT5137 0x5C // Haptic -#define HAPTIC_RCC_AHB1Periph_GPIO RCC_AHB1Periph_GPIOA +#define HAPTIC_RCC_AHB1Periph RCC_AHB1Periph_GPIOA +#define HAPTIC_RCC_APB2Periph RCC_APB2ENR_TIM11EN #define HAPTIC_GPIO GPIOA #define HAPTIC_GPIO_PIN GPIO_Pin_2 -#define HAPTIC_RCC_APB2Periph_TIMER RCC_APB2ENR_TIM11EN #define HAPTIC_GPIO_TIMER TIM11 #define HAPTIC_GPIO_AF GPIO_AF_TIM11 #define HAPTIC_GPIO_PinSource GPIO_PinSource2 diff --git a/radio/src/targets/Horus/haptic_driver.cpp b/radio/src/targets/Horus/haptic_driver.cpp index 0f62cc625..9aa0e4c7e 100644 --- a/radio/src/targets/Horus/haptic_driver.cpp +++ b/radio/src/targets/Horus/haptic_driver.cpp @@ -51,9 +51,6 @@ void hapticOn(uint32_t pwmPercent) void hapticInit(void) { - RCC_AHB1PeriphClockCmd(HAPTIC_RCC_AHB1Periph_GPIO, ENABLE); - RCC_APB2PeriphClockCmd(HAPTIC_RCC_APB2Periph_TIMER, ENABLE); - GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.GPIO_Pin = HAPTIC_GPIO_PIN; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; diff --git a/radio/src/targets/Horus/i2c_driver.cpp b/radio/src/targets/Horus/i2c_driver.cpp index 79ad59260..4793fbc0c 100644 --- a/radio/src/targets/Horus/i2c_driver.cpp +++ b/radio/src/targets/Horus/i2c_driver.cpp @@ -2,9 +2,6 @@ void i2cInit(void) { - RCC_AHB1PeriphClockCmd(I2C_RCC_AHB1Periph_GPIO, ENABLE); - RCC_APB1PeriphClockCmd(I2C_RCC_APB1Periph_I2C, ENABLE); - GPIO_PinAFConfig(I2C_GPIO, I2C_GPIO_PinSource_SCL, I2C_GPIO_AF); GPIO_PinAFConfig(I2C_GPIO, I2C_GPIO_PinSource_SDA, I2C_GPIO_AF); diff --git a/radio/src/targets/Horus/keys_driver.cpp b/radio/src/targets/Horus/keys_driver.cpp index 141238c4e..692cd9a61 100644 --- a/radio/src/targets/Horus/keys_driver.cpp +++ b/radio/src/targets/Horus/keys_driver.cpp @@ -207,8 +207,6 @@ bool switchState(EnumKeys enuk) void keysInit() { - RCC_AHB1PeriphClockCmd(KEYS_RCC_AHB1Periph_GPIO, ENABLE); - GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; diff --git a/radio/src/targets/Horus/lcd_driver.cpp b/radio/src/targets/Horus/lcd_driver.cpp index 7e6b38a1a..ab73605e5 100644 --- a/radio/src/targets/Horus/lcd_driver.cpp +++ b/radio/src/targets/Horus/lcd_driver.cpp @@ -1,14 +1,3 @@ -/** - ****************************************************************************** - * @file Project/lcd/lcd.c - * @author FrSky Application Team - * @Hardware version V0.2 - * @date 11-July-2012 - * @brief This file provides LCD Init and botom drivers. - * * - ****************************************************************************** -*/ - #include "../../opentx.h" #define HBP 42 @@ -20,45 +9,20 @@ #define HFP 3 #define VFP 2 -#define LCD_PIXEL_WIDTH ((uint16_t)480) -#define LCD_PIXEL_HEIGHT ((uint16_t)272) -/** - * @brief LCD Direction - */ -#define LCD_DIR_HORIZONTAL 0x0000 -#define LCD_DIR_VERTICAL 0x0001 +#define LCD_DIR_HORIZONTAL 0x0000 +#define LCD_DIR_VERTICAL 0x0001 -/** - * @brief LCD Layer - */ -#define LCD_BACKGROUND_LAYER 0x0000 -#define LCD_FOREGROUND_LAYER 0x0001 +#define LCD_FIRST_LAYER 0 +#define LCD_SECOND_LAYER 1 -/** - * @brief The Touch panel connector for LCD panel addresses - */ -#define LCD_ADDR 0x80 -#define ASSEMBLE_RGB(R ,G, B) ((((R)& 0xF8) << 8) | (((G) & 0xFC) << 3) | (((B) & 0xF8) >> 3)) +#define LCD_BKLIGHT_PWM_FREQ 300 -#define LCD_BKLIGHT_PWM_FREQ 300 -#define ABS(X) ((X) > 0 ? (X) : -(X)) +#define LCD_FIRST_FRAME_BUFFER SDRAM_BANK_ADDR +#define LCD_SECOND_FRAME_BUFFER (SDRAM_BANK_ADDR + DISPLAY_BUFFER_SIZE) +#define LCD_BACKUP_FRAME_BUFFER (SDRAM_BANK_ADDR + 2*DISPLAY_BUFFER_SIZE) -#define POLY_X(Z) ((int32_t)((Points + Z)->X)) -#define POLY_Y(Z) ((int32_t)((Points + Z)->Y)) - -/* Global variables to set the written text color */ -static uint16_t CurrentTextColor = 0x0000; -static uint16_t CurrentBackColor = 0xFFFF; - -/** @defgroup STM324x9I_EVAL_LCD_Private_Variables - * @{ - */ -// static sFONT *LCD_Currentfonts; -#define LCD_DEFAULT_FRAME_BUFFER SDRAM_BANK_ADDR -#define FRAME_BUFFER_OFFSET ((uint32_t)0x100000) -/* Default LCD configuration with LCD Layer 1 */ -static uint32_t CurrentFrameBuffer = LCD_DEFAULT_FRAME_BUFFER; -static uint32_t CurrentLayer = LCD_BACKGROUND_LAYER; +uint32_t CurrentFrameBuffer = LCD_FIRST_FRAME_BUFFER; +uint32_t CurrentLayer = LCD_FIRST_LAYER; #define NRST_LOW() do { LCD_GPIO_NRST->BSRRH = LCD_GPIO_PIN_NRST; } while(0) #define NRST_HIGH() do { LCD_GPIO_NRST->BSRRL = LCD_GPIO_PIN_NRST; } while(0) @@ -227,13 +191,13 @@ void LCD_Init_LTDC(void) /* Configure accumulated vertical back porch */ LTDC_InitStruct.LTDC_AccumulatedVBP = VBP; /* Configure accumulated active width */ - LTDC_InitStruct.LTDC_AccumulatedActiveW = LCD_PIXEL_WIDTH + HBP; + LTDC_InitStruct.LTDC_AccumulatedActiveW = LCD_W + HBP; /* Configure accumulated active height */ - LTDC_InitStruct.LTDC_AccumulatedActiveH = LCD_PIXEL_HEIGHT + VBP; + LTDC_InitStruct.LTDC_AccumulatedActiveH = LCD_H + VBP; /* Configure total width */ - LTDC_InitStruct.LTDC_TotalWidth = LCD_PIXEL_WIDTH + HBP + HFP; + LTDC_InitStruct.LTDC_TotalWidth = LCD_W + HBP + HFP; /* Configure total height */ - LTDC_InitStruct.LTDC_TotalHeigh = LCD_PIXEL_HEIGHT + VBP + VFP; + LTDC_InitStruct.LTDC_TotalHeigh = LCD_H + VBP + VFP; // init ltdc LTDC_Init(<DC_InitStruct); @@ -274,9 +238,9 @@ void LCD_LayerInit() Vertical start = vertical synchronization + vertical back porch = 4 Vertical stop = Vertical start + window height -1 = 4 + 320 -1 */ LTDC_Layer_InitStruct.LTDC_HorizontalStart = HBP + 1; - LTDC_Layer_InitStruct.LTDC_HorizontalStop = (LCD_PIXEL_WIDTH + HBP); + LTDC_Layer_InitStruct.LTDC_HorizontalStop = (LCD_W + HBP); LTDC_Layer_InitStruct.LTDC_VerticalStart = VBP + 1;; - LTDC_Layer_InitStruct.LTDC_VerticalStop = (LCD_PIXEL_HEIGHT + VBP); + LTDC_Layer_InitStruct.LTDC_VerticalStop = (LCD_H + VBP); /* Pixel Format configuration*/ LTDC_Layer_InitStruct.LTDC_PixelFormat = LTDC_Pixelformat_RGB565; @@ -294,20 +258,20 @@ void LCD_LayerInit() /* the length of one line of pixels in bytes + 3 then : Line Lenth = Active high width x number of bytes per pixel + 3 - Active high width = LCD_PIXEL_WIDTH + Active high width = LCD_W number of bytes per pixel = 2 (pixel_format : RGB565) */ - LTDC_Layer_InitStruct.LTDC_CFBLineLength = ((LCD_PIXEL_WIDTH * 2) + 3); + LTDC_Layer_InitStruct.LTDC_CFBLineLength = ((LCD_W * 2) + 3); /* the pitch is the increment from the start of one line of pixels to the start of the next line in bytes, then : Pitch = Active high width x number of bytes per pixel */ - LTDC_Layer_InitStruct.LTDC_CFBPitch = (LCD_PIXEL_WIDTH * 2); + LTDC_Layer_InitStruct.LTDC_CFBPitch = (LCD_W * 2); /* Configure the number of lines */ - LTDC_Layer_InitStruct.LTDC_CFBLineNumber = LCD_PIXEL_HEIGHT; + LTDC_Layer_InitStruct.LTDC_CFBLineNumber = LCD_H; /* Start Address configuration : the LCD Frame buffer is defined on SDRAM w/ Offset */ - LTDC_Layer_InitStruct.LTDC_CFBStartAdress = LCD_DEFAULT_FRAME_BUFFER; + LTDC_Layer_InitStruct.LTDC_CFBStartAdress = LCD_FIRST_FRAME_BUFFER; /* Initialize LTDC layer 1 */ LTDC_LayerInit(LTDC_Layer1, <DC_Layer_InitStruct); @@ -317,7 +281,7 @@ void LCD_LayerInit() LTDC_Layer_InitStruct.LTDC_BlendingFactor_2 = LTDC_BlendingFactor2_PAxCA; /* Start Address configuration : the LCD Frame buffer is defined on SDRAM w/ Offset */ - LTDC_Layer_InitStruct.LTDC_CFBStartAdress = LCD_DEFAULT_FRAME_BUFFER + FRAME_BUFFER_OFFSET; + LTDC_Layer_InitStruct.LTDC_CFBStartAdress = LCD_FIRST_FRAME_BUFFER + DISPLAY_BUFFER_SIZE; /* Initialize LTDC layer 2 */ LTDC_LayerInit(LTDC_Layer2, <DC_Layer_InitStruct); @@ -385,9 +349,6 @@ void LCD_ControlLight(uint16_t dutyCycle) */ void LCD_Init(void) { - RCC_AHB1PeriphClockCmd(LCD_RCC_AHB1Periph, ENABLE); - RCC_APB2PeriphClockCmd(LCD_RCC_APB2Periph, ENABLE); - /* Reset the LCD --------------------------------------------------------*/ LCD_NRSTConfig(); lcd_reset(); @@ -411,48 +372,15 @@ void LCD_Init(void) */ void LCD_SetLayer(uint32_t Layerx) { - if (Layerx == LCD_BACKGROUND_LAYER) + if (Layerx == LCD_FIRST_LAYER) { - CurrentFrameBuffer = LCD_DEFAULT_FRAME_BUFFER; - CurrentLayer = LCD_BACKGROUND_LAYER; + CurrentFrameBuffer = LCD_FIRST_FRAME_BUFFER; + CurrentLayer = LCD_FIRST_LAYER; } else { - CurrentFrameBuffer = LCD_DEFAULT_FRAME_BUFFER + FRAME_BUFFER_OFFSET; - CurrentLayer = LCD_FOREGROUND_LAYER; - } -} - -#define LCD_COLOR_WHITE 0xFFFF -#define LCD_COLOR_RED 0xF800 - -void LCD_DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius) -{ - int x = -Radius, y = 0, err = 2-2*Radius, e2; - do { - *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos-x) + LCD_PIXEL_WIDTH*(Ypos+y)))) = LCD_COLOR_RED; - *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos+x) + LCD_PIXEL_WIDTH*(Ypos+y)))) = LCD_COLOR_RED; - *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos+x) + LCD_PIXEL_WIDTH*(Ypos-y)))) = LCD_COLOR_RED; - *(__IO uint16_t*) (CurrentFrameBuffer + (2*((Xpos-x) + LCD_PIXEL_WIDTH*(Ypos-y)))) = LCD_COLOR_RED; - - e2 = err; - if (e2 <= y) { - err += ++y*2+1; - if (-x == y && e2 <= x) e2 = 0; - } - if (e2 > x) err += ++x*2+1; - } - while (x <= 0); -} - -void LCD_Clear(uint16_t Color) -{ - uint16_t *index ; - - /* erase memory */ - for (index = (uint16_t *)CurrentFrameBuffer; index < (uint16_t *)(CurrentFrameBuffer+(FRAME_BUFFER_OFFSET)); index++) - { - *index = Color; + CurrentFrameBuffer = LCD_FIRST_FRAME_BUFFER + DISPLAY_BUFFER_SIZE; + CurrentLayer = LCD_SECOND_LAYER; } } @@ -464,44 +392,15 @@ void LCD_Clear(uint16_t Color) */ void LCD_SetTransparency(uint8_t transparency) { - if (CurrentLayer == LCD_BACKGROUND_LAYER) - { + if (CurrentLayer == LCD_FIRST_LAYER) { LTDC_LayerAlpha(LTDC_Layer1, transparency); } - else - { + else { LTDC_LayerAlpha(LTDC_Layer2, transparency); } LTDC_ReloadConfig(LTDC_IMReload); } -void LCD_SetColorKeying(uint32_t RGBValue) -{ - uint32_t tmp = 0; - - LTDC_ColorKeying_InitTypeDef LTDC_colorkeying_InitStruct; - - /* configure the color Keying */ - LTDC_colorkeying_InitStruct.LTDC_ColorKeyBlue = 0xFF & RGBValue; - tmp = (0xFF00 & RGBValue); - LTDC_colorkeying_InitStruct.LTDC_ColorKeyGreen = (tmp >> 8); - tmp = (0xFF0000 & RGBValue); - LTDC_colorkeying_InitStruct.LTDC_ColorKeyRed = (tmp >> 16); - - if (CurrentLayer == LCD_BACKGROUND_LAYER) - { - /* Enable the color Keying for Layer1 */ - LTDC_ColorKeyingConfig(LTDC_Layer1, <DC_colorkeying_InitStruct, ENABLE); - LTDC_ReloadConfig(LTDC_IMReload); - } - else - { - /* Enable the color Keying for Layer2 */ - LTDC_ColorKeyingConfig(LTDC_Layer2, <DC_colorkeying_InitStruct, ENABLE); - LTDC_ReloadConfig(LTDC_IMReload); - } -} - void lcdInit(void) { /* Initialize the LCD */ @@ -512,18 +411,131 @@ void lcdInit(void) LTDC_Cmd(ENABLE); /* Set Background layer */ - LCD_SetLayer(LCD_BACKGROUND_LAYER); - LCD_Clear(0); + LCD_SetLayer(LCD_FIRST_LAYER); + // lcdClear(); LCD_SetTransparency(0); - + /* Set Foreground layer */ - LCD_SetLayer(LCD_FOREGROUND_LAYER); - LCD_Clear(0); + LCD_SetLayer(LCD_SECOND_LAYER); + lcdClear(); LCD_SetTransparency(255); } +void lcdDrawSolidFilledRectDMA(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color) +{ + uint32_t addr = CurrentFrameBuffer + 2*(LCD_W*y + x); + uint8_t red = (0xF800 & color) >> 11; + uint8_t blue = 0x001F & color; + uint8_t green = (0x07E0 & color) >> 5; + + DMA2D_DeInit(); + + DMA2D_InitTypeDef DMA2D_InitStruct; + DMA2D_InitStruct.DMA2D_Mode = DMA2D_R2M; + DMA2D_InitStruct.DMA2D_CMode = DMA2D_RGB565; + DMA2D_InitStruct.DMA2D_OutputGreen = green; + DMA2D_InitStruct.DMA2D_OutputBlue = blue; + DMA2D_InitStruct.DMA2D_OutputRed = red; + DMA2D_InitStruct.DMA2D_OutputAlpha = 0x0F; + DMA2D_InitStruct.DMA2D_OutputMemoryAdd = addr; + DMA2D_InitStruct.DMA2D_OutputOffset = (LCD_W - w); + DMA2D_InitStruct.DMA2D_NumberOfLine = h; + DMA2D_InitStruct.DMA2D_PixelPerLine = w; + DMA2D_Init(&DMA2D_InitStruct); + + /* Start Transfer */ + DMA2D_StartTransfer(); + + /* Wait for CTC Flag activation */ + while (DMA2D_GetFlagStatus(DMA2D_FLAG_TC) == RESET); +} + +void lcdDrawBitmapDMA(uint16_t x, uint16_t y, uint16_t w, uint16_t h, const uint8_t * bitmap) +{ + uint32_t addr = CurrentFrameBuffer + 2*(LCD_W*y + x); + + DMA2D_DeInit(); + + DMA2D_InitTypeDef DMA2D_InitStruct; + DMA2D_InitStruct.DMA2D_Mode = DMA2D_M2M; + DMA2D_InitStruct.DMA2D_CMode = DMA2D_RGB565; + DMA2D_InitStruct.DMA2D_OutputMemoryAdd = addr; + DMA2D_InitStruct.DMA2D_OutputGreen = 0; + DMA2D_InitStruct.DMA2D_OutputBlue = 0; + DMA2D_InitStruct.DMA2D_OutputRed = 0; + DMA2D_InitStruct.DMA2D_OutputAlpha = 0; + DMA2D_InitStruct.DMA2D_OutputOffset = (LCD_W - w); + DMA2D_InitStruct.DMA2D_NumberOfLine = h; + DMA2D_InitStruct.DMA2D_PixelPerLine = w; + DMA2D_Init(&DMA2D_InitStruct); + + DMA2D_FG_InitTypeDef DMA2D_FG_InitStruct; + DMA2D_FG_StructInit(&DMA2D_FG_InitStruct); + DMA2D_FG_InitStruct.DMA2D_FGMA = CONVERT_PTR_UINT(bitmap); + DMA2D_FG_InitStruct.DMA2D_FGO = 0; + DMA2D_FG_InitStruct.DMA2D_FGCM = CM_RGB565; + DMA2D_FG_InitStruct.DMA2D_FGPFC_ALPHA_MODE = NO_MODIF_ALPHA_VALUE; + DMA2D_FG_InitStruct.DMA2D_FGPFC_ALPHA_VALUE = 0; + DMA2D_FGConfig(&DMA2D_FG_InitStruct); + + /* Start Transfer */ + DMA2D_StartTransfer(); + + /* Wait for CTC Flag activation */ + while (DMA2D_GetFlagStatus(DMA2D_FLAG_TC) == RESET); +} + +void DMAcopy(void * src, void * dest, int len) +{ + DMA2D_DeInit(); + + DMA2D_InitTypeDef DMA2D_InitStruct; + DMA2D_InitStruct.DMA2D_Mode = DMA2D_M2M; + DMA2D_InitStruct.DMA2D_CMode = DMA2D_RGB565; + DMA2D_InitStruct.DMA2D_OutputMemoryAdd = CONVERT_PTR_UINT(dest); + DMA2D_InitStruct.DMA2D_OutputGreen = 0; + DMA2D_InitStruct.DMA2D_OutputBlue = 0; + DMA2D_InitStruct.DMA2D_OutputRed = 0; + DMA2D_InitStruct.DMA2D_OutputAlpha = 0; + DMA2D_InitStruct.DMA2D_OutputOffset = 0; + DMA2D_InitStruct.DMA2D_NumberOfLine = LCD_H; + DMA2D_InitStruct.DMA2D_PixelPerLine = LCD_W; + DMA2D_Init(&DMA2D_InitStruct); + + DMA2D_FG_InitTypeDef DMA2D_FG_InitStruct; + DMA2D_FG_StructInit(&DMA2D_FG_InitStruct); + DMA2D_FG_InitStruct.DMA2D_FGMA = CONVERT_PTR_UINT(src); + DMA2D_FG_InitStruct.DMA2D_FGO = 0; + DMA2D_FG_InitStruct.DMA2D_FGCM = CM_RGB565; + DMA2D_FG_InitStruct.DMA2D_FGPFC_ALPHA_MODE = NO_MODIF_ALPHA_VALUE; + DMA2D_FG_InitStruct.DMA2D_FGPFC_ALPHA_VALUE = 0; + DMA2D_FGConfig(&DMA2D_FG_InitStruct); + + /* Start Transfer */ + DMA2D_StartTransfer(); + + /* Wait for CTC Flag activation */ + while (DMA2D_GetFlagStatus(DMA2D_FLAG_TC) == RESET); +} + +void lcdStoreBackupBuffer() +{ + uint16_t * src = (uint16_t *)CurrentFrameBuffer, * dest = (uint16_t *)LCD_BACKUP_FRAME_BUFFER; + DMAcopy(src, dest, DISPLAY_BUFFER_SIZE); +} + +void lcdRestoreBackupBuffer() +{ + uint16_t * dest = (uint16_t *)CurrentFrameBuffer, * src = (uint16_t *)LCD_BACKUP_FRAME_BUFFER; + DMAcopy(src, dest, DISPLAY_BUFFER_SIZE); +} void lcdRefresh() { - memcpy((void *)(SDRAM_BANK_ADDR+FRAME_BUFFER_OFFSET), (void *)SDRAM_BANK_ADDR, 480*272*2); + LCD_SetTransparency(255); + if (CurrentLayer == LCD_FIRST_LAYER) + LCD_SetLayer(LCD_SECOND_LAYER); + else + LCD_SetLayer(LCD_FIRST_LAYER); + LCD_SetTransparency(0); } diff --git a/radio/src/targets/Horus/led_driver.cpp b/radio/src/targets/Horus/led_driver.cpp index 8da96ac4c..e3f1b9547 100644 --- a/radio/src/targets/Horus/led_driver.cpp +++ b/radio/src/targets/Horus/led_driver.cpp @@ -38,7 +38,7 @@ void ledInit() { - RCC_AHB1PeriphClockCmd(LED_RCC_AHB1Periph_GPIO, ENABLE); + RCC_AHB1PeriphClockCmd(LED_RCC_AHB1Periph, ENABLE); GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.GPIO_Pin = LED_GPIO_PIN; @@ -51,7 +51,7 @@ void ledInit() void ledOff() { - RCC_AHB1PeriphClockCmd(LED_RCC_AHB1Periph_GPIO, DISABLE); + RCC_AHB1PeriphClockCmd(LED_RCC_AHB1Periph, DISABLE); } void ledRed() diff --git a/radio/src/targets/Horus/pulses_driver.cpp b/radio/src/targets/Horus/pulses_driver.cpp index 9094ee3b9..7daa3f516 100644 --- a/radio/src/targets/Horus/pulses_driver.cpp +++ b/radio/src/targets/Horus/pulses_driver.cpp @@ -55,7 +55,7 @@ void init_no_pulses(uint32_t port) // Timer1, channel 1 GPIO_InitTypeDef GPIO_InitStructure; RCC_AHB1PeriphClockCmd(EXTMODULE_RCC_AHB1Periph_GPIO, ENABLE); - + GPIO_InitStructure.GPIO_Pin = EXTMODULE_GPIO_PIN; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT ; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; diff --git a/radio/src/targets/Horus/pwr_driver.c b/radio/src/targets/Horus/pwr_driver.c index a7202ca8e..2c63ef630 100644 --- a/radio/src/targets/Horus/pwr_driver.c +++ b/radio/src/targets/Horus/pwr_driver.c @@ -44,9 +44,6 @@ void pwrInit() { GPIO_InitTypeDef GPIO_InitStructure; - /* Clock enable */ - RCC_AHB1PeriphClockCmd(PWR_RCC_AHB1Periph_GPIO, ENABLE); - /* GPIO Configuration*/ GPIO_InitStructure.GPIO_Pin = PWR_GPIO_PIN_ON; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; diff --git a/radio/src/targets/Horus/sdio_sd.c b/radio/src/targets/Horus/sdio_sd.c index 8749bc62f..9691c7e1c 100644 --- a/radio/src/targets/Horus/sdio_sd.c +++ b/radio/src/targets/Horus/sdio_sd.c @@ -331,21 +331,6 @@ */ #define SDIO_SEND_IF_COND ((uint32_t)0x00000008) -/** - * @} - */ - -/** @defgroup STM32F4_DISCOVERY_SDIO_SD_Private_Macros - * @{ - */ -/** - * @} - */ - -/** @defgroup STM32F4_DISCOVERY_SDIO_SD_Private_Variables - * @{ - */ - static uint32_t CardType = SDIO_STD_CAPACITY_SD_CARD_V1_1; static uint32_t CSD_Tab[4], CID_Tab[4], RCA = 0; static uint8_t SDSTATUS_Tab[16]; @@ -357,14 +342,7 @@ SD_CardInfo SDCardInfo; SDIO_InitTypeDef SDIO_InitStructure; SDIO_CmdInitTypeDef SDIO_CmdInitStructure; SDIO_DataInitTypeDef SDIO_DataInitStructure; -/** - * @} - */ - -/** @defgroup STM32F4_DISCOVERY_SDIO_SD_Private_Function_Prototypes - * @{ - */ static SD_Error CmdError(void); static SD_Error CmdResp1Error(uint8_t cmd); static SD_Error CmdResp7Error(void); @@ -440,7 +418,7 @@ void SD_LowLevel_Init(void) /* Configure PC.08, PC.09, PC.10, PC.11 pins: D0, D1, D2, D3 pins */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_25MHz; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; @@ -498,7 +476,7 @@ void SD_LowLevel_DMA_TxConfig(uint32_t *BufferSRC, uint32_t BufferSize) SDDMA_InitStructure.DMA_PeripheralBaseAddr = SD_SDIO_FIFO_ADDRESS; SDDMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)BufferSRC; SDDMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral; - SDDMA_InitStructure.DMA_BufferSize = 0; + SDDMA_InitStructure.DMA_BufferSize = 1; SDDMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; SDDMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; SDDMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word; @@ -540,7 +518,7 @@ void SD_LowLevel_DMA_RxConfig(uint32_t *BufferDST, uint32_t BufferSize) SDDMA_InitStructure.DMA_PeripheralBaseAddr = SD_SDIO_FIFO_ADDRESS; SDDMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)BufferDST; SDDMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory; - SDDMA_InitStructure.DMA_BufferSize = 0; + SDDMA_InitStructure.DMA_BufferSize = 1; SDDMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; SDDMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; SDDMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word; @@ -712,13 +690,17 @@ uint8_t SD_Detect(void) return status; } +//--------------------------------------------------------------------------------------- +//disable optimize +#define OPTIMIZE(level) __attribute__((optimize(level))) + /** * @brief Enquires cards about their operating voltage and configures * clock controls. * @param None * @retval SD_Error: SD Card Error code. */ -SD_Error SD_PowerON(void) +OPTIMIZE("O0") SD_Error SD_PowerON(void) { __IO SD_Error errorstatus = SD_OK; uint32_t response = 0, count = 0, validvoltage = 0; @@ -865,7 +847,7 @@ SD_Error SD_PowerON(void) * @param None * @retval SD_Error: SD Card Error code. */ -SD_Error SD_PowerOFF(void) +OPTIMIZE("O0") SD_Error SD_PowerOFF(void) { SD_Error errorstatus = SD_OK; @@ -881,7 +863,7 @@ SD_Error SD_PowerOFF(void) * @param None * @retval SD_Error: SD Card Error code. */ -SD_Error SD_InitializeCards(void) +OPTIMIZE("O0") SD_Error SD_InitializeCards(void) { SD_Error errorstatus = SD_OK; uint16_t rca = 0x01; @@ -970,7 +952,7 @@ SD_Error SD_InitializeCards(void) * information. * @retval SD_Error: SD Card Error code. */ -SD_Error SD_GetCardInfo(SD_CardInfo *cardinfo) +OPTIMIZE("O0") SD_Error SD_GetCardInfo(SD_CardInfo *cardinfo) { SD_Error errorstatus = SD_OK; uint8_t tmp = 0; @@ -1061,7 +1043,7 @@ SD_Error SD_GetCardInfo(SD_CardInfo *cardinfo) /*!< Byte 10 */ tmp = (uint8_t)((CSD_Tab[2] & 0x0000FF00) >> 8); - cardinfo->CardCapacity = (uint64_t)(cardinfo->SD_csd.DeviceSize + 1) * (uint64_t)(512 * 1024); + cardinfo->CardCapacity = ((uint64_t)cardinfo->SD_csd.DeviceSize + 1) * 512 * 1024; cardinfo->CardBlockSize = 512; } @@ -1182,7 +1164,7 @@ SD_Error SD_GetCardInfo(SD_CardInfo *cardinfo) * @arg SDIO_BusWide_1b: 1-bit data transfer * @retval SD_Error: SD Card Error code. */ -SD_Error SD_GetCardStatus(SD_CardStatus *cardstatus) +OPTIMIZE("O0") SD_Error SD_GetCardStatus(SD_CardStatus *cardstatus) { SD_Error errorstatus = SD_OK; uint8_t tmp = 0; @@ -1267,7 +1249,7 @@ SD_Error SD_GetCardStatus(SD_CardStatus *cardstatus) * @arg SDIO_BusWide_1b: 1-bit data transfer * @retval SD_Error: SD Card Error code. */ -SD_Error SD_EnableWideBusOperation(uint32_t WideMode) +OPTIMIZE("O0") SD_Error SD_EnableWideBusOperation(uint32_t WideMode) { SD_Error errorstatus = SD_OK; @@ -1326,7 +1308,7 @@ SD_Error SD_EnableWideBusOperation(uint32_t WideMode) * @param addr: Address of the Card to be selected. * @retval SD_Error: SD Card Error code. */ -SD_Error SD_SelectDeselect(uint32_t addr) +OPTIMIZE("O0") SD_Error SD_SelectDeselect(uint32_t addr) { SD_Error errorstatus = SD_OK; @@ -1357,7 +1339,7 @@ SD_Error SD_SelectDeselect(uint32_t addr) * @param BlockSize: the SD card Data block size. The Block size should be 512. * @retval SD_Error: SD Card Error code. */ -SD_Error SD_ReadBlock(uint8_t *readbuff, uint32_t ReadAddr, uint16_t BlockSize) +OPTIMIZE("O0") SD_Error SD_ReadBlock(uint8_t *readbuff, uint32_t ReadAddr, uint16_t BlockSize) { SD_Error errorstatus = SD_OK; #if defined (SD_POLLING_MODE) @@ -1367,13 +1349,21 @@ SD_Error SD_ReadBlock(uint8_t *readbuff, uint32_t ReadAddr, uint16_t BlockSize) TransferError = SD_OK; TransferEnd = 0; StopCondition = 0; + DMAEndOfTransfer = 0; SDIO->DCTRL = 0x0; - if (CardType == SDIO_HIGH_CAPACITY_SD_CARD) - { +#if defined (SD_DMA_MODE) + SDIO_ITConfig(SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT | SDIO_IT_DATAEND | SDIO_IT_RXOVERR | SDIO_IT_STBITERR, ENABLE); + SDIO_DMACmd(ENABLE); + SD_LowLevel_DMA_RxConfig((uint32_t *)readbuff, BlockSize); +#endif + + if (CardType == SDIO_HIGH_CAPACITY_SD_CARD) { BlockSize = 512; - ReadAddr /= 512; + } + else { + ReadAddr *= 512; } /* Set Block Size for Card */ @@ -1464,10 +1454,6 @@ SD_Error SD_ReadBlock(uint8_t *readbuff, uint32_t ReadAddr, uint16_t BlockSize) /*!< Clear all the static flags */ SDIO_ClearFlag(SDIO_STATIC_FLAGS); -#elif defined (SD_DMA_MODE) - SDIO_ITConfig(SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT | SDIO_IT_DATAEND | SDIO_IT_RXOVERR | SDIO_IT_STBITERR, ENABLE); - SDIO_DMACmd(ENABLE); - SD_LowLevel_DMA_RxConfig((uint32_t *)readbuff, BlockSize); #endif return(errorstatus); @@ -1488,19 +1474,25 @@ SD_Error SD_ReadBlock(uint8_t *readbuff, uint32_t ReadAddr, uint16_t BlockSize) * @param NumberOfBlocks: number of blocks to be read. * @retval SD_Error: SD Card Error code. */ -SD_Error SD_ReadMultiBlocks(uint8_t *readbuff, uint32_t ReadAddr, uint16_t BlockSize, uint32_t NumberOfBlocks) +OPTIMIZE("O0") SD_Error SD_ReadMultiBlocks(uint8_t *readbuff, uint32_t ReadAddr, uint16_t BlockSize, uint32_t NumberOfBlocks) { SD_Error errorstatus = SD_OK; TransferError = SD_OK; TransferEnd = 0; StopCondition = 1; + DMAEndOfTransfer = 0; SDIO->DCTRL = 0x0; - if (CardType == SDIO_HIGH_CAPACITY_SD_CARD) - { + SDIO_ITConfig(SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT | SDIO_IT_DATAEND | SDIO_IT_RXOVERR | SDIO_IT_STBITERR, ENABLE); + SD_LowLevel_DMA_RxConfig((uint32_t *)readbuff, (NumberOfBlocks * BlockSize)); + SDIO_DMACmd(ENABLE); + + if (CardType == SDIO_HIGH_CAPACITY_SD_CARD) { BlockSize = 512; - ReadAddr /= 512; + } + else { + ReadAddr *= 512; } /*!< Set Block Size for Card */ @@ -1541,71 +1533,6 @@ SD_Error SD_ReadMultiBlocks(uint8_t *readbuff, uint32_t ReadAddr, uint16_t Block return(errorstatus); } - SDIO_ITConfig(SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT | SDIO_IT_DATAEND | SDIO_IT_RXOVERR | SDIO_IT_STBITERR, ENABLE); - SDIO_DMACmd(ENABLE); - SD_LowLevel_DMA_RxConfig((uint32_t *)readbuff, (NumberOfBlocks * BlockSize)); - - return(errorstatus); -} - -// FIXED Version where ReadAddr is in BLOCKS NOT BYTES, permits SDHC media >4GB - -SD_Error SD_ReadMultiBlocksFIXED(uint8_t *readbuff, uint32_t ReadAddr, uint32_t BlockSize, uint32_t NumberOfBlocks) -{ - SD_Error errorstatus = SD_OK; - TransferError = SD_OK; - TransferEnd = 0; - StopCondition = 1; - - SDIO->DCTRL = 0x0; - - if (CardType == SDIO_HIGH_CAPACITY_SD_CARD) - BlockSize = 512; - else - ReadAddr *= BlockSize; // Convert to Bytes for NON SDHC - - /*!< Set Block Size for Card */ - SDIO_CmdInitStructure.SDIO_Argument = (uint32_t) BlockSize; - SDIO_CmdInitStructure.SDIO_CmdIndex = SD_CMD_SET_BLOCKLEN; - SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short; - SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No; - SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable; - SDIO_SendCommand(&SDIO_CmdInitStructure); - - errorstatus = CmdResp1Error(SD_CMD_SET_BLOCKLEN); - - if (SD_OK != errorstatus) - { - return(errorstatus); - } - - SDIO_DataInitStructure.SDIO_DataTimeOut = SD_DATATIMEOUT; - SDIO_DataInitStructure.SDIO_DataLength = NumberOfBlocks * BlockSize; - SDIO_DataInitStructure.SDIO_DataBlockSize = (uint32_t) 9 << 4; - SDIO_DataInitStructure.SDIO_TransferDir = SDIO_TransferDir_ToSDIO; - SDIO_DataInitStructure.SDIO_TransferMode = SDIO_TransferMode_Block; - SDIO_DataInitStructure.SDIO_DPSM = SDIO_DPSM_Enable; - SDIO_DataConfig(&SDIO_DataInitStructure); - - /*!< Send CMD18 READ_MULT_BLOCK with argument data address */ - SDIO_CmdInitStructure.SDIO_Argument = (uint32_t)ReadAddr; - SDIO_CmdInitStructure.SDIO_CmdIndex = SD_CMD_READ_MULT_BLOCK; - SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short; - SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No; - SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable; - SDIO_SendCommand(&SDIO_CmdInitStructure); - - errorstatus = CmdResp1Error(SD_CMD_READ_MULT_BLOCK); - - if (errorstatus != SD_OK) - { - return(errorstatus); - } - - SDIO_ITConfig(SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT | SDIO_IT_DATAEND | SDIO_IT_RXOVERR | SDIO_IT_STBITERR, ENABLE); - SDIO_DMACmd(ENABLE); - SD_LowLevel_DMA_RxConfig((uint32_t *)readbuff, (NumberOfBlocks * BlockSize)); - return(errorstatus); } @@ -1617,7 +1544,7 @@ SD_Error SD_ReadMultiBlocksFIXED(uint8_t *readbuff, uint32_t ReadAddr, uint32_t * @param None. * @retval SD_Error: SD Card Error code. */ -SD_Error SD_WaitReadOperation(void) +OPTIMIZE("O0") SD_Error SD_WaitReadOperation(void) { SD_Error errorstatus = SD_OK; uint32_t timeout; @@ -1641,6 +1568,7 @@ SD_Error SD_WaitReadOperation(void) if (StopCondition == 1) { errorstatus = SD_StopTransfer(); + StopCondition = 0; } if ((timeout == 0) && (errorstatus == SD_OK)) @@ -1675,7 +1603,7 @@ SD_Error SD_WaitReadOperation(void) * @param BlockSize: the SD card Data block size. The Block size should be 512. * @retval SD_Error: SD Card Error code. */ -SD_Error SD_WriteBlock(uint8_t *writebuff, uint32_t WriteAddr, uint16_t BlockSize) +OPTIMIZE("O0") SD_Error SD_WriteBlock(uint8_t *writebuff, uint32_t WriteAddr, uint16_t BlockSize) { SD_Error errorstatus = SD_OK; @@ -1690,6 +1618,11 @@ SD_Error SD_WriteBlock(uint8_t *writebuff, uint32_t WriteAddr, uint16_t BlockSiz SDIO->DCTRL = 0x0; +#if defined (SD_DMA_MODE) + SDIO_ITConfig(SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT | SDIO_IT_DATAEND | SDIO_IT_RXOVERR | SDIO_IT_STBITERR, ENABLE); + SD_LowLevel_DMA_TxConfig((uint32_t *)writebuff, BlockSize); + SDIO_DMACmd(ENABLE); +#endif if (CardType == SDIO_HIGH_CAPACITY_SD_CARD) { @@ -1784,10 +1717,6 @@ SD_Error SD_WriteBlock(uint8_t *writebuff, uint32_t WriteAddr, uint16_t BlockSiz errorstatus = SD_START_BIT_ERR; return(errorstatus); } -#elif defined (SD_DMA_MODE) - SDIO_ITConfig(SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT | SDIO_IT_DATAEND | SDIO_IT_RXOVERR | SDIO_IT_STBITERR, ENABLE); - SD_LowLevel_DMA_TxConfig((uint32_t *)writebuff, BlockSize); - SDIO_DMACmd(ENABLE); #endif return(errorstatus); @@ -1808,7 +1737,7 @@ SD_Error SD_WriteBlock(uint8_t *writebuff, uint32_t WriteAddr, uint16_t BlockSiz * @param NumberOfBlocks: number of blocks to be written. * @retval SD_Error: SD Card Error code. */ -SD_Error SD_WriteMultiBlocks(uint8_t *writebuff, uint32_t WriteAddr, uint16_t BlockSize, uint32_t NumberOfBlocks) +OPTIMIZE("O0") SD_Error SD_WriteMultiBlocks(uint8_t *writebuff, uint32_t WriteAddr, uint16_t BlockSize, uint32_t NumberOfBlocks) { SD_Error errorstatus = SD_OK; @@ -1818,6 +1747,10 @@ SD_Error SD_WriteMultiBlocks(uint8_t *writebuff, uint32_t WriteAddr, uint16_t Bl SDIO->DCTRL = 0x0; + SDIO_ITConfig(SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT | SDIO_IT_DATAEND | SDIO_IT_TXUNDERR | SDIO_IT_STBITERR, ENABLE); + SD_LowLevel_DMA_TxConfig((uint32_t *)writebuff, (NumberOfBlocks * BlockSize)); + SDIO_DMACmd(ENABLE); + if (CardType == SDIO_HIGH_CAPACITY_SD_CARD) { BlockSize = 512; @@ -1893,105 +1826,9 @@ SD_Error SD_WriteMultiBlocks(uint8_t *writebuff, uint32_t WriteAddr, uint16_t Bl SDIO_DataInitStructure.SDIO_DPSM = SDIO_DPSM_Enable; SDIO_DataConfig(&SDIO_DataInitStructure); - SDIO_ITConfig(SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT | SDIO_IT_DATAEND | SDIO_IT_RXOVERR | SDIO_IT_STBITERR, ENABLE); - SDIO_DMACmd(ENABLE); - SD_LowLevel_DMA_TxConfig((uint32_t *)writebuff, (NumberOfBlocks * BlockSize)); - return(errorstatus); } -// FIXED Version where WriteAddr is in BLOCKS NOT BYTES, permits SDHC media >4GB - -SD_Error SD_WriteMultiBlocksFIXED(uint8_t *writebuff, uint32_t WriteAddr, uint32_t BlockSize, uint32_t NumberOfBlocks) -{ - SD_Error errorstatus = SD_OK; - - TransferError = SD_OK; - TransferEnd = 0; - StopCondition = 1; - - SDIO->DCTRL = 0x0; - - if (CardType == SDIO_HIGH_CAPACITY_SD_CARD) - BlockSize = 512; - else - WriteAddr *= BlockSize; // Convert to Bytes for NON SDHC - - /* Set Block Size for Card */ - SDIO_CmdInitStructure.SDIO_Argument = (uint32_t) BlockSize; - SDIO_CmdInitStructure.SDIO_CmdIndex = SD_CMD_SET_BLOCKLEN; - SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short; - SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No; - SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable; - SDIO_SendCommand(&SDIO_CmdInitStructure); - - errorstatus = CmdResp1Error(SD_CMD_SET_BLOCKLEN); - - if (SD_OK != errorstatus) - { - return(errorstatus); - } - - /*!< To improve performance */ - SDIO_CmdInitStructure.SDIO_Argument = (uint32_t) (RCA << 16); - SDIO_CmdInitStructure.SDIO_CmdIndex = SD_CMD_APP_CMD; - SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short; - SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No; - SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable; - SDIO_SendCommand(&SDIO_CmdInitStructure); - - - errorstatus = CmdResp1Error(SD_CMD_APP_CMD); - - if (errorstatus != SD_OK) - { - return(errorstatus); - } - /*!< To improve performance */ - SDIO_CmdInitStructure.SDIO_Argument = (uint32_t)NumberOfBlocks; - SDIO_CmdInitStructure.SDIO_CmdIndex = SD_CMD_SET_BLOCK_COUNT; - SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short; - SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No; - SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable; - SDIO_SendCommand(&SDIO_CmdInitStructure); - - errorstatus = CmdResp1Error(SD_CMD_SET_BLOCK_COUNT); - - if (errorstatus != SD_OK) - { - return(errorstatus); - } - - - /*!< Send CMD25 WRITE_MULT_BLOCK with argument data address */ - SDIO_CmdInitStructure.SDIO_Argument = (uint32_t)WriteAddr; - SDIO_CmdInitStructure.SDIO_CmdIndex = SD_CMD_WRITE_MULT_BLOCK; - SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short; - SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No; - SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable; - SDIO_SendCommand(&SDIO_CmdInitStructure); - - errorstatus = CmdResp1Error(SD_CMD_WRITE_MULT_BLOCK); - - if (SD_OK != errorstatus) - { - return(errorstatus); - } - - SDIO_DataInitStructure.SDIO_DataTimeOut = SD_DATATIMEOUT; - SDIO_DataInitStructure.SDIO_DataLength = NumberOfBlocks * BlockSize; - SDIO_DataInitStructure.SDIO_DataBlockSize = (uint32_t) 9 << 4; - SDIO_DataInitStructure.SDIO_TransferDir = SDIO_TransferDir_ToCard; - SDIO_DataInitStructure.SDIO_TransferMode = SDIO_TransferMode_Block; - SDIO_DataInitStructure.SDIO_DPSM = SDIO_DPSM_Enable; - SDIO_DataConfig(&SDIO_DataInitStructure); - - SDIO_ITConfig(SDIO_IT_DCRCFAIL | SDIO_IT_DTIMEOUT | SDIO_IT_DATAEND | SDIO_IT_RXOVERR | SDIO_IT_STBITERR, ENABLE); - SDIO_DMACmd(ENABLE); - SD_LowLevel_DMA_TxConfig((uint32_t *)writebuff, (NumberOfBlocks * BlockSize)); - - return(errorstatus); -} /** * @brief This function waits until the SDIO DMA data transfer is finished. @@ -2001,7 +1838,7 @@ SD_Error SD_WriteMultiBlocksFIXED(uint8_t *writebuff, uint32_t WriteAddr, uint32 * @param None. * @retval SD_Error: SD Card Error code. */ -SD_Error SD_WaitWriteOperation(void) +OPTIMIZE("O0") SD_Error SD_WaitWriteOperation(void) { SD_Error errorstatus = SD_OK; uint32_t timeout; @@ -2025,6 +1862,7 @@ SD_Error SD_WaitWriteOperation(void) if (StopCondition == 1) { errorstatus = SD_StopTransfer(); + StopCondition = 0; } if ((timeout == 0) && (errorstatus == SD_OK)) @@ -2053,7 +1891,7 @@ SD_Error SD_WaitWriteOperation(void) * - SD_TRANSFER_OK: No data transfer is acting * - SD_TRANSFER_BUSY: Data transfer is acting */ -SDTransferState SD_GetTransferState(void) +OPTIMIZE("O0") SDTransferState SD_GetTransferState(void) { if (SDIO->STA & (SDIO_FLAG_TXACT | SDIO_FLAG_RXACT)) { @@ -2070,7 +1908,7 @@ SDTransferState SD_GetTransferState(void) * @param None * @retval SD_Error: SD Card Error code. */ -SD_Error SD_StopTransfer(void) +OPTIMIZE("O0") SD_Error SD_StopTransfer(void) { SD_Error errorstatus = SD_OK; @@ -2093,7 +1931,7 @@ SD_Error SD_StopTransfer(void) * @param endaddr: the end address. * @retval SD_Error: SD Card Error code. */ -SD_Error SD_Erase(uint32_t startaddr, uint32_t endaddr) +OPTIMIZE("O0") SD_Error SD_Erase(uint32_t startaddr, uint32_t endaddr) { SD_Error errorstatus = SD_OK; uint32_t delay = 0; @@ -2189,7 +2027,7 @@ SD_Error SD_Erase(uint32_t startaddr, uint32_t endaddr) * status (Card Status register). * @retval SD_Error: SD Card Error code. */ -SD_Error SD_SendStatus(uint32_t *pcardstatus) +OPTIMIZE("O0") SD_Error SD_SendStatus(uint32_t *pcardstatus) { SD_Error errorstatus = SD_OK; @@ -2224,7 +2062,7 @@ SD_Error SD_SendStatus(uint32_t *pcardstatus) * (SD Status register). * @retval SD_Error: SD Card Error code. */ -SD_Error SD_SendSDStatus(uint32_t *psdstatus) +OPTIMIZE("O0") SD_Error SD_SendSDStatus(uint32_t *psdstatus) { SD_Error errorstatus = SD_OK; uint32_t count = 0; @@ -2341,7 +2179,7 @@ SD_Error SD_SendSDStatus(uint32_t *psdstatus) * @param None * @retval SD_Error: SD Card Error code. */ -SD_Error SD_ProcessIRQ(void) +OPTIMIZE("O0") SD_Error SD_ProcessIRQ(void) { if (SDIO_GetITStatus(SDIO_IT_DATAEND) != RESET) { @@ -2386,7 +2224,7 @@ SD_Error SD_ProcessIRQ(void) * @param None. * @retval None. */ -void SD_ProcessDMAIRQ(void) +OPTIMIZE("O0") void SD_ProcessDMAIRQ(void) { if(DMA2->LISR & SD_SDIO_DMA_FLAG_TCIF) { @@ -2400,7 +2238,7 @@ void SD_ProcessDMAIRQ(void) * @param None * @retval SD_Error: SD Card Error code. */ -static SD_Error CmdError(void) +OPTIMIZE("O0") static SD_Error CmdError(void) { SD_Error errorstatus = SD_OK; uint32_t timeout; @@ -2429,7 +2267,7 @@ static SD_Error CmdError(void) * @param None * @retval SD_Error: SD Card Error code. */ -static SD_Error CmdResp7Error(void) +OPTIMIZE("O0") static SD_Error CmdResp7Error(void) { SD_Error errorstatus = SD_OK; uint32_t status; @@ -2466,7 +2304,7 @@ static SD_Error CmdResp7Error(void) * @param cmd: The sent command index. * @retval SD_Error: SD Card Error code. */ -static SD_Error CmdResp1Error(uint8_t cmd) +OPTIMIZE("O0") static SD_Error CmdResp1Error(uint8_t cmd) { SD_Error errorstatus = SD_OK; uint32_t status; @@ -2612,7 +2450,7 @@ static SD_Error CmdResp1Error(uint8_t cmd) * @param None * @retval SD_Error: SD Card Error code. */ -static SD_Error CmdResp3Error(void) +OPTIMIZE("O0") static SD_Error CmdResp3Error(void) { SD_Error errorstatus = SD_OK; uint32_t status; @@ -2640,7 +2478,7 @@ static SD_Error CmdResp3Error(void) * @param None * @retval SD_Error: SD Card Error code. */ -static SD_Error CmdResp2Error(void) +OPTIMIZE("O0") static SD_Error CmdResp2Error(void) { SD_Error errorstatus = SD_OK; uint32_t status; @@ -2678,7 +2516,7 @@ static SD_Error CmdResp2Error(void) * address RCA. * @retval SD_Error: SD Card Error code. */ -static SD_Error CmdResp6Error(uint8_t cmd, uint16_t *prca) +OPTIMIZE("O0") static SD_Error CmdResp6Error(uint8_t cmd, uint16_t *prca) { SD_Error errorstatus = SD_OK; uint32_t status; @@ -2747,7 +2585,7 @@ static SD_Error CmdResp6Error(uint8_t cmd, uint16_t *prca) * This parameter can be: ENABLE or DISABLE. * @retval SD_Error: SD Card Error code. */ -static SD_Error SDEnWideBus(FunctionalState NewState) +OPTIMIZE("O0") static SD_Error SDEnWideBus(FunctionalState NewState) { SD_Error errorstatus = SD_OK; @@ -2861,7 +2699,7 @@ static SD_Error SDEnWideBus(FunctionalState NewState) * @param pstatus: pointer to the variable that will contain the SD card state. * @retval SD_Error: SD Card Error code. */ -static SD_Error IsCardProgramming(uint8_t *pstatus) +OPTIMIZE("O0") static SD_Error IsCardProgramming(uint8_t *pstatus) { SD_Error errorstatus = SD_OK; __IO uint32_t respR1 = 0, status = 0; @@ -3020,7 +2858,7 @@ static SD_Error IsCardProgramming(uint8_t *pstatus) * @param pscr: pointer to the buffer that will contain the SCR value. * @retval SD_Error: SD Card Error code. */ -static SD_Error FindSCR(uint16_t rca, uint32_t *pscr) +OPTIMIZE("O0") static SD_Error FindSCR(uint16_t rca, uint32_t *pscr) { uint32_t index = 0; SD_Error errorstatus = SD_OK; @@ -3129,7 +2967,7 @@ static SD_Error FindSCR(uint16_t rca, uint32_t *pscr) * @param NumberOfBytes: number of bytes. * @retval None */ -uint8_t convert_from_bytes_to_power_of_two(uint16_t NumberOfBytes) +OPTIMIZE("O0") uint8_t convert_from_bytes_to_power_of_two(uint16_t NumberOfBytes) { uint8_t count = 0; diff --git a/radio/src/targets/Horus/sdio_sd.h b/radio/src/targets/Horus/sdio_sd.h index 5d3671b78..8e69d25d4 100644 --- a/radio/src/targets/Horus/sdio_sd.h +++ b/radio/src/targets/Horus/sdio_sd.h @@ -386,6 +386,8 @@ SD_Error SD_WaitWriteOperation(void); } #endif +extern SD_CardInfo SDCardInfo; + #endif /* __STM32F4_DISCOVERY_SDIO_SD_H */ /** * @} diff --git a/radio/src/targets/Horus/serial2_driver.cpp b/radio/src/targets/Horus/serial2_driver.cpp index 12d4bf94f..ff34fb186 100644 --- a/radio/src/targets/Horus/serial2_driver.cpp +++ b/radio/src/targets/Horus/serial2_driver.cpp @@ -46,8 +46,6 @@ void uart3Setup(unsigned int baudrate) USART_InitTypeDef USART_InitStructure; GPIO_InitTypeDef GPIO_InitStructure; - RCC_AHB1PeriphClockCmd(SERIAL_RCC_AHB1Periph_GPIO, ENABLE); - GPIO_PinAFConfig(SERIAL_GPIO, SERIAL_GPIO_PinSource_RX, SERIAL_GPIO_AF); GPIO_PinAFConfig(SERIAL_GPIO, SERIAL_GPIO_PinSource_TX, SERIAL_GPIO_AF); @@ -58,8 +56,6 @@ void uart3Setup(unsigned int baudrate) GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(SERIAL_GPIO, &GPIO_InitStructure); - RCC_APB1PeriphClockCmd(SERIAL_RCC_APB1Periph_USART, ENABLE); - USART_InitStructure.USART_BaudRate = baudrate; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; diff --git a/radio/src/targets/Horus/telemetry_driver.cpp b/radio/src/targets/Horus/telemetry_driver.cpp index 998204738..1ce9c880a 100644 --- a/radio/src/targets/Horus/telemetry_driver.cpp +++ b/radio/src/targets/Horus/telemetry_driver.cpp @@ -48,8 +48,6 @@ void telemetryPortInit(uint32_t baudrate) USART_InitTypeDef USART_InitStructure; GPIO_InitTypeDef GPIO_InitStructure; - RCC_AHB1PeriphClockCmd(TELEMETRY_RCC_AHB1Periph_GPIO, ENABLE); - GPIO_PinAFConfig(TELEMETRY_GPIO, TELEMETRY_GPIO_PinSource_RX, TELEMETRY_GPIO_AF); GPIO_PinAFConfig(TELEMETRY_GPIO, TELEMETRY_GPIO_PinSource_TX, TELEMETRY_GPIO_AF); @@ -65,8 +63,6 @@ void telemetryPortInit(uint32_t baudrate) GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(TELEMETRY_GPIO_DIR, &GPIO_InitStructure); GPIO_ResetBits(TELEMETRY_GPIO_DIR, TELEMETRY_GPIO_PIN_DIR); - - RCC_APB1PeriphClockCmd(TELEMETRY_RCC_APB1Periph_USART, ENABLE); USART_InitStructure.USART_BaudRate = baudrate; USART_InitStructure.USART_WordLength = USART_WordLength_8b; diff --git a/radio/src/targets/Horus/usb_conf.h b/radio/src/targets/Horus/usb_conf.h index c285e607d..7e02211c4 100644 --- a/radio/src/targets/Horus/usb_conf.h +++ b/radio/src/targets/Horus/usb_conf.h @@ -43,7 +43,7 @@ * when FS core is used. *******************************************************************************/ #ifndef USE_USB_OTG_FS - #define USE_USB_OTG_FS + #define USE_USB_OTG_FS // USB2.0 Full Speed == 12 Mbit #endif /* USE_USB_OTG_FS */ #ifdef USE_USB_OTG_FS diff --git a/radio/src/targets/Horus/usbd_desc.c b/radio/src/targets/Horus/usbd_desc.c index 541200a16..63187d67b 100644 --- a/radio/src/targets/Horus/usbd_desc.c +++ b/radio/src/targets/Horus/usbd_desc.c @@ -65,22 +65,22 @@ #if defined(BOOT) #define USBD_PID 0x5720 - #define USBD_PRODUCT_FS_STRING "FrSky Taranis Bootloader" + #define USBD_PRODUCT_FS_STRING "FrSky Horus Bootloader" #define USBD_CONFIGURATION_FS_STRING "MSC Config" #define USBD_INTERFACE_FS_STRING "MSC Interface" #elif defined(USB_JOYSTICK) #define USBD_PID 0x5710 - #define USBD_PRODUCT_FS_STRING "FrSky Taranis Joystick" + #define USBD_PRODUCT_FS_STRING "FrSky Horus Joystick" #define USBD_CONFIGURATION_FS_STRING "HID Config" #define USBD_INTERFACE_FS_STRING "HID Interface" #elif defined(USB_SERIAL) #define USBD_PID 0x5740 // do not change, this ID is used by the ST USB driver for Windows - #define USBD_PRODUCT_FS_STRING "FrSky Taranis Serial Port" + #define USBD_PRODUCT_FS_STRING "FrSky Horus Serial Port" #define USBD_CONFIGURATION_FS_STRING "VSP Config" #define USBD_INTERFACE_FS_STRING "VSP Interface" #elif defined(USB_MASS_STORAGE) #define USBD_PID 0x5720 - #define USBD_PRODUCT_FS_STRING "FrSky Taranis Mass Storage" + #define USBD_PRODUCT_FS_STRING "FrSky Horus Mass Storage" #define USBD_CONFIGURATION_FS_STRING "MSC Config" #define USBD_INTERFACE_FS_STRING "MSC Interface" #endif diff --git a/radio/src/targets/Horus/usbd_desc.h b/radio/src/targets/Horus/usbd_desc.h index 7a9d5b564..537f69b14 100644 --- a/radio/src/targets/Horus/usbd_desc.h +++ b/radio/src/targets/Horus/usbd_desc.h @@ -31,7 +31,8 @@ #define __USB_DESC_H /* Includes ------------------------------------------------------------------*/ -#include "STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/inc/usbd_def.h" +#include "usb_core.h" +#include "usbd_def.h" /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY * @{ diff --git a/radio/src/targets/taranis/usbd_desc.h b/radio/src/targets/Horus/usbd_desc.h~origin_next similarity index 100% rename from radio/src/targets/taranis/usbd_desc.h rename to radio/src/targets/Horus/usbd_desc.h~origin_next diff --git a/radio/src/targets/Horus/usbd_storage_msd.cpp b/radio/src/targets/Horus/usbd_storage_msd.cpp index 59fec18eb..fd3fbcd98 100644 --- a/radio/src/targets/Horus/usbd_storage_msd.cpp +++ b/radio/src/targets/Horus/usbd_storage_msd.cpp @@ -28,6 +28,7 @@ /* Includes ------------------------------------------------------------------*/ #include "../../opentx.h" #include "../../thirdparty/FatFs/diskio.h" +#include "sdio_sd.h" #include "board_horus.h" #if defined(__cplusplus) && !defined(SIMU) @@ -37,12 +38,8 @@ extern "C" { #include "usbd_msc_mem.h" #include "usb_conf.h" -#if defined(BOOT) -#define STORAGE_LUN_NBR 2 -#else /* SD card only when not running bootloader */ #define STORAGE_LUN_NBR 1 -#endif #define BLOCKSIZE 512 /* USB Mass storage Standard Inquiry Data */ @@ -58,30 +55,10 @@ const unsigned char STORAGE_Inquirydata[] = {//36 0x00, 0x00, 'F', 'r', 'S', 'k', 'y', ' ', ' ', ' ', /* Manufacturer : 8 bytes */ - 'T', 'a', 'r', 'a', 'n', 'i', 's', ' ', /* Product : 16 Bytes */ + 'H', 'o', 'r', 'u', 's', ' ', ' ', ' ', /* Product : 16 Bytes */ 'R', 'a', 'd', 'i', 'o', ' ', ' ', ' ', '1', '.', '0', '0', /* Version : 4 Bytes */ -#if defined(BOOT) - /* LUN 1 */ - 0x00, - 0x80, - 0x02, - 0x02, - (USBD_STD_INQUIRY_LENGTH - 5), - 0x00, - 0x00, - 0x00, - 'F', 'r', 'S', 'k', 'y', ' ', ' ', ' ', /* Manufacturer : 8 bytes */ - 'T', 'a', 'r', 'a', 'n', 'i', 's', ' ', /* Product : 16 Bytes */ - 'R', 'a', 'd', 'i', 'o', ' ', ' ', ' ', - '1', '.', '0' ,'0', /* Version : 4 Bytes */ -#endif -}; - -#if defined(BOOT) -int32_t fat12Write( const uint8_t *buffer, uint16_t sector, uint16_t count ) ; -int32_t fat12Read( uint8_t *buffer, uint16_t sector, uint16_t count ) ; -#endif +}; int8_t STORAGE_Init (uint8_t lun); @@ -151,49 +128,22 @@ int8_t STORAGE_Init (uint8_t lun) */ int8_t STORAGE_GetCapacity (uint8_t lun, uint32_t *block_num, uint32_t *block_size) { -#if defined(BOOT) - if (lun == 1) { - *block_size = BLOCKSIZE; - *block_num = 3 + EESIZE/BLOCKSIZE + FLASHSIZE/BLOCKSIZE; - } - else -#endif - { - if (!SD_CARD_PRESENT()) - return -1; + if (!SD_CARD_PRESENT()) + return -1; - *block_size = BLOCKSIZE; - - static DWORD sector_count = 0; - if (sector_count == 0) { - if (disk_ioctl(0, GET_SECTOR_COUNT, §or_count) != RES_OK) { - sector_count = 0; - return -1; - } - } - - *block_num = sector_count; - } + *block_size = SDCardInfo.CardBlockSize; + *block_num = (SDCardInfo.CardCapacity / SDCardInfo.CardBlockSize) - 1; return 0; } -#if defined(BOOT) -uint8_t lunReady[2] ; -#else uint8_t lunReady[1] ; -#endif void usbPluggedIn() { if (lunReady[0] == 0) { lunReady[0] = 1; } -#if defined(BOOT) - if (lunReady[1] == 0) { - lunReady[1] = 1; - } -#endif } /** @@ -203,21 +153,9 @@ void usbPluggedIn() */ int8_t STORAGE_IsReady (uint8_t lun) { -#if defined(BOOT) - if (lun == 1) { - if (lunReady[1] == 0) { - return -1 ; - } - return 0 ; - } - else -#endif - { - if (lunReady[0] == 0) { - return -1 ; - } - return SD_CARD_PRESENT() ? 0 : -1; - } + if (lunReady[0] == 0) + return -1 ; + return SD_CARD_PRESENT() ? 0 : -1; } /** @@ -239,27 +177,28 @@ int8_t STORAGE_IsWriteProtected (uint8_t lun) * @retval Status */ -int8_t SD_ReadSectors(uint8_t *buff, uint32_t sector, uint32_t count); - int8_t STORAGE_Read (uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len) { -#if defined(BOOT) - if (lun == 1) { - if (fat12Read(buf, blk_addr, blk_len) != 0) - return -1; - } - else -#endif - { - if (SD_ReadSectors(buf, blk_addr, blk_len) != 0) { - return -1; + + for (int retry=0; retry<3; retry++) { + if (SD_ReadMultiBlocks(buf, blk_addr, BLOCKSIZE, blk_len) != 0) { + continue; + } + + SDTransferState State; + + SD_Error Status = SD_WaitReadOperation(); // Check if the Transfer is finished + + while((State = SD_GetStatus()) == SD_TRANSFER_BUSY); // BUSY, OK (DONE), ERROR (FAIL) + + if ((State == SD_TRANSFER_OK) && (Status == SD_OK)) { + return 0; } } - - return 0; + return -1; } /** * @brief Write data to the medium @@ -270,26 +209,24 @@ int8_t STORAGE_Read (uint8_t lun, * @retval Status */ -int8_t SD_WriteSectors(const uint8_t *buf, uint32_t sector, uint32_t count); - int8_t STORAGE_Write (uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len) { -#if defined(BOOT) - if (lun == 1) { - if (fat12Write(buf, blk_addr, blk_len) != 0) - return -1; - } - else -#endif - { - if (SD_WriteSectors(buf, blk_addr, blk_len) != 0) - return -1; - } + if (SD_WriteMultiBlocks(buf, blk_addr, BLOCKSIZE, blk_len) != 0) + return -1; - return (0); + SDTransferState State; + + SD_Error Status = SD_WaitWriteOperation(); // Check if the Transfer is finished + + while((State = SD_GetStatus()) == SD_TRANSFER_BUSY); // BUSY, OK (DONE), ERROR (FAIL) + + if ((State == SD_TRANSFER_ERROR) || (Status != SD_OK)) + return -1; + + return 0; } /** @@ -302,510 +239,3 @@ int8_t STORAGE_GetMaxLun (void) { return STORAGE_LUN_NBR - 1; } - -#if defined(BOOT) -//------------------------------------------------------------------------------ -/** - * FAT12 boot sector partition. - */ -const char g_FATboot[BLOCKSIZE] = -{ - 0xeb, 0x3c, 0x90, // Jump instruction. - 0x39, 0x58, 0x20, 0x54, 0x45, 0x41, 0x4D, 0x00, // OEM Name - 0x00, 0x02, // Bytes per sector - 0x08, // Sectors per FS cluster. - 0x01, 0x00, // Reserved sector count - - 0x01, // Number of FATs - 0x10, 0x00, // Number of root directory entries - 3+(EESIZE/BLOCKSIZE), (FLASHSIZE/BLOCKSIZE)>>8, // Total sectors - 0xf8, // Media descriptor - 0x01, 0x00, // Sectors per FAT table - 0x20, 0x00, // Sectors per track - 0x40, 0x00, // Number of heads - 0x00, 0x00, 0x00, 0x00, // Number of hidden sectors - - 0x00, 0x00, 0x00, 0x00, // Large number of sectors. - 0x00, // Physical drive number - 0x00, // Reserved - 0x29, // Extended boot signature - 0xCE, 0xFA, 0x5C, 0xD1, // Disk ID (serial number) - 0x56, 0x49, 0x52, 0x54, 0x46, 0x53, 0x20, 0x20, 0x20, 0x20, 0x20, // Volume label - 0x46, 0x41, 0x54, 0x31, 0x32, 0x20, 0x20, 0x20, // FAT file system type - 0x00, 0x00, // OS boot code - - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xaa -}; - -#if defined(REV4a) -const char g_FAT[BLOCKSIZE] = -{ - 0xF8, 0xFF, 0xFF, 0x03, 0x40, 0x00, 0x05, 0x60, 0x00, 0x07, 0x80, 0x00, 0x09, 0xA0, 0x00, 0x0B, - 0xC0, 0x00, 0x0D, 0xE0, 0x00, 0x0F, 0x00, 0x01, 0x11, 0xF0, 0xFF, 0x13, 0x40, 0x01, 0x15, 0x60, - 0x01, 0x17, 0x80, 0x01, 0x19, 0xA0, 0x01, 0x1B, 0xC0, 0x01, 0x1D, 0xE0, 0x01, 0x1F, 0x00, 0x02, - 0x21, 0x20, 0x02, 0x23, 0x40, 0x02, 0x25, 0x60, 0x02, 0x27, 0x80, 0x02, 0x29, 0xA0, 0x02, 0x2B, - 0xC0, 0x02, 0x2D, 0xE0, 0x02, 0x2F, 0x00, 0x03, 0x31, 0x20, 0x03, 0x33, 0x40, 0x03, 0x35, 0x60, - 0x03, 0x37, 0x80, 0x03, 0x39, 0xA0, 0x03, 0x3B, 0xC0, 0x03, 0x3D, 0xE0, 0x03, 0x3F, 0x00, 0x04, - 0x41, 0x20, 0x04, 0x43, 0x40, 0x04, 0x45, 0x60, 0x04, 0x47, 0x80, 0x04, 0x49, 0xA0, 0x04, 0x4B, - 0xC0, 0x04, 0x4D, 0xE0, 0x04, 0x4F, 0x00, 0x05, 0x51, 0x20, 0x05, 0x53, 0x40, 0x05, 0x55, 0x60, - 0x05, 0x57, 0x80, 0x05, 0x59, 0xA0, 0x05, 0x5B, 0xC0, 0x05, 0x5D, 0xE0, 0x05, 0x5F, 0x00, 0x06, - 0x61, 0x20, 0x06, 0x63, 0x40, 0x06, 0x65, 0x60, 0x06, 0x67, 0x80, 0x06, 0x69, 0xA0, 0x06, 0x6B, - 0xC0, 0x06, 0x6D, 0xE0, 0x06, 0x6F, 0x00, 0x07, 0x71, 0x20, 0x07, 0x73, 0x40, 0x07, 0x75, 0x60, - 0x07, 0x77, 0x80, 0x07, 0x79, 0xA0, 0x07, 0x7B, 0xC0, 0x07, 0x7D, 0xE0, 0x07, 0x7F, 0x00, 0x08, - 0x81, 0x20, 0x08, 0x83, 0x40, 0x08, 0x85, 0x60, 0x08, 0x87, 0x80, 0x08, 0x89, 0xA0, 0x08, 0x8B, - 0xC0, 0x08, 0x8D, 0xE0, 0x08, 0x8F, 0x00, 0x09, 0x91, 0xF0, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; -#else -const char g_FAT[BLOCKSIZE] = -{ - 0xF8, 0xFF, 0xFF, 0x03, 0x40, 0x00, 0x05, 0x60, 0x00, 0x07, 0x80, 0x00, 0x09, 0xF0, 0xFF, 0x0B, - 0xC0, 0x00, 0x0D, 0xE0, 0x00, 0x0F, 0x00, 0x01, 0x11, 0x20, 0x01, 0x13, 0x40, 0x01, 0x15, 0x60, - 0x01, 0x17, 0x80, 0x01, 0x19, 0xA0, 0x01, 0x1B, 0xC0, 0x01, 0x1D, 0xE0, 0x01, 0x1F, 0x00, 0x02, - 0x21, 0x20, 0x02, 0x23, 0x40, 0x02, 0x25, 0x60, 0x02, 0x27, 0x80, 0x02, 0x29, 0xA0, 0x02, 0x2B, - 0xC0, 0x02, 0x2D, 0xE0, 0x02, 0x2F, 0x00, 0x03, 0x31, 0x20, 0x03, 0x33, 0x40, 0x03, 0x35, 0x60, - 0x03, 0x37, 0x80, 0x03, 0x39, 0xA0, 0x03, 0x3B, 0xC0, 0x03, 0x3D, 0xE0, 0x03, 0x3F, 0x00, 0x04, - 0x41, 0x20, 0x04, 0x43, 0x40, 0x04, 0x45, 0x60, 0x04, 0x47, 0x80, 0x04, 0x49, 0xA0, 0x04, 0x4B, - 0xC0, 0x04, 0x4D, 0xE0, 0x04, 0x4F, 0x00, 0x05, 0x51, 0x20, 0x05, 0x53, 0x40, 0x05, 0x55, 0x60, - 0x05, 0x57, 0x80, 0x05, 0x59, 0xA0, 0x05, 0x5B, 0xC0, 0x05, 0x5D, 0xE0, 0x05, 0x5F, 0x00, 0x06, - 0x61, 0x20, 0x06, 0x63, 0x40, 0x06, 0x65, 0x60, 0x06, 0x67, 0x80, 0x06, 0x69, 0xA0, 0x06, 0x6B, - 0xC0, 0x06, 0x6D, 0xE0, 0x06, 0x6F, 0x00, 0x07, 0x71, 0x20, 0x07, 0x73, 0x40, 0x07, 0x75, 0x60, - 0x07, 0x77, 0x80, 0x07, 0x79, 0xA0, 0x07, 0x7B, 0xC0, 0x07, 0x7D, 0xE0, 0x07, 0x7F, 0x00, 0x08, - 0x81, 0x20, 0x08, 0x83, 0x40, 0x08, 0x85, 0x60, 0x08, 0x87, 0x80, 0x08, 0x89, 0xF0, 0xFF, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; -#endif - -// File Attributes -// 0 0x01 Read Only. -// 1 0x02 Hidden. -// 2 0x04 System. -// 3 0x08 Volume Label. -// 4 0x10 Subdirectory. -// 5 0x20 Archive. -// 6 0x40 Device. -// 7 0x80 Reserved. - -typedef struct -{ - uint8_t name[8]; - uint8_t ext[3]; - uint8_t attribute; - uint8_t reserved; - uint8_t create_time_ms; - uint16_t create_time; - uint16_t create_date; - uint16_t access_date; - uint16_t ea_index; - uint16_t modify_time; - uint16_t modify_date; - uint16_t start_cluster; - uint32_t file_size; -} FATDirEntry_t; - -// First 16 FAT root directory entries (1 sector) -const FATDirEntry_t g_DIRroot[16] = -{ - { - { 'T', 'A', 'R', 'A', 'N', 'I', 'S', ' '}, - { ' ', ' ', ' '}, - 0x08, // Volume - 0x00, - 0x00, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x00000000 - }, - { - { 'E', 'E', 'P', 'R', 'O', 'M', ' ', ' '}, - { 'B', 'I', 'N'}, - 0x20, // Archive - 0x00, - 0x3E, - 0xA301, - 0x3D55, - 0x3D55, - 0x0000, - 0xA302, - 0x3D55, - 0x0002, - EESIZE - }, - { - { 'F', 'I', 'R', 'M', 'W', 'A', 'R', 'E'}, - { 'B', 'I', 'N'}, - 0x20, // Archive - 0x00, - 0x3E, - 0xA301, - 0x3D55, - 0x3D55, - 0x0000, - 0xA302, - 0x3D55, - 0x0002 + (EESIZE/BLOCKSIZE)/8, - FLASHSIZE - }, - { - { '\x00', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, - { ' ', ' ', ' '}, - 0x00, - 0x00, - 0x00, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x00000000 - }, - { - { '\x00', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, - { ' ', ' ', ' '}, - 0x00, - 0x00, - 0x00, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x00000000 - }, - { - { '\x00', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, - { ' ', ' ', ' '}, - 0x00, - 0x00, - 0x00, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x00000000 - }, - { - { '\x00', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, - { ' ', ' ', ' '}, - 0x00, - 0x00, - 0x00, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x00000000 - }, - { - { '\x00', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, - { ' ', ' ', ' '}, - 0x00, - 0x00, - 0x00, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x00000000 - }, - { - { '\x00', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, - { ' ', ' ', ' '}, - 0x00, - 0x00, - 0x00, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x00000000 - }, - { - { '\x00', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, - { ' ', ' ', ' '}, - 0x00, - 0x00, - 0x00, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x00000000 - }, - { - { '\x00', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, - { ' ', ' ', ' '}, - 0x00, - 0x00, - 0x00, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x00000000 - }, - { - { '\x00', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, - { ' ', ' ', ' '}, - 0x00, - 0x00, - 0x00, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x00000000 - }, - { - { '\x00', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, - { ' ', ' ', ' '}, - 0x00, - 0x00, - 0x00, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x00000000 - }, - { - { '\x00', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, - { ' ', ' ', ' '}, - 0x00, - 0x00, - 0x00, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x00000000 - }, - { - { '\x00', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, - { ' ', ' ', ' '}, - 0x00, - 0x00, - 0x00, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x00000000 - }, - { - { '\x00', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, - { ' ', ' ', ' '}, - 0x00, - 0x00, - 0x00, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x0000, - 0x00000000 - }, -}; - -// count is number of 512 byte sectors -int32_t fat12Read( uint8_t *buffer, uint16_t sector, uint16_t count ) -{ - while ( count ) - { - if (sector == 0) { - memcpy(buffer, g_FATboot, BLOCKSIZE ) ; - } - else if (sector == 1/*Reserved sector count*/) { - // FAT table. - memcpy(buffer, g_FAT, BLOCKSIZE); - } - else if (sector == 2) { - memcpy(buffer, g_DIRroot, BLOCKSIZE ) ; - } - else if (sector < 3 + (EESIZE/BLOCKSIZE)) { - eepromReadBlock(buffer, (sector-3)*BLOCKSIZE, BLOCKSIZE); - } - else if (sector < 3 + (EESIZE/BLOCKSIZE) + (FLASHSIZE/BLOCKSIZE)) { - uint32_t address; - address = sector - 3 - (EESIZE/BLOCKSIZE); - address *= BLOCKSIZE; - address += FIRMWARE_ADDRESS; - memcpy(buffer, (uint8_t *)address, BLOCKSIZE); - } - buffer += BLOCKSIZE ; - sector++ ; - count-- ; - } - return 0 ; -} - -int32_t fat12Write(const uint8_t *buffer, uint16_t sector, uint16_t count) -{ - enum FatWriteOperation { - FATWRITE_NONE, - FATWRITE_EEPROM, - FATWRITE_FIRMWARE - }; - - static unsigned int operation = FATWRITE_NONE; - - TRACE("FAT12 Write(sector=%d, count=%d)", sector, count); - - if (sector < 3) { - // reserved, read-only - } - else if (sector < 3 + (EESIZE/BLOCKSIZE)) { - // eeprom - while (count) { - if (operation == FATWRITE_NONE && isEepromStart(buffer)) { - TRACE("EEPROM start found in sector %d", sector); - operation = FATWRITE_EEPROM; - } - if (operation == FATWRITE_EEPROM) { - eepromWriteBlock((uint8_t *)buffer, (sector-3)*BLOCKSIZE, BLOCKSIZE); - } - buffer += BLOCKSIZE; - sector++; - count--; - if (sector-3 >= (EESIZE/BLOCKSIZE)) { - TRACE("EEPROM end written at sector %d", sector-1); - operation = FATWRITE_NONE; - } - } - } - else if (sector < 3 + (EESIZE/BLOCKSIZE) + (FLASHSIZE/BLOCKSIZE)) { - // firmware - uint32_t address; - address = sector - 3 - (EESIZE/BLOCKSIZE); - address *= BLOCKSIZE; - address += FIRMWARE_ADDRESS; - while (count) { - for (uint32_t i=0; i= FIRMWARE_ADDRESS+BOOTLOADER_SIZE/*protect bootloader*/ && address <= FIRMWARE_ADDRESS+FLASHSIZE-FLASH_PAGESIZE) { - if (address == FIRMWARE_ADDRESS+BOOTLOADER_SIZE && isFirmwareStart(buffer)) { - TRACE("FIRMWARE start found in sector %d", sector); - operation = FATWRITE_FIRMWARE; - } - if (operation == FATWRITE_FIRMWARE) { - writeFlash((uint32_t *)address, (uint32_t *)buffer); - } - } - address += FLASH_PAGESIZE; - buffer += FLASH_PAGESIZE; - } - sector++; - count--; - if (sector-3-(EESIZE/BLOCKSIZE) >= (FLASHSIZE/BLOCKSIZE)) { - TRACE("FIRMWARE end written at sector %d", sector-1); - operation = FATWRITE_NONE; - } - } - } - return 0 ; -} -#endif diff --git a/radio/src/targets/mega2560/00readme.txt b/radio/src/targets/Mega2560/00readme.txt similarity index 100% rename from radio/src/targets/mega2560/00readme.txt rename to radio/src/targets/Mega2560/00readme.txt diff --git a/radio/src/targets/mega2560/board_mega2560.cpp b/radio/src/targets/Mega2560/board_mega2560.cpp similarity index 100% rename from radio/src/targets/mega2560/board_mega2560.cpp rename to radio/src/targets/Mega2560/board_mega2560.cpp diff --git a/radio/src/targets/mega2560/board_mega2560.h b/radio/src/targets/Mega2560/board_mega2560.h similarity index 100% rename from radio/src/targets/mega2560/board_mega2560.h rename to radio/src/targets/Mega2560/board_mega2560.h diff --git a/radio/src/targets/sky9x/AT91SAM3S2.h b/radio/src/targets/Sky9x/AT91SAM3S2.h similarity index 100% rename from radio/src/targets/sky9x/AT91SAM3S2.h rename to radio/src/targets/Sky9x/AT91SAM3S2.h diff --git a/radio/src/targets/sky9x/AT91SAM3S4.h b/radio/src/targets/Sky9x/AT91SAM3S4.h similarity index 100% rename from radio/src/targets/sky9x/AT91SAM3S4.h rename to radio/src/targets/Sky9x/AT91SAM3S4.h diff --git a/radio/src/targets/sky9x/MEDSdcard.c b/radio/src/targets/Sky9x/MEDSdcard.c similarity index 96% rename from radio/src/targets/sky9x/MEDSdcard.c rename to radio/src/targets/Sky9x/MEDSdcard.c index 40c360413..de334dafe 100644 --- a/radio/src/targets/sky9x/MEDSdcard.c +++ b/radio/src/targets/Sky9x/MEDSdcard.c @@ -32,10 +32,10 @@ //------------------------------------------------------------------------------ #include -#include "Media.h" #include "debug.h" -#include "board.h" #include "../FatFs/diskio.h" +#include "../Sky9x/board.h" +#include "../Sky9x/Media.h" //------------------------------------------------------------------------------ // Constants diff --git a/radio/src/targets/sky9x/Media.h b/radio/src/targets/Sky9x/Media.h similarity index 100% rename from radio/src/targets/sky9x/Media.h rename to radio/src/targets/Sky9x/Media.h diff --git a/radio/src/targets/sky9x/adc_driver.cpp b/radio/src/targets/Sky9x/adc_driver.cpp similarity index 85% rename from radio/src/targets/sky9x/adc_driver.cpp rename to radio/src/targets/Sky9x/adc_driver.cpp index cf10e8778..730677ceb 100644 --- a/radio/src/targets/sky9x/adc_driver.cpp +++ b/radio/src/targets/Sky9x/adc_driver.cpp @@ -36,7 +36,7 @@ #include "../opentx.h" -uint16_t Analog_values[NUMBER_ANALOG]; +uint16_t adcValues[NUMBER_ANALOG]; #if defined(FRSKY_STICKS) const char ana_direction[NUMBER_ANALOG] = {1, 1, 0, 1 ,0 ,1 ,0, 0, 0}; @@ -99,17 +99,17 @@ void adcRead() x = padc->ADC_LCDR; // Clear DRSY flag } // Next bit may be done using the PDC - Analog_values[0] = ADC->ADC_CDR1; - Analog_values[1] = ADC->ADC_CDR2; - Analog_values[2] = ADC->ADC_CDR3; - Analog_values[3] = ADC->ADC_CDR4; - Analog_values[4] = ADC->ADC_CDR5; - Analog_values[5] = ADC->ADC_CDR9; - Analog_values[6] = ADC->ADC_CDR13; - Analog_values[7] = ADC->ADC_CDR14; + adcValues[0] = ADC->ADC_CDR1; + adcValues[1] = ADC->ADC_CDR2; + adcValues[2] = ADC->ADC_CDR3; + adcValues[3] = ADC->ADC_CDR4; + adcValues[4] = ADC->ADC_CDR5; + adcValues[5] = ADC->ADC_CDR9; + adcValues[6] = ADC->ADC_CDR13; + adcValues[7] = ADC->ADC_CDR14; #if !defined(REVA) - Analog_values[8] = ADC->ADC_CDR8 ; + adcValues[8] = ADC->ADC_CDR8 ; #endif temperature = (((int32_t)temperature * 7) + ((((int32_t)ADC->ADC_CDR15 - 838) * 621) >> 11)) >> 3; // Filter it @@ -122,7 +122,7 @@ void adcRead() uint32_t i ; for (i=0; i -#include "chip.h" + +#include "../Sky9x/chip.h" #if defined(REVA) -#include "AT91SAM3S2.h" +#include "../Sky9x/AT91SAM3S2.h" #else -#include "AT91SAM3S4.h" +#include "../Sky9x/AT91SAM3S4.h" #endif #if !defined(SIMU) -#include "core_cm3.h" +#include "../Sky9x/core_cm3.h" #endif //------------------------------------------------------------------------------ @@ -97,7 +98,7 @@ // ADC //------------------------------------------------------------------------------ -/// Startup time max, return from Idle mode (in µs) +/// Startup time max, return from Idle mode (in �s) #define ADC_STARTUP_TIME_MAX 15 /// Track and hold Acquisition Time min (in ns) #define ADC_TRACK_HOLD_TIME_MIN 1200 diff --git a/radio/src/targets/sky9x/board_lowlevel.c b/radio/src/targets/Sky9x/board_lowlevel.c similarity index 96% rename from radio/src/targets/sky9x/board_lowlevel.c rename to radio/src/targets/Sky9x/board_lowlevel.c index 49d3a1b53..9e72d975f 100644 --- a/radio/src/targets/sky9x/board_lowlevel.c +++ b/radio/src/targets/Sky9x/board_lowlevel.c @@ -39,7 +39,7 @@ * Headers *----------------------------------------------------------------------------*/ -#include "board.h" +#include "../Sky9x/board.h" /*---------------------------------------------------------------------------- * Local definitions diff --git a/radio/src/targets/sky9x/board_sky9x.cpp b/radio/src/targets/Sky9x/board_sky9x.cpp similarity index 100% rename from radio/src/targets/sky9x/board_sky9x.cpp rename to radio/src/targets/Sky9x/board_sky9x.cpp diff --git a/radio/src/targets/sky9x/board_sky9x.h b/radio/src/targets/Sky9x/board_sky9x.h similarity index 100% rename from radio/src/targets/sky9x/board_sky9x.h rename to radio/src/targets/Sky9x/board_sky9x.h diff --git a/radio/src/targets/sky9x/buzzer_driver.cpp b/radio/src/targets/Sky9x/buzzer_driver.cpp similarity index 100% rename from radio/src/targets/sky9x/buzzer_driver.cpp rename to radio/src/targets/Sky9x/buzzer_driver.cpp diff --git a/radio/src/targets/sky9x/chip.h b/radio/src/targets/Sky9x/chip.h similarity index 100% rename from radio/src/targets/sky9x/chip.h rename to radio/src/targets/Sky9x/chip.h diff --git a/radio/src/targets/sky9x/coproc_driver.cpp b/radio/src/targets/Sky9x/coproc_driver.cpp similarity index 100% rename from radio/src/targets/sky9x/coproc_driver.cpp rename to radio/src/targets/Sky9x/coproc_driver.cpp diff --git a/radio/src/targets/sky9x/core_cm3.c b/radio/src/targets/Sky9x/core_cm3.c similarity index 100% rename from radio/src/targets/sky9x/core_cm3.c rename to radio/src/targets/Sky9x/core_cm3.c diff --git a/radio/src/targets/sky9x/core_cm3.h b/radio/src/targets/Sky9x/core_cm3.h similarity index 100% rename from radio/src/targets/sky9x/core_cm3.h rename to radio/src/targets/Sky9x/core_cm3.h diff --git a/radio/src/targets/sky9x/crt.c b/radio/src/targets/Sky9x/crt.c similarity index 100% rename from radio/src/targets/sky9x/crt.c rename to radio/src/targets/Sky9x/crt.c diff --git a/radio/src/targets/sky9x/diskio.cpp b/radio/src/targets/Sky9x/diskio.cpp similarity index 96% rename from radio/src/targets/sky9x/diskio.cpp rename to radio/src/targets/Sky9x/diskio.cpp index 45aaa1068..0b7b790ba 100644 --- a/radio/src/targets/sky9x/diskio.cpp +++ b/radio/src/targets/Sky9x/diskio.cpp @@ -42,11 +42,11 @@ /*-----------------------------------------------------------------------*/ #include -#include "board.h" #include "debug.h" #include "../FatFs/diskio.h" #include "../FatFs/ff.h" #include "../CoOS/kernel/CoOS.h" +#include "../Sky9x/board.h" #define CARD_TYPE_bmHC (1 << 0) /**< Bit for High-Capacity(Density) */ #define CARD_TYPE_bmSDMMC (0x3 << 1) /**< Bits mask for SD/MMC */ diff --git a/radio/src/targets/sky9x/eeprom_driver.cpp b/radio/src/targets/Sky9x/eeprom_driver.cpp similarity index 100% rename from radio/src/targets/sky9x/eeprom_driver.cpp rename to radio/src/targets/Sky9x/eeprom_driver.cpp diff --git a/radio/src/targets/sky9x/flash_driver.cpp b/radio/src/targets/Sky9x/flash_driver.cpp similarity index 100% rename from radio/src/targets/sky9x/flash_driver.cpp rename to radio/src/targets/Sky9x/flash_driver.cpp diff --git a/radio/src/targets/sky9x/haptic_driver.cpp b/radio/src/targets/Sky9x/haptic_driver.cpp similarity index 100% rename from radio/src/targets/sky9x/haptic_driver.cpp rename to radio/src/targets/Sky9x/haptic_driver.cpp diff --git a/radio/src/targets/sky9x/keys_driver.cpp b/radio/src/targets/Sky9x/keys_driver.cpp similarity index 100% rename from radio/src/targets/sky9x/keys_driver.cpp rename to radio/src/targets/Sky9x/keys_driver.cpp diff --git a/radio/src/targets/sky9x/lcd_driver.cpp b/radio/src/targets/Sky9x/lcd_driver.cpp similarity index 100% rename from radio/src/targets/sky9x/lcd_driver.cpp rename to radio/src/targets/Sky9x/lcd_driver.cpp diff --git a/radio/src/targets/sky9x/massstorage.cpp b/radio/src/targets/Sky9x/massstorage.cpp similarity index 94% rename from radio/src/targets/sky9x/massstorage.cpp rename to radio/src/targets/Sky9x/massstorage.cpp index 39a0fbd5f..9fa6ea3d3 100644 --- a/radio/src/targets/sky9x/massstorage.cpp +++ b/radio/src/targets/Sky9x/massstorage.cpp @@ -39,7 +39,7 @@ #ifndef SIMU extern "C" { -#include "usb/device/massstorage/MSDDriver.h" +#include "../Sky9x/usb/device/massstorage/MSDDriver.h" extern unsigned char MEDSdcard_Initialize(Media *media, unsigned char mciID); } diff --git a/radio/src/targets/sky9x/pulses_driver.cpp b/radio/src/targets/Sky9x/pulses_driver.cpp similarity index 100% rename from radio/src/targets/sky9x/pulses_driver.cpp rename to radio/src/targets/Sky9x/pulses_driver.cpp diff --git a/radio/src/targets/sky9x/pwr_driver.cpp b/radio/src/targets/Sky9x/pwr_driver.cpp similarity index 100% rename from radio/src/targets/sky9x/pwr_driver.cpp rename to radio/src/targets/Sky9x/pwr_driver.cpp diff --git a/radio/src/targets/sky9x/rotenc_driver.cpp b/radio/src/targets/Sky9x/rotenc_driver.cpp similarity index 100% rename from radio/src/targets/sky9x/rotenc_driver.cpp rename to radio/src/targets/Sky9x/rotenc_driver.cpp diff --git a/radio/src/targets/sky9x/rtc_driver.cpp b/radio/src/targets/Sky9x/rtc_driver.cpp similarity index 100% rename from radio/src/targets/sky9x/rtc_driver.cpp rename to radio/src/targets/Sky9x/rtc_driver.cpp diff --git a/radio/src/targets/sky9x/sam3s2c_flash.ld b/radio/src/targets/Sky9x/sam3s2c_flash.ld similarity index 100% rename from radio/src/targets/sky9x/sam3s2c_flash.ld rename to radio/src/targets/Sky9x/sam3s2c_flash.ld diff --git a/radio/src/targets/sky9x/sam3s4c_flash.ld b/radio/src/targets/Sky9x/sam3s4c_flash.ld similarity index 100% rename from radio/src/targets/sky9x/sam3s4c_flash.ld rename to radio/src/targets/Sky9x/sam3s4c_flash.ld diff --git a/radio/src/targets/sky9x/sam3s8c_flash.ld b/radio/src/targets/Sky9x/sam3s8c_flash.ld similarity index 100% rename from radio/src/targets/sky9x/sam3s8c_flash.ld rename to radio/src/targets/Sky9x/sam3s8c_flash.ld diff --git a/radio/src/targets/sky9x/sdcard_driver.cpp b/radio/src/targets/Sky9x/sdcard_driver.cpp similarity index 100% rename from radio/src/targets/sky9x/sdcard_driver.cpp rename to radio/src/targets/Sky9x/sdcard_driver.cpp diff --git a/radio/src/targets/sky9x/serial2_driver.cpp b/radio/src/targets/Sky9x/serial2_driver.cpp similarity index 100% rename from radio/src/targets/sky9x/serial2_driver.cpp rename to radio/src/targets/Sky9x/serial2_driver.cpp diff --git a/radio/src/targets/sky9x/telemetry_driver.cpp b/radio/src/targets/Sky9x/telemetry_driver.cpp similarity index 100% rename from radio/src/targets/sky9x/telemetry_driver.cpp rename to radio/src/targets/Sky9x/telemetry_driver.cpp diff --git a/radio/src/targets/sky9x/usb/common/core/USBConfigurationDescriptor.c b/radio/src/targets/Sky9x/usb/common/core/USBConfigurationDescriptor.c similarity index 96% rename from radio/src/targets/sky9x/usb/common/core/USBConfigurationDescriptor.c rename to radio/src/targets/Sky9x/usb/common/core/USBConfigurationDescriptor.c index 503dceb0c..b41c06be6 100644 --- a/radio/src/targets/sky9x/usb/common/core/USBConfigurationDescriptor.c +++ b/radio/src/targets/Sky9x/usb/common/core/USBConfigurationDescriptor.c @@ -38,7 +38,7 @@ // Headers //----------------------------------------------------------------------------- -#include "USBConfigurationDescriptor.h" +#include "../../../../Sky9x/usb/common/core/USBConfigurationDescriptor.h" //----------------------------------------------------------------------------- // Exported functions diff --git a/radio/src/targets/sky9x/usb/common/core/USBConfigurationDescriptor.h b/radio/src/targets/Sky9x/usb/common/core/USBConfigurationDescriptor.h similarity index 94% rename from radio/src/targets/sky9x/usb/common/core/USBConfigurationDescriptor.h rename to radio/src/targets/Sky9x/usb/common/core/USBConfigurationDescriptor.h index 150e6563e..8d10b7d8d 100644 --- a/radio/src/targets/sky9x/usb/common/core/USBConfigurationDescriptor.h +++ b/radio/src/targets/Sky9x/usb/common/core/USBConfigurationDescriptor.h @@ -54,9 +54,9 @@ // Headers //----------------------------------------------------------------------------- -#include "USBGenericDescriptor.h" -#include "USBInterfaceDescriptor.h" -#include "USBEndpointDescriptor.h" +#include "../../../../Sky9x/usb/common/core/USBEndpointDescriptor.h" +#include "../../../../Sky9x/usb/common/core/USBGenericDescriptor.h" +#include "../../../../Sky9x/usb/common/core/USBInterfaceDescriptor.h" //----------------------------------------------------------------------------- // Definitions diff --git a/radio/src/targets/sky9x/usb/common/core/USBDeviceDescriptor.h b/radio/src/targets/Sky9x/usb/common/core/USBDeviceDescriptor.h similarity index 94% rename from radio/src/targets/sky9x/usb/common/core/USBDeviceDescriptor.h rename to radio/src/targets/Sky9x/usb/common/core/USBDeviceDescriptor.h index ce8d19988..f526e9c47 100644 --- a/radio/src/targets/sky9x/usb/common/core/USBDeviceDescriptor.h +++ b/radio/src/targets/Sky9x/usb/common/core/USBDeviceDescriptor.h @@ -42,7 +42,7 @@ #ifndef USBDEVICEDESCRIPTOR_H #define USBDEVICEDESCRIPTOR_H -#include +#include "../../../../Sky9x/board.h" //------------------------------------------------------------------------------ // Definitions //------------------------------------------------------------------------------ @@ -111,7 +111,7 @@ typedef struct { unsigned char bLength; /// Descriptor type (USBGenericDescriptor_OTG). unsigned char bDescriptorType; - /// Attribute Fields D7…2: Reserved D1: HNP support D0: SRP support + /// Attribute Fields D7�2: Reserved D1: HNP support D0: SRP support unsigned char bmAttributes; } __attribute__ ((packed)) USBOtgDescriptor; // GCC diff --git a/radio/src/targets/sky9x/usb/common/core/USBDeviceQualifierDescriptor.h b/radio/src/targets/Sky9x/usb/common/core/USBDeviceQualifierDescriptor.h similarity index 100% rename from radio/src/targets/sky9x/usb/common/core/USBDeviceQualifierDescriptor.h rename to radio/src/targets/Sky9x/usb/common/core/USBDeviceQualifierDescriptor.h diff --git a/radio/src/targets/sky9x/usb/common/core/USBEndpointDescriptor.c b/radio/src/targets/Sky9x/usb/common/core/USBEndpointDescriptor.c similarity index 96% rename from radio/src/targets/sky9x/usb/common/core/USBEndpointDescriptor.c rename to radio/src/targets/Sky9x/usb/common/core/USBEndpointDescriptor.c index 6300adeea..aa3ac0220 100644 --- a/radio/src/targets/sky9x/usb/common/core/USBEndpointDescriptor.c +++ b/radio/src/targets/Sky9x/usb/common/core/USBEndpointDescriptor.c @@ -38,7 +38,7 @@ // Headers //------------------------------------------------------------------------------ -#include "USBEndpointDescriptor.h" +#include "../../../../Sky9x/usb/common/core/USBEndpointDescriptor.h" //------------------------------------------------------------------------------ // Exported functions diff --git a/radio/src/targets/sky9x/usb/common/core/USBEndpointDescriptor.h b/radio/src/targets/Sky9x/usb/common/core/USBEndpointDescriptor.h similarity index 100% rename from radio/src/targets/sky9x/usb/common/core/USBEndpointDescriptor.h rename to radio/src/targets/Sky9x/usb/common/core/USBEndpointDescriptor.h diff --git a/radio/src/targets/sky9x/usb/common/core/USBFeatureRequest.c b/radio/src/targets/Sky9x/usb/common/core/USBFeatureRequest.c similarity index 95% rename from radio/src/targets/sky9x/usb/common/core/USBFeatureRequest.c rename to radio/src/targets/Sky9x/usb/common/core/USBFeatureRequest.c index 1e0422af4..d4793f2fb 100644 --- a/radio/src/targets/sky9x/usb/common/core/USBFeatureRequest.c +++ b/radio/src/targets/Sky9x/usb/common/core/USBFeatureRequest.c @@ -38,7 +38,7 @@ // Headers //------------------------------------------------------------------------------ -#include "USBFeatureRequest.h" +#include "../../../../Sky9x/usb/common/core/USBFeatureRequest.h" //------------------------------------------------------------------------------ // Exported functions diff --git a/radio/src/targets/sky9x/usb/common/core/USBFeatureRequest.h b/radio/src/targets/Sky9x/usb/common/core/USBFeatureRequest.h similarity index 96% rename from radio/src/targets/sky9x/usb/common/core/USBFeatureRequest.h rename to radio/src/targets/Sky9x/usb/common/core/USBFeatureRequest.h index 0454ffbb0..a917bb148 100644 --- a/radio/src/targets/sky9x/usb/common/core/USBFeatureRequest.h +++ b/radio/src/targets/Sky9x/usb/common/core/USBFeatureRequest.h @@ -50,7 +50,7 @@ // Headers //------------------------------------------------------------------------------ -#include "USBGenericRequest.h" +#include "../../../../Sky9x/usb/common/core/USBGenericRequest.h" //------------------------------------------------------------------------------ // Definitions diff --git a/radio/src/targets/sky9x/usb/common/core/USBGenericDescriptor.c b/radio/src/targets/Sky9x/usb/common/core/USBGenericDescriptor.c similarity index 95% rename from radio/src/targets/sky9x/usb/common/core/USBGenericDescriptor.c rename to radio/src/targets/Sky9x/usb/common/core/USBGenericDescriptor.c index 99ed6f94d..3c13044be 100644 --- a/radio/src/targets/sky9x/usb/common/core/USBGenericDescriptor.c +++ b/radio/src/targets/Sky9x/usb/common/core/USBGenericDescriptor.c @@ -38,7 +38,7 @@ // Headers //------------------------------------------------------------------------------ -#include "USBGenericDescriptor.h" +#include "../../../../Sky9x/usb/common/core/USBGenericDescriptor.h" //------------------------------------------------------------------------------ // Exported functions diff --git a/radio/src/targets/sky9x/usb/common/core/USBGenericDescriptor.h b/radio/src/targets/Sky9x/usb/common/core/USBGenericDescriptor.h similarity index 100% rename from radio/src/targets/sky9x/usb/common/core/USBGenericDescriptor.h rename to radio/src/targets/Sky9x/usb/common/core/USBGenericDescriptor.h diff --git a/radio/src/targets/sky9x/usb/common/core/USBGenericRequest.c b/radio/src/targets/Sky9x/usb/common/core/USBGenericRequest.c similarity index 96% rename from radio/src/targets/sky9x/usb/common/core/USBGenericRequest.c rename to radio/src/targets/Sky9x/usb/common/core/USBGenericRequest.c index a3bbbfd1a..893bd1caa 100644 --- a/radio/src/targets/sky9x/usb/common/core/USBGenericRequest.c +++ b/radio/src/targets/Sky9x/usb/common/core/USBGenericRequest.c @@ -38,7 +38,7 @@ // Headers //------------------------------------------------------------------------------ -#include "USBGenericRequest.h" +#include "../../../../Sky9x/usb/common/core/USBGenericRequest.h" //------------------------------------------------------------------------------ // Exported functions diff --git a/radio/src/targets/sky9x/usb/common/core/USBGenericRequest.h b/radio/src/targets/Sky9x/usb/common/core/USBGenericRequest.h similarity index 100% rename from radio/src/targets/sky9x/usb/common/core/USBGenericRequest.h rename to radio/src/targets/Sky9x/usb/common/core/USBGenericRequest.h diff --git a/radio/src/targets/sky9x/usb/common/core/USBGetDescriptorRequest.c b/radio/src/targets/Sky9x/usb/common/core/USBGetDescriptorRequest.c similarity index 95% rename from radio/src/targets/sky9x/usb/common/core/USBGetDescriptorRequest.c rename to radio/src/targets/Sky9x/usb/common/core/USBGetDescriptorRequest.c index 293792962..9822d2ee0 100644 --- a/radio/src/targets/sky9x/usb/common/core/USBGetDescriptorRequest.c +++ b/radio/src/targets/Sky9x/usb/common/core/USBGetDescriptorRequest.c @@ -38,7 +38,7 @@ // Headers //------------------------------------------------------------------------------ -#include "USBGetDescriptorRequest.h" +#include "../../../../Sky9x/usb/common/core/USBGetDescriptorRequest.h" //------------------------------------------------------------------------------ // Exported functions diff --git a/radio/src/targets/sky9x/usb/common/core/USBGetDescriptorRequest.h b/radio/src/targets/Sky9x/usb/common/core/USBGetDescriptorRequest.h similarity index 95% rename from radio/src/targets/sky9x/usb/common/core/USBGetDescriptorRequest.h rename to radio/src/targets/Sky9x/usb/common/core/USBGetDescriptorRequest.h index 43f6afd3d..75e440860 100644 --- a/radio/src/targets/sky9x/usb/common/core/USBGetDescriptorRequest.h +++ b/radio/src/targets/Sky9x/usb/common/core/USBGetDescriptorRequest.h @@ -51,7 +51,7 @@ // Headers //------------------------------------------------------------------------------ -#include "USBGenericRequest.h" +#include "../../../../Sky9x/usb/common/core/USBGenericRequest.h" //------------------------------------------------------------------------------ // Exported functions diff --git a/radio/src/targets/sky9x/usb/common/core/USBInterfaceAssociationDescriptor.h b/radio/src/targets/Sky9x/usb/common/core/USBInterfaceAssociationDescriptor.h similarity index 100% rename from radio/src/targets/sky9x/usb/common/core/USBInterfaceAssociationDescriptor.h rename to radio/src/targets/Sky9x/usb/common/core/USBInterfaceAssociationDescriptor.h diff --git a/radio/src/targets/sky9x/usb/common/core/USBInterfaceDescriptor.h b/radio/src/targets/Sky9x/usb/common/core/USBInterfaceDescriptor.h similarity index 100% rename from radio/src/targets/sky9x/usb/common/core/USBInterfaceDescriptor.h rename to radio/src/targets/Sky9x/usb/common/core/USBInterfaceDescriptor.h diff --git a/radio/src/targets/sky9x/usb/common/core/USBInterfaceRequest.c b/radio/src/targets/Sky9x/usb/common/core/USBInterfaceRequest.c similarity index 95% rename from radio/src/targets/sky9x/usb/common/core/USBInterfaceRequest.c rename to radio/src/targets/Sky9x/usb/common/core/USBInterfaceRequest.c index 61bf6ed77..4d896256e 100644 --- a/radio/src/targets/sky9x/usb/common/core/USBInterfaceRequest.c +++ b/radio/src/targets/Sky9x/usb/common/core/USBInterfaceRequest.c @@ -38,7 +38,7 @@ // Headers //------------------------------------------------------------------------------ -#include "USBInterfaceRequest.h" +#include "../../../../Sky9x/usb/common/core/USBInterfaceRequest.h" //------------------------------------------------------------------------------ // Exported functions diff --git a/radio/src/targets/sky9x/usb/common/core/USBInterfaceRequest.h b/radio/src/targets/Sky9x/usb/common/core/USBInterfaceRequest.h similarity index 95% rename from radio/src/targets/sky9x/usb/common/core/USBInterfaceRequest.h rename to radio/src/targets/Sky9x/usb/common/core/USBInterfaceRequest.h index bd4cddd17..71c2aa2bf 100644 --- a/radio/src/targets/sky9x/usb/common/core/USBInterfaceRequest.h +++ b/radio/src/targets/Sky9x/usb/common/core/USBInterfaceRequest.h @@ -51,7 +51,7 @@ // Headers //------------------------------------------------------------------------------ -#include "USBGenericRequest.h" +#include "../../../../Sky9x/usb/common/core/USBGenericRequest.h" //------------------------------------------------------------------------------ // Exported functions diff --git a/radio/src/targets/sky9x/usb/common/core/USBIrqHandler.c b/radio/src/targets/Sky9x/usb/common/core/USBIrqHandler.c similarity index 94% rename from radio/src/targets/sky9x/usb/common/core/USBIrqHandler.c rename to radio/src/targets/Sky9x/usb/common/core/USBIrqHandler.c index 386ebd216..bc4634b89 100644 --- a/radio/src/targets/sky9x/usb/common/core/USBIrqHandler.c +++ b/radio/src/targets/Sky9x/usb/common/core/USBIrqHandler.c @@ -37,10 +37,9 @@ //------------------------------------------------------------------------------ // Headers //------------------------------------------------------------------------------ -#include -#include - #include +#include "../../../../Sky9x/board.h" +#include "../../../../Sky9x/usb/device/core/USBD.h" //------------------------------------------------------------------------------ // Exported functions diff --git a/radio/src/targets/sky9x/usb/common/core/USBIrqHandler.h b/radio/src/targets/Sky9x/usb/common/core/USBIrqHandler.h similarity index 100% rename from radio/src/targets/sky9x/usb/common/core/USBIrqHandler.h rename to radio/src/targets/Sky9x/usb/common/core/USBIrqHandler.h diff --git a/radio/src/targets/sky9x/usb/common/core/USBSetAddressRequest.c b/radio/src/targets/Sky9x/usb/common/core/USBSetAddressRequest.c similarity index 95% rename from radio/src/targets/sky9x/usb/common/core/USBSetAddressRequest.c rename to radio/src/targets/Sky9x/usb/common/core/USBSetAddressRequest.c index 0e82a7f7f..e8cb01e1c 100644 --- a/radio/src/targets/sky9x/usb/common/core/USBSetAddressRequest.c +++ b/radio/src/targets/Sky9x/usb/common/core/USBSetAddressRequest.c @@ -38,7 +38,7 @@ // Headers //------------------------------------------------------------------------------ -#include "USBSetAddressRequest.h" +#include "../../../../Sky9x/usb/common/core/USBSetAddressRequest.h" //------------------------------------------------------------------------------ // Exported functions diff --git a/radio/src/targets/sky9x/usb/common/core/USBSetAddressRequest.h b/radio/src/targets/Sky9x/usb/common/core/USBSetAddressRequest.h similarity index 94% rename from radio/src/targets/sky9x/usb/common/core/USBSetAddressRequest.h rename to radio/src/targets/Sky9x/usb/common/core/USBSetAddressRequest.h index 78034c3d1..2ca7947d2 100644 --- a/radio/src/targets/sky9x/usb/common/core/USBSetAddressRequest.h +++ b/radio/src/targets/Sky9x/usb/common/core/USBSetAddressRequest.h @@ -47,7 +47,7 @@ // Headers //------------------------------------------------------------------------------ -#include "USBGenericRequest.h" +#include "../../../../Sky9x/usb/common/core/USBGenericRequest.h" //------------------------------------------------------------------------------ // Exported functions diff --git a/radio/src/targets/sky9x/usb/common/core/USBSetConfigurationRequest.c b/radio/src/targets/Sky9x/usb/common/core/USBSetConfigurationRequest.c similarity index 95% rename from radio/src/targets/sky9x/usb/common/core/USBSetConfigurationRequest.c rename to radio/src/targets/Sky9x/usb/common/core/USBSetConfigurationRequest.c index 3aa747d3a..cf4b27d9c 100644 --- a/radio/src/targets/sky9x/usb/common/core/USBSetConfigurationRequest.c +++ b/radio/src/targets/Sky9x/usb/common/core/USBSetConfigurationRequest.c @@ -38,7 +38,7 @@ // Headers //------------------------------------------------------------------------------ -#include "USBSetConfigurationRequest.h" +#include "../../../../Sky9x/usb/common/core/USBSetConfigurationRequest.h" //------------------------------------------------------------------------------ // Exported functions diff --git a/radio/src/targets/sky9x/usb/common/core/USBSetConfigurationRequest.h b/radio/src/targets/Sky9x/usb/common/core/USBSetConfigurationRequest.h similarity index 95% rename from radio/src/targets/sky9x/usb/common/core/USBSetConfigurationRequest.h rename to radio/src/targets/Sky9x/usb/common/core/USBSetConfigurationRequest.h index aa1fa1729..73b34b21e 100644 --- a/radio/src/targets/sky9x/usb/common/core/USBSetConfigurationRequest.h +++ b/radio/src/targets/Sky9x/usb/common/core/USBSetConfigurationRequest.h @@ -48,7 +48,7 @@ // Headers //------------------------------------------------------------------------------ -#include "USBGenericRequest.h" +#include "../../../../Sky9x/usb/common/core/USBGenericRequest.h" //------------------------------------------------------------------------------ // Exported functions diff --git a/radio/src/targets/sky9x/usb/common/core/USBStringDescriptor.h b/radio/src/targets/Sky9x/usb/common/core/USBStringDescriptor.h similarity index 100% rename from radio/src/targets/sky9x/usb/common/core/USBStringDescriptor.h rename to radio/src/targets/Sky9x/usb/common/core/USBStringDescriptor.h diff --git a/radio/src/targets/sky9x/usb/common/massstorage/MSDeviceDescriptor.h b/radio/src/targets/Sky9x/usb/common/massstorage/MSDeviceDescriptor.h similarity index 100% rename from radio/src/targets/sky9x/usb/common/massstorage/MSDeviceDescriptor.h rename to radio/src/targets/Sky9x/usb/common/massstorage/MSDeviceDescriptor.h diff --git a/radio/src/targets/sky9x/usb/common/massstorage/MSInterfaceDescriptor.h b/radio/src/targets/Sky9x/usb/common/massstorage/MSInterfaceDescriptor.h similarity index 100% rename from radio/src/targets/sky9x/usb/common/massstorage/MSInterfaceDescriptor.h rename to radio/src/targets/Sky9x/usb/common/massstorage/MSInterfaceDescriptor.h diff --git a/radio/src/targets/sky9x/usb/device/core/USBD.h b/radio/src/targets/Sky9x/usb/device/core/USBD.h similarity index 96% rename from radio/src/targets/sky9x/usb/device/core/USBD.h rename to radio/src/targets/Sky9x/usb/device/core/USBD.h index 7c1474582..f466a9c38 100644 --- a/radio/src/targets/sky9x/usb/device/core/USBD.h +++ b/radio/src/targets/Sky9x/usb/device/core/USBD.h @@ -50,8 +50,8 @@ //------------------------------------------------------------------------------ // #include -#include -#include +#include "../../../../Sky9x/usb/common/core/USBEndpointDescriptor.h" +#include "../../../../Sky9x/usb/common/core/USBGenericRequest.h" //------------------------------------------------------------------------------ // Compile Options diff --git a/radio/src/targets/sky9x/usb/device/core/USBDDriver.c b/radio/src/targets/Sky9x/usb/device/core/USBDDriver.c similarity index 92% rename from radio/src/targets/sky9x/usb/device/core/USBDDriver.c rename to radio/src/targets/Sky9x/usb/device/core/USBDDriver.c index e8315702b..e456b5efd 100644 --- a/radio/src/targets/sky9x/usb/device/core/USBDDriver.c +++ b/radio/src/targets/Sky9x/usb/device/core/USBDDriver.c @@ -31,22 +31,22 @@ // Headers //------------------------------------------------------------------------------ -#include "USBDDriver.h" -#include "USBD.h" -#include -#include "debug.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "../../../../Sky9x/usb/device/core/USBDDriver.h" +#include "debug.h" #include +#include "../../../../Sky9x/board.h" +#include "../../../../Sky9x/usb/common/core/USBConfigurationDescriptor.h" +#include "../../../../Sky9x/usb/common/core/USBDeviceDescriptor.h" +#include "../../../../Sky9x/usb/common/core/USBDeviceQualifierDescriptor.h" +#include "../../../../Sky9x/usb/common/core/USBEndpointDescriptor.h" +#include "../../../../Sky9x/usb/common/core/USBFeatureRequest.h" +#include "../../../../Sky9x/usb/common/core/USBGenericDescriptor.h" +#include "../../../../Sky9x/usb/common/core/USBGetDescriptorRequest.h" +#include "../../../../Sky9x/usb/common/core/USBInterfaceRequest.h" +#include "../../../../Sky9x/usb/common/core/USBSetAddressRequest.h" +#include "../../../../Sky9x/usb/common/core/USBSetConfigurationRequest.h" +#include "../../../../Sky9x/usb/device/core/USBD.h" //------------------------------------------------------------------------------ // Local functions @@ -419,8 +419,8 @@ static void USBDDriver_Test(unsigned char test) //patterns, jitter, and any other dynamic waveform specifications. //The test packet is made up by concatenating the following strings. //(Note: For J/K NRZI data, and for NRZ data, the bit on the left is the first one - //transmitted. “S” indicates that a bit stuff occurs, which inserts an “extra” NRZI data bit. - //“* N” is used to indicate N occurrences of a string of bits or symbols.) + //transmitted. �S� indicates that a bit stuff occurs, which inserts an �extra� NRZI data bit. + //�* N� is used to indicate N occurrences of a string of bits or symbols.) //A port in Test_Packet mode must send this packet repetitively. The inter-packet timing //must be no less than the minimum allowable inter-packet gap as defined in Section 7.1.18 and //no greater than 125 us. @@ -433,7 +433,7 @@ static void USBDDriver_Test(unsigned char test) case USBFeatureRequest_TESTJ: //Test mode Test_J: - //Upon command, a port’s transceiver must enter the high-speed J state and remain in that + //Upon command, a port�s transceiver must enter the high-speed J state and remain in that //state until the exit action is taken. This enables the testing of the high output drive //level on the D+ line. // Send ZLP @@ -445,7 +445,7 @@ static void USBDDriver_Test(unsigned char test) case USBFeatureRequest_TESTK: //Test mode Test_K: - //Upon command, a port’s transceiver must enter the high-speed K state and remain in + //Upon command, a port�s transceiver must enter the high-speed K state and remain in //that state until the exit action is taken. This enables the testing of the high output drive //level on the D- line. // Send a ZLP @@ -456,7 +456,7 @@ static void USBDDriver_Test(unsigned char test) case USBFeatureRequest_TESTSE0NAK: //Test mode Test_SE0_NAK: - //Upon command, a port’s transceiver must enter the high-speed receive mode + //Upon command, a port�s transceiver must enter the high-speed receive mode //and remain in that mode until the exit action is taken. This enables the testing //of output impedance, low level output voltage, and loading characteristics. //In addition, while in this mode, upstream facing ports (and only upstream facing ports) diff --git a/radio/src/targets/sky9x/usb/device/core/USBDDriver.h b/radio/src/targets/Sky9x/usb/device/core/USBDDriver.h similarity index 94% rename from radio/src/targets/sky9x/usb/device/core/USBDDriver.h rename to radio/src/targets/Sky9x/usb/device/core/USBDDriver.h index 40ca6d77a..eef7a6e44 100644 --- a/radio/src/targets/sky9x/usb/device/core/USBDDriver.h +++ b/radio/src/targets/Sky9x/usb/device/core/USBDDriver.h @@ -50,8 +50,8 @@ // Headers //------------------------------------------------------------------------------ -#include "USBDDriverDescriptors.h" -#include +#include "../../../../Sky9x/usb/common/core/USBGenericRequest.h" +#include "../../../../Sky9x/usb/device/core/USBDDriverDescriptors.h" //------------------------------------------------------------------------------ // Types diff --git a/radio/src/targets/sky9x/usb/device/core/USBDDriverDescriptors.h b/radio/src/targets/Sky9x/usb/device/core/USBDDriverDescriptors.h similarity index 92% rename from radio/src/targets/sky9x/usb/device/core/USBDDriverDescriptors.h rename to radio/src/targets/Sky9x/usb/device/core/USBDDriverDescriptors.h index f1064e4ac..50416c162 100644 --- a/radio/src/targets/sky9x/usb/device/core/USBDDriverDescriptors.h +++ b/radio/src/targets/Sky9x/usb/device/core/USBDDriverDescriptors.h @@ -43,9 +43,9 @@ // Headers //------------------------------------------------------------------------------ -#include -#include -#include +#include "../../../../Sky9x/usb/common/core/USBConfigurationDescriptor.h" +#include "../../../../Sky9x/usb/common/core/USBDeviceDescriptor.h" +#include "../../../../Sky9x/usb/common/core/USBDeviceQualifierDescriptor.h" //------------------------------------------------------------------------------ // Types diff --git a/radio/src/targets/sky9x/usb/device/core/USBD_UDP.c b/radio/src/targets/Sky9x/usb/device/core/USBD_UDP.c similarity index 96% rename from radio/src/targets/sky9x/usb/device/core/USBD_UDP.c rename to radio/src/targets/Sky9x/usb/device/core/USBD_UDP.c index 544f68596..fba624a43 100644 --- a/radio/src/targets/sky9x/usb/device/core/USBD_UDP.c +++ b/radio/src/targets/Sky9x/usb/device/core/USBD_UDP.c @@ -41,11 +41,11 @@ // Headers //------------------------------------------------------------------------------ -#include "USBD.h" -#include +#include "../../../../Sky9x/board.h" +#include "../../../../Sky9x/usb/common/core/USBEndpointDescriptor.h" +#include "../../../../Sky9x/usb/common/core/USBGenericRequest.h" +#include "../../../../Sky9x/usb/device/core/USBD.h" #include "debug.h" -#include -#include //------------------------------------------------------------------------------ // Local definitions diff --git a/radio/src/targets/sky9x/usb/device/massstorage/MSD.h b/radio/src/targets/Sky9x/usb/device/massstorage/MSD.h similarity index 100% rename from radio/src/targets/sky9x/usb/device/massstorage/MSD.h rename to radio/src/targets/Sky9x/usb/device/massstorage/MSD.h diff --git a/radio/src/targets/sky9x/usb/device/massstorage/MSDDStateMachine.c b/radio/src/targets/Sky9x/usb/device/massstorage/MSDDStateMachine.c similarity index 96% rename from radio/src/targets/sky9x/usb/device/massstorage/MSDDStateMachine.c rename to radio/src/targets/Sky9x/usb/device/massstorage/MSDDStateMachine.c index a024e26de..41c0f9e76 100644 --- a/radio/src/targets/sky9x/usb/device/massstorage/MSDDStateMachine.c +++ b/radio/src/targets/Sky9x/usb/device/massstorage/MSDDStateMachine.c @@ -31,8 +31,9 @@ // Includes //----------------------------------------------------------------------------- -#include "SBCMethods.h" -#include "MSDDStateMachine.h" +#include "../../../../Sky9x/usb/device/massstorage/MSDDStateMachine.h" + +#include "../../../../Sky9x/usb/device/massstorage/SBCMethods.h" //----------------------------------------------------------------------------- // Internal functions diff --git a/radio/src/targets/sky9x/usb/device/massstorage/MSDDStateMachine.h b/radio/src/targets/Sky9x/usb/device/massstorage/MSDDStateMachine.h similarity index 96% rename from radio/src/targets/sky9x/usb/device/massstorage/MSDDStateMachine.h rename to radio/src/targets/Sky9x/usb/device/massstorage/MSDDStateMachine.h index c52adc93f..bbfd88742 100644 --- a/radio/src/targets/sky9x/usb/device/massstorage/MSDDStateMachine.h +++ b/radio/src/targets/Sky9x/usb/device/massstorage/MSDDStateMachine.h @@ -51,8 +51,8 @@ // Headers //----------------------------------------------------------------------------- -#include "MSD.h" -#include "MSDLun.h" +#include "../../../../Sky9x/usb/device/massstorage/MSD.h" +#include "../../../../Sky9x/usb/device/massstorage/MSDLun.h" #include "debug.h" //----------------------------------------------------------------------------- diff --git a/radio/src/targets/sky9x/usb/device/massstorage/MSDDriver.c b/radio/src/targets/Sky9x/usb/device/massstorage/MSDDriver.c similarity index 93% rename from radio/src/targets/sky9x/usb/device/massstorage/MSDDriver.c rename to radio/src/targets/Sky9x/usb/device/massstorage/MSDDriver.c index 4082bdd9e..e546d77fe 100644 --- a/radio/src/targets/sky9x/usb/device/massstorage/MSDDriver.c +++ b/radio/src/targets/Sky9x/usb/device/massstorage/MSDDriver.c @@ -31,15 +31,16 @@ // Includes //------------------------------------------------------------------------------ -#include -#include "MSDDriver.h" -#include "MSDDriverDescriptors.h" -#include "SBCMethods.h" +#include "../../../../Sky9x/usb/device/massstorage/MSDDriver.h" + +#include "../../../../Sky9x/Media.h" +#include "../../../../Sky9x/usb/common/core/USBFeatureRequest.h" +#include "../../../../Sky9x/usb/common/core/USBGenericRequest.h" +#include "../../../../Sky9x/usb/device/core/USBD.h" +#include "../../../../Sky9x/usb/device/core/USBDDriver.h" +#include "../../../../Sky9x/usb/device/massstorage/MSDDriverDescriptors.h" +#include "../../../../Sky9x/usb/device/massstorage/SBCMethods.h" #include "debug.h" -#include -#include -#include -#include //----------------------------------------------------------------------------- // Internal variables diff --git a/radio/src/targets/sky9x/usb/device/massstorage/MSDDriver.h b/radio/src/targets/Sky9x/usb/device/massstorage/MSDDriver.h similarity index 94% rename from radio/src/targets/sky9x/usb/device/massstorage/MSDDriver.h rename to radio/src/targets/Sky9x/usb/device/massstorage/MSDDriver.h index 388f0adcb..09f797f96 100644 --- a/radio/src/targets/sky9x/usb/device/massstorage/MSDDriver.h +++ b/radio/src/targets/Sky9x/usb/device/massstorage/MSDDriver.h @@ -50,8 +50,8 @@ // Headers //------------------------------------------------------------------------------ -#include "MSD.h" -#include "MSDLun.h" +#include "../../../../Sky9x/usb/device/massstorage/MSD.h" +#include "../../../../Sky9x/usb/device/massstorage/MSDLun.h" // #include //------------------------------------------------------------------------------ diff --git a/radio/src/targets/sky9x/usb/device/massstorage/MSDDriverDescriptors.c b/radio/src/targets/Sky9x/usb/device/massstorage/MSDDriverDescriptors.c similarity index 93% rename from radio/src/targets/sky9x/usb/device/massstorage/MSDDriverDescriptors.c rename to radio/src/targets/Sky9x/usb/device/massstorage/MSDDriverDescriptors.c index 30e1efb12..529de130c 100644 --- a/radio/src/targets/sky9x/usb/device/massstorage/MSDDriverDescriptors.c +++ b/radio/src/targets/Sky9x/usb/device/massstorage/MSDDriverDescriptors.c @@ -31,16 +31,17 @@ // Headers //------------------------------------------------------------------------------ -#include "MSDDriverDescriptors.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "../../../../Sky9x/usb/device/massstorage/MSDDriverDescriptors.h" + +#include "../../../../Sky9x/board.h" +#include "../../../../Sky9x/usb/common/core/USBConfigurationDescriptor.h" +#include "../../../../Sky9x/usb/common/core/USBDeviceDescriptor.h" +#include "../../../../Sky9x/usb/common/core/USBEndpointDescriptor.h" +#include "../../../../Sky9x/usb/common/core/USBGenericDescriptor.h" +#include "../../../../Sky9x/usb/common/core/USBInterfaceDescriptor.h" +#include "../../../../Sky9x/usb/common/core/USBStringDescriptor.h" +#include "../../../../Sky9x/usb/common/massstorage/MSDeviceDescriptor.h" +#include "../../../../Sky9x/usb/common/massstorage/MSInterfaceDescriptor.h" //------------------------------------------------------------------------------ // Internal definitions diff --git a/radio/src/targets/sky9x/usb/device/massstorage/MSDDriverDescriptors.h b/radio/src/targets/Sky9x/usb/device/massstorage/MSDDriverDescriptors.h similarity index 95% rename from radio/src/targets/sky9x/usb/device/massstorage/MSDDriverDescriptors.h rename to radio/src/targets/Sky9x/usb/device/massstorage/MSDDriverDescriptors.h index be046a95f..c2a3a36ef 100644 --- a/radio/src/targets/sky9x/usb/device/massstorage/MSDDriverDescriptors.h +++ b/radio/src/targets/Sky9x/usb/device/massstorage/MSDDriverDescriptors.h @@ -47,7 +47,7 @@ // Headers //------------------------------------------------------------------------------ -#include +#include "../../../../Sky9x/usb/device/core/USBDDriverDescriptors.h" //------------------------------------------------------------------------------ // Definitions diff --git a/radio/src/targets/sky9x/usb/device/massstorage/MSDIOFifo.h b/radio/src/targets/Sky9x/usb/device/massstorage/MSDIOFifo.h similarity index 100% rename from radio/src/targets/sky9x/usb/device/massstorage/MSDIOFifo.h rename to radio/src/targets/Sky9x/usb/device/massstorage/MSDIOFifo.h diff --git a/radio/src/targets/sky9x/usb/device/massstorage/MSDLun.c b/radio/src/targets/Sky9x/usb/device/massstorage/MSDLun.c similarity index 96% rename from radio/src/targets/sky9x/usb/device/massstorage/MSDLun.c rename to radio/src/targets/Sky9x/usb/device/massstorage/MSDLun.c index 00c8376d3..c83e0b4fa 100644 --- a/radio/src/targets/sky9x/usb/device/massstorage/MSDLun.c +++ b/radio/src/targets/Sky9x/usb/device/massstorage/MSDLun.c @@ -32,9 +32,10 @@ //------------------------------------------------------------------------------ -#include "MSDLun.h" +#include "../../../../Sky9x/usb/device/massstorage/MSDLun.h" + +#include "../../../../Sky9x/usb/device/core/USBD.h" #include "debug.h" -#include //------------------------------------------------------------------------------ // Constants diff --git a/radio/src/targets/sky9x/usb/device/massstorage/MSDLun.h b/radio/src/targets/Sky9x/usb/device/massstorage/MSDLun.h similarity index 94% rename from radio/src/targets/sky9x/usb/device/massstorage/MSDLun.h rename to radio/src/targets/Sky9x/usb/device/massstorage/MSDLun.h index 15754f403..6124ccd6f 100644 --- a/radio/src/targets/sky9x/usb/device/massstorage/MSDLun.h +++ b/radio/src/targets/Sky9x/usb/device/massstorage/MSDLun.h @@ -50,10 +50,10 @@ // Headers //------------------------------------------------------------------------------ -#include "SBC.h" -#include -#include -#include +#include "../../../../Sky9x/Media.h" +#include "../../../../Sky9x/usb/device/core/USBD.h" +#include "../../../../Sky9x/usb/device/massstorage/MSDIOFifo.h" +#include "../../../../Sky9x/usb/device/massstorage/SBC.h" //------------------------------------------------------------------------------ // Definitions diff --git a/radio/src/targets/sky9x/usb/device/massstorage/SBC.h b/radio/src/targets/Sky9x/usb/device/massstorage/SBC.h similarity index 100% rename from radio/src/targets/sky9x/usb/device/massstorage/SBC.h rename to radio/src/targets/Sky9x/usb/device/massstorage/SBC.h diff --git a/radio/src/targets/sky9x/usb/device/massstorage/SBCMethods.c b/radio/src/targets/Sky9x/usb/device/massstorage/SBCMethods.c similarity index 96% rename from radio/src/targets/sky9x/usb/device/massstorage/SBCMethods.c rename to radio/src/targets/Sky9x/usb/device/massstorage/SBCMethods.c index 0f69cd111..65b416bbb 100644 --- a/radio/src/targets/sky9x/usb/device/massstorage/SBCMethods.c +++ b/radio/src/targets/Sky9x/usb/device/massstorage/SBCMethods.c @@ -31,11 +31,11 @@ // Headers //------------------------------------------------------------------------------ -#include "SBCMethods.h" -#include "MSDDStateMachine.h" -#include +#include "../../../../Sky9x/usb/device/massstorage/SBCMethods.h" -#include "MSDIOFifo.h" +#include "../../../../Sky9x/usb/device/core/USBD.h" +#include "../../../../Sky9x/usb/device/massstorage/MSDDStateMachine.h" +#include "../../../../Sky9x/usb/device/massstorage/MSDIOFifo.h" //------------------------------------------------------------------------------ // Global variables diff --git a/radio/src/targets/sky9x/usb/device/massstorage/SBCMethods.h b/radio/src/targets/Sky9x/usb/device/massstorage/SBCMethods.h similarity index 95% rename from radio/src/targets/sky9x/usb/device/massstorage/SBCMethods.h rename to radio/src/targets/Sky9x/usb/device/massstorage/SBCMethods.h index f40f55af3..25b1d5e76 100644 --- a/radio/src/targets/sky9x/usb/device/massstorage/SBCMethods.h +++ b/radio/src/targets/Sky9x/usb/device/massstorage/SBCMethods.h @@ -51,9 +51,8 @@ // Headers //------------------------------------------------------------------------------ -#include "SBC.h" -// #include -#include "MSDDStateMachine.h" +#include "../../../../Sky9x/usb/device/massstorage/MSDDStateMachine.h" +#include "../../../../Sky9x/usb/device/massstorage/SBC.h" //------------------------------------------------------------------------------ // Definitions diff --git a/radio/src/targets/sky9x/vectors_sam3s.c b/radio/src/targets/Sky9x/vectors_sam3s.c similarity index 100% rename from radio/src/targets/sky9x/vectors_sam3s.c rename to radio/src/targets/Sky9x/vectors_sam3s.c diff --git a/radio/src/targets/taranis/adc_driver.cpp b/radio/src/targets/Taranis/adc_driver.cpp similarity index 93% rename from radio/src/targets/taranis/adc_driver.cpp rename to radio/src/targets/Taranis/adc_driver.cpp index b6339c3b7..fb2be49e1 100644 --- a/radio/src/targets/taranis/adc_driver.cpp +++ b/radio/src/targets/Taranis/adc_driver.cpp @@ -57,7 +57,7 @@ #if defined(REV9E) #define NUMBER_ANALOG_ADC1 10 #define NUMBER_ANALOG_ADC3 3 - // mapping from Analog_values order to enum Analogs + // mapping from adcValues order to enum Analogs const uint8_t ana_mapping[NUMBER_ANALOG] = { 0 /*STICK1*/, 1 /*STICK2*/, 2 /*STICK3*/, 3 /*STICK4*/, 10 /*POT1*/, 4 /*POT2*/, 5 /*POT3*/, 6 /*POT4*/, 11 /*SLIDER1*/, 12 /*SLIDER2*/, 7 /*SLIDER3*/, 8 /*SLIDER4*/, @@ -66,7 +66,7 @@ #define NUMBER_ANALOG_ADC1 10 #endif -uint16_t Analog_values[NUMBER_ANALOG] __DMA; +uint16_t adcValues[NUMBER_ANALOG] __DMA; void adcInit() { @@ -102,7 +102,7 @@ void adcInit() DMA2_Stream0->CR = DMA_SxCR_PL | DMA_SxCR_MSIZE_0 | DMA_SxCR_PSIZE_0 | DMA_SxCR_MINC; DMA2_Stream0->PAR = CONVERT_PTR_UINT(&ADC1->DR); - DMA2_Stream0->M0AR = CONVERT_PTR_UINT(Analog_values); + DMA2_Stream0->M0AR = CONVERT_PTR_UINT(adcValues); DMA2_Stream0->NDTR = NUMBER_ANALOG_ADC1; DMA2_Stream0->FCR = DMA_SxFCR_DMDIS | DMA_SxFCR_FTH_0 ; @@ -118,7 +118,7 @@ void adcInit() // Enable the DMA channel here, DMA2 stream 1, channel 2 DMA2_Stream1->CR = DMA_SxCR_PL | DMA_SxCR_CHSEL_1 | DMA_SxCR_MSIZE_0 | DMA_SxCR_PSIZE_0 | DMA_SxCR_MINC; DMA2_Stream1->PAR = CONVERT_PTR_UINT(&ADC3->DR); - DMA2_Stream1->M0AR = CONVERT_PTR_UINT(Analog_values + NUMBER_ANALOG_ADC1); + DMA2_Stream1->M0AR = CONVERT_PTR_UINT(adcValues + NUMBER_ANALOG_ADC1); DMA2_Stream1->NDTR = NUMBER_ANALOG_ADC3; DMA2_Stream1->FCR = DMA_SxFCR_DMDIS | DMA_SxFCR_FTH_0 ; #endif @@ -175,7 +175,7 @@ uint16_t getAnalogValue(uint32_t index) index = ana_mapping[index]; #endif if (ana_direction[index] < 0) - return 4096 - Analog_values[index]; + return 4096 - adcValues[index]; else - return Analog_values[index]; + return adcValues[index]; } diff --git a/radio/src/targets/taranis/aspi.c b/radio/src/targets/Taranis/aspi.c similarity index 92% rename from radio/src/targets/taranis/aspi.c rename to radio/src/targets/Taranis/aspi.c index ce435faa0..1292eebfa 100644 --- a/radio/src/targets/taranis/aspi.c +++ b/radio/src/targets/Taranis/aspi.c @@ -10,7 +10,7 @@ ****************************************************************************** */ -#include "board_taranis.h" +#include "../Taranis/board_taranis.h" /** **********send command to lcd************** diff --git a/radio/src/targets/taranis/aspi.h b/radio/src/targets/Taranis/aspi.h similarity index 100% rename from radio/src/targets/taranis/aspi.h rename to radio/src/targets/Taranis/aspi.h diff --git a/radio/src/targets/taranis/audio_driver.cpp b/radio/src/targets/Taranis/audio_driver.cpp similarity index 100% rename from radio/src/targets/taranis/audio_driver.cpp rename to radio/src/targets/Taranis/audio_driver.cpp diff --git a/radio/src/targets/taranis/bluetooth_driver.cpp b/radio/src/targets/Taranis/bluetooth_driver.cpp similarity index 95% rename from radio/src/targets/taranis/bluetooth_driver.cpp rename to radio/src/targets/Taranis/bluetooth_driver.cpp index 65789778c..9490df75d 100644 --- a/radio/src/targets/taranis/bluetooth_driver.cpp +++ b/radio/src/targets/Taranis/bluetooth_driver.cpp @@ -8,9 +8,9 @@ * - */ -#include "board_taranis.h" #include "string.h" #include "../../fifo.h" +#include "../Taranis/board_taranis.h" Fifo<64> btTxFifo; Fifo<64> btRxFifo; diff --git a/radio/src/targets/taranis/board_taranis.cpp b/radio/src/targets/Taranis/board_taranis.cpp similarity index 95% rename from radio/src/targets/taranis/board_taranis.cpp rename to radio/src/targets/Taranis/board_taranis.cpp index 47644dc36..15dd5e705 100644 --- a/radio/src/targets/taranis/board_taranis.cpp +++ b/radio/src/targets/Taranis/board_taranis.cpp @@ -161,7 +161,7 @@ void boardInit() #if defined(REV9E) if (!WAS_RESET_BY_WATCHDOG_OR_SOFTWARE()) { - lcd_clear(); + lcdClear(); lcd_bmp(76, 2, bmp_lock, 0, 60); lcdRefresh(); lcdRefreshWait(); @@ -173,7 +173,7 @@ void boardInit() duration = get_tmr10ms() - start; if (duration < PWR_PRESS_DURATION_MIN) { unsigned index = duration / (PWR_PRESS_DURATION_MIN / 4); - lcd_clear(); + lcdClear(); lcd_bmp(76, 2, bmp_startup, index*60, 60); } else if (duration >= PWR_PRESS_DURATION_MAX) { @@ -199,7 +199,7 @@ void boardInit() pwrInit(); backlightInit(); } - topLcdInit(); + toplcdInit(); #else backlightInit(); #endif @@ -209,7 +209,7 @@ void boardOff() { BACKLIGHT_OFF(); #if defined(REV9E) - topLcdOff(); + toplcdOff(); #endif #if defined(REV9E) diff --git a/radio/src/targets/taranis/board_taranis.h b/radio/src/targets/Taranis/board_taranis.h similarity index 95% rename from radio/src/targets/taranis/board_taranis.h rename to radio/src/targets/Taranis/board_taranis.h index fa042076e..bfe416943 100644 --- a/radio/src/targets/taranis/board_taranis.h +++ b/radio/src/targets/Taranis/board_taranis.h @@ -78,13 +78,13 @@ extern "C" { #include "usbd_msc_core.h" #include "usbd_hid_core.h" #include "usbd_usr.h" - #include "usbd_desc.h" - #include "usb_conf.h" - #include "usbd_conf.h" + #include "../Taranis/usbd_desc.h" + #include "../Taranis/usb_conf.h" + #include "../Taranis/usbd_conf.h" #endif -#include "hal.h" -#include "aspi.h" +#include "../Taranis/hal.h" +#include "../Taranis/aspi.h" #if defined(__cplusplus) && !defined(SIMU) } @@ -352,10 +352,10 @@ void lcdOff(void); // Top LCD driver #if defined(REV9E) -void topLcdInit(void); -void topLcdOff(void); -void topLcdRefreshStart(void); -void topLcdRefreshEnd(void); +void toplcdInit(void); +void toplcdOff(void); +void toplcdRefreshStart(void); +void toplcdRefreshEnd(void); void setTopFirstTimer(int32_t value); void setTopSecondTimer(uint32_t value); void setTopRssi(uint32_t rssi); diff --git a/radio/src/targets/taranis/bootloader/.gitignore b/radio/src/targets/Taranis/bootloader/.gitignore similarity index 100% rename from radio/src/targets/taranis/bootloader/.gitignore rename to radio/src/targets/Taranis/bootloader/.gitignore diff --git a/radio/src/targets/taranis/bootloader/Makefile b/radio/src/targets/Taranis/bootloader/Makefile similarity index 100% rename from radio/src/targets/taranis/bootloader/Makefile rename to radio/src/targets/Taranis/bootloader/Makefile diff --git a/radio/src/targets/taranis/bootloader/boot.cpp b/radio/src/targets/Taranis/bootloader/boot.cpp similarity index 98% rename from radio/src/targets/taranis/bootloader/boot.cpp rename to radio/src/targets/Taranis/bootloader/boot.cpp index 2460dd7fe..f4d57be1f 100644 --- a/radio/src/targets/taranis/bootloader/boot.cpp +++ b/radio/src/targets/Taranis/bootloader/boot.cpp @@ -53,8 +53,8 @@ #include #include -#include "board_taranis.h" -#include "eeprom_rlc.h" +#include "../board_taranis.h" +#include "storage/eeprom_rlc.h" #include "pwr.h" #include "gui/Taranis/lcd.h" #include "keys.h" @@ -63,6 +63,7 @@ #include "FatFs/diskio.h" #include "translations/en.h" #include "stamp-opentx.h" +#include "strhelpers.h" #if defined(PCBTARANIS) #define BOOTLOADER_TITLE " Taranis BootLoader - " VERS_STR @@ -156,7 +157,7 @@ extern void usbPluggedIn(); #if defined(REV9E) typedef int32_t rotenc_t; -extern rotenc_t x9de_rotenc; +extern rotenc_t rotencValue; #endif void interrupt10ms(void) @@ -174,7 +175,7 @@ void interrupt10ms(void) #if defined(REV9E) checkRotaryEncoder(); static rotenc_t rePreviousValue; - rotenc_t reNewValue = (x9de_rotenc / 2); + rotenc_t reNewValue = (rotencValue / 2); int8_t scrollRE = reNewValue - rePreviousValue; if (scrollRE) { rePreviousValue = reNewValue; @@ -402,7 +403,7 @@ int main() lcdInit(); backlightInit(); - lcd_clear(); + lcdClear(); lcd_putsn(0, 0, (const char *)bootloaderVersion, 0); // trick to avoid bootloaderVersion to be optimized out ... lcd_putsLeft(0, BOOTLOADER_TITLE); lcd_invert_line(0); @@ -427,7 +428,7 @@ int main() Tenms = 0; lcdRefreshWait(); - lcd_clear(); + lcdClear(); lcd_putsLeft(0, BOOTLOADER_TITLE); lcd_invert_line(0); @@ -539,7 +540,7 @@ int main() else { x = 0; } - lcd_putsnAtt(INDENT_WIDTH, 16 + FH * i, &Filenames[i][x], DISPLAY_CHAR_WIDTH, 0); + lcdDrawTextWithLen(INDENT_WIDTH, 16 + FH * i, &Filenames[i][x], DISPLAY_CHAR_WIDTH, 0); } if (event == EVT_KEY_REPT(BOOT_KEY_DOWN) || event == EVT_KEY_FIRST(BOOT_KEY_DOWN)) { @@ -627,7 +628,7 @@ int main() progress = (200*eepromWritten) / EESIZE; } - lcd_rect( 3, 6*FH+4, 204, 7); + lcdDrawRect( 3, 6*FH+4, 204, 7); lcd_hline(5, 6*FH+6, progress, FORCE); lcd_hline(5, 6*FH+7, progress, FORCE); lcd_hline(5, 6*FH+8, progress, FORCE); @@ -686,7 +687,7 @@ int main() if (state == ST_REBOOT) { if (readKeys() == 0) { - lcd_clear(); + lcdClear(); lcdRefresh(); lcdRefreshWait(); RCC->CSR |= RCC_CSR_RMVF; //clear the reset flags in RCC clock control & status register diff --git a/radio/src/targets/taranis/bootloader/init.c b/radio/src/targets/Taranis/bootloader/init.c similarity index 100% rename from radio/src/targets/taranis/bootloader/init.c rename to radio/src/targets/Taranis/bootloader/init.c diff --git a/radio/src/targets/taranis/configure_pins.cpp b/radio/src/targets/Taranis/configure_pins.cpp similarity index 100% rename from radio/src/targets/taranis/configure_pins.cpp rename to radio/src/targets/Taranis/configure_pins.cpp diff --git a/radio/src/targets/taranis/delays.c b/radio/src/targets/Taranis/delays.c similarity index 94% rename from radio/src/targets/taranis/delays.c rename to radio/src/targets/Taranis/delays.c index 756db1ed7..6d32f8e86 100644 --- a/radio/src/targets/taranis/delays.c +++ b/radio/src/targets/Taranis/delays.c @@ -34,7 +34,7 @@ * */ -#include "board_taranis.h" +#include "../Taranis/board_taranis.h" void delaysInit(void) { diff --git a/radio/src/targets/taranis/diskio.cpp b/radio/src/targets/Taranis/diskio.cpp similarity index 96% rename from radio/src/targets/taranis/diskio.cpp rename to radio/src/targets/Taranis/diskio.cpp index 5f6bb1bd5..d7e111b28 100644 --- a/radio/src/targets/taranis/diskio.cpp +++ b/radio/src/targets/Taranis/diskio.cpp @@ -35,12 +35,12 @@ */ #include -#include "board_taranis.h" #include "../../thirdparty/FatFs/diskio.h" #include "../../thirdparty/FatFs/ff.h" #include "../../thirdparty/CoOS/kernel/CoOS.h" -#include "hal.h" #include "../../debug.h" +#include "../Taranis/board_taranis.h" +#include "../Taranis/hal.h" /* Definitions for MMC/SDC command */ #define CMD0 (0x40+0) /* GO_IDLE_STATE */ @@ -81,7 +81,6 @@ /*-----------------------------------------------------------------------*/ #if !defined(BOOT) static OS_MutexID ioMutex; -volatile int mutexCheck = 0; int ff_cre_syncobj (BYTE vol, _SYNC_t *mutex) { diff --git a/radio/src/targets/taranis/flash_driver.cpp b/radio/src/targets/Taranis/flash_driver.cpp similarity index 100% rename from radio/src/targets/taranis/flash_driver.cpp rename to radio/src/targets/Taranis/flash_driver.cpp diff --git a/radio/src/targets/taranis/hal.h b/radio/src/targets/Taranis/hal.h similarity index 100% rename from radio/src/targets/taranis/hal.h rename to radio/src/targets/Taranis/hal.h diff --git a/radio/src/targets/taranis/haptic_driver.cpp b/radio/src/targets/Taranis/haptic_driver.cpp similarity index 100% rename from radio/src/targets/taranis/haptic_driver.cpp rename to radio/src/targets/Taranis/haptic_driver.cpp diff --git a/radio/src/targets/taranis/i2c_driver.cpp b/radio/src/targets/Taranis/i2c_driver.cpp similarity index 96% rename from radio/src/targets/taranis/i2c_driver.cpp rename to radio/src/targets/Taranis/i2c_driver.cpp index 3655e3730..2686a0de3 100644 --- a/radio/src/targets/taranis/i2c_driver.cpp +++ b/radio/src/targets/Taranis/i2c_driver.cpp @@ -1,4 +1,4 @@ -#include "board_taranis.h" +#include "../Taranis/board_taranis.h" void eepromPageWrite(uint8_t* pBuffer, uint16_t WriteAddr, uint8_t NumByteToWrite); void eepromWaitEepromStandbyState(void); diff --git a/radio/src/targets/taranis/keys_driver.cpp b/radio/src/targets/Taranis/keys_driver.cpp similarity index 95% rename from radio/src/targets/taranis/keys_driver.cpp rename to radio/src/targets/Taranis/keys_driver.cpp index a9f7d72b6..6e824b32b 100644 --- a/radio/src/targets/taranis/keys_driver.cpp +++ b/radio/src/targets/Taranis/keys_driver.cpp @@ -99,7 +99,7 @@ uint8_t keyDown() #if defined(REV9E) uint32_t Rotary_position; -rotenc_t x9de_rotenc; +rotenc_t rotencValue; void checkRotaryEncoder() { register uint32_t dummy ; @@ -111,11 +111,11 @@ void checkRotaryEncoder() { if ( ( Rotary_position & 0x01 ) ^ ( ( dummy & 0x02) >> 1 ) ) { - --x9de_rotenc; + --rotencValue; } else { - ++x9de_rotenc; + ++rotencValue; } Rotary_position &= ~0x03 ; Rotary_position |= dummy ; @@ -135,7 +135,7 @@ void readKeysAndTrims() #if defined(REV9E) && !defined(SIMU) #define X9E_RE_TIMEOUT 5 static rotenc_t rePreviousValue; - rotenc_t reNewValue = (x9de_rotenc / 2); + rotenc_t reNewValue = (rotencValue / 2); static int timeout = X9E_RE_TIMEOUT; static int lastkey = 0; int8_t scrollRE = reNewValue - rePreviousValue; diff --git a/radio/src/targets/taranis/lcd_driver.cpp b/radio/src/targets/Taranis/lcd_driver.cpp similarity index 100% rename from radio/src/targets/taranis/lcd_driver.cpp rename to radio/src/targets/Taranis/lcd_driver.cpp diff --git a/radio/src/targets/taranis/pulses_driver.cpp b/radio/src/targets/Taranis/pulses_driver.cpp similarity index 100% rename from radio/src/targets/taranis/pulses_driver.cpp rename to radio/src/targets/Taranis/pulses_driver.cpp diff --git a/radio/src/targets/taranis/pwr_driver.c b/radio/src/targets/Taranis/pwr_driver.c similarity index 95% rename from radio/src/targets/taranis/pwr_driver.c rename to radio/src/targets/Taranis/pwr_driver.c index 6ad746999..e9b17cfd2 100644 --- a/radio/src/targets/taranis/pwr_driver.c +++ b/radio/src/targets/Taranis/pwr_driver.c @@ -34,8 +34,8 @@ * */ -#include "board_taranis.h" #include "../../pwr.h" +#include "../Taranis/board_taranis.h" void pwrInit() { diff --git a/radio/src/targets/taranis/rtc_driver.cpp b/radio/src/targets/Taranis/rtc_driver.cpp similarity index 100% rename from radio/src/targets/taranis/rtc_driver.cpp rename to radio/src/targets/Taranis/rtc_driver.cpp diff --git a/radio/src/targets/taranis/serial2_driver.cpp b/radio/src/targets/Taranis/serial2_driver.cpp similarity index 100% rename from radio/src/targets/taranis/serial2_driver.cpp rename to radio/src/targets/Taranis/serial2_driver.cpp diff --git a/radio/src/targets/taranis/stm32_ramboot.ld b/radio/src/targets/Taranis/stm32_ramboot.ld similarity index 100% rename from radio/src/targets/taranis/stm32_ramboot.ld rename to radio/src/targets/Taranis/stm32_ramboot.ld diff --git a/radio/src/targets/taranis/stm32f2_flash.ld b/radio/src/targets/Taranis/stm32f2_flash.ld similarity index 100% rename from radio/src/targets/taranis/stm32f2_flash.ld rename to radio/src/targets/Taranis/stm32f2_flash.ld diff --git a/radio/src/targets/taranis/stm32f4_flash.ld b/radio/src/targets/Taranis/stm32f4_flash.ld similarity index 100% rename from radio/src/targets/taranis/stm32f4_flash.ld rename to radio/src/targets/Taranis/stm32f4_flash.ld diff --git a/radio/src/targets/taranis/system_stm32f2xx.c b/radio/src/targets/Taranis/system_stm32f2xx.c similarity index 100% rename from radio/src/targets/taranis/system_stm32f2xx.c rename to radio/src/targets/Taranis/system_stm32f2xx.c diff --git a/radio/src/targets/taranis/system_stm32f4xx.c b/radio/src/targets/Taranis/system_stm32f4xx.c similarity index 100% rename from radio/src/targets/taranis/system_stm32f4xx.c rename to radio/src/targets/Taranis/system_stm32f4xx.c diff --git a/radio/src/targets/taranis/telemetry_driver.cpp b/radio/src/targets/Taranis/telemetry_driver.cpp similarity index 100% rename from radio/src/targets/taranis/telemetry_driver.cpp rename to radio/src/targets/Taranis/telemetry_driver.cpp diff --git a/radio/src/targets/taranis/top_lcd_driver.cpp b/radio/src/targets/Taranis/top_lcd_driver.cpp similarity index 97% rename from radio/src/targets/taranis/top_lcd_driver.cpp rename to radio/src/targets/Taranis/top_lcd_driver.cpp index e6e86c54b..566cd27fb 100644 --- a/radio/src/targets/taranis/top_lcd_driver.cpp +++ b/radio/src/targets/Taranis/top_lcd_driver.cpp @@ -34,7 +34,7 @@ * */ -#include "board_taranis.h" +#include "../Taranis/board_taranis.h" #define CS1_HIGH() TOPLCD_GPIO->BSRRL = TOPLCD_GPIO_PIN_CS1 #define CS1_LOW() TOPLCD_GPIO->BSRRH = TOPLCD_GPIO_PIN_CS1 @@ -233,7 +233,7 @@ extern "C" void TIM8_BRK_TIM12_IRQHandler() } #endif -void topLcdInit() +void toplcdInit() { RCC_AHB1PeriphClockCmd(TOPLCD_RCC_AHB1Periph, ENABLE); GPIO_InitTypeDef GPIO_InitStructure; @@ -254,15 +254,15 @@ void topLcdInit() ht1621SendCommand(1, 0x01); ht1621SendCommand(1, 0x29); - topLcdRefreshStart(); - topLcdRefreshEnd(); + toplcdRefreshStart(); + toplcdRefreshEnd(); } -void topLcdOff() +void toplcdOff() { BL_OFF(); - topLcdRefreshStart(); - topLcdRefreshEnd(); + toplcdRefreshStart(); + toplcdRefreshEnd(); } void setTopFirstTimer(int32_t value) @@ -419,13 +419,13 @@ void setTopSecondTimer(uint32_t value) Ht1621Data1[3] |= 0x10; // "Operation Time" } -void topLcdRefreshStart() +void toplcdRefreshStart() { memset(Ht1621Data1, 0, sizeof(Ht1621Data1)); memset(Ht1621Data2, 0, sizeof(Ht1621Data2)); } -void topLcdRefreshEnd() +void toplcdRefreshEnd() { ht1621WrAllData(0, Ht1621Data1); ht1621WrAllData(1, Ht1621Data2); diff --git a/radio/src/targets/taranis/trainer_driver.cpp b/radio/src/targets/Taranis/trainer_driver.cpp similarity index 100% rename from radio/src/targets/taranis/trainer_driver.cpp rename to radio/src/targets/Taranis/trainer_driver.cpp diff --git a/radio/src/targets/taranis/usb_bsp.c b/radio/src/targets/Taranis/usb_bsp.c similarity index 96% rename from radio/src/targets/taranis/usb_bsp.c rename to radio/src/targets/Taranis/usb_bsp.c index eefa412a2..8d29546c1 100644 --- a/radio/src/targets/taranis/usb_bsp.c +++ b/radio/src/targets/Taranis/usb_bsp.c @@ -28,8 +28,9 @@ /* Includes ------------------------------------------------------------------*/ -#include "board_taranis.h" #include "usb_bsp.h" + +#include "board_taranis.h" #include "usbd_conf.h" extern uint32_t SystemCoreClock; diff --git a/radio/src/targets/taranis/usb_conf.h b/radio/src/targets/Taranis/usb_conf.h similarity index 100% rename from radio/src/targets/taranis/usb_conf.h rename to radio/src/targets/Taranis/usb_conf.h diff --git a/radio/src/targets/taranis/usb_driver.c b/radio/src/targets/Taranis/usb_driver.c similarity index 100% rename from radio/src/targets/taranis/usb_driver.c rename to radio/src/targets/Taranis/usb_driver.c diff --git a/radio/src/targets/taranis/usbd_cdc.cpp b/radio/src/targets/Taranis/usbd_cdc.cpp similarity index 100% rename from radio/src/targets/taranis/usbd_cdc.cpp rename to radio/src/targets/Taranis/usbd_cdc.cpp diff --git a/radio/src/targets/taranis/usbd_conf.h b/radio/src/targets/Taranis/usbd_conf.h similarity index 100% rename from radio/src/targets/taranis/usbd_conf.h rename to radio/src/targets/Taranis/usbd_conf.h diff --git a/radio/src/targets/taranis/usbd_desc.c b/radio/src/targets/Taranis/usbd_desc.c similarity index 100% rename from radio/src/targets/taranis/usbd_desc.c rename to radio/src/targets/Taranis/usbd_desc.c diff --git a/radio/src/targets/Taranis/usbd_desc.h b/radio/src/targets/Taranis/usbd_desc.h new file mode 100644 index 000000000..537f69b14 --- /dev/null +++ b/radio/src/targets/Taranis/usbd_desc.h @@ -0,0 +1,121 @@ +/** + ****************************************************************************** + * @file usbd_desc.h + * @author MCD Application Team + * @version V1.1.0 + * @date 19-March-2012 + * @brief header file for the usbd_desc.c file + ****************************************************************************** + * @attention + * + *

© COPYRIGHT 2012 STMicroelectronics

+ * + * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.st.com/software_license_agreement_liberty_v2 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ + +#ifndef __USB_DESC_H +#define __USB_DESC_H + +/* Includes ------------------------------------------------------------------*/ +#include "usb_core.h" +#include "usbd_def.h" + +/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY + * @{ + */ + +/** @defgroup USB_DESC + * @brief general defines for the usb device library file + * @{ + */ + +/** @defgroup USB_DESC_Exported_Defines + * @{ + */ +#define USB_DEVICE_DESCRIPTOR_TYPE 0x01 +#define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02 +#define USB_STRING_DESCRIPTOR_TYPE 0x03 +#define USB_INTERFACE_DESCRIPTOR_TYPE 0x04 +#define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05 +#define USB_SIZ_DEVICE_DESC 18 +#define USB_SIZ_STRING_LANGID 4 + +/** + * @} + */ + + +/** @defgroup USBD_DESC_Exported_TypesDefinitions + * @{ + */ +/** + * @} + */ + + + +/** @defgroup USBD_DESC_Exported_Macros + * @{ + */ +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_Variables + * @{ + */ +extern const uint8_t USBD_DeviceDesc [USB_SIZ_DEVICE_DESC]; +extern uint8_t USBD_StrDesc[USB_MAX_STR_DESC_SIZ]; +extern const uint8_t USBD_OtherSpeedCfgDesc[USB_LEN_CFG_DESC]; +extern const uint8_t USBD_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC]; +extern const uint8_t USBD_LangIDDesc[USB_SIZ_STRING_LANGID]; +extern const USBD_DEVICE USR_desc; +/** + * @} + */ + +/** @defgroup USBD_DESC_Exported_FunctionsPrototype + * @{ + */ + + +uint8_t * USBD_USR_DeviceDescriptor( uint8_t speed , uint16_t *length); +uint8_t * USBD_USR_LangIDStrDescriptor( uint8_t speed , uint16_t *length); +uint8_t * USBD_USR_ManufacturerStrDescriptor ( uint8_t speed , uint16_t *length); +uint8_t * USBD_USR_ProductStrDescriptor ( uint8_t speed , uint16_t *length); +uint8_t * USBD_USR_SerialStrDescriptor( uint8_t speed , uint16_t *length); +uint8_t * USBD_USR_ConfigStrDescriptor( uint8_t speed , uint16_t *length); +uint8_t * USBD_USR_InterfaceStrDescriptor( uint8_t speed , uint16_t *length); + +#ifdef USB_SUPPORT_USER_STRING_DESC +uint8_t * USBD_USR_USRStringDesc (uint8_t speed, uint8_t idx , uint16_t *length); +#endif /* USB_SUPPORT_USER_STRING_DESC */ + +/** + * @} + */ + +#endif /* __USBD_DESC_H */ + +/** + * @} + */ + +/** +* @} +*/ +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/radio/src/targets/taranis/usbd_hid_joystick.c b/radio/src/targets/Taranis/usbd_hid_joystick.c similarity index 100% rename from radio/src/targets/taranis/usbd_hid_joystick.c rename to radio/src/targets/Taranis/usbd_hid_joystick.c diff --git a/radio/src/targets/taranis/usbd_storage_msd.cpp b/radio/src/targets/Taranis/usbd_storage_msd.cpp similarity index 100% rename from radio/src/targets/taranis/usbd_storage_msd.cpp rename to radio/src/targets/Taranis/usbd_storage_msd.cpp diff --git a/radio/src/targets/taranis/usbd_usr.cpp b/radio/src/targets/Taranis/usbd_usr.cpp similarity index 100% rename from radio/src/targets/taranis/usbd_usr.cpp rename to radio/src/targets/Taranis/usbd_usr.cpp diff --git a/radio/src/targets/simu/simpgmspace.cpp b/radio/src/targets/simu/simpgmspace.cpp index 6481b42c7..704953283 100644 --- a/radio/src/targets/simu/simpgmspace.cpp +++ b/radio/src/targets/simu/simpgmspace.cpp @@ -45,6 +45,7 @@ #if defined WIN32 || !defined __GNUC__ #include + #define mkdir(s, f) _mkdir(s) #endif #if defined(SIMU_DISKIO) @@ -64,7 +65,7 @@ int g_snapshot_idx = 0; #if defined(CPUSTM32) uint32_t Peri1_frequency, Peri2_frequency; -GPIO_TypeDef gpioa, gpiob, gpioc, gpiod, gpioe, gpiof, gpiog; +GPIO_TypeDef gpioa, gpiob, gpioc, gpiod, gpioe, gpiof, gpiog, gpioh, gpioi, gpioj; TIM_TypeDef tim1, tim2, tim3, tim4, tim5, tim6, tim7, tim8, tim9, tim10; RCC_TypeDef rcc; DMA_Stream_TypeDef dma2_stream2, dma2_stream6; @@ -152,7 +153,13 @@ void simuSetKey(uint8_t key, bool state) switch (key) { KEY_CASE(KEY_MENU, KEYS_GPIO_REG_MENU, KEYS_GPIO_PIN_MENU) KEY_CASE(KEY_EXIT, KEYS_GPIO_REG_EXIT, KEYS_GPIO_PIN_EXIT) -#if defined(PCBTARANIS) +#if defined(PCBHORUS) + KEY_CASE(KEY_ENTER, KEYS_GPIO_REG_ENTER, KEYS_GPIO_PIN_ENTER) + KEY_CASE(KEY_RIGHT, KEYS_GPIO_REG_RIGHT, KEYS_GPIO_PIN_RIGHT) + KEY_CASE(KEY_LEFT, KEYS_GPIO_REG_LEFT, KEYS_GPIO_PIN_LEFT) + KEY_CASE(KEY_UP, KEYS_GPIO_REG_UP, KEYS_GPIO_PIN_UP) + KEY_CASE(KEY_DOWN, KEYS_GPIO_REG_DOWN, KEYS_GPIO_PIN_DOWN) +#elif defined(PCBTARANIS) || defined(PCBFLAMENCO) KEY_CASE(KEY_ENTER, KEYS_GPIO_REG_ENTER, KEYS_GPIO_PIN_ENTER) KEY_CASE(KEY_PAGE, KEYS_GPIO_REG_PAGE, KEYS_GPIO_PIN_PAGE) KEY_CASE(KEY_MINUS, KEYS_GPIO_REG_MINUS, KEYS_GPIO_PIN_MINUS) @@ -186,6 +193,12 @@ void simuSetTrim(uint8_t trim, bool state) TRIM_CASE(5, TRIMS_GPIO_REG_RVU, TRIMS_GPIO_PIN_RVU) TRIM_CASE(6, TRIMS_GPIO_REG_RHL, TRIMS_GPIO_PIN_RHL) TRIM_CASE(7, TRIMS_GPIO_REG_RHR, TRIMS_GPIO_PIN_RHR) +#if defined(HORUS) + TRIM_CASE(8, TRIMS_GPIO_REG_LSU, TRIMS_GPIO_PIN_LSU) + TRIM_CASE(9, TRIMS_GPIO_REG_LSD, TRIMS_GPIO_PIN_RVU) + TRIM_CASE(10, TRIMS_GPIO_REG_RSU, TRIMS_GPIO_PIN_RHL) + TRIM_CASE(11, TRIMS_GPIO_REG_RSD, TRIMS_GPIO_PIN_RHR) +#endif } } @@ -194,7 +207,14 @@ void simuSetSwitch(uint8_t swtch, int8_t state) { // TRACE("simuSetSwitch(%d, %d)", swtch, state); switch (swtch) { -#if defined(PCBTARANIS) && defined(REV9E) +#if defined(PCBFLAMENCO) + // SWITCH_3_CASE(0, SWITCHES_GPIO_REG_A_L, SWITCHES_GPIO_REG_A_H, SWITCHES_GPIO_PIN_A_L, SWITCHES_GPIO_PIN_A_H) + // SWITCH_CASE(1, SWITCHES_GPIO_REG_B, SWITCHES_GPIO_PIN_B) + // SWITCH_3_CASE(2, SWITCHES_GPIO_REG_C_L, SWITCHES_GPIO_REG_C_H, SWITCHES_GPIO_PIN_C_L, SWITCHES_GPIO_PIN_C_H) + // SWITCH_3_CASE(3, SWITCHES_GPIO_REG_D_L, SWITCHES_GPIO_REG_D_H, SWITCHES_GPIO_PIN_D_L, SWITCHES_GPIO_PIN_D_H) + // SWITCH_CASE(4, SWITCHES_GPIO_REG_E, SWITCHES_GPIO_PIN_E) + // SWITCH_3_CASE(5, SWITCHES_GPIO_REG_F_H, SWITCHES_GPIO_REG_F_L, SWITCHES_GPIO_PIN_F_H, SWITCHES_GPIO_PIN_F_L) +#elif defined(PCBTARANIS) && defined(REV9E) SWITCH_3_CASE(0, SWITCHES_GPIO_REG_A_L, SWITCHES_GPIO_REG_A_H, SWITCHES_GPIO_PIN_A_L, SWITCHES_GPIO_PIN_A_H) SWITCH_3_CASE(1, SWITCHES_GPIO_REG_B_L, SWITCHES_GPIO_REG_B_H, SWITCHES_GPIO_PIN_B_L, SWITCHES_GPIO_PIN_B_H) SWITCH_3_CASE(2, SWITCHES_GPIO_REG_C_L, SWITCHES_GPIO_REG_C_H, SWITCHES_GPIO_PIN_C_L, SWITCHES_GPIO_PIN_C_H) @@ -213,7 +233,7 @@ void simuSetSwitch(uint8_t swtch, int8_t state) SWITCH_3_CASE(15, SWITCHES_GPIO_REG_P_L, SWITCHES_GPIO_REG_P_H, SWITCHES_GPIO_PIN_P_L, SWITCHES_GPIO_PIN_P_H) SWITCH_3_CASE(16, SWITCHES_GPIO_REG_Q_L, SWITCHES_GPIO_REG_Q_H, SWITCHES_GPIO_PIN_Q_L, SWITCHES_GPIO_PIN_Q_H) SWITCH_3_CASE(17, SWITCHES_GPIO_REG_R_L, SWITCHES_GPIO_REG_R_H, SWITCHES_GPIO_PIN_R_L, SWITCHES_GPIO_PIN_R_H) -#elif defined(PCBTARANIS) +#elif defined(PCBTARANIS) || defined(PCBHORUS) SWITCH_3_CASE(0, SWITCHES_GPIO_REG_A_L, SWITCHES_GPIO_REG_A_H, SWITCHES_GPIO_PIN_A_L, SWITCHES_GPIO_PIN_A_H) SWITCH_3_CASE(1, SWITCHES_GPIO_REG_B_L, SWITCHES_GPIO_REG_B_H, SWITCHES_GPIO_PIN_B_L, SWITCHES_GPIO_PIN_B_H) SWITCH_3_CASE(2, SWITCHES_GPIO_REG_C_L, SWITCHES_GPIO_REG_C_H, SWITCHES_GPIO_PIN_C_L, SWITCHES_GPIO_PIN_C_H) @@ -271,7 +291,7 @@ uint16_t getTmr16KHz() return get_tmr10ms() * 160; } -#if !defined(PCBTARANIS) +#if !defined(PCBTARANIS) && !defined(PCBHORUS) bool eeprom_thread_running = true; void *eeprom_write_function(void *) { @@ -329,6 +349,10 @@ void *main_thread(void *) try { #endif +#if defined(PCBHORUS) + lcdColorsInit(); +#endif + #if defined(CPUARM) stackPaint(); #endif @@ -339,7 +363,7 @@ void *main_thread(void *) g_menuStack[0] = menuMainView; g_menuStack[1] = menuModelSelect; - eeReadAll(); // load general setup and selected model + storageReadAll(); // load general setup and selected model #if defined(SIMU_DISKIO) f_mount(&g_FATFS_Obj, "", 1); @@ -356,14 +380,13 @@ void *main_thread(void *) if (main_thread_running == 1) { opentxStart(); } - else { -#if defined(CPUARM) - eeLoadModel(g_eeGeneral.currModel); -#endif - } s_current_protocol[0] = 0; +#if defined(PCBFLAMENCO) + menuEntryTime = get_tmr10ms() - 200; +#endif + while (main_thread_running) { #if defined(CPUARM) doMixerCalculations(); @@ -603,7 +626,7 @@ void StartEepromThread(const char *filename) sem_init(eeprom_write_sem, 0, 0); #endif -#if !defined(PCBTARANIS) +#if !defined(PCBTARANIS) && !defined(PCBHORUS) eeprom_thread_running = true; assert(!pthread_create(&eeprom_thread_pid, NULL, &eeprom_write_function, NULL)); #endif @@ -611,7 +634,7 @@ void StartEepromThread(const char *filename) void StopEepromThread() { -#if !defined(PCBTARANIS) +#if !defined(PCBTARANIS) && !defined(PCBFLAMENCO) && !defined(PCBHORUS) eeprom_thread_running = false; sem_post(eeprom_write_sem); pthread_join(eeprom_thread_pid, NULL); @@ -640,7 +663,7 @@ void eepromReadBlock (uint8_t * pointer_ram, uint32_t pointer_eeprom, uint32_t s } } -#if defined(PCBTARANIS) +#if defined(PCBTARANIS) || defined(PCBFLAMENCO) void eepromWriteBlock(uint8_t * pointer_ram, uint32_t pointer_eeprom, uint32_t size) { assert(size); @@ -694,7 +717,7 @@ namespace simu { FATFS g_FATFS_Obj; #endif -char *convertSimuPath(const char *path) +char * convertSimuPath(const char *path) { static char result[1024]; if (path[0] == '/' && strcmp(simuSdDirectory, "/") != 0) @@ -933,35 +956,50 @@ FRESULT f_readdir (DIR * rep, FILINFO * fil) return FR_OK; } -FRESULT f_mkfs (const TCHAR *path, BYTE, UINT) +FRESULT f_mkfs (const TCHAR * path, BYTE, UINT) { TRACE("Format SD..."); return FR_OK; } -FRESULT f_mkdir (const TCHAR*) +FRESULT f_mkdir (const TCHAR * name) { + char * path = convertSimuPath(name); + if (mkdir(path, 0777)) { + TRACE("mkdir(%s) = error %d (%s)", path, errno, strerror(errno)); + return FR_INVALID_NAME; + } + else { + TRACE("mkdir(%s) = OK", path); + return FR_OK; + } return FR_OK; } -FRESULT f_unlink (const TCHAR* name) +FRESULT f_unlink (const TCHAR * name) { - char *path = convertSimuPath(name); + char * path = convertSimuPath(name); if (unlink(path)) { TRACE("f_unlink(%s) = error %d (%s)", path, errno, strerror(errno)); return FR_INVALID_NAME; } - TRACE("f_unlink(%s) = OK", path); - return FR_OK; + else { + TRACE("f_unlink(%s) = OK", path); + return FR_OK; + } } FRESULT f_rename(const TCHAR *oldname, const TCHAR *newname) { - if (rename(oldname, newname) < 0) { - TRACE("f_rename(%s, %s) = error %d (%s)", oldname, newname, errno, strerror(errno)); + char old[1024]; + strcpy(old, convertSimuPath(oldname)); + char * path = convertSimuPath(newname); + + if (rename(old, path) < 0) { + TRACE("f_rename(%s, %s) = error %d (%s)", old, path, errno, strerror(errno)); return FR_INVALID_NAME; } - TRACE("f_rename(%s, %s) = OK", oldname, newname); + TRACE("f_rename(%s, %s) = OK", old, path); return FR_OK; } @@ -1208,14 +1246,14 @@ uint32_t sdGetSpeed() #endif // #if defined(SIMU_DISKIO) +bool simuLcdRefresh = true; +display_t simuLcdBuf[DISPLAY_BUFFER_SIZE]; - -bool lcd_refresh = true; -display_t lcd_buf[DISPLAY_BUF_SIZE]; - +#if !defined(PCBFLAMENCO) && !defined(PCBHORUS) void lcdSetRefVolt(uint8_t val) { } +#endif void adcPrepareBandgap() { @@ -1229,11 +1267,26 @@ void lcdOff() void lcdRefresh() { - memcpy(lcd_buf, displayBuf, sizeof(lcd_buf)); - lcd_refresh = true; +#if defined(PCBFLAMENCO) + TW8823_SendScreen(); +#endif + + memcpy(simuLcdBuf, displayBuf, sizeof(simuLcdBuf)); + simuLcdRefresh = true; } -#if defined(PCBTARANIS) +display_t simuLcdBackupBuf[DISPLAY_BUFFER_SIZE]; +void lcdStoreBackupBuffer() +{ + memcpy(simuLcdBackupBuf, displayBuf, sizeof(simuLcdBackupBuf)); +} + +void lcdRestoreBackupBuffer() +{ + memcpy(displayBuf, simuLcdBackupBuf, sizeof(displayBuf)); +} + +#if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS) void pwrInit() { } void pwrOff() { } #if defined(REV9E) @@ -1290,3 +1343,8 @@ void turnBacklightOff(void) #endif // #if defined(PCBTARANIS) +#if defined(PCBFLAMENCO) +void i2cWriteTW8823(unsigned char, unsigned char) { } +uint8_t i2cReadBQ24195(uint8_t) { return 0; } +void i2cWriteBQ24195(uint8_t, uint8_t) { } +#endif diff --git a/radio/src/targets/simu/simpgmspace.h b/radio/src/targets/simu/simpgmspace.h index 0b7523494..936ff29cd 100644 --- a/radio/src/targets/simu/simpgmspace.h +++ b/radio/src/targets/simu/simpgmspace.h @@ -101,7 +101,7 @@ typedef const int16_t pm_int16_t; typedef const int8_t pm_int8_t; #if defined(CPUSTM32) -extern GPIO_TypeDef gpioa, gpiob, gpioc, gpiod, gpioe, gpiof, gpiog; +extern GPIO_TypeDef gpioa, gpiob, gpioc, gpiod, gpioe, gpiof, gpiog, gpioh, gpioi, gpioj; extern TIM_TypeDef tim1, tim2, tim3, tim4, tim5, tim6, tim7, tim8, tim9, tim10; extern USART_TypeDef Usart0, Usart1, Usart2, Usart3, Usart4; extern RCC_TypeDef rcc; @@ -114,6 +114,9 @@ extern DMA_TypeDef dma2; #undef GPIOE #undef GPIOF #undef GPIOG +#undef GPIOH +#undef GPIOI +#undef GPIOJ #define GPIOA (&gpioa) #define GPIOB (&gpiob) #define GPIOC (&gpioc) @@ -121,6 +124,9 @@ extern DMA_TypeDef dma2; #define GPIOE (&gpioe) #define GPIOF (&gpiof) #define GPIOG (&gpiog) +#define GPIOH (&gpioh) +#define GPIOI (&gpioi) +#define GPIOJ (&gpioj) #undef TIM1 #undef TIM2 #undef TIM3 @@ -392,23 +398,24 @@ extern OS_MutexID audioMutex; #define CoInitOS(...) #define CoStartOS(...) -#define CoCreateTask(...) (0) -#define CoCreateMutex(...) PTHREAD_MUTEX_INITIALIZER +#define CoCreateTask(...) 0 +#define CoCreateTaskEx(...) 0 +#define CoCreateMutex(...) PTHREAD_MUTEX_INITIALIZER #define CoSetFlag(...) #define CoClearFlag(...) #define CoSetTmrCnt(...) #define CoEnterISR(...) #define CoExitISR(...) #define CoStartTmr(...) -#define CoWaitForSingleFlag(...) 0 -#define CoEnterMutexSection(m) pthread_mutex_lock(&(m)) -#define CoLeaveMutexSection(m) pthread_mutex_unlock(&(m)) +#define CoWaitForSingleFlag(...) 0 +#define CoEnterMutexSection(m) pthread_mutex_lock(&(m)) +#define CoLeaveMutexSection(m) pthread_mutex_unlock(&(m)) #define CoTickDelay(...) -#define CoCreateFlag(...) 0 -#define CoGetOSTime(...) 0 +#define CoCreateFlag(...) 0 +#define CoGetOSTime(...) 0 #define UART_Stop(...) #define UART3_Stop(...) -#define USART_GetITStatus(...) 0 +#define USART_GetITStatus(...) 0 #if defined(CPUSTM32) inline void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct) { } diff --git a/radio/src/tasks_arm.cpp b/radio/src/tasks_arm.cpp index 7b990e387..640dca234 100644 --- a/radio/src/tasks_arm.cpp +++ b/radio/src/tasks_arm.cpp @@ -52,7 +52,7 @@ OS_TID menusTaskId; TaskStack _ALIGNED(8) menusStack; OS_TID mixerTaskId; -TaskStack mixerStack; +TaskStack mixerStack; OS_TID audioTaskId; TaskStack audioStack; @@ -97,6 +97,9 @@ uint16_t getStackAvailable(void * address, uint16_t size) i++; } return i*4; +#if defined(CLI) + cliStackPaint(); +#endif } template @@ -189,15 +192,16 @@ void menusTask(void * pdata) } #if defined(PCBTARANIS) && defined(REV9E) - topLcdOff(); + toplcdOff(); #endif BACKLIGHT_OFF(); -#if defined(PCBTARANIS) +#if defined(COLORLCD) +#elif defined(PCBTARANIS) displaySleepBitmap(); #else - lcd_clear(); + lcdClear(); displayPopup(STR_SHUTDOWN); #endif @@ -231,4 +235,4 @@ void tasksStart() CoStartOS(); } -#endif // #if !defined(SIMU) +#endif // !defined(SIMU) diff --git a/radio/src/telemetry/ardupilot.cpp b/radio/src/telemetry/ardupilot.cpp index 256553b75..dc21e1c80 100644 --- a/radio/src/telemetry/ardupilot.cpp +++ b/radio/src/telemetry/ardupilot.cpp @@ -514,10 +514,10 @@ void menuTelemetryArduPilot1(uint8_t event) title ('1'); lcd_puts (5*FW, 1*FH, PSTR(" Latitude")); // line 1 column 5 // first buffer into line 2 column 2 - lcd_putsAtt (2*FW, 2*FH, VALSTR(0), APSIZE); + lcdDrawText (2*FW, 2*FH, VALSTR(0), APSIZE); lcd_puts (5*FW, 4*FH, PSTR(" Longitude")); // line 4 column 5 // second buffer into line 5 column 2 - lcd_putsAtt (1*FW, 5*FH, VALSTR(1), APSIZE); + lcdDrawText (1*FW, 5*FH, VALSTR(1), APSIZE); } void menuTelemetryArduPilot2(uint8_t event) @@ -539,9 +539,9 @@ void menuTelemetryArduPilot2(uint8_t event) initval (1, PACK_POS, CRT); title ('2'); lcd_puts (1*FW, 1*FH, PSTR(" Ground speed")); - lcd_putsAtt (2*FW, 2*FH, VALSTR(0), APSIZE); + lcdDrawText (2*FW, 2*FH, VALSTR(0), APSIZE); lcd_puts (1*FW, 4*FH, PSTR(" Climb rate") ); - lcd_putsAtt (2*FW, 5*FH, VALSTR(1), APSIZE); + lcdDrawText (2*FW, 5*FH, VALSTR(1), APSIZE); } void menuTelemetryArduPilot3(uint8_t event) @@ -563,9 +563,9 @@ void menuTelemetryArduPilot3(uint8_t event) initval (1, PACK_POS, ALH); title ('3'); lcd_puts (1*FW, 1*FH, PSTR(" Altitude")); - lcd_putsAtt (2*FW, 2*FH, VALSTR(0), APSIZE); + lcdDrawText (2*FW, 2*FH, VALSTR(0), APSIZE); lcd_puts (1*FW, 4*FH, PSTR(" Altitude Hold") ); - lcd_putsAtt (2*FW, 5*FH, VALSTR(1), APSIZE); + lcdDrawText (2*FW, 5*FH, VALSTR(1), APSIZE); } void menuTelemetryArduPilot4(uint8_t event) @@ -587,9 +587,9 @@ void menuTelemetryArduPilot4(uint8_t event) initval (1, PACK_POS, BER); title ('4'); lcd_puts (1*FW, 1*FH, PSTR(" Course")); - lcd_putsAtt (2*FW, 2*FH, VALSTR(0), APSIZE); + lcdDrawText (2*FW, 2*FH, VALSTR(0), APSIZE); lcd_puts (1*FW, 4*FH, PSTR(" Bearing")); - lcd_putsAtt (2*FW, 5*FH, VALSTR(1), APSIZE); + lcdDrawText (2*FW, 5*FH, VALSTR(1), APSIZE); } void menuTelemetryArduPilot5(uint8_t event) @@ -613,9 +613,9 @@ void menuTelemetryArduPilot5(uint8_t event) initval (1, PACK_POS, DST); title ('5'); lcd_puts (1*FW, 1*FH, PSTR(" Way Point # ")); - lcd_putsAtt (2*FW, 2*FH, VALSTR(0), APSIZE); + lcdDrawText (2*FW, 2*FH, VALSTR(0), APSIZE); lcd_puts (1*FW, 4*FH, PSTR(" Distance ")); - lcd_putsAtt (2*FW, 5*FH, VALSTR(1), APSIZE); + lcdDrawText (2*FW, 5*FH, VALSTR(1), APSIZE); } void menuTelemetryArduPilot6(uint8_t event) @@ -639,9 +639,9 @@ void menuTelemetryArduPilot6(uint8_t event) initval (1, PACK_ATT, THH); title ('6'); lcd_puts (1*FW, 1*FH, PSTR(" Air Speed ")); - lcd_putsAtt (2*FW, 2*FH, VALSTR(0), APSIZE); + lcdDrawText (2*FW, 2*FH, VALSTR(0), APSIZE); lcd_puts (1*FW, 4*FH, PSTR(" Climb Rate ")); - lcd_putsAtt (2*FW, 5*FH, VALSTR(1), APSIZE); + lcdDrawText (2*FW, 5*FH, VALSTR(1), APSIZE); } void menuTelemetryArduPilot7(uint8_t event) @@ -665,9 +665,9 @@ void menuTelemetryArduPilot7(uint8_t event) initval (1, PACK_ATT, PCH); title ('7'); lcd_puts (1*FW, 1*FH, PSTR(" Roll Angle")); - lcd_putsAtt (2*FW, 2*FH, VALSTR(0), APSIZE); + lcdDrawText (2*FW, 2*FH, VALSTR(0), APSIZE); lcd_puts (1*FW, 4*FH, PSTR(" Pitch Angle")); - lcd_putsAtt (2*FW, 5*FH, VALSTR(1), APSIZE); + lcdDrawText (2*FW, 5*FH, VALSTR(1), APSIZE); } void menuTelemetryArduPilot8(uint8_t event) @@ -691,15 +691,15 @@ void menuTelemetryArduPilot8(uint8_t event) initval (1, PACK_WPC, WPC); title ('8'); lcd_puts (1*FW, 1*FH, PSTR(" ArduPilot Mode")); - lcd_putsAtt (2*FW, 2*FH, VALSTR(0), APSIZE); + lcdDrawText (2*FW, 2*FH, VALSTR(0), APSIZE); lcd_puts (1*FW, 4*FH, PSTR(" RTL Distance")); - lcd_putsAtt (2*FW, 5*FH, VALSTR(1), APSIZE); + lcdDrawText (2*FW, 5*FH, VALSTR(1), APSIZE); } void title(char x) { - lcd_putsAtt (0, 0, PSTR(" ARDU PILOT Mega ?/8 "), INVERS); - lcd_putcAtt(17*FW, 0*FH, x, INVERS); + lcdDrawText (0, 0, PSTR(" ARDU PILOT Mega ?/8 "), INVERS); + lcdDrawChar(17*FW, 0*FH, x, INVERS); } void initval(uint8_t num, uint8_t pack, uint8_t val) diff --git a/radio/src/telemetry/frsky.cpp b/radio/src/telemetry/frsky.cpp index 9dffd4b23..daa122f72 100644 --- a/radio/src/telemetry/frsky.cpp +++ b/radio/src/telemetry/frsky.cpp @@ -47,7 +47,7 @@ uint8_t link_counter = 0; #define FRSKY_RX_PACKET_SIZE 19 uint8_t frskyRxBuffer[FRSKY_RX_PACKET_SIZE]; // Receive buffer. 9 bytes (full packet), worst case 18 bytes with byte-stuffing (+1) -#if !defined(CPUARM) +#if !defined(CPUARM) && !defined(PCBFLAMENCO) uint8_t frskyTxBuffer[FRSKY_TX_PACKET_SIZE]; #endif @@ -59,7 +59,7 @@ uint8_t frskyTxBufferCount = 0; uint8_t telemetryState = TELEMETRY_INIT; #endif -#if defined(PCBTARANIS) +#if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS) Fifo<512> telemetryFifo; // TODO should be in the driver #endif @@ -323,7 +323,7 @@ void telemetryWakeup() } #endif -#if !defined(CPUARM) +#if !defined(CPUARM) && !defined(PCBFLAMENCO) if (IS_FRSKY_D_PROTOCOL()) { // Attempt to transmit any waiting Fr-Sky alarm set packets every 50ms (subject to packet buffer availability) static uint8_t frskyTxDelay = 5; diff --git a/radio/src/telemetry/frsky.h b/radio/src/telemetry/frsky.h index ebb9b14f7..07c9a5c2b 100644 --- a/radio/src/telemetry/frsky.h +++ b/radio/src/telemetry/frsky.h @@ -491,7 +491,7 @@ enum FrSkyDataState { #endif }; -#if defined(CPUARM) +#if defined(CPUARM) || defined(PCBFLAMENCO) #define frskySendAlarms() #else #define SEND_RSSI_ALARMS 6 diff --git a/radio/src/telemetry/frsky_d_arm.cpp b/radio/src/telemetry/frsky_d_arm.cpp index eadcae3fa..664a8cec1 100644 --- a/radio/src/telemetry/frsky_d_arm.cpp +++ b/radio/src/telemetry/frsky_d_arm.cpp @@ -300,5 +300,5 @@ void frskyDSetDefault(int index, uint16_t id) telemetrySensor.init(id); } - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } diff --git a/radio/src/telemetry/frsky_sport.cpp b/radio/src/telemetry/frsky_sport.cpp index 1394d9081..6be1a96c7 100644 --- a/radio/src/telemetry/frsky_sport.cpp +++ b/radio/src/telemetry/frsky_sport.cpp @@ -294,7 +294,7 @@ void frskySportSetDefault(int index, uint16_t id, uint8_t instance) telemetrySensor.init(id); } - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } #if defined(PCBTARANIS) diff --git a/radio/src/telemetry/jeti.cpp b/radio/src/telemetry/jeti.cpp index 4a56eb644..11c235833 100644 --- a/radio/src/telemetry/jeti.cpp +++ b/radio/src/telemetry/jeti.cpp @@ -211,8 +211,8 @@ void menuTelemetryJeti(uint8_t event) lcdDrawTelemetryTopBar(); for (uint8_t i=0; i<16; i++) { - lcd_putcAtt((i+2)*FW, 3*FH, jetiRxBuffer[i], BSS); - lcd_putcAtt((i+2)*FW, 4*FH, jetiRxBuffer[i+16], BSS); + lcdDrawChar((i+2)*FW, 3*FH, jetiRxBuffer[i], BSS); + lcdDrawChar((i+2)*FW, 4*FH, jetiRxBuffer[i+16], BSS); } if (event == EVT_KEY_FIRST(KEY_EXIT)) { diff --git a/radio/src/telemetry/mavlink.cpp b/radio/src/telemetry/mavlink.cpp index 094c94ec3..c5c04e16e 100644 --- a/radio/src/telemetry/mavlink.cpp +++ b/radio/src/telemetry/mavlink.cpp @@ -341,12 +341,12 @@ void putsMavlinParams(uint8_t x, uint8_t y, uint8_t idx, uint8_t att) { const pm_char * s = getParamId(idx); char c; while ((c = pgm_read_byte(s++))) { - lcd_putcAtt(x, y, (c == '_' ? ' ' : c), 0); + lcdDrawChar(x, y, (c == '_' ? ' ' : c), 0); x += FW; } if (idx < NB_PID_PARAMS) { x = 11 * FW; - lcd_putcAtt(x, y, "PI"[idx & 0x01], att); + lcdDrawChar(x, y, "PI"[idx & 0x01], att); } } } diff --git a/radio/src/telemetry/nmea.cpp b/radio/src/telemetry/nmea.cpp index 3630602e5..64b3c39f9 100644 --- a/radio/src/telemetry/nmea.cpp +++ b/radio/src/telemetry/nmea.cpp @@ -463,15 +463,15 @@ void menuTelemetryNMEA1(uint8_t event) lcd_puts ( 2*FW, 1*FH, PSTR("UTC-Time Sat")); if (rbuf[0][0]) { // show always if data have been received - lcd_putcAtt ( 19*FW, 1*FH, sbuf[2], 0); // satellites in view - lcd_putsnAtt ( 2*FW, 2*FH, &rbuf[0][0], 2, APSIZE); // hours - lcd_putcAtt ( 6*FW, 2*FH, ':', DBLSIZE); // ":" - lcd_putsnAtt ( 8*FW, 2*FH, &rbuf[0][2], 2, APSIZE); // minutes - lcd_putcAtt ( 12*FW, 2*FH, ':', DBLSIZE); // ":" - lcd_putsnAtt ( 14*FW, 2*FH, &rbuf[0][4], 2, APSIZE); // seconds + lcdDrawChar ( 19*FW, 1*FH, sbuf[2], 0); // satellites in view + lcdDrawTextWithLen ( 2*FW, 2*FH, &rbuf[0][0], 2, APSIZE); // hours + lcdDrawChar ( 6*FW, 2*FH, ':', DBLSIZE); // ":" + lcdDrawTextWithLen ( 8*FW, 2*FH, &rbuf[0][2], 2, APSIZE); // minutes + lcdDrawChar ( 12*FW, 2*FH, ':', DBLSIZE); // ":" + lcdDrawTextWithLen ( 14*FW, 2*FH, &rbuf[0][4], 2, APSIZE); // seconds } else - lcd_putsAtt ( 2*FW, 2*FH, val_unknown, APSIZE); // "?" + lcdDrawText ( 2*FW, 2*FH, val_unknown, APSIZE); // "?" if ((show_timer == 1) && rbuf[0][0]) { // show the Timer when data have been received @@ -483,14 +483,14 @@ void menuTelemetryNMEA1(uint8_t event) lcd_puts ( 2*FW, 4*FH, PSTR("Date")); // show the UTC Date if (rbuf[1][0]) { - lcd_putsnAtt( 2*FW, 5*FH, &rbuf[1][0], 2, APSIZE); // year - lcd_putcAtt ( 6*FW, 5*FH, '/', DBLSIZE); // "/" - lcd_putsnAtt( 8*FW, 5*FH, &rbuf[1][2], 2, APSIZE); // month - lcd_putcAtt (12*FW, 5*FH, '/', DBLSIZE); // "/" - lcd_putsnAtt(14*FW, 5*FH, &rbuf[1][4], 2, APSIZE); // day + lcdDrawTextWithLen( 2*FW, 5*FH, &rbuf[1][0], 2, APSIZE); // year + lcdDrawChar ( 6*FW, 5*FH, '/', DBLSIZE); // "/" + lcdDrawTextWithLen( 8*FW, 5*FH, &rbuf[1][2], 2, APSIZE); // month + lcdDrawChar (12*FW, 5*FH, '/', DBLSIZE); // "/" + lcdDrawTextWithLen(14*FW, 5*FH, &rbuf[1][4], 2, APSIZE); // day } else - lcd_putsAtt ( 2*FW, 5*FH, val_unknown, APSIZE); // "?" + lcdDrawText ( 2*FW, 5*FH, val_unknown, APSIZE); // "?" } } @@ -630,7 +630,7 @@ void menuTelemetryNMEA2(uint8_t event) } if (rbuf[0][0]) { - lcd_putcAtt ( 13*FW, 1*FH, sbuf[2], 0); // satellites in view + lcdDrawChar ( 13*FW, 1*FH, sbuf[2], 0); // satellites in view if (sbuf[1]>0x30) { // & GGA has FIX > 0 @@ -643,16 +643,16 @@ void menuTelemetryNMEA2(uint8_t event) lcd_outdezNAtt( 20*FW, 2*FH, max_alt, PREC1, 6); // display small characters - lcd_putcAtt ( 11*FW, 3*FH, sbuf[0], 0); // dimension [m] + lcdDrawChar ( 11*FW, 3*FH, sbuf[0], 0); // dimension [m] lcd_outdezNAtt( 10*FW, 5*FH, lift_alt, DBLSIZE|PREC1, 6); // lift - lcd_putcAtt ( 11*FW, 6*FH, sbuf[0], 0); // dimension [m/S] + lcdDrawChar ( 11*FW, 6*FH, sbuf[0], 0); // dimension [m/S] lcd_puts ( 12*FW, 6*FH, PSTR("/S") ); } } else { - lcd_putsAtt ( 2*FW, 2*FH, val_unknown, APSIZE); - lcd_putsAtt ( 2*FW, 5*FH, val_unknown, APSIZE); + lcdDrawText ( 2*FW, 2*FH, val_unknown, APSIZE); + lcdDrawText ( 2*FW, 5*FH, val_unknown, APSIZE); } } @@ -694,15 +694,15 @@ void menuTelemetryNMEA3(uint8_t event) } i++; } - lcd_putsAtt ( 2*FW, 2*FH, VALSTR(0), APSIZE); // speed over ground + lcdDrawText ( 2*FW, 2*FH, VALSTR(0), APSIZE); // speed over ground } else - lcd_putsAtt ( 2*FW, 2*FH, val_unknown, APSIZE); + lcdDrawText ( 2*FW, 2*FH, val_unknown, APSIZE); - lcd_putcAtt ( 19*FW, 1*FH, sbuf[2], 0); // satellites in view + lcdDrawChar ( 19*FW, 1*FH, sbuf[2], 0); // satellites in view lcd_puts ( 1*FW, 4*FH, PSTR("Course over ground") ); - lcd_putsAtt ( 2*FW, 5*FH, VALSTR(1), APSIZE); // course over ground + lcdDrawText ( 2*FW, 5*FH, VALSTR(1), APSIZE); // course over ground } @@ -739,32 +739,32 @@ void menuTelemetryNMEA4(uint8_t event) // first buffer into line 2 column 2 if (rbuf[0][0]) { - lcd_putcAtt ( 13*FW, 1*FH, sbuf[0], 0); // N or S - lcd_putcAtt ( 19*FW, 1*FH, sbuf[2], 0); // satellites in view - lcd_putsnAtt ( 1*FW, 2*FH, rbuf[0], 2, APSIZE); - lcd_putcAtt ( 5*FW, 2*FH, '@',0); - lcd_putsAtt ( 6*FW, 2*FH, &rbuf[0][2], APSIZE); // minutes with small decimal point + lcdDrawChar ( 13*FW, 1*FH, sbuf[0], 0); // N or S + lcdDrawChar ( 19*FW, 1*FH, sbuf[2], 0); // satellites in view + lcdDrawTextWithLen ( 1*FW, 2*FH, rbuf[0], 2, APSIZE); + lcdDrawChar ( 5*FW, 2*FH, '@',0); + lcdDrawText ( 6*FW, 2*FH, &rbuf[0][2], APSIZE); // minutes with small decimal point } else - lcd_putsAtt ( 2*FW, 2*FH, val_unknown, APSIZE); + lcdDrawText ( 2*FW, 2*FH, val_unknown, APSIZE); lcd_puts ( 3*FW, 4*FH, PSTR("Longitude")); // line 4 column 5 // second buffer into line 5 column 2 if (rbuf[0][0]) { - lcd_putcAtt ( 13*FW, 4*FH, sbuf[1], 0); // E or W - lcd_putsnAtt ( 0*FW, 5*FH, rbuf[1], 3, APSIZE); - lcd_putcAtt ( 6*FW, 5*FH, '@',0); - lcd_putsAtt ( 7*FW, 5*FH, &rbuf[1][3], APSIZE); // minutes with small decimal point + lcdDrawChar ( 13*FW, 4*FH, sbuf[1], 0); // E or W + lcdDrawTextWithLen ( 0*FW, 5*FH, rbuf[1], 3, APSIZE); + lcdDrawChar ( 6*FW, 5*FH, '@',0); + lcdDrawText ( 7*FW, 5*FH, &rbuf[1][3], APSIZE); // minutes with small decimal point } else - lcd_putsAtt ( 2*FW, 5*FH, val_unknown, APSIZE); + lcdDrawText ( 2*FW, 5*FH, val_unknown, APSIZE); } void title(char x) { - lcd_putsAtt (0*FW, 0*FH, PSTR(" GPS NMEA data ?/4 "), INVERS); - lcd_putcAtt(16*FW, 0*FH, x, INVERS); + lcdDrawText (0*FW, 0*FH, PSTR(" GPS NMEA data ?/4 "), INVERS); + lcdDrawChar(16*FW, 0*FH, x, INVERS); } void initval(uint8_t num, uint8_t pack, uint8_t val) diff --git a/radio/src/telemetry/telemetry.cpp b/radio/src/telemetry/telemetry.cpp index b7c51318a..eeb9513a3 100644 --- a/radio/src/telemetry/telemetry.cpp +++ b/radio/src/telemetry/telemetry.cpp @@ -455,7 +455,7 @@ void delTelemetryIndex(uint8_t index) { memclear(&g_model.telemetrySensors[index], sizeof(TelemetrySensor)); telemetryItems[index].clear(); - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } int availableTelemetryIndex() diff --git a/radio/src/templates.cpp b/radio/src/templates.cpp index 2bb663e03..12a152697 100644 --- a/radio/src/templates.cpp +++ b/radio/src/templates.cpp @@ -270,5 +270,5 @@ void applyTemplate(uint8_t idx) } - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } diff --git a/radio/src/tests/eeprom.cpp b/radio/src/tests/eeprom.cpp index 0a032ae25..1ad3bddbe 100644 --- a/radio/src/tests/eeprom.cpp +++ b/radio/src/tests/eeprom.cpp @@ -37,14 +37,14 @@ #include "gtests.h" #if !defined(PCBSKY9X) -TEST(EEPROM, 100_random_writes) +TEST(Eeprom, 100_random_writes) { eepromFile = NULL; // in memory RlcFile f; uint8_t buf[1000]; uint8_t buf2[1000]; - eepromFormat(); + storageFormat(); for(int i=0; i<100; i++) { int size = rand()%800; @@ -60,13 +60,13 @@ TEST(EEPROM, 100_random_writes) } } -TEST(EEPROM, test2) +TEST(Eeprom, test2) { eepromFile = NULL; // in memory RlcFile f; uint8_t buf[1000]; - eepromFormat(); + storageFormat(); for(int i=0; i<1000; i++) buf[i]='6'+i%4; @@ -83,19 +83,19 @@ TEST(EEPROM, test2) EXPECT_EQ(sz, 300); } -TEST(EEPROM, eeCheckImmediately) +TEST(Eeprom, storageCheckImmediately) { eepromFile = NULL; // in memory // RlcFile f; uint8_t buf[1000]; - eepromFormat(); + storageFormat(); for(int i=0; i<1000; i++) buf[i]='6'+i%4; theFile.writeRlc(6, 6, buf, 300, false); - eeCheck(true); + storageCheck(true); theFile.openRd(6); uint16_t sz=0; @@ -108,13 +108,13 @@ TEST(EEPROM, eeCheckImmediately) EXPECT_EQ(sz, 300); } -TEST(EEPROM, copy) +TEST(Eeprom, copy) { eepromFile = NULL; // in memory uint8_t buf[1000]; - eepromFormat(); + storageFormat(); for(int i=0; i<1000; i++) buf[i]='6'+i%4; @@ -133,13 +133,13 @@ TEST(EEPROM, copy) EXPECT_EQ(sz, 300); } -TEST(EEPROM, rm) +TEST(Eeprom, rm) { eepromFile = NULL; // in memory uint8_t buf[1000]; - eepromFormat(); + storageFormat(); for(int i=0; i<1000; i++) buf[i]='6'+i%4; diff --git a/radio/src/tests/frsky.cpp b/radio/src/tests/frsky.cpp index c82109319..5dd2391ad 100644 --- a/radio/src/tests/frsky.cpp +++ b/radio/src/tests/frsky.cpp @@ -341,7 +341,7 @@ TEST(FrSkySPORT, frskySetCellVoltage) EXPECT_EQ(telemetryItems[0].valueMax, 2071); //display test - lcd_clear(); + lcdClear(); g_model.frsky.voltsSource = FRSKY_VOLTS_SOURCE_A1; } @@ -416,7 +416,7 @@ TEST(FrSkySPORT, frskySetCellVoltageTwoSensors) EXPECT_EQ(telemetryItems[2].valueMax, 287); //display test - lcd_clear(); + lcdClear(); g_model.frsky.voltsSource = FRSKY_VOLTS_SOURCE_A1; } diff --git a/radio/src/tests/lcd.cpp b/radio/src/tests/lcd.cpp index dbba72798..2042de3a6 100644 --- a/radio/src/tests/lcd.cpp +++ b/radio/src/tests/lcd.cpp @@ -72,11 +72,11 @@ void doPaint(QPainter & p) #endif for (int x=0; x> 4) : (lcd_buf[idx] & 0x0F); + unsigned int z = (y & 1) ? (simuLcdBuf[idx] >> 4) : (simuLcdBuf[idx] & 0x0F); if (z) { if (z != previousDepth) { previousDepth = z; @@ -114,7 +114,7 @@ bool checkScreenshot(const QString & test) TEST(outdezNAtt, test_unsigned) { - lcd_clear(); + lcdClear(); lcd_outdezNAtt(0, 0, 65530, LEFT|UNSIGN); EXPECT_TRUE(checkScreenshot("unsigned")) << "Unsigned numbers will be bad displayed"; } @@ -122,7 +122,7 @@ TEST(outdezNAtt, test_unsigned) #if defined(CPUARM) TEST(outdezNAtt, testBigNumbers) { - lcd_clear(); + lcdClear(); lcd_outdezNAtt(0, 0, 1234567, LEFT); lcd_outdezNAtt(0, FH, -1234567, LEFT); EXPECT_TRUE(checkScreenshot("big_numbers")); @@ -132,28 +132,28 @@ TEST(outdezNAtt, testBigNumbers) TEST(Lcd, Invers_0_0) { - lcd_clear(); - lcd_putsAtt(0, 0, "Test", INVERS); + lcdClear(); + lcdDrawText(0, 0, "Test", INVERS); EXPECT_TRUE(checkScreenshot("invers_0_0")); } TEST(Lcd, Invers_0_1) { - lcd_clear(); - lcd_putsAtt(0, 1, "Test", INVERS); + lcdClear(); + lcdDrawText(0, 1, "Test", INVERS); EXPECT_TRUE(checkScreenshot("invers_0_1")); } TEST(Lcd, Prec2_Left) { - lcd_clear(); + lcdClear(); lcd_outdezAtt(0, 0, 2, PREC2|LEFT); EXPECT_TRUE(checkScreenshot("prec2_left")); } TEST(Lcd, Prec2_Right) { - lcd_clear(); + lcdClear(); lcd_outdezAtt(LCD_W, LCD_H-FH, 2, PREC2); EXPECT_TRUE(checkScreenshot("prec2_right")); } @@ -161,7 +161,7 @@ TEST(Lcd, Prec2_Right) #if defined(CPUARM) TEST(Lcd, Prec1_Dblsize_Invers) { - lcd_clear(); + lcdClear(); lcd_outdezAtt(LCD_W, 10, 51, PREC1|DBLSIZE|INVERS); EXPECT_TRUE(checkScreenshot("prec1_dblsize_invers")); } @@ -169,22 +169,22 @@ TEST(Lcd, Prec1_Dblsize_Invers) TEST(Lcd, Line_Wrap) { - lcd_clear(); + lcdClear(); lcd_puts(LCD_W-10, 0, "TEST"); EXPECT_TRUE(checkScreenshot("line_wrap")); } TEST(Lcd, DblsizeBottomRight) { - lcd_clear(); - lcd_putsAtt(LCD_W-20, LCD_H-16, "TEST", DBLSIZE); + lcdClear(); + lcdDrawText(LCD_W-20, LCD_H-16, "TEST", DBLSIZE); EXPECT_TRUE(checkScreenshot("dblsize_bottom_right")); } #if defined(CPUARM) TEST(Lcd, Smlsize_putsStrIdx) { - lcd_clear(); + lcdClear(); putsStrIdx(0, 0, "FM", 0, SMLSIZE); EXPECT_TRUE(checkScreenshot("smlsize_putsstridx")); } @@ -192,7 +192,7 @@ TEST(Lcd, Smlsize_putsStrIdx) TEST(Lcd, vline) { - lcd_clear(); + lcdClear(); for (int x=0; x<100; x+=2) { lcd_vline(x, x/2, 12); } @@ -202,7 +202,7 @@ TEST(Lcd, vline) #if defined(CPUARM) TEST(Lcd, vline_x_lt0) { - lcd_clear(); + lcdClear(); lcd_vline(50, -10, 12); lcd_vline(100, -10, 1); EXPECT_TRUE(checkScreenshot("vline_lt0")); @@ -212,15 +212,15 @@ TEST(Lcd, vline_x_lt0) #if defined(CPUARM) TEST(Lcd, Smlsize) { - lcd_clear(); - lcd_putsAtt(0, 0, "TESTgy,", SMLSIZE); - lcd_putsAtt(10, 22, "TESTgy,", SMLSIZE|INVERS); + lcdClear(); + lcdDrawText(0, 0, "TESTgy,", SMLSIZE); + lcdDrawText(10, 22, "TESTgy,", SMLSIZE|INVERS); drawFilledRect(8, 40, 100, 20); - lcd_putsAtt(10, 42, "TESTgy,", SMLSIZE); + lcdDrawText(10, 42, "TESTgy,", SMLSIZE); bool invert = false; for(int i=0; i<3; i++) { - lcd_putsAtt(40+(4*i), 0+(4*i), "ABC", SMLSIZE|(invert?INVERS:0)); + lcdDrawText(40+(4*i), 0+(4*i), "ABC", SMLSIZE|(invert?INVERS:0)); invert = !invert; } @@ -229,15 +229,15 @@ TEST(Lcd, Smlsize) TEST(Lcd, Stdsize) { - lcd_clear(); - lcd_putsAtt(0, 0, "TEST", 0); - lcd_putsAtt(10, 22, "TEST", INVERS); + lcdClear(); + lcdDrawText(0, 0, "TEST", 0); + lcdDrawText(10, 22, "TEST", INVERS); drawFilledRect(8, 40, 100, 20); - lcd_putsAtt(10, 42, "TEST", 0); + lcdDrawText(10, 42, "TEST", 0); bool invert = false; for(int i=0; i<3; i++) { - lcd_putsAtt(40+(4*i), 0+(4*i), "ABC", (invert?INVERS:0)); + lcdDrawText(40+(4*i), 0+(4*i), "ABC", (invert?INVERS:0)); invert = !invert; } @@ -246,15 +246,15 @@ TEST(Lcd, Stdsize) TEST(Lcd, Midsize) { - lcd_clear(); - lcd_putsAtt(0, 0, "TEST", MIDSIZE); - lcd_putsAtt(10, 22, "TEST", MIDSIZE|INVERS); + lcdClear(); + lcdDrawText(0, 0, "TEST", MIDSIZE); + lcdDrawText(10, 22, "TEST", MIDSIZE|INVERS); drawFilledRect(8, 40, 100, 20); - lcd_putsAtt(10, 42, "TEST", MIDSIZE); + lcdDrawText(10, 42, "TEST", MIDSIZE); bool invert = false; for(int i=0; i<3; i++) { - lcd_putsAtt(40+(4*i), 0+(4*i), "ABC", MIDSIZE|(invert?INVERS:0)); + lcdDrawText(40+(4*i), 0+(4*i), "ABC", MIDSIZE|(invert?INVERS:0)); invert = !invert; } @@ -263,15 +263,15 @@ TEST(Lcd, Midsize) TEST(Lcd, Dblsize) { - lcd_clear(); - lcd_putsAtt(2, 10, "TST", DBLSIZE); - lcd_putsAtt(42, 10, "TST", DBLSIZE|INVERS); + lcdClear(); + lcdDrawText(2, 10, "TST", DBLSIZE); + lcdDrawText(42, 10, "TST", DBLSIZE|INVERS); drawFilledRect(80, 8, 46, 24); - lcd_putsAtt(82, 10, "TST", DBLSIZE); + lcdDrawText(82, 10, "TST", DBLSIZE); bool invert = false; for(int i=0; i<3; i++) { - lcd_putsAtt(10+(4*i), 30+(4*i), "ABC", DBLSIZE|(invert?INVERS:0)); + lcdDrawText(10+(4*i), 30+(4*i), "ABC", DBLSIZE|(invert?INVERS:0)); invert = !invert; } @@ -282,7 +282,7 @@ TEST(Lcd, Dblsize) #if defined(PCBTARANIS) TEST(Lcd, DrawSwitch) { - lcd_clear(); + lcdClear(); putsSwitches(0, 10, SWSRC_SA0, 0); putsSwitches(30, 10, SWSRC_SA0, SMLSIZE); // putsSwitches(60, 10, SWSRC_SA0, MIDSIZE); missing arrows in this font @@ -294,7 +294,7 @@ TEST(Lcd, DrawSwitch) #if defined(PCBTARANIS) TEST(Lcd, BMPWrapping) { - lcd_clear(); + lcdClear(); uint8_t bitmap[2+40*40/2]; bmpLoad(bitmap, "./tests/plane.bmp", 40, 40); lcd_bmp(200, 0, bitmap); @@ -306,28 +306,28 @@ TEST(Lcd, BMPWrapping) #endif #if defined(PCBTARANIS) -TEST(Lcd, lcd_hlineStip) +TEST(Lcd, lcdDrawHorizontalLine) { - lcd_clear(); - lcd_hlineStip(0, 10, LCD_W, DOTTED); - lcd_hlineStip(0, 20, LCD_W, SOLID); - lcd_hlineStip(50, 30, LCD_W, 0xEE); //too wide - lcd_hlineStip(50, LCD_H + 10, 20, SOLID); //too low - lcd_hlineStip(250, 30, LCD_W, SOLID); //x outside display - EXPECT_TRUE(checkScreenshot("lcd_hlineStip")); + lcdClear(); + lcdDrawHorizontalLine(0, 10, LCD_W, DOTTED); + lcdDrawHorizontalLine(0, 20, LCD_W, SOLID); + lcdDrawHorizontalLine(50, 30, LCD_W, 0xEE); //too wide + lcdDrawHorizontalLine(50, LCD_H + 10, 20, SOLID); //too low + lcdDrawHorizontalLine(250, 30, LCD_W, SOLID); //x outside display + EXPECT_TRUE(checkScreenshot("lcdDrawHorizontalLine")); } #endif #if defined(PCBTARANIS) -TEST(Lcd, lcd_vlineStip) +TEST(Lcd, lcdDrawVerticalLine) { - lcd_clear(); - lcd_vlineStip(10, 0, LCD_H, DOTTED); - lcd_vlineStip(20, 0, LCD_H, SOLID); - lcd_vlineStip(30, 30, LCD_H, 0xEE); //too high - lcd_vlineStip(40, LCD_H + 10, 20, SOLID); //too low - lcd_vlineStip(250, LCD_H + 10, LCD_H, SOLID); //x outside display - EXPECT_TRUE(checkScreenshot("lcd_vlineStip")); + lcdClear(); + lcdDrawVerticalLine(10, 0, LCD_H, DOTTED); + lcdDrawVerticalLine(20, 0, LCD_H, SOLID); + lcdDrawVerticalLine(30, 30, LCD_H, 0xEE); //too high + lcdDrawVerticalLine(40, LCD_H + 10, 20, SOLID); //too low + lcdDrawVerticalLine(250, LCD_H + 10, LCD_H, SOLID); //x outside display + EXPECT_TRUE(checkScreenshot("lcdDrawVerticalLine")); } #endif @@ -361,7 +361,7 @@ public: #if defined(PCBTARANIS) TEST(Lcd, lcd_bmpLoadAndDisplay) { - lcd_clear(); + lcdClear(); // Test proper BMP files, they should display correctly { TestBuffer<1000> bitmap(BITMAP_BUFFER_SIZE(7, 32)); @@ -410,68 +410,68 @@ TEST(Lcd, lcd_bmpLoadAndDisplay) #endif #if defined(PCBTARANIS) -TEST(Lcd, lcd_line) +TEST(Lcd, lcdDrawLine) { int start, length, xOffset; uint8_t pattern; - lcd_clear(); + lcdClear(); start = 5; pattern = SOLID; length = 40; xOffset = 0; - lcd_line(start+(length>0?1:-1)+xOffset, start, start+(length>0?1:-1)+xOffset+length, start, pattern, 0); - lcd_line(start+xOffset, start+(length>0?1:-1), start+xOffset, start+(length>0?1:-1)+length, pattern, 0); + lcdDrawLine(start+(length>0?1:-1)+xOffset, start, start+(length>0?1:-1)+xOffset+length, start, pattern, 0); + lcdDrawLine(start+xOffset, start+(length>0?1:-1), start+xOffset, start+(length>0?1:-1)+length, pattern, 0); start = 10; pattern = DOTTED; length = 40; xOffset = 0; - lcd_line(start+(length>0?1:-1)+xOffset, start, start+(length>0?1:-1)+xOffset+length, start, pattern, 0); - lcd_line(start+xOffset, start+(length>0?1:-1), start+xOffset, start+(length>0?1:-1)+length, pattern, 0); + lcdDrawLine(start+(length>0?1:-1)+xOffset, start, start+(length>0?1:-1)+xOffset+length, start, pattern, 0); + lcdDrawLine(start+xOffset, start+(length>0?1:-1), start+xOffset, start+(length>0?1:-1)+length, pattern, 0); start = 55; pattern = SOLID; length = -40; xOffset = 80; - lcd_line(start+(length>0?1:-1)+xOffset, start, start+(length>0?1:-1)+xOffset+length, start, pattern, 0); - lcd_line(start+xOffset, start+(length>0?1:-1), start+xOffset, start+(length>0?1:-1)+length, pattern, 0); + lcdDrawLine(start+(length>0?1:-1)+xOffset, start, start+(length>0?1:-1)+xOffset+length, start, pattern, 0); + lcdDrawLine(start+xOffset, start+(length>0?1:-1), start+xOffset, start+(length>0?1:-1)+length, pattern, 0); start = 50; pattern = DOTTED; length = -40; xOffset = 80; - lcd_line(start+(length>0?1:-1)+xOffset, start, start+(length>0?1:-1)+xOffset+length, start, pattern, 0); - lcd_line(start+xOffset, start+(length>0?1:-1), start+xOffset, start+(length>0?1:-1)+length, pattern, 0); + lcdDrawLine(start+(length>0?1:-1)+xOffset, start, start+(length>0?1:-1)+xOffset+length, start, pattern, 0); + lcdDrawLine(start+xOffset, start+(length>0?1:-1), start+xOffset, start+(length>0?1:-1)+length, pattern, 0); // 45 deg lines - lcd_line( 35, 40, 45, 40, SOLID, FORCE ); - lcd_line( 40, 35, 40, 45, SOLID, FORCE ); + lcdDrawLine( 35, 40, 45, 40, SOLID, FORCE ); + lcdDrawLine( 40, 35, 40, 45, SOLID, FORCE ); - lcd_line( 20, 40, 40, 20, SOLID, FORCE ); - lcd_line( 40, 20, 60, 40, SOLID, FORCE ); - lcd_line( 60, 40, 40, 60, SOLID, FORCE ); - lcd_line( 40, 60, 20, 40, SOLID, FORCE ); + lcdDrawLine( 20, 40, 40, 20, SOLID, FORCE ); + lcdDrawLine( 40, 20, 60, 40, SOLID, FORCE ); + lcdDrawLine( 60, 40, 40, 60, SOLID, FORCE ); + lcdDrawLine( 40, 60, 20, 40, SOLID, FORCE ); - lcd_line( 31, 39, 39, 31, SOLID, FORCE ); - lcd_line( 41, 31, 49, 39, SOLID, FORCE ); - lcd_line( 49, 41, 41, 49, SOLID, FORCE ); - lcd_line( 39, 49, 31, 41, SOLID, FORCE ); + lcdDrawLine( 31, 39, 39, 31, SOLID, FORCE ); + lcdDrawLine( 41, 31, 49, 39, SOLID, FORCE ); + lcdDrawLine( 49, 41, 41, 49, SOLID, FORCE ); + lcdDrawLine( 39, 49, 31, 41, SOLID, FORCE ); // slanted lines - lcd_line( 150, 10, 190, 10, SOLID, FORCE ); - lcd_line( 150, 10, 190, 20, SOLID, FORCE ); - lcd_line( 150, 10, 190, 30, SOLID, FORCE ); - lcd_line( 150, 10, 190, 40, SOLID, FORCE ); - lcd_line( 150, 10, 190, 50, SOLID, FORCE ); + lcdDrawLine( 150, 10, 190, 10, SOLID, FORCE ); + lcdDrawLine( 150, 10, 190, 20, SOLID, FORCE ); + lcdDrawLine( 150, 10, 190, 30, SOLID, FORCE ); + lcdDrawLine( 150, 10, 190, 40, SOLID, FORCE ); + lcdDrawLine( 150, 10, 190, 50, SOLID, FORCE ); - lcd_line( 150, 10, 190, 50, SOLID, FORCE ); - lcd_line( 150, 10, 180, 50, SOLID, FORCE ); - lcd_line( 150, 10, 170, 50, SOLID, FORCE ); - lcd_line( 150, 10, 160, 50, SOLID, FORCE ); - lcd_line( 150, 10, 150, 50, SOLID, FORCE ); + lcdDrawLine( 150, 10, 190, 50, SOLID, FORCE ); + lcdDrawLine( 150, 10, 180, 50, SOLID, FORCE ); + lcdDrawLine( 150, 10, 170, 50, SOLID, FORCE ); + lcdDrawLine( 150, 10, 160, 50, SOLID, FORCE ); + lcdDrawLine( 150, 10, 150, 50, SOLID, FORCE ); - EXPECT_TRUE(checkScreenshot("lcd_line")); + EXPECT_TRUE(checkScreenshot("lcdDrawLine")); } #endif diff --git a/radio/src/tests/lcd_hlineStip_212x64.png b/radio/src/tests/lcdDrawHorizontalLine_212x64.png similarity index 100% rename from radio/src/tests/lcd_hlineStip_212x64.png rename to radio/src/tests/lcdDrawHorizontalLine_212x64.png diff --git a/radio/src/tests/lcd_line_212x64.png b/radio/src/tests/lcdDrawLine_212x64.png similarity index 100% rename from radio/src/tests/lcd_line_212x64.png rename to radio/src/tests/lcdDrawLine_212x64.png diff --git a/radio/src/tests/lcd_vlineStip_212x64.png b/radio/src/tests/lcdDrawVerticalLine_212x64.png similarity index 100% rename from radio/src/tests/lcd_vlineStip_212x64.png rename to radio/src/tests/lcdDrawVerticalLine_212x64.png diff --git a/radio/src/thirdparty/CoOS/OsConfig.h b/radio/src/thirdparty/CoOS/OsConfig.h index 7c1876d37..ffc41ca1a 100644 --- a/radio/src/thirdparty/CoOS/OsConfig.h +++ b/radio/src/thirdparty/CoOS/OsConfig.h @@ -69,9 +69,9 @@ Idle task stack size(word). /*!< System frequency (Hz). */ -#if defined(PCBTARANIS) && defined(REV9E) +#if defined(PCBFLAMENCO) || (defined(PCBTARANIS) && defined(REV9E)) #define CFG_CPU_FREQ (168000000) -#elif defined(PCBTARANIS) +#elif defined(PCBTARANIS) || defined(PCBHORUS) #define CFG_CPU_FREQ (120000000) #else #define CFG_CPU_FREQ (36000000) // TODO check if really correct for sky9x? diff --git a/radio/src/thirdparty/GCS_MAVLink/message_definitions_v1.0/matrixpilot.xml b/radio/src/thirdparty/GCS_MAVLink/message_definitions_v1.0/matrixpilot.xml index 29d368d2a..240c0ed01 100644 --- a/radio/src/thirdparty/GCS_MAVLink/message_definitions_v1.0/matrixpilot.xml +++ b/radio/src/thirdparty/GCS_MAVLink/message_definitions_v1.0/matrixpilot.xml @@ -178,7 +178,7 @@ Serial UDB Extra Current Waypoint Goal X Serial UDB Extra Current Waypoint Goal Y Serial UDB Extra Current Waypoint Goal Z - Serial UDB Extra Stack Memory Free + Serial UDB Extra Stack Memory Free Backwards compatible version of SERIAL_UDB_EXTRA F4: format diff --git a/radio/src/thirdparty/STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_dma2d.h b/radio/src/thirdparty/STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_dma2d.h index 0e456ed36..1dc95de1c 100644 --- a/radio/src/thirdparty/STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_dma2d.h +++ b/radio/src/thirdparty/STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_dma2d.h @@ -35,7 +35,7 @@ #endif /* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx.h" +#include "../../CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h" /** @addtogroup STM32F4xx_StdPeriph_Driver * @{ diff --git a/radio/src/thirdparty/STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_fmc.h b/radio/src/thirdparty/STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_fmc.h index 41b3c64e9..a2157f4d0 100644 --- a/radio/src/thirdparty/STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_fmc.h +++ b/radio/src/thirdparty/STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_fmc.h @@ -35,7 +35,7 @@ #endif /* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx.h" +#include "../../CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h" /** @addtogroup STM32F4xx_StdPeriph_Driver * @{ diff --git a/radio/src/thirdparty/STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_ltdc.h b/radio/src/thirdparty/STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_ltdc.h index 1c67a77fb..e94d2d09e 100644 --- a/radio/src/thirdparty/STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_ltdc.h +++ b/radio/src/thirdparty/STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_ltdc.h @@ -35,7 +35,7 @@ #endif /* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx.h" +#include "../../CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h" /** @addtogroup STM32F4xx_StdPeriph_Driver * @{ diff --git a/radio/src/thirdparty/STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_tim.h b/radio/src/thirdparty/STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_tim.h index adc8140e5..3fc4d0db7 100644 --- a/radio/src/thirdparty/STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_tim.h +++ b/radio/src/thirdparty/STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_tim.h @@ -35,7 +35,7 @@ #endif /* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx.h" +#include "../../CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h" /** @addtogroup STM32F4xx_StdPeriph_Driver * @{ diff --git a/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/audio/inc/usbd_audio_core.h b/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/audio/inc/usbd_audio_core.h index eeb90532b..914f70218 100644 --- a/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/audio/inc/usbd_audio_core.h +++ b/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/audio/inc/usbd_audio_core.h @@ -30,9 +30,9 @@ #ifndef __USB_AUDIO_CORE_H_ #define __USB_AUDIO_CORE_H_ +#include "usbd_desc.h" #include "usbd_ioreq.h" #include "usbd_req.h" -#include "usbd_desc.h" diff --git a/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/cdc/src/usbd_cdc_core.c b/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/cdc/src/usbd_cdc_core.c index 3856f778d..4cce796e7 100644 --- a/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/cdc/src/usbd_cdc_core.c +++ b/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/cdc/src/usbd_cdc_core.c @@ -64,7 +64,8 @@ */ /* Includes ------------------------------------------------------------------*/ -#include "usbd_cdc_core.h" +#include "../inc/usbd_cdc_core.h" + #include "usbd_desc.h" #include "usbd_req.h" diff --git a/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/dfu/inc/usbd_dfu_mal.h b/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/dfu/inc/usbd_dfu_mal.h index bf6aae491..2711dfc0e 100644 --- a/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/dfu/inc/usbd_dfu_mal.h +++ b/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/dfu/inc/usbd_dfu_mal.h @@ -31,7 +31,6 @@ /* Includes ------------------------------------------------------------------*/ #include "usb_conf.h" - #include "usbd_conf.h" #include "usbd_dfu_core.h" diff --git a/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/dfu/inc/usbd_mem_if_template.h b/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/dfu/inc/usbd_mem_if_template.h index eaae60359..d4542f515 100644 --- a/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/dfu/inc/usbd_mem_if_template.h +++ b/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/dfu/inc/usbd_mem_if_template.h @@ -31,7 +31,6 @@ /* Includes ------------------------------------------------------------------*/ #include "usb_conf.h" - #include "usbd_dfu_mal.h" /* Exported types ------------------------------------------------------------*/ diff --git a/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/dfu/src/usbd_dfu_core.c b/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/dfu/src/usbd_dfu_core.c index 5f2b3b360..0cfa47897 100644 --- a/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/dfu/src/usbd_dfu_core.c +++ b/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/dfu/src/usbd_dfu_core.c @@ -63,6 +63,7 @@ /* Includes ------------------------------------------------------------------*/ #include "usbd_dfu_core.h" + #include "usbd_desc.h" #include "usbd_req.h" #include "usb_bsp.h" diff --git a/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/hid/src/usbd_hid_core.c b/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/hid/src/usbd_hid_core.c index 7cdc52349..3dcfd918c 100644 --- a/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/hid/src/usbd_hid_core.c +++ b/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Class/hid/src/usbd_hid_core.c @@ -48,7 +48,8 @@ /* Includes ------------------------------------------------------------------*/ #include "usbd_hid_core.h" -#include "../../../../../usbd_desc.h" + +#include "usbd_desc.h" #include "usbd_req.h" diff --git a/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/inc/usbd_core.h b/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/inc/usbd_core.h index c01964749..a49985ba2 100644 --- a/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/inc/usbd_core.h +++ b/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/inc/usbd_core.h @@ -30,9 +30,9 @@ #define __USBD_CORE_H /* Includes ------------------------------------------------------------------*/ +#include "usbd_conf.h" #include "../../../STM32_USB_OTG_Driver/inc/usb_dcd.h" #include "usbd_def.h" -#include "usbd_conf.h" /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY * @{ diff --git a/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/inc/usbd_req.h b/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/inc/usbd_req.h index f88416df3..87b0f5444 100644 --- a/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/inc/usbd_req.h +++ b/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/inc/usbd_req.h @@ -31,9 +31,9 @@ #define __USB_REQUEST_H_ /* Includes ------------------------------------------------------------------*/ +#include "usbd_conf.h" #include "usbd_def.h" #include "usbd_core.h" -#include "usbd_conf.h" /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY diff --git a/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/src/usbd_req.c b/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/src/usbd_req.c index 2659732e6..cd7a409d9 100644 --- a/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/src/usbd_req.c +++ b/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_Device_Library/Core/src/usbd_req.c @@ -27,8 +27,9 @@ /* Includes ------------------------------------------------------------------*/ #include "usbd_req.h" -#include "usbd_ioreq.h" + #include "usbd_desc.h" +#include "usbd_ioreq.h" /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY diff --git a/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/src/usb_hcd.c b/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/src/usb_hcd.c index 56e224418..115b1ad5d 100644 --- a/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/src/usb_hcd.c +++ b/radio/src/thirdparty/STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/src/usb_hcd.c @@ -28,6 +28,7 @@ /* Includes ------------------------------------------------------------------*/ #include "usb_core.h" #include "usb_hcd.h" + #include "usb_conf.h" #include "usb_bsp.h" diff --git a/radio/src/timers.cpp b/radio/src/timers.cpp index 4826eea64..589a9c628 100644 --- a/radio/src/timers.cpp +++ b/radio/src/timers.cpp @@ -78,7 +78,7 @@ void saveTimers() TimerState *timerState = &timersStates[i]; if (g_model.timers[i].value != (uint16_t)timerState->val) { g_model.timers[i].value = timerState->val; - eeDirty(EE_MODEL); + storageDirty(EE_MODEL); } } } @@ -86,7 +86,7 @@ void saveTimers() #if defined(CPUARM) && !defined(REVA) if (sessionTimer > 0) { g_eeGeneral.globalTimer += sessionTimer; - eeDirty(EE_GENERAL); + storageDirty(EE_GENERAL); sessionTimer = 0; } #endif diff --git a/radio/src/translations.cpp b/radio/src/translations.cpp index 524d87a55..e5e3325d3 100644 --- a/radio/src/translations.cpp +++ b/radio/src/translations.cpp @@ -298,18 +298,27 @@ const pm_char STR_CH[] PROGMEM = TR_CH; const pm_char STR_MODEL[] PROGMEM = TR_MODEL; const pm_char STR_FP[] PROGMEM = TR_FP; const pm_char STR_MIX[] PROGMEM = TR_MIX; -const pm_char STR_EEPROMLOWMEM[] PROGMEM = TR_EEPROMLOWMEM; const pm_char STR_ALERT[] PROGMEM = TR_ALERT; const pm_char STR_PRESSANYKEYTOSKIP[] PROGMEM = TR_PRESSANYKEYTOSKIP; const pm_char STR_THROTTLENOTIDLE[] PROGMEM = TR_THROTTLENOTIDLE; const pm_char STR_ALARMSDISABLED[] PROGMEM = TR_ALARMSDISABLED; const pm_char STR_PRESSANYKEY[] PROGMEM = TR_PRESSANYKEY; -const pm_char STR_BADEEPROMDATA[] PROGMEM = TR_BADEEPROMDATA; -const pm_char STR_EEPROMFORMATTING[] PROGMEM = TR_EEPROMFORMATTING; -const pm_char STR_EEPROMOVERFLOW[] PROGMEM = TR_EEPROMOVERFLOW; const pm_char STR_TRIMS2OFFSETS[] PROGMEM = TR_TRIMS2OFFSETS; const pm_char STR_MENURADIOSETUP[] PROGMEM = TR_MENURADIOSETUP; +#if defined(EEPROM) +const pm_char STR_BAD_RADIO_DATA[] PROGMEM = TR_BADEEPROMDATA; +const pm_char STR_STORAGE_FORMAT[] PROGMEM = TR_EEPROMFORMATTING; +const pm_char STR_STORAGE_WARNING[] PROGMEM = TR_EEPROMWARN; +const pm_char STR_EEPROM_CONVERTING[] PROGMEM = TR_EEPROM_CONVERTING; +const pm_char STR_EEPROMLOWMEM[] PROGMEM = TR_EEPROMLOWMEM; +const pm_char STR_EEPROMOVERFLOW[] PROGMEM = TR_EEPROMOVERFLOW; +#else +const pm_char STR_BAD_RADIO_DATA[] PROGMEM = TR_BAD_RADIO_DATA; +const pm_char STR_STORAGE_WARNING[] PROGMEM = TR_STORAGE_WARNING; +const pm_char STR_STORAGE_FORMAT[] PROGMEM = TR_STORAGE_FORMAT; +#endif + #if defined(FAS_OFFSET) || !defined(CPUM64) const pm_char STR_FAS_OFFSET[] PROGMEM = TR_FAS_OFFSET; #endif @@ -416,6 +425,7 @@ const pm_char STR_PERSISTENT_MAH[] PROGMEM = TR_PERSISTENT_MAH; #if defined(NAVIGATION_MENUS) const pm_char STR_SELECT_MODEL[] PROGMEM = TR_SELECT_MODEL; const pm_char STR_CREATE_MODEL[] PROGMEM = TR_CREATE_MODEL; +const pm_char STR_DUPLICATE_MODEL[] PROGMEM = TR_DUPLICATE_MODEL; const pm_char STR_COPY_MODEL[] PROGMEM = TR_COPY_MODEL; const pm_char STR_MOVE_MODEL[] PROGMEM = TR_MOVE_MODEL; const pm_char STR_DELETE_MODEL[] PROGMEM = TR_DELETE_MODEL; @@ -452,8 +462,6 @@ const pm_char STR_MODELS_EXT[] PROGMEM = MODELS_EXT; #endif const pm_char STR_WARNING[] PROGMEM = TR_WARNING; -const pm_char STR_EEPROMWARN[] PROGMEM = TR_EEPROMWARN; -const pm_char STR_EEPROM_CONVERTING[] PROGMEM = TR_EEPROM_CONVERTING; const pm_char STR_THROTTLEWARN[] PROGMEM = TR_THROTTLEWARN; const pm_char STR_ALARMSWARN[] PROGMEM = TR_ALARMSWARN; const pm_char STR_SWITCHWARN[] PROGMEM = TR_SWITCHWARN; @@ -550,6 +558,7 @@ const pm_char STR_BLCOLOR[] PROGMEM = TR_BLCOLOR; const pm_char STR_PREFLIGHT[] PROGMEM = TR_PREFLIGHT; const pm_char STR_CHECKLIST[] PROGMEM = TR_CHECKLIST; const pm_char STR_VIEW_NOTES[] PROGMEM = TR_VIEW_NOTES; +const pm_char STR_MODEL_SELECT[] PROGMEM = TR_MODEL_SELECT; const pm_char STR_RESET_SUBMENU[] PROGMEM = TR_RESET_SUBMENU; const pm_char STR_LOWALARM[] PROGMEM = TR_LOWALARM; const pm_char STR_CRITICALALARM[] PROGMEM = TR_CRITICALALARM; @@ -581,7 +590,7 @@ const pm_char STR_BLCOLOR[] PROGMEM = TR_BLCOLOR; const pm_char STR_CONFIRMDELETE[] PROGMEM = TR_CONFIRMDELETE; #endif -#if defined(PCBTARANIS) +#if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS) const pm_char STR_BYTES[] PROGMEM = TR_BYTES; const pm_char STR_ANTENNAPROBLEM[] PROGMEM = TR_ANTENNAPROBLEM; const pm_char STR_MODULE[] PROGMEM = TR_MODULE; diff --git a/radio/src/translations.h b/radio/src/translations.h index c533a504d..8f26c28f5 100644 --- a/radio/src/translations.h +++ b/radio/src/translations.h @@ -500,8 +500,8 @@ extern const pm_char STR_THROTTLENOTIDLE[]; extern const pm_char STR_ALARMSDISABLED[]; extern const pm_char STR_PRESSANYKEY[]; #define LEN_PRESSANYKEY PSIZE(TR_PRESSANYKEY) -extern const pm_char STR_BADEEPROMDATA[]; -extern const pm_char STR_EEPROMFORMATTING[]; +extern const pm_char STR_BAD_RADIO_DATA[]; +extern const pm_char STR_STORAGE_FORMAT[]; extern const pm_char STR_EEPROMOVERFLOW[]; extern const pm_char STR_TRIMS2OFFSETS[]; extern const pm_char STR_MENURADIOSETUP[]; @@ -598,6 +598,7 @@ extern const pm_char STR_CURRENT[]; #if defined(NAVIGATION_MENUS) extern const pm_char STR_SELECT_MODEL[]; extern const pm_char STR_CREATE_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[]; @@ -635,7 +636,7 @@ extern const pm_char STR_RESET_BTN[]; #endif extern const pm_char STR_WARNING[]; -extern const pm_char STR_EEPROMWARN[]; +extern const pm_char STR_STORAGE_WARNING[]; extern const pm_char STR_EEPROM_CONVERTING[]; extern const pm_char STR_THROTTLEWARN[]; extern const pm_char STR_ALARMSWARN[]; @@ -769,6 +770,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_RESET_SUBMENU[]; extern const pm_char STR_LOWALARM[]; extern const pm_char STR_CRITICALALARM[]; @@ -800,7 +802,7 @@ extern const pm_char STR_BLCOLOR[]; extern const pm_char STR_CONFIRMDELETE[]; #endif -#if defined(PCBTARANIS) +#if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS) extern const pm_char STR_BYTES[]; extern const pm_char STR_ANTENNAPROBLEM[]; extern const pm_char STR_MODULE[]; diff --git a/radio/src/translations/cz.h.txt b/radio/src/translations/cz.h.txt index 2977767ad..9aeeb0dab 100644 --- a/radio/src/translations/cz.h.txt +++ b/radio/src/translations/cz.h.txt @@ -806,6 +806,7 @@ #define TR_CURRENT INDENT"Proud" #define TR_SELECT_MODEL "Vyber model" #define TR_CREATE_MODEL "Nový model" +#define TR_DUPLICATE_MODEL "Duplicate Model" #define TR_COPY_MODEL "Kopírovat" #define TR_MOVE_MODEL "Přesunout" #define TR_BACKUP_MODEL "Zálohovat na SD" @@ -1063,6 +1064,7 @@ #define TR_SCALE "Měřítko" #define TR_VIEW_CHANNELS "Zobrazit kanály" #define TR_VIEW_NOTES "Zobrazit poznámky" +#define TR_MODEL_SELECT "Model Select" #define TR_MODS_FORBIDDEN "Změny nejsou povoleny!" #define TR_UNLOCKED "Odemčeno" #define TR_ID "ID" diff --git a/radio/src/translations/de.h.txt b/radio/src/translations/de.h.txt index 5360c51bf..7e85e1bfe 100644 --- a/radio/src/translations/de.h.txt +++ b/radio/src/translations/de.h.txt @@ -810,6 +810,7 @@ #define TR_CURRENT TR(INDENT "Strom", INDENT "Stromquelle") #define TR_SELECT_MODEL "Modell Wählen" #define TR_CREATE_MODEL "Neues Modell" +#define TR_DUPLICATE_MODEL "Duplicate Model" #define TR_COPY_MODEL "Kopiere Modell" #define TR_MOVE_MODEL "Verschiebe Modell" #define TR_BACKUP_MODEL "Modell auf SD-Karte" //9XR-Pro @@ -1067,6 +1068,7 @@ #define TR_SCALE "Skalierer" #define TR_VIEW_CHANNELS "Zeige Kanäle" #define TR_VIEW_NOTES "Zeige Notizen" +#define TR_MODEL_SELECT "Model Select" #define TR_MODS_FORBIDDEN "Veränderungen verboten!" #define TR_UNLOCKED "Entsperrt" #define TR_ID "ID" diff --git a/radio/src/translations/en.h.txt b/radio/src/translations/en.h.txt index 2850b58a1..06e6adfd0 100644 --- a/radio/src/translations/en.h.txt +++ b/radio/src/translations/en.h.txt @@ -129,7 +129,9 @@ #define LEN_RETA123 "\001" -#if defined(PCBTARANIS) && defined(REV9E) +#if defined(PCBFLAMENCO) + #define TR_RETA123 "RETA123LR" +#elif defined(PCBTARANIS) && defined(REV9E) #define TR_RETA123 "RETA1234LRLR" #elif defined(PCBTARANIS) || defined(REVX) #define TR_RETA123 "RETA123LR" @@ -443,8 +445,16 @@ #define LEN_VSWASHTYPE "\004" #define TR_VSWASHTYPE "---\0""120\0""120X""140\0""90\0" +#if defined(PCBHORUS) +#define LEN_VKEYS "\006" +#define TR_VKEYS "Menu\0 ""Exit\0 ""Enter\0""Up\0 ""Down\0 ""Right\0""Left" +#elif defined(PCBTARANIS) #define LEN_VKEYS "\005" -#define TR_VKEYS TR("Menu\0""Exit\0""Down\0""Up\0 ""Right""Left\0", "Menu\0""Exit\0""Enter""Page\0""Plus\0""Minus") +#define TR_VKEYS "Menu\0""Exit\0""Enter""Page\0""Plus\0""Minus" +#else +#define LEN_VKEYS "\005" +#define TR_VKEYS "Menu\0""Exit\0""Down\0""Up\0 ""Right""Left\0" +#endif #define LEN_VRENCODERS "\003" #define TR_VRENCODERS "REa""REb" @@ -454,8 +464,14 @@ #define TR_STICKS_VSRCRAW TR("Rud\0""Ele\0""Thr\0""Ail\0", "\307Rud""\307Ele""\307Thr""\307Ail") #define TR_TRIMS_VSRCRAW TR("TrmR""TrmE""TrmT""TrmA", "\313Rud""\313Ele""\313Thr""\313Ail") - -#if defined(PCBTARANIS) && defined(REV9E) + +#if defined(PCBHORUS) + #define TR_POTS_VSRCRAW "\310F1\0""\310F2\0""\310F3\0""\311S1\0""\311S2\0""\311LS\0""\311RS\0" + #define TR_SW_VSRCRAW "\312SA\0""\312SB\0""\312SC\0""\312SD\0""\312SE\0""\312SF\0""\312SG\0""\312SH\0" +#elif defined(PCBFLAMENCO) + #define TR_POTS_VSRCRAW "SD\0 ""LS\0 ""RS\0 " + #define TR_SW_VSRCRAW "SA\0 ""SB\0 ""SC\0 ""SE\0 ""SF\0 " +#elif defined(PCBTARANIS) && defined(REV9E) #define TR_POTS_VSRCRAW "\310F1\0""\310F2\0""\310F3\0""\310F4\0""\311S1\0""\311S2\0""\311LS\0""\311RS\0" #define TR_SW_VSRCRAW "\312SA\0""\312SB\0""\312SC\0""\312SD\0""\312SE\0""\312SF\0""\312SG\0""\312SH\0""\312SI\0""\312SJ\0""\312SK\0""\312SL\0""\312SM\0""\312SN\0""\312SO\0""\312SP\0""\312SQ\0""\312SR\0" #elif defined(PCBTARANIS) @@ -486,13 +502,17 @@ #define TR_ROTENC_SWITCHES #endif -#if !defined(PCBTARANIS) +#if defined(PCBFLAMENCO) + #define TR_PHYS_SWITCHES "SA\300""SA-""SA\301""SB\300""SB\301""SC1""SC2""SC3""SC4""SC5""SC6""SE\300""SE\301""SF\300""SF-""SF\301" +#elif !defined(PCBTARANIS) && !defined(PCBHORUS) #define TR_PHYS_SWITCHES "THR""RUD""ELE""AIL""GEA""TRN" #endif #define TR_ON_ONE_SWITCHES "ON\0""One" -#if defined(PCBTARANIS) +#if defined(PCBFLAMENCO) + #define TR_VSWITCHES "---" TR_PHYS_SWITCHES TR_TRIMS_SWITCHES TR_ROTENC_SWITCHES TR_LOGICALSW "ON\0""One" +#elif defined(PCBTARANIS) || defined(PCBHORUS) // only special switches here #define TR_VSWITCHES "---" TR_TRIMS_SWITCHES TR_ON_ONE_SWITCHES #else @@ -546,8 +566,8 @@ // ZERO TERMINATED STRINGS #if defined(COLORLCD) - #define INDENT "\007" - #define LEN_INDENT 1 + #define INDENT " " + #define LEN_INDENT 3 #define INDENT_WIDTH 12 #define BREAKSPACE "\036" #else @@ -557,7 +577,7 @@ #define BREAKSPACE " " #endif -#if defined(PCBTARANIS) +#if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS) #define TR_ENTER "[ENTER]" #else #define TR_ENTER "[MENU]" @@ -565,7 +585,9 @@ #define TR_EXIT "[EXIT]" -#if defined(PCBTARANIS) +#if defined(PCBFLAMENCO) + #define TR_POPUPS TR_EXIT "\010" TR_ENTER +#elif defined(PCBTARANIS) #define TR_POPUPS TR_EXIT "\010" "\010" "\010" "\010" TR_ENTER #else #define TR_POPUPS TR_ENTER "\010" TR_EXIT @@ -741,7 +763,9 @@ #define TR_ALARMSDISABLED "Alarms Disabled" #define TR_PRESSANYKEY TR("\010Press any Key", "Press any Key") #define TR_BADEEPROMDATA "Bad EEprom Data" +#define TR_BAD_RADIO_DATA "Bad Radio Data" #define TR_EEPROMFORMATTING "Formatting EEPROM" +#define TR_STORAGE_FORMAT "Storage Preparation" #define TR_EEPROMOVERFLOW "EEPROM overflow" #define TR_MENURADIOSETUP "RADIO SETUP" #define TR_MENUDATEANDTIME "DATE AND TIME" @@ -805,6 +829,7 @@ #define TR_CURRENT TR(INDENT "Current",INDENT "Current Source") #define TR_SELECT_MODEL "Select Model" #define TR_CREATE_MODEL "Create Model" +#define TR_DUPLICATE_MODEL "Duplicate Model" #define TR_COPY_MODEL "Copy Model" #define TR_MOVE_MODEL "Move Model" #define TR_BACKUP_MODEL "Backup Model" @@ -816,6 +841,7 @@ #define TR_INCOMPATIBLE "Incompatible" #define TR_WARNING "WARNING" #define TR_EEPROMWARN "EEPROM" +#define TR_STORAGE_WARNING "STORAGE" #define TR_EEPROM_CONVERTING "Converting EEPROM" #define TR_THROTTLEWARN "THROTTLE" #define TR_ALARMSWARN "ALARMS" @@ -1031,7 +1057,11 @@ #define TR_ABOUT_MARTIN_1 "Martin Hotar" #define TR_ABOUT_MARTIN_2 "Graphics designer" -#if defined(PCBTARANIS) +#if defined(PCBFLAMENCO) + #define TR_ABOUT_HARDWARE_1 "XXX" + #define TR_ABOUT_HARDWARE_2 "Hardware designer/producer" + #define TR_ABOUT_HARDWARE_3 "" +#elif defined(PCBTARANIS) || defined(PCBHORUS) #define TR_ABOUT_HARDWARE_1 "FrSky" #define TR_ABOUT_HARDWARE_2 "Hardware designer/producer" #define TR_ABOUT_HARDWARE_3 "Firmware contributor" @@ -1062,6 +1092,7 @@ #define TR_SCALE "Scale" #define TR_VIEW_CHANNELS "View Channels" #define TR_VIEW_NOTES "View Notes" +#define TR_MODEL_SELECT "Model Select" #define TR_MODS_FORBIDDEN "Modifications forbidden!" #define TR_UNLOCKED "Unlocked" #define TR_ID "ID" diff --git a/radio/src/translations/es.h.txt b/radio/src/translations/es.h.txt index a41288ec0..53137e75b 100644 --- a/radio/src/translations/es.h.txt +++ b/radio/src/translations/es.h.txt @@ -760,6 +760,7 @@ #define TR_CURRENT INDENT"Actual" #define TR_SELECT_MODEL "Selec Modelo" #define TR_CREATE_MODEL "Crear Modelo" +#define TR_DUPLICATE_MODEL "Duplicate Model" #define TR_COPY_MODEL "Copiar Modelo" #define TR_MOVE_MODEL "Mover Modelo" #define TR_BACKUP_MODEL "Copia Sgdad Mod." @@ -1017,6 +1018,7 @@ #define TR_SCALE "Scale" #define TR_VIEW_CHANNELS "View Channels" #define TR_VIEW_NOTES "View Notes" +#define TR_MODEL_SELECT "Model Select" #define TR_MODS_FORBIDDEN "Modifications forbidden!" #define TR_UNLOCKED "Unlocked" #define TR_ID "ID" diff --git a/radio/src/translations/fi.h.txt b/radio/src/translations/fi.h.txt index 0f6ad2e51..5cc4de5ed 100644 --- a/radio/src/translations/fi.h.txt +++ b/radio/src/translations/fi.h.txt @@ -760,6 +760,7 @@ #define TR_CURRENT INDENT"Current" #define TR_SELECT_MODEL "Select Model" #define TR_CREATE_MODEL "Create Model" +#define TR_DUPLICATE_MODEL "Duplicate Model" #define TR_COPY_MODEL "Copy Model" #define TR_MOVE_MODEL "Move Model" #define TR_BACKUP_MODEL "Backup Model" @@ -1017,6 +1018,7 @@ #define TR_SCALE "Scale" #define TR_VIEW_CHANNELS "View Channels" #define TR_VIEW_NOTES "View Notes" +#define TR_MODEL_SELECT "Model Select" #define TR_MODS_FORBIDDEN "Muutokset kielletty!" #define TR_UNLOCKED "Avattu" #define TR_ID "ID" diff --git a/radio/src/translations/fr.h.txt b/radio/src/translations/fr.h.txt index 41c4a0215..5d1e28580 100644 --- a/radio/src/translations/fr.h.txt +++ b/radio/src/translations/fr.h.txt @@ -797,6 +797,7 @@ #define TR_CURRENT TR(INDENT "Courant",INDENT "Source Courant") #define TR_SELECT_MODEL "Sélect. Modèle" #define TR_CREATE_MODEL "Créer Modèle" +#define TR_DUPLICATE_MODEL "Duplicate Model" #define TR_COPY_MODEL "Copier Modèle" #define TR_MOVE_MODEL "Déplacer Modèle" #define TR_BACKUP_MODEL "Archiver Modèle" @@ -1054,6 +1055,7 @@ #define TR_SCALE "Echelle" #define TR_VIEW_CHANNELS "Voir Voies" #define TR_VIEW_NOTES "Voir Notes" +#define TR_MODEL_SELECT "Model Select" #define TR_MODS_FORBIDDEN "Modifications désactivées!" #define TR_UNLOCKED "Déverrouillé" #define TR_ID "ID" diff --git a/radio/src/translations/it.h.txt b/radio/src/translations/it.h.txt index ac9ce7883..205aab898 100644 --- a/radio/src/translations/it.h.txt +++ b/radio/src/translations/it.h.txt @@ -808,6 +808,7 @@ #define TR_CURRENT TR(INDENT "Corrente",INDENT "Corrente") #define TR_SELECT_MODEL "Scegli Memo." #define TR_CREATE_MODEL "Crea Modello" +#define TR_DUPLICATE_MODEL "Duplicate Model" #define TR_COPY_MODEL "Copia Modello" #define TR_MOVE_MODEL "Sposta Modello" #define TR_BACKUP_MODEL "Salva Modello" @@ -1065,6 +1066,7 @@ #define TR_SCALE "Scala" #define TR_VIEW_CHANNELS "Vedi Canali" #define TR_VIEW_NOTES "Vedi Note" +#define TR_MODEL_SELECT "Model Select" #define TR_MODS_FORBIDDEN "Modifica proibita!" #define TR_UNLOCKED "Sbloccato" #define TR_ID "ID" diff --git a/radio/src/translations/nl.h.txt b/radio/src/translations/nl.h.txt index 6155920dc..ab4fc3eeb 100644 --- a/radio/src/translations/nl.h.txt +++ b/radio/src/translations/nl.h.txt @@ -827,6 +827,7 @@ #define TR_CURRENT TR(INDENT "Stroom", INDENT "Stroombron") #define TR_SELECT_MODEL "Kies Model" #define TR_CREATE_MODEL "Nieuw Model" +#define TR_DUPLICATE_MODEL "Duplicate Model" #define TR_COPY_MODEL "Kopieer Model" #define TR_MOVE_MODEL "Verplaats Model" #define TR_BACKUP_MODEL "Backup Model" @@ -1084,6 +1085,7 @@ #define TR_SCALE "Schaal" #define TR_VIEW_CHANNELS "Toon Kanalen" #define TR_VIEW_NOTES "Toon Notities" +#define TR_MODEL_SELECT "Model Select" #define TR_MODS_FORBIDDEN "Wijzigen niet toegestaan!" #define TR_UNLOCKED "Vrijgegeven" #define TR_ID "ID" diff --git a/radio/src/translations/pl.h.txt b/radio/src/translations/pl.h.txt index ecda92148..4fab82065 100644 --- a/radio/src/translations/pl.h.txt +++ b/radio/src/translations/pl.h.txt @@ -809,6 +809,7 @@ #define TR_CURRENT TR (INDENT"Prąd",INDENT"Źródło Prądu") #define TR_SELECT_MODEL "Wybór modelu" #define TR_CREATE_MODEL "Nowy model" +#define TR_DUPLICATE_MODEL "Duplicate Model" #define TR_COPY_MODEL "Skopiuj model" #define TR_MOVE_MODEL "Przenieś model" #define TR_BACKUP_MODEL "Zbackupuj model" @@ -1066,6 +1067,7 @@ #define TR_SCALE "Skala" #define TR_VIEW_CHANNELS "Pokaż Kanały" #define TR_VIEW_NOTES "Pokaż Notki" +#define TR_MODEL_SELECT "Model Select" #define TR_MODS_FORBIDDEN "Modyfikacje zabronione!" #define TR_UNLOCKED "Odblokowane" #define TR_ID "ID" diff --git a/radio/src/translations/pt.h.txt b/radio/src/translations/pt.h.txt index 024298dd5..5d00d28ee 100644 --- a/radio/src/translations/pt.h.txt +++ b/radio/src/translations/pt.h.txt @@ -760,6 +760,7 @@ #define TR_CURRENT INDENT"Amperes" #define TR_SELECT_MODEL "Selec. Modelo" #define TR_CREATE_MODEL "Criar Modelo" +#define TR_DUPLICATE_MODEL "Duplicate Model" #define TR_COPY_MODEL "Copy Model" #define TR_MOVE_MODEL "Move Model" #define TR_BACKUP_MODEL "Salvar Modelo" @@ -1017,6 +1018,7 @@ #define TR_SCALE "Scale" #define TR_VIEW_CHANNELS "View Channels" #define TR_VIEW_NOTES "View Notes" +#define TR_MODEL_SELECT "Model Select" #define TR_MODS_FORBIDDEN "Modifications forbidden!" #define TR_UNLOCKED "Unlocked" #define TR_ID "ID" diff --git a/radio/src/translations/se.h.txt b/radio/src/translations/se.h.txt index b0b5a9235..b09c9f530 100644 --- a/radio/src/translations/se.h.txt +++ b/radio/src/translations/se.h.txt @@ -760,6 +760,7 @@ #define TR_CURRENT INDENT"Ampere" #define TR_SELECT_MODEL "Välj Modell" #define TR_CREATE_MODEL "Skapa Modell" +#define TR_DUPLICATE_MODEL "Duplicate Model" #define TR_COPY_MODEL "Kopiera Modell" #define TR_MOVE_MODEL "Flytta Modell" #define TR_BACKUP_MODEL "Modell-backup" @@ -1017,6 +1018,7 @@ #define TR_SCALE "Skala" #define TR_VIEW_CHANNELS "Visa Kanaler" #define TR_VIEW_NOTES "Visa Noteringars" +#define TR_MODEL_SELECT "Model Select" #define TR_MODS_FORBIDDEN "Modifikationer förbjudna!" #define TR_UNLOCKED "Olåst" #define TR_ID "ID" diff --git a/radio/util/compile.py b/radio/util/compile.py deleted file mode 100755 index c41dcfd82..000000000 --- a/radio/util/compile.py +++ /dev/null @@ -1,234 +0,0 @@ -#!/usr/bin/env python - -import os, sys, shutil, platform, getpass, subprocess, zipfile, ftplib, httplib, threading - -BINARY_DIR = "../build/" - -options_stock = [[("", "EXT=STD"), ("frsky", "EXT=FRSKY"), ("jeti", "EXT=JETI"), ("ardupilot", "EXT=ARDUPILOT"), ("nmea", "EXT=NMEA")], - [("", "HELI=NO"), ("heli", "HELI=YES")], - [("", "TEMPLATES=NO"), ("templates", "TEMPLATES=YES")], - [("", ""), ("nosplash", "SPLASH=NO")], - [("", ""), ("nofp", "FLIGHT_PHASES=NO")], - [("", "AUDIO=NO"), ("audio", "AUDIO=YES")], - [("", "HAPTIC=NO"), ("haptic", "HAPTIC=YES")], - [("", "PXX=NO"), ("PXX", "PXX=YES")], - [("", "DSM2=NO"), ("DSM2", "DSM2=PPM")], - [("", ""), ("ppmca", "PPM_CENTER_ADJUSTABLE=YES")], - [("", "NAVIGATION=NO"), ("potscroll", "NAVIGATION=POTS")], - [("", ""), ("autoswitch", "AUTOSWITCH=YES")], - [("", ""), ("pgbar", "EEPROM_PROGRESS_BAR=YES")], - [("", "UNITS=METRIC"), ("imperial", "UNITS=IMPERIAL")], - ] - -options_v4 = [[("", "EXT=FRSKY")], - [("", "HELI=NO"), ("heli", "HELI=YES")], - [("", "TEMPLATES=NO"), ("templates", "TEMPLATES=YES")], - [("", ""), ("nofp", "FLIGHT_PHASES=NO")], - [("", "SDCARD=NO"), ("sdcard", "SDCARD=YES")], - [("", "SOMO=NO"), ("SOMO", "SOMO=YES")], - [("", ""), ("ppmca", "PPM_CENTER_ADJUSTABLE=YES")], - [("", ""), ("autoswitch", "AUTOSWITCH=YES")], - [("", ""), ("pgbar", "EEPROM_PROGRESS_BAR=YES")], - [("", "UNITS=METRIC"), ("imperial", "UNITS=IMPERIAL")], - ] - -options_arm = [[("", "EXT=FRSKY")], - [("", "HELI=NO"), ("heli", "HELI=YES")], - [("", "TEMPLATES=NO"), ("templates", "TEMPLATES=YES")], - [("", ""), ("nofp", "FLIGHT_PHASES=NO")], - [("", ""), ("autoswitch", "AUTOSWITCH=YES")], - [("", "UNITS=METRIC"), ("imperial", "UNITS=IMPERIAL")], - ] - -languages = ["en", "fr", "se"] - -#ftp_host = "ftpperso.free.fr" -#ftp_user = "open9x" -ftp_host = "open9x.freehosting.com" -ftp_user = "openxfre" -ftp_directory = "public_html/binaries/" - -def upload(binaries, ext, stamp): - if not ftp: - return - - print "Zip creation..." - zip_name = "release.zip" - zip = zipfile.ZipFile(zip_name, "w", zipfile.ZIP_DEFLATED) - for bin in binaries: - zip.write(BINARY_DIR + bin + "." + ext, bin + "." + ext) - zip.write(BINARY_DIR + stamp, stamp) - zip.close() - - print "FTP transfer..." - ftp_connection = ftplib.FTP(ftp_host, ftp_user, ftp_password) - try: - ftp_connection.delete(ftp_directory + zip_name) - except: - pass - f = open(zip_name, 'rb') - ftp_connection.storbinary('STOR ' + ftp_directory + zip_name, f) - f.close() - ftp_connection.quit() - - print "ZIP extraction...", - http_connection = httplib.HTTPConnection("open9x.freehosting.com") - http_connection.request("GET", "/binaries/uncompress.php") - response = http_connection.getresponse() - print response.status, response.reason - os.remove(zip_name) - -global_current = 0 -global_count = 0 -def generate(hex, arg, extension, options, languages, maxsize): - global global_current - global global_count - - result = [] - states = [0] * len(options) - - count = len(languages) - for option in options: - count *= len(option) - global_count += count - - while 1: - # print index, states - - for language in languages: - hex_file = hex - make_args = ["make", arg] - for i, option in enumerate(options): - state = states[len(options) - 1 - i] - if option[state][0]: - hex_file += "-" + option[state][0] - make_args.append(option[state][1]) - hex_file += "-" + language - make_args.append("TRANSLATIONS=" + language.upper()) - if mt: - cwd = language - else: - cwd = "." - - size = 0 - if compile: - subprocess.Popen(["make", "clean", arg], stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=cwd).wait() - p = subprocess.Popen(make_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=cwd) - ret = p.wait() - stderr = p.stderr.read() - global_current += 1 - print "[%d/%d]" % (global_current, global_count), hex_file - if ret or "error" in stderr: - print stderr - exit() - for line in stderr.split("\n"): - if "warning" in line: - print " ", line - for line in p.stdout.readlines(): - if line.startswith("Program:"): - parts = line.split(" ") - while "" in parts: - parts.remove("") - size = int(parts[1]) - if size > maxsize: - print " ", line[:-1], "[NOT RELEASED]" - else: - print " ", line, - if line.startswith("Data:"): - print " ", line, - - if size <= maxsize: - binary_name = hex_file + "." + extension - if compile: - shutil.copyfile(cwd + "/open9x." + extension, BINARY_DIR + binary_name) - result.append(hex_file) - - for index, state in enumerate(states): - if state < len(options[len(options) - 1 - index]) - 1: - for i in range(index): - states[i] = 0 - states[index] += 1 - break - else: - break - - # stamp - stamp = "stamp-open9x-%s.txt" % hex.split("-")[1] - subprocess.Popen(["make", hex.split("-")[1] + "-stamp"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd="../src").wait() - shutil.copyfile("../src/" + stamp, BINARY_DIR + stamp) - - return result, stamp - -class GenerateThread(threading.Thread): - def __init__ (self, hex, arg, extension, options, language, maxsize): - threading.Thread.__init__(self) - self.hex = hex - self.arg = arg - self.extension = extension - self.options = options - self.language = language - self.maxsize = maxsize - - def run(self): - self.hexes, self.stamp = generate(self.hex, self.arg, self.extension, self.options, [self.language], self.maxsize) - -def multithread_generate(hex, arg, extension, options, languages, maxsize): - if mt: - result = [] - threads = [] - for language in languages: - thread = GenerateThread(hex, arg, extension, options, language, maxsize) - threads.append(thread) - thread.start() - for thread in threads: - thread.join() - result.extend(thread.hexes) - stamp = thread.stamp - return result, stamp - else: - return generate(hex, arg, extension, options, languages, maxsize) - - -def generate_c9x_list(filename, hexes, board): - f = open(filename, "w") - f.write("const char *open9x_%s_binaries[] = {\n" % board) - for hex in hexes: - f.write('"%s",\n' % hex) - f.write("0\n};\n") - -if __name__ == "__main__": - - ftp = "ftp" in sys.argv - mt = "mt" in sys.argv and platform.system() != "Windows" - compile = not "nc" in sys.argv - - if ftp: - ftp_password = getpass.getpass() - - if mt: - shutil.rmtree("util", True) - shutil.copytree("../util", "util") - for lang in languages: - print "Directory %s creation..." % lang - shutil.rmtree(lang, True) - shutil.copytree("../src", lang) - - if platform.system() == "Windows": - # arm board - hexes, stamp = generate("open9x-arm", "PCB=ARM", "bin", options_arm, languages, 262000) - generate_c9x_list("../../companion9x/src/open9x-arm-binaries.cpp", hexes, "arm") - upload(hexes, "bin", stamp) - - else: - # stock board - if not "v4" in sys.argv: - hexes, stamp = multithread_generate("open9x-stock", "PCB=STD", "hex", options_stock, languages, 65530) - generate_c9x_list("../../companion9x/src/open9x-stock-binaries.cpp", hexes, "stock") - upload(hexes, "hex", stamp) - - # v4 board - if not "stock" in sys.argv: - hexes, stamp = multithread_generate("open9x-v4", "PCB=V4", "hex", options_v4, languages, 262000) - generate_c9x_list("../../companion9x/src/open9x-v4-binaries.cpp", hexes, "v4") - upload(hexes, "hex", stamp) - diff --git a/radio/util/font2png.py b/radio/util/font2png.py index 8d23f6806..ef24ac825 100755 --- a/radio/util/font2png.py +++ b/radio/util/font2png.py @@ -2,14 +2,15 @@ # -*- coding: utf-8 -*- import sys -from PyQt4 import Qt, QtGui +from PyQt4 import Qt, QtCore, QtGui +import glob -try: - app = Qt.QApplication(sys.argv) -except: - pass +app = Qt.QApplication(sys.argv) -chars = u""" !"#$%&'()*+,-./0123456789:;<=>?°ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz~ ≥→←↑↓ △Ⓘ""" +for f in glob.glob("fonts/*.ttf"): + QtGui.QFontDatabase.addApplicationFont(f) + +chars = u""" !"#$%&'()*+,-./0123456789:;<=>?°ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz~ ≥→←↑↓↗↘↙↖△""" def getCharWidth(fontsize, metrics, index): if index == 0: @@ -18,21 +19,42 @@ def getCharWidth(fontsize, metrics, index): return 1 else: rect = metrics.boundingRect(chars[index]) - return rect.width() - + if fontsize >= 24: + return rect.width() + 3 + else: + return rect.width() + 1 + +def getFontTopBottom(fontsize, metrics): + top, bottom = 0, 0 + for i, c in enumerate(chars): + rect = metrics.boundingRect(chars[i]) + top = min(top, rect.top()) + bottom = max(bottom, rect.bottom()) + return top, bottom + def getFontWidth(fontsize, metrics): width = 0 for i, c in enumerate(chars): width += getCharWidth(fontsize, metrics, i) return width -def createFontBitmap(filename, fontname, fontsize, foreground, background, coordsfile=True): +def createFontBitmap(filename, fontname, fontsize, fontbold, foreground, background, coordsfile=True): coords = [ ] font = QtGui.QFont(fontname) - font.setPointSize(fontsize) + font.setPixelSize(fontsize) + font.setBold(fontbold) + font.setHintingPreference(QtGui.QFont.PreferNoHinting) + font.setStyleStrategy(QtGui.QFont.PreferAntialias) metrics = QtGui.QFontMetrics(font) + width = getFontWidth(fontsize, metrics) - image = QtGui.QImage(width, fontsize+4, QtGui.QImage.Format_RGB32) + top, bottom = getFontTopBottom(fontsize, metrics) + extraImage = QtGui.QImage("fonts/extra_%dpx.png" % fontsize) + if extraImage.isNull(): + extraWidth = 0 + else: + extraWidth = extraImage.size().width() + image = QtGui.QImage(width + extraWidth, fontsize+2, QtGui.QImage.Format_RGB32) image.fill(background) painter = QtGui.QPainter() painter.begin(image) @@ -48,8 +70,14 @@ def createFontBitmap(filename, fontname, fontsize, foreground, background, coord painter.drawPoint(width, fontsize); else: rect = metrics.boundingRect(c) - painter.drawText(width-rect.left(), fontsize+1, c) + if fontsize >= 24: + painter.drawText(width-rect.left()+1, fontsize-2, c) # fontsize-bottom+1 -17 / 7 + else: + painter.drawText(width-rect.left(), fontsize-1, c) # fontsize-bottom+1 -17 / 7 width += getCharWidth(fontsize, metrics, i) + if extraWidth: + painter.drawImage(QtCore.QPoint(width, 0), extraImage) + coords.append(width) painter.end() image.save(filename + ".png") @@ -57,9 +85,13 @@ def createFontBitmap(filename, fontname, fontsize, foreground, background, coord f = file(filename + ".specs", "w") f.write("{ ") f.write(",".join(str(tmp) for tmp in coords)) + if extraWidth: + for i in range(1, 14): + f.write(", %d" % (int(coords[-1])+i*(extraWidth/12))) + # f.write(file("fonts/extra_%dpx.specs" % fontsize).read()) f.write(" }") f.close() return coords -if len(sys.argv) == 4: - createFontBitmap(sys.argv[3], sys.argv[1], int(sys.argv[2]), QtGui.QColor(0x00, 0x00, 0x00), QtGui.QColor(0xFF, 0xFF, 0xFF)) +if __name__ == "__main__": + createFontBitmap(sys.argv[4], sys.argv[1], float(sys.argv[2]), sys.argv[3] == "True", QtGui.QColor(0x00, 0x00, 0x00), QtGui.QColor(0xFF, 0xFF, 0xFF)) diff --git a/radio/util/img2lbm.py b/radio/util/img2lbm.py index 83e151d98..e02ac7a25 100755 --- a/radio/util/img2lbm.py +++ b/radio/util/img2lbm.py @@ -36,7 +36,7 @@ if what == "1bit": value += 1 << z f.write("0x%02x," % value) f.write("\n") -elif what == "16bits": +elif what == "4/4/4/4": colors = [] f.write("%d,%d,\n" % (width, height)) for y in range(height): @@ -44,6 +44,16 @@ elif what == "16bits": pixel = image.pixel(x, y) f.write("0x%1x%1x%1x%1x," % (Qt.qAlpha(pixel)/16, Qt.qRed(pixel)/16, Qt.qGreen(pixel)/16, Qt.qBlue(pixel)/16)) f.write("\n") +elif what == "5/6/5/8": + colors = [] + writeSize(f, width, height) + for y in range(height): + for x in range(width): + pixel = image.pixel(x, y) + val = ((Qt.qRed(pixel) >> 3) << 11) + ((Qt.qGreen(pixel) >> 2) << 5) + ((Qt.qBlue(pixel) >> 3) << 0) + # f.write("%d,%d,%d," % (val%256, val/256, Qt.qAlpha(pixel) >> 4)) + f.write("%d,%d," % (val%256, val/256)) + f.write("\n") elif what == "4bits": colors = [] writeSize(f, width, height) @@ -62,6 +72,15 @@ elif what == "4bits": value -= 1<<(4+i) f.write("0x%02x," % value) f.write("\n") +elif what == "8bits": + colors = [] + writeSize(f, width, height) + for y in range(height): + for x in range(width): + value = Qt.qGray(image.pixel(x, y)) + value = 0x0f - (value >> 4) + f.write("0x%02x," % value) + f.write("\n") elif what == "03x05": for y in range(0, height, 5): for x in range(width):