InfiniTime.git

ref: fdc89f1a20889c0295534f58dc2e82ce8c55a18b

src/displayapp/LittleVgl.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
#pragma once

#include <lvgl/lvgl.h>

namespace Pinetime {
  namespace Drivers {
    class Cst816S;
    class St7789;
  }

  namespace Components {
    class LittleVgl {
    public:
      enum class FullRefreshDirections { None, Up, Down, Left, Right, LeftAnim, RightAnim };
      LittleVgl(Pinetime::Drivers::St7789& lcd, Pinetime::Drivers::Cst816S& touchPanel);

      LittleVgl(const LittleVgl&) = delete;
      LittleVgl& operator=(const LittleVgl&) = delete;
      LittleVgl(LittleVgl&&) = delete;
      LittleVgl& operator=(LittleVgl&&) = delete;

      void Init();

      void FlushDisplay(const lv_area_t* area, lv_color_t* color_p);
      bool GetTouchPadInfo(lv_indev_data_t* ptr);
      void SetFullRefresh(FullRefreshDirections direction);
      void SetNewTouchPoint(uint16_t x, uint16_t y, bool contact);

      bool GetFullRefresh() {
        bool returnValue = fullRefresh;
        if (fullRefresh) {
          fullRefresh = false;
        }
        return returnValue;
      }

    private:
      void InitDisplay();
      void InitTouchpad();
      void InitTheme();

      Pinetime::Drivers::St7789& lcd;
      Pinetime::Drivers::Cst816S& touchPanel;

      lv_disp_buf_t disp_buf_2;
      lv_color_t buf2_1[LV_HOR_RES_MAX * 4];
      lv_color_t buf2_2[LV_HOR_RES_MAX * 4];

      lv_disp_drv_t disp_drv;

      bool fullRefresh = false;
      static constexpr uint8_t nbWriteLines = 4;
      static constexpr uint16_t totalNbLines = 320;
      static constexpr uint16_t visibleNbLines = 240;
      static constexpr uint8_t MaxScrollOffset() {
        return LV_VER_RES_MAX - nbWriteLines;
      }
      FullRefreshDirections scrollDirection = FullRefreshDirections::None;
      uint16_t writeOffset = 0;
      uint16_t scrollOffset = 0;

      uint16_t tap_x = 0;
      uint16_t tap_y = 0;
      bool tapped = false;
    };
  }
}