[fix] wrong display marker in phase helper

This commit is contained in:
2023-05-01 15:59:10 +02:00
parent f0f71f3252
commit 8c0137a59c

View File

@@ -12,13 +12,14 @@
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
#define FREQ_MAX_DIGIT 7
#define AMPL_MAX_DIGIT 3
#define SEVEN_DIGIT 7
#define FOUR_DIGIT 3
#define THREE_DIGIT 2
const uint8_t btn_pos_x[DISP_BTN_MAX] = {0, 26, 52, 78, 104};
const uint8_t marker_freq_pos_x[FREQ_MAX_DIGIT] = {76, 84, 90, 96, 105, 111, 118};
const uint8_t marker_ampl_pos_x[AMPL_MAX_DIGIT] = {82, 94, 100};
const uint8_t marker_phas_pos_x[AMPL_MAX_DIGIT] = {82, 88, 96};
const uint8_t marker_pos_7dig[SEVEN_DIGIT] = {76, 84, 90, 96, 105, 111, 118};
const uint8_t marker_pos_4dig[FOUR_DIGIT] = {82, 94, 100};
const uint8_t marker_pos_3dig[THREE_DIGIT] = {82, 88};
// clang-format off
const GFX_bitmap_t marker_down = {05, 03, (uint8_t[]){0x01,0x03,0x07,0x03,0x01}};// res: 5x3(8) - 5 bytes
@@ -109,7 +110,7 @@ static void _drawButtons(GFX_display_t *disp, APP_data_t *app_data)
static uint8_t _calcMarkerPos(uint32_t value, uint32_t max)
{
return ((62 * value) + (max / 2)) / max;
return ((61 * value) + (max / 2)) / max;
// return (value < 0) ? ((62 * value) - (max / 2)) / max : ((62 * value) + (max / 2)) / max;
}
@@ -150,7 +151,7 @@ static void _drawFreqValueHelper(GFX_display_t *disp, uint32_t freq, uint8_t foc
DISP_clearRegion(disp, 64, 13, 66, 40);
DISP_writeString(disp, &font5x7Info, (uint8_t *)"F:", 64, 20, BM_NORMAL);
_drawFreqValue(disp, freq, 20);
DISP_drawBitmap(disp, &marker_down, marker_freq_pos_x[(FREQ_MAX_DIGIT - 1) - focus_digit], 15, BM_NORMAL);
DISP_drawBitmap(disp, &marker_down, marker_pos_7dig[(SEVEN_DIGIT - 1) - focus_digit], 15, BM_NORMAL);
}
static void _drawAmplValueHelper(GFX_display_t *disp, uint32_t ampl, uint8_t focus_digit)
@@ -158,7 +159,7 @@ static void _drawAmplValueHelper(GFX_display_t *disp, uint32_t ampl, uint8_t foc
DISP_clearRegion(disp, 64, 13, 66, 40);
DISP_writeString(disp, &font5x7Info, (uint8_t *)"A:", 64, 20, BM_NORMAL);
_drawAmplValue(disp, ampl, 20);
DISP_drawBitmap(disp, &marker_down, marker_ampl_pos_x[(AMPL_MAX_DIGIT - 1) - focus_digit], 15, BM_NORMAL);
DISP_drawBitmap(disp, &marker_down, marker_pos_4dig[(FOUR_DIGIT - 1) - focus_digit], 15, BM_NORMAL);
}
static void _drawOffsValueHelper(GFX_display_t *disp, int32_t offs, uint8_t focus_digit)
@@ -166,7 +167,7 @@ static void _drawOffsValueHelper(GFX_display_t *disp, int32_t offs, uint8_t focu
DISP_clearRegion(disp, 64, 13, 66, 40);
DISP_writeString(disp, &font5x7Info, (uint8_t *)"O:", 64, 20, BM_NORMAL);
_drawOffsValue(disp, offs, 20);
DISP_drawBitmap(disp, &marker_down, marker_ampl_pos_x[(AMPL_MAX_DIGIT - 1) - focus_digit], 15, BM_NORMAL);
DISP_drawBitmap(disp, &marker_down, marker_pos_4dig[(FOUR_DIGIT - 1) - focus_digit], 15, BM_NORMAL);
}
static void _drawPhaseValueHelper(GFX_display_t *disp, uint32_t phase, uint8_t focus_digit)
@@ -174,7 +175,7 @@ static void _drawPhaseValueHelper(GFX_display_t *disp, uint32_t phase, uint8_t f
DISP_clearRegion(disp, 64, 13, 66, 40);
DISP_writeString(disp, &font5x7Info, (uint8_t *)"P:", 64, 20, BM_NORMAL);
_drawPhasValue(disp, phase, 20);
DISP_drawBitmap(disp, &marker_down, marker_phas_pos_x[(AMPL_MAX_DIGIT - 1) - focus_digit], 15, BM_NORMAL);
DISP_drawBitmap(disp, &marker_down, marker_pos_3dig[(THREE_DIGIT - 1) - focus_digit], 15, BM_NORMAL);
}
static void _drawFuncGenValues(GFX_display_t *disp, APP_data_t *app_data)