[c]代码库
/* Includes ------------------------------------------------------------------*/
#include "stm32f10x.h"
//u16 DeviceCode;
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
#define EPD_TIMER_DELAY 0xf//0x11111111
#define LOOP_TIME 4
extern const unsigned char array0[];
extern const unsigned char array1[];
unsigned char *ptr_old_pic;
unsigned char *ptr_new_pic;
//------------------ four state of buff -------------------------------------------
#define EPD_TIMER_DELAY_FUNC
//---------------------------------------------------------------------
#define EPD_CL GPIO_Pin_1 //PA1
#define EPD_XCE1 GPIO_Pin_2 //PA2
#define EPD_XCE2 GPIO_Pin_3 //PA3
#define EPD_LE GPIO_Pin_8 //PA8
#define KEY_WKUP GPIO_Pin_0 //PA0
#define EPD_OE GPIO_Pin_0 //PB0
#define EPD_STL GPIO_Pin_1 //PB1
#define EPD_SHR GPIO_Pin_8 //PB8
#define EPD_XRL GPIO_Pin_9 //PB9
#define EPD_GMODE2 GPIO_Pin_10 //PB10
#define EPD_GMODE1 GPIO_Pin_11 //PB11
#define VBO_CTR1 GPIO_Pin_12 //PB12
#define VBO_CTR2 GPIO_Pin_13 //PB13
#define AAT_EN1 GPIO_Pin_14 //PB14
#define AAT_EN2 GPIO_Pin_15 //PB15
#define EPD_DB_0 GPIO_Pin_0 //PC0
#define EPD_DB_1 GPIO_Pin_1 //PC1
#define EPD_DB_2 GPIO_Pin_2 //PC2
#define EPD_DB_3 GPIO_Pin_3 //PC3
#define EPD_DB_4 GPIO_Pin_4 //PC4
#define EPD_DB_5 GPIO_Pin_5 //PC5
#define EPD_DB_6 GPIO_Pin_6 //PC6
#define EPD_DB_7 GPIO_Pin_7 //PC7
#define EPD_DB_7_OT GPIO_Pin_12 //PC7
#define EPD_XSPV GPIO_Pin_8 //PC8
#define EPD_CLK GPIO_Pin_9 //PC9
#define VCOM_CTR2 GPIO_Pin_10 //PC10
#define KEY_USER3 GPIO_Pin_11 //PC11
#define KEY_USER4 GPIO_Pin_12 //PC12
#define KEY_TANPER GPIO_Pin_13 //PC13
#define POWER_CTR GPIO_Pin_2 //PD2
#define VCOM_CTR1 GPIO_Pin_4 //PE4
#define KEY_USER1 GPIO_Pin_10 //PF10
#define KEY_USER2 GPIO_Pin_11 //PF11
#define SD1_PIN GPIO_Pin_6 //PF6
#define SD2_PIN GPIO_Pin_7 //PF7
#define AAT_EN3 GPIO_Pin_8 //PG8
#define AAT_EN4 GPIO_Pin_15 //PG15
//---------------------------------------------------------------------
#define EPD_XCE_PORT GPIOA
#define EPD_CL_PORT GPIOA
#define EPD_LE_PORT GPIOA
#define KEY_WKUP_PORT GPIOA
#define VBO_CTR_PORT GPIOB
#define EPD_GMODE_PORT GPIOB
#define EPD_OE_PORT GPIOB
#define EPD_STL_PORT GPIOB
#define EPD_SHR_PORT GPIOB
#define EPD_XRL_PORT GPIOB
#define AAT_EN1_PORT GPIOB
#define AAT_EN2_PORT GPIOB
#define EPD_XSPV_PORT GPIOC
#define EPD_CLK_PORT GPIOC
#define VCOM_CTR2_PORT GPIOC
#define EPD_DB_PORT GPIOC
#define KEY_USER3_PORT GPIOC
#define KEY_USER4_PORT GPIOC
#define KEY_TANPER_PORT GPIOC
#define POWER_CTR_PORT GPIOD
#define VCOM_CTR1_PORT GPIOE
#define KEY_USER1_PORT GPIOF
#define KEY_USER2_PORT GPIOF
#define LED1_IN_PORT GPIOF
#define LED2_IN_PORT GPIOF
#define AAT_EN3_PORT GPIOG
#define AAT_EN4_PORT GPIOG
/* Values magic to the Board keys */
#define NOKEY
#define KEY1 KEY_WKUP
#define KEY2 KEY_USER1
#define KEY3 KEY_USER2
#define KEY4 KEY_USER3
#define KEY5 KEY_USER4
#define KEY6 KEY_TANPER
//---------------------------------------------------------------------
#define PORT_A_PIN_EPD_USE EPD_CL | EPD_XCE1 | EPD_XCE2 | EPD_LE
#define PORT_A_PIN_KEY_USE KEY1
#define PORT_B_PIN_EPD_USE EPD_OE | EPD_STL | EPD_SHR | EPD_XRL | EPD_GMODE2 | EPD_GMODE1 | VBO_CTR1 | VBO_CTR2 | AAT_EN1 | AAT_EN2
#if 1//由于PC7坏了,所以用PC12代替,原PC12是按键检测口,这里有改动
#define PORT_C_PIN_EPD_USE EPD_XSPV | EPD_CLK | VCOM_CTR2 | EPD_DB_0 | EPD_DB_1 | EPD_DB_2 | EPD_DB_3 | EPD_DB_4 | EPD_DB_5 | EPD_DB_6 | EPD_DB_7 | EPD_DB_7_OT
#define PORT_C_PIN_KEY_USE KEY4|KEY6// KEY4|KEY5|KEY6
#else
#define PORT_C_PIN_EPD_USE EPD_XSPV | EPD_CLK | VCOM_CTR2 | EPD_DB_0 | EPD_DB_1 | EPD_DB_2 | EPD_DB_3 | EPD_DB_4 | EPD_DB_5 | EPD_DB_6 | EPD_DB_7
#define PORT_C_PIN_KEY_USE KEY4|KEY5|KEY6
#endif
#define PORT_D_PIN_EPD_USE POWER_CTR
#define PORT_E_PIN_EPD_USE VCOM_CTR1
#define PORT_F_PIN_EPD_USE SD1_PIN|SD2_PIN
#define PORT_F_PIN_KEY_USE KEY2|KEY3
#define PORT_G_PIN_EPD_USE AAT_EN3 | AAT_EN4
//---------------------------------------------------------------------
//---------------------------------------------------------------------
#define RCC_GPIO_USE RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE| RCC_APB2Periph_GPIOF | RCC_APB2Periph_GPIOG
#if 1
#define GPIO_SPEED_EPD GPIO_Speed_50MHz
#else
#define GPIO_SPEED_EPD GPIO_Speed_2MHz//GPIO_Speed_10MHz
#endif
//----------------------------------------------------------------------
//---------------------------------------------------------------------
#if 1
#define FRAME_LEN 18
//波形Excel文件
unsigned char wave[4][FRAME_LEN]=
{
0,0,0,0,0,0,1,1,1,1,1,2,2,2,2,2,0,0, //白到白
0,0,1,1,1,1,1,2,2,2,2,2,1,1,1,1,0,0, //白到黑
0,0,2,2,2,2,1,1,1,1,1,2,2,2,2,2,0,0, //黑到白
0,0,2,2,2,2,2,2,2,1,1,1,1,1,1,1,0,0, //黑到黑
};
#define FRAME_INIT_LEN 44
unsigned char init_wave[FRAME_INIT_LEN]=
{
0,0,
0x55,0x55,0x55,0x55,0x55,
0,0,
0xaa,0xaa,0xaa,0xaa,0xaa,
0,0,
0x55,0x55,0x55,0x55,0x55,
0,0,
0xaa,0xaa,0xaa,0xaa,0xaa,
0,0,
0x55,0x55,0x55,0x55,0x55,
0,0,
0xaa,0xaa,0xaa,0xaa,0xaa,
0,0,
};
#endif
//生成于Ram的波形数据表
unsigned char wave_table[256][FRAME_LEN]={0};
unsigned char g_dest_data[200];
unsigned char loop = 0;
unsigned char column = 0;
unsigned int old_data;
unsigned int new_data;
//---------------------------------------------------------------------
//---------------------------------------------------------------------
#define EPD_CL_H EPD_CL_PORT->BSRR =EPD_CL
#define EPD_CL_L EPD_CL_PORT->BRR =EPD_CL
#define EPD_LE_H EPD_LE_PORT->BSRR =EPD_LE
#define EPD_LE_L EPD_LE_PORT->BRR =EPD_LE
#define EPD_OE_H EPD_OE_PORT->BSRR =EPD_OE
#define EPD_OE_L EPD_OE_PORT->BRR =EPD_OE
#define EPD_STL_H EPD_STL_PORT->BSRR =EPD_STL
#define EPD_STL_L EPD_STL_PORT->BRR =EPD_STL
#define EPD_XSPV_H EPD_XSPV_PORT->BSRR =EPD_XSPV
#define EPD_XSPV_L EPD_XSPV_PORT->BRR =EPD_XSPV
#define EPD_CLK_H EPD_CLK_PORT->BSRR =EPD_CLK
#define EPD_CLK_L EPD_CLK_PORT->BRR =EPD_CLK
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
GPIO_InitTypeDef GPIO_InitStructure;
ErrorStatus HSEStartUpStatus;
/* Private function prototypes -----------------------------------------------*/
void Delay(vu32 nCount);
void SYS_Init(void);
void AAT1156_ON(void);
void AAT1156_OFF(void);
void EPD_Init(void);
void EPD_Start_Scan(void);
void EPD_End_Scan(void);
void EPD_Send_Row_Data(u8 *pArray);
void EPD_Display_end_Screen(void);
void EPD_Display_ChagnePIC(const unsigned char *pold, const unsigned char *pnew);
void EPD_Display_INIT();
void EPD_Display_TEST();
void EPD_Display_PIC(const unsigned char *pnew);
/*------------------------------------------------------*/
//void EPD_Display(const unsigned char *pic);
//
void make_wave_table()
{
int frame, num;
unsigned char tmp,value;
for(frame=0; frame<FRAME_LEN; frame++)
{
for(num=0; num<256; num++)
{
tmp = 0;
tmp = wave[(((num>>7)&0x1)*2 + ((num>>3)&0x1))][frame];
tmp = tmp<< 2;
tmp &= 0xfffc;
tmp |= wave[(((num>>6)&0x1)*2 + ((num>>2)&0x1))][frame];
tmp = tmp<< 2;
tmp &= 0xfffc;
tmp |= wave[(((num>>5)&0x1)*2 + ((num>>1)&0x1))][frame];
tmp = tmp<< 2;
tmp &= 0xfffc;
tmp |= wave[(((num>>4)&0x1)*2 + ((num>>0)&0x1))][frame];
value = 0;
value = (tmp <<6) & 0xc0;
value += (tmp<<2) & 0x30;
value += (tmp>>2) & 0x0c;
value += (tmp>>6) & 0x03;
wave_table[num][frame] = value;
}
}
}
/*******************************************************************************
* Function Name : main
* Description : Main program.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
int main(void)
{
SYS_Init();
AAT1156_OFF();
//SPI_Flash_Init();
EPD_Init();
GPIO_ResetBits(LED1_IN_PORT ,SD1_PIN);
GPIO_SetBits(LED1_IN_PORT ,SD1_PIN);
GPIO_ResetBits(LED2_IN_PORT ,SD2_PIN);
make_wave_table();
#if 0
EPD_Display_INIT();
EPD_Display_PIC(array0);
Delay(0x03ffffff);
EPD_Display_INIT();
EPD_Display_PIC(array1);
#else
EPD_Display_INIT(); //第一次开机状态未知,故需刷屏
EPD_Display_PIC(array0);
Delay(0x03ffffff);
EPD_Display_ChagnePIC(array0, array1);
#endif
GPIO_ResetBits(LED2_IN_PORT ,SD2_PIN);
GPIO_ResetBits(LED2_IN_PORT ,SD2_PIN);
GPIO_ResetBits(LED1_IN_PORT ,SD1_PIN);
while(1);
}
/*******************************************************************************
* Function Name : Delay
* Description : Inserts a delay time.
* Input : nCount: specifies the delay time length.
* Output : None
* Return : None
*******************************************************************************/
void Delay(vu32 nCount)
{
for(; nCount != 0; nCount--);
}
void SYS_Init(void)
{
SystemInit();//
RCC_APB2PeriphClockCmd(RCC_GPIO_USE, ENABLE); /*使能系统使用到的GPIO的时钟*/
//配置EPD使用到的GPIO的参数
GPIO_InitStructure.GPIO_Pin = PORT_A_PIN_EPD_USE;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_SPEED_EPD;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = PORT_A_PIN_KEY_USE;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_InitStructure.GPIO_Speed = GPIO_SPEED_EPD;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = PORT_B_PIN_EPD_USE;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_SPEED_EPD;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = PORT_C_PIN_EPD_USE;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_SPEED_EPD;
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = PORT_C_PIN_KEY_USE;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_InitStructure.GPIO_Speed = GPIO_SPEED_EPD;
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = PORT_D_PIN_EPD_USE;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_SPEED_EPD;
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = PORT_E_PIN_EPD_USE;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_SPEED_EPD;
GPIO_Init(GPIOE, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = PORT_F_PIN_EPD_USE;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_SPEED_EPD;
GPIO_Init(GPIOF, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = PORT_F_PIN_KEY_USE;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_InitStructure.GPIO_Speed = GPIO_SPEED_EPD;
GPIO_Init(GPIOF, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = PORT_G_PIN_EPD_USE;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_SPEED_EPD;
GPIO_Init(GPIOG, &GPIO_InitStructure);
//---------END----------------
}
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
void AAT1156_ON(void)
{
GPIO_SetBits(AAT_EN1_PORT,AAT_EN1);
GPIO_SetBits(AAT_EN2_PORT,AAT_EN2);
GPIO_SetBits(AAT_EN3_PORT,AAT_EN3);
GPIO_SetBits(AAT_EN4_PORT,AAT_EN4);
Delay(0xff);
GPIO_SetBits(VCOM_CTR1_PORT,VCOM_CTR2);//VCOM = -V
GPIO_ResetBits(VCOM_CTR2_PORT,VCOM_CTR1);
GPIO_SetBits(GPIOB,VBO_CTR2);//VBORDER = -15V
GPIO_ResetBits(GPIOB,VBO_CTR1);
Delay(0xff);
}
void AAT1156_OFF(void)
{
GPIO_SetBits(VCOM_CTR1_PORT,VCOM_CTR2);//VCOM = -V
GPIO_SetBits(VCOM_CTR2_PORT,VCOM_CTR1);
GPIO_SetBits(GPIOB,VBO_CTR2);//VBORDER = -15V
GPIO_SetBits(GPIOB,VBO_CTR1);
Delay(0xff);
GPIO_ResetBits(AAT_EN4_PORT,AAT_EN4);
GPIO_ResetBits(AAT_EN3_PORT,AAT_EN3);
GPIO_ResetBits(AAT_EN2_PORT,AAT_EN2);
GPIO_ResetBits(AAT_EN1_PORT,AAT_EN1);
Delay(0xff);
}
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
void EPD_Init(void)
{
GPIO_ResetBits(EPD_SHR_PORT,EPD_SHR); //Shift direction source driver
GPIO_SetBits(EPD_GMODE_PORT,EPD_GMODE1 | EPD_GMODE2); //one pulse mode
GPIO_ResetBits(EPD_XRL_PORT,EPD_XRL); //Shift direction gate driver
GPIO_ResetBits(EPD_XCE_PORT,EPD_XCE1 | EPD_XCE2); //EPD正像
GPIO_SetBits(VCOM_CTR1_PORT,VCOM_CTR2); //VCOM = -V
GPIO_ResetBits(VCOM_CTR2_PORT,VCOM_CTR1);
GPIO_SetBits(GPIOB,VBO_CTR2); //VBORDER = -15V
GPIO_ResetBits(GPIOB,VBO_CTR1);
EPD_LE_L;
EPD_CL_L;
EPD_OE_L;
EPD_STL_H;
EPD_XSPV_H;
EPD_CLK_L;
}
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//EPD开始时序
void EPD_Start_Scan(void)
{
EPD_XSPV_H; //XSPV先高
loop = LOOP_TIME; //DCLK跑3个时钟
while(loop--)
{
EPD_CLK_L;
Delay(EPD_TIMER_DELAY);
EPD_CLK_H;
Delay(EPD_TIMER_DELAY);
}
EPD_XSPV_L; //XSPV再低
loop = LOOP_TIME;
while(loop--)
{
EPD_CLK_L; //DCLK跑3个时钟
Delay(EPD_TIMER_DELAY);
EPD_CLK_H;
Delay(EPD_TIMER_DELAY);
}
EPD_XSPV_H; //XSPV 变高
loop = LOOP_TIME;
while(loop--)
{
EPD_CLK_L;
Delay(EPD_TIMER_DELAY);
EPD_CLK_H;
Delay(EPD_TIMER_DELAY);
}
}
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//行结束扫描波形函数
void EPD_End_Scan(void)
{
loop = 1; //CL 又一个时钟,
while(loop--)
{
EPD_CL_L;
Delay(EPD_TIMER_DELAY);
EPD_CL_H;
Delay(EPD_TIMER_DELAY);
}
EPD_CLK_L; //DCLK 变低
EPD_OE_L; //OE 变低
loop = 3; //cl循环3个时钟送数据。
while(loop--)
{
EPD_CL_L;
Delay(EPD_TIMER_DELAY);
EPD_CL_H;
Delay(EPD_TIMER_DELAY);
}
EPD_CLK_H; //DCLK 变高( DCLK 一个时钟)
}
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//行扫描
void EPD_Send_Row_Data(u8 *pArray ) // 送数据,
{
EPD_LE_L; //LE 先低
asm("NOP");
asm("NOP");
asm("NOP");
asm("NOP");
EPD_OE_H; //OE 先高
asm("NOP");
asm("NOP");
asm("NOP");
asm("NOP");
EPD_STL_L; //STL 先低,
old_data = (uint16_t)EPD_DB_PORT->ODR;
old_data &= 0xFF00;
for(column= 0; column < 200; column++) // 写一行数据,
{
new_data = old_data | (u16)pArray[column];
#if 1 //PC7口坏了,用PC12代替
new_data &= 0xefff;
if(((pArray [column]>>7)&0x1)==1)
new_data |= 0x1000;
#endif
EPD_DB_PORT->ODR = new_data;
EPD_CL_L;
EPD_CL_H;
}
loop = 2; //CL又2 个时钟,
while(loop--)
{
EPD_CL_L;
EPD_CL_H;
}
EPD_LE_H; //LE 变高
loop = 3; //cl循环3个时钟送数据。
while(loop--)
{
EPD_CL_L;
EPD_CL_H;
}
EPD_LE_L; //LE 变低
EPD_STL_H; //STL 高,
}
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
void line_data_changepic(u8 *old_pic, u8 *new_pic, u8 frame)
{
int i, j;
unsigned char tmp =0;
for(i=0, j=0; i<100; i++, j+=2)
{
tmp = (old_pic[i] & 0xf0);
tmp += ((new_pic[i] & 0xf0) >> 4);
g_dest_data[j] = wave_table[tmp][frame];
tmp = ((old_pic[i] & 0x0f) << 4 );
tmp += ((new_pic[i] & 0x0f));
g_dest_data[j+1] = wave_table[tmp][frame];
}
}
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
void EPD_Display_ChagnePIC(const unsigned char *pold, const unsigned char *pnew)
{
int line, frame;
bool led_flag = TRUE;
AAT1156_ON();
ptr_old_pic = (unsigned char *)pold;
ptr_new_pic = (unsigned char *)pnew;
for(frame=0; frame<FRAME_LEN; frame++)//FRAME_LEN
{
if(led_flag)
{
GPIO_ResetBits(LED1_IN_PORT ,SD1_PIN);
led_flag = FALSE;
}
else
{
GPIO_SetBits(LED1_IN_PORT ,SD1_PIN);
led_flag = TRUE;
}
EPD_Start_Scan();
for(line=0; line<600; line++)
{
line_data_changepic(ptr_old_pic + line*100, ptr_new_pic + line*100, frame);
EPD_Send_Row_Data( g_dest_data );
EPD_End_Scan();
}
}
GPIO_SetBits(LED1_IN_PORT ,SD1_PIN);
AAT1156_OFF();
}
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
void line_data_init(u8 frame)
{
int i, j;
unsigned char tmp =0;
for(i=0; i<200; i++)
{
g_dest_data[i] = init_wave[frame];
}
}
//黑白黑白刷3次。最终到达白背景
void EPD_Display_INIT()
{
int line, frame;
bool led_flag = TRUE;
AAT1156_ON();
for(frame=0; frame<FRAME_INIT_LEN; frame++)//FRAME_LEN
{
if(led_flag)
{
GPIO_ResetBits(LED1_IN_PORT ,SD1_PIN);
led_flag = FALSE;
}
else
{
GPIO_SetBits(LED1_IN_PORT ,SD1_PIN);
led_flag = TRUE;
}
EPD_Start_Scan();
for(line=0; line<600; line++)
{
line_data_init(frame);
line_data_init(frame); //加该指令是保持时间与ChangePIC时一致
line_data_init(frame); //加该指令是保持时间与ChangePIC时一致
EPD_Send_Row_Data( g_dest_data );
EPD_End_Scan();
}
}
GPIO_SetBits(LED1_IN_PORT ,SD1_PIN);
AAT1156_OFF();
}
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
void line_init_pic(u8 *new_pic, u8 frame)
{
int i, j;
unsigned char tmp =0;
for(i=0, j=0; i<100; i++, j+=2)
{
tmp = (new_pic[i] & 0x00);
tmp += ((new_pic[i] & 0xf0) >> 4);
g_dest_data[j] = wave_table[tmp][frame];
tmp = ((new_pic[i] & 0x00) << 4 );
tmp += ((new_pic[i] & 0x0f));
g_dest_data[j+1] = wave_table[tmp][frame];
}
}
//从白背景转到图片
void EPD_Display_PIC(const unsigned char *pnew)
{
int line, frame;
bool led_flag = TRUE;
AAT1156_ON();
ptr_new_pic = (unsigned char *)pnew;
for(frame=0; frame<FRAME_LEN; frame++)//FRAME_LEN
{
if(led_flag)
{
GPIO_ResetBits(LED1_IN_PORT ,SD1_PIN);
led_flag = FALSE;
}
else
{
GPIO_SetBits(LED1_IN_PORT ,SD1_PIN);
led_flag = TRUE;
}
EPD_Start_Scan();
for(line=0; line<600; line++)
{
line_data_init(frame); //加该指令是保持时间与ChangePIC时一致
line_init_pic(ptr_new_pic + line*100, frame);
EPD_Send_Row_Data( g_dest_data );
EPD_End_Scan();
}
}
GPIO_SetBits(LED1_IN_PORT ,SD1_PIN);
AAT1156_OFF();
}
by: 发表于:2017-08-08 11:15:16 顶(0) | 踩(0) 回复
??
回复评论