Advertisement
Guest User

Untitled

a guest
Jul 20th, 2021
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. // UTFT_SdRaw_320x240_Serial_Demo_Native_Port
  2. // Copyright (C)2015 Graham Lawrence (GHLawrence2000). All Rights reserved.
  3. // web: https://github.com/ghlawrence2000/UTFT_SdRaw
  4. //
  5. // This program is a demo of how to use Serial/SerialUSB source to draw an
  6. // image with UTFT_SdRaw.
  7. //
  8. // The companion Processing sketch 'SdRaw_Serial_Uploader' can be found in
  9. // the 'Extras' folder.
  10. //
  11. // This program requires the UTFT and SdFat libraries.
  12. //
  13.  
  14. #include <UTFT.h>
  15. #include <UTFT_SdRaw.h>
  16.  
  17. #include <SPI.h>
  18. #include <SdFat.h>
  19.  
  20. // Set the pins to the correct ones for your development shield
  21. // ------------------------------------------------------------
  22. // Standard Arduino Mega/Due shield : <display model>,38,39,40,41
  23. // CTE TFT LCD/SD Shield for Arduino Due : <display model>,25,26,27,28
  24. // Teensy 3.x TFT Test Board : <display model>,23,22, 3, 4
  25. // ElecHouse TFT LCD/SD Shield for Arduino Due : <display model>,22,23,31,33
  26. //
  27. // Remember to change the model parameter to suit your display module!
  28. UTFT myGLCD(CPLD, 25, 26, 27, 28);
  29.  
  30. UTFT_SdRaw myFiles(&myGLCD);
  31.  
  32. void setup()
  33. {
  34. myGLCD.InitLCD(LANDSCAPE);
  35. myGLCD.clrScr();
  36.  
  37. // Open Serial communications and wait for port to open:
  38. Serial.begin(115200);
  39. while (!Serial) ;
  40. // wait for Serial port to connect. Needed for Leonardo and DUE
  41. }
  42.  
  43. void loop()
  44. {
  45. while (!Serial.available()) ; // Wait for Serial connection
  46. if (Serial.find("HELLO\n")) { // Wait for host
  47. Serial.println("OK"); // Tell host we are ready
  48. }
  49. // loadS(port, x, y, xsize, ysize, buffermultiplier, invert colours)
  50. // port can be Serial / SerialUSB
  51. // x , y are the display coordinates
  52. // xsize , ysize are the expected image dimensions
  53. // buffer multiplier is used to potentially increase speed a little :-
  54. // total buffer size = buffermultiplier * 2 * xsize
  55. // invert colours is used to swap the MSB/LSB if colour appears wrong
  56. myFiles.loadS(Serial, 0, 0, 320, 240, 4 , 0); // Draw Image
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement