add some code
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/gfx_types.h"
|
||||
#include "core/gfx_core.h"
|
||||
#include "core/gfx_obj.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/*=====================
|
||||
* Animation object creation
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* @brief Create an animation object
|
||||
* @param handle Animation player handle
|
||||
* @return Pointer to the created animation object
|
||||
*/
|
||||
gfx_obj_t * gfx_anim_create(gfx_handle_t handle);
|
||||
|
||||
/*=====================
|
||||
* Animation setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* @brief Set the source data for an animation object
|
||||
* @param obj Pointer to the animation object
|
||||
* @param src_data Source data
|
||||
* @param src_len Source data length
|
||||
* @return ESP_OK on success, error code otherwise
|
||||
*/
|
||||
esp_err_t gfx_anim_set_src(gfx_obj_t *obj, const void *src_data, size_t src_len);
|
||||
|
||||
/**
|
||||
* @brief Set the segment for an animation object
|
||||
* @param obj Pointer to the animation object
|
||||
* @param start Start frame index
|
||||
* @param end End frame index
|
||||
* @param fps Frames per second
|
||||
* @param repeat Whether to repeat the animation
|
||||
* @return ESP_OK on success, error code otherwise
|
||||
*/
|
||||
esp_err_t gfx_anim_set_segment(gfx_obj_t *obj, uint32_t start, uint32_t end, uint32_t fps, bool repeat);
|
||||
|
||||
/**
|
||||
* @brief Start the animation
|
||||
* @param obj Pointer to the animation object
|
||||
* @return ESP_OK on success, error code otherwise
|
||||
*/
|
||||
esp_err_t gfx_anim_start(gfx_obj_t *obj);
|
||||
|
||||
/**
|
||||
* @brief Stop the animation
|
||||
* @param obj Pointer to the animation object
|
||||
* @return ESP_OK on success, error code otherwise
|
||||
*/
|
||||
esp_err_t gfx_anim_stop(gfx_obj_t *obj);
|
||||
|
||||
/**
|
||||
* @brief Set mirror display for an animation object
|
||||
* @param obj Pointer to the animation object
|
||||
* @param enabled Whether to enable mirror display
|
||||
* @param offset Mirror offset in pixels
|
||||
* @return ESP_OK on success, error code otherwise
|
||||
*/
|
||||
esp_err_t gfx_anim_set_mirror(gfx_obj_t *obj, bool enabled, int16_t offset);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/gfx_types.h"
|
||||
#include "core/gfx_obj.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/* Magic numbers for image headers */
|
||||
#define C_ARRAY_HEADER_MAGIC 0x19
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/* Color format enumeration - simplified for public use */
|
||||
typedef enum {
|
||||
GFX_COLOR_FORMAT_RGB565A8 = 0x0A,
|
||||
} gfx_color_format_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t magic: 8; /**< Magic number. Must be GFX_IMAGE_HEADER_MAGIC */
|
||||
uint32_t cf : 8; /**< Color format: See `gfx_color_format_t` */
|
||||
uint32_t flags: 16; /**< Image flags */
|
||||
uint32_t w: 16; /**< Width of the image */
|
||||
uint32_t h: 16; /**< Height of the image */
|
||||
uint32_t stride: 16; /**< Number of bytes in a row */
|
||||
uint32_t reserved: 16; /**< Reserved for future use */
|
||||
} gfx_image_header_t;
|
||||
|
||||
/* Image descriptor structure - compatible with LVGL */
|
||||
typedef struct {
|
||||
gfx_image_header_t header; /**< A header describing the basics of the image */
|
||||
uint32_t data_size; /**< Size of the image in bytes */
|
||||
const uint8_t * data; /**< Pointer to the data of the image */
|
||||
const void * reserved; /**< Reserved field for future use */
|
||||
const void * reserved_2; /**< Reserved field for future use */
|
||||
} gfx_image_dsc_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/*=====================
|
||||
* Image object creation
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* @brief Create an image object
|
||||
* @param handle Animation player handle
|
||||
* @return Pointer to the created image object
|
||||
*/
|
||||
gfx_obj_t * gfx_img_create(gfx_handle_t handle);
|
||||
|
||||
/*=====================
|
||||
* Image setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* @brief Set the source data for an image object
|
||||
* @param obj Pointer to the image object
|
||||
* @param src Pointer to the image source data
|
||||
* @return Pointer to the object
|
||||
*/
|
||||
gfx_obj_t * gfx_img_set_src(gfx_obj_t *obj, void *src);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,190 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/gfx_types.h"
|
||||
#include "core/gfx_core.h"
|
||||
#include "core/gfx_obj.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/* Font handle type - hides internal FreeType implementation */
|
||||
typedef void *gfx_font_t;
|
||||
|
||||
/* Label configuration structure */
|
||||
typedef struct {
|
||||
const char * name; /**< The name of the font file */
|
||||
const void * mem; /**< The pointer to the font file */
|
||||
size_t mem_size; /**< The size of the memory */
|
||||
} gfx_label_cfg_t;
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Text alignment enumeration (similar to LVGL)
|
||||
*/
|
||||
typedef enum {
|
||||
GFX_TEXT_ALIGN_AUTO, /**< Align text auto */
|
||||
GFX_TEXT_ALIGN_LEFT, /**< Align text to left */
|
||||
GFX_TEXT_ALIGN_CENTER, /**< Align text to center */
|
||||
GFX_TEXT_ALIGN_RIGHT, /**< Align text to right */
|
||||
} gfx_text_align_t;
|
||||
|
||||
/**
|
||||
* Long text mode enumeration (similar to LVGL)
|
||||
*/
|
||||
typedef enum {
|
||||
GFX_LABEL_LONG_WRAP, /**< Break the long lines (word wrap) */
|
||||
GFX_LABEL_LONG_SCROLL, /**< Make the text scrolling horizontally */
|
||||
GFX_LABEL_LONG_CLIP, /**< Simply clip the parts which don't fit */
|
||||
} gfx_label_long_mode_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/*=====================
|
||||
* Label object creation
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* @brief Create a label object
|
||||
* @param handle Animation player handle
|
||||
* @param cfg Font configuration
|
||||
* @return Pointer to the created label object
|
||||
*/
|
||||
gfx_obj_t * gfx_label_create(gfx_handle_t handle);
|
||||
|
||||
/**
|
||||
* @brief Create a new font
|
||||
* @param handle Animation player handle
|
||||
* @param cfg Font configuration
|
||||
* @param ret_font Pointer to store the font handle
|
||||
* @return ESP_OK on success, error code otherwise
|
||||
*/
|
||||
esp_err_t gfx_label_new_font(gfx_handle_t handle, const gfx_label_cfg_t *cfg, gfx_font_t *ret_font);
|
||||
|
||||
/*=====================
|
||||
* Label setter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* @brief Set the text for a label object
|
||||
* @param obj Pointer to the label object
|
||||
* @param text Text string to display
|
||||
* @return ESP_OK on success, error code otherwise
|
||||
*/
|
||||
esp_err_t gfx_label_set_text(gfx_obj_t *obj, const char *text);
|
||||
|
||||
/**
|
||||
* @brief Set the text for a label object with format
|
||||
* @param obj Pointer to the label object
|
||||
* @param fmt Format string
|
||||
* @return ESP_OK on success, error code otherwise
|
||||
*/
|
||||
esp_err_t gfx_label_set_text_fmt(gfx_obj_t * obj, const char * fmt, ...);
|
||||
|
||||
/**
|
||||
* @brief Set the color for a label object
|
||||
* @param obj Pointer to the label object
|
||||
* @param color Color value
|
||||
* @return ESP_OK on success, error code otherwise
|
||||
*/
|
||||
esp_err_t gfx_label_set_color(gfx_obj_t *obj, gfx_color_t color);
|
||||
|
||||
/**
|
||||
* @brief Set the background color for a label object
|
||||
* @param obj Pointer to the label object
|
||||
* @param bg_color Background color value
|
||||
* @return ESP_OK on success, error code otherwise
|
||||
*/
|
||||
esp_err_t gfx_label_set_bg_color(gfx_obj_t *obj, gfx_color_t bg_color);
|
||||
|
||||
/**
|
||||
* @brief Enable or disable background for a label object
|
||||
* @param obj Pointer to the label object
|
||||
* @param enable True to enable background, false to disable
|
||||
* @return ESP_OK on success, error code otherwise
|
||||
*/
|
||||
esp_err_t gfx_label_set_bg_enable(gfx_obj_t *obj, bool enable);
|
||||
|
||||
/**
|
||||
* @brief Set the opacity for a label object
|
||||
* @param obj Pointer to the label object
|
||||
* @param opa Opacity value (0-255)
|
||||
* @return ESP_OK on success, error code otherwise
|
||||
*/
|
||||
esp_err_t gfx_label_set_opa(gfx_obj_t *obj, gfx_opa_t opa);
|
||||
|
||||
/**
|
||||
* @brief Set the font size for a label object
|
||||
* @param obj Pointer to the label object
|
||||
* @param font_size Font size in points
|
||||
* @return ESP_OK on success, error code otherwise
|
||||
*/
|
||||
esp_err_t gfx_label_set_font_size(gfx_obj_t *obj, uint8_t font_size);
|
||||
|
||||
/**
|
||||
* @brief Set the font for a label object
|
||||
* @param obj Pointer to the label object
|
||||
* @param font Font handle
|
||||
*/
|
||||
esp_err_t gfx_label_set_font(gfx_obj_t *obj, gfx_font_t font);
|
||||
|
||||
/**
|
||||
* @brief Set the text alignment for a label object
|
||||
* @param obj Pointer to the label object
|
||||
* @param align Text alignment value
|
||||
* @return ESP_OK on success, error code otherwise
|
||||
*/
|
||||
esp_err_t gfx_label_set_text_align(gfx_obj_t *obj, gfx_text_align_t align);
|
||||
|
||||
/**
|
||||
* @brief Set the long text mode for a label object
|
||||
* @param obj Pointer to the label object
|
||||
* @param long_mode Long text handling mode (wrap, scroll, or clip)
|
||||
* @return ESP_OK on success, error code otherwise
|
||||
*/
|
||||
esp_err_t gfx_label_set_long_mode(gfx_obj_t *obj, gfx_label_long_mode_t long_mode);
|
||||
|
||||
/**
|
||||
* @brief Set the line spacing for a label object
|
||||
* @param obj Pointer to the label object
|
||||
* @param spacing Line spacing in pixels
|
||||
* @return ESP_OK on success, error code otherwise
|
||||
*/
|
||||
esp_err_t gfx_label_set_line_spacing(gfx_obj_t *obj, uint16_t spacing);
|
||||
|
||||
/**
|
||||
* @brief Set the horizontal scrolling speed for a label object
|
||||
* @param obj Pointer to the label object
|
||||
* @param speed_ms Scrolling speed in milliseconds per pixel
|
||||
* @note Only effective when long_mode is GFX_LABEL_LONG_SCROLL
|
||||
* @return ESP_OK on success, error code otherwise
|
||||
*/
|
||||
esp_err_t gfx_label_set_scroll_speed(gfx_obj_t *obj, uint32_t speed_ms);
|
||||
|
||||
/**
|
||||
* @brief Set whether scrolling should loop continuously
|
||||
* @param obj Pointer to the label object
|
||||
* @param loop True to enable continuous looping, false for one-time scroll
|
||||
* @note Only effective when long_mode is GFX_LABEL_LONG_SCROLL
|
||||
* @return ESP_OK on success, error code otherwise
|
||||
*/
|
||||
esp_err_t gfx_label_set_scroll_loop(gfx_obj_t *obj, bool loop);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user