diff --git a/firmware/shared_libs/controllers/ctrl_app.c b/firmware/shared_libs/controllers/ctrl_app.c index 4d76d96..d4004d4 100644 --- a/firmware/shared_libs/controllers/ctrl_app.c +++ b/firmware/shared_libs/controllers/ctrl_app.c @@ -136,8 +136,11 @@ static void _changeValueFunGen(int8_t dir) } default: ULOG_ERROR("%s:%d: Unknown layout: %d", __FILE__, __LINE__, _app_data->curr_state_lay); - break; + return; } + + _app_data->isValueChange = 1; + _app_data->isGraphChange = 1; } static void _changeValuePwmGen(int8_t dir) @@ -149,7 +152,7 @@ static void _changeValuePwmGen(int8_t dir) case LAY_FREQ: { uint32_t new_freq = dir * pow_of_10[_app_data->freq_focus_digit] + gen->frequency; - ULOG_DEBUG(" New freq: %lu", new_freq); + ULOG_DEBUG(" New freq: %lu", new_freq); if (new_freq > MAX_FREQ) { return; @@ -160,7 +163,7 @@ static void _changeValuePwmGen(int8_t dir) case LAY_AMPL: { uint16_t new_ampl = dir * pow_of_10[_app_data->ampl_focus_digit] + gen->amplitude; - ULOG_DEBUG(" New ampl: %u", new_ampl); + ULOG_DEBUG(" New ampl: %u", new_ampl); if (gen->offset + new_ampl > MAX_VOLT_POS || gen->offset - new_ampl < MAX_VOLT_NEG) { return; @@ -171,7 +174,7 @@ static void _changeValuePwmGen(int8_t dir) case LAY_OFFS: { int16_t new_offs = dir * pow_of_10[_app_data->offs_focus_digit] + gen->offset; - ULOG_DEBUG(" New offs: %i", new_offs); + ULOG_DEBUG(" New offs: %i", new_offs); if (new_offs + gen->amplitude > MAX_VOLT_POS || new_offs - gen->amplitude < MAX_VOLT_NEG) { return; @@ -182,7 +185,7 @@ static void _changeValuePwmGen(int8_t dir) case LAY_PHAS: { uint16_t new_phas = dir * pow_of_10[_app_data->phas_focus_digit] + gen->phase; - ULOG_DEBUG(" New phas: %u", new_phas); + ULOG_DEBUG(" New phas: %u", new_phas); if (new_phas > MAX_PHAS) { return; @@ -193,7 +196,7 @@ static void _changeValuePwmGen(int8_t dir) case LAY_DUTY: { uint8_t new_duty = dir * pow_of_10[_app_data->duty_focus_digit] + gen->duty; - ULOG_DEBUG(" New duty: %u", new_duty); + ULOG_DEBUG(" New duty: %u", new_duty); if (new_duty > MAX_DUTY) { return; @@ -202,8 +205,12 @@ static void _changeValuePwmGen(int8_t dir) break; } default: - break; + ULOG_ERROR("%s:%d: Unknown layout: %d", __FILE__, __LINE__, _app_data->curr_state_lay); + return; } + + _app_data->isValueChange = 1; + _app_data->isGraphChange = 1; } void CTRL_encoderEvent(int8_t enc) @@ -219,11 +226,9 @@ void CTRL_encoderEvent(int8_t enc) break; default: - ULOG_ERROR("%s:%d: Unknown generator type.", __FILE__, __LINE__); + ULOG_ERROR("%s:%d: Unknown generator type: %d", __FILE__, __LINE__, _app_data->curr_gen_type); break; } - - _app_data->isValueChange = 1; } inline BITMAP_buttonName_t CTRL_getBitmapName(LAY_dispBtn_t disp_btn) diff --git a/firmware/shared_libs/disp_layout/disp_layout.c b/firmware/shared_libs/disp_layout/disp_layout.c index 42e9ff3..b407123 100644 --- a/firmware/shared_libs/disp_layout/disp_layout.c +++ b/firmware/shared_libs/disp_layout/disp_layout.c @@ -8,7 +8,9 @@ #include "disp_layout.h" -#define abs(x) ((x) < 0 ? -(x) : (x)) +#define ABS(x) ((x) < 0 ? -(x) : (x)) +#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 @@ -43,7 +45,7 @@ static void _drawAmplValue(GFX_display_t *disp, uint16_t ampl, uint8_t pos_y) static void _drawOffsValue(GFX_display_t *disp, int16_t offs, uint8_t pos_y) { uint8_t data[8]; - snprintf((char *)data, 8, "%+01d.%02d V", offs / 100, abs(offs) % 100); + snprintf((char *)data, 8, "%+01d.%02d V", offs / 100, ABS(offs) % 100); if (offs < 0) { data[0] = '-'; @@ -241,18 +243,13 @@ static void _drawValues(GFX_display_t *disp, APP_data_t *app_data) static void _drawOffsetLine(GFX_display_t *disp, int16_t offs, uint32_t ampl) { - int8_t offs_shift = _calcVerticalShiftInPxl(offs, ampl); + int8_t vert_shift = _calcVerticalShiftInPxl(offs, ampl); - if (offs_shift > 20) - { - offs_shift = 20; - } - if (offs_shift < -19) - { - offs_shift = -19; - } + vert_shift = MIN(vert_shift, 20); + vert_shift = MAX(vert_shift, -19); - DISP_drawHorizontalLine(disp, 2, 31 + offs_shift, 57, GFX_WHITE); + ULOG_TRACE(" shift: %i", vert_shift); + DISP_drawHorizontalLine(disp, 2, 31 + vert_shift, 57, GFX_WHITE); } // static void _drawMaxAmpLine(GFX_display_t *disp, int16_t offs, uint32_t ampl) @@ -267,6 +264,7 @@ static void _drawOffsetLine(GFX_display_t *disp, int16_t offs, uint32_t ampl) static void _drawFunGenGraph(GFX_display_t *disp, APP_data_t *app_data) { GEN_fg_t *fun_gen = (GEN_fg_t *)app_data->generator; + DISP_clearRegion(disp, 3, 12, 57, 40); switch (fun_gen->wave) {