From 939ccc359231b531f5fd8967f5c58ea3c5e235c0 Mon Sep 17 00:00:00 2001 From: 423A35C7 <609514299@qq.com> Date: Sun, 3 Nov 2024 19:28:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=AC=AC=E4=B8=89=E6=AC=A1?= =?UTF-8?q?=E5=AE=9E=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 循环移位数码管 --- exp3/Core/Src/main.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/exp3/Core/Src/main.c b/exp3/Core/Src/main.c index 5c0102a..1fae0ee 100644 --- a/exp3/Core/Src/main.c +++ b/exp3/Core/Src/main.c @@ -65,6 +65,7 @@ uint16_t display_tab[] = { 0x71 }; uint16_t PosSel = 0; +uint8_t bias = 0; /* USER CODE END PV */ /* Private function prototypes -----------------------------------------------*/ @@ -123,11 +124,16 @@ int main(void) if (sSysTickTimer.bTimeOk) { sSysTickTimer.bTimeOk = 0; HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin); + + if (++bias >= 8) { + bias = 0; + } + } // if (sSysTickTimer.bTenMilSecOk) { SegLedData_GPIO_Port->ODR = 0x00; 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) { PosSel = 0; }