#include "main.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "../lvgl/lvgl.h"
#include "../ili9341/core.h"
#include "../ili9341/lv_driver.h"
#include "lv_conf.h"

int main(void)
{
  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration--------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  LL_APB1_GRP2_EnableClock(LL_APB1_GRP2_PERIPH_SYSCFG);
  LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_PWR);

  /* SysTick_IRQn interrupt configuration */
  NVIC_SetPriority(SysTick_IRQn, 3);

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_DMA_Init();
  MX_SPI2_Init();
	LL_mDelay(100);
	
	lv_init(); // LittleVgl (6.0)

  /* USER CODE BEGIN 2 */
	ILI9341_init();

  /* USER CODE END 2 */
		LL_mDelay(1000);
		static lv_color_t disp_buf1[320 * 10];
		static lv_disp_draw_buf_t buf;
		lv_disp_draw_buf_init(&buf, disp_buf1, NULL, 320 * 10);


    lv_disp_drv_t disp_drv;
    lv_disp_drv_init(&disp_drv);
    disp_drv.draw_buf = &buf;
    disp_drv.flush_cb = ILI9341_flush;
    disp_drv.hor_res = 320;                /*Set the horizontal resolution in pixels*/
    disp_drv.ver_res = 240;                /*Set the vertical resolution in pixels*/
    lv_disp_drv_register(&disp_drv);
 	LL_mDelay(100);

		lv_obj_t * label = lv_label_create(lv_scr_act());
    lv_label_set_text(label, "single freq:");
		
		/* Infinite loop */
		/* USER CODE BEGIN WHILE */
		while (1)
		{
				LL_mDelay(5);
			/* USER CODE END WHILE */
					lv_task_handler();
					lv_tick_inc(10);


			/* USER CODE BEGIN 3 */
		}
  /* USER CODE END 3 */
}
