Guest User

Untitled

a guest
Jun 27th, 2020
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 KB | None | 0 0
  1. /*
  2.  
  3. HelloWorld.ino
  4.  
  5. Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
  6.  
  7. Copyright (c) 2016, [email protected]
  8. All rights reserved.
  9.  
  10. Redistribution and use in source and binary forms, with or without modification,
  11. are permitted provided that the following conditions are met:
  12.  
  13. * Redistributions of source code must retain the above copyright notice, this list
  14. of conditions and the following disclaimer.
  15.  
  16. * Redistributions in binary form must reproduce the above copyright notice, this
  17. list of conditions and the following disclaimer in the documentation and/or other
  18. materials provided with the distribution.
  19.  
  20. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  21. CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  22. INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  23. MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  24. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  25. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  26. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  27. NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  28. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  30. STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  31. ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  32. ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33.  
  34. */
  35.  
  36. #include <Arduino.h>
  37. #include <U8g2lib.h>
  38.  
  39. #ifdef U8X8_HAVE_HW_SPI
  40. #include <SPI.h>
  41. #endif
  42. #ifdef U8X8_HAVE_HW_I2C
  43. #include <Wire.h>
  44. #endif
  45.  
  46. /*
  47. U8glib Example Overview:
  48. Frame Buffer Examples: clearBuffer/sendBuffer. Fast, but may not work with all Arduino boards because of RAM consumption
  49. Page Buffer Examples: firstPage/nextPage. Less RAM usage, should work with all Arduino boards.
  50. U8x8 Text Only Example: No RAM usage, direct communication with display controller. No graphics, 8x8 Text only.
  51.  
  52. */
  53.  
  54. // Please UNCOMMENT one of the contructor lines below
  55. // U8g2 Contructor List (Frame Buffer)
  56. // The complete list is available here: https://github.com/olikraus/u8g2/wiki/u8g2setupcpp
  57. // Please update the pin numbers according to your setup. Use U8X8_PIN_NONE if the reset pin is not connected
  58. U8G2_ST7920_128X64_F_SW_SPI u8g2(U8G2_R0, /* clock=*/ 2, /* data=*/ 10, /* CS=*/ 7, /* reset=*/ 8);
  59.  
  60. void setup(void) {
  61. u8g2.begin();
  62. }
  63.  
  64. void loop(void) {
  65. u8g2.clearBuffer(); // clear the internal memory
  66. u8g2.setFont(u8g2_font_ncenB14_tr); // choose a suitable font
  67. u8g2.drawStr(0,20,"12:00"); // write something to the internal memory
  68. u8g2.sendBuffer(); // transfer internal memory to the display
  69. delay(1000);
  70. }
Advertisement
Add Comment
Please, Sign In to add comment