summaryrefslogtreecommitdiff
path: root/src/Components/Gfx/Gfx.h
blob: d8728701fc96a2b21a3fd5e3602ebc82da4a40fa (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
#pragma once
#include <cstdint>
#include <nrf_font.h>


namespace Pinetime {
  namespace Drivers {
    class St7789;
  }
  namespace Components {
    class Gfx {
      public:
        explicit Gfx(Drivers::St7789& lcd);
        void Init();
        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);
        void FillRectangle(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint16_t color);

        void Sleep();
        void Wakeup();

      private:
        static constexpr uint8_t width = 240;
        static constexpr uint8_t height = 240;

        uint16_t buffer[width]; // 1 line buffer
        Drivers::St7789& lcd;

        void pixel_draw(uint8_t x, uint8_t y, uint16_t color);
        void SetBackgroundColor(uint16_t color);
    };
  }
}