完成第三次实验

循环移位数码管
This commit is contained in:
423A35C7 2024-11-03 19:28:34 +08:00
parent 53c5cef582
commit 939ccc3592

View File

@ -65,6 +65,7 @@ uint16_t display_tab[] = {
0x71 0x71
}; };
uint16_t PosSel = 0; uint16_t PosSel = 0;
uint8_t bias = 0;
/* USER CODE END PV */ /* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/
@ -123,11 +124,16 @@ int main(void)
if (sSysTickTimer.bTimeOk) { if (sSysTickTimer.bTimeOk) {
sSysTickTimer.bTimeOk = 0; sSysTickTimer.bTimeOk = 0;
HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin); HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin);
if (++bias >= 8) {
bias = 0;
}
} }
// if (sSysTickTimer.bTenMilSecOk) { // if (sSysTickTimer.bTenMilSecOk) {
SegLedData_GPIO_Port->ODR = 0x00; SegLedData_GPIO_Port->ODR = 0x00;
AddrA_GPIO_Port->ODR = PosSel; AddrA_GPIO_Port->ODR = PosSel;
SegLedData_GPIO_Port->ODR = display_tab[PosSel % 8]; SegLedData_GPIO_Port->ODR = display_tab[(PosSel + bias) % 8];
if (++PosSel >= 8) { if (++PosSel >= 8) {
PosSel = 0; PosSel = 0;
} }