summaryrefslogtreecommitdiff
path: root/src/displayapp/DisplayAppRecovery.h
blob: 9f5fb130b6ff4d37cee2678c173d76039688dfb3 (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
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#pragma once
#include <FreeRTOS.h>
#include <task.h>
#include <drivers/St7789.h>
#include <drivers/SpiMaster.h>
#include <bits/unique_ptr.h>
#include <queue.h>
#include "components/gfx/Gfx.h"
#include "drivers/Cst816s.h"
#include <date/date.h>
#include <drivers/Watchdog.h>
#include <components/motor/MotorController.h>
#include <BootErrors.h>
#include "TouchEvents.h"
#include "Apps.h"
#include "Messages.h"
#include "DummyLittleVgl.h"

namespace Pinetime {
  namespace Drivers {
    class St7789;
    class Cst816S;
    class WatchdogView;
  }
  namespace Controllers {
    class Settings;
    class Battery;
    class Ble;
    class DateTime;
    class NotificationManager;
    class HeartRateController;
    class MotionController;
    class TouchHandler;
    class MotorController;
    class TimerController;
    class AlarmController;
  }

  namespace System {
    class SystemTask;
  };

  namespace Applications {
    class DisplayApp {
    public:
      DisplayApp(Drivers::St7789& lcd,
                 Components::LittleVgl& lvgl,
                 Drivers::Cst816S&,
                 Controllers::Battery& batteryController,
                 Controllers::Ble& bleController,
                 Controllers::DateTime& dateTimeController,
                 Drivers::WatchdogView& watchdog,
                 Pinetime::Controllers::NotificationManager& notificationManager,
                 Pinetime::Controllers::HeartRateController& heartRateController,
                 Controllers::Settings& settingsController,
                 Pinetime::Controllers::MotorController& motorController,
                 Pinetime::Controllers::MotionController& motionController,
                 Pinetime::Controllers::TimerController& timerController,
                 Pinetime::Controllers::AlarmController& alarmController,
                 Pinetime::Controllers::TouchHandler& touchHandler);
      void Start();
      void Start(Pinetime::System::BootErrors){ Start(); };
      void PushMessage(Pinetime::Applications::Display::Messages msg);
      void Register(Pinetime::System::SystemTask* systemTask);

    private:
      TaskHandle_t taskHandle;
      static void Process(void* instance);
      void DisplayLogo(uint16_t color);
      void DisplayOtaProgress(uint8_t percent, uint16_t color);
      void InitHw();
      void Refresh();
      Pinetime::Drivers::St7789& lcd;
      Controllers::Ble& bleController;

      static constexpr uint8_t queueSize = 10;
      static constexpr uint8_t itemSize = 1;
      QueueHandle_t msgQueue;
      static constexpr uint8_t displayWidth = 240;
      static constexpr uint8_t displayHeight = 240;
      static constexpr uint8_t bytesPerPixel = 2;

      static constexpr uint16_t colorWhite = 0xFFFF;
      static constexpr uint16_t colorGreen = 0x07E0;
      static constexpr uint16_t colorGreenSwapped = 0xE007;
      static constexpr uint16_t colorBlue = 0x0000ff;
      static constexpr uint16_t colorRed = 0xff00;
      static constexpr uint16_t colorRedSwapped = 0x00ff;
      static constexpr uint16_t colorBlack = 0x0000;
      uint8_t displayBuffer[displayWidth * bytesPerPixel];
    };
  }
}