You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

153 lines
4.9 KiB

3 years ago
  1. // Copyright 2020 Espressif Systems (Shanghai) Co. Ltd.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #include "sdkconfig.h"
  15. #include <string.h>
  16. #include "screen_driver.h"
  17. #include "esp_log.h"
  18. static const char *TAG = "screen driver";
  19. #define LCD_CHECK(a, str, ret) if(!(a)) { \
  20. ESP_LOGE(TAG,"%s:%d (%s):%s", __FILE__, __LINE__, __FUNCTION__, str); \
  21. return (ret); \
  22. }
  23. /**
  24. * Define screen instance
  25. */
  26. /**< Colorful screen */
  27. #ifdef CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_ILI9341
  28. extern scr_driver_t lcd_ili9341_default_driver;
  29. #endif
  30. #ifdef CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_ILI9486
  31. extern scr_driver_t lcd_ili9486_default_driver;
  32. #endif
  33. #ifdef CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_ILI9806
  34. extern scr_driver_t lcd_ili9806_default_driver;
  35. #endif
  36. #ifdef CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_ILI9488
  37. extern scr_driver_t lcd_ili9488_default_driver;
  38. #endif
  39. #ifdef CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_NT35510
  40. extern scr_driver_t lcd_nt35510_default_driver;
  41. #endif
  42. #ifdef CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_RM68120
  43. extern scr_driver_t lcd_rm68120_default_driver;
  44. #endif
  45. #ifdef CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_SSD1351
  46. extern scr_driver_t lcd_ssd1351_default_driver;
  47. #endif
  48. #ifdef CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_SSD1963
  49. extern scr_driver_t lcd_ssd1963_default_driver;
  50. #endif
  51. #ifdef CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_ST7789
  52. extern scr_driver_t lcd_st7789_default_driver;
  53. #endif
  54. #ifdef CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_ST7796
  55. extern scr_driver_t lcd_st7796_default_driver;
  56. #endif
  57. /**< Monochrome screen */
  58. #ifdef CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_SSD1306
  59. extern scr_driver_t lcd_ssd1306_default_driver;
  60. #endif
  61. #ifdef CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_SSD1307
  62. extern scr_driver_t lcd_ssd1307_default_driver;
  63. #endif
  64. #ifdef CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_SSD1322
  65. extern scr_driver_t lcd_ssd1322_default_driver;
  66. #endif
  67. esp_err_t scr_find_driver(scr_controller_t controller, scr_driver_t *out_screen)
  68. {
  69. LCD_CHECK(NULL != out_screen, "Pointer of screen is invalid", ESP_ERR_INVALID_ARG);
  70. esp_err_t ret = ESP_OK;
  71. switch (controller) {
  72. /**< Colorful screen */
  73. #ifdef CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_ILI9341
  74. case SCREEN_CONTROLLER_ILI9341:
  75. *out_screen = lcd_ili9341_default_driver;
  76. break;
  77. #endif
  78. #ifdef CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_ILI9806
  79. case SCREEN_CONTROLLER_ILI9806:
  80. *out_screen = lcd_ili9806_default_driver;
  81. break;
  82. #endif
  83. #ifdef CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_ILI9486
  84. case SCREEN_CONTROLLER_ILI9486:
  85. *out_screen = lcd_ili9486_default_driver;
  86. break;
  87. #endif
  88. #ifdef CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_ILI9488
  89. case SCREEN_CONTROLLER_ILI9488:
  90. *out_screen = lcd_ili9488_default_driver;
  91. break;
  92. #endif
  93. #ifdef CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_NT35510
  94. case SCREEN_CONTROLLER_NT35510:
  95. *out_screen = lcd_nt35510_default_driver;
  96. break;
  97. #endif
  98. #ifdef CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_RM68120
  99. case SCREEN_CONTROLLER_RM68120:
  100. *out_screen = lcd_rm68120_default_driver;
  101. break;
  102. #endif
  103. #ifdef CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_ST7789
  104. case SCREEN_CONTROLLER_ST7789:
  105. *out_screen = lcd_st7789_default_driver;
  106. break;
  107. #endif
  108. #ifdef CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_ST7796
  109. case SCREEN_CONTROLLER_ST7796:
  110. *out_screen = lcd_st7796_default_driver;
  111. break;
  112. #endif
  113. #ifdef CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_SSD1351
  114. case SCREEN_CONTROLLER_SSD1351:
  115. *out_screen = lcd_ssd1351_default_driver;
  116. break;
  117. #endif
  118. #ifdef CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_SSD1963
  119. case SCREEN_CONTROLLER_SSD1963:
  120. *out_screen = lcd_ssd1963_default_driver;
  121. break;
  122. #endif
  123. /**< Monochrome screen */
  124. #ifdef CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_SSD1306
  125. case SCREEN_CONTROLLER_SSD1306:
  126. *out_screen = lcd_ssd1306_default_driver;
  127. break;
  128. #endif
  129. #ifdef CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_SSD1307
  130. case SCREEN_CONTROLLER_SSD1307:
  131. *out_screen = lcd_ssd1307_default_driver;
  132. break;
  133. #endif
  134. #ifdef CONFIG_LCD_DRIVER_SCREEN_CONTROLLER_SSD1322
  135. case SCREEN_CONTROLLER_SSD1322:
  136. *out_screen = lcd_ssd1322_default_driver;
  137. break;
  138. #endif
  139. default:
  140. ESP_LOGE(TAG, "Not support screen controller, it may not be enabled in menuconfig");
  141. ret = ESP_ERR_NOT_FOUND;
  142. break;
  143. }
  144. return ret;
  145. }