luat_lcd_jd9261t.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include "luat_base.h"
  2. #include "luat_lcd.h"
  3. #include "luat_gpio.h"
  4. #include "luat_mem.h"
  5. #include "luat_rtos.h"
  6. #include "luat_i2c.h"
  7. #define LUAT_LOG_TAG "jd9261t-lcd"
  8. #include "luat_log.h"
  9. static int jd9261t_inited_init(luat_lcd_conf_t* conf)
  10. {
  11. if (!conf->buff)
  12. {
  13. conf->buff = luat_heap_opt_zalloc(LUAT_HEAP_AUTO, conf->w * conf->h * ((conf->bpp <= 16)?2:4));
  14. conf->flush_y_min = conf->h;
  15. conf->flush_y_max = 0;
  16. }
  17. luat_lcd_qspi_conf_t auto_flush =
  18. {
  19. .write_4line_cmd = 0xde,
  20. .vsync_reg = 0x61,
  21. .hsync_cmd = 0xde,
  22. .hsync_reg = 0x60,
  23. .write_1line_cmd = 0xde,
  24. };
  25. luat_gpio_set(conf->pin_rst, Luat_GPIO_LOW);
  26. // luat_rtos_task_sleep(5);
  27. // luat_gpio_set(conf->tp_pin_rst, Luat_GPIO_HIGH);
  28. luat_rtos_task_sleep(5);
  29. luat_gpio_set(conf->pin_rst, Luat_GPIO_HIGH);
  30. // luat_gpio_set(conf->tp_pin_rst, Luat_GPIO_LOW);
  31. // luat_rtos_task_sleep(50);
  32. // luat_gpio_set(conf->tp_pin_rst, Luat_GPIO_HIGH);
  33. // luat_rtos_task_sleep(100);
  34. luat_rtos_task_sleep(150);
  35. luat_lcd_qspi_config(conf, &auto_flush); //必须在第一个命令发送前就准备好
  36. luat_lcd_set_direction(conf,conf->direction);
  37. luat_rtos_task_sleep(5);
  38. luat_gpio_set(conf->pin_pwr, Luat_GPIO_HIGH);
  39. luat_lcd_qspi_auto_flush_on_off(conf, 1);
  40. return 0;
  41. }
  42. luat_lcd_opts_t lcd_opts_jd9261t_inited = {
  43. .name = "jd9261t_inited",
  44. .sleep_cmd = 0xff, //不需要发命令
  45. .wakeup_cmd = 0xff, //不需要发命令
  46. .init_cmds_len = 0,
  47. .init_cmds = NULL,
  48. .direction0 = 0x00,
  49. .direction90 = 0x00,
  50. .direction180 = 0x03,
  51. .direction270 = 0x03,
  52. .rb_swap = 1,
  53. .no_ram_mode = 1,
  54. .user_ctrl_init = jd9261t_inited_init,
  55. };