summaryrefslogtreecommitdiff
path: root/src/main.cc
blob: 765f1d928fcb93d7a783b405ed81c2b658ec43d8 (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
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/wdt.h>
#include <util/delay.h>
#include <stdlib.h>

#include "display.h"
#include "font.h"
#include "storage.h"
#include "modem.h"
#include "system.h"

animation_t ohai;

int main (void)
{
	ohai.mode = AnimationType::TEXT;
	ohai.speed = (2 << 4) + 15;
	ohai.data = (uint8_t *)"\001 Ohai  ";
	ohai.length = 8;

	uint8_t anim_data[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0 };

	animation_t test;
	test.mode = AnimationType::FRAMES;
	test.speed = 14;
	test.length = 2*8;
	test.data = anim_data;

	// disable ADC to save power
	PRR |= _BV(PRADC);

	// dito
	wdt_disable();

	// Enable pull-ups on PC3 and PC7 (button pins)
	PORTC |= _BV(PC3) | _BV(PC7);

	display.show(&ohai);

	display.enable();
	modem.enable();
	storage.enable();

	sei();

	while (1) {
		// nothing to do here, go to idle to save power
		SMCR = _BV(SE);
		asm("sleep");
		/*
		 * The display timer causes a wakeup after 256µs. Run the system
		 * loop after the timer's ISR is done.
		 * The Modem also causes wakeups, which is pretty convenient since
		 * it means we can immediately process the received data.
		 */
		rocket.loop();
		display.update();
	}

	return 0;
}