-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
81 lines (70 loc) · 1.53 KB
/
Copy pathmain.c
File metadata and controls
81 lines (70 loc) · 1.53 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
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
/*
* GraphicalLCD.c
*
* Created: 1/24/2025 2:38:50 PM
* Author : itsLydt
*/
#include "sam.h"
#include "lcd.h"
#define CONFIG_IMPL
#include "config.h"
void TRAN_Init();
int main(void)
{
TRAN_Init();
LCD_Init();
ClearDisplay();
FillWith(0xFF);
//write_command(0x30); // change to basic instruction mode
ReturnHome();
char c = 'A';
_Bool page = 0;
uint8_t background = 0;
DrawChar('H');
DrawChar('i');
delay_ms(2000);
while (1)
{
switch(background){
case 0:
FillWith(0xFF);
write_command(0x30); // change back to basic instruction mode
break;
case 1:
FillHalf(0xFF, 0);
write_command(0x30); // change back to basic instruction mode
break;
case 2:
FillHalf(0xFF, 1);
write_command(0x30);
break;
default:
write_command(0x34); // set extended function mode on + GD off
write_command(0x30); // change back to basic instruction mode
break;
}
background = (++background) % 4;
if(page){
SetDDRAMAddr(16);
}
else {
ReturnHome();
}
page = !page;
for(int i = 0; i < 18; i++){
write_data(c);
++c;
if(c > 126){
c = 33;
}
delay_ms(500);
}
}
}
/* initialize pins for the transceiver */
void TRAN_Init(){
GPIO_SetPinDirection(TRAN_PORT, PIN_DIR, GPIO_OUT);
GPIO_SetPinDirection(TRAN_PORT, PIN_ENABLE, GPIO_OUT);
GPIO_WritePin(TRAN_PORT, PIN_DIR, 1); // high causes DIR to become low, setting the MCU to be the input side of the transceiver
GPIO_WritePin(TRAN_PORT, PIN_ENABLE, 1); // high causes OE to become low, enabling the transceiver
}