-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisplay.h
More file actions
82 lines (64 loc) · 1.59 KB
/
display.h
File metadata and controls
82 lines (64 loc) · 1.59 KB
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
/*
* File: display.h
* Author: kostas
*
* Created on October 1, 2017, 5:37 PM
*/
#ifndef DISPLAY_H
#define DISPLAY_H
#include "main.h"
#include "font.h"
#include <linux/i2c-dev.h>
#define I2C_DEV "/dev/i2c-1"
#define I2C_ADDR 0x3C
#define ROW_SELECTED 0x01
class Display;
class TextCursor {
private:
Display *display;
int get_sx(int);
int get_sy(int);
void fill_row_padding(int row);
public:
uint8_t *buffer;
int chs_per_line;
int row_count;
int line_l_padding = 2;
int line_b_padding = 1;
int x, y;
TextCursor(Display *display);
~TextCursor();
void set(int x, int y);
void print(const char *text, bool wrap);
void inverse_row(int row);
void flush();
void clear();
};
class Display {
private:
int display_f;
uint8_t *screen;
void send_bus_commands(uint8_t reg, uint8_t *cmds, int len);
void send_bus_buffer(uint8_t reg, uint8_t *buff, int len);
public:
int width = 128;
int height = 64;
size_t screen_len = width * 8;
TextCursor *cursor;
Display();
virtual ~Display();
void update();
bool get_pixel(int x, int y);
void set_pixel(int x, int y);
void clear_pixel(int x, int y);
void render_char(const char *bitmap, int sx, int sy);
void inverse_area(int bx, int by, int ex, int ey);
void clear_area(int bx, int by, int ex, int ey);
void draw_line(int bx, int by, int ex, int ry);
void draw_rect(
int ax, int ay, int bx, int by,
int cx, int cy,int dx, int dy
);
void clear();
};
#endif /* DISPLAY_H */