Initial commit

This commit is contained in:
Carter committed 2026-07-21 13:45:37 -04:00
commit 2c7628bb9f
381 files changed
+83535

No files matched your search

+256
View File
@@ -0,0 +1,256 @@
/**
* @file lv_arc.h
*
*/
#ifndef LV_ARC_H
#define LV_ARC_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "liblvgl/lv_conf_internal.h"
#if LV_USE_ARC != 0
#include "liblvgl/core/lv_obj.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
enum {
LV_ARC_MODE_NORMAL,
LV_ARC_MODE_SYMMETRICAL,
LV_ARC_MODE_REVERSE
};
typedef uint8_t lv_arc_mode_t;
typedef struct {
lv_obj_t obj;
uint16_t rotation;
uint16_t indic_angle_start;
uint16_t indic_angle_end;
uint16_t bg_angle_start;
uint16_t bg_angle_end;
int16_t value; /*Current value of the arc*/
int16_t min_value; /*Minimum value of the arc*/
int16_t max_value; /*Maximum value of the arc*/
uint16_t dragging : 1;
uint16_t type : 2;
uint16_t min_close : 1; /*1: the last pressed angle was closer to minimum end*/
uint16_t chg_rate; /*Drag angle rate of change of the arc (degrees/sec)*/
uint32_t last_tick; /*Last dragging event timestamp of the arc*/
int16_t last_angle; /*Last dragging angle of the arc*/
} lv_arc_t;
extern const lv_obj_class_t lv_arc_class;
/**
* `type` field in `lv_obj_draw_part_dsc_t` if `class_p = lv_arc_class`
* Used in `LV_EVENT_DRAW_PART_BEGIN` and `LV_EVENT_DRAW_PART_END`
*/
typedef enum {
LV_ARC_DRAW_PART_BACKGROUND, /**< The background arc*/
LV_ARC_DRAW_PART_FOREGROUND, /**< The foreground arc*/
LV_ARC_DRAW_PART_KNOB, /**< The knob*/
} lv_arc_draw_part_type_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create an arc object
* @param parent pointer to an object, it will be the parent of the new arc
* @return pointer to the created arc
*/
lv_obj_t * lv_arc_create(lv_obj_t * parent);
/*======================
* Add/remove functions
*=====================*/
/*=====================
* Setter functions
*====================*/
/**
* Set the start angle of an arc. 0 deg: right, 90 bottom, etc.
* @param obj pointer to an arc object
* @param start the start angle
*/
void lv_arc_set_start_angle(lv_obj_t * obj, uint16_t start);
/**
* Set the end angle of an arc. 0 deg: right, 90 bottom, etc.
* @param obj pointer to an arc object
* @param end the end angle
*/
void lv_arc_set_end_angle(lv_obj_t * obj, uint16_t end);
/**
* Set the start and end angles
* @param obj pointer to an arc object
* @param start the start angle
* @param end the end angle
*/
void lv_arc_set_angles(lv_obj_t * obj, uint16_t start, uint16_t end);
/**
* Set the start angle of an arc background. 0 deg: right, 90 bottom, etc.
* @param obj pointer to an arc object
* @param start the start angle
*/
void lv_arc_set_bg_start_angle(lv_obj_t * obj, uint16_t start);
/**
* Set the start angle of an arc background. 0 deg: right, 90 bottom etc.
* @param obj pointer to an arc object
* @param end the end angle
*/
void lv_arc_set_bg_end_angle(lv_obj_t * obj, uint16_t end);
/**
* Set the start and end angles of the arc background
* @param obj pointer to an arc object
* @param start the start angle
* @param end the end angle
*/
void lv_arc_set_bg_angles(lv_obj_t * obj, uint16_t start, uint16_t end);
/**
* Set the rotation for the whole arc
* @param obj pointer to an arc object
* @param rotation rotation angle
*/
void lv_arc_set_rotation(lv_obj_t * obj, uint16_t rotation);
/**
* Set the type of arc.
* @param obj pointer to arc object
* @param mode arc's mode
*/
void lv_arc_set_mode(lv_obj_t * obj, lv_arc_mode_t type);
/**
* Set a new value on the arc
* @param obj pointer to an arc object
* @param value new value
*/
void lv_arc_set_value(lv_obj_t * obj, int16_t value);
/**
* Set minimum and the maximum values of an arc
* @param obj pointer to the arc object
* @param min minimum value
* @param max maximum value
*/
void lv_arc_set_range(lv_obj_t * obj, int16_t min, int16_t max);
/**
* Set a change rate to limit the speed how fast the arc should reach the pressed point.
* @param obj pointer to an arc object
* @param rate the change rate
*/
void lv_arc_set_change_rate(lv_obj_t * obj, uint16_t rate);
/*=====================
* Getter functions
*====================*/
/**
* Get the start angle of an arc.
* @param obj pointer to an arc object
* @return the start angle [0..360]
*/
uint16_t lv_arc_get_angle_start(lv_obj_t * obj);
/**
* Get the end angle of an arc.
* @param obj pointer to an arc object
* @return the end angle [0..360]
*/
uint16_t lv_arc_get_angle_end(lv_obj_t * obj);
/**
* Get the start angle of an arc background.
* @param obj pointer to an arc object
* @return the start angle [0..360]
*/
uint16_t lv_arc_get_bg_angle_start(lv_obj_t * obj);
/**
* Get the end angle of an arc background.
* @param obj pointer to an arc object
* @return the end angle [0..360]
*/
uint16_t lv_arc_get_bg_angle_end(lv_obj_t * obj);
/**
* Get the value of an arc
* @param obj pointer to an arc object
* @return the value of the arc
*/
int16_t lv_arc_get_value(const lv_obj_t * obj);
/**
* Get the minimum value of an arc
* @param obj pointer to an arc object
* @return the minimum value of the arc
*/
int16_t lv_arc_get_min_value(const lv_obj_t * obj);
/**
* Get the maximum value of an arc
* @param obj pointer to an arc object
* @return the maximum value of the arc
*/
int16_t lv_arc_get_max_value(const lv_obj_t * obj);
/**
* Get whether the arc is type or not.
* @param obj pointer to an arc object
* @return arc's mode
*/
lv_arc_mode_t lv_arc_get_mode(const lv_obj_t * obj);
/*=====================
* Other functions
*====================*/
/**
* Align an object to the current position of the arc (knob)
* @param obj pointer to an arc object
* @param obj_to_align pointer to an object to align
* @param r_offset consider the radius larger with this value (< 0: for smaller radius)
*/
void lv_arc_align_obj_to_angle(const lv_obj_t * obj, lv_obj_t * obj_to_align, lv_coord_t r_offset);
/**
* Rotate an object to the current position of the arc (knob)
* @param obj pointer to an arc object
* @param obj_to_align pointer to an object to rotate
* @param r_offset consider the radius larger with this value (< 0: for smaller radius)
*/
void lv_arc_rotate_obj_to_angle(const lv_obj_t * obj, lv_obj_t * obj_to_rotate, lv_coord_t r_offset);
/**********************
* MACROS
**********************/
#endif /*LV_USE_ARC*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_ARC_H*/
+164
View File
@@ -0,0 +1,164 @@
/**
* @file lv_bar.h
*
*/
#ifndef LV_BAR_H
#define LV_BAR_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "liblvgl/lv_conf_internal.h"
#if LV_USE_BAR != 0
#include "liblvgl/core/lv_obj.h"
#include "liblvgl/misc/lv_anim.h"
#include "lv_btn.h"
#include "lv_label.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
enum {
LV_BAR_MODE_NORMAL,
LV_BAR_MODE_SYMMETRICAL,
LV_BAR_MODE_RANGE
};
typedef uint8_t lv_bar_mode_t;
typedef struct {
lv_obj_t * bar;
int32_t anim_start;
int32_t anim_end;
int32_t anim_state;
} _lv_bar_anim_t;
typedef struct {
lv_obj_t obj;
int32_t cur_value; /**< Current value of the bar*/
int32_t min_value; /**< Minimum value of the bar*/
int32_t max_value; /**< Maximum value of the bar*/
int32_t start_value; /**< Start value of the bar*/
lv_area_t indic_area; /**< Save the indicator area. Might be used by derived types*/
_lv_bar_anim_t cur_value_anim;
_lv_bar_anim_t start_value_anim;
lv_bar_mode_t mode : 2; /**< Type of bar*/
} lv_bar_t;
extern const lv_obj_class_t lv_bar_class;
/**
* `type` field in `lv_obj_draw_part_dsc_t` if `class_p = lv_bar_class`
* Used in `LV_EVENT_DRAW_PART_BEGIN` and `LV_EVENT_DRAW_PART_END`
*/
typedef enum {
LV_BAR_DRAW_PART_INDICATOR, /**< The indicator*/
} lv_bar_draw_part_type_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a bar object
* @param parent pointer to an object, it will be the parent of the new bar
* @return pointer to the created bar
*/
lv_obj_t * lv_bar_create(lv_obj_t * parent);
/*=====================
* Setter functions
*====================*/
/**
* Set a new value on the bar
* @param bar pointer to a bar object
* @param value new value
* @param anim LV_ANIM_ON: set the value with an animation; LV_ANIM_OFF: change the value immediately
*/
void lv_bar_set_value(lv_obj_t * obj, int32_t value, lv_anim_enable_t anim);
/**
* Set a new start value on the bar
* @param obj pointer to a bar object
* @param value new start value
* @param anim LV_ANIM_ON: set the value with an animation; LV_ANIM_OFF: change the value immediately
*/
void lv_bar_set_start_value(lv_obj_t * obj, int32_t start_value, lv_anim_enable_t anim);
/**
* Set minimum and the maximum values of a bar
* @param obj pointer to the bar object
* @param min minimum value
* @param max maximum value
*/
void lv_bar_set_range(lv_obj_t * obj, int32_t min, int32_t max);
/**
* Set the type of bar.
* @param obj pointer to bar object
* @param mode bar type from ::lv_bar_mode_t
*/
void lv_bar_set_mode(lv_obj_t * obj, lv_bar_mode_t mode);
/*=====================
* Getter functions
*====================*/
/**
* Get the value of a bar
* @param obj pointer to a bar object
* @return the value of the bar
*/
int32_t lv_bar_get_value(const lv_obj_t * obj);
/**
* Get the start value of a bar
* @param obj pointer to a bar object
* @return the start value of the bar
*/
int32_t lv_bar_get_start_value(const lv_obj_t * obj);
/**
* Get the minimum value of a bar
* @param obj pointer to a bar object
* @return the minimum value of the bar
*/
int32_t lv_bar_get_min_value(const lv_obj_t * obj);
/**
* Get the maximum value of a bar
* @param obj pointer to a bar object
* @return the maximum value of the bar
*/
int32_t lv_bar_get_max_value(const lv_obj_t * obj);
/**
* Get the type of bar.
* @param obj pointer to bar object
* @return bar type from ::lv_bar_mode_t
*/
lv_bar_mode_t lv_bar_get_mode(lv_obj_t * obj);
/**********************
* MACROS
**********************/
#endif /*LV_USE_BAR*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_BAR_H*/
+56
View File
@@ -0,0 +1,56 @@
/**
* @file lv_btn.h
*
*/
#ifndef LV_BTN_H
#define LV_BTN_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "liblvgl/lv_conf_internal.h"
#if LV_USE_BTN != 0
#include "liblvgl/core/lv_obj.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
typedef struct {
lv_obj_t obj;
} lv_btn_t;
extern const lv_obj_class_t lv_btn_class;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a button object
* @param parent pointer to an object, it will be the parent of the new button
* @return pointer to the created button
*/
lv_obj_t * lv_btn_create(lv_obj_t * parent);
/**********************
* MACROS
**********************/
#endif /*LV_USE_BTN*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_BTN_H*/
+225
View File
@@ -0,0 +1,225 @@
/**
* @file lv_btnmatrix.h
*
*/
#ifndef LV_BTNMATRIX_H
#define LV_BTNMATRIX_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "liblvgl/lv_conf_internal.h"
#if LV_USE_BTNMATRIX != 0
#include "liblvgl/core/lv_obj.h"
/*********************
* DEFINES
*********************/
#define LV_BTNMATRIX_BTN_NONE 0xFFFF
LV_EXPORT_CONST_INT(LV_BTNMATRIX_BTN_NONE);
/**********************
* TYPEDEFS
**********************/
/** Type to store button control bits (disabled, hidden etc.)
* The first 3 bits are used to store the width*/
enum {
_LV_BTNMATRIX_WIDTH = 0x0007, /**< Reserved to stire the size units*/
LV_BTNMATRIX_CTRL_HIDDEN = 0x0008, /**< Button hidden*/
LV_BTNMATRIX_CTRL_NO_REPEAT = 0x0010, /**< Do not repeat press this button.*/
LV_BTNMATRIX_CTRL_DISABLED = 0x0020, /**< Disable this button.*/
LV_BTNMATRIX_CTRL_CHECKABLE = 0x0040, /**< The button can be toggled.*/
LV_BTNMATRIX_CTRL_CHECKED = 0x0080, /**< Button is currently toggled (e.g. checked).*/
LV_BTNMATRIX_CTRL_CLICK_TRIG = 0x0100, /**< 1: Send LV_EVENT_VALUE_CHANGE on CLICK, 0: Send LV_EVENT_VALUE_CHANGE on PRESS*/
LV_BTNMATRIX_CTRL_POPOVER = 0x0200, /**< Show a popover when pressing this key*/
LV_BTNMATRIX_CTRL_RECOLOR = 0x1000, /**< Enable text recoloring with `#color`*/
_LV_BTNMATRIX_CTRL_RESERVED = 0x2000, /**< Reserved for later use*/
LV_BTNMATRIX_CTRL_CUSTOM_1 = 0x4000, /**< Custom free to use flag*/
LV_BTNMATRIX_CTRL_CUSTOM_2 = 0x8000, /**< Custom free to use flag*/
};
typedef uint16_t lv_btnmatrix_ctrl_t;
typedef bool (*lv_btnmatrix_btn_draw_cb_t)(lv_obj_t * btnm, uint32_t btn_id, const lv_area_t * draw_area,
const lv_area_t * clip_area);
/*Data of button matrix*/
typedef struct {
lv_obj_t obj;
const char ** map_p; /*Pointer to the current map*/
lv_area_t * button_areas; /*Array of areas of buttons*/
lv_btnmatrix_ctrl_t * ctrl_bits; /*Array of control bytes*/
uint16_t btn_cnt; /*Number of button in 'map_p'(Handled by the library)*/
uint16_t row_cnt; /*Number of rows in 'map_p'(Handled by the library)*/
uint16_t btn_id_sel; /*Index of the active button (being pressed/released etc) or LV_BTNMATRIX_BTN_NONE*/
uint8_t one_check : 1; /*Single button toggled at once*/
} lv_btnmatrix_t;
extern const lv_obj_class_t lv_btnmatrix_class;
/**
* `type` field in `lv_obj_draw_part_dsc_t` if `class_p = lv_btnmatrix_class`
* Used in `LV_EVENT_DRAW_PART_BEGIN` and `LV_EVENT_DRAW_PART_END`
*/
typedef enum {
LV_BTNMATRIX_DRAW_PART_BTN, /**< The rectangle and label of buttons*/
} lv_btnmatrix_draw_part_type_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a button matrix object
* @param parent pointer to an object, it will be the parent of the new button matrix
* @return pointer to the created button matrix
*/
lv_obj_t * lv_btnmatrix_create(lv_obj_t * parent);
/*=====================
* Setter functions
*====================*/
/**
* Set a new map. Buttons will be created/deleted according to the map. The
* button matrix keeps a reference to the map and so the string array must not
* be deallocated during the life of the matrix.
* @param obj pointer to a button matrix object
* @param map pointer a string array. The last string has to be: "". Use "\n" to make a line break.
*/
void lv_btnmatrix_set_map(lv_obj_t * obj, const char * map[]);
/**
* Set the button control map (hidden, disabled etc.) for a button matrix.
* The control map array will be copied and so may be deallocated after this
* function returns.
* @param obj pointer to a button matrix object
* @param ctrl_map pointer to an array of `lv_btn_ctrl_t` control bytes. The
* length of the array and position of the elements must match
* the number and order of the individual buttons (i.e. excludes
* newline entries).
* An element of the map should look like e.g.:
* `ctrl_map[0] = width | LV_BTNMATRIX_CTRL_NO_REPEAT | LV_BTNMATRIX_CTRL_TGL_ENABLE`
*/
void lv_btnmatrix_set_ctrl_map(lv_obj_t * obj, const lv_btnmatrix_ctrl_t ctrl_map[]);
/**
* Set the selected buttons
* @param obj pointer to button matrix object
* @param btn_id 0 based index of the button to modify. (Not counting new lines)
*/
void lv_btnmatrix_set_selected_btn(lv_obj_t * obj, uint16_t btn_id);
/**
* Set the attributes of a button of the button matrix
* @param obj pointer to button matrix object
* @param btn_id 0 based index of the button to modify. (Not counting new lines)
* @param ctrl OR-ed attributs. E.g. `LV_BTNMATRIX_CTRL_NO_REPEAT | LV_BTNMATRIX_CTRL_CHECKABLE`
*/
void lv_btnmatrix_set_btn_ctrl(lv_obj_t * obj, uint16_t btn_id, lv_btnmatrix_ctrl_t ctrl);
/**
* Clear the attributes of a button of the button matrix
* @param obj pointer to button matrix object
* @param btn_id 0 based index of the button to modify. (Not counting new lines)
* @param ctrl OR-ed attributs. E.g. `LV_BTNMATRIX_CTRL_NO_REPEAT | LV_BTNMATRIX_CTRL_CHECKABLE`
*/
void lv_btnmatrix_clear_btn_ctrl(lv_obj_t * obj, uint16_t btn_id, lv_btnmatrix_ctrl_t ctrl);
/**
* Set attributes of all buttons of a button matrix
* @param obj pointer to a button matrix object
* @param ctrl attribute(s) to set from `lv_btnmatrix_ctrl_t`. Values can be ORed.
*/
void lv_btnmatrix_set_btn_ctrl_all(lv_obj_t * obj, lv_btnmatrix_ctrl_t ctrl);
/**
* Clear the attributes of all buttons of a button matrix
* @param obj pointer to a button matrix object
* @param ctrl attribute(s) to set from `lv_btnmatrix_ctrl_t`. Values can be ORed.
* @param en true: set the attributes; false: clear the attributes
*/
void lv_btnmatrix_clear_btn_ctrl_all(lv_obj_t * obj, lv_btnmatrix_ctrl_t ctrl);
/**
* Set a single button's relative width.
* This method will cause the matrix be regenerated and is a relatively
* expensive operation. It is recommended that initial width be specified using
* `lv_btnmatrix_set_ctrl_map` and this method only be used for dynamic changes.
* @param obj pointer to button matrix object
* @param btn_id 0 based index of the button to modify.
* @param width relative width compared to the buttons in the same row. [1..7]
*/
void lv_btnmatrix_set_btn_width(lv_obj_t * obj, uint16_t btn_id, uint8_t width);
/**
* Make the button matrix like a selector widget (only one button may be checked at a time).
* `LV_BTNMATRIX_CTRL_CHECKABLE` must be enabled on the buttons to be selected using
* `lv_btnmatrix_set_ctrl()` or `lv_btnmatrix_set_btn_ctrl_all()`.
* @param obj pointer to a button matrix object
* @param en whether "one check" mode is enabled
*/
void lv_btnmatrix_set_one_checked(lv_obj_t * obj, bool en);
/*=====================
* Getter functions
*====================*/
/**
* Get the current map of a button matrix
* @param obj pointer to a button matrix object
* @return the current map
*/
const char ** lv_btnmatrix_get_map(const lv_obj_t * obj);
/**
* Get the index of the lastly "activated" button by the user (pressed, released, focused etc)
* Useful in the `event_cb` to get the text of the button, check if hidden etc.
* @param obj pointer to button matrix object
* @return index of the last released button (LV_BTNMATRIX_BTN_NONE: if unset)
*/
uint16_t lv_btnmatrix_get_selected_btn(const lv_obj_t * obj);
/**
* Get the button's text
* @param obj pointer to button matrix object
* @param btn_id the index a button not counting new line characters.
* @return text of btn_index` button
*/
const char * lv_btnmatrix_get_btn_text(const lv_obj_t * obj, uint16_t btn_id);
/**
* Get the whether a control value is enabled or disabled for button of a button matrix
* @param obj pointer to a button matrix object
* @param btn_id the index of a button not counting new line characters.
* @param ctrl control values to check (ORed value can be used)
* @return true: the control attribute is enabled false: disabled
*/
bool lv_btnmatrix_has_btn_ctrl(lv_obj_t * obj, uint16_t btn_id, lv_btnmatrix_ctrl_t ctrl);
/**
* Tell whether "one check" mode is enabled or not.
* @param obj Button matrix object
* @return true: "one check" mode is enabled; false: disabled
*/
bool lv_btnmatrix_get_one_checked(const lv_obj_t * obj);
/**********************
* MACROS
**********************/
#endif /*LV_USE_BTNMATRIX*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_BTNMATRIX_H*/
+280
View File
@@ -0,0 +1,280 @@
/**
* @file lv_canvas.h
*
*/
#ifndef LV_CANVAS_H
#define LV_CANVAS_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "liblvgl/lv_conf_internal.h"
#if LV_USE_CANVAS != 0
#include "liblvgl/core/lv_obj.h"
#include "liblvgl/widgets/lv_img.h"
#include "liblvgl/draw/lv_draw_img.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
extern const lv_obj_class_t lv_canvas_class;
/*Data of canvas*/
typedef struct {
lv_img_t img;
lv_img_dsc_t dsc;
} lv_canvas_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a canvas object
* @param parent pointer to an object, it will be the parent of the new canvas
* @return pointer to the created canvas
*/
lv_obj_t * lv_canvas_create(lv_obj_t * parent);
/*=====================
* Setter functions
*====================*/
/**
* Set a buffer for the canvas.
* @param buf a buffer where the content of the canvas will be.
* The required size is (lv_img_color_format_get_px_size(cf) * w) / 8 * h)
* It can be allocated with `lv_mem_alloc()` or
* it can be statically allocated array (e.g. static lv_color_t buf[100*50]) or
* it can be an address in RAM or external SRAM
* @param canvas pointer to a canvas object
* @param w width of the canvas
* @param h height of the canvas
* @param cf color format. `LV_IMG_CF_...`
*/
void lv_canvas_set_buffer(lv_obj_t * canvas, void * buf, lv_coord_t w, lv_coord_t h, lv_img_cf_t cf);
/**
* Set the color of a pixel on the canvas
* @param canvas
* @param x x coordinate of the point to set
* @param y x coordinate of the point to set
* @param c color of the pixel
*/
void lv_canvas_set_px_color(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_color_t c);
/**
* DEPRECATED: added only for backward compatibility
*/
static inline void lv_canvas_set_px(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_color_t c)
{
lv_canvas_set_px_color(canvas, x, y, c);
}
/**
* Set the opacity of a pixel on the canvas
* @param canvas
* @param x x coordinate of the point to set
* @param y x coordinate of the point to set
* @param opa opacity of the pixel (0..255)
*/
void lv_canvas_set_px_opa(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_opa_t opa);
/**
* Set the palette color of a canvas with index format. Valid only for `LV_IMG_CF_INDEXED1/2/4/8`
* @param canvas pointer to canvas object
* @param id the palette color to set:
* - for `LV_IMG_CF_INDEXED1`: 0..1
* - for `LV_IMG_CF_INDEXED2`: 0..3
* - for `LV_IMG_CF_INDEXED4`: 0..15
* - for `LV_IMG_CF_INDEXED8`: 0..255
* @param c the color to set
*/
void lv_canvas_set_palette(lv_obj_t * canvas, uint8_t id, lv_color_t c);
/*=====================
* Getter functions
*====================*/
/**
* Get the color of a pixel on the canvas
* @param canvas
* @param x x coordinate of the point to set
* @param y x coordinate of the point to set
* @return color of the point
*/
lv_color_t lv_canvas_get_px(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y);
/**
* Get the image of the canvas as a pointer to an `lv_img_dsc_t` variable.
* @param canvas pointer to a canvas object
* @return pointer to the image descriptor.
*/
lv_img_dsc_t * lv_canvas_get_img(lv_obj_t * canvas);
/*=====================
* Other functions
*====================*/
/**
* Copy a buffer to the canvas
* @param canvas pointer to a canvas object
* @param to_copy buffer to copy. The color format has to match with the canvas's buffer color
* format
* @param x left side of the destination position
* @param y top side of the destination position
* @param w width of the buffer to copy
* @param h height of the buffer to copy
*/
void lv_canvas_copy_buf(lv_obj_t * canvas, const void * to_copy, lv_coord_t x, lv_coord_t y, lv_coord_t w,
lv_coord_t h);
/**
* Transform and image and store the result on a canvas.
* @param canvas pointer to a canvas object to store the result of the transformation.
* @param img pointer to an image descriptor to transform.
* Can be the image descriptor of an other canvas too (`lv_canvas_get_img()`).
* @param angle the angle of rotation (0..3600), 0.1 deg resolution
* @param zoom zoom factor (256 no zoom);
* @param offset_x offset X to tell where to put the result data on destination canvas
* @param offset_y offset X to tell where to put the result data on destination canvas
* @param pivot_x pivot X of rotation. Relative to the source canvas
* Set to `source width / 2` to rotate around the center
* @param pivot_y pivot Y of rotation. Relative to the source canvas
* Set to `source height / 2` to rotate around the center
* @param antialias apply anti-aliasing during the transformation. Looks better but slower.
*/
void lv_canvas_transform(lv_obj_t * canvas, lv_img_dsc_t * img, int16_t angle, uint16_t zoom, lv_coord_t offset_x,
lv_coord_t offset_y,
int32_t pivot_x, int32_t pivot_y, bool antialias);
/**
* Apply horizontal blur on the canvas
* @param canvas pointer to a canvas object
* @param area the area to blur. If `NULL` the whole canvas will be blurred.
* @param r radius of the blur
*/
void lv_canvas_blur_hor(lv_obj_t * canvas, const lv_area_t * area, uint16_t r);
/**
* Apply vertical blur on the canvas
* @param canvas pointer to a canvas object
* @param area the area to blur. If `NULL` the whole canvas will be blurred.
* @param r radius of the blur
*/
void lv_canvas_blur_ver(lv_obj_t * canvas, const lv_area_t * area, uint16_t r);
/**
* Fill the canvas with color
* @param canvas pointer to a canvas
* @param color the background color
* @param opa the desired opacity
*/
void lv_canvas_fill_bg(lv_obj_t * canvas, lv_color_t color, lv_opa_t opa);
/**
* Draw a rectangle on the canvas
* @param canvas pointer to a canvas object
* @param x left coordinate of the rectangle
* @param y top coordinate of the rectangle
* @param w width of the rectangle
* @param h height of the rectangle
* @param draw_dsc descriptor of the rectangle
*/
void lv_canvas_draw_rect(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h,
const lv_draw_rect_dsc_t * draw_dsc);
/**
* Draw a text on the canvas.
* @param canvas pointer to a canvas object
* @param x left coordinate of the text
* @param y top coordinate of the text
* @param max_w max width of the text. The text will be wrapped to fit into this size
* @param draw_dsc pointer to a valid label descriptor `lv_draw_label_dsc_t`
* @param txt text to display
*/
void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t max_w,
lv_draw_label_dsc_t * draw_dsc, const char * txt);
/**
* Draw an image on the canvas
* @param canvas pointer to a canvas object
* @param x left coordinate of the image
* @param y top coordinate of the image
* @param src image source. Can be a pointer an `lv_img_dsc_t` variable or a path an image.
* @param draw_dsc pointer to a valid label descriptor `lv_draw_img_dsc_t`
*/
void lv_canvas_draw_img(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, const void * src,
const lv_draw_img_dsc_t * draw_dsc);
/**
* Draw a line on the canvas
* @param canvas pointer to a canvas object
* @param points point of the line
* @param point_cnt number of points
* @param draw_dsc pointer to an initialized `lv_draw_line_dsc_t` variable
*/
void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t points[], uint32_t point_cnt,
const lv_draw_line_dsc_t * draw_dsc);
/**
* Draw a polygon on the canvas
* @param canvas pointer to a canvas object
* @param points point of the polygon
* @param point_cnt number of points
* @param draw_dsc pointer to an initialized `lv_draw_rect_dsc_t` variable
*/
void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t points[], uint32_t point_cnt,
const lv_draw_rect_dsc_t * draw_dsc);
/**
* Draw an arc on the canvas
* @param canvas pointer to a canvas object
* @param x origo x of the arc
* @param y origo y of the arc
* @param r radius of the arc
* @param start_angle start angle in degrees
* @param end_angle end angle in degrees
* @param draw_dsc pointer to an initialized `lv_draw_line_dsc_t` variable
*/
void lv_canvas_draw_arc(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t r, int32_t start_angle,
int32_t end_angle, const lv_draw_arc_dsc_t * draw_dsc);
/**********************
* MACROS
**********************/
#define LV_CANVAS_BUF_SIZE_TRUE_COLOR(w, h) LV_IMG_BUF_SIZE_TRUE_COLOR(w, h)
#define LV_CANVAS_BUF_SIZE_TRUE_COLOR_CHROMA_KEYED(w, h) LV_IMG_BUF_SIZE_TRUE_COLOR_CHROMA_KEYED(w, h)
#define LV_CANVAS_BUF_SIZE_TRUE_COLOR_ALPHA(w, h) LV_IMG_BUF_SIZE_TRUE_COLOR_ALPHA(w, h)
/*+ 1: to be sure no fractional row*/
#define LV_CANVAS_BUF_SIZE_ALPHA_1BIT(w, h) LV_IMG_BUF_SIZE_ALPHA_1BIT(w, h)
#define LV_CANVAS_BUF_SIZE_ALPHA_2BIT(w, h) LV_IMG_BUF_SIZE_ALPHA_2BIT(w, h)
#define LV_CANVAS_BUF_SIZE_ALPHA_4BIT(w, h) LV_IMG_BUF_SIZE_ALPHA_4BIT(w, h)
#define LV_CANVAS_BUF_SIZE_ALPHA_8BIT(w, h) LV_IMG_BUF_SIZE_ALPHA_8BIT(w, h)
/*4 * X: for palette*/
#define LV_CANVAS_BUF_SIZE_INDEXED_1BIT(w, h) LV_IMG_BUF_SIZE_INDEXED_1BIT(w, h)
#define LV_CANVAS_BUF_SIZE_INDEXED_2BIT(w, h) LV_IMG_BUF_SIZE_INDEXED_2BIT(w, h)
#define LV_CANVAS_BUF_SIZE_INDEXED_4BIT(w, h) LV_IMG_BUF_SIZE_INDEXED_4BIT(w, h)
#define LV_CANVAS_BUF_SIZE_INDEXED_8BIT(w, h) LV_IMG_BUF_SIZE_INDEXED_8BIT(w, h)
#endif /*LV_USE_CANVAS*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_CANVAS_H*/
+97
View File
@@ -0,0 +1,97 @@
/**
* @file lv_cb.h
*
*/
#ifndef LV_CHECKBOX_H
#define LV_CHECKBOX_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "liblvgl/lv_conf_internal.h"
#include "liblvgl/core/lv_obj.h"
#if LV_USE_CHECKBOX != 0
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
typedef struct {
lv_obj_t obj;
char * txt;
uint32_t static_txt : 1;
} lv_checkbox_t;
extern const lv_obj_class_t lv_checkbox_class;
/**
* `type` field in `lv_obj_draw_part_dsc_t` if `class_p = lv_checkbox_class`
* Used in `LV_EVENT_DRAW_PART_BEGIN` and `LV_EVENT_DRAW_PART_END`
*/
typedef enum {
LV_CHECKBOX_DRAW_PART_BOX, /**< The tick box*/
} lv_checkbox_draw_part_type_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a check box object
* @param parent pointer to an object, it will be the parent of the new button
* @return pointer to the created check box
*/
lv_obj_t * lv_checkbox_create(lv_obj_t * parent);
/*=====================
* Setter functions
*====================*/
/**
* Set the text of a check box. `txt` will be copied and may be deallocated
* after this function returns.
* @param cb pointer to a check box
* @param txt the text of the check box. NULL to refresh with the current text.
*/
void lv_checkbox_set_text(lv_obj_t * obj, const char * txt);
/**
* Set the text of a check box. `txt` must not be deallocated during the life
* of this checkbox.
* @param cb pointer to a check box
* @param txt the text of the check box.
*/
void lv_checkbox_set_text_static(lv_obj_t * obj, const char * txt);
/*=====================
* Getter functions
*====================*/
/**
* Get the text of a check box
* @param cb pointer to check box object
* @return pointer to the text of the check box
*/
const char * lv_checkbox_get_text(const lv_obj_t * obj);
/**********************
* MACROS
**********************/
#endif /*LV_USE_CHECKBOX*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_CHECKBOX_H*/
+254
View File
@@ -0,0 +1,254 @@
/**
* @file lv_dropdown.h
*
*/
#ifndef LV_DROPDOWN_H
#define LV_DROPDOWN_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "liblvgl/lv_conf_internal.h"
#if LV_USE_DROPDOWN != 0
/*Testing of dependencies*/
#if LV_USE_LABEL == 0
#error "lv_dropdown: lv_label is required. Enable it in lv_conf.h (LV_USE_LABEL 1)"
#endif
#include "../widgets/lv_label.h"
/*********************
* DEFINES
*********************/
#define LV_DROPDOWN_POS_LAST 0xFFFF
LV_EXPORT_CONST_INT(LV_DROPDOWN_POS_LAST);
/**********************
* TYPEDEFS
**********************/
typedef struct {
lv_obj_t obj;
lv_obj_t * list; /**< The dropped down list*/
const char * text; /**< Text to display on the dropdown's button*/
const void * symbol; /**< Arrow or other icon when the drop-down list is closed*/
char * options; /**< Options in a '\n' separated list*/
uint16_t option_cnt; /**< Number of options*/
uint16_t sel_opt_id; /**< Index of the currently selected option*/
uint16_t sel_opt_id_orig; /**< Store the original index on focus*/
uint16_t pr_opt_id; /**< Index of the currently pressed option*/
lv_dir_t dir : 4; /**< Direction in which the list should open*/
uint8_t static_txt : 1; /**< 1: Only a pointer is saved in `options`*/
uint8_t selected_highlight: 1; /**< 1: Make the selected option highlighted in the list*/
} lv_dropdown_t;
typedef struct {
lv_obj_t obj;
lv_obj_t * dropdown;
} lv_dropdown_list_t;
extern const lv_obj_class_t lv_dropdown_class;
extern const lv_obj_class_t lv_dropdownlist_class;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a drop-down list object
* @param parent pointer to an object, it will be the parent of the new drop-down list
* @return pointer to the created drop-down list
*/
lv_obj_t * lv_dropdown_create(lv_obj_t * parent);
/*=====================
* Setter functions
*====================*/
/**
* Set text of the drop-down list's button.
* If set to `NULL` the selected option's text will be displayed on the button.
* If set to a specific text then that text will be shown regardless of the selected option.
* @param obj pointer to a drop-down list object
* @param txt the text as a string (Only its pointer is saved)
*/
void lv_dropdown_set_text(lv_obj_t * obj, const char * txt);
/**
* Set the options in a drop-down list from a string.
* The options will be copied and saved in the object so the `options` can be destroyed after calling this function
* @param obj pointer to drop-down list object
* @param options a string with '\n' separated options. E.g. "One\nTwo\nThree"
*/
void lv_dropdown_set_options(lv_obj_t * obj, const char * options);
/**
* Set the options in a drop-down list from a static string (global, static or dynamically allocated).
* Only the pointer of the option string will be saved.
* @param obj pointer to drop-down list object
* @param options a static string with '\n' separated options. E.g. "One\nTwo\nThree"
*/
void lv_dropdown_set_options_static(lv_obj_t * obj, const char * options);
/**
* Add an options to a drop-down list from a string. Only works for non-static options.
* @param obj pointer to drop-down list object
* @param option a string without '\n'. E.g. "Four"
* @param pos the insert position, indexed from 0, LV_DROPDOWN_POS_LAST = end of string
*/
void lv_dropdown_add_option(lv_obj_t * obj, const char * option, uint32_t pos);
/**
* Clear all options in a drop-down list. Works with both static and dynamic options.
* @param obj pointer to drop-down list object
*/
void lv_dropdown_clear_options(lv_obj_t * obj);
/**
* Set the selected option
* @param obj pointer to drop-down list object
* @param sel_opt id of the selected option (0 ... number of option - 1);
*/
void lv_dropdown_set_selected(lv_obj_t * obj, uint16_t sel_opt);
/**
* Set the direction of the a drop-down list
* @param obj pointer to a drop-down list object
* @param dir LV_DIR_LEFT/RIGHT/TOP/BOTTOM
*/
void lv_dropdown_set_dir(lv_obj_t * obj, lv_dir_t dir);
/**
* Set an arrow or other symbol to display when on drop-down list's button. Typically a down caret or arrow.
* @param obj pointer to drop-down list object
* @param symbol a text like `LV_SYMBOL_DOWN`, an image (pointer or path) or NULL to not draw symbol icon
* @note angle and zoom transformation can be applied if the symbol is an image.
* E.g. when drop down is checked (opened) rotate the symbol by 180 degree
*/
void lv_dropdown_set_symbol(lv_obj_t * obj, const void * symbol);
/**
* Set whether the selected option in the list should be highlighted or not
* @param obj pointer to drop-down list object
* @param en true: highlight enabled; false: disabled
*/
void lv_dropdown_set_selected_highlight(lv_obj_t * obj, bool en);
/*=====================
* Getter functions
*====================*/
/**
* Get the list of a drop-down to allow styling or other modifications
* @param obj pointer to a drop-down list object
* @return pointer to the list of the drop-down
*/
lv_obj_t * lv_dropdown_get_list(lv_obj_t * obj);
/**
* Get text of the drop-down list's button.
* @param obj pointer to a drop-down list object
* @return the text as string, `NULL` if no text
*/
const char * lv_dropdown_get_text(lv_obj_t * obj);
/**
* Get the options of a drop-down list
* @param obj pointer to drop-down list object
* @return the options separated by '\n'-s (E.g. "Option1\nOption2\nOption3")
*/
const char * lv_dropdown_get_options(const lv_obj_t * obj);
/**
* Get the index of the selected option
* @param obj pointer to drop-down list object
* @return index of the selected option (0 ... number of option - 1);
*/
uint16_t lv_dropdown_get_selected(const lv_obj_t * obj);
/**
* Get the total number of options
* @param obj pointer to drop-down list object
* @return the total number of options in the list
*/
uint16_t lv_dropdown_get_option_cnt(const lv_obj_t * obj);
/**
* Get the current selected option as a string
* @param obj pointer to drop-down object
* @param buf pointer to an array to store the string
* @param buf_size size of `buf` in bytes. 0: to ignore it.
*/
void lv_dropdown_get_selected_str(const lv_obj_t * obj, char * buf, uint32_t buf_size);
/**
* Get the index of an option.
* @param obj pointer to drop-down object
* @param option an option as string
* @return index of `option` in the list of all options. -1 if not found.
*/
int32_t lv_dropdown_get_option_index(lv_obj_t * obj, const char * option);
/**
* Get the symbol on the drop-down list. Typically a down caret or arrow.
* @param obj pointer to drop-down list object
* @return the symbol or NULL if not enabled
*/
const char * lv_dropdown_get_symbol(lv_obj_t * obj);
/**
* Get whether the selected option in the list should be highlighted or not
* @param obj pointer to drop-down list object
* @return true: highlight enabled; false: disabled
*/
bool lv_dropdown_get_selected_highlight(lv_obj_t * obj);
/**
* Get the direction of the drop-down list
* @param obj pointer to a drop-down list object
* @return LV_DIR_LEF/RIGHT/TOP/BOTTOM
*/
lv_dir_t lv_dropdown_get_dir(const lv_obj_t * obj);
/*=====================
* Other functions
*====================*/
/**
* Open the drop.down list
* @param obj pointer to drop-down list object
*/
void lv_dropdown_open(lv_obj_t * dropdown_obj);
/**
* Close (Collapse) the drop-down list
* @param obj pointer to drop-down list object
*/
void lv_dropdown_close(lv_obj_t * obj);
/**
* Tells whether the list is opened or not
* @param obj pointer to a drop-down list object
* @return true if the list os opened
*/
bool lv_dropdown_is_open(lv_obj_t * obj);
/**********************
* MACROS
**********************/
#endif /*LV_USE_DROPDOWN*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_DROPDOWN_H*/
+234
View File
@@ -0,0 +1,234 @@
/**
* @file lv_img.h
*
*/
#ifndef LV_IMG_H
#define LV_IMG_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "liblvgl/lv_conf_internal.h"
#if LV_USE_IMG != 0
/*Testing of dependencies*/
#if LV_USE_LABEL == 0
#error "lv_img: lv_label is required. Enable it in lv_conf.h (LV_USE_LABEL 1)"
#endif
#include "liblvgl/core/lv_obj.h"
#include "liblvgl/misc/lv_fs.h"
#include "liblvgl/draw/lv_draw.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**
* Data of image
*/
typedef struct {
lv_obj_t obj;
const void * src; /*Image source: Pointer to an array or a file or a symbol*/
lv_point_t offset;
lv_coord_t w; /*Width of the image (Handled by the library)*/
lv_coord_t h; /*Height of the image (Handled by the library)*/
uint16_t angle; /*rotation angle of the image*/
lv_point_t pivot; /*rotation center of the image*/
uint16_t zoom; /*256 means no zoom, 512 double size, 128 half size*/
uint8_t src_type : 2; /*See: lv_img_src_t*/
uint8_t cf : 5; /*Color format from `lv_img_color_format_t`*/
uint8_t antialias : 1; /*Apply anti-aliasing in transformations (rotate, zoom)*/
uint8_t obj_size_mode: 2; /*Image size mode when image size and object size is different.*/
} lv_img_t;
extern const lv_obj_class_t lv_img_class;
/**
* Image size mode, when image size and object size is different
*/
enum {
/** Zoom doesn't affect the coordinates of the object,
* however if zoomed in the image is drawn out of the its coordinates.
* The layout's won't change on zoom */
LV_IMG_SIZE_MODE_VIRTUAL = 0,
/** If the object size is set to SIZE_CONTENT, then object size equals zoomed image size.
* It causes layout recalculation.
* If the object size is set explicitly, the image will be cropped when zoomed in.*/
LV_IMG_SIZE_MODE_REAL,
};
typedef uint8_t lv_img_size_mode_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create an image object
* @param parent pointer to an object, it will be the parent of the new image
* @return pointer to the created image
*/
lv_obj_t * lv_img_create(lv_obj_t * parent);
/*=====================
* Setter functions
*====================*/
/**
* Set the image data to display on the object
* @param obj pointer to an image object
* @param src_img 1) pointer to an ::lv_img_dsc_t descriptor (converted by LVGL's image converter) (e.g. &my_img) or
* 2) path to an image file (e.g. "S:/dir/img.bin")or
* 3) a SYMBOL (e.g. LV_SYMBOL_OK)
*/
void lv_img_set_src(lv_obj_t * obj, const void * src);
/**
* Set an offset for the source of an image so the image will be displayed from the new origin.
* @param obj pointer to an image
* @param x the new offset along x axis.
*/
void lv_img_set_offset_x(lv_obj_t * obj, lv_coord_t x);
/**
* Set an offset for the source of an image.
* so the image will be displayed from the new origin.
* @param obj pointer to an image
* @param y the new offset along y axis.
*/
void lv_img_set_offset_y(lv_obj_t * obj, lv_coord_t y);
/**
* Set the rotation angle of the image.
* The image will be rotated around the set pivot set by `lv_img_set_pivot()`
* Note that indexed and alpha only images can't be transformed.
* @param obj pointer to an image object
* @param angle rotation angle in degree with 0.1 degree resolution (0..3600: clock wise)
*/
void lv_img_set_angle(lv_obj_t * obj, int16_t angle);
/**
* Set the rotation center of the image.
* The image will be rotated around this point.
* @param obj pointer to an image object
* @param x rotation center x of the image
* @param y rotation center y of the image
*/
void lv_img_set_pivot(lv_obj_t * obj, lv_coord_t x, lv_coord_t y);
/**
* Set the zoom factor of the image.
* Note that indexed and alpha only images can't be transformed.
* @param img pointer to an image object
* @param zoom the zoom factor.
* @example 256 or LV_ZOOM_IMG_NONE for no zoom
* @example <256: scale down
* @example >256 scale up
* @example 128 half size
* @example 512 double size
*/
void lv_img_set_zoom(lv_obj_t * obj, uint16_t zoom);
/**
* Enable/disable anti-aliasing for the transformations (rotate, zoom) or not.
* The quality is better with anti-aliasing looks better but slower.
* @param obj pointer to an image object
* @param antialias true: anti-aliased; false: not anti-aliased
*/
void lv_img_set_antialias(lv_obj_t * obj, bool antialias);
/**
* Set the image object size mode.
*
* @param obj pointer to an image object
* @param mode the new size mode.
*/
void lv_img_set_size_mode(lv_obj_t * obj, lv_img_size_mode_t mode);
/*=====================
* Getter functions
*====================*/
/**
* Get the source of the image
* @param obj pointer to an image object
* @return the image source (symbol, file name or ::lv-img_dsc_t for C arrays)
*/
const void * lv_img_get_src(lv_obj_t * obj);
/**
* Get the offset's x attribute of the image object.
* @param img pointer to an image
* @return offset X value.
*/
lv_coord_t lv_img_get_offset_x(lv_obj_t * obj);
/**
* Get the offset's y attribute of the image object.
* @param obj pointer to an image
* @return offset Y value.
*/
lv_coord_t lv_img_get_offset_y(lv_obj_t * obj);
/**
* Get the rotation angle of the image.
* @param obj pointer to an image object
* @return rotation angle in 0.1 degrees (0..3600)
*/
uint16_t lv_img_get_angle(lv_obj_t * obj);
/**
* Get the pivot (rotation center) of the image.
* @param img pointer to an image object
* @param pivot store the rotation center here
*/
void lv_img_get_pivot(lv_obj_t * obj, lv_point_t * pivot);
/**
* Get the zoom factor of the image.
* @param obj pointer to an image object
* @return zoom factor (256: no zoom)
*/
uint16_t lv_img_get_zoom(lv_obj_t * obj);
/**
* Get whether the transformations (rotate, zoom) are anti-aliased or not
* @param obj pointer to an image object
* @return true: anti-aliased; false: not anti-aliased
*/
bool lv_img_get_antialias(lv_obj_t * obj);
/**
* Get the size mode of the image
* @param obj pointer to an image object
* @return element of @ref lv_img_size_mode_t
*/
lv_img_size_mode_t lv_img_get_size_mode(lv_obj_t * obj);
/**********************
* MACROS
**********************/
/** Use this macro to declare an image in a C file*/
#define LV_IMG_DECLARE(var_name) extern const lv_img_dsc_t var_name;
#endif /*LV_USE_IMG*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_IMG_H*/
+246
View File
@@ -0,0 +1,246 @@
/**
* @file lv_label.h
*
*/
#ifndef LV_LABEL_H
#define LV_LABEL_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../lv_conf_internal.h"
#if LV_USE_LABEL != 0
#include <stdarg.h>
#include "liblvgl/core/lv_obj.h"
#include "liblvgl/font/lv_font.h"
#include "liblvgl/font/lv_symbol_def.h"
#include "liblvgl/misc/lv_txt.h"
#include "liblvgl/draw/lv_draw.h"
/*********************
* DEFINES
*********************/
#define LV_LABEL_WAIT_CHAR_COUNT 3
#define LV_LABEL_DOT_NUM 3
#define LV_LABEL_POS_LAST 0xFFFF
#define LV_LABEL_TEXT_SELECTION_OFF LV_DRAW_LABEL_NO_TXT_SEL
LV_EXPORT_CONST_INT(LV_LABEL_DOT_NUM);
LV_EXPORT_CONST_INT(LV_LABEL_POS_LAST);
LV_EXPORT_CONST_INT(LV_LABEL_TEXT_SELECTION_OFF);
/**********************
* TYPEDEFS
**********************/
/** Long mode behaviors. Used in 'lv_label_ext_t'*/
enum {
LV_LABEL_LONG_WRAP, /**< Keep the object width, wrap the too long lines and expand the object height*/
LV_LABEL_LONG_DOT, /**< Keep the size and write dots at the end if the text is too long*/
LV_LABEL_LONG_SCROLL, /**< Keep the size and roll the text back and forth*/
LV_LABEL_LONG_SCROLL_CIRCULAR, /**< Keep the size and roll the text circularly*/
LV_LABEL_LONG_CLIP, /**< Keep the size and clip the text out of it*/
};
typedef uint8_t lv_label_long_mode_t;
typedef struct {
lv_obj_t obj;
char * text;
union {
char * tmp_ptr; /*Pointer to the allocated memory containing the character replaced by dots*/
char tmp[LV_LABEL_DOT_NUM + 1]; /*Directly store the characters if <=4 characters*/
} dot;
uint32_t dot_end; /*The real text length, used in dot mode*/
#if LV_LABEL_LONG_TXT_HINT
lv_draw_label_hint_t hint;
#endif
#if LV_LABEL_TEXT_SELECTION
uint32_t sel_start;
uint32_t sel_end;
#endif
lv_point_t offset; /*Text draw position offset*/
lv_label_long_mode_t long_mode : 3; /*Determine what to do with the long texts*/
uint8_t static_txt : 1; /*Flag to indicate the text is static*/
uint8_t recolor : 1; /*Enable in-line letter re-coloring*/
uint8_t expand : 1; /*Ignore real width (used by the library with LV_LABEL_LONG_SCROLL)*/
uint8_t dot_tmp_alloc : 1; /*1: dot is allocated, 0: dot directly holds up to 4 chars*/
} lv_label_t;
extern const lv_obj_class_t lv_label_class;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a label object
* @param parent pointer to an object, it will be the parent of the new label.
* @return pointer to the created button
*/
lv_obj_t * lv_label_create(lv_obj_t * parent);
/*=====================
* Setter functions
*====================*/
/**
* Set a new text for a label. Memory will be allocated to store the text by the label.
* @param obj pointer to a label object
* @param text '\0' terminated character string. NULL to refresh with the current text.
*/
void lv_label_set_text(lv_obj_t * obj, const char * text);
/**
* Set a new formatted text for a label. Memory will be allocated to store the text by the label.
* @param obj pointer to a label object
* @param fmt `printf`-like format
* @example lv_label_set_text_fmt(label1, "%d user", user_num);
*/
void lv_label_set_text_fmt(lv_obj_t * obj, const char * fmt, ...) LV_FORMAT_ATTRIBUTE(2, 3);
/**
* Set a static text. It will not be saved by the label so the 'text' variable
* has to be 'alive' while the label exists.
* @param obj pointer to a label object
* @param text pointer to a text. NULL to refresh with the current text.
*/
void lv_label_set_text_static(lv_obj_t * obj, const char * text);
/**
* Set the behavior of the label with longer text then the object size
* @param obj pointer to a label object
* @param long_mode the new mode from 'lv_label_long_mode' enum.
* In LV_LONG_WRAP/DOT/SCROLL/SCROLL_CIRC the size of the label should be set AFTER this function
*/
void lv_label_set_long_mode(lv_obj_t * obj, lv_label_long_mode_t long_mode);
/**
* Enable the recoloring by in-line commands
* @param obj pointer to a label object
* @param en true: enable recoloring, false: disable
* @example "This is a #ff0000 red# word"
*/
void lv_label_set_recolor(lv_obj_t * obj, bool en);
/**
* Set where text selection should start
* @param obj pointer to a label object
* @param index character index from where selection should start. `LV_LABEL_TEXT_SELECTION_OFF` for no selection
*/
void lv_label_set_text_sel_start(lv_obj_t * obj, uint32_t index);
/**
* Set where text selection should end
* @param obj pointer to a label object
* @param index character index where selection should end. `LV_LABEL_TEXT_SELECTION_OFF` for no selection
*/
void lv_label_set_text_sel_end(lv_obj_t * obj, uint32_t index);
/*=====================
* Getter functions
*====================*/
/**
* Get the text of a label
* @param obj pointer to a label object
* @return the text of the label
*/
char * lv_label_get_text(const lv_obj_t * obj);
/**
* Get the long mode of a label
* @param obj pointer to a label object
* @return the current long mode
*/
lv_label_long_mode_t lv_label_get_long_mode(const lv_obj_t * obj);
/**
* Get the recoloring attribute
* @param obj pointer to a label object
* @return true: recoloring is enabled, false: disable
*/
bool lv_label_get_recolor(const lv_obj_t * obj);
/**
* Get the relative x and y coordinates of a letter
* @param obj pointer to a label object
* @param index index of the character [0 ... text length - 1].
* Expressed in character index, not byte index (different in UTF-8)
* @param pos store the result here (E.g. index = 0 gives 0;0 coordinates if the text if aligned to the left)
*/
void lv_label_get_letter_pos(const lv_obj_t * obj, uint32_t char_id, lv_point_t * pos);
/**
* Get the index of letter on a relative point of a label.
* @param obj pointer to label object
* @param pos pointer to point with coordinates on a the label
* @return The index of the letter on the 'pos_p' point (E.g. on 0;0 is the 0. letter if aligned to the left)
* Expressed in character index and not byte index (different in UTF-8)
*/
uint32_t lv_label_get_letter_on(const lv_obj_t * obj, lv_point_t * pos_in);
/**
* Check if a character is drawn under a point.
* @param obj pointer to a label object
* @param pos Point to check for character under
* @return whether a character is drawn under the point
*/
bool lv_label_is_char_under_pos(const lv_obj_t * obj, lv_point_t * pos);
/**
* @brief Get the selection start index.
* @param obj pointer to a label object.
* @return selection start index. `LV_LABEL_TEXT_SELECTION_OFF` if nothing is selected.
*/
uint32_t lv_label_get_text_selection_start(const lv_obj_t * obj);
/**
* @brief Get the selection end index.
* @param obj pointer to a label object.
* @return selection end index. `LV_LABEL_TXT_SEL_OFF` if nothing is selected.
*/
uint32_t lv_label_get_text_selection_end(const lv_obj_t * obj);
/*=====================
* Other functions
*====================*/
/**
* Insert a text to a label. The label text can not be static.
* @param obj pointer to a label object
* @param pos character index to insert. Expressed in character index and not byte index.
* 0: before first char. LV_LABEL_POS_LAST: after last char.
* @param txt pointer to the text to insert
*/
void lv_label_ins_text(lv_obj_t * obj, uint32_t pos, const char * txt);
/**
* Delete characters from a label. The label text can not be static.
* @param obj pointer to a label object
* @param pos character index from where to cut. Expressed in character index and not byte index.
* 0: start in from of the first character
* @param cnt number of characters to cut
*/
void lv_label_cut_text(lv_obj_t * obj, uint32_t pos, uint32_t cnt);
/**********************
* MACROS
**********************/
#endif /*LV_USE_LABEL*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_LABEL_H*/
+93
View File
@@ -0,0 +1,93 @@
/**
* @file lv_line.h
*
*/
#ifndef LV_LINE_H
#define LV_LINE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "liblvgl/lv_conf_internal.h"
#if LV_USE_LINE != 0
#include "liblvgl/core/lv_obj.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/*Data of line*/
typedef struct {
lv_obj_t obj;
const lv_point_t * point_array; /**< Pointer to an array with the points of the line*/
uint16_t point_num; /**< Number of points in 'point_array'*/
uint8_t y_inv : 1; /**< 1: y == 0 will be on the bottom*/
} lv_line_t;
extern const lv_obj_class_t lv_line_class;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a line object
* @param parent pointer to an object, it will be the parent of the new line
* @return pointer to the created line
*/
lv_obj_t * lv_line_create(lv_obj_t * parent);
/*=====================
* Setter functions
*====================*/
/**
* Set an array of points. The line object will connect these points.
* @param obj pointer to a line object
* @param points an array of points. Only the address is saved, so the array needs to be alive while the line exists
* @param point_num number of points in 'point_a'
*/
void lv_line_set_points(lv_obj_t * obj, const lv_point_t points[], uint16_t point_num);
/**
* Enable (or disable) the y coordinate inversion.
* If enabled then y will be subtracted from the height of the object,
* therefore the y = 0 coordinate will be on the bottom.
* @param obj pointer to a line object
* @param en true: enable the y inversion, false:disable the y inversion
*/
void lv_line_set_y_invert(lv_obj_t * obj, bool en);
/*=====================
* Getter functions
*====================*/
/**
* Get the y inversion attribute
* @param obj pointer to a line object
* @return true: y inversion is enabled, false: disabled
*/
bool lv_line_get_y_invert(const lv_obj_t * obj);
/**********************
* MACROS
**********************/
#endif /*LV_USE_LINE*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_LINE_H*/
+81
View File
@@ -0,0 +1,81 @@
/**
* @file lv_templ.h
*
*/
/**
* TODO Remove these instructions
* Search and replace: templ -> object short name with lower case(e.g. btn, label etc)
* TEMPL -> object short name with upper case (e.g. BTN, LABEL etc.)
*
*/
#ifndef LV_TEMPL_H
#define LV_TEMPL_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "liblvgl/lv_conf_internal.h"
#if LV_USE_TEMPL != 0
#include "liblvgl/core/lv_obj.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/*Data of template*/
typedef struct {
lv_ANCESTOR_t ancestor; /*The ancestor widget, e.g. lv_slider_t slider*/
/*New data for this type*/
} lv_templ_t;
extern const lv_obj_class_t lv_templ_class;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a templ object
* @param parent pointer to an object, it will be the parent of the new templ
* @return pointer to the created bar
*/
lv_obj_t * lv_templ_create(lv_obj_t * parent);
/*======================
* Add/remove functions
*=====================*/
/*=====================
* Setter functions
*====================*/
/*=====================
* Getter functions
*====================*/
/*=====================
* Other functions
*====================*/
/**********************
* MACROS
**********************/
#endif /*LV_USE_TEMPL*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_TEMPL_H*/
+138
View File
@@ -0,0 +1,138 @@
/**
* @file lv_roller.h
*
*/
#ifndef LV_ROLLER_H
#define LV_ROLLER_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "liblvgl/lv_conf_internal.h"
#if LV_USE_ROLLER != 0
/*Testing of dependencies*/
#if LV_USE_LABEL == 0
#error "lv_roller: lv_label is required. Enable it in lv_conf.h (LV_USE_ROLLER 1)"
#endif
#include "liblvgl/core/lv_obj.h"
#include "lv_label.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/** Roller mode.*/
enum {
LV_ROLLER_MODE_NORMAL, /**< Normal mode (roller ends at the end of the options).*/
LV_ROLLER_MODE_INFINITE, /**< Infinite mode (roller can be scrolled forever).*/
};
typedef uint8_t lv_roller_mode_t;
typedef struct {
lv_obj_t obj;
uint16_t option_cnt; /**< Number of options*/
uint16_t sel_opt_id; /**< Index of the current option*/
uint16_t sel_opt_id_ori; /**< Store the original index on focus*/
lv_roller_mode_t mode : 1;
uint32_t moved : 1;
} lv_roller_t;
extern const lv_obj_class_t lv_roller_class;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a roller object
* @param parent pointer to an object, it will be the parent of the new roller.
* @return pointer to the created roller
*/
lv_obj_t * lv_roller_create(lv_obj_t * parent);
/*=====================
* Setter functions
*====================*/
/**
* Set the options on a roller
* @param obj pointer to roller object
* @param options a string with '\n' separated options. E.g. "One\nTwo\nThree"
* @param mode `LV_ROLLER_MODE_NORMAL` or `LV_ROLLER_MODE_INFINITE`
*/
void lv_roller_set_options(lv_obj_t * obj, const char * options, lv_roller_mode_t mode);
/**
* Set the selected option
* @param obj pointer to a roller object
* @param sel_opt index of the selected option (0 ... number of option - 1);
* @param anim_en LV_ANIM_ON: set with animation; LV_ANOM_OFF set immediately
*/
void lv_roller_set_selected(lv_obj_t * obj, uint16_t sel_opt, lv_anim_enable_t anim);
/**
* Set the height to show the given number of rows (options)
* @param obj pointer to a roller object
* @param row_cnt number of desired visible rows
*/
void lv_roller_set_visible_row_count(lv_obj_t * obj, uint8_t row_cnt);
/*=====================
* Getter functions
*====================*/
/**
* Get the index of the selected option
* @param obj pointer to a roller object
* @return index of the selected option (0 ... number of option - 1);
*/
uint16_t lv_roller_get_selected(const lv_obj_t * obj);
/**
* Get the current selected option as a string.
* @param obj pointer to ddlist object
* @param buf pointer to an array to store the string
* @param buf_size size of `buf` in bytes. 0: to ignore it.
*/
void lv_roller_get_selected_str(const lv_obj_t * obj, char * buf, uint32_t buf_size);
/**
* Get the options of a roller
* @param obj pointer to roller object
* @return the options separated by '\n'-s (E.g. "Option1\nOption2\nOption3")
*/
const char * lv_roller_get_options(const lv_obj_t * obj);
/**
* Get the total number of options
* @param obj pointer to a roller object
* @return the total number of options
*/
uint16_t lv_roller_get_option_cnt(const lv_obj_t * obj);
/**********************
* MACROS
**********************/
#endif /*LV_USE_ROLLER*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_ROLLER_H*/
+195
View File
@@ -0,0 +1,195 @@
/**
* @file lv_slider.h
*
*/
#ifndef LV_SLIDER_H
#define LV_SLIDER_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "liblvgl/lv_conf_internal.h"
#if LV_USE_SLIDER != 0
/*Testing of dependencies*/
#if LV_USE_BAR == 0
#error "lv_slider: lv_bar is required. Enable it in lv_conf.h (LV_USE_BAR 1)"
#endif
#include "liblvgl/core/lv_obj.h"
#include "lv_bar.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
enum {
LV_SLIDER_MODE_NORMAL = LV_BAR_MODE_NORMAL,
LV_SLIDER_MODE_SYMMETRICAL = LV_BAR_MODE_SYMMETRICAL,
LV_SLIDER_MODE_RANGE = LV_BAR_MODE_RANGE
};
typedef uint8_t lv_slider_mode_t;
typedef struct {
lv_bar_t bar; /*Add the ancestor's type first*/
lv_area_t left_knob_area;
lv_area_t right_knob_area;
int32_t * value_to_set; /*Which bar value to set*/
uint8_t dragging : 1; /*1: the slider is being dragged*/
uint8_t left_knob_focus : 1; /*1: with encoder now the right knob can be adjusted*/
} lv_slider_t;
extern const lv_obj_class_t lv_slider_class;
/**
* `type` field in `lv_obj_draw_part_dsc_t` if `class_p = lv_slider_class`
* Used in `LV_EVENT_DRAW_PART_BEGIN` and `LV_EVENT_DRAW_PART_END`
*/
typedef enum {
LV_SLIDER_DRAW_PART_KNOB, /**< The main (right) knob's rectangle*/
LV_SLIDER_DRAW_PART_KNOB_LEFT, /**< The left knob's rectangle*/
} lv_slider_draw_part_type_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a slider object
* @param parent pointer to an object, it will be the parent of the new slider.
* @return pointer to the created slider
*/
lv_obj_t * lv_slider_create(lv_obj_t * parent);
/*=====================
* Setter functions
*====================*/
/**
* Set a new value on the slider
* @param obj pointer to a slider object
* @param value the new value
* @param anim LV_ANIM_ON: set the value with an animation; LV_ANIM_OFF: change the value immediately
*/
static inline void lv_slider_set_value(lv_obj_t * obj, int32_t value, lv_anim_enable_t anim)
{
lv_bar_set_value(obj, value, anim);
}
/**
* Set a new value for the left knob of a slider
* @param obj pointer to a slider object
* @param value new value
* @param anim LV_ANIM_ON: set the value with an animation; LV_ANIM_OFF: change the value immediately
*/
static inline void lv_slider_set_left_value(lv_obj_t * obj, int32_t value, lv_anim_enable_t anim)
{
lv_bar_set_start_value(obj, value, anim);
}
/**
* Set minimum and the maximum values of a bar
* @param obj pointer to the slider object
* @param min minimum value
* @param max maximum value
*/
static inline void lv_slider_set_range(lv_obj_t * obj, int32_t min, int32_t max)
{
lv_bar_set_range(obj, min, max);
}
/**
* Set the mode of slider.
* @param obj pointer to a slider object
* @param mode the mode of the slider. See ::lv_slider_mode_t
*/
static inline void lv_slider_set_mode(lv_obj_t * obj, lv_slider_mode_t mode)
{
lv_bar_set_mode(obj, (lv_bar_mode_t)mode);
}
/*=====================
* Getter functions
*====================*/
/**
* Get the value of the main knob of a slider
* @param obj pointer to a slider object
* @return the value of the main knob of the slider
*/
static inline int32_t lv_slider_get_value(const lv_obj_t * obj)
{
return lv_bar_get_value(obj);
}
/**
* Get the value of the left knob of a slider
* @param obj pointer to a slider object
* @return the value of the left knob of the slider
*/
static inline int32_t lv_slider_get_left_value(const lv_obj_t * obj)
{
return lv_bar_get_start_value(obj);
}
/**
* Get the minimum value of a slider
* @param obj pointer to a slider object
* @return the minimum value of the slider
*/
static inline int32_t lv_slider_get_min_value(const lv_obj_t * obj)
{
return lv_bar_get_min_value(obj);
}
/**
* Get the maximum value of a slider
* @param obj pointer to a slider object
* @return the maximum value of the slider
*/
static inline int32_t lv_slider_get_max_value(const lv_obj_t * obj)
{
return lv_bar_get_max_value(obj);
}
/**
* Give the slider is being dragged or not
* @param obj pointer to a slider object
* @return true: drag in progress false: not dragged
*/
bool lv_slider_is_dragged(const lv_obj_t * obj);
/**
* Get the mode of the slider.
* @param obj pointer to a bar object
* @return see ::lv_slider_mode_t
*/
static inline lv_slider_mode_t lv_slider_get_mode(lv_obj_t * slider)
{
lv_bar_mode_t mode = lv_bar_get_mode(slider);
if(mode == LV_BAR_MODE_SYMMETRICAL) return LV_SLIDER_MODE_SYMMETRICAL;
else if(mode == LV_BAR_MODE_RANGE) return LV_SLIDER_MODE_RANGE;
else return LV_SLIDER_MODE_NORMAL;
}
/**********************
* MACROS
**********************/
#endif /*LV_USE_SLIDER*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_SLIDER_H*/
+61
View File
@@ -0,0 +1,61 @@
/**
* @file lv_switch.h
*
*/
#ifndef LV_SWITCH_H
#define LV_SWITCH_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "liblvgl/lv_conf_internal.h"
#if LV_USE_SWITCH != 0
#include "liblvgl/core/lv_obj.h"
/*********************
* DEFINES
*********************/
/** Switch knob extra area correction factor */
#define _LV_SWITCH_KNOB_EXT_AREA_CORRECTION 2
/**********************
* TYPEDEFS
**********************/
typedef struct {
lv_obj_t obj;
int32_t anim_state;
} lv_switch_t;
extern const lv_obj_class_t lv_switch_class;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a switch object
* @param parent pointer to an object, it will be the parent of the new switch
* @return pointer to the created switch
*/
lv_obj_t * lv_switch_create(lv_obj_t * parent);
/**********************
* MACROS
**********************/
#endif /*LV_USE_SWITCH*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_SWITCH_H*/
+210
View File
@@ -0,0 +1,210 @@
/**
* @file lv_table.h
*
*/
#ifndef LV_TABLE_H
#define LV_TABLE_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "liblvgl/lv_conf_internal.h"
#if LV_USE_TABLE != 0
/*Testing of dependencies*/
#if LV_USE_LABEL == 0
#error "lv_table: lv_label is required. Enable it in lv_conf.h (LV_USE_LABEL 1)"
#endif
#include "liblvgl/core/lv_obj.h"
#include "lv_label.h"
/*********************
* DEFINES
*********************/
#define LV_TABLE_CELL_NONE 0XFFFF
LV_EXPORT_CONST_INT(LV_TABLE_CELL_NONE);
/**********************
* TYPEDEFS
**********************/
enum {
LV_TABLE_CELL_CTRL_MERGE_RIGHT = 1 << 0,
LV_TABLE_CELL_CTRL_TEXT_CROP = 1 << 1,
LV_TABLE_CELL_CTRL_CUSTOM_1 = 1 << 4,
LV_TABLE_CELL_CTRL_CUSTOM_2 = 1 << 5,
LV_TABLE_CELL_CTRL_CUSTOM_3 = 1 << 6,
LV_TABLE_CELL_CTRL_CUSTOM_4 = 1 << 7,
};
typedef uint8_t lv_table_cell_ctrl_t;
/*Data of table*/
typedef struct {
lv_obj_t obj;
uint16_t col_cnt;
uint16_t row_cnt;
char ** cell_data;
lv_coord_t * row_h;
lv_coord_t * col_w;
uint16_t col_act;
uint16_t row_act;
} lv_table_t;
extern const lv_obj_class_t lv_table_class;
/**
* `type` field in `lv_obj_draw_part_dsc_t` if `class_p = lv_table_class`
* Used in `LV_EVENT_DRAW_PART_BEGIN` and `LV_EVENT_DRAW_PART_END`
*/
typedef enum {
LV_TABLE_DRAW_PART_CELL, /**< A cell*/
} lv_table_draw_part_type_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a table object
* @param parent pointer to an object, it will be the parent of the new table
* @return pointer to the created table
*/
lv_obj_t * lv_table_create(lv_obj_t * parent);
/*=====================
* Setter functions
*====================*/
/**
* Set the value of a cell.
* @param obj pointer to a Table object
* @param row id of the row [0 .. row_cnt -1]
* @param col id of the column [0 .. col_cnt -1]
* @param txt text to display in the cell. It will be copied and saved so this variable is not required after this function call.
* @note New roes/columns are added automatically if required
*/
void lv_table_set_cell_value(lv_obj_t * obj, uint16_t row, uint16_t col, const char * txt);
/**
* Set the value of a cell. Memory will be allocated to store the text by the table.
* @param obj pointer to a Table object
* @param row id of the row [0 .. row_cnt -1]
* @param col id of the column [0 .. col_cnt -1]
* @param fmt `printf`-like format
* @note New roes/columns are added automatically if required
*/
void lv_table_set_cell_value_fmt(lv_obj_t * obj, uint16_t row, uint16_t col, const char * fmt, ...);
/**
* Set the number of rows
* @param obj table pointer to a Table object
* @param row_cnt number of rows
*/
void lv_table_set_row_cnt(lv_obj_t * obj, uint16_t row_cnt);
/**
* Set the number of columns
* @param obj table pointer to a Table object
* @param col_cnt number of columns.
*/
void lv_table_set_col_cnt(lv_obj_t * obj, uint16_t col_cnt);
/**
* Set the width of a column
* @param obj table pointer to a Table object
* @param col_id id of the column [0 .. LV_TABLE_COL_MAX -1]
* @param w width of the column
*/
void lv_table_set_col_width(lv_obj_t * obj, uint16_t col_id, lv_coord_t w);
/**
* Add control bits to the cell.
* @param obj pointer to a Table object
* @param row id of the row [0 .. row_cnt -1]
* @param col id of the column [0 .. col_cnt -1]
* @param ctrl OR-ed values from ::lv_table_cell_ctrl_t
*/
void lv_table_add_cell_ctrl(lv_obj_t * obj, uint16_t row, uint16_t col, lv_table_cell_ctrl_t ctrl);
/**
* Clear control bits of the cell.
* @param obj pointer to a Table object
* @param row id of the row [0 .. row_cnt -1]
* @param col id of the column [0 .. col_cnt -1]
* @param ctrl OR-ed values from ::lv_table_cell_ctrl_t
*/
void lv_table_clear_cell_ctrl(lv_obj_t * obj, uint16_t row, uint16_t col, lv_table_cell_ctrl_t ctrl);
/*=====================
* Getter functions
*====================*/
/**
* Get the value of a cell.
* @param obj pointer to a Table object
* @param row id of the row [0 .. row_cnt -1]
* @param col id of the column [0 .. col_cnt -1]
* @return text in the cell
*/
const char * lv_table_get_cell_value(lv_obj_t * obj, uint16_t row, uint16_t col);
/**
* Get the number of rows.
* @param obj table pointer to a Table object
* @return number of rows.
*/
uint16_t lv_table_get_row_cnt(lv_obj_t * obj);
/**
* Get the number of columns.
* @param obj table pointer to a Table object
* @return number of columns.
*/
uint16_t lv_table_get_col_cnt(lv_obj_t * obj);
/**
* Get the width of a column
* @param obj table pointer to a Table object
* @param col id of the column [0 .. LV_TABLE_COL_MAX -1]
* @return width of the column
*/
lv_coord_t lv_table_get_col_width(lv_obj_t * obj, uint16_t col);
/**
* Get whether a cell has the control bits
* @param obj pointer to a Table object
* @param row id of the row [0 .. row_cnt -1]
* @param col id of the column [0 .. col_cnt -1]
* @param ctrl OR-ed values from ::lv_table_cell_ctrl_t
* @return true: all control bits are set; false: not all control bits are set
*/
bool lv_table_has_cell_ctrl(lv_obj_t * obj, uint16_t row, uint16_t col, lv_table_cell_ctrl_t ctrl);
/**
* Get the selected cell (pressed and or focused)
* @param obj pointer to a table object
* @param row pointer to variable to store the selected row (LV_TABLE_CELL_NONE: if no cell selected)
* @param col pointer to variable to store the selected column (LV_TABLE_CELL_NONE: if no cell selected)
*/
void lv_table_get_selected_cell(lv_obj_t * obj, uint16_t * row, uint16_t * col);
/**********************
* MACROS
**********************/
#endif /*LV_USE_TABLE*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_TABLE_H*/
+358
View File
@@ -0,0 +1,358 @@
/**
* @file lv_textarea.h
*
*/
#ifndef LV_TEXTAREA_H
#define LV_TEXTAREA_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "liblvgl/lv_conf_internal.h"
#if LV_USE_TEXTAREA != 0
/*Testing of dependencies*/
#if LV_USE_LABEL == 0
#error "lv_ta: lv_label is required. Enable it in lv_conf.h (LV_USE_LABEL 1)"
#endif
#include "liblvgl/core/lv_obj.h"
#include "lv_label.h"
/*********************
* DEFINES
*********************/
#define LV_TEXTAREA_CURSOR_LAST (0x7FFF) /*Put the cursor after the last character*/
LV_EXPORT_CONST_INT(LV_TEXTAREA_CURSOR_LAST);
/**********************
* TYPEDEFS
**********************/
/*Data of text area*/
typedef struct {
lv_obj_t obj;
lv_obj_t * label; /*Label of the text area*/
char * placeholder_txt; /*Place holder label. only visible if text is an empty string*/
char * pwd_tmp; /*Used to store the original text in password mode*/
char * pwd_bullet; /*Replacement characters displayed in password mode*/
const char * accepted_chars; /*Only these characters will be accepted. NULL: accept all*/
uint32_t max_length; /*The max. number of characters. 0: no limit*/
uint16_t pwd_show_time; /*Time to show characters in password mode before change them to '*'*/
struct {
lv_coord_t valid_x; /*Used when stepping up/down to a shorter line.
*(Used by the library)*/
uint32_t pos; /*The current cursor position
*(0: before 1st letter; 1: before 2nd letter ...)*/
lv_area_t area; /*Cursor area relative to the Text Area*/
uint32_t txt_byte_pos; /*Byte index of the letter after (on) the cursor*/
uint8_t show : 1; /*Cursor is visible now or not (Handled by the library)*/
uint8_t click_pos : 1; /*1: Enable positioning the cursor by clicking the text area*/
} cursor;
#if LV_LABEL_TEXT_SELECTION
uint32_t sel_start; /*Temporary values for text selection*/
uint32_t sel_end;
uint8_t text_sel_in_prog : 1; /*User is in process of selecting*/
uint8_t text_sel_en : 1; /*Text can be selected on this text area*/
#endif
uint8_t pwd_mode : 1; /*Replace characters with '*'*/
uint8_t one_line : 1; /*One line mode (ignore line breaks)*/
} lv_textarea_t;
extern const lv_obj_class_t lv_textarea_class;
enum {
LV_PART_TEXTAREA_PLACEHOLDER = LV_PART_CUSTOM_FIRST,
};
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Create a text area object
* @param parent pointer to an object, it will be the parent of the new text area
* @return pointer to the created text area
*/
lv_obj_t * lv_textarea_create(lv_obj_t * parent);
/*======================
* Add/remove functions
*=====================*/
/**
* Insert a character to the current cursor position.
* To add a wide char, e.g. 'Á' use `_lv_txt_encoded_conv_wc('Á')`
* @param obj pointer to a text area object
* @param c a character (e.g. 'a')
*/
void lv_textarea_add_char(lv_obj_t * obj, uint32_t c);
/**
* Insert a text to the current cursor position
* @param obj pointer to a text area object
* @param txt a '\0' terminated string to insert
*/
void lv_textarea_add_text(lv_obj_t * obj, const char * txt);
/**
* Delete a the left character from the current cursor position
* @param obj pointer to a text area object
*/
void lv_textarea_del_char(lv_obj_t * obj);
/**
* Delete the right character from the current cursor position
* @param obj pointer to a text area object
*/
void lv_textarea_del_char_forward(lv_obj_t * obj);
/*=====================
* Setter functions
*====================*/
/**
* Set the text of a text area
* @param obj pointer to a text area object
* @param txt pointer to the text
*/
void lv_textarea_set_text(lv_obj_t * obj, const char * txt);
/**
* Set the placeholder text of a text area
* @param obj pointer to a text area object
* @param txt pointer to the text
*/
void lv_textarea_set_placeholder_text(lv_obj_t * obj, const char * txt);
/**
* Set the cursor position
* @param obj pointer to a text area object
* @param pos the new cursor position in character index
* < 0 : index from the end of the text
* LV_TEXTAREA_CURSOR_LAST: go after the last character
*/
void lv_textarea_set_cursor_pos(lv_obj_t * obj, int32_t pos);
/**
* Enable/Disable the positioning of the cursor by clicking the text on the text area.
* @param obj pointer to a text area object
* @param en true: enable click positions; false: disable
*/
void lv_textarea_set_cursor_click_pos(lv_obj_t * obj, bool en);
/**
* Enable/Disable password mode
* @param obj pointer to a text area object
* @param en true: enable, false: disable
*/
void lv_textarea_set_password_mode(lv_obj_t * obj, bool en);
/**
* Set the replacement characters to show in password mode
* @param obj pointer to a text area object
* @param bullet pointer to the replacement text
*/
void lv_textarea_set_password_bullet(lv_obj_t * obj, const char * bullet);
/**
* Configure the text area to one line or back to normal
* @param obj pointer to a text area object
* @param en true: one line, false: normal
*/
void lv_textarea_set_one_line(lv_obj_t * obj, bool en);
/**
* Set a list of characters. Only these characters will be accepted by the text area
* @param obj pointer to a text area object
* @param list list of characters. Only the pointer is saved. E.g. "+-.,0123456789"
*/
void lv_textarea_set_accepted_chars(lv_obj_t * obj, const char * list);
/**
* Set max length of a Text Area.
* @param obj pointer to a text area object
* @param num the maximal number of characters can be added (`lv_textarea_set_text` ignores it)
*/
void lv_textarea_set_max_length(lv_obj_t * obj, uint32_t num);
/**
* In `LV_EVENT_INSERT` the text which planned to be inserted can be replaced by an other text.
* It can be used to add automatic formatting to the text area.
* @param obj pointer to a text area object
* @param txt pointer to a new string to insert. If `""` no text will be added.
* The variable must be live after the `event_cb` exists. (Should be `global` or `static`)
*/
void lv_textarea_set_insert_replace(lv_obj_t * obj, const char * txt);
/**
* Enable/disable selection mode.
* @param obj pointer to a text area object
* @param en true or false to enable/disable selection mode
*/
void lv_textarea_set_text_selection(lv_obj_t * obj, bool en);
/**
* Set how long show the password before changing it to '*'
* @param obj pointer to a text area object
* @param time show time in milliseconds. 0: hide immediately.
*/
void lv_textarea_set_password_show_time(lv_obj_t * obj, uint16_t time);
/**
* Deprecated: use the normal text_align style property instead
* Set the label's alignment.
* It sets where the label is aligned (in one line mode it can be smaller than the text area)
* and how the lines of the area align in case of multiline text area
* @param obj pointer to a text area object
* @param align the align mode from ::lv_text_align_t
*/
void lv_textarea_set_align(lv_obj_t * obj, lv_text_align_t align);
/*=====================
* Getter functions
*====================*/
/**
* Get the text of a text area. In password mode it gives the real text (not '*'s).
* @param obj pointer to a text area object
* @return pointer to the text
*/
const char * lv_textarea_get_text(const lv_obj_t * obj);
/**
* Get the placeholder text of a text area
* @param obj pointer to a text area object
* @return pointer to the text
*/
const char * lv_textarea_get_placeholder_text(lv_obj_t * obj);
/**
* Get the label of a text area
* @param obj pointer to a text area object
* @return pointer to the label object
*/
lv_obj_t * lv_textarea_get_label(const lv_obj_t * obj);
/**
* Get the current cursor position in character index
* @param obj pointer to a text area object
* @return the cursor position
*/
uint32_t lv_textarea_get_cursor_pos(const lv_obj_t * obj);
/**
* Get whether the cursor click positioning is enabled or not.
* @param obj pointer to a text area object
* @return true: enable click positions; false: disable
*/
bool lv_textarea_get_cursor_click_pos(lv_obj_t * obj);
/**
* Get the password mode attribute
* @param obj pointer to a text area object
* @return true: password mode is enabled, false: disabled
*/
bool lv_textarea_get_password_mode(const lv_obj_t * obj);
/**
* Get the replacement characters to show in password mode
* @param obj pointer to a text area object
* @return pointer to the replacement text
*/
const char * lv_textarea_get_password_bullet(lv_obj_t * obj);
/**
* Get the one line configuration attribute
* @param obj pointer to a text area object
* @return true: one line configuration is enabled, false: disabled
*/
bool lv_textarea_get_one_line(const lv_obj_t * obj);
/**
* Get a list of accepted characters.
* @param obj pointer to a text area object
* @return list of accented characters.
*/
const char * lv_textarea_get_accepted_chars(lv_obj_t * obj);
/**
* Get max length of a Text Area.
* @param obj pointer to a text area object
* @return the maximal number of characters to be add
*/
uint32_t lv_textarea_get_max_length(lv_obj_t * obj);
/**
* Find whether text is selected or not.
* @param obj pointer to a text area object
* @return whether text is selected or not
*/
bool lv_textarea_text_is_selected(const lv_obj_t * obj);
/**
* Find whether selection mode is enabled.
* @param obj pointer to a text area object
* @return true: selection mode is enabled, false: disabled
*/
bool lv_textarea_get_text_selection(lv_obj_t * obj);
/**
* Set how long show the password before changing it to '*'
* @param obj pointer to a text area object
* @return show time in milliseconds. 0: hide immediately.
*/
uint16_t lv_textarea_get_password_show_time(lv_obj_t * obj);
/*=====================
* Other functions
*====================*/
/**
* Clear the selection on the text area.
* @param obj pointer to a text area object
*/
void lv_textarea_clear_selection(lv_obj_t * obj);
/**
* Move the cursor one character right
* @param obj pointer to a text area object
*/
void lv_textarea_cursor_right(lv_obj_t * obj);
/**
* Move the cursor one character left
* @param obj pointer to a text area object
*/
void lv_textarea_cursor_left(lv_obj_t * obj);
/**
* Move the cursor one line down
* @param obj pointer to a text area object
*/
void lv_textarea_cursor_down(lv_obj_t * obj);
/**
* Move the cursor one line up
* @param obj pointer to a text area object
*/
void lv_textarea_cursor_up(lv_obj_t * obj);
/**********************
* MACROS
**********************/
#endif /*LV_USE_TEXTAREA_H*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_TEXTAREA_H*/