forked from andygock/glcd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
51 lines (41 loc) · 1.2 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
#include <stdio.h>
#include <string.h>
#include <sched.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <bcm2835.h>
#include "glcd.h"
#include "fonts/font5x7.h"
int main(int argc, char* const argv[])
{
struct sched_param sp;
memset(&sp, 0, sizeof(sp));
sp.sched_priority = sched_get_priority_max(SCHED_FIFO);
sched_setscheduler(0, SCHED_FIFO, &sp);
mlockall(MCL_CURRENT | MCL_FUTURE);
glcd_tiny_set_font(Font5x7, 5, 7, 32, 127);
glcd_select_screen((uint8_t *)&glcd_buffer, &glcd_bbox);
if (glcd_init() > 0) {
printf("glcd_init error!");
fflush(stdout);
exit(EXIT_FAILURE);
}
glcd_normal();
glcd_clear_buffer();
glcd_tiny_draw_string(4, 2, " #/***/#");
glcd_tiny_draw_string(4, 3, " #|^_^|# Hello World!");
glcd_tiny_draw_string(4, 4, " #/---/# By HanChen");
glcd_write();
bcm2835_delay(1000 * 30);
// Relative positioning
glcd_clear_buffer();
glcd_fill_rect(4, 0, 127, 63, 1);
glcd_fill_rect(4, 0, 1, 1, 0);
glcd_fill_rect(131, 0, 1, 1, 1);
glcd_fill_rect(4, 63, 1, 1, 1);
glcd_fill_rect(131,63, 1, 1, 1);
glcd_write();
bcm2835_delay(1000 * 1);
glcd_close();
exit(EXIT_SUCCESS);
}