Merge pull request #1264 from Maldus512/master
Added rotation feature to the lmeter
This commit is contained in:
@@ -236,7 +236,7 @@ typedef void * lv_indev_drv_user_data_t; /*Type of user data in the i
|
|||||||
# define LV_LOG_LEVEL LV_LOG_LEVEL_WARN
|
# define LV_LOG_LEVEL LV_LOG_LEVEL_WARN
|
||||||
|
|
||||||
/* 1: Print the log with 'printf';
|
/* 1: Print the log with 'printf';
|
||||||
* 0: user need to register a callback with `lv_log_register_print`*/
|
* 0: user need to register a callback with `lv_log_register_print_cb`*/
|
||||||
# define LV_LOG_PRINTF 0
|
# define LV_LOG_PRINTF 0
|
||||||
#endif /*LV_USE_LOG*/
|
#endif /*LV_USE_LOG*/
|
||||||
|
|
||||||
|
|||||||
1
lvgl.h
1
lvgl.h
@@ -25,6 +25,7 @@ extern "C" {
|
|||||||
|
|
||||||
#include "src/lv_core/lv_obj.h"
|
#include "src/lv_core/lv_obj.h"
|
||||||
#include "src/lv_core/lv_group.h"
|
#include "src/lv_core/lv_group.h"
|
||||||
|
#include "src/lv_core/lv_indev.h"
|
||||||
|
|
||||||
#include "src/lv_core/lv_refr.h"
|
#include "src/lv_core/lv_refr.h"
|
||||||
#include "src/lv_core/lv_disp.h"
|
#include "src/lv_core/lv_disp.h"
|
||||||
|
|||||||
@@ -177,6 +177,21 @@ void lv_lmeter_set_scale(lv_obj_t * lmeter, uint16_t angle, uint8_t line_cnt)
|
|||||||
lv_obj_invalidate(lmeter);
|
lv_obj_invalidate(lmeter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the angle settings of a line meter
|
||||||
|
* @param lmeter pointer to a line meter object
|
||||||
|
* @param angle angle where the meter will be facing (with its center)
|
||||||
|
*/
|
||||||
|
void lv_lmeter_set_angle(lv_obj_t * lmeter, uint16_t angle)
|
||||||
|
{
|
||||||
|
lv_lmeter_ext_t * ext = lv_obj_get_ext_attr(lmeter);
|
||||||
|
if(ext->angle == angle) return;
|
||||||
|
|
||||||
|
ext->angle = angle;
|
||||||
|
|
||||||
|
lv_obj_invalidate(lmeter);
|
||||||
|
}
|
||||||
|
|
||||||
/*=====================
|
/*=====================
|
||||||
* Getter functions
|
* Getter functions
|
||||||
*====================*/
|
*====================*/
|
||||||
@@ -287,7 +302,7 @@ static bool lv_lmeter_design(lv_obj_t * lmeter, const lv_area_t * mask, lv_desig
|
|||||||
|
|
||||||
lv_coord_t x_ofs = lv_obj_get_width(lmeter) / 2 + lmeter->coords.x1;
|
lv_coord_t x_ofs = lv_obj_get_width(lmeter) / 2 + lmeter->coords.x1;
|
||||||
lv_coord_t y_ofs = lv_obj_get_height(lmeter) / 2 + lmeter->coords.y1;
|
lv_coord_t y_ofs = lv_obj_get_height(lmeter) / 2 + lmeter->coords.y1;
|
||||||
int16_t angle_ofs = 90 + (360 - ext->scale_angle) / 2;
|
int16_t angle_ofs = ext->angle + 90 + (360 - ext->scale_angle) / 2;
|
||||||
int16_t level =
|
int16_t level =
|
||||||
(int32_t)((int32_t)(ext->cur_value - ext->min_value) * ext->line_cnt) / (ext->max_value - ext->min_value);
|
(int32_t)((int32_t)(ext->cur_value - ext->min_value) * ext->line_cnt) / (ext->max_value - ext->min_value);
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ typedef struct
|
|||||||
/*No inherited ext.*/ /*Ext. of ancestor*/
|
/*No inherited ext.*/ /*Ext. of ancestor*/
|
||||||
/*New data for this type */
|
/*New data for this type */
|
||||||
uint16_t scale_angle; /*Angle of the scale in deg. (0..360)*/
|
uint16_t scale_angle; /*Angle of the scale in deg. (0..360)*/
|
||||||
|
uint16_t angle;
|
||||||
uint8_t line_cnt; /*Count of lines */
|
uint8_t line_cnt; /*Count of lines */
|
||||||
int16_t cur_value;
|
int16_t cur_value;
|
||||||
int16_t min_value;
|
int16_t min_value;
|
||||||
@@ -88,6 +89,13 @@ void lv_lmeter_set_range(lv_obj_t * lmeter, int16_t min, int16_t max);
|
|||||||
*/
|
*/
|
||||||
void lv_lmeter_set_scale(lv_obj_t * lmeter, uint16_t angle, uint8_t line_cnt);
|
void lv_lmeter_set_scale(lv_obj_t * lmeter, uint16_t angle, uint8_t line_cnt);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the rotation settings of a line meter
|
||||||
|
* @param lmeter pointer to a line meter object
|
||||||
|
* @param angle angle of rotation (relative to the northen axis)
|
||||||
|
*/
|
||||||
|
void lv_lmeter_set_angle(lv_obj_t * lmeter, uint16_t angle);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the styles of a line meter
|
* Set the styles of a line meter
|
||||||
* @param lmeter pointer to a line meter object
|
* @param lmeter pointer to a line meter object
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "../lv_core/lv_debug.h"
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_core/lv_group.h"
|
#include "../lv_core/lv_group.h"
|
||||||
|
#include "../lv_core/lv_indev.h"
|
||||||
#include "../lv_draw/lv_draw.h"
|
#include "../lv_draw/lv_draw.h"
|
||||||
#include "../lv_themes/lv_theme.h"
|
#include "../lv_themes/lv_theme.h"
|
||||||
#include "../lv_misc/lv_math.h"
|
#include "../lv_misc/lv_math.h"
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include "../lv_core/lv_debug.h"
|
#include "../lv_core/lv_debug.h"
|
||||||
#include "../lv_themes/lv_theme.h"
|
#include "../lv_themes/lv_theme.h"
|
||||||
#include "../lv_misc/lv_math.h"
|
#include "../lv_misc/lv_math.h"
|
||||||
|
#include "../lv_core/lv_indev.h"
|
||||||
|
|
||||||
/*********************
|
/*********************
|
||||||
* DEFINES
|
* DEFINES
|
||||||
|
|||||||
Reference in New Issue
Block a user