Display.cpp 20 KB

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