Fix mixer knob outline at max volume by seating the knob on the track capsule ends.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
c1b32c0351
commit
a818065c2e
|
|
@ -53,8 +53,33 @@ void DrawAllFaders(void)
|
|||
drv_nvm_save_to_flash();
|
||||
}
|
||||
|
||||
/* 0902-06:实心蓝色圆钮(勿用同心空心圆,会透出色条) */
|
||||
#define MIXER_KNOB_R 14
|
||||
/* 0902-06:圆钮定位半径 = 色条半宽;填充略大以盖住柱端抗锯齿白边(夹紧不画出柱外) */
|
||||
#define MIXER_KNOB_R 15
|
||||
#define MIXER_KNOB_FILL_R 16
|
||||
#define MIXER_TRACK_HALF_W 15
|
||||
|
||||
/* 与柱端半圆同形的实心圆钮:顶/底档位与色条圆角完美贴合,无虚线白边 */
|
||||
static void DrawMixerKnob(uint16_t cx, uint16_t cy)
|
||||
{
|
||||
int16_t dy;
|
||||
int32_t r2 = (int32_t)MIXER_KNOB_FILL_R * (int32_t)MIXER_KNOB_FILL_R;
|
||||
for (dy = -(int16_t)MIXER_KNOB_R; dy <= (int16_t)MIXER_KNOB_R; dy++)
|
||||
{
|
||||
int32_t xx = r2 - (int32_t)dy * (int32_t)dy;
|
||||
int16_t dx = 0;
|
||||
int16_t half;
|
||||
if (xx < 0)
|
||||
continue;
|
||||
while ((int32_t)(dx + 1) * (dx + 1) <= xx)
|
||||
dx++;
|
||||
half = dx;
|
||||
if (half > (int16_t)MIXER_TRACK_HALF_W)
|
||||
half = (int16_t)MIXER_TRACK_HALF_W;
|
||||
LCD_FillByColor((uint16_t)(cx - half), (uint16_t)(cy + dy),
|
||||
(uint16_t)(cx + half + 1), (uint16_t)(cy + dy + 1),
|
||||
COLOR_GRAD_MID);
|
||||
}
|
||||
}
|
||||
|
||||
static void DrawFaderSlider(Fader_t *f, uint16_t slider_y)
|
||||
{
|
||||
|
|
@ -62,9 +87,9 @@ static void DrawFaderSlider(Fader_t *f, uint16_t slider_y)
|
|||
uint16_t ly = f->y + f->h + 8;
|
||||
uint16_t cy = (uint16_t)(slider_y + MIXER_KNOB_R);
|
||||
char buf[8];
|
||||
LCD_FillCircle(cx, cy, MIXER_KNOB_R, COLOR_GRAD_MID);
|
||||
DrawMixerKnob(cx, cy);
|
||||
sprintf(buf, "%d", f->val);
|
||||
LCD_ShowString_AutoAlign((uint16_t)(cx - 8), (uint16_t)(cx + 8),
|
||||
LCD_ShowString_AutoAlign((uint16_t)(cx - 10), (uint16_t)(cx + 10),
|
||||
(uint16_t)(cy - 5),
|
||||
(uint8_t*)buf, LCD_ALIGN_CENTER, WHITE, COLOR_GRAD_MID, 0, 11);
|
||||
LCD_FillByColor(cx - 15, ly + 17, cx + 15, ly + 19, UI0902_BG_COLOR);
|
||||
|
|
@ -149,17 +174,14 @@ void UpdateFaderByTouch(int idx, uint16_t y)
|
|||
}
|
||||
|
||||
// ============================================================
|
||||
// ??????Y????????val? 0~10??
|
||||
// 滑块顶边 Y:val0/10 时圆心落在色条底/顶半圆中心,两端对称贴合
|
||||
// ============================================================
|
||||
static uint16_t CalcSliderY(Fader_t *f)
|
||||
{
|
||||
uint16_t slider_h = (uint16_t)(MIXER_KNOB_R * 2);
|
||||
uint16_t fill_h = (f->val * f->h) / 10;
|
||||
if (fill_h > f->h) fill_h = f->h;
|
||||
uint16_t slider_y = f->y + f->h - fill_h - (slider_h / 2);
|
||||
if (slider_y < f->y) slider_y = f->y;
|
||||
if (slider_y > f->y + f->h - slider_h) slider_y = f->y + f->h - slider_h;
|
||||
return slider_y;
|
||||
uint16_t top_cy = (uint16_t)(f->y + MIXER_KNOB_R);
|
||||
uint16_t bot_cy = (uint16_t)(f->y + f->h - 1 - MIXER_KNOB_R);
|
||||
uint16_t cy = (uint16_t)(bot_cy - ((uint32_t)(bot_cy - top_cy) * f->val) / 10);
|
||||
return (uint16_t)(cy - MIXER_KNOB_R);
|
||||
}
|
||||
|
||||
int CheckTouchFader(uint16_t x, uint16_t y)
|
||||
|
|
|
|||
Loading…
Reference in New Issue