84 lines
2.1 KiB
C
84 lines
2.1 KiB
C
/* Hello World Example
|
|
|
|
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
|
|
|
Unless required by applicable law or agreed to in writing, this
|
|
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
CONDITIONS OF ANY KIND, either express or implied.
|
|
*/
|
|
#include <stdio.h>
|
|
|
|
/* IDF headers */
|
|
#include "esp_log.h"
|
|
#include "esp_spi_flash.h"
|
|
#include "esp_system.h"
|
|
|
|
/* Drivers */
|
|
#include "driver/spi_master.h"
|
|
|
|
/* FreeRTOS */
|
|
#include "freertos/FreeRTOS.h"
|
|
#include "freertos/task.h"
|
|
|
|
/* Config */
|
|
#include "sdkconfig.h"
|
|
|
|
/* LCD */
|
|
#include "st7789_lcd.h"
|
|
|
|
#define APP_LOG_TAG "MAIN"
|
|
|
|
spi_device_handle_t lcd_impl_init(void);
|
|
st7789_lcd_ret_t lcd_impl_reset(void *pdev);
|
|
st7789_lcd_ret_t lcd_impl_delay(void *pdev, uint32_t msec);
|
|
st7789_lcd_ret_t lcd_impl_write_command(void *pdev, uint8_t *command, uint32_t len);
|
|
st7789_lcd_ret_t lcd_impl_write_data(void *pdev, uint8_t *data, uint32_t len);
|
|
|
|
extern const uint8_t app_demo_image_1_rgb565[115200];
|
|
|
|
void app_main(void) {
|
|
ESP_LOGI(APP_LOG_TAG, "MAIN");
|
|
|
|
st7789_lcd_t lcd = {
|
|
.cb =
|
|
{
|
|
.write_command_cb = lcd_impl_write_command,
|
|
.write_data_cb = lcd_impl_write_data,
|
|
.reset_cb = lcd_impl_reset,
|
|
.delay_cb = lcd_impl_delay,
|
|
},
|
|
.config =
|
|
{
|
|
.dir = ST7789_LCD_DIR_0,
|
|
.inverted = false,
|
|
.bgr_mode = true,
|
|
.pix_fmt = ST7789_LCD_PIXFMT_RGB565,
|
|
},
|
|
.user_data = lcd_impl_init(),
|
|
};
|
|
|
|
if (lcd.user_data == NULL) {
|
|
ESP_LOGE(APP_LOG_TAG, "IMPL initialization failed");
|
|
vTaskSuspend(NULL);
|
|
}
|
|
|
|
if (st7789_lcd_init(&lcd) != ST7789_SUCCESS) {
|
|
ESP_LOGE(APP_LOG_TAG, "LCD init failed");
|
|
}
|
|
|
|
st7789_lcd_coord_t coord = {
|
|
.x_start = 0,
|
|
.x_end = 239,
|
|
.y_start = 0,
|
|
.y_end = 239,
|
|
};
|
|
|
|
if(st7789_lcd_upload(&lcd, &coord, (uint8_t *)app_demo_image_1_rgb565) != ST7789_SUCCESS) {
|
|
ESP_LOGE(APP_LOG_TAG, "LCD upload failed");
|
|
}
|
|
|
|
for (;;) {
|
|
vTaskSuspend(NULL);
|
|
}
|
|
}
|