-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdotmatrix.c~
More file actions
49 lines (42 loc) · 1.58 KB
/
dotmatrix.c~
File metadata and controls
49 lines (42 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <mega32.h>
#include <delay.h>
// ÊÚÑíÝ ÊãÇã ÓÊæäåÇí ÊãÇã ÍÑæÝ Èå ÕæÑÊ íæÓÊå
unsigned char continuous_text[] = {
0x00, 0xFF, 0xFF, 0x1B, 0x3B, 0x6F, 0xCE, 0x80,
0x00, 0xFF, 0xFF, 0xDB, 0xDB, 0xDB, 0xDB, 0x00,
0x00, 0xE3, 0xF3, 0xDB, 0xCF, 0xC7, 0xC7, 0x00,
0x00, 0xFC, 0xFE, 0x33, 0x33, 0xFE, 0xFC, 0x00,
0x00, 0x7E, 0xFF, 0xC3, 0xD3, 0xD3, 0x76, 0x00,
0x00, 0x7E, 0xFF, 0xC3, 0xC3, 0xFF, 0x7E, 0x00,
0x00, 0x7E, 0xFF, 0xC3, 0xC3, 0xFF, 0x7E, 0x00,
0x00, 0xFF, 0xFF, 0x1E, 0x72, 0xFF, 0xFF, 0x00,
0x00, 0xFF, 0xFF, 0xDB, 0xDB, 0xDB, 0xDB, 0x00,
0x00, 0xFF, 0xFF, 0x1B, 0x3B, 0x6F, 0xCE, 0x80
};
#define TOTAL_COLUMNS (sizeof(continuous_text)/sizeof(continuous_text[0]))
void send_to_matrix(unsigned char column, unsigned char row_data) {
PORTA = column;
PORTB = row_data;
delay_us(500);
}
void scroll_continuous_text() {
int start_col, i, j;
// ÇÓ˜Ñæá ÊãÇã ÓÊæäåÇ Èå ÕæÑÊ íæÓÊå
for (start_col = 0; start_col < TOTAL_COLUMNS + 8; start_col++) {
for (j = 0; j < 10; j++) { // ÊÃÎíÑ ÈÑÇí åÑ ÝÑíã
for (i = 0; i < 8; i++) { // ÇÓ˜ä åÑ ÓÊæä
int text_col = start_col - i;
unsigned char col_data = (text_col >= 0 && text_col < TOTAL_COLUMNS) ? continuous_text[text_col] : 0x00;
send_to_matrix(~(1 << i), col_data); // ÑÇäÊÒ ÈÓÊå ÇÖÇÝå ÔÏ
}
}
}
}
void main(void) {
DDRA = 0xFF;
DDRB = 0xFF;
while (1) {
scroll_continuous_text();
delay_ms(500); // ÊÃÎíÑ ÞÈá ÇÒ Ê˜ÑÇÑ
}
}