WaveShare e-paper module (epd1in54). Monochrome version

e-Paper Module

Description

Waveshare 1.54 e-paper module imported from offiicial code https://www.waveshare.com/wiki/1.54inch_e-Paper_Module Codes are referenced from official Arduino code and Raspberry pi code.

SPI is used for communication between ePaper module and mbed.

Following shapes can be used:

  • primitive shape (square, circle, line)
  • font (variable sizes)

Pull request are appreciated (Note that the original code is copyrighted by (C) Waveshare )

Example Output

Display output with example code will be like following image:

/media/uploads/imachooon/img_20180216_223238.jpg

Example Code

include the mbed library with this snippet

#include "mbed.h"
#include "epd1in54.h"
#include "m41t62_rtc.h"
// Control
PinName rst;
PinName dc;
PinName busy;
// SPI communication
PinName mosi;
PinName miso;
PinName sclk;
PinName cs;

DigitalOut myled(LED1);

unsigned char frame_black[EPD_HEIGHT*EPD_WIDTH/8];


int main() {
    mosi = p5;
    miso = p6;
    sclk = p7;
    cs = p8;
    rst = p9;
    dc = p10;
    busy = p11;
    
    memset(frame_black, 0xFF, sizeof(unsigned char)*EPD_HEIGHT*EPD_WIDTH/8);

    Epd epd = Epd(mosi, miso, sclk, cs, dc, rst, busy);
    if (epd.Init(lut_full_update) != 0){
        return -1;
    }

    /* Draw something to the frame buffer */
    // For simplicity, the arguments are explicit numerical coordinates
    epd.DrawRectangle(frame_black, 10, 60, 50, 110, COLORED);
    epd.DrawLine(frame_black, 10, 60, 50, 110, COLORED);
    epd.DrawLine(frame_black, 50, 60, 10, 110, COLORED);
    epd.DrawCircle(frame_black, 120, 80, 30, COLORED);
    epd.DrawFilledRectangle(frame_black, 10, 130, 50, 180, COLORED);
    epd.DrawFilledRectangle(frame_black, 0, 6, 200, 26, COLORED);
    epd.DrawFilledCircle(frame_black, 120, 150, 30, COLORED);

    /*Write strings to the buffer */
    epd.DrawStringAt(frame_black, 30, 30, "e-Paper Demo", &Font16, COLORED);
    epd.DrawStringAt(frame_black, 28, 10, "Hello world!", &Font16, UNCOLORED);


    
    /* Display the frame_buffer */
    epd.SetFrameMemory(frame_black, 0, 0, epd.width, epd.height);
    epd.DisplayFrame();
    epd.Sleep();

    
    while(1) {
        myled = 1;
        wait(0.5);
        myled = 0;
        wait(0.5);
    }
}

Committer:
imachooon
Date:
Fri Feb 16 21:30:08 2018 +0000
Revision:
0:ac97d71fe296
initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
imachooon 0:ac97d71fe296 1 /**
imachooon 0:ac97d71fe296 2 ******************************************************************************
imachooon 0:ac97d71fe296 3 * @file fonts.h
imachooon 0:ac97d71fe296 4 * @author MCD Application Team
imachooon 0:ac97d71fe296 5 * @version V1.0.0
imachooon 0:ac97d71fe296 6 * @date 18-February-2014
imachooon 0:ac97d71fe296 7 * @brief Header for fonts.c file
imachooon 0:ac97d71fe296 8 ******************************************************************************
imachooon 0:ac97d71fe296 9 * @attention
imachooon 0:ac97d71fe296 10 *
imachooon 0:ac97d71fe296 11 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
imachooon 0:ac97d71fe296 12 *
imachooon 0:ac97d71fe296 13 * Redistribution and use in source and binary forms, with or without modification,
imachooon 0:ac97d71fe296 14 * are permitted provided that the following conditions are met:
imachooon 0:ac97d71fe296 15 * 1. Redistributions of source code must retain the above copyright notice,
imachooon 0:ac97d71fe296 16 * this list of conditions and the following disclaimer.
imachooon 0:ac97d71fe296 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
imachooon 0:ac97d71fe296 18 * this list of conditions and the following disclaimer in the documentation
imachooon 0:ac97d71fe296 19 * and/or other materials provided with the distribution.
imachooon 0:ac97d71fe296 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
imachooon 0:ac97d71fe296 21 * may be used to endorse or promote products derived from this software
imachooon 0:ac97d71fe296 22 * without specific prior written permission.
imachooon 0:ac97d71fe296 23 *
imachooon 0:ac97d71fe296 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
imachooon 0:ac97d71fe296 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
imachooon 0:ac97d71fe296 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
imachooon 0:ac97d71fe296 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
imachooon 0:ac97d71fe296 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
imachooon 0:ac97d71fe296 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
imachooon 0:ac97d71fe296 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
imachooon 0:ac97d71fe296 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
imachooon 0:ac97d71fe296 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
imachooon 0:ac97d71fe296 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
imachooon 0:ac97d71fe296 34 *
imachooon 0:ac97d71fe296 35 ******************************************************************************
imachooon 0:ac97d71fe296 36 */
imachooon 0:ac97d71fe296 37
imachooon 0:ac97d71fe296 38 /* Define to prevent recursive inclusion -------------------------------------*/
imachooon 0:ac97d71fe296 39 #ifndef __FONTS_H
imachooon 0:ac97d71fe296 40 #define __FONTS_H
imachooon 0:ac97d71fe296 41
imachooon 0:ac97d71fe296 42 /* Max size of bitmap will based on a font24 (17x24) */
imachooon 0:ac97d71fe296 43 #define MAX_HEIGHT_FONT 24
imachooon 0:ac97d71fe296 44 #define MAX_WIDTH_FONT 17
imachooon 0:ac97d71fe296 45 #define OFFSET_BITMAP 54
imachooon 0:ac97d71fe296 46
imachooon 0:ac97d71fe296 47 #ifdef __cplusplus
imachooon 0:ac97d71fe296 48 extern "C" {
imachooon 0:ac97d71fe296 49 #endif
imachooon 0:ac97d71fe296 50
imachooon 0:ac97d71fe296 51 /* Includes ------------------------------------------------------------------*/
imachooon 0:ac97d71fe296 52 #include <stdint.h>
imachooon 0:ac97d71fe296 53
imachooon 0:ac97d71fe296 54 typedef struct _tFont
imachooon 0:ac97d71fe296 55 {
imachooon 0:ac97d71fe296 56 const uint8_t *table;
imachooon 0:ac97d71fe296 57 uint16_t Width;
imachooon 0:ac97d71fe296 58 uint16_t Height;
imachooon 0:ac97d71fe296 59
imachooon 0:ac97d71fe296 60 } sFONT;
imachooon 0:ac97d71fe296 61
imachooon 0:ac97d71fe296 62 extern sFONT Font24;
imachooon 0:ac97d71fe296 63 extern sFONT Font20;
imachooon 0:ac97d71fe296 64 extern sFONT Font16;
imachooon 0:ac97d71fe296 65 extern sFONT Font12;
imachooon 0:ac97d71fe296 66 extern sFONT Font8;
imachooon 0:ac97d71fe296 67
imachooon 0:ac97d71fe296 68 #ifdef __cplusplus
imachooon 0:ac97d71fe296 69 }
imachooon 0:ac97d71fe296 70 #endif
imachooon 0:ac97d71fe296 71
imachooon 0:ac97d71fe296 72 #endif /* __FONTS_H */
imachooon 0:ac97d71fe296 73
imachooon 0:ac97d71fe296 74
imachooon 0:ac97d71fe296 75 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/