diff --git a/radio/src/gui/horus/screens_setup.cpp b/radio/src/gui/horus/screens_setup.cpp index 5a4664cc9..6872963ab 100644 --- a/radio/src/gui/horus/screens_setup.cpp +++ b/radio/src/gui/horus/screens_setup.cpp @@ -78,7 +78,7 @@ bool editZoneOption(coord_t y, const ZoneOption * option, ZoneOptionValue * valu else if (option->type == ZoneOption::Integer) { lcdDrawNumber(SCREENS_SETUP_2ND_COLUMN, y, value->signedValue, attr | LEFT); if (attr) { - CHECK_INCDEC_MODELVAR(event, value->signedValue, -30000, 30000); // TODO i_flags + CHECK_INCDEC_MODELVAR(event, value->signedValue, option->min.signedValue, option->max.signedValue); // TODO i_flags } } else if (option->type == ZoneOption::String) { @@ -129,8 +129,8 @@ bool editZoneOption(coord_t y, const ZoneOption * option, ZoneOptionValue * valu COLOR_SPLIT(value->unsignedValue, r, g, b); lcdSetColor(value->unsignedValue); - lcdDrawSolidFilledRect(SCREENS_SETUP_2ND_COLUMN-1, y-1, 42, 17, TEXT_COLOR); - lcdDrawSolidFilledRect(SCREENS_SETUP_2ND_COLUMN, y, 40, 15, CUSTOM_COLOR); + lcdDrawSolidFilledRect(SCREENS_SETUP_2ND_COLUMN-1, y+1, 42, 17, TEXT_COLOR); + lcdDrawSolidFilledRect(SCREENS_SETUP_2ND_COLUMN, y+2, 40, 15, CUSTOM_COLOR); lcdDrawText(SCREENS_SETUP_2ND_COLUMN + 50, y, "R:", TEXT_COLOR); lcdDrawNumber(SCREENS_SETUP_2ND_COLUMN + 70, y, r << 3, LEFT|TEXT_COLOR|((attr && menuHorizontalPosition == 0) ? attr : 0)); @@ -273,7 +273,7 @@ bool menuWidgetChoice(evt_t event) lcdDrawBitmapPattern(zone.x-10, zone.y+zone.h/2-10, LBM_SWIPE_LEFT, TEXT_INVERTED_COLOR); lcdDrawBitmapPattern(zone.x+zone.w-9, zone.y+zone.h/2-10, LBM_SWIPE_CIRCLE, TEXT_INVERTED_BGCOLOR); lcdDrawBitmapPattern(zone.x+zone.w-9, zone.y+zone.h/2-10, LBM_SWIPE_RIGHT, TEXT_INVERTED_COLOR); - lcdDrawText(zone.x + zone.w, zone.y, currentWidget->getFactory()->getName(), RIGHT | TEXT_COLOR | INVERS); + lcdDrawText(zone.x + zone.w, zone.y-1, currentWidget->getFactory()->getName(), RIGHT | TEXT_COLOR | SMLSIZE | INVERS); return true; } diff --git a/radio/src/gui/horus/themes/default.cpp b/radio/src/gui/horus/themes/default.cpp index ba04cc690..72c9329b2 100644 --- a/radio/src/gui/horus/themes/default.cpp +++ b/radio/src/gui/horus/themes/default.cpp @@ -21,8 +21,8 @@ #include "opentx.h" const ZoneOption OPTIONS_THEME_DEFAULT[] = { - { "Background color", ZoneOption::Color, OPTION_DEFAULT_VALUE_UNSIGNED(WHITE) }, - { "Main color", ZoneOption::Color, OPTION_DEFAULT_VALUE_UNSIGNED(RED) }, + { "Background color", ZoneOption::Color, OPTION_VALUE_UNSIGNED(WHITE) }, + { "Main color", ZoneOption::Color, OPTION_VALUE_UNSIGNED(RED) }, { NULL, ZoneOption::Bool } }; diff --git a/radio/src/gui/horus/widget.h b/radio/src/gui/horus/widget.h index bc02c233a..e6e003b10 100644 --- a/radio/src/gui/horus/widget.h +++ b/radio/src/gui/horus/widget.h @@ -41,15 +41,15 @@ union ZoneOptionValue }; #if defined(_MSC_VER) - #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__ + #define OPTION_VALUE_UNSIGNED(x) uint32_t(x) + #define OPTION_VALUE_SIGNED(x) uint32_t(x) + #define OPTION_VALUE_BOOL(x) uint32_t(x) + #define OPTION_VALUE_STRING(...) *(ZoneOptionValue *)(const char *)__VA_ARGS__ #else - #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(...) *(ZoneOptionValue *)(const char *)__VA_ARGS__ + #define OPTION_VALUE_UNSIGNED(x) { .unsignedValue = (x) } + #define OPTION_VALUE_SIGNED(x) { .signedValue = (x) } + #define OPTION_VALUE_BOOL(x) { .boolValue = (x) } + #define OPTION_VALUE_STRING(...) *(ZoneOptionValue *)(const char *)__VA_ARGS__ #endif struct ZoneOption @@ -69,6 +69,8 @@ struct ZoneOption const char * name; Type type; ZoneOptionValue deflt; + ZoneOptionValue min; + ZoneOptionValue max; }; class WidgetFactory; diff --git a/radio/src/gui/horus/widgets/gauge.cpp b/radio/src/gui/horus/widgets/gauge.cpp index 366a35840..6cb7b357b 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_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) }, + { "Source", ZoneOption::Source, OPTION_VALUE_UNSIGNED(1) }, + { "Min", ZoneOption::Integer, OPTION_VALUE_SIGNED(-RESX), OPTION_VALUE_SIGNED(-RESX), OPTION_VALUE_SIGNED(RESX) }, + { "Max", ZoneOption::Integer, OPTION_VALUE_SIGNED(RESX), OPTION_VALUE_SIGNED(-RESX), OPTION_VALUE_SIGNED(RESX) }, + { "Color", ZoneOption::Color, OPTION_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 bf0c690a6..f14ca69ce 100644 --- a/radio/src/gui/horus/widgets/outputs.cpp +++ b/radio/src/gui/horus/widgets/outputs.cpp @@ -22,7 +22,7 @@ #define RECT_OFFSET 80 #define RECT_WIDTH (w - RECT_OFFSET) -#define ROW_HEIGHT 20 +#define ROW_HEIGHT 17 class OutputsWidget: public Widget { @@ -33,30 +33,32 @@ class OutputsWidget: public Widget } virtual void refresh(); - + uint8_t drawChannels(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint8_t firstChan) { char chanString[] = "CH32"; - uint8_t lastChan = firstChan + h / ROW_HEIGHT; - - for (uint8_t curChan = firstChan; curChan <= lastChan && curChan < 33; curChan++) { - int16_t chanVal = calcRESXto100(channelOutputs[curChan-1]); + uint8_t numChan = h / ROW_HEIGHT; + uint8_t row_height = (h - numChan * ROW_HEIGHT >= numChan ? ROW_HEIGHT + 1 : ROW_HEIGHT); + uint8_t lastChan = firstChan + numChan; + + for (uint8_t curChan = firstChan; curChan < lastChan && curChan < 33; curChan++) { + int16_t chanVal = calcRESXto100(channelOutputs[curChan-1]); strAppend(chanString, "CH"); strAppendSigned(&chanString[2], curChan, 2); - lcdDrawText(x, y + (curChan - firstChan) * ROW_HEIGHT, chanString, SMLSIZE | TEXT_COLOR | LEFT); + lcdDrawText(x, y + (curChan - firstChan) * row_height + 1, chanString, SMLSIZE | TEXT_COLOR | LEFT); strAppendSigned(chanString, chanVal); - lcdDrawText(x + RECT_OFFSET - 2, y + (curChan - firstChan) * ROW_HEIGHT, chanString, SMLSIZE | TEXT_COLOR | RIGHT); + lcdDrawText(x + RECT_OFFSET - 2, y + (curChan - firstChan) * row_height + 1, chanString, SMLSIZE | TEXT_COLOR | RIGHT); if (chanVal > 0) { - lcdDrawSolidFilledRect(x + RECT_OFFSET + RECT_WIDTH / 2, y + (curChan -firstChan) * ROW_HEIGHT, divRoundClosest(RECT_WIDTH * chanVal, 200), ROW_HEIGHT, MAINVIEW_GRAPHICS_COLOR); + lcdDrawSolidFilledRect(x + RECT_OFFSET + RECT_WIDTH / 2, y + (curChan -firstChan) * row_height, divRoundClosest(RECT_WIDTH * chanVal, 200), row_height, MAINVIEW_GRAPHICS_COLOR); } else if (chanVal < 0) { uint16_t startpoint = x + RECT_OFFSET; uint16_t endpoint = startpoint + RECT_WIDTH / 2; uint16_t size = divRoundClosest(- RECT_WIDTH * chanVal, 200); - lcdDrawSolidFilledRect(endpoint - size, y + (curChan - firstChan) * ROW_HEIGHT, size, ROW_HEIGHT, MAINVIEW_GRAPHICS_COLOR); + lcdDrawSolidFilledRect(endpoint - size, y + (curChan - firstChan) * row_height, size, row_height, MAINVIEW_GRAPHICS_COLOR); } - lcdDrawRect(x + RECT_OFFSET, y + (curChan -firstChan) * ROW_HEIGHT, RECT_WIDTH, ROW_HEIGHT); - lcd->drawSolidVerticalLine(x + RECT_OFFSET + RECT_WIDTH / 2, y + (curChan - firstChan) * ROW_HEIGHT, ROW_HEIGHT, MAINVIEW_GRAPHICS_COLOR); + lcdDrawRect(x + RECT_OFFSET, y + (curChan - firstChan) * row_height, RECT_WIDTH, row_height+1); + lcd->drawSolidVerticalLine(x + RECT_OFFSET + RECT_WIDTH / 2, y + (curChan - firstChan) * row_height, row_height, MAINVIEW_GRAPHICS_COLOR); } return lastChan; } @@ -76,7 +78,7 @@ class OutputsWidget: public Widget }; const ZoneOption OutputsWidget::options[] = { - { "First", ZoneOption::Integer, OPTION_DEFAULT_VALUE_UNSIGNED(1) }, + { "First channel", ZoneOption::Integer, OPTION_VALUE_UNSIGNED(1), OPTION_VALUE_UNSIGNED(1), OPTION_VALUE_UNSIGNED(32) }, { NULL, ZoneOption::Bool } }; diff --git a/radio/src/gui/horus/widgets/text.cpp b/radio/src/gui/horus/widgets/text.cpp index 7239abc4c..5a84c41d1 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_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) }, + { "Text", ZoneOption::String, OPTION_VALUE_STRING("\015\347\0\14\377\376\373\364") }, + { "Color", ZoneOption::Color, OPTION_VALUE_UNSIGNED(RED) }, + { "Size", ZoneOption::TextSize, OPTION_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 41137f721..799be4c49 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_UNSIGNED(0) }, + { "Timer source", ZoneOption::Timer, OPTION_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 c84916677..317826816 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_UNSIGNED(MIXSRC_Rud) }, + { "Source", ZoneOption::Source, OPTION_VALUE_UNSIGNED(MIXSRC_Rud) }, { NULL, ZoneOption::Bool } }; diff --git a/radio/src/lua/interface.cpp b/radio/src/lua/interface.cpp index fe266ceb6..c33f99531 100644 --- a/radio/src/lua/interface.cpp +++ b/radio/src/lua/interface.cpp @@ -807,6 +807,16 @@ ZoneOption * createOptionsArray(int reference) luaL_checktype(L, -1, LUA_TNUMBER); // value is number option->deflt.signedValue = lua_tointeger(L, -1); break; + case 3: + luaL_checktype(L, -2, LUA_TNUMBER); // key is number + luaL_checktype(L, -1, LUA_TNUMBER); // value is number + option->min.signedValue = lua_tointeger(L, -1); + break; + case 4: + luaL_checktype(L, -2, LUA_TNUMBER); // key is number + luaL_checktype(L, -1, LUA_TNUMBER); // value is number + option->max.signedValue = lua_tointeger(L, -1); + break; } } option++;