/ src / display / display_screen.h
display_screen.h
 1  #pragma once
 2  
 3  #include <cstdint>
 4  #include "ili9341.h"
 5  #include "input/input_keypad.h"
 6  
 7  #include "led/display_led_low_power_pwm.h"
 8  
 9  namespace display
10  {
11  	using color_t = uint32_t;
12  	using coord_t = uint16_t;
13  
14  	class Screen
15  	{
16  	public:
17  		Screen(input::Keypad* keypad, float initialBacklight = 1.0f);
18  		virtual ~Screen();
19  		Screen(const Screen &) = delete;
20  		Screen &operator=(const Screen &) = delete;
21  
22  		void Update(float timeDelta);
23  		void BacklightOn();
24  		void BacklightOff();
25  		void BacklightOffImmediate();
26  		void SetBacklightBrightness(float brightnessPercent);
27  		float GetBacklightBrightness() { return lastBacklightBrightness; }
28  
29  		void SetBatteryStatus(uint8_t stateOfCharge, bool isCharging);
30  
31  		void DisplaySleep();
32  		void DisplayWake();
33  
34  		inline bool IsInitialized() { return initialized; }
35  		static constexpr uint32_t GraphicsTickMs = 1;
36  		static constexpr float BacklightAnimationDurationSlow = 0.5f;
37  		static constexpr float BacklightAnimationDurationFast = 0.1f;
38  	private:
39  		static void Tick(void* context);
40  		void InitializeBacklight(float initialBrightness);
41  
42  		bool initialized;
43  		input::Keypad* keypad;
44  		float lastBacklightBrightness = 1.0f;
45  		led::RgbLeds backlight;
46  	};
47  } // namespace display