gui_paint.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. /******************************************************************************
  2. * | File : GUI_Paint.h
  3. * | Author : Waveshare electronics
  4. * | Function : Achieve drawing: draw points, lines, boxes, circles and
  5. * their size, solid dotted line, solid rectangle hollow
  6. * rectangle, solid circle hollow circle.
  7. * | Info :
  8. * Achieve display characters: Display a single character, string, number
  9. * Achieve time display: adaptive size display time minutes and seconds
  10. *----------------
  11. * | This version: V3.0
  12. * | Date : 2019-04-18
  13. * | Info :
  14. * -----------------------------------------------------------------------------
  15. * V3.0(2019-04-18):
  16. * 1.Change:
  17. * Paint_DrawPoint(..., DOT_STYLE DOT_STYLE)
  18. * => Paint_DrawPoint(..., DOT_STYLE Dot_Style)
  19. * Paint_DrawLine(..., LINE_STYLE Line_Style, DOT_PIXEL Dot_Pixel)
  20. * => Paint_DrawLine(..., DOT_PIXEL Line_width, LINE_STYLE Line_Style)
  21. * Paint_DrawRectangle(..., DRAW_FILL Filled, DOT_PIXEL Dot_Pixel)
  22. * => Paint_DrawRectangle(..., DOT_PIXEL Line_width, DRAW_FILL Draw_Fill)
  23. * Paint_DrawCircle(..., DRAW_FILL Draw_Fill, DOT_PIXEL Dot_Pixel)
  24. * => Paint_DrawCircle(..., DOT_PIXEL Line_width, DRAW_FILL Draw_Filll)
  25. *
  26. * -----------------------------------------------------------------------------
  27. * V2.0(2018-11-15):
  28. * 1.add: Paint_NewImage()
  29. * Create an image's properties
  30. * 2.add: Paint_SelectImage()
  31. * Select the picture to be drawn
  32. * 3.add: Paint_SetRotate()
  33. * Set the direction of the cache
  34. * 4.add: Paint_RotateImage()
  35. * Can flip the picture, Support 0-360 degrees,
  36. * but only 90.180.270 rotation is better
  37. * 4.add: Paint_SetMirroring()
  38. * Can Mirroring the picture, horizontal, vertical, origin
  39. * 5.add: Paint_DrawString_CN()
  40. * Can display Chinese(GB1312)
  41. *
  42. * -----------------------------------------------------------------------------
  43. * V1.0(2018-07-17):
  44. * Create library
  45. *
  46. * Permission is hereby granted, free of charge, to any person obtaining a copy
  47. * of this software and associated documnetation files (the "Software"), to deal
  48. * in the Software without restriction, including without limitation the rights
  49. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  50. * copies of the Software, and to permit persons to whom the Software is
  51. * furished to do so, subject to the following conditions:
  52. *
  53. * The above copyright notice and this permission notice shall be included in
  54. * all copies or substantial portions of the Software.
  55. *
  56. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  57. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  58. * FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  59. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  60. * LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  61. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  62. * THE SOFTWARE.
  63. *
  64. ******************************************************************************/
  65. #ifndef __GUI_PAINT_H
  66. #define __GUI_PAINT_H
  67. #include "epd_config.h"
  68. //#include "fonts.h"
  69. /**
  70. * Image attributes
  71. **/
  72. typedef struct {
  73. UBYTE *Image;
  74. UWORD Width;
  75. UWORD Height;
  76. UWORD WidthMemory;
  77. UWORD HeightMemory;
  78. UWORD Color;
  79. UWORD Rotate;
  80. UWORD Mirror;
  81. UWORD WidthByte;
  82. UWORD HeightByte;
  83. UWORD Scale;
  84. } PAINT;
  85. extern PAINT Paint;
  86. /**
  87. * Display rotate
  88. **/
  89. #define ROTATE_0 0
  90. #define ROTATE_90 90
  91. #define ROTATE_180 180
  92. #define ROTATE_270 270
  93. /**
  94. * Display Flip
  95. **/
  96. typedef enum {
  97. MIRROR_NONE = 0x00,
  98. MIRROR_HORIZONTAL = 0x01,
  99. MIRROR_VERTICAL = 0x02,
  100. MIRROR_ORIGIN = 0x03,
  101. } MIRROR_IMAGE;
  102. #define MIRROR_IMAGE_DFT MIRROR_NONE
  103. /**
  104. * image color
  105. **/
  106. #define WHITE 0xFF
  107. #define BLACK 0x00
  108. #define RED BLACK
  109. #define IMAGE_BACKGROUND WHITE
  110. #define FONT_FOREGROUND BLACK
  111. #define FONT_BACKGROUND WHITE
  112. #define TRUE 1
  113. #define FALSE 0
  114. //4 Gray level
  115. #define GRAY1 0x03 //Blackest
  116. #define GRAY2 0x02
  117. #define GRAY3 0x01 //gray
  118. #define GRAY4 0x00 //white
  119. /**
  120. * The size of the point
  121. **/
  122. typedef enum {
  123. DOT_PIXEL_1X1 = 1, // 1 x 1
  124. DOT_PIXEL_2X2 , // 2 X 2
  125. DOT_PIXEL_3X3 , // 3 X 3
  126. DOT_PIXEL_4X4 , // 4 X 4
  127. DOT_PIXEL_5X5 , // 5 X 5
  128. DOT_PIXEL_6X6 , // 6 X 6
  129. DOT_PIXEL_7X7 , // 7 X 7
  130. DOT_PIXEL_8X8 , // 8 X 8
  131. } DOT_PIXEL;
  132. #define DOT_PIXEL_DFT DOT_PIXEL_1X1 //Default dot pilex
  133. /**
  134. * Point size fill style
  135. **/
  136. typedef enum {
  137. DOT_FILL_AROUND = 1, // dot pixel 1 x 1
  138. DOT_FILL_RIGHTUP , // dot pixel 2 X 2
  139. } DOT_STYLE;
  140. #define DOT_STYLE_DFT DOT_FILL_AROUND //Default dot pilex
  141. /**
  142. * Line style, solid or dashed
  143. **/
  144. typedef enum {
  145. LINE_STYLE_SOLID = 0,
  146. LINE_STYLE_DOTTED,
  147. } LINE_STYLE;
  148. /**
  149. * Whether the graphic is filled
  150. **/
  151. typedef enum {
  152. DRAW_FILL_EMPTY = 0,
  153. DRAW_FILL_FULL,
  154. } DRAW_FILL;
  155. /**
  156. * Custom structure of a time attribute
  157. **/
  158. typedef struct {
  159. UWORD Year; //0000
  160. UBYTE Month; //1 - 12
  161. UBYTE Day; //1 - 30
  162. UBYTE Hour; //0 - 23
  163. UBYTE Min; //0 - 59
  164. UBYTE Sec; //0 - 59
  165. } PAINT_TIME;
  166. extern PAINT_TIME sPaint_time;
  167. //init and Clear
  168. void Paint_NewImage(UBYTE *image, UWORD Width, UWORD Height, UWORD Rotate, UWORD Color);
  169. void Paint_SelectImage(UBYTE *image);
  170. void Paint_SetRotate(UWORD Rotate);
  171. void Paint_SetMirroring(UBYTE mirror);
  172. void Paint_SetPixel(UWORD Xpoint, UWORD Ypoint, UWORD Color);
  173. void Paint_SetScale(UBYTE scale);
  174. void Paint_Clear(UWORD Color);
  175. void Paint_ClearWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD Color);
  176. //Drawing
  177. void Paint_DrawPoint(UWORD Xpoint, UWORD Ypoint, UWORD Color, DOT_PIXEL Dot_Pixel, DOT_STYLE Dot_FillWay);
  178. void Paint_DrawLine(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD Color, DOT_PIXEL Line_width, LINE_STYLE Line_Style);
  179. void Paint_DrawRectangle(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD Color, DOT_PIXEL Line_width, DRAW_FILL Draw_Fill);
  180. void Paint_DrawCircle(UWORD X_Center, UWORD Y_Center, UWORD Radius, UWORD Color, DOT_PIXEL Line_width, DRAW_FILL Draw_Fill);
  181. //Display string
  182. //void Paint_DrawChar(UWORD Xstart, UWORD Ystart, const char Acsii_Char, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background);
  183. //void Paint_DrawString_EN(UWORD Xstart, UWORD Ystart, const char * pString, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background);
  184. //void Paint_DrawString_CN(UWORD Xstart, UWORD Ystart, const char * pString, cFONT* font, UWORD Color_Foreground, UWORD Color_Background);
  185. //void Paint_DrawNum(UWORD Xpoint, UWORD Ypoint, int32_t Nummber, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background);
  186. //void Paint_DrawNumDecimals(UWORD Xpoint, UWORD Ypoint, double Nummber, sFONT* Font, UWORD Digit, UWORD Color_Foreground, UWORD Color_Background); // Able to display decimals
  187. //void Paint_DrawTime(UWORD Xstart, UWORD Ystart, PAINT_TIME *pTime, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background);
  188. //pic
  189. void Paint_DrawBitMap(const unsigned char* image_buffer);
  190. void Paint_DrawBitMap_Paste(const unsigned char* image_buffer, UWORD Xstart, UWORD Ystart, UWORD imageWidth, UWORD imageHeight, UBYTE flipColor);
  191. //void Paint_DrawBitMap_Half(const unsigned char* image_buffer, UBYTE Region);
  192. //void Paint_DrawBitMap_OneQuarter(const unsigned char* image_buffer, UBYTE Region);
  193. //void Paint_DrawBitMap_OneEighth(const unsigned char* image_buffer, UBYTE Region);
  194. void Paint_DrawBitMap_Block(const unsigned char* image_buffer, UBYTE Region);
  195. #endif