Post It

Dependencies:   LM75B

Fork of EM027BS013 by EmbeddedArtists AB

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?

UserRevisionLine numberNew contents of line
embeddedartists 0:9297e33f50cf 1 /**
embeddedartists 0:9297e33f50cf 2 * \file
embeddedartists 0:9297e33f50cf 3 *
embeddedartists 0:9297e33f50cf 4 * \brief The definition of COG driving data and process
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 #ifndef DISPLAY_COG_PROCESS__H_INCLUDED
embeddedartists 0:9297e33f50cf 35 #define DISPLAY_COG_PROCESS__H_INCLUDED
embeddedartists 0:9297e33f50cf 36
embeddedartists 0:9297e33f50cf 37 #include "Pervasive_Displays_small_EPD.h"
embeddedartists 0:9297e33f50cf 38 /**
embeddedartists 0:9297e33f50cf 39 * \brief The definition for driving stage to compare with for getting Odd and Even data */
embeddedartists 0:9297e33f50cf 40 #define BLACK0 (uint8_t)(0x03) /**< getting bit1 or bit0 as black color(11) */
embeddedartists 0:9297e33f50cf 41 #define BLACK1 (uint8_t)(0x0C) /**< getting bit3 or bit2 as black color(11) */
embeddedartists 0:9297e33f50cf 42 #define BLACK2 (uint8_t)(0x30) /**< getting bit5 or bit4 as black color(11) */
embeddedartists 0:9297e33f50cf 43 #define BLACK3 (uint8_t)(0xC0) /**< getting bit7 or bit6 as black color(11) */
embeddedartists 0:9297e33f50cf 44 #define WHITE0 (uint8_t)(0x02) /**< getting bit1 or bit0 as white color(10) */
embeddedartists 0:9297e33f50cf 45 #define WHITE1 (uint8_t)(0x08) /**< getting bit3 or bit2 as white color(10) */
embeddedartists 0:9297e33f50cf 46 #define WHITE2 (uint8_t)(0x20) /**< getting bit5 or bit4 as white color(10) */
embeddedartists 0:9297e33f50cf 47 #define WHITE3 (uint8_t)(0x80) /**< getting bit7 or bit6 as white color(10) */
embeddedartists 0:9297e33f50cf 48 #define NOTHING0 (uint8_t)(0x01) /**< getting bit1 or bit0 as nothing input(01) */
embeddedartists 0:9297e33f50cf 49 #define NOTHING1 (uint8_t)(0x04) /**< getting bit3 or bit2 as nothing input(01) */
embeddedartists 0:9297e33f50cf 50 #define NOTHING2 (uint8_t)(0x10) /**< getting bit5 or bit4 as nothing input(01) */
embeddedartists 0:9297e33f50cf 51 #define NOTHING3 (uint8_t)(0x40) /**< getting bit7 or bit6 as nothing input(01) */
embeddedartists 0:9297e33f50cf 52 #define NOTHING (uint8_t)(0x55) /**< sending Nothing frame, 01=Nothing, 0101=0x5 */
embeddedartists 0:9297e33f50cf 53
embeddedartists 0:9297e33f50cf 54
embeddedartists 0:9297e33f50cf 55 #define ALL_BLACK (uint8_t)(0xFF)
embeddedartists 0:9297e33f50cf 56 #define ALL_WHITE (uint8_t)(0xAA)
embeddedartists 0:9297e33f50cf 57 #define BORDER_BYTE_B (uint8_t)(0xFF)
embeddedartists 0:9297e33f50cf 58 #define BORDER_BYTE_W (uint8_t)(0xAA)
embeddedartists 0:9297e33f50cf 59 #define ERROR_BUSY (uint8_t)(0xF0)
embeddedartists 0:9297e33f50cf 60 #define ERROR_COG_ID (uint8_t)(0xF1)
embeddedartists 0:9297e33f50cf 61 #define ERROR_BREAKAGE (uint8_t)(0xF2)
embeddedartists 0:9297e33f50cf 62 #define ERROR_DC (uint8_t)(0xF3)
embeddedartists 0:9297e33f50cf 63 #define ERROR_CHARGEPUMP (uint8_t)(0xF4)
embeddedartists 0:9297e33f50cf 64 #define RES_OK (uint8_t)(0x00)
embeddedartists 0:9297e33f50cf 65
embeddedartists 0:9297e33f50cf 66 /**
embeddedartists 0:9297e33f50cf 67 * \brief The COG Driver uses a buffer to update the EPD line by line.
embeddedartists 0:9297e33f50cf 68 \note Use the 2.7" maximum data(66)+scan(44)+dummy(1) bytes as line buffer size=111.*/
embeddedartists 0:9297e33f50cf 69 #define LINE_BUFFER_DATA_SIZE 33
embeddedartists 0:9297e33f50cf 70 #define COG_line_Max_Size 33
embeddedartists 0:9297e33f50cf 71 /**
embeddedartists 0:9297e33f50cf 72 * \brief Support 1.44", 2" and 2.7" three type EPD currently */
embeddedartists 0:9297e33f50cf 73 #define COUNT_OF_EPD_TYPE 3
embeddedartists 0:9297e33f50cf 74
embeddedartists 0:9297e33f50cf 75 /**
embeddedartists 0:9297e33f50cf 76 * \brief Four driving stages */
embeddedartists 0:9297e33f50cf 77 enum Stage {
embeddedartists 0:9297e33f50cf 78 Stage1, /**< Inverse previous image */
embeddedartists 0:9297e33f50cf 79 Stage2, /**< White */
embeddedartists 0:9297e33f50cf 80 Stage3, /**< Inverse new image */
embeddedartists 0:9297e33f50cf 81 Stage4 /**< New image */
embeddedartists 0:9297e33f50cf 82 };
embeddedartists 0:9297e33f50cf 83
embeddedartists 0:9297e33f50cf 84 #if (defined COG_V110_G1)
embeddedartists 0:9297e33f50cf 85 /**
embeddedartists 0:9297e33f50cf 86 * \brief Line data structure of 1.44 inch EPD
embeddedartists 0:9297e33f50cf 87 * \note
embeddedartists 0:9297e33f50cf 88 * 1.44 inch needs to put border_control byte at the front of data line.
embeddedartists 0:9297e33f50cf 89 * Refer to COG document Section 5.2 - 1.44" Input Data Order.
embeddedartists 0:9297e33f50cf 90 */
embeddedartists 0:9297e33f50cf 91 struct COG_144_line_data_t {
embeddedartists 0:9297e33f50cf 92 uint8_t border_byte; /**< Internal border_control, for 1.44" EPD only */
embeddedartists 0:9297e33f50cf 93 uint8_t even[16]; /**< 1.44" even byte array */
embeddedartists 0:9297e33f50cf 94 uint8_t scan[24]; /**< 1.44" scan byte array */
embeddedartists 0:9297e33f50cf 95 uint8_t odd [16]; /**< 1.44" odd byte array */
embeddedartists 0:9297e33f50cf 96 } ;
embeddedartists 0:9297e33f50cf 97
embeddedartists 0:9297e33f50cf 98 /**
embeddedartists 0:9297e33f50cf 99 * \brief Line data structure of 2 inch EPD
embeddedartists 0:9297e33f50cf 100 * \note
embeddedartists 0:9297e33f50cf 101 * Add one byte x00 to complete a line
embeddedartists 0:9297e33f50cf 102 * Refer to COG document Section 5.2 - 2" Input Data Order.
embeddedartists 0:9297e33f50cf 103 */
embeddedartists 0:9297e33f50cf 104 struct COG_200_line_data_t {
embeddedartists 0:9297e33f50cf 105 uint8_t even[25]; /**< 2" even byte array */
embeddedartists 0:9297e33f50cf 106 uint8_t scan[24]; /**< 2" scan byte array */
embeddedartists 0:9297e33f50cf 107 uint8_t odd [25]; /**< 2" odd byte array */
embeddedartists 0:9297e33f50cf 108 uint8_t dummy_data; /**< dummy byte 0x00 */
embeddedartists 0:9297e33f50cf 109 } ;
embeddedartists 0:9297e33f50cf 110
embeddedartists 0:9297e33f50cf 111 /**
embeddedartists 0:9297e33f50cf 112 * \brief Line data structure of 2.7 inch EPD
embeddedartists 0:9297e33f50cf 113 * \note
embeddedartists 0:9297e33f50cf 114 * Add one byte x00 to complete a line
embeddedartists 0:9297e33f50cf 115 * Refer to COG document Section 5.2 - 2.7" Input Data Order.
embeddedartists 0:9297e33f50cf 116 */
embeddedartists 0:9297e33f50cf 117 struct COG_270_line_data_t {
embeddedartists 0:9297e33f50cf 118 uint8_t even[33]; /**< 2.7" even byte array */
embeddedartists 0:9297e33f50cf 119 uint8_t scan[44]; /**< 2.7" scan byte array */
embeddedartists 0:9297e33f50cf 120 uint8_t odd [33]; /**< 2.7" odd byte array */
embeddedartists 0:9297e33f50cf 121 uint8_t dummy_data; /**< dummy byte 0x00 */
embeddedartists 0:9297e33f50cf 122 } ;
embeddedartists 0:9297e33f50cf 123
embeddedartists 0:9297e33f50cf 124
embeddedartists 0:9297e33f50cf 125 #elif (defined COG_V230_G2)
embeddedartists 0:9297e33f50cf 126 /**
embeddedartists 0:9297e33f50cf 127 * \brief Line data structure of 1.44 inch V230 EPD with G2 COG
embeddedartists 0:9297e33f50cf 128 * \note
embeddedartists 0:9297e33f50cf 129 * 1.44 inch needs to put border_control byte at the front of data line.
embeddedartists 0:9297e33f50cf 130 * Refer to COG document Section 5.2 - 1.44" Input Data Order.
embeddedartists 0:9297e33f50cf 131 */
embeddedartists 0:9297e33f50cf 132 struct COG_144_line_data_t {
embeddedartists 0:9297e33f50cf 133 uint8_t even[16]; /**< 1.44" even byte array */
embeddedartists 0:9297e33f50cf 134 uint8_t scan[24]; /**< 1.44" scan byte array */
embeddedartists 0:9297e33f50cf 135 uint8_t odd [16]; /**< 1.44" odd byte array */
embeddedartists 0:9297e33f50cf 136 uint8_t border_byte; /**< Internal border_control*/
embeddedartists 0:9297e33f50cf 137 } ;
embeddedartists 0:9297e33f50cf 138
embeddedartists 0:9297e33f50cf 139 /**
embeddedartists 0:9297e33f50cf 140 * \brief Line data structure of 2 inch V230 EPD with G2 COG
embeddedartists 0:9297e33f50cf 141 * \note
embeddedartists 0:9297e33f50cf 142 * Add one byte x00 to complete a line
embeddedartists 0:9297e33f50cf 143 * Refer to COG document Section 5.2 - 2" Input Data Order.
embeddedartists 0:9297e33f50cf 144 */
embeddedartists 0:9297e33f50cf 145 struct COG_200_line_data_t {
embeddedartists 0:9297e33f50cf 146 uint8_t border_byte; /**< Internal border_control*/
embeddedartists 0:9297e33f50cf 147 uint8_t even[25]; /**< 2" even byte array */
embeddedartists 0:9297e33f50cf 148 uint8_t scan[24]; /**< 2" scan byte array */
embeddedartists 0:9297e33f50cf 149 uint8_t odd [25]; /**< 2" odd byte array */
embeddedartists 0:9297e33f50cf 150 } ;
embeddedartists 0:9297e33f50cf 151
embeddedartists 0:9297e33f50cf 152 /**
embeddedartists 0:9297e33f50cf 153 * \brief Line data structure of 2.7 inch V230 EPD with G2 COG
embeddedartists 0:9297e33f50cf 154 * \note
embeddedartists 0:9297e33f50cf 155 * Add one byte x00 to complete a line
embeddedartists 0:9297e33f50cf 156 * Refer to COG document Section 5.2 - 2.7" Input Data Order.
embeddedartists 0:9297e33f50cf 157 */
embeddedartists 0:9297e33f50cf 158 struct COG_270_line_data_t {
embeddedartists 0:9297e33f50cf 159 uint8_t border_byte; /**< Internal border_control*/
embeddedartists 0:9297e33f50cf 160 uint8_t even[33]; /**< 2.7" even byte array */
embeddedartists 0:9297e33f50cf 161 uint8_t scan[44]; /**< 2.7" scan byte array */
embeddedartists 0:9297e33f50cf 162 uint8_t odd [33]; /**< 2.7" odd byte array */
embeddedartists 0:9297e33f50cf 163 } ;
embeddedartists 0:9297e33f50cf 164
embeddedartists 0:9297e33f50cf 165 /**
embeddedartists 0:9297e33f50cf 166 * \brief Define waveform stages for V230 EPD with G2 COG
embeddedartists 0:9297e33f50cf 167 */
embeddedartists 0:9297e33f50cf 168 struct EPD_WaveformTable_Struct
embeddedartists 0:9297e33f50cf 169 {
embeddedartists 0:9297e33f50cf 170 uint8_t stage1_frame1;
embeddedartists 0:9297e33f50cf 171 uint8_t stage1_block1;
embeddedartists 0:9297e33f50cf 172 uint8_t stage1_step1;
embeddedartists 0:9297e33f50cf 173
embeddedartists 0:9297e33f50cf 174 uint16_t stage2_t1;
embeddedartists 0:9297e33f50cf 175 uint16_t stage2_t2;
embeddedartists 0:9297e33f50cf 176 uint8_t stage2_cycle;
embeddedartists 0:9297e33f50cf 177
embeddedartists 0:9297e33f50cf 178 uint8_t stage3_frame3;
embeddedartists 0:9297e33f50cf 179 uint8_t stage3_block3;
embeddedartists 0:9297e33f50cf 180 uint8_t stage3_step3;
embeddedartists 0:9297e33f50cf 181 };
embeddedartists 0:9297e33f50cf 182
embeddedartists 0:9297e33f50cf 183 /**
embeddedartists 0:9297e33f50cf 184 * \brief Define the Block type waveform structure
embeddedartists 0:9297e33f50cf 185 */
embeddedartists 0:9297e33f50cf 186 struct EPD_V230_G2_Struct
embeddedartists 0:9297e33f50cf 187 {
embeddedartists 0:9297e33f50cf 188 int16_t frame_y0;
embeddedartists 0:9297e33f50cf 189 int16_t frame_y1;
embeddedartists 0:9297e33f50cf 190 int16_t block_y0;
embeddedartists 0:9297e33f50cf 191 int16_t block_y1;
embeddedartists 0:9297e33f50cf 192 int16_t block_size;
embeddedartists 0:9297e33f50cf 193 int16_t step_size;
embeddedartists 0:9297e33f50cf 194 int16_t frame_cycle;
embeddedartists 0:9297e33f50cf 195 int16_t step_y0;
embeddedartists 0:9297e33f50cf 196 int16_t step_y1;
embeddedartists 0:9297e33f50cf 197 int16_t number_of_steps;
embeddedartists 0:9297e33f50cf 198 };
embeddedartists 0:9297e33f50cf 199 #else
embeddedartists 0:9297e33f50cf 200 #error "ERROR: The EPD's COG type is not defined."
embeddedartists 0:9297e33f50cf 201 #endif
embeddedartists 0:9297e33f50cf 202
embeddedartists 0:9297e33f50cf 203 /**
embeddedartists 0:9297e33f50cf 204 * \brief Packet structure of a line data */
embeddedartists 0:9297e33f50cf 205 typedef union {
embeddedartists 0:9297e33f50cf 206 union {
embeddedartists 0:9297e33f50cf 207 struct COG_144_line_data_t line_data_for_144; /**< line data structure of 1.44" EPD */
embeddedartists 0:9297e33f50cf 208 struct COG_200_line_data_t line_data_for_200; /**< line data structure of 2" EPD */
embeddedartists 0:9297e33f50cf 209 struct COG_270_line_data_t line_data_for_270; /**< line data structure of 2.7" EPD */
embeddedartists 0:9297e33f50cf 210 } line_data_by_size; /**< the line data of specific EPD size */
embeddedartists 0:9297e33f50cf 211 uint8_t uint8[LINE_BUFFER_DATA_SIZE]; /**< the maximum line buffer data size as length */
embeddedartists 0:9297e33f50cf 212 } COG_line_data_packet_type;
embeddedartists 0:9297e33f50cf 213
embeddedartists 0:9297e33f50cf 214 /**
embeddedartists 0:9297e33f50cf 215 * \brief Define the COG driver's parameters */
embeddedartists 0:9297e33f50cf 216 struct COG_parameters_t {
embeddedartists 0:9297e33f50cf 217 uint8_t channel_select[8]; /**< the SPI register data of Channel Select */
embeddedartists 0:9297e33f50cf 218 uint8_t voltage_level; /**< the SPI register data of Voltage Level */
embeddedartists 0:9297e33f50cf 219 uint16_t horizontal_size; /**< the bytes of width of EPD */
embeddedartists 0:9297e33f50cf 220 uint16_t vertical_size; /**< the bytes of height of EPD */
embeddedartists 0:9297e33f50cf 221 uint8_t data_line_size; /**< Data + Scan + Dummy bytes */
embeddedartists 0:9297e33f50cf 222 uint16_t frame_time_offset; /**< the rest of frame time in a stage */
embeddedartists 0:9297e33f50cf 223 uint16_t stage_time; /**< defined stage time */
embeddedartists 0:9297e33f50cf 224 } ;
embeddedartists 0:9297e33f50cf 225
embeddedartists 0:9297e33f50cf 226 extern const struct COG_parameters_t COG_parameters[COUNT_OF_EPD_TYPE];
embeddedartists 0:9297e33f50cf 227 extern const uint8_t SCAN_TABLE[4];
embeddedartists 0:9297e33f50cf 228 void EPD_init(void);
embeddedartists 0:9297e33f50cf 229 void EPD_power_on (void);
embeddedartists 0:9297e33f50cf 230 uint8_t EPD_initialize_driver (uint8_t EPD_type_index);
embeddedartists 0:9297e33f50cf 231 void EPD_display_from_array_prt (uint8_t EPD_type_index, uint8_t *previous_image_ptr,
embeddedartists 0:9297e33f50cf 232 uint8_t *new_image_ptr);
embeddedartists 0:9297e33f50cf 233 void EPD_display_from_flash_prt (uint8_t EPD_type_index, long previous_image_flash_address,
embeddedartists 0:9297e33f50cf 234 long new_image_flash_address,EPD_read_flash_handler On_EPD_read_flash);
embeddedartists 0:9297e33f50cf 235 uint8_t EPD_power_off (uint8_t EPD_type_index);
embeddedartists 0:9297e33f50cf 236 void COG_driver_EPDtype_select(uint8_t EPD_type_index);
embeddedartists 0:9297e33f50cf 237
embeddedartists 0:9297e33f50cf 238 #endif //DISPLAY_COG_PROCESS__H_INCLUDED
embeddedartists 0:9297e33f50cf 239
embeddedartists 0:9297e33f50cf 240
embeddedartists 0:9297e33f50cf 241