summaryrefslogtreecommitdiff
path: root/src/display.h
blob: 70939ca6cbc76738afddccdc95c2acff4fd4e2f8 (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
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/wdt.h>
#include <util/delay.h>
#include <stdlib.h>

struct __text {
	uint8_t speed;
	uint8_t delay;
	uint8_t direction;
	uint8_t *str;
};

struct __animation {
	uint8_t speed;
	uint8_t delay;
	uint8_t *data;
};

typedef struct __text text_t;
typedef struct __animation animation_t;

class Display {
	private:
		text_t active_text;
		animation_t active_anim;
		uint8_t need_update;
		uint8_t active_col;
		uint8_t disp_buf[8];
		uint8_t str_pos;
		int8_t char_pos;
		uint8_t data_buf[128];
		enum DisplayMode : uint8_t {
			TEXT = 1,
			ANIMATION = 2
		};
		DisplayMode mode;
	public:
		Display();
		void enable(void);
		void disable(void);

		void multiplex(void);
		void reset(void);
		void update(void);

		void show(text_t text);
		void show(animation_t anim);
		void show(uint8_t *str);
};

extern Display display;