mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-22 15:24:16 +08:00
Merge branch 'dev-6.0' into manison-feature/theme_focus_cb
This commit is contained in:
@@ -78,6 +78,14 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st
|
||||
pos.x = coords->x1;
|
||||
pos.y = coords->y1;
|
||||
|
||||
lv_coord_t x_ofs = 0;
|
||||
lv_coord_t y_ofs = 0;
|
||||
if(offset != NULL) {
|
||||
x_ofs = offset->x;
|
||||
y_ofs = offset->y;
|
||||
pos.y += y_ofs;
|
||||
}
|
||||
|
||||
uint32_t line_start = 0;
|
||||
uint32_t line_end = lv_txt_get_next_line(txt, font, style->text.letter_space, w, flag);
|
||||
|
||||
@@ -115,14 +123,6 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st
|
||||
lv_color_t recolor;
|
||||
lv_coord_t letter_w;
|
||||
|
||||
lv_coord_t x_ofs = 0;
|
||||
lv_coord_t y_ofs = 0;
|
||||
if(offset != NULL) {
|
||||
x_ofs = offset->x;
|
||||
y_ofs = offset->y;
|
||||
pos.y += y_ofs;
|
||||
}
|
||||
|
||||
/*Real draw need a background color for higher bpp letter*/
|
||||
#if LV_VDB_SIZE == 0
|
||||
lv_rletter_set_background(style->body.main_color);
|
||||
|
||||
+23
-42
@@ -8,6 +8,7 @@
|
||||
*********************/
|
||||
#include "lv_math.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@@ -34,7 +35,7 @@ static int16_t sin0_90_table[] = {
|
||||
28377, 28659, 28932, 29196, 29451, 29697, 29934, 30162, 30381, 30591,
|
||||
30791, 30982, 31163, 31335, 31498, 31650, 31794, 31927, 32051, 32165,
|
||||
32269, 32364, 32448, 32523, 32587, 32642, 32687, 32722, 32747, 32762,
|
||||
32767
|
||||
32767
|
||||
};
|
||||
|
||||
|
||||
@@ -54,53 +55,33 @@ static int16_t sin0_90_table[] = {
|
||||
*/
|
||||
char * lv_math_num_to_str(int32_t num, char * buf)
|
||||
{
|
||||
char * buf_ori = buf;
|
||||
if(num == 0) {
|
||||
if (num == 0) {
|
||||
buf[0] = '0';
|
||||
buf[1] = '\0';
|
||||
return buf;
|
||||
} else if(num < 0) {
|
||||
(*buf) = '-';
|
||||
buf++;
|
||||
num = LV_MATH_ABS(num);
|
||||
}
|
||||
uint32_t output = 0;
|
||||
int8_t i;
|
||||
|
||||
for(i = 31; i >= 0; i--) {
|
||||
if((output & 0xF) >= 5)
|
||||
output += 3;
|
||||
if(((output & 0xF0) >> 4) >= 5)
|
||||
output += (3 << 4);
|
||||
if(((output & 0xF00) >> 8) >= 5)
|
||||
output += (3 << 8);
|
||||
if(((output & 0xF000) >> 12) >= 5)
|
||||
output += (3 << 12);
|
||||
if(((output & 0xF0000) >> 16) >= 5)
|
||||
output += (3 << 16);
|
||||
if(((output & 0xF00000) >> 20) >= 5)
|
||||
output += (3 << 20);
|
||||
if(((output & 0xF000000) >> 24) >= 5)
|
||||
output += (3 << 24);
|
||||
if(((output & 0xF0000000) >> 28) >= 5)
|
||||
output += (3 << 28);
|
||||
output = (output << 1) | ((num >> i) & 1);
|
||||
int8_t digitCount = 0;
|
||||
int8_t i = 0;
|
||||
if (num < 0) {
|
||||
buf[digitCount++] = '-';
|
||||
num = abs(num);
|
||||
++i;
|
||||
}
|
||||
|
||||
uint8_t digit;
|
||||
bool leading_zero_ready = false;
|
||||
for(i = 28; i >= 0; i -= 4) {
|
||||
digit = ((output >> i) & 0xF) + '0';
|
||||
if(digit == '0' && leading_zero_ready == false) continue;
|
||||
|
||||
leading_zero_ready = true;
|
||||
(*buf) = digit;
|
||||
buf++;
|
||||
while (num) {
|
||||
char digit = num % 10;
|
||||
buf[digitCount++] = digit + 48;
|
||||
num /= 10;
|
||||
}
|
||||
|
||||
(*buf) = '\0';
|
||||
|
||||
return buf_ori;
|
||||
buf[digitCount] = '\0';
|
||||
digitCount--;
|
||||
while (digitCount > i) {
|
||||
char temp = buf[i];
|
||||
buf[i] = buf[digitCount];
|
||||
buf[digitCount] = temp;
|
||||
digitCount--;
|
||||
i++;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+3
-3
@@ -19,9 +19,9 @@ extern "C" {
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_MATH_MIN(a,b) (a<b?a:b)
|
||||
#define LV_MATH_MAX(a,b) (a>b?a:b)
|
||||
#define LV_MATH_ABS(x) ((x)>0?(x):(-(x)))
|
||||
#define LV_MATH_MIN(a,b) ((a) < (b) ? (a) : (b))
|
||||
#define LV_MATH_MAX(a,b) ((a) > (b) ? (a) : (b))
|
||||
#define LV_MATH_ABS(x) ((x) > 0 ? (x) : (-(x)))
|
||||
|
||||
#define LV_TRIGO_SIN_MAX 32767
|
||||
#define LV_TRIGO_SHIFT 15 /* >> LV_TRIGO_SHIFT to normalize*/
|
||||
|
||||
@@ -73,7 +73,7 @@ extern "C" {
|
||||
#define SYMBOL_BATTERY_EMPTY _SYMBOL_VALUE1(F0)
|
||||
#define SYMBOL_BLUETOOTH _SYMBOL_VALUE1(F1)
|
||||
#define LV_SYMBOL_GLYPH_LAST 0xF1
|
||||
#define SYMBOL_DUMMY _SYMBOL_VALUE1(xFF) /*Invalid symbol. If written before a string then `lv_img` will show it as a label*/
|
||||
#define SYMBOL_DUMMY _SYMBOL_VALUE1(FF) /*Invalid symbol. If written before a string then `lv_img` will show it as a label*/
|
||||
|
||||
#else
|
||||
#define LV_SYMBOL_GLYPH_FIRST 0xF800
|
||||
|
||||
+4
-3
@@ -175,9 +175,10 @@ void lv_chart_clear_serie(lv_obj_t * chart, lv_chart_series_t * serie)
|
||||
if(chart == NULL || serie == NULL)
|
||||
return;
|
||||
lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart);
|
||||
if(ext == NULL)
|
||||
return;
|
||||
for(uint32_t i = 0; i < ext->point_cnt; i++)
|
||||
if(ext == NULL) return;
|
||||
|
||||
uint32_t i;
|
||||
for(i = 0; i < ext->point_cnt; i++)
|
||||
{
|
||||
serie->points[i] = LV_CHART_POINT_DEF;
|
||||
}
|
||||
|
||||
@@ -624,6 +624,7 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par
|
||||
} else if(sign == LV_SIGNAL_CLEANUP) {
|
||||
ext->label = NULL;
|
||||
} else if(sign == LV_SIGNAL_FOCUS) {
|
||||
#if USE_LV_GROUP
|
||||
lv_group_t * g = lv_obj_get_group(ddlist);
|
||||
bool editing = lv_group_get_editing(g);
|
||||
lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||
@@ -651,6 +652,7 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par
|
||||
lv_ddlist_refr_size(ddlist, true);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} else if(sign == LV_SIGNAL_DEFOCUS) {
|
||||
if(ext->opened) {
|
||||
ext->opened = false;
|
||||
@@ -686,9 +688,11 @@ static lv_res_t lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * par
|
||||
ext->opened = 0;
|
||||
if(ext->action) ext->action(ddlist);
|
||||
|
||||
#if USE_LV_GROUP
|
||||
lv_group_t * g = lv_obj_get_group(ddlist);
|
||||
bool editing = lv_group_get_editing(g);
|
||||
if(editing) lv_group_set_editing(g, false); /*In edit mode go to navigate mode if an option is selected*/
|
||||
#endif
|
||||
} else {
|
||||
ext->opened = 1;
|
||||
}
|
||||
|
||||
+1
-1
@@ -385,7 +385,7 @@ static void refr_img(lv_obj_t * imgbtn)
|
||||
ext->act_cf = LV_IMG_CF_UNKOWN;
|
||||
}
|
||||
|
||||
|
||||
lv_obj_invalidate(imgbtn);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -361,6 +361,7 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par
|
||||
refr_position(roller, false);
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_FOCUS) {
|
||||
#if USE_LV_GROUP
|
||||
lv_group_t * g = lv_obj_get_group(roller);
|
||||
bool editing = lv_group_get_editing(g);
|
||||
lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||
@@ -382,12 +383,15 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par
|
||||
ext->ddlist.sel_opt_id_ori = ext->ddlist.sel_opt_id; /*Save the current value. Used to revert this state if ENER wont't be pressed*/
|
||||
|
||||
}
|
||||
#endif
|
||||
} else if(sign == LV_SIGNAL_DEFOCUS) {
|
||||
#if USE_LV_GROUP
|
||||
/*Revert the original state*/
|
||||
if(ext->ddlist.sel_opt_id != ext->ddlist.sel_opt_id_ori) {
|
||||
ext->ddlist.sel_opt_id = ext->ddlist.sel_opt_id_ori;
|
||||
refr_position(roller, true);
|
||||
}
|
||||
#endif
|
||||
} else if(sign == LV_SIGNAL_CONTROLL) {
|
||||
char c = *((char *)param);
|
||||
if(c == LV_GROUP_KEY_RIGHT || c == LV_GROUP_KEY_DOWN) {
|
||||
@@ -402,9 +406,11 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par
|
||||
ext->ddlist.sel_opt_id_ori = ext->ddlist.sel_opt_id; /*Set the entered value as default*/
|
||||
if(ext->ddlist.action) ext->ddlist.action(roller);
|
||||
|
||||
#if USE_LV_GROUP
|
||||
lv_group_t * g = lv_obj_get_group(roller);
|
||||
bool editing = lv_group_get_editing(g);
|
||||
if(editing) lv_group_set_editing(g, false); /*In edit mode go to navigate mode if an option is selected*/
|
||||
#endif
|
||||
}
|
||||
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
||||
lv_obj_type_t * buf = param;
|
||||
|
||||
+98
-128
@@ -10,6 +10,7 @@
|
||||
|
||||
#if USE_LV_SPINBOX != 0
|
||||
#include "../lv_themes/lv_theme.h"
|
||||
#include "../lv_misc/lv_math.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@@ -64,7 +65,7 @@ lv_obj_t * lv_spinbox_create(lv_obj_t * par, const lv_obj_t * copy)
|
||||
/*Initialize the allocated 'ext'*/
|
||||
ext->ta.one_line = 1;
|
||||
ext->ta.pwd_mode = 0;
|
||||
ext->ta.accapted_chars = "1234567890+-.";
|
||||
ext->ta.accapted_chars = "1234567890+-. ";
|
||||
|
||||
ext->value = 0;
|
||||
ext->dec_point_pos = 0;
|
||||
@@ -188,13 +189,11 @@ void lv_spinbox_set_range(lv_obj_t * spinbox, int32_t range_min, int32_t range_m
|
||||
ext->range_max = range_max;
|
||||
ext->range_min = range_min;
|
||||
|
||||
if(ext->value > ext->range_max)
|
||||
{
|
||||
if(ext->value > ext->range_max) {
|
||||
ext->value = ext->range_max;
|
||||
lv_obj_invalidate(spinbox);
|
||||
}
|
||||
if(ext->value < ext->range_min)
|
||||
{
|
||||
if(ext->value < ext->range_min) {
|
||||
ext->value = ext->range_min;
|
||||
lv_obj_invalidate(spinbox);
|
||||
}
|
||||
@@ -251,11 +250,9 @@ void lv_spinbox_step_next(lv_obj_t * spinbox)
|
||||
{
|
||||
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);
|
||||
|
||||
|
||||
if((ext->step / 10) < ext->range_max && (ext->step / 10) > ext->range_min && (ext->step / 10) > 0)
|
||||
{
|
||||
ext->step /= 10;
|
||||
}
|
||||
int32_t new_step = ext->step / 10;
|
||||
if((new_step) > 0) ext->step = new_step;
|
||||
else ext->step = 1;
|
||||
|
||||
lv_spinbox_updatevalue(spinbox);
|
||||
}
|
||||
@@ -267,12 +264,10 @@ void lv_spinbox_step_next(lv_obj_t * spinbox)
|
||||
void lv_spinbox_step_previous(lv_obj_t * spinbox)
|
||||
{
|
||||
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);
|
||||
|
||||
|
||||
if((ext->step * 10) <= ext->range_max && (ext->step * 10) > ext->range_min && (ext->step * 10) > 0)
|
||||
{
|
||||
ext->step *= 10;
|
||||
}
|
||||
int32_t step_limit;
|
||||
step_limit = LV_MATH_MAX(ext->range_max, (ext->range_min < 0 ? (-ext->range_min) : ext->range_min));
|
||||
int32_t new_step = ext->step * 10;
|
||||
if(new_step <= step_limit) ext->step = new_step;
|
||||
|
||||
lv_spinbox_updatevalue(spinbox);
|
||||
}
|
||||
@@ -285,20 +280,16 @@ void lv_spinbox_increment(lv_obj_t * spinbox)
|
||||
{
|
||||
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);
|
||||
|
||||
if(ext->value + ext->step <= ext->range_max)
|
||||
{
|
||||
if(ext->value + ext->step <= ext->range_max) {
|
||||
/*Special mode when zero crossing*/
|
||||
if((ext->value + ext->step) > 0 && ext->value < 0)
|
||||
{
|
||||
ext->value = -ext->value;
|
||||
}/*end special mode*/
|
||||
if((ext->value + ext->step) > 0 && ext->value < 0) ext->value = -ext->value;
|
||||
ext->value += ext->step;
|
||||
|
||||
if(ext->value_changed_cb != NULL)
|
||||
{
|
||||
ext->value_changed_cb(spinbox, ext->value);
|
||||
}
|
||||
} else {
|
||||
ext->value = ext->range_max;
|
||||
}
|
||||
|
||||
if(ext->value_changed_cb != NULL) ext->value_changed_cb(spinbox, ext->value);
|
||||
lv_spinbox_updatevalue(spinbox);
|
||||
}
|
||||
|
||||
@@ -310,20 +301,15 @@ void lv_spinbox_decrement(lv_obj_t * spinbox)
|
||||
{
|
||||
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);
|
||||
|
||||
if(ext->value - ext->step >= ext->range_min)
|
||||
{
|
||||
if(ext->value - ext->step >= ext->range_min) {
|
||||
/*Special mode when zero crossing*/
|
||||
if((ext->value - ext->step) < 0 && ext->value > 0)
|
||||
{
|
||||
ext->value = -ext->value;
|
||||
}/*end special mode*/
|
||||
if((ext->value - ext->step) < 0 && ext->value > 0) ext->value = -ext->value;
|
||||
ext->value -= ext->step;
|
||||
|
||||
if(ext->value_changed_cb != NULL)
|
||||
{
|
||||
ext->value_changed_cb(spinbox, ext->value);
|
||||
}
|
||||
} else {
|
||||
ext->value = ext->range_min;
|
||||
}
|
||||
|
||||
if(ext->value_changed_cb != NULL) ext->value_changed_cb(spinbox, ext->value);
|
||||
lv_spinbox_updatevalue(spinbox);
|
||||
}
|
||||
|
||||
@@ -365,137 +351,121 @@ static lv_res_t lv_spinbox_signal(lv_obj_t * spinbox, lv_signal_t sign, void * p
|
||||
if(buf->type[i] == NULL) break;
|
||||
}
|
||||
buf->type[i] = "lv_spinbox";
|
||||
}else if(sign == LV_SIGNAL_CONTROLL)
|
||||
{
|
||||
}
|
||||
else if(sign == LV_SIGNAL_CONTROLL) {
|
||||
lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||
|
||||
uint32_t c = *((uint32_t *)param); /*uint32_t because can be UTF-8*/
|
||||
if(c == LV_GROUP_KEY_RIGHT)
|
||||
{
|
||||
if(indev_type == LV_INDEV_TYPE_ENCODER)
|
||||
{
|
||||
lv_spinbox_increment(spinbox);
|
||||
}
|
||||
else
|
||||
{
|
||||
lv_spinbox_step_next(spinbox);
|
||||
}
|
||||
if(c == LV_GROUP_KEY_RIGHT) {
|
||||
if(indev_type == LV_INDEV_TYPE_ENCODER) lv_spinbox_increment(spinbox);
|
||||
else lv_spinbox_step_next(spinbox);
|
||||
}
|
||||
else if(c == LV_GROUP_KEY_LEFT)
|
||||
{
|
||||
if(indev_type == LV_INDEV_TYPE_ENCODER)
|
||||
{
|
||||
lv_spinbox_decrement(spinbox);
|
||||
}
|
||||
else
|
||||
{
|
||||
else if(c == LV_GROUP_KEY_LEFT) {
|
||||
if(indev_type == LV_INDEV_TYPE_ENCODER) lv_spinbox_decrement(spinbox);
|
||||
else lv_spinbox_step_previous(spinbox);
|
||||
}
|
||||
else if(c == LV_GROUP_KEY_UP) {
|
||||
lv_spinbox_increment(spinbox);
|
||||
}
|
||||
else if(c == LV_GROUP_KEY_DOWN) {
|
||||
lv_spinbox_decrement(spinbox);
|
||||
}
|
||||
else if(c == LV_GROUP_KEY_ENTER) {
|
||||
|
||||
if(ext->step > 1) {
|
||||
lv_spinbox_step_next(spinbox);
|
||||
} else {
|
||||
/*Restart from the MSB*/
|
||||
ext->step = 1;
|
||||
uint32_t i;
|
||||
for(i = 0; i < ext->digit_count; i++) {
|
||||
int32_t new_step = ext->step * 10;
|
||||
if(new_step >= ext->range_max) break;
|
||||
ext->step = new_step;
|
||||
}
|
||||
lv_spinbox_step_previous(spinbox);
|
||||
}
|
||||
}
|
||||
else if(c == LV_GROUP_KEY_UP)
|
||||
{
|
||||
lv_spinbox_increment(spinbox);
|
||||
}
|
||||
else if(c == LV_GROUP_KEY_DOWN)
|
||||
{
|
||||
lv_spinbox_decrement(spinbox);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(c == LV_GROUP_KEY_ENTER)
|
||||
{
|
||||
int p = lv_ta_get_cursor_pos(spinbox);
|
||||
if(p == (1 + ext->digit_padding_left + ext->digit_count))
|
||||
{
|
||||
for(int i = 0; i < ext->digit_count; i++)
|
||||
lv_spinbox_step_previous(spinbox);
|
||||
} else
|
||||
{
|
||||
lv_spinbox_step_next(spinbox);
|
||||
}
|
||||
|
||||
|
||||
lv_spinbox_updatevalue(spinbox);
|
||||
}
|
||||
else
|
||||
{
|
||||
lv_ta_add_char(spinbox, c);
|
||||
}
|
||||
else {
|
||||
lv_ta_add_char(spinbox, c);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static void lv_spinbox_updatevalue(lv_obj_t * spinbox)
|
||||
{
|
||||
lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox);
|
||||
int32_t v = ext->value;
|
||||
int32_t intDigits, decDigits;
|
||||
uint8_t dc = ext->digit_count;
|
||||
|
||||
intDigits = (ext->dec_point_pos==0) ? ext->digit_count : ext->dec_point_pos;
|
||||
decDigits = ext->digit_count - intDigits;
|
||||
char buf[LV_SPINBOX_MAX_DIGIT_COUNT + 8];
|
||||
memset(buf, 0, sizeof(buf));
|
||||
char * buf_p = buf;
|
||||
|
||||
ext->digits[0] = v>=0 ? '+' : '-';
|
||||
/*Add the sign*/
|
||||
(*buf_p) = ext->value >= 0 ? '+' : '-';
|
||||
buf_p++;
|
||||
|
||||
int pl; /*padding left*/
|
||||
for(pl = 0; pl < ext->digit_padding_left; pl++)
|
||||
{
|
||||
ext->digits[1 + pl] = ' ';
|
||||
int i;
|
||||
/*padding left*/
|
||||
for(i = 0; i < ext->digit_padding_left; i++) {
|
||||
(*buf_p) = ' ';
|
||||
buf_p++;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
uint8_t digits[16];
|
||||
char digits[64];
|
||||
/*Convert the numbers to string (the sign is already handled so always covert positive number)*/
|
||||
lv_math_num_to_str(ext->value < 0 ? -ext->value : ext->value, digits);
|
||||
|
||||
if(v < 0) v = -v;
|
||||
|
||||
for(i = 0; i < dc; i++)
|
||||
{
|
||||
digits[i] = v%10;
|
||||
v = v/10;
|
||||
/*Add leading zeros*/
|
||||
int lz_cnt = ext->digit_count - (int)strlen(digits);
|
||||
if(lz_cnt > 0) {
|
||||
for(i = strlen(digits); i >= 0; i--) {
|
||||
digits[i + lz_cnt] = digits[i];
|
||||
}
|
||||
for(i = 0; i < lz_cnt; i++) {
|
||||
digits[i] = '0';
|
||||
}
|
||||
}
|
||||
|
||||
int k;
|
||||
for(k = 0; k < intDigits; k++)
|
||||
{
|
||||
ext->digits[1 + pl + k] = '0' + digits[--i];
|
||||
int32_t intDigits;
|
||||
intDigits = (ext->dec_point_pos == 0) ? ext->digit_count : ext->dec_point_pos;
|
||||
|
||||
/*Add the decimal part*/
|
||||
for(i = 0; i < intDigits && digits[i] != '\0'; i++) {
|
||||
(*buf_p) = digits[i];
|
||||
buf_p++;
|
||||
}
|
||||
|
||||
if(ext->dec_point_pos != 0) {
|
||||
ext->digits[1 + pl + intDigits] = '.';
|
||||
/*Insert the decimal point*/
|
||||
(*buf_p) = '.';
|
||||
buf_p++;
|
||||
|
||||
int d;
|
||||
|
||||
for(d = 0; d < decDigits; d++)
|
||||
{
|
||||
ext->digits[1 + pl + intDigits + 1 + d] = '0' + digits[--i];
|
||||
for(/*Leave i*/ ;i < ext->digit_count && digits[i] != '\0'; i++) {
|
||||
(*buf_p) = digits[i];
|
||||
buf_p++;
|
||||
}
|
||||
|
||||
ext->digits[1 + pl + intDigits + 1 + decDigits] = '\0';
|
||||
} else {
|
||||
ext->digits[1 + pl + intDigits] = '\0';
|
||||
|
||||
}
|
||||
|
||||
/*Refresh the text*/
|
||||
lv_ta_set_text(spinbox, (char*)buf);
|
||||
|
||||
lv_ta_set_text(spinbox, (char*)ext->digits);
|
||||
|
||||
/*Set the cursor position*/
|
||||
int32_t step = ext->step;
|
||||
uint8_t cPos = ext->digit_count + pl;
|
||||
uint8_t cur_pos = ext->digit_count;
|
||||
while(step >= 10)
|
||||
{
|
||||
step /= 10;
|
||||
cPos--;
|
||||
cur_pos--;
|
||||
}
|
||||
|
||||
if(cPos > pl + intDigits )
|
||||
{
|
||||
cPos ++;
|
||||
}
|
||||
if(cur_pos > intDigits ) cur_pos ++; /*Skip teh decimal point*/
|
||||
|
||||
lv_ta_set_cursor_pos(spinbox, cPos);
|
||||
cur_pos += ext->digit_padding_left;
|
||||
|
||||
lv_ta_set_cursor_pos(spinbox, cur_pos);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -50,11 +50,9 @@ typedef struct {
|
||||
int32_t range_max;
|
||||
int32_t range_min;
|
||||
int32_t step;
|
||||
uint8_t digit_count:4;
|
||||
uint8_t dec_point_pos:4; /*if 0, there is no separator and the number is an integer*/
|
||||
uint8_t digit_padding_left:4;
|
||||
uint8_t digit_padding_right:4;
|
||||
uint8_t digits[1+1+LV_SPINBOX_MAX_DIGIT_COUNT]; /*1 sign, 1 point, 16 num digits*/
|
||||
uint16_t digit_count:4;
|
||||
uint16_t dec_point_pos:4; /*if 0, there is no separator and the number is an integer*/
|
||||
uint16_t digit_padding_left:4;
|
||||
lv_spinbox_value_changed_cb_t value_changed_cb;
|
||||
} lv_spinbox_ext_t;
|
||||
|
||||
|
||||
@@ -621,12 +621,14 @@ static lv_res_t lv_tabview_signal(lv_obj_t * tabview, lv_signal_t sign, void * p
|
||||
lv_hal_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act());
|
||||
/*With ENCODER select the first button only in edit mode*/
|
||||
if(indev_type == LV_INDEV_TYPE_ENCODER) {
|
||||
#if USE_LV_GROUP
|
||||
lv_group_t * g = lv_obj_get_group(tabview);
|
||||
if(lv_group_get_editing(g)) {
|
||||
lv_btnm_ext_t * btnm_ext = lv_obj_get_ext_attr(ext->btns);
|
||||
btnm_ext->btn_id_pr = 0;
|
||||
lv_obj_invalidate(ext->btns);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
lv_btnm_ext_t * btnm_ext = lv_obj_get_ext_attr(ext->btns);
|
||||
btnm_ext->btn_id_pr = 0;
|
||||
|
||||
Reference in New Issue
Block a user