aboutsummaryrefslogtreecommitdiffstats
path: root/source/sharp.cpp
blob: 8fa22f981962833f1fb40fe84442aa01d94414c6 (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
#include "sharp.hpp"
#include "rtc.hpp"

constexpr unsigned int SHARP_WIDTH = 144;
constexpr unsigned int SHARP_HEIGHT = 168;

constexpr unsigned int SHARP_SCK = 12;
constexpr unsigned int SHARP_MOSI = 13;
constexpr unsigned int SHARP_SS = 14;

Adafruit_SharpMem Sharp::display(SHARP_SCK, SHARP_MOSI, SHARP_SS, SHARP_WIDTH,
	SHARP_HEIGHT);
TaskHandle_t Sharp::taskHandle;
std::vector<Widget *> Sharp::widgets;

void Sharp::begin(void)
{
	widgets.reserve(10);
	display.begin();
	display.clearDisplay();
	display.setTextSize(3);
	display.setTextColor(BLACK, WHITE);

	xTaskCreate(updateTask, "sharp", 512, nullptr, TASK_PRIO_LOW,
		&taskHandle);
}

void Sharp::updateTask([[maybe_unused]] void *arg)
{
	while (1) {
		unsigned int y = 0;
		for (auto& w : widgets) {
			w->render(display, y);
			y += w->getHeight();
    			display.drawFastHLine(0, y + 1, SHARP_WIDTH, BLACK);
			y += 3;
			if (y >= SHARP_HEIGHT)
				break;
		}

		display.refresh();
		delay(300);
	}
}