工程标准

1.移植lvgl库

链接:https://github.com/lvgl/lvgl

2.在工程目录下新建./main/qm_ui_entry.h ./main/qm_ui_entry.c用于生成8MS平台代码

-注: qm_ui_entry.h 中需要 include lvgl 库并且声明 void lv_qm_ui_entry(void); void lv_qm_ui_loop(void);

3.需要提供api用于读取芯片的指定识别码用于后续授权相关工作

4.BLOCKLY硬件功能实现

(下列函数的参数类型,返回值不需要完全一致)

- GPIO

typedef enum
    {
        LV_8MS_GPIO_LOW = 0,
        LV_8MS_GPIO_HIGH
    } lv_8ms_gpio_level_t;

    typedef enum
    {
        LV_8MS_GPIO_OUT = 0,
        LV_8MS_GPIO_OUT_OD,
        LV_8MS_GPIO_IN_UP,
        LV_8MS_GPIO_IN_DOWN,
        LV_8MS_GPIO_IN_FLOATING
    } lv_8ms_gpio_dir_t;
/**
* @brief 设置修改模式的消息
* @param gpio_num 引脚编号,注意有些引脚功能不完全,详见 @ref gpio_num_t
* @param mode 引脚模式,有输出两种,输入三种,详见 @ref lv_8ms_gpio_dir_t
*/
void lv_8ms_gpio_init(gpio_num_t gpio_num, lv_8ms_gpio_dir_t mode)
/** 
* @brief 设置读取引脚电平的消息
* @param gpio_num 引脚编号,注意有些引脚功能不完全,详见 @ref gpio_num_t
* @return 返回高低电平,0 或者 1,如果错误会返回-1
*/

int lv_8ms_gpio_read(gpio_num_t gpio_num)
/**
* @brief 设置写入电平的消息
* @param gpio_num 引脚编号,注意有些引脚功能不完全,详见 @ref gpio_num_t 
* @param level 引脚电平的高低,LOW或者HIGH,详见 @ref lv_8ms_gpio_level_t
*/
void lv_8ms_gpio_write(gpio_num_t gpio_num, lv_8ms_gpio_level_t level)

I2C
int lv_8ms_i2c_init(const char *devname);
void lv_8ms_i2c_uninit(int fd);
int lv_8ms_i2c_write(int fd, unsigned char slave_addr, unsigned char reg_addr, unsigned char value);
int lv_8ms_i2c_read(int fd, unsigned char slave_addr, unsigned char reg_addr, unsigned char *value);

PWM
int lv_8ms_pwm_init(int chipid, int pin);
int lv_8ms_pwm_uninit(int chipid, int pin);
int lv_8ms_pwm_read_period(int chidid, int pin);
int lv_8ms_pwm_write_period(int chidid, int pin, int s);
int lv_8ms_pwm_write_period_ms(int chidid, int pin, int ms);
int lv_8ms_pwm_write_period_us(int chidid, int pin, int us);
int lv_8ms_pwm_read_duty(int chipid, int pin, int duty);
int lv_8ms_pwm_write_duty(int chipid, int pin, int duty);
int lv_8ms_pwm_set_status(int chidid, int pin, int status);
int lv_8ms_pwm_get_status(int chipid, int pin);

UART
typedef enum {
    LV_8MS_UART_PARITY_NONE = 0,
    LV_8MS_UART_PARITY_EVEN = 1,
    LV_8MS_UART_PARITY_ODD = 2,
    LV_8MS_UART_PARITY_MARK = 3,
    LV_8MS_UART_PARITY_SPACE = 4
} lv_8ms_uart_parity_t;

int lv_8ms_uart_init(const char *devname);
int lv_8ms_uart_settings(int fd, int* baudrate, int* databits, int* stopbits, lv_8ms_uart_parity_t* parity, unsigned int* ctsrts, unsigned int* xonxoff);
int lv_8ms_uart_flush(int fd);
int lv_8ms_uart_sendbreak(int fd, int duration);
int lv_8ms_uart_set_baudrate(int fd, unsigned int baud);
int lv_8ms_uart_set_mode(int fd, int bytesize, lv_8ms_uart_parity_t parity, int stopbits);
int lv_8ms_uart_set_flowcontrol(int fd, int xonxoff, int rtscts);
int lv_8ms_uart_set_timeout(int fd, int readtimeout);
int lv_8ms_uart_set_non_blocking(int fd, int nonblock);
void lv_8ms_uart_uninit(int fd);
int lv_8ms_uart_write(int fd, const char* buf, size_t len);
int lv_8ms_uart_read(int fd, char* buf, size_t len);
int lv_8ms_uart_data_available(int fd, unsigned int millis);
文档更新时间: 2021-04-26 14:39   作者:shuke