1.1 --- a/Display_COG_Process.c Sun May 19 22:06:40 2013 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,616 +0,0 @@
1.4 -// Copyright 2013 Pervasive Displays, Inc.
1.5 -//
1.6 -// Licensed under the Apache License, Version 2.0 (the "License");
1.7 -// you may not use this file except in compliance with the License.
1.8 -// You may obtain a copy of the License at:
1.9 -//
1.10 -// http://www.apache.org/licenses/LICENSE-2.0
1.11 -//
1.12 -// Unless required by applicable law or agreed to in writing,
1.13 -// software distributed under the License is distributed on an
1.14 -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
1.15 -// express or implied. See the License for the specific language
1.16 -// governing permissions and limitations under the License.
1.17 -
1.18 -/******************************************************************************
1.19 - * Includes
1.20 - *****************************************************************************/
1.21 -//#include "driver_config.h"
1.22 -//#include "target_config.h"
1.23 -//#include "type.h"
1.24 -//#include "gpio.h"
1.25 -#include "Display_COG_Process.h"
1.26 -#include "Display_Hardware_Driver.h"
1.27 -#include "Display_Controller.h"
1.28 -#include <stdio.h>
1.29 -
1.30 -
1.31 -/******************************************************************************
1.32 - * Defines and typedefs
1.33 - *****************************************************************************/
1.34 -#define _GaugeFrameTimeMark 0
1.35 -
1.36 -const COG_Parameters_t COG_Parameters[3]= {
1.37 - { //for 1.44"
1.38 - {0x00,0x00,0x00,0x00,0x00,0x0f,0xff,0x00},
1.39 - 0x03,
1.40 - (128/8),
1.41 - 96,
1.42 - (((128+96)*2)/8),
1.43 - (43),
1.44 - 480
1.45 - },
1.46 - { //for 2.0"
1.47 - {0x00,0x00,0x00,0x00,0x01,0xFF,0xE0,0x00},
1.48 - 0x03,
1.49 - (200/8),
1.50 - 96,
1.51 - (((200+96)*2)/8)+1,
1.52 - (53),
1.53 - 480
1.54 - },
1.55 - { //for 2.7"
1.56 - {0x00,0x00,0x00,0x7F,0xFF,0xFE,0x00,0x00},
1.57 - 0x00,
1.58 - (264/8),
1.59 - 176,
1.60 - (((264+176)*2)/8)+1,
1.61 - 105,
1.62 - 630
1.63 - },
1.64 -};
1.65 -
1.66 -const uint8_t ScanTable[4] = {0xC0, 0x30, 0x0C, 0x03};
1.67 -
1.68 -
1.69 -/******************************************************************************
1.70 - * Local variables
1.71 - *****************************************************************************/
1.72 -static uint32_t StageTime = 480;
1.73 -static COG_LineDataPacket_t COG_Line;
1.74 -static uint16_t EPD_Type_Index = 0;
1.75 -static uint16_t cnt = 0;
1.76 -static uint32_t Currentframe;
1.77 -static uint8_t *DataLineEven;
1.78 -static uint8_t *DataLineOdd;
1.79 -static uint8_t *DataLineScan;
1.80 -static uint8_t *DisplayOrgPtr;
1.81 -
1.82 -
1.83 -/******************************************************************************
1.84 - * Local functions
1.85 - *****************************************************************************/
1.86 -static void SetTemperature_Factor(uint8_t EPD_Type_Index)
1.87 -{
1.88 - int16_t Temperature;
1.89 -
1.90 - //Get current temperature
1.91 - Temperature = epd_get_temperature();
1.92 -
1.93 - if (Temperature < -10)
1.94 - {
1.95 - StageTime = COG_Parameters[EPD_Type_Index].StageTime * 17;
1.96 - }
1.97 - else if (Temperature < -5)
1.98 - {
1.99 - StageTime = COG_Parameters[EPD_Type_Index].StageTime * 12;
1.100 - }
1.101 - else if (Temperature < 5)
1.102 - {
1.103 - StageTime = COG_Parameters[EPD_Type_Index].StageTime * 8;
1.104 - }
1.105 - else if (Temperature < 10)
1.106 - {
1.107 - StageTime = COG_Parameters[EPD_Type_Index].StageTime * 4;
1.108 - }
1.109 - else if (Temperature < 15)
1.110 - {
1.111 - StageTime = COG_Parameters[EPD_Type_Index].StageTime * 3;
1.112 - }
1.113 - else if (Temperature < 20)
1.114 - {
1.115 - StageTime = COG_Parameters[EPD_Type_Index].StageTime * 2;
1.116 - }
1.117 - else if (Temperature < 40)
1.118 - {
1.119 - StageTime = COG_Parameters[EPD_Type_Index].StageTime * 1;
1.120 - }
1.121 - else
1.122 - {
1.123 - StageTime = (COG_Parameters[EPD_Type_Index].StageTime * 7)/10;
1.124 - }
1.125 -}
1.126 -
1.127 -static void Driver_TypeSelect(uint8_t typeIndex)
1.128 -{
1.129 - switch(typeIndex)
1.130 - {
1.131 - case EPDType_144:
1.132 - DataLineEven=&COG_Line.LineDatas.COG_144LineData.Even[0];
1.133 - DataLineOdd=&COG_Line.LineDatas.COG_144LineData.Odd[0];
1.134 - DataLineScan=&COG_Line.LineDatas.COG_144LineData.Scan[0];
1.135 - break;
1.136 - case EPDType_200:
1.137 - DataLineEven=&COG_Line.LineDatas.COG_20LineData.Even[0];
1.138 - DataLineOdd=&COG_Line.LineDatas.COG_20LineData.Odd[0];
1.139 - DataLineScan=&COG_Line.LineDatas.COG_20LineData.Scan[0];
1.140 - break;
1.141 - case EPDType_270:
1.142 - DataLineEven=&COG_Line.LineDatas.COG_27LineData.Even[0];
1.143 - DataLineOdd=&COG_Line.LineDatas.COG_27LineData.Odd[0];
1.144 - DataLineScan=&COG_Line.LineDatas.COG_27LineData.Scan[0];
1.145 - break;
1.146 - }
1.147 -}
1.148 -
1.149 -//#pragma GCC optimize ("-O3")
1.150 -static void Display_Stage_1 (uint8_t *PreviousPicture)
1.151 -{
1.152 - uint16_t i,j,k; // general counters
1.153 - uint8_t TempByte; // Temporary storage for image data check
1.154 - uint16_t StartClock;
1.155 -#ifdef DISPLAY_180_DEGREE
1.156 - uint8_t *DataLinePrt;
1.157 - DisplayOrgPtr = (PreviousPicture+(uint32_t)((COG_Parameters[EPD_Type_Index].VERTICAL-1)*COG_Parameters[EPD_Type_Index].HORIZONTAL));
1.158 -#else
1.159 - DisplayOrgPtr = PreviousPicture;
1.160 -#endif
1.161 - Currentframe = (uint32_t)COG_Parameters[EPD_Type_Index].FrameTime;
1.162 -//TestPinTrigger();
1.163 - cnt = 0;
1.164 - StartClock = epd_GetCurrentTimeTick();
1.165 - do
1.166 - {
1.167 -// TestPin2Trigger();
1.168 - PreviousPicture = DisplayOrgPtr;
1.169 -#ifdef DISPLAY_180_DEGREE
1.170 - DataLinePrt = PreviousPicture;
1.171 -#endif
1.172 - for (i = 0; i < COG_Parameters[EPD_Type_Index].VERTICAL; i++) // for every line
1.173 - {
1.174 - // SPI (0x04, ...)
1.175 - epd_SPI_Send_Byte(0x04, COG_Parameters[EPD_Type_Index].VoltageLevel);
1.176 - k = COG_Parameters[EPD_Type_Index].HORIZONTAL-1;
1.177 - for (j = 0; j < COG_Parameters[EPD_Type_Index].HORIZONTAL; j++) // check every bit in the line
1.178 - {
1.179 - TempByte = (*PreviousPicture++);
1.180 -#ifdef DISPLAY_180_DEGREE
1.181 - DataLineEven[j] = ((TempByte & 0x80) ? BLACK3 : WHITE3)
1.182 - | ((TempByte & 0x20) ? BLACK2 : WHITE2)
1.183 - | ((TempByte & 0x08) ? BLACK1 : WHITE1)
1.184 - | ((TempByte & 0x02) ? BLACK0 : WHITE0);
1.185 -
1.186 - DataLineOdd[k--] = ((TempByte & 0x01) ? BLACK3 : WHITE3)
1.187 - | ((TempByte & 0x04) ? BLACK2 : WHITE2)
1.188 - | ((TempByte & 0x10) ? BLACK1 : WHITE1)
1.189 - | ((TempByte & 0x40) ? BLACK0 : WHITE0);
1.190 - DataLinePrt--;
1.191 -#else
1.192 - DataLineOdd[j] = ((TempByte & 0x80) ? BLACK3 : WHITE3)
1.193 - | ((TempByte & 0x20) ? BLACK2 : WHITE2)
1.194 - | ((TempByte & 0x08) ? BLACK1 : WHITE1)
1.195 - | ((TempByte & 0x02) ? BLACK0 : WHITE0);
1.196 -
1.197 - DataLineEven[k--] = ((TempByte & 0x01) ? BLACK3 : WHITE3)
1.198 - | ((TempByte & 0x04) ? BLACK2 : WHITE2)
1.199 - | ((TempByte & 0x10) ? BLACK1 : WHITE1)
1.200 - | ((TempByte & 0x40) ? BLACK0 : WHITE0);
1.201 -#endif
1.202 - }
1.203 -#ifdef DISPLAY_180_DEGREE
1.204 - PreviousPicture = DataLinePrt;
1.205 -#endif
1.206 - DataLineScan[(i>>2)] = ScanTable[(i%4)];
1.207 - // SPI (0x0a, line data....)
1.208 - epd_SPI_Send(0x0a, (uint8_t *)&COG_Line.uint8, COG_Parameters[EPD_Type_Index].DataLineSize);
1.209 -
1.210 - // SPI (0x02, 0x25)
1.211 - epd_SPI_Send_Byte(0x02, 0x2F);
1.212 -
1.213 - DataLineScan[(i>>2)] = 0;
1.214 - }
1.215 -#if(!_GaugeFrameTimeMark)
1.216 - if(COG_Parameters[EPD_Type_Index].FrameTime>0)
1.217 - {
1.218 - while(Currentframe>(epd_GetCurrentTimeTick() - StartClock));
1.219 - }
1.220 -#endif
1.221 - //TestPin2Trigger();
1.222 - Currentframe=(uint32_t)(epd_GetCurrentTimeTick() - StartClock)+COG_Parameters[EPD_Type_Index].FrameTime ;
1.223 - cnt++;
1.224 - }while (StageTime>Currentframe);
1.225 -// TestPin2Trigger();
1.226 - while(StageTime>(epd_GetCurrentTimeTick() - StartClock));
1.227 -// TestPin2Trigger();
1.228 -// TestPinTrigger();
1.229 -}
1.230 -
1.231 -//#pragma GCC optimize ("-O3")
1.232 -static void Display_Stage_2 (uint8_t *PreviousPicture)
1.233 -{
1.234 - uint16_t i, j, k; // general counters
1.235 - uint8_t TempByte; // Temporary storage for image data check
1.236 - uint16_t StartClock;
1.237 -#ifdef DISPLAY_180_DEGREE
1.238 - uint8_t *DataLinePrt;
1.239 - DisplayOrgPtr = (PreviousPicture+(uint32_t)((COG_Parameters[EPD_Type_Index].VERTICAL-1)*COG_Parameters[EPD_Type_Index].HORIZONTAL));
1.240 -#else
1.241 - DisplayOrgPtr = PreviousPicture;
1.242 -#endif
1.243 -
1.244 -// TestPinTrigger();
1.245 - cnt = 0;
1.246 - Currentframe = (uint32_t)COG_Parameters[EPD_Type_Index].FrameTime;
1.247 - StartClock = epd_GetCurrentTimeTick();
1.248 - do
1.249 - {
1.250 -// TestPin2Trigger();
1.251 - PreviousPicture = DisplayOrgPtr;
1.252 -#ifdef DISPLAY_180_DEGREE
1.253 - DataLinePrt = PreviousPicture;
1.254 -#endif
1.255 - for (i = 0; i < COG_Parameters[EPD_Type_Index].VERTICAL; i++) // for every line
1.256 - {
1.257 - // SPI (0x04, ...)
1.258 - epd_SPI_Send_Byte(0x04, COG_Parameters[EPD_Type_Index].VoltageLevel);
1.259 - k = COG_Parameters[EPD_Type_Index].HORIZONTAL-1;
1.260 - for (j = 0; j < COG_Parameters[EPD_Type_Index].HORIZONTAL; j++) // make every bit in the line black
1.261 - {
1.262 - TempByte =(*PreviousPicture++);
1.263 -#ifdef DISPLAY_180_DEGREE
1.264 - DataLineEven[j] = ((TempByte & 0x80) ? WHITE3 : NOTHING)
1.265 - | ((TempByte & 0x20) ? WHITE2 : NOTHING)
1.266 - | ((TempByte & 0x08) ? WHITE1 : NOTHING)
1.267 - | ((TempByte & 0x02) ? WHITE0 : NOTHING);
1.268 - DataLineOdd[k--] = ((TempByte & 0x01) ? WHITE3 : NOTHING)
1.269 - | ((TempByte & 0x04) ? WHITE2 : NOTHING)
1.270 - | ((TempByte & 0x10) ? WHITE1 : NOTHING)
1.271 - | ((TempByte & 0x40) ? WHITE0 : NOTHING);
1.272 - DataLinePrt--;
1.273 -#else
1.274 - DataLineOdd[j] = ((TempByte & 0x80) ? WHITE3 : NOTHING)
1.275 - | ((TempByte & 0x20) ? WHITE2 : NOTHING)
1.276 - | ((TempByte & 0x08) ? WHITE1 : NOTHING)
1.277 - | ((TempByte & 0x02) ? WHITE0 : NOTHING);
1.278 - DataLineEven[k--] = ((TempByte & 0x01) ? WHITE3 : NOTHING)
1.279 - | ((TempByte & 0x04) ? WHITE2 : NOTHING)
1.280 - | ((TempByte & 0x10) ? WHITE1 : NOTHING)
1.281 - | ((TempByte & 0x40) ? WHITE0 : NOTHING);
1.282 -#endif
1.283 - }
1.284 -
1.285 -#ifdef DISPLAY_180_DEGREE
1.286 - PreviousPicture = DataLinePrt;
1.287 -#endif
1.288 - DataLineScan[(i>>2)] = ScanTable[(i%4)];
1.289 - // SPI (0x0a, line data....)
1.290 - epd_SPI_Send(0x0a, (uint8_t *)&COG_Line.uint8, COG_Parameters[EPD_Type_Index].DataLineSize);
1.291 -
1.292 - epd_SPI_Send_Byte(0x02, 0x25);
1.293 -
1.294 - DataLineScan[(i>>2)] = 0;
1.295 - }
1.296 -#if(!_GaugeFrameTimeMark)
1.297 - if(COG_Parameters[EPD_Type_Index].FrameTime>0)
1.298 - {
1.299 - while(Currentframe>(epd_GetCurrentTimeTick() - StartClock));
1.300 - }
1.301 -#endif
1.302 - //TestPin2Trigger();
1.303 - Currentframe=(uint32_t)(epd_GetCurrentTimeTick() - StartClock)+COG_Parameters[EPD_Type_Index].FrameTime ;
1.304 - cnt++;
1.305 - }while (StageTime>Currentframe);
1.306 -// TestPin2Trigger();
1.307 - while(StageTime>(epd_GetCurrentTimeTick() - StartClock));
1.308 -// TestPin2Trigger();
1.309 -// TestPinTrigger();
1.310 -}
1.311 -
1.312 -
1.313 -//#pragma GCC optimize ("-O3")
1.314 -static void Display_Stage_3 (uint8_t *Picture)
1.315 -{
1.316 - uint16_t i, j,k; // general counters
1.317 - uint8_t TempByte; // Temporary storage for image data check
1.318 - uint16_t StartClock;
1.319 -#ifdef DISPLAY_180_DEGREE
1.320 - uint8_t *DataLinePrt;
1.321 - DisplayOrgPtr = (Picture+(uint32_t)((COG_Parameters[EPD_Type_Index].VERTICAL-1)*COG_Parameters[EPD_Type_Index].HORIZONTAL));
1.322 -#else
1.323 - DisplayOrgPtr = Picture;
1.324 -#endif
1.325 - Currentframe = (uint32_t)COG_Parameters[EPD_Type_Index].FrameTime;
1.326 - cnt = 0;
1.327 -// TestPinTrigger();
1.328 - StartClock = epd_GetCurrentTimeTick();
1.329 - do
1.330 - {
1.331 -// TestPin2Trigger();
1.332 - Picture = DisplayOrgPtr;
1.333 -#ifdef DISPLAY_180_DEGREE
1.334 - DataLinePrt = Picture;
1.335 -#endif
1.336 - for (i = 0; i < COG_Parameters[EPD_Type_Index].VERTICAL; i++) // for every line
1.337 - {
1.338 - // SPI (0x04, 0x03)
1.339 - epd_SPI_Send_Byte(0x04, COG_Parameters[EPD_Type_Index].VoltageLevel);
1.340 - k = COG_Parameters[EPD_Type_Index].HORIZONTAL-1;
1.341 - for (j = 0; j < COG_Parameters[EPD_Type_Index].HORIZONTAL; j++) // check every bit in the line
1.342 - {
1.343 - TempByte = (*Picture++);
1.344 -#ifdef DISPLAY_180_DEGREE
1.345 - DataLineEven[j] = ((TempByte & 0x80) ? BLACK3 : NOTHING)
1.346 - | ((TempByte & 0x20) ? BLACK2 : NOTHING )
1.347 - | ((TempByte & 0x08) ? BLACK1 : NOTHING )
1.348 - | ((TempByte & 0x02) ? BLACK0 : NOTHING );
1.349 -
1.350 - DataLineOdd[k--] = ((TempByte & 0x01) ? BLACK3 : NOTHING)
1.351 - | ((TempByte & 0x04) ? BLACK2 : NOTHING )
1.352 - | ((TempByte & 0x10) ? BLACK1 : NOTHING )
1.353 - | ((TempByte & 0x40) ? BLACK0 : NOTHING );
1.354 - DataLinePrt--;
1.355 -#else
1.356 - DataLineOdd[j] = ((TempByte & 0x80) ? BLACK3 : NOTHING)
1.357 - | ((TempByte & 0x20) ? BLACK2 : NOTHING )
1.358 - | ((TempByte & 0x08) ? BLACK1 : NOTHING )
1.359 - | ((TempByte & 0x02) ? BLACK0 : NOTHING );
1.360 -
1.361 - DataLineEven[k--] = ((TempByte & 0x01) ? BLACK3 : NOTHING)
1.362 - | ((TempByte & 0x04) ? BLACK2 : NOTHING )
1.363 - | ((TempByte & 0x10) ? BLACK1 : NOTHING )
1.364 - | ((TempByte & 0x40) ? BLACK0 : NOTHING );
1.365 -#endif
1.366 - }
1.367 -#ifdef DISPLAY_180_DEGREE
1.368 - Picture = DataLinePrt;
1.369 -#endif
1.370 - DataLineScan[(i>>2)] = ScanTable[(i%4)];
1.371 - // SPI (0x0a, line data....)
1.372 - epd_SPI_Send(0x0a, (uint8_t *)&COG_Line.uint8, COG_Parameters[EPD_Type_Index].DataLineSize);
1.373 -
1.374 - epd_SPI_Send_Byte(0x02, 0x2F);
1.375 -
1.376 - DataLineScan[(i>>2)] = 0;
1.377 - }
1.378 -#if(!_GaugeFrameTimeMark)
1.379 - if(COG_Parameters[EPD_Type_Index].FrameTime>0)
1.380 - {
1.381 - while(Currentframe>(epd_GetCurrentTimeTick() - StartClock));
1.382 - }
1.383 -#endif
1.384 - //TestPin2Trigger();
1.385 - Currentframe=(uint32_t)(epd_GetCurrentTimeTick() - StartClock)+COG_Parameters[EPD_Type_Index].FrameTime ;
1.386 - cnt++;
1.387 - }while (StageTime>Currentframe);
1.388 -// TestPin2Trigger();
1.389 - while(StageTime>(epd_GetCurrentTimeTick() - StartClock));
1.390 -// TestPin2Trigger();
1.391 -// TestPinTrigger();
1.392 -}
1.393 -
1.394 -//#pragma GCC optimize ("-O3")
1.395 -static void Display_Stage_4 (uint8_t *Picture)
1.396 -{
1.397 - uint16_t i, j,k; // general counters
1.398 - uint8_t TempByte; // Temporary storage for image data check
1.399 - uint16_t StartClock;
1.400 -#ifdef DISPLAY_180_DEGREE
1.401 - uint8_t *DataLinePrt;
1.402 - DisplayOrgPtr = (Picture+(uint32_t)((COG_Parameters[EPD_Type_Index].VERTICAL-1)*COG_Parameters[EPD_Type_Index].HORIZONTAL));
1.403 -#else
1.404 - DisplayOrgPtr = Picture;
1.405 -#endif
1.406 - Currentframe = (uint32_t)COG_Parameters[EPD_Type_Index].FrameTime;
1.407 - cnt = 0;
1.408 -// TestPinTrigger();
1.409 -
1.410 - StartClock = epd_GetCurrentTimeTick();
1.411 - do
1.412 - {
1.413 -// TestPin2Trigger();
1.414 - Picture = DisplayOrgPtr;
1.415 -#ifdef DISPLAY_180_DEGREE
1.416 - DataLinePrt = Picture;
1.417 -#endif
1.418 - for (i = 0; i < COG_Parameters[EPD_Type_Index].VERTICAL; i++) // for every line
1.419 - {
1.420 - // SPI (0x04, ...)
1.421 - epd_SPI_Send_Byte(0x04, COG_Parameters[EPD_Type_Index].VoltageLevel);
1.422 - k = COG_Parameters[EPD_Type_Index].HORIZONTAL-1;
1.423 - for (j = 0; j < COG_Parameters[EPD_Type_Index].HORIZONTAL; j++) // check every bit in the line
1.424 - {
1.425 - TempByte =(*Picture++);
1.426 -#ifdef DISPLAY_180_DEGREE
1.427 - DataLineEven[j] = ((TempByte & 0x80) ? WHITE3 : BLACK3 )
1.428 - | ((TempByte & 0x20) ? WHITE2 : BLACK2 )
1.429 - | ((TempByte & 0x08) ? WHITE1 : BLACK1 )
1.430 - | ((TempByte & 0x02) ? WHITE0 : BLACK0 );
1.431 -
1.432 - DataLineOdd[k--] = ((TempByte & 0x01) ? WHITE3 : BLACK3 )
1.433 - | ((TempByte & 0x04) ? WHITE2 : BLACK2 )
1.434 - | ((TempByte & 0x10) ? WHITE1 : BLACK1 )
1.435 - | ((TempByte & 0x40) ? WHITE0 : BLACK0 );
1.436 - DataLinePrt--;
1.437 -#else
1.438 - DataLineOdd[j] = ((TempByte & 0x80) ? WHITE3 : BLACK3 )
1.439 - | ((TempByte & 0x20) ? WHITE2 : BLACK2 )
1.440 - | ((TempByte & 0x08) ? WHITE1 : BLACK1 )
1.441 - | ((TempByte & 0x02) ? WHITE0 : BLACK0 );
1.442 -
1.443 - DataLineEven[k--] = ((TempByte & 0x01) ? WHITE3 : BLACK3 )
1.444 - | ((TempByte & 0x04) ? WHITE2 : BLACK2 )
1.445 - | ((TempByte & 0x10) ? WHITE1 : BLACK1 )
1.446 - | ((TempByte & 0x40) ? WHITE0 : BLACK0 );
1.447 -#endif
1.448 - }
1.449 -#ifdef DISPLAY_180_DEGREE
1.450 - Picture = DataLinePrt;
1.451 -#endif
1.452 - DataLineScan[(i>>2)] = ScanTable[(i%4)];
1.453 - // SPI (0x0a, line data....)
1.454 - epd_SPI_Send(0x0a, (uint8_t *)&COG_Line.uint8, COG_Parameters[EPD_Type_Index].DataLineSize);
1.455 -
1.456 - epd_SPI_Send_Byte(0x02, 0x2F);
1.457 -
1.458 - DataLineScan[(i>>2)] = 0;
1.459 - }
1.460 -#if(!_GaugeFrameTimeMark)
1.461 - if(COG_Parameters[EPD_Type_Index].FrameTime>0)
1.462 - {
1.463 - while(Currentframe>(epd_GetCurrentTimeTick() - StartClock));
1.464 - }
1.465 -#endif
1.466 - //TestPin2Trigger();
1.467 - Currentframe=(uint32_t)(epd_GetCurrentTimeTick() - StartClock)+COG_Parameters[EPD_Type_Index].FrameTime ;
1.468 - cnt++;
1.469 - }while (StageTime>Currentframe);
1.470 -
1.471 -// TestPin2Trigger();
1.472 - while(StageTime>(epd_GetCurrentTimeTick() - StartClock));
1.473 -// TestPin2Trigger();
1.474 -// TestPinTrigger();
1.475 -}
1.476 -
1.477 -static void Display_Nothing (void)
1.478 -{
1.479 - uint16_t i; // general counters
1.480 -
1.481 - for (i = 0; i < COG_Parameters[EPD_Type_Index].HORIZONTAL; i++) // make every bit in the line white
1.482 - {
1.483 - DataLineEven[i] = 0x00;
1.484 - DataLineOdd[i] = 0x00;
1.485 - }
1.486 -
1.487 - for (i = 0; i < COG_Parameters[EPD_Type_Index].VERTICAL; i++) // for every line
1.488 - {
1.489 - epd_SPI_Send_Byte(0x04, 0x03);
1.490 - DataLineScan[(i>>2)] = ScanTable[(i%4)];
1.491 - // SPI (0x0a, line data....)
1.492 - epd_SPI_Send(0x0a, (uint8_t *)&COG_Line.uint8, COG_Parameters[EPD_Type_Index].DataLineSize);
1.493 -
1.494 - epd_SPI_Send_Byte(0x02, 0x2F);
1.495 - }
1.496 -}
1.497 -
1.498 -static void Dummy_line(void)
1.499 -{
1.500 - uint16_t i;
1.501 -
1.502 - for (i = 0; i < COG_Parameters[EPD_Type_Index].DataLineSize; i++)
1.503 - {
1.504 - COG_Line.uint8[i] = 0x00;
1.505 - }
1.506 -
1.507 - epd_SPI_Send_Byte(0x04, 0x03);
1.508 -
1.509 - // SPI (0x0a, line data....)
1.510 - epd_SPI_Send(0x0a, (uint8_t *)&COG_Line.uint8, COG_Parameters[EPD_Type_Index].DataLineSize);
1.511 -
1.512 - epd_SPI_Send_Byte(0x02, 0x2F);
1.513 -}
1.514 -
1.515 -
1.516 -/******************************************************************************
1.517 - * Public functions
1.518 - *****************************************************************************/
1.519 -void epd_HwInit(void)
1.520 -{
1.521 - epd_InitDisplayHardware();
1.522 -}
1.523 -
1.524 -void epd_PowerOn(void)
1.525 -{
1.526 - bsp_PowerOn();
1.527 -}
1.528 -
1.529 -void epd_InitializeDriver(uint8_t EPDIndex)
1.530 -{
1.531 - uint8_t SendBuffer[2];
1.532 - uint16_t k;
1.533 -
1.534 - EPD_Type_Index = EPDIndex;
1.535 -
1.536 - //Data Line Clear
1.537 - for (k = 0; k <= __LineDataSize; k ++)
1.538 - {
1.539 - COG_Line.uint8[k] = 0x00;
1.540 - }
1.541 - Driver_TypeSelect(EPDIndex);
1.542 - k = 0;
1.543 -
1.544 - SetTemperature_Factor(EPDIndex);
1.545 -
1.546 - /*while (DRIVERBUSY_Get())
1.547 - {
1.548 - delayT32B0Us(500);
1.549 - if((k++)>=1000) return;//wait 500 ms
1.550 - }
1.551 - */
1.552 -
1.553 - // SPI (0x01, 0x0000, 0x0000, 0x01ff, 0xe000)
1.554 - epd_SPI_Send(0x01, (uint8_t *)&COG_Parameters[EPDIndex].ChannelSelect, 8);
1.555 -
1.556 - epd_SPI_Send_Byte(0x06, 0xff);
1.557 - epd_SPI_Send_Byte(0x07, 0x9d);
1.558 - epd_SPI_Send_Byte(0x08, 0x00);
1.559 -
1.560 - // SPI (0x09, 0xd000)
1.561 - SendBuffer[0] = 0xd0;
1.562 - SendBuffer[1] = 0x00;
1.563 - epd_SPI_Send(0x09, SendBuffer, 2);
1.564 -
1.565 - epd_SPI_Send_Byte(0x04,COG_Parameters[EPDIndex].VoltageLevel);
1.566 -
1.567 - epd_SPI_Send_Byte(0x03, 0x01);
1.568 - epd_SPI_Send_Byte(0x03, 0x00);
1.569 -
1.570 - epd_pwm_active(5);
1.571 -
1.572 - epd_SPI_Send_Byte(0x05, 0x01);
1.573 -
1.574 - epd_pwm_active(30);
1.575 -
1.576 - epd_SPI_Send_Byte(0x05, 0x03);
1.577 - epd_delay_ms(30);
1.578 - epd_SPI_Send_Byte(0x05, 0x0f);
1.579 - epd_delay_ms(30);
1.580 - epd_SPI_Send_Byte(0x02, 0x24);
1.581 - printf("Done initialisation.\n");
1.582 -}
1.583 -
1.584 -void epd_Display (uint8_t *pNewImg, uint8_t *pPrevImg)
1.585 -{
1.586 - //COG Process - update display in four steps
1.587 - Display_Stage_1(pPrevImg);
1.588 - Display_Stage_2(pPrevImg);
1.589 - Display_Stage_3(pNewImg);
1.590 - Display_Stage_4(pNewImg);
1.591 -}
1.592 -
1.593 -void epd_PowerOff (void)
1.594 -{
1.595 - Display_Nothing();
1.596 - Dummy_line();
1.597 - epd_delay_ms(25);
1.598 -
1.599 - //border_low();
1.600 - //epd_delay_ms(_30ms);
1.601 - //border_high();
1.602 -
1.603 - epd_SPI_Send_Byte(0x03, 0x01);
1.604 - epd_SPI_Send_Byte(0x02, 0x05);
1.605 - epd_SPI_Send_Byte(0x05, 0x0E);
1.606 - epd_SPI_Send_Byte(0x05, 0x02);
1.607 - epd_SPI_Send_Byte(0x04, 0x0C);
1.608 - epd_delay_ms(120);
1.609 - epd_SPI_Send_Byte(0x05, 0x00);
1.610 - epd_SPI_Send_Byte(0x07, 0x0D);
1.611 - epd_SPI_Send_Byte(0x04, 0x50);
1.612 - epd_delay_ms(40);
1.613 - epd_SPI_Send_Byte(0x04, 0xA0);
1.614 - epd_delay_ms(40);
1.615 - epd_SPI_Send_Byte(0x04, 0x00);
1.616 -
1.617 - printf("Shutdown...\n");
1.618 - bsp_Shutdown();
1.619 -}