archieve: homework7 test3
This commit is contained in:
@@ -19,7 +19,8 @@
|
||||
"targets": {
|
||||
"Debug": {
|
||||
"excludeList": [
|
||||
"src/test1.c"
|
||||
"src/test1.c",
|
||||
"src/test2.c"
|
||||
],
|
||||
"toolchain": "Keil_C51",
|
||||
"compileConfig": {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* @author: msksbr
|
||||
* @date: 2025-05-24
|
||||
* @description: a header for homework7's homework tests
|
||||
* @version: 1.0
|
||||
* @version: 1.0f: fix errors in timer
|
||||
* variables:
|
||||
* 1.0:
|
||||
* 1. sbit DB_0 ~ sbit DB_7: pin number for led matrix cathodes
|
||||
|
||||
@@ -21,7 +21,7 @@ void test2()
|
||||
{
|
||||
for (i = 8; i > 0; i--) // @loop: display the heart shape on the led matrix
|
||||
{
|
||||
switch_138(i); // switch the 74HC138's address to i
|
||||
switch_138(i); // switch the 74HC138's address to i
|
||||
P2 = ~heart[i]; // display the heart shape on the led matrix
|
||||
delay_ms(1);
|
||||
P2 = 0xFF; // turn off the led matrix
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* @name: test1.c
|
||||
* @author: msksbr
|
||||
* @date: 2025-05-24
|
||||
* @description: a test for homework7's homework tests
|
||||
* @version: 1.0
|
||||
* homework zh_CN: 点阵显示一个 I ❤ U 的向下移动动画
|
||||
* homework EN: display a animation of I ❤ U moving down on the led matrix
|
||||
*/
|
||||
|
||||
#include "homework7.h"
|
||||
|
||||
unsigned char code char_i[] = {
|
||||
0x00, 0x3C, 0x18, 0x18,
|
||||
0x18, 0x18, 0x18, 0x3C};
|
||||
unsigned char code char_heart[] = {
|
||||
0x00, 0x66, 0xFF, 0xFF,
|
||||
0xFF, 0x7E, 0x3C, 0x18};
|
||||
unsigned char code char_u[] = {
|
||||
0x00, 0x66, 0x66, 0x66,
|
||||
0x66, 0x66, 0x7E, 0x3C};
|
||||
|
||||
void test3()
|
||||
{
|
||||
unsigned char i; // @var i: a counter for the loop
|
||||
unsigned char char_pos; // @var char_pos: the position of the character to be displayed on the led matrix
|
||||
while (1) {
|
||||
for (char_pos = 0; char_pos < 3; char_pos++) { // @loop: switch the char
|
||||
for (i = 8; i > 0; i--) { // @loop: display shape on the led matrix
|
||||
switch_138(i); // switch the 74HC138's address to i
|
||||
switch (char_pos) { // switch the char to be displayed on the led matrix
|
||||
case 0:
|
||||
P2 = ~char_i[i]; // display the char_i on the led matrix
|
||||
break;
|
||||
case 1:
|
||||
P2 = ~char_heart[i]; // display the char_heart on the led matrix
|
||||
break;
|
||||
case 2:
|
||||
P2 = ~char_u[i]; // display the char_u on the led matrix
|
||||
break;
|
||||
}
|
||||
delay_ms(1); // delay 1ms
|
||||
P2 = 0xFF; // turn off the led matrix
|
||||
}
|
||||
i = 8; // @subsection reset i to 8
|
||||
}
|
||||
char_pos = 0; // @subsection reset char_pos to 0
|
||||
}
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
test3();
|
||||
}
|
||||
Reference in New Issue
Block a user