3 * Copyright (c) 2020 Project CHIP Authors
4 * Copyright (c) 2018 Nest Labs, Inc.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 * This describes helper APIs for the M5Stack's Display
29 #include "esp_system.h"
31 #if CONFIG_DEVICE_TYPE_M5STACK
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
37 #elif CONFIG_DEVICE_TYPE_ESP32_WROVER_KIT
39 #define CONFIG_HAVE_DISPLAY 1
40 #define INVERT_DISPLAY INVERT_OFF
44 #define CONFIG_HAVE_DISPLAY 0
48 #if CONFIG_HAVE_DISPLAY
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
58 extern uint16_t DisplayHeight;
59 extern uint16_t DisplayWidth;
63 * Initialize the M5Stack's display driver and set the default bright control and timeout
65 * @return esp_err_t 0 if the display driver was initialized correctly
67 extern esp_err_t InitDisplay();
70 * Clear the display by setting the whole screen to black
72 extern void ClearDisplay();
76 * Clear a portion of the display by drawing a black rectangle based on the given arguments
78 * Calling this with default arguments is the same as calling `ClearDisplay()`.
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.
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);
89 * Display a status message at a given vertical position
91 * The status message will be drawn from the left edge of the screen
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
96 extern void DisplayStatusMessage(char * msg, uint16_t vpos);
99 * Reset the display timeout and set the brightness back up to default values
101 * @return true If the display was woken
103 extern bool WakeDisplay();
105 #endif // #if CONFIG_HAVE_DISPLAY