My Marlin configs for Fabrikator Mini and CTC i3 Pro B
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.

SPI_TFT.cpp 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #include "../../../inc/MarlinConfigPre.h"
  23. #if HAS_TFT_LVGL_UI
  24. #include "SPI_TFT.h"
  25. #include "pic_manager.h"
  26. #include "tft_lvgl_configuration.h"
  27. #include "../../../inc/MarlinConfig.h"
  28. #include <SPI.h>
  29. #include "draw_ui.h"
  30. TFT SPI_TFT;
  31. // use SPI1 for the spi tft.
  32. void TFT::spi_init(uint8_t spiRate) {
  33. tftio.Init();
  34. }
  35. void TFT::SetPoint(uint16_t x, uint16_t y, uint16_t point) {
  36. if ((x > 480) || (y > 320)) return;
  37. setWindow(x, y, 1, 1);
  38. tftio.WriteMultiple(point, (uint16_t)1);
  39. }
  40. void TFT::setWindow(uint16_t x, uint16_t y, uint16_t with, uint16_t height) {
  41. tftio.set_window(x, y, (x + with - 1), (y + height - 1));
  42. }
  43. void TFT::LCD_init() {
  44. tftio.InitTFT();
  45. #if PIN_EXISTS(TFT_BACKLIGHT)
  46. OUT_WRITE(TFT_BACKLIGHT_PIN, LOW);
  47. #endif
  48. delay(100);
  49. LCD_clear(0x0000);
  50. LCD_Draw_Logo();
  51. #if PIN_EXISTS(TFT_BACKLIGHT)
  52. OUT_WRITE(TFT_BACKLIGHT_PIN, HIGH);
  53. #endif
  54. #if HAS_LOGO_IN_FLASH
  55. delay(2000);
  56. #endif
  57. }
  58. void TFT::LCD_clear(uint16_t color) {
  59. setWindow(0, 0, TFT_WIDTH, TFT_HEIGHT);
  60. tftio.WriteMultiple(color, uint32_t(TFT_WIDTH) * uint32_t(TFT_HEIGHT));
  61. }
  62. void TFT::LCD_Draw_Logo() {
  63. #if HAS_LOGO_IN_FLASH
  64. setWindow(0, 0, TFT_WIDTH, TFT_HEIGHT);
  65. for (uint16_t i = 0; i < (TFT_HEIGHT); i++) {
  66. Pic_Logo_Read((uint8_t *)"", (uint8_t *)bmp_public_buf, (TFT_WIDTH) * 2);
  67. tftio.WriteSequence((uint16_t *)bmp_public_buf, TFT_WIDTH);
  68. }
  69. #endif
  70. }
  71. #endif // HAS_TFT_LVGL_UI