Advertisement
m33600

UTFT 480x320 library manual

Mar 31st, 2018
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 16.82 KB | None | 0 0
  1. UTFT
  2. Multi-Platform Universal TFT display library
  3. Manual
  4. /*
  5. http://www.RinkyDinkElectronics.com/
  6. (C)2016 Rinky-Dink Electronics, Henning KarlsenIntroduction:
  7. This library was originally the continuation of my ITDB02_Graph, ITDB02_Graph16 and RGB_GLCD
  8. libraries for Arduino and chipKit. As the number of supported display modules and controllers
  9. started to increase I felt it was time to make a single, universal library as it will be much
  10. easier to maintain in the future.
  11. Basic functionality of this library was originally based on the demo-code provided by ITead
  12. studio (for the ITDB02 modules) and NKC Electronics (for the RGB GLCD module/shield).
  13. This library supports a number of 8bit, 16bit and serial graphic displays, and will work with
  14. both Arduino, chipKit boards and select TI LaunchPads. For a full list of tested display
  15. modules and controllers, see the document UTFT_Supported_display_modules_&_controllers.pdf.
  16. You can always find the latest version of the library at http://www.RinkyDinkElectronics.com/
  17. For version information, please refer to version.txt.
  18. IMPORTANT:
  19. When using 8bit and 16bit display modules there are some requirements you must adhere to.
  20. These requirements can be found in the document UTFT_Requirements.pdf.
  21. There are no special requirements when using serial displays.
  22. Since most people have only one or possibly two different display modules a lot
  23. been wasted to keep support for many unneeded controller chips.
  24. As of v1.1 you now have the option to easily remove this unneeded code from the
  25. disabling the controllers you don't need you can reduce the memory footprint of
  26. several Kb. For more information, please refer to memorysaver.h.
  27. TFT controllers used only by display modules and shields that have been retired
  28. vendors are as of v2.82 disabled by default.
  29. of memory has
  30. library. By
  31. the library by
  32. by their
  33. If you are using the “AquaLEDSource All in One Super Screw Shield” on a chipKit Max32, please
  34. read the comment in hardware/pic32/HW_PIC32_defines.h
  35. If you are using the “CTE TFT LCD/SD Shield for Arduino Due” or the “ElecHouse TFT LCD Screen
  36. Shield for Arduino DUE / Taijiuino”, please read the comment in hardware/arm/HW_ARM_defines.h
  37. 8 bit display shields designed for use on Arduino Uno (and similarly sized boards) can now be
  38. used on Arduino Megas. Please read the comment in hardware/avr/HW_AVR_defines.h
  39. Some of the larger (4.3”+) display modules have not been tested on all supported development
  40. boards due to the high current requirement for the LED backlight.
  41. This library is licensed under a CC BY-NC-SA 3.0 (Creative Commons Attribution-
  42. NonCommercial-ShareAlike 3.0 Unported) License.
  43. For more information see: http://creativecommons.org/licenses/by-nc-sa/3.0/
  44. */
  45. Library Manual: UTFT
  46. Page 1DEFINED LITERALS:
  47. Alignment
  48. For use with print(), printNumI() and printNumF()
  49. LEFT:
  50. RIGHT:
  51. CENTER:
  52. 0
  53. 9999
  54. 9998
  55. Orientation
  56. For use with InitLCD()
  57. PORTRAIT:
  58. LANDSCAPE:
  59. 0
  60. 1
  61. VGA Colors
  62. Predefined colors for use with setColor() and setBackColor()
  63. VGA_BLACK
  64. VGA_MAROON
  65. VGA_GREEN
  66. VGA_NAVY
  67. VGA_SILVER
  68. VGA_GRAY
  69. VGA_RED
  70. VGA_PURPLE
  71. VGA_LIME
  72. VGA_OLIVE
  73. VGA_BLUE
  74. VGA_TEAL
  75. VGA_TRANSPARENT (only valid for setBackColor())
  76. VGA_WHITE
  77. VGA_FUCHSIA
  78. VGA_YELLOW
  79. VGA_AQUA
  80. Display model
  81. For use with UTFT()
  82. Please see UTFT_Supported_display_modules_&_controllers.pdf
  83. INCLUDED FONTS:
  84. SmallFont
  85. Charactersize:
  86. Number of characters:
  87. 8x12 pixels
  88. 95
  89. BigFont
  90. Charactersize:
  91. Number of characters:
  92. 16x16 pixels
  93. 95
  94. SevenSegNumFont
  95. Charactersize:
  96. Number of characters:
  97. 32x50 pixels
  98. 10
  99. More fonts can be found in the “Resources” section of http://www.RinkyDinkElectronics.com/.
  100. There is also a tool there to make your own fonts if you cannot find any that suit your needs.
  101. For those who want to know the specifications of the font arrays there is also an explanation
  102. of that there.
  103. Library Manual: UTFT
  104. Page 2FUNCTIONS:
  105. UTFT(Model, RS, WR, CS, RST[, ALE]);
  106. The main class constructor when using 8bit or 16bit display modules.
  107. Parameters: Model:
  108. RS:
  109. WR:
  110. CS:
  111. RST:
  112. ALE:
  113. Usage: UTFT myGLCD(ITDB32S,19,18,17,16); // Start an instance of the UTFT class
  114. See the separate document for the supported display modules
  115. Pin for Register Select
  116. Pin for Write
  117. Pin for Chip Select
  118. Pin for Reset
  119. <optional> Only used for latched 16bit shields
  120. Pin for Latch signal
  121. UTFT(Model, SDA, SCL, CS, RST[, RS]);
  122. The main class constructor when using serial display modules.
  123. Parameters: Model:
  124. SDA:
  125. SCL:
  126. CS:
  127. RST:
  128. RS:
  129. Usage: UTFT myGLCD(ITDB18SP,11,10,9,12,8); // Start an instance of the UTFT class
  130. See the separate document for the supported display modules
  131. Pin for Serial Data
  132. Pin for Serial Clock
  133. Pin for Chip Select
  134. Pin for Reset
  135. <optional> Only used for 5pin serial modules
  136. Pin for Register Select
  137. InitLCD([orientation]);
  138. Initialize the LCD and set display orientation.
  139. Parameters:
  140. Usage:
  141. Notes:
  142. Orientation: <optional>
  143. PORTRAIT
  144. LANDSCAPE (default)
  145. myGLCD.initLCD(); // Initialize the display
  146. This will reset color to white with black background. Selected font will be reset to none.
  147. getDisplayXSize();
  148. Get the width of the screen in the current orientation.
  149. Parameters:
  150. Returns:
  151. Usage:
  152. None
  153. Width of the screen in the current orientation in pixels
  154. Xsize = myGLCD.getDisplayXSize(); // Get the width
  155. getDisplayYSize();
  156. Get the height of the screen in the current orientation.
  157. Parameters:
  158. Returns:
  159. Usage:
  160. None
  161. Height of the screen in the current orientation in pixels
  162. Ysize = myGLCD.getDisplayYSize(); // Get the height
  163. Library Manual: UTFT
  164. Page 3lcdOff();
  165. Turn off the LCD. No commands will be executed until a lcdOn(); is sent.
  166. Parameters:
  167. Usage:
  168. Notes:
  169. None
  170. myGLCD.lcdOff(); // Turn off the lcd
  171. This function is currently only supported on PCF8833 and CPLD-based displays.
  172. CPLD-based displays will only turn off the backlight. It will accept further commands/writes.
  173. lcdOn();
  174. Turn on the LCD after issuing a lcdOff()-command.
  175. Parameters:
  176. Usage:
  177. Notes:
  178. None
  179. myGLCD.lcdOn(); // Turn on the lcd
  180. This function is currently only supported on PCF8833 and CPLD-based displays.
  181. CPLD-based displays will only turn on the backlight.
  182. setContrast(c);
  183. Set the contrast of the display.
  184. Parameters:
  185. Usage:
  186. Notes:
  187. c: Contrast-level (0-64)
  188. myGLCD.setContrast(64); // Set contrast to full (default)
  189. This function is currently only supported on PCF8833-based displays
  190. setBrightness(br);
  191. Set the brightness of the display backlight.
  192. Parameters:
  193. Usage:
  194. Notes:
  195. br: Brightness-level (0-16)
  196. myGLCD.setBrightness(16); // Set brightness to maximum (default)
  197. This function is currently only supported on CPLD-based displays
  198. setDisplayPage(pg);
  199. Set which memory page to display.
  200. Parameters:
  201. Usage:
  202. Notes:
  203. pg: Page (0-7) (0 is default)
  204. myGLCD.setDisplayPage(4); // Display page 4
  205. This function is currently only supported on CPLD-based displays
  206. setWritePage(pg);
  207. Set which memory page to use for subsequent display writes.
  208. Parameters:
  209. Usage:
  210. Notes:
  211. pg: Page (0-7) (0 is default)
  212. myGLCD.setWritePage(2); // Use page 2 for subsequent writes
  213. This function is currently only supported on CPLD-based displays
  214. Library Manual: UTFT
  215. Page 4clrScr();
  216. Clear the screen. The background-color will be set to black.
  217. Parameters:
  218. Usage:
  219. None
  220. myGLCD.clrScr(); // Clear the screen
  221. fillScr(r, g, b);
  222. Fill the screen with a specified color.
  223. Parameters:
  224. Usage:
  225. r: Red component of an RGB value (0-255)
  226. g: Green component of an RGB value (0-255)
  227. b: Blue component of an RGB value (0-255)
  228. myGLCD.fillScr(255,127,0); // Fill the screen with orange
  229. fillScr(color);
  230. Fill the screen with a specified pre-calculated RGB565 color.
  231. Parameters:
  232. Usage:
  233. color: RGB565 color value
  234. myGLCD.fillScr(VGA_RED); // Fill the screen with red
  235. setColor(r, g, b);
  236. Set the color to use for all draw*, fill* and print commands.
  237. Parameters:
  238. Usage:
  239. r: Red component of an RGB value (0-255)
  240. g: Green component of an RGB value (0-255)
  241. b: Blue component of an RGB value (0-255)
  242. myGLCD.setColor(0,255,255); // Set the color to cyan
  243. setColor(color);
  244. Set the specified pre-calculated RGB565 color to use for all draw*, fill* and print commands.
  245. Parameters:
  246. Usage:
  247. color: RGB565 color value
  248. myGLCD.setColor(VGA_AQUA); // Set the color to aqua
  249. getColor();
  250. Get the currently selected color.
  251. Parameters:
  252. Returns:
  253. Usage:
  254. None
  255. Currently selected color as a RGB565 value (word)
  256. Color = myGLCD.getColor(); // Get the current color
  257. setBackColor(r, g, b);
  258. Set the background color to use for all print commands.
  259. Parameters:
  260. Usage:
  261. r: Red component of an RGB value (0-255)
  262. g: Green component of an RGB value (0-255)
  263. b: Blue component of an RGB value (0-255)
  264. myGLCD.setBackColor(255,255,255); // Set the background color to white
  265. setBackColor(color);
  266. Set the specified pre-calculated RGB565 background color to use for all print commands.
  267. Parameters:
  268. Usage:
  269. color: RGB565 color value
  270. myGLCD.setBackColor(VGA_LIME); // Set the background color to lime
  271. getBackColor();
  272. Get the currently selected background color.
  273. Parameters:
  274. Returns:
  275. Usage:
  276. None
  277. Currently selected background color as a RGB565 value (word)
  278. BackColor = myGLCD.getBackColor(); // Get the current background color
  279. Library Manual: UTFT
  280. Page 5drawPixel(x, y);
  281. Draw a single pixel.
  282. Parameters:
  283. Usage:
  284. x: x-coordinate of the pixel
  285. y: y-coordinate of the pixel
  286. myGLCD.drawPixel(119,159); // Draw a single pixel
  287. drawLine(x1, y1, x2, y2);
  288. Draw a line between two points.
  289. Parameters:
  290. Usage:
  291. x1: x-coordinate of the start-point
  292. y1: y-coordinate of the start-point
  293. x2: x-coordinate of the end-point
  294. y2: y-coordinate of the end-point
  295. myGLCD.drawLine(0,0,239,319); // Draw a diagonal line
  296. drawRect(x1, y1, x2, y2);
  297. Draw a rectangle between two points.
  298. Parameters:
  299. Usage:
  300. x1: x-coordinate of the start-corner
  301. y1: y-coordinate of the start-corner
  302. x2: x-coordinate of the end-corner
  303. y2: y-coordinate of the end-corner
  304. myGLCD.drawRect(119,159,239,319); // Draw a rectangle
  305. drawRoundRect(x1, y1, x2, y2);
  306. Draw a rectangle with slightly rounded corners between two points. The minimum size is 5 pixels in both directions. If a
  307. smaller size is requested the rectangle will not be drawn.
  308. Parameters:
  309. Usage:
  310. x1: x-coordinate of the start-corner
  311. y1: y-coordinate of the start-corner
  312. x2: x-coordinate of the end-corner
  313. y2: y-coordinate of the end-corner
  314. myGLCD.drawRoundRect(0,0,119,159); // Draw a rounded rectangle
  315. fillRect(x1, y1, x2, y2);
  316. Draw a filled rectangle between two points.
  317. Parameters:
  318. Usage:
  319. x1: x-coordinate of the start-corner
  320. y1: y-coordinate of the start-corner
  321. x2: x-coordinate of the end-corner
  322. y2: y-coordinate of the end-corner
  323. myGLCD.fillRect(119,0,239,159); // Draw a filled rectangle
  324. fillRoundRect(x1, y1, x2, y2);
  325. Draw a filled rectangle with slightly rounded corners between two points. The minimum size is 5 pixels in both directions. If a
  326. smaller size is requested the rectangle will not be drawn.
  327. Parameters:
  328. Usage:
  329. x1: x-coordinate of the start-corner
  330. y1: y-coordinate of the start-corner
  331. x2: x-coordinate of the end-corner
  332. y2: y-coordinate of the end-corner
  333. myGLCD.fillRoundRect(0,159,119,319); // Draw a filled, rounded rectangle
  334. drawCircle(x, y, radius);
  335. Draw a circle with a specified radius.
  336. Parameters:
  337. Usage:
  338. x:
  339. x-coordinate of the center of the circle
  340. y:
  341. y-coordinate of the center of the circle
  342. radius: radius of the circle in pixels
  343. myGLCD.drawCircle(119,159,20); // Draw a circle with a radius of 20 pixels
  344. fillCircle(x, y, radius);
  345. Draw a filled circle with a specified radius.
  346. Parameters:
  347. Usage:
  348. x:
  349. x-coordinate of the center of the circle
  350. y:
  351. y-coordinate of the center of the circle
  352. radius: radius of the circle in pixels
  353. myGLCD.fillCircle(119,159,10); // Draw a filled circle with a radius of 10 pixels
  354. Library Manual: UTFT
  355. Page 6print(st, x, y[, deg]);
  356. Print a string at the specified coordinates.
  357. You can use the literals LEFT, CENTER and RIGHT as the x-coordinate to align the string on the screen.
  358. Parameters:
  359. Usage:
  360. Notes:
  361. st:
  362. x:
  363. y:
  364. deg:
  365. the string to print
  366. x-coordinate of the upper, left corner of the first character
  367. y-coordinate of the upper, left corner of the first character
  368. <optional>
  369. Degrees to rotate text (0-359). Text will be rotated around the upper left corner.
  370. myGLCD.print(“Hello, World!”,CENTER,0); // Print “Hello, World!”
  371. CENTER and RIGHT will not calculate the coordinates correctly when rotating text.
  372. The string can be either a char array or a String object
  373. printNumI(num, x, y[, length[, filler]]);
  374. Print an integer number at the specified coordinates.
  375. You can use the literals LEFT, CENTER and RIGHT as the x-coordinate to align the string on the screen.
  376. Parameters:
  377. Usage:
  378. num:
  379. x:
  380. y:
  381. length:
  382. the value to print (-2,147,483,648 to 2,147,483,647) INTEGERS ONLY
  383. x-coordinate of the upper, left corner of the first digit/sign
  384. y-coordinate of the upper, left corner of the first digit/sign
  385. <optional>
  386. minimum number of digits/characters (including sign) to display
  387. filler: <optional>
  388. filler character to use to get the minimum length. The character will be inserted in front
  389. of the number, but after the sign. Default is ' ' (space).
  390. myGLCD.printNumI(num,CENTER,0); // Print the value of “num”
  391. printNumF(num, dec, x, y[, divider[, length[, filler]]]);
  392. Print a floating-point number at the specified coordinates.
  393. You can use the literals LEFT, CENTER and RIGHT as the x-coordinate to align the string on the screen.
  394. WARNING: Floating point numbers are not exact, and may yield strange results when compared. Use at your own discretion.
  395. Parameters:
  396. Usage:
  397. Notes:
  398. num:
  399. dec:
  400. x:
  401. y:
  402. divider:
  403. the value to print (See note)
  404. digits in the fractional part (1-5) 0 is not supported. Use printNumI() instead.
  405. x-coordinate of the upper, left corner of the first digit/sign
  406. y-coordinate of the upper, left corner of the first digit/sign
  407. <Optional>
  408. Single character to use as decimal point. Default is '.'
  409. length:
  410. <optional>
  411. minimum number of digits/characters (including sign) to display
  412. filler:
  413. <optional>
  414. filler character to use to get the minimum length. The character will be inserted in front
  415. of the number, but after the sign. Default is ' ' (space).
  416. myGLCD.printNumF(num, 3, CENTER,0); // Print the value of “num” with 3 fractional digits
  417. Supported range depends on the number of fractional digits used.
  418. Approx range is +/- 2*(10^(9-dec))
  419. setFont(fontname);
  420. Select font to use with print(), printNumI() and printNumF().
  421. Parameters:
  422. Usage:
  423. Notes:
  424. fontname: Name of the array containing the font you wish to use
  425. myGLCD.setFont(BigFont); // Select the font called BigFont
  426. You must declare the font-array as an external or include it in your sketch.
  427. getFont();
  428. Get the currently selected font.
  429. Parameters:
  430. Returns:
  431. Usage:
  432. None
  433. Currently selected font
  434. CurrentFont = myGLCD.getFont(); // Get the current font
  435. getFontXsize();
  436. Get the width of the currently selected font.
  437. Parameters:
  438. Returns:
  439. Usage:
  440. None
  441. Width of the currently selected font in pixels
  442. Xsize = myGLCD.getFontXsize (); // Get font width
  443. getFontYsize();
  444. Get the height of the currently selected font.
  445. Parameters:
  446. Returns:
  447. Usage:
  448. None
  449. Height of the currently selected font in pixels
  450. Ysize = myGLCD.getFontYsize (); // Get font height
  451. Library Manual: UTFT
  452. Page 7drawBitmap (x, y, sx, sy, data[, scale]);
  453. Draw a bitmap on the screen.
  454. Parameters:
  455. Usage:
  456. Notes:
  457. x:
  458. y:
  459. sx:
  460. sy:
  461. data:
  462. scale:
  463. x-coordinate of the upper, left corner of the bitmap
  464. y-coordinate of the upper, left corner of the bitmap
  465. width of the bitmap in pixels
  466. height of the bitmap in pixels
  467. array containing the bitmap-data
  468. <optional>
  469. Scaling factor. Each pixel in the bitmap will be drawn as <scale>x<scale> pixels on screen.
  470. myGLCD.drawBitmap(0, 0, 32, 32, bitmap); // Draw a 32x32 pixel bitmap
  471. You can use the online-tool “ImageConverter 565” or “ImageConverter565.exe” in the Tools-folder to
  472. convert pictures into compatible arrays. The online-tool can be found on my website.
  473. Requires that you #include <avr/pgmspace.h> when using an Arduino other than Arduino Due.
  474. drawBitmap (x, y, sx, sy, data, deg, rox, roy);
  475. Draw a bitmap on the screen with rotation.
  476. Parameters:
  477. Usage:
  478. Notes:
  479. x:
  480. x-coordinate of the upper, left corner of the bitmap
  481. y:
  482. y-coordinate of the upper, left corner of the bitmap
  483. sx:
  484. width of the bitmap in pixels
  485. sy:
  486. height of the bitmap in pixels
  487. data: array containing the bitmap-data
  488. deg: Degrees to rotate bitmap (0-359)
  489. rox: x-coordinate of the pixel to use as rotational center relative to bitmaps upper left corner
  490. roy: y-coordinate of the pixel to use as rotational center relative to bitmaps upper left corner
  491. myGLCD.drawBitmap(50, 50, 32, 32, bitmap, 45, 16, 16); // Draw a bitmap rotated 45 degrees around
  492. its center
  493. You can use the online-tool “ImageConverter 565” or “ImageConverter565.exe” in the Tools-folder to
  494. convert pictures into compatible arrays. The online-tool can be found on my website.
  495. Requires that you #include <avr/pgmspace.h> when using an Arduino other than Arduino Due.
  496. Library Manual: UTFT
  497. Page 8
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement