Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / examples / common / screen-framework / include / Display.h
1 /*
2  *
3  *    Copyright (c) 2020 Project CHIP Authors
4  *    Copyright (c) 2018 Nest Labs, Inc.
5  *    All rights reserved.
6  *
7  *    Licensed under the Apache License, Version 2.0 (the "License");
8  *    you may not use this file except in compliance with the License.
9  *    You may obtain a copy of the License at
10  *
11  *        http://www.apache.org/licenses/LICENSE-2.0
12  *
13  *    Unless required by applicable law or agreed to in writing, software
14  *    distributed under the License is distributed on an "AS IS" BASIS,
15  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  *    See the License for the specific language governing permissions and
17  *    limitations under the License.
18  */
19
20 /**
21  * @file Display.h
22  *
23  * This describes helper APIs for the M5Stack's Display
24  *
25  */
26
27 #pragma once
28
29 #include "esp_system.h"
30
31 #if CONFIG_DEVICE_TYPE_M5STACK
32
33 #define CONFIG_HAVE_DISPLAY 1
34 // for some reason this is backwards (turns out this is because of a 2019 update to the m5stack hw)
35 #define INVERT_DISPLAY INVERT_ON
36
37 #elif CONFIG_DEVICE_TYPE_ESP32_WROVER_KIT
38
39 #define CONFIG_HAVE_DISPLAY 1
40 #define INVERT_DISPLAY INVERT_OFF
41
42 #else
43
44 #define CONFIG_HAVE_DISPLAY 0
45
46 #endif
47
48 #if CONFIG_HAVE_DISPLAY
49
50 extern "C" {
51 #include "tft.h"
52 #include "tftspi.h"
53 } // extern "C"
54
55 // To reduce wear (and heat) on the screen, the display will always go off after a few seconds
56 #define DISPLAY_TIMEOUT_MS 30000
57
58 extern uint16_t DisplayHeight;
59 extern uint16_t DisplayWidth;
60
61 /**
62  * @brief
63  *  Initialize the M5Stack's display driver and set the default bright control and timeout
64  *
65  * @return esp_err_t    0 if the display driver was initialized correctly
66  */
67 extern esp_err_t InitDisplay();
68 /**
69  * @brief
70  *  Clear the display by setting the whole screen to black
71  */
72 extern void ClearDisplay();
73
74 /**
75  * @brief
76  *  Clear a portion of the display by drawing a black rectangle based on the given arguments
77  *
78  *  Calling this with default arguments is the same as calling `ClearDisplay()`.
79  *
80  * @param x_percent_start   The starting x coordinate specified as a percentage of the screen's width.
81  * @param y_percent_start   The starting y coordinate specified as a percentage of the screen's height.
82  * @param x_percent_end     The end x coordinate specified as a percentage of the screen's width.
83  * @param y_percent_end     The end y coordinate specified as a percentage of the screen's height.
84  */
85 extern void ClearRect(uint16_t x_percent_start = 0, uint16_t y_percent_start = 0, uint16_t x_percent_end = 100,
86                       uint16_t y_percent_end = 100);
87 /**
88  * @brief
89  *  Display a status message at a given vertical position
90  *
91  *  The status message will be drawn from the left edge of the screen
92  *
93  * @param msg   The message to display
94  * @param vpos  The vertical position(0-100 percent) of the message. Where 0 is the top of the screen
95  */
96 extern void DisplayStatusMessage(char * msg, uint16_t vpos);
97 /**
98  * @brief
99  *  Reset the display timeout and set the brightness back up to default values
100  *
101  * @return true     If the display was woken
102  */
103 extern bool WakeDisplay();
104
105 #endif // #if CONFIG_HAVE_DISPLAY