Display.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  1. #include "Display.h"
  2. /*
  3. Big thanks to bodmer for having great TFT and JPEG libraries
  4. https://github.com/bodmer
  5. */
  6. Display::Display()
  7. {
  8. }
  9. // Function to prepare the display and the menus
  10. void Display::RunSetup()
  11. {
  12. run_setup = false;
  13. // Need to declare new
  14. display_buffer = new LinkedList<String>();
  15. tft.init();
  16. tft.setRotation(0); // Portrait
  17. tft.setCursor(0, 0);
  18. //tft.setFreeFont(&FreeMonoBold9pt7b);
  19. // Calibration data
  20. //uint16_t calData[5] = { 390, 3516, 253, 3520, 7 }; tft.setRotation(1); // Portrait
  21. #ifdef TFT_SHIELD
  22. uint16_t calData[5] = { 275, 3494, 361, 3528, 4 }; // tft.setRotation(0); // Portrait with TFT Shield
  23. Serial.println("Using TFT Shield");
  24. #else if defined(TFT_DIY)
  25. uint16_t calData[5] = { 339, 3470, 237, 3438, 2 }; // tft.setRotation(0); // Portrait with DIY TFT
  26. Serial.println("Using TFT DIY");
  27. #endif
  28. tft.setTouch(calData);
  29. //tft.fillScreen(TFT_BLACK);
  30. clearScreen();
  31. // Initialize file system
  32. // This should probably have its own class
  33. if (!SPIFFS.begin()) {
  34. Serial.println("SPIFFS initialisation failed!");
  35. while (1) yield(); // Stay here twiddling thumbs waiting
  36. }
  37. // Draw the title screen
  38. drawJpeg("/marauder3L.jpg", 0 , 0); // 240 x 320 image
  39. //showCenterText(version_number, 250);
  40. tft.drawCentreString(version_number, 120, 250, 2);
  41. digitalWrite(TFT_BL, HIGH);
  42. delay(5000);
  43. }
  44. void Display::tftDrawGraphObjects(byte x_scale)
  45. {
  46. //draw the graph objects
  47. tft.fillRect(11, 5, x_scale+1, 120, TFT_BLACK); // positive start point
  48. tft.fillRect(11, 121, x_scale+1, 119, TFT_BLACK); // negative start point
  49. tft.drawFastVLine(10, 5, 230, TFT_WHITE); // y axis
  50. tft.drawFastHLine(10, HEIGHT_1 - 1, 310, TFT_WHITE); // x axis
  51. tft.setTextColor(TFT_YELLOW); tft.setTextSize(1); // set parameters for y axis labels
  52. //tft.setCursor(3, 116); tft.print(midway); // "0" at center of ya axis
  53. tft.setCursor(3, 6); tft.print("+"); // "+' at top of y axis
  54. tft.setCursor(3, 228); tft.print("0"); // "-" at bottom of y axis
  55. }
  56. void Display::tftDrawColorKey()
  57. {
  58. //Display color key
  59. tft.setTextSize(1); tft.setTextColor(TFT_WHITE);
  60. tft.fillRect(14, 0, 15, 8, TFT_GREEN); tft.setCursor(30, 0); tft.print(" - Beacons");
  61. tft.fillRect(14, 8, 15, 8, TFT_RED); tft.setCursor(30, 8); tft.print(" - Deauths");
  62. tft.fillRect(14, 16, 15, 8, TFT_BLUE); tft.setCursor(30, 16); tft.print(" - Probes");
  63. }
  64. void Display::tftDrawXScaleButtons(byte x_scale)
  65. {
  66. tft.drawFastVLine(234, 0, 20, TFT_WHITE);
  67. tft.setCursor(208, 21); tft.setTextColor(TFT_WHITE); tft.setTextSize(1); tft.print("X Scale:"); tft.print(x_scale);
  68. key[0].initButton(&tft, // x - box
  69. 220,
  70. 10, // x, y, w, h, outline, fill, text
  71. 20,
  72. 20,
  73. TFT_BLACK, // Outline
  74. TFT_CYAN, // Fill
  75. TFT_BLACK, // Text
  76. "-",
  77. 2);
  78. key[1].initButton(&tft, // x + box
  79. 249,
  80. 10, // x, y, w, h, outline, fill, text
  81. 20,
  82. 20,
  83. TFT_BLACK, // Outline
  84. TFT_CYAN, // Fill
  85. TFT_BLACK, // Text
  86. "+",
  87. 2);
  88. key[0].setLabelDatum(1, 5, MC_DATUM);
  89. key[1].setLabelDatum(1, 5, MC_DATUM);
  90. key[0].drawButton();
  91. key[1].drawButton();
  92. }
  93. void Display::tftDrawYScaleButtons(byte y_scale)
  94. {
  95. tft.drawFastVLine(290, 0, 20, TFT_WHITE);
  96. tft.setCursor(265, 21); tft.setTextColor(TFT_WHITE); tft.setTextSize(1); tft.print("Y Scale:"); tft.print(y_scale);
  97. key[2].initButton(&tft, // y - box
  98. 276,
  99. 10, // x, y, w, h, outline, fill, text
  100. 20,
  101. 20,
  102. TFT_BLACK, // Outline
  103. TFT_MAGENTA, // Fill
  104. TFT_BLACK, // Text
  105. "-",
  106. 2);
  107. key[3].initButton(&tft, // y + box
  108. 305,
  109. 10, // x, y, w, h, outline, fill, text
  110. 20,
  111. 20,
  112. TFT_BLACK, // Outline
  113. TFT_MAGENTA, // Fill
  114. TFT_BLACK, // Text
  115. "+",
  116. 2);
  117. key[2].setLabelDatum(1, 5, MC_DATUM);
  118. key[3].setLabelDatum(1, 5, MC_DATUM);
  119. key[2].drawButton();
  120. key[3].drawButton();
  121. }
  122. void Display::tftDrawChannelScaleButtons(int set_channel)
  123. {
  124. tft.drawFastVLine(178, 0, 20, TFT_WHITE);
  125. tft.setCursor(145, 21); tft.setTextColor(TFT_WHITE); tft.setTextSize(1); tft.print("Channel:"); tft.print(set_channel);
  126. key[4].initButton(&tft, // channel - box
  127. 164,
  128. 10, // x, y, w, h, outline, fill, text
  129. 20,
  130. 20,
  131. TFT_BLACK, // Outline
  132. TFT_BLUE, // Fill
  133. TFT_BLACK, // Text
  134. "-",
  135. 2);
  136. key[5].initButton(&tft, // channel + box
  137. 193,
  138. 10, // x, y, w, h, outline, fill, text
  139. 20,
  140. 20,
  141. TFT_BLACK, // Outline
  142. TFT_BLUE, // Fill
  143. TFT_BLACK, // Text
  144. "+",
  145. 2);
  146. key[4].setLabelDatum(1, 5, MC_DATUM);
  147. key[5].setLabelDatum(1, 5, MC_DATUM);
  148. key[4].drawButton();
  149. key[5].drawButton();
  150. }
  151. void Display::tftDrawExitScaleButtons()
  152. {
  153. //tft.drawFastVLine(178, 0, 20, TFT_WHITE);
  154. //tft.setCursor(145, 21); tft.setTextColor(TFT_WHITE); tft.setTextSize(1); tft.print("Channel:"); tft.print(set_channel);
  155. key[6].initButton(&tft, // Exit box
  156. 137,
  157. 10, // x, y, w, h, outline, fill, text
  158. 20,
  159. 20,
  160. TFT_ORANGE, // Outline
  161. TFT_RED, // Fill
  162. TFT_BLACK, // Text
  163. "X",
  164. 2);
  165. key[6].setLabelDatum(1, 5, MC_DATUM);
  166. key[6].drawButton();
  167. }
  168. void Display::twoPartDisplay(String center_text)
  169. {
  170. tft.setTextColor(TFT_BLACK, TFT_YELLOW);
  171. tft.fillRect(0,16,HEIGHT_1,144, TFT_YELLOW);
  172. //tft.drawCentreString(center_text,120,82,1);
  173. tft.setTextWrap(true);
  174. tft.setFreeFont(NULL);
  175. //showCenterText(center_text, 82);
  176. //tft.drawCentreString(center_text,120,82,1);
  177. tft.setCursor(0, 82);
  178. tft.println(center_text);
  179. tft.setFreeFont(MENU_FONT);
  180. tft.setTextWrap(false);
  181. }
  182. void Display::touchToExit()
  183. {
  184. tft.setTextColor(TFT_BLACK, TFT_LIGHTGREY);
  185. tft.fillRect(0,16,HEIGHT_1,16, TFT_LIGHTGREY);
  186. tft.drawCentreString("Touch screen to exit",120,16,2);
  187. }
  188. // Function to just draw the screen black
  189. void Display::clearScreen()
  190. {
  191. Serial.println("clearScreen()");
  192. tft.fillScreen(TFT_BLACK);
  193. tft.setCursor(0, 0);
  194. }
  195. void Display::displayBuffer(bool do_clear)
  196. {
  197. if (this->display_buffer->size() > 0)
  198. {
  199. delay(1);
  200. while (display_buffer->size() > 0)
  201. {
  202. xPos = 0;
  203. if ((display_buffer->size() > 0) && (!loading))
  204. {
  205. printing = true;
  206. delay(print_delay_1);
  207. yDraw = scroll_line(TFT_RED);
  208. tft.setCursor(xPos, yDraw);
  209. tft.print(display_buffer->shift());
  210. printing = false;
  211. delay(print_delay_2);
  212. }
  213. if (!tteBar)
  214. blank[(18+(yStart - TOP_FIXED_AREA) / TEXT_HEIGHT)%19] = xPos;
  215. else
  216. blank[(18+(yStart - TOP_FIXED_AREA_2) / TEXT_HEIGHT)%19] = xPos;
  217. }
  218. }
  219. }
  220. void Display::showCenterText(String text, int y)
  221. {
  222. tft.setCursor((SCREEN_WIDTH - (text.length() * 6)) / 2, y);
  223. tft.println(text);
  224. }
  225. void Display::initScrollValues(bool tte)
  226. {
  227. Serial.println("initScrollValues()");
  228. yDraw = YMAX - BOT_FIXED_AREA - TEXT_HEIGHT;
  229. xPos = 0;
  230. if (!tte)
  231. {
  232. yStart = TOP_FIXED_AREA;
  233. yArea = YMAX - TOP_FIXED_AREA - BOT_FIXED_AREA;
  234. }
  235. else
  236. {
  237. yStart = TOP_FIXED_AREA_2;
  238. yArea = YMAX - TOP_FIXED_AREA_2 - BOT_FIXED_AREA;
  239. }
  240. for(int i = 0; i < 18; i++) blank[i] = 0;
  241. }
  242. // Function to execute hardware scroll for TFT screen
  243. int Display::scroll_line(uint32_t color) {
  244. //Serial.println("scroll_line()");
  245. int yTemp = yStart; // Store the old yStart, this is where we draw the next line
  246. // Use the record of line lengths to optimise the rectangle size we need to erase the top line
  247. // Check if we have the "touch to exit bar"
  248. if (!tteBar)
  249. {
  250. tft.fillRect(0,yStart,blank[(yStart-TOP_FIXED_AREA)/TEXT_HEIGHT],TEXT_HEIGHT, color);
  251. // Change the top of the scroll area
  252. yStart+=TEXT_HEIGHT;
  253. // The value must wrap around as the screen memory is a circular buffer
  254. if (yStart >= YMAX - BOT_FIXED_AREA) yStart = TOP_FIXED_AREA + (yStart - YMAX + BOT_FIXED_AREA);
  255. }
  256. else
  257. {
  258. tft.fillRect(0,yStart,blank[(yStart-TOP_FIXED_AREA_2)/TEXT_HEIGHT],TEXT_HEIGHT, color);
  259. // Change the top of the scroll area
  260. yStart+=TEXT_HEIGHT;
  261. // The value must wrap around as the screen memory is a circular buffer
  262. if (yStart >= YMAX - BOT_FIXED_AREA) yStart = TOP_FIXED_AREA_2 + (yStart - YMAX + BOT_FIXED_AREA);
  263. }
  264. // Now we can scroll the display
  265. scrollAddress(yStart);
  266. return yTemp;
  267. }
  268. // Function to setup hardware scroll for TFT screen
  269. void Display::setupScrollArea(uint16_t tfa, uint16_t bfa) {
  270. Serial.println("setupScrollAread()");
  271. tft.writecommand(ILI9341_VSCRDEF); // Vertical scroll definition
  272. tft.writedata(tfa >> 8); // Top Fixed Area line count
  273. tft.writedata(tfa);
  274. tft.writedata((YMAX-tfa-bfa)>>8); // Vertical Scrolling Area line count
  275. tft.writedata(YMAX-tfa-bfa);
  276. tft.writedata(bfa >> 8); // Bottom Fixed Area line count
  277. tft.writedata(bfa);
  278. }
  279. void Display::scrollAddress(uint16_t vsp) {
  280. tft.writecommand(ILI9341_VSCRSADD); // Vertical scrolling pointer
  281. tft.writedata(vsp>>8);
  282. tft.writedata(vsp);
  283. }
  284. // JPEG_functions
  285. void Display::drawJpeg(const char *filename, int xpos, int ypos) {
  286. // Open the named file (the Jpeg decoder library will close it after rendering image)
  287. fs::File jpegFile = SPIFFS.open( filename, "r"); // File handle reference for SPIFFS
  288. //ESP32 always seems to return 1 for jpegFile so this null trap does not work
  289. if ( !jpegFile ) {
  290. Serial.print("ERROR: File \""); Serial.print(filename); Serial.println ("\" not found!");
  291. return;
  292. }
  293. // Use one of the three following methods to initialise the decoder,
  294. // the filename can be a String or character array type:
  295. boolean decoded = JpegDec.decodeFsFile(filename); // or pass the filename (leading / distinguishes SPIFFS files)
  296. if (decoded) {
  297. // print information about the image to the serial port
  298. jpegInfo();
  299. // render the image onto the screen at given coordinates
  300. jpegRender(xpos, ypos);
  301. }
  302. else {
  303. Serial.println("Jpeg file format not supported!");
  304. }
  305. }
  306. void Display::drawStylus()
  307. {
  308. uint16_t x = 0, y = 0; // To store the touch coordinates
  309. // Pressed will be set true is there is a valid touch on the screen
  310. boolean pressed = tft.getTouch(&x, &y);
  311. // Draw a white spot at the detected coordinates
  312. if (pressed) {
  313. tft.fillCircle(x, y, 2, TFT_WHITE);
  314. //Serial.print("x,y = ");
  315. //Serial.print(x);
  316. //Serial.print(",");
  317. //Serial.println(y);
  318. }
  319. }
  320. //====================================================================================
  321. // Decode and render the Jpeg image onto the TFT screen
  322. //====================================================================================
  323. void Display::jpegRender(int xpos, int ypos) {
  324. // retrieve infomration about the image
  325. uint16_t *pImg;
  326. int16_t mcu_w = JpegDec.MCUWidth;
  327. int16_t mcu_h = JpegDec.MCUHeight;
  328. int32_t max_x = JpegDec.width;
  329. int32_t max_y = JpegDec.height;
  330. // Jpeg images are draw as a set of image block (tiles) called Minimum Coding Units (MCUs)
  331. // Typically these MCUs are 16x16 pixel blocks
  332. // Determine the width and height of the right and bottom edge image blocks
  333. int32_t min_w = minimum(mcu_w, max_x % mcu_w);
  334. int32_t min_h = minimum(mcu_h, max_y % mcu_h);
  335. // save the current image block size
  336. int32_t win_w = mcu_w;
  337. int32_t win_h = mcu_h;
  338. // record the current time so we can measure how long it takes to draw an image
  339. uint32_t drawTime = millis();
  340. // save the coordinate of the right and bottom edges to assist image cropping
  341. // to the screen size
  342. max_x += xpos;
  343. max_y += ypos;
  344. // read each MCU block until there are no more
  345. while ( JpegDec.readSwappedBytes()) { // Swapped byte order read
  346. // save a pointer to the image block
  347. pImg = JpegDec.pImage;
  348. // calculate where the image block should be drawn on the screen
  349. int mcu_x = JpegDec.MCUx * mcu_w + xpos; // Calculate coordinates of top left corner of current MCU
  350. int mcu_y = JpegDec.MCUy * mcu_h + ypos;
  351. // check if the image block size needs to be changed for the right edge
  352. if (mcu_x + mcu_w <= max_x) win_w = mcu_w;
  353. else win_w = min_w;
  354. // check if the image block size needs to be changed for the bottom edge
  355. if (mcu_y + mcu_h <= max_y) win_h = mcu_h;
  356. else win_h = min_h;
  357. // copy pixels into a contiguous block
  358. if (win_w != mcu_w)
  359. {
  360. for (int h = 1; h < win_h-1; h++)
  361. {
  362. memcpy(pImg + h * win_w, pImg + (h + 1) * mcu_w, win_w << 1);
  363. }
  364. }
  365. // draw image MCU block only if it will fit on the screen
  366. if ( mcu_x < tft.width() && mcu_y < tft.height())
  367. {
  368. // Now push the image block to the screen
  369. tft.pushImage(mcu_x, mcu_y, win_w, win_h, pImg);
  370. }
  371. else if ( ( mcu_y + win_h) >= tft.height()) JpegDec.abort();
  372. }
  373. // calculate how long it took to draw the image
  374. drawTime = millis() - drawTime; // Calculate the time it took
  375. }
  376. //====================================================================================
  377. // Print information decoded from the Jpeg image
  378. //====================================================================================
  379. void Display::jpegInfo() {
  380. /*
  381. Serial.println("===============");
  382. Serial.println("JPEG image info");
  383. Serial.println("===============");
  384. Serial.print ("Width :"); Serial.println(JpegDec.width);
  385. Serial.print ("Height :"); Serial.println(JpegDec.height);
  386. Serial.print ("Components :"); Serial.println(JpegDec.comps);
  387. Serial.print ("MCU / row :"); Serial.println(JpegDec.MCUSPerRow);
  388. Serial.print ("MCU / col :"); Serial.println(JpegDec.MCUSPerCol);
  389. Serial.print ("Scan type :"); Serial.println(JpegDec.scanType);
  390. Serial.print ("MCU width :"); Serial.println(JpegDec.MCUWidth);
  391. Serial.print ("MCU height :"); Serial.println(JpegDec.MCUHeight);
  392. Serial.println("===============");
  393. Serial.println("");
  394. */
  395. }
  396. //====================================================================================
  397. // Open a Jpeg file and send it to the Serial port in a C array compatible format
  398. //====================================================================================
  399. void createArray(const char *filename) {
  400. // Open the named file
  401. fs::File jpgFile = SPIFFS.open( filename, "r"); // File handle reference for SPIFFS
  402. // File jpgFile = SD.open( filename, FILE_READ); // or, file handle reference for SD library
  403. if ( !jpgFile ) {
  404. Serial.print("ERROR: File \""); Serial.print(filename); Serial.println ("\" not found!");
  405. return;
  406. }
  407. uint8_t data;
  408. byte line_len = 0;
  409. Serial.println("");
  410. Serial.println("// Generated by a JPEGDecoder library example sketch:");
  411. Serial.println("// https://github.com/Bodmer/JPEGDecoder");
  412. Serial.println("");
  413. Serial.println("#if defined(__AVR__)");
  414. Serial.println(" #include <avr/pgmspace.h>");
  415. Serial.println("#endif");
  416. Serial.println("");
  417. Serial.print ("const uint8_t ");
  418. while (*filename != '.') Serial.print(*filename++);
  419. Serial.println("[] PROGMEM = {"); // PROGMEM added for AVR processors, it is ignored by Due
  420. while ( jpgFile.available()) {
  421. data = jpgFile.read();
  422. Serial.print("0x"); if (abs(data) < 16) Serial.print("0");
  423. Serial.print(data, HEX); Serial.print(",");// Add value and comma
  424. line_len++;
  425. if ( line_len >= 32) {
  426. line_len = 0;
  427. Serial.println();
  428. }
  429. }
  430. Serial.println("};\r\n");
  431. jpgFile.close();
  432. }
  433. // End JPEG_functions
  434. // SPIFFS_functions
  435. #ifdef ESP8266
  436. void Display::listFiles(void) {
  437. Serial.println();
  438. Serial.println("SPIFFS files found:");
  439. fs::Dir dir = SPIFFS.openDir("/"); // Root directory
  440. String line = "=====================================";
  441. Serial.println(line);
  442. Serial.println(" File name Size");
  443. Serial.println(line);
  444. while (dir.next()) {
  445. String fileName = dir.fileName();
  446. Serial.print(fileName);
  447. int spaces = 21 - fileName.length(); // Tabulate nicely
  448. while (spaces--) Serial.print(" ");
  449. fs::File f = dir.openFile("r");
  450. String fileSize = (String) f.size();
  451. spaces = 10 - fileSize.length(); // Tabulate nicely
  452. while (spaces--) Serial.print(" ");
  453. Serial.println(fileSize + " bytes");
  454. }
  455. Serial.println(line);
  456. Serial.println();
  457. delay(1000);
  458. }
  459. #endif
  460. //====================================================================================
  461. #ifdef ESP32
  462. void Display::listFiles(void) {
  463. listDir(SPIFFS, "/", 0);
  464. }
  465. void Display::listDir(fs::FS &fs, const char * dirname, uint8_t levels) {
  466. Serial.println();
  467. Serial.println("SPIFFS files found:");
  468. Serial.printf("Listing directory: %s\n", "/");
  469. String line = "=====================================";
  470. Serial.println(line);
  471. Serial.println(" File name Size");
  472. Serial.println(line);
  473. fs::File root = fs.open(dirname);
  474. if (!root) {
  475. Serial.println("Failed to open directory");
  476. return;
  477. }
  478. if (!root.isDirectory()) {
  479. Serial.println("Not a directory");
  480. return;
  481. }
  482. fs::File file = root.openNextFile();
  483. while (file) {
  484. if (file.isDirectory()) {
  485. Serial.print("DIR : ");
  486. String fileName = file.name();
  487. Serial.print(fileName);
  488. if (levels) {
  489. listDir(fs, file.name(), levels - 1);
  490. }
  491. } else {
  492. String fileName = file.name();
  493. Serial.print(" " + fileName);
  494. int spaces = 20 - fileName.length(); // Tabulate nicely
  495. while (spaces--) Serial.print(" ");
  496. String fileSize = (String) file.size();
  497. spaces = 10 - fileSize.length(); // Tabulate nicely
  498. while (spaces--) Serial.print(" ");
  499. Serial.println(fileSize + " bytes");
  500. }
  501. file = root.openNextFile();
  502. }
  503. Serial.println(line);
  504. Serial.println();
  505. delay(1000);
  506. }
  507. #endif
  508. void Display::updateBanner(String msg)
  509. {
  510. this->img.deleteSprite();
  511. this->img.setColorDepth(8);
  512. this->img.createSprite(SCREEN_WIDTH, TEXT_HEIGHT);
  513. this->buildBanner(msg, current_banner_pos);
  514. this->img.pushSprite(0, 0);
  515. current_banner_pos--;
  516. if (current_banner_pos <= 0)
  517. current_banner_pos = SCREEN_WIDTH;
  518. }
  519. void Display::buildBanner(String msg, int xpos)
  520. {
  521. int h = TEXT_HEIGHT;
  522. // We could just use fillSprite(color) but lets be a bit more creative...
  523. // Fill with rainbow stripes
  524. //while (h--) img.drawFastHLine(0, h, SCREEN_WIDTH, 255);
  525. // Draw some graphics, the text will apear to scroll over these
  526. //img.fillRect (SCREEN_WIDTH / 2 - 20, TEXT_HEIGHT / 2 - 10, 40, 20, TFT_YELLOW);
  527. //img.fillCircle(SCREEN_WIDTH / 2, TEXT_HEIGHT / 2, 10, TFT_ORANGE);
  528. // Now print text on top of the graphics
  529. img.setTextSize(2); // Font size scaling is x1
  530. img.setTextFont(0); // Font 4 selected
  531. img.setTextColor(TFT_WHITE); // Black text, no background colour
  532. img.setTextWrap(false); // Turn of wrap so we can print past end of sprite
  533. // Need to print twice so text appears to wrap around at left and right edges
  534. img.setCursor(xpos, 2); // Print text at xpos
  535. img.print(msg);
  536. img.setCursor(xpos - SCREEN_WIDTH, 2); // Print text at xpos - sprite width
  537. img.print(msg);
  538. }
  539. void Display::main()
  540. {
  541. return;
  542. }
  543. // End SPIFFS_functions