#include "main.h" #include "variable.h" extern uint8_t is_setting_time; extern TIME_STATE set_time_state; extern uint8_t show_digit; uint16_t display_tab[] = { 0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f, 0x77, 0x7c, 0x39, 0x5e, 0x79, 0x71, 0x40, 0x00 }; uint8_t DispBuff[8]; uint16_t PosSel = 0; static void DisplayOneLed(uint8_t dat, uint8_t pos, uint8_t dot) { uint16_t temp; if (is_setting_time && !show_digit) { switch (set_time_state) { case SET_HOUR_TENS: if (pos == 0) dat = 17; break; case SET_HOUR_ONES: if (pos == 1) dat = 17; break; case SET_MIN_TENS: if (pos == 3) dat = 17; break; case SET_MIN_ONES: if (pos == 4) dat = 17; break; case SET_SEC_TENS: if (pos == 6) dat = 17; break; case SET_SEC_ONES: if (pos == 7) dat = 17; break; default: break; } } temp = display_tab[dat]; if (dot) temp |= 0x80; SegLedData_GPIO_Port->ODR &= 0xFF00; SegLedData_GPIO_Port->ODR |= temp; // 段码 AddrA_GPIO_Port->ODR &= 0xFFF0; AddrA_GPIO_Port->ODR |= pos; // 位码 } void Display(void) { static uint8_t mPos = 0; DisplayOneLed(DispBuff[mPos], mPos, 0); if (++mPos >= 8) mPos = 0; } void TimeToBuff(structTime *nstTime) { DispBuff[0] = nstTime->mHour / 10; DispBuff[1] = nstTime->mHour % 10; DispBuff[2] = 16; DispBuff[3] = nstTime->mMinute / 10; DispBuff[4] = nstTime->mMinute % 10; DispBuff[5] = 16; DispBuff[6] = nstTime->mSecond / 10; DispBuff[7] = nstTime->mSecond % 10; } void DispToBuff(uint8_t val) { uint8_t i; for (int i = 0; i < 7; i++) { DispBuff[i] = DispBuff[i + 1]; } DispBuff[7] = val; }