初版
This commit is contained in:
@@ -0,0 +1,538 @@
|
||||
/* Copyright(C)
|
||||
* not free
|
||||
* All right reserved
|
||||
*
|
||||
* @file dbi.h
|
||||
* @brief DBI模块驱动API头文件。DBI模块为专门用于推屏的独立硬件模块,与硬件SPI无关。其配置仅在屏幕驱动的结构体中,推屏时钟的频率为内部通过推屏帧率计算而得,但时钟是由PLL进行分频而来,因此实际时钟频率仅会在分频组合允许的前提下尽可能接近所需的目标频率(实际测量的推屏时钟与计算并非绝对一致)。
|
||||
* @author zhuhaifang@zh-jieli.com
|
||||
* @version V201
|
||||
* @date 2023-01-10
|
||||
*/
|
||||
|
||||
#ifndef __DBI_H__
|
||||
#define __DBI_H__
|
||||
|
||||
#include "generic/typedef.h"
|
||||
#include "os/os_api.h"
|
||||
#include "gpio.h"
|
||||
|
||||
extern const u8 lvgl_ui_enable;
|
||||
|
||||
enum OUTPUT_FORMAT {
|
||||
/* 0 */OUTPUT_FORMAT_RGB888,
|
||||
/* 1 */OUTPUT_FORMAT_RGB565,
|
||||
};
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief DBI模块私有变量。注意:该变量内部使用,外部禁止操作,否则会导致不可预测的问题。
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
extern struct dbi_variable dbi_var;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 模块驱动接口组,DBI模块下管理了SPI, MCU, RGB三组驱动接口,具体驱动接口在这里
|
||||
* 注册给DBI模块管理使用。注意:该变量内部使用,外部无需修改,否则会导致不可预测的问题。
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct dbi_driver {
|
||||
void (*init)(struct dbi_variable *priv);
|
||||
void (*write)(u32, u8 *, u32);
|
||||
void (*read)(u32, u8 *, u32);
|
||||
void (*set_draw_area)(int, int, int, int);
|
||||
void (*clear)(u32, int, int, int, int);
|
||||
void (*draw)(u8 *, int, int, int, int);
|
||||
void (*draw_continue)(u8 *, int, int, int, int);
|
||||
void (*enter_sleep)();
|
||||
void (*exit_sleep)();
|
||||
};
|
||||
|
||||
|
||||
//[DBI接口IO定义]
|
||||
#define DBI_CSX_VSYNC IO_PORTA_07
|
||||
#define DBI_DCX_HSYNC IO_PORTA_13
|
||||
#define DBI_SCL_WRX IO_PORTA_12
|
||||
#define DBI_D0 IO_PORTA_08
|
||||
#define DBI_D1 IO_PORTA_09
|
||||
#define DBI_D2 IO_PORTA_10
|
||||
#define DBI_D3 IO_PORTA_11
|
||||
#define DBI_D4 IO_PORTC_00
|
||||
#define DBI_D5 IO_PORTC_01
|
||||
#define DBI_D6 IO_PORTC_02
|
||||
#define DBI_D7 IO_PORTC_03
|
||||
#define DBI_RDX_DEN IO_PORTC_10
|
||||
|
||||
|
||||
|
||||
// <<<[lcd接口配置]>>>
|
||||
#define SPI_MODE (0<<4)
|
||||
#define DSPI_MODE (1<<4)
|
||||
#define QSPI_MODE (2<<4)
|
||||
|
||||
// SPI线数标志(clk + dat)
|
||||
#define SPI_WIRE3 0
|
||||
#define SPI_WIRE4 1
|
||||
|
||||
// QSPI的子模式标志(除SUBMODE0为1 dat线之外,其余模式都为4 dat线)
|
||||
#define QSPI_SUBMODE0 0//0x02
|
||||
#define QSPI_SUBMODE1 1//0x32
|
||||
#define QSPI_SUBMODE2 2//0x12
|
||||
#define QSPI_RAMLESS 3//0xde
|
||||
#define QSPI_FT2388 4//0x32 1ch cmd + 4ch data
|
||||
#define QSPI_SD3302 5
|
||||
|
||||
// LCD时序标志(根据LCD数据手册配置,常用时序均已组合到LCD_DRIVE_CONFIG宏,在LCD驱动文件配置)
|
||||
#define PIXEL_1P1T (0<<5)
|
||||
#define PIXEL_1P2T (1<<5)
|
||||
#define PIXEL_1P3T (2<<5)
|
||||
#define PIXEL_2P3T (3<<5)
|
||||
|
||||
#define PIXEL_1T2B 1
|
||||
#define PIXEL_1T6B 5
|
||||
#define PIXEL_1T8B 7
|
||||
#define PIXEL_1T9B 8
|
||||
#define PIXEL_1T12B 11
|
||||
#define PIXEL_1T16B 15
|
||||
#define PIXEL_1T18B 17
|
||||
#define PIXEL_1T24B 23
|
||||
|
||||
#define FORMAT_RGB565 1//0//1P2T
|
||||
#define FORMAT_RGB666 2//1//1P3T
|
||||
#define FORMAT_RGB888 0//2//1P3T
|
||||
|
||||
|
||||
#define SPI_MODE_UNIDIR 0//半双工,d0分时发送接收
|
||||
#define SPI_MODE_BIDIR 1//全双工,d0发送、d1接收
|
||||
|
||||
enum {
|
||||
CMD_MODE,
|
||||
};
|
||||
|
||||
enum {
|
||||
CMD_8BIT,
|
||||
CMD_16BIT,
|
||||
CMD_24BIT,
|
||||
};
|
||||
|
||||
/*
|
||||
** dbi私有全局变量定义
|
||||
*/
|
||||
struct dbi_variable {
|
||||
volatile u8 dbi_busy; // dbi忙碌标志
|
||||
u8 clock_init: 1; // dbi时钟初始化标志
|
||||
u8 clock_div_sel: 7; // dbi时钟
|
||||
u8 sfr_save; // 寄存器保存标志
|
||||
u8 row_align; // 行对齐
|
||||
u8 column_align;// 列对齐
|
||||
int (*te_stat)(); // TE 信号检测,返回值为TE脚电平,使用内部等待TE信号时,这个函数须注册
|
||||
void (*te_wait)(); // TE 信号等待,如果使用外部TE等待函数,注册这个回调,则等TE时会调用这
|
||||
struct dbi_param *param;
|
||||
int (*dbi_callback)(void *priv);//dbi回调
|
||||
u8 cmd_mode;
|
||||
OS_SEM draw_sem;
|
||||
u8 *frameBufferOld;
|
||||
u8 *frameBuffer;
|
||||
u32 frameBufferSize;
|
||||
u32 clearColor;
|
||||
int frameBufferChanged;
|
||||
int xstart;
|
||||
int xend;
|
||||
int ystart;
|
||||
int yend;
|
||||
float actual_fps;
|
||||
|
||||
int soft_cs_pin;
|
||||
volatile int cs_high;
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 屏幕驱动接口类型定义,根据屏幕的接口类型在屏驱内配置使用
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
typedef enum lcd_type_cfg {
|
||||
LCD_TYPE_SPI, // SPI屏
|
||||
LCD_TYPE_SPI_RAMLESS, // SPI RAMLESS屏
|
||||
LCD_TYPE_MCU, // MCU屏
|
||||
LCD_TYPE_RGB, // RGB屏
|
||||
LCD_TYPE_MAX,
|
||||
} LCD_TYPE;
|
||||
|
||||
typedef enum {
|
||||
DC_PIN_SEL_PA9,
|
||||
DC_PIN_SEL_PA13,
|
||||
DC_PIN_SEL_SOFT,
|
||||
} DC_PIN_SEL;
|
||||
|
||||
typedef enum {
|
||||
CS_PIN_SEL_PA7,
|
||||
CS_PIN_SEL_SOFT,
|
||||
} CS_PIN_SEL;
|
||||
|
||||
// 以下配置只对SPI_MODE_UNIDIR模式生效, SPI_MODE_BIDIR模式固定PA9
|
||||
// 具体使用SPI/DSPI/QSPI哪个通道读数据,可查询屏DriverIC手册或者咨询屏厂,
|
||||
// 读IO肯定是PA8/PA9/PA10/PA11其中的某一个, 也可以逐个试一下,看读0x0A寄存器的值是否正常
|
||||
typedef enum {
|
||||
READ_PIN_SEL_PA8,
|
||||
READ_PIN_SEL_PA9,
|
||||
READ_PIN_SEL_SOFT,
|
||||
} READ_PIN_SEL;
|
||||
|
||||
// 只适用于MCU屏配置
|
||||
// 若需要读寄存器,RDX引脚固定选PA13,由硬件控制
|
||||
// 若没有读寄存器的需求,RDX引脚可不打开,可以省一个IO,屏驱上的DCX脚需要接高电平
|
||||
typedef enum {
|
||||
RDX_PIN_SEL_PA13,
|
||||
RDX_PIN_SEL_NONE,
|
||||
} RDX_PIN_SEL;
|
||||
|
||||
typedef enum {
|
||||
CLOCK_POLARITY_IDLE_LOW, // 空闲时为低电平
|
||||
CLOCK_POLARITY_IDLE_HIGH, // 空闲时为高电平
|
||||
} CLOCK_POLARITY;
|
||||
|
||||
struct dbi_param {
|
||||
// 显示区域相关(用于配置推屏区域,可不推全屏)
|
||||
int scr_x;
|
||||
int scr_y;
|
||||
int scr_w;
|
||||
int scr_h;
|
||||
|
||||
// lcd配置
|
||||
int lcd_width;
|
||||
int lcd_height;
|
||||
LCD_TYPE lcd_type; // LCD接口类型:SPI, SPI Ramless, MCU, RGB
|
||||
|
||||
// 显存配置
|
||||
int buffer_num;
|
||||
int buffer_size;
|
||||
|
||||
// dbi模块的输入,与imb模块一起用时,也是imb模块的输出
|
||||
int in_width;
|
||||
int in_height;
|
||||
int in_format;
|
||||
int in_stride;
|
||||
|
||||
// debug模式(推新屏时,可使能debug模式,先推纯色测试)
|
||||
int debug_mode_en;
|
||||
int debug_mode_color;
|
||||
|
||||
// 帧率配置(用于计算DBI模块时钟频率,但实际推屏帧率仅会接近配置,并非100%一致)
|
||||
int fps;
|
||||
|
||||
// 以下为三种屏驱动相关配置,out_format为屏幕的像素格式类型
|
||||
struct spi_param {
|
||||
int spi_mode;
|
||||
int pixel_type;
|
||||
int out_format;
|
||||
int spi_dat_mode;
|
||||
DC_PIN_SEL dc_pin_select; //若选择SPI_4WIRE_RGB888_1T8B/SPI_4WIRE_RGB888_1T24B/SPI_4WIRE_RGB666_1T18B/SPI_4WIRE_RGB565_1T8B/SPI_4WIRE_RGB565_1T16B时序,
|
||||
//dc_pin_select = DC_PIN_SEL_PA9, dc信号从PA9输出(硬件控制)
|
||||
//dc_pin_select = DC_PIN_SEL_PA13, dc信号从PA13输出(硬件控制)
|
||||
//dc_pin_select = DC_PIN_SEL_SOFT, dc信号从soft_dc_pin指定的引脚输出(软件控制,只对4线spi有效)
|
||||
int soft_dc_pin; //软件dc脚, 可指定任意gpio, IO_PORTX_xx
|
||||
CS_PIN_SEL cs_pin_select;
|
||||
//cs_pin_select = CS_PIN_SEL_PA7, cs信号从PA7输出(硬件控制)
|
||||
//cs_pin_select = CS_PIN_SEL_SOFT, cs信号从soft_cs_pin指定的引脚输出(软件控制, 对spi/dspi/qspi有效, qspi ramless时序不支持)
|
||||
int soft_cs_pin; //软件cs脚, 可指定任意gpio, IO_PORTX_xx
|
||||
READ_PIN_SEL read_pin_select;
|
||||
//read_pin_select = READ_PIN_SEL_PA8, 从PA8接收sdo信号(硬件控制)
|
||||
//read_pin_select = READ_PIN_SEL_PA9, 从PA9接收sdo信号(硬件控制)
|
||||
//read_pin_select = READ_PIN_SEL_SOFT, 从soft_read_pin指定的引脚接收sdo信号(软件控制)
|
||||
int soft_read_pin; //软件输入脚, 可指定任意gpio, IO_PORTX_xx
|
||||
struct qspi_cmd {
|
||||
u8 write_cmd;
|
||||
u8 read_cmd;
|
||||
u8 submode0_cmd;//0x2c/0x3c/数据单线, default value 0x02
|
||||
u8 submode1_cmd;//0x2c/0x3c单线,数据四线,default value 0x32
|
||||
u8 submode2_cmd;//0x2c/0x3c/数据四线, default value 0x12
|
||||
} qspi_cmd;
|
||||
struct ramless {
|
||||
u32 frame_sync_cmd;//ramless cmd
|
||||
u32 porch_sync_cmd;//ramless cmd
|
||||
u32 line_sync_cmd;//ramless cmd
|
||||
u16 hsync;
|
||||
u16 hbp; //hori back porch
|
||||
u16 hact; //hori actual
|
||||
u16 hfp; //hori front porch
|
||||
u16 vsync;
|
||||
u16 vbp; //vert back porch
|
||||
u16 vact; //vert actual line
|
||||
u16 vfp; //vert front porch
|
||||
} ramless;
|
||||
u8 caset_cmd;//Column Address Set, default value 0x2a
|
||||
u8 paset_cmd;//Page Address Set, default value 0x2b
|
||||
u8 ramwr_cmd;//Memory Write Start, default value 0x2c
|
||||
u8 ramwrc_cmd;//Memory Write Continue, default valus 0x3c
|
||||
|
||||
CLOCK_POLARITY clk_pol; // 时钟极性
|
||||
} spi;
|
||||
|
||||
struct pap_param {
|
||||
RDX_PIN_SEL rdx_pin_select; //dcx 引脚配置
|
||||
int out_format;
|
||||
} pap;
|
||||
|
||||
struct rgb_param {
|
||||
int use_spi;
|
||||
int out_format;
|
||||
int continue_frames;
|
||||
|
||||
int hpw_prd;
|
||||
int hbw_prd;
|
||||
int hfw_prd;
|
||||
int hact_prd;
|
||||
|
||||
int vpw_prd;
|
||||
int vbw_prd;
|
||||
int vfw_prd;
|
||||
int vact_prd;
|
||||
} rgb;
|
||||
};
|
||||
|
||||
|
||||
struct dbi_ramless_callback_param {
|
||||
int lcd_buff_update;
|
||||
u32 lcd_buff_old;
|
||||
u32 lcd_buff_new;
|
||||
};
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief lcd_init DBI模块初始化(注意:需要操作DBI或从DBI获取信息时,必须先初始化)
|
||||
*
|
||||
* @param param DBI配置句柄
|
||||
*
|
||||
* @return 0
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int lcd_init(struct dbi_param *param);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief lcd_write_cmd DBI模块向LCD指定地址写数据
|
||||
*
|
||||
* @param cmd 待操作的LCD命令地址
|
||||
* @param buf 数据缓存buf(如果不需要写数据,可传入NULL)
|
||||
* @param len 数据缓存长度(如果不写数据,需将len配置为0)
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void lcd_write_cmd(u32 cmd, u8 *buf, u32 len);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief lcd_read_cmd DBI模块从LCD指定地址读数据
|
||||
*
|
||||
* @param cmd 待操作的LCD命令地址
|
||||
* @param buf 数据缓存buf(输出)
|
||||
* @param len 读取的数据长度(需与buf匹配,不可超过buf大小)
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void lcd_read_cmd(u32 cmd, u8 *buf, u32 len);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief lcd_set_draw_area 设置LCD显示区域(2A, 2B命令)
|
||||
*
|
||||
* @param xstart X起始像素坐标
|
||||
* @param xend X结束像素坐标
|
||||
* @param ystart Y起始像素坐标
|
||||
* @param yend Y结束像素坐标
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void lcd_set_draw_area(int xstart, int xend, int ystart, int yend);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief lcd_draw DBI硬件写显示数据到LCD, 非阻塞接口,与lcd_set_draw_area配合使用
|
||||
*
|
||||
* @param buf 待写出数据
|
||||
* @param xstart X起始像素坐标
|
||||
* @param xend X结束像素坐标
|
||||
* @param ystart Y起始像素坐标
|
||||
* @param yend Y结束像素坐标
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void lcd_draw(u8 *buf, int xstart, int xend, int ystart, int yend);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief lcd_draw_continue DBI硬件以续传方式写显示数据到LCD, 非阻塞接口,与lcd_set_draw_area、lcd_draw配合使用
|
||||
*
|
||||
* @param buf 待写出数据
|
||||
* @param xstart X起始像素坐标
|
||||
* @param xend X结束像素坐标
|
||||
* @param ystart Y起始像素坐标
|
||||
* @param yend Y结束像素坐标
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void lcd_draw_continue(u8 *buf, int xstart, int xend, int ystart, int yend);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief lcd_clear 纯色填充LCD指定区域
|
||||
*
|
||||
* @param color 待填充的RGB888颜色值
|
||||
* @param xstart 待填充的X起始像素坐标
|
||||
* @param xend 待填充的X结束像素坐标
|
||||
* @param ystart 待填充的Y起始像素坐标
|
||||
* @param yend 待填充的Y结束像素坐标
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void lcd_clear(u32 color, int xstart, int xend, int ystart, int yend);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief lcd_set_ctrl_pin_func 配置LCD控制脚操作函数
|
||||
*
|
||||
* @param te_stat TE脚控制函数
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void lcd_set_ctrl_pin_func(int (*te_stat)());
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief lcd_set_te_wait_cb 配置TE信号等待回调函数,如果注册,等待TE时将调用回调进行等待
|
||||
*
|
||||
* @Params te_wait 应用层实现的TE等待函数
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void lcd_set_te_wait_cb(void (*te_wait)());
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief lcd_set_align 设置LCD对齐参数
|
||||
*
|
||||
* @param row_align 设置行对齐参数
|
||||
* @param column_align 设置列对齐参数
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void lcd_set_align(u8 row_align, u8 column_align);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief lcd_get_align 设置LCD对齐参数
|
||||
*
|
||||
* @param row_align 获取行对齐参数
|
||||
* @param column_align 获取列对齐参数
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void lcd_get_align(u8 *row_align, u8 *column_align);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief lcd_check_align 检查LCD刷屏区域参数是否对齐
|
||||
*
|
||||
* @param xstart X起始像素坐标
|
||||
* @param xend X结束像素坐标
|
||||
* @param ystart Y起始像素坐标
|
||||
* @param yend Y结束像素坐标
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int lcd_check_align(int xstart, int xend, int ystart, int yend);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief lcd_wait_busy 等待lcd空闲
|
||||
* 注意:本函数一般在推屏buffer释放前调用,等待推屏结束
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void lcd_wait_busy();
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief lcd_draw_kistart 无等待推屏接口
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void lcd_draw_kistart(uint8_t *buf, int xstart, int xend, int ystart, int yend);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief lcd_draw_set_callback 设置推屏结束回调, lcd_draw、lcd_draw_continue推屏结束时调用该回调
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int lcd_draw_set_callback(int (*callback)(void *priv));
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
|
||||
* @brief lcd_te_trig_kistart_set_busy 设置LCD繁忙状态,需TE中断调用lcd_draw_kistart接口推屏,推屏结束后会自动消除繁忙状态,
|
||||
* 另外附加作用是打印调试接口,如果是kistart是由TE来引导的,那么wait lcd busy就是正常的, 不用打印出来
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void lcd_te_trig_kistart_set_busy(void);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief lcd_set_param 设置LCD模式
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void lcd_set_param(u8 mode, int priv);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief lcd_get_param 获取LCD模式
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int lcd_get_param(u8 mode);
|
||||
|
||||
float dbi_get_actual_fps();
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief lcd_clock_reinit LCD时钟重新初始化(必须在lcd空闲时调用!!!)
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void lcd_clock_reinit(int fps);
|
||||
|
||||
void lcd_enter_sleep();
|
||||
void lcd_exit_sleep();
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/* -------------------------------- SPI/DSPI/QSPI专用接口 ---------------------------*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief lcd_spi_set_cs_pin 设置软件cs脚(cs_pin_select指定CS_PIN_SEL_SOFT时生效)
|
||||
*
|
||||
* @param gpio 指定普通io作为软件cs脚
|
||||
*
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void lcd_spi_set_cs_pin(int gpio);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief lcd_spi_get_cs_pin 获取软件cs脚(cs_pin_select指定CS_PIN_SEL_SOFT时生效)
|
||||
*
|
||||
* @return gpio : 软件cs脚
|
||||
*
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int lcd_spi_get_cs_pin();
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,265 @@
|
||||
#ifndef __DBI_SFR_H__
|
||||
#define __DBI_SFR_H__
|
||||
//===============================================================================//
|
||||
//
|
||||
// config code mapping
|
||||
//
|
||||
//===============================================================================//
|
||||
|
||||
// dbi_img_con -> fmt
|
||||
//**********************************
|
||||
typedef enum {
|
||||
DBI_IN_RGB565
|
||||
, DBI_IN_RGB888
|
||||
} DBI_IN_FMT_ENUM;
|
||||
|
||||
// dbi_hdl_con -> op
|
||||
//**********************************
|
||||
typedef enum {
|
||||
DBI_OP_SET_START // 开启CS
|
||||
, DBI_OP_SET_END // 关闭CS
|
||||
, DBI_OP_SET_TXC // 切换到命令发送模式
|
||||
, DBI_OP_SET_TXD // 切换到数据发送模式
|
||||
, DBI_OP_SET_RXD // 切换到数据接收模式
|
||||
, DBI_OP_SEND_DLY // 发送delay,无时钟输出
|
||||
, DBI_OP_SEND_DMY // 发送dummy,有时钟输出
|
||||
, RESERVED
|
||||
, DBI_OP_SEND_DAT // 发送数据
|
||||
, DBI_OP_RECE_DAT // 接收数据
|
||||
} DBI_OPCODE_ENUM;
|
||||
|
||||
// dbi_flow_con0 -> protocol
|
||||
//**********************************
|
||||
typedef enum {
|
||||
DBI_TA
|
||||
, DBI_TB
|
||||
, DBI_TC_O1
|
||||
, DBI_TC_O3
|
||||
, DBI_TC_O4
|
||||
, DBI_MSPI
|
||||
} DBI_PROTOCOL_ENUM;
|
||||
|
||||
// dbi_flow_con0 -> pix_fmt
|
||||
//**********************************
|
||||
typedef enum {
|
||||
DBI_OUT_RGB565
|
||||
, DBI_OUT_RGB666
|
||||
, DBI_OUT_RGB888
|
||||
} DBI_OUT_FMT_ENUM;
|
||||
|
||||
// dbi_flow_con0 -> pix_line
|
||||
// dbi_flow_con0 -> cmd_line
|
||||
// dbi_flow_con0 -> adr_line
|
||||
// dbi_flow_con0 -> dma_line
|
||||
// dbi_hdl_con -> line
|
||||
//**********************************
|
||||
typedef enum {
|
||||
DBI_LINE1
|
||||
, DBI_LINE2
|
||||
, DBI_LINE4
|
||||
, DBI_LINE8
|
||||
, DBI_LINE9
|
||||
, DBI_LINE16
|
||||
, DBI_LINE18
|
||||
} DBI_LINE_ENUM;
|
||||
|
||||
// dbi_flow_con0 -> pix_num
|
||||
//**********************************
|
||||
typedef enum {
|
||||
DBI_1_PIX
|
||||
, DBI_2_PIX
|
||||
} DBI_PNUM_ENUM;
|
||||
|
||||
// dbi_flow_con0 -> pix_spl
|
||||
//**********************************
|
||||
typedef enum {
|
||||
DBI_1_TRANS
|
||||
, DBI_2_TRANS
|
||||
, DBI_3_TRANS
|
||||
} DBI_TNUM_ENUM;
|
||||
|
||||
// dbi_flow_sline -> seg
|
||||
// dbi_flow_pline -> seg
|
||||
// dbi_flow_aline -> seg
|
||||
//**********************************
|
||||
#define DBI_SEG_START BIT(0)
|
||||
#define DBI_SEG_CMD BIT(1)
|
||||
#define DBI_SEG_DMY0 BIT(2)
|
||||
#define DBI_SEG_DCX1 BIT(3)
|
||||
#define DBI_SEG_ADR0 BIT(4)
|
||||
#define DBI_SEG_ADR1 BIT(5)
|
||||
#define DBI_SEG_ADR2 BIT(6)
|
||||
#define DBI_SEG_DMY1 BIT(7)
|
||||
#define DBI_SEG_HBP BIT(8)
|
||||
#define DBI_SEG_HACT BIT(9)
|
||||
#define DBI_SEG_HFP BIT(10)
|
||||
#define DBI_SEG_DMY2 BIT(11)
|
||||
#define DBI_SEG_END BIT(12)
|
||||
|
||||
//===============================================================================//
|
||||
//
|
||||
// SFR sub function mapping
|
||||
//
|
||||
//===============================================================================//
|
||||
typedef struct {
|
||||
__RW __u32 cf_hdl_done : 1; // [0]
|
||||
__RW __u32 cf_task_done : 1; // [1]
|
||||
__RW __u32 tg_task_done : 1; // [2]
|
||||
__RW __u32 tg_task_tout : 1; // [3]
|
||||
} t_dbi_pnd;
|
||||
|
||||
typedef struct {
|
||||
__RW __u32 : 1; // [0]
|
||||
__RW __u32 cf_task_kick : 1; // [1]
|
||||
__RW __u32 tg_task_kick : 1; // [2]
|
||||
__RO __u32 : 1; // [3]
|
||||
__RO __u32 xcvr_sta : 4; // [7:4]
|
||||
__RO __u32 cf_hdl_busy : 1; // [8]
|
||||
__RO __u32 cf_task_busy : 1; // [9]
|
||||
__RO __u32 tg_task_busy : 1; // [10]
|
||||
__RO __u32 fc_task_busy : 1; // [11]
|
||||
__RO __u32 fc_sbuf_busy : 1; // [12]
|
||||
} t_dbi_sta_con;
|
||||
|
||||
typedef struct {
|
||||
__RW __u32 bus_nrst : 1; // [0]
|
||||
__RW __u32 vdo_mode : 1; // [1]
|
||||
__RW __u32 dma_mode : 1; // [2]
|
||||
__RW __u32 test_mode : 1; // [3]
|
||||
__RO __u32 : 4; // [7:4]
|
||||
__RW __u32 test_color : 24; // [31:8]
|
||||
} t_dbi_com_con;
|
||||
|
||||
typedef struct {
|
||||
__RW __u32 dat_en : 18; // [17:0]
|
||||
__RW __u32 csx_en : 1; // [18]
|
||||
__RW __u32 dcx_en : 1; // [19]
|
||||
__RW __u32 rwx_en : 1; // [20]
|
||||
__RW __u32 ck_en : 1; // [21]
|
||||
__RW __u32 csx_pol : 1; // [22]
|
||||
__RW __u32 dcx_pol : 1; // [23]
|
||||
__RW __u32 rwx_pol : 1; // [24]
|
||||
__RW __u32 ck_pol : 1; // [25]
|
||||
__RW __u32 ck_phase : 1; // [26]
|
||||
__RW __u32 force_cken : 1; // [27]
|
||||
} t_dbi_port_con;
|
||||
|
||||
typedef struct {
|
||||
__RW __u32 fmt : 1; // [0]
|
||||
__RW __u32 big_end : 1; // [1]
|
||||
__RW __u32 rb_swap : 1; // [2]
|
||||
} t_dbi_img_con;
|
||||
|
||||
typedef struct {
|
||||
__RW __u32 continue_mode: 1; // [0]
|
||||
__RW __u32 vsyn_oe : 1; // [1]
|
||||
__RW __u32 vbp_oe : 1; // [2]
|
||||
__RW __u32 vfp_oe : 1; // [3]
|
||||
__RW __u32 vact_oe : 1; // [4]
|
||||
} t_dbi_tgen_con;
|
||||
|
||||
typedef struct {
|
||||
__RW __u32 protocol : 3; // [2:0]
|
||||
__RW __u32 pix_line : 3; // [5:3]
|
||||
__RW __u32 pix_num : 1; // [6]
|
||||
__RW __u32 pix_spl : 2; // [8:7]
|
||||
__RW __u32 pix_fmt : 2; // [10:9]
|
||||
__RW __u32 cmd_line : 3; // [13:11]
|
||||
__RW __u32 adr_line : 3; // [16:14]
|
||||
__RW __u32 dma_line : 3; // [19:17]
|
||||
} t_dbi_flow_con0;
|
||||
|
||||
typedef struct {
|
||||
__RW __u32 dmy_cfg0 : 8; // [7:0]
|
||||
__RW __u32 dmy_cfg1 : 8; // [15:8]
|
||||
__RW __u32 dmy_cfg2 : 8; // [23:16]
|
||||
__RW __u32 dly_mod0 : 1; // [24]
|
||||
__RW __u32 dly_mod1 : 1; // [25]
|
||||
__RW __u32 dly_mod2 : 1; // [26]
|
||||
} t_dbi_flow_con1;
|
||||
|
||||
typedef struct {
|
||||
__RW __u32 seg : 13; // [12:0]
|
||||
__RO __u32 : 19; // [31:13]
|
||||
__RW __u32 cmd : 8; // [7:0]
|
||||
__RW __u32 adr0 : 8; // [15:8]
|
||||
__RW __u32 adr1 : 8; // [23:16]
|
||||
__RW __u32 adr2 : 8; // [31:24]
|
||||
} t_dbi_xline;
|
||||
|
||||
typedef struct {
|
||||
__RW __u32 cs_setup : 8; // [7:0]
|
||||
__RW __u32 cs_hold : 8; // [15:8]
|
||||
__RW __u32 sta_setup : 8; // [23:16]
|
||||
} t_dbi_flow_con8;
|
||||
|
||||
typedef struct {
|
||||
__RW __u32 op : 4; // [3:0]
|
||||
__RW __u32 line : 3; // [6:4]
|
||||
__RW __u32 num : 2; // [8:7]
|
||||
__RW __u32 rx_mode : 1; // [9]
|
||||
__RW __u32 rx_div : 8; // [17:10]
|
||||
__RW __u32 rx_bsel : 1; // [18]
|
||||
} t_dbi_hdl_con;
|
||||
|
||||
typedef struct {
|
||||
__RW __u32 pix_fmt : 2; // [1:0]
|
||||
__RW __u32 pix_cyc : 2; // [3:2]
|
||||
__RW __u32 blk_mod : 1; // [4]
|
||||
__RW __u32 rb_swap : 1; // [5]
|
||||
__RW __u32 big_end : 1; // [6]
|
||||
} t_dbi_rgb_con;
|
||||
|
||||
//===============================================================================//
|
||||
//
|
||||
// SFR address mapping
|
||||
//
|
||||
//===============================================================================//
|
||||
#define dip_prp0_base (hs_base + map_adr(0x22, 0x00))
|
||||
#define dbi_msfr(i,j) ((j *)(u32)(dip_prp0_base + i*4))
|
||||
#define dbi_wsfr(i) (*(volatile u32 *)(dip_prp0_base + i*4))
|
||||
|
||||
#define dbi_pnd_con dbi_msfr(0x01, t_dbi_pnd)
|
||||
#define dbi_pnd_clr dbi_msfr(0x02, t_dbi_pnd)
|
||||
#define dbi_pnd_ie dbi_msfr(0x03, t_dbi_pnd)
|
||||
|
||||
#define dbi_sta_con dbi_msfr(0x08, t_dbi_sta_con)
|
||||
#define dbi_com_con dbi_msfr(0x09, t_dbi_com_con)
|
||||
#define dbi_port_con dbi_msfr(0x0a, t_dbi_port_con)
|
||||
|
||||
#define dbi_img_con dbi_msfr(0x10, t_dbi_img_con)
|
||||
#define dbi_img_high dbi_wsfr(0x11)
|
||||
#define dbi_img_burst dbi_wsfr(0x12)
|
||||
#define dbi_img_stride dbi_wsfr(0x13)
|
||||
#define dbi_img_addr dbi_wsfr(0x14)
|
||||
|
||||
#define dbi_tgen_con dbi_msfr(0x20, t_dbi_tgen_con)
|
||||
#define dbi_tgen_vsyn dbi_wsfr(0x21)
|
||||
#define dbi_tgen_vbp dbi_wsfr(0x22)
|
||||
#define dbi_tgen_vfp dbi_wsfr(0x23)
|
||||
#define dbi_tgen_vact dbi_wsfr(0x24)
|
||||
#define dbi_tgen_httl dbi_wsfr(0x25)
|
||||
|
||||
#define dbi_flow_hsyn dbi_wsfr(0x30)
|
||||
#define dbi_flow_hbp dbi_wsfr(0x31)
|
||||
#define dbi_flow_hfp dbi_wsfr(0x32)
|
||||
#define dbi_flow_hact dbi_wsfr(0x33)
|
||||
#define dbi_flow_con0 dbi_msfr(0x34, t_dbi_flow_con0)
|
||||
#define dbi_flow_con1 dbi_msfr(0x35, t_dbi_flow_con1)
|
||||
#define dbi_flow_sline dbi_msfr(0x36, t_dbi_xline)
|
||||
//#define dbi_flow_con2 dbi_wsfr(0x36)
|
||||
//#define dbi_flow_con3 dbi_wsfr(0x37)
|
||||
#define dbi_flow_pline dbi_msfr(0x38, t_dbi_xline)
|
||||
//#define dbi_flow_con4 dbi_wsfr(0x38)
|
||||
//#define dbi_flow_con5 dbi_wsfr(0x39)
|
||||
#define dbi_flow_aline dbi_msfr(0x3a, t_dbi_xline)
|
||||
//#define dbi_flow_con6 dbi_wsfr(0x3a)
|
||||
//#define dbi_flow_con7 dbi_wsfr(0x3b)
|
||||
#define dbi_flow_con8 dbi_msfr(0x3c, t_dbi_flow_con8)
|
||||
|
||||
#define dbi_hdl_con dbi_wsfr(0x3d) //, t_dbi_hdl_con)
|
||||
#define dbi_hdl_buf dbi_wsfr(0x3e)
|
||||
|
||||
#define dbi_rgb_con dbi_msfr(0x3f, t_dbi_rgb_con)
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef __LIB_GPU_FORMAT_H__
|
||||
#define __LIB_GPU_FORMAT_H__
|
||||
|
||||
int res_format_to_gpu(int res_format);
|
||||
int gpu_format_to_res(int gpu_format);
|
||||
int text_format_to_gpu(int res_format);
|
||||
int gpu_format_to_text(int gpu_format);
|
||||
int get_clut_format_tabsize(int res_format, int clut_format);
|
||||
int gpu_format_to_lut_size(int gpu_format, int clut_format);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief texture_line_to_tile_base 纹理行排列转为块排列
|
||||
*
|
||||
* @Params dst 纹理输出(注意对齐)
|
||||
* @Params src 纹理输入
|
||||
* @Params src_w 纹理输入宽度
|
||||
* @Params src_h 纹理输入高度
|
||||
* @Params format 纹理格式,参考 GPU_format_t
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void texture_line_to_tile_base(void *dst, void *src, int src_w, int src_h, int format);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,603 @@
|
||||
#ifndef __JLGPU_DRIVER_H__
|
||||
#define __JLGPU_DRIVER_H__
|
||||
|
||||
|
||||
#define GPU_PLATFORM_PC 0
|
||||
|
||||
|
||||
|
||||
|
||||
#if GPU_PLATFORM_PC
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
#else
|
||||
|
||||
#include "asm/cpu.h"
|
||||
#include "system/includes.h"
|
||||
#include "jlgpu_math.h"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#define GPU_COLOR_RAMP_SPREAD_PAD 0x00000000U
|
||||
#define GPU_COLOR_RAMP_SPREAD_REFLECT 0x00000001U
|
||||
#define GPU_COLOR_RAMP_SPREAD_REPEAT 0x00000002U
|
||||
|
||||
#define GPU_BLEND_SRC 0x00000000U
|
||||
#define GPU_BLEND_SRC_OVER 0x00000001U
|
||||
#define GPU_BLEND_DST_OUT 0x00000002U
|
||||
#define GPU_BLEND_DST_IN 0x00000003U
|
||||
#define GPU_BLEND_MAX 0x00000004U
|
||||
#define GPU_BLEND_DST_OVER 0x00000005U
|
||||
#define GPU_BLEND_SRC_OUT 0x00000006U
|
||||
#define GPU_BLEND_SRC_IN 0x00000007U
|
||||
|
||||
#define GPU_FILL 0x00000000U
|
||||
#define GPU_FILL_MASK 0x00000001U
|
||||
#define GPU_FILL_AFFINE 0x00000002U
|
||||
#define GPU_LINEGRAD 0x00000002U
|
||||
#define GPU_FILL_PERSPECTIVE 0x00000003U
|
||||
#define GPU_LINEGRAD_PERSPECTIVE 0x00000003U
|
||||
#define GPU_TEXTURE 0x00000004U
|
||||
#define GPU_TEXTURE_MASK 0x00000005U
|
||||
#define GPU_TEXTURE_AFFINE 0x00000006U
|
||||
#define GPU_TEXTURE_PERSPECTIVE 0x00000007U
|
||||
|
||||
#define LINEGRAD(mode) ((mode) << 4) // 线性渐变左移4bit,用于和FILL区分开
|
||||
|
||||
#define GPU_OUTPUT_WIN_MAX 0xFFFF // uint16_t
|
||||
#define GPU_BOUND_BOX_MAX 0x07FF // uint32_t 11bit
|
||||
|
||||
#define GPU_API_CODE AT(.gpu_api.text.cache.L2)
|
||||
|
||||
typedef enum {
|
||||
GPU_FORMAT_ARGB8888 = 0x00,
|
||||
GPU_FORMAT_ARGB8565 = 0x01, //out
|
||||
GPU_FORMAT_ARGB1555 = 0x02,
|
||||
GPU_FORMAT_ARGB4444 = 0x03,
|
||||
GPU_FORMAT_RGB888 = 0x04,
|
||||
GPU_FORMAT_RGB565 = 0x05, //out
|
||||
|
||||
GPU_FORMAT_YUV422_BT601 = 0x06,
|
||||
GPU_FORMAT_YUV422_BT709 = 0x07,
|
||||
|
||||
GPU_FORMAT_AL88 = 0x08,
|
||||
GPU_FORMAT_AL44 = 0x10,
|
||||
GPU_FORMAT_AL22 = 0x11,
|
||||
GPU_FORMAT_L8 = 0x12,
|
||||
GPU_FORMAT_L4 = 0x13,
|
||||
GPU_FORMAT_L2 = 0x14,
|
||||
GPU_FORMAT_L1 = 0x15,
|
||||
GPU_FORMAT_A8 = 0x16,//out
|
||||
GPU_FORMAT_A4 = 0x17,//out,
|
||||
GPU_FORMAT_A2 = 0x18,//out,
|
||||
GPU_FORMAT_A1 = 0x19,//out,
|
||||
} GPU_format_t;
|
||||
|
||||
typedef enum {
|
||||
GPU_MASK_FORMAT_A8 = 0x00,
|
||||
GPU_MASK_FORMAT_A4 = 0x01,
|
||||
GPU_MASK_FORMAT_A2 = 0x02,
|
||||
GPU_MASK_FORMAT_A1 = 0x03,
|
||||
} GPU_mask_format_t;
|
||||
|
||||
typedef enum {
|
||||
GPU_OUT_FORMAT_ARGB8565 = 0x01, //out
|
||||
GPU_OUT_FORMAT_RGB565 = 0x05, //out
|
||||
GPU_OUT_FORMAT_A8 = 0x16,//out
|
||||
GPU_OUT_FORMAT_A4 = 0x17,//out,
|
||||
GPU_OUT_FORMAT_A2 = 0x18,//out,
|
||||
GPU_OUT_FORMAT_A1 = 0x19,//out,
|
||||
} GPU_out_format_t;
|
||||
|
||||
typedef enum {
|
||||
GPU_CLUT_FORMAT_ARGB8888 = 0x00,
|
||||
GPU_CLUT_FORMAT_ARGB8565 = 0x01,
|
||||
GPU_CLUT_FORMAT_RGB888 = 0x02,
|
||||
GPU_CLUT_FORMAT_RGB565 = 0x03,
|
||||
} GPU_clut_format_t;
|
||||
|
||||
// mmu table page size symbol define.
|
||||
typedef enum {
|
||||
MMU_PAGE_4K = 0x00,
|
||||
MMU_PAGE_16K = 0x01,
|
||||
MMU_PAGE_32K = 0x02,
|
||||
MMU_PAGE_64K = 0x03,
|
||||
} GPU_mmu_page_size_t;
|
||||
|
||||
// 状态定义
|
||||
typedef enum {
|
||||
GPU_STA_IDLE = 0,
|
||||
GPU_STA_RUNNING,
|
||||
GPU_STA_BREAK,
|
||||
GPU_STA_PAUSE,
|
||||
GPU_STA_TIMEOUT,
|
||||
} GPU_State;
|
||||
|
||||
typedef struct {
|
||||
uint8_t *data;
|
||||
uint32_t stride;
|
||||
uint8_t format;
|
||||
uint8_t rbs;
|
||||
uint8_t rgba;
|
||||
uint8_t endian;
|
||||
uint16_t win_x_min;
|
||||
uint16_t win_x_max;
|
||||
uint16_t win_y_min;
|
||||
uint16_t win_y_max;
|
||||
uint16_t offset_left;
|
||||
} gpu_out_params_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t format;
|
||||
uint8_t compress_mode;
|
||||
uint8_t adr_mode;
|
||||
uint8_t big_end;
|
||||
uint8_t alpha_end;
|
||||
uint8_t rbs;
|
||||
uint8_t color_ext_mode;
|
||||
uint16_t stride;
|
||||
uint8_t *data;
|
||||
uint32_t compress_size;
|
||||
} gpu_texture_params_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t *clut;
|
||||
uint8_t layer_en;
|
||||
uint8_t pad_mode;
|
||||
uint8_t trans_mode;
|
||||
uint8_t mask_en;
|
||||
uint8_t blend_mode;
|
||||
uint8_t colorkey_en;
|
||||
uint8_t dither_en;
|
||||
uint8_t clut_format;
|
||||
uint8_t premult;
|
||||
uint8_t ext_mode;
|
||||
uint8_t breakpoint_en;
|
||||
uint16_t act_x_min;
|
||||
uint16_t act_x_max;
|
||||
uint16_t act_y_min;
|
||||
uint16_t act_y_max;
|
||||
uint8_t global_alpha;
|
||||
uint8_t alpha;
|
||||
uint8_t red;
|
||||
uint8_t green;
|
||||
uint8_t blue;
|
||||
//linegrad
|
||||
uint8_t spread_mode;
|
||||
uint8_t lut_lvl;
|
||||
} gpu_basic_params_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t sample_mode;
|
||||
uint8_t shift_sel;
|
||||
float M00;
|
||||
float M01;
|
||||
float M02;
|
||||
float M10;
|
||||
float M11;
|
||||
float M12;
|
||||
float M20;
|
||||
float M21;
|
||||
float M22;
|
||||
uint8_t coeff0;
|
||||
uint8_t coeff1;
|
||||
uint8_t coeff2;
|
||||
uint8_t coeff3;
|
||||
uint8_t coeff4;
|
||||
uint8_t coeff5;
|
||||
uint16_t fg_x_min;
|
||||
uint16_t fg_x_max;
|
||||
uint16_t fg_y_min;
|
||||
uint16_t fg_y_max;
|
||||
} gpu_transform_params_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t *data;
|
||||
uint32_t stride;
|
||||
uint8_t mask_inv;
|
||||
uint8_t mask_big_end;
|
||||
uint8_t mask_format;
|
||||
uint16_t mask_x_min;
|
||||
uint16_t mask_x_max;
|
||||
uint16_t mask_y_min;
|
||||
uint16_t mask_y_max;
|
||||
} gpu_mask_params_t; //add
|
||||
|
||||
void gpu_set_sfr(uint8_t *param, uint8_t *out_data);
|
||||
void gpu_set_out_layer(gpu_out_params_t *param);
|
||||
void gpu_set_texture_mmu(uint8_t *mmu_tb_base, uint8_t mmu_en, uint8_t mmu_page_size, uint8_t mode);
|
||||
int gpu_init();
|
||||
int gpu_free();
|
||||
int gpu_run();
|
||||
int gpu_wait_done();
|
||||
|
||||
void gpu_reset_all_regs(uint8_t mode);
|
||||
uint32_t gpu_get_format_bpp(uint32_t format);
|
||||
uint32_t gpu_get_mask_format_bpp(uint32_t format);
|
||||
void gpu_computeLinearParameters(int x0, int y0, int x1, int y1, gpu_transform_params_t *transform_params);
|
||||
void gpu_fill(gpu_basic_params_t *basic_params);
|
||||
void gpu_fill_mask(gpu_basic_params_t *basic_params, gpu_mask_params_t *mask_params);
|
||||
void gpu_fill_affine(gpu_basic_params_t *basic_params, gpu_transform_params_t *transform_params);
|
||||
void gpu_lineargrad(gpu_basic_params_t *basic_params, gpu_transform_params_t *transform_params);
|
||||
void gpu_fill_perspective(gpu_basic_params_t *basic_params, gpu_transform_params_t *transform_params);
|
||||
void gpu_lineargrad_perspective(gpu_basic_params_t *basic_params, gpu_transform_params_t *transform_params);
|
||||
void gpu_texture(gpu_basic_params_t *basic_params, gpu_texture_params_t *texture_params);
|
||||
void gpu_texture_mask(gpu_basic_params_t *basic_params, gpu_texture_params_t *texture_params, gpu_mask_params_t *mask_params);
|
||||
void gpu_texture_affine(gpu_basic_params_t *basic_params, gpu_texture_params_t *texture_params, gpu_transform_params_t *transform_params);
|
||||
void gpu_texture_perspective(gpu_basic_params_t *basic_params, gpu_texture_params_t *texture_params, gpu_transform_params_t *transform_params);
|
||||
|
||||
void *gpu_get_current_task();
|
||||
void *gpu_create_task(uint8_t mode);
|
||||
void gpu_free_all_tasks();
|
||||
void gpu_dumcp_all_tasks();
|
||||
|
||||
void gpu_fill(gpu_basic_params_t *basic_params);
|
||||
|
||||
void gpu_set_out_layer(gpu_out_params_t *param);
|
||||
|
||||
// 获取状态
|
||||
GPU_State gpu_get_state(void);
|
||||
int gpu_get_break_state(void);
|
||||
//清除状态
|
||||
int gpu_clr_break_state(u8 state);
|
||||
int gpu_clr_break_state_all();
|
||||
int gpu_isr_sem_clr();
|
||||
uint32_t gpu_pack_pixel(uint8_t a, uint8_t r, uint8_t g, uint8_t b, uint32_t format);
|
||||
|
||||
|
||||
typedef struct {
|
||||
int x, y, w, h;
|
||||
} gpu_rectangle_t;
|
||||
|
||||
|
||||
void gpu_rectangle_intersect(gpu_rectangle_t *dst, gpu_rectangle_t *src0, gpu_rectangle_t *src1);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief gpu_task_get_len 根据类型获取 GPU 任务所需的 BUF 长度
|
||||
*
|
||||
* @Params mode GPU 任务类型
|
||||
*
|
||||
* @return GPU 任务所需的 BUF 长度
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
uint32_t gpu_task_get_len(uint8_t mode);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief gpu_task_add_to_list GPU 任务追加到任务链末尾
|
||||
*
|
||||
* @Params base_task GPU 任务链起始地址
|
||||
* @Params new_task 待追加的 GPU 任务
|
||||
*
|
||||
* @return 待追加的 GPU 任务
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void *gpu_task_add_to_list(void *base_task, void *new_task);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief gpu_task_add_to_next 在指定任务下追加下一个任务
|
||||
*
|
||||
* @Params curr_task 指定任务
|
||||
* @Params next_task 下一个任务
|
||||
*
|
||||
* @return 下一个任务
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void *gpu_task_add_to_next(void *curr_task, void *next_task);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief gpu_task_have_next 判断指定任务是否有下一个任务
|
||||
*
|
||||
* @Params curr_task 指定任务
|
||||
*
|
||||
* @return 0 无下一个任务,1 有下一个任务
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int gpu_task_have_next(void *curr_task);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief gpu_task_get_next 获取指定任务的下一个任务
|
||||
*
|
||||
* @Params curr_task 指定任务
|
||||
*
|
||||
* @return NULL 指定任务无下一个任务,其他 指定任务的下一个任务
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void *gpu_task_get_next(void *curr_task);
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief gpu_task_del_next 删除指定任务的下一个任务
|
||||
*
|
||||
* @Params curr_task 指定任务
|
||||
*
|
||||
* @return NULL 指定任务无下一个任务,其他 指定任务原来的下一个任务
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void *gpu_task_del_next(void *curr_task);
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief gpu_task_set_mode 设置指定任务的类型
|
||||
*
|
||||
* @Params taskp 任务指针
|
||||
* @Params mode 任务类型
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void gpu_task_set_mode(void *taskp, uint8_t mode);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief gpu_task_get_mode 获取指定任务的类型
|
||||
*
|
||||
* @Params task_p 任务指针
|
||||
*
|
||||
* @return 任务类型
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
uint8_t gpu_task_get_mode(void *task_p);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief gpu_task_set_enable 设置GPU任务使能开关
|
||||
*
|
||||
* @Params task_p 任务指针
|
||||
* @Params enable 1 使能,0 不使能
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void gpu_task_set_enable(void *task_p, u32 enable);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief gpu_task_get_enable 获取指定任务的使能标志
|
||||
*
|
||||
* @Params task_p 任务指针
|
||||
*
|
||||
* @return 1 任务使能,0 任务未使能
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int gpu_task_get_enable(void *task_p);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief gpu_task_set_breakpoint_enable 设置断点使能
|
||||
*
|
||||
* @param task_p
|
||||
* @param enable
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void gpu_task_set_breakpoint_enable(void *task_p, u32 enable);
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief gpu_task_get_bbox 获取GPU任务的绘图区域
|
||||
*
|
||||
* @Params task_p 任务指针
|
||||
* @Params xmin x最小值,输出
|
||||
* @Params xmax x最大值,输出
|
||||
* @Params ymin y最小值,输出
|
||||
* @Params ymax y最大值,输出
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void gpu_task_get_bbox(void *task_p, u16 *xmin, u16 *xmax, u16 *ymin, u16 *ymax);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief gpu_task_set_fill 设置 GPU_FILL 任务参数
|
||||
*
|
||||
* @Params task_p 任务指针
|
||||
* @Params basic_params gpu_basic_params_t
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void gpu_task_set_fill(void *task_p, gpu_basic_params_t *basic_params);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief gpu_task_set_fill_mask 设置 GPU_FILL_MASK 任务参数
|
||||
*
|
||||
* @Params task_p 任务指针
|
||||
* @Params basic_params gpu_basic_params_t
|
||||
* @Params mask_params gpu_mask_params_t
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void gpu_task_set_fill_mask(void *task_p, gpu_basic_params_t *basic_params, gpu_mask_params_t *mask_params);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief gpu_task_set_fill_affine 设置 GPU_FILL_AFFINE 任务参数
|
||||
*
|
||||
* @Params task_p 任务指针
|
||||
* @Params basic_params gpu_basic_params_t
|
||||
* @Params transform_params gpu_transform_params_t
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void gpu_task_set_fill_affine(void *task_p, gpu_basic_params_t *basic_params, gpu_transform_params_t *transform_params);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief gpu_task_set_fill_perspective 设置 GPU_FILL_PERSPECTIVE 任务参数
|
||||
*
|
||||
* @Params task_p 任务指针
|
||||
* @Params basic_params gpu_basic_params_t
|
||||
* @Params transform_params gpu_transform_params_t
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void gpu_task_set_fill_perspective(void *task_p, gpu_basic_params_t *basic_params, gpu_transform_params_t *transform_params);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief gpu_task_set_lineargrad 设置 GPU_LINEGRAD 任务参数
|
||||
*
|
||||
* @Params task_p 任务指针
|
||||
* @Params basic_params gpu_basic_params_t
|
||||
* @Params transform_params gpu_transform_params_t
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void gpu_task_set_lineargrad(void *task_p, gpu_basic_params_t *basic_params, gpu_transform_params_t *transform_params);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief gpu_task_set_lineargrad_perspective 设置 GPU_LINEGRAD_PERSPECTIVE 任务参数
|
||||
*
|
||||
* @Params task_p 任务指针
|
||||
* @Params basic_params gpu_basic_params_t
|
||||
* @Params transform_params gpu_transform_params_t
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void gpu_task_set_lineargrad_perspective(void *task_p, gpu_basic_params_t *basic_params, gpu_transform_params_t *transform_params);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief gpu_task_set_texture 设置 GPU_TEXTURE 任务参数
|
||||
*
|
||||
* @Params task_p 任务指针
|
||||
* @Params basic_params gpu_basic_params_t
|
||||
* @Params texture_params gpu_texture_params_t
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void gpu_task_set_texture(void *task_p, gpu_basic_params_t *basic_params, gpu_texture_params_t *texture_params);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief gpu_task_set_texture_mask 设置 GPU_TEXTURE_MASK 任务参数
|
||||
*
|
||||
* @Params task_p 任务指针
|
||||
* @Params basic_params gpu_basic_params_t
|
||||
* @Params texture_params gpu_texture_params_t
|
||||
* @Params mask_params gpu_mask_params_t
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void gpu_task_set_texture_mask(void *task_p, gpu_basic_params_t *basic_params, gpu_texture_params_t *texture_params, gpu_mask_params_t *mask_params);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief gpu_task_set_texture_affine 设置 GPU_TEXTURE_AFFINE 任务参数
|
||||
*
|
||||
* @Params task_p 任务指针
|
||||
* @Params basic_params gpu_basic_params_t
|
||||
* @Params texture_params gpu_texture_params_t
|
||||
* @Params transform_params gpu_transform_params_t
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void gpu_task_set_texture_affine(void *task_p, gpu_basic_params_t *basic_params, gpu_texture_params_t *texture_params, gpu_transform_params_t *transform_params);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief gpu_task_set_texture_perspective 设置 GPU_TEXTURE_PERSPECTIVE 任务参数
|
||||
*
|
||||
* @Params task_p 任务指针
|
||||
* @Params basic_params gpu_basic_params_t
|
||||
* @Params texture_params gpu_texture_params_t
|
||||
* @Params transform_params gpu_transform_params_t
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void gpu_task_set_texture_perspective(void *task_p, gpu_basic_params_t *basic_params, gpu_texture_params_t *texture_params, gpu_transform_params_t *transform_params);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief gpu_task_set_texture_mmu 设置 GPU_TEXTURE 任务的MMU(文件table表)
|
||||
*
|
||||
* @Params task_p 任务指针
|
||||
* @Params mmu_tb_base mmu 起始地址,相当于第一个 page 的偏移地址
|
||||
* @Params mmu_en mmu 使能标志:1 使能,0 不使能
|
||||
* @Params mmu_page_size mmu page 大小,参考 GPU_mmu_page_size_t
|
||||
*
|
||||
* @return int 0 设置成功,-1 设置失败,任务没有 mmu 命令(任务类型错误)
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int gpu_task_set_texture_mmu(void *task_p, uint8_t *mmu_tb_base, uint8_t mmu_en, uint8_t mmu_page_size);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief gpu_get_next_task_by_reg 从GPU模块寄存器获取下一个GPU任务(非必要情况禁止使用)
|
||||
*
|
||||
* @return 下一个GPU任务指针
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void *gpu_get_next_task_by_reg();
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief gpu_get_curr_task_by_reg 从GPU模块寄存器获取当前的GPU任务(非必要情况禁止使用)
|
||||
*
|
||||
* @return 当前的CPU任务指针
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void *gpu_get_curr_task_by_reg();
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief gpu_task_list_run 运行 GPU 任务链
|
||||
*
|
||||
* @Params base_task_addr GPU 任务链首地址
|
||||
*
|
||||
* @return 0 运行成功,其他 运行失败
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int gpu_task_list_run(void *base_task_addr);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief gpu_dump_task_list 打印任务链中所有任务信息,用于 debug
|
||||
*
|
||||
* @Params base_task 任务链起始地址
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void gpu_dump_task_list(void *base_task);
|
||||
|
||||
|
||||
void jlgpu_driver_get_matrix(void *p, gpu_matrix_t *matrix);
|
||||
void jlgpu_driver_set_matrix(void *p, gpu_matrix_t *matrix);
|
||||
void jlgpu_driver_set_bbox(void *p, gpu_boundbox_t *bbox);
|
||||
void jlgpu_driver_get_bbox(void *p, gpu_boundbox_t *bbox);
|
||||
uint8_t jlgpu_driver_mode(void *p);
|
||||
void jlgpu_driver_set_next_inst_addr(void *p, u32 addr);
|
||||
void jlgpu_driver_set_trans_mode(void *p, int trans_mode);
|
||||
void jlgpu_driver_get_clip(void *p, int *clip_x_min, int *clip_x_max, int *clip_y_min, int *clip_y_max, int width, int height);
|
||||
void jlgpu_driver_set_clip(void *p, int *clip_x_min, int *clip_x_max, int *clip_y_min, int *clip_y_max);
|
||||
void jlgpu_driver_set_breakpoint(void *p, u32 enable);
|
||||
void jlgpu_driver_get_texture_addr(void *p, u32 *mmu_en, u32 *mmu_tb_base, u32 *tex_base_adr, u32 *rle_limit_adr, u32 *tex_stride);
|
||||
void jlgpu_driver_set_texture_addr(void *p, u32 *mmu_en, u32 *mmu_tb_base, u32 *tex_base_adr, u32 *rle_limit_adr, u32 *tex_stride);
|
||||
int jlgpu_driver_get_format(void *p);
|
||||
int jlgpu_driver_get_clut_format(void *p);
|
||||
void *jlgpu_driver_get_clut_addr(void *p);
|
||||
void jlgpu_driver_set_texture_big_end(void *p, int big_end);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
#ifndef __GPU_MATH_H__
|
||||
#define __GPU_MATH_H__
|
||||
|
||||
// #include <stdint.h>
|
||||
#include "asm/cpu.h"
|
||||
#include "system/includes.h"
|
||||
|
||||
#define GPU_MATH_CODE AT(.math_api.text.cache.L2)
|
||||
|
||||
typedef struct {
|
||||
|
||||
float m[3][3];
|
||||
|
||||
} gpu_matrix_t;
|
||||
|
||||
typedef struct {
|
||||
|
||||
float x;
|
||||
float y;
|
||||
|
||||
} gpu_point2_t;
|
||||
|
||||
typedef struct {
|
||||
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
} gpu_point3_t;
|
||||
|
||||
typedef struct {
|
||||
int minx;
|
||||
int maxx;
|
||||
int miny;
|
||||
int maxy;
|
||||
} gpu_boundbox_t;
|
||||
|
||||
|
||||
float gpu_sinf(float x);
|
||||
float gpu_cosf(float x);
|
||||
gpu_matrix_t *gpu_matrix_create();
|
||||
void gpu_matrix_free_(gpu_matrix_t *m);
|
||||
void gpu_matrix_set_identity(gpu_matrix_t *m);
|
||||
void gpu_matrix_set_translate(gpu_matrix_t *m, float tx, float ty);
|
||||
void gpu_matrix_set_scale(gpu_matrix_t *m, float sx, float sy);
|
||||
void gpu_matrix_set_shear(gpu_matrix_t *m, float shx, float shy);
|
||||
void gpu_matrix_set_rotate(gpu_matrix_t *m, float a);
|
||||
void gpu_matrix_set_flip(gpu_matrix_t *m, int x_en, int y_en);
|
||||
|
||||
void gpu_matrix_multiply(gpu_matrix_t *d, gpu_matrix_t *s0, gpu_matrix_t *s1);
|
||||
void gpu_matrix_mul_const(gpu_matrix_t *m, float f);
|
||||
int gpu_matrix_is_affine(gpu_matrix_t *m);
|
||||
int gpu_matrix_invert(gpu_matrix_t *dm, gpu_matrix_t *m);
|
||||
|
||||
|
||||
void gpu_matrix_translate(gpu_matrix_t *m, float tx, float ty);
|
||||
void gpu_matrix_scale(gpu_matrix_t *m, float sx, float sy);
|
||||
void gpu_matrix_shear(gpu_matrix_t *m, float shx, float shy);
|
||||
void gpu_matrix_rotate(gpu_matrix_t *m, float a);
|
||||
void gpu_matrix_flip(gpu_matrix_t *m, int x_en, int y_en);
|
||||
|
||||
void gpu_transform_point2(gpu_point2_t *dp, gpu_matrix_t *m, gpu_point2_t *sp);
|
||||
|
||||
void gpu_point2_add(gpu_point2_t *d, gpu_point2_t *s0, gpu_point2_t *s1);
|
||||
void gpu_point2_sub(gpu_point2_t *d, gpu_point2_t *s0, gpu_point2_t *s1);
|
||||
void gpu_point2_mul(gpu_point2_t *d, gpu_point2_t *s0, gpu_point2_t *s1);
|
||||
float gpu_point2_len(gpu_point2_t *s0, gpu_point2_t *s1);
|
||||
|
||||
void gpu_matrix_get_boundbox(gpu_matrix_t *matrix, gpu_boundbox_t *src, gpu_boundbox_t *dst);
|
||||
|
||||
int gpu_matrix_calc_by_point(gpu_matrix_t *matrix, int pt_w, int pt_h, float points[8]);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,376 @@
|
||||
/*----------------------------------------------*/
|
||||
/* JL HW JEPG CODEC */
|
||||
/*----------------------------------------------*/
|
||||
#ifndef _JL_HW_JPGDEC
|
||||
#define _JL_HW_JPGDEC
|
||||
#include "typedef.h"
|
||||
#include "generic/rect.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//#define MCU_BUFF_NUM 1
|
||||
#ifndef MCU_BUFF_NUM
|
||||
#define MCU_BUFF_NUM 2
|
||||
#endif
|
||||
/* Allow the number of cached MUC blocks , Default to 2 , 默认双buff乒乓,支持多 buff 模式,最小可以设置为 1 */
|
||||
/* 当上层触发解码动作的速度比解码速度快时,适当改大可以提高速度,比如直接设置整幅图片的总 MCU 数量, 即硬件直接解完,效率只受限于解码速度*/
|
||||
/* 当上层触发解码动作的速度比解码速度慢时,使用 2 个buff即保证每次来取数据都有已经解码完成的内容,改大没有意义 */
|
||||
|
||||
//#define BIT_BUFF_NUM 1
|
||||
#ifndef BIT_BUFF_NUM
|
||||
#define BIT_BUFF_NUM 1
|
||||
#endif
|
||||
/* Allow the number of cached MUC blocks , Default to 2 , 双buff乒乓或者单buff阻塞使用 */
|
||||
/* 大致情况和 MCU 类似,主要考虑到输入bit流需要时32位对齐的地址空间,原始 bit 流需要从 flash 或者 SD 卡之中进行拷贝到RAM中,因此建议乒乓操作, 更多的 buff 没有意义,因为取 bit 流的动作会比解码动作慢 */
|
||||
|
||||
//#define JDEC_SZBUF 1024 * 8
|
||||
#ifndef JDEC_SZBUF
|
||||
#define JDEC_SZBUF 512
|
||||
#endif
|
||||
/* Specifies size of stream input buffer , >= 17 + 256 */
|
||||
|
||||
#define JDEC_MAGIC "JLHWJPEG"
|
||||
|
||||
typedef enum {
|
||||
JPG_TEM = 0X01, //算术编码中作临时之用
|
||||
|
||||
//非层次哈夫曼编码
|
||||
JPIF_SOF0 = 0XC0, //基线离散余弦变换/*只支持这种编码格式的图片*/
|
||||
JPIF_SOF1, //扩展顺序离散余弦变换
|
||||
JPIF_SOF2, //递进离散余弦变换
|
||||
JPIF_SOF3, //空间顺序无损
|
||||
|
||||
JPIF_DHT = 0XC4, //哈夫曼表
|
||||
|
||||
//层次哈夫曼编码
|
||||
JPIF_SOF5, //差分离散余弦变换
|
||||
JPIF_SOF6, //差分层次离散余弦变换
|
||||
JPIF_SOF7, //差分空间无损
|
||||
|
||||
//非层次算术编码
|
||||
JPIF_SOF8, //为JPEG扩展保留
|
||||
JPIF_SOF9, //扩展顺序离散余弦变换
|
||||
JPIF_SOF10, //递进离散余弦变换
|
||||
JPIF_SOF11, //空间顺序无损
|
||||
|
||||
JPIF_DAC = 0XCC, //算术编码表
|
||||
|
||||
//层次算术编码
|
||||
JPIF_SOF13, //差分离散余弦变换
|
||||
JPIF_SOF14, //差分层次离散余弦变换
|
||||
JPIF_SOF15, //差分空间无损
|
||||
|
||||
JPIF_RST0 = 0XD0, //每隔n个MCU 块就有一个RST标记
|
||||
JPIF_RST1,
|
||||
JPIF_RST2,
|
||||
JPIF_RST3,
|
||||
JPIF_RST4,
|
||||
JPIF_RST5,
|
||||
JPIF_RST6,
|
||||
JPIF_RST7 = 0XD7,
|
||||
|
||||
JPIF_SOI = 0XD8, //文件头
|
||||
JPIF_EOI = 0XD9, //文件尾
|
||||
JPIF_SOS = 0XDA, //扫描行开始
|
||||
JPIF_DQT = 0XDB, //量化表
|
||||
JPIF_DNL = 0XDC, //线数
|
||||
JPIF_DRI = 0XDD, //重新开始间隔
|
||||
JPIF_DHP = 0XDE, //层次级数
|
||||
JPIF_EXP = 0XDF, //展开参考图像
|
||||
|
||||
JPIF_APP0 = 0XE0, //交换格式和图像识别信息
|
||||
JPIF_APP1,
|
||||
JPIF_APP2,
|
||||
JPIF_APP3,
|
||||
JPIF_APP4,
|
||||
JPIF_APP5,
|
||||
JPIF_APP6,
|
||||
JPIF_APP7,
|
||||
JPIF_APP8,
|
||||
JPIF_APP9,
|
||||
JPIF_APP10,
|
||||
JPIF_APP11,
|
||||
JPIF_APP12,
|
||||
JPIF_APP13,
|
||||
JPIF_APP14,
|
||||
JPIF_APP15,
|
||||
JPIF_COM = 0XFE, //注释
|
||||
JPIF_MASK = 0XFF,
|
||||
} JPG_TYPE;
|
||||
|
||||
/* Decode event code */
|
||||
typedef enum {
|
||||
JDEC_INTER_MCU, /* 0: The specified number of MCU blocks finishes decoding */
|
||||
JDEC_INTER_BIT, /* 1: End of bit stream */
|
||||
JDEC_INTER_FINISH, /* 2: End of file decoding */
|
||||
} jdec_msg;
|
||||
|
||||
/* Error code */
|
||||
typedef enum {
|
||||
JDEC_OK = 0, /* 0: Succeeded */
|
||||
JDEC_INP, /* 1: Device error or wrong termination of input stream */
|
||||
JDEC_MEM1, /* 2: Memory request failed */
|
||||
JDEC_MEM2, /* 3: Memory space not requested */
|
||||
JDEC_MEM3, /* 4: Exceeds input buffer size : > JDEC_SZBUF */
|
||||
JDEC_FMT1, /* 5: Data format error (may be broken data) */
|
||||
JDEC_FMT2, /* 6: Right format but not supported */
|
||||
JDEC_FMT3, /* 7: Not supported JPEG standard */
|
||||
JDEC_FMT4, /* 8: Decoding execution error*/
|
||||
JDEC_STA, /* 9: Jpeg work status error*/
|
||||
JDEC_TIMEOUT,/*10: DEC_TIMEOUT*/
|
||||
JDEC_HD_ERR,/*11:DEC_HD ERR*/
|
||||
} jdec_err;
|
||||
|
||||
/* HW JPEG work state code */
|
||||
typedef enum {
|
||||
JDEC_WORK_STATE_CLOSE = 0, /* The jpeg decoding module is turned off */
|
||||
JDEC_WORK_STATE_INIT, /* The jpeg decoding module is inited*/
|
||||
JDEC_WORK_STATE_OPEN, /* The jpeg decoding module is enabled */
|
||||
JDEC_WORK_STATE_START, /* jpeg decoding begins */
|
||||
JDEC_WORK_STATE_STOP, /* End of jpeg decoding */
|
||||
JDEC_WORK_STATE_SUSPEND, /* Pause during jpeg decoding */
|
||||
} jdec_work_state;
|
||||
|
||||
/* MCU/BIT buff state code */
|
||||
typedef enum {
|
||||
JDEC_BUFF_STATE_INVALID = 0, /* 0: The buff is invalid, and the data is outdated or invalid */
|
||||
JDEC_BUFF_STATE_UNDECODED, /* 1: The mcu block or bit stream that has not yet begun decoding */
|
||||
JDEC_BUFF_STATE_DECODING, /* 2: Wait for the mcu block or bit stream to decode */
|
||||
JDEC_BUFF_STATE_DECODED, /* 3: The decoding of the mcu block or bit stream is completed */
|
||||
JDEC_BUFF_STATE_COPY, /* 4: MCU buf copy to line buf */
|
||||
} jdec_buff_state;
|
||||
|
||||
/* Mcu buff information structure */
|
||||
typedef struct _jdec_muc_buff {
|
||||
jdec_buff_state state; /* mcu block usage status */
|
||||
u16 mcuid; /* mcu block ID */
|
||||
u8 *buf; /* data buffer */
|
||||
} jdec_mcu_buff;
|
||||
|
||||
/* Bit buff information structure */
|
||||
typedef struct _jdec_bit_buff {
|
||||
jdec_buff_state state; /* bit stream usage status */
|
||||
u32 len; /* data len */
|
||||
u8 *buf; /* data buffer */
|
||||
} jdec_bit_buff;
|
||||
|
||||
/* Huffman table structs */
|
||||
typedef struct _huff_tab {
|
||||
u16 *min;
|
||||
u8 *index;
|
||||
u8 *pval;
|
||||
} huff_tab;
|
||||
|
||||
/* Decompressor object structure */
|
||||
typedef struct _jdec_opj {
|
||||
void *magic; /* Decoder magic */
|
||||
|
||||
jdec_work_state work_state: 4; /* Working state of the jpeg decoder module */
|
||||
u8 msx: 4;
|
||||
u8 msy: 4; /* MCU size in unit of block (width, height) */
|
||||
|
||||
u8 ycnt: 2; /* Y in the proportion of MCU components: 0:YUV444;1:YUV422;3:YUV411/YUV420 */
|
||||
|
||||
u8 isr_flags: 4; /* BIT0:MCU BIT2:BITS BIT3:LINE BIT4:REV */
|
||||
u8 ncomp: 2; /* Number of color components 1:grayscale, 3:color */
|
||||
u8 format: 1; /*1:565 0:888*/
|
||||
u8 line_buf_vaild: 1; /*line buf 有效位*/
|
||||
u8 bit_buff_sw: 1; /*bits_buff*/
|
||||
u8 dri_enable: 1; /*dri_enable*/
|
||||
u8 cur_rst_flag: 3; /*rst_flag:0xff d0~d7*/
|
||||
u32 rev: 5; /* 预留拓展*/
|
||||
|
||||
u16 wmcu_num; /* The number of mcu blocks in the horizontal direction */
|
||||
u16 hmcu_num; /* The number of mcu blocks in the vertical direction */
|
||||
|
||||
u16 all_mcucnt; /* The total number of mcu blocks of the picture */
|
||||
u16 curr_mcuid; /* The mcu block ID currently to be decodeid: 0 - (all_mcucnt - 1) */
|
||||
u16 start_mcuid; /*单次解码的开始id*/
|
||||
u16 end_mcuid; /*单次解码的结束id*/
|
||||
u16 mcu_cnt; /*单次解码 MCU 块的数量*/
|
||||
u16 mcu_size; /*单个 MCU 块的大小*/
|
||||
|
||||
u8 qtid[3]; /* Quantization table ID of each component, Y, Cb, Cr */
|
||||
|
||||
u16 width; /* Size of the input image (pixel) */
|
||||
u16 height; /* Size of the input image (pixel) */
|
||||
|
||||
u32(*infunc)(struct _jdec_opj *, u8 *buf, u32 len); /* Pointer to jpeg stream input function */
|
||||
void (*decode_msg)(struct _jdec_opj *, jdec_msg); /* Pointer to the jpeg decoding event function */
|
||||
void (*decode_wait)(struct _jdec_opj *); /* The decoder event waits for the callback */
|
||||
void *device; /* Pointer to I/O device identifiler for the session */
|
||||
int curr_offset; /*文件内偏移*/
|
||||
|
||||
u8 *outbuf; /* YUV422 to RGB buff: 这个 buff 从上层应用传下来装载数据 */
|
||||
huff_tab hufftbl[2][2]; /* Huffman tables [id][dcac] */
|
||||
u16 *qt_table;
|
||||
s16 *qttbl[2]; /* Dequantizer tables [id] */
|
||||
u16 *std_huffman_table;
|
||||
u32 *huffman;
|
||||
jdec_mcu_buff mcu_buff[MCU_BUFF_NUM]; /* MCU_BUFF_NUM mcu block buffers: 这些 buff 负责暂存解码后的 MCU 块数据和 MCU 块信息 */
|
||||
jdec_bit_buff bit_buff[BIT_BUFF_NUM]; /* BIT_BUFF_NUM bit stream buffers: 这些 buff 负责暂存原始的 JPEG 数据或者 JPEG 段信息 */
|
||||
u8 *line_buf; /*mcu解码后数据先暂存到linebuf再统一变换输出,同时缓存部分数据给下一次解码使用,避免重复*/
|
||||
struct rect draw_rect; /*jpeg在屏幕的绘制区域*/
|
||||
struct rect jpeg_rect; /*在jpeg解码的相对位置*/
|
||||
struct rect obuf_rect; /*输出buffer的区域*/
|
||||
struct rect cover_rect;
|
||||
void *matrix; /* affine matrix: 用于合成这个JPG时做GPU变换 */
|
||||
s16 surplus_line; /* line buf 剩余未使用数据*/
|
||||
u16 nrst;
|
||||
u32 bit_cnt_start; /*位流起始地址*/
|
||||
unsigned long bit_usec; /*bit usec*/
|
||||
unsigned long mcu_usec; /*mcu_usec*/
|
||||
} jdec_opj;
|
||||
|
||||
extern const char jljpeg_magic[]; //识别解码器的标志字
|
||||
|
||||
/* JL JPEG DEC API functions */
|
||||
void jljpeg_os_init(void);
|
||||
void jljpeg_hw_config_stage1(jdec_opj *opj, bool os_flag);
|
||||
jdec_err jljpeg_hw_config_stage2(void (*decode_msg)(struct _jdec_opj *, jdec_msg), void (*decode_wait)(struct _jdec_opj *), \
|
||||
uint16_t mcu_cnt, uint8_t *mcu_buff);
|
||||
jdec_err jljpeg_hw_config_stage3(uint16_t x, uint16_t y, uint8_t *buf);
|
||||
void jljpeg_hw_release(void);
|
||||
void jljpeg_hw_resource_release(bool os_flag);
|
||||
jdec_opj *jpeg_hw_get(void);
|
||||
void jpeg_hw_set(jdec_opj *opj);
|
||||
|
||||
void jljpeg_hw_init(jdec_opj *opj);
|
||||
void jljpeg_hw_reset(void);
|
||||
void jljpeg_hw_restart(void);
|
||||
void jljpeg_hw_mcubuff_reset(jdec_opj *opj, uint16_t mcu_cnt, uint8_t *mcu_buff);
|
||||
|
||||
void *jpeg_malloc(int size);
|
||||
void jpeg_free(void *p);
|
||||
#define JPEG_MALLOC(a) jpeg_malloc(a)
|
||||
#define JPEG_FREE(a) jpeg_free(a)
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief jljpeg_img_info_get 读取文件头
|
||||
*
|
||||
* @param opj
|
||||
* @param infunc
|
||||
* @param dev
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
jdec_err jljpeg_img_info_get(jdec_opj *opj, u32(*infunc)(jdec_opj *opj, u8 *buf, u32 size), void *dev);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief jpeg_decode_module_init jpeg 模块初始化
|
||||
*
|
||||
* @param malloc 申请
|
||||
* @param free 释放
|
||||
* @param gpu_blend 绘图
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
|
||||
int jpeg_decode_module_init(
|
||||
void *(*malloc)(int size, u32 ram_type, u32 module_type),
|
||||
void (*free)(void *p, u32 ram_type, u32 module_type),
|
||||
int (*gpu_blend)(u8 *dst_buf, struct rect *dst_rect, u8 *src_buf, struct rect *src_rect, struct rect *draw_rect, int src_stride, int format, void *p, int line_surpule, struct rect *cover)
|
||||
);
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief jljpeg_decode_init 初始化解码
|
||||
*
|
||||
* @param opj
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int jljpeg_decode_init(jdec_opj *opj);
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief jljpeg_decode_set_callback 注册回调
|
||||
*
|
||||
* @param opj 句柄
|
||||
* @param infunc 输入数据流回调
|
||||
* @param decode_msg
|
||||
* @param decode_wait
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int jljpeg_decode_set_callback(jdec_opj *opj,
|
||||
u32(*infunc)(struct _jdec_opj *opj, u8 *buf, u32 len),
|
||||
void (*decode_msg)(struct _jdec_opj *, jdec_msg),
|
||||
void (*decode_wait)(struct _jdec_opj *)
|
||||
);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief jljpeg_decode_start 启动jpeg解码
|
||||
*
|
||||
* @param opj 解码句柄
|
||||
* @param draw_rect 图片绘制区域
|
||||
* @param jpeg_rect 在jpeg中的解码区域
|
||||
* @param cover_rect 图片限制区域
|
||||
* @param obuf_rect 输出buf区域
|
||||
* @param dec_out_buf 输出buf
|
||||
*
|
||||
* @return jdec_err
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
jdec_err jljpeg_decode_start(jdec_opj *opj, struct rect *draw_rect, struct rect *jpeg_rect, struct rect *cover_rect, struct rect *obuf_rect, void *dec_out_buf);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief jljpeg_decode_release
|
||||
*
|
||||
* @param opj 解码句柄
|
||||
* @param global_hd_clr 将全局解码句柄置为NULL,需应用层free句柄
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int jljpeg_decode_release(jdec_opj *opj, int global_hd_clr);
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief jljpeg_get_decode_hd 将当前解码句柄置为NULL,需应用层free句柄
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void jljpeg_get_decode_hd_clr();
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief jljpeg_get_decode_hd 获取文件句柄
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void *jljpeg_get_decode_hd();
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief jljpeg_decode_reset_curr 重新解码当前文件(废)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int jljpeg_decode_reset_curr();
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief jljpeg_decode_hdl_reset 重新解码当前文件
|
||||
*
|
||||
* @param opj
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int jljpeg_decode_hdl_reset(jdec_opj *opj);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _JL_HW_JPGDEC */
|
||||
@@ -0,0 +1,581 @@
|
||||
/* Copyright(C) 2010- , JIELI TECHNOLOGY, Inc.
|
||||
* All right reserved.
|
||||
*/
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @file control.h
|
||||
*
|
||||
* @brief 杰理UI控件信息、类型定义
|
||||
*
|
||||
* @author zhuhaifang@zh-jieli.com
|
||||
*
|
||||
* @version V1.0.0
|
||||
*
|
||||
* @date 2024-06-05
|
||||
*
|
||||
* 注意:本文件内容不可擅自改动,需配合UI工具,UI编译工具同步改动,否则影响UI框架运行
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef UI_CONTROL_H
|
||||
#define UI_CONTROL_H
|
||||
|
||||
#include "jlui/ui_core.h"
|
||||
|
||||
union ui_control_info;
|
||||
struct layout_info;
|
||||
|
||||
#define ENABLE_LUA_VIRTUAL_MACHINE 0 //LUA脚本使能
|
||||
|
||||
/***************************************** 控件类型定义 *****************************************/
|
||||
// 可通过 ui_id2type(ID) 获取,用于通过控件ID区分控件类型
|
||||
#define CTRL_TYPE_WINDOW 2
|
||||
#define CTRL_TYPE_LAYOUT 3
|
||||
#define CTRL_TYPE_LAYER 4
|
||||
#define CTRL_TYPE_GRID 5
|
||||
#define CTRL_TYPE_LIST 6
|
||||
#define CTRL_TYPE_BUTTON 7
|
||||
#define CTRL_TYPE_PIC 8
|
||||
#define CTRL_TYPE_BATTERY 9
|
||||
#define CTRL_TYPE_TIME 10
|
||||
#define CTRL_TYPE_CAMERA_VIEW 11
|
||||
#define CTRL_TYPE_TEXT 12
|
||||
#define CTRL_TYPE_ANIMATION 13
|
||||
#define CTRL_TYPE_PLAYER 14
|
||||
#define CTRL_TYPE_NUMBER 15
|
||||
|
||||
// 圆环进度条控件
|
||||
#define CTRL_TYPE_PROGRESS 20
|
||||
#define CTRL_PROGRESS_CHILD_BEGIN (CTRL_TYPE_PROGRESS + 1)
|
||||
#define CTRL_PROGRESS_CHILD_HIGHLIGHT (CTRL_PROGRESS_CHILD_BEGIN) //21
|
||||
#define CTRL_PROGRESS_CHILD_END (CTRL_PROGRESS_CHILD_BEGIN + 1)
|
||||
|
||||
// 多重圆环进度条控件
|
||||
#define CTRL_TYPE_MULTIPROGRESS 22
|
||||
#define CTRL_MULTIPROGRESS_CHILD_BEGIN (CTRL_TYPE_MULTIPROGRESS + 1)
|
||||
#define CTRL_MULTIPROGRESS_CHILD_HIGHLIGHT (CTRL_MULTIPROGRESS_CHILD_BEGIN)//23
|
||||
#define CTRL_MULTIPROGRESS_CHILD_END (CTRL_MULTIPROGRESS_CHILD_BEGIN + 1)
|
||||
|
||||
// watch(表盘)控件
|
||||
#define CTRL_TYPE_WATCH 24
|
||||
#define CTRL_WATCH_CHILD_BEGIN (CTRL_TYPE_WATCH + 1)
|
||||
#define CTRL_WATCH_CHILD_HOUR (CTRL_WATCH_CHILD_BEGIN)//25
|
||||
#define CTRL_WATCH_CHILD_MIN (CTRL_WATCH_CHILD_BEGIN+1)//26
|
||||
#define CTRL_WATCH_CHILD_SEC (CTRL_WATCH_CHILD_BEGIN+2)//27
|
||||
#define CTRL_WATCH_CHILD_END (CTRL_WATCH_CHILD_BEGIN+3)
|
||||
|
||||
// 水平进度条控件
|
||||
#define CTRL_TYPE_SLIDER 28
|
||||
|
||||
#define SLIDER_CHILD_BEGIN (CTRL_TYPE_SLIDER+1)
|
||||
#define SLIDER_CHILD_UNSELECT_PIC (SLIDER_CHILD_BEGIN)//29
|
||||
#define SLIDER_CHILD_SELECTED_PIC (SLIDER_CHILD_BEGIN+1)//30
|
||||
#define SLIDER_CHILD_SLIDER_PIC (SLIDER_CHILD_BEGIN+2)//31
|
||||
#define SLIDER_CHILD_PERSENT_TEXT (SLIDER_CHILD_BEGIN+3)//32
|
||||
#define SLIDER_CHILD_END (SLIDER_CHILD_BEGIN+4)
|
||||
|
||||
// 垂直进度条控件
|
||||
#define CTRL_TYPE_VSLIDER 33
|
||||
|
||||
#define VSLIDER_CHILD_BEGIN (CTRL_TYPE_VSLIDER+1)
|
||||
#define VSLIDER_CHILD_UNSELECT_PIC (VSLIDER_CHILD_BEGIN)//34
|
||||
#define VSLIDER_CHILD_SELECTED_PIC (VSLIDER_CHILD_BEGIN+1)//35
|
||||
#define VSLIDER_CHILD_SLIDER_PIC (VSLIDER_CHILD_BEGIN+2)//36
|
||||
#define VSLIDER_CHILD_PERSENT_TEXT (VSLIDER_CHILD_BEGIN+3)//37
|
||||
#define VSLIDER_CHILD_END (VSLIDER_CHILD_BEGIN+4)
|
||||
|
||||
// 指南针控件
|
||||
#define CTRL_TYPE_COMPASS 38
|
||||
|
||||
#define CTRL_COMPASS_CHILD_BEGIN (CTRL_TYPE_COMPASS+1)
|
||||
#define CTRL_COMPASS_CHILD_BKIMG (CTRL_COMPASS_CHILD_BEGIN)//39
|
||||
#define CTRL_COMPASS_CHILD_INDICATOR (CTRL_COMPASS_CHILD_BEGIN+1)//40
|
||||
#define CTRL_COMPASS_CHILD_END (CTRL_COMPASS_CHILD_BEGIN+2)
|
||||
|
||||
|
||||
// 通过ID号获取控件工程号(模式界面、表盘界面、侧边栏界面属于不同工程号,在UI编译工具上设置)
|
||||
#define ui_id2prj(id) ((((u32)id)>>26) & 0x3f)
|
||||
|
||||
// 通过ID号获取控件页面号(控件所在页面号)
|
||||
#define ui_id2page(id) ((((u32)id)>>17) & 0x1ff)
|
||||
|
||||
// 通过ID号获取控件类型
|
||||
#define ui_id2type(id) ((((u32)id)>>10) & 0x7f)
|
||||
|
||||
// 通过页面序号转换成页面ID
|
||||
#define ui_page2id(id) (((u32)(id)&0x1ff)<<17|(2<<10)|((u32)(id)&0x3ff))
|
||||
|
||||
/***************************************** LUA相关 *****************************************/
|
||||
// lua功能使能开关。注意:ui控件的属性不关,只是不会自动获取lua代码执行
|
||||
// extern const int ENABLE_LUA_VIRTUAL_MACHINE;
|
||||
|
||||
// lua事件类型
|
||||
enum luascript_event_type {
|
||||
LUA_EVENT_ONLOAD = 0,
|
||||
LUA_EVENT_UNLOAD,
|
||||
LUA_EVENT_TOUCH_DOWN,
|
||||
LUA_EVENT_TOUCH_MOVE,
|
||||
LUA_EVENT_TOUCH_R_MOVE,
|
||||
LUA_EVENT_TOUCH_L_MOVE,
|
||||
LUA_EVENT_TOUCH_D_MOVE,
|
||||
LUA_EVENT_TOUCH_U_MOVE,
|
||||
LUA_EVENT_TOUCH_HOLD,
|
||||
LUA_EVENT_TOUCH_UP,
|
||||
LUA_EVENT_ONSHOW,
|
||||
LUA_EVENT_MAX,
|
||||
};
|
||||
|
||||
// lua属性结构
|
||||
struct luascript_code {
|
||||
u16 type;
|
||||
u16 argc;
|
||||
char argv[0];
|
||||
};
|
||||
|
||||
|
||||
|
||||
/***************************************** UI资源相关 *****************************************/
|
||||
// ui资源结构
|
||||
struct element_luascript {
|
||||
u16 num;
|
||||
u16 nop; //FFFF
|
||||
struct luascript_code code[0];
|
||||
};
|
||||
|
||||
struct element_luascript_t {
|
||||
u16 num;
|
||||
u16 nop; //FFFF
|
||||
struct luascript_code *code[LUA_EVENT_MAX];
|
||||
};
|
||||
|
||||
|
||||
// 控件信息头
|
||||
struct ui_ctrl_info_head {
|
||||
u16 type: 7; //curr max : 40
|
||||
u16 ctrl_num: 7; //curr max : 73
|
||||
u16 css_num: 2; //curr max : 2
|
||||
u16 len: 7; //curr max : 71
|
||||
u16 page: 9; //curr max : 113
|
||||
int id; //prj[31..26] page[25..17] ctrlType[16:10] ctrlID[9..0]
|
||||
struct element_css1 *css;
|
||||
}; // 12 bytes
|
||||
|
||||
|
||||
// 图片列表结构
|
||||
struct ui_image_list {
|
||||
u16 num;
|
||||
u16 image_num;
|
||||
u16 image[0];
|
||||
};
|
||||
|
||||
// 文本列表结构
|
||||
struct ui_text_list {
|
||||
u16 num;
|
||||
u16 str_num;
|
||||
char str[0];
|
||||
};
|
||||
|
||||
|
||||
#define UI_IMAGE_MAX_INDEX 128 //图片控件的图片索引最大值, 可手动更改
|
||||
|
||||
struct ui_image_list_t {
|
||||
u16 num; //控件实际图片数量
|
||||
u16 image_num; //image数组的数量
|
||||
u16 image[UI_IMAGE_MAX_INDEX];
|
||||
};
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief BR28手表部分手表客户开发150种运动功能,需扩大多国语言可读取数量
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
#define UI_TEXT_STRPIC_MAX_INDEX 255
|
||||
|
||||
|
||||
#define UI_TEXT_LIST_MAX_NUM 3
|
||||
struct ui_text_list_t {
|
||||
u16 num; //控件实际str数量
|
||||
u16 str_num; //str数组的数量
|
||||
u16 str[UI_TEXT_STRPIC_MAX_INDEX];
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief button控件信息
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct ui_button_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
}; // 12 bytes
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief time控件信息
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct ui_time_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
char source[8];
|
||||
char format[12]; // Y/M/D h:m:s
|
||||
u16 color;
|
||||
u16 hi_color;
|
||||
u16 number[10];
|
||||
u16 delimiter[5];
|
||||
u8 auto_cnt;
|
||||
} __attribute__((packed)); // 67 bytes
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief number控件信息
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct ui_number_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
char source[8];
|
||||
char format[10]; // %04d/%04d
|
||||
u16 color; //RGB565
|
||||
u16 hi_color; //RGB565
|
||||
u16 number[10];// 0~9
|
||||
u16 delimiter[2];
|
||||
u16 space[1];
|
||||
}; // 60 bytes
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief pic控件信息
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct ui_pic_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
char source[8];
|
||||
u8 highlight;
|
||||
u8 play_mode;
|
||||
u16 play_interval;
|
||||
struct ui_image_list *normal_img;
|
||||
struct ui_image_list *highlight_img;
|
||||
}; // 32 bytes
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief battery控件信息
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct ui_battery_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
struct ui_image_list *normal_image;
|
||||
struct ui_image_list *charge_image;
|
||||
}; // 20bytes
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief text控件信息
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
enum ENCODE {
|
||||
UI_TEXT_ENCODE_TEXT,
|
||||
UI_TEXT_ENCODE_ASCII,
|
||||
UI_TEXT_ENCODE_STRPIC,
|
||||
UI_TEXT_ENCODE_MULSTR,
|
||||
UI_TEXT_ENCODE_IMAGE,
|
||||
};
|
||||
enum {
|
||||
UI_TEXT_STRPIC_MODE_IMAGE,
|
||||
UI_TEXT_STRPIC_MODE_INDEX,
|
||||
UI_TEXT_STRPIC_MODE_ENCODE,
|
||||
};
|
||||
|
||||
struct ui_text_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
char source[8]; //考虑br28控件结构的转换,不做调整
|
||||
u16 color; //RGB565
|
||||
u16 highlight_color; //RGB565
|
||||
struct ui_text_list *str;
|
||||
u8 code; //编码方式
|
||||
} __attribute__((packed)); // 29 bytes
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief grid控件信息
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct ui_grid_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
struct layout_info *info; //需要放最后,跟工具绑定
|
||||
u8 page_mode;
|
||||
char highlight_index;
|
||||
} __attribute__((packed)); // 18 bytes
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief slider控件信息
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct ui_slider_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
struct ui_ctrl_info_head *ctrl;
|
||||
u8 step;
|
||||
} __attribute__((packed)); // 17 bytes
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief vslider控件信息
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct ui_vslider_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
struct ui_ctrl_info_head *ctrl;
|
||||
u8 step;
|
||||
} __attribute__((packed)); // 17 bytes
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief watch控件信息
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct ui_watch_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
char source[8];
|
||||
struct ui_ctrl_info_head *ctrl;
|
||||
}; // 24 bytes
|
||||
|
||||
// compass控件信息
|
||||
struct ui_compass_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
char source[8];
|
||||
struct ui_ctrl_info_head *ctrl;
|
||||
}; // 24 bytes
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief progress控件信息
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct ui_progress_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
char source[8];
|
||||
struct ui_ctrl_info_head *ctrl;
|
||||
}; // 24 bytes
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief multiprogress控件信息
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct ui_multiprogress_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
char source[8];
|
||||
struct ui_ctrl_info_head *ctrl;
|
||||
}; // 24 bytes
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief layout控件信息
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct layout_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
union ui_control_info *ctrl;
|
||||
}; // 16 bytes
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief layer控件信息
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct layer_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
struct layout_info *layout;//需要放最后,跟工具绑定
|
||||
} __attribute__((packed)); //17 bytes
|
||||
|
||||
|
||||
union ui_control_info {
|
||||
struct ui_ctrl_info_head head;//16 bytes
|
||||
struct ui_button_info button;//20 bytes
|
||||
struct ui_time_info time;//84 bytes
|
||||
struct ui_number_info number;
|
||||
struct ui_pic_info pic;//36 bytes
|
||||
struct ui_battery_info battery;//28 bytes
|
||||
struct ui_text_info text;//40 bytes
|
||||
struct ui_grid_info grid;//28 bytes
|
||||
struct layer_info layer;
|
||||
struct layout_info layout;
|
||||
struct ui_watch_info watch;
|
||||
struct ui_progress_info progress;
|
||||
struct ui_multiprogress_info multiprogress;
|
||||
struct ui_slider_info slider;
|
||||
struct ui_vslider_info vslider;
|
||||
};//84 bytes
|
||||
|
||||
|
||||
|
||||
struct rect_s {
|
||||
s16 left;
|
||||
s16 top;
|
||||
s16 width;
|
||||
s16 height;
|
||||
};
|
||||
|
||||
struct window_info {
|
||||
u16 type: 7; //curr max : 40
|
||||
u16 ctrl_num: 7; //curr max : 73
|
||||
u16 css_num: 2; //curr max : 2
|
||||
u16 len: 7; //curr max : 71
|
||||
u16 page: 9;
|
||||
struct rect_s rect; //8 bytes
|
||||
struct layer_info *layer;
|
||||
}; //16 bytes
|
||||
|
||||
|
||||
struct control_ops {
|
||||
int type;
|
||||
void *(*new)(const void *, struct element *);
|
||||
/*int (*delete)(void *);*/
|
||||
};
|
||||
|
||||
extern const struct control_ops control_ops_begin[];
|
||||
extern const struct control_ops control_ops_end[];
|
||||
|
||||
|
||||
#define REGISTER_CONTROL_OPS(_type) \
|
||||
static const struct control_ops control_ops_##_type sec(.control_ops) __attribute__((used)) = { \
|
||||
.type = _type,
|
||||
|
||||
|
||||
|
||||
#define get_control_ops_by_type(_type) \
|
||||
({ \
|
||||
const struct control_ops *ops, *ret=NULL; \
|
||||
for (ops = control_ops_begin; ops < control_ops_end; ops++) { \
|
||||
if (ops->type == _type) { \
|
||||
ret = ops; \
|
||||
break; \
|
||||
} \
|
||||
}\
|
||||
ret; \
|
||||
})
|
||||
|
||||
|
||||
/*
|
||||
* 通过事件找到对应控件的lua code
|
||||
* */
|
||||
/* static inline int luascript_code_find(struct element_luascript_t *elm_code, u8 event_type, struct luascript_code **code) */
|
||||
// {
|
||||
// if (!ENABLE_LUA_VIRTUAL_MACHINE) {
|
||||
// return 0;
|
||||
// }
|
||||
// struct luascript_code *lua_code = NULL;
|
||||
|
||||
// for (u8 i = 0; i < elm_code->num; i++) {
|
||||
// lua_code = elm_code->code[i];
|
||||
// if (lua_code->type == event_type) {
|
||||
// // printf("layout luascript_code type:%d\n",lua_code->type);
|
||||
// // printf("layout luascript_code len:%d\n",lua_code->argc);
|
||||
// // printf("layout luascript_code code:\n%s\n",&lua_code->argv);
|
||||
// *code = lua_code;
|
||||
// return 1;
|
||||
// }
|
||||
// // lua_code = (struct luascript_code *)((u32)&lua_code->argv + lua_code->argc);
|
||||
// }
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
// 默认有lua被执行就将touch消息截断,后续不让继续跑。
|
||||
// 由run_lua_string函数控制touch消息是否截断,如果没有lua代码被执行则不截断。
|
||||
/* static inline int lua_touch_event_run(struct element_luascript_t *code, struct element_touch_event *e) */
|
||||
// {
|
||||
// if (!ENABLE_LUA_VIRTUAL_MACHINE) {
|
||||
// return 0;
|
||||
// }
|
||||
// // printf("======lua_touch_event_run:%d\n", e->event);
|
||||
// struct luascript_code *lua_code = NULL;
|
||||
// int type = -1;
|
||||
// switch (e->event) {
|
||||
// case ELM_EVENT_TOUCH_DOWN:
|
||||
// type = LUA_EVENT_TOUCH_DOWN;
|
||||
// break;
|
||||
// case ELM_EVENT_TOUCH_MOVE:
|
||||
// type = LUA_EVENT_TOUCH_MOVE;
|
||||
// break;
|
||||
// case ELM_EVENT_TOUCH_U_MOVE:
|
||||
// type = LUA_EVENT_TOUCH_U_MOVE;
|
||||
// break;
|
||||
// case ELM_EVENT_TOUCH_D_MOVE:
|
||||
// type = LUA_EVENT_TOUCH_D_MOVE;
|
||||
// break;
|
||||
// case ELM_EVENT_TOUCH_L_MOVE:
|
||||
// type = LUA_EVENT_TOUCH_L_MOVE;
|
||||
// break;
|
||||
// case ELM_EVENT_TOUCH_R_MOVE:
|
||||
// type = LUA_EVENT_TOUCH_R_MOVE;
|
||||
// break;
|
||||
// case ELM_EVENT_TOUCH_HOLD:
|
||||
// type = LUA_EVENT_TOUCH_HOLD;
|
||||
// break;
|
||||
// case ELM_EVENT_TOUCH_UP:
|
||||
// type = LUA_EVENT_TOUCH_UP;
|
||||
// break;
|
||||
// }
|
||||
// if (luascript_code_find(code, type, &lua_code)) {
|
||||
// // printf("func: %s %d find lua code\n",__func__,__LINE__ );
|
||||
// return run_lua_string(lua_code->argc, (const char *) &lua_code->argv);
|
||||
// } else {
|
||||
// // printf("not find lua code\n");
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
// // return 1; //err
|
||||
// }
|
||||
|
||||
|
||||
#if 0
|
||||
struct control_event_header {
|
||||
int id;
|
||||
int len;
|
||||
};
|
||||
|
||||
extern struct control_event_header control_event_handler_begin[];
|
||||
extern struct control_event_header control_event_handler_end[];
|
||||
|
||||
|
||||
#define REGISTER_CONTROL_EVENT_HANDLER(control, _id) \
|
||||
static const struct control##_event_handler __##control##_event_handler_##_id \
|
||||
sec(.control_event_handler) = { \
|
||||
.header = { \
|
||||
.id = _id, \
|
||||
.len = sizeof(struct control##_event_handler), \
|
||||
}, \
|
||||
|
||||
|
||||
|
||||
|
||||
static inline void *control_event_handler_for_id(int id)
|
||||
{
|
||||
struct control_event_header *p;
|
||||
|
||||
for (p = control_event_handler_begin; p < control_event_handler_end;) {
|
||||
if (p->id == id) {
|
||||
return p;
|
||||
}
|
||||
p = (u8 *)p + p->len;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,220 @@
|
||||
#ifndef __FONT_ALL_H__
|
||||
#define __FONT_ALL_H__
|
||||
|
||||
#include "generic/typedef.h"
|
||||
#include "font/font_sdfs.h"
|
||||
|
||||
typedef struct {
|
||||
u8 width;
|
||||
u8 size;
|
||||
u16 addr;
|
||||
} ASCSTRUCT;
|
||||
|
||||
typedef struct {
|
||||
unsigned int width: 6;
|
||||
unsigned int height: 6;
|
||||
unsigned int addr: 20;
|
||||
} ASCSTRUCTV2;
|
||||
|
||||
//标志位
|
||||
#define FONT_GET_WIDTH 0x01 /* 获取文本宽度 */
|
||||
#define FONT_SHOW_PIXEL 0x02 /* 显示单行文本 */
|
||||
#define FONT_SHOW_MULTI_LINE 0x04 /* 显示多行文本(默认显示一行) */
|
||||
#define FONT_SHOW_SCROLL 0x08 /* 滚动显示*/
|
||||
#define FONT_HIGHLIGHT_SCROLL 0x10 /* 高亮滚动显示*/
|
||||
#define FONT_VERTICAL_SCROLL 0x20 /* 垂直滚动显示*/
|
||||
#define FONT_SCROLL_CIRCULAR 0x40 /* 首尾相接的环形滚动*/
|
||||
#define FONT_DEFAULT (FONT_SHOW_PIXEL)
|
||||
|
||||
#define FONT_ENCODE_ANSI 0x00 /* 内码格式 */
|
||||
#define FONT_ENCODE_UNICODE 0x01 /* unicode编码格式 */
|
||||
#define FONT_ENCODE_UTF8 0x02 /* utf8编码格式 */
|
||||
|
||||
#define FONT_ENDIAN_BIG 0x00 /* utf16 大端 */
|
||||
#define FONT_ENDIAN_SMALL 0x01 /* utf16 小端 */
|
||||
|
||||
|
||||
extern const int FONT_USE_PTR;
|
||||
extern const int ARABIC_MODE_SWITCH;
|
||||
extern const int HEBREW_MODE_SWITCH;
|
||||
extern const int THAI_MODE_SWITCH;
|
||||
extern const int MYANMAR_MODE_SWITCH;
|
||||
extern const int BENGALI_MODE_SWITCH;
|
||||
extern const int KHMER_MODE_SWITCH;
|
||||
extern const int INDIC_MODE_SWITCH;
|
||||
extern const int TIBETAN_MODE_SWITCH;
|
||||
extern const int MIXLEFT_MODE_SWITCH;
|
||||
extern const int MIXRIGHT_MODE_SWITCH;
|
||||
extern const int FONT_UNIC_SWITCH;
|
||||
|
||||
struct font_file {
|
||||
char *name;
|
||||
FILE *fd;
|
||||
};
|
||||
|
||||
struct font {
|
||||
struct font_file file;
|
||||
u16 nbytes;
|
||||
u8 size;
|
||||
u8 version;
|
||||
u8 *pixelbuf;
|
||||
};
|
||||
|
||||
struct dispbuf {
|
||||
int format;
|
||||
u32 color;
|
||||
void *rect;
|
||||
void *map;
|
||||
};
|
||||
|
||||
enum FONT_STATUS {
|
||||
FT_ERROR_NONE,
|
||||
FT_ERROR_NOPIXFILE = 0x01, //没有字模文件
|
||||
FT_ERROR_NOASCPIXFILE = 0x02, //没有ASCII字模文件
|
||||
FT_ERROR_NOTABFILE = 0x04, //没有TAB文件
|
||||
FT_ERROR_NOMEM = 0x08, //内存不足
|
||||
FT_ERROR_CODEPAGE = 0x10, //代码页错误
|
||||
};
|
||||
|
||||
enum BIT_DEPTH {
|
||||
BIT_DEPTH_1BPP,
|
||||
BIT_DEPTH_2BPP,
|
||||
BIT_DEPTH_4BPP,
|
||||
BIT_DEPTH_8BPP,
|
||||
};
|
||||
|
||||
struct font_info {
|
||||
struct font ascpixel; //ASCII像素
|
||||
struct font pixel; //像素
|
||||
struct font_file tabfile; //UNICODE转内码文件
|
||||
struct font_file extfile; //UNICODE转内码文件
|
||||
u8 sta; //状态
|
||||
u8 ratio; //放大倍数,默认为1
|
||||
u8 language_id; //语言ID
|
||||
u8 bigendian; //大端模式(unicode编码)
|
||||
u8 isgb2312; //是否GB2312,用以区分GBK以及GB2312字库
|
||||
u8 codepage; //代码页
|
||||
u16 x;
|
||||
u16 y;
|
||||
u16 text_width; //文本宽度
|
||||
u16 text_height; //文本高度
|
||||
u16 string_width; //字符串宽度
|
||||
u16 string_height; //字符串高度
|
||||
u16 offset; //显示偏移
|
||||
u32 flags; //标志位
|
||||
|
||||
u8 *text_image_buf; //文本点阵缓存buf
|
||||
u32 text_image_buf_size; //文本点阵缓存buf size
|
||||
u32 text_image_stride; //文本点阵缓存buf对齐宽度
|
||||
u16 text_image_width; //文本点阵缓存buf实际宽度
|
||||
u16 text_image_height; //文本点阵缓存buf实际高度
|
||||
|
||||
struct dispbuf disp; //显示相关信息
|
||||
void (*putchar)(struct font_info *info, u8 *pixel, u16 width, u16 height, u16 x, u16 y);
|
||||
void *dc;
|
||||
u16 line_num;
|
||||
u16 default_code; //字库文件中不存在待显示字符时的默认替换字符编码
|
||||
void *text;
|
||||
short word_space; //补充字间距
|
||||
short line_space; //补充行间距
|
||||
short xpos_offset;
|
||||
short extra_word_space_for_dep;
|
||||
u32 tool_version;
|
||||
int top_extra_fill : 16;
|
||||
int bottom_extra_fill : 15;
|
||||
int mix_start : 1;
|
||||
u16 *each_line_width_info;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
u32 width : 6;
|
||||
u32 height : 7;
|
||||
s32 top : 8;
|
||||
u32 size : 11;
|
||||
s32 left : 7;
|
||||
u32 addr : 25;
|
||||
u8 advance_x;
|
||||
} __attribute__((packed, aligned(1))) UnicInfo_new;
|
||||
|
||||
typedef struct {
|
||||
u8 width;
|
||||
u8 height;
|
||||
s8 left;
|
||||
s8 top;
|
||||
u32 addr;
|
||||
} __attribute__((packed, aligned(1))) UnicInfo_old;
|
||||
|
||||
typedef struct {
|
||||
u8 width;
|
||||
u8 height;
|
||||
s8 left;
|
||||
s8 top;
|
||||
u8 advance_x;
|
||||
} __attribute__((packed, aligned(1))) UnicInfo;
|
||||
|
||||
#define font_ntohl(x) (unsigned long)((x>>24)|((x>>8)&0xff00)|(x<<24)|((x&0xff00)<<8))
|
||||
#define font_ntoh(x) (unsigned short int )((x>>8&0x00ff)|x<<8&0xff00)
|
||||
|
||||
extern const struct font_info font_info_table[];
|
||||
|
||||
|
||||
typedef struct {
|
||||
u8 codepage;
|
||||
u32 ansi_offset;
|
||||
u32 table_offset;
|
||||
} LANG_TABLE;
|
||||
|
||||
|
||||
struct font_new_cb_priv {
|
||||
u8 *pixbuf;
|
||||
u16 color;
|
||||
short x;
|
||||
short y;
|
||||
u16 width;
|
||||
u16 height;
|
||||
u16 bufsize;
|
||||
u16 dis_width;
|
||||
u16 scroll_offset;
|
||||
};
|
||||
|
||||
#define CP874 (1)
|
||||
#define CP937 (2)
|
||||
#define CP1250 (3)
|
||||
#define CP1251 (4)
|
||||
#define CP1252 (5)
|
||||
#define CP1253 (6)
|
||||
#define CP1254 (7)
|
||||
#define CP1255 (8)
|
||||
#define CP1256 (9)
|
||||
#define CP1257 (10)
|
||||
#define CP1258 (11)
|
||||
#define CPKSC (12)
|
||||
#define CPSJIS (13)
|
||||
#define CPBIG5 (14)
|
||||
#define INDIC (15)
|
||||
#define TIBETAN (16)
|
||||
|
||||
/**
|
||||
* @brief 设置内码偏移表,混合内码字库需要 *
|
||||
* @param table 内码偏移表地址
|
||||
* @returns 0
|
||||
*/
|
||||
extern int font_set_offset_table(const LANG_TABLE *table);
|
||||
|
||||
/* 内码偏移表 */
|
||||
extern const LANG_TABLE *lange_info_table;
|
||||
|
||||
|
||||
/**
|
||||
* @brief 获取字库位深
|
||||
*
|
||||
* @returns 字库位深
|
||||
*/
|
||||
extern int Font_GetBitDepth();
|
||||
|
||||
/***************************************************************/
|
||||
|
||||
#include "font/font_textout.h"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef __UI_SDFS_H__
|
||||
#define __UI_SDFS_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "generic/typedef.h"
|
||||
#include "fs/fs.h"
|
||||
|
||||
#define SD_SEEK_SET 0x00
|
||||
#define SD_SEEK_CUR 0x01
|
||||
|
||||
FILE *font_sd_fopen(const char *filename, void *arg);
|
||||
int font_sd_fread(FILE *fp, void *buf, u32 len);
|
||||
int font_sd_fseek(FILE *fp, u8 seek_mode, u32 offset);
|
||||
int font_sd_fclose(FILE *fp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,206 @@
|
||||
#ifndef __FONT_OUT_H__
|
||||
#define __FONT_OUT_H__
|
||||
|
||||
#include "generic/typedef.h"
|
||||
#include "font/font_all.h"
|
||||
#include "font/font_unic.h"
|
||||
|
||||
/**
|
||||
* @brief 打开字库
|
||||
*
|
||||
* @param info:字库信息
|
||||
* @param language:语言id
|
||||
*
|
||||
* @returns TRUE:打开成功 FALSE:打开失败
|
||||
*/
|
||||
struct font_info *font_open(struct font_info *info, u8 language);
|
||||
|
||||
|
||||
/**
|
||||
* @brief 关闭字库,释放相关资源
|
||||
*
|
||||
* @param info
|
||||
*/
|
||||
void font_close(struct font_info *info);
|
||||
|
||||
|
||||
/**
|
||||
* @brief 获取内码字符宽度
|
||||
*
|
||||
* @param info
|
||||
* @param str
|
||||
* @param strlen
|
||||
*
|
||||
* @returns 字符串宽度
|
||||
*/
|
||||
u16 font_text_width(struct font_info *info, u8 *str, u16 strlen);
|
||||
|
||||
|
||||
/**
|
||||
* @brief 获取unicode编码字符宽度
|
||||
*
|
||||
* @param info
|
||||
* @param str
|
||||
* @param strlen
|
||||
*
|
||||
* @returns 字符串宽度
|
||||
*/
|
||||
u16 font_textw_width(struct font_info *info, u8 *str, u16 strlen);
|
||||
|
||||
|
||||
/**
|
||||
* @brief 获取utf8编码字符宽度
|
||||
*
|
||||
* @param info
|
||||
* @param str
|
||||
* @param strlen
|
||||
*
|
||||
* @returns 字符串宽度
|
||||
*/
|
||||
u16 font_textu_width(struct font_info *info, u8 *str, u16 strlen);
|
||||
|
||||
|
||||
/**
|
||||
* @brief 设置字库语言id
|
||||
*
|
||||
* @param language
|
||||
*
|
||||
* @returns
|
||||
*/
|
||||
void font_lang_set(int language);
|
||||
|
||||
|
||||
/**
|
||||
* @brief 获取字库语言id *
|
||||
*
|
||||
* @returns 字库语言id
|
||||
*/
|
||||
int font_lang_get();
|
||||
|
||||
|
||||
// 字库换行方式 value == 1:换行时考虑单词整体性, value == 0:强制换行; 默认为1
|
||||
void font_smart_line_break_set(u8 value);
|
||||
|
||||
|
||||
/**
|
||||
* @brief 字库内码显示接口
|
||||
*
|
||||
* @param info
|
||||
* @param str
|
||||
* @param strlen
|
||||
*
|
||||
* @returns 实际显示的编码长度
|
||||
*/
|
||||
u16 font_textout(struct font_info *info, u8 *str, u16 strlen, u16 x, u16 y);
|
||||
|
||||
|
||||
/**
|
||||
* @brief 字库unicode显示接口
|
||||
*
|
||||
* @param info
|
||||
* @param str
|
||||
* @param strlen
|
||||
* @param x 显示起始x坐标
|
||||
* @param y 显示起始Y坐标
|
||||
*
|
||||
* @returns 实际显示的编码长度
|
||||
*/
|
||||
u16 font_textout_unicode(struct font_info *info, u8 *str, u16 strlen, u16 x, u16 y);
|
||||
|
||||
|
||||
/**
|
||||
* @brief 字库utf8显示接口
|
||||
*
|
||||
* @param info
|
||||
* @param str
|
||||
* @param strlen
|
||||
* @param x 显示起始x坐标
|
||||
* @param y 显示起始Y坐标
|
||||
*
|
||||
* @returns 实际显示的编码长度
|
||||
*/
|
||||
u16 font_textout_utf8(struct font_info *info, u8 *str, u16 strlen, u16 x, u16 y);
|
||||
|
||||
|
||||
/**
|
||||
* @brief utf8转内码
|
||||
*
|
||||
* @param info
|
||||
* @param utf8
|
||||
* @param utf8len
|
||||
* @param ansi
|
||||
*
|
||||
* @returns 内码长度
|
||||
*/
|
||||
u16 font_utf8toansi(struct font_info *info, u8 *utf8, u16 utf8len, u8 *ansi);
|
||||
|
||||
|
||||
/**
|
||||
* @brief utf16转内码
|
||||
*
|
||||
* @param info
|
||||
* @param utf
|
||||
* @param len
|
||||
* @param ansi
|
||||
*
|
||||
* @returns 内码长度
|
||||
*/
|
||||
u16 font_utf16toansi(struct font_info *info, u8 *utf, u16 len, u8 *ansi);
|
||||
|
||||
|
||||
/**
|
||||
* @brief utf8转utf16
|
||||
*
|
||||
* @param info
|
||||
* @param utf8
|
||||
* @param utf8len
|
||||
* @param utf16
|
||||
*
|
||||
* @returns utf16长度
|
||||
*/
|
||||
u16 font_utf8toutf16(struct font_info *info, u8 *utf8, u16 utf8len, u16 *utf16);
|
||||
|
||||
|
||||
/**
|
||||
* @brief 字库层malloc接口,弱函数,用户可自定义
|
||||
*
|
||||
* @param size 申请大小(byte)
|
||||
* @returns buf地址
|
||||
*/
|
||||
void *font_malloc(size_t size);
|
||||
|
||||
|
||||
/**
|
||||
* @brief 字库层zalloc接口,弱函数,用户可自定义
|
||||
*
|
||||
* @param size 申请大小(byte)
|
||||
* @returns buf地址
|
||||
*/
|
||||
void *font_zalloc(size_t size);
|
||||
|
||||
|
||||
/**
|
||||
* @brief 字库层free接口,弱函数,用户可自定义
|
||||
*
|
||||
* @param pv 待释放内存地址
|
||||
*/
|
||||
void font_free(void *pv);
|
||||
|
||||
|
||||
/**
|
||||
* @brief 字库多行显示时用于记录每行宽度信息,多行居中的功能需要
|
||||
*
|
||||
* @param info 字库结构体
|
||||
*/
|
||||
int font_create_each_line_width_info(struct font_info *info);
|
||||
|
||||
|
||||
/**
|
||||
* @brief 字库释放多行信息
|
||||
*
|
||||
* @param info 字库结构体
|
||||
*/
|
||||
void font_release_each_line_width_info(struct font_info *info);
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,95 @@
|
||||
#ifndef __FONT_UNIC_H__
|
||||
#define __FONT_UNIC_H__
|
||||
|
||||
#include "generic/typedef.h"
|
||||
|
||||
#define PIXEL_TO_BASE_LINE(x) (((x)*26/32)+1)
|
||||
|
||||
/* 0xe00->0xe7f:Thai Unicode编码范围 */
|
||||
/* 0x900->0x97f:Indic Unicode编码范围 */
|
||||
/* 0x600->0x6ff:Arabic Unicode编码范围 */
|
||||
/* 0x590->0x5ff:Hebrew Unicode编码范围 */
|
||||
/* 0xf00->0xfff:Tibetan Unicode编码范围 */
|
||||
enum unic_type {
|
||||
UNIC_ERR,
|
||||
UNIC_THAI,
|
||||
UNIC_INDIC,
|
||||
UNIC_ARABIC,
|
||||
UNIC_HEBREW,
|
||||
UNIC_TIBETAN,
|
||||
UNIC_MYANMAR,
|
||||
UNIC_BENGALI,
|
||||
UNIC_KHMER,
|
||||
UNIC_OTHER
|
||||
};
|
||||
|
||||
enum myanmar_type {
|
||||
myanmar_top,
|
||||
myanmar_below,
|
||||
myanmar_103c,
|
||||
myanmar_half,
|
||||
myanmar_follow,
|
||||
myanmar_other,
|
||||
};
|
||||
|
||||
|
||||
int Font_GetCharBits(struct font_info *info, u16 unicode);
|
||||
int Font_GetCharWidth(struct font_info *info, u16 unicode);
|
||||
UnicInfo *Font_GetCharbuf(struct font_info *info, u16 unicode);
|
||||
UnicInfo *Font_GetCharUnicInfo(struct font_info *info, u16 unicode);
|
||||
bool InitFont_Unicode(struct font_info *info);
|
||||
u16 TextOutW_Unicode(struct font_info *info, u8 *str, u16 len, u16 x, u16 y);
|
||||
|
||||
u16 TextOutW_UnicMixRightword(struct font_info *info, u8 *str, u16 len, u16 x, u16 y);
|
||||
u16 TextOutW_UnicMixLeftword(struct font_info *info, u8 *str, u16 len, u16 x, u16 y);
|
||||
|
||||
u8 font_code_inrang(u16 code, const u16 *unicbuf, u16 len);
|
||||
u16 font_left_drawbuf(struct font_info *info, u16(*buffer)[2], int *buffer_data, int *offset_xy);
|
||||
u16 font_left_get_offset(struct font_info *info, u16(*buffer)[2], int *buffer_data, int left_width);
|
||||
u16 font_left_get_width(struct font_info *info, u16(*buffer)[2], u16 len);
|
||||
|
||||
//缅甸语
|
||||
enum myanmar_type font_myanmar_get_type(u16 code);
|
||||
void font_myanmar_update(u16 *unicbuf, u16 len);
|
||||
u16 font_myanmar_replace(struct font_info *info, u16 *unicbuf, u16 len);
|
||||
void find_syllables_myanmar(uint16_t *buffer, uint32_t len, uint8_t *syllable);
|
||||
u16 font_myanmar_drawbuf(struct font_info *info, u16(*buffer)[2], u16 len, int x, int y, int *offset_xy);
|
||||
u16 TextOutW_UnicMyanmar(struct font_info *info, u8 *str, u16 len, u16 x, u16 y);
|
||||
|
||||
//孟加拉语
|
||||
u8 bengali_getBaseType(u16 base);
|
||||
int bengali_getMarkIndex(u16 code);
|
||||
u16 font_bengali_type4_replace(struct font_info *info, u16 *unicbuf, u16 len);
|
||||
u16 font_bengali_type6_replace(struct font_info *info, u16 *unicbuf, u16 len);
|
||||
void bengali_getOffset(u16 text, u16 prev_text, s8 *offsety);
|
||||
u16 font_bengali_reorder(struct font_info *info, u16 *unicbuf, u16 len);
|
||||
u16 font_bengali_drawbuf(struct font_info *info, u16(*buffer)[2], u16 len, int x, int y, int *offset_xy);
|
||||
u16 TextOutW_UnicBengali(struct font_info *info, u8 *str, u16 len, u16 x, u16 y);
|
||||
|
||||
//高棉语
|
||||
u16 font_khmer_get_mark_type(u16 *curr, u16 *prev, u16 *next);
|
||||
u16 font_khmer_replace(struct font_info *info, u16 *unicbuf, u16 len);
|
||||
u16 font_khmer_reorder(struct font_info *info, u16 *unicbuf, u16 len);
|
||||
u16 font_khmer_drawbuf(struct font_info *info, u16(*buffer)[2], u16 len, int x, int y, int *offset_xy);
|
||||
u16 TextOutW_UnicKhmer(struct font_info *info, u8 *str, u16 len, u16 x, u16 y);
|
||||
|
||||
//希伯来语
|
||||
u16 TextOutW_Hebrew(struct font_info *info, u8 *str, u16 len, u16 x, u16 y);
|
||||
u16 TextOutW_UnicHebrew(struct font_info *info, u8 *str, u16 len, u16 x, u16 y);
|
||||
|
||||
//藏语
|
||||
u16 TextOutW_Tibetan(struct font_info *info, u8 *str, u16 len, u16 x, u16 y);
|
||||
u16 TextOutW_UnicTibetan(struct font_info *info, u8 *str, u16 len, u16 x, u16 y);
|
||||
u16 font_tibetan_drawbuf(struct font_info *info, u16(*buffer)[2], u16 len, int x, int y, int *offset_xy);
|
||||
u16 TextW_TibetanReplace(struct font_info *info, u16 *str_buf, u16 len);
|
||||
|
||||
//印地语
|
||||
u16 TextOutW_Indic(struct font_info *info, u8 *str, u16 len, u16 x, u16 y);
|
||||
u16 TextOutW_UnicIndic(struct font_info *info, u8 *str, u16 len, u16 x, u16 y);
|
||||
void find_syllables_indic(uint16_t *buffer, uint32_t len, uint8_t *syllable);
|
||||
u16 TextW_IndicReorder(struct font_info *info, u8 *str, u16 len);
|
||||
u16 TextW_IndicReplace(struct font_info *info, u8 *str, u16 len);
|
||||
u16 font_indic_drawbuf(struct font_info *info, u16(*buffer)[2], u16 len, int x, int y, int *offset_xy);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
#ifndef __LANGUAGE_LIST_H__
|
||||
#define __LANGUAGE_LIST_H__
|
||||
|
||||
#define Chinese_Simplified 1 //简体中文
|
||||
#define Chinese_Traditional 2 //繁体中文
|
||||
#define Japanese 3 //日语
|
||||
#define Korean 4 //韩语
|
||||
#define English 5 //英语
|
||||
#define French 6 //法语
|
||||
#define German 7 //德语
|
||||
#define Italian 8 //意大利语
|
||||
#define Dutch 9 //荷兰语
|
||||
#define Portuguese 10 //葡萄牙语
|
||||
#define Spanish 11 //西班牙语
|
||||
#define Swedish 12 //瑞典语
|
||||
#define Czech 13 //捷克语
|
||||
#define Danish 14 //丹麦语
|
||||
#define Polish 15 //波兰语
|
||||
#define Russian 16 //俄语
|
||||
#define Turkey 17 //土耳其语
|
||||
#define Hebrew 18 //希伯来语
|
||||
#define Thai 19 //泰语
|
||||
#define Hungarian 20 //匈牙利语
|
||||
#define Romanian 21 //罗马尼亚语
|
||||
#define Arabic 22 //阿拉伯语
|
||||
#define Vietnam 23 //越南语
|
||||
#define Malay 24 //马来语
|
||||
#define Tibetan 25 //藏文
|
||||
#define Indic 26 //印地语
|
||||
#define Myanmar 27 //缅甸语
|
||||
#define Bengali 28 //孟加拉语
|
||||
#define Khmer 29 //高棉语
|
||||
|
||||
#define MixAllLanguage 60 //混合语言
|
||||
#define UnicodeMixRightword 61 //Unicode正向混合
|
||||
#define UnicodeMixLeftword 62 //Unicode反向混合
|
||||
#define Unicode 63 //Unicode
|
||||
#endif
|
||||
@@ -0,0 +1,151 @@
|
||||
#ifndef __GIF_H__
|
||||
#define __GIF_H__
|
||||
|
||||
#include "typedef.h"
|
||||
#include "gpu_port.h"
|
||||
#include "res/resfile.h"
|
||||
#include "generic/list.h"
|
||||
|
||||
enum {
|
||||
COMPRESS_LOW, //低压缩,省SRAM,NorFlash不需要PSRAM
|
||||
COMPRESS_MIDDLE, //中压缩,是否需要PSRAM视GIF图片而定
|
||||
COMPRESS_HIGH, //高压缩,省Flash, 需要PSRAM
|
||||
};
|
||||
|
||||
struct gif_file_info {
|
||||
u16 width;
|
||||
u16 height;
|
||||
u16 frame_num;
|
||||
u16 delay;
|
||||
u16 version;
|
||||
};
|
||||
|
||||
struct gif_frame_info {
|
||||
u16 x;
|
||||
u16 y;
|
||||
u16 width;
|
||||
u16 height;
|
||||
u32 addr;
|
||||
u32 size;
|
||||
int type;
|
||||
int compress;
|
||||
u16 delay;
|
||||
u8 *buf;
|
||||
u8 *lut;
|
||||
};
|
||||
|
||||
struct gif_file {
|
||||
void *fp; //资源文件句柄
|
||||
int offset; //数据在资源文件里的偏移
|
||||
int flash_addr; //文件在flash中的起始地址
|
||||
int len; //数据长度
|
||||
void *file_info; //norflash地址映射表信息
|
||||
int extern_file_info; //外部file_info
|
||||
int (*read)(void *, int, u8 *, int);//自定义读接口
|
||||
};
|
||||
|
||||
typedef void *(*GIF_CACHE_CB)(void *, pJLGPUTaskParam_t, void *, int);
|
||||
typedef void (*GIF_TIMER_CB)(void *);
|
||||
|
||||
struct gif_info {
|
||||
u16 gif_timer_id;
|
||||
u16 gif_frame_num;
|
||||
u16 gif_frame_index;
|
||||
u16 gif_frame_last_index;
|
||||
u16 gif_frame_main_index;
|
||||
u16 gif_delay;
|
||||
u8 *gif_palette1;
|
||||
u8 *gif_dec_buf;
|
||||
u8 *gif_palette2;
|
||||
struct gif_file gif_file;
|
||||
u32 gif_addr;
|
||||
u32 gif_size;
|
||||
|
||||
u8 *gif_keyframe_mmu_tab_base;
|
||||
u8 *gif_keyframe_addr;
|
||||
u32 gif_keyframe_size;
|
||||
int priority;
|
||||
|
||||
//gpu
|
||||
pJLGPUTaskHead_t head;
|
||||
gpu_matrix_t *matrix;
|
||||
struct rect draw; // gif绘制区域
|
||||
struct rect rect;
|
||||
u32 element_id;
|
||||
u32 task_id;
|
||||
|
||||
u8 gif_type;
|
||||
u8 gif_compress;
|
||||
u16 gif_version;
|
||||
|
||||
u8 *gif_buf;
|
||||
u8 task_prior;
|
||||
u8 play_single;
|
||||
|
||||
//nandflash
|
||||
void *fp;
|
||||
int index;
|
||||
GIF_CACHE_CB cache_data_cb;
|
||||
|
||||
|
||||
//scale、rotate
|
||||
u8 ratio_en;
|
||||
u8 rotate_en;
|
||||
s16 rotate_cx; // 旋转参数,rotate_en使能时有效
|
||||
s16 rotate_cy;
|
||||
s16 rotate_dx;
|
||||
s16 rotate_dy;
|
||||
float rotate_angle;
|
||||
float ratio_w; // 缩放参数,scale_en使能时有效
|
||||
float ratio_h;
|
||||
};
|
||||
|
||||
struct gif_timer {
|
||||
struct list_head head;
|
||||
pJLGPUTaskUnit_t task;
|
||||
int page;
|
||||
u16 timer_id;
|
||||
u32 element_id;
|
||||
u32 task_id;
|
||||
};
|
||||
|
||||
|
||||
struct gif_param {
|
||||
struct gif_file *file;
|
||||
struct gif_file_info *file_info;
|
||||
struct gif_frame_info *frame_info;
|
||||
pJLGPUTaskUnit_t p;
|
||||
GIF_TIMER_CB gif_timer_cb;
|
||||
pJLGPUTaskHead_t head;
|
||||
pJLGPUTaskParam_t gpu_param;
|
||||
struct rect *rect;
|
||||
struct rect *draw;
|
||||
void *fp;
|
||||
int index;
|
||||
u32 keyframe_addr;
|
||||
GIF_CACHE_CB cache_data_cb;
|
||||
u8 ratio_en;
|
||||
u8 rotate_en;
|
||||
s16 rotate_cx; // 旋转参数,rotate_en使能时有效
|
||||
s16 rotate_cy;
|
||||
s16 rotate_dx;
|
||||
s16 rotate_dy;
|
||||
float rotate_angle;
|
||||
float ratio_w; // 缩放参数,scale_en使能时有效
|
||||
float ratio_h;
|
||||
};
|
||||
|
||||
int gif_read_head_info(struct gif_file *file, struct gif_file_info *file_info, struct gif_frame_info *frame_info);
|
||||
struct gif_timer *gif_decode_init(struct gif_param *gif_param);
|
||||
int gif_decode(int element_id, int task_id);
|
||||
int gif_decode_uninit(int element_id, int task_id, const char *task_name, int (*gif_msg_type)());
|
||||
struct gif_info *gif_info_get(int element_id, int task_id);
|
||||
int gif_info_del(int element_id, int task_id);
|
||||
void gif_task_delete(pJLGPUTaskHead_t head, int element_id, int task_id);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
/* Copyright(C) 2010- , JIELI TECHNOLOGY, Inc.
|
||||
* All right reserved.
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @file layer.h
|
||||
*
|
||||
* @brief 图层控件API头文件
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version V2.0.1
|
||||
*
|
||||
* @date 2022-12-14
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __UI_LAYER_WIDGET_H__
|
||||
#define __UI_LAYER_WIDGET_H__
|
||||
|
||||
|
||||
#include "jlui/layout.h"
|
||||
#include "jlui/control.h"
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 图层控件句柄结构形式
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct layer {
|
||||
struct element elm; //must be first
|
||||
|
||||
u8 inited/* : 1 */; // 是否初始化标志
|
||||
u8 highlight/* : 1 */; // 是否高亮标志
|
||||
u8 css_num/* : 2 */; // 属性数量,UI资源存储用 2bit,这里为对齐用 6bit
|
||||
u8 ctrl_num/* : 7 */; // 控件数量,UI资源存储用 7bit,这里为对齐用 8bit
|
||||
// 这里对齐 32bit
|
||||
|
||||
u32 css[2]; // 属性指针
|
||||
struct draw_context dc; // DC 结构体,一个图层只有一个,目前一个页面指允许一个图层,则DC指针也只有一个
|
||||
struct layout *layout; // 子控件、布局指针,图层下只能放布局
|
||||
const struct layer_info *info; // 图层信息指针,从flash获取的UI框架控件信息
|
||||
const struct element_event_handler *handler; // 回调句柄,由应用层注册,不可省略
|
||||
}; // 312 byte
|
||||
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief layer_for_id 通过图层ID获取图层控件句柄
|
||||
*
|
||||
* @param id 图层控件ID
|
||||
*
|
||||
* @return layer 图层控件句柄
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
#define layer_for_id(id) \
|
||||
ui_element_for_id(id, struct layer)
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief layer_new 创建图层(内部调用)
|
||||
*
|
||||
* @param info 图层控件信息
|
||||
* @param num 图层数量
|
||||
* @param parent 父控件
|
||||
*
|
||||
* @return layer 图层句柄
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct layer *layer_new(struct layer_info *info, int num, struct element *parent);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief layer_delete_probe 准备删除图层(内部调用)
|
||||
*
|
||||
* @param layer
|
||||
* @param num
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void layer_delete_probe(struct layer *layer, int num);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief layer_delete 删除图层(内部调用)
|
||||
*
|
||||
* @param layer
|
||||
* @param num
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void layer_delete(struct layer *layer, int num);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief layer_show 显示图层控件
|
||||
*
|
||||
* @param id 图层控件ID
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int layer_show(int id);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief layer_hide 隐藏图层控件
|
||||
*
|
||||
* @param id 图层控件ID
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int layer_hide(int id);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief layer_toggle 图层的显示、隐藏状态切换。原来为显示则设置为隐藏,原来为隐藏则设置为显示。
|
||||
*
|
||||
* @param id 图层控件的ID
|
||||
*
|
||||
* @return 0 隐藏,1 显示,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int layer_toggle(int id);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
/* Copyright(C) 2010- , JIELI TECHNOLOGY, Inc.
|
||||
* All right reserved.
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @file layout.h
|
||||
*
|
||||
* @brief 布局控件API头文件
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version
|
||||
*
|
||||
* @date 2022-12-14
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __UI_LAYOUT_WIDGET_H__
|
||||
#define __UI_LAYOUT_WIDGET_H__
|
||||
|
||||
|
||||
#include "jlui/ui_core.h"
|
||||
#include "jlui/control.h"
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 布局控件句柄结构
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct layout {
|
||||
struct element elm; //must be first
|
||||
u8 inited; // 是否初始化,只有 true、false 两种状态
|
||||
u8 release; // 子layout是否在onchange中释放标志,目前只有是、否两种状态
|
||||
// 空2byte
|
||||
struct layout *layout; // 子控件指针
|
||||
const struct layout_info *info; // layout info,从flash读进来
|
||||
const struct element_event_handler *handler; // 回调句柄
|
||||
}; // 80byte
|
||||
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief layout_for_id 通过布局ID获取布局控件句柄
|
||||
*
|
||||
* @param id 布局控件ID
|
||||
*
|
||||
* @return layout布局控件句柄
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
#define layout_for_id(id) \
|
||||
ui_element_for_id(id, struct layout)
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief layout_new 创建layout控件(内部调用)
|
||||
*
|
||||
* @param info 布局控件信息
|
||||
* @param num 布局控件数量
|
||||
* @param parent 父控件句柄
|
||||
*
|
||||
* @return layout 布局控件句柄
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct layout *layout_new(struct layout_info *, int, struct element *);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief layout_delete_probe 布局控件准备删除(内部调用)
|
||||
*
|
||||
* @param layout 带删除布局控件
|
||||
* @param num 布局控件数量
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void layout_delete_probe(struct layout *layout, int num);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief layout_delete 删除布局控件(内部调用)
|
||||
*
|
||||
* @param layout 布局控件句柄
|
||||
* @param num 布局控件数量
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void layout_delete(struct layout *layout, int num);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief layout_show 显示布局控件
|
||||
*
|
||||
* @param id 布局控件ID
|
||||
*
|
||||
* @return 0 正常,-22控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int layout_show(int id);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief layout_hide 隐藏布局控件
|
||||
*
|
||||
* @param id 布局控件ID
|
||||
*
|
||||
* @return 0 正常,-22控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int layout_hide(int id);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief layout_toggle 布局控件显示状态切换,显示时切换为隐藏,隐藏时切换为显示
|
||||
*
|
||||
* @param id 布局控件ID
|
||||
*
|
||||
* @return 0 隐藏,1 显示,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int layout_toggle(int id);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief layout_on_focus 布局控件聚焦,将指定布局控件设置为焦点
|
||||
*
|
||||
* @param layout 布局控件句柄
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void layout_on_focus(struct layout *layout);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief layout_lose_focus 布局控件失焦,将布局控件焦点释放
|
||||
*
|
||||
* @param layout 布局控件句柄
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void layout_lose_focus(struct layout *layout);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
#ifndef _LYRICS_H_
|
||||
#define _LYRICS_H_
|
||||
|
||||
#include "typedef.h"
|
||||
#include "utils/fs/fs.h"
|
||||
|
||||
#define LRC_SIZEOF_ALIN(var, al) ((((var)+(al)-1)/(al))*(al))
|
||||
|
||||
//类型声明区
|
||||
typedef struct _TIME_LABEL { /*时间标签信息[mm:ss.ms]*/
|
||||
u16 dbtime_s; //time of label,unit:s
|
||||
u8 btime_100ms; //time of label,unit:ms
|
||||
u8 btext_len; //the length of lrc content, 占用的实际字节数
|
||||
u32 wline_pos; //for record next (byte addr) after the (real label of time)
|
||||
} TIME_LABEL;
|
||||
|
||||
typedef struct __LRC_FILE_IO {
|
||||
int(*seek)(FILE *file, int offset, int orig);
|
||||
int(*read)(FILE *file, void *buf, u32 len);
|
||||
} LRC_FILE_IO;
|
||||
|
||||
typedef struct _LABEL_INFO { /*标签处理后信息*/
|
||||
u16 dbtime_base; //first of time
|
||||
u16 dbtime_limit; //end of time
|
||||
u8 base_100ms; //first of time
|
||||
u8 limit_100ms; //first of time
|
||||
u16 dblabel_cnt; //(real label of time) count
|
||||
TIME_LABEL *g_plabel_buf; //解析过程中时间标签存储buf
|
||||
u8 *plabel_buf_tmp;
|
||||
u16 plabel_buf_len; //解析过程中时间标签存储buf长度
|
||||
} LABEL_INFO;
|
||||
|
||||
|
||||
|
||||
typedef struct _SORTING_INFO { /*文件解析信息*/
|
||||
u16 dbnow_fp_addr;//current addr of file pointer
|
||||
u8 bdata_len; //the length of lrc content
|
||||
u8 bis_next_file;//jump to next file
|
||||
} SORTING_INFO;
|
||||
|
||||
|
||||
typedef struct __LRC_FILE {
|
||||
void *hdl;
|
||||
LRC_FILE_IO *_io;
|
||||
} LRC_FILE;
|
||||
|
||||
|
||||
|
||||
typedef struct _LRC_INFO { ///</*lrc显示信息*/
|
||||
u8 coding_type; ///<歌词unicode编码格式
|
||||
///<显示相关的
|
||||
u8 bis_lrc_update; ///<lrc显示歌词更新标志
|
||||
u8 broll_speed_control; ///<lrc显示滚动速度控制标志
|
||||
u8 blcd_roll_speed; ///<lcd显示歌词内容滚动速度
|
||||
u8 content_len; ///<当前歌词内容长度
|
||||
u8 lrc_data_len; ///<实际歌词显示内容长度
|
||||
|
||||
//CFG
|
||||
u16 blrc_buf_len; ///<lrc显示内容buf长度,配置
|
||||
u8 *blrc_buf; ///<lrc显示内容buf地址
|
||||
|
||||
///<file相关的,CFG
|
||||
u8 *lrc_read_buf; ///<lrc读取数据buffer
|
||||
LRC_FILE file; ///lrc文件操作控制
|
||||
/* void *lrc_file_hdl; ///<lrc文件句柄 */
|
||||
u32 cur_faddr; ///当前文件文件位置
|
||||
u16 once_read_len; ///<一次读取的长度,需要配置
|
||||
u16 real_len; ///<真实一次读取到的数据长度
|
||||
u16 data_len_count; ///<缓存中已分析的数据offset
|
||||
u16 label_id; ///<时间标签读取id(0~)
|
||||
u16 lrc_label_len; ///<解析后标签数据长度
|
||||
|
||||
|
||||
bool bfirst_lable; ///<第一个时间标签标记
|
||||
bool blast_lable; ///<最后一个时间标签标记
|
||||
u8 lrc_text_id; ///text id
|
||||
u8 read_next_lrc_flag; ///是否预读下一条歌词lrc
|
||||
u8 save_flash;
|
||||
SORTING_INFO *sorting; ///<歌词文件解析信息
|
||||
LABEL_INFO *lab_info; ///<标签处理后信息
|
||||
|
||||
void (*roll_speed_ctrl_cb)(u8 lrc_len, u32 time_gap, u8 *roll_speed);///翻页速度控制
|
||||
void (*clr_lrc_disp_cb)(void);
|
||||
|
||||
} LRC_INFO;
|
||||
|
||||
|
||||
|
||||
typedef struct __LRC_CFG {
|
||||
u16 once_read_len;///一次读取长度配置
|
||||
u16 once_disp_len;///一次显示缓存长度配置
|
||||
u16 label_temp_buf_len;///时间标签缓存总长度配置
|
||||
u8 lrc_text_id; ///text id
|
||||
u8 read_next_lrc_flag; ///是否预读下一条歌词lrc
|
||||
u8 enable_save_lable_to_flash;//使能保存时间标签到flash,主要是解决长歌词文件不支持问题
|
||||
void (*roll_speed_ctrl_cb)(u8 lrc_len, u32 time_gap, u8 *roll_speed);///速度控制配置
|
||||
void (*clr_lrc_disp_cb)(void);///清屏回调
|
||||
} LRC_CFG;
|
||||
|
||||
|
||||
extern void lrc_destroy(void);
|
||||
extern int lrc_param_init(LRC_CFG *cfg, u8 *lrc_info_buf);
|
||||
extern bool lrc_analysis(void *lrc_handle, const LRC_FILE_IO *file_io);
|
||||
extern bool lrc_get(u16 dbtime_s, u8 btime_100ms);
|
||||
extern bool lrc_show(int text_id, u16 dbtime_s, u8 btime_100ms);
|
||||
|
||||
enum {
|
||||
LRC_GBK = 0, //内码
|
||||
LRC_UTF16_S, //unicode小端码
|
||||
LRC_UTF16_B, //unicode大端码
|
||||
LRC_UTF8,
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/* Copyright(C) 2010- , JIELI TECHNOLOGY, Inc.
|
||||
* All right reserved.
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @file p.h
|
||||
*
|
||||
* @brief 杰理UI文本操作
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version V1.0.0
|
||||
*
|
||||
* @date 2024-06-13
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __UI_P_TEXT_H__
|
||||
#define __UI_P_TEXT_H__
|
||||
|
||||
#include "jlui/ui_core.h"
|
||||
|
||||
|
||||
struct ui_str {
|
||||
const char *format;
|
||||
char *str;
|
||||
};
|
||||
|
||||
|
||||
struct element_text {
|
||||
struct element elm; //must be first
|
||||
char *str;
|
||||
// const char *format;
|
||||
|
||||
void *priv;
|
||||
u32 x_interval: 8; // 字符间隔
|
||||
u32 format : 3; // 编码格式,与UI资源同步
|
||||
u32 unused : 5; // 5bit暂未使用
|
||||
u32 color: 16; // 使用RGB565,这里多8byte保留
|
||||
const struct element_event_handler *handler;
|
||||
};
|
||||
|
||||
|
||||
void text_element_set_text(struct element_text *text, char *str,
|
||||
int format, int color);
|
||||
|
||||
|
||||
void text_element_init(struct element_text *text, int id, u8 page, u8 prj, u8 css_num,
|
||||
const struct element_css1 *css
|
||||
);
|
||||
|
||||
|
||||
void text_element_set_event_handler(struct element_text *text, void *priv,
|
||||
const struct element_event_handler *handler);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
#ifndef FONT_ASCII_H
|
||||
#define FONT_ASCII_H
|
||||
|
||||
|
||||
#include "typedef.h"
|
||||
|
||||
|
||||
void font_ascii_get_width_and_height(char code, int *height, int *width);
|
||||
int font_ascii_get_pix(char code, u8 *pixbuf, int buflen, int *height, int *width);
|
||||
|
||||
int font_ascii_width_check(const char *str);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
#ifndef _JPEG_DECODER_H_
|
||||
#define _JPEG_DECODER_H_
|
||||
|
||||
#include "typedef.h"
|
||||
#include "system/task.h"
|
||||
#include "generic/rect.h"
|
||||
|
||||
extern u16 QT_TBL[0x80];
|
||||
extern u16 STD_HUFFMAN_TBL[258];
|
||||
|
||||
#define QTAB_ADDR ((s16 *)(QT_TBL))
|
||||
#define HTAB_DC0_ADDR ((u16 *)((u8*)STD_HUFFMAN_TBL)) // 0x30
|
||||
#define HTAB_AC0_ADDR ((u16 *)((u8*)STD_HUFFMAN_TBL + 0x30)) // 0xd2
|
||||
#define HTAB_DC1_ADDR ((u16 *)((u8*)STD_HUFFMAN_TBL + 0x30 + 0xd2)) // 0x30
|
||||
#define HTAB_AC1_ADDR ((u16 *)((u8*)STD_HUFFMAN_TBL + 0x30 + 0xd2 + 0x30)) // 0xd2
|
||||
|
||||
|
||||
#define JPG_SAMP_FMT_INVALID 0x0
|
||||
#define JPG_SAMP_FMT_YUV444 0x1
|
||||
#define JPG_SAMP_FMT_YUV422 0x2
|
||||
#define JPG_SAMP_FMT_YUV420 0x3
|
||||
|
||||
|
||||
#define jpg_be16_to_cpu(x) (((x)[0] << 8) | (x)[1])
|
||||
|
||||
#define SINGLE_BUFFER_MODE 0x0
|
||||
#define DOUBLE_BUFFER_MODE 0x1
|
||||
|
||||
|
||||
enum {
|
||||
RGB888,
|
||||
RGB565,
|
||||
};
|
||||
|
||||
struct jpeg_yuv {
|
||||
u8 *y;
|
||||
u8 *u;
|
||||
u8 *v;
|
||||
};
|
||||
|
||||
struct jpeg_data {
|
||||
u8 *buf;
|
||||
u32 len;
|
||||
};
|
||||
|
||||
struct jpeg_codec_handle {
|
||||
JL_JPG_TypeDef *reg;
|
||||
struct jpeg_decoder_fd *decoder_fd;
|
||||
OS_SEM sem;
|
||||
};
|
||||
|
||||
enum std_markers {
|
||||
DQT = 0xDB,
|
||||
SOF = 0xC0,
|
||||
DHT = 0xC4,
|
||||
SOI = 0xD8,
|
||||
SOS = 0xDA,
|
||||
RST = 0xD0,
|
||||
RST7 = 0xD7,
|
||||
EOI = 0xD9,
|
||||
DRI = 0xDD,
|
||||
APP0 = 0xE0,
|
||||
};
|
||||
|
||||
struct decoder_info {
|
||||
u16 x;
|
||||
u16 y;
|
||||
u16 x_mcu_num;
|
||||
u16 y_mcu_num;
|
||||
u16 x_mcu_cnt;
|
||||
u16 y_mcu_cnt;
|
||||
u8 mcu_h;
|
||||
u8 samp_Y;
|
||||
u8 htab_Y;
|
||||
u8 htab_Cr;
|
||||
u8 htab_Cb;
|
||||
u8 qtab_Y;
|
||||
u8 qtab_Cr;
|
||||
u8 qtab_Cb;
|
||||
u8 y_cnt;
|
||||
};
|
||||
|
||||
|
||||
typedef u8 *(*jpg_stream_input)(void *__fat_info, u32 *len, u32 offset_4k);
|
||||
|
||||
struct jpeg_decoder_fd {
|
||||
void *parent;
|
||||
struct decoder_info info;
|
||||
struct jpeg_yuv yuv;
|
||||
struct jpeg_yuv yuv0;
|
||||
struct jpeg_yuv yuv1;
|
||||
struct jpeg_data data;
|
||||
u32 mcu_num;
|
||||
u32 head_len;
|
||||
u8 *stream;
|
||||
//u8 *stream_end;
|
||||
u8 *cur_stream;
|
||||
u32 bits_cnt;
|
||||
u32 cur_bits_cnt;
|
||||
u8 yuv_type;
|
||||
u8 last_rst_marker_seen;
|
||||
u8 DRI_enable;
|
||||
u8 next_rst;
|
||||
u8 rst_flag;
|
||||
u8 mcupnd_flag;
|
||||
u32 next_rst_bits_cnt;
|
||||
u32 restart_interval;
|
||||
u32 rst_mcu_cnt;
|
||||
u16 row_mcu_num;
|
||||
u8 rgb_format;
|
||||
u16 seg_idx;
|
||||
u16 seg_num;
|
||||
// u16 lcd_width;
|
||||
// u16 lcd_height;
|
||||
u16 need_dec_mcu_num;
|
||||
u8 data_out_mode;
|
||||
u8 buf_flag;
|
||||
u8 *fb;
|
||||
u8 *fb0;
|
||||
u8 *fb1;
|
||||
u8 *hbuf;
|
||||
u8 fend;
|
||||
u8 stop_flag;
|
||||
u8 head_buf[512];
|
||||
u8 fd_free_enable;
|
||||
void *fat_info;
|
||||
jpg_stream_input jpg_ginfo_cb;
|
||||
u32 fb_size;
|
||||
u8 *jpg_obuf;
|
||||
struct rect cur_draw;
|
||||
struct rect draw_rect;
|
||||
struct rect jpeg_rect;
|
||||
};
|
||||
|
||||
int jpeg_dec_init(void *fat_info, u8 lcd_format, jpg_stream_input jpg_ginfo_cb);
|
||||
int jpeg_dec_start(struct rect *cur_draw, struct rect *draw_rect, struct rect *jpeg_rect, void *dec_out_buf);
|
||||
struct jpeg_decoder_fd *jpeg_dec_get_fd();
|
||||
void jpeg_dec_stop();
|
||||
void jpeg_dec_uninit();
|
||||
int jpeg_decoder_open(struct jpeg_decoder_fd *fd);
|
||||
int _jpeg_parse_header(struct jpeg_decoder_fd *fd, u8 *buf, int len);
|
||||
int jpeg_decode_area(struct jpeg_decoder_fd *decoder_fd);
|
||||
int jpeg_decoder_start(void *_fd);
|
||||
int jpeg_decoder_init(struct jpeg_decoder_fd *fd);
|
||||
int decoder_bits_pnd_handler(struct jpeg_decoder_fd *fd);
|
||||
int decoder_mcu_pnd_handler(struct jpeg_decoder_fd *fd);
|
||||
int jpeg_decoder_manual_start(void *_fd);
|
||||
int jpeg_decoder_close(void *fd);
|
||||
int jpeg_codec_init(void);
|
||||
|
||||
extern u8 *jpg_ginfo(void *__fat_info, u32 *len, u32 offset_4k);
|
||||
|
||||
int ui_jpeg_decoder_init();
|
||||
int ui_jpeg_decoder_uninit();
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,38 @@
|
||||
#ifndef MEM_VAR_H
|
||||
#define MEM_VAR_H
|
||||
|
||||
#include "typedef.h"
|
||||
#include "generic/list.h"
|
||||
|
||||
struct mem_var_element {
|
||||
u16 crc;
|
||||
u16 checksum;
|
||||
u16 len;
|
||||
u8 buf[0];
|
||||
};
|
||||
|
||||
struct mem_var {
|
||||
struct list_head head;
|
||||
struct mem_var_element var;
|
||||
};
|
||||
|
||||
struct mem_var_head {
|
||||
struct list_head head;
|
||||
int total_mem_size;
|
||||
int items;
|
||||
int use_mem_size;
|
||||
int hits;
|
||||
u8 debug;
|
||||
};
|
||||
|
||||
extern struct mem_var_head var_list;
|
||||
|
||||
void mem_var_init(u32 size, u8 debug);
|
||||
int mem_var_add(u32 index, u32 type, u32 id, u32 page, u32 prj, u8 *buf, u16 len);
|
||||
void mem_var_free();
|
||||
int mem_var_del(struct mem_var *var);
|
||||
void mem_var_get(struct mem_var *var, u8 *buf, u16 len);
|
||||
struct mem_var *mem_var_search(u32 index, u32 type, u32 id, u32 page, u32 prj);
|
||||
void mem_var_stat();
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,227 @@
|
||||
#ifndef RESFILE_H
|
||||
#define RESFILE_H
|
||||
|
||||
#include "typedef.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs/sdfile.h"
|
||||
|
||||
// resfile共用文件句柄
|
||||
#if (defined(CONFIG_CPU_BR23) && defined(CONFIG_APP_WATCH))
|
||||
#define RESFILE_COMMON_HDL_EN 0
|
||||
#else
|
||||
#define RESFILE_COMMON_HDL_EN 0
|
||||
#endif
|
||||
|
||||
#define FILE_TYPE_JPEG 5
|
||||
|
||||
#ifndef AT_UI_RAM
|
||||
#define AT_UI_RAM //AT(.ui_ram)
|
||||
#endif
|
||||
|
||||
//文本数据格式
|
||||
enum {
|
||||
TEXT_1BPP,
|
||||
TEXT_2BPP,
|
||||
TEXT_4BPP,
|
||||
TEXT_8BPP,
|
||||
};
|
||||
|
||||
|
||||
//图像数据格式
|
||||
enum {
|
||||
PIXEL_FMT_ARGB8888,
|
||||
PIXEL_FMT_ARGB8565,
|
||||
PIXEL_FMT_ARGB1555,
|
||||
PIXEL_FMT_ARGB4444,
|
||||
PIXEL_FMT_RGB888,
|
||||
PIXEL_FMT_RGB565,
|
||||
PIXEL_FMT_AL88,
|
||||
PIXEL_FMT_AL44,
|
||||
PIXEL_FMT_AL22,
|
||||
PIXEL_FMT_L8,
|
||||
PIXEL_FMT_L4,
|
||||
PIXEL_FMT_L2,
|
||||
PIXEL_FMT_L1,
|
||||
PIXEL_FMT_A8,
|
||||
PIXEL_FMT_A4,
|
||||
PIXEL_FMT_A2,
|
||||
PIXEL_FMT_A1,
|
||||
PIXEL_FMT_JPEG,
|
||||
PIXEL_FMT_GIF,
|
||||
};
|
||||
|
||||
|
||||
struct image_file {
|
||||
u8 format;
|
||||
u8 clut_format;
|
||||
u8 compress;
|
||||
u8 has_clut;
|
||||
u8 strpic_mode;
|
||||
u16 data_crc;
|
||||
u16 width;
|
||||
u16 height;
|
||||
u32 offset;
|
||||
u32 len;
|
||||
u32 unzipOffset;
|
||||
u32 unzipLen;
|
||||
};
|
||||
|
||||
struct file_cache {
|
||||
struct list_head entry;
|
||||
u32 addr;
|
||||
u32 len;
|
||||
u8 *buf;
|
||||
u16 crc;
|
||||
};
|
||||
|
||||
typedef struct ui_resfile {
|
||||
FILE *file;
|
||||
int offset;
|
||||
u32 ver;
|
||||
char fname[64];
|
||||
struct list_head root;
|
||||
#if RESFILE_COMMON_HDL_EN
|
||||
struct list_head entry;
|
||||
u32 offset;
|
||||
u32 size;
|
||||
#endif
|
||||
u32 in_addr;
|
||||
u32 in_len;
|
||||
} UI_RESFILE;
|
||||
struct flashheader {
|
||||
u16 crc16;
|
||||
u16 crcfileheaddata;
|
||||
u8 info[8];
|
||||
u32 filenum;
|
||||
u32 version;
|
||||
u32 version1;
|
||||
u8 chiptype[8];
|
||||
};
|
||||
|
||||
struct flashfilehead {
|
||||
u8 filetype;
|
||||
u8 reserv;
|
||||
u16 crc16;
|
||||
u32 addr;
|
||||
u32 len;
|
||||
u32 version;
|
||||
u8 name[64];
|
||||
};
|
||||
|
||||
|
||||
struct myfile {
|
||||
SDFILE *file;
|
||||
FILE *_file;
|
||||
u8 name[64];
|
||||
u32 addr;
|
||||
u32 len;
|
||||
};
|
||||
|
||||
struct flash_file_info {
|
||||
u32 *tab;
|
||||
u16 tab_size;
|
||||
u32 offset;
|
||||
u32 last_tab_data_len;
|
||||
};
|
||||
|
||||
#define PHY_JL_EXTERN_FLASH 0 //杰理外挂fat 文件系统方案
|
||||
#define PHY_JL_INSERT_FLASH 1 //杰理内置flash 文件系统方案
|
||||
#define PHY_JL_NAND_FLASH 2 //nandflash文件系统方案
|
||||
//针对内封flash 场景 ui 硬件模块需要获取知道当前路径是挂靠在内置flash 还是 外挂flash
|
||||
|
||||
struct ui_load_info {
|
||||
u8 pj_id;
|
||||
u8 mmu_tab;
|
||||
u8 phy_dev;
|
||||
//针对内封flash 场景 ui 硬件模块需要获取知道当前路径是挂靠在内置flash 还是 外挂flash
|
||||
u32 phy_addr;
|
||||
//针对内封flash 场景 设备的物理地址不是从0开始的,需要告诉硬件模块偏移
|
||||
const char *path;
|
||||
UI_RESFILE *file;
|
||||
UI_RESFILE *res;
|
||||
UI_RESFILE *str;
|
||||
struct flash_file_info image_file_info;
|
||||
struct flash_file_info str_file_info;
|
||||
};
|
||||
|
||||
int open_resfile(const char *name);
|
||||
void close_resfile();
|
||||
|
||||
int open_str_file(const char *name);
|
||||
void close_str_file();
|
||||
|
||||
int open_style_file(const char *name);
|
||||
|
||||
int res_file_version_compare(int res_ver);
|
||||
int str_file_version_compare(int str_ver);
|
||||
int sty_file_check(UI_RESFILE *file);
|
||||
|
||||
int font_ascii_init(const char *name);
|
||||
|
||||
int load_pallet_table(int id, u32 *data);
|
||||
|
||||
int ui_language_set(int language);
|
||||
int ui_language_get();
|
||||
|
||||
UI_RESFILE *res_fopen(const char *path, const char *mode);
|
||||
int res_fread(UI_RESFILE *_file, void *buf, u32 len);
|
||||
int res_fseek(UI_RESFILE *_file, int offset, int fromwhere);
|
||||
int res_cache(UI_RESFILE *_file, int addr, u32 len);
|
||||
int res_nocache(UI_RESFILE *_file, int addr, u32 len);
|
||||
int res_flen(UI_RESFILE *file);
|
||||
int res_fclose(UI_RESFILE *file);
|
||||
int _norflash_read_watch(u8 *buf, u32 addr, u32 len, u8 wait);//加速读
|
||||
|
||||
int ui_prj_info_table_init(
|
||||
struct ui_load_info *info,
|
||||
void *(*malloc)(int size, u32 ram_type, u32 module_type),
|
||||
void (*free)(void *p, u32 ram_type, u32 module_type));
|
||||
int ui_prj_info_table_release();
|
||||
|
||||
void *ui_load_res_by_pj_id(int pj_id);
|
||||
void *ui_load_str_by_pj_id(int pj_id);
|
||||
void *ui_load_sty_by_pj_id(int pj_id);
|
||||
void *ui_get_image_file_info_by_pj_id(int pj_id);
|
||||
void *ui_get_str_file_info_by_pj_id(int pj_id);
|
||||
int ui_unload_file_info_not_contain_prj_id(u8 pj_id);
|
||||
|
||||
int ui_res_flash_info_get(struct flash_file_info *file_info, char *path, char *str, int mmu_tab);
|
||||
void ui_res_flash_info_free(struct flash_file_info *file_info, char *str);
|
||||
int ui_res_get_image_flash_info(struct flash_file_info *image_info, struct flash_file_info *prj_info, struct image_file *img_file);
|
||||
int ui_res_get_flash_tab_info(struct flash_file_info *file_info, u32 file_base_addr, u32 filelen);
|
||||
int ui_set_sty_path_by_pj_id(int pj_id, const u8 *path);
|
||||
int __ui_res_flash_info_get(struct flash_file_info *file_info, char *path, char *str, u8 phy_dev, u32 phy_addr, int mmu_tab);
|
||||
int ui_res_file_open(struct ui_load_info *info, const u8 *path, const char *mode);
|
||||
int ui_unload_file_info();
|
||||
|
||||
void select_resfile(u8 index);
|
||||
void select_strfile(u8 index);
|
||||
|
||||
int open_image_by_id(int prj, UI_RESFILE *specfile, struct image_file *f, int id, int page);
|
||||
int open_image_by_addr_id(struct image_file *f, u32 res_addr, int id, int page_num);
|
||||
int read_image_data(int prj, UI_RESFILE *specfile, struct image_file *f, u8 *data, int len, int offset);
|
||||
int br23_read_image_data(int prj, UI_RESFILE *specfile, struct image_file *f, u8 *data, int len, int offset);
|
||||
int br25_read_image_data(UI_RESFILE *specfile, struct image_file *f, u8 *data, int len, int offset);
|
||||
u32 image_decode(const void *pSour, void *pDest, u32 SourLen, u32 DestLen, u8 compress);
|
||||
|
||||
int open_string_pic(int prj, struct image_file *file, int id);
|
||||
int open_string_by_id(int prj, UI_RESFILE *specfile, struct image_file *f, int id);
|
||||
int read_str_data(struct image_file *f, u8 *data, int len);
|
||||
int br23_read_str_data(struct image_file *f, u8 *data, int len, int offset);
|
||||
int br25_read_str_data(struct image_file *f, u8 *data, int len, int offset);
|
||||
int read_string_type(int prj, int id);
|
||||
int open_string_pic2(int prj, struct image_file *file, int id);
|
||||
|
||||
int ui_res_cache_head(UI_RESFILE *file);
|
||||
int ui_res_cache(UI_RESFILE *file, int page_num);
|
||||
int ui_res_nocache(UI_RESFILE *file, int page_num);
|
||||
int ui_str_cache(UI_RESFILE *file, int language_index);
|
||||
int ui_str_nocache(UI_RESFILE *file, int language_index);
|
||||
int ui_sty_cache(UI_RESFILE *file, int page);
|
||||
int ui_sty_nocache(UI_RESFILE *file, int page);
|
||||
int ui_sty_cache_head(UI_RESFILE *file);
|
||||
|
||||
int res_get_image_stride(int gpu_format, struct image_file *image, u8 *adr_mode, u8 *compress_mode, int *compress_size);
|
||||
|
||||
int res_get_image_len(u32 gpu_format, int height, u32 adr_mode, u32 compress_mode, u32 compress_size, u32 stride);
|
||||
#endif
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef _ZZ_H_
|
||||
#define _ZZ_H_
|
||||
|
||||
int text_decompress(void *dst, int dst_len, void *src, int src_len);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,885 @@
|
||||
/* Copyright(C) 2010- , JIELI TECHNOLOGY, Inc.
|
||||
* All right reserved.
|
||||
*/
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @file ui.h
|
||||
*
|
||||
* @brief 杰理UI框架头文件
|
||||
*
|
||||
* @author JIELI TECHNOLOGY ZHUHAI
|
||||
*
|
||||
* @version V1.0.0
|
||||
*
|
||||
* @date 2024-06-04
|
||||
*
|
||||
* 注意:杰理UI框架在控件刷新时会触发on_change事件回调,
|
||||
* 因此在on_change事件的回调中禁止调用含有redraw刷新的接口,
|
||||
* 否则会进入递归引发不可预测的问题
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef UI_CORE_H
|
||||
#define UI_CORE_H
|
||||
|
||||
#include "ui_animation_utils.h"
|
||||
#include "ui_animation_math.h"
|
||||
#include "ui_animation.h"
|
||||
|
||||
#include "window.h"
|
||||
#include "ui_button.h"
|
||||
#include "ui_grid.h"
|
||||
#include "ui_time.h"
|
||||
#include "ui_camera.h"
|
||||
#include "ui_pic.h"
|
||||
#include "ui_text.h"
|
||||
#include "ui_battery.h"
|
||||
#include "ui_browser.h"
|
||||
#include "ui_slider.h"
|
||||
#include "ui_slider_vert.h"
|
||||
#include "ui_number.h"
|
||||
#include "ui_watch.h"
|
||||
#include "ui_progress.h"
|
||||
#include "ui_progress_multi.h"
|
||||
#include "ui_rotate.h"
|
||||
#include "ui_page_manager.h"
|
||||
#include "ui_compass.h"
|
||||
#include "ui_draw/ui_figure.h"
|
||||
#include "ui_multi_page_manager.h"
|
||||
#include "ui_draw/ui_obj.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
extern const int UI_DATA_STORE_IN_NORFLASH;
|
||||
|
||||
|
||||
|
||||
struct uimsg_handl {
|
||||
const char *msg;
|
||||
int (*handler)(const char *type, u32 args);
|
||||
};
|
||||
|
||||
enum {
|
||||
HIDE_WITH_REDRAW,
|
||||
HIDE_WITHOUT_REDRAW,
|
||||
};
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_framework_init ui框架初始化
|
||||
*
|
||||
* @param lcd配置句柄,在board.c文件配置
|
||||
*
|
||||
* @return 0
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_framework_init(void *);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_set_style_file 设置ui风格
|
||||
*
|
||||
* @param style ui风格资源句柄
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_set_style_file(struct ui_style *style);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_style_file_version_compare UI风格版本检查
|
||||
*
|
||||
* @param version 目标版本号
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_style_file_version_compare(int version);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_redraw UI控件刷新
|
||||
*
|
||||
* @param id 待刷新的UI控件ID(注意:凡刷新的动作,不允许在ONCHANGE事件中调用)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_redraw(int id);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_show 设置UI控件为显示
|
||||
*
|
||||
* @param id UI控件ID
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_show(int id);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_hide 设置UI控件为隐藏
|
||||
*
|
||||
* @param id UI控件ID
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_hide(int id);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_set_call 设置页面回调
|
||||
* (一般在ONCHANGE_INIT事件中使用,页面第一次显示完后会触发回调,回调中可调用redraw,可用
|
||||
* 于图标等内容第一次显示时更新图标。回调被调用后,指针会被清空;即回调注册后只会被调用一
|
||||
* 次)
|
||||
*
|
||||
* @param func 回调函数指针
|
||||
* @param param 传给回调函数的参数
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_set_call(int (*func)(int), int param);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_event_onkey UI控件按键事件回调
|
||||
*
|
||||
* @param e 按键事件句柄
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_event_onkey(struct element_key_event *e);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_event_ontouch UI控件触摸事件回调
|
||||
*
|
||||
* @param e 触摸事件句柄
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_event_ontouch(struct element_touch_event *e);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_card_ontouch UI卡片触摸事件回调(已放到lcd_ui_api.c文件)
|
||||
*
|
||||
* @param e 触摸事件句柄
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_card_ontouch(struct element_touch_event *e);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_core_get_root
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct element *ui_core_get_root();
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_get_highlight_child_by_id 获取高亮的子控件
|
||||
*
|
||||
* @param id 控件ID
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct element *ui_get_highlight_child_by_id(int id);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_invert_element_by_id
|
||||
*
|
||||
* @param id
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_invert_element_by_id(int id);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_no_highlight_element 取消控件高亮(不带redraw)
|
||||
*
|
||||
* @param elm 控件句柄
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_no_highlight_element(struct element *elm);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_no_highlight_element_by_id 取消控件高亮(带redraw)
|
||||
*
|
||||
* @param id 控件ID
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_no_highlight_element_by_id(int id);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_highlight_element 设置控件高亮(不带redraw)
|
||||
*
|
||||
* @param elm 控件句柄
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_highlight_element(struct element *elm);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_highlight_element_by_id 设置控件高亮(带redraw)
|
||||
*
|
||||
* @param id 控件ID
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_highlight_element_by_id(int id);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_get_current_window_id 获取当前显示的window ID
|
||||
*
|
||||
* @return 当前显示的window ID
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_get_current_window_id();
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_page_switch 手动切换页面
|
||||
*
|
||||
* @param curr_win 当前页面ID
|
||||
* @param next_win 下一个页面ID
|
||||
* @param xoffset 移动步距
|
||||
* @param mode 特效模式(暂时只有模式0)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_page_switch(int curr_win, int next_win, int xoffset, int mode);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_register_msg_handler 注册指定控件的消息回调句柄
|
||||
*
|
||||
* @param id 控件ID
|
||||
* @param handl 回调句柄
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_register_msg_handler(int id, const struct uimsg_handl *handl);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_message_handler
|
||||
*
|
||||
* @param id
|
||||
* @param msg
|
||||
* @param va_list
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_message_handler(int id, const char *msg, va_list);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief str_substr_iter
|
||||
*
|
||||
* @param str
|
||||
* @param delim
|
||||
* @param iter
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
const char *str_substr_iter(const char *str, char delim, int *iter);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_get_child_by_id
|
||||
*
|
||||
* @param id
|
||||
* @param event_handler_cb
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_get_child_by_id(int id, int (*event_handler_cb)(void *, int, int));
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_set_default_handler
|
||||
*
|
||||
* @param ontouch
|
||||
* @param onkey
|
||||
* @param onchange
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_set_default_handler(struct element *elm, int (*ontouch)(void *, struct element_touch_event *),
|
||||
int (*onkey)(void *, struct element_key_event *),
|
||||
int (*onchange)(void *, enum element_change_event, void *));
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_ontouch_lock 触摸消息锁定发送给控件之外的区域
|
||||
*
|
||||
* @param elm 目标控件的元素
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_ontouch_lock(void *elm);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_ontouch_unlock 释放控件之外的区域锁定
|
||||
*
|
||||
* @param elm 目标控件的元素
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_ontouch_unlock(void *elm);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_lock_layer 锁定控件的父图层,先不推向imb显示
|
||||
*
|
||||
* @param id 控件ID
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_lock_layer(int id);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_unlock_layer 释放控件的父图层,可以推向imb显示
|
||||
*
|
||||
* @param id 控件ID
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_unlock_layer(int id);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_get_disp_status_by_id 获取指定控件的显示状态(默认隐藏标志)
|
||||
*
|
||||
* @param id 待获取状态的控件ID
|
||||
*
|
||||
* @return false 显示,true 隐藏
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_get_disp_status_by_id(int id);
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief create_control_by_id 动态创建控件(将B工程的指定控件显示到A工程的指定容器中)
|
||||
*
|
||||
* @param tabfile 待创建控件的tab文件路径
|
||||
* @param page_id 带创建控件所在PAGE ID
|
||||
* @param id 待创建控件的ID
|
||||
* @param parent_id 容器控件的ID
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int create_control_by_id(char *tabfile, int page_id, int id, int parent_id);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief delete_control_by_id 删除动态创建的控件(一般与create_control_by_id成对使用)
|
||||
*
|
||||
* @param id 要删除的动态创建的控件ID
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int delete_control_by_id(int id);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_remove_backcolor 删除控件的背景颜色
|
||||
*
|
||||
* @param elm 待删除颜色的控件句柄
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_remove_backcolor(struct element *elm);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_remove_backimage 删除控件的背景图
|
||||
*
|
||||
* @param elm 待删除背景图的控件句柄
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_remove_backimage(struct element *elm);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_remove_border 删除控件的边框
|
||||
*
|
||||
* @param elm 待删除边框的控件句柄
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_remove_border(struct element *elm);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_fill_rect ui填充矩形
|
||||
*
|
||||
* @param dc UI框架句柄
|
||||
* @param left 矩形left坐标
|
||||
* @param top 矩形top坐标
|
||||
* @param width 矩形宽度
|
||||
* @param height 矩形高度
|
||||
* @param acolor 填充颜色(带透明度)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_fill_rect(struct draw_context *dc, int left, int top, int width, int height, u32 acolor);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_draw_image 自定义绘图方式显示图片
|
||||
*
|
||||
* @param dc 待显示的上下文句柄
|
||||
* @param page 待显示图片所在页面
|
||||
* @param id 待显示图片所在控件ID
|
||||
* @param x 待显示图片将显示的X坐标
|
||||
* @param y 待显示图片将显示的Y坐标
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_draw_image(struct draw_context *dc, int page, int id, int x, int y);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_draw_image_large 大图片截取显示
|
||||
*
|
||||
* @param dc 显示上下文
|
||||
* @param page 页面号
|
||||
* @param id 图片索引
|
||||
* @param x 显示的X坐标(相对屏幕)
|
||||
* @param y 显示的Y坐标(相对屏幕)
|
||||
* @param width 显示宽度
|
||||
* @param height 显示高度
|
||||
* @param image_x 图片的X坐标(相对图片)
|
||||
* @param image_y 图片的Y坐标(相对图片)
|
||||
*
|
||||
* @return -1 失败,0 正常
|
||||
* @note 大图片显示具有尺寸限制,请留意工具或者代码提示信息
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_draw_image_large(struct draw_context *dc, int page, int id, int x, int y, int width, int height, int image_x, int image_y);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_draw_ascii 自定义合成ascii字符串显示
|
||||
*
|
||||
* @param dc 显示上下文
|
||||
* @param str 字符串指针
|
||||
* @param strlen 字符串长度
|
||||
* @param x 字符串X坐标
|
||||
* @param y 字符串Y坐标
|
||||
* @param color 字符串显示颜色
|
||||
*
|
||||
* @return 0 正常,-1 失败
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_draw_ascii(struct draw_context *dc, char *str, int strlen, int x, int y, int color);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_draw_text 自定义显示字符串
|
||||
*
|
||||
* @param dc 显示上下文
|
||||
* @param encode 编码格式
|
||||
* @param endian 大小端
|
||||
* @param str 字符串指针
|
||||
* @param strlen 字符串长度
|
||||
* @param x 显示X坐标
|
||||
* @param y 显示Y坐标
|
||||
* @param color 显示颜色
|
||||
*
|
||||
* @return 0 正常,-1 失败
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_draw_text(struct draw_context *dc, int encode, int endian, char *str, int strlen, int x, int y, int color);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_draw_strpic 显示多国语言excel表文本
|
||||
*
|
||||
* @param dc 显示上下文
|
||||
* @param id 文本控件ID
|
||||
* @param x 显示X坐标
|
||||
* @param y 显示Y坐标
|
||||
* @param color 文本颜色
|
||||
*
|
||||
* @return 0 正常,-1 失败
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_draw_strpic(struct draw_context *dc, int id, int x, int y, int color);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_draw_line 绘制直线
|
||||
*
|
||||
* @param _dc 显示上下文
|
||||
* @param x0 直线起点X坐标
|
||||
* @param y0 直线起点Y坐标
|
||||
* @param x1 直线终点X坐标
|
||||
* @param y1 直线终点Y坐标
|
||||
* @param color 直线颜色
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_draw_line(void *_dc, int x0, int y0, int x1, int y1, int color);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_draw_line_by_angle 绘制指定角度的直线
|
||||
*
|
||||
* @param _dc 显示上下文
|
||||
* @param x 直线起点X坐标
|
||||
* @param y 直线起点Y坐标
|
||||
* @param length 直线长度
|
||||
* @param angle 直线角度
|
||||
* @param color 直线颜色
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_draw_line_by_angle(void *_dc, int x, int y, int length, int angle, int color);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_draw_rect 绘制矩形填充
|
||||
*
|
||||
* @param _dc 显示上下文
|
||||
* @param x 矩形左上角X坐标
|
||||
* @param y 矩形左上角Y坐标
|
||||
* @param width 矩形宽度
|
||||
* @param height 矩形高度
|
||||
* @param color 填充颜色
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_draw_rect(void *_dc, int x, int y, int width, int height, int color);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_draw_image_invert 绘制镜像图片(图片倒影)
|
||||
*
|
||||
* @param dc 绘图句柄
|
||||
* @param page 页面
|
||||
* @param id 资源id
|
||||
* @param x left
|
||||
* @param y top
|
||||
* @param x_en 使能水平翻转:0不翻转 1向右翻转 2向左翻转
|
||||
* @param y_en 使能垂直翻转:0不翻转 1向下翻转 2向上翻转
|
||||
* @param x_dist 翻转后距离原图最近边界距离
|
||||
* @param y_dist 翻转后距离原图最近边界距离
|
||||
* @param alpha 反转后图片透明度
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_draw_image_invert(struct draw_context *dc, int page, int id, int x, int y, int x_en, int y_en, int x_dist, int y_dist, int alpha);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_draw_ring 绘制圆
|
||||
*
|
||||
* @param _dc 显示上下文
|
||||
* @param x 圆心X坐标
|
||||
* @param y 圆心Y坐标
|
||||
* @param radius_big 圆形外径
|
||||
* @param radius_small 圆形内径
|
||||
* @param angle_begin 起始角度
|
||||
* @param angle_end 结束角度
|
||||
* @param color 颜色
|
||||
* @param percent 绘制百分比
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_draw_ring(void *_dc, int x, int y, int radius_big, int radius_small, int angle_begin, int angle_end, int color, int percent);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_draw_bar 绘制水平进度条
|
||||
*
|
||||
* @param _dc 显示上下文句柄
|
||||
* @param x 绘制的X坐标(左上角)
|
||||
* @param y 绘制的Y坐标(右上角)
|
||||
* @param width 绘制宽度
|
||||
* @param height 绘制高度
|
||||
* @param color 高亮颜色
|
||||
* @param percent 高亮百分比
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_draw_bar(void *_dc, int x, int y, int width, int height, int color, int percent, int wait_sync);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_draw_alpha_bar 透明度圆环
|
||||
*
|
||||
* @param _dc
|
||||
* @param x
|
||||
* @param y
|
||||
* @param width
|
||||
* @param height
|
||||
* @param color
|
||||
* @param percent (0-100)
|
||||
* @param alpha (0-255)
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_draw_alpha_bar(void *_dc, int x, int y, int width, int height, int color, int percent, int alpha);
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_draw_slidebar 绘制进度条
|
||||
*
|
||||
* @param dc 绘图句柄
|
||||
* @param fg_color 前景色
|
||||
* @param bg_color 背景色
|
||||
* @param percent 百分比
|
||||
* @param x left
|
||||
* @param y top
|
||||
* @param width
|
||||
* @param height
|
||||
* @param style 水平靠左/水平靠右/垂直靠上/垂直靠下
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_draw_slidebar(struct draw_context *dc, u32 fg_color, u32 bg_color, int percent, int x, int y, int width, int height, SLIDEBAR_STYLE style);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_draw_airrect 绘制带圆角的矩形(填充)
|
||||
*
|
||||
* @param dc 绘图句柄
|
||||
* @param x left
|
||||
* @param y top
|
||||
* @param width
|
||||
* @param height
|
||||
* @param color 填充颜色
|
||||
* @param radius 圆角半径
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_draw_airrect(void *_dc, int x, int y, int width, int height, int color, int radius);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_draw_airrect_border 绘制带圆角的矩形(边框)
|
||||
*
|
||||
* @param dc 绘图句柄
|
||||
* @param x left
|
||||
* @param y top
|
||||
* @param width
|
||||
* @param height
|
||||
* @param color 填充颜色
|
||||
* @param radius 圆角半径
|
||||
* @param border_width 边框宽度
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_draw_airrect_border(void *_dc, int x, int y, int width, int height, int color, int radius, int border_width);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_draw_poly_line 绘制折线(已知多个端点,将相邻端点连接起来)
|
||||
*
|
||||
* @param dc 绘图句柄
|
||||
* @param x left
|
||||
* @param y top
|
||||
* @param width
|
||||
* @param height
|
||||
* @param points 端点
|
||||
* @param points_num 端点数量
|
||||
* @param line_width 线宽
|
||||
* @param color 颜色
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_draw_poly_line(void *_dc, int x, int y, int width, int height, ui_point_t *points, int points_num, int line_width, u32 color);
|
||||
|
||||
/* 弃用 */
|
||||
int ui_draw_set_pixel(struct draw_context *dc, int x, int y, int pixel);
|
||||
u32 ui_draw_get_pixel(struct draw_context *dc, int x, int y);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_draw_get_mixed_pixel 颜色混合(ARGB565)
|
||||
*
|
||||
* @param backcolor 背景色
|
||||
* @param forecolor 前景色
|
||||
* @param alpha 透明度
|
||||
*
|
||||
* @return u16 混合后的颜色值
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
u16 ui_draw_get_mixed_pixel(u16 backcolor, u16 forecolor, u8 alpha);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_custom_draw_clear 清空自定义绘图
|
||||
*
|
||||
* @param dc 显示上下文
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_custom_draw_clear(struct draw_context *dc);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief load_control_info_by_id 通过控件ID加载控件资源信息
|
||||
*
|
||||
* @param tabfile 控件所在tab文件路径
|
||||
* @param page_id 控件所在页面ID
|
||||
* @param id 控件ID
|
||||
*
|
||||
* @return NULL 失败,control_pos * 控件在UI资源中的信息
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void *load_control_info_by_id(char *tabfile, u32 page_id, u32 id);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_control_new 创建新控件
|
||||
*
|
||||
* @param _pos 控件资源信息
|
||||
* @param parent 父控件句柄
|
||||
*
|
||||
* @return 新创建的控件句柄
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void *ui_control_new(void *_pos, void *parent);
|
||||
|
||||
|
||||
/* 弃用 */
|
||||
int ui_draw_begin(struct draw_context *dc);
|
||||
int ui_draw_end(struct draw_context *dc);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_draw
|
||||
*
|
||||
* @param dc
|
||||
* @param buf
|
||||
* @param x
|
||||
* @param y
|
||||
* @param width
|
||||
* @param height
|
||||
* @param cb
|
||||
* @param priv
|
||||
* @param priv_len
|
||||
* @param id
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_draw(struct draw_context *dc, u8 *buf, int x, int y, int width, int height, void *cb, void *priv, int priv_len, int id);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_page_set_param 卡片界面左右滑动参数设置
|
||||
*
|
||||
* @param threshold 阈值(继续滑动或回弹)
|
||||
* @param step 步距(自动滑动或回弹时每次步进量)
|
||||
* @param delay 自动滑动时间间隔(delay * 10 ms)
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_page_set_param(int threshold, int step, int delay);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_hide_set 设置控件隐藏动作是否刷新
|
||||
*
|
||||
* @param id 控件ID
|
||||
* @param redraw 刷新标志
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_hide_set(int id, int redraw);
|
||||
|
||||
|
||||
int ui_draw(struct draw_context *dc, u8 *buf, int x, int y, int width, int height, void *cb, void *priv, int priv_len, int id);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,499 @@
|
||||
/* Copyright(C)
|
||||
* not free
|
||||
* All right reserved
|
||||
*
|
||||
* @file ui_animation.h
|
||||
* @brief JL_UI 动画,相关接口确保在ui任务中调用
|
||||
* @author
|
||||
* @version
|
||||
* @date 2024-05-21
|
||||
*/
|
||||
|
||||
#ifndef _UI_ANIMATION_H
|
||||
#define _UI_ANIMATION_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "typedef.h"
|
||||
#include "list.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
#define UI_ANIM_REPEAT_INFINITE 0xFFFF
|
||||
#define UI_ANIM_PLAYTIME_INFINITE 0xFFFFFFFF
|
||||
|
||||
#define UI_USE_USER_DATA 1
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/** Can be used to indicate if animations are enabled or disabled in a case*/
|
||||
typedef enum {
|
||||
UI_ANIM_OFF,
|
||||
UI_ANIM_ON,
|
||||
} ui_anim_enable_t;
|
||||
|
||||
struct _ui_anim_t;
|
||||
struct _ui_timer_t;
|
||||
|
||||
/** Get the current value during an animation*/
|
||||
typedef int32_t (*ui_anim_path_cb_t)(const struct _ui_anim_t *);
|
||||
|
||||
/** Generic prototype of "animator" functions.
|
||||
* First parameter is the variable to JL_UI element id.
|
||||
* Second parameter is the value to set.
|
||||
* Compatible with `ui_xxx_set_yyy(obj, value)` functions
|
||||
* The `x` in `_xcb_t` means it's not a fully generic prototype because
|
||||
* it doesn't receive `ui_anim_t *` as its first argument*/
|
||||
typedef void (*ui_anim_exec_xcb_t)(int, int32_t);
|
||||
|
||||
/** Same as `ui_anim_exec_xcb_t` but receives `ui_anim_t *` as the first parameter.
|
||||
* It's more consistent but less convenient. Might be used by binding generator functions.*/
|
||||
typedef void (*ui_anim_custom_exec_cb_t)(struct _ui_anim_t *, int32_t);
|
||||
|
||||
/** Callback to call when the animation is ready*/
|
||||
typedef void (*ui_anim_ready_cb_t)(struct _ui_anim_t *);
|
||||
|
||||
/** Callback to call when the animation really stars (considering `delay`)*/
|
||||
typedef void (*ui_anim_start_cb_t)(struct _ui_anim_t *);
|
||||
|
||||
/** Callback used when the animation values are relative to get the current value*/
|
||||
typedef int32_t (*ui_anim_get_value_cb_t)(struct _ui_anim_t *);
|
||||
|
||||
/** Callback used when the animation is deleted*/
|
||||
typedef void (*ui_anim_deleted_cb_t)(struct _ui_anim_t *);
|
||||
|
||||
/** Describes an animation*/
|
||||
typedef struct _ui_anim_t {
|
||||
int var; /**<JL_UI element id*/
|
||||
ui_anim_exec_xcb_t exec_cb; /**< Function to execute to animate*/
|
||||
ui_anim_start_cb_t start_cb; /**< Call it when the animation is starts (considering `delay`)*/
|
||||
ui_anim_ready_cb_t ready_cb; /**< Call it when the animation is ready*/
|
||||
ui_anim_deleted_cb_t deleted_cb; /**< Call it when the animation is deleted*/
|
||||
ui_anim_get_value_cb_t get_value_cb; /**< Get the current value in relative mode*/
|
||||
#if UI_USE_USER_DATA
|
||||
void *user_data; /**< Custom user data*/
|
||||
#endif
|
||||
ui_anim_path_cb_t path_cb; /**< Describe the path (curve) of animations*/
|
||||
int32_t start_value; /**< Start value*/
|
||||
int32_t current_value; /**< Current value*/
|
||||
int32_t end_value; /**< End value*/
|
||||
int32_t time; /**< Animation time in ms*/
|
||||
int32_t act_time; /**< Current time in animation. Set to negative to make delay.*/
|
||||
uint32_t playback_delay; /**< Wait before play back*/
|
||||
uint32_t playback_time; /**< Duration of playback animation*/
|
||||
uint32_t repeat_delay; /**< Wait before repeat*/
|
||||
uint16_t repeat_cnt; /**< Repeat count for the animation*/
|
||||
uint8_t early_apply : 1; /**< 1: Apply start value immediately even is there is `delay`*/
|
||||
|
||||
/*Animation system use these - user shouldn't set*/
|
||||
uint8_t playback_now : 1; /**< Play back is in progress*/
|
||||
uint8_t run_round : 1; /**< Indicates the animation has run in this round*/
|
||||
uint8_t start_cb_called : 1; /**< Indicates that the `start_cb` was already called*/
|
||||
|
||||
struct list_head entry;
|
||||
} ui_anim_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Init. the animation module
|
||||
*/
|
||||
void ui_anim_core_init(void);
|
||||
|
||||
/**
|
||||
* Initialize an animation variable.
|
||||
* E.g.:
|
||||
* ui_anim_t a;
|
||||
* ui_anim_init(&a);
|
||||
* ui_anim_set_...(&a);
|
||||
* ui_anim_start(&a);
|
||||
* @param a pointer to an `ui_anim_t` variable to initialize
|
||||
*/
|
||||
void ui_anim_init(ui_anim_t *a);
|
||||
|
||||
/**
|
||||
* Set a variable to animate
|
||||
* @param a pointer to an initialized `ui_anim_t` variable
|
||||
* @param var JL_UI element id
|
||||
*/
|
||||
static inline void ui_anim_set_var(ui_anim_t *a, int var)
|
||||
{
|
||||
a->var = var;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a function to animate `var`
|
||||
* @param a pointer to an initialized `ui_anim_t` variable
|
||||
* @param exec_cb a function to execute during animation
|
||||
* LVGL's built-in functions can be used.
|
||||
* E.g. ui_obj_set_x
|
||||
*/
|
||||
static inline void ui_anim_set_exec_cb(ui_anim_t *a, ui_anim_exec_xcb_t exec_cb)
|
||||
{
|
||||
a->exec_cb = exec_cb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the duration of an animation
|
||||
* @param a pointer to an initialized `ui_anim_t` variable
|
||||
* @param duration duration of the animation in milliseconds
|
||||
*/
|
||||
static inline void ui_anim_set_time(ui_anim_t *a, uint32_t duration)
|
||||
{
|
||||
a->time = duration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a delay before starting the animation
|
||||
* @param a pointer to an initialized `ui_anim_t` variable
|
||||
* @param delay delay before the animation in milliseconds
|
||||
*/
|
||||
static inline void ui_anim_set_delay(ui_anim_t *a, uint32_t delay)
|
||||
{
|
||||
a->act_time = -(int32_t)(delay);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the start and end values of an animation
|
||||
* @param a pointer to an initialized `ui_anim_t` variable
|
||||
* @param start the start value
|
||||
* @param end the end value
|
||||
*/
|
||||
static inline void ui_anim_set_values(ui_anim_t *a, int32_t start, int32_t end)
|
||||
{
|
||||
a->start_value = start;
|
||||
a->current_value = start;
|
||||
a->end_value = end;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the path (curve) of the animation.
|
||||
* @param a pointer to an initialized `ui_anim_t` variable
|
||||
* @param path_cb a function to set the current value of the animation.
|
||||
*/
|
||||
static inline void ui_anim_set_path_cb(ui_anim_t *a, ui_anim_path_cb_t path_cb)
|
||||
{
|
||||
a->path_cb = path_cb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a function call when the animation really starts (considering `delay`)
|
||||
* @param a pointer to an initialized `ui_anim_t` variable
|
||||
* @param start_cb a function call when the animation starts
|
||||
*/
|
||||
static inline void ui_anim_set_start_cb(ui_anim_t *a, ui_anim_start_cb_t start_cb)
|
||||
{
|
||||
a->start_cb = start_cb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a function to use the current value of the variable and make start and end value
|
||||
* relative to the returned current value.
|
||||
* @param a pointer to an initialized `ui_anim_t` variable
|
||||
* @param get_value_cb a function call when the animation starts
|
||||
*/
|
||||
static inline void ui_anim_set_get_value_cb(ui_anim_t *a, ui_anim_get_value_cb_t get_value_cb)
|
||||
{
|
||||
a->get_value_cb = get_value_cb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a function call when the animation is ready
|
||||
* @param a pointer to an initialized `ui_anim_t` variable
|
||||
* @param ready_cb a function call when the animation is ready
|
||||
*/
|
||||
static inline void ui_anim_set_ready_cb(ui_anim_t *a, ui_anim_ready_cb_t ready_cb)
|
||||
{
|
||||
a->ready_cb = ready_cb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a function call when the animation is deleted.
|
||||
* @param a pointer to an initialized `ui_anim_t` variable
|
||||
* @param deleted_cb a function call when the animation is deleted
|
||||
*/
|
||||
static inline void ui_anim_set_deleted_cb(ui_anim_t *a, ui_anim_deleted_cb_t deleted_cb)
|
||||
{
|
||||
a->deleted_cb = deleted_cb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make the animation to play back to when the forward direction is ready
|
||||
* @param a pointer to an initialized `ui_anim_t` variable
|
||||
* @param time the duration of the playback animation in milliseconds. 0: disable playback
|
||||
*/
|
||||
static inline void ui_anim_set_playback_time(ui_anim_t *a, uint32_t time)
|
||||
{
|
||||
a->playback_time = time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make the animation to play back to when the forward direction is ready
|
||||
* @param a pointer to an initialized `ui_anim_t` variable
|
||||
* @param delay delay in milliseconds before starting the playback animation.
|
||||
*/
|
||||
static inline void ui_anim_set_playback_delay(ui_anim_t *a, uint32_t delay)
|
||||
{
|
||||
a->playback_delay = delay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make the animation repeat itself.
|
||||
* @param a pointer to an initialized `ui_anim_t` variable
|
||||
* @param cnt repeat count or `UI_ANIM_REPEAT_INFINITE` for infinite repetition. 0: to disable repetition.
|
||||
*/
|
||||
static inline void ui_anim_set_repeat_count(ui_anim_t *a, uint16_t cnt)
|
||||
{
|
||||
a->repeat_cnt = cnt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a delay before repeating the animation.
|
||||
* @param a pointer to an initialized `ui_anim_t` variable
|
||||
* @param delay delay in milliseconds before repeating the animation.
|
||||
*/
|
||||
static inline void ui_anim_set_repeat_delay(ui_anim_t *a, uint32_t delay)
|
||||
{
|
||||
a->repeat_delay = delay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a whether the animation's should be applied immediately or only when the delay expired.
|
||||
* @param a pointer to an initialized `ui_anim_t` variable
|
||||
* @param en true: apply the start value immediately in `ui_anim_start`;
|
||||
* false: apply the start value only when `delay` ms is elapsed and the animations really starts
|
||||
*/
|
||||
static inline void ui_anim_set_early_apply(ui_anim_t *a, bool en)
|
||||
{
|
||||
a->early_apply = en;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the custom user data field of the animation.
|
||||
* @param a pointer to an initialized `ui_anim_t` variable
|
||||
* @param user_data pointer to the new user_data.
|
||||
*/
|
||||
#if UI_USE_USER_DATA
|
||||
static inline void ui_anim_set_user_data(ui_anim_t *a, void *user_data)
|
||||
{
|
||||
a->user_data = user_data;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Create an animation
|
||||
* @param a an initialized 'anim_t' variable. Not required after call.
|
||||
* @return pointer to the created animation (different from the `a` parameter)
|
||||
*/
|
||||
ui_anim_t *ui_anim_start(const ui_anim_t *a);
|
||||
|
||||
/**
|
||||
* Get a delay before starting the animation
|
||||
* @param a pointer to an initialized `ui_anim_t` variable
|
||||
* @return delay before the animation in milliseconds
|
||||
*/
|
||||
static inline uint32_t ui_anim_get_delay(ui_anim_t *a)
|
||||
{
|
||||
return -a->act_time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the time used to play the animation.
|
||||
* @param a pointer to an animation.
|
||||
* @return the play time in milliseconds.
|
||||
*/
|
||||
uint32_t ui_anim_get_playtime(ui_anim_t *a);
|
||||
|
||||
/**
|
||||
* Get the user_data field of the animation
|
||||
* @param a pointer to an initialized `ui_anim_t` variable
|
||||
* @return the pointer to the custom user_data of the animation
|
||||
*/
|
||||
#if UI_USE_USER_DATA
|
||||
static inline void *ui_anim_get_user_data(ui_anim_t *a)
|
||||
{
|
||||
return a->user_data;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Delete an animation of a variable with a given animator function
|
||||
* @param var JL_UI element id
|
||||
* @param exec_cb a function pointer which is animating 'var',
|
||||
* or NULL to ignore it and delete all the animations of 'var
|
||||
* @return true: at least 1 animation is deleted, false: no animation is deleted
|
||||
*/
|
||||
bool ui_anim_del(int var, ui_anim_exec_xcb_t exec_cb);
|
||||
|
||||
/**
|
||||
* Delete all the animations
|
||||
*/
|
||||
void ui_anim_del_all(void);
|
||||
|
||||
/**
|
||||
* Get the animation of a variable and its `exec_cb`.
|
||||
* @param var JL_UI element id
|
||||
* @param exec_cb a function pointer which is animating 'var', or NULL to return first matching 'var'
|
||||
* @return pointer to the animation.
|
||||
*/
|
||||
ui_anim_t *ui_anim_get(int var, ui_anim_exec_xcb_t exec_cb);
|
||||
|
||||
/**
|
||||
* Get global animation refresher timer.
|
||||
* @return pointer to the animation refresher timer.
|
||||
*/
|
||||
struct ui_anim_timer_t *ui_anim_get_timer(void);
|
||||
|
||||
/**
|
||||
* Delete an animation by getting the animated variable from `a`.
|
||||
* Only animations with `exec_cb` will be deleted.
|
||||
* This function exists because it's logical that all anim. functions receives an
|
||||
* `ui_anim_t` as their first parameter. It's not practical in C but might make
|
||||
* the API more consequent and makes easier to generate bindings.
|
||||
* @param a pointer to an animation.
|
||||
* @param exec_cb a function pointer which is animating 'var',
|
||||
* or NULL to ignore it and delete all the animations of 'var
|
||||
* @return true: at least 1 animation is deleted, false: no animation is deleted
|
||||
*/
|
||||
static inline bool ui_anim_custom_del(ui_anim_t *a, ui_anim_custom_exec_cb_t exec_cb)
|
||||
{
|
||||
return ui_anim_del(a ? a->var : 0, (ui_anim_exec_xcb_t)exec_cb);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the animation of a variable and its `exec_cb`.
|
||||
* This function exists because it's logical that all anim. functions receives an
|
||||
* `ui_anim_t` as their first parameter. It's not practical in C but might make
|
||||
* the API more consequent and makes easier to generate bindings.
|
||||
* @param a pointer to an animation.
|
||||
* @param exec_cb a function pointer which is animating 'var', or NULL to return first matching 'var'
|
||||
* @return pointer to the animation.
|
||||
*/
|
||||
static inline ui_anim_t *ui_anim_custom_get(ui_anim_t *a, ui_anim_custom_exec_cb_t exec_cb)
|
||||
{
|
||||
return ui_anim_get(a ? a->var : 0, (ui_anim_exec_xcb_t)exec_cb);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of currently running animations
|
||||
* @return the number of running animations
|
||||
*/
|
||||
uint16_t ui_anim_count_running(void);
|
||||
|
||||
/**
|
||||
* Calculate the time of an animation with a given speed and the start and end values
|
||||
* @param speed speed of animation in unit/sec
|
||||
* @param start start value of the animation
|
||||
* @param end end value of the animation
|
||||
* @return the required time [ms] for the animation with the given parameters
|
||||
*/
|
||||
uint32_t ui_anim_speed_to_time(uint32_t speed, int32_t start, int32_t end);
|
||||
|
||||
/**
|
||||
* Manually refresh the state of the animations.
|
||||
* Useful to make the animations running in a blocking process where
|
||||
* `ui_timer_handler` can't run for a while.
|
||||
* Shouldn't be used directly because it is called in `ui_refr_now()`.
|
||||
*/
|
||||
void ui_anim_refr_now(void);
|
||||
|
||||
/**
|
||||
* Calculate the current value of an animation applying linear characteristic
|
||||
* @param a pointer to an animation
|
||||
* @return the current value to set
|
||||
*/
|
||||
int32_t ui_anim_path_linear(const ui_anim_t *a);
|
||||
|
||||
/**
|
||||
* Calculate the current value of an animation slowing down the start phase
|
||||
* @param a pointer to an animation
|
||||
* @return the current value to set
|
||||
*/
|
||||
int32_t ui_anim_path_ease_in(const ui_anim_t *a);
|
||||
|
||||
/**
|
||||
* Calculate the current value of an animation slowing down the end phase
|
||||
* @param a pointer to an animation
|
||||
* @return the current value to set
|
||||
*/
|
||||
int32_t ui_anim_path_ease_out(const ui_anim_t *a);
|
||||
|
||||
/**
|
||||
* Calculate the current value of an animation applying an "S" characteristic (cosine)
|
||||
* @param a pointer to an animation
|
||||
* @return the current value to set
|
||||
*/
|
||||
int32_t ui_anim_path_ease_in_out(const ui_anim_t *a);
|
||||
|
||||
/**
|
||||
* Calculate the current value of an animation with overshoot at the end
|
||||
* @param a pointer to an animation
|
||||
* @return the current value to set
|
||||
*/
|
||||
int32_t ui_anim_path_overshoot(const ui_anim_t *a);
|
||||
|
||||
/**
|
||||
* Calculate the current value of an animation with 3 bounces
|
||||
* @param a pointer to an animation
|
||||
* @return the current value to set
|
||||
*/
|
||||
int32_t ui_anim_path_bounce(const ui_anim_t *a);
|
||||
|
||||
/**
|
||||
* Calculate the current value of an animation applying step characteristic.
|
||||
* (Set end value on the end of the animation)
|
||||
* @param a pointer to an animation
|
||||
* @return the current value to set
|
||||
*/
|
||||
int32_t ui_anim_path_step(const ui_anim_t *a);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief JL_UI 动画绘制函数
|
||||
*
|
||||
* @Params param 目前不使用,保留该参数
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_anim_handler(void *param);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 设置动画在哪个任务下跑
|
||||
*
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_anim_set_run_task(const char *run_task_name);
|
||||
|
||||
/**********************
|
||||
* GLOBAL VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/*Default display refresh period. JL_UI will redraw changed areas with this period time*/
|
||||
#define UI_ANIM_DISP_DEF_REFR_PERIOD 2 /*单位:tick(10ms)*/
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*_UI_ANIMATION_H*/
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
/**
|
||||
* @file ui_animation_math.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _UI_ANIMATION_MATH_H
|
||||
#define _UI_ANIMATION_MATH_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <stdint.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define UI_TRIGO_SIN_MAX 32767
|
||||
#define UI_TRIGO_SHIFT 15 /**< >> UI_TRIGO_SHIFT to normalize*/
|
||||
|
||||
#define UI_BEZIER_VAL_MAX 1024 /**< Max time in Bezier functions (not [0..1] to use integers)*/
|
||||
#define UI_BEZIER_VAL_SHIFT 10 /**< log2(UI_BEZIER_VAL_MAX): used to normalize up scaled values*/
|
||||
|
||||
|
||||
#define UI_ATTRIBUTE_FAST_MEM
|
||||
|
||||
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef struct {
|
||||
uint16_t i;
|
||||
uint16_t f;
|
||||
} ui_sqrt_res_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
//! @cond Doxygen_Suppress
|
||||
/**
|
||||
* Return with sinus of an angle
|
||||
* @param angle
|
||||
* @return sinus of 'angle'. sin(-90) = -32767, sin(90) = 32767
|
||||
*/
|
||||
UI_ATTRIBUTE_FAST_MEM int16_t ui_trigo_sin(int16_t angle);
|
||||
|
||||
static inline UI_ATTRIBUTE_FAST_MEM int16_t ui_trigo_cos(int16_t angle)
|
||||
{
|
||||
return ui_trigo_sin(angle + 90);
|
||||
}
|
||||
|
||||
//! @endcond
|
||||
|
||||
/**
|
||||
* Calculate a value of a Cubic Bezier function.
|
||||
* @param t time in range of [0..UI_BEZIER_VAL_MAX]
|
||||
* @param u0 start values in range of [0..UI_BEZIER_VAL_MAX]
|
||||
* @param u1 control value 1 values in range of [0..UI_BEZIER_VAL_MAX]
|
||||
* @param u2 control value 2 in range of [0..UI_BEZIER_VAL_MAX]
|
||||
* @param u3 end values in range of [0..UI_BEZIER_VAL_MAX]
|
||||
* @return the value calculated from the given parameters in range of [0..UI_BEZIER_VAL_MAX]
|
||||
*/
|
||||
uint32_t ui_bezier3(uint32_t t, uint32_t u0, uint32_t u1, uint32_t u2, uint32_t u3);
|
||||
|
||||
/**
|
||||
* Calculate the atan2 of a vector.
|
||||
* @param x
|
||||
* @param y
|
||||
* @return the angle in degree calculated from the given parameters in range of [0..360]
|
||||
*/
|
||||
uint16_t ui_atan2(int x, int y);
|
||||
|
||||
//! @cond Doxygen_Suppress
|
||||
|
||||
/**
|
||||
* Get the square root of a number
|
||||
* @param x integer which square root should be calculated
|
||||
* @param q store the result here. q->i: integer part, q->f: fractional part in 1/256 unit
|
||||
* @param mask optional to skip some iterations if the magnitude of the root is known.
|
||||
* Set to 0x8000 by default.
|
||||
* If root < 16: mask = 0x80
|
||||
* If root < 256: mask = 0x800
|
||||
* Else: mask = 0x8000
|
||||
*/
|
||||
UI_ATTRIBUTE_FAST_MEM void ui_sqrt(uint32_t x, ui_sqrt_res_t *q, uint32_t mask);
|
||||
|
||||
//! @endcond
|
||||
|
||||
/**
|
||||
* Calculate the integer exponents.
|
||||
* @param base
|
||||
* @param power
|
||||
* @return base raised to the power exponent
|
||||
*/
|
||||
int64_t ui_pow(int64_t base, int8_t exp);
|
||||
|
||||
/**
|
||||
* Get the mapped of a number given an input and output range
|
||||
* @param x integer which mapped value should be calculated
|
||||
* @param min_in min input range
|
||||
* @param max_in max input range
|
||||
* @param min_out max output range
|
||||
* @param max_out max output range
|
||||
* @return the mapped number
|
||||
*/
|
||||
int32_t ui_map(int32_t x, int32_t min_in, int32_t max_in, int32_t min_out, int32_t max_out);
|
||||
|
||||
/**
|
||||
* Get a pseudo random number in the given range
|
||||
* @param min the minimum value
|
||||
* @param max the maximum value
|
||||
* @return return the random number. min <= return_value <= max
|
||||
*/
|
||||
uint32_t ui_rand(uint32_t min, uint32_t max);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
#define UI_MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#define UI_MIN3(a, b, c) (UI_MIN(UI_MIN(a,b), c))
|
||||
#define UI_MIN4(a, b, c, d) (UI_MIN(UI_MIN(a,b), UI_MIN(c,d)))
|
||||
|
||||
#define UI_MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#define UI_MAX3(a, b, c) (UI_MAX(UI_MAX(a,b), c))
|
||||
#define UI_MAX4(a, b, c, d) (UI_MAX(UI_MAX(a,b), UI_MAX(c,d)))
|
||||
|
||||
#define UI_CLAMP(min, val, max) (UI_MAX(min, (UI_MIN(val, max))))
|
||||
|
||||
#define UI_ABS(x) ((x) > 0 ? (x) : (-(x)))
|
||||
#define UI_UDIV255(x) (((x) * 0x8081U) >> 0x17)
|
||||
|
||||
#define UI_IS_SIGNED(t) (((t)(-1)) < ((t)0))
|
||||
#define UI_UMAX_OF(t) (((0x1ULL << ((sizeof(t) * 8ULL) - 1ULL)) - 1ULL) | (0xFULL << ((sizeof(t) * 8ULL) - 4ULL)))
|
||||
#define UI_SMAX_OF(t) (((0x1ULL << ((sizeof(t) * 8ULL) - 1ULL)) - 1ULL) | (0x7ULL << ((sizeof(t) * 8ULL) - 4ULL)))
|
||||
#define UI_MAX_OF(t) ((unsigned long)(UI_IS_SIGNED(t) ? UI_SMAX_OF(t) : UI_UMAX_OF(t)))
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
/* Copyright(C)
|
||||
* not free
|
||||
* All right reserved
|
||||
*
|
||||
* @file ui_animation.h
|
||||
* @brief JL_UI 动画相关工具函数
|
||||
* @author
|
||||
* @version
|
||||
* @date 2024-05-21
|
||||
*/
|
||||
|
||||
#ifndef _UI_ANIMATION_UTILS_H
|
||||
#define _UI_ANIMATION_UTILS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "ui_animation.h"
|
||||
|
||||
#include "typedef.h"
|
||||
#include "list.h"
|
||||
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief animation play interval
|
||||
*
|
||||
* @Params ms: interval time
|
||||
*
|
||||
* @note call befor ui_anim_start()
|
||||
*
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_anim_set_interval(u16 ms);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief suspend animation
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_anim_timer_suspend(void);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief resume animation
|
||||
*
|
||||
* @Params ms: interval time
|
||||
*
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_anim_timer_resume(u16 interval_ms);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Get the elapsed milliseconds since start up
|
||||
*
|
||||
* @Return the elapsed milliseconds
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
u32 ui_anim_tick_get(void);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Get the elapsed milliseconds since a previous time stamp
|
||||
*
|
||||
* @Params prev_tick a previous time stamp (return value of ui_anim_tick_get() )
|
||||
*
|
||||
* @Return the elapsed milliseconds since 'prev_tick'
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
u32 ui_anim_tick_elaps(uint32_t prev_tick);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief add a new node to the animaton list
|
||||
*
|
||||
* @Params root: the animation list head
|
||||
* @Params node: new node to be added
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_anim_list_add(struct list_head *root, struct list_head *node);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief del the node from the animaton list
|
||||
*
|
||||
* @Params node: node to be deleted
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_anim_list_del(struct list_head *node);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief del and free all node from the animation list. The list remain valid but become empty.
|
||||
*
|
||||
* @Params root: the animation list head
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_anim_list_clear(struct list_head *root);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Return with first node of the animation list
|
||||
*
|
||||
* @Params root: the animation list head
|
||||
*
|
||||
* @Return the first node from a list
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
ui_anim_t *ui_anim_list_get_head(const struct list_head *root);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Return with the pointer of the next node after 'cur_node'
|
||||
*
|
||||
* @Params root: the animation list head
|
||||
* @Params node: current node
|
||||
*
|
||||
* @Return pointer to the next node
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
ui_anim_t *ui_anim_list_get_next(const struct list_head *root, const struct list_head *cur_node);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*_UI_ANIMATION_UTILS_H*/
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
/* Copyright(C) 2010- , JIELI TECHNOLOGY, Inc.
|
||||
* All right reserved.
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @file ui_battery.h
|
||||
*
|
||||
* @brief 杰理UI电池电量控件API
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version V1.0.0
|
||||
*
|
||||
* @date 2024-06-13
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __UI_BATTERY_WIDGET_H__
|
||||
#define __UI_BATTERY_WIDGET_H__
|
||||
|
||||
|
||||
#include "jlui/control.h"
|
||||
#include "list.h"
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 电池控件句柄结构
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct ui_battery {
|
||||
struct element elm;
|
||||
int src; // 当前显示的图片ID
|
||||
u8 index; // 当前显示的图片索引
|
||||
struct ui_image_list *charge_image; // 充电状态图片列表
|
||||
struct ui_image_list *normal_image; // 电量状态图片列表
|
||||
struct list_head entry; // 电量控件链表,用于把所有电量控件串联起来,一个控件更新,则所有控件一起更新
|
||||
const struct ui_battery_info *info;
|
||||
const struct element_event_handler *handler;
|
||||
}; // 96byte
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 通过ID获取电池电量控件句柄
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
#define ui_battery_for_id(id) \
|
||||
ui_element_for_id(id, struct ui_battery)
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_battery_enable 电池控件使能(内部调用)
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_battery_enable();
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_battery_level_change 设置所有电池控件状态
|
||||
*
|
||||
* @param persent 电量百分比
|
||||
* @param incharge 是否正在充电(true 充电状态,false 显示电量百分比)
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_battery_level_change(int persent, int incharge);//改变所有电池控件
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_battery_set_level_by_id 设置指定电池控件状态(带redraw)
|
||||
*
|
||||
* @param id 电池控件ID
|
||||
* @param persent 电量百分比
|
||||
* @param incharge 是否正在充电
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_battery_set_level_by_id(int id, int persent, int incharge);//修改指定id
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_battery_set_level 设置指点电池控件状态(不带redraw)
|
||||
*
|
||||
* @param battery 电池控件句柄
|
||||
* @param persent 电量百分比
|
||||
* @param incharge 充电状态
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_battery_set_level(struct ui_battery *battery, int persent, int incharge);//初始化使用
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
#ifndef UI_BROWSER_H
|
||||
#define UI_BROWSER_H
|
||||
|
||||
|
||||
|
||||
#include "jlui/ui_core.h"
|
||||
#include "jlui/control.h"
|
||||
|
||||
|
||||
#define ui_browser_for_id(id) \
|
||||
ui_element_for_id(id, struct ui_browser)
|
||||
|
||||
|
||||
struct ui_browser {
|
||||
struct element elm;
|
||||
struct ui_file_browser *hdl;
|
||||
char order; // 1 表示 正序, 非1 表示反序
|
||||
u8 inited;
|
||||
u8 hide_byself;
|
||||
u8 item_num;
|
||||
u8 highlight;
|
||||
u8 show_mode;
|
||||
u16 cur_number;
|
||||
u16 file_number;
|
||||
struct ui_grid *grid;
|
||||
const char *path;
|
||||
const char *ftype;
|
||||
const struct ui_browser_info *info;
|
||||
const struct element_event_handler *handler;
|
||||
};
|
||||
|
||||
|
||||
#define ui_file_browser_cur_item(bro) ui_grid_cur_item(((struct ui_browser *)bro)->grid)
|
||||
|
||||
|
||||
int ui_file_browser_page_num(struct ui_browser *bro);
|
||||
|
||||
int ui_file_browser_cur_page(struct ui_browser *bro, int *file_num);
|
||||
|
||||
int ui_file_browser_set_page(struct ui_browser *bro, int page);
|
||||
|
||||
int ui_file_browser_set_page_by_id(int id, int page);
|
||||
|
||||
int ui_file_browser_next_page(struct ui_browser *bro);
|
||||
|
||||
int ui_file_browser_next_page_by_id(int id);
|
||||
|
||||
int ui_file_browser_prev_page(struct ui_browser *bro);
|
||||
|
||||
int ui_file_browser_prev_page_by_id(int id);
|
||||
|
||||
int ui_file_browser_set_dir(struct ui_browser *bro, const char *path, const char *ftype);
|
||||
|
||||
int ui_file_browser_set_dir_by_id(int id, const char *path, const char *ftype);
|
||||
|
||||
int ui_file_browser_get_file_attrs(struct ui_browser *bro, int item,
|
||||
struct ui_file_attrs *attrs);
|
||||
|
||||
int ui_file_browser_set_file_attrs(struct ui_browser *bro, int item,
|
||||
struct ui_file_attrs *attrs);
|
||||
|
||||
void *ui_file_browser_open_file(struct ui_browser *bro, int item);
|
||||
|
||||
|
||||
int ui_file_browser_del_file(struct ui_browser *bro, int item);
|
||||
|
||||
int ui_file_browser_highlight_item(struct ui_browser *bro, int item, bool yes);
|
||||
|
||||
void *ui_file_browser_get_child_by_id(struct ui_browser *bro, int item, int id);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,60 @@
|
||||
/* Copyright(C) 2010- , JIELI TECHNOLOGY, Inc.
|
||||
* All right reserved.
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @file ui_button.h
|
||||
*
|
||||
* @brief 杰理UI按钮控件API
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version V1.0.0
|
||||
*
|
||||
* @date 2024-06-13
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __UI_BUTTON_WIDGET_H__
|
||||
#define __UI_BUTTON_WIDGET_H__
|
||||
|
||||
|
||||
#include "jlui/control.h"
|
||||
#include "jlui/ui_core.h"
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 按钮控件句柄结构
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct button {
|
||||
struct element elm;
|
||||
u8 image_index; // 图片索引
|
||||
u32 css[2]; // CSS属性指针
|
||||
const struct ui_button_info *info;
|
||||
const struct element_event_handler *handler;
|
||||
}; // 84byte
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 通过ID获取图片控件句柄
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
#define ui_button_for_id(id) \
|
||||
ui_element_for_id(id, struct button)
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_button_enable 按钮控件使能(内部调用)
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_button_enable();
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef UI_CAMERA_H
|
||||
#define UI_CAMERA_H
|
||||
|
||||
#include "jlui/control.h"
|
||||
#include "jlui/ui_core.h"
|
||||
|
||||
|
||||
#define ui_camera_for_id(id) \
|
||||
ui_element_for_id(id, struct ui_camera)
|
||||
|
||||
|
||||
struct ui_camera {
|
||||
struct element elm; //must be first
|
||||
int fd;
|
||||
const struct ui_camera_info *info;
|
||||
const struct element_event_handler *handler;
|
||||
};
|
||||
|
||||
|
||||
|
||||
void register_ui_camera_handler(const struct element_event_handler *handler);
|
||||
|
||||
int ui_camera_set_rect(int id, struct rect *r);
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
/* Copyright(C) 2010- , JIELI TECHNOLOGY, Inc.
|
||||
* All right reserved.
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @file ui_compass.h
|
||||
*
|
||||
* @brief 杰理UI指南针控件API
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version V1.0.0
|
||||
*
|
||||
* @date 2024-06-13
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __UI_COMPASS_WIDGET_H__
|
||||
#define __UI_COMPASS_WIDGET_H__
|
||||
|
||||
|
||||
#include "jlui/control.h"
|
||||
#include "jlui/ui_core.h"
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 指南针控件的子控件数量
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
#define COMPASS_CHILD_NUM (CTRL_COMPASS_CHILD_END - CTRL_COMPASS_CHILD_BEGIN)
|
||||
|
||||
|
||||
struct compass_pic_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
s16 cent_x;
|
||||
s16 cent_y;
|
||||
struct ui_image_list *img;
|
||||
};
|
||||
|
||||
|
||||
struct compass_css_info {
|
||||
s16 left;
|
||||
s16 top;
|
||||
s16 width;
|
||||
s16 height;
|
||||
};
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 指南针控件句柄结构
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct ui_compass {
|
||||
struct element elm;
|
||||
struct element child_elm[COMPASS_CHILD_NUM]; // 子控件单元 2个
|
||||
struct compass_css_info child_css[COMPASS_CHILD_NUM]; // 子控件CSS属性 2个
|
||||
char source[9]; // 数据源
|
||||
u8 ctrl_num; // 控件数量,从flash读进来
|
||||
u16 bk_angle; // 背景角度
|
||||
u32 indicator_angle: 9; // 指针角度
|
||||
u32 last_bk_angle: 9; // 上一次背景角度,用于判断是否要重新旋转图片进行刷新,如果当前角度和上一次角度不同才刷新
|
||||
u32 last_indicator_angle: 9; // 上一次指针角度,同上
|
||||
const struct layout_info *info;
|
||||
const struct compass_pic_info *pic_info[COMPASS_CHILD_NUM];
|
||||
const struct element_event_handler *handler;
|
||||
}; // 240byte
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 通过ID获取指南针控件句柄
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
#define ui_compass_for_id(id) \
|
||||
ui_element_for_id(id, struct ui_compass)
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_compass_enable 指南针控件使能(内部调用)
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_compass_enable();
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_compass_update 刷新指南针控件
|
||||
*
|
||||
* @param compass 指南针控件句柄
|
||||
* @param refresh 是否redraw(true redraw, false not redraw)
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_compass_update(struct ui_compass *compass, u8 refresh);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_compass_set_angle_by_id 设置指南针角度(带redraw)
|
||||
*
|
||||
* @param id 指南针控件ID
|
||||
* @param bk_angle 背景角度
|
||||
* @param indicator_angle 指针角度
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_compass_set_angle_by_id(int id, int bk_angle, int indicator_angle);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_compass_set_angle 设置指南针角度(不带redraw)
|
||||
*
|
||||
* @param compass 指南针控件句柄
|
||||
* @param bk_angle 背景图角度
|
||||
* @param indicator_angle 指针角度
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_compass_set_angle(struct ui_compass *compass, int bk_angle, int indicator_angle);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,109 @@
|
||||
#ifndef __BASIC_H__
|
||||
#define __BASIC_H__
|
||||
|
||||
#include "generic/typedef.h"
|
||||
#include "generic/rect.h"
|
||||
|
||||
#define ALIGN_MASK 0x3
|
||||
|
||||
#define COLOR_16_SWAP 0
|
||||
typedef union {
|
||||
struct {
|
||||
#if COLOR_16_SWAP == 0
|
||||
u16 blue : 5;
|
||||
u16 green : 6;
|
||||
u16 red : 5;
|
||||
#else
|
||||
u16 green_h : 3;
|
||||
u16 red : 5;
|
||||
u16 blue : 5;
|
||||
u16 green_l : 3;
|
||||
#endif
|
||||
} ch;
|
||||
u16 full;
|
||||
} color16_t;
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
u16 blue : 5;
|
||||
u16 green : 6;
|
||||
u16 red : 5;
|
||||
} ch;
|
||||
u16 full;
|
||||
} color16_l;
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
u16 green_h : 3;
|
||||
u16 red : 5;
|
||||
u16 blue : 5;
|
||||
u16 green_l : 3;
|
||||
} ch;
|
||||
u16 full;
|
||||
} color16_b;
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
u8 blue;
|
||||
u8 green;
|
||||
u8 red;
|
||||
u8 alpha;
|
||||
} ch;
|
||||
u32 full;
|
||||
} color32_t;
|
||||
|
||||
|
||||
typedef color16_t color_t;
|
||||
typedef color16_l color_l;
|
||||
typedef color16_b color_b;
|
||||
|
||||
struct gpu_blend_interface {
|
||||
void (*gpu_blend)(u8 *mask_buf, struct rect *mask_r, u8 *disp_buf, struct rect *disp_r, int color);
|
||||
void (*gpu_output)(u8 *mask_buf, struct rect *mask_r, u8 *disp_buf, struct rect *disp_r, int color);
|
||||
//expand
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
int ui_disp_line_buf_init();
|
||||
int ui_disp_line_buf_uninit();
|
||||
void *ui_disp_line_buf_malloc(int size);
|
||||
void ui_disp_line_buf_release(void *buf);
|
||||
int ui_disp_win_hor_res_get();
|
||||
|
||||
void ui_disp_buffer_rect_set(struct rect *rect);
|
||||
void ui_disp_buffer_rect_get(struct rect *rect);
|
||||
struct rect *ui_disp_dispbuf_rect_get();
|
||||
u8 *ui_disp_buffer_get();
|
||||
void ui_disp_buffer_set(u16 *buf, int buf_size);
|
||||
u16 ui_disp_get_buffer_size();
|
||||
u16 ui_disp_get_buffer_line(u16 width);
|
||||
void ui_disp_buffer_clear(struct rect *rect, color_t color);
|
||||
void ui_disp_buffer_flush(struct rect *rect, u8 *buffer);
|
||||
int ui_disp_out_stride_set(u16 stride);
|
||||
int ui_disp_out_stride_get();
|
||||
|
||||
int ui_gpu_buf_max_size_set(int max_size);
|
||||
int ui_gpu_buf_max_size_get();
|
||||
int ui_gpu_buf_init();
|
||||
int ui_gpu_buf_release();
|
||||
u8 *ui_gpu_buf_get();
|
||||
int ui_gpu_buf_clear();
|
||||
void ui_gpu_buf_set(u8 *buf, int size);
|
||||
int ui_gpu_buf_get_default_size();
|
||||
|
||||
void memset_fast(void *dst, u8 v, u32 len);
|
||||
void memset_ff(void *dst, u32 len);
|
||||
void memset_00(void *dst, u32 len);
|
||||
|
||||
void blend(u8 *mask_buf, int abs_x, int abs_y, int len, u8 calpha, color_t color);
|
||||
void blend_nopa(u8 *mask_buf, int abs_x, int abs_y, int len, color_t color);
|
||||
void blend_opa(u8 *mask_buf, int abs_x, int abs_y, int len, color_t color, u8 opa);
|
||||
void blend_map(u8 *mask_buf, int abs_x, int abs_y, int len, color_t *map);
|
||||
void blend_map_opa(u8 *mask_buf, int abs_x, int abs_y, int len, color_t *map, u8 opa);
|
||||
|
||||
int gpu_blend_init(struct gpu_blend_interface *api);
|
||||
void gpu_blend(u8 *mask_buf, struct rect *mask_r, u8 *disp_buf, struct rect *disp_r, int color);
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef __CIRCLE_H__
|
||||
#define __CIRCLE_H__
|
||||
|
||||
#include "typedef.h"
|
||||
#include "generic/rect.h"
|
||||
|
||||
#define RADIUS_CIRCLE (0x7FFF)
|
||||
|
||||
struct circle_info {
|
||||
s16 center_x;
|
||||
s16 center_y;
|
||||
s16 radius;
|
||||
u16 color;
|
||||
u8 alpha;
|
||||
u8 dont_output;
|
||||
};
|
||||
void draw_circle(int center_x, int center_y, int radius,
|
||||
u16 color, u8 alpha,
|
||||
u8 *buf, u32 buflen, struct rect *disp, struct rect *ctrl, int draw_id, int dont_output);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
#ifndef __UI_CURVE_GRAD_H__
|
||||
#define __UI_CURVE_GRAD_H__
|
||||
|
||||
|
||||
/* cg 为 curve gradient 缩写,避免 point 结构体命名与其它冲突 */
|
||||
struct cg_point {
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
|
||||
typedef struct {
|
||||
int x;
|
||||
int y;
|
||||
u8 alpha;
|
||||
} Pixel;
|
||||
|
||||
/* 绘制信息结构体 */
|
||||
struct curve_grad_info {
|
||||
int x;
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
struct cg_point *points;
|
||||
int points_num;
|
||||
int line_width;
|
||||
u32 color;
|
||||
};
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief create_a8_gradient 创建alpha渐变数组,渐变色宽度为start --> end
|
||||
*
|
||||
* @Params start 起始点索引(包含)
|
||||
* @Params end 结束点索引(包含)
|
||||
* @Params grid_max alpha的最大值
|
||||
*
|
||||
* @return 堆内存分配的渐变数组指针,需调用者释放
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
u8 *create_a8_gradient(int start, int end, int grid_max);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief compute_smooth_curve 通过离散点计算平滑曲线,曲线经过所有离散点
|
||||
*
|
||||
* 注意:
|
||||
* 1. 离散点必须时x坐标递增的;
|
||||
* 2. 平滑曲线点只计算y坐标,默认x坐标从0递增到points[points_num-1].x;
|
||||
* 3. 返回堆内存,需调用者释放内存。
|
||||
*
|
||||
* @Params points 离散点坐标列表
|
||||
* @Params points_num 离散点坐标数量
|
||||
* @Params x_max x坐标最大值,等于points[points_num - 1].x
|
||||
* @Params y_max y坐标最大值,所有点都在[0, y_max]区间
|
||||
*
|
||||
* @return 堆内存分配的平滑曲线y坐标数组指针,需调用者释放
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int *compute_smooth_curve(struct cg_point *points, int points_num, int x_max, int y_max);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief get_curve_grad_check 计算平滑曲线渐变图的校验值
|
||||
* 对折线的宽、高、坐标、线宽、颜色进行校验计算,如果校验值变化,则重新生成,否则只调整坐标。
|
||||
*
|
||||
* @Params points 离散点坐标列表
|
||||
* @Params points_num 离散点坐标数量
|
||||
* @Params draw_width 绘制宽度
|
||||
* @Params draw_height 绘制高度
|
||||
* @Params line_width 线宽
|
||||
* @Params color 颜色
|
||||
*
|
||||
* @return crc校验值
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
u32 get_curve_grad_check(struct cg_point *points, int points_num, int draw_width, int draw_height, int line_width, u32 color);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
#ifndef UI_FIGURE_H
|
||||
#define UI_FIGURE_H
|
||||
|
||||
#include "ui_draw/ui_circle.h"
|
||||
#include "ui_draw/ui_rect.h"
|
||||
#include "ui_draw/ui_basic.h"
|
||||
#include "ui_draw/ui_mask.h"
|
||||
#include "ui_draw/ui_curve_grad.h"
|
||||
//ui_draw_default_id
|
||||
#define DRAW_LINE 0x1
|
||||
#define DRAW_LINE_BY_ANGLE 0x2
|
||||
#define DRAW_RECT 0x3
|
||||
#define FILL_RECT 0x4
|
||||
#define DRAW_CIRCLE 0x5
|
||||
#define DRAW_RING 0x6
|
||||
#define DRAW_RING_CPU 0x7
|
||||
#define DRAW_BAR_CPU 0x8
|
||||
#define DRAW_LINEMETER 0x9
|
||||
#define DRAW_AIRECT 0xa
|
||||
#define DRAW_NEWLINE 0xb
|
||||
#define DRAW_POLY 0xc
|
||||
#define DRAW_SMOOTH_LINE 0xd
|
||||
#define DRAW_BAR 0xe
|
||||
#define DRAW_CURVE_GRAD 0xf
|
||||
|
||||
|
||||
typedef enum {
|
||||
DRAW_SLIDEBAR_HORIZONTAL_LEFT,
|
||||
DRAW_SLIDEBAR_HORIZONTAL_RIGHT,
|
||||
DRAW_SLIDEBAR_VERTICAL_TOP,
|
||||
DRAW_SLIDEBAR_VERTICAL_BTM,
|
||||
} SLIDEBAR_STYLE;
|
||||
|
||||
struct _line {
|
||||
int x_begin;
|
||||
int y_begin;
|
||||
int x_end;
|
||||
int y_end;
|
||||
int length;
|
||||
int angle;
|
||||
int color;
|
||||
};
|
||||
|
||||
struct _rect {
|
||||
struct rect rectangle;
|
||||
int color;
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief draw_line 画水平/垂直线段接口
|
||||
*
|
||||
* @param _dc dc
|
||||
* @param line_info 线段参数
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void draw_line(void *_dc, struct _line *line_info);
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief draw_line_by_angle 带角度的线段
|
||||
*
|
||||
* @param _dc dc
|
||||
* @param line_info 线段参数
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void draw_line_by_angle(void *_dc, struct _line *line_info);
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief draw_triangle 绘制三角形
|
||||
*
|
||||
* @param _dc dc
|
||||
* @param line_info1 边1参数
|
||||
* @param line_info2 边2参数
|
||||
* @param line_info3 边3参数
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void draw_triangle(void *_dc, struct _line *line_info1, struct _line *line_info2, struct _line *line_info3);
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief draw_rect 绘制矩形(非填充)
|
||||
*
|
||||
* @param _dc dc
|
||||
* @param rectangle 矩形参数
|
||||
* @param color 边框颜色
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void draw_rect(void *_dc, struct rect *rectangle, u16 color);
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief draw_circle_or_arc 绘制圆或弧
|
||||
*
|
||||
* @param _dc dc
|
||||
* @param info 圆/弧参数
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void draw_circle_or_arc(void *_dc, struct circle_info *info);
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_draw_default 绘制default_id的图形
|
||||
*
|
||||
* @param id 见ui_draw_default_id
|
||||
* @param dst_buf 屏显buffer
|
||||
* @param dst_r 屏显区域
|
||||
* @param src_r 绘制区域
|
||||
* @param bytes_per_pixel 像素字节数
|
||||
* @param priv 图像参数
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_draw_default(int id, u8 *dst_buf, struct rect *dst_r, struct rect *src_r, u8 bytes_per_pixel, void *priv);
|
||||
typedef void (*custom_draw_func)(int id, u8 *dst_buf, struct rect *dst_r, struct rect *src_r, u8 bytes_per_pixel, void *priv);
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_draw_curve_grad 绘制平滑曲线渐变图
|
||||
*
|
||||
* @Params _dc dc
|
||||
* @Params x 绘制x坐标
|
||||
* @Params y 绘制y坐标
|
||||
* @Params width 绘制宽度
|
||||
* @Params height 绘制高度
|
||||
* @Params points 离散点坐标列表
|
||||
* @Params points_num 离散点坐标数量
|
||||
* @Params line_width 曲线宽度(像素)
|
||||
* @Params color 绘制颜色
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_draw_curve_grad(void *_dc, int x, int y, int width, int height, struct cg_point *points, int points_num, int line_width, u32 color);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_draw_get_color 获取自定义绘图的配置颜色
|
||||
*
|
||||
* @Params id 自定义绘图功能ID
|
||||
* @Params priv 自定义绘图功能配置
|
||||
*
|
||||
* @return ARGB8565 颜色值
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
u32 ui_draw_get_color(u32 id, void *priv);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
#ifndef __MASK_H__
|
||||
#define __MASK_H__
|
||||
|
||||
#include "generic/typedef.h"
|
||||
#include "ui_draw/ui_type.h"
|
||||
#include "ui_draw/ui_math.h"
|
||||
|
||||
typedef u8(*mask_cb)(u8 *mask_buf, int abs_x, int abs_y, int len, void *p);
|
||||
|
||||
typedef struct {
|
||||
void *param;
|
||||
void *custom_id;
|
||||
} mask_info;
|
||||
|
||||
#define MASK_ID_INV (-1)
|
||||
#define MASK_MAX_NUM 16
|
||||
typedef mask_info mask_info_list[MASK_MAX_NUM];
|
||||
|
||||
enum {
|
||||
MASK_TYPE_LINE, //直线
|
||||
MASK_TYPE_ANGLE, //圆形扇区
|
||||
MASK_TYPE_RADIUS, //圆角矩形相关
|
||||
MASK_TYPE_FADE, //垂直渐变
|
||||
MASK_TYPE_MAP, //混合
|
||||
};
|
||||
|
||||
enum {
|
||||
MASK_LINE_SIDE_LEFT = 0,
|
||||
MASK_LINE_SIDE_RIGHT,
|
||||
MASK_LINE_SIDE_TOP,
|
||||
MASK_LINE_SIDE_BOTTOM,
|
||||
};
|
||||
|
||||
enum {
|
||||
MASK_RES_TRANSP, //全透明,mask_buf没有清0
|
||||
MASK_RES_FULL_COVER, //可见,mask_buf不变
|
||||
MASK_RES_CHANGED, //每个mask_buf都不一致
|
||||
MASK_RES_UNKNOWN //未定义
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
mask_cb cb;
|
||||
u8 type;
|
||||
} mask_common_dsc_t;
|
||||
|
||||
typedef struct {
|
||||
mask_common_dsc_t dsc;
|
||||
struct {
|
||||
struct draw_area rect;
|
||||
int radius;
|
||||
u8 outer: 1;
|
||||
} cfg;
|
||||
int y_prev;
|
||||
sqrt_res_t y_prev_x;
|
||||
} mask_radius_param_t;
|
||||
|
||||
typedef struct {
|
||||
mask_common_dsc_t dsc;
|
||||
struct {
|
||||
struct draw_point p1;
|
||||
struct draw_point p2;
|
||||
u8 side : 2;
|
||||
} cfg;
|
||||
struct draw_point origo;
|
||||
int xy_steep;
|
||||
int yx_steep;
|
||||
int steep;
|
||||
int spx;
|
||||
u8 flat : 1;
|
||||
u8 inv: 1;
|
||||
} mask_line_param_t;
|
||||
|
||||
typedef struct {
|
||||
mask_common_dsc_t dsc;
|
||||
struct {
|
||||
struct draw_point vertex_p;
|
||||
int start_angle;
|
||||
int end_angle;
|
||||
} cfg;
|
||||
mask_line_param_t start_line;
|
||||
mask_line_param_t end_line;
|
||||
u16 delta_deg;
|
||||
} mask_angle_param_t;
|
||||
|
||||
|
||||
void mask_angle_init(mask_angle_param_t *param, int vertex_x, int vertex_y, int start_angle, int end_angle);
|
||||
void mask_radius_init(mask_radius_param_t *param, const struct draw_area *rect, int radius, bool inv);
|
||||
void mask_line_points_init(mask_line_param_t *param, int p1x, int p1y, int p2x, int p2y, u8 side);
|
||||
void mask_line_angle_init(mask_line_param_t *param, int p1x, int py, int angle, u8 side);
|
||||
|
||||
int mask_add(void *param, void *custom_id);
|
||||
u8 mask_get_cnt(void);
|
||||
void *mask_remove_id(int id);
|
||||
u8 mask_apply(u8 *mask_buf, int abs_x, int abs_y, int len);
|
||||
|
||||
#define OPA_MIN 2
|
||||
#define OPA_MAX 253
|
||||
#define MATH_UDIV255(x) ((u32)((u32) (x) * 0x8081) >> 0x17)
|
||||
AT_UI_RAM
|
||||
static inline u8 mask_mix(u8 mask_act, u8 mask_new)
|
||||
{
|
||||
if (mask_new >= OPA_MAX) {
|
||||
return mask_act;
|
||||
}
|
||||
if (mask_new <= OPA_MIN) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 1
|
||||
return (((u32)mask_act * (u32)mask_new) >> 8);
|
||||
#else
|
||||
return MATH_UDIV255(mask_act * mask_new);// >> 8);
|
||||
#endif
|
||||
}
|
||||
|
||||
AT_UI_RAM
|
||||
static inline void *memcpy_small(void *dst, const void *src, u32 len)
|
||||
{
|
||||
|
||||
#if 1
|
||||
memcpy(dst, src, len);
|
||||
return dst;
|
||||
#else
|
||||
u8 *d8 = (u8 *)dst;
|
||||
const u8 *s8 = (const u8 *)src;
|
||||
|
||||
while (len) {
|
||||
*d8 = *s8;
|
||||
d8++;
|
||||
s8++;
|
||||
len--;
|
||||
}
|
||||
|
||||
return dst;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
AT_UI_RAM
|
||||
inline static void draw_area_copy(struct draw_area *dest, const struct draw_area *src)
|
||||
{
|
||||
memcpy_small(dest, src, sizeof(struct draw_area));
|
||||
}
|
||||
|
||||
AT_UI_RAM
|
||||
static inline int draw_area_get_width(const struct draw_area *area_p)
|
||||
{
|
||||
return (int)(area_p->x2 - area_p->x1 + 1);
|
||||
}
|
||||
|
||||
AT_UI_RAM
|
||||
static inline int draw_area_get_height(const struct draw_area *area_p)
|
||||
{
|
||||
return (int)(area_p->y2 - area_p->y1 + 1);
|
||||
}
|
||||
|
||||
AT_UI_RAM
|
||||
static inline int draw_area_get_size(const struct draw_area *area_p)
|
||||
{
|
||||
return (int)(area_p->x2 - area_p->x1 + 1) * (area_p->y2 - area_p->y1 + 1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
#ifndef __MATH_H__
|
||||
#define __MATH_H__
|
||||
|
||||
#include "generic/typedef.h"
|
||||
|
||||
typedef struct {
|
||||
u16 i;
|
||||
u16 f;
|
||||
} sqrt_res_t;
|
||||
|
||||
#define MATH_MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#define MATH_MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#ifndef MATH_ABS
|
||||
#define MATH_ABS(x) ((x) > 0 ? (x) : (-(x)))
|
||||
#endif
|
||||
#define TRIGO_SHIFT 15
|
||||
|
||||
int _trigo_sin(int angle);
|
||||
int _trigo_cos(int angle);
|
||||
void _sqrt(u32 x, sqrt_res_t *q, u32 mask);
|
||||
|
||||
AT_UI_RAM
|
||||
static inline void sqrt_approx(sqrt_res_t *q, sqrt_res_t *ref, u32 x)
|
||||
{
|
||||
// printf("_sq0: %d, %d\n", ref->i, x);
|
||||
x = x << 8;
|
||||
|
||||
u32 raw = (ref->i << 4) + (ref->f >> 4);
|
||||
u32 raw2 = raw * raw;
|
||||
|
||||
int d = x - raw2;
|
||||
d = (int)d / (int)(2 * raw) + raw;
|
||||
|
||||
q->i = d >> 4;
|
||||
q->f = (d & 0xF) << 4;
|
||||
// printf("_sq1: %d, %d\n", q->i, q->f);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,255 @@
|
||||
#ifndef UI_OBJ_H
|
||||
#define UI_OBJ_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
// #include <stddef.h>
|
||||
// #include <stdbool.h>
|
||||
// #include "generic/typedef.h"
|
||||
#include "ui_draw/ui_type.h"
|
||||
#include "ui_draw/ui_basic.h"
|
||||
#include "ui_draw/ui_mask.h"
|
||||
|
||||
|
||||
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define UI_USE_LINEMETER 1
|
||||
#define UI_USE_ARBIRECT 1
|
||||
#define UI_USE_LINE 1
|
||||
#define UI_USE_POLY 1
|
||||
|
||||
|
||||
#define UI_RADIUS_CIRCLE (0x7FFF)
|
||||
|
||||
#define ATTRIBUTE_FAST_MEM //AT_UI_RAM
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef signed char int8_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef signed short int16_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef signed int int32_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef long long int64_t;
|
||||
typedef int16_t ui_coord_t;
|
||||
typedef int16_t ui_style_int_t;
|
||||
typedef color_t ui_color_t;
|
||||
typedef uint8_t ui_opa_t;
|
||||
typedef uint8_t ui_grad_dir_t;
|
||||
typedef uint8_t ui_blend_mode_t;
|
||||
typedef struct draw_area ui_area_t;
|
||||
typedef struct draw_point ui_point_t;
|
||||
typedef uint8_t ui_draw_mask_res_t;
|
||||
|
||||
typedef struct _ui_style_list_t {
|
||||
ui_style_int_t scale_width;//刻度线的长度,大于等于10
|
||||
ui_color_t line_color;//活跃刻度线起始颜色,画线时表示线的颜色
|
||||
ui_color_t scale_grad_color;//活跃刻度线终止颜色
|
||||
ui_color_t scale_end_color;//非活跃刻度线颜色
|
||||
ui_style_int_t line_width;//刻度线的宽度,大于等于6,画线时表示线宽,最小可以为1
|
||||
} ui_style_list_t;
|
||||
|
||||
|
||||
struct _ui_obj_t;
|
||||
|
||||
|
||||
#define _COLOR_MAKE_TYPE_HELPER (ui_color_t)
|
||||
|
||||
# define COLOR_SET_R16(c, v) (c).ch.red = (uint8_t)((v) & 0x1FU)
|
||||
#if COLOR_16_SWAP == 0
|
||||
# define COLOR_SET_G16(c, v) (c).ch.green = (uint8_t)((v) & 0x3FU)
|
||||
#else
|
||||
# define COLOR_SET_G16(c, v) {(c).ch.green_h = (uint8_t)(((v) >> 3) & 0x7); (c).ch.green_l = (uint8_t)((v) & 0x7);}
|
||||
#endif
|
||||
# define COLOR_SET_B16(c, v) (c).ch.blue = (uint8_t)((v) & 0x1FU)
|
||||
# define COLOR_SET_A16(c, v) do {} while(0)
|
||||
|
||||
# define COLOR_GET_R16(c) (c).ch.red
|
||||
#if COLOR_16_SWAP == 0
|
||||
# define COLOR_GET_G16(c) (c).ch.green
|
||||
#else
|
||||
# define COLOR_GET_G16(c) (((c).ch.green_h << 3) + (c).ch.green_l)
|
||||
#endif
|
||||
# define COLOR_GET_B16(c) (c).ch.blue
|
||||
# define COLOR_GET_A16(c) 0xFF
|
||||
|
||||
#if COLOR_16_SWAP == 0
|
||||
# define _COLOR_ZERO_INITIALIZER16 {{0x00, 0x00, 0x00}}
|
||||
# define COLOR_MAKE16(r8, g8, b8) (_COLOR_MAKE_TYPE_HELPER{{(uint8_t)((b8 >> 3) & 0x1FU), (uint8_t)((g8 >> 2) & 0x3FU), (uint8_t)((r8 >> 3) & 0x1FU)}})
|
||||
#else
|
||||
# define _COLOR_ZERO_INITIALIZER16 {{0x00, 0x00, 0x00, 0x00}}
|
||||
# define COLOR_MAKE16(r8, g8, b8) (_COLOR_MAKE_TYPE_HELPER{{(uint8_t)((g8 >> 5) & 0x7U), (uint8_t)((r8 >> 3) & 0x1FU), (uint8_t)((b8 >> 3) & 0x1FU), (uint8_t)((g8 >> 2) & 0x7U)}})
|
||||
#endif
|
||||
|
||||
|
||||
# define COLOR_SET_R32(c, v) (c).ch.red = (uint8_t)((v) & 0xFF)
|
||||
# define COLOR_SET_G32(c, v) (c).ch.green = (uint8_t)((v) & 0xFF)
|
||||
# define COLOR_SET_B32(c, v) (c).ch.blue = (uint8_t)((v) & 0xFF)
|
||||
# define COLOR_SET_A32(c, v) (c).ch.alpha = (uint8_t)((v) & 0xFF)
|
||||
|
||||
# define COLOR_GET_R32(c) (c).ch.red
|
||||
# define COLOR_GET_G32(c) (c).ch.green
|
||||
# define COLOR_GET_B32(c) (c).ch.blue
|
||||
# define COLOR_GET_A32(c) (c).ch.alpha
|
||||
|
||||
# define _COLOR_ZERO_INITIALIZER32 {{0x00, 0x00, 0x00, 0x00}}
|
||||
# define COLOR_MAKE32(r8, g8, b8) (_COLOR_MAKE_TYPE_HELPER{{b8, g8, r8, 0xff}}) /*Fix 0xff alpha*/
|
||||
|
||||
|
||||
#define COLOR_SET_R(c, v) COLOR_SET_R16(c, v)
|
||||
#define COLOR_SET_G(c, v) COLOR_SET_G16(c, v)
|
||||
#define COLOR_SET_B(c, v) COLOR_SET_B16(c, v)
|
||||
#define COLOR_SET_A(c, v) COLOR_SET_A16(c, v)
|
||||
|
||||
#define COLOR_GET_R(c) COLOR_GET_R16(c)
|
||||
#define COLOR_GET_G(c) COLOR_GET_G16(c)
|
||||
#define COLOR_GET_B(c) COLOR_GET_B16(c)
|
||||
#define COLOR_GET_A(c) COLOR_GET_A16(c)
|
||||
|
||||
|
||||
|
||||
#define _COLOR_ZERO_INITIALIZER _COLOR_ZERO_INITIALIZER16
|
||||
#define COLOR_MAKE(r8, g8, b8) COLOR_MAKE16(r8, g8, b8)
|
||||
|
||||
|
||||
#define UI_COLOR_WHITE COLOR_MAKE(0xFF, 0xFF, 0xFF)
|
||||
#define UI_COLOR_SILVER COLOR_MAKE(0xC0, 0xC0, 0xC0)
|
||||
#define UI_COLOR_GRAY COLOR_MAKE(0x80, 0x80, 0x80)
|
||||
#define UI_COLOR_BLACK COLOR_MAKE(0x00, 0x00, 0x00)
|
||||
#define UI_COLOR_RED COLOR_MAKE(0xFF, 0x00, 0x00)
|
||||
#define UI_COLOR_MAROON COLOR_MAKE(0x80, 0x00, 0x00)
|
||||
#define UI_COLOR_YELLOW COLOR_MAKE(0xFF, 0xFF, 0x00)
|
||||
#define UI_COLOR_OLIVE COLOR_MAKE(0x80, 0x80, 0x00)
|
||||
#define UI_COLOR_LIME COLOR_MAKE(0x00, 0xFF, 0x00)
|
||||
#define UI_COLOR_GREEN COLOR_MAKE(0x00, 0x80, 0x00)
|
||||
#define UI_COLOR_CYAN COLOR_MAKE(0x00, 0xFF, 0xFF)
|
||||
#define UI_COLOR_AQUA UI_COLOR_CYAN
|
||||
#define UI_COLOR_TEAL COLOR_MAKE(0x00, 0x80, 0x80)
|
||||
#define UI_COLOR_BLUE COLOR_MAKE(0x00, 0x00, 0xFF)
|
||||
#define UI_COLOR_NAVY COLOR_MAKE(0x00, 0x00, 0x80)
|
||||
#define UI_COLOR_MAGENTA COLOR_MAKE(0xFF, 0x00, 0xFF)
|
||||
#define UI_COLOR_PURPLE COLOR_MAKE(0x80, 0x00, 0x80)
|
||||
#define UI_COLOR_ORANGE COLOR_MAKE(0xFF, 0xA5, 0x00)
|
||||
|
||||
|
||||
#define UI_COLOR_LZ COLOR_MAKE(0x80, 0x80, 0xFF)
|
||||
#define UI_COLOR_LB COLOR_MAKE(0x00, 0xFF, 0xFF)
|
||||
#define UI_COLOR_ZI COLOR_MAKE(0xFF, 0x00, 0xFF)
|
||||
|
||||
|
||||
|
||||
#ifndef COLOR_MIX_ROUND_OFS
|
||||
|
||||
#define COLOR_MIX_ROUND_OFS 128
|
||||
|
||||
// #if COLOR_DEPTH == 32
|
||||
// #define COLOR_MIX_ROUND_OFS 0
|
||||
// #else
|
||||
// #define COLOR_MIX_ROUND_OFS 128
|
||||
// #endif
|
||||
#endif
|
||||
|
||||
ATTRIBUTE_FAST_MEM static inline ui_color_t ui_color_mix(ui_color_t c1, ui_color_t c2, uint8_t mix)
|
||||
{
|
||||
ui_color_t ret;
|
||||
COLOR_SET_R(ret, MATH_UDIV255((uint16_t) COLOR_GET_R(c1) * mix + COLOR_GET_R(c2) *
|
||||
(255 - mix) + COLOR_MIX_ROUND_OFS));
|
||||
COLOR_SET_G(ret, MATH_UDIV255((uint16_t) COLOR_GET_G(c1) * mix + COLOR_GET_G(c2) *
|
||||
(255 - mix) + COLOR_MIX_ROUND_OFS));
|
||||
COLOR_SET_B(ret, MATH_UDIV255((uint16_t) COLOR_GET_B(c1) * mix + COLOR_GET_B(c2) *
|
||||
(255 - mix) + COLOR_MIX_ROUND_OFS));
|
||||
COLOR_SET_A(ret, 0xFF);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*To avoid overflow don't let the max ranges (reduce with 1000) */
|
||||
#define UI_COORD_MAX ((ui_coord_t)((uint32_t)((uint32_t)1 << (8 * sizeof(ui_coord_t) - 1)) - 1000))
|
||||
#define UI_COORD_MIN (-UI_COORD_MAX)
|
||||
|
||||
|
||||
|
||||
enum {
|
||||
UI_BORDER_SIDE_NONE = 0x00,
|
||||
UI_BORDER_SIDE_BOTTOM = 0x01,
|
||||
UI_BORDER_SIDE_TOP = 0x02,
|
||||
UI_BORDER_SIDE_LEFT = 0x04,
|
||||
UI_BORDER_SIDE_RIGHT = 0x08,
|
||||
UI_BORDER_SIDE_FULL = 0x0F,
|
||||
UI_BORDER_SIDE_INTERNAL = 0x10,
|
||||
_UI_BORDER_SIDE_LAST
|
||||
};
|
||||
|
||||
|
||||
enum {
|
||||
UI_GRAD_DIR_NONE,
|
||||
UI_GRAD_DIR_VER,
|
||||
UI_GRAD_DIR_HOR,
|
||||
_UI_GRAD_DIR_LAST
|
||||
};
|
||||
|
||||
|
||||
|
||||
enum {
|
||||
UI_OPA_TRANSP = 0,
|
||||
UI_OPA_0 = 0,
|
||||
UI_OPA_10 = 25,
|
||||
UI_OPA_20 = 51,
|
||||
UI_OPA_30 = 76,
|
||||
UI_OPA_40 = 102,
|
||||
UI_OPA_50 = 127,
|
||||
UI_OPA_60 = 153,
|
||||
UI_OPA_70 = 178,
|
||||
UI_OPA_80 = 204,
|
||||
UI_OPA_90 = 229,
|
||||
UI_OPA_100 = 255,
|
||||
UI_OPA_COVER = 255,
|
||||
};
|
||||
|
||||
|
||||
enum {
|
||||
UI_STATE_DEFAULT = 0x00,
|
||||
UI_STATE_CHECKED = 0x01,
|
||||
UI_STATE_FOCUSED = 0x02,
|
||||
UI_STATE_EDITED = 0x04,
|
||||
UI_STATE_HOVERED = 0x08,
|
||||
UI_STATE_PRESSED = 0x10,
|
||||
UI_STATE_DISABLED = 0x20,
|
||||
};
|
||||
typedef uint8_t ui_state_t;
|
||||
|
||||
typedef struct _ui_obj_t {
|
||||
ui_area_t coords; /**< Coordinates of the object (x1, y1, x2, y2)*/
|
||||
void *ext_attr; /**< Object type specific extended data*/
|
||||
|
||||
int ext_draw_pad; /**< EXTend the size in every direction for drawing. */
|
||||
|
||||
ui_state_t state;
|
||||
|
||||
ui_style_list_t style;
|
||||
} ui_obj_t;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*UI_OBJ_H*/
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
#ifndef __DRAW_RECT_H__
|
||||
#define __DRAW_RECT_H__
|
||||
|
||||
#include "generic/typedef.h"
|
||||
#include "ui_draw/ui_basic.h"
|
||||
#include "ui_draw/ui_mask.h"
|
||||
|
||||
#define COLOR_BLACK 0x0000
|
||||
|
||||
enum {
|
||||
OPA_TRANSP = 0,
|
||||
OPA_COVER = 255,
|
||||
};
|
||||
|
||||
enum {
|
||||
BORDER_SIDE_NONE = 0x00, //无边框
|
||||
BORDER_SIDE_BOTTOM = 0x01, //底部边框
|
||||
BORDER_SIDE_TOP = 0x02, //顶部边框
|
||||
BORDER_SIDE_LEFT = 0x04, //左边框
|
||||
BORDER_SIDE_RIGHT = 0x08, //右边框
|
||||
BORDER_SIDE_FULL = 0x0F, //四周边框
|
||||
BORDER_SIDE_INTERNAL = 0x10, //边境一侧内部
|
||||
_BORDER_SIDE_LAST
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
int draw_id;
|
||||
int radius;
|
||||
color_t bg_color;
|
||||
u8 bg_opa;
|
||||
u8 alpha;
|
||||
color_t border_color;
|
||||
int border_width;
|
||||
int border_side;
|
||||
u8 border_opa;
|
||||
} draw_rect_dsc_t;
|
||||
|
||||
typedef struct {
|
||||
int draw_id;
|
||||
color_t color;
|
||||
int width;
|
||||
u8 alpha;
|
||||
u8 opa;
|
||||
u8 round_start : 1;
|
||||
u8 round_end : 1;
|
||||
u8 dont_output : 1;
|
||||
} draw_line_dsc_t;
|
||||
void draw_rect_dsc_init(draw_rect_dsc_t *dsc);
|
||||
|
||||
bool draw_area_intersect(struct draw_area *res_p, const struct draw_area *a1_p, const struct draw_area *a2_p);
|
||||
void draw_rect_with_border(const struct draw_area *coords, const struct draw_area *clip, const draw_rect_dsc_t *dsc);
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef __TYPE_H__
|
||||
#define __TYPE_H__
|
||||
|
||||
#include "generic/typedef.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#define RGB565(r,g,b) (((((u8)r)>>3)<<11)|((((u8)g)>>2)<<5)|(((u8)b)>>3))
|
||||
|
||||
struct draw_area {
|
||||
int x1;
|
||||
int y1;
|
||||
int x2;
|
||||
int y2;
|
||||
};
|
||||
|
||||
struct draw_point {
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,238 @@
|
||||
#ifndef __UI_EFFECT_H__
|
||||
#define __UI_EFFECT_H__
|
||||
|
||||
|
||||
#include "generic/typedef.h"
|
||||
|
||||
|
||||
//注意!!!当有两个页面的时候,也就是滑屏的时候
|
||||
//1.一个页面需要做特效,另外一个不需要特效,那么
|
||||
//只需要配置做特效的那个页面的(effect_mode + copy)
|
||||
//2.两个页面都需要做特效,那么两个页面配置的
|
||||
//copy方式必须一致,但effect_mode可以不同
|
||||
//3.如果两个页面都不需要做特效,effect_mode = 0,
|
||||
//那么会默认以EFFECT_COPY_SPLIC方式拼接成一张大图
|
||||
|
||||
|
||||
|
||||
|
||||
#define EFFECT_COPY_SIGLE 2//单独存放页面,滑屏的时候有两个页面单独存放
|
||||
#define EFFECT_COPY_SPLIC 1//拼接成一个页面,不滑屏的时候只有一个页面
|
||||
|
||||
//effect_mode:高8位是effect_mode,低8位是进行特效前需要
|
||||
//将合成的页面拼接成一张大图还是单独存放
|
||||
//新加的特效宏要按顺序加1 !!!
|
||||
#define EFFECT_MODE_NONE (u16)(0)
|
||||
#define EFFECT_MODE_SCA (u16)((1 << 8) | EFFECT_COPY_SIGLE)//屏幕的宽和高都小于或者等于240时才可使用
|
||||
#define EFFECT_MODE_USER0 (u16)((2 << 8) | EFFECT_COPY_SPLIC)
|
||||
#define EFFECT_MODE_USER1 (u16)((3 << 8) | EFFECT_COPY_SIGLE)
|
||||
#define EFFECT_MODE_FLIP_SCA_ALPHA (u16)((4 << 8) | EFFECT_COPY_SIGLE)
|
||||
#define EFFECT_MODE_3D (u16)((5 << 8) | EFFECT_COPY_SIGLE)
|
||||
#define EFFECT_MODE_SCA_ALPHA (u16)((6 << 8) | EFFECT_COPY_SIGLE)
|
||||
#define EFFECT_MODE_REDRAW_PART (u16)((7 << 8) | EFFECT_COPY_SIGLE)
|
||||
#define EFFECT_MODE_AUTO_SCA_WITH_BG (u16)((8 << 8) | EFFECT_COPY_SIGLE)//页面间子菜单缩放切换
|
||||
#define EFFECT_MODE_GET_FRAME (u16)((9 << 8) | EFFECT_COPY_SIGLE)
|
||||
#define EFFECT_MODE_AUTO_SCA_WITH_FRAME (u16)((10 << 8) | EFFECT_COPY_SIGLE)//同一个页面的布局层子菜单缩放切换
|
||||
#define EFFECT_MODE_AUTO_PASS (u16)((11 << 8) | EFFECT_COPY_SIGLE)//子菜单滑动过渡切换效果
|
||||
#define EFFECT_MODE_DRAWER (u16)((12 << 8) | EFFECT_COPY_SIGLE)//抽屉效果
|
||||
#define EFFECT_MODE_AUTO_BIG_SCA (u16)((13 << 8) | EFFECT_COPY_SIGLE)//页面间缩放从2.0到1.0特效
|
||||
#define EFFECT_MODE_PAGE_MOVE (u16)((14 << 8) | EFFECT_COPY_SIGLE)//page_move
|
||||
|
||||
|
||||
|
||||
#define EFFECT_MODE_MAX (u16)14
|
||||
|
||||
//注意!!!这里高8要随着最大值加1而动态改变
|
||||
#define EFFECT_MODE_LIMIT (u16)(((EFFECT_MODE_MAX + 1) << 8) | EFFECT_COPY_SPLIC)
|
||||
enum EFFECT_MASK {
|
||||
EFFECT_MASK_NONE,
|
||||
EFFECT_MASK_CIRCULAR_BORDER, //圆屏边框裁剪
|
||||
EFFECT_MASK_ROUNDED_BORDER, //方屏边框裁剪
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
struct effect_ctrl {
|
||||
// u8 copy_to_psram;//EFFECT_COPY_SIGLE / EFFECT_COPY_SPLIC
|
||||
u8 *splicing_buf; //拼接buf
|
||||
u8 *psbuf[2]; //单独buf
|
||||
|
||||
u8 *sca_obuf; //硬件缩放的输出buf,内部缩放特效使用
|
||||
u8 *cache_buf[2]; //内部特效使用
|
||||
|
||||
int not_refresh;//特效处理完之后,是否推屏,置一表示不推屏
|
||||
|
||||
//由特效处理函数赋值,有特效时必须在特效处理函数里面赋值
|
||||
//1.滑屏的时候,如果ps_obuf = splicing_buf,表示特效处理完
|
||||
//之后还是放到原来的空间(对于那种不需要随着滑动而改变的特
|
||||
//效,只做一次就可以不断来回滑动),否则就是新的一块空间(该
|
||||
//空间只有一个页面大小)
|
||||
//2.不滑屏的时候,该值由特效本身决定
|
||||
u8 *ps_obuf;
|
||||
int mix;
|
||||
};
|
||||
|
||||
struct effect_part {
|
||||
int group;
|
||||
u8 *bg_addr;
|
||||
};
|
||||
|
||||
//用户自定义回调原型
|
||||
//ctrl:特效控制结构体 详细看结构体说明
|
||||
//cur_head:当前需要做特效的页面结构体(struct imb_task_head)
|
||||
//other_head:另外一个页面结构体,另外页面不一定需要做特效
|
||||
typedef void *(*effect_cb)(struct effect_ctrl *ctrl, void *cur_head, void *other_head);
|
||||
|
||||
|
||||
//EFFECT_MODE_SCA
|
||||
//1.取值范围0.3~1
|
||||
//2.可以不传该参数,内部使用1
|
||||
//3.参数要静态或者全局变量
|
||||
struct effect_ratio {
|
||||
float ratio_w;
|
||||
float ratio_h;
|
||||
};
|
||||
|
||||
|
||||
//EFFECT_MODE_SCA_ALPHA & EFFECT_MODE_FLIP_SCA_ALPHA
|
||||
//1.当作为EFFECT_MODE_FLIP_SCA_ALPHA模式的参数时,表示起始
|
||||
//的值 start_alpha,start_scale
|
||||
//2.可以不传该参数,内部使用默认的值(sca = 0.7, alpha = 64)
|
||||
//3.flip_all_en : 滑动时是否两页都做特效
|
||||
//4.mask_mode :EFFECT_MASK,只对EFFECT_MODE_AUTO_SCA_WITH_BG/EFFECT_MODE_GET_FRAME生效,增加时间开销
|
||||
//5.mask_priv : mask_mode == EFFECT_MASK_ROUNDED_BORDER 时,为方屏圆角半径
|
||||
//6.参数要静态或者全局变量
|
||||
struct effect_sca_alpha {
|
||||
float sca;
|
||||
int alpha;
|
||||
int flip_all_en;
|
||||
int cnt; // >=2 <=5
|
||||
int wait_te;
|
||||
int mask_mode;
|
||||
int mask_priv;
|
||||
};
|
||||
|
||||
//EFFECT_MODE_3D
|
||||
//1.focal取值100~1000,值越小变化越明显
|
||||
//2.可以不传该参数,内部使用默认的值(focal = 500)
|
||||
//3.参数要静态或者全局变量
|
||||
struct effect_3d {
|
||||
int focal;
|
||||
};
|
||||
|
||||
//EFFECT_MODE_REDRAW_PART
|
||||
//1.只合成第一部分的那一次存放的地址,内部使用
|
||||
//2.表示第一部分是否只合成一次,置一就只合成一次,然后做第一部分的特效时使用合成的那次作为输入
|
||||
//3.reflesh表示做完该特效后是否刷新显示
|
||||
//4.part1_effect_mode:该特效第一部分的特效模式
|
||||
//5.part1_effect_priv:该特效第一部分的特效参数
|
||||
//6.part1:第一部分的分组,分组是ui_core_set_group()函数分的组,只针对全屏布局
|
||||
//7.patr2:第二部分的分组,分组是ui_core_set_group()函数分的组,只针对全屏布局
|
||||
//8.参数要静态或者全局变量
|
||||
struct effect_redraw_part {
|
||||
u8 *part1_kick_buf;
|
||||
u8 part1_one_kick;
|
||||
u8 reflesh;
|
||||
|
||||
u16 part1_effect_mode;
|
||||
void *part1_effect_priv;
|
||||
struct effect_part part1;
|
||||
struct effect_part part2;
|
||||
};
|
||||
|
||||
//子菜单滑动过渡切换效果
|
||||
struct effect_auto_pass {
|
||||
int direction;//0:左到右 1:右到左
|
||||
int pl;//0:页面间切换 1:布局间切换
|
||||
};
|
||||
|
||||
//子菜单滑动过渡切换效果
|
||||
//从2.0缩放到1.0,带alpha会慢很多
|
||||
struct effect_auto_big_sca {
|
||||
int has_alpha;//是否带alpha
|
||||
int pl;//0:页面间切换 1:布局间切换
|
||||
int cnt;//0:使用默认,其他:cnt > 2,次数越多越慢
|
||||
};
|
||||
|
||||
|
||||
//抽屉效果参数
|
||||
struct drawer_item {
|
||||
struct list_head entry;
|
||||
int index;
|
||||
int page_id;
|
||||
struct rect ccoor;
|
||||
u8 *org_img;
|
||||
float sca;
|
||||
void *sca_info;
|
||||
};
|
||||
|
||||
struct drawer_ctl {
|
||||
int init;
|
||||
struct list_head head;
|
||||
struct drawer_item *first_ditem; //显示出来的item中的第一个
|
||||
struct drawer_item *cur_item;
|
||||
int status;
|
||||
|
||||
u8 *buf[3];
|
||||
u8 buf_busy;
|
||||
u8 has_new_item;
|
||||
|
||||
int max_cy_limit;
|
||||
int min_cy_limit;
|
||||
float ratio;
|
||||
};
|
||||
|
||||
|
||||
struct page_move_ctl {
|
||||
int l_left;
|
||||
int r_left;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//页面设置特效的唯一入口,在页面的图层或者全局的布局初始化的时候(ON_CHANGE_INIT)可以调用,如果id为-1,则可以在滑屏之前调用:
|
||||
//id:单个页面的id,如果为-1,则表示设置页面间滑动的特效
|
||||
//effect_mode:某个页面需要的特效,宏定义在ui_effect.h里面
|
||||
//user_effect:用户自定义特效处理的回调函数,可以为空,如果有值,库里面
|
||||
//会优先使用这个函数去处理该页面的特效,一般配对EFFECT_MODE_USER 0~N 使用
|
||||
//effect_priv:特效的私有值,可以为空,库里面会传递给特效处理函数
|
||||
//或者自定义特效回调函数
|
||||
int ui_window_effect(int id, u16 effect_mode, void *user_effect, void *effect_priv);
|
||||
|
||||
|
||||
//做特效时,可以控制页面停止刷新
|
||||
void ui_window_stop_redraw(int stop_redraw);
|
||||
|
||||
|
||||
/**
|
||||
* @brief ui_page_set_auto_sw_effect 使能页面跳转使用特效,只有psram版本能使用
|
||||
*
|
||||
* @param en 1:使能子菜单页面自动跳转特效 0:不使能
|
||||
*/
|
||||
void ui_page_set_auto_sw_effect(int en);
|
||||
|
||||
/**
|
||||
* @brief ui_page_get_auto_sw_effect 获取页面跳转特效使能状态
|
||||
*
|
||||
* @return 页面跳转使能状态
|
||||
*/
|
||||
int ui_page_get_auto_sw_effect();
|
||||
|
||||
/**
|
||||
* @brief ui_page_auto_sw_effect 页面跳转使用特效
|
||||
* 注意:该函数只能在ui任务里面使用,因为里面调用了ui_core_redraw, ui_core_show等相关的ui立即刷新页面的函数
|
||||
*
|
||||
* @param curr_win:页面ID或者layout ID(必须是全屏的布局),必须和next_win类型保持一致
|
||||
* @param next_win:页面ID或者layout ID(必须是全屏的布局),必须和curr_win类型保持一致
|
||||
* @param effect_mode:页面跳转的特效模式
|
||||
* @param user_effect:用户自定义页面跳转的特效处理的回调函数,可以为空
|
||||
* @param effect_priv:特效的私有值,可以为空,传递给特效处理函数
|
||||
*
|
||||
* @return -1:页面切换失败 0:页面切换成功
|
||||
*/
|
||||
int ui_page_auto_sw_effect(int curr_win, int next_win, u16 effect_mode, void *user_effect, void *effect_priv);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
#ifndef __BUFFER_MANAGER_H__
|
||||
#define __BUFFER_MANAGER_H__
|
||||
|
||||
|
||||
|
||||
// 缓存buf的状态定义
|
||||
typedef enum buffer_status_def {
|
||||
BUFFER_STATUS_INIT, // 初始
|
||||
BUFFER_STATUS_IDLE, // 空闲
|
||||
BUFFER_STATUS_LOCK, // 锁定
|
||||
BUFFER_STATUS_PEND, // 等待
|
||||
BUFFER_STATUS_USED, // 使用
|
||||
} BUFFER_STATUS;
|
||||
|
||||
|
||||
|
||||
// buffer管理原生API,不建议直接调用原生API,
|
||||
// 防止后续库升级导致调用方法改变,使用时请调用重封装的快捷调用
|
||||
int buffer_manager_set_default_handler(void *buffer_hdl);
|
||||
|
||||
void buffer_manager_set_memory_callback(void *(*malloc)(int size, u32 ram_type, u32 module_type), void (*free)(void *p, u32 ram_type, u32 module_type));
|
||||
|
||||
void *buffer_manager_init_handler(u32 buf_list[], int buf_num);
|
||||
|
||||
void buffer_manager_free_handler(void *buffer_hdl);
|
||||
|
||||
int buffer_manager_set_buf_status(void *buffer_hdl, void *buf, int status);
|
||||
|
||||
int buffer_manager_get_buf_status(void *buffer_hdl, void *buf);
|
||||
|
||||
void *buffer_manager_get_buf_by_status(void *buffer_hdl, int status);
|
||||
|
||||
void *buffer_manager_change_buf_status(void *buffer_hdl, int target, int result);
|
||||
|
||||
void *buffer_manager_status_dump(void *buffer_hdl);
|
||||
|
||||
/* buffer管理API快捷调用 */
|
||||
// 注册buffer管理模块的回调
|
||||
#define buffer_manager_callback(malloc, free) \
|
||||
buffer_manager_set_memory_callback(malloc, free)
|
||||
|
||||
// 初始化buffer管理,创建buffer管理句柄
|
||||
#define buffer_manager_init(hdl, buf, size, block_num) \
|
||||
{ \
|
||||
int BM_i = 0; \
|
||||
int BM_buf_size = (size) / (block_num); \
|
||||
u32 BM_buf_list[3] = {0}; \
|
||||
for (BM_i = 0; BM_i < (block_num); BM_i++) { \
|
||||
BM_buf_list[BM_i] = (u32)((buf) + (BM_buf_size * BM_i)); \
|
||||
} \
|
||||
(hdl) = buffer_manager_init_handler(BM_buf_list, (block_num)); \
|
||||
}
|
||||
|
||||
// 释放buffer管理资源和句柄
|
||||
#define buffer_manager_free(buffer_handler) \
|
||||
buffer_manager_free_handler(buffer_handler)
|
||||
|
||||
// 设置指定buffer的状态
|
||||
#define set_buffer_status(buffer_handler, buf_addr, status) \
|
||||
buffer_manager_set_buf_status(buffer_handler, buf_addr, status)
|
||||
|
||||
// 获取指定buffer的状态
|
||||
#define get_buffer_status(buffer_handler, buf_addr) \
|
||||
buffer_manager_get_buf_status(buffer_handler, buf_addr)
|
||||
|
||||
// 获取指定状态的buffer
|
||||
#define get_buffer_by_status(buffer_handler, status) \
|
||||
buffer_manager_get_buf_by_status(buffer_handler, status)
|
||||
|
||||
// 获取目标状态的buffer,并修改为结果状态
|
||||
#define change_buffer_status(buffer_handler, target, result) \
|
||||
buffer_manager_change_buf_status(buffer_handler, target, result)
|
||||
|
||||
|
||||
// 设置默认句柄,可以设置一个默认句柄,该句柄将作为buffer管理的静态变量,外部无需每次操作都传入该句柄
|
||||
// 需要注意的时,buffer_manager_free时,可以传入NULL来释放默认句柄,但大buffer还需外面主动释放
|
||||
// 即:buffer管理只做状态管理,和自身资源的申请、释放,不管被管理的buffer申请和释放
|
||||
#define set_default_buffer_handler(buffer_handler) \
|
||||
buffer_manager_set_default_handler(buffer_handler)
|
||||
|
||||
|
||||
|
||||
|
||||
/* 快捷获取指定状态的buffer */
|
||||
// 获取空闲状态的buffer
|
||||
#define get_idle_buffer(buffer_handler) \
|
||||
get_buffer_by_status(buffer_handler, BUFFER_STATUS_IDLE)
|
||||
|
||||
// 获取锁定状态的buffer
|
||||
#define get_lock_buffer(buffer_handler) \
|
||||
get_buffer_by_status(buffer_handler, BUFFER_STATUS_LOCK)
|
||||
|
||||
// 获取等待状态的buffer
|
||||
#define get_pend_buffer(buffer_handler) \
|
||||
get_buffer_by_status(buffer_handler, BUFFER_STATUS_PEND)
|
||||
|
||||
// 获取使用状态的buffer
|
||||
#define get_used_buffer(buffer_handler) \
|
||||
get_buffer_by_status(buffer_handler, BUFFER_STATUS_USED)
|
||||
|
||||
|
||||
|
||||
|
||||
/* 快捷获取指定状态的buffer,并修改buffer状态 */
|
||||
// 获取空闲状态的buffer,并修改为锁定状态
|
||||
#define get_idle_buffer_to_lock(buffer_handler) \
|
||||
change_buffer_status(buffer_handler, BUFFER_STATUS_IDLE, BUFFER_STATUS_LOCK)
|
||||
|
||||
// 获取锁定状态的buffer,并修改为等待状态
|
||||
#define get_lock_buffer_to_pend(buffer_handler) \
|
||||
change_buffer_status(buffer_handler, BUFFER_STATUS_LOCK, BUFFER_STATUS_PEND)
|
||||
|
||||
// 获取等待状态的buffer,并修改为使用状态
|
||||
#define get_pend_buffer_to_used(buffer_handler) \
|
||||
change_buffer_status(buffer_handler, BUFFER_STATUS_PEND, BUFFER_STATUS_USED)
|
||||
|
||||
// 获取使用状态的buffer,并修改为空闲状态
|
||||
#define get_used_buffer_to_idle(buffer_handler) \
|
||||
change_buffer_status(buffer_handler, BUFFER_STATUS_USED, BUFFER_STATUS_IDLE)
|
||||
|
||||
|
||||
|
||||
|
||||
/* 快捷设置指定buffer的状态 */
|
||||
// 设置buffer状态为空闲
|
||||
#define set_buffer_idle(buffer_handler, buf) \
|
||||
set_buffer_status(buffer_handler, buf, BUFFER_STATUS_IDLE)
|
||||
|
||||
// 设置buffer状态为锁定
|
||||
#define set_buffer_lock(buffer_handler, buf) \
|
||||
set_buffer_status(buffer_handler, buf, BUFFER_STATUS_LOCK)
|
||||
|
||||
// 设置buffer状态为等待
|
||||
#define set_buffer_pend(buffer_handler, buf) \
|
||||
set_buffer_status(buffer_handler, buf, BUFFER_STATUS_PEND)
|
||||
|
||||
// 设置buffer状态为使用
|
||||
#define set_buffer_used(buffer_handler, buf) \
|
||||
set_buffer_status(buffer_handler, buf, BUFFER_STATUS_USED)
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @file time_count.h
|
||||
*
|
||||
* @brief 时间探针,用于粗略记录程序执行时间
|
||||
*
|
||||
* 使用方法:
|
||||
* 1. 在程序开始执行的位置调用 time_count_start;
|
||||
* 2. 在程序结束执行的位置调用 time_count_end;
|
||||
* 3. 保证 start 和 end 时传入的 id 一致、模块会自动在程序结束位置打印出执行时间,单位 us;
|
||||
* 4. 若打印出 Error 信息,说明 start 和 end 时传入的 id 不一致;
|
||||
* 5. 此方法仅用于粗略统计程序执行时间,非精确时间。可用于性能调试参考。
|
||||
* 注意:
|
||||
* 本模块接口仅应用层可以调用,库里调用会导致宏开关无法关闭,造成资源浪费。
|
||||
* 每start一个时间,会malloc 20byte空间占用,end时会释放
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version V1.0.0
|
||||
*
|
||||
* @date 2025-03-18
|
||||
*
|
||||
* Copyright(C) 2010- , JIELI TECHNOLOGY, Inc.
|
||||
* All right reserved.
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __TIME_COUNT_H__
|
||||
#define __TIME_COUNT_H__
|
||||
|
||||
// 程序计数功能使能
|
||||
#define TIME_COUNT_ENABLE 0
|
||||
|
||||
|
||||
#if (defined TIME_COUNT_ENABLE && TIME_COUNT_ENABLE)
|
||||
|
||||
#define time_count_start(id) \
|
||||
time_count_pushing(id)
|
||||
|
||||
#define time_count_end(id) \
|
||||
{ \
|
||||
printf("%s(), %d, time count id: %d, time: %llu us\n", __func__, __LINE__, id, time_count_popping(id)); \
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define time_count_start(id)
|
||||
|
||||
#define time_count_end(id)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief time_count_pushing 将当前时间压入计时栈中
|
||||
*
|
||||
* @Params id 为当前时间命名的id,用于计时出栈时计算运行时间
|
||||
*
|
||||
* @return 当前时间
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
u64 time_count_pushing(u32 id);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief time_count_popping 统计指定ID的程序段运行时间,并将该时间出栈
|
||||
*
|
||||
* @Params id 需要统计时间的ID号,与计时入栈时传入的ID一致
|
||||
*
|
||||
* @return 指定ID的程序段运行时间,如果指定ID没有入栈,则返回当前时间,并打印错误提示
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
u64 time_count_popping(u32 id);
|
||||
|
||||
|
||||
#endif // !__TIME_COUNT_H__
|
||||
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
/* Copyright(C) 2010- , JIELI TECHNOLOGY, Inc.
|
||||
* All right reserved.
|
||||
*/
|
||||
|
||||
#ifndef __UI_ADDR_H__
|
||||
#define __UI_ADDR_H__
|
||||
|
||||
#include "system/malloc.h"
|
||||
#include "asm/psram_api.h"
|
||||
|
||||
|
||||
/* ================================= FLASH 地址处理 ================================= */
|
||||
|
||||
/* 判断地址是否在 flash 范围内 */
|
||||
#define UI_ADDR_IN_FLASH(addr) (memory_in_flash((const void *)(addr)))
|
||||
|
||||
/* 判断地址是否在 flash cache 范围内 */
|
||||
#define UI_ADDR_IN_FLASH_CACHE(addr) (memory_in_flash_cache((const void *)(addr)))
|
||||
|
||||
/* 判断地址是否在 flash nocache 范围内 */
|
||||
#define UI_ADDR_IN_FLASH_NOCACHE(addr) (memory_in_flash_nocache((const void *)(addr)))
|
||||
|
||||
|
||||
/* ================================= SRAM 地址处理 ================================= */
|
||||
|
||||
/* 判断地址是否在物理 RAM 范围内 */
|
||||
#define UI_ADDR_IN_PHY_RAM(addr) (memory_in_phy((const void *)(addr)))
|
||||
|
||||
/* 判断地址是否在虚拟 RAM 范围内 */
|
||||
#define UI_ADDR_IN_VLT_RAM(addr) (memory_in_vtl((const void *)(addr)))
|
||||
|
||||
/* 判断地址是否为 RAM 地址 */
|
||||
#define UI_ADDR_IN_RAM(addr) (UI_ADDR_IN_PHY_RAM(addr) || UI_ADDR_IN_VLT_RAM(addr))
|
||||
|
||||
|
||||
|
||||
/* ================================= PSRAM 地址处理 ================================= */
|
||||
|
||||
/* 判断地址是否在 PSRAM 范围 */
|
||||
#define UI_ADDR_IN_PSRAM(addr) (UI_ADDR_IN_PSRAM_NOCACHE(addr) || UI_ADDR_IN_PSRAM_CACHE(addr))
|
||||
|
||||
/* 判断地址是否在 PSRAM nocache 范围*/
|
||||
#define UI_ADDR_IN_PSRAM_NOCACHE(addr) (psram_no_cache_check((void *)(addr)))
|
||||
|
||||
/* 判断地址是否在 PSRAM cache 范围 */
|
||||
#define UI_ADDR_IN_PSRAM_CACHE(addr) (psram_cache_check((void *)(addr)))
|
||||
|
||||
/* PSRAM cache 地址转 nocache*/
|
||||
#define UI_PSRAM_CACHE_TO_NOCACHE(addr) (UI_ADDR_IN_PSRAM_CACHE(addr) ? ((void *)psram_cache_2_no_cache((void *)(addr))) : (void *)(addr))
|
||||
|
||||
/* PSRAM nocache 地址转 cache */
|
||||
#define UI_PSRAM_NOCACHE_TO_CACHE(addr) (UI_ADDR_IN_PSRAM_NOCACHE(addr) ? ((void *)psram_no_cache_2_cache((void *)(addr))) : (void *)(addr))
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
|
||||
#ifndef __UI_COLOR_H__
|
||||
#define __UI_COLOR_H__
|
||||
|
||||
|
||||
// RGB555
|
||||
#define TO_RGB555(R,G,B) (((((u8)(R))>>3)<<10) | ((((u8)(G))>>3)<<5) | (((u8)(B))>>3))
|
||||
#define TO_ARGB8555(A,R,G,B) ((((u8)(A))<<16) | TO_RGB555(R,G,B))
|
||||
|
||||
#define RGB555_R(C) ((u8)((((C)>>10)&0x1f)<<3)|0x7)
|
||||
#define RGB555_G(C) ((u8)((((C)>>5)&0x1f)<<3)|0x7)
|
||||
#define RGB555_B(C) ((u8)(((C)&0x1f)<<3)|0x7)
|
||||
|
||||
#define ARGB8555_A(C) ((u8)((C)>>16))
|
||||
#define ARGB8555_R(C) RGB555_R(C)
|
||||
#define ARGB8555_G(C) RGB555_G(C)
|
||||
#define ARGB8555_B(C) RGB555_B(C)
|
||||
|
||||
|
||||
// RGB565
|
||||
#define TO_RGB565(R,G,B) (((((u8)(R))>>3)<<11) | ((((u8)(G))>>2)<<5) | (((u8)(B))>>3))
|
||||
#define TO_ARGB8565(A,R,G,B) ((((u8)(A))<<16) | TO_RGB565(R,G,B))
|
||||
|
||||
#define RGB565_R(C) ((u8)(((((C)>>11)&0x1f)<<3)|0x7))
|
||||
#define RGB565_G(C) ((u8)(((((C)>>5)&0x3f)<<2)|0x3))
|
||||
#define RGB565_B(C) ((u8)((((C)&0x1f)<<3)|0x7))
|
||||
|
||||
#define ARGB8565_A(C) ((u8)((C)>>16))
|
||||
#define ARGB8565_R(C) RGB565_R(C)
|
||||
#define ARGB8565_G(C) RGB565_G(C)
|
||||
#define ARGB8565_B(C) RGB565_B(C)
|
||||
|
||||
|
||||
// RGB888
|
||||
#define TO_RGB888(R,G,B) ((((u8)(R))<<16) | (((u8)(G))<<8) | (((u8)(B))))
|
||||
#define TO_ARGB8888(A,R,G,B) ((((u8)(A))<<24) | TO_RGB888(R,G,B))
|
||||
|
||||
#define RGB888_R(C) ((u8)((C)>>16))
|
||||
#define RGB888_G(C) ((u8)((C)>>8))
|
||||
#define RGB888_B(C) ((u8)((C)&0xff))
|
||||
|
||||
#define ARGB8888_A(C) ((u8)((C)>>24))
|
||||
#define ARGB8888_R(C) RGB888_R(C)
|
||||
#define ARGB8888_G(C) RGB888_G(C)
|
||||
#define ARGB8888_B(C) RGB888_B(C)
|
||||
|
||||
|
||||
// 555转565、888
|
||||
#define RGB555_TO_RGB565(C) TO_RGB565(RGB555_R(C),RGB555_G(C),RGB555_B(C))
|
||||
#define RGB555_TO_RGB888(C) TO_RGB888(RGB555_R(C),RGB555_G(C),RGB555_B(C))
|
||||
#define ARGB8555_TO_ARGB8565(C) TO_ARGB8565(ARGB8555_A(C),ARGB8555_R(C),ARGB8555_G(C),ARGB8555_B(C))
|
||||
#define ARGB8555_TO_ARGB8888(C) TO_ARGB8888(ARGB8555_A(C),ARGB8555_R(C),ARGB8555_G(C),ARGB8555_B(C))
|
||||
|
||||
// 565转555、888
|
||||
#define RGB565_TO_RGB555(C) TO_RGB555(RGB565_R(C),RGB565_G(C),RGB565_B(C))
|
||||
#define RGB565_TO_RGB888(C) TO_RGB888(RGB565_R(C),RGB565_G(C),RGB565_B(C))
|
||||
#define ARGB8565_TO_ARGB8555(C) TO_ARGB8555(ARGB8565_A(C),ARGB8565_R(C),ARGB8565_G(C),ARGB8565_B(C))
|
||||
#define ARGB8565_TO_ARGB8888(C) TO_ARGB8888(ARGB8565_A(C),ARGB8565_R(C),ARGB8565_G(C),ARGB8565_B(C))
|
||||
|
||||
// 888转555、565
|
||||
#define RGB888_TO_RGB555(C) TO_RGB555(RGB888_R(C),RGB888_G(C),RGB888_B(C))
|
||||
#define RGB888_TO_RGB565(C) TO_RGB565(RGB888_R(C),RGB888_G(C),RGB888_B(C))
|
||||
#define ARGB8888_TO_ARGB8555(C) TO_ARGB8555(ARGB8888_A(C),ARGB8888_R(C),ARGB8888_G(C),ARGB8888_B(C))
|
||||
#define ARGB8888_TO_ARGB8565(C) TO_ARGB8565(ARGB8888_A(C),ARGB8888_R(C),ARGB8888_G(C),ARGB8888_B(C))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
#ifndef __PUBLIC_UI_EXPAND_H__
|
||||
#define __PUBLIC_UI_EXPAND_H__
|
||||
|
||||
|
||||
#ifndef ABS
|
||||
#define ABS(x) (((x) > 0) ? (x) : (-(x))) // 整形绝对值
|
||||
#endif
|
||||
|
||||
#ifndef INV
|
||||
#define INV(x) (((x) > 0) ? (-(x)) : (x)) // 取反向值
|
||||
#endif
|
||||
|
||||
#ifndef ASS
|
||||
#define ASS(a, x) (((a) > 0) ? ABS(x) : INV(x)) // 取a同号
|
||||
#endif
|
||||
|
||||
#ifndef OPE
|
||||
#define OPE(x) (((x) > 0) ? 1 : (-1)) // 取x符号
|
||||
#endif
|
||||
|
||||
#ifndef FABS
|
||||
#define FABS(x) (((x) < 0.0f) ? (-(x)) : (x)) // 浮点绝对值
|
||||
#endif
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a, b) (((a) > (b)) ? (a) : (b)) // 取较大值
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b)) // 取较小值
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef UI_PI
|
||||
#define UI_PI 3.14159265f // 定义PI
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef ANGLE_TO_RADIAN
|
||||
#define ANGLE_TO_RADIAN(a) (((a) * (UI_PI)) / 180.0f) // 角度转弧度
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef RADIAN_TO_ANGLE
|
||||
#define RADIAN_TO_ANGLE(r) (((r) * 180.0f) / (UI_PI)) // 弧度转角度
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef INT_MAX
|
||||
#define INT_MAX (0x7FFFFFFF) // 2147483647
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef INT_MIN
|
||||
#define INT_MIN (-INT_MAX - 1)
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef U16_MAX
|
||||
#define U16_MAX (65535) // u16 最大值
|
||||
#endif
|
||||
|
||||
|
||||
// 字符串HASH化,djb2
|
||||
#ifndef HASH_STRING
|
||||
#define HASH_STRING(str) ({ \
|
||||
unsigned int hash = 5381; \
|
||||
const char *s = str; \
|
||||
while (*s) { \
|
||||
hash = ((hash << 5) + hash) + (*s++); \
|
||||
} \
|
||||
hash; \
|
||||
})
|
||||
#endif
|
||||
|
||||
|
||||
// 计算数组长度
|
||||
#ifndef ARRAY_LEN
|
||||
#define ARRAY_LEN(array) (sizeof(array)/sizeof(array[0]))
|
||||
#endif
|
||||
|
||||
|
||||
#define DUMP_RECT(func, line, name, rect) \
|
||||
printf("[RECT] %s() %d, %s [%d, %d, %d, %d]\n", func, line, name, (rect)->left, (rect)->top, (rect)->width, (rect)->height)
|
||||
|
||||
#define JLUI_RECT_TO_CSS(x, X) (x)//((x) * 10000 / (X)) // 绝对坐标转相对坐标
|
||||
#define JLUI_CSS_TO_RECT(c, C) ((c) * (C) / 10000) // 相对坐标转绝对坐标
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
|
||||
#ifndef __UI_SCROLL_VIEW_H__
|
||||
#define __UI_SCROLL_VIEW_H__
|
||||
|
||||
|
||||
|
||||
typedef struct ui_scrollview_t {
|
||||
u16 timer_id; // 定时器ID
|
||||
u16 interval; // 定时器中断间隔
|
||||
void *priv; // 私有参数
|
||||
|
||||
int pos;
|
||||
|
||||
int record;
|
||||
int cursor;
|
||||
int target;
|
||||
|
||||
int min_pos;
|
||||
int max_pos;
|
||||
int bounces;
|
||||
|
||||
int velocity;
|
||||
int distance;
|
||||
|
||||
int scroll_mode;
|
||||
int align_mode;
|
||||
|
||||
int align_gap;
|
||||
int align_dir; // 对齐方向
|
||||
|
||||
|
||||
int (*cb)(struct ui_scrollview_t *s, void *priv, int pos);
|
||||
} ui_scrollview_t, *pui_scrollview_t;
|
||||
|
||||
|
||||
int ui_scrollview_init(ui_scrollview_t *s, void *priv, int pos, int (*cb)(ui_scrollview_t *s, void *priv, int pos));
|
||||
int ui_scrollview_free(ui_scrollview_t *s);
|
||||
int ui_scrollview_stop(ui_scrollview_t *s);
|
||||
|
||||
int ui_scrollview_set_bounces(ui_scrollview_t *s, int bounces);
|
||||
int ui_scrollview_set_scroll_area(ui_scrollview_t *s, int min, int max);
|
||||
int ui_scrollview_set_align_by_gap(ui_scrollview_t *s, int gap);
|
||||
int ui_scrollview_set_align_by_tab(ui_scrollview_t *s, int *tab, int size);
|
||||
|
||||
int ui_scrollview_auto_align(ui_scrollview_t *s);
|
||||
int ui_scrollview_move_offset(ui_scrollview_t *s, int offset);
|
||||
int ui_scrollview_move_accrue(ui_scrollview_t *s, int offset);
|
||||
int ui_scrollview_move_velocity(ui_scrollview_t *s, int v);
|
||||
int ui_scrollview_move_distance(ui_scrollview_t *s, int dist);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,847 @@
|
||||
/* Copyright(C) 2010- , JIELI TECHNOLOGY, Inc.
|
||||
* All right reserved.
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @file ui_grid.h
|
||||
*
|
||||
* @brief 杰理UI表格控件API
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version V1.0.0
|
||||
*
|
||||
* @date 2024-06-13
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __UI_GRID_WIDGET_H__
|
||||
#define __UI_GRID_WIDGET_H__
|
||||
|
||||
|
||||
#include "ui_animation.h"
|
||||
#include "jlui/ui_core.h"
|
||||
#include "jlui/control.h"
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
enum {
|
||||
GRID_SCROLL_MODE,
|
||||
GRID_PAGE_MODE,
|
||||
};
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 列表滚动方向
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
enum {
|
||||
SCROLL_DIRECTION_NONE,
|
||||
SCROLL_DIRECTION_LR,
|
||||
SCROLL_DIRECTION_UD,
|
||||
};
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 自动居中类型选项
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
typedef enum {
|
||||
NO_AUTO_CENTER,
|
||||
AUTO_CENTER_MODE1,//滑动惯性距离小于1/2屏幕时回弹
|
||||
AUTO_CENTER_MODE2,//滑动惯性较小时依然能滑向下一项
|
||||
AUTO_CENTER_CUSTOM,//自定义滑动处理
|
||||
} AUTO_CENTER_MODE;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct ui_grid_item_info {
|
||||
u8 row;
|
||||
u8 col;
|
||||
u8 page_mode;
|
||||
u8 highlight_index;
|
||||
u16 interval;
|
||||
struct layout_info *info;
|
||||
};
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 列表显示/滚动区域
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct scroll_area {
|
||||
s16 left;
|
||||
s16 top;
|
||||
s16 right;
|
||||
s16 bottom;
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 动态列表info
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct ui_grid_dynamic {
|
||||
int dhi_index;
|
||||
int dcol_num;
|
||||
int drow_num;
|
||||
|
||||
int min_row_index;
|
||||
int max_row_index;
|
||||
int min_col_index;
|
||||
int max_col_index;
|
||||
int min_show_row_index;
|
||||
int max_show_row_index;
|
||||
int min_show_col_index;
|
||||
int max_show_col_index;
|
||||
|
||||
int grid_xval;
|
||||
int grid_yval;
|
||||
u8 grid_col_num;
|
||||
u8 grid_row_num;
|
||||
u8 grid_show_row;
|
||||
u8 grid_show_col;
|
||||
int base_index_once;
|
||||
int init_step_once;
|
||||
};
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 列表元素
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct ui_grid {
|
||||
struct element elm;
|
||||
|
||||
int max_show_left;
|
||||
int max_show_top;
|
||||
int min_show_left;
|
||||
int min_show_top;
|
||||
|
||||
int max_left;
|
||||
int max_top;
|
||||
int min_left;
|
||||
int min_top;
|
||||
|
||||
s16 x_interval;
|
||||
s16 y_interval;
|
||||
|
||||
char hi_index;
|
||||
char touch_index;
|
||||
char cur_dindex;
|
||||
char onfocus;
|
||||
|
||||
u8 col_num;
|
||||
u8 row_num;
|
||||
u8 show_row;
|
||||
u8 show_col;
|
||||
|
||||
u8 avail_item_num;
|
||||
u8 ctrl_num;
|
||||
char touch_hi_index;
|
||||
u8 tslide;
|
||||
// u8 page;
|
||||
u8 page_mode: 2;
|
||||
u8 slide_direction: 2;
|
||||
u8 pix_scroll: 1;
|
||||
u8 child_init: 1;
|
||||
u8 flick_close: 1;
|
||||
u8 flick_unlock: 1;
|
||||
u8 flick_top: 1;
|
||||
u8 center_enable: 4; //
|
||||
u8 energy_status: 3;
|
||||
|
||||
u16 flick_distance;
|
||||
|
||||
u16 center_target_line; //居中目标中线位置
|
||||
u16 center_next_threshold; //滑入下一项阈值
|
||||
|
||||
int anim_tmp;
|
||||
float anim_a; //参考值 -0.04
|
||||
float anim_val; //参考值2
|
||||
|
||||
ui_anim_t anim;
|
||||
ui_anim_ready_cb_t ready_cb;
|
||||
ui_anim_deleted_cb_t deleted_cb;
|
||||
|
||||
struct scroll_area *area;
|
||||
struct scroll_area limit_area;
|
||||
struct layout *item;
|
||||
struct layout_info *item_info;
|
||||
struct ui_grid_dynamic *dynamic;
|
||||
struct position pos;
|
||||
struct position down_pos;
|
||||
struct draw_context dc;
|
||||
struct element_touch_event *e;
|
||||
const struct ui_grid_info *info;
|
||||
const struct element_event_handler *handler;
|
||||
u8 key_jump;
|
||||
u8 key_cnt: 5; //计数
|
||||
u8 key_dir: 1; //方向
|
||||
u8 key_sta: 2; //状态
|
||||
u8 center_item_offset; //最大偏移项数
|
||||
void (*highlight_ajust)(struct ui_grid *grid, int direction);
|
||||
void (*end_once)(struct ui_grid *grid);
|
||||
}; //
|
||||
enum {
|
||||
UI_GRID_KEY_STA_CLOSE,//
|
||||
UI_GRID_KEY_STA_STOP,
|
||||
UI_GRID_KEY_STA_START,
|
||||
UI_GRID_KEY_STA_CENTER,
|
||||
};
|
||||
enum {
|
||||
UI_GRID_KEY_DIR_MINUS,
|
||||
UI_GRID_KEY_DIR_PLUS,
|
||||
};
|
||||
extern const struct element_event_handler grid_elm_handler;
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 通过ID获取表格控件句柄
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
#define ui_grid_for_id(id) \
|
||||
ui_element_for_id(id, struct ui_grid)
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_enable
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_grid_enable();
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_on_focus 列表作为焦点控件
|
||||
*
|
||||
* @param grid 列表控件句柄
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_grid_on_focus(struct ui_grid *grid);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_lose_focus 列表不作为焦点控件
|
||||
*
|
||||
* @param grid 列表控件句柄
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_grid_lose_focus(struct ui_grid *grid);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_state_reset 重置列表状态
|
||||
*
|
||||
* @param grid 列表控件句柄
|
||||
* @param highlight_item 默认高亮项
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_grid_state_reset(struct ui_grid *grid, int highlight_item);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_highlight_item 设置列表高亮项
|
||||
*
|
||||
* @param grid 列表控件句柄
|
||||
* @param item 高亮项索引
|
||||
* @param yes 高亮/非高亮
|
||||
*
|
||||
* @return 0,正常;其他,异常
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_grid_highlight_item(struct ui_grid *grid, int item, bool yes);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_highlight_item_by_id 设置列表高亮项
|
||||
*
|
||||
* @param id 列表控件id
|
||||
* @param item 高亮项索引
|
||||
* @param yes 高亮/非高亮
|
||||
*
|
||||
* @return 0,正常;其他,异常
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_grid_highlight_item_by_id(int id, int item, bool yes);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief __ui_grid_new 创建列表控件
|
||||
*
|
||||
* @param css 控件css属性
|
||||
* @param id 控件id
|
||||
* @param info 列表项信息
|
||||
* @param parent 父控件句柄
|
||||
*
|
||||
* @return 列表句柄
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct ui_grid *__ui_grid_new(struct element_css1 *css, int id, struct ui_grid_item_info *info, struct element *parent);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_child_init 自动化初始化
|
||||
*
|
||||
* @param grid 列表控件句柄
|
||||
* @param info 列表子控件info
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_grid_child_init(struct ui_grid *grid, struct ui_grid_info *info);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_set_slide_direction 设置列表滑动方向
|
||||
*
|
||||
* @param grid 列表控件句柄
|
||||
* @param dir 列表滑动方向
|
||||
*
|
||||
* @return 0,正常;其他,异常
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_grid_set_slide_direction(struct ui_grid *grid, int dir);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief grid_key_jump 静态垂直或者水平列表才能使用,用于使用按键时,
|
||||
* 没有高亮项,但按下按键能看到列表跳动
|
||||
* 注意:必须要初始化的回调里面,并且设置了方向之后才能调用
|
||||
*
|
||||
* @param grid 列表句柄
|
||||
* @param en 是否使能该模式
|
||||
*
|
||||
* @return 0 正常;其他 异常
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int grid_key_jump(struct ui_grid *grid, int en);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_set_pix_scroll 设置列表跟手滑动使能
|
||||
*
|
||||
* @param grid 列表控件句柄
|
||||
* @param enable true 跟手滑动:false 按项滚动
|
||||
*
|
||||
* @return 0 正常;其他 异常
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_grid_set_pix_scroll(struct ui_grid *grid, int enable);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_slide 列表滑动
|
||||
*
|
||||
* @param grid 列表控件句柄
|
||||
* @param direction 列表滑动方向
|
||||
* @param steps 滑动距离
|
||||
*
|
||||
* @return true 成功 ;false 失败
|
||||
*
|
||||
* @note 自动刷新
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_grid_slide(struct ui_grid *grid, int direction, int steps);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_slide_with_callback 静态列表滑动接口_with_callback
|
||||
*
|
||||
* @param grid 列表控件句柄
|
||||
* @param direction 列表滑动方向
|
||||
* @param steps 列表滑动距离
|
||||
* @param callback 滑动后回调,一般需要在回调调用redraw
|
||||
*
|
||||
* @return true 成功 ;false 失败
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_grid_slide_with_callback(struct ui_grid *grid, int direction, int steps, void(*callback)(void *ctrl));
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_set_item_num 设置列表项的数量
|
||||
*
|
||||
* @param grid 列表控件句柄
|
||||
* @param item_num 项的数量
|
||||
*
|
||||
* @return 0,正常;其他,异常
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_grid_set_item_num(struct ui_grid *grid, int item_num);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_set_scroll_area 设置列表滑动区域
|
||||
*
|
||||
* @param grid 列表控件句柄
|
||||
* @param area 滑动区域 *传入全局变量或局部静态变量
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_grid_set_scroll_area(struct ui_grid *grid, struct scroll_area *area);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_touch_item 列表触摸项
|
||||
*
|
||||
* @param grid 列表控件句柄
|
||||
*
|
||||
* @return 触摸项索引;空白区域=-1
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
static inline int ui_grid_touch_item(struct ui_grid *grid)
|
||||
{
|
||||
return grid->touch_index;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_get_hindex 获取列表高亮项
|
||||
*
|
||||
* @param grid 列表控件句柄
|
||||
*
|
||||
* @return 静态高亮项
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_grid_get_hindex(struct ui_grid *grid);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_cur_item 列表选中项
|
||||
*
|
||||
* @param grid 列表控件句柄
|
||||
*
|
||||
* @return 存在触摸时反回触摸项;否则返回高亮项
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
static inline int ui_grid_cur_item(struct ui_grid *grid)
|
||||
{
|
||||
if (grid->touch_index >= 0) {
|
||||
return grid->touch_index;
|
||||
}
|
||||
return grid->hi_index;
|
||||
}
|
||||
|
||||
#define ui_grid_set_item(grid, index) (grid)->hi_index = index
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_set_hi_index 设置列表高亮项
|
||||
*
|
||||
* @param grid 列表控件句柄
|
||||
* @param hi_index 高亮项索引值
|
||||
*
|
||||
* @return 0 正常;其他 异常
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_grid_set_hi_index(struct ui_grid *grid, int hi_index);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_flick_ctrl_close 列表自动回弹功能开关
|
||||
*
|
||||
* @param grid 列表控件句柄
|
||||
* @param flag 是否关闭标志(1关闭,0不关闭)
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_grid_flick_ctrl_close(struct ui_grid *grid, u8 flag);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_set_tslide 列表惯性/回弹滑动时间间隔
|
||||
*
|
||||
* @param grid 列表控件句柄
|
||||
* @param tslide 时间间隔ms,默认:回弹50ms 惯性40ms
|
||||
*
|
||||
* @return 0 正常;其他 异常
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_grid_set_tslide(struct ui_grid *grid, u8 tslide);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_set_energy 惯性滑动参数设置
|
||||
*
|
||||
* @param grid 列表控件句柄
|
||||
* @param a 惯性负加速度 默认-0.01
|
||||
* @param val 惯性系数,用于压缩滑动距离,默认0.3
|
||||
*
|
||||
* @return 0 正常;其他 异常
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_grid_set_energy(struct ui_grid *grid, float a, float val);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_energy_auto_center 列表滑动居中使能
|
||||
*
|
||||
* @param grid 列表控件句柄
|
||||
* @param auto_center_enable MODE/DISABLE(0)
|
||||
*
|
||||
* @return 0 正常;其他 异常
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_grid_energy_auto_center(struct ui_grid *grid, AUTO_CENTER_MODE auto_center_mode);//是否启动滑动居中
|
||||
#define grid_energy_auto_center(a, b) ui_grid_energy_auto_center(a, b)
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_auto_center_and_flick 列表自动居中对齐和回弹(固定列表和边长列表都可以用)
|
||||
*
|
||||
* @Params grid 列表句柄
|
||||
*
|
||||
* @return 0 正常;其它 异常
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_grid_auto_center_and_flick(struct ui_grid *grid);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_set_energy_item_offset 设置最大偏移项的数量
|
||||
*
|
||||
* @param grid 列表句柄
|
||||
* @param item_offset 默认值为0,设置为1时,每次滑动只能滑动1项
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_grid_set_energy_item_offset(struct ui_grid *grid, int item_offset);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_set_energy_target_line 设置自动居中的目标线
|
||||
*
|
||||
* @param grid 列表控件句柄
|
||||
* @param target_line 目标线(默认值为父控件的一半;例如屏高454,项高112,间隔2,第二项高亮居中,则target_line=(112+2+(112/2))。)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_grid_set_energy_target_line(struct ui_grid *grid, int target_line);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_set_energy_next_threshold 滑动居中偏移到下一项阈值
|
||||
*
|
||||
* @param grid 列表控件句柄
|
||||
* @param next_threshold 跟随模式配置(默认值0,1000 移动距离超过父控件宽/高的10%时,居中下一项, 否则回弹)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_grid_set_energy_next_threshold(struct ui_grid *grid, int next_threshold);
|
||||
|
||||
int ui_grid_auto_center_set_custom_param(struct ui_grid *grid, float a, float val, u8 tslide, int target_line, int item_offset, int next_threshold, int index_mode);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_set_hi_move 设置静态列表滑动之后,刷新前,调整高亮项
|
||||
*
|
||||
* @param grid 列表控件句柄
|
||||
* @param hi_move true 使能;false 关闭
|
||||
* @param hi_func 回调,可自行处理逻辑;NULL 默认逻辑
|
||||
*
|
||||
* @return 0 正常;其他 异常
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_grid_set_hi_move(struct ui_grid *grid, u8 hi_move, void (*hi_func)(struct ui_grid *grid, int direction));
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_set_end_once 设置列表滑动(含惯性、回弹)结束的回调函数
|
||||
*
|
||||
* @param grid 列表控件句柄
|
||||
* @param end_once 回调
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_grid_set_end_once(struct ui_grid *grid, void (*end_once)(struct ui_grid *grid));
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_dynamic_create 动态列表创建*旧接口
|
||||
*
|
||||
* @param grid 列表控件句柄
|
||||
* @param direction 滑动方向
|
||||
* @param list_total 项数
|
||||
* @param event_handler_cb 列表项的子控件onchange事件回调
|
||||
*
|
||||
* @return 0 正常;其他 异常
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_grid_dynamic_create(struct ui_grid *grid, int direction, int list_total, int (*event_handler_cb)(void *, int, int, int));
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_dynamic_release 动态列表释放*旧接口
|
||||
*
|
||||
* @param grid 列表控件句柄
|
||||
*
|
||||
* @return 0 正常;其他 异常
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_grid_dynamic_release(struct ui_grid *grid);//动态列表释放
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_dynamic_cur_item 动态列表获取选项
|
||||
*
|
||||
* @param grid 列表句柄
|
||||
*
|
||||
* @return -1 异常;有触摸,触摸项;无触摸,高亮项
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_grid_dynamic_cur_item(struct ui_grid *grid);//动态列表获取选项
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_dynamic_set_item_by_id 修改动态列表项数*旧接口
|
||||
*
|
||||
* @param id 列表id
|
||||
* @param count 项数
|
||||
*
|
||||
* @return 0 正常;其他 异常
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_grid_dynamic_set_item_by_id(int id, int count);//修改动态列表数
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_dynamic_reset 重置动态列表*旧接口
|
||||
*
|
||||
* @param grid
|
||||
* @param index
|
||||
*
|
||||
* @return 0 正常;其他 异常
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_grid_dynamic_reset(struct ui_grid *grid, int index); //重置动态列表
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_init_dynamic 初始化动态列表 *新接口
|
||||
*
|
||||
* @param grid 列表控件句柄
|
||||
* @param row 行数
|
||||
* @param col 列数
|
||||
*
|
||||
* @return 0 正常;其他 异常
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_grid_init_dynamic(struct ui_grid *grid, int *row, int *col);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_add_dynamic 增加动态项
|
||||
*
|
||||
* @param grid 列表控件句柄
|
||||
* @param row 增加行数
|
||||
* @param col 增加列数
|
||||
* @param redraw 1 刷新 ;0 不刷新
|
||||
*
|
||||
* @return 0 正常;其他 异常
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_grid_add_dynamic(struct ui_grid *grid, int *row, int *col, int redraw);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_add_dynamic_by_id 增加动态列表项数 *新接口
|
||||
*
|
||||
* @param id 列表id
|
||||
* @param row 增加行数
|
||||
* @param col 增加列数
|
||||
* @param redraw 是否刷新
|
||||
*
|
||||
* @return 0 正常;其他 异常
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_grid_add_dynamic_by_id(int id, int *row, int *col, int redraw);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_del_dynamic 删除动态项
|
||||
*
|
||||
* @param grid 列表控件句柄
|
||||
* @param row 减少行数
|
||||
* @param col 减少列数
|
||||
* @param redraw 1 刷新 ;0 不刷新
|
||||
*
|
||||
* @return 0 正常;其他 异常
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_grid_del_dynamic(struct ui_grid *grid, int *row, int *col, int redraw);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_del_dynamic_by_id 减少动态列表项数 *新接口
|
||||
*
|
||||
* @param id 列表id
|
||||
* @param row 减少的行数
|
||||
* @param col 减少的列数
|
||||
* @param redraw 是否刷新
|
||||
*
|
||||
* @return 0 正常;其他 异常
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_grid_del_dynamic_by_id(int id, int *row, int *col, int redraw);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_dynamic_slide 动态列表滑动
|
||||
*
|
||||
* @param grid 列表控件句柄
|
||||
* @param direction 列表滑动方向
|
||||
* @param steps 列表滑动距离
|
||||
*
|
||||
* @return true 成功 ;false 失败
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_grid_dynamic_slide(struct ui_grid *grid, int direction, int steps);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_slide_with_callback_dynamic 动态列表滑动
|
||||
*
|
||||
* @param grid 列表控件句柄
|
||||
* @param direction 滑动方向
|
||||
* @param steps 滑动距离
|
||||
* @param callback 回调函数,一般需要在回调中调用ui_core_redraw刷新
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_grid_slide_with_callback_dynamic(struct ui_grid *grid, int direction, int steps, void(*callback)(void *ctrl));
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_get_hindex_dynamic 获取动态高亮项
|
||||
*
|
||||
* @param grid 列表控件句柄
|
||||
*
|
||||
* @return 动态高亮项
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_grid_get_hindex_dynamic(struct ui_grid *grid);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_cur_item_dynamic 获取动态选择项
|
||||
*
|
||||
* @param grid 列表控件句柄
|
||||
*
|
||||
* @return 返回触摸项或高亮项
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_grid_cur_item_dynamic(struct ui_grid *grid);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_set_hindex_dynamic 设置动态高亮项
|
||||
*
|
||||
* @param grid 列表控件句柄
|
||||
* @param dhindex 初始化时需要跳转到的动态高亮项
|
||||
* @param init 释放初始化
|
||||
* @param hi_index init为1时有效,表示要将dhindex设置到真实列表项的第几项
|
||||
*
|
||||
* @return 0 正常;其他 异常
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_grid_set_hindex_dynamic(struct ui_grid *grid, int dhindex, int init, int hi_index);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_set_base_dynamic 设置动态列表初始步进
|
||||
*
|
||||
* @param grid 列表控件句柄
|
||||
* @param base_index_once 0~max_dynamic_index,动态列表初始化时一次性索引基础值,一般配置为ui_grid_set_hindex_dynamic函数参数的(dhindex - hi_index),如果dhindex < hi_index,则需要根据列表项本身来调整
|
||||
|
||||
* @param init_step_once 初始化记忆之后,在第一次刷新之前,需要移动的步进
|
||||
*
|
||||
* @return 0 正常;其他 异常
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_grid_set_base_dynamic(struct ui_grid *grid, u32 base_index_once, int init_step_once);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_update_by_id_dynamic 更新动态列表高亮项*新接口
|
||||
*
|
||||
* @param id 列表id
|
||||
* @param item_sel 选中项
|
||||
* @param redraw 是否刷新
|
||||
*
|
||||
* @return 0 正常;其他 异常
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_grid_update_by_id_dynamic(int id, int item_sel, int redraw);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_grid_anim_set_cb 设置列表惯性起始以及结束回调
|
||||
*
|
||||
* @param ready_cb 惯性开始回调
|
||||
* @param deleted_cb 惯性结束回调
|
||||
*
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_grid_anim_set_cb(struct ui_grid *grid, ui_anim_ready_cb_t ready_cb, ui_anim_deleted_cb_t deleted_cb);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
/* Copyright(C) 2010- , JIELI TECHNOLOGY, Inc.
|
||||
* All right reserved.
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @file ui_measure.h
|
||||
*
|
||||
* @brief 杰理UI性能测试API
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version V1.0.0
|
||||
*
|
||||
* @date 2024-06-13
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __UI_MEASURE_H__
|
||||
#define __UI_MEASURE_H__
|
||||
|
||||
#include "generic/typedef.h"
|
||||
#include "gpio.h"
|
||||
// #include "asm/gpio_hw.h"
|
||||
|
||||
|
||||
// UI各功能测试模块使能
|
||||
#define UI_MEASURE_ENABLE 0
|
||||
|
||||
|
||||
#define PORT(i,a,b) (u16)((i<<8)|((a-'A')<<4)|(b))
|
||||
|
||||
|
||||
// 各测试模块IO定义
|
||||
#define IO_GPU IO_PORTB_00 //PORT(6,'B',0)
|
||||
#define IO_DBI IO_PORTB_01 //PORT(6,'B',1)
|
||||
#define IO_MELD //IO_PORTB_03 //PORT(6,'B',2)
|
||||
#define IO_REDRAW IO_PORTB_05
|
||||
|
||||
#define IO_FRAME IO_PORTB_04//PORT(0,'B',4)
|
||||
#define IO_FLASH //PORT(1,'B',5)
|
||||
#define IO_CPU IO_PORTB_04//PORT(6,'B',6)
|
||||
#define IO_INERTIA IO_PORTB_05//PORT(6,'B',6)
|
||||
|
||||
|
||||
#define LOW 0
|
||||
#define HIGH 1
|
||||
|
||||
|
||||
// extern int gpio_hw_direction_output(const enum gpio_port port, u32 pin, const int value);
|
||||
|
||||
#define MEASURE_IO_SET(io, level) gpio_hw_direction_output(IO_PORT_SPILT(io), (level))
|
||||
|
||||
|
||||
#if (defined UI_MEASURE_ENABLE && UI_MEASURE_ENABLE)
|
||||
// 开测试功能时,使用宏定义函数拉IO
|
||||
#define IO_FRAME_HIGH() MEASURE_IO_SET(IO_FRAME, HIGH)
|
||||
#define IO_FRAME_LOW() MEASURE_IO_SET(IO_FRAME, LOW)
|
||||
|
||||
#define IO_REDRAW_HIGH() MEASURE_IO_SET(IO_REDRAW, HIGH)
|
||||
#define IO_REDRAW_LOW() MEASURE_IO_SET(IO_REDRAW, LOW)
|
||||
|
||||
#define IO_FLASH_HIGH() MEASURE_IO_SET(IO_FLASH, HIGH)
|
||||
#define IO_FLASH_LOW() MEASURE_IO_SET(IO_FLASH, LOW)
|
||||
|
||||
#define IO_GPU_HIGH() MEASURE_IO_SET(IO_GPU, HIGH)
|
||||
#define IO_GPU_LOW() MEASURE_IO_SET(IO_GPU, LOW)
|
||||
|
||||
#define IO_DBI_HIGH() MEASURE_IO_SET(IO_DBI, HIGH)
|
||||
#define IO_DBI_LOW() MEASURE_IO_SET(IO_DBI, LOW)
|
||||
|
||||
#define IO_CPU_HIGH() MEASURE_IO_SET(IO_CPU, HIGH)
|
||||
#define IO_CPU_LOW() MEASURE_IO_SET(IO_CPU, LOW)
|
||||
|
||||
#define IO_MELD_HIGH() MEASURE_IO_SET(IO_MELD, HIGH)
|
||||
#define IO_MELD_LOW() MEASURE_IO_SET(IO_MELD, LOW)
|
||||
|
||||
#define IO_INERTIA_HIGH() MEASURE_IO_SET(IO_INERTIA, HIGH)
|
||||
#define IO_INERTIA_LOW() MEASURE_IO_SET(IO_INERTIA, LOW)
|
||||
|
||||
#else
|
||||
// 不开测试功能时,用空的宏,不影响源代码
|
||||
#define IO_FRAME_HIGH()
|
||||
#define IO_FRAME_LOW()
|
||||
|
||||
#define IO_REDRAW_HIGH()
|
||||
#define IO_REDRAW_LOW()
|
||||
|
||||
#define IO_FLASH_HIGH()
|
||||
#define IO_FLASH_LOW()
|
||||
|
||||
#define IO_GPU_HIGH()
|
||||
#define IO_GPU_LOW()
|
||||
|
||||
#define IO_DBI_HIGH()
|
||||
#define IO_DBI_LOW()
|
||||
|
||||
#define IO_CPU_HIGH()
|
||||
#define IO_CPU_LOW()
|
||||
|
||||
#define IO_MELD_HIGH()
|
||||
#define IO_MELD_LOW()
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
void ui_io_set(u16 io, u8 level);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef __UI_MULTI_PAGE_MANAGER_H__
|
||||
#define __UI_MULTI_PAGE_MANAGER_H__
|
||||
|
||||
#include "system/includes.h"
|
||||
|
||||
enum PAGE_PRIO {
|
||||
PAGE_PRIO_TOP, // 顶层显示
|
||||
PAGE_PRIO_BOTTOM, // 底层显示
|
||||
};
|
||||
|
||||
struct multi_page_info {
|
||||
int page_id; // 页面id
|
||||
int page_index; // 页面索引
|
||||
enum PAGE_PRIO prio;// 页面显示优先级
|
||||
};
|
||||
|
||||
int ui_multi_page_init(const struct multi_page_info *info_table, int num);
|
||||
|
||||
int ui_multi_page_check_id(int id);
|
||||
|
||||
int ui_multi_page_check_index(int index);
|
||||
|
||||
int ui_multi_page_get_index_by_id(int id);
|
||||
|
||||
int ui_multi_page_get_index_by_prio(int prio, int *tab);
|
||||
|
||||
int ui_multi_page_get_id_by_prio(int prio, int *tab);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,168 @@
|
||||
/* Copyright(C) 2010- , JIELI TECHNOLOGY, Inc.
|
||||
* All right reserved.
|
||||
*/
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/*
|
||||
* @file ui_number.h
|
||||
*
|
||||
* @brief 数字控件API头文件
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version V201
|
||||
*
|
||||
* @date 2022-12-15
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __UI_NUMBER_WIDGET_H__
|
||||
#define __UI_NUMBER_WIDGET_H__
|
||||
|
||||
|
||||
#include "jlui/control.h"
|
||||
#include "jlui/ui_core.h"
|
||||
#include "jlui/p.h"
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 数字控件参数 type 的类型定义,允许显示数字或字符串
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
enum {
|
||||
TYPE_NUM,
|
||||
TYPE_STRING,
|
||||
};
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 数字控件显示参数
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct unumber {
|
||||
u8 numbs; // 参数数量
|
||||
u8 type; // 参数类型
|
||||
|
||||
// 参数类型(type)决定使用下面哪个参数用作显示,number[2]和num_str互斥,数字控件只会显示其中一个
|
||||
u32 number[2]; // 数字(允许显示两个数值,中间自动由间隔符隔开)
|
||||
u8 *num_str; // 字符串(将通过ascii字库显示)
|
||||
};
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 数字控件元素句柄
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct ui_number {
|
||||
struct element_text text; // 共享文本的起始结构,如果数字控件无图片时,用ascii绘图,84byte
|
||||
char source[9]; // 数据源
|
||||
u8 css_num : 4; // css属性个数
|
||||
u8 nums: 2; // 显示的数字个数,这里决定从 number[]中拿几个数字使用
|
||||
u8 type: 2; // 数据类型,TYPE_NUM/TYPE_STRING,目前就两种选项
|
||||
u16 number[2]; // 最多两个数字,u16的大小,如果显示小数,number[0].number[1]
|
||||
u16 buf[20]; // 使用图片显示数字时的索引,按照这个buf顺序显示图片,最多显示19个图片,要以 0xff 结尾
|
||||
|
||||
u16 color; // 普通颜色,与flash资源保持一致
|
||||
u16 hi_color; // 高亮颜色,与flash资源保持一致
|
||||
|
||||
char delimiter[2]; // 分隔符索引映射表,比如数字控件的格式为%d/%d?,当解析到字符'/'时,会读取分隔符图片列表中序号为delimiter[0]的分隔符图片,即delimiter数组的下标由格式字符串的分隔符序号决定(序号从0开始,依此类推)
|
||||
|
||||
u32 css[2]; // 控件属性指针
|
||||
|
||||
u8 *num_str; // 如果显示字符串时的字符串内容
|
||||
|
||||
const struct ui_number_info *info;
|
||||
const struct element_event_handler *handler; // text 结构体中已经包含了handler指针
|
||||
}; // 164 byte
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 通过ID获取数字控件句柄
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
#define ui_number_for_id(id) \
|
||||
(struct ui_number *)ui_core_get_element_by_id(id)
|
||||
// ui_element_for_id(id, struct ui_number)
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_number_enable 数字控件使能(内部调用)
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_number_enable();
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief new_ui_number 创建新的数字控件(内部调用)
|
||||
*
|
||||
* @param _info 数字控件信息
|
||||
* @param parent 父控件
|
||||
*
|
||||
* @return 数字控件元素句柄
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void *new_ui_number(const void *_info, struct element *parent);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_number_update 更新数字控件内容(不带redraw)
|
||||
*
|
||||
* @param number 数字控件句柄
|
||||
* @param n 待显示的内容
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_number_update(struct ui_number *number, struct unumber *n);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_number_update_by_id 更新数字控件内容(带redraw)
|
||||
*
|
||||
* @param id 数字控件ID
|
||||
* @param n 待显示内容
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_number_update_by_id(int id, struct unumber *n);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_number_update_with_delimiter 更新数字控件内容以及分隔符序号(不带redraw)
|
||||
*
|
||||
* @param number 数字控件句柄
|
||||
* @param n 待显示的内容
|
||||
* @param delimiter_0 数字控件格式属性第一个分隔符在分隔符图片列表中的序号(从0开始),-1为使用默认序号
|
||||
* @param delimiter_1 数字控件格式属性第二个分隔符在分隔符图片列表中的序号(从0开始),-1为使用默认序号
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_number_update_with_delimiter(struct ui_number *number, struct unumber *n, char delimiter_0, char delimiter_1);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_number_update_with_delimiter_by_id 更新数字控件内容以及分隔符序号(带redraw)
|
||||
*
|
||||
* @param id 数字控件ID
|
||||
* @param n 待显示内容
|
||||
* @param delimiter_0 数字控件格式属性第一个分隔符在分隔符图片列表中的序号(从0开始),-1为使用默认序号
|
||||
* @param delimiter_1 数字控件格式属性第二个分隔符在分隔符图片列表中的序号(从0开始),-1为使用默认序号
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_number_update_with_delimiter_by_id(int id, struct unumber *n, char delimiter_0, char delimiter_1);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
/* Copyright(C)
|
||||
* not free
|
||||
* All right reserved
|
||||
*
|
||||
* @file ui_page_manager.h
|
||||
* @brief UI卡片页面滑动管理API头文件
|
||||
* @author
|
||||
* @version V201
|
||||
* @date 2022-12-15
|
||||
*/
|
||||
|
||||
#ifndef __UI_PAGE_H__
|
||||
#define __UI_PAGE_H__
|
||||
|
||||
#include "generic/list.h"
|
||||
#include "system/spinlock.h"
|
||||
|
||||
struct ui_page {
|
||||
struct list_head head;
|
||||
u32 id;
|
||||
u8 num;
|
||||
};
|
||||
|
||||
struct ui_page_head {
|
||||
struct list_head head;
|
||||
u8 ui_page_list_total_num;
|
||||
spinlock_t ui_page_list_lock;
|
||||
};
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_page_init 卡片页面管理初始化
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_page_init();
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_page_add 添加页面到卡片
|
||||
*
|
||||
* @param id 页面ID
|
||||
*
|
||||
* @return 0 正常,其他 异常
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_page_add(u32 id);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_page_del 把页面从卡片删除
|
||||
*
|
||||
* @param id 待删除的页面ID
|
||||
*
|
||||
* @return 0 正常,其他 异常
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_page_del(u32 id);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_page_del_by_num 通过页面号从卡片删除指定页面
|
||||
*
|
||||
* @param num 页面号
|
||||
*
|
||||
* @return 0 正常,其他异常
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_page_del_by_num(u8 num);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_page_free 释放卡片页面管理模块
|
||||
*
|
||||
* @return 0 正常,其他 异常
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_page_free();
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_page_next 获取卡片页面管理中,指定页面的下一个页面
|
||||
*
|
||||
* @param id 指定页面的ID
|
||||
*
|
||||
* @return 指定页面的下一个页面ID
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
u32 ui_page_next(u32 id);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_page_prev 获取卡片页面管理中,指定页面的上一个页面
|
||||
*
|
||||
* @param id 指定页面的ID
|
||||
*
|
||||
* @return 指定页面的上一个页面ID
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
u32 ui_page_prev(u32 id);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_page_list_all 打印出所有的卡片页面信息
|
||||
*
|
||||
* @return 0 正常,-1 卡片页面未初始化
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_page_list_all();
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_page_search 搜索卡片页面中指定页面的链表节点元素
|
||||
*
|
||||
* @param id 指定页面的ID
|
||||
*
|
||||
* @return 指定页面的链表节点
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct ui_page *ui_page_search(u32 id);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_page_has_been_init 获取卡片界面管理模块初始化状态
|
||||
*
|
||||
* @return true 卡片管理模块已经初始化,false 卡片管理模块未初始化
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_page_has_been_init();
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_page_get_first 获取卡片界面链表的第一个界面节点元素
|
||||
*
|
||||
* @return 卡片界面链表中第一个界面的元素
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct ui_page *ui_page_get_first();
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_page_list_id_modify 修改指定索引的卡片界面ID,将ID设置到第num位置
|
||||
*
|
||||
* @param num 索引号
|
||||
* @param id 页面ID
|
||||
*
|
||||
* @return 0 正常,其他异常
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_page_list_id_modify(u8 num, u32 id);
|
||||
|
||||
|
||||
u8 get_ui_page_list_total_num();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,261 @@
|
||||
/* Copyright(C)
|
||||
* not free
|
||||
* All right reserved
|
||||
*
|
||||
* @file ui_page_switch.h
|
||||
* @brief 卡片页面滑动管理模块API头文件
|
||||
* @author
|
||||
* @version V201
|
||||
* @date 2022-12-15
|
||||
*/
|
||||
|
||||
#ifndef __UI_PAGE_SWITCH_H__
|
||||
#define __UI_PAGE_SWITCH_H__
|
||||
|
||||
#include "ui_core.h"
|
||||
#include "ui_animation.h"
|
||||
#include "cube.h"
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 滑动方向定义
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
enum {
|
||||
DIRECTION_NOT_INIT, // 未初始化
|
||||
DIRECTION_NONE, // 滑动方向未知
|
||||
DIRECTION_UP, // 向上滑动
|
||||
DIRECTION_DOWN, // 向下滑动
|
||||
DIRECTION_LEFT, // 向左滑动
|
||||
DIRECTION_RIGHT, // 向右滑动
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 转场特效
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
enum {
|
||||
PAGE_MOVE_MODE_DOUBLE_PAGE, //双页面滑动
|
||||
PAGE_MOVE_MODE_CURR_PAGE, //当前页面滑动,其他页面不动
|
||||
PAGE_MOVE_MODE_OTHER_PAGE, //当前页面不懂,其他页面滑动
|
||||
PAGE_MOVE_MODE_SCALE_DOUBLE, //双页面缩放
|
||||
PAGE_MOVE_MODE_FLIP, //翻页
|
||||
PAGE_MOVE_MODE_CENTER_FLIP, //中心轴翻转
|
||||
PAGE_MOVE_MODE_EDGE_FLIP, //边沿翻转
|
||||
PAGE_MOVE_MODE_CUBE_FLIP, //立方体翻页(+ 倒影)
|
||||
PAGE_MOVE_MODE_DRIFT_FLIP, //漂移翻页(+ 倒影)
|
||||
PAGE_MOVE_MODE_BOARD_FLIP, // 翻板翻转特效
|
||||
PAGE_MOVE_MODE_BOARD_SLICING_FLIP, // 切片翻板翻转特效(TODO)
|
||||
|
||||
PAGE_MOVE_MODE_CUBE, //3D 立方体
|
||||
PAGE_MOVE_MODE_HEXAGON, //3D 灯笼
|
||||
PAGE_MOVE_MODE_REFLECTION, //3D 灯笼 + 倒影
|
||||
PAGE_MOVE_MODE_CUBE_REFLECTION, //立方体(灯笼) + 倒影
|
||||
PAGE_MOVE_MODE_USER, //用户自定义
|
||||
};
|
||||
|
||||
struct ui_page_anim_info {
|
||||
u32 mode : 8;
|
||||
u32 dir : 8;
|
||||
int curr_win;
|
||||
struct element_touch_event *e; // 惯性信息
|
||||
void (*anim_start)(int curr_win);
|
||||
void (*anim_stop)(int curr_win);
|
||||
};
|
||||
|
||||
struct ui_page_anim {
|
||||
u16 pos_x;
|
||||
int next_win;
|
||||
struct ui_page_anim_info info;
|
||||
ui_anim_t anim;
|
||||
};
|
||||
|
||||
struct ui_page_priv {
|
||||
u32 threshold: 14; /*回弹阈值*/
|
||||
u32 step: 14; /*居中步进*/
|
||||
u32 delay: 4; /*刷新延时*/
|
||||
|
||||
/*转场动画效果*/
|
||||
int transition_anim_busy;
|
||||
|
||||
/*过渡动画*/
|
||||
struct ui_page_anim *p_anim;
|
||||
u16 anim_time_max; // 动画最大运行时间,ms
|
||||
u16 anim_time_min; // 动画最小运行时间,ms
|
||||
u8 anim_energy_coeff; // 惯性补充系数
|
||||
|
||||
/*缩放系数*/
|
||||
float scale_min;
|
||||
float scale_max;
|
||||
/*任务相关的*/
|
||||
u16 left_flip: 1; /*滑动方向 1:left to right*/
|
||||
u16 mode: 7; /*模式*/
|
||||
u8 curr_page_index; /*页索引*/
|
||||
|
||||
/*翻转系数*/
|
||||
float degree; /*翻转角度*/
|
||||
float last_degree; /*翻转角度 last*/
|
||||
s16 flip_left; /*flip_left*/
|
||||
s16 flip_width; /*flip_width*/
|
||||
|
||||
float edge_flip_angle; /* PAGE_MOVE_MODE_EDGE_FLIP两个页面之间的夹角 */
|
||||
|
||||
/*用户自定义回调*/
|
||||
void (*user_mode_cb)(struct element *curr_elm, struct element *prev_elm, struct element *nex_elm, int cur_left);
|
||||
};
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_page_get_param 获取卡片滑动参数
|
||||
*
|
||||
* @return 卡片滑动参数
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct ui_page_priv *ui_page_get_param();
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_page_set_param 配置卡片页面滑动参数
|
||||
*
|
||||
* @param threshold 滑动阈值(沿某方向滑动距离超过阈值时,move_auto会划向下一页,否则回弹)
|
||||
* @param step 滑动步距(滑动时每次移动的步距)
|
||||
* @param delay 自动滑动定时器时间(delay * 10 ms)
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_page_set_param(int threshold, int step, int delay);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_page_move 界面滑动处理
|
||||
*
|
||||
* @param curr_win 当前页面ID
|
||||
* @param xoffset X方向的移动量
|
||||
* @param yoffset Y方向的移动量
|
||||
* @param mode 移动模式(暂未开发相关功能)
|
||||
*
|
||||
* @return 0
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_page_move(int curr_win, int xoffset, int yoffset, int mode);
|
||||
int ui_page_down(int curr_win, int mode);
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_page_switch 界面手动切换
|
||||
*
|
||||
* @param curr_win 当前界面
|
||||
* @param next_win 下一个界面
|
||||
* @param xoffset X方向移动量
|
||||
* @param mode 模式(暂未开发相关功能)
|
||||
*
|
||||
* @return 0
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_page_switch(int curr_win, int next_win, int xoffset, int mode);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_page_move_auto 卡片界面自动滑动(根据阈值判断自动滑动方向)
|
||||
*
|
||||
* @param curr_win 当前界面ID
|
||||
* @param mode 模式
|
||||
*
|
||||
* @return 0
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_page_move_auto(int curr_win, int mode);
|
||||
int ui_page_move_stop(int curr_win, int mode);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_page_move_callback_run 运行卡片是否使能回调(在卡片滑动时,先获取该回调结果判断是否响应卡片滑动)
|
||||
*
|
||||
* @return true 响应卡片滑动,false 不响应卡片滑动
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
u8 ui_page_move_callback_run(void);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief get_direction 通过tp两次报点计算滑动方向
|
||||
*
|
||||
* @param startx 起始X坐标
|
||||
* @param starty 起始Y坐标
|
||||
* @param endx 结束X坐标
|
||||
* @param endy 结束Y坐标
|
||||
*
|
||||
* @return 滑动方向
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int get_direction(int startx, int starty, int endx, int endy);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_page_scale_set_delay 设置页面进入、退出缩放过程延时
|
||||
*
|
||||
* @Params delay 延时时间 us
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_page_scale_set_delay(int delay);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 实现页面进入退出缩放效果
|
||||
*
|
||||
* @param curr_win 当前页面ID
|
||||
* @param next_win 跳转页面ID
|
||||
* @param dir 1:进入 0:退出
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_page_scale(int curr_win, int next_win, int dir);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 动画功能停止
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_page_anim_stop(void);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 动画开始
|
||||
*
|
||||
* @param *info 动画参数
|
||||
*
|
||||
* @return 0:ok
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_page_anim_auto(struct ui_page_anim_info *info);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 设置动画最大最小时间
|
||||
*
|
||||
* @param max_ms 最大时间,单位ms
|
||||
* @param min_ms 最小时间,单位ms
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_page_set_anim_run_time(u16 max_ms, u16 min_ms);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 设置边沿翻转特效两页面间的夹角
|
||||
*
|
||||
* @param angle 夹角角度
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_page_set_edge_flip_anble(float angle);
|
||||
|
||||
void ui_page_set_busy(int busy);
|
||||
|
||||
int ui_page_get_busy();
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,151 @@
|
||||
/* Copyright(C) 2010- , JIELI TECHNOLOGY, Inc.
|
||||
* All right reserved.
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/*
|
||||
* @file ui_pic.h
|
||||
*
|
||||
* @brief 图片控件API接口头文件
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version V201
|
||||
*
|
||||
* @date 2022-12-15
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __UI_PIC_WIDGET_H__
|
||||
#define __UI_PIC_WIDGET_H__
|
||||
|
||||
|
||||
#include "jlui/ui_core.h"
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 图片自动播放标志定义
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
enum {
|
||||
PLAY_NONE, // 不自动播放
|
||||
PLAY_ONCE, // 播放一次
|
||||
PLAY_LOOP, // 循环播放
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 图片控件句柄结构定义
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct ui_pic {
|
||||
struct element elm; // 共同属性,必须在第一个
|
||||
char source[9]; // 数据源
|
||||
u8 index; // 当前图片索引,后面会有3个byte空余用作对齐
|
||||
|
||||
u16 play_mode: 2; // 播放模式,三种模式:不播放,单次播放,循环播放
|
||||
u16 play_interval: 14; // 定时器时间
|
||||
u16 timer; // 定时器ID,应使用 u16 的变量存储
|
||||
|
||||
const struct ui_pic_info *info;
|
||||
const struct element_event_handler *handler;
|
||||
}; // 88byte
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 通过ID获取图片控件句柄
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
#define ui_pic_for_id(id) \
|
||||
ui_element_for_id(id, struct ui_pic)
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_pic_enable 图片控件使能(内部调用)
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_pic_enable();
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief new_ui_pic 创建图片控件(内部调用)
|
||||
*
|
||||
* @param _info 图片控件信息
|
||||
* @param parent 父控件句柄
|
||||
*
|
||||
* @return 图片控件句柄
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void *new_ui_pic(const void *_info, struct element *parent);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_pic_show_image_by_id 设置图片控件显示的图片索引(带redraw)
|
||||
*
|
||||
* @param id 图片控件ID
|
||||
* @param index 图片在“图片列表”中的索引
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_pic_show_image_by_id(int id, int index);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_pic_set_image_index 设置图片控件显示的图片索引(不带redraw)
|
||||
*
|
||||
* @param pic 图片控件句柄
|
||||
* @param index 图片在“图片列表”的索引
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_pic_set_image_index(struct ui_pic *pic, int index);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_pic_get_normal_image_number_by_id 获取“普通图片列表”中图片数量
|
||||
*
|
||||
* @param id 图片控件ID
|
||||
*
|
||||
* @return “普通图片列表”中图片的数量
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_pic_get_normal_image_number_by_id(int id);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_pic_get_highlgiht_image_number_by_id 获取“高亮图片列表”中图片的数量
|
||||
*
|
||||
* @param id 图片控件ID
|
||||
*
|
||||
* @return “高亮图片列表”中图片的数量
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_pic_get_highlgiht_image_number_by_id(int id);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_pic_set_hide_by_id 设置图片控件显示或隐藏
|
||||
*
|
||||
* @param id 图片控件ID
|
||||
* @param hide 是否隐藏(true 隐藏,false显示)
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_pic_set_hide_by_id(int id, int hide);
|
||||
|
||||
int ui_pic_show_image(struct ui_pic *pic, int index);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,120 @@
|
||||
/* Copyright(C) 2010- , JIELI TECHNOLOGY, Inc.
|
||||
* All right reserved.
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/*
|
||||
* @file ui_progress.h
|
||||
*
|
||||
* @brief 圆弧进度条控件API接口头文件
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version V201
|
||||
*
|
||||
* @date 2022-12-15
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __UI_PROGRESS_WIDGET_H__
|
||||
#define __UI_PROGRESS_WIDGET_H__
|
||||
|
||||
|
||||
#include "jlui/control.h"
|
||||
#include "jlui/ui_core.h"
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 圆弧进度条控件子控件数量定义
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
#define PROGRESS_CHILD_NUM (CTRL_PROGRESS_CHILD_END - CTRL_PROGRESS_CHILD_BEGIN)
|
||||
|
||||
|
||||
struct progress_highlight_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
s16 center_x; // 旋转中心
|
||||
s16 center_y;
|
||||
u16 radius_big; // 圆环大半径
|
||||
u16 radius_small; // 圆环小半径
|
||||
u16 angle_begin; // 开始角度
|
||||
u16 angle_end; // 结束角度
|
||||
struct ui_image_list *img;
|
||||
u16 color; // 颜色
|
||||
};
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 圆弧进度条控件句柄结构定义
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct ui_progress {
|
||||
struct element elm;
|
||||
struct element child_elm[PROGRESS_CHILD_NUM]; // 子控件个数 1
|
||||
char source[9]; // 数据源
|
||||
|
||||
s16 center_x; // 旋转中心x坐标
|
||||
s16 center_y; // 旋转中心y坐标
|
||||
|
||||
u16 radius; // 半径
|
||||
u16 angle_begin;// 起始角度
|
||||
u16 angle_end; // 结束角度
|
||||
|
||||
u8 ctrl_num; // 控件数量
|
||||
char percent; // 百分比
|
||||
const struct layout_info *info;
|
||||
const struct progress_highlight_info *pic_info[PROGRESS_CHILD_NUM];
|
||||
const struct element_event_handler *handler;
|
||||
}; // 160byte
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 通过ID获取圆弧进度条控件句柄
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
#define ui_progress_for_id(id) \
|
||||
ui_element_for_id(id, struct ui_progress)
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_progress_enable 圆弧进度条控件使能(内部调用)
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_progress_enable();
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_progress_set_persent_by_id 设置圆弧进度条百分比(带redraw)
|
||||
*
|
||||
* @param id 圆弧进度条控件ID
|
||||
* @param persent 圆弧进度条显示的百分比
|
||||
*
|
||||
* @return 0 正常,-22控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_progress_set_persent_by_id(int id, int persent);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_progress_set_persent 设置圆弧进度条百分比(不带redraw)
|
||||
*
|
||||
* @param progress 圆弧进度条句柄
|
||||
* @param percent 圆弧进度条显示的百分比
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_progress_set_persent(struct ui_progress *progress, int percent);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
/* Copyright(C) 2010- , JIELI TECHNOLOGY, Inc.
|
||||
* All right reserved.
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/*
|
||||
* @file ui_progress_multi.h
|
||||
*
|
||||
* @brief 多重圆弧进度条控件API接口头文件
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version V201
|
||||
*
|
||||
* @date 2022-12-15
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __UI_PROGRESS_MULTI_WIDGET_H__
|
||||
#define __UI_PROGRESS_MULTI_WIDGET_H__
|
||||
|
||||
|
||||
#include "jlui/control.h"
|
||||
#include "jlui/ui_core.h"
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 多重圆弧进度条控件子控件数量定义
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
#define MULTIPROGRESS_CHILD_NUM (CTRL_MULTIPROGRESS_CHILD_END - CTRL_MULTIPROGRESS_CHILD_BEGIN)
|
||||
|
||||
|
||||
struct multiprogress_highlight_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
u16 number;
|
||||
|
||||
s16 center_x; // 圆环中心
|
||||
s16 center_y;
|
||||
|
||||
u16 radius0_big; // 第一圈圆环大、小半径,颜色
|
||||
u16 radius0_small;
|
||||
u16 color0;
|
||||
|
||||
u16 radius1_big; // 第二圈圆环大、小半径、颜色
|
||||
u16 radius1_small;
|
||||
u16 color1;
|
||||
|
||||
u16 radius2_big; // 第三圈圆环大、小半径、颜色
|
||||
u16 radius2_small;
|
||||
u16 color2;
|
||||
|
||||
u16 angle_begin; // 开始、结束角度
|
||||
u16 angle_end;
|
||||
struct ui_image_list *img;
|
||||
};
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 多重圆弧进度条控件句柄结构定义
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct ui_multiprogress {
|
||||
struct element elm;
|
||||
struct element child_elm[MULTIPROGRESS_CHILD_NUM]; // 子控件元素 1
|
||||
char source[9]; // 数据源
|
||||
|
||||
s16 center_x; // 中心x坐标
|
||||
s16 center_y; // 中心y坐标
|
||||
|
||||
u16 angle_begin; // 进度条的起始角度
|
||||
u16 angle_end; // 进度条的结束角度
|
||||
|
||||
u16 radius; // 半径
|
||||
|
||||
u8 ctrl_num; // 控件数量,从flash读进来
|
||||
char percent[3]; // 百分比(三个进度条)
|
||||
|
||||
const struct layout_info *info;
|
||||
const struct multiprogress_highlight_info *pic_info[MULTIPROGRESS_CHILD_NUM];
|
||||
const struct element_event_handler *handler;
|
||||
}; // 164byte
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 通过ID获取多重圆弧进度条控件句柄
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
#define ui_multiprogress_for_id(id) \
|
||||
ui_element_for_id(id, struct ui_multiprogress)
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_multiprogress_enable 多重进度条控件使能(内部调用)
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_multiprogress_enable();
|
||||
int ui_multiprogress_set_persent_by_id(int id, int persent);
|
||||
int ui_multiprogress_set_second_persent_by_id(int id, int percent);
|
||||
int ui_multiprogress_set_third_persent_by_id(int id, int percent);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_multiprogress_set_persent_by_id 设置第一个进度条的百分比(待redraw)
|
||||
*
|
||||
* @param id 多重进度条控件ID
|
||||
* @param persent 第一个进度条显示的百分比
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_multiprogress_set_persent_by_id(int id, int persent); // 第一个进度条
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_multiprogress_set_second_persent_by_id 设置第二个进度条的百分比(待redraw)
|
||||
*
|
||||
* @param id 多重进度条控件ID
|
||||
* @param persent 第二个进度条显示的百分比
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_multiprogress_set_second_persent_by_id(int id, int percent); // 第二个进度条
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_multiprogress_set_third_persent_by_id 设置第三个进度条的百分比(待redraw)
|
||||
*
|
||||
* @param id 多重进度条控件ID
|
||||
* @param persent 第三个进度条显示的百分比
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_multiprogress_set_third_persent_by_id(int id, int percent); // 第三个进度条
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_multiprogress_set_persent 设置多重圆弧进度条第一个的百分比(不带redraw)
|
||||
*
|
||||
* @param multiprogress 多重圆弧进度条句柄
|
||||
* @param percent 第一个圆弧进度条百分比
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_multiprogress_set_persent(struct ui_multiprogress *multiprogress, int percent);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_multiprogress_set_second_persent 设置多重圆弧进度条第二个的百分比(不带redraw)
|
||||
*
|
||||
* @param multiprogress 多重圆弧进度条句柄
|
||||
* @param percent 第二个圆弧进度条百分比
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_multiprogress_set_second_persent(struct ui_multiprogress *multiprogress, int percent);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_multiprogress_set_third_persent 设置多重圆弧进度条第三个的百分比(不带redraw)
|
||||
*
|
||||
* @param multiprogress 多重圆弧进度条句柄
|
||||
* @param percent 第三个圆弧进度条百分比
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_multiprogress_set_third_persent(struct ui_multiprogress *multiprogress, int percent);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
#ifndef __UI_ROTATE_H__
|
||||
#define __UI_ROTATE_H__
|
||||
|
||||
#include "rect.h"
|
||||
|
||||
void rotate_0(unsigned char *src, unsigned char *src1, int sw, int sh, int cx, int cy, unsigned char *dst, int dw, int dh, int dx, int dy, struct rect *rect, int angle);
|
||||
void rotate_1(unsigned char *tmp, unsigned char *src, int sw, int sh, int cx, int cy, unsigned char *dst, int dw, int dh, int dx, int dy, struct rect *rect, int angle);
|
||||
void rotate_map(int sw, int sh, int scx, int scy, int *dw, int *dh, int dcx, int dcy, int angle);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
/* Copyright(C) 2010- , JIELI TECHNOLOGY, Inc.
|
||||
* All right reserved.
|
||||
*/
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @file ui_slider.h
|
||||
*
|
||||
* @brief 水平进度条控件API接口头文件
|
||||
*
|
||||
* @author zhuhaifang@zh-jieli.com
|
||||
*
|
||||
* @version V201
|
||||
*
|
||||
* @date 2022-12-15
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __UI_SLIDER_WIDGET_H__
|
||||
#define __UI_SLIDER_WIDGET_H__
|
||||
|
||||
|
||||
#include "jlui/ui_core.h"
|
||||
#include "jlui/control.h"
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 定义水平进度条控件子控件数量
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
#define SLIDER_CHILD_NUM (SLIDER_CHILD_END - SLIDER_CHILD_BEGIN)
|
||||
|
||||
|
||||
struct slider_text_info {
|
||||
u8 move;
|
||||
int min_value;
|
||||
int max_value;
|
||||
int text_color;
|
||||
};
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 水平进度条控件句柄结构
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct ui_slider {
|
||||
struct element elm; // 进度条控件本身
|
||||
struct element child_elm[SLIDER_CHILD_NUM]; // 进度条控件子控件,3个:高亮、非高亮、滑块
|
||||
|
||||
u8 move: 1; // 划动使能(true使能,false不使能)
|
||||
u8 step: 7; // 步进量
|
||||
|
||||
u8 follow_pic: 1; // right_pic和left_pic分界跟随滑块中线(注意,使能它将进度0%和100%时不被填满,适用滑块有图片的场景)
|
||||
u8 persent: 7; // 百分比 0-100
|
||||
|
||||
s16 left; // selected的left
|
||||
s16 width; // selected的width
|
||||
s16 min_value; // 最小值
|
||||
s16 max_value; // 最大值
|
||||
const struct ui_slider_info *info;
|
||||
const struct element_event_handler *handler;
|
||||
}; // 340byte
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 通过ID获取水平进度条控件句柄
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
#define ui_slider_for_id(id) \
|
||||
ui_element_for_id(id, struct ui_slider)
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_slider_enable 水平进度条控件使能(内部调用)
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_slider_enable();
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_slider_set_persent_by_id 设置水平进度条百分比(待redraw)
|
||||
*
|
||||
* @param id 水平进度条控件ID
|
||||
* @param persent 水平进度条显示百分比
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_slider_set_persent_by_id(int id, int persent);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_slider_set_persent 设置水平进度条控件百分比(不带redraw)
|
||||
*
|
||||
* @param slider 水平进度条控件句柄
|
||||
* @param persent 水平进度条显示百分比
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_slider_set_persent(struct ui_slider *slider, int persent);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief slider_touch_slider_move 水平进度条控件划动(在ON_TOUCH_MOVE事件没有return true时,将move标志设置为真,底层会自动调用该接口)
|
||||
*
|
||||
* @param slider 水平进度条控件句柄
|
||||
* @param e 触摸事件
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int slider_touch_slider_move(struct ui_slider *slider, struct element_touch_event *e);//触摸滑动功能
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_slider_set_follow_pic 设置高亮和非高亮部分是否跟随滑块中心
|
||||
*
|
||||
* @Params slider 进度条控件
|
||||
* @Params follow_pic 是否跟随滑块中心 true 跟随,false 不跟随
|
||||
*
|
||||
* @return true 跟随滑块,false 不跟随滑块
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_slider_set_follow_pic(struct ui_slider *slider, u8 follow_pic);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief slider_get_percent 获取水平进度条控件百分比
|
||||
*
|
||||
* @param slider 水平进度条控件句柄
|
||||
*
|
||||
* @return 水平进度条控件百分比值
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int slider_get_percent(struct ui_slider *slider);
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
/* Copyright(C) 2010- , JIELI TECHNOLOGY, Inc.
|
||||
* All right reserved.
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @file ui_slider_vert.h
|
||||
*
|
||||
* @brief 杰理UI垂直进度条控件API
|
||||
*
|
||||
* @author zhuhaifang@zh-jieli.com
|
||||
*
|
||||
* @version V1.0.0
|
||||
*
|
||||
* @date 2024-06-13
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __UI_SLIDER_VERT_WIDGET_H__
|
||||
#define __UI_SLIDER_VERT_WIDGET_H__
|
||||
|
||||
|
||||
#include "jlui/ui_core.h"
|
||||
#include "jlui/control.h"
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 定义垂直进度条控件子控件数量
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
#define VSLIDER_CHILD_NUM (VSLIDER_CHILD_END - VSLIDER_CHILD_BEGIN)
|
||||
|
||||
|
||||
struct vslider_text_info {
|
||||
u8 move;
|
||||
int min_value;
|
||||
int max_value;
|
||||
int text_color;
|
||||
};
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 垂直进度条控件句柄结构定义
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct ui_vslider {
|
||||
struct element elm;
|
||||
struct element child_elm[VSLIDER_CHILD_NUM];
|
||||
|
||||
u8 move: 1; // 滑动使能标志
|
||||
u8 step: 7; // 步进
|
||||
|
||||
u8 follow_pic: 1;
|
||||
u8 persent: 7; // 百分比
|
||||
|
||||
s16 top; // selected的top
|
||||
s16 height; // selected的height
|
||||
s16 min_value; // 最小值
|
||||
s16 max_value; // 最大值
|
||||
const struct ui_slider_info *info;
|
||||
const struct element_event_handler *handler;
|
||||
}; // 340byte
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 通过ID获取垂直进度条控件句柄
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
#define ui_vslider_for_id(id) \
|
||||
ui_element_for_id(id, struct ui_vslider)
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_vslider_enable 垂直进度条控件使能(内部调用)
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_vslider_enable();
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_vslider_set_persent_by_id 设置垂直进度条百分比(待redraw)
|
||||
*
|
||||
* @param id 垂直进度条控件ID
|
||||
* @param persent 垂直进度条控件显示百分比
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_vslider_set_persent_by_id(int id, int persent);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_vslider_set_persent 设置垂直进度条控件百分比(不带redraw)
|
||||
*
|
||||
* @param vslider 垂直进度条控件
|
||||
* @param persent 垂直进度条控件显示百分比
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_vslider_set_persent(struct ui_vslider *vslider, int persent);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief vslider_touch_slider_move 垂直进度条控件划动回调(如果应用层ON_TOUCH_MOVE没有return true,并且把vslider->move设置为true,底层会自动调用该接口)
|
||||
*
|
||||
* @param vslider 垂直进度条控件句柄
|
||||
* @param e 触摸事件
|
||||
*
|
||||
* @return false百分比无变化,true百分比改变并已经redraw
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int vslider_touch_slider_move(struct ui_vslider *vslider, struct element_touch_event *e);//触摸滑动功能
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_vslider_set_follow_pic 设置高亮和非高亮部分是否跟随滑块中心
|
||||
*
|
||||
* @Params vslider 进度条控件
|
||||
* @Params follow_pic 是否跟随滑块中心 true 跟随,false 不跟随
|
||||
*
|
||||
* @return true 跟随,false 不跟随
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_vslider_set_follow_pic(struct ui_vslider *vslider, u8 follow_pic);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief vslider_get_percent 获取垂直进度条百分比
|
||||
*
|
||||
* @param vslider 垂直进度条控件句柄
|
||||
*
|
||||
* @return 垂直进度条当前百分比
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int vslider_get_percent(struct ui_vslider *vslider);
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,346 @@
|
||||
/* Copyright(C) 2010- , JIELI TECHNOLOGY, Inc.
|
||||
* All right reserved.
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/*
|
||||
* @file ui_text.h
|
||||
*
|
||||
* @brief 文本控件API接口头文件
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version V201
|
||||
*
|
||||
* @date 2022-12-15
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __UI_TEXT_WIDGET_H__
|
||||
#define __UI_TEXT_WIDGET_H__
|
||||
|
||||
|
||||
#include "jlui/ui_core.h"
|
||||
#include "jlui/control.h"
|
||||
#include "font/font_all.h"
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 文本控件句柄结构定义
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct ui_text {
|
||||
struct element elm;
|
||||
struct ui_text_attrs attrs; // 文本属性,跟字库的使用相关,不能随意优化 64byte
|
||||
char source[9]; // 数据源
|
||||
u8 _format: 3; // 编码格式,跟随 UI 资源调整为枚举型,TEXT,ASCII,STRPIC,MULSTR,IMAGE 五种,3bit
|
||||
u8 scroll: 5; //滚动使能,使能/不使能,可用1bit
|
||||
|
||||
u16 _str[UI_TEXT_LIST_MAX_NUM]; // 3个u16,数组
|
||||
u16 timer; // 定时器id,用作文本滚动显示
|
||||
|
||||
|
||||
u8 index; // 文本索引
|
||||
u8 scroll_start_cnt; //滚动前计数:计数值*滚动间隔=滚动前停止时间
|
||||
u8 scroll_end_cnt; //滚动后计数:同上
|
||||
|
||||
u8 scroll_real_cnt; //滚动实时计数值
|
||||
|
||||
const struct ui_text_info *info; // flash 存储相关
|
||||
const struct element_event_handler *handler;
|
||||
}; // 160byte
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 通过ID获取文本控件句柄
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
#define ui_text_for_id(id) \
|
||||
ui_element_for_id(id, struct ui_text)
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_text_enable 文本控件使能(内部调用)
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_text_enable();
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief new_ui_text 创建文本控件(内部调用)
|
||||
*
|
||||
* @param _info 文本控件信息
|
||||
* @param parent 父控件元素
|
||||
*
|
||||
* @return 文本控件句柄
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void *new_ui_text(const void *_info, struct element *parent);
|
||||
|
||||
|
||||
|
||||
/****************************** api of format 'ascii' ******************************/
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_text_set_str 文本控件显示ASCII编码字符串
|
||||
*
|
||||
* @param text 文本控件句柄
|
||||
* @param format 文本编码格式
|
||||
* @param str 文本字符串(注意:字符串buf生命周期必须与控件一致)
|
||||
* @param strlen 文本字符串长度
|
||||
* @param flags 显示标志
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_text_set_str(struct ui_text *text, int format, const char *str, int strlen, u32 flags);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_text_set_utf8_str 设置文本控件显示UTF-8编码字符串
|
||||
*
|
||||
* @param text 文本控件句柄
|
||||
* @param format 文本编码格式
|
||||
* @param str 文本字符串(注意:字符串buf生命周期必须与控件一致)
|
||||
* @param strlen 文本字符串长度
|
||||
* @param flags 显示标志
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_text_set_utf8_str(struct ui_text *text, int format, const char *str, int strlen, u32 flags);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_text_set_str_by_id 设置文本控件显示字符串(带redraw)
|
||||
*
|
||||
* @param id 文本控件ID
|
||||
* @param format 文本编码格式
|
||||
* @param str 文本字符串指针(注意:字符串buf生命周期必须与控件一致)
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_text_set_str_by_id(int id, int format, const char *str);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/****************************** api of format 'strpic' ******************************/
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_text_set_index 设置文本控件显示的文本索引
|
||||
*
|
||||
* @param text 文本控件句柄
|
||||
* @param index 文本在“文字列表”中的索引
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_text_set_index(struct ui_text *text, int index);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_text_show_index_by_id 设置文本控件显示的文本索引
|
||||
*
|
||||
* @param id 文本控件ID
|
||||
* @param index 文本在“文字列表”中的索引
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_text_show_index_by_id(int id, int index);
|
||||
|
||||
|
||||
|
||||
|
||||
/****************************** api of format 'text' ******************************/
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_text_set_text_attrs 设置文本控件属性
|
||||
*
|
||||
* @param text 文本控件句柄
|
||||
* @param str 文本字符串指针(注意:字符串buf生命周期必须与控件一致)
|
||||
* @param strlen 文本字符串长度
|
||||
* @param encode 文本字符串编码格式
|
||||
* @param endian 文本字符串大、小端
|
||||
* @param flags 显示标志
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_text_set_text_attrs(struct ui_text *text, const char *str, int strlen, u8 encode, u8 endian, u32 flags);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_text_set_text_by_id 设置指定ID的文本控件显示内容
|
||||
*
|
||||
* @param id 文本控件ID
|
||||
* @param str 字符串指针(注意:字符串buf生命周期必须与控件一致)
|
||||
* @param strlen 字符串长度
|
||||
* @param flags 显示标志
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_text_set_text_by_id(int id, const char *str, int strlen, u32 flags);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_text_set_textw_by_id 设置指定ID的文本控件显示宽字节字符串
|
||||
*
|
||||
* @param id 文本控件ID
|
||||
* @param str 宽字节字符串(注意:字符串buf生命周期必须与控件一致)
|
||||
* @param strlen 字符串长度
|
||||
* @param endian 存储格式(大端、小端)
|
||||
* @param flags 显示标志
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_text_set_textw_by_id(int id, const char *str, int strlen, int endian, u32 flags);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_text_set_textu_by_id 设置指定ID的文本控件显示UTF8编码字符串
|
||||
*
|
||||
* @param id 文本控件ID
|
||||
* @param str UTF8编码字符串(注意:字符串buf生命周期必须与控件一致)
|
||||
* @param strlen 字符串长度
|
||||
* @param flags 显示标志
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_text_set_textu_by_id(int id, const char *str, int strlen, u32 flags);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief text_release 释放文本控件
|
||||
*
|
||||
* @param text 文本控件句柄
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void text_release(struct ui_text *text);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_text_set_combine_index 设置文本控件显示多个excel文本拼接字符串
|
||||
*
|
||||
* @param text 文本控件句柄
|
||||
* @param store_buf 必须是全局或者静态,不能是局部buf,大小为index_num+1
|
||||
* @param index_buf 表示当前文本控件字符串ID的序号,从0开始
|
||||
* @param index_num 表示有多少个字符串ID拼接起来
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_text_set_combine_index(struct ui_text *text, u16 *store_buf, u8 *index_buf, int index_num);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_text_set_multi_text_index 设置文本控件拼接显示excel文本
|
||||
*
|
||||
* @param text 文本控件指针
|
||||
* @param index_buf 当前文本控件显示的文本索引列表
|
||||
* @param index_num 文本列表中有多少个文本拼接显示
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_text_set_multi_text_index(struct ui_text *text, u8 *index_buf, int index_num);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_text_set_hide_by_id 设置为文本控件的隐藏状态
|
||||
*
|
||||
* @param id 文本控件ID
|
||||
* @param hide 是否设置为隐藏状态(true 隐藏,false 显示)
|
||||
*
|
||||
* @return 0 正常, -22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_text_set_hide_by_id(int id, int hide);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief text_set_strpic_scroll_interval 设置strpic文本滚动时间间隔
|
||||
*
|
||||
* @param ms 默认250ms
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void text_set_strpic_scroll_interval(u16 ms);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief text_set_font_scroll_interval 设置字库文本滚动间隔
|
||||
*
|
||||
* @param ms 默认1000ms
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void text_set_font_scroll_interval(u16 ms);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_text_get_strpic_scroll_interval 获取strpic文本滚动时间间隔
|
||||
*
|
||||
* @return 间隔
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
u16 ui_text_get_strpic_scroll_interval();
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_text_get_font_scroll_interval 获取字库文本滚动间隔
|
||||
*
|
||||
* @return 间隔
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
u16 ui_text_get_font_scroll_interval();
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_text_set_default_scroll_cnt 设置文本滚动前和滚动结束的静止等待时间
|
||||
*
|
||||
* @param strpic_start_cnt
|
||||
* @param strpic_end_cnt
|
||||
* @param font_start_cnt
|
||||
* @param font_end_cnt
|
||||
*
|
||||
* @note 0不等待
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_text_set_default_scroll_cnt(u8 strpic_start_cnt, u8 strpic_end_cnt, u8 font_start_cnt, u8 font_end_cnt);
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_text_set_scroll_redraw_enable 底层是否刷新文本(滚动参数还是会跑,只是不主动刷新)
|
||||
*
|
||||
* @param enable
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
u8 ui_text_set_scroll_redraw_enable(int enable);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_text_set_strpic_scroll_steps 刷新步进
|
||||
*
|
||||
* @param pixel
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_text_set_strpic_scroll_steps(u8 pixel);
|
||||
u8 ui_text_get_strpic_scroll_steps();
|
||||
/* 判断是否是utf-8格式编码 */
|
||||
/* return true: 符合utf-8 */
|
||||
int ui_text_utf8_check(u8 *buf, u16 len);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,137 @@
|
||||
/* Copyright(C) 2010- , JIELI TECHNOLOGY, Inc.
|
||||
* All right reserved.
|
||||
*/
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/*
|
||||
* @file ui_time.h
|
||||
*
|
||||
* @brief 时间控件API接口头文件
|
||||
*
|
||||
* @author
|
||||
*
|
||||
* @version V201
|
||||
*
|
||||
* @date 2022-12-15
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __UI_TIME_WIDGET_H__
|
||||
#define __UI_TIME_WIDGET_H__
|
||||
|
||||
|
||||
#include "jlui/control.h"
|
||||
#include "jlui/ui_core.h"
|
||||
#include "jlui/p.h"
|
||||
|
||||
|
||||
struct utime {
|
||||
u16 year;
|
||||
u8 month;
|
||||
u8 day;
|
||||
u8 hour;
|
||||
u8 min;
|
||||
u8 sec;
|
||||
};
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 时间控件句柄结构定义
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct ui_time {
|
||||
struct element_text text;
|
||||
char source[9]; // 数据源
|
||||
// 8byte
|
||||
u8 css_num; // css属性数量,可用2bit,最大2,与UI资源保持一致
|
||||
|
||||
u16 year: 12; // 年,最大 4095
|
||||
u16 month: 4; // 月,最大 15
|
||||
u8 day; // 日,可用 5bit,最大到 31
|
||||
u8 hour; // 时,可用 5bit,最大到 31
|
||||
// 4byte
|
||||
|
||||
u8 min; // 分,可用 6bit,最大到 63
|
||||
u8 sec; // 秒,可用 6bit,最大到 63
|
||||
|
||||
// 4byte
|
||||
u16 timer; // 定时器ID
|
||||
u8 auto_cnt; // 自动计时标志,可用1bit,是/否
|
||||
// 空2byte
|
||||
|
||||
u32 css[2]; // CSS属性指针
|
||||
// 8byte
|
||||
|
||||
u16 color; // 颜色,使用RGB565,与UI资源保持一致
|
||||
u16 hi_color; // 高亮颜色,使用RGB565,与UI资源保持一致
|
||||
// 4byte
|
||||
|
||||
u16 buf[20]; // 显示的图片索引 2024/06/07 11:25:32 --> 最多需19个图片,还需 0xff结尾
|
||||
// 40byte
|
||||
|
||||
const struct ui_time_info *info;
|
||||
const struct element_event_handler *handler;
|
||||
}; // 164byte
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 通过ID获取时间控件句柄
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
#define ui_time_for_id(id) \
|
||||
(struct ui_time *)ui_core_get_element_by_id(id)
|
||||
// ui_element_for_id(id, struct ui_time)
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_time_enable 时间控件使能(内部调用)
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_time_enable();
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief new_ui_time 创建时间控件(内部调用)
|
||||
*
|
||||
* @param _info 时间控件信息
|
||||
* @param parent 父控件句柄
|
||||
*
|
||||
* @return 时间控件句柄
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void *new_ui_time(const void *_info, struct element *parent);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_time_update 刷新时间控件的时间(不带redraw)
|
||||
*
|
||||
* @param time 时间控件句柄
|
||||
* @param t 待显示的时间
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_time_update(struct ui_time *time, struct utime *t);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_time_update_by_id 设置时间控件显示的时间(带redraw)
|
||||
*
|
||||
* @param id 时间控件ID
|
||||
* @param time 待显示的时间
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_time_update_by_id(int id, struct utime *time);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,141 @@
|
||||
/* Copyright(C) 2010- , JIELI TECHNOLOGY, Inc.
|
||||
* All right reserved.
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @file ui_watch.h
|
||||
*
|
||||
* @brief 杰理UI表盘控件API
|
||||
*
|
||||
* @author zhuhaifang@zh-jieli.com
|
||||
*
|
||||
* @version V1.0.0
|
||||
*
|
||||
* @date 2024-06-13
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __UI_WATCH_WIDGET_H__
|
||||
#define __UI_WATCH_WIDGET_H__
|
||||
|
||||
|
||||
#include "jlui/control.h"
|
||||
#include "jlui/ui_core.h"
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 表盘控件子控件数量定义
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
#define WATCH_CHILD_NUM (CTRL_WATCH_CHILD_END - CTRL_WATCH_CHILD_BEGIN)
|
||||
|
||||
|
||||
struct watch_pic_info {
|
||||
struct ui_ctrl_info_head head;
|
||||
s16 cent_x;
|
||||
s16 cent_y;
|
||||
s16 dst_cent_x;
|
||||
s16 dst_cent_y;
|
||||
struct ui_image_list *img;
|
||||
};
|
||||
|
||||
struct watch_css_info {
|
||||
s16 left;
|
||||
s16 top;
|
||||
s16 width;
|
||||
s16 height;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 表盘控件句柄结构定义
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct ui_watch {
|
||||
struct element elm;
|
||||
struct element child_elm[WATCH_CHILD_NUM]; // 子控件句柄 3个
|
||||
struct watch_css_info child_css[WATCH_CHILD_NUM]; // 子控件属性 3个
|
||||
char source[9]; // 数据源
|
||||
|
||||
u32 ctrl_num : 5; // 控件数量,如果与UI资源保持一致,需7bit
|
||||
u32 hour : 5; // 时 max 31
|
||||
u32 min : 6; // 分 max 63
|
||||
u32 sec : 6; // 秒 max 63
|
||||
u32 msec : 10; // 毫秒 max 1000
|
||||
|
||||
const struct layout_info *info;
|
||||
const struct watch_pic_info *pic_info[WATCH_CHILD_NUM];
|
||||
const struct element_event_handler *handler;
|
||||
}; // 316byte
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief 通过ID获取表盘控件elm指针
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
#define ui_watch_for_id(id) \
|
||||
ui_element_for_id(id, struct ui_watch)
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_watch_enable 表盘控件使能(内部调用)
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_watch_enable();
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_watch_set_time_by_id 设置表盘控件实际(待redraw)
|
||||
*
|
||||
* @param id 表盘控件ID
|
||||
* @param hour 小时
|
||||
* @param min 分钟
|
||||
* @param sec 秒钟
|
||||
* @param msec 毫秒
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_watch_set_time_by_id(int id, int hour, int min, int sec, int msec);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_watch_set_time 设置表盘控件时间(不带redraw)
|
||||
*
|
||||
* @param watch表盘控件句柄
|
||||
* @param hour 小时
|
||||
* @param min 分钟
|
||||
* @param sec 秒钟
|
||||
* @param msec 毫秒
|
||||
*
|
||||
* @return 0 正常,-22 控件不存在
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int ui_watch_set_time(struct ui_watch *watch, int hour, int min, int sec, int msec);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief ui_watch_update 表盘控件主动刷新
|
||||
*
|
||||
* @param watch 表盘控件句柄
|
||||
* @param refresh 是否调用redraw刷新
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void ui_watch_update(struct ui_watch *watch, u8 refresh);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/* Copyright(C) 2010- , JIELI TECHNOLOGY, Inc.
|
||||
* All right reserved.
|
||||
*/
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @file window.h
|
||||
*
|
||||
* @brief 杰理UI窗口控件API
|
||||
*
|
||||
* @author zhuhaifang@zh-jieli.com
|
||||
*
|
||||
* @version V1.0.0
|
||||
*
|
||||
* @date 2024-06-13
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __UI_WINDOW_WIDGET_H__
|
||||
#define __UI_WINDOW_WIDGET_H__
|
||||
|
||||
|
||||
#include "jlui/layer.h"
|
||||
#include "jlui/ui_core.h"
|
||||
#include "jlui/control.h"
|
||||
#include "list.h"
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief window 控件句柄结构体定义
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
struct window {
|
||||
struct element elm; //must be first
|
||||
u8 busy; // 繁忙状态
|
||||
u8 hide; // 是否隐藏
|
||||
u8 ctrl_num; // 控件数量
|
||||
struct list_head entry;
|
||||
struct layer *layer; // 图层
|
||||
const struct window_info *info;
|
||||
const struct element_event_handler *handler;
|
||||
|
||||
void *private_data; // 私有参数
|
||||
struct element_event_handler global_handler; // 全局回调,作为默认回调,若无其它控件接管事件处理,默认跑这里
|
||||
}; // 108 byte
|
||||
|
||||
|
||||
extern const struct window_info *window_table;
|
||||
|
||||
|
||||
#define REGISTER_WINDOW_EVENT_HANDLER(id) \
|
||||
REGISTER_UI_EVENT_HANDLER(id)
|
||||
|
||||
|
||||
#define ui_window_for_id(id) \
|
||||
ui_element_for_id(id, struct window)
|
||||
|
||||
int window_init(int id);
|
||||
|
||||
int window_show(int);
|
||||
|
||||
int window_hide(int id);
|
||||
|
||||
int window_toggle(int id);
|
||||
|
||||
int window_ontouch(struct element_touch_event *e);
|
||||
|
||||
int window_onkey(struct element_key_event *e);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
#ifndef __FOOTBALL_H__
|
||||
#define __FOOTBALL_H__
|
||||
|
||||
#include "gpu_port.h"
|
||||
#include "ui_core.h"
|
||||
|
||||
struct cube_param {
|
||||
pJLGPUTaskHead_t head; //gpu链表
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 立方体模型初始化
|
||||
@param width[6] : 立方体6个面的宽度
|
||||
@param heihgt[6] : 立方体6个面的高度
|
||||
@param w_scale : 立方体每个面宽度的缩放系数
|
||||
@param h_scale : 立方体每个面高度的缩放系数
|
||||
@param view_distance : 视距(值越小, 立方体越大)
|
||||
@param win_x : win区域x坐标偏移
|
||||
@param win_y : win区域y坐标偏移
|
||||
@param win_w : win区域宽度
|
||||
@param win_h : win区域高度
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int cube_init(int width[6], int height[6], float w_scale, float h_scale, float view_distance, int win_x, int win_y, int win_w, int win_h);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 立方体刷新
|
||||
@param x_diff : x方向偏移
|
||||
@param y_diff : y方向偏移
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int cube_draw(struct cube_param *param, float x_diff, float y_diff);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 立方体触摸点检测
|
||||
@param x : 触摸点x坐标
|
||||
@param y : 触摸点y坐标
|
||||
@return -1 : 触摸点未落在立方体上, >= 0: 立方体某个面的索引(从0开始)
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int cube_get_face_index(int x, int y);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 立方体资源释放
|
||||
@param
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void cube_uninit(void);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,66 @@
|
||||
#ifndef __CUBE_REFLECTION__
|
||||
#define __CUBE_REFLECTION__
|
||||
|
||||
#include "gpu_port.h"
|
||||
#include "ui_core.h"
|
||||
|
||||
struct cube_reflection_param {
|
||||
pJLGPUTaskHead_t head; //gpu链表
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 3D 灯笼倒影模型初始化
|
||||
@param width : 立方体每个面的宽度
|
||||
@param heihgt : 立方体每个面的高度
|
||||
@param w_scale : 立方体每个面宽度的缩放系数
|
||||
@param h_scale : 立方体每个面高度的缩放系数
|
||||
@param view_distance : 视距(值越小, 立方体越大)
|
||||
@param view_distance_min : 视距最小值(值最小, 立方体最大)
|
||||
@param view_distance_max : 视距最大值(值最大, 立方体最小)
|
||||
@param win_x : win区域x坐标偏移
|
||||
@param win_y : win区域y坐标偏移
|
||||
@param win_w : win区域宽度
|
||||
@param win_h : win区域高度
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int cube_reflection_init(int width[12], int height[12], float w_scale, float h_scale, float view_distance, float view_distance_min, float view_distance_max, int win_x, int win_y, int win_w, int win_h);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 3D 灯笼倒影刷新
|
||||
@param x_update_val : x方向更新的角度
|
||||
@param y_update_val : y方向更新的角度
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int cube_reflection_draw(struct cube_reflection_param *param, float x_update_val, float y_update_val);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 3D 灯笼倒影触摸点检测
|
||||
@param x : 触摸点x坐标
|
||||
@param y : 触摸点y坐标
|
||||
@return -1 : 触摸点未落在立方体上, >= 0: 立方体某个面的索引(从0开始)
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int cube_reflection_get_face_index(int x, int y);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 3D 灯笼倒影资源释放
|
||||
@param
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void cube_reflection_uninit(void);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief cube_reflection_get_face_angle 获取对应 ID 面的角度
|
||||
*
|
||||
* @Params index
|
||||
* @Params x_angle
|
||||
* @Params y_angle
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void cube_reflection_get_face_angle(int index, int *x_angle, int *y_angle);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,111 @@
|
||||
#ifndef __FOOTBALL_H__
|
||||
#define __FOOTBALL_H__
|
||||
|
||||
#include "gpu_port.h"
|
||||
#include "ui_core.h"
|
||||
|
||||
struct football_bg_rgb_t {
|
||||
u8 red;
|
||||
u8 green;
|
||||
u8 blue;
|
||||
};
|
||||
|
||||
struct football_param {
|
||||
pJLGPUTaskHead_t head;//gpu链表
|
||||
u8 mask_en; // 六边形背景+图标mask
|
||||
int element_id; //控件id(ui框架相关, 可不配置)
|
||||
int task_id; //gpu任务id(ui框架相关, 第三方UI框架需指定一个链表里唯一的标识, 用于区分不同的图片)
|
||||
int prior; //优先级(ui框架相关, 可不配置)
|
||||
int image_bg_num; //背景图片数量,固定用法, 0:无六边形背景图片(六边形图标) 1:共用一张六边形背景图片,可以单独上色(圆形图标) 3:使用3张六边形背景图片叠加,3张图片分别上色混合叠加(圆形图标) 20:使用20张六边形背景图片,跟圆形图标一一对应(圆形图标)
|
||||
int image_num; //图片数量
|
||||
struct ui_image_attrs *image_bg; //背景图片属性, 需要跟image_bg_num保持一致
|
||||
struct ui_image_attrs *image; //图片属性, 需要跟image_num保持一致
|
||||
struct football_bg_rgb_t *football_bg_rgb; // 背景图片颜色
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 足球模型初始化
|
||||
@param width : 足球球面宽度
|
||||
@param height : 足球球面高度
|
||||
@param scale : 足球球面缩放
|
||||
@param view_distance : 视距(值越小, 足球越大)
|
||||
@param win_x : win区域x坐标偏移
|
||||
@param win_y : win区域y坐标偏移
|
||||
@param win_w : win区域宽度
|
||||
@param win_h : win区域高度
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int football_init(int width, int height, float scale, float view_distance, int win_x, int win_y, int win_w, int win_h);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 足球刷新
|
||||
@param param : 足球显示相关参数
|
||||
@param x_diff : x方向偏移
|
||||
@param y_diff : y方向偏移
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void football_draw(struct football_param *param, float x_diff, float y_diff);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 足球触摸点检测
|
||||
@param x : 触摸点x坐标
|
||||
@param y : 触摸点y坐标
|
||||
@return -1: 触摸点未落在球面上, >= 0: 球面索引(从0开始)
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int football_get_face_index(int x, int y);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 足球资源释放
|
||||
@param
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void football_uinit(void);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 设置mask图片缩放倍数(mask_en使能后有效)
|
||||
@param
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void football_set_mask_scale(float scale);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 足球六边形背景+图标mask
|
||||
@param
|
||||
@return
|
||||
@note 需在football_init后调用
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void set_football_bg_mask_en(u8 flag);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 设置mask图片缩放倍数(mask_en使能后有效)
|
||||
@param
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void football_set_mask_scale(float scale);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 获取足球位置
|
||||
@param cur_mat : 位置参数, float[9]数组
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void football_get_pos(float *cur_mat);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 设置足球位置
|
||||
@param cur_mat : 位置参数, float[9]数组
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void football_set_pos(float *cur_mat);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
#ifndef __HEXAGON_H__
|
||||
#define __HEXAGON_H__
|
||||
|
||||
#include "gpu_port.h"
|
||||
#include "ui_core.h"
|
||||
|
||||
#define POLYTOPE_SIX 6 //六面体
|
||||
#define POLYTOPE_EIGHT 8 //八面体
|
||||
#define POLYTOPE_ALL 255 //共存
|
||||
#define POLYTOPE_CONFIG POLYTOPE_SIX
|
||||
extern const u8 polytope;
|
||||
void hexagon_polytope_type_set(u8 type);
|
||||
|
||||
struct hexagon_param {
|
||||
pJLGPUTaskHead_t head; //gpu链表
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 3D 灯笼模型初始化
|
||||
@param width : 立方体每个面的宽度
|
||||
@param heihgt : 立方体每个面的高度
|
||||
@param w_scale : 立方体每个面宽度的缩放系数
|
||||
@param h_scale : 立方体每个面高度的缩放系数
|
||||
@param view_distance : 视距(值越小, 立方体越大)
|
||||
@param win_x : win区域x坐标偏移
|
||||
@param win_y : win区域y坐标偏移
|
||||
@param win_w : win区域宽度
|
||||
@param win_h : win区域高度
|
||||
@param h_ofs_range : 实际是 hexagon_draw 的 x_angle 范围, 用于计算投影中心的偏移
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int hexagon_init(int width[8], int height[8], float w_scale, float h_scale, float view_distance, int win_x, int win_y, int win_w, int win_h, float h_ofs_range);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief hexagon_draw
|
||||
*
|
||||
* @Params param
|
||||
* @Params x_update_val : x方向更新的角度
|
||||
* @Params y_update_val : y方向更新的角度
|
||||
* @param x_angle : 模型绕 x 轴旋转的角度
|
||||
* @param h_ofs_val : 实际是 hexagon_draw 的 x_angle 的有效偏移, 用于计算投影中心的偏移
|
||||
* @param reset_sep : 重新调整的 GPU 任务链表序号
|
||||
* @param is_draw : 当前是否需要绘制模型
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
int hexagon_draw(struct hexagon_param *param, float x_update_val, float y_update_val, float x_angle, float h_ofs_val, u8 *reset_sep, u8 is_draw);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 3D 灯笼触摸点检测
|
||||
@param x : 触摸点x坐标
|
||||
@param y : 触摸点y坐标
|
||||
@return -1 : 触摸点未落在立方体上, >= 0: 立方体某个面的索引(从0开始)
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int hexagon_get_face_index(int x, int y);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 3D 灯笼资源释放
|
||||
@param
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void hexagon_uninit(void);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief hexagon_get_face_angle 获取对应 ID 面的角度
|
||||
*
|
||||
* @Params index
|
||||
* @Params x_angle
|
||||
* @Params y_angle
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void hexagon_get_face_angle(int index, int *x_angle, int *y_angle);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,119 @@
|
||||
#ifndef __JLUI_EFFECT__
|
||||
#define __JLUI_EFFECT__
|
||||
|
||||
#include "gpu_port.h"
|
||||
#include "ui_core.h"
|
||||
|
||||
void get_flip_matrix(gpu_matrix_t *matrix, int screen_x, int screen_y, int screen_w, int screen_h, float degree);
|
||||
int get_flip_width(int screen_w, float degree);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief get_cube_flip_matrix
|
||||
*
|
||||
* @Params matrix
|
||||
* @Params screen_x
|
||||
* @Params screen_y
|
||||
* @Params screen_w
|
||||
* @Params screen_h
|
||||
* @Params degree
|
||||
* @Params is_reflection : 是否为镜像面, 0 - 非镜像; 1 - 镜像
|
||||
* @Params flip_dir : 翻转方向, 0 - 从右向左; 1 - 从左向右
|
||||
* @Params face_flag : 是否为当前页面, 0 - 当前页面; 1 - 上一页或下一页
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void get_cube_flip_matrix(gpu_matrix_t *matrix, int screen_x, int screen_y, int screen_w, int screen_h, float degree, u8 is_reflection, u8 flip_dir, u8 face_flag);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief get_drift_flip_matrix
|
||||
*
|
||||
* @Params matrix
|
||||
* @Params screen_x
|
||||
* @Params screen_y
|
||||
* @Params screen_w
|
||||
* @Params screen_h
|
||||
* @Params degree
|
||||
* @Params is_reflection : 是否为镜像面, 0 - 非镜像; 1 - 镜像
|
||||
* @Params flip_dir : 翻转方向, 0 - 从右向左; 1 - 从左向右
|
||||
* @Params face_flag : 是否为当前页面, 0 - 当前页面; 1 - 上一页或下一页
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void get_drift_flip_matrix(gpu_matrix_t *matrix, int screen_x, int screen_y, int screen_w, int screen_h, float degree, u8 is_reflection, u8 flip_dir, u8 face_flag);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief get_edge_flip_matrix
|
||||
*
|
||||
* @Params matrix
|
||||
* @Params screen_x
|
||||
* @Params screen_y
|
||||
* @Params screen_w
|
||||
* @Params screen_h
|
||||
* @Params degree
|
||||
* @Params flip_dir : 翻转方向, 0 - 从右向左; 1 - 从左向右
|
||||
* @Params face_flag : 是否为当前页面, 0 - 当前页面; 1 - 上一页或下一页
|
||||
* @Params angle : 两个页面之间的夹角
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void get_edge_flip_matrix(gpu_matrix_t *matrix, int screen_x, int screen_y, int screen_w, int screen_h, float degree, u8 flip_dir, u8 face_flag, float angle);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 立方体模型初始化
|
||||
@param width : 立方体每个面的宽度
|
||||
@param heihgt : 立方体每个面的高度
|
||||
@param w_scale : 立方体每个面宽度的缩放系数
|
||||
@param h_scale : 立方体每个面高度的缩放系数
|
||||
@param win_x : win区域x坐标偏移
|
||||
@param win_y : win区域y坐标偏移
|
||||
@param win_w : win区域宽度
|
||||
@param win_h : win区域高度
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int board_cube_init(int width, int height, float w_scale, float h_scale, int win_x, int win_y, int win_w, int win_h);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 立方体资源释放
|
||||
@param
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void board_cube_uninit(void);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief get_board_flip_matrix
|
||||
*
|
||||
* @Params matrix
|
||||
* @Params degree
|
||||
* @Params flip_dir : 翻转方向, 0 - 从右向左; 1 - 从左向右
|
||||
* @Params face_flag : 选择当前页面, 0 - 当前页面; 1 - 上一页或下一页; 2 - 左侧板宽; 3 - 右侧板宽
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void get_board_flip_matrix(gpu_matrix_t *matrix, float degree, u8 flip_dir, u8 face_flag);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief create_board_flip_fill_task
|
||||
*
|
||||
* @Params head
|
||||
* @Params draw_rect
|
||||
* @Params color
|
||||
* @Params degree
|
||||
* @Params flip_dir : 翻转方向, 0 - 从右向左; 1 - 从左向右
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void create_board_flip_fill_task(pJLGPUTaskHead_t head, struct rect draw_rect, u32 color, float degree, u8 flip_dir);
|
||||
|
||||
#endif //__JLUI_EFFECT__
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
#ifndef __REFLECTION__
|
||||
#define __REFLECTION__
|
||||
|
||||
#include "gpu_port.h"
|
||||
#include "ui_core.h"
|
||||
#include "hexagon.h"
|
||||
|
||||
#define REF_POLYTOPE_SIX 6 //六面体
|
||||
#define REF_POLYTOPE_EIGHT 8 //八面体
|
||||
#define REF_POLYTOPE_ALL 255 //共存
|
||||
#define REF_POLYTOPE_CONFIG REF_POLYTOPE_SIX
|
||||
extern const u8 ref_polytope;
|
||||
void hexagon_reflection_polytope_type_set(u8 type);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 3D 灯笼倒影模型初始化
|
||||
@param width : 立方体每个面的宽度
|
||||
@param heihgt : 立方体每个面的高度
|
||||
@param w_scale : 立方体每个面宽度的缩放系数
|
||||
@param h_scale : 立方体每个面高度的缩放系数
|
||||
@param view_distance : 视距(值越小, 立方体越大)
|
||||
@param win_x : win区域x坐标偏移
|
||||
@param win_y : win区域y坐标偏移
|
||||
@param win_w : win区域宽度
|
||||
@param win_h : win区域高度
|
||||
@param h_ofs_range : 实际是 reflection_draw 的 x_angle 范围, 用于计算投影中心的偏移
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int reflection_init(int width[16], int height[16], float w_scale, float h_scale, float view_distance, int win_x, int win_y, int win_w, int win_h, float h_ofs_range);
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 3D灯笼倒影本体与倒影之间的间距
|
||||
@param interval : 间距(默认值为30.0f, 值越大,间距越大)
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void reflection_set_interval(float interval);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 3D 灯笼倒影刷新
|
||||
@param x_diff : x方向偏移
|
||||
@param y_diff : y方向偏移
|
||||
@param x_angle : 模型绕 x 轴旋转的角度
|
||||
@param h_ofs_val : 实际是 reflection_draw 的 x_angle 的有效偏移, 用于计算投影中心的偏移
|
||||
@param reset_sep : 重新调整的 GPU 任务链表序号
|
||||
@param is_draw : 当前是否需要绘制模型
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int reflection_draw(struct hexagon_param *param, float x_diff, float y_diff, float x_angle, float h_ofs_val, u8 *reset_sep, u8 is_draw);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 3D 灯笼倒影触摸点检测
|
||||
@param x : 触摸点x坐标
|
||||
@param y : 触摸点y坐标
|
||||
@return -1 : 触摸点未落在立方体上, >= 0: 立方体某个面的索引(从0开始)
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int reflection_get_face_index(int x, int y);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 3D 灯笼倒影资源释放
|
||||
@param
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void reflection_uninit(void);
|
||||
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief reflection_get_face_angle 获取对应 ID 面的角度
|
||||
*
|
||||
* @Params index
|
||||
* @Params x_angle
|
||||
* @Params y_angle
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------------*/
|
||||
void reflection_get_face_angle(int index, int *x_angle, int *y_angle);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,32 @@
|
||||
#ifndef __RUBIKS_CUBE_H__
|
||||
#define __RUBIKS_CUBE_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct rubiks_cube_screen_info {
|
||||
int screen_width; // 屏幕宽
|
||||
int screen_height; // 屏幕高
|
||||
int side; // 边长
|
||||
int gamepad; // 控制面旋转幅度的量
|
||||
};
|
||||
|
||||
int rubiks_cube_init(int width, int height, void *cfg_task, void *draw_cube); //初始化魔方游戏
|
||||
int rubiks_cube_uninit(void); //退出魔方游戏
|
||||
void restore_cube(void); //复原魔方
|
||||
void OnMove(int x, int y); //输入设备MOVE事件中调用
|
||||
void OnMouseUp(int x, int y); //输入设备UP事件中调用
|
||||
void OnMouseDown(int x, int y);
|
||||
int is_cube_restored(void); //1:复原完成
|
||||
void random_cube(void); //随机打乱魔方
|
||||
|
||||
void draw_quadrilateral(float points[8], uint8_t color[4]);
|
||||
void display_cube(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
|
||||
#endif // __RUBIKS_CUBE_H__
|
||||
@@ -0,0 +1,449 @@
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.data : ALIGN(4)
|
||||
{
|
||||
system_ui_data_start = .;
|
||||
|
||||
system_ui_font_data_start = .;
|
||||
*(.font_Arabic.data)
|
||||
*(.font_ascii.data)
|
||||
*(.font_big5.data)
|
||||
*(.font_gbk.data)
|
||||
*(.font_Hebrew.data)
|
||||
*(.font_ksc.data)
|
||||
*(.font_other_language.data)
|
||||
*(.font_sdfs.data)
|
||||
*(.font_sjis.data)
|
||||
*(.font_textout.data)
|
||||
*(.font_thai.data)
|
||||
*(.font_utf8_2_unicode.data)
|
||||
system_ui_font_data_end = .;
|
||||
system_ui_font_data_total_size = system_ui_font_data_end - system_ui_font_data_start;
|
||||
|
||||
system_ui_framework_data_start = .;
|
||||
*(.layer.data)
|
||||
*(.layout.data)
|
||||
*(.lyrics.data)
|
||||
*(.ui_battery.data)
|
||||
*(.ui_button.data)
|
||||
*(.ui_core.data)
|
||||
*(.ui_core_api.data)
|
||||
*(.ui_core_dot.data)
|
||||
*(.ui_file_attrs.data)
|
||||
*(.ui_file_browser.data)
|
||||
*(.ui_grid.data)
|
||||
*(.ui_number.data)
|
||||
*(.ui_p.data)
|
||||
*(.ui_pic.data)
|
||||
*(.ui_progress.data)
|
||||
*(.ui_progress_multi.data)
|
||||
*(.ui_rotatable_pic.data)
|
||||
*(.ui_rotate.data)
|
||||
*(.ui_slider.data)
|
||||
*(.ui_slider_vert.data)
|
||||
*(.ui_text.data)
|
||||
*(.ui_time.data)
|
||||
*(.ui_watch.data)
|
||||
*(.window.data)
|
||||
system_ui_framework_data_end = .;
|
||||
system_ui_framework_data_total_size = system_ui_framework_data_end - system_ui_framework_data_start;
|
||||
|
||||
system_ui_resource_data_start = .;
|
||||
*(.ascii.data)
|
||||
*(.memvar.data)
|
||||
*(.quicklz.data)
|
||||
*(.resfile.data)
|
||||
*(.rle.data)
|
||||
system_ui_resource_data_end = .;
|
||||
system_ui_resource_data_total_size = system_ui_resource_data_end - system_ui_resource_data_start;
|
||||
|
||||
system_ui_timer_data_start = .;
|
||||
*(.timer.data)
|
||||
system_ui_timer_data_end = .;
|
||||
system_ui_timer_data_total_size = system_ui_timer_data_end - system_ui_timer_data_start;
|
||||
|
||||
system_ui_draw_data_start = .;
|
||||
*(.buffer_manager.data)
|
||||
*(.image_process.data)
|
||||
*(.ui_bar_chart.data)
|
||||
*(.ui_circle.data)
|
||||
*(.ui_figure.data)
|
||||
*(.ui_wave.data)
|
||||
system_ui_draw_data_end = .;
|
||||
system_ui_draw_data_total_size = system_ui_draw_data_end - system_ui_draw_data_start;
|
||||
|
||||
system_ui_simple_data_start = .;
|
||||
*(.ap_res.data)
|
||||
system_ui_simple_data_end = .;
|
||||
system_ui_simple_data_total_size = system_ui_simple_data_end - system_ui_simple_data_start;
|
||||
|
||||
system_ui_vm_data_start = .;
|
||||
*(.ui_vm_common.data)
|
||||
system_ui_vm_data_end = .;
|
||||
system_ui_vm_data_total_size = system_ui_vm_data_end - system_ui_vm_data_start;
|
||||
|
||||
system_lv_ui_core_data_start = .;
|
||||
*(.lv_ui_core.data)
|
||||
system_lv_ui_core_data_end = .;
|
||||
system_lv_ui_core_data_total_size = system_lv_ui_core_data_end - system_lv_ui_core_data_start;
|
||||
|
||||
system_lv_ui_generated_data_start = .;
|
||||
*(.lv_ui_generated.data)
|
||||
system_lv_ui_generated_data_end = .;
|
||||
system_lv_ui_generated_data_total_size = system_lv_ui_generated_data_end - system_lv_ui_generated_data_start;
|
||||
|
||||
. = ALIGN(4);
|
||||
system_lcd_device_data_start = .;
|
||||
lcd_device_begin = .;
|
||||
KEEP(*(.lcd_device_info))
|
||||
lcd_device_end = .;
|
||||
system_lcd_device_data_end = .;
|
||||
system_lcd_device_data_total_size = system_lcd_device_data_end - system_lcd_device_data_start;
|
||||
|
||||
. = ALIGN(4);
|
||||
system_ui_data_end = .;
|
||||
} > ram0
|
||||
|
||||
.bss (NOLOAD) :ALIGN(4)
|
||||
{
|
||||
system_ui_bss_start = .;
|
||||
#include "ui_varable_reg.ld"
|
||||
|
||||
system_ui_font_data_bss_start = .;
|
||||
*(.font_Arabic.data.bss)
|
||||
*(.font_ascii.data.bss)
|
||||
*(.font_big5.data.bss)
|
||||
*(.font_gbk.data.bss)
|
||||
*(.font_Hebrew.data.bss)
|
||||
*(.font_ksc.data.bss)
|
||||
*(.font_other_language.data.bss)
|
||||
*(.font_sdfs.data.bss)
|
||||
*(.font_sjis.data.bss)
|
||||
*(.font_textout.data.bss)
|
||||
*(.font_thai.data.bss)
|
||||
*(.font_utf8_2_unicode.data.bss)
|
||||
system_ui_font_data_bss_end = .;
|
||||
system_ui_font_data_bss_total_size = system_ui_font_data_bss_end - system_ui_font_data_bss_start;
|
||||
|
||||
system_ui_framework_data_bss_start = .;
|
||||
*(.layer.data.bss)
|
||||
*(.layout.data.bss)
|
||||
*(.lyrics.data.bss)
|
||||
*(.ui_battery.data.bss)
|
||||
*(.ui_button.data.bss)
|
||||
*(.ui_core.data.bss)
|
||||
*(.ui_core_api.data.bss)
|
||||
*(.ui_core_dot.data.bss)
|
||||
*(.ui_file_attrs.data.bss)
|
||||
*(.ui_file_browser.data.bss)
|
||||
*(.ui_grid.data.bss)
|
||||
*(.ui_number.data.bss)
|
||||
*(.ui_p.data.bss)
|
||||
*(.ui_pic.data.bss)
|
||||
*(.ui_progress.data.bss)
|
||||
*(.ui_progress_multi.data.bss)
|
||||
*(.ui_rotatable_pic.data.bss)
|
||||
*(.ui_rotate.data.bss)
|
||||
*(.ui_slider.data.bss)
|
||||
*(.ui_slider_vert.data.bss)
|
||||
*(.ui_text.data.bss)
|
||||
*(.ui_time.data.bss)
|
||||
*(.ui_watch.data.bss)
|
||||
*(.window.data.bss)
|
||||
system_ui_framework_data_bss_end = .;
|
||||
system_ui_framework_data_bss_total_size = system_ui_framework_data_bss_end - system_ui_framework_data_bss_start;
|
||||
|
||||
system_ui_resource_data_bss_start = .;
|
||||
*(.ascii.data.bss)
|
||||
*(.mem_var.data.bss)
|
||||
*(.quicklz.data.bss)
|
||||
*(.resfile.data.bss)
|
||||
*(.rle.data.bss)
|
||||
system_ui_resource_data_bss_end = .;
|
||||
system_ui_resource_data_bss_total_size = system_ui_resource_data_bss_end - system_ui_resource_data_bss_start;
|
||||
|
||||
system_ui_timer_data_bss_start = .;
|
||||
*(.timer.data.bss)
|
||||
system_ui_timer_data_bss_end = .;
|
||||
system_ui_timer_data_bss_total_size = system_ui_timer_data_bss_end - system_ui_timer_data_bss_start;
|
||||
|
||||
system_ui_draw_data_bss_start = .;
|
||||
*(.buffer_manager.data.bss)
|
||||
*(.image_process.data.bss)
|
||||
*(.ui_bar_chart.data.bss)
|
||||
*(.ui_circle.data.bssa)
|
||||
*(.ui_figure.data.bss)
|
||||
*(.ui_wave.data.bss)
|
||||
system_ui_draw_data_bss_end = .;
|
||||
system_ui_draw_data_bss_total_size = system_ui_draw_data_bss_end - system_ui_draw_data_bss_start;
|
||||
|
||||
system_ui_simple_data_bss_start = .;
|
||||
*(.ap_res.data.bss)
|
||||
system_ui_simple_data_bss_end = .;
|
||||
system_ui_simple_data_bss_total_size = system_ui_simple_data_bss_end - system_ui_simple_data_bss_start;
|
||||
|
||||
system_ui_vm_data_bss_start = .;
|
||||
*(.ui_vm_common.data.bss)
|
||||
system_ui_vm_data_bss_end = .;
|
||||
system_ui_vm_data_bss_total_size = system_ui_vm_data_bss_end - system_ui_vm_data_bss_start;
|
||||
|
||||
system_lv_ui_core_data_bss_start = .;
|
||||
*(.lv_ui_core.data.bss)
|
||||
system_lv_ui_core_data_bss_end = .;
|
||||
system_lv_ui_core_data_bss_total_size = system_lv_ui_core_data_bss_end - system_lv_ui_core_data_bss_start;
|
||||
|
||||
system_lv_ui_generated_data_bss_start = .;
|
||||
*(.lv_ui_generated.data.bss)
|
||||
system_lv_ui_generated_data_bss_end = .;
|
||||
system_lv_ui_generated_data_bss_total_size = system_lv_ui_generated_data_bss_end - system_lv_ui_generated_data_bss_start;
|
||||
|
||||
. = ALIGN(4);
|
||||
system_ui_bss_end = .;
|
||||
} > ram0
|
||||
|
||||
.text : ALIGN(4)
|
||||
{
|
||||
system_ui_text_start = .;
|
||||
|
||||
system_ui_font_text_start = .;
|
||||
*(.ui_ram)
|
||||
*(.font_Arabic.text)
|
||||
*(.font_Arabic.text.const)
|
||||
*(.font_ascii.text)
|
||||
*(.font_ascii.text.const)
|
||||
*(.font_big5.text)
|
||||
*(.font_big5.text.const)
|
||||
*(.font_gbk.text)
|
||||
*(.font_gbk.text.const)
|
||||
*(.font_Hebrew.text)
|
||||
*(.font_Hebrew.text.const)
|
||||
*(.font_ksc.text)
|
||||
*(.font_ksc.text.const)
|
||||
*(.font_other_language.text)
|
||||
*(.font_other_language.text.const)
|
||||
*(.font_sdfs.text)
|
||||
*(.font_sdfs.text.const)
|
||||
*(.font_sjis.text)
|
||||
*(.font_sjis.text.const)
|
||||
*(.font_textout.text)
|
||||
*(.font_textout.text.const)
|
||||
*(.font_thai.text)
|
||||
*(.font_thai.text.const)
|
||||
*(.font_utf8_2_unicode.text)
|
||||
*(.font_utf8_2_unicode.text.const)
|
||||
system_ui_font_text_end = .;
|
||||
system_ui_font_text_total_size = system_ui_font_text_end - system_ui_font_text_start;
|
||||
|
||||
system_ui_framework_text_start = .;
|
||||
*(.layer.text)
|
||||
*(.layout.text)
|
||||
*(.lyrics.text)
|
||||
*(.ui_battery.text)
|
||||
*(.ui_button.text)
|
||||
*(.ui_core.text)
|
||||
*(.ui_core_api.text)
|
||||
*(.ui_core_dot.text)
|
||||
*(.ui_file_attrs.text)
|
||||
*(.ui_file_browser.text)
|
||||
*(.ui_grid.text)
|
||||
*(.ui_number.text)
|
||||
*(.ui_p.text)
|
||||
*(.ui_pic.text)
|
||||
*(.ui_progress.text)
|
||||
*(.ui_progress_multi.text)
|
||||
*(.ui_rotatable_pic.text)
|
||||
*(.ui_rotate.text)
|
||||
*(.ui_slider.text)
|
||||
*(.ui_slider_vert.text)
|
||||
*(.ui_text.text)
|
||||
*(.ui_time.text)
|
||||
*(.ui_watch.text)
|
||||
*(.window.text)
|
||||
*(.layer.text.const)
|
||||
*(.layout.text.const)
|
||||
*(.lyrics.text.const)
|
||||
*(.ui_battery.text.const)
|
||||
*(.ui_button.text.const)
|
||||
*(.ui_core.text.const)
|
||||
*(.ui_core_api.text.const)
|
||||
*(.ui_core_dot.text.const)
|
||||
*(.ui_file_attrs.text.const)
|
||||
*(.ui_file_browser.text.const)
|
||||
*(.ui_grid.text.const)
|
||||
*(.ui_number.text.const)
|
||||
*(.ui_p.text.const)
|
||||
*(.ui_pic.text.const)
|
||||
*(.ui_progress.text.const)
|
||||
*(.ui_progress_multi.text.const)
|
||||
*(.ui_rotatable_pic.text.const)
|
||||
*(.ui_rotate.text.const)
|
||||
*(.ui_slider.text.const)
|
||||
*(.ui_slider_vert.text.const)
|
||||
*(.ui_text.text.const)
|
||||
*(.ui_time.text.const)
|
||||
*(.ui_watch.text.const)
|
||||
*(.window.text.const)
|
||||
system_ui_framework_text_end = .;
|
||||
system_ui_framework_text_total_size = system_ui_framework_text_end - system_ui_framework_text_start;
|
||||
|
||||
system_ui_resource_text_start = .;
|
||||
*(.ascii.text)
|
||||
*(.mem_var.text)
|
||||
*(.quicklz.text)
|
||||
*(.resfile.text)
|
||||
*(.rle.text)
|
||||
*(.ascii.text.const)
|
||||
*(.memvar.text.const)
|
||||
*(.quicklz.text.const)
|
||||
*(.resfile.text.const)
|
||||
*(.rle.text.const)
|
||||
system_ui_resource_text_end = .;
|
||||
system_ui_resource_text_total_size = system_ui_resource_text_end - system_ui_resource_text_start;
|
||||
|
||||
system_ui_timer_text_start = .;
|
||||
*(.timer.text)
|
||||
*(.timer.text.const)
|
||||
system_ui_timer_text_end = .;
|
||||
system_ui_timer_text_total_size = system_ui_timer_text_end - system_ui_timer_text_start;
|
||||
|
||||
system_ui_draw_text_start = .;
|
||||
*(.buffer_manager.text)
|
||||
*(.image_process.text)
|
||||
*(.ui_bar_chart.text)
|
||||
*(.ui_circle.text)
|
||||
*(.ui_figure.text)
|
||||
*(.ui_wave.text)
|
||||
*(.buffer_manager.text.const)
|
||||
*(.image_process.text.const)
|
||||
*(.ui_bar_chart.text.const)
|
||||
*(.ui_circle.text.const)
|
||||
*(.ui_figure.text.const)
|
||||
*(.ui_wave.text.const)
|
||||
system_ui_draw_text_end = .;
|
||||
system_ui_draw_text_total_size = system_ui_draw_text_end - system_ui_draw_text_start;
|
||||
|
||||
system_ui_simple_text_start = .;
|
||||
*(.ap_res.text)
|
||||
*(.ap_res.text.const)
|
||||
system_ui_simple_text_end = .;
|
||||
system_ui_simple_text_total_size = system_ui_simple_text_end - system_ui_simple_text_start;
|
||||
|
||||
system_ui_vm_text_start = .;
|
||||
*(.ui_vm_common.text)
|
||||
*(.ui_vm_common.text.const)
|
||||
system_ui_vm_text_end = .;
|
||||
system_ui_vm_text_total_size = system_ui_vm_text_end - system_ui_vm_text_start;
|
||||
|
||||
system_lv_ui_core_text_start = .;
|
||||
*(.lv_ui_core.text)
|
||||
*(.lv_ui_core.text.const)
|
||||
system_lv_ui_core_text_end = .;
|
||||
system_lv_ui_core_text_total_size = system_lv_ui_core_text_end - system_lv_ui_core_text_start;
|
||||
|
||||
system_lv_ui_generated_text_start = .;
|
||||
*(.lv_ui_generated.text)
|
||||
*(.lv_ui_generated.text.const)
|
||||
system_lv_ui_generated_text_end = .;
|
||||
system_lv_ui_generated_text_total_size = system_lv_ui_generated_text_end - system_lv_ui_generated_text_start;
|
||||
|
||||
. = ALIGN(4);
|
||||
lcd_interface_begin = .;
|
||||
KEEP(*(.lcd_if_info))
|
||||
lcd_interface_end = .;
|
||||
|
||||
|
||||
ui_style_begin = .;
|
||||
KEEP(*(.ui_style))
|
||||
ui_style_end = .;
|
||||
|
||||
|
||||
elm_event_handler_begin_JL = .;
|
||||
KEEP(*(.elm_event_handler_JL))
|
||||
elm_event_handler_end_JL = .;
|
||||
|
||||
elm_event_handler_begin_UPGRADE = .;
|
||||
KEEP(*(.elm_event_handler_UPGRADE))
|
||||
elm_event_handler_end_UPGRADE = .;
|
||||
|
||||
|
||||
|
||||
elm_event_handler_begin_DIAL = .;
|
||||
KEEP(*(.elm_event_handler_DIAL))
|
||||
elm_event_handler_end_DIAL = .;
|
||||
|
||||
|
||||
control_event_handler_begin = .;
|
||||
KEEP(*(.control_event_handler))
|
||||
control_event_handler_end = .;
|
||||
|
||||
control_ops_begin = .;
|
||||
KEEP(*(.control_ops))
|
||||
control_ops_end = .;
|
||||
|
||||
battery_notify_begin = .;
|
||||
*(.battery_notify)
|
||||
battery_notify_end = .;
|
||||
|
||||
. = ALIGN(4);
|
||||
lcd_sleep_ctrl_headler_begin = .;
|
||||
KEEP(*(.lcd_sleep_headler))
|
||||
lcd_sleep_ctrl_headler_end = .;
|
||||
|
||||
//ui变量寄存器专属
|
||||
#if TCFG_UI_ENABLE && CONFIG_LVGL_UI_ENABLE
|
||||
PROVIDE(ui_varable_reg_tab_begin = .);
|
||||
KEEP(*(.ui_varable_reg_tab))
|
||||
PROVIDE(ui_varable_reg_tab_end = .);
|
||||
|
||||
ui_module_event_handler_begin = .;
|
||||
KEEP(*(.ui_module_event_handler))
|
||||
ui_module_event_handler_end = .;
|
||||
|
||||
ui_screen_action_handler_begin = .;
|
||||
KEEP(*(.ui_screen_action_handler))
|
||||
ui_screen_action_handler_end = .;
|
||||
|
||||
ui_key_event_handler_begin = .;
|
||||
KEEP(*(.ui_key_event_handler))
|
||||
ui_key_event_handler_end = .;
|
||||
#else
|
||||
|
||||
PROVIDE(ui_varable_reg_tab_begin = .);
|
||||
*(.ui_varable_reg_tab)
|
||||
PROVIDE(ui_varable_reg_tab_end = .);
|
||||
|
||||
ui_module_event_handler_begin = .;
|
||||
*(.ui_module_event_handler)
|
||||
ui_module_event_handler_end = .;
|
||||
|
||||
ui_screen_action_handler_begin = .;
|
||||
*(.ui_screen_action_handler)
|
||||
ui_screen_action_handler_end = .;
|
||||
|
||||
ui_key_event_handler_begin = .;
|
||||
*(.ui_key_event_handler)
|
||||
ui_key_event_handler_end = .;
|
||||
#endif
|
||||
|
||||
. = ALIGN(4);
|
||||
system_ui_text_end = .;
|
||||
} > code0
|
||||
|
||||
.data_code ALIGN(32):
|
||||
{
|
||||
system_ui_data_text_start = .;
|
||||
system_ui_data_text_end = .;
|
||||
} > ram0
|
||||
|
||||
}
|
||||
|
||||
ui_ld_data_size = system_ui_data_end - system_ui_data_start;
|
||||
ui_ld_bss_size = system_ui_bss_end - system_ui_bss_start;
|
||||
ui_ld_text_size = system_ui_text_end - system_ui_text_start;
|
||||
ui_ld_data_text_size = system_ui_data_text_end - system_ui_data_text_start;
|
||||
|
||||
ui_ld_code_size = ui_ld_data_size + ui_ld_text_size + ui_ld_data_text_size;
|
||||
ui_ld_ram_size = ui_ld_data_size + ui_ld_bss_size + ui_ld_data_text_size;
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#define REGISTER_UI_VARIABLE_REG(MSG_ID) \
|
||||
. = ALIGN(4);\
|
||||
PROVIDE(ui_varable_reg_begin_##MSG_ID = .); \
|
||||
KEEP(*(.ui_varable_reg_##MSG_ID)) \
|
||||
PROVIDE(ui_varable_reg_end_##MSG_ID = .);
|
||||
|
||||
|
||||
|
||||
|
||||
PROVIDE(ui_varable_reg_begin = .);
|
||||
|
||||
//根据实际变量寄存器的类型对齐,连续对齐保持可节省内存空间
|
||||
REGISTER_UI_VARIABLE_REG(10)
|
||||
REGISTER_UI_VARIABLE_REG(11)
|
||||
REGISTER_UI_VARIABLE_REG(12)
|
||||
|
||||
|
||||
PROVIDE(ui_varable_reg_end = .);
|
||||
|
||||
Reference in New Issue
Block a user