current_v/8F_5AW_Display/8f_5aw_display.c
ipason 2251469662 发给吴工的完整版显示+电量计程序
(电量计程序和之前发的不一样 之前发的是五个390k的版本 当前的是3个620的版本 检测结果存在10V的差异)
2026-01-12 10:37:18 +08:00

561 lines
18 KiB
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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.

/**
******************************************************************************
* @file 8f_5aw_display.c
* @author Motor Control SDK Team, Yuwell Software XiangenWang
* @brief Voice Recognition Module Initialization Section,
including peripheral initialization and message node insertion, etc.
* @version 1.0
* @changelog version 1.0 ³õʼ°æ±¾ 2026.1.8
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2025 Yuwell Software Danyang.Jiangsu.China.
* All rights reserved.</center></h2>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted, provided that the following conditions are met:
*
* 1. Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of Yuwell Software nor the names of other
* contributors to this software may be used to endorse or promote products
* derived from this software without specific written permission.
* 4. This software, including modifications and/or derivative works of this
* software, must execute solely and exclusively on microcontroller or
* microprocessor devices manufactured by or for Yuwell Software.
* 5. Redistribution and use of this software other than as permitted under
* this license is void and will automatically terminate your rights under
* this license.
*
* THIS SOFTWARE IS PROVIDED BY Yuwell Software AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
* SHALL Yuwell Software OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************
*/
/* USER CODE END Header */
#include "8f_5aw_display.h"
uint8_t display_buffer[BL55072A_DISP_BUF_SIZE];
// Ãæ°åÏÔʾÐÅÏ¢½á¹¹Ìå
volatile PanelDisplayInfo panel_display_info;
#define ENABLE_PRECISE_I2C_DELAY (1)
#define configCPU_CLOCK_HZ (8000000)
/************************************************** ÍⲿӳÉäAPI **************************************************/
#define SDA_SET BL55072A_SDA_SET
#define SCL_SET BL55072A_SCL_SET
#define SDA_CLEAR BL55072A_SDA_CLEAR
#define SCL_CLEAR BL55072A_SCL_CLEAR
/************************************************** ¾²Ì¬×Óº¯Êý¶¨Òå **************************************************/
/**
* @brief I2CרÓÃus¼¶ÑÓʱº¯Êý£¨½öÓÃvolatile£¬ÎÞ±àÒëÆ÷ÊôÐÔ£©
* @param us: ÒªÑÓʱµÄ΢ÃëÊý
* @note Ñ­»·ÌåÌî³äÎÞÓÃÖ¸Á½øÒ»²½·ÀÖ¹±àÒëÆ÷ÓÅ»¯
*/
static void I2C_Delay_us(uint32_t us)
{
#if ENABLE_PRECISE_I2C_DELAY
const uint32_t cycles_per_us = configCPU_CLOCK_HZ / 1000000UL;
const uint32_t Calib_Num = 8;
const uint32_t Calib_Den = 10;
uint32_t total_cycles = (us * cycles_per_us * Calib_Num) / Calib_Den;
if (total_cycles == 0 && us > 0)
{
total_cycles = 1;
}
volatile uint32_t i, j = 0;
for (i = 0; i < total_cycles; i++)
{
j++;
j--;
__NOP();
}
#else
// Ö÷Ƶ¹ý¸ßʱ²»ÊÊÓÃ
for(uint32_t i = 0;i < us;i++)
{
__NOP();
}
#endif
}
/**
* @brief I2CÆðʼÌõ¼þ£ºSCL¸ßµçƽʱ£¬SDA´Ó¸ß±äµÍ
* @param NONE
* @retval NONE
* @note ¸ù¾Ý·ÉÀûÆÖI2C¹Ù·½Îĵµ±àд
* @author jarvis
* @data 2025.11.25
*/
static void I2C_Start(void)
{
SDA_SET();
SCL_SET();
I2C_Delay_us(1);
SDA_CLEAR();
I2C_Delay_us(1);
SCL_CLEAR();
}
/**
* @brief I2CÍ£Ö¹Ìõ¼þ£ºSCL¸ßµçƽʱ£¬SDA´ÓµÍ±ä¸ß
* @param NONE
* @retval NONE
* @note ¸ù¾Ý·ÉÀûÆÖI2C¹Ù·½Îĵµ±àд£¬Í£Ö¹ºóÊÍ·ÅI2C×ÜÏß¿ØÖÆÈ¨
* @author jarvis
* @date 2025.11.25
*/
static void I2C_Stop(void)
{
SDA_CLEAR();
SCL_SET();
I2C_Delay_us(1);
SDA_SET();
I2C_Delay_us(1);
}
/**
* @brief I2C½ÓÊÕÓ¦´ðÐźÅ
* @param NONE
* @retval uint8_t - Ó¦´ð¼ì²â½á¹û£º0±íʾ½ÓÊÕµ½Ó¦´ð(ACK)£¬1±íʾδ½ÓÊÕµ½Ó¦´ð(NACK)
* @note SDAÒý½ÅÐèÅäÖÃΪÊäÈëģʽ£¬Í¨¹ý¼ì²âPC11Òý½ÅµçƽÅжÏÓ¦´ð״̬£¬×ñÑ­I2CЭÒéʱÐò
* @author jarvis
* @date 2025.11.25
*/
static uint8_t I2C_ReceiveAck(void)
{
uint8_t ack = 1;
SCL_CLEAR();
SDA_SET(); // ÊÍ·ÅSDA×ÜÏß
I2C_Delay_us(1);
SCL_SET();
I2C_Delay_us(1);
if((FL_GPIO_ReadInputPort(BL55072A_SDA_GPIO_PORT)&BL55072A_SDA_GPIO_PIN) == 0)
{
ack = 0; // ¼ì²âµ½Ó¦´ð
}
SCL_CLEAR();
return ack;
}
/**
* @brief I2C·¢ËÍÒ»¸ö×Ö½ÚÊý¾Ý
* @param data - ´ý·¢Ë͵Ä8λÊý¾Ý
* @retval NONE
* @note ¸ßλÏÈÐÐ(MSB first)£¬×ñÑ­I2CЭÒéʱÐò£¬SCL¸ßµçƽʱÊý¾ÝÓÐЧ
* @author jarvis
* @date 2025.11.25
*/
static void I2C_SendByte(uint8_t data)
{
uint8_t i;
SCL_CLEAR();
for(i = 0; i < 8; i++)
{
if(data & 0x80)
{
SDA_SET(); // ·¢ËÍ×î¸ßλ
}else{
SDA_CLEAR();
}
data <<= 1;
I2C_Delay_us(1);
SCL_SET();
I2C_Delay_us(1);
SCL_CLEAR();
}
}
/************************** ³£Á¿¶¨Òå **************************/
static const PanelDisplayInfo panel_display_default =
{
.timer =
{
.hours = 88,
.minutes = 88,
.is_light = LIGHT_ON
},
.total_time =
{
.time_mode = MODE_TOTAL_TIME,
.hours = 88888,
.first8_segtable_index = 10,
.second8_segtable_index = 10,
.third8_segtable_index = 10,
.fourth8_segtable_index = 10,
.fifth8_segtable_index = 10,
.is_light = LIGHT_ON
},
.error =
{
.first8_segtable_index = 8,
.second8_segtable_index = 8,
.is_light = LIGHT_ON
},
.oxg =
{
.value = 888,
.is_light = LIGHT_ON
},
};
#define SEG_TABLE_SIZE (20) // ¶ÏÂë±í´óС
const uint8_t SEG_TAB[SEG_TABLE_SIZE] =
{
//--0--,--1--,--2--,--3--,--4--,--5--,--6--,--7--,--8--,--9--,
0x5F, 0x50, 0x6B, 0x79, 0x74, 0x3D, 0x3F, 0x58, 0x7F, 0x7D,
//'-', ' ', 'E', 'L', 'P', 'H', 'C', 'F', 'U', 'A',
0x20, 0x00, 0x2F, 0x07, 0x6E, 0x76, 0x0F, 0x2E, 0x57, 0x7E,
};
/************************** ¹©Íⲿµ÷ÓõÄAPIº¯Êý **************************/
/**
* @brief BL55072AÒº¾§ÏÔʾоƬ³õʼ»¯º¯Êý
* @note Íê³ÉGPIO³õʼ»¯¡¢I2C×ÜÏß³õʼ»¯¡¢Ð¾Æ¬»ù´¡ÅäÖü°ÏÔ´æÇå¿Õ
* ³õʼ»¯ºóÆÁÄ»´¦ÓڹرÕ״̬£¬Ðèµ÷ÓÃuser_display_refresh¿ªÆôÏÔʾ
* @param ÎÞ
* @retval ÎÞ
* @author jarvis
* @date 2026.01.09
*/
void user_display_init(void)
{
// ³õʼ»¯I2CÒý½ÅGPIOÅäÖÃ
FL_GPIO_InitTypeDef GPIO_InitStruct;
GPIO_InitStruct.pin = BL55072A_SDA_GPIO_PIN;
GPIO_InitStruct.mode = FL_GPIO_MODE_OUTPUT;
GPIO_InitStruct.pull = FL_DISABLE;
GPIO_InitStruct.remapPin = FL_DISABLE;
GPIO_InitStruct.analogSwitch = FL_DISABLE;
GPIO_InitStruct.outputType = FL_GPIO_OUTPUT_OPENDRAIN;
FL_GPIO_Init(BL55072A_SDA_GPIO_PORT, &GPIO_InitStruct); // ³õʼ»¯SDAÒý½Å
GPIO_InitStruct.pin = BL55072A_SCL_GPIO_PIN;
GPIO_InitStruct.pull = FL_ENABLE;
GPIO_InitStruct.outputType = FL_GPIO_OUTPUT_PUSHPULL;
FL_GPIO_Init(BL55072A_SCL_GPIO_PORT, &GPIO_InitStruct); // ³õʼ»¯SCLÒý½Å
// ³õʼ»¯ÏÔʾ»º³åÇøÎªÈ«1
memset(display_buffer, 0xFF, sizeof(display_buffer));
// ³õʼ»¯ÆÁÄ»ÅäÖýṹÌå
panel_display_info = panel_display_default;
// ------------------- I2C×ÜÏß¼°Ð¾Æ¬³õʼ»¯Á÷³Ì -------------------
// È·±£I2C×ÜÏß´¦ÓÚֹͣ״̬£¬±ÜÃâ×ÜÏßÒì³£
I2C_Stop();
I2C_Delay_us(100); // ×ÜÏßÎȶ¨ÑÓʱ£¨100us£©
// ·¢ËÍI2CÆðʼÌõ¼þ
I2C_Start();
// ·¢ËÍоƬдµØÖ·£¨0x7C£©£¬ºöÂÔACK¼ì²â£¨½öÏÔʾ³¡¾°£©
I2C_SendByte(BL55072A_I2C_ADDR_W);
(void)I2C_ReceiveAck(); // ÏÔʽºöÂÔ·µ»ØÖµ£¬±ÜÃâ±àÒëÆ÷¾¯¸æ
// ·¢ËÍICSETÃüÁоƬ»ù´¡ÅäÖã¨ÄÚ²¿Õñµ´Æ÷¡¢²»¸´Î»£©
I2C_SendByte(BL55072A_CMD_ICSET);
(void)I2C_ReceiveAck();
// ·¢ËÍDISCTLÃüÁÏÔʾÇý¶¯²ÎÊýÅäÖã¨Ö¡Æµ¡¢Çý¶¯Ä£Ê½£©
I2C_SendByte(BL55072A_CMD_DISCTL);
(void)I2C_ReceiveAck();
// ·¢ËÍMODESETÃüÁ¹Ø±ÕÏÔʾ£¨1/3Æ«Öã©
I2C_SendByte(MODESET_BASIC | MODESET_DISP_OFF | MODESET_BIAS_1_3);
(void)I2C_ReceiveAck();
// ·¢ËÍADSETÃüÁÉèÖÃÏÔʾ¼Ä´æÆ÷ÆðʼµØÖ·ÎªSEG0
I2C_SendByte(BL55072A_CMD_ADSET);
(void)I2C_ReceiveAck();
// Çå¿ÕÏԴ棨0x00~0x23µØÖ·£©£¬·ÀÖ¹ÔàÊý¾Ýµ¼ÖÂÏÔʾÒì³£
for(uint8_t i = 0; i < BL55072A_DISP_BUF_SIZE; i++)
{
I2C_SendByte(0x00);
(void)I2C_ReceiveAck();
}
// ·¢ËÍI2CÍ£Ö¹Ìõ¼þ£¬È·ÈÏÊý¾ÝдÈëÉúЧ
I2C_Stop();
// ÏÔʾÎȶ¨ÑÓʱ£¨100us£©
I2C_Delay_us(100);
}
/**
* @brief BL55072AÒº¾§ÏÔʾˢк¯Êý
* @note ¼ÓÔØÏÔʾ»º³åÇøÊý¾Ýµ½Ð¾Æ¬ÏԴ棬²¢¿ªÆôÏÔʾ
* ÐèÔÚ³õʼ»¯Íê³Éºóµ÷Ó㬻ò¸üÐÂdisplay_bufferºóµ÷ÓÃ
* @param ÎÞ
* @retval ÎÞ
* @author jarvis
* @date 2026.01.09
*/
void user_display_refresh(void)
{
uint8_t timer_hour_ten; // Сʱʮ루0-9£©
uint8_t timer_hour_unit; // Сʱ¸ö루0-9£©
uint8_t timer_minute_ten; // ·ÖÖÓʮ루0-9£©
uint8_t timer_minute_unit; // ·ÖÖÓ¸ö루0-9£©
uint8_t total_time_unit; // ´æ´¢ÀÛʱµÄ¸ö¡¢Ê®¡¢°Ù¡¢Ç§¡¢Íò룬¶¨Òå±äÁ¿
uint8_t total_time_ten;
uint8_t total_time_hundred;
uint8_t total_time_thousand;
uint8_t total_time_ten_thousand;
uint8_t oxg_ten; // ´æ´¢Å¨¶ÈµÄ¸ö¡¢Ê®¡¢Ð¡Êýµã
uint8_t oxg_unit;
uint8_t oxg_decimal;
// ------------------- ¸ù¾ÝÅäÖÃÄÚÈݸü¸ÄÏÔ´æ -------------------
memset(display_buffer, 0x00, sizeof(display_buffer));
// È·¶¨¶¨Ê±²¿·ÖÏÔ´æÊý¾Ý
if(panel_display_info.timer.is_light == LIGHT_ON)
{
timer_hour_ten = (panel_display_info.timer.hours / 10) % 10; // ʮλ£ºÏȳý10ÔÙÈ¡Óà10
timer_hour_unit = panel_display_info.timer.hours % 10;
timer_minute_ten = (panel_display_info.timer.minutes / 10) % 10; // ʮλ£ºÏȳý10ÔÙÈ¡Óà10
timer_minute_unit = panel_display_info.timer.minutes % 10;
display_buffer[TIMER_FIRST8_AFED_SEG_NUM/2] |= (SEG_TAB[timer_hour_ten]&0x0F)<<4;
display_buffer[TIMER_FIRST8_BGC_SEG_NUM/2] |= (SEG_TAB[timer_hour_ten]&0xF0)>>4;
display_buffer[TIMER_SECOND8_AFED_SEG_NUM/2] |= (SEG_TAB[timer_hour_unit]&0x0F)<<4;
display_buffer[TIMER_SECOND8_BGC_SEG_NUM/2] |= (SEG_TAB[timer_hour_unit]&0xF0)>>4;
display_buffer[TIMER_THIRD8_AFED_SEG_NUM/2] |= (SEG_TAB[timer_minute_ten]&0x0F)<<4;
display_buffer[TIMER_THIRD8_BGC_SEG_NUM/2] |= (SEG_TAB[timer_minute_ten]&0xF0)>>4;
display_buffer[TIMER_FOURTH8_AFED_SEG_NUM/2] |= (SEG_TAB[timer_minute_unit]&0x0F)<<4;
display_buffer[TIMER_FOURTH8_BGC_SEG_NUM/2] |= (SEG_TAB[timer_minute_unit]&0xF0)>>4;
display_buffer[TIMER_COL_ARRAY_INDEX] |= ADDITION_SEG_POS;
display_buffer[TIMER_H1_ARRAY_INDEX] |= ADDITION_SEG_POS;
}
// È·¶¨ÀÛʱ²¿·ÖÏÔ´æÊý¾Ý
if(panel_display_info.total_time.is_light == LIGHT_ON)
{
if(panel_display_info.total_time.time_mode == MODE_TOTAL_TIME)
{
// ÓÀԶֻȡǰÎåλ ²»Ó÷ÀÖ¹Òç³ö
total_time_unit = panel_display_info.total_time.hours % 10;
total_time_ten = (panel_display_info.total_time.hours / 10) % 10; // ʮλ£ºÏȳý10ÔÙÈ¡Óà10
total_time_hundred = (panel_display_info.total_time.hours / 100) % 10; // °Ùλ£ºÏȳý100ÔÙÈ¡Óà10
total_time_thousand = (panel_display_info.total_time.hours / 1000) % 10; // ǧλ£ºÏȳý1000ÔÙÈ¡Óà10
total_time_ten_thousand = (panel_display_info.total_time.hours / 10000) % 10; // Íòλ£ºÏȳý10000ÔÙÈ¡Óà10
display_buffer[TIME_FIRST8_AFED_SEG_NUM/2] |= (SEG_TAB[total_time_ten_thousand]&0x0F)<<4;
display_buffer[TIME_FIRST8_BGC_SEG_NUM/2] |= (SEG_TAB[total_time_ten_thousand]&0xF0)>>4;
display_buffer[TIME_SECOND8_AFED_SEG_NUM/2] |= (SEG_TAB[total_time_thousand]&0x0F)<<4;
display_buffer[TIME_SECOND8_BGC_SEG_NUM/2] |= (SEG_TAB[total_time_thousand]&0xF0)>>4;
display_buffer[TIME_THIRD8_AFED_SEG_NUM/2] |= (SEG_TAB[total_time_hundred]&0x0F)<<4;
display_buffer[TIME_THIRD8_BGC_SG_NUM/2] |= (SEG_TAB[total_time_hundred]&0xF0)>>4;
display_buffer[TIME_FOURTH8_AFED_SEG_NUM/2] |= (SEG_TAB[total_time_ten]&0x0F)<<4;
display_buffer[TIME_FOURTH8_BGC_SEG_NUM/2] |= (SEG_TAB[total_time_ten]&0xF0)>>4;
display_buffer[TIME_FIFTH8_AFED_SEG_NUM/2] |= (SEG_TAB[total_time_unit]&0x0F)<<4;
display_buffer[TIME_FIFTH8_BGC_SEG_NUM/2] |= (SEG_TAB[total_time_unit]&0xF0)>>4;
display_buffer[TOTAL_TIME_H2_ARRAY_INDEX] |= ADDITION_SEG_POS;
}else if(panel_display_info.total_time.time_mode == MODE_INDEX)
{
// ÖмäÀÛʱ²¿·Ö°´ÕÕË÷ÒýÏÔʾ
display_buffer[TIME_FIRST8_AFED_SEG_NUM/2] |= (SEG_TAB[panel_display_info.total_time.first8_segtable_index]&0x0F)<<4;
display_buffer[TIME_FIRST8_BGC_SEG_NUM/2] |= (SEG_TAB[panel_display_info.total_time.first8_segtable_index]&0xF0)>>4;
display_buffer[TIME_SECOND8_AFED_SEG_NUM/2] |= (SEG_TAB[panel_display_info.total_time.second8_segtable_index]&0x0F)<<4;
display_buffer[TIME_SECOND8_BGC_SEG_NUM/2] |= (SEG_TAB[panel_display_info.total_time.second8_segtable_index]&0xF0)>>4;
display_buffer[TIME_THIRD8_AFED_SEG_NUM/2] |= (SEG_TAB[panel_display_info.total_time.third8_segtable_index]&0x0F)<<4;
display_buffer[TIME_THIRD8_BGC_SG_NUM/2] |= (SEG_TAB[panel_display_info.total_time.third8_segtable_index]&0xF0)>>4;
display_buffer[TIME_FOURTH8_AFED_SEG_NUM/2] |= (SEG_TAB[panel_display_info.total_time.fourth8_segtable_index]&0x0F)<<4;
display_buffer[TIME_FOURTH8_BGC_SEG_NUM/2] |= (SEG_TAB[panel_display_info.total_time.fourth8_segtable_index]&0xF0)>>4;
display_buffer[TIME_FIFTH8_AFED_SEG_NUM/2] |= (SEG_TAB[panel_display_info.total_time.fifth8_segtable_index]&0x0F)<<4;
display_buffer[TIME_FIFTH8_BGC_SEG_NUM/2] |= (SEG_TAB[panel_display_info.total_time.fifth8_segtable_index]&0xF0)>>4;
}
}
// ¹ÊÕÏÂëÏÔʾ
if(panel_display_info.error.is_light == LIGHT_ON)
{
// ·ÀÖ¹³¬³ö¶ÏÂë±í·¶Î§
panel_display_info.error.first8_segtable_index = panel_display_info.error.first8_segtable_index >= SEG_TABLE_SIZE?\
(SEG_TABLE_SIZE-1):panel_display_info.error.first8_segtable_index;
panel_display_info.error.second8_segtable_index = panel_display_info.error.second8_segtable_index >= SEG_TABLE_SIZE?\
(SEG_TABLE_SIZE-1):panel_display_info.error.second8_segtable_index;
display_buffer[ERROR_FIRT8_AFED_SEG_NUM/2] |= (SEG_TAB[panel_display_info.error.first8_segtable_index]&0x0F);
display_buffer[ERROR_FIRT8_BGC_SEG_NUM/2] |= (SEG_TAB[panel_display_info.error.first8_segtable_index]&0xF0);
display_buffer[ERROR_SECOND8_AFED_SEG_NUM/2] |= (SEG_TAB[panel_display_info.error.second8_segtable_index]&0x0F);
display_buffer[ERROR_SECOND8_BGC_SEG_NUM/2] |= (SEG_TAB[panel_display_info.error.second8_segtable_index]&0xF0);
}
// ÑõŨ¶ÈÏÔʾ
if(panel_display_info.oxg.is_light == LIGHT_ON)
{
oxg_decimal = panel_display_info.oxg.value % 10;
oxg_unit = (panel_display_info.oxg.value / 10) % 10;
oxg_ten = (panel_display_info.oxg.value / 100) % 10;
display_buffer[OXG_FIRST8_AFED_SEG_NUM/2] |= (SEG_TAB[oxg_ten]&0x0F);
display_buffer[OXG_FIRST8_BGC_SEG_NUM/2] |= (SEG_TAB[oxg_ten]&0xF0);
display_buffer[OXG_SECOND8_AFED_SEG_NUM/2] |= (SEG_TAB[oxg_unit]&0x0F);
display_buffer[OXG_SECOND8_BGC_SEG_NUM/2] |= (SEG_TAB[oxg_unit]&0xF0);
display_buffer[OXG_THIRD8_AFED_SEG_NUM/2] |= (SEG_TAB[oxg_decimal]&0x0F);
display_buffer[OXG_THIRD8_BGC_SG_NUM/2] |= (SEG_TAB[oxg_decimal]&0xF0);
display_buffer[OXG_S1_ARRAY_INDEX] |= ADDITION_SEG_POS<<4;
display_buffer[OXG_POINT_ARRAY_INDEX] |= ADDITION_SEG_POS<<4;
display_buffer[OXG_PERCEENET_ARRAY_INDEX] |= ADDITION_SEG_POS<<4;
}
// ------------------- ¼ÓÔØÏÔʾ»º³åÇøÊý¾Ý -------------------
// ·¢ËÍI2CÆðʼÌõ¼þ
I2C_Start();
// ·¢ËÍоƬдµØÖ·
I2C_SendByte(BL55072A_I2C_ADDR_W);
(void)I2C_ReceiveAck(); // ÏÔʽºöÂÔ·µ»ØÖµ£¬±ÜÃâ±àÒëÆ÷¾¯¸æ
// ·¢ËÍBLKCTLÃüÁ¹Ø±ÕÉÁ˸¹¦ÄÜ
I2C_SendByte(BL55072A_CMD_BLKCTL);
(void)I2C_ReceiveAck();
// ·¢ËÍDISCTLÃüÁÅäÖÃÏÔʾÇý¶¯²ÎÊý
I2C_SendByte(BL55072A_CMD_DISCTL);
(void)I2C_ReceiveAck();
// ·¢ËÍICSETÃüÁоƬ»ù´¡²ÎÊýÅäÖÃ
I2C_SendByte(BL55072A_CMD_ICSET);
(void)I2C_ReceiveAck();
// ·¢ËÍADSETÃüÁÉèÖÃÏÔʾ¼Ä´æÆ÷ÆðʼµØÖ·
I2C_SendByte(BL55072A_CMD_ADSET);
(void)I2C_ReceiveAck();
// ½«ÏÔʾ»º³åÇøÊý¾ÝдÈëоƬÏԴ棨0x00~0x23µØÖ·£©
for(uint8_t i = 0; i < BL55072A_DISP_BUF_SIZE; i++)
{
I2C_SendByte(display_buffer[i]);
(void)I2C_ReceiveAck();
}
// Í£Ö¹I2C´«Ê䣬ȷÈÏÊý¾ÝдÈë
I2C_Stop();
// ------------------- ¿ªÆôÏÔʾ -------------------
I2C_Delay_us(100); // ×ÜÏßÎȶ¨ÑÓʱ£¨100us£©
// ·¢ËÍI2CÆðʼÌõ¼þ
I2C_Start();
// ·¢ËÍоƬдµØÖ·£¨0x7C£©
I2C_SendByte(BL55072A_I2C_ADDR_W);
(void)I2C_ReceiveAck(); // ÏÔʽºöÂÔ·µ»ØÖµ£¬±ÜÃâ±àÒëÆ÷¾¯¸æ
// ·¢ËÍMODESETÃüÁ¿ªÆôÏÔʾ£¨ºËÐIJ½Ö裩
I2C_SendByte(BL55072A_CMD_MODESET);
(void)I2C_ReceiveAck();
// Í£Ö¹I2C´«Ê䣬Íê³ÉÏÔʾ¿ªÆô
I2C_Stop();
}
/************************ (C) COPYRIGHT YUWELL *****END OF FILE****/