From 995888ae41ca1ca03be47c9673a850f8a1874ed5 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Wed, 14 Aug 2019 23:37:08 +0200 Subject: [PATCH 1/7] Add support for pwr-on and power-off speed --- companion/src/firmwares/eeprominterface.h | 3 +- companion/src/firmwares/generalsettings.h | 3 + .../src/firmwares/opentx/opentxeeprom.cpp | 11 +- .../src/firmwares/opentx/opentxinterface.cpp | 2 + companion/src/generaledit/generalsetup.cpp | 25 + companion/src/generaledit/generalsetup.h | 2 + companion/src/generaledit/generalsetup.ui | 1452 +++++++++-------- radio/src/datastructs.h | 9 +- radio/src/gui/128x64/radio_setup.cpp | 19 +- radio/src/gui/128x64/startup_shutdown.cpp | 14 +- radio/src/gui/212x64/radio_setup.cpp | 18 + radio/src/gui/212x64/startup_shutdown.cpp | 14 +- radio/src/gui/480x272/radio_setup.cpp | 9 + radio/src/gui/480x272/widgets.cpp | 8 +- radio/src/gui/480x272/widgets.h | 2 +- radio/src/gui/common/stdlcd/draw_functions.h | 4 +- radio/src/opentx.cpp | 24 +- radio/src/opentx.h | 8 +- .../common/arm/stm32/bootloader/boot.cpp | 11 + radio/src/translations.cpp | 2 + radio/src/translations.h | 4 + radio/src/translations/cz.h.txt | 2 + radio/src/translations/de.h.txt | 2 + radio/src/translations/en.h.txt | 2 + radio/src/translations/es.h.txt | 2 + radio/src/translations/fi.h.txt | 2 + radio/src/translations/fr.h.txt | 2 + radio/src/translations/it.h.txt | 2 + radio/src/translations/nl.h.txt | 2 + radio/src/translations/pl.h.txt | 2 + radio/src/translations/pt.h.txt | 2 + radio/src/translations/se.h.txt | 2 + 32 files changed, 927 insertions(+), 739 deletions(-) diff --git a/companion/src/firmwares/eeprominterface.h b/companion/src/firmwares/eeprominterface.h index e8da6274d..b562f50e9 100644 --- a/companion/src/firmwares/eeprominterface.h +++ b/companion/src/firmwares/eeprominterface.h @@ -148,7 +148,8 @@ enum Capability { HasBatMeterRange, DangerousFunctions, HasModelCategories, - HasSwitchableJack + HasSwitchableJack, + PwrButtonPress }; class EEPROMInterface diff --git a/companion/src/firmwares/generalsettings.h b/companion/src/firmwares/generalsettings.h index 1bb9217dc..25e300628 100644 --- a/companion/src/firmwares/generalsettings.h +++ b/companion/src/firmwares/generalsettings.h @@ -170,6 +170,9 @@ class GeneralSettings { int gyroMax; int gyroOffset; + unsigned int pwrOnSpeed; + unsigned int pwrOffSpeed; + bool switchPositionAllowedTaranis(int index) const; bool switchSourceAllowedTaranis(int index) const; bool isPotAvailable(int index) const; diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index c990b6c89..8196533f2 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -2404,7 +2404,16 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, Board::Type if (version < 218) internalField.Append(new UnsignedField<8>(this, generalData.rotarySteps)); - internalField.Append(new UnsignedField<8>(this, generalData.countryCode)); + internalField.Append(new UnsignedField<2>(this, generalData.countryCode)); + + if (version >= 219 && IS_HORUS_OR_TARANIS(board)) { + internalField.Append(new UnsignedField<2>(this, generalData.pwrOnSpeed, "Power On Speed")); + internalField.Append(new UnsignedField<4>(this, generalData.pwrOffSpeed, "Power Off Speed")); + } + else { + internalField.Append(new SpareBitsField<6>(this)); + } + internalField.Append(new UnsignedField<1>(this, generalData.imperial)); if (version >= 218) { internalField.Append(new BoolField<1>(this, generalData.jitterFilter)); diff --git a/companion/src/firmwares/opentx/opentxinterface.cpp b/companion/src/firmwares/opentx/opentxinterface.cpp index 437dc4b16..72483c506 100644 --- a/companion/src/firmwares/opentx/opentxinterface.cpp +++ b/companion/src/firmwares/opentx/opentxinterface.cpp @@ -734,6 +734,8 @@ int OpenTxFirmware::getCapability(::Capability capability) return IS_HORUS(board); case HasSwitchableJack: return IS_TARANIS_XLITES(board); + case PwrButtonPress: + return IS_HORUS_OR_TARANIS(board) && (board!=Board::BOARD_TARANIS_X9D) && (board!=Board::BOARD_TARANIS_X9DP); default: return 0; } diff --git a/companion/src/generaledit/generalsetup.cpp b/companion/src/generaledit/generalsetup.cpp index b6bf20711..b96306af3 100644 --- a/companion/src/generaledit/generalsetup.cpp +++ b/companion/src/generaledit/generalsetup.cpp @@ -255,6 +255,17 @@ ui(new Ui::GeneralSetup) ui->splashScreenChkB->setChecked(!generalSettings.splashMode); } + if (!firmware->getCapability(PwrButtonPress)) { + ui->pwrOnSpeedLabel->hide(); + ui->pwrOnSpeed->hide(); + ui->pwrOffSpeedLabel->hide(); + ui->pwrOffSpeed->hide(); + } + else if (!IS_TARANIS(firmware->getBoard())) { + ui->pwrOnSpeedLabel->hide(); + ui->pwrOnSpeed->hide(); + } + setValues(); lock = false; @@ -441,6 +452,9 @@ void GeneralSetupPanel::setValues() ui->vBatMinDSB->setValue((double)(generalSettings.vBatMin + 90) / 10); ui->vBatMaxDSB->setValue((double)(generalSettings.vBatMax + 120) / 10); } + + ui->pwrOnSpeed->setValue(generalSettings.pwrOnSpeed); + ui->pwrOffSpeed->setValue(generalSettings.pwrOffSpeed); } void GeneralSetupPanel::on_faimode_CB_stateChanged(int) @@ -493,6 +507,17 @@ void GeneralSetupPanel::on_splashScreenDuration_currentIndexChanged(int index) emit modified(); } +void GeneralSetupPanel::on_pwrOnSpeed_valueChanged() +{ + generalSettings.pwrOnSpeed = ui->pwrOnSpeed->value(); + emit modified(); +} + +void GeneralSetupPanel::on_pwrOffSpeed_valueChanged() +{ + generalSettings.pwrOffSpeed = ui->pwrOffSpeed->value(); + emit modified(); +} void GeneralSetupPanel::on_beepVolume_SL_valueChanged() { diff --git a/companion/src/generaledit/generalsetup.h b/companion/src/generaledit/generalsetup.h index d3f800714..9dc636768 100644 --- a/companion/src/generaledit/generalsetup.h +++ b/companion/src/generaledit/generalsetup.h @@ -88,6 +88,8 @@ class GeneralSetupPanel : public GeneralPanel void on_vBatMaxDSB_editingFinished(); void on_contrastSB_editingFinished(); + void on_pwrOnSpeed_valueChanged(); + void on_pwrOffSpeed_valueChanged(); private: Ui::GeneralSetup *ui; diff --git a/companion/src/generaledit/generalsetup.ui b/companion/src/generaledit/generalsetup.ui index a6e09c95a..9378b2dc0 100644 --- a/companion/src/generaledit/generalsetup.ui +++ b/companion/src/generaledit/generalsetup.ui @@ -7,7 +7,7 @@ 0 0 809 - 801 + 880 @@ -29,10 +29,10 @@ QLayout::SetMinimumSize - + 0 - + 0 @@ -1121,7 +1121,65 @@ p, li { white-space: pre-wrap; } QLayout::SetDefaultConstraint - + + + + + 0 + 0 + + + + + 0 + 0 + + + + + + + Contrast + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + Quiet + + + + + Only Alarms + + + + + No Keys + + + + + All + + + + + GPS Coordinates @@ -1129,7 +1187,52 @@ p, li { white-space: pre-wrap; } - + + + + Metric + + + + + Imperial + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + "No Sound" Warning + + + + + + + + 0 + 0 + + + + + 0 + 22 + + @@ -1137,93 +1240,17 @@ p, li { white-space: pre-wrap; } - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">LCD Screen Contrast</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Values can be 20-45</span></p></body></html> + If not zero will sound beeps if the transmitter has been left without inputs for the specified number of minutes. - ms - - - 0 + min - 1000 - - - 10 - - - 0 + 120 - - - - - - Min - - - - - - - v - - - 1 - - - 4.000000000000000 - - - 16.000000000000000 - - - 0.100000000000000 - - - 9.000000000000000 - - - - - - - Max - - - - - - - v - - - 1 - - - 4.000000000000000 - - - 16.000000000000000 - - - 0.100000000000000 - - - 12.000000000000000 - - - - - - + @@ -1277,41 +1304,26 @@ Mode 4: - - - - Stick Mode - - - - - + + - + 0 0 + + + 0 + 0 + + - Default Channel Order + LCD Display Type - - - - - Metric - - - - - Imperial - - - - - + @@ -1447,45 +1459,253 @@ Mode 4: - - - - - Ask on Connect - - - - - Joystick (HID) - - - - - USB Mass Storage - - - - - USB Serial (CDC) - - - - - - - - USB Mode - - - - - + + - + 0 0 + + Play Delay (switch mid position) + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + + + + + + Battery warning voltage. +This is the threashhold where the battery warning sounds. + +Acceptable values are 5v..10v + + + + + + V + + + 1 + + + 4.000000000000000 + + + 12.000000000000000 + + + 0.100000000000000 + + + 9.600000000000000 + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + -2 + + + 2 + + + 1 + + + Qt::Horizontal + + + + + + + Power On Speed + + + + + + + Jack Mode + + + + + + + + 0 + 0 + + + + MAVLink Baud Rate + + + + + + + + 0 + 0 + + + + Default Channel Order + + + + + + + + 0 + 0 + + + + + 20 + 0 + + + + + + + Battery Warning + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Haptic Strength + + + + + + + + + Min + + + + + + + v + + + 1 + + + 4.000000000000000 + + + 16.000000000000000 + + + 0.100000000000000 + + + 9.000000000000000 + + + + + + + Max + + + + + + + v + + + 1 + + + 4.000000000000000 + + + 16.000000000000000 + + + 0.100000000000000 + + + 12.000000000000000 + + + + + + + + + + 0 + 0 + + + + + 0 + 22 + + 16777215 @@ -1513,25 +1733,6 @@ p, li { white-space: pre-wrap; } - - - - - 0 - 0 - - - - - 0 - 0 - - - - RSSI Poweroff Warning - - - @@ -1551,57 +1752,6 @@ p, li { white-space: pre-wrap; } - - - - - 0 - 0 - - - - - 0 - 22 - - - - - - - - - - Beeper volume - -0 - Quiet. No beeps at all. -1 - No Keys. Normal beeps but menu keys do not beep. -2 - Normal. -3 - Loud. -4 - Extra loud. - - - - Quiet - - - - - Alarms Only - - - - - No Keys - - - - - All - - - - @@ -1643,252 +1793,6 @@ p, li { white-space: pre-wrap; } - - - - - 0 - 0 - - - - - 0 - 0 - - - - Beeper Mode - - - - - - - Measurement Units - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Haptic Mode - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - 0 - 0 - - - - Play Delay (switch mid position) - - - - - - - - 4800 Baud - - - - - 9600 Baud - - - - - 14400 Baud - - - - - 19200 Baud - - - - - 38400 Baud - - - - - 57600 Baud - - - - - 76800 Baud - - - - - 115200 Baud - - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - X-Short - - - - - Short - - - - - Normal - - - - - Long - - - - - X-Long - - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - 16777215 - 16777215 - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" text-decoration: underline;">Warnings</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">These will define startup warnings.</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Throttle warning - will alert if the throttle is not at idle during startup</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Switch warning - will alert if switches are not in their defaul position</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Memory warning - will alert if there's not a lot of memory left</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Silent mode warning - will alert you if the beeper is set to quiet (0)</p></body></html> - - - - - - true - - - - - - - - DMS - - - - - NMEA - - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" text-decoration: underline;">Warnings</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">These will define startup warnings.</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Throttle warning - will alert if the throttle is not at idle during startup</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Switch warning - will alert if switches are not in their defaul position</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Memory warning - will alert if there's not a lot of memory left</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Silent mode warning - will alert you if the beeper is set to quiet (0)</p></body></html> - - - - - - true - - - @@ -1968,8 +1872,8 @@ p, li { white-space: pre-wrap; } - - + + 0 @@ -1979,48 +1883,86 @@ p, li { white-space: pre-wrap; } 0 - 22 + 0 - - - - - - - - If not zero will sound beeps if the transmitter has been left without inputs for the specified number of minutes. - - - min - - - 120 + + Inactivity Timer - - - - - 0 - 0 - + + + + Qt::Vertical - + - 0 - 22 + 20 + 40 + + + + - Standard + Ask on Connect - Optrex + Audio + + + + + Trainer + + + + + + + + + 4800 Baud + + + + + 9600 Baud + + + + + 14400 Baud + + + + + 19200 Baud + + + + + 38400 Baud + + + + + 57600 Baud + + + + + 76800 Baud + + + + + 115200 Baud @@ -2059,171 +2001,18 @@ p, li { white-space: pre-wrap; } - - - - - 0 - 0 - - - - - 0 - 22 - - - - - - - - - - Battery warning voltage. -This is the threashhold where the battery warning sounds. - -Acceptable values are 5v..10v - - - - - - V - - - 1 - - - 4.000000000000000 - - - 12.000000000000000 - - - 0.100000000000000 - - - 9.600000000000000 - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - -2 - - - 2 - - - 1 - - - Qt::Horizontal - - - - - - - - 0 - 0 - - - - - 0 - 22 - - + + - Quiet + DMS - Only Alarms + NMEA - - - No Keys - - - - - All - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - "No Sound" Warning - - - - - - - - 0 - 0 - - - - MAVLink Baud Rate - - - - - - - - 0 - 0 - - - - - 20 - 0 - - - - - - - Battery Warning - @@ -2245,8 +2034,8 @@ Acceptable values are 5v..10v - - + + 0 @@ -2260,7 +2049,42 @@ Acceptable values are 5v..10v - LCD Display Type + Beeper Mode + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" text-decoration: underline;">Warnings</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">These will define startup warnings.</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Throttle warning - will alert if the throttle is not at idle during startup</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Switch warning - will alert if switches are not in their defaul position</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Memory warning - will alert if there's not a lot of memory left</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Silent mode warning - will alert you if the beeper is set to quiet (0)</p></body></html> + + + + + + true @@ -2283,45 +2107,42 @@ Acceptable values are 5v..10v - - + + - + 0 0 - + - 0 - 0 + 16777215 + 16777215 + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" text-decoration: underline;">Warnings</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">These will define startup warnings.</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Throttle warning - will alert if the throttle is not at idle during startup</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Switch warning - will alert if switches are not in their defaul position</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Memory warning - will alert if there's not a lot of memory left</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Silent mode warning - will alert you if the beeper is set to quiet (0)</p></body></html> + - Haptic Strength + + + + true - - - - - 0 - 0 - - - - - 0 - 0 - - - - Inactivity Timer - - - - + @@ -2340,6 +2161,162 @@ Acceptable values are 5v..10v + + + + + 0 + 0 + + + + + 0 + 0 + + + + RSSI Poweroff Warning + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Haptic Mode + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + Standard + + + + + Optrex + + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + X-Short + + + + + Short + + + + + Normal + + + + + Long + + + + + X-Long + + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + + + + + + Beeper volume + +0 - Quiet. No beeps at all. +1 - No Keys. Normal beeps but menu keys do not beep. +2 - Normal. +3 - Loud. +4 - Extra loud. + + + + Quiet + + + + + Alarms Only + + + + + No Keys + + + + + All + + + + @@ -2359,37 +2336,55 @@ Acceptable values are 5v..10v - - - - - 0 - 0 - - - - - 0 - 0 - - - - - - - Contrast - - - - - - - Jack Mode - - - - + + + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">LCD Screen Contrast</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Values can be 20-45</span></p></body></html> + + + ms + + + 0 + + + 1000 + + + 10 + + + 0 + + + + + + + Stick Mode + + + + + + + USB Mode + + + + + Ask on Connect @@ -2397,14 +2392,53 @@ Acceptable values are 5v..10v - Audio + Joystick (HID) - Trainer + USB Mass Storage + + + USB Serial (CDC) + + + + + + + + Measurement Units + + + + + + + Power Off Speed + + + + + + + 3 + + + Qt::Horizontal + + + + + + + 3 + + + Qt::Horizontal + diff --git a/radio/src/datastructs.h b/radio/src/datastructs.h index ae9cae750..8fe3c6ca6 100644 --- a/radio/src/datastructs.h +++ b/radio/src/datastructs.h @@ -771,7 +771,14 @@ PACK(struct RadioData { NOBACKUP(uint32_t globalTimer); NOBACKUP(uint8_t bluetoothBaudrate:4); NOBACKUP(uint8_t bluetoothMode:4); - NOBACKUP(uint8_t countryCode); + NOBACKUP(uint8_t countryCode:2); +#if defined(PCBHORUS) || defined(PCBTARANIS) + NOBACKUP(uint8_t pwrOnSpeed:2); + NOBACKUP(uint8_t pwrOffSpeed:2); + NOBACKUP(uint8_t spareCC:2); +#else + NOBACKUP(uint8_t spareCC:6); +#endif NOBACKUP(uint8_t imperial:1); NOBACKUP(uint8_t jitterFilter:1); /* 0 - active */ NOBACKUP(uint8_t disableRssiPoweroffAlarm:1); diff --git a/radio/src/gui/128x64/radio_setup.cpp b/radio/src/gui/128x64/radio_setup.cpp index cb565816e..eef530c53 100644 --- a/radio/src/gui/128x64/radio_setup.cpp +++ b/radio/src/gui/128x64/radio_setup.cpp @@ -87,6 +87,8 @@ enum { CASE_PWM_BACKLIGHT(ITEM_RADIO_SETUP_BACKLIGHT_BRIGHTNESS_ON) ITEM_RADIO_SETUP_FLASH_BEEP, CASE_SPLASH_PARAM(ITEM_RADIO_SETUP_DISABLE_SPLASH) + CASE_PWR_BUTTON_PRESS(ITEM_RADIO_SETUP_PWR_ON_SPEED) + CASE_PWR_BUTTON_PRESS(ITEM_RADIO_SETUP_PWR_OFF_SPEED) CASE_PXX2(ITEM_RADIO_SETUP_OWNER_ID) CASE_GPS(ITEM_RADIO_SETUP_TIMEZONE) ITEM_RADIO_SETUP_ADJUST_RTC, @@ -155,7 +157,8 @@ void menuRadioSetup(event_t event) CASE_PWM_BACKLIGHT(0) 0, CASE_SPLASH_PARAM(0) - + CASE_PWR_BUTTON_PRESS(0) + CASE_PWR_BUTTON_PRESS(0) CASE_PXX2(0) /* owner registration ID */ CASE_GPS(0) @@ -506,6 +509,20 @@ void menuRadioSetup(event_t event) } #endif +#if defined(PWR_BUTTON_PRESS) + case ITEM_RADIO_SETUP_PWR_ON_SPEED: + lcdDrawTextAlignedLeft(y, STR_PWR_ON_SPEED); + lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.pwrOnSpeed, attr|LEFT); + if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.pwrOnSpeed, 0, 3); + break; + + case ITEM_RADIO_SETUP_PWR_OFF_SPEED: + lcdDrawTextAlignedLeft(y, STR_PWR_OFF_SPEED); + lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.pwrOffSpeed, attr|LEFT); + if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.pwrOffSpeed, 0, 3); + break; +#endif + #if defined(PXX2) case ITEM_RADIO_SETUP_OWNER_ID: editSingleName(RADIO_SETUP_2ND_COLUMN, y, STR_OWNER_ID, g_eeGeneral.ownerRegistrationID, PXX2_LEN_REGISTRATION_ID, event, attr); diff --git a/radio/src/gui/128x64/startup_shutdown.cpp b/radio/src/gui/128x64/startup_shutdown.cpp index bc4d82c35..2b0a2e617 100644 --- a/radio/src/gui/128x64/startup_shutdown.cpp +++ b/radio/src/gui/128x64/startup_shutdown.cpp @@ -20,8 +20,6 @@ #include "opentx.h" -#define PWR_PRESS_DURATION_MIN 100 // 1s -#define PWR_PRESS_DURATION_MAX 500 // 5s #define SLEEP_BITMAP_WIDTH 60 #define SLEEP_BITMAP_HEIGHT 60 @@ -30,9 +28,11 @@ const unsigned char bmp_sleep[] = { #include "sleep.lbm" }; -void drawStartupAnimation(uint32_t duration) +void drawStartupAnimation(uint32_t duration, uint32_t total_duration) { - uint8_t index = limit(0, duration / (PWR_PRESS_DURATION_MIN / 5), 4); + if (total_duration == 0) return; + + uint8_t index = limit(0, duration / (total_duration / 5), 4); lcdRefreshWait(); lcdClear(); @@ -47,9 +47,11 @@ void drawStartupAnimation(uint32_t duration) lcdRefreshWait(); } -void drawShutdownAnimation(uint32_t duration, const char * message) +void drawShutdownAnimation(uint32_t duration, uint32_t total_duration, const char * message) { - uint8_t index = limit(0, duration / (PWR_PRESS_SHUTDOWN_DELAY / 5), 4); + if (total_duration == 0) return; + + uint8_t index = limit(0, duration / (total_duration / 5), 4); lcdRefreshWait(); lcdClear(); diff --git a/radio/src/gui/212x64/radio_setup.cpp b/radio/src/gui/212x64/radio_setup.cpp index b04c92468..edf3459e1 100644 --- a/radio/src/gui/212x64/radio_setup.cpp +++ b/radio/src/gui/212x64/radio_setup.cpp @@ -78,6 +78,8 @@ enum MenuRadioSetupItems { CASE_PCBX9E_PCBX9DP(ITEM_RADIO_SETUP_BACKLIGHT_COLOR) ITEM_RADIO_SETUP_FLASH_BEEP, CASE_SPLASH_PARAM(ITEM_RADIO_SETUP_DISABLE_SPLASH) + CASE_PWR_BUTTON_PRESS(ITEM_RADIO_SETUP_PWR_ON_SPEED) + CASE_PWR_BUTTON_PRESS(ITEM_RADIO_SETUP_PWR_OFF_SPEED) #if defined(PXX2) ITEM_RADIO_SETUP_OWNER_ID, #endif @@ -155,6 +157,8 @@ void menuRadioSetup(event_t event) CASE_PCBX9E_PCBX9DP(0) // backlight color 0, // flash beep CASE_SPLASH_PARAM(0) // disable splash + CASE_PWR_BUTTON_PRESS(0) // pwr on speed + CASE_PWR_BUTTON_PRESS(0) // pwr off speed CASE_PXX2(0) CASE_GPS(LABEL(GPS)) CASE_GPS(0) // timezone @@ -466,6 +470,20 @@ void menuRadioSetup(event_t event) break; #endif +#if defined(PWR_BUTTON_PRESS) + case ITEM_RADIO_SETUP_PWR_ON_SPEED: + lcdDrawTextAlignedLeft(y, STR_PWR_ON_SPEED); + lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.pwrOnSpeed, attr|LEFT); + if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.pwrOnSpeed, 0, 3); + break; + + case ITEM_RADIO_SETUP_PWR_OFF_SPEED: + lcdDrawTextAlignedLeft(y, STR_PWR_OFF_SPEED); + lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.pwrOffSpeed, attr|LEFT); + if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.pwrOffSpeed, 0, 3); + break; +#endif + #if defined(TELEMETRY_FRSKY) && defined(GPS) case ITEM_RADIO_SETUP_LABEL_GPS: lcdDrawTextAlignedLeft(y, STR_GPS); diff --git a/radio/src/gui/212x64/startup_shutdown.cpp b/radio/src/gui/212x64/startup_shutdown.cpp index ac4c2a186..91c81f471 100644 --- a/radio/src/gui/212x64/startup_shutdown.cpp +++ b/radio/src/gui/212x64/startup_shutdown.cpp @@ -20,8 +20,6 @@ #include "opentx.h" -#define PWR_PRESS_DURATION_MIN 100 // 1s -#define PWR_PRESS_DURATION_MAX 500 // 5s #define ANIMATIONS_BITMAP_WIDTH 60 #define ANIMATIONS_BITMAP_HEIGHT 60 @@ -42,9 +40,11 @@ const unsigned char bmp_sleep[] = { #include "sleep.lbm" }; -void drawStartupAnimation(uint32_t duration) +void drawStartupAnimation(uint32_t duration, uint32_t total_duration) { - uint8_t index = limit(0, duration / (PWR_PRESS_DURATION_MIN / 5), 4); + if (total_duration == 0) return; + + uint8_t index = limit(0, duration / (total_duration / 5), 4); lcdRefreshWait(); lcdClear(); @@ -57,9 +57,11 @@ void drawStartupAnimation(uint32_t duration) lcdRefresh(); } -void drawShutdownAnimation(uint32_t duration, const char * message) +void drawShutdownAnimation(uint32_t duration, uint32_t total_duration, const char * message) { - uint8_t index = limit(0, duration / (PWR_PRESS_SHUTDOWN_DELAY / 4), 3); + if (total_duration == 0) return; + + uint8_t index = limit(0, duration / (total_duration / 4), 3); lcdRefreshWait(); lcdClear(); diff --git a/radio/src/gui/480x272/radio_setup.cpp b/radio/src/gui/480x272/radio_setup.cpp index 98da1577e..4e679c909 100644 --- a/radio/src/gui/480x272/radio_setup.cpp +++ b/radio/src/gui/480x272/radio_setup.cpp @@ -66,6 +66,7 @@ enum menuRadioSetupItems { ITEM_SETUP_BRIGHTNESS, ITEM_SETUP_DIM_LEVEL, ITEM_SETUP_FLASH_BEEP, + CASE_PWR_BUTTON_PRESS(ITEM_SETUP_PWR_OFF_SPEED) CASE_GPS(ITEM_SETUP_LABEL_GPS) CASE_GPS(ITEM_SETUP_TIMEZONE) CASE_GPS(ITEM_SETUP_ADJUST_RTC) @@ -114,6 +115,7 @@ bool menuRadioSetup(event_t event) CASE_HAPTIC(LABEL(HAPTIC)) CASE_HAPTIC(0) CASE_HAPTIC(0) CASE_HAPTIC(0) LABEL(ALARMS), 0, 0, 0, 0, LABEL(BACKLIGHT), 0, 0, 0, 0, 0, + CASE_PWR_BUTTON_PRESS(0) CASE_GPS(LABEL(GPS)) CASE_GPS(0) CASE_GPS(0) CASE_GPS(0) CASE_PXX1(0) 0, 0, FAI_CHOICE_ROW 0, 0, 0, 0, 1/*to force edit mode*/ }); // Country code - Voice Language - Units - Fai choice - Play delay - USB mode - Chan order - Mode (1 to 4) @@ -380,6 +382,13 @@ bool menuRadioSetup(event_t event) g_eeGeneral.blOffBright = editSlider(RADIO_SETUP_2ND_COLUMN, y, event, g_eeGeneral.blOffBright, BACKLIGHT_LEVEL_MIN, BACKLIGHT_LEVEL_MAX, attr); break; +#if defined(PWR_BUTTON_PRESS) + case ITEM_SETUP_PWR_OFF_SPEED: + lcdDrawText(MENUS_MARGIN_LEFT, y, STR_PWR_OFF_SPEED); + g_eeGeneral.pwrOffSpeed = editSlider(RADIO_SETUP_2ND_COLUMN, y, event, g_eeGeneral.pwrOffSpeed, 0, 3, attr); + break; +#endif + case ITEM_SETUP_LABEL_GPS: lcdDrawText(MENUS_MARGIN_LEFT, y, STR_GPS); break; diff --git a/radio/src/gui/480x272/widgets.cpp b/radio/src/gui/480x272/widgets.cpp index fe21563b0..d95d813bd 100644 --- a/radio/src/gui/480x272/widgets.cpp +++ b/radio/src/gui/480x272/widgets.cpp @@ -391,8 +391,10 @@ void drawSleepBitmap() } #define SHUTDOWN_CIRCLE_DIAMETER 150 -void drawShutdownAnimation(uint32_t duration, const char * message) +void drawShutdownAnimation(uint32_t duration, uint32_t total_duration, const char * message) { + if (total_duration == 0) return; + static uint32_t lastDuration = 0xffffffff; static const BitmapBuffer * shutdown = BitmapBuffer::load(getThemePath("shutdown.bmp")); @@ -404,7 +406,7 @@ void drawShutdownAnimation(uint32_t duration, const char * message) } else { lcdRestoreBackupBuffer(); - int quarter = duration / (PWR_PRESS_SHUTDOWN_DELAY / 5); + int quarter = duration / (total_duration / 5); if (quarter >= 1) lcdDrawBitmapPattern(LCD_W/2, (LCD_H-SHUTDOWN_CIRCLE_DIAMETER)/2, LBM_SHUTDOWN_CIRCLE, TEXT_COLOR, 0, SHUTDOWN_CIRCLE_DIAMETER/2); if (quarter >= 2) lcdDrawBitmapPattern(LCD_W/2, LCD_H/2, LBM_SHUTDOWN_CIRCLE, TEXT_COLOR, SHUTDOWN_CIRCLE_DIAMETER/2, SHUTDOWN_CIRCLE_DIAMETER/2); if (quarter >= 3) lcdDrawBitmapPattern((LCD_W-SHUTDOWN_CIRCLE_DIAMETER)/2, LCD_H/2, LBM_SHUTDOWN_CIRCLE, TEXT_COLOR, SHUTDOWN_CIRCLE_DIAMETER, SHUTDOWN_CIRCLE_DIAMETER/2); @@ -413,7 +415,7 @@ void drawShutdownAnimation(uint32_t duration, const char * message) } else { lcd->clear(); - int quarter = duration / (PWR_PRESS_SHUTDOWN_DELAY / 5); + int quarter = duration / (total_duration / 5); for (int i=1; i<=4; i++) { if (quarter >= i) { lcd->drawSolidFilledRect(LCD_W / 2 - 70 + 24 * i, LCD_H / 2 - 10, 20, 20, TEXT_BGCOLOR); diff --git a/radio/src/gui/480x272/widgets.h b/radio/src/gui/480x272/widgets.h index 5b10e88fb..b7f65e417 100644 --- a/radio/src/gui/480x272/widgets.h +++ b/radio/src/gui/480x272/widgets.h @@ -69,7 +69,7 @@ int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min, int void drawMenuTemplate(const char * title, uint8_t icon, const uint8_t * icons=nullptr, uint32_t options=0); void drawSplash(); void drawSleepBitmap(); -void drawShutdownAnimation(uint32_t duration, const char * message); +void drawShutdownAnimation(uint32_t duration, uint32_t total_duration, const char * message); // Main view standard widgets void drawTopBar(); diff --git a/radio/src/gui/common/stdlcd/draw_functions.h b/radio/src/gui/common/stdlcd/draw_functions.h index 6476289e7..cf0f4e25e 100644 --- a/radio/src/gui/common/stdlcd/draw_functions.h +++ b/radio/src/gui/common/stdlcd/draw_functions.h @@ -36,8 +36,8 @@ inline void drawTimer(coord_t x, coord_t y, int32_t tme, LcdFlags att = 0) drawTimer(x, y, tme, att, att); } -void drawStartupAnimation(uint32_t duration); -void drawShutdownAnimation(uint32_t duration, const char * message); +void drawStartupAnimation(uint32_t duration, uint32_t total_duration); +void drawShutdownAnimation(uint32_t duration, uint32_t total_duration, const char * message); void drawSleepBitmap(); #endif // _COMMON_DRAW_FUNCTIONS_H_ diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index d8067b4b1..92100ee6b 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -1728,8 +1728,17 @@ void copyTrimsToOffset(uint8_t ch) storageDirty(EE_MODEL); } + +const uint8_t _pwrOnOffDuration_lookup[] = { + 200, // 2s + 100, // 1s + 50, // 0.5s + 0, // none +}; + #if defined(STARTUP_ANIMATION) -#define PWR_PRESS_DURATION_MIN 100 // 1s + +#define PWR_PRESS_DURATION_MIN() (_pwrOnOffDuration_lookup[g_eeGeneral.pwrOnSpeed & 3]) #define PWR_PRESS_DURATION_MAX 500 // 5s void runStartupAnimation() @@ -1740,8 +1749,8 @@ void runStartupAnimation() while (pwrPressed()) { duration = get_tmr10ms() - start; - if (duration < PWR_PRESS_DURATION_MIN) { - drawStartupAnimation(duration); + if (duration < PWR_PRESS_DURATION_MIN()) { + drawStartupAnimation(duration, PWR_PRESS_DURATION_MIN()); } else if (duration >= PWR_PRESS_DURATION_MAX) { drawSleepBitmap(); @@ -1754,7 +1763,7 @@ void runStartupAnimation() } } - if (duration < PWR_PRESS_DURATION_MIN || duration >= PWR_PRESS_DURATION_MAX) { + if (duration < PWR_PRESS_DURATION_MIN() || duration >= PWR_PRESS_DURATION_MAX) { boardOff(); } } @@ -2025,6 +2034,9 @@ int main() #if !defined(SIMU) #if defined(PWR_BUTTON_PRESS) + +#define PWR_PRESS_SHUTDOWN_DELAY() (_pwrOnOffDuration_lookup[g_eeGeneral.pwrOffSpeed & 3]) + uint32_t pwr_press_time = 0; uint32_t pwrPressedDuration() @@ -2070,7 +2082,7 @@ uint32_t pwrCheck() if (g_eeGeneral.backlightMode != e_backlight_mode_off) { BACKLIGHT_ENABLE(); } - if (get_tmr10ms() - pwr_press_time > PWR_PRESS_SHUTDOWN_DELAY) { + if (get_tmr10ms() - pwr_press_time > (uint32_t)PWR_PRESS_SHUTDOWN_DELAY()) { #if defined(SHUTDOWN_CONFIRMATION) while (1) { #else @@ -2100,7 +2112,7 @@ uint32_t pwrCheck() return e_power_off; } else { - drawShutdownAnimation(pwrPressedDuration(), message); + drawShutdownAnimation(pwrPressedDuration(), PWR_PRESS_SHUTDOWN_DELAY(), message); return e_power_press; } } diff --git a/radio/src/opentx.h b/radio/src/opentx.h index f53dd9c36..c31498d41 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -127,6 +127,12 @@ #define CASE_SPLASH(x) #endif +#if defined(PWR_BUTTON_PRESS) + #define CASE_PWR_BUTTON_PRESS(x) x, +#else + #define CASE_PWR_BUTTON_PRESS(x) +#endif + #if defined(TELEMETRY_FRSKY) #define CASE_FRSKY(x) x, #else @@ -293,8 +299,6 @@ void memswap(void * a, void * b, uint8_t size); #define pwrOffPressed() (!pwrPressed()) #endif -#define PWR_PRESS_SHUTDOWN_DELAY 300 // 3s - #define GET_LOWRES_POT_POSITION(i) (getValue(MIXSRC_FIRST_POT+(i)) >> 4) #define SAVE_POT_POSITION(i) g_model.potsWarnPosition[i] = GET_LOWRES_POT_POSITION(i) diff --git a/radio/src/targets/common/arm/stm32/bootloader/boot.cpp b/radio/src/targets/common/arm/stm32/bootloader/boot.cpp index 4d3d7cc91..ae9f6b551 100644 --- a/radio/src/targets/common/arm/stm32/bootloader/boot.cpp +++ b/radio/src/targets/common/arm/stm32/bootloader/boot.cpp @@ -213,6 +213,17 @@ int main() pwrInit(); pwrOff(); + // wait a bit for the inputs to stabilize... + // ... otherwise the bootloader cannot be started + // when the power on delay is cut to 0. + for (int i=0; i<5000;i++) + readTrims(); + + // avoid booting after DFU bootloader + if (!pwrPressed()) { + boardOff(); + } + // LHR & RHL trims not pressed simultanously if (readTrims() != BOOTLOADER_KEYS) { // Start main application diff --git a/radio/src/translations.cpp b/radio/src/translations.cpp index 9ecfbee65..5c7c72bdf 100644 --- a/radio/src/translations.cpp +++ b/radio/src/translations.cpp @@ -236,6 +236,8 @@ const char STR_MENULOGICALSWITCH[] = TR_MENULOGICALSWITCH; const char STR_MENULOGICALSWITCHES[] = TR_MENULOGICALSWITCHES; const char STR_MENUCUSTOMFUNC[] = TR_MENUCUSTOMFUNC; const char STR_SPLASHSCREEN[] = TR_SPLASHSCREEN; +const char STR_PWR_ON_SPEED[] = TR_PWR_ON_SPEED; +const char STR_PWR_OFF_SPEED[] = TR_PWR_OFF_SPEED; const char STR_THROTTLEWARNING[] = TR_THROTTLEWARNING; const char STR_SWITCHWARNING[] = TR_SWITCHWARNING; const char STR_POTWARNINGSTATE[] = TR_POTWARNINGSTATE; diff --git a/radio/src/translations.h b/radio/src/translations.h index 2b5e13015..a51fedded 100644 --- a/radio/src/translations.h +++ b/radio/src/translations.h @@ -296,6 +296,10 @@ extern const char STR_BLOFFBRIGHTNESS[]; #endif extern const char STR_SPLASHSCREEN[]; +#if defined(PWR_BUTTON_PRESS) +extern const char STR_PWR_ON_SPEED[]; +extern const char STR_PWR_OFF_SPEED[]; +#endif extern const char STR_THROTTLEWARNING[]; extern const char STR_SWITCHWARNING[]; extern const char STR_POTWARNINGSTATE[]; diff --git a/radio/src/translations/cz.h.txt b/radio/src/translations/cz.h.txt index ac7ef9ad0..d253bb52a 100644 --- a/radio/src/translations/cz.h.txt +++ b/radio/src/translations/cz.h.txt @@ -591,6 +591,8 @@ #define TR_BLOFFBRIGHTNESS TR3(INDENT"Jas Vyp.", INDENT"Jas Vyp.", INDENT"Jas vypnutého LCD") #define TR_BLCOLOR INDENT "Barva" #define TR_SPLASHSCREEN TR("úvodní logo", "Zobrazit úvodní logo") +#define TR_PWR_ON_SPEED "Pwr On speed" +#define TR_PWR_OFF_SPEED "Pwr Off speed" #define TR_THROTTLEWARNING TR("* Plyn", INDENT "Kontrola plynu") #define TR_SWITCHWARNING TR("* Spínače", INDENT "Polohy spínačů") #define TR_POTWARNINGSTATE TR("* Pot&Slid.", INDENT "Kontrola Pot&Slid.") diff --git a/radio/src/translations/de.h.txt b/radio/src/translations/de.h.txt index e371a3754..f8abd9eff 100644 --- a/radio/src/translations/de.h.txt +++ b/radio/src/translations/de.h.txt @@ -602,6 +602,8 @@ #define TR_BLOFFBRIGHTNESS INDENT "Aus-Helligkeit" #define TR_BLCOLOR INDENT "Farbe" #define TR_SPLASHSCREEN TR("Startbild Ein", "Startbild Anzeigedauer") +#define TR_PWR_ON_SPEED "Pwr On speed" +#define TR_PWR_OFF_SPEED "Pwr Off speed" #define TR_THROTTLEWARNING TR("Gasalarm", INDENT "Gas Alarm") #define TR_SWITCHWARNING TR("Sch. Alarm", INDENT "Schalter-Alarm") #define TR_POTWARNINGSTATE TR(INDENT "Pot&Slid.", INDENT "Pots & sliders") diff --git a/radio/src/translations/en.h.txt b/radio/src/translations/en.h.txt index cbeb7737d..11783de8c 100644 --- a/radio/src/translations/en.h.txt +++ b/radio/src/translations/en.h.txt @@ -593,6 +593,8 @@ #define TR_BLOFFBRIGHTNESS INDENT "OFF brightness" #define TR_BLCOLOR INDENT "Color" #define TR_SPLASHSCREEN "Splash screen" +#define TR_PWR_ON_SPEED "Pwr On speed" +#define TR_PWR_OFF_SPEED "Pwr Off speed" #define TR_THROTTLEWARNING TR(INDENT "T-Warning", INDENT "Throttle state") #define TR_SWITCHWARNING TR(INDENT "S-Warning", INDENT "Switch positions") #define TR_POTWARNINGSTATE TR(INDENT "Pot&Slid.", INDENT "Pots & sliders") diff --git a/radio/src/translations/es.h.txt b/radio/src/translations/es.h.txt index 9fb7c76d1..30af9cc34 100644 --- a/radio/src/translations/es.h.txt +++ b/radio/src/translations/es.h.txt @@ -613,6 +613,8 @@ #define TR_BLOFFBRIGHTNESS INDENT"MENOS Brillo" #define TR_BLCOLOR INDENT "Color" #define TR_SPLASHSCREEN "Ptalla.inicio" +#define TR_PWR_ON_SPEED "Pwr On speed" +#define TR_PWR_OFF_SPEED "Pwr Off speed" #define TR_THROTTLEWARNING TR("Aviso-A", INDENT "Aviso Acelerador") #define TR_SWITCHWARNING TR("Aviso-I", INDENT "Aviso Intrptor") #define TR_POTWARNINGSTATE TR(INDENT "Pot&Slid.", INDENT "Pots & sliders") diff --git a/radio/src/translations/fi.h.txt b/radio/src/translations/fi.h.txt index ebca41dbb..8ab2eeca2 100644 --- a/radio/src/translations/fi.h.txt +++ b/radio/src/translations/fi.h.txt @@ -605,6 +605,8 @@ #define TR_BLOFFBRIGHTNESS INDENT"OFF Brightness" #define TR_BLCOLOR INDENT "Color" #define TR_SPLASHSCREEN "Splash screen" +#define TR_PWR_ON_SPEED "Pwr On speed" +#define TR_PWR_OFF_SPEED "Pwr Off speed" #define TR_THROTTLEWARNING TR("T-Warning", INDENT "Throttle Warning") #define TR_SWITCHWARNING TR("S-Warning", INDENT "Switch Warning") #define TR_POTWARNINGSTATE TR(INDENT "Pot&Slid.", INDENT "Pots & sliders") diff --git a/radio/src/translations/fr.h.txt b/radio/src/translations/fr.h.txt index ea1495400..96228acc2 100644 --- a/radio/src/translations/fr.h.txt +++ b/radio/src/translations/fr.h.txt @@ -611,6 +611,8 @@ #define TR_BLOFFBRIGHTNESS INDENT "Luminosité OFF" #define TR_BLCOLOR INDENT "Couleur" #define TR_SPLASHSCREEN "Logo d'accueil" +#define TR_PWR_ON_SPEED "Pwr On speed" +#define TR_PWR_OFF_SPEED "Pwr Off speed" #define TR_THROTTLEWARNING TR(INDENT "Alerte gaz", INDENT "Alerte gaz") #define TR_SWITCHWARNING TR(INDENT "Alerte int", INDENT "Pos. interrupteurs") #define TR_POTWARNINGSTATE TR(INDENT "Pot&Slid.", INDENT "Pots & sliders") diff --git a/radio/src/translations/it.h.txt b/radio/src/translations/it.h.txt index 3aa9e1a6c..a5812a04b 100644 --- a/radio/src/translations/it.h.txt +++ b/radio/src/translations/it.h.txt @@ -612,6 +612,8 @@ #define TR_BLOFFBRIGHTNESS TR(INDENT"Lumin. OFF",INDENT"Luminosità OFF") #define TR_BLCOLOR INDENT "Colore" #define TR_SPLASHSCREEN TR("Schermo avvio", "Schermata di avvio") +#define TR_PWR_ON_SPEED "Pwr On speed" +#define TR_PWR_OFF_SPEED "Pwr Off speed" #define TR_THROTTLEWARNING TR("All. Mot.", INDENT "Allarme Motore") #define TR_SWITCHWARNING TR("Avv. Int.", INDENT "Avviso Interr.") #define TR_POTWARNINGSTATE TR(INDENT "Pot&Slid.", INDENT "Pots & sliders") diff --git a/radio/src/translations/nl.h.txt b/radio/src/translations/nl.h.txt index e35eb3175..cd94cc308 100644 --- a/radio/src/translations/nl.h.txt +++ b/radio/src/translations/nl.h.txt @@ -596,6 +596,8 @@ TR_GYR_VSRCRAW #define TR_BLOFFBRIGHTNESS INDENT "Uit-Helderheid" #define TR_BLCOLOR INDENT "Kleur" #define TR_SPLASHSCREEN "Startscherm Aan" +#define TR_PWR_ON_SPEED "Pwr On speed" +#define TR_PWR_OFF_SPEED "Pwr Off speed" #define TR_THROTTLEWARNING TR(INDENT "T-Warning", INDENT "Throttle Status") #define TR_SWITCHWARNING TR(INDENT "S-Warning", INDENT "Switch Posities") #define TR_POTWARNINGSTATE TR(INDENT "Pot&Slid.", INDENT "Pots & sliders") diff --git a/radio/src/translations/pl.h.txt b/radio/src/translations/pl.h.txt index 66ba2ea8e..ac4009108 100644 --- a/radio/src/translations/pl.h.txt +++ b/radio/src/translations/pl.h.txt @@ -612,6 +612,8 @@ #define TR_BLOFFBRIGHTNESS INDENT"Jasność wył." #define TR_BLCOLOR INDENT "Color" #define TR_SPLASHSCREEN "Logo ekranu" +#define TR_PWR_ON_SPEED "Pwr On speed" +#define TR_PWR_OFF_SPEED "Pwr Off speed" #define TR_THROTTLEWARNING TR(INDENT"OstrzGaz", INDENT "OstrzeżenieGaz") #define TR_SWITCHWARNING TR(INDENT "OstrzPrzeł", INDENT "PozycjaPrzeł") #define TR_POTWARNINGSTATE TR(INDENT "Pot&Slid.", INDENT "Pots & sliders") diff --git a/radio/src/translations/pt.h.txt b/radio/src/translations/pt.h.txt index 79226ec3f..92d1163d6 100644 --- a/radio/src/translations/pt.h.txt +++ b/radio/src/translations/pt.h.txt @@ -598,6 +598,8 @@ #define TR_BLOFFBRIGHTNESS INDENT "OFF Brightness" #define TR_BLCOLOR INDENT "Color" #define TR_SPLASHSCREEN "Splash screen" +#define TR_PWR_ON_SPEED "Pwr On speed" +#define TR_PWR_OFF_SPEED "Pwr Off speed" #define TR_THROTTLEWARNING TR("Avisa Acel", INDENT "Avisa Acel") #define TR_SWITCHWARNING TR("Avisa Chav", INDENT "Avisa Chav") #define TR_POTWARNINGSTATE TR(INDENT "Pot&Slid.", INDENT "Pots & sliders") diff --git a/radio/src/translations/se.h.txt b/radio/src/translations/se.h.txt index b6aa76072..d2d9cffb4 100644 --- a/radio/src/translations/se.h.txt +++ b/radio/src/translations/se.h.txt @@ -610,6 +610,8 @@ #define TR_BLONBRIGHTNESS INDENT "På Ljusstyrka" #define TR_BLOFFBRIGHTNESS INDENT "Av Ljusstyrka" #define TR_SPLASHSCREEN "Startbild" +#define TR_PWR_ON_SPEED "Pwr On speed" +#define TR_PWR_OFF_SPEED "Pwr Off speed" #define TR_BLCOLOR INDENT "Color" #define TR_THROTTLEWARNING TR("Gasvarning", INDENT "Gasvarning") #define TR_SWITCHWARNING TR("Bryt.varn.", INDENT "Brytarvarning") From 06eed5d79ff205009a28fbd3c35ff03226aad7dd Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Fri, 16 Aug 2019 22:18:19 +0200 Subject: [PATCH 2/7] small fixes --- companion/src/firmwares/opentx/opentxeeprom.cpp | 3 ++- radio/src/datastructs.h | 6 +----- radio/src/gui/128x64/startup_shutdown.cpp | 12 ++++++------ radio/src/gui/212x64/startup_shutdown.cpp | 12 ++++++------ radio/src/gui/480x272/widgets.cpp | 8 ++++---- radio/src/gui/common/stdlcd/draw_functions.h | 4 ++-- 6 files changed, 21 insertions(+), 24 deletions(-) diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 8196533f2..8e54b853d 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -2408,7 +2408,8 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, Board::Type if (version >= 219 && IS_HORUS_OR_TARANIS(board)) { internalField.Append(new UnsignedField<2>(this, generalData.pwrOnSpeed, "Power On Speed")); - internalField.Append(new UnsignedField<4>(this, generalData.pwrOffSpeed, "Power Off Speed")); + internalField.Append(new UnsignedField<2>(this, generalData.pwrOffSpeed, "Power Off Speed")); + internalField.Append(new SpareBitsField<2>(this)); } else { internalField.Append(new SpareBitsField<6>(this)); diff --git a/radio/src/datastructs.h b/radio/src/datastructs.h index 8fe3c6ca6..2b4c28f4c 100644 --- a/radio/src/datastructs.h +++ b/radio/src/datastructs.h @@ -772,13 +772,9 @@ PACK(struct RadioData { NOBACKUP(uint8_t bluetoothBaudrate:4); NOBACKUP(uint8_t bluetoothMode:4); NOBACKUP(uint8_t countryCode:2); -#if defined(PCBHORUS) || defined(PCBTARANIS) NOBACKUP(uint8_t pwrOnSpeed:2); NOBACKUP(uint8_t pwrOffSpeed:2); - NOBACKUP(uint8_t spareCC:2); -#else - NOBACKUP(uint8_t spareCC:6); -#endif + NOBACKUP(uint8_t spare5:2); NOBACKUP(uint8_t imperial:1); NOBACKUP(uint8_t jitterFilter:1); /* 0 - active */ NOBACKUP(uint8_t disableRssiPoweroffAlarm:1); diff --git a/radio/src/gui/128x64/startup_shutdown.cpp b/radio/src/gui/128x64/startup_shutdown.cpp index 2b0a2e617..b12bc8fa8 100644 --- a/radio/src/gui/128x64/startup_shutdown.cpp +++ b/radio/src/gui/128x64/startup_shutdown.cpp @@ -28,11 +28,11 @@ const unsigned char bmp_sleep[] = { #include "sleep.lbm" }; -void drawStartupAnimation(uint32_t duration, uint32_t total_duration) +void drawStartupAnimation(uint32_t duration, uint32_t totalDuration) { - if (total_duration == 0) return; + if (totalDuration == 0) return; - uint8_t index = limit(0, duration / (total_duration / 5), 4); + uint8_t index = limit(0, duration / (totalDuration / 5), 4); lcdRefreshWait(); lcdClear(); @@ -47,11 +47,11 @@ void drawStartupAnimation(uint32_t duration, uint32_t total_duration) lcdRefreshWait(); } -void drawShutdownAnimation(uint32_t duration, uint32_t total_duration, const char * message) +void drawShutdownAnimation(uint32_t duration, uint32_t totalDuration, const char * message) { - if (total_duration == 0) return; + if (totalDuration == 0) return; - uint8_t index = limit(0, duration / (total_duration / 5), 4); + uint8_t index = limit(0, duration / (totalDuration / 5), 4); lcdRefreshWait(); lcdClear(); diff --git a/radio/src/gui/212x64/startup_shutdown.cpp b/radio/src/gui/212x64/startup_shutdown.cpp index 91c81f471..e739b3754 100644 --- a/radio/src/gui/212x64/startup_shutdown.cpp +++ b/radio/src/gui/212x64/startup_shutdown.cpp @@ -40,11 +40,11 @@ const unsigned char bmp_sleep[] = { #include "sleep.lbm" }; -void drawStartupAnimation(uint32_t duration, uint32_t total_duration) +void drawStartupAnimation(uint32_t duration, uint32_t totalDuration) { - if (total_duration == 0) return; + if (totalDuration == 0) return; - uint8_t index = limit(0, duration / (total_duration / 5), 4); + uint8_t index = limit(0, duration / (totalDuration / 5), 4); lcdRefreshWait(); lcdClear(); @@ -57,11 +57,11 @@ void drawStartupAnimation(uint32_t duration, uint32_t total_duration) lcdRefresh(); } -void drawShutdownAnimation(uint32_t duration, uint32_t total_duration, const char * message) +void drawShutdownAnimation(uint32_t duration, uint32_t totalDuration, const char * message) { - if (total_duration == 0) return; + if (totalDuration == 0) return; - uint8_t index = limit(0, duration / (total_duration / 4), 3); + uint8_t index = limit(0, duration / (totalDuration / 4), 3); lcdRefreshWait(); lcdClear(); diff --git a/radio/src/gui/480x272/widgets.cpp b/radio/src/gui/480x272/widgets.cpp index d95d813bd..4696c851b 100644 --- a/radio/src/gui/480x272/widgets.cpp +++ b/radio/src/gui/480x272/widgets.cpp @@ -391,9 +391,9 @@ void drawSleepBitmap() } #define SHUTDOWN_CIRCLE_DIAMETER 150 -void drawShutdownAnimation(uint32_t duration, uint32_t total_duration, const char * message) +void drawShutdownAnimation(uint32_t duration, uint32_t totalDuration, const char * message) { - if (total_duration == 0) return; + if (totalDuration == 0) return; static uint32_t lastDuration = 0xffffffff; static const BitmapBuffer * shutdown = BitmapBuffer::load(getThemePath("shutdown.bmp")); @@ -406,7 +406,7 @@ void drawShutdownAnimation(uint32_t duration, uint32_t total_duration, const cha } else { lcdRestoreBackupBuffer(); - int quarter = duration / (total_duration / 5); + int quarter = duration / (totalDuration / 5); if (quarter >= 1) lcdDrawBitmapPattern(LCD_W/2, (LCD_H-SHUTDOWN_CIRCLE_DIAMETER)/2, LBM_SHUTDOWN_CIRCLE, TEXT_COLOR, 0, SHUTDOWN_CIRCLE_DIAMETER/2); if (quarter >= 2) lcdDrawBitmapPattern(LCD_W/2, LCD_H/2, LBM_SHUTDOWN_CIRCLE, TEXT_COLOR, SHUTDOWN_CIRCLE_DIAMETER/2, SHUTDOWN_CIRCLE_DIAMETER/2); if (quarter >= 3) lcdDrawBitmapPattern((LCD_W-SHUTDOWN_CIRCLE_DIAMETER)/2, LCD_H/2, LBM_SHUTDOWN_CIRCLE, TEXT_COLOR, SHUTDOWN_CIRCLE_DIAMETER, SHUTDOWN_CIRCLE_DIAMETER/2); @@ -415,7 +415,7 @@ void drawShutdownAnimation(uint32_t duration, uint32_t total_duration, const cha } else { lcd->clear(); - int quarter = duration / (total_duration / 5); + int quarter = duration / (totalDuration / 5); for (int i=1; i<=4; i++) { if (quarter >= i) { lcd->drawSolidFilledRect(LCD_W / 2 - 70 + 24 * i, LCD_H / 2 - 10, 20, 20, TEXT_BGCOLOR); diff --git a/radio/src/gui/common/stdlcd/draw_functions.h b/radio/src/gui/common/stdlcd/draw_functions.h index cf0f4e25e..03ad2aaae 100644 --- a/radio/src/gui/common/stdlcd/draw_functions.h +++ b/radio/src/gui/common/stdlcd/draw_functions.h @@ -36,8 +36,8 @@ inline void drawTimer(coord_t x, coord_t y, int32_t tme, LcdFlags att = 0) drawTimer(x, y, tme, att, att); } -void drawStartupAnimation(uint32_t duration, uint32_t total_duration); -void drawShutdownAnimation(uint32_t duration, uint32_t total_duration, const char * message); +void drawStartupAnimation(uint32_t duration, uint32_t totalDuration); +void drawShutdownAnimation(uint32_t duration, uint32_t totalDuration, const char * message); void drawSleepBitmap(); #endif // _COMMON_DRAW_FUNCTIONS_H_ From 57c48de4941478e2e3d1fea4dc6f300e8e263127 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Fri, 16 Aug 2019 22:45:51 +0200 Subject: [PATCH 3/7] remove busy loop from bootloader --- radio/src/targets/common/arm/stm32/bootloader/boot.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/radio/src/targets/common/arm/stm32/bootloader/boot.cpp b/radio/src/targets/common/arm/stm32/bootloader/boot.cpp index ae9f6b551..3aa7fbfcf 100644 --- a/radio/src/targets/common/arm/stm32/bootloader/boot.cpp +++ b/radio/src/targets/common/arm/stm32/bootloader/boot.cpp @@ -216,8 +216,6 @@ int main() // wait a bit for the inputs to stabilize... // ... otherwise the bootloader cannot be started // when the power on delay is cut to 0. - for (int i=0; i<5000;i++) - readTrims(); // avoid booting after DFU bootloader if (!pwrPressed()) { From 83efad8f43f4d774ff503b5b56f476bad1031995 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Fri, 16 Aug 2019 23:44:00 +0200 Subject: [PATCH 4/7] use signed pwr on/off speed from -1 to 2 (delay 0 to 3) --- companion/src/firmwares/generalsettings.h | 4 ++-- companion/src/firmwares/opentx/opentxeeprom.cpp | 4 ++-- companion/src/generaledit/generalsetup.ui | 10 ++++++++-- radio/src/datastructs.h | 4 ++-- radio/src/gui/128x64/radio_setup.cpp | 12 ++++++------ radio/src/gui/212x64/radio_setup.cpp | 8 ++++---- radio/src/gui/480x272/radio_setup.cpp | 2 +- radio/src/opentx.cpp | 13 +++---------- 8 files changed, 28 insertions(+), 29 deletions(-) diff --git a/companion/src/firmwares/generalsettings.h b/companion/src/firmwares/generalsettings.h index 25e300628..2fb98e8e6 100644 --- a/companion/src/firmwares/generalsettings.h +++ b/companion/src/firmwares/generalsettings.h @@ -170,8 +170,8 @@ class GeneralSettings { int gyroMax; int gyroOffset; - unsigned int pwrOnSpeed; - unsigned int pwrOffSpeed; + int pwrOnSpeed; + int pwrOffSpeed; bool switchPositionAllowedTaranis(int index) const; bool switchSourceAllowedTaranis(int index) const; diff --git a/companion/src/firmwares/opentx/opentxeeprom.cpp b/companion/src/firmwares/opentx/opentxeeprom.cpp index 8e54b853d..b4ec24d5b 100644 --- a/companion/src/firmwares/opentx/opentxeeprom.cpp +++ b/companion/src/firmwares/opentx/opentxeeprom.cpp @@ -2407,8 +2407,8 @@ OpenTxGeneralData::OpenTxGeneralData(GeneralSettings & generalData, Board::Type internalField.Append(new UnsignedField<2>(this, generalData.countryCode)); if (version >= 219 && IS_HORUS_OR_TARANIS(board)) { - internalField.Append(new UnsignedField<2>(this, generalData.pwrOnSpeed, "Power On Speed")); - internalField.Append(new UnsignedField<2>(this, generalData.pwrOffSpeed, "Power Off Speed")); + internalField.Append(new SignedField<2>(this, generalData.pwrOnSpeed, "Power On Speed")); + internalField.Append(new SignedField<2>(this, generalData.pwrOffSpeed, "Power Off Speed")); internalField.Append(new SpareBitsField<2>(this)); } else { diff --git a/companion/src/generaledit/generalsetup.ui b/companion/src/generaledit/generalsetup.ui index 9378b2dc0..5e2941508 100644 --- a/companion/src/generaledit/generalsetup.ui +++ b/companion/src/generaledit/generalsetup.ui @@ -2423,8 +2423,11 @@ p, li { white-space: pre-wrap; } + + -1 + - 3 + 2 Qt::Horizontal @@ -2433,8 +2436,11 @@ p, li { white-space: pre-wrap; } + + -1 + - 3 + 2 Qt::Horizontal diff --git a/radio/src/datastructs.h b/radio/src/datastructs.h index 2b4c28f4c..dcc2fda60 100644 --- a/radio/src/datastructs.h +++ b/radio/src/datastructs.h @@ -772,8 +772,8 @@ PACK(struct RadioData { NOBACKUP(uint8_t bluetoothBaudrate:4); NOBACKUP(uint8_t bluetoothMode:4); NOBACKUP(uint8_t countryCode:2); - NOBACKUP(uint8_t pwrOnSpeed:2); - NOBACKUP(uint8_t pwrOffSpeed:2); + NOBACKUP(int8_t pwrOnSpeed:2); + NOBACKUP(int8_t pwrOffSpeed:2); NOBACKUP(uint8_t spare5:2); NOBACKUP(uint8_t imperial:1); NOBACKUP(uint8_t jitterFilter:1); /* 0 - active */ diff --git a/radio/src/gui/128x64/radio_setup.cpp b/radio/src/gui/128x64/radio_setup.cpp index eef530c53..30b37b156 100644 --- a/radio/src/gui/128x64/radio_setup.cpp +++ b/radio/src/gui/128x64/radio_setup.cpp @@ -510,16 +510,16 @@ void menuRadioSetup(event_t event) #endif #if defined(PWR_BUTTON_PRESS) - case ITEM_RADIO_SETUP_PWR_ON_SPEED: + case ITEM_RADIO_SETUP_PWR_ON_SPEED: lcdDrawTextAlignedLeft(y, STR_PWR_ON_SPEED); - lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.pwrOnSpeed, attr|LEFT); - if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.pwrOnSpeed, 0, 3); + lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.pwrOnSpeed + 1, attr|LEFT); + if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.pwrOnSpeed, -1, 2); break; - case ITEM_RADIO_SETUP_PWR_OFF_SPEED: + case ITEM_RADIO_SETUP_PWR_OFF_SPEED: lcdDrawTextAlignedLeft(y, STR_PWR_OFF_SPEED); - lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.pwrOffSpeed, attr|LEFT); - if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.pwrOffSpeed, 0, 3); + lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.pwrOffSpeed + 1, attr|LEFT); + if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.pwrOffSpeed, -1, 2); break; #endif diff --git a/radio/src/gui/212x64/radio_setup.cpp b/radio/src/gui/212x64/radio_setup.cpp index edf3459e1..2eedcc884 100644 --- a/radio/src/gui/212x64/radio_setup.cpp +++ b/radio/src/gui/212x64/radio_setup.cpp @@ -473,14 +473,14 @@ void menuRadioSetup(event_t event) #if defined(PWR_BUTTON_PRESS) case ITEM_RADIO_SETUP_PWR_ON_SPEED: lcdDrawTextAlignedLeft(y, STR_PWR_ON_SPEED); - lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.pwrOnSpeed, attr|LEFT); - if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.pwrOnSpeed, 0, 3); + lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.pwrOnSpeed + 1, attr|LEFT); + if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.pwrOnSpeed, -1, 2); break; case ITEM_RADIO_SETUP_PWR_OFF_SPEED: lcdDrawTextAlignedLeft(y, STR_PWR_OFF_SPEED); - lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.pwrOffSpeed, attr|LEFT); - if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.pwrOffSpeed, 0, 3); + lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.pwrOffSpeed + 1, attr|LEFT); + if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.pwrOffSpeed, -1, 2); break; #endif diff --git a/radio/src/gui/480x272/radio_setup.cpp b/radio/src/gui/480x272/radio_setup.cpp index 4e679c909..a26d2d08a 100644 --- a/radio/src/gui/480x272/radio_setup.cpp +++ b/radio/src/gui/480x272/radio_setup.cpp @@ -385,7 +385,7 @@ bool menuRadioSetup(event_t event) #if defined(PWR_BUTTON_PRESS) case ITEM_SETUP_PWR_OFF_SPEED: lcdDrawText(MENUS_MARGIN_LEFT, y, STR_PWR_OFF_SPEED); - g_eeGeneral.pwrOffSpeed = editSlider(RADIO_SETUP_2ND_COLUMN, y, event, g_eeGeneral.pwrOffSpeed, 0, 3, attr); + g_eeGeneral.pwrOffSpeed = editSlider(RADIO_SETUP_2ND_COLUMN, y, event, g_eeGeneral.pwrOffSpeed, -1, 2, attr); break; #endif diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 92100ee6b..186bc43da 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -1729,17 +1729,10 @@ void copyTrimsToOffset(uint8_t ch) } -const uint8_t _pwrOnOffDuration_lookup[] = { - 200, // 2s - 100, // 1s - 50, // 0.5s - 0, // none -}; - #if defined(STARTUP_ANIMATION) -#define PWR_PRESS_DURATION_MIN() (_pwrOnOffDuration_lookup[g_eeGeneral.pwrOnSpeed & 3]) -#define PWR_PRESS_DURATION_MAX 500 // 5s +#define PWR_PRESS_DURATION_MIN() (2 - g_eeGeneral.pwrOnSpeed) +#define PWR_PRESS_DURATION_MAX 500 // 5s void runStartupAnimation() { @@ -2035,7 +2028,7 @@ int main() #if !defined(SIMU) #if defined(PWR_BUTTON_PRESS) -#define PWR_PRESS_SHUTDOWN_DELAY() (_pwrOnOffDuration_lookup[g_eeGeneral.pwrOffSpeed & 3]) +#define PWR_PRESS_SHUTDOWN_DELAY() (2 - g_eeGeneral.pwrOffSpeed) uint32_t pwr_press_time = 0; From 5de3632ea10f805f459731da4d8d7b84ab553910 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Sat, 17 Aug 2019 10:37:06 +0200 Subject: [PATCH 5/7] cosmetics --- radio/src/gui/128x64/startup_shutdown.cpp | 6 ++++-- radio/src/gui/212x64/radio_setup.cpp | 4 ++-- radio/src/gui/212x64/startup_shutdown.cpp | 6 ++++-- radio/src/gui/480x272/widgets.cpp | 3 ++- radio/src/opentx.cpp | 13 ++++++++++--- 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/radio/src/gui/128x64/startup_shutdown.cpp b/radio/src/gui/128x64/startup_shutdown.cpp index b12bc8fa8..96f9dbaea 100644 --- a/radio/src/gui/128x64/startup_shutdown.cpp +++ b/radio/src/gui/128x64/startup_shutdown.cpp @@ -30,7 +30,8 @@ const unsigned char bmp_sleep[] = { void drawStartupAnimation(uint32_t duration, uint32_t totalDuration) { - if (totalDuration == 0) return; + if (totalDuration == 0) + return; uint8_t index = limit(0, duration / (totalDuration / 5), 4); @@ -49,7 +50,8 @@ void drawStartupAnimation(uint32_t duration, uint32_t totalDuration) void drawShutdownAnimation(uint32_t duration, uint32_t totalDuration, const char * message) { - if (totalDuration == 0) return; + if (totalDuration == 0) + return; uint8_t index = limit(0, duration / (totalDuration / 5), 4); diff --git a/radio/src/gui/212x64/radio_setup.cpp b/radio/src/gui/212x64/radio_setup.cpp index 2eedcc884..c4848fe9f 100644 --- a/radio/src/gui/212x64/radio_setup.cpp +++ b/radio/src/gui/212x64/radio_setup.cpp @@ -471,13 +471,13 @@ void menuRadioSetup(event_t event) #endif #if defined(PWR_BUTTON_PRESS) - case ITEM_RADIO_SETUP_PWR_ON_SPEED: + case ITEM_RADIO_SETUP_PWR_ON_SPEED: lcdDrawTextAlignedLeft(y, STR_PWR_ON_SPEED); lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.pwrOnSpeed + 1, attr|LEFT); if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.pwrOnSpeed, -1, 2); break; - case ITEM_RADIO_SETUP_PWR_OFF_SPEED: + case ITEM_RADIO_SETUP_PWR_OFF_SPEED: lcdDrawTextAlignedLeft(y, STR_PWR_OFF_SPEED); lcdDrawNumber(RADIO_SETUP_2ND_COLUMN, y, g_eeGeneral.pwrOffSpeed + 1, attr|LEFT); if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.pwrOffSpeed, -1, 2); diff --git a/radio/src/gui/212x64/startup_shutdown.cpp b/radio/src/gui/212x64/startup_shutdown.cpp index e739b3754..6b039ed71 100644 --- a/radio/src/gui/212x64/startup_shutdown.cpp +++ b/radio/src/gui/212x64/startup_shutdown.cpp @@ -42,7 +42,8 @@ const unsigned char bmp_sleep[] = { void drawStartupAnimation(uint32_t duration, uint32_t totalDuration) { - if (totalDuration == 0) return; + if (totalDuration == 0) + return; uint8_t index = limit(0, duration / (totalDuration / 5), 4); @@ -59,7 +60,8 @@ void drawStartupAnimation(uint32_t duration, uint32_t totalDuration) void drawShutdownAnimation(uint32_t duration, uint32_t totalDuration, const char * message) { - if (totalDuration == 0) return; + if (totalDuration == 0) + return; uint8_t index = limit(0, duration / (totalDuration / 4), 3); diff --git a/radio/src/gui/480x272/widgets.cpp b/radio/src/gui/480x272/widgets.cpp index 4696c851b..301fe575b 100644 --- a/radio/src/gui/480x272/widgets.cpp +++ b/radio/src/gui/480x272/widgets.cpp @@ -393,7 +393,8 @@ void drawSleepBitmap() #define SHUTDOWN_CIRCLE_DIAMETER 150 void drawShutdownAnimation(uint32_t duration, uint32_t totalDuration, const char * message) { - if (totalDuration == 0) return; + if (totalDuration == 0) + return; static uint32_t lastDuration = 0xffffffff; static const BitmapBuffer * shutdown = BitmapBuffer::load(getThemePath("shutdown.bmp")); diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 186bc43da..4905906ba 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -1731,8 +1731,12 @@ void copyTrimsToOffset(uint8_t ch) #if defined(STARTUP_ANIMATION) -#define PWR_PRESS_DURATION_MIN() (2 - g_eeGeneral.pwrOnSpeed) -#define PWR_PRESS_DURATION_MAX 500 // 5s +inline uint32_t PWR_PRESS_DURATION_MIN() +{ + return 2 - g_eeGeneral.pwrOnSpeed; +} + +constexpr uint32_t PWR_PRESS_DURATION_MAX = 500; // 5s void runStartupAnimation() { @@ -2028,7 +2032,10 @@ int main() #if !defined(SIMU) #if defined(PWR_BUTTON_PRESS) -#define PWR_PRESS_SHUTDOWN_DELAY() (2 - g_eeGeneral.pwrOffSpeed) +inline uint32_t PWR_PRESS_SHUTDOWN_DELAY() +{ + return 2 - g_eeGeneral.pwrOffSpeed; +} uint32_t pwr_press_time = 0; From 94209ac3088eca00de8dc495c9867ed4b8405750 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Sat, 17 Aug 2019 12:41:54 +0200 Subject: [PATCH 6/7] small fix --- radio/src/gui/480x272/widgets.h | 2 +- radio/src/opentx.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/radio/src/gui/480x272/widgets.h b/radio/src/gui/480x272/widgets.h index b7f65e417..ebd7363b3 100644 --- a/radio/src/gui/480x272/widgets.h +++ b/radio/src/gui/480x272/widgets.h @@ -69,7 +69,7 @@ int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min, int void drawMenuTemplate(const char * title, uint8_t icon, const uint8_t * icons=nullptr, uint32_t options=0); void drawSplash(); void drawSleepBitmap(); -void drawShutdownAnimation(uint32_t duration, uint32_t total_duration, const char * message); +void drawShutdownAnimation(uint32_t duration, uint32_t totalDuration, const char * message); // Main view standard widgets void drawTopBar(); diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 4905906ba..bd41995ab 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -1733,7 +1733,7 @@ void copyTrimsToOffset(uint8_t ch) inline uint32_t PWR_PRESS_DURATION_MIN() { - return 2 - g_eeGeneral.pwrOnSpeed; + return (2 - g_eeGeneral.pwrOnSpeed) * 100; } constexpr uint32_t PWR_PRESS_DURATION_MAX = 500; // 5s @@ -2034,7 +2034,7 @@ int main() inline uint32_t PWR_PRESS_SHUTDOWN_DELAY() { - return 2 - g_eeGeneral.pwrOffSpeed; + return (2 - g_eeGeneral.pwrOffSpeed) * 100; } uint32_t pwr_press_time = 0; From d223b1fc336f1d1ca6fdfda7cc1445cd64e892f7 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Sat, 17 Aug 2019 13:20:33 +0200 Subject: [PATCH 7/7] cast removed --- radio/src/opentx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index bd41995ab..1a2033451 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -2082,7 +2082,7 @@ uint32_t pwrCheck() if (g_eeGeneral.backlightMode != e_backlight_mode_off) { BACKLIGHT_ENABLE(); } - if (get_tmr10ms() - pwr_press_time > (uint32_t)PWR_PRESS_SHUTDOWN_DELAY()) { + if (get_tmr10ms() - pwr_press_time > PWR_PRESS_SHUTDOWN_DELAY()) { #if defined(SHUTDOWN_CONFIRMATION) while (1) { #else