-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
100 lines (89 loc) · 2.49 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/* **************************************************
* this is just an example to show how library works
* this project is on atmega32
* pin connections(LCD->AVR):
* VCC->+3.3
* GND->GND
* CS->PB0
* RST->PB1
* A0->PB2
* SDA->MOSI
* SCK->SCK
* LED->VCC
************************************************** */
#include "tft144.h"
#include <stdio.h>
#include <avr/pgmspace.h>
void uart_putchar(char c);
char uart_getchar();
FILE uart_output = FDEV_SETUP_STREAM(uart_putchar, NULL, _FDEV_SETUP_WRITE);
FILE uart_input = FDEV_SETUP_STREAM(NULL,uart_getchar, _FDEV_SETUP_READ);
void uart_putchar(char c) {
loop_until_bit_is_set(UCSRA,UDRE);
UDR = c;
loop_until_bit_is_set(UCSRA, TXC); /* Wait until transmission ready. */
}
char uart_getchar() {
loop_until_bit_is_set(UCSRA,RXC);
return UDR;
}
void USART_Init() {
UCSRA=0x00;
UCSRB=0x18;
UCSRC=0x86;
UBRRH=0x00;
UBRRL=0x05;
}
void init() {
PORTB = (1 << 4);
DDRB = (1 << 7) | (1 << 5) | (1 << 4) | 1; // (MOSI,SCK,SS) should be output
USART_Init(115200);
stdout = &uart_output;
stdin = &uart_input;
printf("initializing system...\r\n");
tft144_reset();
tft144_init();
}
int main() {
u8 a,b,str[2]={0,0};
float v=0;
uint8_t x[4]={0,0,60,100},y[4]={0,40,30,90};
init();
for(a=0;a<128;a++)
for(b=0;b<128;b++)
tft144_draw_dot(a,b,RGB565(a*a,b*b,a*b));
_delay_ms(1000);
tft144_clear_display(BLACK);
a=0; b=0;
tft144_putstring("abcdefghijklmnopqrstuvwxyz",&a,&b,WHITE,BLACK,0);
tft144_putstring("abcdefghijklmnopqrstuvwxyz",&a,&b,WHITE,BLACK,1);
tft144_putstring("abcdefghijklmnopqrstuvwxyz",&a,&b,WHITE,BLACK,2);
_delay_ms(5000);
tft144_clear_display(BLACK);
a=0;b=0;
tft144_putstring("UART Sniffer\nBaud 115200\n",&a,&b,WHITE,BLACK,1);
tft144_draw_line(0,16,127,16,RED);
while(1) {
/***********************************************************************
* Example of reading pixels from UART and write them to 128x128 LCD :
tft144_set_frame(0, 127, 0, 127);
tft144_write_command(WRITE_MEMORY_START);
TFT_CTRL_PORT |= (1<<TFT_DC); // high(data)
for(af=0;af<16384;af++) {
loop_until_bit_is_set(UCSRA,RXC);
bb = UDR;
loop_until_bit_is_set(UCSRA,RXC);
spi_write(UDR);
spi_write(bb);
}
************************************************************************/
str[0] = getchar();
tft144_putstring((char*)str,&a,&b,GREEN,BLACK,2);
if(b >= 128) {
tft144_clear_display(BLACK);
a=0;b=0;
tft144_putstring("UART Sniffer\nBaud 115200\n",&a,&b,WHITE,BLACK,1);
tft144_draw_line(0,16,127,16,RED);
}
}
}