Library to control the EM027BS013 ePaper display from Pervasive Display.
Dependents: app_epaper_EM027BS013_LPC1549 lpc4088_ebb_epaper EaEpaper_EM027BS013 app_epaper_EM027BS013 ... more
EPD_controller.cpp@0:9297e33f50cf, 2014-07-22 (annotated)
- Committer:
- embeddedartists
- Date:
- Tue Jul 22 11:59:06 2014 +0000
- Revision:
- 0:9297e33f50cf
First version of library for the EM027BS013 ePaper display.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
embeddedartists | 0:9297e33f50cf | 1 | /** |
embeddedartists | 0:9297e33f50cf | 2 | * \file |
embeddedartists | 0:9297e33f50cf | 3 | * |
embeddedartists | 0:9297e33f50cf | 4 | * \brief The interface for external application wants to update EPD |
embeddedartists | 0:9297e33f50cf | 5 | * |
embeddedartists | 0:9297e33f50cf | 6 | * Copyright (c) 2012-2014 Pervasive Displays Inc. All rights reserved. |
embeddedartists | 0:9297e33f50cf | 7 | * |
embeddedartists | 0:9297e33f50cf | 8 | * Authors: Pervasive Displays Inc. |
embeddedartists | 0:9297e33f50cf | 9 | * |
embeddedartists | 0:9297e33f50cf | 10 | * Redistribution and use in source and binary forms, with or without |
embeddedartists | 0:9297e33f50cf | 11 | * modification, are permitted provided that the following conditions |
embeddedartists | 0:9297e33f50cf | 12 | * are met: |
embeddedartists | 0:9297e33f50cf | 13 | * |
embeddedartists | 0:9297e33f50cf | 14 | * 1. Redistributions of source code must retain the above copyright |
embeddedartists | 0:9297e33f50cf | 15 | * notice, this list of conditions and the following disclaimer. |
embeddedartists | 0:9297e33f50cf | 16 | * 2. Redistributions in binary form must reproduce the above copyright |
embeddedartists | 0:9297e33f50cf | 17 | * notice, this list of conditions and the following disclaimer in |
embeddedartists | 0:9297e33f50cf | 18 | * the documentation and/or other materials provided with the |
embeddedartists | 0:9297e33f50cf | 19 | * distribution. |
embeddedartists | 0:9297e33f50cf | 20 | * |
embeddedartists | 0:9297e33f50cf | 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
embeddedartists | 0:9297e33f50cf | 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
embeddedartists | 0:9297e33f50cf | 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
embeddedartists | 0:9297e33f50cf | 24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
embeddedartists | 0:9297e33f50cf | 25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
embeddedartists | 0:9297e33f50cf | 26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
embeddedartists | 0:9297e33f50cf | 27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
embeddedartists | 0:9297e33f50cf | 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
embeddedartists | 0:9297e33f50cf | 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
embeddedartists | 0:9297e33f50cf | 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
embeddedartists | 0:9297e33f50cf | 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
embeddedartists | 0:9297e33f50cf | 32 | */ |
embeddedartists | 0:9297e33f50cf | 33 | |
embeddedartists | 0:9297e33f50cf | 34 | #include "EPD_controller.h" |
embeddedartists | 0:9297e33f50cf | 35 | |
embeddedartists | 0:9297e33f50cf | 36 | /** |
embeddedartists | 0:9297e33f50cf | 37 | * \brief Initialize the EPD hardware setting |
embeddedartists | 0:9297e33f50cf | 38 | */ |
embeddedartists | 0:9297e33f50cf | 39 | void EPD_display_init(void) { |
embeddedartists | 0:9297e33f50cf | 40 | EPD_init(); |
embeddedartists | 0:9297e33f50cf | 41 | } |
embeddedartists | 0:9297e33f50cf | 42 | |
embeddedartists | 0:9297e33f50cf | 43 | |
embeddedartists | 0:9297e33f50cf | 44 | |
embeddedartists | 0:9297e33f50cf | 45 | |
embeddedartists | 0:9297e33f50cf | 46 | /** |
embeddedartists | 0:9297e33f50cf | 47 | * \brief Show image from the pointer of memory array |
embeddedartists | 0:9297e33f50cf | 48 | * |
embeddedartists | 0:9297e33f50cf | 49 | * \param EPD_type_index The defined EPD size |
embeddedartists | 0:9297e33f50cf | 50 | * \param previous_image_ptr The pointer of memory that stores previous image |
embeddedartists | 0:9297e33f50cf | 51 | * \param new_image_ptr The pointer of memory that stores new image |
embeddedartists | 0:9297e33f50cf | 52 | */ |
embeddedartists | 0:9297e33f50cf | 53 | void EPD_display_from_pointer(uint8_t EPD_type_index,uint8_t *previous_image_ptr, |
embeddedartists | 0:9297e33f50cf | 54 | uint8_t *new_image_ptr) { |
embeddedartists | 0:9297e33f50cf | 55 | /* Initialize EPD hardware */ |
embeddedartists | 0:9297e33f50cf | 56 | EPD_init(); |
embeddedartists | 0:9297e33f50cf | 57 | |
embeddedartists | 0:9297e33f50cf | 58 | /* Power on COG Driver */ |
embeddedartists | 0:9297e33f50cf | 59 | EPD_power_on(); |
embeddedartists | 0:9297e33f50cf | 60 | |
embeddedartists | 0:9297e33f50cf | 61 | /* Initialize COG Driver */ |
embeddedartists | 0:9297e33f50cf | 62 | EPD_initialize_driver(EPD_type_index); |
embeddedartists | 0:9297e33f50cf | 63 | |
embeddedartists | 0:9297e33f50cf | 64 | /* Display image data on EPD from image array */ |
embeddedartists | 0:9297e33f50cf | 65 | EPD_display_from_array_prt(EPD_type_index,previous_image_ptr,new_image_ptr); |
embeddedartists | 0:9297e33f50cf | 66 | |
embeddedartists | 0:9297e33f50cf | 67 | /* Power off COG Driver */ |
embeddedartists | 0:9297e33f50cf | 68 | EPD_power_off (EPD_type_index); |
embeddedartists | 0:9297e33f50cf | 69 | } |
embeddedartists | 0:9297e33f50cf | 70 | |
embeddedartists | 0:9297e33f50cf | 71 | /** |
embeddedartists | 0:9297e33f50cf | 72 | * \brief Show image from Flash memory |
embeddedartists | 0:9297e33f50cf | 73 | * |
embeddedartists | 0:9297e33f50cf | 74 | * \param EPD_type_index The defined EPD size |
embeddedartists | 0:9297e33f50cf | 75 | * \param previous_image_address The address of memory that stores previous image |
embeddedartists | 0:9297e33f50cf | 76 | * \param new_image_address The address of memory that stores new image |
embeddedartists | 0:9297e33f50cf | 77 | * \param On_EPD_read_flash Developer needs to create an external function to read flash |
embeddedartists | 0:9297e33f50cf | 78 | */ |
embeddedartists | 0:9297e33f50cf | 79 | void EPD_display_from_flash(uint8_t EPD_type_index,long previous_image_address, |
embeddedartists | 0:9297e33f50cf | 80 | long new_image_address,EPD_read_flash_handler On_EPD_read_flash) { |
embeddedartists | 0:9297e33f50cf | 81 | /* Initialize EPD hardware */ |
embeddedartists | 0:9297e33f50cf | 82 | EPD_init(); |
embeddedartists | 0:9297e33f50cf | 83 | |
embeddedartists | 0:9297e33f50cf | 84 | /* Power on COG Driver */ |
embeddedartists | 0:9297e33f50cf | 85 | EPD_power_on(); |
embeddedartists | 0:9297e33f50cf | 86 | |
embeddedartists | 0:9297e33f50cf | 87 | /* Initialize COG Driver */ |
embeddedartists | 0:9297e33f50cf | 88 | EPD_initialize_driver(EPD_type_index); |
embeddedartists | 0:9297e33f50cf | 89 | |
embeddedartists | 0:9297e33f50cf | 90 | /* Display image data on EPD from Flash memory */ |
embeddedartists | 0:9297e33f50cf | 91 | EPD_display_from_flash_prt(EPD_type_index,previous_image_address, |
embeddedartists | 0:9297e33f50cf | 92 | new_image_address,On_EPD_read_flash); |
embeddedartists | 0:9297e33f50cf | 93 | |
embeddedartists | 0:9297e33f50cf | 94 | /* Power off COG Driver */ |
embeddedartists | 0:9297e33f50cf | 95 | EPD_power_off (EPD_type_index); |
embeddedartists | 0:9297e33f50cf | 96 | } |
embeddedartists | 0:9297e33f50cf | 97 | /** |
embeddedartists | 0:9297e33f50cf | 98 | * \brief Initialize the EPD hardware setting and COG driver |
embeddedartists | 0:9297e33f50cf | 99 | * |
embeddedartists | 0:9297e33f50cf | 100 | * \param EPD_type_index The defined EPD size |
embeddedartists | 0:9297e33f50cf | 101 | */ |
embeddedartists | 0:9297e33f50cf | 102 | void EPD_power_init(uint8_t EPD_type_index) { |
embeddedartists | 0:9297e33f50cf | 103 | EPD_init(); |
embeddedartists | 0:9297e33f50cf | 104 | EPD_power_on (); |
embeddedartists | 0:9297e33f50cf | 105 | EPD_initialize_driver (EPD_type_index); |
embeddedartists | 0:9297e33f50cf | 106 | } |
embeddedartists | 0:9297e33f50cf | 107 | |
embeddedartists | 0:9297e33f50cf | 108 | /** |
embeddedartists | 0:9297e33f50cf | 109 | * \brief Show image from Flash memory when SPI is common used with COG and Flash |
embeddedartists | 0:9297e33f50cf | 110 | * |
embeddedartists | 0:9297e33f50cf | 111 | * \note |
embeddedartists | 0:9297e33f50cf | 112 | * - This function must work with EPD_power_init when SPI is common used with |
embeddedartists | 0:9297e33f50cf | 113 | * COG and Flash, or the charge pump doesn't work correctly. |
embeddedartists | 0:9297e33f50cf | 114 | * - EPD_power_init -> write data to flash (switch SPI) -> EPD_display_from_flash_Ex |
embeddedartists | 0:9297e33f50cf | 115 | * |
embeddedartists | 0:9297e33f50cf | 116 | * \param EPD_type_index The defined EPD size |
embeddedartists | 0:9297e33f50cf | 117 | * \param previous_image_address The address of memory that stores previous image |
embeddedartists | 0:9297e33f50cf | 118 | * \param new_image_address The address of memory that stores new image |
embeddedartists | 0:9297e33f50cf | 119 | * \param On_EPD_read_flash Developer needs to create an external function to read flash |
embeddedartists | 0:9297e33f50cf | 120 | */ |
embeddedartists | 0:9297e33f50cf | 121 | void EPD_display_from_flash_Ex(uint8_t EPD_type_index,long previous_image_address, |
embeddedartists | 0:9297e33f50cf | 122 | long new_image_address,EPD_read_flash_handler On_EPD_read_flash) { |
embeddedartists | 0:9297e33f50cf | 123 | |
embeddedartists | 0:9297e33f50cf | 124 | /* Display image data on EPD from Flash memory */ |
embeddedartists | 0:9297e33f50cf | 125 | EPD_display_from_flash_prt(EPD_type_index,previous_image_address, |
embeddedartists | 0:9297e33f50cf | 126 | new_image_address,On_EPD_read_flash); |
embeddedartists | 0:9297e33f50cf | 127 | |
embeddedartists | 0:9297e33f50cf | 128 | /* Power off COG Driver */ |
embeddedartists | 0:9297e33f50cf | 129 | EPD_power_off (EPD_type_index); |
embeddedartists | 0:9297e33f50cf | 130 | } |
embeddedartists | 0:9297e33f50cf | 131 | |
embeddedartists | 0:9297e33f50cf | 132 | |
embeddedartists | 0:9297e33f50cf | 133 | |
embeddedartists | 0:9297e33f50cf | 134 |