summaryrefslogtreecommitdiff
path: root/src/app/sharp96-bad-apple/main.cc
blob: eb85229bc9436228b8324251aae13f526d6d35d1 (plain)
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
82
83
84
85
86
/*
 * Copyright 2020 Daniel Friesel
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */
#include "arch.h"
#include "driver/gpio.h"
#include "driver/stdout.h"
#include "driver/spi.h"
#include "driver/sharp96.h"
#include "lib/inflate.h"

#include "driver/timer.h"
volatile unsigned char timer_done = 0;

#include "frames.cc"

__attribute__((section(".leaRAM"))) unsigned char img_buf[(72 * 96 / 8) * 3];

int main(void)
{
	unsigned int i = 0;
	unsigned char line;
	arch.setup();
	gpio.setup();
	kout.setup();
	spi.setup();
	sharp96.setup();
	sharp96.powerOn();
	sharp96.clear();

	timer.setup_hz_low(frame_rate);

	while (1) {
		for (i = 0; i < (sizeof(frames) / sizeof(frames[0])); i++) {

			timer_done = 0;
			timer.start(1);

			for (line = 0; line < 72; line++) {
				sharp96.writeLine(line, img_buf + (12 * 72 * 2) + (12 * line));
			}

			inflate(frames[i], sizeof(img_buf), img_buf, sizeof(img_buf));

			while (!timer_done) {
				arch.idle();
			}
			timer.stop();

			timer_done = 0;
			timer.start(1);

			for (line = 0; line < 72; line++) {
				sharp96.writeLine(line, img_buf + (12 * line));
			}

			while (!timer_done) {
				arch.idle();
			}
			timer.stop();

			timer_done = 0;
			timer.start(1);

			for (line = 0; line < 72; line++) {
				sharp96.writeLine(line, img_buf + (12 * 72) + (12 * line));
			}

			while (!timer_done) {
				arch.idle();
			}
			timer.stop();

			if ((i%10)==0) {
				sharp96.toggleVCOM();
			}
		}
	}

	return 0;
}

ON_TIMER_INTERRUPT_head
	timer_done = 1;
ON_TIMER_INTERRUPT_tail