1
0
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:
Gabor Kiss-Vamosi 2020-04-29 14:46:29 +02:00 committed by GitHub
commit 013e6e9b21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 1 deletions

View File

@ -198,6 +198,26 @@ uint32_t lv_sqrt(uint32_t num)
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
**********************/

View File

@ -74,6 +74,14 @@ uint16_t lv_atan2(int x, int y);
*/
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
**********************/

View File

@ -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(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->dec_point_pos = separator_position;

View File

@ -32,7 +32,7 @@ extern "C" {
/*********************
* DEFINES
*********************/
#define LV_SPINBOX_MAX_DIGIT_COUNT 16
#define LV_SPINBOX_MAX_DIGIT_COUNT 10
/**********************
* TYPEDEFS