current_v/Inc/ht16k33_dot_matrix.h
2025-12-31 08:21:43 +08:00

142 lines
5.2 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file : ht16k33_dot_matrix.h
* @brief : 屏幕显示
* @version : 1.0
* @changelog : version 1.0 初始版本 2025.11.13
******************************************************************************
* @attention
*
* Copyright (c) 2025 Yuwell Software Danyang.Jiangsu.China
* THIS SOFTWARE is licensed under the Mulan PSL v1.
* can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __OXG_8F_10W_DISPLAY_H
#define __OXG_8F_10W_DISPLAY_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include "fm33lg0xx_fl.h"
#include "fm33lg0xx_queue.h"
#include "fm33lg0xx_event.h"
/************************** 硬件层接口定义 *************************/
#define HT16K33_SDA_GPIO_GROUP GPIOC
#define HT16K33_SDA_GPIO_PIN FL_GPIO_PIN_11
#define HT16K33_SCL_GPIO_GROUP GPIOC
#define HT16K33_SCL_GPIO_PIN FL_GPIO_PIN_12
/************************** 软件层可配置项定义 *************************/
// HT16K33 28脚版本I2C地址A0~A2悬空时为0x70可通过引脚配置修改
#define HT16K33_ADDR 0x70 << 1 // I2C地址左移1位包含读写位
// 核心命令定义
#define HT16K33_CMD_SYSTEM_ON 0x21 // 系统开启(振荡器启动)
#define HT16K33_CMD_SYSTEM_OFF 0x20 // 系统关闭(待机模式)
#define HT16K33_CMD_DISPLAY_ON 0x81 // 显示开启D=1闪烁关闭
#define HT16K33_CMD_DISPLAY_OFF 0x80 // 显示关闭
#define HT16K33_CMD_BLINK_0_5HZ 0x83 // 闪烁频率0.5HzB1=1,B0=1
#define HT16K33_CMD_BLINK_1HZ 0x82 // 闪烁频率1HzB1=1,B0=0
#define HT16K33_CMD_BLINK_2HZ 0x81 // 闪烁频率2HzB1=0,B0=1
#define HT16K33_CMD_DIMMING_MAX 0xEF // 最大亮度16/16占空比
#define HT16K33_CMD_INT_ENABLE 0xA9 // INT引脚使能active-high
#define HT16K33_CMD_DISP_ADDR 0x00 // 显示RAM地址指针起始0x00
#define HT16K33_CMD_ADDR_KEY 0x40 // 按键RAM地址指针起始0x40
#define DISP_BUFFER_SIZE (16)
#define SEG_TABLE_SIZE (20)
/************************** 显示数据存储格式定义 *************************/
/**
* @brief 复杂子结构体:显示模式及对应数据
* 用于控制当前界面显示累时或氧浓度
*/
typedef struct
{
uint32_t work_hours; // 累时模式下的工作小时数0-19999h
uint32_t work_minutes; // 获取累时分钟数
uint32_t work_seconds; // 工作秒数
uint16_t oxygen_val; // 氧浓度模式下的浓度值0-999对应0%-99.9%
uint16_t flow_val; // 流量数据用于ui界面刷新时检测LL故障
struct{
uint8_t num1_is_show;
uint8_t first_8_index;
uint8_t second_8_index;
uint8_t third_8_index;
uint8_t fourth_8_index;
uint8_t carlib_code;
}seg_index;
} DisplayContent;
/**
* @brief 界面元素状态结构体(记录各类指示灯及显示内容)
*/
typedef struct
{
uint8_t ok_led_show : 1; // OK灯是否显示1:显示 0:不显示)
uint8_t alarm_led_show : 1; // 报警灯是否显示1:显示 0:不显示)
uint8_t clean_filter_show : 1; // 清洁滤网提示是否显示1:显示 0:不显示)
uint8_t replace_box_show : 1; // 更换过滤盒提示是否显示1:显示 0:不显示)
uint8_t total_time_chn : 1; // 累时包含中文和h 中文是否显示1:显示 0:不显示)
uint8_t oxg_concentration_chn : 1; // 浓度的中文(包含中文 % 和.是否显示1:显示 0:不显示)
// uint8_t on_left_num_1 : 1; // 最左侧的数字1是否显示1:显示 0:不显示)
DisplayContent disp_info; // 显示模式及对应数据(子结构体)
} UIElements;
/************************** 宏函数定义 *************************/
#define HT16K33_SDA_CLEAR() FL_GPIO_ResetOutputPin(HT16K33_SDA_GPIO_GROUP,HT16K33_SDA_GPIO_PIN);
#define HT16K33_SDA_SET() FL_GPIO_SetOutputPin(HT16K33_SDA_GPIO_GROUP,HT16K33_SDA_GPIO_PIN);
#define HT16K33_SCL_CLEAR() FL_GPIO_ResetOutputPin(HT16K33_SCL_GPIO_GROUP,HT16K33_SCL_GPIO_PIN);
#define HT16K33_SCL_SET() FL_GPIO_SetOutputPin(HT16K33_SCL_GPIO_GROUP,HT16K33_SCL_GPIO_PIN);
/************************** 提供给外部的函数及变量 *************************/
extern UIElements ui;
extern uint8_t ht16k33_disp_buff[DISP_BUFFER_SIZE];
void ht16k33_ui_init(UIElements* p_ui); // 初始化屏幕
void ht16k33_chip_init(void); // 放在初始化中-初始化芯片 开启芯片时钟
uint8_t ht16k33_send_buffer(uint8_t* disp_buffer); // 放在初始化中-下发显示缓存
void ht16k33_refresh_task(void); // 根据消息队列内容修改变量ui
void ht16k33_refresh_screen(void); // 放到ui任务最后《先初始化屏幕-再下发计算后的缓存》根据ui变量刷新屏幕显示内容
#ifdef __cplusplus
}
#endif
#endif /* __OXG_8F_10W_DISPLAY_H */
/************************ (C) COPYRIGHT Yuwell *****END OF FILE****/