_TFT_ILI9163C_func.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. // DISPLAY_DEV.setCursor(0,60);
  2. // DISPLAY_DEV.print(LCDarray1); DISPLAY_DEV.print(" "); DISPLAY_DEV.print(LCDarray2);
  3. TFT_ILI9163C DISPLAY_DEV = TFT_ILI9163C(TFT_ILI9163C_CSpin, TFT_ILI9163C_DCpin, TFT_ILI9163C__RSTpin);
  4. //defineScrollArea
  5. //scroll
  6. //startPushData(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
  7. // void pushData(uint16_t color);
  8. // void endPushData();
  9. //fillRect(int16_t x, int16_t y, int16_t w, int16_t h,uint16_t color),
  10. // setRotation(uint8_t r),
  11. //drawPixel(int16_t x, int16_t y, uint16_t color),
  12. // drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color),
  13. // drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color),
  14. /*
  15. void TFT_ILI9163C_BASE::defineScrollArea(uint16_t tfa, uint16_t bfa){
  16. tfa += __OFFSET ;
  17. int16_t vsa = _GRAMHEIGH - tfa - bfa;
  18. if (vsa >= 0) {
  19. writecommand(CMD_VSCLLDEF);
  20. writedata16(tfa);
  21. writedata16(vsa);
  22. writedata16(bfa);
  23. }
  24. }
  25. void TFT_ILI9163C_BASE::scroll(uint16_t ssa) {
  26. if (ssa <= _TFTHEIGHT) {
  27. writecommand(CMD_VSSTADRS);
  28. writedata16(ssa + __OFFSET);
  29. }
  30. }
  31. int16_t getCursorX(void) const { return cursor_x; }
  32. @brief Get text cursor Y location
  33. @returns Y coordinate in pixels
  34. int16_t getCursorY(void) const { return cursor_y; };
  35. write -
  36. tft.fillScreen();
  37. unsigned long start = micros();
  38. tft.setCursor(0, 0);
  39. tft.setTextColor(WHITE);
  40. tft.setTextSize(1);
  41. tft.println("Hello World!");
  42. tft.setTextColor(YELLOW);
  43. tft.setTextSize(2);
  44. tft.println(1234.56);
  45. tft.setTextColor(RED);
  46. tft.setTextSize(3);
  47. tft.println(0xDEAD, HEX);
  48. tft.println();
  49. tft.setTextColor(GREEN);
  50. tft.setTextSize(4);
  51. tft.println("Hello");
  52. return micros() - start;
  53. */
  54. void DISPLAY_DEV__CURSOR_Y_CHARS__SET(DISPLAY_PHYSICAL_CHAR_T &DISPLAY_PHYSICAL_CHAR_A,
  55. DISPLAY_CURSOR_Y_CHARS_T DISPLAY_CURSOR_Y_CHARS_A
  56. ) {
  57. DISPLAY_PHYSICAL_CHAR_A.DISPLAY_CURSOR_Y_CHARS_A = DISPLAY_CURSOR_Y_CHARS_A ;
  58. DISPLAY_PHYSICAL_CHAR_A.DISPLAY_CURSOR_X_CHARS_A = 0 ; //[ARDUINO_ATTR_ARRAY_S_INDEX]
  59. #if defined(ENABLE_DISPLAY_MENU)
  60. #else
  61. DISPLAY_DEV.setCursor(0,
  62. DISPLAY_PHYSICAL_CHAR_A.DISPLAY_CURSOR_Y_CHARS_A * DISPLAY_PHYSICAL_CHAR_A.DISPLAY_textsize_y_A); //[ARDUINO_ATTR_ARRAY_S_INDEX]
  63. //DISPLAY_DEV.clearScreen();
  64. DISPLAY_DEV.fillRect(0,
  65. ( DISPLAY_PHYSICAL_CHAR_A.DISPLAY_CURSOR_Y_CHARS_A + 1 ) * DISPLAY_PHYSICAL_CHAR_A.DISPLAY_textsize_y_A,
  66. DISPLAY_PHYSICAL_CHAR_A.DISPLAY_PHYSICAL_X_PX_A ,
  67. DISPLAY_PHYSICAL_CHAR_A.DISPLAY_textsize_y_A , GREEN);
  68. #endif
  69. }
  70. void DISPLAY_DEV__CURSOR__clearScreen(DISPLAY_PHYSICAL_CHAR_T &DISPLAY_PHYSICAL_CHAR_A) {
  71. #if defined(ENABLE_DISPLAY_MENU)
  72. #else
  73. DISPLAY_DEV.setCursor(0,0);
  74. //DISPLAY_DEV.clearScreen();
  75. DISPLAY_DEV.fillRect(0, 0, DISPLAY_PHYSICAL_CHAR_A.DISPLAY_PHYSICAL_X_PX_A , DISPLAY_PHYSICAL_CHAR_A.DISPLAY_textsize_y_A ,BLUE),
  76. DISPLAY_PHYSICAL_CHAR_A.DISPLAY_CURSOR_Y_CHARS_A = 0 ; //[ARDUINO_ATTR_ARRAY_S_INDEX]
  77. DISPLAY_PHYSICAL_CHAR_A.DISPLAY_CURSOR_X_CHARS_A = 0 ; //[ARDUINO_ATTR_ARRAY_S_INDEX]
  78. #endif
  79. }
  80. void DISPLAY_DEV__CURSOR__NEWLINE(DISPLAY_PHYSICAL_CHAR_T &DISPLAY_PHYSICAL_CHAR_A
  81. ) {
  82. #if defined(ENABLE_DISPLAY_MENU)
  83. #else
  84. if(DISPLAY_PHYSICAL_CHAR_A.DISPLAY_CURSOR_Y_CHARS_A + 1 >= DISPLAY_PHYSICAL_CHAR_A.DISPLAY_PHYSICAL_Y_CHARS_A) {//[ARDUINO_ATTR_ARRAY_S_INDEX]
  85. DISPLAY_DEV.setCursor(0,0);
  86. //DISPLAY_DEV.clearScreen();
  87. DISPLAY_DEV.fillRect(0, 0, DISPLAY_PHYSICAL_CHAR_A.DISPLAY_PHYSICAL_X_PX_A , DISPLAY_PHYSICAL_CHAR_A.DISPLAY_textsize_y_A ,BLUE) ;
  88. DISPLAY_PHYSICAL_CHAR_A.DISPLAY_CURSOR_Y_CHARS_A = 0 ; //[ARDUINO_ATTR_ARRAY_S_INDEX]
  89. DISPLAY_PHYSICAL_CHAR_A.DISPLAY_CURSOR_X_CHARS_A = 0 ; //[ARDUINO_ATTR_ARRAY_S_INDEX]
  90. } else {
  91. DISPLAY_PHYSICAL_CHAR_A.DISPLAY_CURSOR_Y_CHARS_A ++ ; //[ARDUINO_ATTR_ARRAY_S_INDEX]
  92. DISPLAY_PHYSICAL_CHAR_A.DISPLAY_CURSOR_X_CHARS_A = 0 ; //[ARDUINO_ATTR_ARRAY_S_INDEX]
  93. DISPLAY_DEV.setCursor(0,DISPLAY_PHYSICAL_CHAR_A.DISPLAY_CURSOR_Y_CHARS_A * DISPLAY_PHYSICAL_CHAR_A.DISPLAY_textsize_y_A); //[ARDUINO_ATTR_ARRAY_S_INDEX]
  94. DISPLAY_DEV.fillRect(0, DISPLAY_PHYSICAL_CHAR_A.DISPLAY_CURSOR_Y_CHARS_A * DISPLAY_PHYSICAL_CHAR_A.DISPLAY_textsize_y_A, DISPLAY_PHYSICAL_CHAR_A.DISPLAY_PHYSICAL_X_PX_A , DISPLAY_PHYSICAL_CHAR_A.DISPLAY_textsize_y_A ,BLUE);
  95. }
  96. #if defined(DEBUG)
  97. if(DEBUG > 6) {
  98. Serial.print("#83 Dspl Y:["); Serial.print(DISPLAY_PHYSICAL_CHAR_A.DISPLAY_CURSOR_Y_CHARS_A); //[ARDUINO_ATTR_ARRAY_S_INDEX]
  99. Serial.print("] #MaxY:["); Serial.print(DISPLAY_PHYSICAL_CHAR_A.DISPLAY_PHYSICAL_Y_CHARS_A); //[ARDUINO_ATTR_ARRAY_S_INDEX]
  100. Serial.print("] maxX:["); Serial.print(DISPLAY_PHYSICAL_CHAR_A.DISPLAY_PHYSICAL_X_CHARS_A); //[ARDUINO_ATTR_ARRAY_S_INDEX]
  101. Serial.print("] x_A:["); Serial.print(DISPLAY_PHYSICAL_CHAR_A.DISPLAY_textsize_x_A); //[ARDUINO_ATTR_ARRAY_S_INDEX]
  102. //Serial.print("] #YxF:["); Serial.print(&DISPLAY_PHYSICAL_CHAR_A.DISPLAY_CURSOR_Y_CHARS_A * DISPLAY_PHYSICAL_CHAR_A.DISPLAY_textsize_y_A); //[ARDUINO_ATTR_ARRAY_S_INDEX]
  103. Serial.println("] ");
  104. }
  105. #endif
  106. #endif
  107. }
  108. void DISPLAY_DEV_CTRL__println(DISPLAY_PHYSICAL_CHAR_T &DISPLAY_PHYSICAL_CHAR_A,
  109. #if defined(DISPLAY_array16_T_is_DISPLAY_string_T)
  110. DISPLAY_string_T DISPLAY_string_A,
  111. #else
  112. DISPLAY_array16_T DISPLAY_array16_A ,
  113. #endif
  114. DISPLAY_pos_seq_T DISPLAY_pos_seq_A
  115. ) {
  116. #if defined(ENABLE_DISPLAY_MENU)
  117. #else
  118. DISPLAY_DEV__CURSOR__NEWLINE(DISPLAY_PHYSICAL_CHAR_A) ;
  119. #if defined(DISPLAY_array16_T_is_DISPLAY_string_T)
  120. if(DISPLAY_pos_seq_A & DISPLAY_pos_seq_A_CLEARSCREEN) DISPLAY_DEV__CURSOR__clearScreen(DISPLAY_PHYSICAL_CHAR_A) ;
  121. DISPLAY_DEV.print(DISPLAY_string_A);
  122. // DISPLAY_DEV__CURSOR__NEWLINE(DISPLAY_PHYSICAL_CHAR_A) ;
  123. #else
  124. String message(DISPLAY_array16_A);
  125. #if defined(ENABLE_DISPLAY_MENU)
  126. #else
  127. if(DISPLAY_pos_seq_A & DISPLAY_pos_seq_A_CLEARSCREEN) DISPLAY_DEV__CURSOR__clearScreen(DISPLAY_PHYSICAL_CHAR_A) ;
  128. #endif
  129. int parts = floor(message.length()/ DISPLAY_PHYSICAL_CHAR_A.DISPLAY_PHYSICAL_X_CHARS_A ) ; //( message.length() + 100)
  130. if(message.length() >= DISPLAY_PHYSICAL_CHAR_A.DISPLAY_PHYSICAL_X_CHARS_A and parts == 1) parts ++;
  131. else if(parts == 0) parts = 1;
  132. int substr_begin = 0 ;
  133. int substr_end = 0 ;
  134. int i;
  135. #if defined(DEBUG)
  136. if(DEBUG > 6) {
  137. Serial.print("#34 arr16"); Serial.print(DISPLAY_array16_A);
  138. Serial.print("] #34 sizeof["); Serial.print(message.length());
  139. Serial.print("] #34 String["); Serial.print(message);
  140. Serial.print("] #34 frag"); Serial.print( message.substring(2, 5));
  141. Serial.print("] parts["); Serial.print( parts);
  142. Serial.print("] yC["); Serial.print( DISPLAY_PHYSICAL_CHAR_A.DISPLAY_CURSOR_Y_CHARS_A);
  143. Serial.println("] ");
  144. }
  145. #endif
  146. int bufi;
  147. char buf[1];
  148. for(i = 1 ; i<= parts; i++) {
  149. //myString.substring(from, to)
  150. substr_end = substr_begin + DISPLAY_PHYSICAL_CHAR_A.DISPLAY_PHYSICAL_X_CHARS_A ;
  151. DISPLAY_DEV.print(message.substring(substr_begin, substr_end));
  152. /*BUG TODO ERROR IF UNCOMMENTED*/
  153. /* for(bufi = 0; bufi <= 16; bufi++) {
  154. message.substring(substr_begin + bufi, substr_begin + bufi + 1).toCharArray(buf,1);
  155. //DISPLAY_DEV.print(buf.substring(bufi, bufi+1));
  156. DISPLAY_DEV.print(buf[0]);
  157. }
  158. */
  159. #if defined(DEBUG)
  160. if(DEBUG > 6) {
  161. Serial.print("#112 msg part["); Serial.print(i);
  162. Serial.print("] beg["); Serial.print(substr_begin);
  163. Serial.print("] end["); Serial.print(substr_end);
  164. Serial.print("] frag["); Serial.print(message.substring(substr_begin, substr_end));
  165. Serial.print("] yC["); Serial.print( DISPLAY_PHYSICAL_CHAR_A.DISPLAY_PHYSICAL_X_CHARS_A);
  166. Serial.println("] ");
  167. }
  168. #endif
  169. substr_begin = substr_end + 1;
  170. if( parts >= 1 and not(parts == i)) {
  171. DISPLAY_DEV__CURSOR__NEWLINE(DISPLAY_PHYSICAL_CHAR_A) ;
  172. } //else if(i == parts) {
  173. // DISPLAY_DEV__CURSOR__NEWLINE(DISPLAY_PHYSICAL_CHAR_A) ;
  174. // }
  175. }
  176. /*BUG TODO ERROR IF UNCOMMENTED
  177. // Serial.end(); // Ends the serial communication once all data is received
  178. //Serial.begin(115200);
  179. // delay(400);
  180. // if (Serial.available()) Serial.write("aaaa49 ");
  181. //delay(100);
  182. // if (Serial.available()) Serial.println("bbbb49 ");
  183. // else Serial.println("cccc49 ");
  184. */
  185. #endif
  186. #endif
  187. }