epd2in13d.ino 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /**
  2. * @filename : epd2in13-demo.ino
  3. * @brief : 2.13inch e-paper display demo
  4. * @author : Yehui from Waveshare
  5. *
  6. * Copyright (C) Waveshare September 9 2017
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9. * of this software and associated documnetation files (the "Software"), to deal
  10. * in the Software without restriction, including without limitation the rights
  11. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. * copies of the Software, and to permit persons to whom the Software is
  13. * furished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included in
  16. * all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. * LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24. * THE SOFTWARE.
  25. */
  26. #include <SPI.h>
  27. #include "epd2in13d.h"
  28. #include "imagedata.h"
  29. /**
  30. * Due to RAM not enough in Arduino UNO, a frame buffer is not allowed.
  31. * In this case, a smaller image buffer is allocated and you have to
  32. * update a partial display several times.
  33. * 1 byte = 8 pixels, therefore you have to set 8*N pixels at a time.
  34. */
  35. Epd epd;
  36. void setup()
  37. {
  38. // put your setup code here, to run once:
  39. Serial.begin(9600);
  40. Serial.print("e-paper Init\n");
  41. epd.Init();
  42. Serial.print("e-paper Clear\n");
  43. epd.Clear(); // bit set = white, bit reset = black
  44. /**
  45. * there are 2 memory areas embedded in the e-paper display
  46. * and once the display is refreshed, the memory area will be auto-toggled,
  47. * i.e. the next action of SetFrameMemory will set the other memory area
  48. * therefore you have to set the frame memory and refresh the display twice.
  49. */
  50. Serial.print("Displayimage\n");
  51. epd.Displayimage(gImage_IMAGE);
  52. delay(500);
  53. epd.Clear();
  54. epd.Sleep();
  55. }
  56. void loop()
  57. {
  58. }