Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
EinkShield.h@0:4cbbe20392ef, 2018-08-20 (annotated)
- Committer:
- jauming
- Date:
- Mon Aug 20 05:59:01 2018 +0000
- Revision:
- 0:4cbbe20392ef
libEinkShield_mbedcli_ARM_NUCLEO_F446RE
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| jauming | 0:4cbbe20392ef | 1 | /* |
| jauming | 0:4cbbe20392ef | 2 | Copyright (c) 2017-2018, E Ink Holdings Inc., All Rights Reserved |
| jauming | 0:4cbbe20392ef | 3 | SPDX-License-Identifier: LicenseRef-PBL |
| jauming | 0:4cbbe20392ef | 4 | |
| jauming | 0:4cbbe20392ef | 5 | This file and the related binary are licensed under the Permissive Binary |
| jauming | 0:4cbbe20392ef | 6 | License, Version 1.0 (the "License"); you may not use these files except in |
| jauming | 0:4cbbe20392ef | 7 | compliance with the License. |
| jauming | 0:4cbbe20392ef | 8 | |
| jauming | 0:4cbbe20392ef | 9 | You may obtain a copy of the License here: |
| jauming | 0:4cbbe20392ef | 10 | LICENSE-permissive-binary-license-1.0.txt and at |
| jauming | 0:4cbbe20392ef | 11 | https://www.mbed.com/licenses/PBL-1.0 |
| jauming | 0:4cbbe20392ef | 12 | |
| jauming | 0:4cbbe20392ef | 13 | See the License for the specific language governing permissions and limitations |
| jauming | 0:4cbbe20392ef | 14 | under the License. |
| jauming | 0:4cbbe20392ef | 15 | */ |
| jauming | 0:4cbbe20392ef | 16 | /** |
| jauming | 0:4cbbe20392ef | 17 | * \mainpage EinkShield usage sample code |
| jauming | 0:4cbbe20392ef | 18 | * \code |
| jauming | 0:4cbbe20392ef | 19 | * #include "mbed.h" |
| jauming | 0:4cbbe20392ef | 20 | * #include "EinkShield.h" |
| jauming | 0:4cbbe20392ef | 21 | * #include "image3.h" |
| jauming | 0:4cbbe20392ef | 22 | * int main() { |
| jauming | 0:4cbbe20392ef | 23 | * EinkShield epd(EL029TR1, |
| jauming | 0:4cbbe20392ef | 24 | * D7, |
| jauming | 0:4cbbe20392ef | 25 | * D6, |
| jauming | 0:4cbbe20392ef | 26 | * D5, |
| jauming | 0:4cbbe20392ef | 27 | * D10, |
| jauming | 0:4cbbe20392ef | 28 | * D2, |
| jauming | 0:4cbbe20392ef | 29 | * D13, |
| jauming | 0:4cbbe20392ef | 30 | * D11); |
| jauming | 0:4cbbe20392ef | 31 | * epd.EPD_Init(); |
| jauming | 0:4cbbe20392ef | 32 | * epd.EPD_Display_Red(); |
| jauming | 0:4cbbe20392ef | 33 | * wait_ms(2000); |
| jauming | 0:4cbbe20392ef | 34 | * while(1) { |
| jauming | 0:4cbbe20392ef | 35 | * epd.EPD_Display_KWR(sale2_KW, sale2_R); |
| jauming | 0:4cbbe20392ef | 36 | * wait_ms(2000); |
| jauming | 0:4cbbe20392ef | 37 | * } |
| jauming | 0:4cbbe20392ef | 38 | * } |
| jauming | 0:4cbbe20392ef | 39 | * \endcode |
| jauming | 0:4cbbe20392ef | 40 | */ |
| jauming | 0:4cbbe20392ef | 41 | #ifndef EINK_SHIELD_H |
| jauming | 0:4cbbe20392ef | 42 | #define EINK_SHIELD_H |
| jauming | 0:4cbbe20392ef | 43 | |
| jauming | 0:4cbbe20392ef | 44 | typedef enum { |
| jauming | 0:4cbbe20392ef | 45 | EL029TR1, |
| jauming | 0:4cbbe20392ef | 46 | } EPD_driver; |
| jauming | 0:4cbbe20392ef | 47 | |
| jauming | 0:4cbbe20392ef | 48 | |
| jauming | 0:4cbbe20392ef | 49 | /** @class EinkShield EinkShield.h */ |
| jauming | 0:4cbbe20392ef | 50 | /** class EinkShield for mbed-os */ |
| jauming | 0:4cbbe20392ef | 51 | class EinkShield { |
| jauming | 0:4cbbe20392ef | 52 | private: |
| jauming | 0:4cbbe20392ef | 53 | DigitalOut bsi ;//(D7); |
| jauming | 0:4cbbe20392ef | 54 | DigitalOut rstn ;//(D6); |
| jauming | 0:4cbbe20392ef | 55 | DigitalIn busyn;//(D5); |
| jauming | 0:4cbbe20392ef | 56 | DigitalOut csb ;//(D10); |
| jauming | 0:4cbbe20392ef | 57 | DigitalOut dc ;//(D2); |
| jauming | 0:4cbbe20392ef | 58 | DigitalOut scl ;//(D13); |
| jauming | 0:4cbbe20392ef | 59 | DigitalOut sda ;//(D11); |
| jauming | 0:4cbbe20392ef | 60 | |
| jauming | 0:4cbbe20392ef | 61 | EPD_driver driver; |
| jauming | 0:4cbbe20392ef | 62 | |
| jauming | 0:4cbbe20392ef | 63 | public: |
| jauming | 0:4cbbe20392ef | 64 | /** |
| jauming | 0:4cbbe20392ef | 65 | * Constructor to set pin assignment and driver |
| jauming | 0:4cbbe20392ef | 66 | * @param driver select different size display driver for EinkShield, for example: EL029TR1 |
| jauming | 0:4cbbe20392ef | 67 | * @param bsi_pin bus selection pin |
| jauming | 0:4cbbe20392ef | 68 | * @param rstn_pin reset pin, L: driver will reset when low |
| jauming | 0:4cbbe20392ef | 69 | * @param busyn_pin busy pin, L: driver is busy |
| jauming | 0:4cbbe20392ef | 70 | * @param csb_pin chip-select pin |
| jauming | 0:4cbbe20392ef | 71 | * @param dc_pin data/command pin |
| jauming | 0:4cbbe20392ef | 72 | * @param scl_pin serial clock pin |
| jauming | 0:4cbbe20392ef | 73 | * @param sda_pin serial data pin |
| jauming | 0:4cbbe20392ef | 74 | * @return none |
| jauming | 0:4cbbe20392ef | 75 | */ |
| jauming | 0:4cbbe20392ef | 76 | EinkShield(EPD_driver driver, |
| jauming | 0:4cbbe20392ef | 77 | PinName bsi_pin, |
| jauming | 0:4cbbe20392ef | 78 | PinName rstn_pin, |
| jauming | 0:4cbbe20392ef | 79 | PinName busyn_pin, |
| jauming | 0:4cbbe20392ef | 80 | PinName csb_pin, |
| jauming | 0:4cbbe20392ef | 81 | PinName dc_pin, |
| jauming | 0:4cbbe20392ef | 82 | PinName scl_pin, |
| jauming | 0:4cbbe20392ef | 83 | PinName sda_pin); |
| jauming | 0:4cbbe20392ef | 84 | /** |
| jauming | 0:4cbbe20392ef | 85 | * Driver initial |
| jauming | 0:4cbbe20392ef | 86 | * @param none |
| jauming | 0:4cbbe20392ef | 87 | * @return none |
| jauming | 0:4cbbe20392ef | 88 | */ |
| jauming | 0:4cbbe20392ef | 89 | void EPD_Init(void); |
| jauming | 0:4cbbe20392ef | 90 | /** |
| jauming | 0:4cbbe20392ef | 91 | * Display image with color: black, white and red. |
| jauming | 0:4cbbe20392ef | 92 | * <pre> |
| jauming | 0:4cbbe20392ef | 93 | * Resolution of EL029TR1 is 128x296. |
| jauming | 0:4cbbe20392ef | 94 | * Pixel data alignment is from left to right and from top to bottom. |
| jauming | 0:4cbbe20392ef | 95 | * |
| jauming | 0:4cbbe20392ef | 96 | * <STRONG>img_kw</STRONG> point to black and white raw pixel data of image, |
| jauming | 0:4cbbe20392ef | 97 | * 1 bit per pixel, 0 = black, 1 = white, |
| jauming | 0:4cbbe20392ef | 98 | * Total size of img_kw is 128x296/8 = 4736 bytes for EL029TR1. |
| jauming | 0:4cbbe20392ef | 99 | * |
| jauming | 0:4cbbe20392ef | 100 | * <STRONG>img_r</STRONG> point to red raw pixel data of image, |
| jauming | 0:4cbbe20392ef | 101 | * 1 bit per pixel, 0 = red, 1 = reserved, |
| jauming | 0:4cbbe20392ef | 102 | * Total size of img_r is 128x296/8 = 4736 bytes for EL029TR1. |
| jauming | 0:4cbbe20392ef | 103 | * </pre> |
| jauming | 0:4cbbe20392ef | 104 | * |
| jauming | 0:4cbbe20392ef | 105 | * @param img_kw <pre>point to black and white raw pixel data of image, |
| jauming | 0:4cbbe20392ef | 106 | * 1 bit per pixel, 0 = black, 1 = white,</pre> |
| jauming | 0:4cbbe20392ef | 107 | * |
| jauming | 0:4cbbe20392ef | 108 | * @param img_r <pre>point to red raw pixel data of image, |
| jauming | 0:4cbbe20392ef | 109 | * 1 bit per pixel, 0 = red, 1 = reserved,</pre> |
| jauming | 0:4cbbe20392ef | 110 | * |
| jauming | 0:4cbbe20392ef | 111 | * |
| jauming | 0:4cbbe20392ef | 112 | * @return none |
| jauming | 0:4cbbe20392ef | 113 | */ |
| jauming | 0:4cbbe20392ef | 114 | void EPD_Display_KWR(unsigned char const *img_kw, unsigned char const *img_r); |
| jauming | 0:4cbbe20392ef | 115 | /** |
| jauming | 0:4cbbe20392ef | 116 | * Display full screen red |
| jauming | 0:4cbbe20392ef | 117 | * |
| jauming | 0:4cbbe20392ef | 118 | * @param none |
| jauming | 0:4cbbe20392ef | 119 | * @return none |
| jauming | 0:4cbbe20392ef | 120 | */ |
| jauming | 0:4cbbe20392ef | 121 | void EPD_Display_Red(void); |
| jauming | 0:4cbbe20392ef | 122 | }; |
| jauming | 0:4cbbe20392ef | 123 | |
| jauming | 0:4cbbe20392ef | 124 | |
| jauming | 0:4cbbe20392ef | 125 | |
| jauming | 0:4cbbe20392ef | 126 | #endif |