WaveShare e-paper module (epd1in54). Monochrome version

Dependents:   Sample_program_Font72

Committer:
WaleedElmughrabi
Date:
Mon Jan 07 19:16:55 2019 +0000
Revision:
3:c1311dd92ca2
Parent:
0:ac97d71fe296
Added font72 (numbers only)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
imachooon 0:ac97d71fe296 1 /**
imachooon 0:ac97d71fe296 2 * @filename : epd1in54.h
imachooon 0:ac97d71fe296 3 * @brief : Header file for e-paper display library epd1in54b.cpp
imachooon 0:ac97d71fe296 4 * @author : Yehui from Waveshare
imachooon 0:ac97d71fe296 5 *
imachooon 0:ac97d71fe296 6 * Copyright (C) Waveshare August 10 2017
imachooon 0:ac97d71fe296 7 *
imachooon 0:ac97d71fe296 8 * Permission is hereby granted, free of charge, to any person obtaining a copy
imachooon 0:ac97d71fe296 9 * of this software and associated documnetation files (the "Software"), to deal
imachooon 0:ac97d71fe296 10 * in the Software without restriction, including without limitation the rights
imachooon 0:ac97d71fe296 11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
imachooon 0:ac97d71fe296 12 * copies of the Software, and to permit persons to whom the Software is
imachooon 0:ac97d71fe296 13 * furished to do so, subject to the following conditions:
imachooon 0:ac97d71fe296 14 *
imachooon 0:ac97d71fe296 15 * The above copyright notice and this permission notice shall be included in
imachooon 0:ac97d71fe296 16 * all copies or substantial portions of the Software.
imachooon 0:ac97d71fe296 17 *
imachooon 0:ac97d71fe296 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
imachooon 0:ac97d71fe296 19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
imachooon 0:ac97d71fe296 20 * FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
imachooon 0:ac97d71fe296 21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
imachooon 0:ac97d71fe296 22 * LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
imachooon 0:ac97d71fe296 23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
imachooon 0:ac97d71fe296 24 * THE SOFTWARE.
imachooon 0:ac97d71fe296 25 */
imachooon 0:ac97d71fe296 26
imachooon 0:ac97d71fe296 27 #ifndef EPD1IN54_H
imachooon 0:ac97d71fe296 28 #define EPD1IN54_H
imachooon 0:ac97d71fe296 29
imachooon 0:ac97d71fe296 30 #include "epdif.h"
imachooon 0:ac97d71fe296 31 #include "fonts.h"
imachooon 0:ac97d71fe296 32
imachooon 0:ac97d71fe296 33 #define LOW 0
imachooon 0:ac97d71fe296 34 #define HIGH 1
imachooon 0:ac97d71fe296 35
imachooon 0:ac97d71fe296 36 // Display resolution
imachooon 0:ac97d71fe296 37 #define EPD_WIDTH 200
imachooon 0:ac97d71fe296 38 #define EPD_HEIGHT 200
imachooon 0:ac97d71fe296 39
imachooon 0:ac97d71fe296 40 #define COLORED 1
imachooon 0:ac97d71fe296 41 #define UNCOLORED 0
imachooon 0:ac97d71fe296 42
imachooon 0:ac97d71fe296 43 // EPD1IN54 commands
imachooon 0:ac97d71fe296 44 #define DRIVER_OUTPUT_CONTROL 0x01
imachooon 0:ac97d71fe296 45 #define BOOSTER_SOFT_START_CONTROL 0x0C
imachooon 0:ac97d71fe296 46 #define GATE_SCAN_START_POSITION 0x0F
imachooon 0:ac97d71fe296 47 #define DEEP_SLEEP_MODE 0x10
imachooon 0:ac97d71fe296 48 #define DATA_ENTRY_MODE_SETTING 0x11
imachooon 0:ac97d71fe296 49 #define SW_RESET 0x12
imachooon 0:ac97d71fe296 50 #define TEMPERATURE_SENSOR_CONTROL 0x1A
imachooon 0:ac97d71fe296 51 #define MASTER_ACTIVATION 0x20
imachooon 0:ac97d71fe296 52 #define DISPLAY_UPDATE_CONTROL_1 0x21
imachooon 0:ac97d71fe296 53 #define DISPLAY_UPDATE_CONTROL_2 0x22
imachooon 0:ac97d71fe296 54 #define WRITE_RAM 0x24
imachooon 0:ac97d71fe296 55 #define WRITE_VCOM_REGISTER 0x2C
imachooon 0:ac97d71fe296 56 #define WRITE_LUT_REGISTER 0x32
imachooon 0:ac97d71fe296 57 #define SET_DUMMY_LINE_PERIOD 0x3A
imachooon 0:ac97d71fe296 58 #define SET_GATE_TIME 0x3B
imachooon 0:ac97d71fe296 59 #define BORDER_WAVEFORM_CONTROL 0x3C
imachooon 0:ac97d71fe296 60 #define SET_RAM_X_ADDRESS_START_END_POSITION 0x44
imachooon 0:ac97d71fe296 61 #define SET_RAM_Y_ADDRESS_START_END_POSITION 0x45
imachooon 0:ac97d71fe296 62 #define SET_RAM_X_ADDRESS_COUNTER 0x4E
imachooon 0:ac97d71fe296 63 #define SET_RAM_Y_ADDRESS_COUNTER 0x4F
imachooon 0:ac97d71fe296 64 #define TERMINATE_FRAME_READ_WRITE 0xFF
imachooon 0:ac97d71fe296 65
imachooon 0:ac97d71fe296 66 // Display orientation
imachooon 0:ac97d71fe296 67 #define ROTATE_0 0
imachooon 0:ac97d71fe296 68 #define ROTATE_90 1
imachooon 0:ac97d71fe296 69 #define ROTATE_180 2
imachooon 0:ac97d71fe296 70 #define ROTATE_270 3
imachooon 0:ac97d71fe296 71
imachooon 0:ac97d71fe296 72 extern const unsigned char lut_full_update[];
imachooon 0:ac97d71fe296 73 extern const unsigned char lut_partial_update[];
imachooon 0:ac97d71fe296 74
imachooon 0:ac97d71fe296 75 class Epd : EpdIf {
imachooon 0:ac97d71fe296 76 public:
imachooon 0:ac97d71fe296 77 unsigned long width;
imachooon 0:ac97d71fe296 78 unsigned long height;
imachooon 0:ac97d71fe296 79 unsigned int rotate;
imachooon 0:ac97d71fe296 80
imachooon 0:ac97d71fe296 81
imachooon 0:ac97d71fe296 82 Epd(PinName mosi,
imachooon 0:ac97d71fe296 83 PinName miso,
imachooon 0:ac97d71fe296 84 PinName sclk,
imachooon 0:ac97d71fe296 85 PinName cs,
imachooon 0:ac97d71fe296 86 PinName dc,
imachooon 0:ac97d71fe296 87 PinName rst,
imachooon 0:ac97d71fe296 88 PinName busy
imachooon 0:ac97d71fe296 89 );
imachooon 0:ac97d71fe296 90 ~Epd();
imachooon 0:ac97d71fe296 91 int Init(const unsigned char* lut);
imachooon 0:ac97d71fe296 92 void SendCommand(unsigned char command);
imachooon 0:ac97d71fe296 93 void SendData(unsigned char data);
imachooon 0:ac97d71fe296 94 void WaitUntilIdle(void);
imachooon 0:ac97d71fe296 95 void Reset(void);
imachooon 0:ac97d71fe296 96
imachooon 0:ac97d71fe296 97 void SetLut(const unsigned char* lut);
imachooon 0:ac97d71fe296 98 void SetMemoryArea(int x_start, int y_start, int x_end, int y_end);
imachooon 0:ac97d71fe296 99 void SetMemoryPointer(int x, int y);
imachooon 0:ac97d71fe296 100 void SetFrameMemory(const unsigned char* image_buffer, int x, int y, int image_width, int image_height);
imachooon 0:ac97d71fe296 101 void ClearFrameMemory(unsigned char color);
imachooon 0:ac97d71fe296 102 void DisplayFrame(void);
imachooon 0:ac97d71fe296 103
imachooon 0:ac97d71fe296 104 void Sleep(void);
imachooon 0:ac97d71fe296 105 void SetRotate(int rotate);
imachooon 0:ac97d71fe296 106 void SetPixel(unsigned char *frame_buffer, int x, int y, int colored);
imachooon 0:ac97d71fe296 107 void SetAbsolutePixel(unsigned char *frame_buffer, int x, int y, int colored);
imachooon 0:ac97d71fe296 108 void DrawLine(unsigned char *frame_buffer, int x0, int y0, int x1, int y1, int colored);
imachooon 0:ac97d71fe296 109 void DrawHorizontalLine(unsigned char *frame_buffer, int x, int y, int width, int colored);
imachooon 0:ac97d71fe296 110 void DrawVerticalLine(unsigned char *frame_buffer, int x, int y, int height, int colored);
imachooon 0:ac97d71fe296 111 void DrawRectangle(unsigned char *frame_buffer, int x0, int y0, int x1, int y1, int colored);
imachooon 0:ac97d71fe296 112 void DrawFilledRectangle(unsigned char *frame_buffer, int x0, int y0, int x1, int y1, int colored);
imachooon 0:ac97d71fe296 113 void DrawCircle(unsigned char *frame_buffer, int x, int y, int radius, int colored);
imachooon 0:ac97d71fe296 114 void DrawFilledCircle(unsigned char *frame_buffer, int x, int y, int radius, int colored);
imachooon 0:ac97d71fe296 115 void DrawCharAt(unsigned char *frame_buffer, int x, int y, char ascii_char, sFONT* font, int colored);
imachooon 0:ac97d71fe296 116 void DrawStringAt(unsigned char *frame_buffer, int x, int y, const char* text, sFONT* font, int colored);
imachooon 0:ac97d71fe296 117
imachooon 0:ac97d71fe296 118
imachooon 0:ac97d71fe296 119 };
imachooon 0:ac97d71fe296 120
imachooon 0:ac97d71fe296 121 #endif /* EPD1IN54_H */
imachooon 0:ac97d71fe296 122
imachooon 0:ac97d71fe296 123 /* END OF FILE */