2019-12-07 17:11:50 +01:00
|
|
|
#pragma once
|
2020-01-26 15:35:18 +01:00
|
|
|
#include <FreeRTOS.h>
|
2020-11-15 15:05:51 +01:00
|
|
|
#include <nrf_font.h>
|
2020-01-26 15:35:18 +01:00
|
|
|
#include <task.h>
|
2020-11-15 15:05:51 +01:00
|
|
|
#include <cstddef>
|
|
|
|
#include <cstdint>
|
|
|
|
#include "drivers/BufferProvider.h"
|
2019-12-07 17:11:50 +01:00
|
|
|
|
|
|
|
namespace Pinetime {
|
|
|
|
namespace Drivers {
|
|
|
|
class St7789;
|
|
|
|
}
|
|
|
|
namespace Components {
|
2020-01-26 13:37:10 +01:00
|
|
|
class Gfx : public Pinetime::Drivers::BufferProvider {
|
2019-12-07 17:11:50 +01:00
|
|
|
public:
|
|
|
|
explicit Gfx(Drivers::St7789& lcd);
|
2020-01-18 18:17:52 +01:00
|
|
|
void Init();
|
2019-12-07 17:11:50 +01:00
|
|
|
void ClearScreen();
|
|
|
|
void DrawString(uint8_t x, uint8_t y, uint16_t color, const char* text, const FONT_INFO *p_font, bool wrap);
|
|
|
|
void DrawChar(const FONT_INFO *font, uint8_t c, uint8_t *x, uint8_t y, uint16_t color);
|
2019-12-07 19:15:33 +01:00
|
|
|
void FillRectangle(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint16_t color);
|
2020-06-06 19:28:01 +02:00
|
|
|
void FillRectangle(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t* b);
|
2020-02-15 15:12:29 +01:00
|
|
|
void SetScrollArea(uint16_t topFixedLines, uint16_t scrollLines, uint16_t bottomFixedLines);
|
|
|
|
void SetScrollStartLine(uint16_t line);
|
|
|
|
|
2019-12-07 17:11:50 +01:00
|
|
|
|
2020-01-17 22:16:45 +01:00
|
|
|
void Sleep();
|
|
|
|
void Wakeup();
|
2020-01-26 13:37:10 +01:00
|
|
|
bool GetNextBuffer(uint8_t **buffer, size_t &size) override;
|
2020-06-06 19:28:01 +02:00
|
|
|
void pixel_draw(uint8_t x, uint8_t y, uint16_t color);
|
|
|
|
|
2020-01-17 22:16:45 +01:00
|
|
|
|
2019-12-07 17:11:50 +01:00
|
|
|
private:
|
2020-01-19 19:47:49 +01:00
|
|
|
static constexpr uint8_t width = 240;
|
|
|
|
static constexpr uint8_t height = 240;
|
|
|
|
|
2020-01-26 13:37:10 +01:00
|
|
|
enum class Action { None, FillRectangle, DrawChar};
|
|
|
|
struct State {
|
|
|
|
State() : busy{false}, action{Action::None}, remainingIterations{0}, currentIteration{0} {}
|
|
|
|
volatile bool busy;
|
|
|
|
volatile Action action;
|
|
|
|
volatile uint16_t remainingIterations;
|
|
|
|
volatile uint16_t currentIteration;
|
|
|
|
volatile FONT_INFO *font;
|
|
|
|
volatile uint16_t color;
|
|
|
|
volatile uint8_t character;
|
2020-01-26 15:35:18 +01:00
|
|
|
volatile TaskHandle_t taskToNotify = nullptr;
|
2020-01-26 13:37:10 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
volatile State state;
|
|
|
|
|
2020-01-19 19:47:49 +01:00
|
|
|
uint16_t buffer[width]; // 1 line buffer
|
2019-12-07 17:11:50 +01:00
|
|
|
Drivers::St7789& lcd;
|
2020-01-19 19:47:49 +01:00
|
|
|
|
|
|
|
void SetBackgroundColor(uint16_t color);
|
2020-11-01 21:22:21 +01:00
|
|
|
void WaitTransferFinished() const;
|
|
|
|
void NotifyEndOfTransfer(TaskHandle_t task);
|
2019-12-07 17:11:50 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|