[fix] clean screen before draw new graph
This commit is contained in:
@@ -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("<FG> New freq: %lu", new_freq);
|
||||
ULOG_DEBUG("<PWM> 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("<FG> New ampl: %u", new_ampl);
|
||||
ULOG_DEBUG("<PWM> 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("<FG> New offs: %i", new_offs);
|
||||
ULOG_DEBUG("<PWM> 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("<FG> New phas: %u", new_phas);
|
||||
ULOG_DEBUG("<PWM> 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("<FG> New duty: %u", new_duty);
|
||||
ULOG_DEBUG("<PWM> 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)
|
||||
|
||||
@@ -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("<OFFSLINE> 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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user