275 lines
11 KiB
C
275 lines
11 KiB
C
/* USER CODE BEGIN Header */
|
||
/**
|
||
******************************************************************************
|
||
* @file : 8f_5aw_display.h
|
||
* @brief : 8f-5aw显示驱动芯片
|
||
* @version : 1.0
|
||
* @changelog : version 1.0 初始版本 2026.1.8
|
||
******************************************************************************
|
||
* @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 __8F_5AW_DISPLAY_H
|
||
#define __8F_5AW_DISPLAY_H
|
||
|
||
#ifdef __cplusplus
|
||
extern "C" {
|
||
#endif
|
||
|
||
#include <stdint.h>
|
||
#include "mf_config.h"
|
||
#include "string.h"
|
||
|
||
|
||
/************************** 硬件参数重映射 **************************/
|
||
// 对硬件进行重定向
|
||
#define BL55072A_SCL_GPIO_PORT GPIOD
|
||
#define BL55072A_SCL_GPIO_PIN FL_GPIO_PIN_2
|
||
#define BL55072A_SDA_GPIO_PORT GPIOD
|
||
#define BL55072A_SDA_GPIO_PIN FL_GPIO_PIN_3
|
||
|
||
|
||
/************************** 宏函数定义 *************************/
|
||
#define BL55072A_SDA_CLEAR() FL_GPIO_ResetOutputPin(BL55072A_SDA_GPIO_PORT,BL55072A_SDA_GPIO_PIN);
|
||
#define BL55072A_SDA_SET() FL_GPIO_SetOutputPin(BL55072A_SDA_GPIO_PORT,BL55072A_SDA_GPIO_PIN);
|
||
|
||
#define BL55072A_SCL_CLEAR() FL_GPIO_ResetOutputPin(BL55072A_SCL_GPIO_PORT,BL55072A_SCL_GPIO_PIN);
|
||
#define BL55072A_SCL_SET() FL_GPIO_SetOutputPin(BL55072A_SCL_GPIO_PORT,BL55072A_SCL_GPIO_PIN);
|
||
|
||
|
||
|
||
|
||
|
||
/************************** 显示芯片配置 **************************/
|
||
#define BL55072A_I2C_ADDR_R 0x7D
|
||
#define BL55072A_I2C_ADDR_W 0x7C
|
||
|
||
|
||
#define BL55072A_DISP_BUF_SIZE 18 // 显示缓冲区大小
|
||
|
||
|
||
// 1. 模式设置命令 MODESET (Bit7=C=1 表示后续仍为命令,C=0表示最后一个命令)
|
||
#define MODESET_BASIC 0xC0 // Bit7=C=1, Bit6=1, Bit5=0(固定格式)
|
||
#define MODESET_DISP_OFF 0x00 // Bit3=0:显示关闭(默认)
|
||
#define MODESET_DISP_ON 0x08 // Bit3=1:显示开启
|
||
#define MODESET_BIAS_1_3 0x00 // Bit2=0:1/3偏置(默认)
|
||
#define MODESET_BIAS_1_2 0x04 // Bit2=1:1/2偏置
|
||
#define BL55072A_CMD_MODESET (MODESET_BASIC | MODESET_DISP_ON | MODESET_BIAS_1_3)
|
||
|
||
|
||
// 2. 地址设置命令 ADSET
|
||
#define BL55072A_CMD_ADSET 0x00 // Bit7=C=0, Bit6=0, Bit5=0 下发之后发送显存
|
||
|
||
|
||
|
||
// 3. 显示控制命令 DISCTL
|
||
#define DISCTL_BASIC 0xA0 // Bit7=C=1, Bit6=0(固定格式)
|
||
// 帧频选择(Bit4~Bit3)
|
||
#define DISCTL_FR_80HZ 0x00 // 00:80Hz(默认)
|
||
#define DISCTL_FR_71HZ 0x08 // 01:71Hz
|
||
#define DISCTL_FR_64HZ 0x10 // 10:64Hz
|
||
#define DISCTL_FR_53HZ 0x18 // 11:53Hz
|
||
// 驱动模式(Bit2)
|
||
#define DISCTL_DM_LINE_INV 0x00 // 0:行反转模式(默认)
|
||
#define DISCTL_DM_FRAME_INV 0x04 // 1:帧反转模式
|
||
// 省电模式(Bit1~Bit0)
|
||
#define DISCTL_SR_MODE1 0x00 // 00:省电模式1
|
||
#define DISCTL_SR_MODE2 0x01 // 01:省电模式2
|
||
#define DISCTL_SR_NORMAL 0x02 // 10:正常模式(默认)
|
||
#define DISCTL_SR_HIGH_POWER 0x03 // 11:高功耗模式
|
||
#define BL55072A_CMD_DISCTL (DISCTL_BASIC | DISCTL_FR_80HZ | DISCTL_DM_LINE_INV |DISCTL_SR_NORMAL)
|
||
|
||
|
||
// 4. 芯片设置命令 ICSET
|
||
#define ICSET_BASIC 0xE0 // Bit7=C=1, Bit6=1, Bit5=1(固定格式)
|
||
#define ICSET_SOFT_RST_DIS 0x00 // Bit1=0:软件复位关闭(默认)
|
||
#define ICSET_SOFT_RST_EN 0x02 // Bit1=1:软件复位使能
|
||
#define ICSET_OSC_INNER 0x00 // Bit0=0:内部振荡器(默认,OSCIO接VSS)
|
||
#define ICSET_OSC_OUTER 0x01 // Bit0=1:外部振荡器(OSCIO接外部时钟)
|
||
#define BL55072A_CMD_ICSET (ICSET_BASIC | ICSET_SOFT_RST_DIS |ICSET_OSC_INNER)
|
||
|
||
|
||
|
||
// 5. 闪烁控制命令 BLKCTL
|
||
#define BLKCTL_BASIC 0xF0 // Bit7=C=1, Bit6=1, Bit5=1, Bit4=1(固定格式)
|
||
#define BLKCTL_OFF 0x00 // 000:闪烁关闭(默认)
|
||
#define BLKCTL_0_5HZ 0x01 // 001:0.5Hz闪烁
|
||
#define BLKCTL_1HZ 0x02 // 010:1Hz闪烁
|
||
#define BLKCTL_2HZ 0x03 // 011:2Hz闪烁
|
||
#define BLKCTL_0_3HZ 0x04 // 100:0.3Hz闪烁(手册为0.3s?按手册定义)
|
||
#define BLKCTL_0_2HZ 0x05 // 101:0.2Hz闪烁(手册为0.2s?按手册定义)
|
||
#define BL55072A_CMD_BLKCTL (BLKCTL_BASIC | BLKCTL_OFF)
|
||
|
||
|
||
|
||
// 6. 全显控制命令 APCTL
|
||
#define APCTL_BASIC 0xFC // Bit7=C=1, Bit6=1, Bit5=1, Bit4=1, Bit3=1, Bit2=1(固定格式)
|
||
#define APCTL_NORMAL 0x00 // 正常显示(默认)
|
||
#define APCTL_ALL_ON 0x02 // Bit1=1:全亮
|
||
#define APCTL_ALL_OFF 0x01 // Bit0=1:全暗(优先级高于全亮)
|
||
#define BL55072A_CMD_APCTL (APCTL_BASIC | APCTL_NORMAL)
|
||
|
||
|
||
|
||
/************************** 原理图SEG地址与液晶屏SEG顺序对照 **************************/
|
||
|
||
#define TIMER_FIRST8_AFED_SEG_NUM (30) // 定时部分第一个8 AFED段 所在SEG
|
||
#define TIMER_FIRST8_BGC_SEG_NUM (29)
|
||
|
||
#define TIMER_SECOND8_AFED_SEG_NUM (28)
|
||
#define TIMER_SECOND8_BGC_SEG_NUM (27)
|
||
|
||
#define TIMER_THIRD8_AFED_SEG_NUM (26)
|
||
#define TIMER_THIRD8_BGC_SEG_NUM (25)
|
||
|
||
#define TIMER_FOURTH8_AFED_SEG_NUM (18)
|
||
#define TIMER_FOURTH8_BGC_SEG_NUM (17)
|
||
|
||
#define TIME_FIRST8_AFED_SEG_NUM (16) // 累时部分第一个8 AFED段 所在SEG
|
||
#define TIME_FIRST8_BGC_SEG_NUM (15)
|
||
|
||
#define TIME_SECOND8_AFED_SEG_NUM (14)
|
||
#define TIME_SECOND8_BGC_SEG_NUM (13)
|
||
|
||
#define TIME_THIRD8_AFED_SEG_NUM (12)
|
||
#define TIME_THIRD8_BGC_SG_NUM (11)
|
||
|
||
#define TIME_FOURTH8_AFED_SEG_NUM (10)
|
||
#define TIME_FOURTH8_BGC_SEG_NUM (9)
|
||
|
||
#define TIME_FIFTH8_AFED_SEG_NUM (8)
|
||
#define TIME_FIFTH8_BGC_SEG_NUM (7)
|
||
|
||
#define ERROR_FIRT8_AFED_SEG_NUM (31) // 故障码显示第一个8
|
||
#define ERROR_FIRT8_BGC_SEG_NUM (32)
|
||
|
||
#define ERROR_SECOND8_AFED_SEG_NUM (33)
|
||
#define ERROR_SECOND8_BGC_SEG_NUM (34)
|
||
|
||
#define OXG_FIRST8_AFED_SEG_NUM (35) // 氧浓度第一个8 AFED段 所在SEG
|
||
#define OXG_FIRST8_BGC_SEG_NUM (0)
|
||
|
||
#define OXG_SECOND8_AFED_SEG_NUM (1)
|
||
#define OXG_SECOND8_BGC_SEG_NUM (2)
|
||
|
||
#define OXG_THIRD8_AFED_SEG_NUM (3)
|
||
#define OXG_THIRD8_BGC_SG_NUM (4)
|
||
|
||
#define ADDITION_SEG_POS (0x08) // 除数字之外其他附加字符所在位置
|
||
|
||
#define TIMER_COL_ARRAY_INDEX (13)
|
||
#define TIMER_H1_ARRAY_INDEX (8)
|
||
#define TOTAL_TIME_H2_ARRAY_INDEX (3)
|
||
#define OXG_S1_ARRAY_INDEX (17)
|
||
#define OXG_POINT_ARRAY_INDEX (1)
|
||
#define OXG_PERCEENET_ARRAY_INDEX (2)
|
||
|
||
|
||
/************************** 显示内容配置结构体定义 **************************/
|
||
// 定义灯的状态枚举
|
||
typedef enum
|
||
{
|
||
LIGHT_OFF = 0, // 灯灭,值为0
|
||
LIGHT_ON = 1 // 亮起,值为1
|
||
}LightState;
|
||
|
||
|
||
// 用于选择累时部分显示模式
|
||
typedef enum
|
||
{
|
||
MODE_TIME_TOTAL_TIME, // 累时部分五个8按照total_time的值进行显示 用于显示H及累时
|
||
MODE_TIME_INDEX // 累时部分五个8使用index的值进行显示,不显示H 用于上电显示Hello
|
||
|
||
}Time_Mode;
|
||
|
||
|
||
// 用于选择浓度部分显示模式
|
||
typedef enum
|
||
{
|
||
MODE_OXG_VALUE, // 用于显示浓度当前浓度值 该模式下将同时显示字符与数字
|
||
MODE_OXG_INDEX // 用于按照索引值进行显示 该模式下数字根据索引进行显示 字符根据配置选择是否显示
|
||
|
||
}OXG_Mode;
|
||
|
||
|
||
// 用于设置界面显示的内容的结构体
|
||
typedef struct
|
||
{
|
||
struct
|
||
{
|
||
uint8_t hours; // 定时小时数
|
||
uint8_t minutes; // 定时分钟数
|
||
|
||
LightState is_light; // 显示控制 用于控制定时部分内容是否显示
|
||
}timer;
|
||
|
||
struct
|
||
{
|
||
Time_Mode time_mode; // 显示累时还是HELLO MODE_TIME_TOTAL_TIME显示累时 MODE_TIME_INDEX用于按照索引值显示
|
||
|
||
uint32_t hours; // 累时小时数
|
||
|
||
uint8_t first8_segtable_index; // 从左向右数第一个8显示内容对应断码表索引
|
||
uint8_t second8_segtable_index;
|
||
uint8_t third8_segtable_index;
|
||
uint8_t fourth8_segtable_index;
|
||
uint8_t fifth8_segtable_index; // 从左向右第五个8 显示内容对应断码表索引
|
||
|
||
LightState is_light; // 显示控制
|
||
}total_time;
|
||
|
||
|
||
struct
|
||
{
|
||
OXG_Mode oxg_mode; // 显示模式 MODE_OXG_VALUE显示当前浓度值 MODE_OXG_INDEX根据索引显示当前值
|
||
|
||
uint16_t value; // 浓度值 999对应99.9% 用于MODE_OXG_VALUE显示当前浓度值
|
||
|
||
uint8_t first8_segtable_index; // 从左向右数第一个8显示内容对应断码表索引
|
||
uint8_t second8_segtable_index;
|
||
uint8_t third8_segtable_index;
|
||
|
||
LightState chn_is_light; // 用于选择在 MODE_OXG_INDEX模式下是否还要显示浓度相关的字符
|
||
|
||
LightState is_light; // 整个浓度区域显示控制 包含字符与数字
|
||
}oxg;
|
||
|
||
|
||
|
||
}PanelDisplayInfo;
|
||
|
||
// 导出屏幕内容显示变量
|
||
extern volatile PanelDisplayInfo panel_display_info;
|
||
|
||
|
||
|
||
|
||
|
||
/************************** 供外部调用的API函数 **************************/
|
||
void user_display_init(void); // 上电后执行 用于初始化GPIO 显示屏显存内容
|
||
void user_display_refresh(void); // 每隔500ms执行一次 用于周期性刷新屏幕
|
||
|
||
|
||
|
||
#ifdef __cplusplus
|
||
}
|
||
#endif
|
||
|
||
#endif /* __8F_5AW_DISPLAY_H */
|
||
|
||
/************************ (C) COPYRIGHT Yuwell *****END OF FILE****/
|