-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
77 lines (59 loc) · 1.51 KB
/
main.c
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include <stdio.h>
#include <modem.h>
#include "lcd.h"
void on_receive_msg(const char *msg, uint8_t size) {
lcd_gotoxy(0, 1);
lcd_puts(" ");
lcd_gotoxy(0, 1);
char message[size + 1];
for(uint8_t i = 0; i < size; i++)
message[i] = msg[i];
message[size] = 0;
lcd_puts(message);
modem_snd_async(message, size);
}
int main(void) {
// char s[16];
// char* p_tester;
// p_tester = (char*) malloc(0 * sizeof(char));
// free(p_tester);
// uint16_t i;
// char t[16];
// uint8_t p = 0b00000000;
// p ^= 0b00000000;
sei();
lcd_init(LCD_DISP_ON_CURSOR_BLINK);
lcd_clrscr();
lcd_puts("R:");
modem_lsn(on_receive_msg);
char information[16];
while (1) {
// lcd_gotoxy(0, 1);
// lcd_puts(s);
// sprintf(t, "%X", p);
// lcd_gotoxy(0, 1);
// lcd_puts(t);
// free(p_tester);
// p_tester = (char*) malloc(16 * sizeof(char));
// sprintf(s, "%u", p_tester);
// lcd_gotoxy(0, 1);
// lcd_puts(s);
// modem_snd_async("U", 1);
const char *bit_rep[16] = {
[ 0] = "0000", [ 1] = "0001", [ 2] = "0010", [ 3] = "0011",
[ 4] = "0100", [ 5] = "0101", [ 6] = "0110", [ 7] = "0111",
[ 8] = "1000", [ 9] = "1001", [10] = "1010", [11] = "1011",
[12] = "1100", [13] = "1101", [14] = "1110", [15] = "1111",
};
sprintf(information, "%s%s = %03u", bit_rep[info() >> 4], bit_rep[info() & 0x0F],info());
lcd_gotoxy(2, 0);
lcd_puts(information);
_delay_ms(50);
PORTD &= ~(1 << 7);
_delay_ms(50);
PORTD |= (1 << 7);
}
}