|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926 |
- #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<datalen;)
- {
- temHz = *(szData+i);
- i +=1;
- Get_8x16_Font(temHz,buf);
- Display_Icon(ucRow,ucCol,buf,8);
- ucCol += 1;
- }
-
- }
-
-
- #endif
-
|