PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

před 3 roky
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. LiquidCrystalFast Arduino Library
  2. =================================
  3. LiquidCrystalFast is an improved version of the Arduino LiquidCrystal
  4. library. The primary improvements are increased speed when the RW pin
  5. is connected, and support for 40x4 displays.
  6. LiquidCrystalFast History
  7. -------------------------
  8. In early-2010, John Raines rewrote the LiquidCrystal library, adding
  9. several features, fixing problems, and greatly improving its speed.
  10. The final version of John's excellent work is at:
  11. http://code.google.com/p/liquidcrystal440/
  12. John prepared a version for inclusion in Arduino 0019, with certain
  13. features removed as requested by the Arduino developers. However,
  14. the Arduino project never adopted John's code.
  15. In mid-2011, Paul Stoffregen merged some of John's versions of the
  16. library and renamed it "LiquidCrystalFast", so it can be used on
  17. Arduino without removing LiquidCrystal.
  18. Speed Increase (with RW pin)
  19. ----------------------------
  20. Using the example in File > Examples > LiquidCrystalFast > Benchmark
  21. on a Teensy 2.0 with Arduino 0022 and Teensyduino 0.95 running on
  22. a 16x2 LCD:
  23. LiquidCrystalFast: 89 milliseconds.
  24. LiquidCrystal: 354 milliseconds.
  25. John Raines's Original Readme
  26. =============================
  27. This version of LiquidCrystal supports the API of LiquidCrystal in
  28. Arduino 17 fully but does not actually ever use 8 data pins. This
  29. change makes the code smaller, saving flash RAM and also less complex,
  30. making it easier to read.
  31. 40x4 LCDs
  32. ---------
  33. I added support for an LCD of 4 LInes and 40 characters. I think that
  34. if 24x4, 32x4 LCDs exist, they would also work with the software as I
  35. have modified it although I have not had the opportunity to test that.
  36. The 40x4 LCD (and any HD44780 based LCD with between 81 and 160
  37. characters) will have 2 enable lines. To use an LCD with 4 lines and
  38. 40 columns you would declare your LiquidCrystal object as:
  39. LiquidCrystal lcd(RS,RW,Enable1,Enable2, data3,data2,data1,data0);
  40. At this time I donʼt support 8 data lines. (You can pass 255 as the
  41. RW item, ground RW and save an Arduino pin.) Then in the setup
  42. function you would call:
  43. lcd.begin(40,4);
  44. Linewrap
  45. --------
  46. When you declare the dimensions of the LCD in your begin call, the
  47. LiquidCrystal library remembers how long the lines are. Now when it
  48. reaches the end of line 1, text wraps onto line 2 (not line 3 as
  49. previously).
  50. println
  51. -------
  52. Although print has worked properly in the past, println has not. Now
  53. the ʻ\rʼ and ʻ\nʼ characters are not sent to the screen as though they
  54. were visible characters and the ʻ\rʼ resets the character position to
  55. the top of the next line.
  56. 16x4 LCDs
  57. ---------
  58. The begin statement also correctly positions text at the beginning of
  59. the line on 16x4 (and 40x4) LCDs, which were not correctly handled
  60. before.
  61. setCursor
  62. ---------
  63. In the past setCursor selected a location in the HD44780ʼs RAM not
  64. actually a screen location. If you use any of the commands that shift
  65. the display left or right with the previous routines, then setCursor
  66. and print, text appears in an unexpected location on the screen. With
  67. the new software, if you call either scrollDisplayLeft() or
  68. scrollDisplayRight(), the LiquidCrystal package keeps track of the
  69. relationship between RAM and the LCD so that setCursor coordinates are
  70. pegged to a specific spot on the screen, rather than a spot in RAM.
  71. The sotware does not handle autoScroll, however. Call home() after
  72. autoScroll to restore the expected relationship between setCursor and
  73. the LCD screen.
  74. Testing the LCD Busy Flag
  75. -------------------------
  76. Previous versions of LiquidCrystal always used timed delays on the
  77. Arduino side of the interface to give the LCD module enough time to
  78. complete its operation. This version still does that if you tie the
  79. RW pin to ground and do not tell LiquidCrystal what that pin number
  80. is. If you do specify RW now, however, the software will poll the
  81. busy flag on the LCD module. Arduino operations may thus overlap LCD
  82. operations and potentially things may go a little faster.
  83. Syntactic Sugar
  84. ---------------
  85. #include <Streaming.h>
  86. from http://arduiniana.org/2009/04/new-streaming-library/
  87. Then you can combine that with an overloading of the () operator in
  88. this code. This lets you specify screen location and chain print
  89. commands together by writing:
  90. lcd(column,line)<<“a=”<<a;
  91. Streaming.h is so efficient you may actually save a few bytes of memory!
  92. Speed testing
  93. -------------
  94. All of the interface modes go faster than the eye can follow. This
  95. version of the software is even slower than the previous version when
  96. using timed delays. I found that my LCD (Axman) needed an even longer
  97. delay than before. In the interests of making the code foolproof, I
  98. lengthened the delays to make that LCD work. However Paul Stoffregen
  99. has significantly speeded up the code when testing the busy flag and
  100. so those options run significantly faster than before. I compared the
  101. speeds of the different interfaces--writing 80 characters to the
  102. screen then 80 blanks and looping through that 20 times. The results
  103. on a Mega are:
  104. Axman 4 data pins no RW 1417 milliseconds | nonAxman 1417
  105. Axman 4 data pins + RW 565 milliseconds | nonAxman 468
  106. Axman 4 pins + user busy 369 milliseconds | nonAxman 316
  107. I also have a Teensy++2.0 board. One of the interesting things about
  108. that board is that the software that comes with it includes
  109. considerable optimization of digitalRead, digitalWrite etc. The board
  110. runs at 16 megaHz, just like the Mega, but speeding up those commands
  111. results in an impressive change in the benchmarks:
  112. Axman 4 data pins no RW 1276 milliseconds | nonAxman 1276
  113. Axman 4 data pins + RW 330 milliseconds | nonAxman 222
  114. Axman 4 pins + user busy 241 milliseconds | nonAxman 190
  115. Crazy 8 Addressing
  116. ------------------
  117. 16x1 LCDs often have an unusual address layout; these modules often
  118. have two 8 character halves and work best with this software if you
  119. declare them as:
  120. lcd.begin(8,2);
  121. If you do that, then you can print(“abcdefghilklmno”); and have all
  122. the characters appear as you would like across the screen. If you use
  123. any of the scrolling commands, the bizarre addressing of these modules
  124. will manifest itself. For details follow the _LCD Addressing_ link at
  125. web.alfredstate.edu/weimandn
  126. User callback busy test
  127. -----------------------
  128. Get LiquidCrystal running without this first; setting up this
  129. complicated option is error-prone and this should be left for last,
  130. if implemented at all. (the remainder of this section was removed)
  131. Special note: LiquidCrystalFast does not have the user callback
  132. feature. For John's original code with user callback, please visit:
  133. http://code.google.com/p/liquidcrystal440/
  134. Disadvantages
  135. -------------
  136. The only real disadvantage I can see to the changes I have made is the
  137. possibility that someone with a little 16x2 LCD is using the
  138. scrollDisplayLeft() or scrollDisplayRight() instructions to move data
  139. across the screen, but wants to write the data 40 characters at a time
  140. with a print statement. This version really does not let the user
  141. write data to the HD44780 DDRAM which is not visible. To accomplish a
  142. scrolling display with 40 characters per line, you would now need to
  143. write 16 characters, scroll the display, write a little more and so on.
  144. There are going to be some incompatibilities between code that assumed
  145. that line 1 wrapped onto line 3, etc.
  146. Directions for the future
  147. -------------------------
  148. Paul Stoffregen suggested making the internal function send() public
  149. rather than private so that classes that inherit from LiquidCrystal
  150. can provide an alternate function, presumably hard coding pins and
  151. getting still more speed. I made all of the ʻprivateʼ functions and
  152. instance variables in LiquidCrystal ʻprotectedʼ. I think this allows
  153. the same functionality, but have not yet tested this.
  154. Bug
  155. ---
  156. The one bug I am aware of is that autoscroll() on a 40x4 LCD only
  157. scrolls 2 lines despite my best efforts.
  158. Thanks
  159. ------
  160. Certainly my efforts would not have been possible without the help and
  161. prior efforts of David Mellis, Limor Friede, and Donald Weiman. Don
  162. was particularly patient in guiding me through the idiosyncracies of
  163. the HD44780 based LCDs and especially in supplying an example of how
  164. the busy flag could be tested. Paul Stoffregen contributed significant
  165. optimization of the code to make it faster.