diff --git a/radio/src/gui/horus/themes/default.cpp b/radio/src/gui/horus/themes/default.cpp index d92463d70..b88e8dd50 100644 --- a/radio/src/gui/horus/themes/default.cpp +++ b/radio/src/gui/horus/themes/default.cpp @@ -25,7 +25,7 @@ const uint8_t LBM_TOPMENU_MASK_OPENTX[] = { }; const ZoneOption OPTIONS_THEME_DEFAULT[] = { - { "Background color", ZoneOption::Color, OPTION_DEFAULT_VALUE({ .unsignedValue = WHITE }) }, + { "Background color", ZoneOption::Color, OPTION_DEFAULT_VALUE_UNSIGNED(WHITE) }, { NULL, ZoneOption::Bool } }; diff --git a/radio/src/gui/horus/widget.h b/radio/src/gui/horus/widget.h index 4266b6215..823a501a6 100644 --- a/radio/src/gui/horus/widget.h +++ b/radio/src/gui/horus/widget.h @@ -34,16 +34,22 @@ struct Zone #define LEN_ZONE_OPTION_STRING 8 union ZoneOptionValue { - bool boolValue; uint32_t unsignedValue; int32_t signedValue; + bool boolValue; char stringValue[LEN_ZONE_OPTION_STRING]; }; #if defined(_MSC_VER) - #define OPTION_DEFAULT_VALUE(...) + #define OPTION_DEFAULT_VALUE_UNSIGNED(x) { uint32_t(x) } + #define OPTION_DEFAULT_VALUE_SIGNED(x) { uint32_t(x) } + #define OPTION_DEFAULT_VALUE_BOOL(x) { uint32_t(x) } + #define OPTION_DEFAULT_VALUE_STRING(...) { *((ZoneOptionValue *)(const char []) __VA_ARGS__) } #else - #define OPTION_DEFAULT_VALUE(...) __VA_ARGS__ + #define OPTION_DEFAULT_VALUE_UNSIGNED(x) { .unsignedValue = (x) } + #define OPTION_DEFAULT_VALUE_SIGNED(x) { .signedValue = (x) } + #define OPTION_DEFAULT_VALUE_BOOL(x) { .boolValue = (x) } + #define OPTION_DEFAULT_VALUE_STRING(...) { .stringValue = __VA_ARGS__} #endif struct ZoneOption diff --git a/radio/src/gui/horus/widgets/gauge.cpp b/radio/src/gui/horus/widgets/gauge.cpp index 4ec5e0d15..366a35840 100644 --- a/radio/src/gui/horus/widgets/gauge.cpp +++ b/radio/src/gui/horus/widgets/gauge.cpp @@ -34,10 +34,10 @@ class GaugeWidget: public Widget }; const ZoneOption GaugeWidget::options[] = { - { "Source", ZoneOption::Source, OPTION_DEFAULT_VALUE({ .unsignedValue = 1 }) }, - { "Min", ZoneOption::Integer, OPTION_DEFAULT_VALUE({ .signedValue = -RESX }) }, - { "Max", ZoneOption::Integer, OPTION_DEFAULT_VALUE({ .signedValue = RESX }) }, - { "Color", ZoneOption::Color, OPTION_DEFAULT_VALUE({ .unsignedValue = RED }) }, + { "Source", ZoneOption::Source, OPTION_DEFAULT_VALUE_UNSIGNED(1) }, + { "Min", ZoneOption::Integer, OPTION_DEFAULT_VALUE_SIGNED(-RESX) }, + { "Max", ZoneOption::Integer, OPTION_DEFAULT_VALUE_SIGNED(RESX) }, + { "Color", ZoneOption::Color, OPTION_DEFAULT_VALUE_UNSIGNED(RED) }, { NULL, ZoneOption::Bool } }; diff --git a/radio/src/gui/horus/widgets/outputs.cpp b/radio/src/gui/horus/widgets/outputs.cpp index 6ba6e53f5..473a840a8 100644 --- a/radio/src/gui/horus/widgets/outputs.cpp +++ b/radio/src/gui/horus/widgets/outputs.cpp @@ -34,9 +34,9 @@ class OutputsWidget: public Widget }; const ZoneOption OutputsWidget::options[] = { - { "Min", ZoneOption::Integer, OPTION_DEFAULT_VALUE({ .unsignedValue = 0 }) }, - { "Max", ZoneOption::Integer, OPTION_DEFAULT_VALUE({ .unsignedValue = 7 }) }, - { "Color", ZoneOption::Color, OPTION_DEFAULT_VALUE({ .unsignedValue = RED }) }, + { "Min", ZoneOption::Integer, OPTION_DEFAULT_VALUE_UNSIGNED(0) }, + { "Max", ZoneOption::Integer, OPTION_DEFAULT_VALUE_UNSIGNED(7) }, + { "Color", ZoneOption::Color, OPTION_DEFAULT_VALUE_UNSIGNED(RED) }, { NULL, ZoneOption::Bool } }; diff --git a/radio/src/gui/horus/widgets/text.cpp b/radio/src/gui/horus/widgets/text.cpp index 79c97498c..137035206 100644 --- a/radio/src/gui/horus/widgets/text.cpp +++ b/radio/src/gui/horus/widgets/text.cpp @@ -34,9 +34,9 @@ class TextWidget: public Widget }; const ZoneOption TextWidget::options[] = { - { "Text", ZoneOption::String, OPTION_DEFAULT_VALUE({ .stringValue = { '\015', '\347', '\0', '\14', '\377', '\376', '\373', '\364' } }) }, - { "Color", ZoneOption::Color, OPTION_DEFAULT_VALUE({ .unsignedValue = RED }) }, - { "Size", ZoneOption::TextSize, OPTION_DEFAULT_VALUE({ .unsignedValue = 0 }) }, + { "Text", ZoneOption::String, OPTION_DEFAULT_VALUE_STRING({ '\015', '\347', '\0', '\14', '\377', '\376', '\373', '\364' }) }, + { "Color", ZoneOption::Color, OPTION_DEFAULT_VALUE_UNSIGNED(RED) }, + { "Size", ZoneOption::TextSize, OPTION_DEFAULT_VALUE_UNSIGNED(0) }, { NULL, ZoneOption::Bool } }; diff --git a/radio/src/gui/horus/widgets/timer.cpp b/radio/src/gui/horus/widgets/timer.cpp index 0f090a4bd..81e4d74c8 100644 --- a/radio/src/gui/horus/widgets/timer.cpp +++ b/radio/src/gui/horus/widgets/timer.cpp @@ -34,7 +34,7 @@ class TimerWidget: public Widget }; const ZoneOption TimerWidget::options[] = { - { "Timer source", ZoneOption::Timer, OPTION_DEFAULT_VALUE({ .unsignedValue = 0 }) }, + { "Timer source", ZoneOption::Timer, OPTION_DEFAULT_VALUE_UNSIGNED(0) }, { NULL, ZoneOption::Bool } }; diff --git a/radio/src/gui/horus/widgets/value.cpp b/radio/src/gui/horus/widgets/value.cpp index 5fc9e6a6c..c84916677 100644 --- a/radio/src/gui/horus/widgets/value.cpp +++ b/radio/src/gui/horus/widgets/value.cpp @@ -34,7 +34,7 @@ class ValueWidget: public Widget }; const ZoneOption ValueWidget::options[] = { - { "Source", ZoneOption::Source, OPTION_DEFAULT_VALUE({ .unsignedValue = MIXSRC_Rud }) }, + { "Source", ZoneOption::Source, OPTION_DEFAULT_VALUE_UNSIGNED(MIXSRC_Rud) }, { NULL, ZoneOption::Bool } }; diff --git a/radio/src/opentx.h b/radio/src/opentx.h index 28b65a6d1..26c4c6cb8 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -1043,7 +1043,10 @@ void checkModelIdUnique(uint8_t index, uint8_t module); inline int divRoundClosest(const int n, const int d) { - return ((n < 0) ^ (d < 0)) ? ((n - d/2)/d) : ((n + d/2)/d); + if (d == 0) + return 0; + else + return ((n < 0) ^ (d < 0)) ? ((n - d/2)/d) : ((n + d/2)/d); } #define calc100to256_16Bits(x) calc100to256(x) @@ -1352,7 +1355,6 @@ uint16_t crc16(uint8_t * buf, uint32_t len); #define PLAY_BACKGROUND 0x20 #define PLAY_INCREMENT(x) ((uint8_t)(((uint8_t)x) << 6)) /* -1, 0, 1, 2 */ -/* make sure the defines below always go in numeric order */ enum AUDIO_SOUNDS { AU_TADA, #if defined(CPUARM) @@ -1362,7 +1364,6 @@ enum AUDIO_SOUNDS { AU_THROTTLE_ALERT, AU_SWITCH_ALERT, AU_BAD_RADIODATA, - AU_STORAGE_FORMAT, #endif AU_TX_BATTERY_LOW, AU_INACTIVITY, @@ -1382,6 +1383,7 @@ enum AUDIO_SOUNDS { AU_TELEMETRY_BACK, AU_TRAINER_LOST, AU_TRAINER_BACK, + AU_SENSOR_LOST, #endif #if defined(PCBSKY9X) AU_TX_MAH_HIGH,