-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathScreen.h
73 lines (52 loc) · 1.54 KB
/
Screen.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
#pragma once
#include <Arduino.h>
#include <OLEDDisplay.h>
#include "../drawing/Canvas.h"
#include "../drawing/CanvasContext.h"
// Represents a screen.
// The only instance of ScreenClass is a global variable `Screen`.
class ScreenClass {
public:
// Creates a new instance of the Screen class.
// Do not call this constructor directly. Always use the global variable `Screen`.
ScreenClass();
// Gets the internal OLEDDisplay object.
OLEDDisplay *getDisplay();
// Gets the canvas of screen.
Canvas *getCanvas();
// Gets or sets brightness percentage of the screen. The range of percentage is 0-100.
uint8_t getBrightness();
void setBrightness(uint8_t percentage);
// Gets true if the screen is on.
bool isOn();
// Gets true if the screen is flipped vertically.
bool isFlipped();
// Sets whether the screen is flipped and mirrored.
void setOrientation(bool flipped = false, bool mirrored = false);
// Gets true if the screen is mirrored horizontally.
bool isMirrored();
// Gets width of the screen.
int getWidth();
// Gets height of the screen.
int getHeight();
// Initializes screen.
void begin(OLEDDisplay *display);
// Updates in the loop.
void update();
// Clears buffer of screen.
void clearBuffer();
// Clears screen immediately.
void clear();
// Turns on.
void turnOn();
// Turns off.
void turnOff();
private:
OLEDDisplay *_display;
Canvas *_canvas;
bool _isOn = true;
int _brightness = 255;
bool _flipped = false;
bool _mirrored = false;
};
extern ScreenClass Screen;