Arduino_R4.ino 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #include "EPD_10in85.h"
  2. #include "GUI_Paint.h"
  3. #include "fonts.h"
  4. #include "ImageData.h"
  5. void setup() {
  6. Debug("EPD_10IN85_test Demo\r\n");
  7. DEV_Module_Init();
  8. Debug("e-Paper Init and Clear...\r\n");
  9. EPD_10in85_Init();
  10. EPD_10in85_Clear();
  11. DEV_Delay_ms(500);
  12. //Create a new image cache
  13. UBYTE *Image;
  14. UDOUBLE Imagesize = ((EPD_10in85_WIDTH % 8 == 0)? (EPD_10in85_WIDTH / 8 ): (EPD_10in85_WIDTH / 8 + 1)) * EPD_10in85_HEIGHT;
  15. if((Image = (UBYTE *)malloc(Imagesize/2)) == NULL) {
  16. Debug("Failed to apply for black memory...\r\n");
  17. while (1);
  18. }
  19. Debug("Paint_NewImage\r\n");
  20. Paint_NewImage(Image, EPD_10in85_WIDTH, EPD_10in85_HEIGHT/2, 0, WHITE);
  21. Paint_SetScale(2);
  22. #if 1 // show bmp
  23. EPD_10in85_Display(gImage_image);
  24. DEV_Delay_ms(1500);
  25. #endif
  26. #if 1 // Drawing on the image
  27. Paint_NewImage(Image, EPD_10in85_WIDTH, EPD_10in85_HEIGHT/2, 0, WHITE);
  28. Debug("Drawing\r\n");
  29. //1.Select Image
  30. EPD_10in85_Init();
  31. Paint_SelectImage(Image);
  32. Paint_Clear(WHITE);
  33. Paint_DrawNum(10, 33, 123456789, &Font12, BLACK, WHITE);
  34. Paint_DrawNum(10, 50, 987654321, &Font16, WHITE, BLACK);
  35. Paint_DrawPoint(10, 80, BLACK, DOT_PIXEL_1X1, DOT_STYLE_DFT);
  36. Paint_DrawPoint(10, 90, BLACK, DOT_PIXEL_2X2, DOT_STYLE_DFT);
  37. Paint_DrawPoint(10, 100, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
  38. Paint_DrawPoint(10, 110, BLACK, DOT_PIXEL_3X3, DOT_STYLE_DFT);
  39. Paint_DrawLine(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
  40. Paint_DrawLine(70, 70, 20, 120, BLACK, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
  41. Paint_DrawLine(85, 95, 125, 95, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
  42. Paint_DrawLine(105, 75, 105, 115, BLACK, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
  43. Paint_DrawRectangle(20, 70, 70, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
  44. Paint_DrawRectangle(80, 70, 130, 120, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
  45. Paint_DrawCircle(160, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
  46. Paint_DrawCircle(210, 95, 20, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
  47. Paint_DrawString_EN(10, 0, "waveshare", &Font16, BLACK, WHITE);
  48. Paint_DrawString_EN(10, 20, "hello world", &Font12, WHITE, BLACK);
  49. Paint_DrawString_CN(130, 0,"你好abc", &Font12CN, BLACK, WHITE);
  50. Paint_DrawString_CN(130, 20, "微雪电子", &Font24CN, WHITE, BLACK);
  51. EPD_10in85_Display2(Image);
  52. DEV_Delay_ms(3000);
  53. #endif
  54. #if 1 //Partial refresh, example shows time
  55. // EPD_10in85_Init();
  56. // EPD_10in85_Clear();
  57. EPD_10in85_Init_Part();
  58. // Paint_NewImage(Image, 120, 50, 0, WHITE);
  59. printf("Partial refresh\r\n");
  60. Paint_SelectImage(Image);
  61. // Paint_SetScale(2);
  62. // Paint_Clear(WHITE);
  63. PAINT_TIME sPaint_time;
  64. sPaint_time.Hour = 12;
  65. sPaint_time.Min = 34;
  66. sPaint_time.Sec = 56;
  67. UBYTE num = 5;
  68. for (;;) {
  69. sPaint_time.Sec = sPaint_time.Sec + 1;
  70. if (sPaint_time.Sec == 60) {
  71. sPaint_time.Min = sPaint_time.Min + 1;
  72. sPaint_time.Sec = 0;
  73. if (sPaint_time.Min == 60) {
  74. sPaint_time.Hour = sPaint_time.Hour + 1;
  75. sPaint_time.Min = 0;
  76. if (sPaint_time.Hour == 24) {
  77. sPaint_time.Hour = 0;
  78. sPaint_time.Min = 0;
  79. sPaint_time.Sec = 0;
  80. }
  81. }
  82. }
  83. Paint_Clear(WHITE);
  84. Paint_DrawRectangle(50, 130, 170, 180, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
  85. Paint_DrawTime(60, 145, &sPaint_time, &Font20, WHITE, BLACK);
  86. num = num - 1;
  87. if(num == 0) {
  88. break;
  89. }
  90. printf("Part refresh...\r\n");
  91. EPD_10in85b_Display_Partial(Image, 0, 0, EPD_10in85_WIDTH/2, EPD_10in85_HEIGHT); // Xstart must be a multiple of 8
  92. DEV_Delay_ms(500);
  93. }
  94. #endif
  95. Debug("Clear...\r\n");
  96. EPD_10in85_Init();
  97. EPD_10in85_Clear();
  98. DEV_Delay_ms(500);
  99. Debug("Goto Sleep...\r\n");
  100. EPD_10in85_Sleep();
  101. free(Image);
  102. DEV_Delay_ms(2000);
  103. // close 5V
  104. Debug("close 5V, Module enters 0 power consumption ...\r\n");
  105. DEV_Module_Exit();
  106. }
  107. void loop() {
  108. }