-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.c
65 lines (59 loc) · 2.04 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
/**
* --------------------------------------------------------------------------------------------+
* @name Main example st7789 LCD driver
* --------------------------------------------------------------------------------------------+
* Copyright (C) 2023 Marian Hrinko.
* Written by Marian Hrinko (mato.hrinko@gmail.com)
*
* @author Marian Hrinko
* @date 03.12.2023
* @file main.c
* @version 1.0
* @tested AVR Atmega328
*
* @depend st7789.h
* --------------------------------------------------------------------------------------------+
* @descr Version 1.0
*
*/
#include "src/st7789.h"
/** @var Screen definition */
extern struct S_SCREEN Screen;
/**
* @desc Main function
*
* @param void
*
* @return int
*/
int main (void)
{
uint16_t i;
// LCD - init struct
// ----------------------------------------------------------
struct signal cs = { .ddr = &DDRB, .port = &PORTB, .pin = 2 }; // Chip Select
struct signal bl = { .ddr = &DDRB, .port = &PORTB, .pin = 1 }; // Back Light
struct signal rs = { .ddr = &DDRB, .port = &PORTB, .pin = 0 }; // Reset
struct signal dc = { .ddr = &DDRD, .port = &PORTD, .pin = 7 }; // Data / Command
struct st7789 lcd = { .cs = &cs, .bl = &bl, .dc = &dc, .rs = &rs }; // LCD struct
// LCD INIT
// ----------------------------------------------------------
ST7789_Init (&lcd, ST77XX_ROTATE_270 | ST77XX_RGB);
// DRAWING
// ----------------------------------------------------------
ST7789_ClearScreen (&lcd, WHITE);
for (i=0; i<Screen.height; i=i+5) {
ST7789_DrawLine (&lcd, 0, Screen.width, 0, i, RED);
}
for (i=0; i<Screen.height; i=i+5) {
ST7789_DrawLine (&lcd, 0, Screen.width, i, 0, BLUE);
}
for (i=0; i<30; i++) {
ST7789_FastLineHorizontal (&lcd, 0, Screen.width, i, BLACK);
}
ST7789_SetPosition (75, 5);
ST7789_DrawString (&lcd, "ST7789V2 DRIVER", WHITE, X3);
// EXIT
// ----------------------------------------------------------
return 0;
}