123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315 |
- /******************************************************************************
- * | File : GUI_Paint.h
- * | Author : Waveshare electronics
- * | Function : Achieve drawing: draw points, lines, boxes, circles and
- * their size, solid dotted line, solid rectangle hollow
- * rectangle, solid circle hollow circle.
- * | Info :
- * Achieve display characters: Display a single character, string, number
- * Achieve time display: adaptive size display time minutes and seconds
- *----------------
- * | This version: V3.0
- * | Date : 2019-04-18
- * | Info :
- * -----------------------------------------------------------------------------
- * V3.0(2019-04-18):
- * 1.Change:
- * Paint_DrawPoint(..., DOT_STYLE DOT_STYLE)
- * => Paint_DrawPoint(..., DOT_STYLE Dot_Style)
- * Paint_DrawLine(..., LINE_STYLE Line_Style, DOT_PIXEL Dot_Pixel)
- * => Paint_DrawLine(..., DOT_PIXEL Line_width, LINE_STYLE Line_Style)
- * Paint_DrawRectangle(..., DRAW_FILL Filled, DOT_PIXEL Dot_Pixel)
- * => Paint_DrawRectangle(..., DOT_PIXEL Line_width, DRAW_FILL Draw_Fill)
- * Paint_DrawCircle(..., DRAW_FILL Draw_Fill, DOT_PIXEL Dot_Pixel)
- * => Paint_DrawCircle(..., DOT_PIXEL Line_width, DRAW_FILL Draw_Filll)
- *
- * -----------------------------------------------------------------------------
- * V2.0(2018-11-15):
- * 1.add: Paint_NewImage()
- * Create an image's properties
- * 2.add: Paint_SelectImage()
- * Select the picture to be drawn
- * 3.add: Paint_SetRotate()
- * Set the direction of the cache
- * 4.add: Paint_RotateImage()
- * Can flip the picture, Support 0-360 degrees,
- * but only 90.180.270 rotation is better
- * 4.add: Paint_SetMirroring()
- * Can Mirroring the picture, horizontal, vertical, origin
- * 5.add: Paint_DrawString_CN()
- * Can display Chinese(GB1312)
- *
- * -----------------------------------------------------------------------------
- * V1.0(2018-07-17):
- * Create library
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documnetation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- ******************************************************************************/
- #ifndef __GUI_PAINT_H
- #define __GUI_PAINT_H
- #include "esp_log.h"
- #define UBYTE uint8_t
- #define UWORD uint16_t
- #define UDOUBLE uint32_t
- //whc set start
- // extern const unsigned char gImage_right[38880];
- // extern const unsigned char gImage_mid[38880];
- // extern const unsigned char gImage_left[38880];
- // extern const unsigned char gImage_baoyang[600];
- // extern const unsigned char gImage_yunxing[600];
- // extern const unsigned char gImage_tingji[600];
- // extern const unsigned char gImage_dailiao[600];
- // extern const unsigned char gImage_guzhang[600];
- // extern const unsigned char gImage_fengcun[600];
- //extern const unsigned char gImage_in_battery[16];
- extern const unsigned char gImage_none_people[75];
- extern const unsigned char gImage_people[75];
- extern const unsigned char gImage_no_sound[72];
- extern const unsigned char gImage_sound[72];
- extern const unsigned char gImage_battery[90];
- extern const unsigned char gImage_right_[15360];
- extern const unsigned char gImage_mid_[15360];
- extern const unsigned char gImage_left_[15360];
- extern const unsigned char gImage_button[576];
- extern const unsigned char gImage_button_128x64[1024];
- extern const unsigned char gImage_nfc[264];
- extern const unsigned char gImage_bat_ing[90];
- extern const unsigned char gImage_charging[18];
- extern const unsigned char gImage_filled[18];
- extern const unsigned char gImage_left_instructions[38880];
- extern const unsigned char gImage_right_instruction[38880];
- extern const unsigned char gImage_low_batt[8162];
- extern const unsigned char gImage_online[90];
- typedef struct _font_type_t
- {
- char *font_type_name;
- uint16_t Font_lib_type;
- uint16_t Font_Width;
- uint16_t Font_Height;
- }FONT_TYPE_T;
- //whc set end
- typedef struct _tFont
- {
- uint8_t *table;
- uint16_t Width;
- uint16_t Height;
- uint8_t font_size;
- uint16_t font_num;
-
- } sFONT;
- //#define LOG_TAG "GUI_PAINT"
- #define Debug(INFO, ... ) ESP_LOGD("GUI_PAINT", INFO, ##__VA_ARGS__)
- /**
- * Image attributes
- **/
- typedef struct {
- UBYTE *Image;
- UWORD Width;
- UWORD Height;
- UWORD WidthMemory;
- UWORD HeightMemory;
- UWORD Color;
- UWORD Rotate;
- UWORD Mirror;
- UWORD WidthByte;
- UWORD HeightByte;
- UWORD Scale;
- } PAINT;
- extern PAINT Paint_info;
- // extern PAINT Paint_left_info;
- // extern PAINT Paint_right_info;
- /**
- * Display rotate
- **/
- #define ROTATE_0 0
- #define ROTATE_90 90
- #define ROTATE_180 180
- #define ROTATE_270 270
- /**
- * Display Flip
- **/
- typedef enum {
- MIRROR_NONE = 0x00,
- MIRROR_HORIZONTAL = 0x01,
- MIRROR_VERTICAL = 0x02,
- MIRROR_ORIGIN = 0x03,
- } MIRROR_IMAGE;
- #define MIRROR_IMAGE_DFT MIRROR_NONE
- /**
- * image color
- **/
- #define WHITE 0x00
- #define BLACK 0xff
- #define RED BLACK
- //
- #define FONT_FOREGROUND BLACK
- #define FONT_BACKGROUND WHITE
- #define IMAGE_BACKGROUND WHITE
- #define PAINT_FOREGROUND BLACK
- #define PAINT_BACKGROUND WHITE
- #define TRUE 1
- #define FALSE 0
- //4 Gray level
- #define GRAY1 0x03 //Blackest
- #define GRAY2 0x02
- #define GRAY3 0x01 //gray
- #define GRAY4 0x00 //white
- /**
- * The size of the point
- **/
- typedef enum {
- DOT_PIXEL_1X1 = 1, // 1 x 1
- DOT_PIXEL_2X2 , // 2 X 2
- DOT_PIXEL_3X3 , // 3 X 3
- DOT_PIXEL_4X4 , // 4 X 4
- DOT_PIXEL_5X5 , // 5 X 5
- DOT_PIXEL_6X6 , // 6 X 6
- DOT_PIXEL_7X7 , // 7 X 7
- DOT_PIXEL_8X8 , // 8 X 8
- } DOT_PIXEL;
- #define DOT_PIXEL_DFT DOT_PIXEL_1X1 //Default dot pilex
- /**
- * Point size fill style
- **/
- typedef enum {
- DOT_FILL_AROUND = 1, // dot pixel 1 x 1
- DOT_FILL_RIGHTUP , // dot pixel 2 X 2
- } DOT_STYLE;
- #define DOT_STYLE_DFT DOT_FILL_AROUND //Default dot pilex
- /**
- * Line style, solid or dashed
- **/
- typedef enum {
- LINE_STYLE_SOLID = 0,
- LINE_STYLE_DOTTED,
- LINE_STYLE_DOTTED_2,
- } LINE_STYLE;
- /**
- * Whether the graphic is filled
- **/
- typedef enum {
- DRAW_FILL_EMPTY = 0,
- DRAW_FILL_FULL,
- } DRAW_FILL;
- /**
- * Custom structure of a time attribute
- **/
- typedef struct {
- UWORD Year; //0000
- UBYTE Month; //1 - 12
- UBYTE Day; //1 - 30
- UBYTE Hour; //0 - 23
- UBYTE Min; //0 - 59
- UBYTE Sec; //0 - 59
- } PAINT_TIME;
- extern PAINT_TIME Paint_time_info;
- //init and Clear
- void Paint_NewImage(UBYTE *image, UWORD Width, UWORD Height, UWORD Rotate, UWORD Color );
- void Paint_SelectImage(UBYTE *image );
- void Paint_SetRotate(UWORD Rotate );
- void Paint_SetMirroring(UBYTE mirror );
- void Paint_SetPixel(UWORD Xpoint, UWORD Ypoint, UWORD Color );
- void Paint_SetScale(UBYTE scale );
- void Paint_Clear(UWORD Color );
- void Paint_ClearWindows(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD Color );
- //Drawing
- void Paint_DrawPoint(UWORD Xpoint, UWORD Ypoint, UWORD Color, DOT_PIXEL Dot_Pixel, DOT_STYLE Dot_FillWay );
- void Paint_DrawLine(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD Color_Background, DOT_PIXEL Line_width, LINE_STYLE Line_Style );
- void Paint_DrawRectangle(UWORD Xstart, UWORD Ystart, UWORD Xend, UWORD Yend, UWORD Color_Background, DOT_PIXEL Line_width, DRAW_FILL Draw_Fill );
- void Paint_DrawCircle(UWORD X_Center, UWORD Y_Center, UWORD Radius, UWORD Color_Background, DOT_PIXEL Line_width, DRAW_FILL Draw_Fill );
- // //Display string
- void Paint_DrawChar(UWORD Xpoint, UWORD Ypoint, const char Acsii_Char,FONT_TYPE_T* Ascii_type, UWORD Color_Foreground, UWORD Color_Background );
- void Paint_DrawString_EN(UWORD Xstart, UWORD Ystart, const char * pString,FONT_TYPE_T* Ascii_type, UWORD Color_Foreground, UWORD Color_Background );
- void Paint_DrawChar_CN(UWORD Xstart, UWORD Ystart, const char * pString, FONT_TYPE_T* chinese_type,UWORD Color_Foreground, UWORD Color_Background );
- void Paint_DrawString_CN(UWORD Xstart, UWORD Ystart, const char * pString, FONT_TYPE_T* chinese_type, UWORD Color_Foreground, UWORD Color_Background );
- void Paint_DrawTime(UWORD Xstart, UWORD Ystart, PAINT_TIME *pTime, FONT_TYPE_T* Font_type,UWORD Color_Foreground, UWORD Color_Background );
- void Paint_DrawString_CN48(UWORD Xstart, UWORD Ystart, const char * pString , int is_black);
- void Paint_DrawChar_CN64(UWORD Xstart, UWORD Ystart, const char * pString );
- void Paint_DrawString_CN64(UWORD Xstart, UWORD Ystart, const char * pString );
- // void Paint_DrawString_CN(UWORD Xstart, UWORD Ystart, const char * pString, cFONT* font, UWORD Color_Foreground, UWORD Color_Background);
- // void Paint_DrawNum(UWORD Xpoint, UWORD Ypoint, int32_t Nummber, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background);
- // void Paint_DrawNumDecimals(UWORD Xpoint, UWORD Ypoint, double Nummber, sFONT* Font, UWORD Digit, UWORD Color_Foreground, UWORD Color_Background); // Able to display decimals
- // void Paint_DrawTime(UWORD Xstart, UWORD Ystart, PAINT_TIME *pTime, sFONT* Font, UWORD Color_Foreground, UWORD Color_Background);
- //pic
- void Paint_DrawBitMap_Vertical(const unsigned char* image_buffer );
- void Paint_DrawBitMap(const unsigned char* image_buffer );
- void Paint_DrawBitMap_Paste(const unsigned char* image_buffer, UWORD Xstart, UWORD Ystart, UWORD imageWidth, UWORD imageHeight, UBYTE flipColor );
- //void Paint_DrawBitMap_Half(const unsigned char* image_buffer, UBYTE Region);
- //void Paint_DrawBitMap_OneQuarter(const unsigned char* image_buffer, UBYTE Region);
- //void Paint_DrawBitMap_OneEighth(const unsigned char* image_buffer, UBYTE Region);
- void Paint_DrawBitMap_Block(const unsigned char* image_buffer, UBYTE Region );
- void Paint_DrawBitMap_Paste_t(const unsigned char* image_buffer, UWORD xStart, UWORD yStart, UWORD imageWidth,
- UWORD imageHeight, UBYTE flipColor );
- void drawQuadraticBezierCurve(uint8_t* framebuffer, int width, int height,
- int x0, int y0, int x1, int y1, int x2, int y2,
- uint8_t color, int thickness) ;
- void drawQuadraticBezierCurve_do(uint8_t* framebuffer, int width, int height,
- int x0, int y0, int x1, int y1, int x2, int y2,
- uint8_t color, int thickness);
- #endif
|