Advertisement
Guest User

Untitled

a guest
Jul 20th, 2021
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.21 KB | None | 0 0
  1. // Demo_Portrait
  2. // Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved
  3. // web: http://www.RinkyDinkElectronics.com/
  4. //
  5. // This program is a demo of the loadBitmap()-function.
  6. //
  7. // This program requires UTFT_tinyFAT, UTFT v2.41 or higher,
  8. // as well as tinyFAT v3.0 or higher.
  9. //
  10. // The image files must be present in the root folder
  11. // of a FAT16 formatted SDcard in the module cardslot.
  12. //
  13. // Please note that this demo only supports the following
  14. // display sizes:
  15. // 176x220
  16. // 240x320
  17. // 240x400
  18.  
  19. #include <tinyFAT.h>
  20. #include <UTFT.h>
  21. #include <UTFT_tinyFAT.h>
  22.  
  23. // Declare which fonts we will be using
  24. extern uint8_t SmallFont[];
  25.  
  26. UTFT myGLCD(ITDB32S, 38, 39, 40, 41); // Remember to change the model parameter to suit your display module!
  27. UTFT_tinyFAT myFiles(&myGLCD);
  28.  
  29. // List of filenames for pictures to display.
  30. char* files320[]={"PIC101.RAW", "PIC102.RAW", "PIC103.RAW", "PIC104.RAW", "PIC105.RAW", "PIC106.RAW", "PIC107.RAW", "PIC108.RAW", "PIC109.RAW", "PIC110.RAW"}; // 240x320
  31. char* files400[]={"PIC201.RAW", "PIC202.RAW", "PIC203.RAW", "PIC204.RAW", "PIC205.RAW", "PIC206.RAW", "PIC207.RAW", "PIC208.RAW", "PIC209.RAW", "PIC210.RAW"}; // 240x400
  32. char* files220[]={"PIC501.RAW", "PIC502.RAW", "PIC503.RAW", "PIC504.RAW", "PIC505.RAW", "PIC506.RAW", "PIC507.RAW", "PIC508.RAW", "PIC509.RAW", "PIC510.RAW"}; // 176x220
  33. char* files[10];
  34.  
  35. int picsize_x, picsize_y;
  36. boolean display_rendertime=false; // Set this to true if you want the rendertime to be displayed after a picture is loaded
  37. boolean display_filename=true; // Set this to false to disable showing of filename
  38.  
  39. word res;
  40. long sm, em;
  41.  
  42. void setup()
  43. {
  44. myGLCD.InitLCD(PORTRAIT);
  45. myGLCD.clrScr();
  46. file.initFAT();
  47. myGLCD.setColor(255,255,255);
  48. myGLCD.setFont(SmallFont);
  49. picsize_x=myGLCD.getDisplayXSize();
  50. picsize_y=myGLCD.getDisplayYSize();
  51. switch (picsize_y)
  52. {
  53. case 220:
  54. for (int z=0; z<sizeof(files220)/sizeof(*files220);z++)
  55. files[z] = files220[z];
  56. break;
  57. case 320:
  58. for (int z=0; z<sizeof(files320)/sizeof(*files320);z++)
  59. files[z] = files320[z];
  60. break;
  61. case 400:
  62. for (int z=0; z<sizeof(files400)/sizeof(*files400);z++)
  63. files[z] = files400[z];
  64. break;
  65. }
  66. }
  67.  
  68. void loop()
  69. {
  70.  
  71. for (int i=0; i<(sizeof(files)/sizeof(*files)); i++)
  72. {
  73. if (files[i]!="")
  74. {
  75. sm=millis();
  76. res=myFiles.loadBitmap(0, 0, picsize_x, picsize_y, files[i]);
  77. em=millis();
  78. if (res!=0)
  79. {
  80. if (res==0x10)
  81. {
  82. myGLCD.print("File not found...", 0, 0);
  83. myGLCD.print(files[i], 0, 14);
  84. }
  85. else
  86. {
  87. myGLCD.print("ERROR: ", 0, 0);
  88. myGLCD.printNumI(res, 56, 0);
  89. }
  90. delay(3000);
  91. myGLCD.clrScr();
  92. }
  93. else
  94. {
  95. if (display_rendertime==true)
  96. {
  97. myGLCD.print("Rendertime (secs):", 0, 0);
  98. myGLCD.printNumF(float((em-sm)/1000.0), 2, 160,0);
  99. }
  100. if (display_filename==true)
  101. {
  102. myGLCD.print(files[i], CENTER, myGLCD.getDisplayYSize()-12);
  103. }
  104. delay(3000);
  105. }
  106. }
  107. }
  108. }
  109.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement