Waleed Elmughrabi / epd1in54

Dependents:   Sample_program_Font72

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers epd1in54.h Source File

epd1in54.h

00001 /**
00002  *  @filename   :   epd1in54.h
00003  *  @brief      :   Header file for e-paper display library epd1in54b.cpp
00004  *  @author     :   Yehui from Waveshare
00005  *  
00006  *  Copyright (C) Waveshare     August 10 2017
00007  *
00008  * Permission is hereby granted, free of charge, to any person obtaining a copy
00009  * of this software and associated documnetation files (the "Software"), to deal
00010  * in the Software without restriction, including without limitation the rights
00011  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00012  * copies of the Software, and to permit persons to  whom the Software is
00013  * furished to do so, subject to the following conditions:
00014  *
00015  * The above copyright notice and this permission notice shall be included in
00016  * all copies or substantial portions of the Software.
00017  *
00018  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00019  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00020  * FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00021  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00022  * LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00023  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00024  * THE SOFTWARE.
00025  */
00026 
00027 #ifndef EPD1IN54_H
00028 #define EPD1IN54_H
00029 
00030 #include "epdif.h"
00031 #include "fonts.h"
00032 
00033 #define LOW  0
00034 #define HIGH 1
00035 
00036 // Display resolution
00037 #define EPD_WIDTH       200
00038 #define EPD_HEIGHT      200
00039 
00040 #define  COLORED        1
00041 #define  UNCOLORED      0
00042 
00043 // EPD1IN54 commands
00044 #define DRIVER_OUTPUT_CONTROL                       0x01
00045 #define BOOSTER_SOFT_START_CONTROL                  0x0C
00046 #define GATE_SCAN_START_POSITION                    0x0F
00047 #define DEEP_SLEEP_MODE                             0x10
00048 #define DATA_ENTRY_MODE_SETTING                     0x11
00049 #define SW_RESET                                    0x12
00050 #define TEMPERATURE_SENSOR_CONTROL                  0x1A
00051 #define MASTER_ACTIVATION                           0x20
00052 #define DISPLAY_UPDATE_CONTROL_1                    0x21
00053 #define DISPLAY_UPDATE_CONTROL_2                    0x22
00054 #define WRITE_RAM                                   0x24
00055 #define WRITE_VCOM_REGISTER                         0x2C
00056 #define WRITE_LUT_REGISTER                          0x32
00057 #define SET_DUMMY_LINE_PERIOD                       0x3A
00058 #define SET_GATE_TIME                               0x3B
00059 #define BORDER_WAVEFORM_CONTROL                     0x3C
00060 #define SET_RAM_X_ADDRESS_START_END_POSITION        0x44
00061 #define SET_RAM_Y_ADDRESS_START_END_POSITION        0x45
00062 #define SET_RAM_X_ADDRESS_COUNTER                   0x4E
00063 #define SET_RAM_Y_ADDRESS_COUNTER                   0x4F
00064 #define TERMINATE_FRAME_READ_WRITE                  0xFF
00065 
00066 // Display orientation
00067 #define ROTATE_0                                     0
00068 #define ROTATE_90                                    1
00069 #define ROTATE_180                                   2
00070 #define ROTATE_270                                   3
00071 
00072 extern const unsigned char lut_full_update[];
00073 extern const unsigned char lut_partial_update[];
00074 
00075 class Epd : EpdIf {
00076 public:
00077     unsigned long width;
00078     unsigned long height;
00079     unsigned int rotate;
00080 
00081 
00082     Epd(PinName mosi,
00083         PinName miso,
00084         PinName sclk, 
00085         PinName cs, 
00086         PinName dc, 
00087         PinName rst, 
00088         PinName busy
00089         );
00090     ~Epd();
00091     int  Init(const unsigned char* lut);
00092     void SendCommand(unsigned char command);
00093     void SendData(unsigned char data);
00094     void WaitUntilIdle(void);
00095     void Reset(void);
00096 
00097     void SetLut(const unsigned char* lut);
00098     void SetMemoryArea(int x_start, int y_start, int x_end, int y_end);
00099     void SetMemoryPointer(int x, int y);
00100     void SetFrameMemory(const unsigned char* image_buffer, int x, int y, int image_width, int image_height);
00101     void ClearFrameMemory(unsigned char color);
00102     void DisplayFrame(void);
00103     
00104     void Sleep(void);
00105     void SetRotate(int rotate);
00106     void SetPixel(unsigned char *frame_buffer, int x, int y, int colored);
00107     void SetAbsolutePixel(unsigned char *frame_buffer, int x, int y, int colored); 
00108     void DrawLine(unsigned char *frame_buffer, int x0, int y0, int x1, int y1, int colored);
00109     void DrawHorizontalLine(unsigned char *frame_buffer, int x, int y, int width, int colored);
00110     void DrawVerticalLine(unsigned char *frame_buffer, int x, int y, int height, int colored);
00111     void DrawRectangle(unsigned char *frame_buffer, int x0, int y0, int x1, int y1, int colored);
00112     void DrawFilledRectangle(unsigned char *frame_buffer, int x0, int y0, int x1, int y1, int colored);
00113     void DrawCircle(unsigned char *frame_buffer, int x, int y, int radius, int colored);
00114     void DrawFilledCircle(unsigned char *frame_buffer, int x, int y, int radius, int colored);
00115     void DrawCharAt(unsigned char *frame_buffer, int x, int y, char ascii_char, sFONT* font, int colored);
00116     void DrawStringAt(unsigned char *frame_buffer, int x, int y, const char* text, sFONT* font, int colored);
00117 
00118 
00119 };
00120 
00121 #endif /* EPD1IN54_H */
00122 
00123 /* END OF FILE */