#include "LCD.h" u8 ucDispDT; static const u8 font816[38][16]= { {0xF8,0xFC,0x04,0xC4,0x24,0xFC,0xF8,0x00,0x07,0x0F,0x09,0x08,0x08,0x0F,0x07,0x00}, // -0- {0x00,0x10,0x18,0xFC,0xFC,0x00,0x00,0x00,0x00,0x08,0x08,0x0F,0x0F,0x08,0x08,0x00}, // -1- {0x08,0x0C,0x84,0xC4,0x64,0x3C,0x18,0x00,0x0E,0x0F,0x09,0x08,0x08,0x0C,0x0C,0x00}, // -2- {0x08,0x0C,0x44,0x44,0x44,0xFC,0xB8,0x00,0x04,0x0C,0x08,0x08,0x08,0x0F,0x07,0x00}, // -3- {0xC0,0xE0,0xB0,0x98,0xFC,0xFC,0x80,0x00,0x00,0x00,0x00,0x08,0x0F,0x0F,0x08,0x00}, // -4- {0x7C,0x7C,0x44,0x44,0xC4,0xC4,0x84,0x00,0x04,0x0C,0x08,0x08,0x08,0x0F,0x07,0x00}, // -5- {0xF0,0xF8,0x4C,0x44,0x44,0xC0,0x80,0x00,0x07,0x0F,0x08,0x08,0x08,0x0F,0x07,0x00}, // -6- {0x0C,0x0C,0x04,0x84,0xC4,0x7C,0x3C,0x00,0x00,0x00,0x0F,0x0F,0x00,0x00,0x00,0x00}, // -7- {0xB8,0xFC,0x44,0x44,0x44,0xFC,0xB8,0x00,0x07,0x0F,0x08,0x08,0x08,0x0F,0x07,0x00}, // -8- {0x38,0x7C,0x44,0x44,0x44,0xFC,0xF8,0x00,0x00,0x08,0x08,0x08,0x0C,0x07,0x03,0x00}, // -9- {0xE0,0xF0,0x98,0x8C,0x98,0xF0,0xE0,0x00,0x0F,0x0F,0x00,0x00,0x00,0x0F,0x0F,0x00}, // -A- 10 {0x04,0xFC,0xFC,0x44,0x44,0xFC,0xB8,0x00,0x08,0x0F,0x0F,0x08,0x08,0x0F,0x07,0x00}, // -B- 11 {0xF0,0xF8,0x0C,0x04,0x04,0x0C,0x18,0x00,0x03,0x07,0x0C,0x08,0x08,0x0C,0x06,0x00}, // -C- 12 {0x04,0xFC,0xFC,0x04,0x0C,0xF8,0xF0,0x00,0x08,0x0F,0x0F,0x08,0x0C,0x07,0x03,0x00}, // -D- 13 {0x04,0xFC,0xFC,0x44,0xE4,0x0C,0x1C,0x00,0x08,0x0F,0x0F,0x08,0x08,0x0C,0x0E,0x00}, // -E- 14 {0x04,0xFC,0xFC,0x44,0xE4,0x0C,0x1C,0x00,0x08,0x0F,0x0F,0x08,0x00,0x00,0x00,0x00}, // -F- 15 {0xF0,0xF8,0x0C,0x84,0x84,0x8C,0x98,0x00,0x03,0x07,0x0C,0x08,0x08,0x07,0x0F,0x00}, // -G- 16 {0xFC,0xFC,0x40,0x40,0x40,0xFC,0xFC,0x00,0x0F,0x0F,0x00,0x00,0x00,0x0F,0x0F,0x00}, // -H- 17 {0x00,0x00,0x04,0xFC,0xFC,0x04,0x00,0x00,0x00,0x00,0x08,0x0F,0x0F,0x08,0x00,0x00}, // -I- 18 {0x00,0x00,0x00,0x04,0xFC,0xFC,0x04,0x00,0x07,0x0F,0x08,0x08,0x0F,0x07,0x00,0x00}, // -J- 19 {0x04,0xFC,0xFC,0xC0,0xF0,0x3C,0x0C,0x00,0x08,0x0F,0x0F,0x00,0x01,0x0F,0x0E,0x00}, // -K- 20 {0x04,0xFC,0xFC,0x04,0x00,0x00,0x00,0x00,0x08,0x0F,0x0F,0x08,0x08,0x0C,0x0E,0x00}, // -L- 21 {0xFC,0xFC,0x38,0x70,0x38,0xFC,0xFC,0x00,0x0F,0x0F,0x00,0x00,0x00,0x0F,0x0F,0x00}, // -M- 22 {0xFC,0xFC,0x38,0x70,0xE0,0xFC,0xFC,0x00,0x0F,0x0F,0x00,0x00,0x00,0x0F,0x0F,0x00}, // -N- 23 {0xF0,0xF8,0x0C,0x04,0x0C,0xF8,0xF0,0x00,0x03,0x07,0x0C,0x08,0x0C,0x07,0x03,0x00}, // -O- 24 {0x04,0xFC,0xFC,0x44,0x44,0x7C,0x38,0x00,0x08,0x0F,0x0F,0x08,0x00,0x00,0x00,0x00}, // -P- 25 {0xF8,0xFC,0x04,0x04,0x04,0xFC,0xF8,0x00,0x07,0x0F,0x08,0x0E,0x3C,0x3F,0x27,0x00}, // -Q- 26 {0x04,0xFC,0xFC,0x44,0xC4,0xFC,0x38,0x00,0x08,0x0F,0x0F,0x00,0x00,0x0F,0x0F,0x00}, // -R- 27 {0x18,0x3C,0x64,0x44,0xC4,0x9C,0x18,0x00,0x06,0x0E,0x08,0x08,0x08,0x0F,0x07,0x00}, // -S- 28 {0x00,0x1C,0x0C,0xFC,0xFC,0x0C,0x1C,0x00,0x00,0x00,0x08,0x0F,0x0F,0x08,0x00,0x00}, // -T- 29 {0xFC,0xFC,0x00,0x00,0x00,0xFC,0xFC,0x00,0x07,0x0F,0x08,0x08,0x08,0x0F,0x07,0x00}, // -U- 30 {0xFC,0xFC,0x00,0x00,0x00,0xFC,0xFC,0x00,0x01,0x03,0x06,0x0C,0x06,0x03,0x01,0x00}, // -V- 31 {0xFC,0xFC,0x00,0x80,0x00,0xFC,0xFC,0x00,0x03,0x0F,0x0E,0x03,0x0E,0x0F,0x03,0x00}, // -W- 32 {0x0C,0x3C,0xF0,0xC0,0xF0,0x3C,0x0C,0x00,0x0C,0x0F,0x03,0x00,0x03,0x0F,0x0C,0x00}, // -X- 33 {0x00,0x3C,0x7C,0xC0,0xC0,0x7C,0x3C,0x00,0x00,0x00,0x08,0x0F,0x0F,0x08,0x00,0x00}, // -Y- 34 {0x1C,0x0C,0x84,0xC4,0x64,0x3C,0x1C,0x00,0x0E,0x0F,0x09,0x08,0x08,0x0C,0x0E,0x00}, // -Z- 35 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x0C,0x00,0x00,0x00}, // -.- 36 {0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x00,0x00,0x00}, // -:- 37 }; void Get_8x16_Font(u16 character ,u8* backbuf) { if( (character>='0')&&(character<='9')) { character -= '0'; } #if 1 else if( (character>='A')&&(character<='Z')) { character = character - 'A' + 10; } #endif else if(character == ':') { character = 37; } else if(character == '.') { character = 36; } //backbuf = (uint8 *)(Num612[character]); memcpy(backbuf, (u8 *)(font816[character]),sizeof(font816[character])); } #if 1 void HexToDec(u32 tempdata,u8* buf,unsigned char bufLen) { buf[0]=tempdata/1000000000; buf[1]=tempdata/100000000-(buf[0]*10); buf[2]=tempdata/10000000-(buf[0]*100)-(buf[1]*10); buf[3]=tempdata/1000000-buf[0]*1000-buf[1]*100-buf[2]*10; buf[4]=tempdata/100000-buf[0]*10000-buf[1]*1000-buf[2]*100-buf[3]*10; buf[5]=tempdata/10000-buf[0]*100000-buf[1]*10000-buf[2]*1000-buf[3]*100-buf[4]*10; buf[6]=tempdata/1000-buf[0]*1000000-buf[1]*100000-buf[2]*10000-buf[3]*1000-buf[4]*100-buf[5]*10; buf[7]=tempdata/100-buf[0]*10000000-buf[1]*1000000-buf[2]*100000-buf[3]*10000-buf[4]*1000-buf[5]*100-buf[6]*10; buf[8]=tempdata/10-buf[0]*100000000-buf[1]*10000000-buf[2]*1000000-buf[3]*100000-buf[4]*10000-buf[5]*1000-buf[6]*100-buf[7]*10; buf[9]=tempdata-buf[0]*1000000000-buf[1]*100000000-buf[2]*10000000-buf[3]*1000000-buf[4]*100000-buf[5]*10000-buf[6]*1000-buf[7]*100-buf[8]*10; } #endif void AttenuatorConfig(void) { GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8; //1A GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //50MHz GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8; //2A //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //50MHz GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; //3A //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //50MHz GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5; //4A //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //50MHz GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14; //5A //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //50MHz GPIO_Init(GPIOC, &GPIO_InitStructure); #if 1 //衰减效果最好 GPIO_SetBits(GPIOA,GPIO_Pin_8); GPIO_SetBits(GPIOC,GPIO_Pin_8); GPIO_SetBits(GPIOC,GPIO_Pin_4); GPIO_SetBits(GPIOC,GPIO_Pin_5); GPIO_SetBits(GPIOC,GPIO_Pin_14); #else GPIO_ResetBits(GPIOA,GPIO_Pin_8); GPIO_ResetBits(GPIOC,GPIO_Pin_8); GPIO_ResetBits(GPIOC,GPIO_Pin_4); GPIO_ResetBits(GPIOC,GPIO_Pin_5); GPIO_ResetBits(GPIOC,GPIO_Pin_14); #endif } void lcd_init(void) { GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; //LCD POWER GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //50MHz GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; //LCD CS //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //50MHz GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3; //LCD RES //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //50MHz GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; //LCD AO //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //50MHz GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11; //LCD SCK //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //50MHz GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12; //LCD SDA 不需要 //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //50MHz GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_SetBits(GPIOC,GPIO_Pin_0); vDispInit(0,24); vDispClear(); } void _vWriteIR_spi(u8 ucData); void _vWriteData_spi(void); void (* WriteIR)(u8); //20120502 hong 函数指针,指向 _vWriteIR 或者_vWriteIR_spi void (* WriteData)(void); //20120502 函数指针,指向_vWriteData或者_vWriteData_spi #if 0 __inline void IRQEnable(void) { int tmp; __asm { MRS tmp,CPSR ///读取CPSR的值 BIC tmp,tmp,#0x80 //将IRQ中断禁止位I清零,即允许IRQ中断 MSR CPSR_c,tmp //设置CPSR的值 } } __inline void IRQDisable(void) { int tmp; __asm { MRS tmp,CPSR ///读取CPSR的值 ORR tmp,tmp,#0x80 //将IRQ中断禁止位I清零,即允许IRQ中断 MSR CPSR_c,tmp //设置CPSR的值 } } #endif #if 0 void SetDISPDATA( u8 DISPDATA ) { IO2SET = IO2SET | DISPDATA; IO2CLR = (~IO2SET) | ((~DISPDATA) &0x000000ff); } #endif u32 vI2cHzkGetStart( u32 addr /*Int32 addr*/ ) { //ulong HfcAdd; u32 HfcAdd; HfcAdd = addr >> 8; HfcAdd *= 264; HfcAdd += (addr & 0xff); return ( HfcAdd ); } /************************************************************** 功能 液晶屏写命令函数 参数 ucData--命令内容 设计 谢红波 日期 20080710xiehb *************************************************************/ void _vWriteIR_spi(u8 ucData) { u8 i; // 关中断 ucData = ucData; //IRQDisable(); //SPI1_CE = 0; //P2WPin_HIGH(PIN_LCD_SDA); //LCD_SDA_OUTMODE_SET; GPIO_SetBits(GPIOC,GPIO_Pin_12); //WPin(P2, PIN_LCD_CS0, 0); //LCD_CS0_OUTMODE_CLEAR; GPIO_ResetBits(GPIOC,GPIO_Pin_2); //P2WPin_LOW(PIN_LCD_DC); //LCD_DC_OUTMODE_CLEAR; GPIO_ResetBits(GPIOC,GPIO_Pin_10); for ( i = 0; i < 8; i++ ) { //P2WPin_LOW(PIN_LCD_SCL); //LCD_SCL_OUTMODE_CLEAR; GPIO_ResetBits(GPIOC,GPIO_Pin_11); if ( (ucData & 0x80) == 0 ) { //P2WPin_LOW(PIN_LCD_SDA); //LCD_SDA_OUTMODE_CLEAR; GPIO_ResetBits(GPIOC,GPIO_Pin_12); } else { //P2WPin_HIGH(PIN_LCD_SDA); //LCD_SDA_OUTMODE_SET; GPIO_SetBits(GPIOC,GPIO_Pin_12); } ucData = ucData << 1; //P2WPin_HIGH(PIN_LCD_SCL); //LCD_SCL_OUTMODE_SET; GPIO_SetBits(GPIOC,GPIO_Pin_11); } //WPin(P2, PIN_LCD_CS0, 1); //LCD_CS0_OUTMODE_SET; GPIO_SetBits(GPIOC,GPIO_Pin_2); //P2WPin_HIGH(PIN_LCD_SDA); //LCD_SDA_OUTMODE_SET; GPIO_SetBits(GPIOC,GPIO_Pin_12); // 开中断 //IRQEnable(); //SPI1_CE = 1; } /************************************************************** 功能 液晶屏写数据函数 参数 ucDispDT--数据内容 设计 谢红波 日期 20080710xiehb *************************************************************/ void _vWriteData_spi() { u8 i; // 关中断 //IRQDisable(); //SPI1_CE = 0; //P2WPin_HIGH(PIN_LCD_SDA); //LCD_SDA_OUTMODE_SET; GPIO_SetBits(GPIOC,GPIO_Pin_12); //WPin(P2, PIN_LCD_CS0, 0); //LCD_CS0_OUTMODE_CLEAR; GPIO_ResetBits(GPIOC,GPIO_Pin_2); //P2WPin_HIGH(PIN_LCD_DC); //LCD_DC_OUTMODE_SET; GPIO_SetBits(GPIOC,GPIO_Pin_10); for ( i = 0; i < 8; i++ ) { //P2WPin_LOW(PIN_LCD_SCL); //LCD_SCL_OUTMODE_CLEAR; GPIO_ResetBits(GPIOC,GPIO_Pin_11); if ( (ucDispDT & 0x80) == 0 ) { //P2WPin_LOW(PIN_LCD_SDA); //LCD_SDA_OUTMODE_CLEAR; GPIO_ResetBits(GPIOC,GPIO_Pin_12); } else { //P2WPin_HIGH(PIN_LCD_SDA); //LCD_SDA_OUTMODE_SET; GPIO_SetBits(GPIOC,GPIO_Pin_12); } ucDispDT = ucDispDT << 1; //P2WPin_HIGH(PIN_LCD_SCL); //LCD_SCL_OUTMODE_SET; GPIO_SetBits(GPIOC,GPIO_Pin_11); } //WPin(P2, PIN_LCD_CS0, 1); //LCD_CS0_OUTMODE_SET; GPIO_SetBits(GPIOC,GPIO_Pin_2); //P2WPin_HIGH(PIN_LCD_SDA); //LCD_SDA_OUTMODE_SET; GPIO_SetBits(GPIOC,GPIO_Pin_12); // 开中断 //IRQEnable(); //SPI1_CE = 1; } ///////////////////////////////////////////////////////////////////////////////////// //****************************************************************** // 名称: void _vDispAddr(uchar ucPage,uchar ucCol) // 功能: 设置显示地址 // 输入: ucPage-页地址;ucCol-列地址 // 返回值: //****************************************************************** void _vDispAddr(u8 ucPage,u8 ucCol) { #if 0 if ( GetMainBoardType () == MAINBOARD_TYPE_GENERAL ) { ucCol += 1; } #endif (*WriteIR)(0xb0+ucPage); // 设置页地址 (*WriteIR)(0x10+(ucCol >> 4));//modify by ljc20071017 // 设置显示开始行高4位 (*WriteIR)( ucCol & 0x0f);//modify by ljc20071017 // 设置显示开始行低4位 } //****************************************************************** // 名称: void vDispOn() // 功能: 打开显示 // 输入: // 返回值: //****************************************************************** void vDispOn(void) { //have adjust (*WriteIR)(0xaf); // 设置打开显示 } //****************************************************************** // 名称: void vDispClear() // 功能: 清除整个显示屏 // 输入: // 返回值: //****************************************************************** void vDispClear(void) { u8 i,j; //have adjust for ( i = 0; i < 8; i++ ) { ucDispDT = 0; _vDispAddr(i, 0); for ( j = 0; j < 133; j++ ) { // 128 (*WriteData)(); } } (*WriteIR)(0xaf); // 打开显示 (*WriteIR)(0x2f); // Power //20070913heq //20071108heq } //****************************************************************** // 名称: void vDispFull() // 功能: 整个显示屏 // 输入: // 返回值: //****************************************************************** void vDispFull ( void ) { u8 i,j; //have adjust for ( i = 0; i < 8; i++ ) { _vDispAddr(i, 0); for ( j = 0; j < 133; j++ ) { ucDispDT = 0xFF; (*WriteData)(); } } (*WriteIR)(0xaf); // 打开显示 (*WriteIR)(0x2f); // Power //20070913heq //20071108heq } //#ifdef SPI_LCD_ENABLE //20110704 liugz /******************************************** SPI屏 初始化 20080710xiehb *********************************************/ void vDispInit_spi(u8 mode,u8 contrast) { if ( mode ) { //LCD_SDA_OUTMODE_SET; GPIO_SetBits(GPIOC,GPIO_Pin_12); delay_5us(1); //LCD_RST_OUTMODE_SET; GPIO_SetBits(GPIOC,GPIO_Pin_3); //LCD_CS0_OUTMODE_CLEAR; GPIO_ResetBits(GPIOC,GPIO_Pin_2); //vDelayMS(5); delay_ms(5); //LCD_RST_OUTMODE_CLEAR; GPIO_ResetBits(GPIOC,GPIO_Pin_3); //vDelayMS(30); delay_ms(30); //LCD_RST_OUTMODE_SET; GPIO_SetBits(GPIOC,GPIO_Pin_3); //vDelayMS(19); delay_ms(19); } //LCD_CS0_OUTMODE_CLEAR; GPIO_ResetBits(GPIOC,GPIO_Pin_2); //LCD_SDA_OUTMODE_SET; GPIO_SetBits(GPIOC,GPIO_Pin_12); //LCD_RST_OUTMODE_SET; GPIO_SetBits(GPIOC,GPIO_Pin_3); (*WriteIR)(0xe2); delay_ms(10); (*WriteIR)(0xa2); /* 1/9bias */ (*WriteIR)(0xa0); /* ADC select , Normal */ (*WriteIR)(0xc8); /* Common output reverse */ (*WriteIR)(0xa6); /* normal display 1=on */ #if 0 if ( GetMainBoardType () != MAINBOARD_TYPE_GENERAL ) { (*WriteIR)(0x2C); DeyNop(10); (*WriteIR)(0x2E); DeyNop(10); } #endif (*WriteIR)(0x2F); /* V/C off, V/R off, V/F on */ //DeyNop(10); delay_5us(2); (*WriteIR)(0xf8); /* Common output reverse */ (*WriteIR)(0x01); /* normal display 1=on */ //(*WriteIR)(0x2F); /* V/C off, V/R off, V/F on */ (*WriteIR)(0x24); /* internal resistor ratio */ #if 0 if ( contrast > MAX_CONTRAST ) { contrast = 0x24; } if ( contrast < MIN_CONTRAST ) { contrast = 0x24; } #else contrast = 0x27; //24 #endif (*WriteIR)(0x81); /* electronic volume mode set */ (*WriteIR)(contrast); /*0x31*/ (*WriteIR)(0xaf); /* display on */ (*WriteIR)(0x40); /* Start line Set 40-7fh 默认40 */ //20110720 liugz //60 } ///20120925 hong 智能识别屏 void vDispInit( u8 mode,u8 contrast ) { WriteIR = _vWriteIR_spi; WriteData = _vWriteData_spi; vDispInit_spi(mode,contrast); } #if 1 /***************************************************************** 函数:E_MAINBOARD_TYPE GetMainBoardType ( void ) 功能:主板类型 参数: 注意: 设计:吴伟聪 时间:2014.06.28 返回: ******************************************************************/ void SetLcdRow ( u8 * ucRow ) { //if ( GetMainBoardType () != MAINBOARD_TYPE_GENERAL ) { if ( *ucRow < 3 ) { *ucRow += 2; } else { *ucRow -= 2; } } } #endif //****************************************************************** // 名称: void vDispClearLine(uchar ucRow) // 功能: 清除LCD屏的一行 // 输入: ucRow-行号 // 返回值: //****************************************************************** void vDispClearLine(u8 ucRow) { u8 i,j; SetLcdRow(&ucRow); if ( --ucRow >= 4 ) { return ; } ucRow += ucRow; for ( i = 0; i < 2; i++ ) { _vDispAddr(ucRow, 0); ucDispDT = 0; for ( j = 0; j < 128; j++ ) { (*WriteData)(); } _vDispAddr(ucRow + 1, 0); ucDispDT = 0; for (j = 0; j < 128; j++) { (*WriteData)(); } } } void Display_Icon16(u8 ucRow, u8 ucCol, unsigned char *icon) { u8 pZiMo; SetLcdRow(&ucRow); if ( --ucRow >= 4 ) { return ; } if ( --ucCol > 16 ) { return ; } ucRow += ucRow; ucCol <<= 3; _vDispAddr(ucRow, ucCol); ucDispDT = 0x00; for ( pZiMo = 0; pZiMo < 8; pZiMo++ ) { if ( icon != 0 ) { ucDispDT = icon[pZiMo]; } (*WriteData)(); } _vDispAddr(ucRow+1, ucCol); for ( ; pZiMo < 16; pZiMo++ ) { if ( icon != 0 ) { ucDispDT = icon[pZiMo]; } (*WriteData)(); } (*WriteIR)(0xaf); // 打开显示//20070913heq (*WriteIR)(0x2f); // Power //20070913heq } void Display_Icon(u8 ucRow, u8 ucCol, unsigned char *icon,u8 size) { u8 pZiMo; SetLcdRow(&ucRow); if ( --ucRow >= 4 ) { return ; } if ( --ucCol >= 16 ) { return ; } ucRow += ucRow; ucCol <<= 3; _vDispAddr(ucRow, ucCol); ucDispDT = 0x00; //for ( pZiMo = 0; pZiMo < 16; pZiMo++ ) for ( pZiMo = 0; pZiMo < size; pZiMo++ ) { if ( icon != 0 ) { ucDispDT = icon[pZiMo]; } (*WriteData)(); } _vDispAddr(ucRow + 1, ucCol); //for ( ; pZiMo < 32; pZiMo++ ) for ( ; pZiMo < (2*size); pZiMo++ ) { if ( icon != 0 ) { ucDispDT = icon[pZiMo]; } (*WriteData)(); } (*WriteIR)(0xaf); // 打开显示//20070913heq (*WriteIR)(0x2f); // Power //20070913heq } #if 0 ///AntiColor = 1 反式显示 ///AntiColor = 0 正常显示 void vDispStr_light(u8 ucRow, u8 ucCol, char *szData, u8 AntiColor) { u8 ZiMo[32], pZiMo; u8 ucDispT1, ucDispT2, ucDispT4; u32 uiDispT; u32 uiDispT1; //SetMayWatchDog(); IWDG_Feed(); //SetLcdRow(&ucRow); if ( --ucRow >= 4 ) { return ; } if ( --ucCol >= 16 ) { return ; } ucRow += ucRow; ucCol <<= 3; // *8 while ( (*szData != 0) && (ucCol < 128) ) { ucDispT1 = *szData; szData++; if ( ucDispT1 == 0xff ) { return ; } //没有0XFF开始的汉字 if ( ucDispT1 < 0x80 ) { //ASC uiDispT = ucDispT1 << 4; //uiDispT <<= 4; pZiMo = 0; vI2cRead(vI2cHzkGetStart( uiDispT + 222080l),16,(char *)ZiMo); _vDispAddr(ucRow, ucCol); if ( AntiColor ) { for ( ucDispT4 = 0; ucDispT4 < 8; ucDispT4++ ) { ucDispDT = ZiMo[pZiMo++] ^ 0xFF; (*WriteData)(); } _vDispAddr(ucRow + 1, ucCol); for ( ucDispT4 = 8; ucDispT4 < 16; ucDispT4++ ) { ucDispDT = ZiMo[pZiMo++] ^ 0xFF; (*WriteData)(); } } else { for ( ucDispT4 = 0; ucDispT4 < 8; ucDispT4++ ) { ucDispDT = ZiMo[pZiMo++]; (*WriteData)(); } _vDispAddr(ucRow + 1, ucCol); for ( ucDispT4 = 8; ucDispT4 < 16; ucDispT4++ ) { ucDispDT = ZiMo[pZiMo++]; (*WriteData)(); } } ucCol += 8; } else { ucDispT2 = *szData; szData++; if ( ucCol > 112 ) { break; } if ( ucDispT1 >= 0xB0 ) { //B0A1~F7FF ucDispT1 -= 0xAE; } else if ( ucDispT1 == 0xA1 ) { //A1A1~A1FF ucDispT1 = 0; } else if ( ucDispT1 == 0xA3 ) { //A3A1~A3FF ucDispT1 = 1; } else { continue; } ucDispT2 -= 0xA1; ucDispT1 <<= 1; //*2; 47 uiDispT = ucDispT1 << 4; uiDispT1 = uiDispT; uiDispT <<= 1; uiDispT += uiDispT1; uiDispT -= ucDispT1; uiDispT += ucDispT2; pZiMo = 0; vI2cRead(vI2cHzkGetStart(uiDispT<<5),32,(char *)ZiMo); _vDispAddr(ucRow, ucCol); if ( AntiColor ) { for ( ucDispT4 = 0; ucDispT4 < 8; ucDispT4++ ) { ucDispDT = ZiMo[pZiMo++] ^ 0xFF; (*WriteData)(); } } else { for ( ucDispT4 = 0; ucDispT4 < 8; ucDispT4++ ) { ucDispDT = ZiMo[pZiMo++]; (*WriteData)(); } } if ( ucCol < 56 ) { if ( AntiColor ) { for ( ucDispT4 = 8; ucDispT4 < 16; ucDispT4++ ) { ucDispDT = ZiMo[pZiMo++] ^ 0xFF; (*WriteData)(); } } else { for ( ucDispT4 = 8; ucDispT4 < 16; ucDispT4++ ) { ucDispDT = ZiMo[pZiMo++]; (*WriteData)(); } } } else { if ( ucCol == 56 ) { _vDispAddr(ucRow, 64); } if ( AntiColor ) { for ( ucDispT4 = 8; ucDispT4 < 16; ucDispT4++ ) { ucDispDT = ZiMo[pZiMo++] ^ 0xFF; (*WriteData)(); } } else { for ( ucDispT4 = 8; ucDispT4 < 16; ucDispT4++ ) { ucDispDT = ZiMo[pZiMo++]; (*WriteData)(); } } } _vDispAddr(ucRow + 1, ucCol); if ( AntiColor ) { for ( ucDispT4 = 16; ucDispT4 < 24; ucDispT4++ ) { ucDispDT = ZiMo[pZiMo++] ^ 0xFF; (*WriteData)(); } } else { for ( ucDispT4 = 16; ucDispT4 < 24; ucDispT4++ ) { ucDispDT = ZiMo[pZiMo++]; (*WriteData)(); } } if ( ucCol < 56 ) { if ( AntiColor ) { for ( ucDispT4 = 24; ucDispT4 < 32; ucDispT4++ ) { ucDispDT = ZiMo[pZiMo++] ^ 0xFF; (*WriteData)(); } } else { for ( ucDispT4 = 24; ucDispT4 < 32; ucDispT4++ ) { ucDispDT = ZiMo[pZiMo++]; (*WriteData)(); } } } else { if ( ucCol == 56 ) { _vDispAddr(ucRow + 1, 64); } if ( AntiColor ) { for ( ucDispT4 = 24; ucDispT4 < 32; ucDispT4++ ) { //vI2cGetHzk(); ucDispDT = ZiMo[pZiMo++] ^ 0xFF; (*WriteData)(); } } else { for ( ucDispT4 = 24; ucDispT4 < 32; ucDispT4++ ) { //vI2cGetHzk(); ucDispDT = ZiMo[pZiMo++]; (*WriteData)(); } } } ucCol += 16; } } (*WriteIR)(0xaf); // 打开显示//20070913heq //20071108heq (*WriteIR)(0x2f); // Power //20070913heq //20071108heq } void vDispStr(u8 ucRow, u8 ucCol, char *szData) { vDispStr_light(ucRow,ucCol,szData,0); } #else void vDispStr(u8 ucRow, u8 ucCol, char *szData,unsigned char datalen) { u16 i; u16 temHz; u8 buf[16]; if(datalen<=0) { return ; } for(i=0;i