Repo unification

This commit is contained in:
2024-03-12 21:22:26 +02:00
parent 7aa7edba33
commit 02cb3a9c70
152 changed files with 14575 additions and 2038 deletions

View File

@@ -0,0 +1,108 @@
/**** Includes ****/
#include "display.h"
/**** Private definitions ****/
/**** Private constants ****/
static const uint8_t BACKLIGHT_DIMM = DSP_BACKLIGHT_DIMM_PERCENT;
static const uint8_t BACKLIGHT_BRIGTH = DSP_BACKLIGHT_BRIGTH_PERCENT;
/**** Private variables ****/
/**** Private function declarations ****/
static uint8_t img_gen_dot10(uint8_t percent);
static uint8_t img_gen_dot20(uint8_t percent);
static uint8_t img_gen_bar(uint8_t percent);
/**** Public function definitions ****/
void dsp_init_ctrl(dsp_ctrl_t* ctrl)
{
ctrl->img_lock = 0;
ctrl->act_img = 0x00;
}
void dsp_set_lock(dsp_ctrl_t* ctrl)
{
ctrl->img_lock = 1;
}
void dsp_reset_lock(dsp_ctrl_t* ctrl)
{
ctrl->img_lock = 0;
}
uint8_t dsp_img_percent(uint8_t value, dsp_style_t style, dsp_ctrl_t* ctrl)
{
if(ctrl->img_lock) return ctrl->act_img;
switch(style)
{
case LED_DSP_BAR:
ctrl->act_img = img_gen_bar(value);
break;
case LED_DSP_DOT10:
ctrl->act_img = img_gen_dot10(value);
break;
default:
ctrl->act_img = img_gen_dot20(value);
break;
}
return ctrl->act_img;
}
uint8_t dsp_img_raw(uint8_t image, dsp_ctrl_t* ctrl)
{
if(ctrl->img_lock) return ctrl->act_img;
ctrl->act_img = image & 0x3F;
return ctrl->act_img;
}
uint8_t dsp_get_act_img(dsp_ctrl_t* ctrl)
{
return ctrl->act_img;
}
uint8_t dsp_backlight(uint8_t dimm_act)
{
if(dimm_act) return BACKLIGHT_DIMM;
else return BACKLIGHT_BRIGTH;
}
/**** Private function definitions ****/
static uint8_t img_gen_dot10(uint8_t percent)
{
if(percent<6) return 0x01;
else if(percent<16) return 0x03;
else if(percent<26) return 0x02;
else if(percent<36) return 0x06;
else if(percent<46) return 0x04;
else if(percent<56) return 0x0C;
else if(percent<66) return 0x08;
else if(percent<76) return 0x18;
else if(percent<86) return 0x10;
else if(percent<96) return 0x30;
else return 0x20;
}
static uint8_t img_gen_dot20(uint8_t percent)
{
if(percent<11) return 0x01;
else if(percent<31) return 0x02;
else if(percent<51) return 0x04;
else if(percent<71) return 0x08;
else if(percent<91) return 0x10;
else return 0x20;
}
static uint8_t img_gen_bar(uint8_t percent)
{
if(percent<11) return 0x01;
else if(percent<31) return 0x03;
else if(percent<51) return 0x07;
else if(percent<71) return 0x0F;
else if(percent<91) return 0x1F;
else return 0x3F;
}