PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

175 lines
3.9KB

  1. // *** Hardwarespecific functions ***
  2. void UTFT::_hw_special_init()
  3. {
  4. }
  5. void UTFT::LCD_Writ_Bus(char VH,char VL, byte mode)
  6. {
  7. switch (mode)
  8. {
  9. case 1:
  10. if (display_serial_mode==SERIAL_4PIN)
  11. {
  12. if (VH==1)
  13. sbi(P_SDA, B_SDA);
  14. else
  15. cbi(P_SDA, B_SDA);
  16. pulse_low(P_SCL, B_SCL);
  17. }
  18. else
  19. {
  20. if (VH==1)
  21. sbi(P_RS, B_RS);
  22. else
  23. cbi(P_RS, B_RS);
  24. }
  25. if (VL & 0x80)
  26. sbi(P_SDA, B_SDA);
  27. else
  28. cbi(P_SDA, B_SDA);
  29. pulse_low(P_SCL, B_SCL);
  30. if (VL & 0x40)
  31. sbi(P_SDA, B_SDA);
  32. else
  33. cbi(P_SDA, B_SDA);
  34. pulse_low(P_SCL, B_SCL);
  35. if (VL & 0x20)
  36. sbi(P_SDA, B_SDA);
  37. else
  38. cbi(P_SDA, B_SDA);
  39. pulse_low(P_SCL, B_SCL);
  40. if (VL & 0x10)
  41. sbi(P_SDA, B_SDA);
  42. else
  43. cbi(P_SDA, B_SDA);
  44. pulse_low(P_SCL, B_SCL);
  45. if (VL & 0x08)
  46. sbi(P_SDA, B_SDA);
  47. else
  48. cbi(P_SDA, B_SDA);
  49. pulse_low(P_SCL, B_SCL);
  50. if (VL & 0x04)
  51. sbi(P_SDA, B_SDA);
  52. else
  53. cbi(P_SDA, B_SDA);
  54. pulse_low(P_SCL, B_SCL);
  55. if (VL & 0x02)
  56. sbi(P_SDA, B_SDA);
  57. else
  58. cbi(P_SDA, B_SDA);
  59. pulse_low(P_SCL, B_SCL);
  60. if (VL & 0x01)
  61. sbi(P_SDA, B_SDA);
  62. else
  63. cbi(P_SDA, B_SDA);
  64. pulse_low(P_SCL, B_SCL);
  65. break;
  66. case 8:
  67. LATECLR = 0xFF;
  68. LATESET = VH;
  69. *P_WR &= ~B_WR;
  70. *P_WR |= B_WR;
  71. LATECLR = 0xFF;
  72. LATESET = VL;
  73. *P_WR &= ~B_WR;
  74. *P_WR |= B_WR;
  75. break;
  76. case 16:
  77. LATDCLR = 0xFF;
  78. LATDSET = VL & 0xFF;
  79. LATECLR = 0xFF;
  80. LATESET = VH & 0xFF;
  81. *P_WR &= ~B_WR;
  82. *P_WR |= B_WR;
  83. break;
  84. case LATCHED_16:
  85. asm("nop"); // Mode is unsupported
  86. break;
  87. }
  88. }
  89. void UTFT::_set_direction_registers(byte mode)
  90. {
  91. if (mode!=LATCHED_16)
  92. {
  93. TRISE=0;
  94. if (mode==16)
  95. TRISD=0;
  96. }
  97. else
  98. {
  99. asm("nop"); // Mode is unsupported
  100. }
  101. }
  102. void UTFT::_fast_fill_16(int ch, int cl, long pix)
  103. {
  104. long blocks;
  105. LATDCLR = 0xFF;
  106. LATDSET = cl & 0xFF;
  107. LATECLR = 0xFF;
  108. LATESET = ch & 0xFF;
  109. blocks = pix/16;
  110. for (int i=0; i<blocks; i++)
  111. {
  112. *P_WR &= ~B_WR; *P_WR |= B_WR;
  113. *P_WR &= ~B_WR; *P_WR |= B_WR;
  114. *P_WR &= ~B_WR; *P_WR |= B_WR;
  115. *P_WR &= ~B_WR; *P_WR |= B_WR;
  116. *P_WR &= ~B_WR; *P_WR |= B_WR;
  117. *P_WR &= ~B_WR; *P_WR |= B_WR;
  118. *P_WR &= ~B_WR; *P_WR |= B_WR;
  119. *P_WR &= ~B_WR; *P_WR |= B_WR;
  120. *P_WR &= ~B_WR; *P_WR |= B_WR;
  121. *P_WR &= ~B_WR; *P_WR |= B_WR;
  122. *P_WR &= ~B_WR; *P_WR |= B_WR;
  123. *P_WR &= ~B_WR; *P_WR |= B_WR;
  124. *P_WR &= ~B_WR; *P_WR |= B_WR;
  125. *P_WR &= ~B_WR; *P_WR |= B_WR;
  126. *P_WR &= ~B_WR; *P_WR |= B_WR;
  127. *P_WR &= ~B_WR; *P_WR |= B_WR;
  128. }
  129. if ((pix % 16) != 0)
  130. for (int i=0; i<(pix % 16)+1; i++)
  131. {
  132. *P_WR &= ~B_WR; *P_WR |= B_WR;
  133. }
  134. }
  135. void UTFT::_fast_fill_8(int ch, long pix)
  136. {
  137. long blocks;
  138. LATECLR = 0xFF;
  139. LATESET = ch;
  140. blocks = pix/16;
  141. for (int i=0; i<blocks; i++)
  142. {
  143. *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR;
  144. *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR;
  145. *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR;
  146. *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR;
  147. *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR;
  148. *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR;
  149. *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR;
  150. *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR;
  151. *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR;
  152. *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR;
  153. *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR;
  154. *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR;
  155. *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR;
  156. *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR;
  157. *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR;
  158. *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR;
  159. }
  160. if ((pix % 16) != 0)
  161. for (int i=0; i<(pix % 16)+1; i++)
  162. {
  163. *P_WR &= ~B_WR; *P_WR |= B_WR; *P_WR &= ~B_WR; *P_WR |= B_WR;
  164. }
  165. }