Arduino_R4.ino 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #include "EPD_4in0e.h"
  2. #include "GUI_Paint.h"
  3. #include "fonts.h"
  4. #include "ImageData.h"
  5. void setup() {
  6. Debug("EPD_4IN0E_test Demo\r\n");
  7. DEV_Module_Init();
  8. Debug("e-Paper Init and Clear...\r\n");
  9. EPD_4IN0E_Init();
  10. EPD_4IN0E_Clear(EPD_4IN0E_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_4IN0E_WIDTH % 2 == 0)? (EPD_4IN0E_WIDTH / 2 ): (EPD_4IN0E_WIDTH / 2 + 1)) * EPD_4IN0E_HEIGHT;
  15. if((Image = (UBYTE *)malloc(Imagesize/6)) == 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, EPD_4IN0E_WIDTH/2, EPD_4IN0E_HEIGHT/3, 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_4IN0E_Display(BMP_1);
  28. DEV_Delay_ms(3000);
  29. #endif
  30. #if 1 // Drawing on the image
  31. Paint_NewImage(Image, EPD_4IN0E_WIDTH/2, EPD_4IN0E_HEIGHT/3, 90, EPD_4IN0E_WHITE);
  32. Paint_SetScale(6);
  33. // 1.Select Image
  34. Debug("SelectImage:BlackImage\r\n");
  35. Paint_SelectImage(Image);
  36. Paint_Clear(EPD_4IN0E_WHITE);
  37. // 2.Drawing on the image
  38. Debug("Drawing:BlackImage\r\n");
  39. Paint_DrawPoint(10, 80, EPD_4IN0E_RED, DOT_PIXEL_1X1, DOT_STYLE_DFT);
  40. Paint_DrawPoint(10, 90, EPD_4IN0E_BLUE, DOT_PIXEL_2X2, DOT_STYLE_DFT);
  41. Paint_DrawPoint(10, 100, EPD_4IN0E_GREEN, DOT_PIXEL_3X3, DOT_STYLE_DFT);
  42. Paint_DrawLine(20, 70, 70, 120, EPD_4IN0E_YELLOW, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
  43. Paint_DrawLine(70, 70, 20, 120, EPD_4IN0E_YELLOW, DOT_PIXEL_1X1, LINE_STYLE_SOLID);
  44. Paint_DrawRectangle(20, 70, 70, 120, EPD_4IN0E_BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
  45. Paint_DrawRectangle(80, 70, 130, 120, EPD_4IN0E_BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
  46. Paint_DrawCircle(45, 95, 20, EPD_4IN0E_BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
  47. Paint_DrawCircle(105, 95, 20, EPD_4IN0E_WHITE, DOT_PIXEL_1X1, DRAW_FILL_FULL);
  48. Paint_DrawLine(85, 95, 125, 95, EPD_4IN0E_YELLOW, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
  49. Paint_DrawLine(105, 75, 105, 115, EPD_4IN0E_YELLOW, DOT_PIXEL_1X1, LINE_STYLE_DOTTED);
  50. Paint_DrawString_CN(10, 130, "你好abc", &Font12CN, EPD_4IN0E_BLACK, EPD_4IN0E_WHITE);
  51. Paint_DrawString_CN(10, 150, "微雪电子", &Font24CN, EPD_4IN0E_WHITE, EPD_4IN0E_BLACK);
  52. Paint_DrawNum(10, 33, 123456789, &Font12, EPD_4IN0E_BLACK, EPD_4IN0E_WHITE);
  53. Paint_DrawNum(10, 50, 987654321, &Font16, EPD_4IN0E_WHITE, EPD_4IN0E_BLACK);
  54. Paint_DrawString_EN(145, 0, "Waveshare", &Font16, EPD_4IN0E_BLACK, EPD_4IN0E_WHITE);
  55. Paint_DrawString_EN(145, 35, "Waveshare", &Font16, EPD_4IN0E_GREEN, EPD_4IN0E_WHITE);
  56. Paint_DrawString_EN(145, 70, "Waveshare", &Font16, EPD_4IN0E_BLUE, EPD_4IN0E_WHITE);
  57. Paint_DrawString_EN(145, 105, "Waveshare", &Font16, EPD_4IN0E_RED, EPD_4IN0E_WHITE);
  58. Paint_DrawString_EN(145, 140, "Waveshare", &Font16, EPD_4IN0E_YELLOW, EPD_4IN0E_WHITE);
  59. Debug("EPD_Display\r\n");
  60. EPD_4IN0E_DisplayPart(Image, 100, 150, 200, 200);
  61. DEV_Delay_ms(3000);
  62. #endif
  63. Debug("Clear...\r\n");
  64. EPD_4IN0E_Clear(EPD_4IN0E_WHITE);
  65. DEV_Delay_ms(2000);
  66. Debug("Goto Sleep...\r\n");
  67. EPD_4IN0E_Sleep();
  68. free(Image);
  69. DEV_Delay_ms(2000);
  70. // close 5V
  71. Debug("close 5V, Module enters 0 power consumption ...\r\n");
  72. DEV_Module_Exit();
  73. }
  74. void loop() {
  75. }