-
Notifications
You must be signed in to change notification settings - Fork 0
/
RGB16DisplayAdaptor.h
77 lines (56 loc) · 1.76 KB
/
RGB16DisplayAdaptor.h
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
#pragma once
#include <Arduino.h>
#include "RGB16.h"
/*
* RGB display generic interface
*/
class RGB16DisplayAdaptor {
public:
RGB16DisplayAdaptor() {}
virtual ~RGB16DisplayAdaptor() {}
/* Initialize interface port */
virtual void begin() {}
/* Returns display width */
virtual uint16_t width() const = 0;
/* Returns display height */
virtual uint16_t height() const = 0;
/* Initialize display */
virtual void init(uint16_t fill_colour = RGB16Black) = 0;
/* Enable / disable display */
virtual void enable(bool on) = 0;
/* Set brightness value */
virtual void set_brightness(uint8_t val) = 0;
/*
* Core drawing API
*/
/* Put pixel */
virtual void put_pixel(uint16_t x, uint16_t y, uint16_t colour) = 0;
/* Fill certain region */
virtual void fill_rect(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t colour) = 0;
/*
* Display memory writing API
*/
/* Setup rectangular writing area */
virtual void write_begin(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, bool col_order) = 0;
/* Write pixels */
virtual void write_pixels(uint16_t const* pix_buff, int len, int pgm = false) = 0;
/* Write pixels bitmap */
virtual void write_pixels_bm(uint8_t const* pix_bm, int len, uint16_t colours[2], int pgm = false) = 0;
/* End writing */
virtual void write_end() = 0;
/*
* Drawing functions implementation
*/
/* Fill display memory with given colour */
void fill(uint16_t colour) {
fill_rect(0, 0, width() - 1, height() - 1, colour);
}
/* Draw horizontal line */
void hline(uint16_t x, uint16_t y, uint16_t len, uint16_t colour) {
fill_rect(x, y, x + len - 1, y, colour);
}
/* Draw vertical line */
void vline(uint16_t x, uint16_t y, uint16_t len, uint16_t colour) {
fill_rect(x, y, x, y + len - 1, colour);
}
};