|
| 1 | +--- |
| 2 | +sidebar_position: 3 |
| 3 | +title: Working with ESP-IDF |
| 4 | +slug: /ESP32-C6-Touch-AMOLCD-1.8/Development-Environment-Setup-ESPIDF |
| 5 | +product_family: |
| 6 | + - ESP32 |
| 7 | +product_model: |
| 8 | + - ESP32-C6-Touch-AMOLCD-1.8 |
| 9 | +--- |
| 10 | + |
| 11 | +import IDF_demo1 from './images/ESP32-C6-Touch-AMOLED-1.8-demo-VS01.webp'; |
| 12 | +import IDF_demo2 from './images/ESP32-C6-Touch-AMOLED-1.8-demo-VS02.webp'; |
| 13 | +import IDF_demo4 from './images/ESP32-C6-Touch-AMOLED-1.8-demo-VS04.webp'; |
| 14 | +import IDF_demo51 from './images/ESP32-C6-Touch-AMOLED-1.8-demo-VS51.webp'; |
| 15 | +import IDF_demo52 from './images/ESP32-C6-Touch-AMOLED-1.8-demo-VS52.webp'; |
| 16 | +import IDF_demo31 from './images/ESP32-C6-Touch-AMOLED-1.8-demo-VS31.webp'; |
| 17 | +import IDF_demo32 from './images/ESP32-C6-Touch-AMOLED-1.8-demo-VS32.webp'; |
| 18 | +import IDF_demo33 from './images/ESP32-C6-Touch-AMOLED-1.8-demo-VS33.webp'; |
| 19 | +import IDF_demo34 from './images/ESP32-C6-Touch-AMOLED-1.8-demo-VS34.webp'; |
| 20 | +import IDF_demo35 from './images/ESP32-C6-Touch-AMOLED-1.8-demo-VS35.webp'; |
| 21 | +import IDF_demo36 from './images/ESP32-C6-Touch-AMOLED-1.8-demo-VS36.webp'; |
| 22 | + |
| 23 | +# Working with ESP-IDF |
| 24 | + |
| 25 | +This chapter includes the following sections, please read as needed: |
| 26 | + |
| 27 | +- [Setting Up Development Environment](#setting-up-development-environment) |
| 28 | +- [Demo](#demo) |
| 29 | + |
| 30 | + |
| 31 | +## Setting Up Development Environment |
| 32 | + |
| 33 | +:::note |
| 34 | +The following environment settings are applicable to Windows 10/11 systems. For Mac/Linux users, please refer to the **[official instructions](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/index.html)** |
| 35 | +::: |
| 36 | + |
| 37 | +1. Download and install [Visual Studio Code](https://code.visualstudio.com/). |
| 38 | + |
| 39 | +2. In VS Code, open the **Extensions** view by clicking the  in the VS Code sidebar or using the shortcut (<kbd>Ctrl+Shift+X</kbd>). Then, search for the [ESP-IDF](https://marketplace.visualstudio.com/items?itemName=espressif.esp-idf-extension) extension and install it. |
| 40 | + |
| 41 | +  |
| 42 | + |
| 43 | +3. After the extension is installed, the  will appear in the activity bar on the left side of VS Code. Clicking this icon will view the basic command list for the ESP-IDF extension. Select **Configure ESP-IDF extension** under **Advanced**. |
| 44 | + |
| 45 | + <!-- Alternatively, press <kbd>F1</kbd>, type `Configure ESP-IDF Extension`, and select the **ESP-IDF: Configure ESP-IDF Extension** option. --> |
| 46 | + |
| 47 | +  |
| 48 | + |
| 49 | +4. Choose **Express** to enter quick configuration mode: |
| 50 | + |
| 51 | +  |
| 52 | + |
| 53 | +5. Modify the following options as needed: |
| 54 | + |
| 55 | + - **Select download server**: |
| 56 | + - Espressif: For users in China, use Espressif's China server for faster downloads. |
| 57 | + - Github: Use the official GitHub release link. |
| 58 | + - **ESP-IDF Version**: Typically, select the version required by the development board. If no specific requirement, it's recommended to use the latest stable version. For [ESP32-C6-Touch-AMOLED-1.8](https://www.waveshare.com/esp32-c6-touch-amoled-1.8.htm), it is recommended to use the Espressif IDF version ≥ v5.5.0. |
| 59 | + - **ESP-IDF Container directory**: It is recommended to use the default path, or use a path that contains only English characters and no spaces. |
| 60 | + - **ESP-IDF Required Tools directory**: It is recommended to use the default path, or use a path that contains only English characters and no spaces. |
| 61 | + |
| 62 | +  |
| 63 | + |
| 64 | +6. Click **Install** to start the installation. You will see a page displaying the installation progress, including the progress status of ESP-IDF download, ESP-IDF tool download and installation, as well as the creation of the Python virtual environment. |
| 65 | + |
| 66 | +  |
| 67 | + |
| 68 | +7. If everything is installed correctly, you'll get a prompt confirming all the setup is done, and you're ready to start using the extension. |
| 69 | + |
| 70 | +  |
| 71 | + |
| 72 | +:::warning |
| 73 | +Note: If ESP-IDF installation fails or needs to be reinstalled, you can try deleting the `C:\Users\%Username%\esp` and `C:\Users\%Username%\.espressif` folders and then retry. |
| 74 | +::: |
| 75 | + |
| 76 | +## Demo |
| 77 | + |
| 78 | +The ESP-IDF demos are located in the `ESP-IDF` directory of the [demo package](https://github.com/waveshareteam/ESP32-C6-Touch-AMOLED-1.8/tree/main/examples). |
| 79 | + |
| 80 | +| Demo | Basic Description | |
| 81 | +| :-------------------------------------------------------------: | :----------------------------------------------------------------------: | |
| 82 | +| [01_AXP2101](#Demo-1-AXP2101) | Drives the AXP2101 PMU using the ported XPowersLib to get power-related data | |
| 83 | +| [02_PCF85063](#Demo-2-PCF85063) | Drives the PCF85063 RTC for time storage and reading | |
| 84 | +| [03_esp_brookesia](#Demo-3-esp-brookesia) | Show a complete mobile-style UI system, including components such as the status bar, navigation bar, app launcher, and gesture interactions | |
| 85 | +| [04_QMI8658](#Demo-4-QMI8658) | Drives the QMI8658 IMU using the ported SensorLib to get gyroscope-related data | |
| 86 | +| [05_LVGL_WITH_RAM](#Demo-5-LVGL_WITH_RAM) | Run the LVGL demo by enabling double buffering and DMA acceleration to prevent tearing | |
| 87 | + |
| 88 | + |
| 89 | +### 01_AXP2101 {#Demo-1-AXP2101} |
| 90 | + |
| 91 | +#### Demo Description |
| 92 | + |
| 93 | +- This demo demonstrates porting XPowersLib in ESP-IDF, and driving AXP2101 to obtain power-related data through the ported XPowersLib |
| 94 | + |
| 95 | +#### Hardware Connection |
| 96 | + |
| 97 | +- Connect the development board to the computer |
| 98 | + |
| 99 | +#### Code Analysis |
| 100 | + |
| 101 | +- i2c_init: Initializes the I2C master to prepare for communication with other devices (like the PMU) |
| 102 | + - Configures I2C parameters, including setting the master device mode, specifying the SDA and SCL pins, enabling the pull-up resistor, and determining the clock frequency |
| 103 | + - Installs the I2C driver and apply the configuration to the actual hardware |
| 104 | +- pmu_register_read: Reads a series of bytes of data from a specific register on the PMU |
| 105 | + - Performs parameter checks to ensure the incoming parameters are valid and avoid invalid read operations |
| 106 | + - Performs I2C operations in two steps, first sends the register address to read, then reads the data. During the reading process, different processing is carried out according to the length of bytes to be read to ensure accurate reading of the data. At the same time, handles error cases in the I2C communication process and returns the corresponding status code so that the upper-layer code can determine if the read operation is successful |
| 107 | + |
| 108 | +#### Expected Result |
| 109 | + |
| 110 | +- This demo will not light up the screen |
| 111 | +- The serial port monitor displays the parameters: chip temperature, charging state, discharging state, standby state, Vbus connection, Vbus condition, charger status, battery voltage, Vbus voltage, system voltage, battery percentage |
| 112 | +<div style={{maxWidth:800}}> <img src={IDF_demo1}/></div> |
| 113 | + |
| 114 | +### 02_PCF85063 {#Demo-2-PCF85063} |
| 115 | + |
| 116 | +#### Demo Description |
| 117 | + |
| 118 | +- This demo uses a simple way to drive the PCF85063 for time storage and reading functionality |
| 119 | + |
| 120 | +#### Hardware Connection |
| 121 | + |
| 122 | +- Connect the development board to the computer |
| 123 | + |
| 124 | +#### Code Analysis |
| 125 | + |
| 126 | +- i2c_master_init |
| 127 | + - Defines the I2C configuration structure conf, set the master device mode, SDA and SCL pins, pull-up resistor, and clock frequency |
| 128 | + - Uses the i2c_param_config function to configure I2C parameters. If the configuration fails, an error log is recorded and an error code is returned |
| 129 | + - Uses the i2c_driver_install function to install the I2C driver, apply the configuration to the actual hardware, and return the result |
| 130 | +- rtc_get_time |
| 131 | + - Defines a 7-byte array to store the read time data |
| 132 | + - Calls the rtc_read_reg function to read 7 bytes of time data starting from the specific register address (0x04) of the RTC chip. If the reading fails, an error log is recorded and an error code is returned |
| 133 | + - Processes the time data read, separately extract the seconds, minutes, hours, days, weeks, months, and years, and convert BCD to decimal |
| 134 | + - Uses ESP_LOGI to output the formatted current time |
| 135 | + |
| 136 | +#### Expected Result |
| 137 | + |
| 138 | +- This demo will not light up the screen |
| 139 | +- The serial port monitor prints time information |
| 140 | +<div style={{maxWidth:800}}> <img src={IDF_demo2}/></div> |
| 141 | + |
| 142 | +### 03_esp_brookesia {#Demo-3-esp-brookesia} |
| 143 | + |
| 144 | +#### Demo Description |
| 145 | + |
| 146 | +- This example showcases a complete mobile-style UI system. It includes components like a status bar, navigation bar, app launcher, and gesture interactions. |
| 147 | + |
| 148 | +#### Hardware Connection |
| 149 | + |
| 150 | +- Connect the development board to the computer |
| 151 | + |
| 152 | +#### Expected Result |
| 153 | + |
| 154 | +| <div style={{maxWidth:360}}> <img src={IDF_demo31}/></div> | <div style={{maxWidth:800}}> <img src={IDF_demo32}/></div> | <div style={{maxWidth:800}}> <img src={IDF_demo33}/></div> |
| 155 | +| ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | |
| 156 | + |
| 157 | + |
| 158 | + |
| 159 | +### 04_QMI8658 {#Demo-4-QMI8658} |
| 160 | + |
| 161 | +#### Demo Description |
| 162 | + |
| 163 | +- This demo demonstrates porting SensorLib in ESP-IDF, then using the ported SensorLib to drive qmi8658 to obtain gyroscope-related data |
| 164 | + |
| 165 | +#### Hardware Connection |
| 166 | + |
| 167 | +- Connect the development board to the computer |
| 168 | + |
| 169 | +#### Code Analysis |
| 170 | + |
| 171 | +- setup_sensor: Sets up and initializes the environment and parameters required to communicate with the QMI8658 sensor |
| 172 | + - Initializes I2C communication to ensure that the connection channel to the sensor is established |
| 173 | + - Initializes the sensor, check if the sensor is properly connected |
| 174 | + - Configures the sensor's accelerometer and gyroscope parameters to meet specific application needs |
| 175 | + - Enables the sensor to start collecting data |
| 176 | +- read_sensor_data: Reads and processes data from the QMI8658 sensor in a continuous loop and outputs the results |
| 177 | + - In the loop, continuously checks if the sensor data is ready |
| 178 | + - When the data is ready, the accelerometer, gyroscope, timestamp, and temperature data are read and logged out |
| 179 | + - Handles the failure of data reading by recording an error log for troubleshooting |
| 180 | + - Controls the execution speed of the loop through delay to avoid excessive consumption of system resources |
| 181 | + |
| 182 | +#### Expected Result |
| 183 | + |
| 184 | +- This demo will not light up the screen |
| 185 | +- The serial port monitor prints sensor data |
| 186 | +<div style={{maxWidth:800}}> <img src={IDF_demo4}/></div> |
| 187 | + |
| 188 | +### 05_LVGL_WITH_RAM {#Demo-5-LVGL_WITH_RAM} |
| 189 | + |
| 190 | +#### Demo Description |
| 191 | + |
| 192 | +- This example shows LVGL demo, which can run LVGL demo by enabling dual caching, enabling DMA acceleration and anti-tearing, etc. to run dynamic graphics and texts smoothly, achieving a frame rate of 200-300 FPS |
| 193 | + |
| 194 | +#### Hardware Connection |
| 195 | + |
| 196 | +- Connect the development board to the computer |
| 197 | + |
| 198 | +#### Code Analysis |
| 199 | + |
| 200 | +- app_main: The initialization and startup process of the entire application |
| 201 | + - Hardware initialization: Configures and initializes hardware devices related to LCD display and touch input (if available), such as GPIO pins, SPI bus, I2C bus, LCD panel driver, and touch controller driver, etc. |
| 202 | + - LVGL initialization: Initializes the LVGL library, allocates drawing buffers, registers display driver and touch input device driver (if available), installs timers, and creates smutexes and starts LVGL tasks |
| 203 | + - Example display: Finally shows LVGL examples, such as widget examples, etc. |
| 204 | +- example_lvgl_port_task: LVGL task function, responsible for handling LVGL regular updates and task delay control, ensuring the smooth operation of the LVGL interface |
| 205 | + - Timed update: In its loop, it grabs a mutex lock and calls the lv_timer_handler to handle the LVGL timer event, which updates the UI state |
| 206 | + - Delay control: Determine the task's delay time based on the results of timer processing to avoid excessive CPU resource usage and ensure timely response to LVGL events |
| 207 | + |
| 208 | +#### Expected Result |
| 209 | + |
| 210 | +| <div style={{maxWidth:800}}> <img src={IDF_demo51}/></div> | <div style={{maxWidth:800}}> <img src={IDF_demo52}/></div> |
| 211 | +| ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | |
0 commit comments