mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
Merge pull request #1481 from Wielebny666/master
Adjusting min and max values to the number format
This commit is contained in:
commit
013e6e9b21
@ -198,6 +198,26 @@ uint32_t lv_sqrt(uint32_t num)
|
|||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate the integer exponents.
|
||||||
|
* @param base
|
||||||
|
* @param power
|
||||||
|
* @return base raised to the power exponent
|
||||||
|
*/
|
||||||
|
int64_t lv_pow(int64_t base, int8_t exp)
|
||||||
|
{
|
||||||
|
int64_t result = 1;
|
||||||
|
while (exp)
|
||||||
|
{
|
||||||
|
if (exp & 1)
|
||||||
|
result *= base;
|
||||||
|
exp >>= 1;
|
||||||
|
base *= base;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* STATIC FUNCTIONS
|
* STATIC FUNCTIONS
|
||||||
**********************/
|
**********************/
|
||||||
|
@ -74,6 +74,14 @@ uint16_t lv_atan2(int x, int y);
|
|||||||
*/
|
*/
|
||||||
uint32_t lv_sqrt(uint32_t num);
|
uint32_t lv_sqrt(uint32_t num);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate the integer exponents.
|
||||||
|
* @param base
|
||||||
|
* @param power
|
||||||
|
* @return base raised to the power exponent
|
||||||
|
*/
|
||||||
|
int64_t lv_pow(int64_t base, int8_t exp);
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* MACROS
|
* MACROS
|
||||||
**********************/
|
**********************/
|
||||||
|
@ -154,6 +154,13 @@ void lv_spinbox_set_digit_format(lv_obj_t * spinbox, uint8_t digit_count, uint8_
|
|||||||
|
|
||||||
if(separator_position > LV_SPINBOX_MAX_DIGIT_COUNT) separator_position = LV_SPINBOX_MAX_DIGIT_COUNT;
|
if(separator_position > LV_SPINBOX_MAX_DIGIT_COUNT) separator_position = LV_SPINBOX_MAX_DIGIT_COUNT;
|
||||||
|
|
||||||
|
if(digit_count < LV_SPINBOX_MAX_DIGIT_COUNT)
|
||||||
|
{
|
||||||
|
uint64_t max_val = lv_pow(10, digit_count);
|
||||||
|
if(ext->range_max > max_val - 1) ext->range_max = max_val - 1;
|
||||||
|
if(ext->range_min < - max_val + 1) ext->range_min = - max_val + 1;
|
||||||
|
}
|
||||||
|
|
||||||
ext->digit_count = digit_count;
|
ext->digit_count = digit_count;
|
||||||
ext->dec_point_pos = separator_position;
|
ext->dec_point_pos = separator_position;
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ extern "C" {
|
|||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
*********************/
|
*********************/
|
||||||
#define LV_SPINBOX_MAX_DIGIT_COUNT 16
|
#define LV_SPINBOX_MAX_DIGIT_COUNT 10
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* TYPEDEFS
|
* TYPEDEFS
|
||||||
|
Loading…
x
Reference in New Issue
Block a user