Show error message in Lua widgets instead of "disabled"
Also a new function drawTextLines(...) in draw_functions that splits a string over multiple lines
This commit is contained in:
@@ -503,3 +503,28 @@ void drawHexNumber(BitmapBuffer * dc, coord_t x, coord_t y, uint32_t val, LcdFla
|
||||
x = dc->drawSizedText(x, y, &c, 1, flags);
|
||||
}
|
||||
}
|
||||
|
||||
void drawTextLines(BitmapBuffer * dc, coord_t left, coord_t top, coord_t width, coord_t height, char * str, LcdFlags flags)
|
||||
{
|
||||
coord_t x = left;
|
||||
coord_t y = top;
|
||||
coord_t line = getFontHeight(flags & 0xFFFF);
|
||||
coord_t space = getTextWidth(" ", 1, flags);
|
||||
coord_t word;
|
||||
char * eos = str + strlen(str);
|
||||
char * nxt;
|
||||
|
||||
while (str < eos) {
|
||||
nxt = strstr(str, " ");
|
||||
if (!nxt) nxt = eos;
|
||||
word = getTextWidth(str, nxt - str, flags);
|
||||
if (x + word > left + width && x > left) {
|
||||
x = left;
|
||||
y += line;
|
||||
}
|
||||
if (y + line > top + height) break;
|
||||
dc->drawSizedText(x, y, str, nxt - str, flags);
|
||||
str = nxt + 1;
|
||||
x += word + space;
|
||||
}
|
||||
}
|
||||
@@ -72,6 +72,7 @@ void drawGPSPosition(BitmapBuffer * dc, coord_t x, coord_t y, int32_t longitude,
|
||||
void drawDate(BitmapBuffer * dc, coord_t x, coord_t y, TelemetryItem & telemetryItem, LcdFlags flags = 0);
|
||||
void drawValueWithUnit(BitmapBuffer * dc, coord_t x, coord_t y, int val, uint8_t unit, LcdFlags flags = 0);
|
||||
void drawHexNumber(BitmapBuffer * dc, coord_t x, coord_t y, uint32_t val, LcdFlags flags = 0);
|
||||
void drawTextLines(BitmapBuffer * dc, coord_t left, coord_t top, coord_t width, coord_t height, char * str, LcdFlags flags);
|
||||
inline void drawChn(BitmapBuffer * dc, coord_t x, coord_t y, uint8_t idx, LcdFlags flags)
|
||||
{
|
||||
drawSource(dc, x, y, MIXSRC_CH1 + idx - 1, flags);
|
||||
|
||||
Reference in New Issue
Block a user