1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-18 05:45:21 +03:00

Default options for widgets / layouts / themes now OK on VC++

This commit is contained in:
Bertrand Songis 2016-03-10 18:42:04 +01:00
parent 62df9831d8
commit c521fce20b
8 changed files with 27 additions and 19 deletions

View file

@ -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 }
};

View file

@ -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

View file

@ -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 }
};

View file

@ -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 }
};

View file

@ -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 }
};

View file

@ -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 }
};

View file

@ -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 }
};

View file

@ -1043,6 +1043,9 @@ void checkModelIdUnique(uint8_t index, uint8_t module);
inline int divRoundClosest(const int n, const int d)
{
if (d == 0)
return 0;
else
return ((n < 0) ^ (d < 0)) ? ((n - d/2)/d) : ((n + d/2)/d);
}
@ -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,