bootloader-display.c 1.5 KB
Newer Older
1
#include "bootloader.h"
Rahix's avatar
Rahix committed
2
3
/* Autogenerated */
#include "splash-screen.h"
Rahix's avatar
Rahix committed
4
#include "card10-version.h"
5

6
#include "gfx.h"
7
8
#include "display.h"

Rahix's avatar
Rahix committed
9
10
static void bootloader_display_splash(void)
{
11
12
13
14
15
16
17
18
19
20
	gfx_copy_region(
		&display_screen,
		0,
		0,
		160,
		80,
		GFX_RLE_MONO,
		sizeof(splash),
		(const void *)(splash)
	);
21
	gfx_update(&display_screen);
Rahix's avatar
Rahix committed
22
23
}

24
25
26
27
28
/*
 * Initialize the display.
 */
void bootloader_display_init(void)
{
Rahix's avatar
Rahix committed
29
	bootloader_display_splash();
30
31
32
33
34
35
36
}

/*
 * Show the bootloader version on the display.
 */
void bootloader_display_header(void)
{
Rahix's avatar
Rahix committed
37
38
39
40
41
42
	gfx_clear(&display_screen);

	Color white = gfx_color(&display_screen, WHITE);
	bootloader_display_line(0, "Bootloader", white);
	bootloader_display_line(1, __DATE__, white);
	bootloader_display_line(2, CARD10_VERSION, white);
43
44
}

45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
void bootloader_display_error(char *errtype, char *line1, char *line2)
{
	gfx_clear(&display_screen);

	Color red    = gfx_color(&display_screen, RED);
	Color yellow = gfx_color(&display_screen, YELLOW);
	Color white  = gfx_color(&display_screen, WHITE);

	bootloader_display_line(0, "[FATAL ERROR]", red);
	bootloader_display_line(1, errtype, yellow);
	bootloader_display_line(2, CARD10_VERSION, white);
	bootloader_display_line(3, line1, white);
	bootloader_display_line(4, line2, white);
}

60
61
62
63
64
/*
 * Display a line of text on the display.
 */
void bootloader_display_line(int line, char *string, uint16_t color)
{
65
66
67
	Color black = gfx_color(&display_screen, BLACK);
	gfx_puts(&Font16, &display_screen, 0, 16 * line, string, color, black);
	gfx_update(&display_screen);
68
}