Arduino_R4.ino 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #include "EPD_13in3e.h"
  2. #include "GUI_Paint.h"
  3. #include "fonts.h"
  4. #include "ImageData.h"
  5. void setup() {
  6. Debug("EPD_13IN3E_test Demo\r\n");
  7. DEV_Module_Init();
  8. Debug("e-Paper Init and Clear...\r\n");
  9. EPD_13IN3E_Init();
  10. EPD_13IN3E_Clear(EPD_13IN3E_WHITE);
  11. DEV_Delay_ms(500);
  12. //Create a new image cache named IMAGE_BW and fill it with white
  13. UBYTE *Image;
  14. UWORD Imagesize = ((EPD_13IN3E_WIDTH % 2 == 0)? (EPD_13IN3E_WIDTH / 2 ): (EPD_13IN3E_WIDTH / 2 + 1)) * EPD_13IN3E_HEIGHT;
  15. if((Image = (UBYTE *)malloc(20000)) == NULL) {
  16. Debug("Failed to apply for black memory...\r\n");
  17. DEV_Module_Exit();
  18. while(1);
  19. }
  20. Debug("NewImage:Image\r\n");
  21. Paint_NewImage(Image, 200, 200, 0, WHITE);
  22. //Select Image
  23. Paint_SelectImage(Image);
  24. Paint_Clear(WHITE);
  25. #if 1 // show bmp
  26. printf("show bmp1-----------------\r\n");
  27. EPD_13IN3E_DisplayPart(BMP_1, 400, 500, 400, 600);
  28. DEV_Delay_ms(3000);
  29. #else // Drawing on the image
  30. Paint_NewImage(Image, 200, 200, 90, EPD_13IN3E_WHITE);
  31. Paint_SetScale(6);
  32. // 1.Select Image
  33. Debug("SelectImage:Image\r\n");
  34. Paint_SelectImage(Image);
  35. Paint_Clear(EPD_13IN3E_WHITE);
  36. // 2.Drawing on the image
  37. Debug("Drawing:Image\r\n");
  38. Paint_DrawPoint(10, 80, EPD_13IN3E_RED, DOT_PIXEL_1X1, DOT_STYLE_DFT);
  39. Paint_DrawPoint(10, 90, EPD_13IN3E_BLUE, DOT_PIXEL_2X2, DOT_STYLE_DFT);
  40. Paint_DrawPoint(10, 100, EPD_13IN3E_GREEN, DOT_PIXEL_3X3, DOT_STYLE_DFT);
  41. Paint_DrawLine(20, 70, 70, 120, EPD_13IN3E_YELLOW, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
  42. Paint_DrawLine(70, 70, 20, 120, EPD_13IN3E_YELLOW, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
  43. Paint_DrawRectangle(20, 70, 70, 120, EPD_13IN3E_BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
  44. Paint_DrawRectangle(80, 70, 130, 120, EPD_13IN3E_BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
  45. Paint_DrawCircle(45, 95, 20, EPD_13IN3E_BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
  46. Paint_DrawCircle(105, 95, 20, EPD_13IN3E_WHITE, DOT_PIXEL_1X1, DRAW_FILL_FULL);
  47. Paint_DrawLine(85, 95, 125, 95, EPD_13IN3E_YELLOW, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
  48. Paint_DrawLine(105, 75, 105, 115, EPD_13IN3E_YELLOW, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
  49. Paint_DrawString_CN(10, 130, "你好abc", &Font12CN, EPD_13IN3E_BLACK, EPD_13IN3E_WHITE);
  50. Paint_DrawString_CN(10, 150, "微雪电子", &Font24CN, EPD_13IN3E_WHITE, EPD_13IN3E_BLACK);
  51. Paint_DrawNum(10, 33, 123456789, &Font12, EPD_13IN3E_BLACK, EPD_13IN3E_WHITE);
  52. Paint_DrawNum(10, 50, 987654321, &Font16, EPD_13IN3E_WHITE, EPD_13IN3E_BLACK);
  53. Paint_DrawString_EN(145, 0, "Waveshare", &Font16, EPD_13IN3E_BLACK, EPD_13IN3E_WHITE);
  54. Paint_DrawString_EN(145, 35, "Waveshare", &Font16, EPD_13IN3E_GREEN, EPD_13IN3E_WHITE);
  55. Paint_DrawString_EN(145, 70, "Waveshare", &Font16, EPD_13IN3E_BLUE, EPD_13IN3E_WHITE);
  56. Paint_DrawString_EN(145, 105, "Waveshare", &Font16, EPD_13IN3E_RED, EPD_13IN3E_WHITE);
  57. Paint_DrawString_EN(145, 140, "Waveshare", &Font16, EPD_13IN3E_YELLOW, EPD_13IN3E_WHITE);
  58. Debug("EPD_Display\r\n");
  59. EPD_13IN3E_DisplayPart(Image, 1000, 0, 200, 200);
  60. DEV_Delay_ms(3000);
  61. #endif
  62. Debug("Clear...\r\n");
  63. EPD_13IN3E_Clear(EPD_13IN3E_WHITE);
  64. DEV_Delay_ms(2000);
  65. Debug("Goto Sleep...\r\n");
  66. EPD_13IN3E_Sleep();
  67. free(Image);
  68. DEV_Delay_ms(2000);
  69. // close 5V
  70. Debug("close 5V, Module enters 0 power consumption ...\r\n");
  71. DEV_Module_Exit();
  72. }
  73. void loop() {
  74. }