Skip to content

Commit

Permalink
fix(B&W): Fixes for inputs, mixes and curves screens (#3299)
Browse files Browse the repository at this point in the history
* Fixes for B&W radio UI screens.

* Fix curve display to fit new size. Adjust curve for better horizontal symmetry. Adjust position crosshair to better fit curve line.
  • Loading branch information
philmoz authored Mar 8, 2023
1 parent da428b4 commit bd1094f
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 22 deletions.
4 changes: 2 additions & 2 deletions radio/src/gui/128x64/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
#define TEXT_VIEWER_LINES NUM_BODY_LINES
#define MENU_HEADER_HEIGHT FH

#define CURVE_SIDE_WIDTH (LCD_H/2)
#define CURVE_CENTER_X (LCD_W-CURVE_SIDE_WIDTH-2)
#define CURVE_SIDE_WIDTH (LCD_H/2-2)
#define CURVE_CENTER_X (LCD_W-CURVE_SIDE_WIDTH-3)
#define CURVE_CENTER_Y (LCD_H/2)

#define MIXES_2ND_COLUMN (12*FW)
Expand Down
14 changes: 9 additions & 5 deletions radio/src/gui/128x64/lcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,10 @@ void lcdDrawChar(coord_t x, coord_t y, uint8_t c)
uint8_t getTextWidth(const char * s, uint8_t len, LcdFlags flags)
{
uint8_t width = 0;
for (int i = 0; len == 0 || i < len; ++i) {
if (len == 0) len = strlen(s);
while (len--) {
#if !defined(BOOT)
unsigned char c = *s;
unsigned char c = map_utf8_char(s, len);
#else
unsigned char c = *s;
#endif
Expand Down Expand Up @@ -788,10 +789,13 @@ void drawSource(coord_t x, coord_t y, uint32_t idx, LcdFlags att)
else if (idx < MIXSRC_CH1)
drawStringWithIndex(x, y, STR_PPM_TRAINER, idx-MIXSRC_FIRST_TRAINER+1, att);
else if (idx <= MIXSRC_LAST_CH) {
drawStringWithIndex(x, y, STR_CH, idx-MIXSRC_CH1+1, att);
if (ZEXIST(g_model.limitData[idx-MIXSRC_CH1].name) && (att & STREXPANDED)) {
lcdDrawChar(lcdLastRightPos, y, ' ', att|SMLSIZE);
lcdDrawSizedText(lcdLastRightPos+3, y, g_model.limitData[idx-MIXSRC_CH1].name, LEN_CHANNEL_NAME, att|SMLSIZE);
char s[LEN_CHANNEL_NAME + 3];
strcpy(s, STR_CHAR_CHANNEL);
strcat(s, g_model.limitData[idx-MIXSRC_CH1].name);
lcdDrawSizedText(x, y, s, LEN_CHANNEL_NAME+2, att);
} else {
drawStringWithIndex(x, y, STR_CH, idx-MIXSRC_CH1+1, att);
}
}
else if (idx <= MIXSRC_LAST_GVAR) {
Expand Down
4 changes: 2 additions & 2 deletions radio/src/gui/212x64/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
#define MODEL_BITMAP_SIZE BITMAP_BUFFER_SIZE(MODEL_BITMAP_WIDTH, MODEL_BITMAP_HEIGHT)
#define LOAD_MODEL_BITMAP() loadModelBitmap(g_model.header.bitmap, modelBitmap)

#define CURVE_SIDE_WIDTH (LCD_H/2)
#define CURVE_CENTER_X (LCD_W-CURVE_SIDE_WIDTH-2)
#define CURVE_SIDE_WIDTH (LCD_H/2-2)
#define CURVE_CENTER_X (LCD_W-CURVE_SIDE_WIDTH-3)
#define CURVE_CENTER_Y (LCD_H/2)

#define MIXES_2ND_COLUMN (18*FW)
Expand Down
28 changes: 15 additions & 13 deletions radio/src/gui/common/stdlcd/model_curves.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,22 +159,24 @@ void editCurveRef(coord_t x, coord_t y, CurveRef & curve, event_t event, LcdFlag

void drawFunction(FnFuncP fn, uint8_t offset)
{
lcdDrawVerticalLine(CURVE_CENTER_X - offset, CURVE_CENTER_Y-CURVE_SIDE_WIDTH, CURVE_SIDE_WIDTH * 2, 0xee);
lcdDrawHorizontalLine(CURVE_CENTER_X - CURVE_SIDE_WIDTH - offset, CURVE_CENTER_Y, CURVE_SIDE_WIDTH * 2, 0xee);
lcdDrawVerticalLine(CURVE_CENTER_X - offset, CURVE_CENTER_Y-CURVE_SIDE_WIDTH, CURVE_SIDE_WIDTH * 2 + 1, 0xee);
lcdDrawHorizontalLine(CURVE_CENTER_X - CURVE_SIDE_WIDTH - offset, CURVE_CENTER_Y, CURVE_SIDE_WIDTH * 2 + 1, 0xbb);

coord_t prev_yv = (coord_t) - 1;
coord_t prev_yv;

for (int xv = -CURVE_SIDE_WIDTH; xv <= CURVE_SIDE_WIDTH; xv++) {
coord_t yv = (LCD_H - 1) - (((uint16_t)RESX + fn(xv * (RESX/CURVE_SIDE_WIDTH))) / 2 * (LCD_H - 1) / RESX);
if (prev_yv != (coord_t) - 1) {
if (abs((int8_t)yv-prev_yv) <= 1) {
lcdDrawPoint(CURVE_CENTER_X + xv - offset - 1, prev_yv, FORCE);
}
else {
uint8_t tmp = (prev_yv < yv ? 0 : 1);
lcdDrawSolidVerticalLine(CURVE_CENTER_X + xv - offset - 1, yv + tmp, prev_yv - yv);
coord_t yv = -(fn((xv * RESX) / CURVE_SIDE_WIDTH) * (CURVE_SIDE_WIDTH*2+1) / (RESX*2));
if ((xv > -CURVE_SIDE_WIDTH) && (abs((int8_t)yv-prev_yv) > 1)) {
int len = 0;
if (yv > prev_yv) {
len = yv - prev_yv - 1;
} else {
len = prev_yv - yv - 1;
prev_yv = yv;
}
lcdDrawSolidVerticalLine(CURVE_CENTER_X + xv - offset + ((xv<0) ? 0 : -1), CURVE_CENTER_Y + prev_yv + 1, len);
}
lcdDrawPoint(CURVE_CENTER_X + xv - offset, CURVE_CENTER_Y + yv, FORCE);
prev_yv = yv;
}
}
Expand All @@ -195,8 +197,8 @@ void drawCursor(FnFuncP fn, uint8_t offset)
y512 = limit(-1024, y512, 1024);
lcdDrawNumber(CURVE_CENTER_X - FWNUM - offset, 1*FH, calcRESXto1000(y512), RIGHT | PREC1);

x512 = CURVE_CENTER_X + x512/(RESX / CURVE_SIDE_WIDTH);
y512 = (LCD_H - 1) - ((y512 + RESX) / 2) * (LCD_H - 1) / RESX;
x512 = CURVE_CENTER_X + (x512 * CURVE_SIDE_WIDTH + (x512 < 0 ? -RESX/2 : RESX/2)) / RESX;
y512 = CURVE_CENTER_Y - (y512 * CURVE_SIDE_WIDTH + (y512 < 0 ? -RESX/2 : RESX/2)) / RESX;

lcdDrawSolidVerticalLine(x512 - offset, y512-3, 3 * 2 + 1);
lcdDrawSolidHorizontalLine(x512 - 3 - offset, y512, 3 * 2 + 1);
Expand Down
1 change: 1 addition & 0 deletions radio/src/gui/common/stdlcd/model_mixes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ void displayMixInfos(coord_t y, MixData * md)
void displayMixLine(coord_t y, MixData * md, bool active)
{
if(active && md->name[0]) {
lcdDrawFilledRect(FW*sizeof(TR_MIXES)+FW/2, 0, FW*4+1, MENU_HEADER_HEIGHT, 0xFF, ERASE);
lcdDrawSizedText(FW*sizeof(TR_MIXES)+FW/2, 0, md->name, sizeof(md->name), 0);
if (!md->flightModes || ((md->curve.value || md->swtch) && ((get_tmr10ms() / 200) & 1)))
displayMixInfos(y, md);
Expand Down

0 comments on commit bd1094f

Please sign in to comment.