
/**
 * @file lcd_display_drv.h
 * @author June6 (https://github.com/Junedoubling6)
 * @brief
 * @version 0.1
 * @date 2023-08-16
 *
 * @copyright Copyright (c) 2022 - , All rights reserved.
 *
 */
#ifndef LCD_DISPLAY_DRV_H__
#define LCD_DISPLAY_DRV_H__

#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>

#include "driver/gpio.h"
#include "err_code.h"

#ifdef __cplusplus
extern "C" {
#endif

#define LCD_DISPLAY_DATA0 (GPIO_NUM_48)
#define LCD_DISPLAY_DATA1 (GPIO_NUM_47)
#define LCD_DISPLAY_DATA2 (GPIO_NUM_21)
#define LCD_DISPLAY_DATA3 (GPIO_NUM_14)
#define LCD_DISPLAY_DATA4 (GPIO_NUM_13)
#define LCD_DISPLAY_DATA5 (GPIO_NUM_12)
#define LCD_DISPLAY_DATA6 (GPIO_NUM_11)
#define LCD_DISPLAY_DATA7 (GPIO_NUM_10)
#define LCD_DISPLAY_DATA8 (GPIO_NUM_2)
#define LCD_DISPLAY_DATA9 (GPIO_NUM_1)
#define LCD_DISPLAY_DATA10 (GPIO_NUM_45)
#define LCD_DISPLAY_DATA11 (GPIO_NUM_42)
#define LCD_DISPLAY_DATA12 (GPIO_NUM_41)
#define LCD_DISPLAY_DATA13 (GPIO_NUM_40)
#define LCD_DISPLAY_DATA14 (GPIO_NUM_39)
#define LCD_DISPLAY_DATA15 (GPIO_NUM_38)

/* WR & CLK */
#define LCD_DISPLAY_PCLK (GPIO_NUM_9)
#define LCD_DISPLAY_DC (GPIO_NUM_NC)
#define LCD_DISPLAY_RST (GPIO_NUM_5)
/* SPI CS */
#define LCD_DISPLAY_CS (GPIO_NUM_8)

#define LCD_DISPLAY_DE (GPIO_NUM_0)
#define LCD_DISPLAY_VSYNC (GPIO_NUM_3)
#define LCD_DISPLAY_HSYNC (GPIO_NUM_46)
#define LCD_DISPLAY_DISP_EN (LCD_DISPLAY_CS)
/* SPI */
/* 复用 */
#define LCD_DISPLAY_SCLK (LCD_DISPLAY_DATA0)
#define LCD_DISPLAY_MOSI (LCD_DISPLAY_DATA1)
#define LCD_DISPLAY_MISO (GPIO_NUM_NC)

/**
 * @brief Get the Lcd Display Work State object
 *
 * @return true
 * @return false
 */
bool get_lcd_display_work_state(void);

/**
 * @brief Get the lcd backlight duty object
 *
 * @return uint8_t
 * @details 返回参数为百分比
 */
uint8_t get_lcd_backlight_duty(void);

/**
 * @brief Set the lcd backlight duty object
 *
 * @param duty
 * @return uint8_t
 * @details 返回参数为百分比
 */
uint8_t set_lcd_backlight_duty(uint8_t duty);

/**
 * @brief Enable or disable lcd panel backlight.
 *
 * @param cmd
 */
void lcd_panel_backlight_enable(bool cmd);

/**
 * @brief Config lcd display gpio.
 *
 * @details Turn off LCD backlight after config.
 */
void lcd_display_gpio_config(void);

/**
 * @brief Initialize lcd display rgb driver.
 *
 */
void lcd_display_rgb_driver_init(void);

#if CONFIG_LCD_CONTROLLER_SLEEP_WAKEUP
/**
 * @brief Sleep lcd display rgb driver.
 *
 */
void lcd_display_rgb_driver_sleep(void);
#endif

#ifdef __cplusplus
}
#endif

#endif  // LCD_DISPLAY_DRV_H__
