123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988 |
- #include "lcd.h"
- #include "dwt.h"
- #include "font.h"
- #include "stdlib.h"
- //////////////////////////////////////////////////////////////////////////////////
- //本程序只供学习使用,未经作者许可,不得用于其它任何用途
- // ALIENTEK战舰STM32开发板
- // 2.4寸/2.8寸/3.5寸/4.3寸 TFT液晶驱动
- //支持驱动IC型号包括:ILI9341/ILI9325/RM68042/RM68021/ILI9320/ILI9328/LGDP4531/LGDP4535/
- // SPFD5408/SSD1289/1505/B505/C505/NT35310/NT35510等
- //正点原子@ALIENTEK
- //技术论坛:www.openedv.com
- //修改日期:2014/2/11
- //版本:V2.5
- //版权所有,盗版必究。
- // Copyright(C) 广州市星翼电子科技有限公司 2009-2019
- // All rights reserved
- //********************************************************************************
- // V1.2修改说明
- //支持了SPFD5408的驱动,另外把液晶ID直接打印成HEX格式.方便查看LCD驱动IC.
- // V1.3
- //加入了快速IO的支持
- //修改了背光控制的极性(适用于V1.8及以后的开发板版本)
- //对于1.8版本之前(不包括1.8)的液晶模块,请修改LCD_Init函数的LCD_LED=1;为LCD_LED=1;
- // V1.4
- //修改了LCD_ShowChar函数,使用画点功能画字符。
- //加入了横竖屏显示的支持
- // V1.5 20110730
- // 1,修改了B505液晶读颜色有误的bug.
- // 2,修改了快速IO及横竖屏的设置方式.
- // V1.6 20111116
- // 1,加入对LGDP4535液晶的驱动支持
- // V1.7 20120713
- // 1,增加LCD_RD_DATA函数
- // 2,增加对ILI9341的支持
- // 3,增加ILI9325的独立驱动代码
- // 4,增加LCD_Scan_Dir函数(慎重使用)
- // 6,另外修改了部分原来的函数,以适应9341的操作
- // V1.8 20120905
- // 1,加入LCD重要参数设置结构体lcddev
- // 2,加入LCD_Display_Dir函数,支持在线横竖屏切换
- // V1.9 20120911
- // 1,新增RM68042驱动(ID:6804),但是6804不支持横屏显示!!原因:改变扫描方式,
- //导致6804坐标设置失效,试过很多方法都不行,暂时无解。
- // V2.0 20120924
- //在不硬件复位的情况下,ILI9341的ID读取会被误读成9300,修改LCD_Init,将无法识别
- //的情况(读到ID为9300/非法ID),强制指定驱动IC为ILI9341,执行9341的初始化。
- // V2.1 20120930
- //修正ILI9325读颜色的bug。
- // V2.2 20121007
- //修正LCD_Scan_Dir的bug。
- // V2.3 20130120
- //新增6804支持横屏显示
- // V2.4 20131120
- // 1,新增NT35310(ID:5310)驱动器的支持
- // 2,新增LCD_Set_Window函数,用于设置窗口,对快速填充,比较有用,但是该函数在横屏时,不支持6804.
- // V2.5 20140211
- // 1,新增NT35510(ID:5510)驱动器的支持
- //////////////////////////////////////////////////////////////////////////////////
- // LCD的画笔颜色和背景色
- u16 POINT_COLOR = 0x0000; //画笔颜色
- u16 BACK_COLOR = 0xFFFF; //背景色
- //管理LCD重要参数
- //默认为竖屏
- _lcd_dev lcddev;
- //写寄存器函数
- // regval:寄存器值
- void LCD_WR_REG(volatile u16 regval)
- {
- regval = regval; //使用-O2优化的时候,必须插入的延时
- LCD->LCD_REG = regval; //写入要写的寄存器序号
- }
- //写LCD数据
- // data:要写入的值
- void LCD_WR_DATA(volatile u16 data)
- {
- data = data; //使用-O2优化的时候,必须插入的延时
- LCD->LCD_RAM = data;
- }
- //读LCD数据
- //返回值:读到的值
- u16 LCD_RD_DATA(void)
- {
- volatile u16 ram; //防止被优化
- ram = LCD->LCD_RAM;
- return ram;
- }
- //写寄存器
- // LCD_Reg:寄存器地址
- // LCD_RegValue:要写入的数据
- void LCD_WriteReg(u16 LCD_Reg, u16 LCD_RegValue)
- {
- LCD->LCD_REG = LCD_Reg; //写入要写的寄存器序号
- LCD->LCD_RAM = LCD_RegValue; //写入数据
- }
- //读寄存器
- // LCD_Reg:寄存器地址
- //返回值:读到的数据
- u16 LCD_ReadReg(u16 LCD_Reg)
- {
- LCD_WR_REG(LCD_Reg); //写入要读的寄存器序号
- us_delay(5);
- return LCD_RD_DATA(); //返回读到的值
- }
- //开始写GRAM
- void LCD_WriteRAM_Prepare(void)
- {
- LCD->LCD_REG = lcddev.wramcmd;
- }
- // LCD写GRAM
- // RGB_Code:颜色值
- void LCD_WriteRAM(u16 RGB_Code)
- {
- LCD->LCD_RAM = RGB_Code; //写十六位GRAM
- }
- //从ILI93xx读出的数据为GBR格式,而我们写入的时候为RGB格式。
- //通过该函数转换
- // c:GBR格式的颜色值
- //返回值:RGB格式的颜色值
- u16 LCD_BGR2RGB(u16 c)
- {
- u16 r, g, b, rgb;
- b = (c >> 0) & 0x1f;
- g = (c >> 5) & 0x3f;
- r = (c >> 11) & 0x1f;
- rgb = (b << 11) + (g << 5) + (r << 0);
- return (rgb);
- }
- //当mdk -O1时间优化时需要设置
- //延时i
- void opt_delay(u8 i)
- {
- while (i--)
- ;
- }
- //读取个某点的颜色值
- // x,y:坐标
- //返回值:此点的颜色
- u16 LCD_ReadPoint(u16 x, u16 y)
- {
- u16 r = 0, g = 0, b = 0;
- if (x >= lcddev.width || y >= lcddev.height)
- return 0; //超过了范围,直接返回
- LCD_SetCursor(x, y);
- if (lcddev.id == 0X9341 || lcddev.id == 0X6804 || lcddev.id == 0X5310)
- LCD_WR_REG(0X2E); // 9341/6804/3510 发送读GRAM指令
- else if (lcddev.id == 0X5510)
- LCD_WR_REG(0X2E00); // 5510 发送读GRAM指令
- else
- LCD_WR_REG(R34); //其他IC发送读GRAM指令
- if (lcddev.id == 0X9320)
- opt_delay(2); // FOR 9320,延时2us
- if (LCD->LCD_RAM)
- r = 0; // dummy Read
- opt_delay(2);
- r = LCD->LCD_RAM; //实际坐标颜色
- if (lcddev.id == 0X9341 || lcddev.id == 0X5310 || lcddev.id == 0X5510) // 9341/NT35310/NT35510要分2次读出
- {
- opt_delay(2);
- b = LCD->LCD_RAM;
- g = r & 0XFF; //对于9341/5310/5510,第一次读取的是RG的值,R在前,G在后,各占8位
- g <<= 8;
- }
- else if (lcddev.id == 0X6804)
- r = LCD->LCD_RAM; // 6804第二次读取的才是真实值
- if (lcddev.id == 0X9325 || lcddev.id == 0X4535 || lcddev.id == 0X4531 || lcddev.id == 0X8989 || lcddev.id == 0XB505)
- return r; //这几种IC直接返回颜色值
- else if (lcddev.id == 0X9341 || lcddev.id == 0X5310 || lcddev.id == 0X5510)
- return (((r >> 11) << 11) | ((g >> 10) << 5) | (b >> 11)); // ILI9341/NT35310/NT35510需要公式转换一下
- else
- return LCD_BGR2RGB(r); //其他IC
- }
- // LCD开启显示
- void LCD_DisplayOn(void)
- {
- if (lcddev.id == 0X9341 || lcddev.id == 0X6804 || lcddev.id == 0X5310)
- LCD_WR_REG(0X29); //开启显示
- else if (lcddev.id == 0X5510)
- LCD_WR_REG(0X2900); //开启显示
- else
- LCD_WriteReg(R7, 0x0173); //开启显示
- }
- // LCD关闭显示
- void LCD_DisplayOff(void)
- {
- if (lcddev.id == 0X9341 || lcddev.id == 0X6804 || lcddev.id == 0X5310)
- LCD_WR_REG(0X28); //关闭显示
- else if (lcddev.id == 0X5510)
- LCD_WR_REG(0X2800); //关闭显示
- else
- LCD_WriteReg(R7, 0x0); //关闭显示
- }
- //设置光标位置
- // Xpos:横坐标
- // Ypos:纵坐标
- void LCD_SetCursor(u16 Xpos, u16 Ypos)
- {
- if (lcddev.id == 0X9341 || lcddev.id == 0X5310)
- {
- LCD_WR_REG(lcddev.setxcmd);
- LCD_WR_DATA(Xpos >> 8);
- LCD_WR_DATA(Xpos & 0XFF);
- LCD_WR_REG(lcddev.setycmd);
- LCD_WR_DATA(Ypos >> 8);
- LCD_WR_DATA(Ypos & 0XFF);
- }
- else if (lcddev.id == 0X6804)
- {
- if (lcddev.dir == 1)
- Xpos = lcddev.width - 1 - Xpos; //横屏时处理
- LCD_WR_REG(lcddev.setxcmd);
- LCD_WR_DATA(Xpos >> 8);
- LCD_WR_DATA(Xpos & 0XFF);
- LCD_WR_REG(lcddev.setycmd);
- LCD_WR_DATA(Ypos >> 8);
- LCD_WR_DATA(Ypos & 0XFF);
- }
- else if (lcddev.id == 0X5510)
- {
- LCD_WR_REG(lcddev.setxcmd);
- LCD_WR_DATA(Xpos >> 8);
- LCD_WR_REG(lcddev.setxcmd + 1);
- LCD_WR_DATA(Xpos & 0XFF);
- LCD_WR_REG(lcddev.setycmd);
- LCD_WR_DATA(Ypos >> 8);
- LCD_WR_REG(lcddev.setycmd + 1);
- LCD_WR_DATA(Ypos & 0XFF);
- }
- else
- {
- if (lcddev.dir == 1)
- Xpos = lcddev.width - 1 - Xpos; //横屏其实就是调转x,y坐标
- LCD_WriteReg(lcddev.setxcmd, Xpos);
- LCD_WriteReg(lcddev.setycmd, Ypos);
- }
- }
- //设置LCD的自动扫描方向
- //注意:其他函数可能会受到此函数设置的影响(尤其是9341/6804这两个奇葩),
- //所以,一般设置为L2R_U2D即可,如果设置为其他扫描方式,可能导致显示不正常.
- // dir:0~7,代表8个方向(具体定义见lcd.h)
- // 9320/9325/9328/4531/4535/1505/b505/8989/5408/9341/5310/5510等IC已经实际测试
- void LCD_Scan_Dir(uint8_t dir)
- {
- uint16_t regval = 0;
- uint16_t dirreg = 0;
- uint16_t temp;
- if ((lcddev.dir == 1 && lcddev.id != 0X6804 && lcddev.id != 0X1963) || (lcddev.dir == 0 && lcddev.id == 0X1963)) //横屏时,对6804和1963不改变扫描方向!竖屏时1963改变方向
- {
- switch (dir) //方向转换
- {
- case 0:
- dir = 6;
- break;
- case 1:
- dir = 7;
- break;
- case 2:
- dir = 4;
- break;
- case 3:
- dir = 5;
- break;
- case 4:
- dir = 1;
- break;
- case 5:
- dir = 0;
- break;
- case 6:
- dir = 3;
- break;
- case 7:
- dir = 2;
- break;
- }
- }
- if (lcddev.id == 0x9341 || lcddev.id == 0X6804 || lcddev.id == 0X5310 || lcddev.id == 0X5510 || lcddev.id == 0X1963) // 9341/6804/5310/5510/1963,特殊处理
- {
- switch (dir)
- {
- case L2R_U2D: //从左到右,从上到下
- regval |= (0 << 7) | (0 << 6) | (0 << 5);
- break;
- case L2R_D2U: //从左到右,从下到上
- regval |= (1 << 7) | (0 << 6) | (0 << 5);
- break;
- case R2L_U2D: //从右到左,从上到下
- regval |= (0 << 7) | (1 << 6) | (0 << 5);
- break;
- case R2L_D2U: //从右到左,从下到上
- regval |= (1 << 7) | (1 << 6) | (0 << 5);
- break;
- case U2D_L2R: //从上到下,从左到右
- regval |= (0 << 7) | (0 << 6) | (1 << 5);
- break;
- case U2D_R2L: //从上到下,从右到左
- regval |= (0 << 7) | (1 << 6) | (1 << 5);
- break;
- case D2U_L2R: //从下到上,从左到右
- regval |= (1 << 7) | (0 << 6) | (1 << 5);
- break;
- case D2U_R2L: //从下到上,从右到左
- regval |= (1 << 7) | (1 << 6) | (1 << 5);
- break;
- }
- if (lcddev.id == 0X5510)
- dirreg = 0X3600;
- else
- dirreg = 0X36;
- if ((lcddev.id != 0X5310) && (lcddev.id != 0X5510) && (lcddev.id != 0X1963))
- regval |= 0X08; // 5310/5510/1963不需要BGR
- if (lcddev.id == 0X6804)
- regval |= 0x02; // 6804的BIT6和9341的反了
- LCD_WriteReg(dirreg, regval);
- if (lcddev.id != 0X1963) // 1963不做坐标处理
- {
- if (regval & 0X20)
- {
- if (lcddev.width < lcddev.height) //交换X,Y
- {
- temp = lcddev.width;
- lcddev.width = lcddev.height;
- lcddev.height = temp;
- }
- }
- else
- {
- if (lcddev.width > lcddev.height) //交换X,Y
- {
- temp = lcddev.width;
- lcddev.width = lcddev.height;
- lcddev.height = temp;
- }
- }
- }
- if (lcddev.id == 0X5510)
- {
- LCD_WR_REG(lcddev.setxcmd);
- LCD_WR_DATA(0);
- LCD_WR_REG(lcddev.setxcmd + 1);
- LCD_WR_DATA(0);
- LCD_WR_REG(lcddev.setxcmd + 2);
- LCD_WR_DATA((lcddev.width - 1) >> 8);
- LCD_WR_REG(lcddev.setxcmd + 3);
- LCD_WR_DATA((lcddev.width - 1) & 0XFF);
- LCD_WR_REG(lcddev.setycmd);
- LCD_WR_DATA(0);
- LCD_WR_REG(lcddev.setycmd + 1);
- LCD_WR_DATA(0);
- LCD_WR_REG(lcddev.setycmd + 2);
- LCD_WR_DATA((lcddev.height - 1) >> 8);
- LCD_WR_REG(lcddev.setycmd + 3);
- LCD_WR_DATA((lcddev.height - 1) & 0XFF);
- }
- else
- {
- LCD_WR_REG(lcddev.setxcmd);
- LCD_WR_DATA(0);
- LCD_WR_DATA(0);
- LCD_WR_DATA((lcddev.width - 1) >> 8);
- LCD_WR_DATA((lcddev.width - 1) & 0XFF);
- LCD_WR_REG(lcddev.setycmd);
- LCD_WR_DATA(0);
- LCD_WR_DATA(0);
- LCD_WR_DATA((lcddev.height - 1) >> 8);
- LCD_WR_DATA((lcddev.height - 1) & 0XFF);
- }
- }
- else
- {
- switch (dir)
- {
- case L2R_U2D: //从左到右,从上到下
- regval |= (1 << 5) | (1 << 4) | (0 << 3);
- break;
- case L2R_D2U: //从左到右,从下到上
- regval |= (0 << 5) | (1 << 4) | (0 << 3);
- break;
- case R2L_U2D: //从右到左,从上到下
- regval |= (1 << 5) | (0 << 4) | (0 << 3);
- break;
- case R2L_D2U: //从右到左,从下到上
- regval |= (0 << 5) | (0 << 4) | (0 << 3);
- break;
- case U2D_L2R: //从上到下,从左到右
- regval |= (1 << 5) | (1 << 4) | (1 << 3);
- break;
- case U2D_R2L: //从上到下,从右到左
- regval |= (1 << 5) | (0 << 4) | (1 << 3);
- break;
- case D2U_L2R: //从下到上,从左到右
- regval |= (0 << 5) | (1 << 4) | (1 << 3);
- break;
- case D2U_R2L: //从下到上,从右到左
- regval |= (0 << 5) | (0 << 4) | (1 << 3);
- break;
- }
- dirreg = 0X03;
- regval |= 1 << 12;
- LCD_WriteReg(dirreg, regval);
- }
- }
- //画点
- // x,y:坐标
- // POINT_COLOR:此点的颜色
- void LCD_DrawPoint(u16 x, u16 y)
- {
- LCD_SetCursor(x, y); //设置光标位置
- LCD_WriteRAM_Prepare(); //开始写入GRAM
- LCD->LCD_RAM = POINT_COLOR;
- }
- //快速画点
- // x,y:坐标
- // color:颜色
- void LCD_Fast_DrawPoint(u16 x, u16 y, u16 color)
- {
- if (lcddev.id == 0X9341 || lcddev.id == 0X5310)
- {
- LCD_WR_REG(lcddev.setxcmd);
- LCD_WR_DATA(x >> 8);
- LCD_WR_DATA(x & 0XFF);
- LCD_WR_REG(lcddev.setycmd);
- LCD_WR_DATA(y >> 8);
- LCD_WR_DATA(y & 0XFF);
- }
- else if (lcddev.id == 0X5510)
- {
- LCD_WR_REG(lcddev.setxcmd);
- LCD_WR_DATA(x >> 8);
- LCD_WR_REG(lcddev.setxcmd + 1);
- LCD_WR_DATA(x & 0XFF);
- LCD_WR_REG(lcddev.setycmd);
- LCD_WR_DATA(y >> 8);
- LCD_WR_REG(lcddev.setycmd + 1);
- LCD_WR_DATA(y & 0XFF);
- }
- else if (lcddev.id == 0X6804)
- {
- if (lcddev.dir == 1)
- x = lcddev.width - 1 - x; //横屏时处理
- LCD_WR_REG(lcddev.setxcmd);
- LCD_WR_DATA(x >> 8);
- LCD_WR_DATA(x & 0XFF);
- LCD_WR_REG(lcddev.setycmd);
- LCD_WR_DATA(y >> 8);
- LCD_WR_DATA(y & 0XFF);
- }
- else
- {
- if (lcddev.dir == 1)
- x = lcddev.width - 1 - x; //横屏其实就是调转x,y坐标
- LCD_WriteReg(lcddev.setxcmd, x);
- LCD_WriteReg(lcddev.setycmd, y);
- }
- LCD->LCD_REG = lcddev.wramcmd;
- LCD->LCD_RAM = color;
- }
- //设置LCD显示方向
- // dir:0,竖屏;1,横屏
- void LCD_Display_Dir(u8 dir)
- {
- if (dir == 0) //竖屏
- {
- lcddev.dir = 0; //竖屏
- lcddev.width = 240;
- lcddev.height = 320;
- if (lcddev.id == 0X9341 || lcddev.id == 0X6804 || lcddev.id == 0X5310)
- {
- lcddev.wramcmd = 0X2C;
- lcddev.setxcmd = 0X2A;
- lcddev.setycmd = 0X2B;
- if (lcddev.id == 0X6804 || lcddev.id == 0X5310)
- {
- lcddev.width = 320;
- lcddev.height = 480;
- }
- }
- else if (lcddev.id == 0X8989)
- {
- lcddev.wramcmd = R34;
- lcddev.setxcmd = 0X4E;
- lcddev.setycmd = 0X4F;
- }
- else if (lcddev.id == 0x5510)
- {
- lcddev.wramcmd = 0X2C00;
- lcddev.setxcmd = 0X2A00;
- lcddev.setycmd = 0X2B00;
- lcddev.width = 480;
- lcddev.height = 800;
- }
- else
- {
- lcddev.wramcmd = R34;
- lcddev.setxcmd = R32;
- lcddev.setycmd = R33;
- }
- }
- else //横屏
- {
- lcddev.dir = 1; //横屏
- lcddev.width = 320;
- lcddev.height = 240;
- if (lcddev.id == 0X9341 || lcddev.id == 0X5310)
- {
- lcddev.wramcmd = 0X2C;
- lcddev.setxcmd = 0X2A;
- lcddev.setycmd = 0X2B;
- }
- else if (lcddev.id == 0X6804)
- {
- lcddev.wramcmd = 0X2C;
- lcddev.setxcmd = 0X2B;
- lcddev.setycmd = 0X2A;
- }
- else if (lcddev.id == 0X8989)
- {
- lcddev.wramcmd = R34;
- lcddev.setxcmd = 0X4F;
- lcddev.setycmd = 0X4E;
- }
- else if (lcddev.id == 0x5510)
- {
- lcddev.wramcmd = 0X2C00;
- lcddev.setxcmd = 0X2A00;
- lcddev.setycmd = 0X2B00;
- lcddev.width = 800;
- lcddev.height = 480;
- }
- else
- {
- lcddev.wramcmd = R34;
- lcddev.setxcmd = R33;
- lcddev.setycmd = R32;
- }
- if (lcddev.id == 0X6804 || lcddev.id == 0X5310)
- {
- lcddev.width = 480;
- lcddev.height = 320;
- }
- }
- LCD_Scan_Dir(DFT_SCAN_DIR); //默认扫描方向
- }
- //设置窗口,并自动设置画点坐标到窗口左上角(sx,sy).
- // sx,sy:窗口起始坐标(左上角)
- // width,height:窗口宽度和高度,必须大于0!!
- //窗体大小:width*height.
- // 68042,横屏时不支持窗口设置!!
- void LCD_Set_Window(u16 sx, u16 sy, u16 width, u16 height)
- {
- u8 hsareg, heareg, vsareg, veareg;
- u16 hsaval, heaval, vsaval, veaval;
- width = sx + width - 1;
- height = sy + height - 1;
- if (lcddev.id == 0X9341 || lcddev.id == 0X5310 || lcddev.id == 0X6804) // 6804横屏不支持
- {
- LCD_WR_REG(lcddev.setxcmd);
- LCD_WR_DATA(sx >> 8);
- LCD_WR_DATA(sx & 0XFF);
- LCD_WR_DATA(width >> 8);
- LCD_WR_DATA(width & 0XFF);
- LCD_WR_REG(lcddev.setycmd);
- LCD_WR_DATA(sy >> 8);
- LCD_WR_DATA(sy & 0XFF);
- LCD_WR_DATA(height >> 8);
- LCD_WR_DATA(height & 0XFF);
- }
- else if (lcddev.id == 0X5510)
- {
- LCD_WR_REG(lcddev.setxcmd);
- LCD_WR_DATA(sx >> 8);
- LCD_WR_REG(lcddev.setxcmd + 1);
- LCD_WR_DATA(sx & 0XFF);
- LCD_WR_REG(lcddev.setxcmd + 2);
- LCD_WR_DATA(width >> 8);
- LCD_WR_REG(lcddev.setxcmd + 3);
- LCD_WR_DATA(width & 0XFF);
- LCD_WR_REG(lcddev.setycmd);
- LCD_WR_DATA(sy >> 8);
- LCD_WR_REG(lcddev.setycmd + 1);
- LCD_WR_DATA(sy & 0XFF);
- LCD_WR_REG(lcddev.setycmd + 2);
- LCD_WR_DATA(height >> 8);
- LCD_WR_REG(lcddev.setycmd + 3);
- LCD_WR_DATA(height & 0XFF);
- }
- else //其他驱动IC
- {
- if (lcddev.dir == 1) //横屏
- {
- //窗口值
- hsaval = sy;
- heaval = height;
- vsaval = lcddev.width - width - 1;
- veaval = lcddev.width - sx - 1;
- }
- else
- {
- hsaval = sx;
- heaval = width;
- vsaval = sy;
- veaval = height;
- }
- if (lcddev.id == 0X8989) // 8989 IC
- {
- hsareg = 0X44;
- heareg = 0X44; //水平方向窗口寄存器 (1289的由一个寄存器控制)
- hsaval |= (heaval << 8); //得到寄存器值.
- heaval = hsaval;
- vsareg = 0X45;
- veareg = 0X46; //垂直方向窗口寄存器
- }
- else //其他驱动IC
- {
- hsareg = 0X50;
- heareg = 0X51; //水平方向窗口寄存器
- vsareg = 0X52;
- veareg = 0X53; //垂直方向窗口寄存器
- }
- //设置寄存器值
- LCD_WriteReg(hsareg, hsaval);
- LCD_WriteReg(heareg, heaval);
- LCD_WriteReg(vsareg, vsaval);
- LCD_WriteReg(veareg, veaval);
- LCD_SetCursor(sx, sy); //设置光标位置
- }
- }
- //初始化lcd
- //该初始化函数可以初始化各种ILI93XX液晶,但是其他函数是基于ILI9320的!!!
- //在其他型号的驱动芯片上没有测试!
- void LCD_Init(void)
- {
- FSMC_NORSRAMInitTypeDef init;
- FSMC_NORSRAMTimingInitTypeDef timingWrite;
- FSMC_NORSRAMTimingInitTypeDef timingRead;
- // GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; // PB0 推挽输出 背光
- // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽输出
- // GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- // GPIO_Init(GPIOB, &GPIO_InitStructure);
- // // PORTD复用推挽输出
- // GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_14 | GPIO_Pin_15; // //PORTD复用推挽输出
- // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //复用推挽输出
- // GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- // GPIO_Init(GPIOD, &GPIO_InitStructure);
- // // PORTE复用推挽输出
- // GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15; // //PORTD复用推挽输出
- // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //复用推挽输出
- // GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- // GPIO_Init(GPIOE, &GPIO_InitStructure);
- // // //PORTG12复用推挽输出 A0
- // GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_12; // //PORTD复用推挽输出
- // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //复用推挽输出
- // GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- // GPIO_Init(GPIOG, &GPIO_InitStructure);
- timingWrite.FSMC_AddressSetupTime = 4;
- timingWrite.FSMC_AddressHoldTime = 0;
- timingWrite.FSMC_DataSetupTime = 6;
- timingWrite.FSMC_BusTurnAroundDuration = 1;
- timingWrite.FSMC_CLKDivision = 0;
- timingWrite.FSMC_DataLatency = 0;
- timingWrite.FSMC_AccessMode = FSMC_AccessMode_A;
- timingRead.FSMC_AddressSetupTime = 4;
- timingRead.FSMC_AddressHoldTime = 0;
- timingRead.FSMC_DataSetupTime = 8;
- timingRead.FSMC_BusTurnAroundDuration = 1;
- timingRead.FSMC_CLKDivision = 0;
- timingRead.FSMC_DataLatency = 0;
- timingRead.FSMC_AccessMode = FSMC_AccessMode_A;
- init.FSMC_Bank = FSMC_Bank1_NORSRAM4;
- init.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
- init.FSMC_MemoryType = FSMC_MemoryType_SRAM;
- init.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
- init.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
- init.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable;
- init.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
- init.FSMC_WrapMode = FSMC_WrapMode_Disable;
- init.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
- init.FSMC_WriteOperation = FSMC_WriteOperation_Enable;
- init.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
- init.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;
- init.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
- init.FSMC_ReadWriteTimingStruct = &timingRead;
- init.FSMC_WriteTimingStruct = &timingWrite;
- FSMC_NORSRAMInit(&init);
- /* - BANK 1 (of NOR/SRAM Bank 1~4) is enabled */
- FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM4, ENABLE);
- ms_delay(50); // delay 50 ms
- LCD_WriteReg(0x0000, 0x0001);
- ms_delay(50); // delay 50 ms
- lcddev.id = LCD_ReadReg(0x0000);
- if (lcddev.id < 0XFF || lcddev.id == 0XFFFF || lcddev.id == 0X9300) //读到ID不正确,新增lcddev.id==0X9300判断,因为9341在未被复位的情况下会被读成9300
- {
- //尝试9341 ID的读取
- LCD_WR_REG(0XD3);
- LCD_RD_DATA(); // dummy read
- LCD_RD_DATA(); //读到0X00
- lcddev.id = LCD_RD_DATA(); //读取93
- lcddev.id <<= 8;
- lcddev.id |= LCD_RD_DATA(); //读取41
- if (lcddev.id != 0X9341) //非9341,尝试是不是6804
- {
- LCD_WR_REG(0XBF);
- LCD_RD_DATA(); // dummy read
- LCD_RD_DATA(); //读回0X01
- LCD_RD_DATA(); //读回0XD0
- lcddev.id = LCD_RD_DATA(); //这里读回0X68
- lcddev.id <<= 8;
- lcddev.id |= LCD_RD_DATA(); //这里读回0X04
- if (lcddev.id != 0X6804) //也不是6804,尝试看看是不是NT35310
- {
- LCD_WR_REG(0XD4);
- LCD_RD_DATA(); // dummy read
- LCD_RD_DATA(); //读回0X01
- lcddev.id = LCD_RD_DATA(); //读回0X53
- lcddev.id <<= 8;
- lcddev.id |= LCD_RD_DATA(); //这里读回0X10
- if (lcddev.id != 0X5310) //也不是NT35310,尝试看看是不是NT35510
- {
- LCD_WR_REG(0XDA00);
- LCD_RD_DATA(); //读回0X00
- LCD_WR_REG(0XDB00);
- lcddev.id = LCD_RD_DATA(); //读回0X80
- lcddev.id <<= 8;
- LCD_WR_REG(0XDC00);
- lcddev.id |= LCD_RD_DATA(); //读回0X00
- if (lcddev.id == 0x8000)
- lcddev.id = 0x5510; // NT35510读回的ID是8000H,为方便区分,我们强制设置为5510
- }
- }
- }
- }
- printf(" LCD ID:%x\r\n", lcddev.id); //打印LCD ID
- if (lcddev.id == 0X9341) // 9341初始化
- {
- LCD_WR_REG(0xCF);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xC1);
- LCD_WR_DATA(0X30);
- LCD_WR_REG(0xED);
- LCD_WR_DATA(0x64);
- LCD_WR_DATA(0x03);
- LCD_WR_DATA(0X12);
- LCD_WR_DATA(0X81);
- LCD_WR_REG(0xE8);
- LCD_WR_DATA(0x85);
- LCD_WR_DATA(0x10);
- LCD_WR_DATA(0x7A);
- LCD_WR_REG(0xCB);
- LCD_WR_DATA(0x39);
- LCD_WR_DATA(0x2C);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x34);
- LCD_WR_DATA(0x02);
- LCD_WR_REG(0xF7);
- LCD_WR_DATA(0x20);
- LCD_WR_REG(0xEA);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_REG(0xC0); // Power control
- LCD_WR_DATA(0x1B); // VRH[5:0]
- LCD_WR_REG(0xC1); // Power control
- LCD_WR_DATA(0x01); // SAP[2:0];BT[3:0]
- LCD_WR_REG(0xC5); // VCM control
- LCD_WR_DATA(0x30); // 3F
- LCD_WR_DATA(0x30); // 3C
- LCD_WR_REG(0xC7); // VCM control2
- LCD_WR_DATA(0XB7);
- LCD_WR_REG(0x36); // Memory Access Control
- LCD_WR_DATA(0x48);
- LCD_WR_REG(0x3A);
- LCD_WR_DATA(0x55);
- LCD_WR_REG(0xB1);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x1A);
- LCD_WR_REG(0xB6); // Display Function Control
- LCD_WR_DATA(0x0A);
- LCD_WR_DATA(0xA2);
- LCD_WR_REG(0xF2); // 3Gamma Function Disable
- LCD_WR_DATA(0x00);
- LCD_WR_REG(0x26); // Gamma curve selected
- LCD_WR_DATA(0x01);
- LCD_WR_REG(0xE0); // Set Gamma
- LCD_WR_DATA(0x0F);
- LCD_WR_DATA(0x2A);
- LCD_WR_DATA(0x28);
- LCD_WR_DATA(0x08);
- LCD_WR_DATA(0x0E);
- LCD_WR_DATA(0x08);
- LCD_WR_DATA(0x54);
- LCD_WR_DATA(0XA9);
- LCD_WR_DATA(0x43);
- LCD_WR_DATA(0x0A);
- LCD_WR_DATA(0x0F);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_REG(0XE1); // Set Gamma
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x15);
- LCD_WR_DATA(0x17);
- LCD_WR_DATA(0x07);
- LCD_WR_DATA(0x11);
- LCD_WR_DATA(0x06);
- LCD_WR_DATA(0x2B);
- LCD_WR_DATA(0x56);
- LCD_WR_DATA(0x3C);
- LCD_WR_DATA(0x05);
- LCD_WR_DATA(0x10);
- LCD_WR_DATA(0x0F);
- LCD_WR_DATA(0x3F);
- LCD_WR_DATA(0x3F);
- LCD_WR_DATA(0x0F);
- LCD_WR_REG(0x2B);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x01);
- LCD_WR_DATA(0x3f);
- LCD_WR_REG(0x2A);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xef);
- LCD_WR_REG(0x11); // Exit Sleep
- ms_delay(120);
- LCD_WR_REG(0x29); // display on
- }
- else if (lcddev.id == 0x6804) // 6804初始化
- {
- LCD_WR_REG(0X11);
- ms_delay(20);
- LCD_WR_REG(0XD0); // VCI1 VCL VGH VGL DDVDH VREG1OUT power amplitude setting
- LCD_WR_DATA(0X07);
- LCD_WR_DATA(0X42);
- LCD_WR_DATA(0X1D);
- LCD_WR_REG(0XD1); // VCOMH VCOM_AC amplitude setting
- LCD_WR_DATA(0X00);
- LCD_WR_DATA(0X1a);
- LCD_WR_DATA(0X09);
- LCD_WR_REG(0XD2); // Operational Amplifier Circuit Constant Current Adjust , charge pump frequency setting
- LCD_WR_DATA(0X01);
- LCD_WR_DATA(0X22);
- LCD_WR_REG(0XC0); // REV SM GS
- LCD_WR_DATA(0X10);
- LCD_WR_DATA(0X3B);
- LCD_WR_DATA(0X00);
- LCD_WR_DATA(0X02);
- LCD_WR_DATA(0X11);
- LCD_WR_REG(0XC5); // Frame rate setting = 72HZ when setting 0x03
- LCD_WR_DATA(0X03);
- LCD_WR_REG(0XC8); // Gamma setting
- LCD_WR_DATA(0X00);
- LCD_WR_DATA(0X25);
- LCD_WR_DATA(0X21);
- LCD_WR_DATA(0X05);
- LCD_WR_DATA(0X00);
- LCD_WR_DATA(0X0a);
- LCD_WR_DATA(0X65);
- LCD_WR_DATA(0X25);
- LCD_WR_DATA(0X77);
- LCD_WR_DATA(0X50);
- LCD_WR_DATA(0X0f);
- LCD_WR_DATA(0X00);
- LCD_WR_REG(0XF8);
- LCD_WR_DATA(0X01);
- LCD_WR_REG(0XFE);
- LCD_WR_DATA(0X00);
- LCD_WR_DATA(0X02);
- LCD_WR_REG(0X20); // Exit invert mode
- LCD_WR_REG(0X36);
- LCD_WR_DATA(0X08); //原来是a
- LCD_WR_REG(0X3A);
- LCD_WR_DATA(0X55); // 16位模式
- LCD_WR_REG(0X2B);
- LCD_WR_DATA(0X00);
- LCD_WR_DATA(0X00);
- LCD_WR_DATA(0X01);
- LCD_WR_DATA(0X3F);
- LCD_WR_REG(0X2A);
- LCD_WR_DATA(0X00);
- LCD_WR_DATA(0X00);
- LCD_WR_DATA(0X01);
- LCD_WR_DATA(0XDF);
- ms_delay(120);
- LCD_WR_REG(0X29);
- }
- else if (lcddev.id == 0x5310)
- {
- LCD_WR_REG(0xED);
- LCD_WR_DATA(0x01);
- LCD_WR_DATA(0xFE);
- LCD_WR_REG(0xEE);
- LCD_WR_DATA(0xDE);
- LCD_WR_DATA(0x21);
- LCD_WR_REG(0xF1);
- LCD_WR_DATA(0x01);
- LCD_WR_REG(0xDF);
- LCD_WR_DATA(0x10);
- // VCOMvoltage//
- LCD_WR_REG(0xC4);
- LCD_WR_DATA(0x8F); // 5f
- LCD_WR_REG(0xC6);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xE2);
- LCD_WR_DATA(0xE2);
- LCD_WR_DATA(0xE2);
- LCD_WR_REG(0xBF);
- LCD_WR_DATA(0xAA);
- LCD_WR_REG(0xB0);
- LCD_WR_DATA(0x0D);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x0D);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x11);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x19);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x21);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x2D);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x3D);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x5D);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x5D);
- LCD_WR_DATA(0x00);
- LCD_WR_REG(0xB1);
- LCD_WR_DATA(0x80);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x8B);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x96);
- LCD_WR_DATA(0x00);
- LCD_WR_REG(0xB2);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x02);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x03);
- LCD_WR_DATA(0x00);
- LCD_WR_REG(0xB3);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_REG(0xB4);
- LCD_WR_DATA(0x8B);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x96);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xA1);
- LCD_WR_DATA(0x00);
- LCD_WR_REG(0xB5);
- LCD_WR_DATA(0x02);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x03);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x04);
- LCD_WR_DATA(0x00);
- LCD_WR_REG(0xB6);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_REG(0xB7);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x3F);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x5E);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x64);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x8C);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xAC);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xDC);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x70);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x90);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xEB);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xDC);
- LCD_WR_DATA(0x00);
- LCD_WR_REG(0xB8);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_REG(0xBA);
- LCD_WR_DATA(0x24);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_REG(0xC1);
- LCD_WR_DATA(0x20);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x54);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xFF);
- LCD_WR_DATA(0x00);
- LCD_WR_REG(0xC2);
- LCD_WR_DATA(0x0A);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x04);
- LCD_WR_DATA(0x00);
- LCD_WR_REG(0xC3);
- LCD_WR_DATA(0x3C);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x3A);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x39);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x37);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x3C);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x36);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x32);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x2F);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x2C);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x29);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x26);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x24);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x24);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x23);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x3C);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x36);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x32);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x2F);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x2C);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x29);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x26);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x24);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x24);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x23);
- LCD_WR_DATA(0x00);
- LCD_WR_REG(0xC4);
- LCD_WR_DATA(0x62);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x05);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x84);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xF0);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x18);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xA4);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x18);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x50);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x0C);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x17);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x95);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xF3);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xE6);
- LCD_WR_DATA(0x00);
- LCD_WR_REG(0xC5);
- LCD_WR_DATA(0x32);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x44);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x65);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x76);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x88);
- LCD_WR_DATA(0x00);
- LCD_WR_REG(0xC6);
- LCD_WR_DATA(0x20);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x17);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x01);
- LCD_WR_DATA(0x00);
- LCD_WR_REG(0xC7);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_REG(0xC8);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_REG(0xC9);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_REG(0xE0);
- LCD_WR_DATA(0x16);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x1C);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x21);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x36);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x46);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x52);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x64);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x7A);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x8B);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x99);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xA8);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xB9);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xC4);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xCA);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xD2);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xD9);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xE0);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xF3);
- LCD_WR_DATA(0x00);
- LCD_WR_REG(0xE1);
- LCD_WR_DATA(0x16);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x1C);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x22);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x36);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x45);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x52);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x64);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x7A);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x8B);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x99);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xA8);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xB9);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xC4);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xCA);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xD2);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xD8);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xE0);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xF3);
- LCD_WR_DATA(0x00);
- LCD_WR_REG(0xE2);
- LCD_WR_DATA(0x05);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x0B);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x1B);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x34);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x44);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x4F);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x61);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x79);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x88);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x97);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xA6);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xB7);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xC2);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xC7);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xD1);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xD6);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xDD);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xF3);
- LCD_WR_DATA(0x00);
- LCD_WR_REG(0xE3);
- LCD_WR_DATA(0x05);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xA);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x1C);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x33);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x44);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x50);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x62);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x78);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x88);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x97);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xA6);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xB7);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xC2);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xC7);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xD1);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xD5);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xDD);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xF3);
- LCD_WR_DATA(0x00);
- LCD_WR_REG(0xE4);
- LCD_WR_DATA(0x01);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x01);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x02);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x2A);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x3C);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x4B);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x5D);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x74);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x84);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x93);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xA2);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xB3);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xBE);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xC4);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xCD);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xD3);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xDD);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xF3);
- LCD_WR_DATA(0x00);
- LCD_WR_REG(0xE5);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x02);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x29);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x3C);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x4B);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x5D);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x74);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x84);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x93);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xA2);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xB3);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xBE);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xC4);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xCD);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xD3);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xDC);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xF3);
- LCD_WR_DATA(0x00);
- LCD_WR_REG(0xE6);
- LCD_WR_DATA(0x11);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x34);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x56);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x76);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x77);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x66);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x88);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x99);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xBB);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x99);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x66);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x55);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x55);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x45);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x43);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x44);
- LCD_WR_DATA(0x00);
- LCD_WR_REG(0xE7);
- LCD_WR_DATA(0x32);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x55);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x76);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x66);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x67);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x67);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x87);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x99);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xBB);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x99);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x77);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x44);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x56);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x23);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x33);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x45);
- LCD_WR_DATA(0x00);
- LCD_WR_REG(0xE8);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x99);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x87);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x88);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x77);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x66);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x88);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xAA);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0xBB);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x99);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x66);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x55);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x55);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x44);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x44);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x55);
- LCD_WR_DATA(0x00);
- LCD_WR_REG(0xE9);
- LCD_WR_DATA(0xAA);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_REG(0x00);
- LCD_WR_DATA(0xAA);
- LCD_WR_REG(0xCF);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_REG(0xF0);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x50);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_DATA(0x00);
- LCD_WR_REG(0xF3);
- LCD_WR_DATA(0x00);
- LCD_WR_REG(0xF9);
- LCD_WR_DATA(0x06);
- LCD_WR_DATA(0x10);
- LCD_WR_DATA(0x29);
- LCD_WR_DATA(0x00);
- LCD_WR_REG(0x3A);
- LCD_WR_DATA(0x55); // 66
- LCD_WR_REG(0x11);
- ms_delay(100);
- LCD_WR_REG(0x29);
- LCD_WR_REG(0x35);
- LCD_WR_DATA(0x00);
- LCD_WR_REG(0x51);
- LCD_WR_DATA(0xFF);
- LCD_WR_REG(0x53);
- LCD_WR_DATA(0x2C);
- LCD_WR_REG(0x55);
- LCD_WR_DATA(0x82);
- LCD_WR_REG(0x2c);
- }
- else if (lcddev.id == 0x5510)
- {
- LCD_WriteReg(0xF000, 0x55);
- LCD_WriteReg(0xF001, 0xAA);
- LCD_WriteReg(0xF002, 0x52);
- LCD_WriteReg(0xF003, 0x08);
- LCD_WriteReg(0xF004, 0x01);
- // AVDD Set AVDD 5.2V
- LCD_WriteReg(0xB000, 0x0D);
- LCD_WriteReg(0xB001, 0x0D);
- LCD_WriteReg(0xB002, 0x0D);
- // AVDD ratio
- LCD_WriteReg(0xB600, 0x34);
- LCD_WriteReg(0xB601, 0x34);
- LCD_WriteReg(0xB602, 0x34);
- // AVEE -5.2V
- LCD_WriteReg(0xB100, 0x0D);
- LCD_WriteReg(0xB101, 0x0D);
- LCD_WriteReg(0xB102, 0x0D);
- // AVEE ratio
- LCD_WriteReg(0xB700, 0x34);
- LCD_WriteReg(0xB701, 0x34);
- LCD_WriteReg(0xB702, 0x34);
- // VCL -2.5V
- LCD_WriteReg(0xB200, 0x00);
- LCD_WriteReg(0xB201, 0x00);
- LCD_WriteReg(0xB202, 0x00);
- // VCL ratio
- LCD_WriteReg(0xB800, 0x24);
- LCD_WriteReg(0xB801, 0x24);
- LCD_WriteReg(0xB802, 0x24);
- // VGH 15V (Free pump)
- LCD_WriteReg(0xBF00, 0x01);
- LCD_WriteReg(0xB300, 0x0F);
- LCD_WriteReg(0xB301, 0x0F);
- LCD_WriteReg(0xB302, 0x0F);
- // VGH ratio
- LCD_WriteReg(0xB900, 0x34);
- LCD_WriteReg(0xB901, 0x34);
- LCD_WriteReg(0xB902, 0x34);
- // VGL_REG -10V
- LCD_WriteReg(0xB500, 0x08);
- LCD_WriteReg(0xB501, 0x08);
- LCD_WriteReg(0xB502, 0x08);
- LCD_WriteReg(0xC200, 0x03);
- // VGLX ratio
- LCD_WriteReg(0xBA00, 0x24);
- LCD_WriteReg(0xBA01, 0x24);
- LCD_WriteReg(0xBA02, 0x24);
- // VGMP/VGSP 4.5V/0V
- LCD_WriteReg(0xBC00, 0x00);
- LCD_WriteReg(0xBC01, 0x78);
- LCD_WriteReg(0xBC02, 0x00);
- // VGMN/VGSN -4.5V/0V
- LCD_WriteReg(0xBD00, 0x00);
- LCD_WriteReg(0xBD01, 0x78);
- LCD_WriteReg(0xBD02, 0x00);
- // VCOM
- LCD_WriteReg(0xBE00, 0x00);
- LCD_WriteReg(0xBE01, 0x64);
- // Gamma Setting
- LCD_WriteReg(0xD100, 0x00);
- LCD_WriteReg(0xD101, 0x33);
- LCD_WriteReg(0xD102, 0x00);
- LCD_WriteReg(0xD103, 0x34);
- LCD_WriteReg(0xD104, 0x00);
- LCD_WriteReg(0xD105, 0x3A);
- LCD_WriteReg(0xD106, 0x00);
- LCD_WriteReg(0xD107, 0x4A);
- LCD_WriteReg(0xD108, 0x00);
- LCD_WriteReg(0xD109, 0x5C);
- LCD_WriteReg(0xD10A, 0x00);
- LCD_WriteReg(0xD10B, 0x81);
- LCD_WriteReg(0xD10C, 0x00);
- LCD_WriteReg(0xD10D, 0xA6);
- LCD_WriteReg(0xD10E, 0x00);
- LCD_WriteReg(0xD10F, 0xE5);
- LCD_WriteReg(0xD110, 0x01);
- LCD_WriteReg(0xD111, 0x13);
- LCD_WriteReg(0xD112, 0x01);
- LCD_WriteReg(0xD113, 0x54);
- LCD_WriteReg(0xD114, 0x01);
- LCD_WriteReg(0xD115, 0x82);
- LCD_WriteReg(0xD116, 0x01);
- LCD_WriteReg(0xD117, 0xCA);
- LCD_WriteReg(0xD118, 0x02);
- LCD_WriteReg(0xD119, 0x00);
- LCD_WriteReg(0xD11A, 0x02);
- LCD_WriteReg(0xD11B, 0x01);
- LCD_WriteReg(0xD11C, 0x02);
- LCD_WriteReg(0xD11D, 0x34);
- LCD_WriteReg(0xD11E, 0x02);
- LCD_WriteReg(0xD11F, 0x67);
- LCD_WriteReg(0xD120, 0x02);
- LCD_WriteReg(0xD121, 0x84);
- LCD_WriteReg(0xD122, 0x02);
- LCD_WriteReg(0xD123, 0xA4);
- LCD_WriteReg(0xD124, 0x02);
- LCD_WriteReg(0xD125, 0xB7);
- LCD_WriteReg(0xD126, 0x02);
- LCD_WriteReg(0xD127, 0xCF);
- LCD_WriteReg(0xD128, 0x02);
- LCD_WriteReg(0xD129, 0xDE);
- LCD_WriteReg(0xD12A, 0x02);
- LCD_WriteReg(0xD12B, 0xF2);
- LCD_WriteReg(0xD12C, 0x02);
- LCD_WriteReg(0xD12D, 0xFE);
- LCD_WriteReg(0xD12E, 0x03);
- LCD_WriteReg(0xD12F, 0x10);
- LCD_WriteReg(0xD130, 0x03);
- LCD_WriteReg(0xD131, 0x33);
- LCD_WriteReg(0xD132, 0x03);
- LCD_WriteReg(0xD133, 0x6D);
- LCD_WriteReg(0xD200, 0x00);
- LCD_WriteReg(0xD201, 0x33);
- LCD_WriteReg(0xD202, 0x00);
- LCD_WriteReg(0xD203, 0x34);
- LCD_WriteReg(0xD204, 0x00);
- LCD_WriteReg(0xD205, 0x3A);
- LCD_WriteReg(0xD206, 0x00);
- LCD_WriteReg(0xD207, 0x4A);
- LCD_WriteReg(0xD208, 0x00);
- LCD_WriteReg(0xD209, 0x5C);
- LCD_WriteReg(0xD20A, 0x00);
- LCD_WriteReg(0xD20B, 0x81);
- LCD_WriteReg(0xD20C, 0x00);
- LCD_WriteReg(0xD20D, 0xA6);
- LCD_WriteReg(0xD20E, 0x00);
- LCD_WriteReg(0xD20F, 0xE5);
- LCD_WriteReg(0xD210, 0x01);
- LCD_WriteReg(0xD211, 0x13);
- LCD_WriteReg(0xD212, 0x01);
- LCD_WriteReg(0xD213, 0x54);
- LCD_WriteReg(0xD214, 0x01);
- LCD_WriteReg(0xD215, 0x82);
- LCD_WriteReg(0xD216, 0x01);
- LCD_WriteReg(0xD217, 0xCA);
- LCD_WriteReg(0xD218, 0x02);
- LCD_WriteReg(0xD219, 0x00);
- LCD_WriteReg(0xD21A, 0x02);
- LCD_WriteReg(0xD21B, 0x01);
- LCD_WriteReg(0xD21C, 0x02);
- LCD_WriteReg(0xD21D, 0x34);
- LCD_WriteReg(0xD21E, 0x02);
- LCD_WriteReg(0xD21F, 0x67);
- LCD_WriteReg(0xD220, 0x02);
- LCD_WriteReg(0xD221, 0x84);
- LCD_WriteReg(0xD222, 0x02);
- LCD_WriteReg(0xD223, 0xA4);
- LCD_WriteReg(0xD224, 0x02);
- LCD_WriteReg(0xD225, 0xB7);
- LCD_WriteReg(0xD226, 0x02);
- LCD_WriteReg(0xD227, 0xCF);
- LCD_WriteReg(0xD228, 0x02);
- LCD_WriteReg(0xD229, 0xDE);
- LCD_WriteReg(0xD22A, 0x02);
- LCD_WriteReg(0xD22B, 0xF2);
- LCD_WriteReg(0xD22C, 0x02);
- LCD_WriteReg(0xD22D, 0xFE);
- LCD_WriteReg(0xD22E, 0x03);
- LCD_WriteReg(0xD22F, 0x10);
- LCD_WriteReg(0xD230, 0x03);
- LCD_WriteReg(0xD231, 0x33);
- LCD_WriteReg(0xD232, 0x03);
- LCD_WriteReg(0xD233, 0x6D);
- LCD_WriteReg(0xD300, 0x00);
- LCD_WriteReg(0xD301, 0x33);
- LCD_WriteReg(0xD302, 0x00);
- LCD_WriteReg(0xD303, 0x34);
- LCD_WriteReg(0xD304, 0x00);
- LCD_WriteReg(0xD305, 0x3A);
- LCD_WriteReg(0xD306, 0x00);
- LCD_WriteReg(0xD307, 0x4A);
- LCD_WriteReg(0xD308, 0x00);
- LCD_WriteReg(0xD309, 0x5C);
- LCD_WriteReg(0xD30A, 0x00);
- LCD_WriteReg(0xD30B, 0x81);
- LCD_WriteReg(0xD30C, 0x00);
- LCD_WriteReg(0xD30D, 0xA6);
- LCD_WriteReg(0xD30E, 0x00);
- LCD_WriteReg(0xD30F, 0xE5);
- LCD_WriteReg(0xD310, 0x01);
- LCD_WriteReg(0xD311, 0x13);
- LCD_WriteReg(0xD312, 0x01);
- LCD_WriteReg(0xD313, 0x54);
- LCD_WriteReg(0xD314, 0x01);
- LCD_WriteReg(0xD315, 0x82);
- LCD_WriteReg(0xD316, 0x01);
- LCD_WriteReg(0xD317, 0xCA);
- LCD_WriteReg(0xD318, 0x02);
- LCD_WriteReg(0xD319, 0x00);
- LCD_WriteReg(0xD31A, 0x02);
- LCD_WriteReg(0xD31B, 0x01);
- LCD_WriteReg(0xD31C, 0x02);
- LCD_WriteReg(0xD31D, 0x34);
- LCD_WriteReg(0xD31E, 0x02);
- LCD_WriteReg(0xD31F, 0x67);
- LCD_WriteReg(0xD320, 0x02);
- LCD_WriteReg(0xD321, 0x84);
- LCD_WriteReg(0xD322, 0x02);
- LCD_WriteReg(0xD323, 0xA4);
- LCD_WriteReg(0xD324, 0x02);
- LCD_WriteReg(0xD325, 0xB7);
- LCD_WriteReg(0xD326, 0x02);
- LCD_WriteReg(0xD327, 0xCF);
- LCD_WriteReg(0xD328, 0x02);
- LCD_WriteReg(0xD329, 0xDE);
- LCD_WriteReg(0xD32A, 0x02);
- LCD_WriteReg(0xD32B, 0xF2);
- LCD_WriteReg(0xD32C, 0x02);
- LCD_WriteReg(0xD32D, 0xFE);
- LCD_WriteReg(0xD32E, 0x03);
- LCD_WriteReg(0xD32F, 0x10);
- LCD_WriteReg(0xD330, 0x03);
- LCD_WriteReg(0xD331, 0x33);
- LCD_WriteReg(0xD332, 0x03);
- LCD_WriteReg(0xD333, 0x6D);
- LCD_WriteReg(0xD400, 0x00);
- LCD_WriteReg(0xD401, 0x33);
- LCD_WriteReg(0xD402, 0x00);
- LCD_WriteReg(0xD403, 0x34);
- LCD_WriteReg(0xD404, 0x00);
- LCD_WriteReg(0xD405, 0x3A);
- LCD_WriteReg(0xD406, 0x00);
- LCD_WriteReg(0xD407, 0x4A);
- LCD_WriteReg(0xD408, 0x00);
- LCD_WriteReg(0xD409, 0x5C);
- LCD_WriteReg(0xD40A, 0x00);
- LCD_WriteReg(0xD40B, 0x81);
- LCD_WriteReg(0xD40C, 0x00);
- LCD_WriteReg(0xD40D, 0xA6);
- LCD_WriteReg(0xD40E, 0x00);
- LCD_WriteReg(0xD40F, 0xE5);
- LCD_WriteReg(0xD410, 0x01);
- LCD_WriteReg(0xD411, 0x13);
- LCD_WriteReg(0xD412, 0x01);
- LCD_WriteReg(0xD413, 0x54);
- LCD_WriteReg(0xD414, 0x01);
- LCD_WriteReg(0xD415, 0x82);
- LCD_WriteReg(0xD416, 0x01);
- LCD_WriteReg(0xD417, 0xCA);
- LCD_WriteReg(0xD418, 0x02);
- LCD_WriteReg(0xD419, 0x00);
- LCD_WriteReg(0xD41A, 0x02);
- LCD_WriteReg(0xD41B, 0x01);
- LCD_WriteReg(0xD41C, 0x02);
- LCD_WriteReg(0xD41D, 0x34);
- LCD_WriteReg(0xD41E, 0x02);
- LCD_WriteReg(0xD41F, 0x67);
- LCD_WriteReg(0xD420, 0x02);
- LCD_WriteReg(0xD421, 0x84);
- LCD_WriteReg(0xD422, 0x02);
- LCD_WriteReg(0xD423, 0xA4);
- LCD_WriteReg(0xD424, 0x02);
- LCD_WriteReg(0xD425, 0xB7);
- LCD_WriteReg(0xD426, 0x02);
- LCD_WriteReg(0xD427, 0xCF);
- LCD_WriteReg(0xD428, 0x02);
- LCD_WriteReg(0xD429, 0xDE);
- LCD_WriteReg(0xD42A, 0x02);
- LCD_WriteReg(0xD42B, 0xF2);
- LCD_WriteReg(0xD42C, 0x02);
- LCD_WriteReg(0xD42D, 0xFE);
- LCD_WriteReg(0xD42E, 0x03);
- LCD_WriteReg(0xD42F, 0x10);
- LCD_WriteReg(0xD430, 0x03);
- LCD_WriteReg(0xD431, 0x33);
- LCD_WriteReg(0xD432, 0x03);
- LCD_WriteReg(0xD433, 0x6D);
- LCD_WriteReg(0xD500, 0x00);
- LCD_WriteReg(0xD501, 0x33);
- LCD_WriteReg(0xD502, 0x00);
- LCD_WriteReg(0xD503, 0x34);
- LCD_WriteReg(0xD504, 0x00);
- LCD_WriteReg(0xD505, 0x3A);
- LCD_WriteReg(0xD506, 0x00);
- LCD_WriteReg(0xD507, 0x4A);
- LCD_WriteReg(0xD508, 0x00);
- LCD_WriteReg(0xD509, 0x5C);
- LCD_WriteReg(0xD50A, 0x00);
- LCD_WriteReg(0xD50B, 0x81);
- LCD_WriteReg(0xD50C, 0x00);
- LCD_WriteReg(0xD50D, 0xA6);
- LCD_WriteReg(0xD50E, 0x00);
- LCD_WriteReg(0xD50F, 0xE5);
- LCD_WriteReg(0xD510, 0x01);
- LCD_WriteReg(0xD511, 0x13);
- LCD_WriteReg(0xD512, 0x01);
- LCD_WriteReg(0xD513, 0x54);
- LCD_WriteReg(0xD514, 0x01);
- LCD_WriteReg(0xD515, 0x82);
- LCD_WriteReg(0xD516, 0x01);
- LCD_WriteReg(0xD517, 0xCA);
- LCD_WriteReg(0xD518, 0x02);
- LCD_WriteReg(0xD519, 0x00);
- LCD_WriteReg(0xD51A, 0x02);
- LCD_WriteReg(0xD51B, 0x01);
- LCD_WriteReg(0xD51C, 0x02);
- LCD_WriteReg(0xD51D, 0x34);
- LCD_WriteReg(0xD51E, 0x02);
- LCD_WriteReg(0xD51F, 0x67);
- LCD_WriteReg(0xD520, 0x02);
- LCD_WriteReg(0xD521, 0x84);
- LCD_WriteReg(0xD522, 0x02);
- LCD_WriteReg(0xD523, 0xA4);
- LCD_WriteReg(0xD524, 0x02);
- LCD_WriteReg(0xD525, 0xB7);
- LCD_WriteReg(0xD526, 0x02);
- LCD_WriteReg(0xD527, 0xCF);
- LCD_WriteReg(0xD528, 0x02);
- LCD_WriteReg(0xD529, 0xDE);
- LCD_WriteReg(0xD52A, 0x02);
- LCD_WriteReg(0xD52B, 0xF2);
- LCD_WriteReg(0xD52C, 0x02);
- LCD_WriteReg(0xD52D, 0xFE);
- LCD_WriteReg(0xD52E, 0x03);
- LCD_WriteReg(0xD52F, 0x10);
- LCD_WriteReg(0xD530, 0x03);
- LCD_WriteReg(0xD531, 0x33);
- LCD_WriteReg(0xD532, 0x03);
- LCD_WriteReg(0xD533, 0x6D);
- LCD_WriteReg(0xD600, 0x00);
- LCD_WriteReg(0xD601, 0x33);
- LCD_WriteReg(0xD602, 0x00);
- LCD_WriteReg(0xD603, 0x34);
- LCD_WriteReg(0xD604, 0x00);
- LCD_WriteReg(0xD605, 0x3A);
- LCD_WriteReg(0xD606, 0x00);
- LCD_WriteReg(0xD607, 0x4A);
- LCD_WriteReg(0xD608, 0x00);
- LCD_WriteReg(0xD609, 0x5C);
- LCD_WriteReg(0xD60A, 0x00);
- LCD_WriteReg(0xD60B, 0x81);
- LCD_WriteReg(0xD60C, 0x00);
- LCD_WriteReg(0xD60D, 0xA6);
- LCD_WriteReg(0xD60E, 0x00);
- LCD_WriteReg(0xD60F, 0xE5);
- LCD_WriteReg(0xD610, 0x01);
- LCD_WriteReg(0xD611, 0x13);
- LCD_WriteReg(0xD612, 0x01);
- LCD_WriteReg(0xD613, 0x54);
- LCD_WriteReg(0xD614, 0x01);
- LCD_WriteReg(0xD615, 0x82);
- LCD_WriteReg(0xD616, 0x01);
- LCD_WriteReg(0xD617, 0xCA);
- LCD_WriteReg(0xD618, 0x02);
- LCD_WriteReg(0xD619, 0x00);
- LCD_WriteReg(0xD61A, 0x02);
- LCD_WriteReg(0xD61B, 0x01);
- LCD_WriteReg(0xD61C, 0x02);
- LCD_WriteReg(0xD61D, 0x34);
- LCD_WriteReg(0xD61E, 0x02);
- LCD_WriteReg(0xD61F, 0x67);
- LCD_WriteReg(0xD620, 0x02);
- LCD_WriteReg(0xD621, 0x84);
- LCD_WriteReg(0xD622, 0x02);
- LCD_WriteReg(0xD623, 0xA4);
- LCD_WriteReg(0xD624, 0x02);
- LCD_WriteReg(0xD625, 0xB7);
- LCD_WriteReg(0xD626, 0x02);
- LCD_WriteReg(0xD627, 0xCF);
- LCD_WriteReg(0xD628, 0x02);
- LCD_WriteReg(0xD629, 0xDE);
- LCD_WriteReg(0xD62A, 0x02);
- LCD_WriteReg(0xD62B, 0xF2);
- LCD_WriteReg(0xD62C, 0x02);
- LCD_WriteReg(0xD62D, 0xFE);
- LCD_WriteReg(0xD62E, 0x03);
- LCD_WriteReg(0xD62F, 0x10);
- LCD_WriteReg(0xD630, 0x03);
- LCD_WriteReg(0xD631, 0x33);
- LCD_WriteReg(0xD632, 0x03);
- LCD_WriteReg(0xD633, 0x6D);
- // LV2 Page 0 enable
- LCD_WriteReg(0xF000, 0x55);
- LCD_WriteReg(0xF001, 0xAA);
- LCD_WriteReg(0xF002, 0x52);
- LCD_WriteReg(0xF003, 0x08);
- LCD_WriteReg(0xF004, 0x00);
- // Display control
- LCD_WriteReg(0xB100, 0xCC);
- LCD_WriteReg(0xB101, 0x00);
- // Source hold time
- LCD_WriteReg(0xB600, 0x05);
- // Gate EQ control
- LCD_WriteReg(0xB700, 0x70);
- LCD_WriteReg(0xB701, 0x70);
- // Source EQ control (Mode 2)
- LCD_WriteReg(0xB800, 0x01);
- LCD_WriteReg(0xB801, 0x03);
- LCD_WriteReg(0xB802, 0x03);
- LCD_WriteReg(0xB803, 0x03);
- // Inversion mode (2-dot)
- LCD_WriteReg(0xBC00, 0x02);
- LCD_WriteReg(0xBC01, 0x00);
- LCD_WriteReg(0xBC02, 0x00);
- // Timing control 4H w/ 4-delay
- LCD_WriteReg(0xC900, 0xD0);
- LCD_WriteReg(0xC901, 0x02);
- LCD_WriteReg(0xC902, 0x50);
- LCD_WriteReg(0xC903, 0x50);
- LCD_WriteReg(0xC904, 0x50);
- LCD_WriteReg(0x3500, 0x00);
- LCD_WriteReg(0x3A00, 0x55); // 16-bit/pixel
- LCD_WR_REG(0x1100);
- us_delay(120);
- LCD_WR_REG(0x2900);
- }
- else if (lcddev.id == 0x9325) // 9325
- {
- LCD_WriteReg(0x00E5, 0x78F0);
- LCD_WriteReg(0x0001, 0x0100);
- LCD_WriteReg(0x0002, 0x0700);
- LCD_WriteReg(0x0003, 0x1030);
- LCD_WriteReg(0x0004, 0x0000);
- LCD_WriteReg(0x0008, 0x0202);
- LCD_WriteReg(0x0009, 0x0000);
- LCD_WriteReg(0x000A, 0x0000);
- LCD_WriteReg(0x000C, 0x0000);
- LCD_WriteReg(0x000D, 0x0000);
- LCD_WriteReg(0x000F, 0x0000);
- // power on sequence VGHVGL
- LCD_WriteReg(0x0010, 0x0000);
- LCD_WriteReg(0x0011, 0x0007);
- LCD_WriteReg(0x0012, 0x0000);
- LCD_WriteReg(0x0013, 0x0000);
- LCD_WriteReg(0x0007, 0x0000);
- // vgh
- LCD_WriteReg(0x0010, 0x1690);
- LCD_WriteReg(0x0011, 0x0227);
- // delayms(100);
- // vregiout
- LCD_WriteReg(0x0012, 0x009D); // 0x001b
- // delayms(100);
- // vom amplitude
- LCD_WriteReg(0x0013, 0x1900);
- // delayms(100);
- // vom H
- LCD_WriteReg(0x0029, 0x0025);
- LCD_WriteReg(0x002B, 0x000D);
- // gamma
- LCD_WriteReg(0x0030, 0x0007);
- LCD_WriteReg(0x0031, 0x0303);
- LCD_WriteReg(0x0032, 0x0003); // 0006
- LCD_WriteReg(0x0035, 0x0206);
- LCD_WriteReg(0x0036, 0x0008);
- LCD_WriteReg(0x0037, 0x0406);
- LCD_WriteReg(0x0038, 0x0304); // 0200
- LCD_WriteReg(0x0039, 0x0007);
- LCD_WriteReg(0x003C, 0x0602); // 0504
- LCD_WriteReg(0x003D, 0x0008);
- // ram
- LCD_WriteReg(0x0050, 0x0000);
- LCD_WriteReg(0x0051, 0x00EF);
- LCD_WriteReg(0x0052, 0x0000);
- LCD_WriteReg(0x0053, 0x013F);
- LCD_WriteReg(0x0060, 0xA700);
- LCD_WriteReg(0x0061, 0x0001);
- LCD_WriteReg(0x006A, 0x0000);
- //
- LCD_WriteReg(0x0080, 0x0000);
- LCD_WriteReg(0x0081, 0x0000);
- LCD_WriteReg(0x0082, 0x0000);
- LCD_WriteReg(0x0083, 0x0000);
- LCD_WriteReg(0x0084, 0x0000);
- LCD_WriteReg(0x0085, 0x0000);
- //
- LCD_WriteReg(0x0090, 0x0010);
- LCD_WriteReg(0x0092, 0x0600);
- LCD_WriteReg(0x0007, 0x0133);
- LCD_WriteReg(0x00, 0x0022); //
- }
- else if (lcddev.id == 0x9328) // ILI9328 OK
- {
- LCD_WriteReg(0x00EC, 0x108F); // internal timeing
- LCD_WriteReg(0x00EF, 0x1234); // ADD
- // LCD_WriteReg(0x00e7,0x0010);
- // LCD_WriteReg(0x0000,0x0001);//开启内部时钟
- LCD_WriteReg(0x0001, 0x0100);
- LCD_WriteReg(0x0002, 0x0700); //电源开启
- // LCD_WriteReg(0x0003,(1<<3)|(1<<4) ); //65K RGB
- // DRIVE TABLE(寄存器 03H)
- // BIT3=AM BIT4:5=ID0:1
- // AM ID0 ID1 FUNCATION
- // 0 0 0 R->L D->U
- // 1 0 0 D->U R->L
- // 0 1 0 L->R D->U
- // 1 1 0 D->U L->R
- // 0 0 1 R->L U->D
- // 1 0 1 U->D R->L
- // 0 1 1 L->R U->D 正常就用这个.
- // 1 1 1 U->D L->R
- LCD_WriteReg(0x0003, (1 << 12) | (3 << 4) | (0 << 3)); // 65K
- LCD_WriteReg(0x0004, 0x0000);
- LCD_WriteReg(0x0008, 0x0202);
- LCD_WriteReg(0x0009, 0x0000);
- LCD_WriteReg(0x000a, 0x0000); // display setting
- LCD_WriteReg(0x000c, 0x0001); // display setting
- LCD_WriteReg(0x000d, 0x0000); // 0f3c
- LCD_WriteReg(0x000f, 0x0000);
- //电源配置
- LCD_WriteReg(0x0010, 0x0000);
- LCD_WriteReg(0x0011, 0x0007);
- LCD_WriteReg(0x0012, 0x0000);
- LCD_WriteReg(0x0013, 0x0000);
- LCD_WriteReg(0x0007, 0x0001);
- ms_delay(50);
- LCD_WriteReg(0x0010, 0x1490);
- LCD_WriteReg(0x0011, 0x0227);
- ms_delay(50);
- LCD_WriteReg(0x0012, 0x008A);
- ms_delay(50);
- LCD_WriteReg(0x0013, 0x1a00);
- LCD_WriteReg(0x0029, 0x0006);
- LCD_WriteReg(0x002b, 0x000d);
- ms_delay(50);
- LCD_WriteReg(0x0020, 0x0000);
- LCD_WriteReg(0x0021, 0x0000);
- ms_delay(50);
- //伽马校正
- LCD_WriteReg(0x0030, 0x0000);
- LCD_WriteReg(0x0031, 0x0604);
- LCD_WriteReg(0x0032, 0x0305);
- LCD_WriteReg(0x0035, 0x0000);
- LCD_WriteReg(0x0036, 0x0C09);
- LCD_WriteReg(0x0037, 0x0204);
- LCD_WriteReg(0x0038, 0x0301);
- LCD_WriteReg(0x0039, 0x0707);
- LCD_WriteReg(0x003c, 0x0000);
- LCD_WriteReg(0x003d, 0x0a0a);
- ms_delay(50);
- LCD_WriteReg(0x0050, 0x0000); //水平GRAM起始位置
- LCD_WriteReg(0x0051, 0x00ef); //水平GRAM终止位置
- LCD_WriteReg(0x0052, 0x0000); //垂直GRAM起始位置
- LCD_WriteReg(0x0053, 0x013f); //垂直GRAM终止位置
- LCD_WriteReg(0x0060, 0xa700);
- LCD_WriteReg(0x0061, 0x0001);
- LCD_WriteReg(0x006a, 0x0000);
- LCD_WriteReg(0x0080, 0x0000);
- LCD_WriteReg(0x0081, 0x0000);
- LCD_WriteReg(0x0082, 0x0000);
- LCD_WriteReg(0x0083, 0x0000);
- LCD_WriteReg(0x0084, 0x0000);
- LCD_WriteReg(0x0085, 0x0000);
- LCD_WriteReg(0x0090, 0x0010);
- LCD_WriteReg(0x0092, 0x0600);
- //开启显示设置
- LCD_WriteReg(0x0007, 0x0133);
- }
- else if (lcddev.id == 0x9320) //测试OK.
- {
- LCD_WriteReg(0x00, 0x0000);
- LCD_WriteReg(0x01, 0x0100); // Driver Output Contral.
- LCD_WriteReg(0x02, 0x0700); // LCD Driver Waveform Contral.
- LCD_WriteReg(0x03, 0x1030); // Entry Mode Set.
- // LCD_WriteReg(0x03,0x1018); //Entry Mode Set.
- LCD_WriteReg(0x04, 0x0000); // Scalling Contral.
- LCD_WriteReg(0x08, 0x0202); // Display Contral 2.(0x0207)
- LCD_WriteReg(0x09, 0x0000); // Display Contral 3.(0x0000)
- LCD_WriteReg(0x0a, 0x0000); // Frame Cycle Contal.(0x0000)
- LCD_WriteReg(0x0c, (1 << 0)); // Extern Display Interface Contral 1.(0x0000)
- LCD_WriteReg(0x0d, 0x0000); // Frame Maker Position.
- LCD_WriteReg(0x0f, 0x0000); // Extern Display Interface Contral 2.
- ms_delay(50);
- LCD_WriteReg(0x07, 0x0101); // Display Contral.
- ms_delay(50);
- LCD_WriteReg(0x10, (1 << 12) | (0 << 8) | (1 << 7) | (1 << 6) | (0 << 4)); // Power Control 1.(0x16b0)
- LCD_WriteReg(0x11, 0x0007); // Power Control 2.(0x0001)
- LCD_WriteReg(0x12, (1 << 8) | (1 << 4) | (0 << 0)); // Power Control 3.(0x0138)
- LCD_WriteReg(0x13, 0x0b00); // Power Control 4.
- LCD_WriteReg(0x29, 0x0000); // Power Control 7.
- LCD_WriteReg(0x2b, (1 << 14) | (1 << 4));
- LCD_WriteReg(0x50, 0); // Set X Star
- //水平GRAM终止位置Set X End.
- LCD_WriteReg(0x51, 239); // Set Y Star
- LCD_WriteReg(0x52, 0); // Set Y End.t.
- LCD_WriteReg(0x53, 319); //
- LCD_WriteReg(0x60, 0x2700); // Driver Output Control.
- LCD_WriteReg(0x61, 0x0001); // Driver Output Control.
- LCD_WriteReg(0x6a, 0x0000); // Vertical Srcoll Control.
- LCD_WriteReg(0x80, 0x0000); // Display Position? Partial Display 1.
- LCD_WriteReg(0x81, 0x0000); // RAM Address Start? Partial Display 1.
- LCD_WriteReg(0x82, 0x0000); // RAM Address End-Partial Display 1.
- LCD_WriteReg(0x83, 0x0000); // Displsy Position? Partial Display 2.
- LCD_WriteReg(0x84, 0x0000); // RAM Address Start? Partial Display 2.
- LCD_WriteReg(0x85, 0x0000); // RAM Address End? Partial Display 2.
- LCD_WriteReg(0x90, (0 << 7) | (16 << 0)); // Frame Cycle Contral.(0x0013)
- LCD_WriteReg(0x92, 0x0000); // Panel Interface Contral 2.(0x0000)
- LCD_WriteReg(0x93, 0x0001); // Panel Interface Contral 3.
- LCD_WriteReg(0x95, 0x0110); // Frame Cycle Contral.(0x0110)
- LCD_WriteReg(0x97, (0 << 8)); //
- LCD_WriteReg(0x98, 0x0000); // Frame Cycle Contral.
- LCD_WriteReg(0x07, 0x0173); //(0x0173)
- }
- else if (lcddev.id == 0X9331) // OK |/|/|
- {
- LCD_WriteReg(0x00E7, 0x1014);
- LCD_WriteReg(0x0001, 0x0100); // set SS and SM bit
- LCD_WriteReg(0x0002, 0x0200); // set 1 line inversion
- LCD_WriteReg(0x0003, (1 << 12) | (3 << 4) | (1 << 3)); // 65K
- // LCD_WriteReg(0x0003, 0x1030); // set GRAM write direction and BGR=1.
- LCD_WriteReg(0x0008, 0x0202); // set the back porch and front porch
- LCD_WriteReg(0x0009, 0x0000); // set non-display area refresh cycle ISC[3:0]
- LCD_WriteReg(0x000A, 0x0000); // FMARK function
- LCD_WriteReg(0x000C, 0x0000); // RGB interface setting
- LCD_WriteReg(0x000D, 0x0000); // Frame marker Position
- LCD_WriteReg(0x000F, 0x0000); // RGB interface polarity
- //*************Power On sequence ****************//
- LCD_WriteReg(0x0010, 0x0000); // SAP, BT[3:0], AP, DSTB, SLP, STB
- LCD_WriteReg(0x0011, 0x0007); // DC1[2:0], DC0[2:0], VC[2:0]
- LCD_WriteReg(0x0012, 0x0000); // VREG1OUT voltage
- LCD_WriteReg(0x0013, 0x0000); // VDV[4:0] for VCOM amplitude
- ms_delay(200); // Dis-charge capacitor power voltage
- LCD_WriteReg(0x0010, 0x1690); // SAP, BT[3:0], AP, DSTB, SLP, STB
- LCD_WriteReg(0x0011, 0x0227); // DC1[2:0], DC0[2:0], VC[2:0]
- ms_delay(50); // Delay 50ms
- LCD_WriteReg(0x0012, 0x000C); // Internal reference voltage= Vci;
- ms_delay(50); // Delay 50ms
- LCD_WriteReg(0x0013, 0x0800); // Set VDV[4:0] for VCOM amplitude
- LCD_WriteReg(0x0029, 0x0011); // Set VCM[5:0] for VCOMH
- LCD_WriteReg(0x002B, 0x000B); // Set Frame Rate
- ms_delay(50); // Delay 50ms
- LCD_WriteReg(0x0020, 0x0000); // GRAM horizontal Address
- LCD_WriteReg(0x0021, 0x013f); // GRAM Vertical Address
- // ----------- Adjust the Gamma Curve ----------//
- LCD_WriteReg(0x0030, 0x0000);
- LCD_WriteReg(0x0031, 0x0106);
- LCD_WriteReg(0x0032, 0x0000);
- LCD_WriteReg(0x0035, 0x0204);
- LCD_WriteReg(0x0036, 0x160A);
- LCD_WriteReg(0x0037, 0x0707);
- LCD_WriteReg(0x0038, 0x0106);
- LCD_WriteReg(0x0039, 0x0707);
- LCD_WriteReg(0x003C, 0x0402);
- LCD_WriteReg(0x003D, 0x0C0F);
- //------------------ Set GRAM area ---------------//
- LCD_WriteReg(0x0050, 0x0000); // Horizontal GRAM Start Address
- LCD_WriteReg(0x0051, 0x00EF); // Horizontal GRAM End Address
- LCD_WriteReg(0x0052, 0x0000); // Vertical GRAM Start Address
- LCD_WriteReg(0x0053, 0x013F); // Vertical GRAM Start Address
- LCD_WriteReg(0x0060, 0x2700); // Gate Scan Line
- LCD_WriteReg(0x0061, 0x0001); // NDL,VLE, REV
- LCD_WriteReg(0x006A, 0x0000); // set scrolling line
- //-------------- Partial Display Control ---------//
- LCD_WriteReg(0x0080, 0x0000);
- LCD_WriteReg(0x0081, 0x0000);
- LCD_WriteReg(0x0082, 0x0000);
- LCD_WriteReg(0x0083, 0x0000);
- LCD_WriteReg(0x0084, 0x0000);
- LCD_WriteReg(0x0085, 0x0000);
- //-------------- Panel Control -------------------//
- LCD_WriteReg(0x0090, 0x0010);
- LCD_WriteReg(0x0092, 0x0600);
- LCD_WriteReg(0x0007, 0x0133); // 262K color and display ON
- }
- else if (lcddev.id == 0x5408)
- {
- LCD_WriteReg(0x01, 0x0100);
- LCD_WriteReg(0x02, 0x0700); // LCD Driving Waveform Contral
- LCD_WriteReg(0x03, 0x1030); // Entry Mode设置
- //指针从左至右自上而下的自动增模式
- // Normal Mode(Window Mode disable)
- // RGB格式
- // 16位数据2次传输的8总线设置
- LCD_WriteReg(0x04, 0x0000); // Scalling Control register
- LCD_WriteReg(0x08, 0x0207); // Display Control 2
- LCD_WriteReg(0x09, 0x0000); // Display Control 3
- LCD_WriteReg(0x0A, 0x0000); // Frame Cycle Control
- LCD_WriteReg(0x0C, 0x0000); // External Display Interface Control 1
- LCD_WriteReg(0x0D, 0x0000); // Frame Maker Position
- LCD_WriteReg(0x0F, 0x0000); // External Display Interface Control 2
- ms_delay(20);
- // TFT 液晶彩色图像显示方法14
- LCD_WriteReg(0x10, 0x16B0); // 0x14B0 //Power Control 1
- LCD_WriteReg(0x11, 0x0001); // 0x0007 //Power Control 2
- LCD_WriteReg(0x17, 0x0001); // 0x0000 //Power Control 3
- LCD_WriteReg(0x12, 0x0138); // 0x013B //Power Control 4
- LCD_WriteReg(0x13, 0x0800); // 0x0800 //Power Control 5
- LCD_WriteReg(0x29, 0x0009); // NVM read data 2
- LCD_WriteReg(0x2a, 0x0009); // NVM read data 3
- LCD_WriteReg(0xa4, 0x0000);
- LCD_WriteReg(0x50, 0x0000); //设置操作窗口的X轴开始列
- LCD_WriteReg(0x51, 0x00EF); //设置操作窗口的X轴结束列
- LCD_WriteReg(0x52, 0x0000); //设置操作窗口的Y轴开始行
- LCD_WriteReg(0x53, 0x013F); //设置操作窗口的Y轴结束行
- LCD_WriteReg(0x60, 0x2700); // Driver Output Control
- //设置屏幕的点数以及扫描的起始行
- LCD_WriteReg(0x61, 0x0001); // Driver Output Control
- LCD_WriteReg(0x6A, 0x0000); // Vertical Scroll Control
- LCD_WriteReg(0x80, 0x0000); // Display Position – Partial Display 1
- LCD_WriteReg(0x81, 0x0000); // RAM Address Start – Partial Display 1
- LCD_WriteReg(0x82, 0x0000); // RAM address End - Partial Display 1
- LCD_WriteReg(0x83, 0x0000); // Display Position – Partial Display 2
- LCD_WriteReg(0x84, 0x0000); // RAM Address Start – Partial Display 2
- LCD_WriteReg(0x85, 0x0000); // RAM address End – Partail Display2
- LCD_WriteReg(0x90, 0x0013); // Frame Cycle Control
- LCD_WriteReg(0x92, 0x0000); // Panel Interface Control 2
- LCD_WriteReg(0x93, 0x0003); // Panel Interface control 3
- LCD_WriteReg(0x95, 0x0110); // Frame Cycle Control
- LCD_WriteReg(0x07, 0x0173);
- ms_delay(50);
- }
- else if (lcddev.id == 0x1505) // OK
- {
- // second release on 3/5 ,luminance is acceptable,water wave appear during camera preview
- LCD_WriteReg(0x0007, 0x0000);
- ms_delay(50);
- LCD_WriteReg(0x0012, 0x011C); // 0x011A why need to set several times?
- LCD_WriteReg(0x00A4, 0x0001); // NVM
- LCD_WriteReg(0x0008, 0x000F);
- LCD_WriteReg(0x000A, 0x0008);
- LCD_WriteReg(0x000D, 0x0008);
- //伽马校正
- LCD_WriteReg(0x0030, 0x0707);
- LCD_WriteReg(0x0031, 0x0007); // 0x0707
- LCD_WriteReg(0x0032, 0x0603);
- LCD_WriteReg(0x0033, 0x0700);
- LCD_WriteReg(0x0034, 0x0202);
- LCD_WriteReg(0x0035, 0x0002); //?0x0606
- LCD_WriteReg(0x0036, 0x1F0F);
- LCD_WriteReg(0x0037, 0x0707); // 0x0f0f 0x0105
- LCD_WriteReg(0x0038, 0x0000);
- LCD_WriteReg(0x0039, 0x0000);
- LCD_WriteReg(0x003A, 0x0707);
- LCD_WriteReg(0x003B, 0x0000); // 0x0303
- LCD_WriteReg(0x003C, 0x0007); //?0x0707
- LCD_WriteReg(0x003D, 0x0000); // 0x1313//0x1f08
- ms_delay(50);
- LCD_WriteReg(0x0007, 0x0001);
- LCD_WriteReg(0x0017, 0x0001); //开启电源
- ms_delay(50);
- //电源配置
- LCD_WriteReg(0x0010, 0x17A0);
- LCD_WriteReg(0x0011, 0x0217); // reference voltage VC[2:0] Vciout = 1.00*Vcivl
- LCD_WriteReg(0x0012, 0x011E); // 0x011c //Vreg1out = Vcilvl*1.80 is it the same as Vgama1out ?
- LCD_WriteReg(0x0013, 0x0F00); // VDV[4:0]-->VCOM Amplitude VcomL = VcomH - Vcom Ampl
- LCD_WriteReg(0x002A, 0x0000);
- LCD_WriteReg(0x0029, 0x000A); // 0x0001F Vcomh = VCM1[4:0]*Vreg1out gate source voltage??
- LCD_WriteReg(0x0012, 0x013E); // 0x013C power supply on
- // Coordinates Control//
- LCD_WriteReg(0x0050, 0x0000); // 0x0e00
- LCD_WriteReg(0x0051, 0x00EF);
- LCD_WriteReg(0x0052, 0x0000);
- LCD_WriteReg(0x0053, 0x013F);
- // Pannel Image Control//
- LCD_WriteReg(0x0060, 0x2700);
- LCD_WriteReg(0x0061, 0x0001);
- LCD_WriteReg(0x006A, 0x0000);
- LCD_WriteReg(0x0080, 0x0000);
- // Partial Image Control//
- LCD_WriteReg(0x0081, 0x0000);
- LCD_WriteReg(0x0082, 0x0000);
- LCD_WriteReg(0x0083, 0x0000);
- LCD_WriteReg(0x0084, 0x0000);
- LCD_WriteReg(0x0085, 0x0000);
- // Panel Interface Control//
- LCD_WriteReg(0x0090, 0x0013); // 0x0010 frenqucy
- LCD_WriteReg(0x0092, 0x0300);
- LCD_WriteReg(0x0093, 0x0005);
- LCD_WriteReg(0x0095, 0x0000);
- LCD_WriteReg(0x0097, 0x0000);
- LCD_WriteReg(0x0098, 0x0000);
- LCD_WriteReg(0x0001, 0x0100);
- LCD_WriteReg(0x0002, 0x0700);
- LCD_WriteReg(0x0003, 0x1038); //扫描方向 上->下 左->右
- LCD_WriteReg(0x0004, 0x0000);
- LCD_WriteReg(0x000C, 0x0000);
- LCD_WriteReg(0x000F, 0x0000);
- LCD_WriteReg(0x0020, 0x0000);
- LCD_WriteReg(0x0021, 0x0000);
- LCD_WriteReg(0x0007, 0x0021);
- ms_delay(20);
- LCD_WriteReg(0x0007, 0x0061);
- ms_delay(20);
- LCD_WriteReg(0x0007, 0x0173);
- ms_delay(20);
- }
- else if (lcddev.id == 0xB505)
- {
- LCD_WriteReg(0x0000, 0x0000);
- LCD_WriteReg(0x0000, 0x0000);
- LCD_WriteReg(0x0000, 0x0000);
- LCD_WriteReg(0x0000, 0x0000);
- LCD_WriteReg(0x00a4, 0x0001);
- ms_delay(20);
- LCD_WriteReg(0x0060, 0x2700);
- LCD_WriteReg(0x0008, 0x0202);
- LCD_WriteReg(0x0030, 0x0214);
- LCD_WriteReg(0x0031, 0x3715);
- LCD_WriteReg(0x0032, 0x0604);
- LCD_WriteReg(0x0033, 0x0e16);
- LCD_WriteReg(0x0034, 0x2211);
- LCD_WriteReg(0x0035, 0x1500);
- LCD_WriteReg(0x0036, 0x8507);
- LCD_WriteReg(0x0037, 0x1407);
- LCD_WriteReg(0x0038, 0x1403);
- LCD_WriteReg(0x0039, 0x0020);
- LCD_WriteReg(0x0090, 0x001a);
- LCD_WriteReg(0x0010, 0x0000);
- LCD_WriteReg(0x0011, 0x0007);
- LCD_WriteReg(0x0012, 0x0000);
- LCD_WriteReg(0x0013, 0x0000);
- ms_delay(20);
- LCD_WriteReg(0x0010, 0x0730);
- LCD_WriteReg(0x0011, 0x0137);
- ms_delay(20);
- LCD_WriteReg(0x0012, 0x01b8);
- ms_delay(20);
- LCD_WriteReg(0x0013, 0x0f00);
- LCD_WriteReg(0x002a, 0x0080);
- LCD_WriteReg(0x0029, 0x0048);
- ms_delay(20);
- LCD_WriteReg(0x0001, 0x0100);
- LCD_WriteReg(0x0002, 0x0700);
- LCD_WriteReg(0x0003, 0x1038); //扫描方向 上->下 左->右
- LCD_WriteReg(0x0008, 0x0202);
- LCD_WriteReg(0x000a, 0x0000);
- LCD_WriteReg(0x000c, 0x0000);
- LCD_WriteReg(0x000d, 0x0000);
- LCD_WriteReg(0x000e, 0x0030);
- LCD_WriteReg(0x0050, 0x0000);
- LCD_WriteReg(0x0051, 0x00ef);
- LCD_WriteReg(0x0052, 0x0000);
- LCD_WriteReg(0x0053, 0x013f);
- LCD_WriteReg(0x0060, 0x2700);
- LCD_WriteReg(0x0061, 0x0001);
- LCD_WriteReg(0x006a, 0x0000);
- // LCD_WriteReg(0x0080,0x0000);
- // LCD_WriteReg(0x0081,0x0000);
- LCD_WriteReg(0x0090, 0X0011);
- LCD_WriteReg(0x0092, 0x0600);
- LCD_WriteReg(0x0093, 0x0402);
- LCD_WriteReg(0x0094, 0x0002);
- ms_delay(20);
- LCD_WriteReg(0x0007, 0x0001);
- ms_delay(20);
- LCD_WriteReg(0x0007, 0x0061);
- LCD_WriteReg(0x0007, 0x0173);
- LCD_WriteReg(0x0020, 0x0000);
- LCD_WriteReg(0x0021, 0x0000);
- LCD_WriteReg(0x00, 0x22);
- }
- else if (lcddev.id == 0xC505)
- {
- LCD_WriteReg(0x0000, 0x0000);
- LCD_WriteReg(0x0000, 0x0000);
- ms_delay(20);
- LCD_WriteReg(0x0000, 0x0000);
- LCD_WriteReg(0x0000, 0x0000);
- LCD_WriteReg(0x0000, 0x0000);
- LCD_WriteReg(0x0000, 0x0000);
- LCD_WriteReg(0x00a4, 0x0001);
- ms_delay(20);
- LCD_WriteReg(0x0060, 0x2700);
- LCD_WriteReg(0x0008, 0x0806);
- LCD_WriteReg(0x0030, 0x0703); // gamma setting
- LCD_WriteReg(0x0031, 0x0001);
- LCD_WriteReg(0x0032, 0x0004);
- LCD_WriteReg(0x0033, 0x0102);
- LCD_WriteReg(0x0034, 0x0300);
- LCD_WriteReg(0x0035, 0x0103);
- LCD_WriteReg(0x0036, 0x001F);
- LCD_WriteReg(0x0037, 0x0703);
- LCD_WriteReg(0x0038, 0x0001);
- LCD_WriteReg(0x0039, 0x0004);
- LCD_WriteReg(0x0090, 0x0015); // 80Hz
- LCD_WriteReg(0x0010, 0X0410); // BT,AP
- LCD_WriteReg(0x0011, 0x0247); // DC1,DC0,VC
- LCD_WriteReg(0x0012, 0x01BC);
- LCD_WriteReg(0x0013, 0x0e00);
- ms_delay(120);
- LCD_WriteReg(0x0001, 0x0100);
- LCD_WriteReg(0x0002, 0x0200);
- LCD_WriteReg(0x0003, 0x1030);
- LCD_WriteReg(0x000A, 0x0008);
- LCD_WriteReg(0x000C, 0x0000);
- LCD_WriteReg(0x000E, 0x0020);
- LCD_WriteReg(0x000F, 0x0000);
- LCD_WriteReg(0x0020, 0x0000); // H Start
- LCD_WriteReg(0x0021, 0x0000); // V Start
- LCD_WriteReg(0x002A, 0x003D); // vcom2
- ms_delay(20);
- LCD_WriteReg(0x0029, 0x002d);
- LCD_WriteReg(0x0050, 0x0000);
- LCD_WriteReg(0x0051, 0xD0EF);
- LCD_WriteReg(0x0052, 0x0000);
- LCD_WriteReg(0x0053, 0x013F);
- LCD_WriteReg(0x0061, 0x0000);
- LCD_WriteReg(0x006A, 0x0000);
- LCD_WriteReg(0x0092, 0x0300);
- LCD_WriteReg(0x0093, 0x0005);
- LCD_WriteReg(0x0007, 0x0100);
- }
- else if (lcddev.id == 0x8989) // OK |/|/|
- {
- LCD_WriteReg(0x0000, 0x0001); //打开晶振
- LCD_WriteReg(0x0003, 0xA8A4); // 0xA8A4
- LCD_WriteReg(0x000C, 0x0000);
- LCD_WriteReg(0x000D, 0x080C);
- LCD_WriteReg(0x000E, 0x2B00);
- LCD_WriteReg(0x001E, 0x00B0);
- LCD_WriteReg(0x0001, 0x2B3F); //驱动输出控制320*240 0x6B3F
- LCD_WriteReg(0x0002, 0x0600);
- LCD_WriteReg(0x0010, 0x0000);
- LCD_WriteReg(0x0011, 0x6078); //定义数据格式 16位色 横屏 0x6058
- LCD_WriteReg(0x0005, 0x0000);
- LCD_WriteReg(0x0006, 0x0000);
- LCD_WriteReg(0x0016, 0xEF1C);
- LCD_WriteReg(0x0017, 0x0003);
- LCD_WriteReg(0x0007, 0x0233); // 0x0233
- LCD_WriteReg(0x000B, 0x0000);
- LCD_WriteReg(0x000F, 0x0000); //扫描开始地址
- LCD_WriteReg(0x0041, 0x0000);
- LCD_WriteReg(0x0042, 0x0000);
- LCD_WriteReg(0x0048, 0x0000);
- LCD_WriteReg(0x0049, 0x013F);
- LCD_WriteReg(0x004A, 0x0000);
- LCD_WriteReg(0x004B, 0x0000);
- LCD_WriteReg(0x0044, 0xEF00);
- LCD_WriteReg(0x0045, 0x0000);
- LCD_WriteReg(0x0046, 0x013F);
- LCD_WriteReg(0x0030, 0x0707);
- LCD_WriteReg(0x0031, 0x0204);
- LCD_WriteReg(0x0032, 0x0204);
- LCD_WriteReg(0x0033, 0x0502);
- LCD_WriteReg(0x0034, 0x0507);
- LCD_WriteReg(0x0035, 0x0204);
- LCD_WriteReg(0x0036, 0x0204);
- LCD_WriteReg(0x0037, 0x0502);
- LCD_WriteReg(0x003A, 0x0302);
- LCD_WriteReg(0x003B, 0x0302);
- LCD_WriteReg(0x0023, 0x0000);
- LCD_WriteReg(0x0024, 0x0000);
- LCD_WriteReg(0x0025, 0x8000);
- LCD_WriteReg(0x004f, 0); //行首址0
- LCD_WriteReg(0x004e, 0); //列首址0
- }
- else if (lcddev.id == 0x4531) // OK |/|/|
- {
- LCD_WriteReg(0X00, 0X0001);
- ms_delay(10);
- LCD_WriteReg(0X10, 0X1628);
- LCD_WriteReg(0X12, 0X000e); // 0x0006
- LCD_WriteReg(0X13, 0X0A39);
- ms_delay(10);
- LCD_WriteReg(0X11, 0X0040);
- LCD_WriteReg(0X15, 0X0050);
- ms_delay(10);
- LCD_WriteReg(0X12, 0X001e); // 16
- ms_delay(10);
- LCD_WriteReg(0X10, 0X1620);
- LCD_WriteReg(0X13, 0X2A39);
- ms_delay(10);
- LCD_WriteReg(0X01, 0X0100);
- LCD_WriteReg(0X02, 0X0300);
- LCD_WriteReg(0X03, 0X1038); //改变方向的
- LCD_WriteReg(0X08, 0X0202);
- LCD_WriteReg(0X0A, 0X0008);
- LCD_WriteReg(0X30, 0X0000);
- LCD_WriteReg(0X31, 0X0402);
- LCD_WriteReg(0X32, 0X0106);
- LCD_WriteReg(0X33, 0X0503);
- LCD_WriteReg(0X34, 0X0104);
- LCD_WriteReg(0X35, 0X0301);
- LCD_WriteReg(0X36, 0X0707);
- LCD_WriteReg(0X37, 0X0305);
- LCD_WriteReg(0X38, 0X0208);
- LCD_WriteReg(0X39, 0X0F0B);
- LCD_WriteReg(0X41, 0X0002);
- LCD_WriteReg(0X60, 0X2700);
- LCD_WriteReg(0X61, 0X0001);
- LCD_WriteReg(0X90, 0X0210);
- LCD_WriteReg(0X92, 0X010A);
- LCD_WriteReg(0X93, 0X0004);
- LCD_WriteReg(0XA0, 0X0100);
- LCD_WriteReg(0X07, 0X0001);
- LCD_WriteReg(0X07, 0X0021);
- LCD_WriteReg(0X07, 0X0023);
- LCD_WriteReg(0X07, 0X0033);
- LCD_WriteReg(0X07, 0X0133);
- LCD_WriteReg(0XA0, 0X0000);
- }
- else if (lcddev.id == 0x4535)
- {
- LCD_WriteReg(0X15, 0X0030);
- LCD_WriteReg(0X9A, 0X0010);
- LCD_WriteReg(0X11, 0X0020);
- LCD_WriteReg(0X10, 0X3428);
- LCD_WriteReg(0X12, 0X0002); // 16
- LCD_WriteReg(0X13, 0X1038);
- ms_delay(40);
- LCD_WriteReg(0X12, 0X0012); // 16
- ms_delay(40);
- LCD_WriteReg(0X10, 0X3420);
- LCD_WriteReg(0X13, 0X3038);
- ms_delay(70);
- LCD_WriteReg(0X30, 0X0000);
- LCD_WriteReg(0X31, 0X0402);
- LCD_WriteReg(0X32, 0X0307);
- LCD_WriteReg(0X33, 0X0304);
- LCD_WriteReg(0X34, 0X0004);
- LCD_WriteReg(0X35, 0X0401);
- LCD_WriteReg(0X36, 0X0707);
- LCD_WriteReg(0X37, 0X0305);
- LCD_WriteReg(0X38, 0X0610);
- LCD_WriteReg(0X39, 0X0610);
- LCD_WriteReg(0X01, 0X0100);
- LCD_WriteReg(0X02, 0X0300);
- LCD_WriteReg(0X03, 0X1030); //改变方向的
- LCD_WriteReg(0X08, 0X0808);
- LCD_WriteReg(0X0A, 0X0008);
- LCD_WriteReg(0X60, 0X2700);
- LCD_WriteReg(0X61, 0X0001);
- LCD_WriteReg(0X90, 0X013E);
- LCD_WriteReg(0X92, 0X0100);
- LCD_WriteReg(0X93, 0X0100);
- LCD_WriteReg(0XA0, 0X3000);
- LCD_WriteReg(0XA3, 0X0010);
- LCD_WriteReg(0X07, 0X0001);
- LCD_WriteReg(0X07, 0X0021);
- LCD_WriteReg(0X07, 0X0023);
- LCD_WriteReg(0X07, 0X0033);
- LCD_WriteReg(0X07, 0X0133);
- }
- LCD_Display_Dir(0); //默认为竖屏
- LCD_PWM_HIGH; //点亮背光
- LCD_Clear(WHITE);
- }
- //清屏函数
- // color:要清屏的填充色
- void LCD_Clear(u16 color)
- {
- u32 index = 0;
- u32 totalpoint = lcddev.width;
- totalpoint *= lcddev.height; //得到总点数
- if ((lcddev.id == 0X6804) && (lcddev.dir == 1)) // 6804横屏的时候特殊处理
- {
- lcddev.dir = 0;
- lcddev.setxcmd = 0X2A;
- lcddev.setycmd = 0X2B;
- LCD_SetCursor(0x00, 0x0000); //设置光标位置
- lcddev.dir = 1;
- lcddev.setxcmd = 0X2B;
- lcddev.setycmd = 0X2A;
- }
- else
- LCD_SetCursor(0x00, 0x0000); //设置光标位置
- LCD_WriteRAM_Prepare(); //开始写入GRAM
- for (index = 0; index < totalpoint; index++)
- {
- LCD->LCD_RAM = color;
- }
- }
- //在指定区域内填充单个颜色
- //(sx,sy),(ex,ey):填充矩形对角坐标,区域大小为:(ex-sx+1)*(ey-sy+1)
- // color:要填充的颜色
- void LCD_Fill(u16 sx, u16 sy, u16 ex, u16 ey, u16 color)
- {
- u16 i, j;
- u16 xlen = 0;
- u16 temp;
- if ((lcddev.id == 0X6804) && (lcddev.dir == 1)) // 6804横屏的时候特殊处理
- {
- temp = sx;
- sx = sy;
- sy = lcddev.width - ex - 1;
- ex = ey;
- ey = lcddev.width - temp - 1;
- lcddev.dir = 0;
- lcddev.setxcmd = 0X2A;
- lcddev.setycmd = 0X2B;
- LCD_Fill(sx, sy, ex, ey, color);
- lcddev.dir = 1;
- lcddev.setxcmd = 0X2B;
- lcddev.setycmd = 0X2A;
- }
- else
- {
- xlen = ex - sx + 1;
- for (i = sy; i <= ey; i++)
- {
- LCD_SetCursor(sx, i); //设置光标位置
- LCD_WriteRAM_Prepare(); //开始写入GRAM
- for (j = 0; j < xlen; j++)
- LCD_WR_DATA(color); //设置光标位置
- }
- }
- }
- //在指定区域内填充指定颜色块
- //(sx,sy),(ex,ey):填充矩形对角坐标,区域大小为:(ex-sx+1)*(ey-sy+1)
- // color:要填充的颜色
- void LCD_Color_Fill(u16 sx, u16 sy, u16 ex, u16 ey, u16 *color)
- {
- u16 height, width;
- u16 i, j;
- width = ex - sx + 1; //得到填充的宽度
- height = ey - sy + 1; //高度
- for (i = 0; i < height; i++)
- {
- LCD_SetCursor(sx, sy + i); //设置光标位置
- LCD_WriteRAM_Prepare(); //开始写入GRAM
- for (j = 0; j < width; j++)
- LCD->LCD_RAM = color[i * height + j]; //写入数据
- }
- }
- //画线
- // x1,y1:起点坐标
- // x2,y2:终点坐标
- void LCD_DrawLine(u16 x1, u16 y1, u16 x2, u16 y2)
- {
- u16 t;
- int xerr = 0, yerr = 0, delta_x, delta_y, distance;
- int incx, incy, uRow, uCol;
- delta_x = x2 - x1; //计算坐标增量
- delta_y = y2 - y1;
- uRow = x1;
- uCol = y1;
- if (delta_x > 0)
- incx = 1; //设置单步方向
- else if (delta_x == 0)
- incx = 0; //垂直线
- else
- {
- incx = -1;
- delta_x = -delta_x;
- }
- if (delta_y > 0)
- incy = 1;
- else if (delta_y == 0)
- incy = 0; //水平线
- else
- {
- incy = -1;
- delta_y = -delta_y;
- }
- if (delta_x > delta_y)
- distance = delta_x; //选取基本增量坐标轴
- else
- distance = delta_y;
- for (t = 0; t <= distance + 1; t++) //画线输出
- {
- LCD_DrawPoint(uRow, uCol); //画点
- xerr += delta_x;
- yerr += delta_y;
- if (xerr > distance)
- {
- xerr -= distance;
- uRow += incx;
- }
- if (yerr > distance)
- {
- yerr -= distance;
- uCol += incy;
- }
- }
- }
- //画矩形
- //(x1,y1),(x2,y2):矩形的对角坐标
- void LCD_DrawRectangle(u16 x1, u16 y1, u16 x2, u16 y2)
- {
- LCD_DrawLine(x1, y1, x2, y1);
- LCD_DrawLine(x1, y1, x1, y2);
- LCD_DrawLine(x1, y2, x2, y2);
- LCD_DrawLine(x2, y1, x2, y2);
- }
- //在指定位置画一个指定大小的圆
- //(x,y):中心点
- // r :半径
- void Draw_Circle(u16 x0, u16 y0, u8 r)
- {
- int a, b;
- int di;
- a = 0;
- b = r;
- di = 3 - (r << 1); //判断下个点位置的标志
- while (a <= b)
- {
- LCD_DrawPoint(x0 + a, y0 - b); // 5
- LCD_DrawPoint(x0 + b, y0 - a); // 0
- LCD_DrawPoint(x0 + b, y0 + a); // 4
- LCD_DrawPoint(x0 + a, y0 + b); // 6
- LCD_DrawPoint(x0 - a, y0 + b); // 1
- LCD_DrawPoint(x0 - b, y0 + a);
- LCD_DrawPoint(x0 - a, y0 - b); // 2
- LCD_DrawPoint(x0 - b, y0 - a); // 7
- a++;
- //使用Bresenham算法画圆
- if (di < 0)
- di += 4 * a + 6;
- else
- {
- di += 10 + 4 * (a - b);
- b--;
- }
- }
- }
- //在指定位置显示一个字符
- // x,y:起始坐标
- // num:要显示的字符:" "--->"~"
- // size:字体大小 12/16
- // mode:叠加方式(1)还是非叠加方式(0)
- void LCD_ShowChar(u16 x, u16 y, u8 num, u8 size, u8 mode)
- {
- u8 temp, t1, t;
- u16 y0 = y;
- u16 colortemp = POINT_COLOR;
- //设置窗口
- num = num - ' '; //得到偏移后的值
- if (!mode) //非叠加方式
- {
- for (t = 0; t < size; t++)
- {
- if (size == 12)
- temp = asc2_1206[num][t]; //调用1206字体
- else
- temp = asc2_1608[num][t]; //调用1608字体
- for (t1 = 0; t1 < 8; t1++)
- {
- if (temp & 0x80)
- POINT_COLOR = colortemp;
- else
- POINT_COLOR = BACK_COLOR;
- LCD_DrawPoint(x, y);
- temp <<= 1;
- y++;
- if (x >= lcddev.width)
- {
- POINT_COLOR = colortemp;
- return;
- } //超区域了
- if ((y - y0) == size)
- {
- y = y0;
- x++;
- if (x >= lcddev.width)
- {
- POINT_COLOR = colortemp;
- return;
- } //超区域了
- break;
- }
- }
- }
- }
- else //叠加方式
- {
- for (t = 0; t < size; t++)
- {
- if (size == 12)
- temp = asc2_1206[num][t]; //调用1206字体
- else
- temp = asc2_1608[num][t]; //调用1608字体
- for (t1 = 0; t1 < 8; t1++)
- {
- if (temp & 0x80)
- LCD_DrawPoint(x, y);
- temp <<= 1;
- y++;
- if (x >= lcddev.height)
- {
- POINT_COLOR = colortemp;
- return;
- } //超区域了
- if ((y - y0) == size)
- {
- y = y0;
- x++;
- if (x >= lcddev.width)
- {
- POINT_COLOR = colortemp;
- return;
- } //超区域了
- break;
- }
- }
- }
- }
- POINT_COLOR = colortemp;
- }
- // m^n函数
- //返回值:m^n次方.
- u32 LCD_Pow(u8 m, u8 n)
- {
- u32 result = 1;
- while (n--)
- result *= m;
- return result;
- }
- //显示数字,高位为0,则不显示
- // x,y :起点坐标
- // len :数字的位数
- // size:字体大小
- // color:颜色
- // num:数值(0~4294967295);
- void LCD_ShowNum(u16 x, u16 y, u32 num, u8 len, u8 size)
- {
- u8 t, temp;
- u8 enshow = 0;
- for (t = 0; t < len; t++)
- {
- temp = (num / LCD_Pow(10, len - t - 1)) % 10;
- if (enshow == 0 && t < (len - 1))
- {
- if (temp == 0)
- {
- LCD_ShowChar(x + (size / 2) * t, y, ' ', size, 0);
- continue;
- }
- else
- enshow = 1;
- }
- LCD_ShowChar(x + (size / 2) * t, y, temp + '0', size, 0);
- }
- }
- //显示数字,高位为0,还是显示
- // x,y:起点坐标
- // num:数值(0~999999999);
- // len:长度(即要显示的位数)
- // size:字体大小
- // mode:
- //[7]:0,不填充;1,填充0.
- //[6:1]:保留
- //[0]:0,非叠加显示;1,叠加显示.
- void LCD_ShowxNum(u16 x, u16 y, u32 num, u8 len, u8 size, u8 mode)
- {
- u8 t, temp;
- u8 enshow = 0;
- for (t = 0; t < len; t++)
- {
- temp = (num / LCD_Pow(10, len - t - 1)) % 10;
- if (enshow == 0 && t < (len - 1))
- {
- if (temp == 0)
- {
- if (mode & 0X80)
- LCD_ShowChar(x + (size / 2) * t, y, '0', size, mode & 0X01);
- else
- LCD_ShowChar(x + (size / 2) * t, y, ' ', size, mode & 0X01);
- continue;
- }
- else
- enshow = 1;
- }
- LCD_ShowChar(x + (size / 2) * t, y, temp + '0', size, mode & 0X01);
- }
- }
- //显示字符串
- // x,y:起点坐标
- // width,height:区域大小
- // size:字体大小
- //*p:字符串起始地址
- void LCD_ShowString(u16 x, u16 y, u16 width, u16 height, u8 size, u8 *p)
- {
- u8 x0 = x;
- width += x;
- height += y;
- while ((*p <= '~') && (*p >= ' ')) //判断是不是非法字符!
- {
- if (x >= width)
- {
- x = x0;
- y += size;
- }
- if (y >= height)
- break; //退出
- LCD_ShowChar(x, y, *p, size, 0);
- x += size / 2;
- p++;
- }
- }
|