My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

tft_spi.h 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. #pragma once
  23. #include "../../../inc/MarlinConfig.h"
  24. #include <SPI.h>
  25. #ifndef LCD_READ_ID
  26. #define LCD_READ_ID 0x04 // Read display identification information (0xD3 on ILI9341)
  27. #endif
  28. #ifndef LCD_READ_ID4
  29. #define LCD_READ_ID4 0xD3 // Read display identification information (0xD3 on ILI9341)
  30. #endif
  31. #define DATASIZE_8BIT DATA_SIZE_8BIT
  32. #define DATASIZE_16BIT DATA_SIZE_16BIT
  33. #define TFT_IO_DRIVER TFT_SPI
  34. #define DMA_MINC_ENABLE 1
  35. #define DMA_MINC_DISABLE 0
  36. class TFT_SPI {
  37. private:
  38. static uint32_t ReadID(uint16_t Reg);
  39. static void Transmit(uint16_t Data);
  40. static void TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Count);
  41. public:
  42. static SPIClass SPIx;
  43. static void Init();
  44. static uint32_t GetID();
  45. static bool isBusy();
  46. static void Abort();
  47. static void DataTransferBegin(uint16_t DataWidth = DATA_SIZE_16BIT);
  48. static void DataTransferEnd() { WRITE(TFT_CS_PIN, HIGH); SPIx.end(); };
  49. static void DataTransferAbort();
  50. static void WriteData(uint16_t Data) { Transmit(Data); }
  51. static void WriteReg(uint16_t Reg) { WRITE(TFT_A0_PIN, LOW); Transmit(Reg); WRITE(TFT_A0_PIN, HIGH); }
  52. static void WriteSequence(uint16_t *Data, uint16_t Count) { TransmitDMA(DMA_MINC_ENABLE, Data, Count); }
  53. static void WriteMultiple(uint16_t Color, uint16_t Count) { static uint16_t Data; Data = Color; TransmitDMA(DMA_MINC_DISABLE, &Data, Count); }
  54. static void WriteMultiple(uint16_t Color, uint32_t Count) {
  55. static uint16_t Data; Data = Color;
  56. while (Count > 0) {
  57. TransmitDMA(DMA_MINC_DISABLE, &Data, Count > 0xFFFF ? 0xFFFF : Count);
  58. Count = Count > 0xFFFF ? Count - 0xFFFF : 0;
  59. }
  60. }
  61. };