/* * @name: test5.c * @author: msksbr * @date: 2025-05-25 * @description: a test for homework7's homework tests * @version: 1.0f: fix the bug that charset is RL reversed * homework zh_CN: 基于点阵的 9 到 0 的倒计时秒表显示 * homework EN: display a countdown timer on the led matrix from 9 to 0 */ #include "homework7.h" unsigned char code number_char[10][8] = { {0x0E, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x0E, 0x00}, // 0 {0x0C, 0x0F, 0x0C, 0x0C, 0x0C, 0x0C, 0x1F, 0x00}, // 1 {0x0F, 0x1B, 0x18, 0x1C, 0x0E, 0x07, 0x1F, 0x00}, // 2 {0x0F, 0x1B, 0x18, 0x1E, 0x18, 0x1B, 0x0F, 0x00}, // 3 {0x0C, 0x0C, 0x0E, 0x0F, 0x1F, 0x0C, 0x0C, 0x00}, // 4 {0x1F, 0x03, 0x0F, 0x18, 0x18, 0x1B, 0x0F, 0x00}, // 5 {0x1E, 0x07, 0x0F, 0x1B, 0x1B, 0x1F, 0x0E, 0x00}, // 6 {0x1F, 0x18, 0x1C, 0x0C, 0x0E, 0x06, 0x06, 0x00}, // 7 {0x0E, 0x1B, 0x1F, 0x1F, 0x1B, 0x1B, 0x0E, 0x00}, // 8 {0x0E, 0x1B, 0x1B, 0x1B, 0x1E, 0x1C, 0x0F, 0x00} // 9 }; void test5() { TMOD = 0x10; TH1 = 0xFC; TL1 = 0x18; TR1 = 1; ET1 = 1; EA = 1; while (1); } void timer1_ISR() interrupt 3 { static unsigned char i = 0; static unsigned int count = 0; static unsigned char current_num = 9; TH1 = 0xFC; TL1 = 0x18; P2 = 0xFF; switch_138(i); P2 = ~number_char[current_num][i]; if (++i >= 8) i = 0; if (++count >= 1000) { count = 0; if (current_num > 0) { current_num--; } else { current_num = 9; } } } void main() { test5(); }