-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.c
63 lines (60 loc) · 1.13 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
//
// Nokia 5110 LCD display test program
//
// Written by Larry Bank 4/6/2016
//
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <nokia5110.h>
int main(int argc, char* argv[])
{
int rc;
int i, x, y;
// SPI Channel, D/C, RESET, LED
rc = nokiaInit(0, 37, 35, 13);
if (rc != 0)
{
printf("Problem initializing nokia5110 library\n");
return 0;
}
nokiaWriteString(2, 1, "Another", FONT_NORMAL);
nokiaWriteString(2, 2, "BitBank", FONT_NORMAL);
nokiaWriteString(1, 3, "FOSS tool", FONT_NORMAL);
nokiaWriteString(2, 4, "Narrow Font", FONT_SMALL);
// draw a box around the whole display
for (x=0; x<84; x++)
{
nokiaSetPixel(x, 0, 1);
nokiaSetPixel(x, 47, 1);
}
for (y=0; y<48; y++)
{
nokiaSetPixel(0, y, 1);
nokiaSetPixel(83, y, 1);
}
usleep(3000000);
for (i=0; i<10000; i++)
{
x = rand() & 0x7f;
y = rand() & 0x3f;
// cover entire display with black
while (nokiaGetPixel(x,y))
{
x++;
if (x >= 84)
{
y++;
x = 0;
if (y >= 48)
break;
}
}
nokiaSetPixel(x, y, 1);
}
usleep(4000000);
nokiaShutdown();
return 0;
} /* main() */