#include "SEG_Display.h"
#include "BU91R65.h"

#define MODULE_DISPLAY_ON 1U
#define MODULE_DISPLAY_OFF 0U

SEGDiaplay_Control_Struct g_stSEGDisplay_Control;
void Check_SEG_Display(void)
{
    static uint8_t display_state = 0;
    if (g_stSEGDisplay_Control.u16SEGDisplay_Count++ >= 10u)
    {
        g_stSEGDisplay_Control.u16SEGDisplay_Count = 0u;
        switch (display_state)
        {
        case 0: // 偶数
            for (uint8_t i = 0; i < BU91R65_BUFFER_SIZE; i++)
            {
                BU91R65_Write_Buffer(BU91R65_CHIP0, i, 0x0F);
                BU91R65_Write_Buffer(BU91R65_CHIP1, i, 0x0F);
            }
            for (uint8_t i = 0; i < BU91R65_BUFFER_SIZE; i++)
            {
                BU91R65_Write_Buffer(BU91R65_CHIP0, i, 0xF0);
                BU91R65_Write_Buffer(BU91R65_CHIP1, i, 0xF0);
            }
            break;
        case 1: // 奇数
            for (uint8_t i = 0; i < BU91R65_BUFFER_SIZE; i++)
            {
                BU91R65_Write_Buffer(BU91R65_CHIP0, i, 0xF0);
                BU91R65_Write_Buffer(BU91R65_CHIP1, i, 0xF0);
            }
            for (uint8_t i = 0; i < BU91R65_BUFFER_SIZE; i++)
            {
                BU91R65_Write_Buffer(BU91R65_CHIP0, i, 0x0F);
                BU91R65_Write_Buffer(BU91R65_CHIP1, i, 0x0F);
            }
            break;

        case 2: // 全亮
            for (uint8_t i = 0; i < BU91R65_BUFFER_SIZE; i++)
            {
                BU91R65_Write_Buffer(BU91R65_CHIP0, i, 0xFF);
                BU91R65_Write_Buffer(BU91R65_CHIP1, i, 0xFF);
            }
            break;
        default:
            for (uint8_t i = 0; i < BU91R65_BUFFER_SIZE; i++)
            {
                BU91R65_Write_Buffer(BU91R65_CHIP0, i, 0x00);
                BU91R65_Write_Buffer(BU91R65_CHIP1, i, 0x00);
            }
        }
        CHIP2_SEG(0, 99) = 0u;
        CHIP2_SEG(1, 99) = 0u;
        CHIP2_SEG(0, 100) = 0u;
        CHIP2_SEG(1, 100) = 0u;
        CHIP2_SEG(0, 102) = 0u;
        CHIP2_SEG(1, 102) = 0u;
        CHIP2_SEG(1, 103) = 0u;
        CHIP2_SEG(0, 103) = 0u;
        CHIP2_SEG(1, 104) = 0u;
        CHIP2_SEG(0, 101) = 0u;
        CHIP2_SEG(1, 101) = 0u;
        CHIP2_SEG(0, 105) = 0u;
        CHIP2_SEG(1, 105) = 0u;
        CHIP2_SEG(0, 106) = 0u;
        CHIP2_SEG(1, 106) = 0u;
        CHIP2_SEG(0, 107) = 0u;
        CHIP2_SEG(1, 107) = 0u;
        CHIP2_SEG(0, 104) = 0u;
        CHIP2_SEG(1, 108) = 0u;
        CHIP2_SEG(0, 108) = 0u;
        CHIP2_SEG(0, 109) = 0u;
        CHIP2_SEG(0, 110) = 0u;
        CHIP2_SEG(1, 110) = 0u;
        CHIP2_SEG(1, 111) = 0u;
        CHIP2_SEG(0, 111) = 0u;
        CHIP2_SEG(1, 112) = 0u;
        CHIP2_SEG(0, 112) = 0u;
        CHIP2_SEG(1, 113) = 0u;
        CHIP2_SEG(0, 113) = 0u;
        CHIP2_SEG(1, 114) = 0u;
        CHIP2_SEG(0, 114) = 0u;
        CHIP2_SEG(1, 57) = 0u;
        CHIP2_SEG(0, 115) = 0u;
        CHIP2_SEG(0, 116) = 0u;
        CHIP2_SEG(1, 136) = 0u;
        display_state = (display_state + 1) % 3;
    }
}
