epd2in13_V4.ino 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #include <SPI.h>
  2. #include "epd2in13_V4.h"
  3. #include "epdpaint.h"
  4. #include "imagedata.h"
  5. #define COLORED 0
  6. #define UNCOLORED 1
  7. /**
  8. * Due to RAM not enough in Arduino UNO, a frame buffer is not allowed.
  9. * In this case, a smaller image buffer is allocated and you have to
  10. * update a partial display several times.
  11. * 1 byte = 8 pixels, therefore you have to set 8*N pixels at a time.
  12. */
  13. unsigned char image[1050];
  14. Paint paint(image, 0, 0);
  15. Epd epd;
  16. void setup()
  17. {
  18. // put your setup code here, to run once:
  19. Serial.begin(115200);
  20. Serial.println("epd FAST");
  21. epd.Init(FAST);
  22. epd.Display_Fast(IMAGE_DATA);
  23. delay(2000);
  24. #if 1
  25. Serial.println("epd FULL");
  26. epd.Init(FULL);
  27. Paint paint(image, epd.bufwidth*8, epd.bufheight); //width should be the multiple of 8
  28. paint.Clear(UNCOLORED);
  29. paint.DrawStringAt(8, 2, "e-Paper Demo", &Font12, COLORED);
  30. paint.DrawStringAt(8, 20, "Hello world", &Font12, COLORED);
  31. epd.Display1(image);//1
  32. paint.Clear(UNCOLORED);
  33. paint.DrawRectangle(2,2,50,50,COLORED);
  34. paint.DrawLine(2,2,50,50,COLORED);
  35. paint.DrawLine(2,50,50,2,COLORED);
  36. paint.DrawFilledRectangle(52,2,100,50,COLORED);
  37. paint.DrawLine(52,2,100,50,UNCOLORED);
  38. paint.DrawLine(100,2,52,50,UNCOLORED);
  39. epd.Display1(image);//2
  40. paint.Clear(UNCOLORED);
  41. paint.DrawCircle(25,25,20,COLORED);
  42. paint.DrawFilledCircle(75,25,20,COLORED);
  43. epd.Display1(image);//3
  44. paint.Clear(UNCOLORED);
  45. epd.Display1(image);//4
  46. delay(2000);
  47. #else
  48. Serial.println("epd PART");
  49. epd.DisplayPartBaseImage(IMAGE_DATA);
  50. char i = 0;
  51. for (i = 0; i < 10; i++) {
  52. Serial.println("e-Paper PART IMAGE_DATA");
  53. epd.Init(PART);
  54. epd.DisplayPart(IMAGE_DATA);
  55. Serial.println("e-Paper PART Clear");
  56. epd.Init(PART);
  57. epd.ClearPart();
  58. delay(2000);
  59. }
  60. #endif
  61. epd.Init(FULL);
  62. Serial.println("e-Paper clear and sleep");
  63. epd.Clear();
  64. epd.Sleep();
  65. }
  66. void loop()
  67. {
  68. }