4.移植ucGui
来源:互联网 发布:国企私有化 知乎 编辑:程序博客网 时间:2024/06/06 00:53
提醒:
如果您是完全按照前面的步骤来新建的工程的话,那很遗憾,你要重新建立一个工程,因为,在前面的文章中,我们选中了GPIO和USART,但是这里我们还需要用到SPI和FSMC,所以要新建一个工程,只是要把GPIO、USART、SPI和FSMC都选中(不知道是不是也应该顺便把EXTI也选中)
其实我很想到官方下载最新的ucGui版本来移植,可惜只能下载到库,据说现在ucGui已经不开源了,我也是刚接触,江湖上的事就不了解了
从朋友那里获取到一个ucGui的3.98版本,就用这个来移植了,在工程中新建如下文件夹:
复制ucgui3.98\Micrium\Software\uC-GUI\Start\GUI目录下的各目录到工程中,并把GUI的各文件添加到工程中,并加入Include Path中,其中GUI_X目录复制ucgui3.98\Micrium\Software\uC-GUI\Sample\GUI_X目录下的GUI_X_Touch.c和GUI_X_uCOS.c
另需要把ucgui3.98\Micrium\Software\uC-GUI\Start\Config目录复制到工程中并添加到Include Path下
然后编译,会报错,执行如下修改:
把OS_X_Delay(1);替换为OSTimeDly(50);,把TRUE替换为1.FALSE替换为0
把同目录下的GUI_X.c文件的最后三行,复制到GUI_X_uCOS.c文件中,再编译,即可编译通过
好,上面是准备工作,下面开始移植...........
先肯定是修改BSP.c文件,BSP_Init方法中加上调用 FSMC_LCD_Init();
void FSMC_LCD_Init(void){FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure;FSMC_NORSRAMTimingInitTypeDef p;GPIO_InitTypeDef GPIO_InitStructure; RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE , ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;GPIO_Init(GPIOD, &GPIO_InitStructure);GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;GPIO_Init(GPIOE, &GPIO_InitStructure); // ¸´Óö˿ÚΪFSMC½Ó¿Ú FSMC-D0--D15GPIO_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;GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;GPIO_Init(GPIOD, &GPIO_InitStructure); 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;GPIO_Init(GPIOE, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7; GPIO_Init(GPIOD, &GPIO_InitStructure);GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 ; GPIO_Init(GPIOD, &GPIO_InitStructure); GPIO_SetBits(GPIOD, GPIO_Pin_13); //LCD±³¹â´ò¿ªp.FSMC_AddressSetupTime = 0x02;p.FSMC_AddressHoldTime = 0x00;p.FSMC_DataSetupTime = 0x05;p.FSMC_BusTurnAroundDuration = 0x00;p.FSMC_CLKDivision = 0x00;p.FSMC_DataLatency = 0x00;p.FSMC_AccessMode = FSMC_AccessMode_B;FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1;FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_NOR;FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p;FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p;FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); /* Enable FSMC Bank1_SRAM Bank */FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE);}
然后在GUI\LCDDriver目录下添加文件lcddriver.c:
#include "lcddriver.h"#define Bank1_LCD_D ((uint32_t)0x60020000) //ÏÔʾÇøÊý¾ÝµØÖ· #define Bank1_LCD_C ((uint32_t)0x60000000) //ÏÔʾÇøÖ¸ÁîµØÖ·void Delay(__IO uint32_t nCount){ for(; nCount != 0; nCount--);}void LCD_WR_CMD(unsigned int index,unsigned int val){*(__IO uint16_t *) (Bank1_LCD_C)= index;*(__IO uint16_t *) (Bank1_LCD_D)= val;}//д16λÏñËØÊý¾Ýº¯Êývoid LCD_WR_Data(unsigned int val){ *(__IO uint16_t *) (Bank1_LCD_D)= val; }void LCD_Init_realize(void){unsigned int i;GPIO_ResetBits(GPIOE, GPIO_Pin_1); //Ó²¼þ¸´Î»Delay(0x1AFFf); GPIO_SetBits(GPIOE, GPIO_Pin_1 ); Delay(0x1AFFf);LCD_WR_CMD(0x0000, 0x00000);LCD_WR_CMD(0x0000, 0x00000);LCD_WR_CMD(0x0000, 0x00000);LCD_WR_CMD(0x0000, 0x00000);LCD_WR_CMD(0x0400, 0x06200);LCD_WR_CMD(0x0008, 0x00808);LCD_WR_CMD(0x0300, 0x00C00);//gammaLCD_WR_CMD(0x0301, 0x05A0B);LCD_WR_CMD(0x0302, 0x00906);LCD_WR_CMD(0x0303, 0x01017);LCD_WR_CMD(0x0304, 0x02300);LCD_WR_CMD(0x0305, 0x01700);LCD_WR_CMD(0x0306, 0x06309);LCD_WR_CMD(0x0307, 0x00C09);LCD_WR_CMD(0x0308, 0x0100C);LCD_WR_CMD(0x0309, 0x02232);LCD_WR_CMD(0x0010, 0x00016);//69.5HzLCD_WR_CMD(0x0011, 0x00101);//LCD_WR_CMD(0x0012, 0x00000);//LCD_WR_CMD(0x0013, 0x00001);//LCD_WR_CMD(0x0100, 0x00330);//BT,APLCD_WR_CMD(0x0101, 0x00237);//DC0,DC1,VCLCD_WR_CMD(0x0103, 0x00F00);//VDVLCD_WR_CMD(0x0280, 0x06100);//VCMLCD_WR_CMD(0x0102, 0x0C1B0);//VRH,VCMR,PSON,PONLCD_WR_CMD(0x0001, 0x00100);LCD_WR_CMD(0x0002, 0x00100);LCD_WR_CMD(0x0003, 0x01030);LCD_WR_CMD(0x0009, 0x00001);LCD_WR_CMD(0x000C, 0x00000);LCD_WR_CMD(0x0090, 0x08000);LCD_WR_CMD(0x000F, 0x00000);LCD_WR_CMD(0x0210, 0x00000);LCD_WR_CMD(0x0211, 0x000EF);LCD_WR_CMD(0x0212, 0x00000);LCD_WR_CMD(0x0213, 0x0018F);//432=1AF, 400=18FLCD_WR_CMD(0x0500, 0x00000);LCD_WR_CMD(0x0501, 0x00000);LCD_WR_CMD(0x0502, 0x0005F);LCD_WR_CMD(0x0401, 0x00001);LCD_WR_CMD(0x0404, 0x00000);LCD_WR_CMD(0x0007, 0x00100);//BASEELCD_WR_CMD(0x0200, 0x00000);LCD_WR_CMD(0x0201, 0x00000);LCD_WR_CMD(0x200, 0);LCD_WR_CMD(0x201, 0);*(__IO uint16_t *) (Bank1_LCD_C)= 0x202; //×¼±¸Ð´Êý¾ÝÏÔʾÇøfor(i=0;i<96000;i++){LCD_WR_Data(0xffff); //ÓúÚÉ«ÇåÆÁ} }void LCD_WR_REG(unsigned int index){*(__IO uint16_t *) (Bank1_LCD_C)= index;}unsigned int LCD_RD_data(void){unsigned int a=0;a=*(__IO uint16_t *) (Bank1_LCD_D); //¿Õ²Ù×÷a=*(__IO uint16_t *) (Bank1_LCD_D); //¶Á³öµÄʵ¼Ê16λÏñËØÊý¾Ý return(a);}void lcd_SetPoint(u16 StartX,u16 StartY,u16 Color){LCD_WR_CMD(0x0003,0x1018);LCD_WR_CMD(0x0210, StartY);LCD_WR_CMD(0x0211, StartY);LCD_WR_CMD(0x0212, 399-StartX);LCD_WR_CMD(0x0213, 399-StartX);LCD_WR_CMD(0x0200, StartY);LCD_WR_CMD(0x0201, 399-StartX);LCD_WR_REG(0x0202);LCD_WR_Data(Color);}void GUI_Line(u16 x0,u16 y0,u16 x1,u16 y1,u16 color){ u16 x,y; u16 dx;// = abs(x1 - x0); u16 dy;// = abs(y1 - y0);if(y0==y1){if(x0<=x1){x=x0;}else{x=x1;x1=x0;} while(x <= x1) { lcd_SetPoint(x,y0,color); x++; } return;}else if(y0>y1){dy=y0-y1;}else{dy=y1-y0;} if(x0==x1){if(y0<=y1){y=y0;}else{y=y1;y1=y0;} while(y <= y1) { lcd_SetPoint(x0,y,color); y++; } return;}else if(x0 > x1) {dx=x0-x1; x = x1; x1 = x0; y = y1; y1 = y0; } else {dx=x1-x0; x = x0; y = y0; } if(dx == dy) { while(x <= x1) { x++;if(y>y1){y--;}else{ y++;} lcd_SetPoint(x,y,color); } } else { lcd_SetPoint(x, y, color); if(y < y1) { if(dx > dy) { s16 p = dy * 2 - dx; s16 twoDy = 2 * dy; s16 twoDyMinusDx = 2 * (dy - dx); while(x < x1) { x++; if(p < 0) { p += twoDy; } else { y++; p += twoDyMinusDx; } lcd_SetPoint(x, y,color); } } else { s16 p = dx * 2 - dy; s16 twoDx = 2 * dx; s16 twoDxMinusDy = 2 * (dx - dy); while(y < y1) { y++; if(p < 0) { p += twoDx; } else { x++; p+= twoDxMinusDy; } lcd_SetPoint(x, y, color); } } } else { if(dx > dy) { s16 p = dy * 2 - dx; s16 twoDy = 2 * dy; s16 twoDyMinusDx = 2 * (dy - dx); while(x < x1) { x++; if(p < 0) { p += twoDy; } else { y--; p += twoDyMinusDx; } lcd_SetPoint(x, y,color); } } else { s16 p = dx * 2 - dy; s16 twoDx = 2 * dx; s16 twoDxMinusDy = 2 * (dx - dy); while(y1 < y) { y--; if(p < 0) { p += twoDx; } else { x++; p+= twoDxMinusDy; } lcd_SetPoint(x, y,color); } } } }}void DrawBitLine1BPP(int x, int y, u8 const*p, int Diff, int xsize, const LCD_PIXELINDEX*pTrans){ LCD_PIXELINDEX pixels; LCD_PIXELINDEX Index0 = *(pTrans+0); LCD_PIXELINDEX Index1 = *(pTrans+1);/*// Jump to right entry point*/ pixels = *p; switch (GUI_Context.DrawMode & (LCD_DRAWMODE_TRANS|LCD_DRAWMODE_XOR)) { case 0: #if defined (SETNEXTPIXEL) /* Optimization ! */ x+=Diff; ili9320_SetCursor(x,y); #endif switch (Diff&7) { case 0: goto WriteBit0; case 1: goto WriteBit1; case 2: goto WriteBit2; case 3: goto WriteBit3; case 4: goto WriteBit4; case 5: goto WriteBit5; case 6: goto WriteBit6; case 7: goto WriteBit7; } break; case LCD_DRAWMODE_TRANS: switch (Diff&7) { case 0: goto WriteTBit0; case 1: goto WriteTBit1; case 2: goto WriteTBit2; case 3: goto WriteTBit3; case 4: goto WriteTBit4; case 5: goto WriteTBit5; case 6: goto WriteTBit6; case 7: goto WriteTBit7; } break; case LCD_DRAWMODE_XOR: switch (Diff&7) { case 0: goto WriteXBit0; case 1: goto WriteXBit1; case 2: goto WriteXBit2; case 3: goto WriteXBit3; case 4: goto WriteXBit4; case 5: goto WriteXBit5; case 6: goto WriteXBit6; case 7: goto WriteXBit7; } }/* Write with transparency*/ WriteTBit0: if (pixels&(1<<7)) lcd_SetPoint(x+0, y, Index1); if (!--xsize) return; WriteTBit1: if (pixels&(1<<6)) lcd_SetPoint(x+1, y, Index1); if (!--xsize) return; WriteTBit2: if (pixels&(1<<5)) lcd_SetPoint(x+2, y, Index1); if (!--xsize) return; WriteTBit3: if (pixels&(1<<4)) lcd_SetPoint(x+3, y, Index1); if (!--xsize) return; WriteTBit4: if (pixels&(1<<3)) lcd_SetPoint(x+4, y, Index1); if (!--xsize) return; WriteTBit5: if (pixels&(1<<2)) lcd_SetPoint(x+5, y, Index1); if (!--xsize) return; WriteTBit6: if (pixels&(1<<1)) lcd_SetPoint(x+6, y, Index1); if (!--xsize) return; WriteTBit7: if (pixels&(1<<0)) lcd_SetPoint(x+7, y, Index1); if (!--xsize) return; x+=8; pixels = *(++p); goto WriteTBit0;/* Write without transparency*/ WriteBit0: lcd_SetPoint(x+0, y, (pixels&(1<<7)) ? Index1 : Index0); if (!--xsize) return; WriteBit1: lcd_SetPoint(x+1, y, (pixels&(1<<6)) ? Index1 : Index0); if (!--xsize) return; WriteBit2: lcd_SetPoint(x+2, y, (pixels&(1<<5)) ? Index1 : Index0); if (!--xsize) return; WriteBit3: lcd_SetPoint(x+3, y, (pixels&(1<<4)) ? Index1 : Index0); if (!--xsize) return; WriteBit4: lcd_SetPoint(x+4, y, (pixels&(1<<3)) ? Index1 : Index0); if (!--xsize) return; WriteBit5: lcd_SetPoint(x+5, y, (pixels&(1<<2)) ? Index1 : Index0); if (!--xsize) return; WriteBit6: lcd_SetPoint(x+6, y, (pixels&(1<<1)) ? Index1 : Index0); if (!--xsize) return; WriteBit7: lcd_SetPoint(x+7, y, (pixels&(1<<0)) ? Index1 : Index0); if (!--xsize) return; x+=8; pixels = *(++p); goto WriteBit0;/* Write XOR mode*/ WriteXBit0: if (pixels&(1<<7)) LCD_L0_XorPixel(x+0, y); if (!--xsize) return; WriteXBit1: if (pixels&(1<<6)) LCD_L0_XorPixel(x+1, y); if (!--xsize) return; WriteXBit2: if (pixels&(1<<5)) LCD_L0_XorPixel(x+2, y); if (!--xsize) return; WriteXBit3: if (pixels&(1<<4)) LCD_L0_XorPixel(x+3, y); if (!--xsize) return; WriteXBit4: if (pixels&(1<<3)) LCD_L0_XorPixel(x+4, y); if (!--xsize) return; WriteXBit5: if (pixels&(1<<2)) LCD_L0_XorPixel(x+5, y); if (!--xsize) return; WriteXBit6: if (pixels&(1<<1)) LCD_L0_XorPixel(x+6, y); if (!--xsize) return; WriteXBit7: if (pixels&(1<<0)) LCD_L0_XorPixel(x+7, y); if (!--xsize) return; x+=8; pixels = *(++p); goto WriteXBit0;}void DrawBitLine2BPP(int x, int y, U8 const*p, int Diff, int xsize, const LCD_PIXELINDEX*pTrans) { LCD_PIXELINDEX pixels;/*// Jump to right entry point*/ pixels = *p; if (pTrans) { /* with palette */ if (GUI_Context.DrawMode & LCD_DRAWMODE_TRANS) switch (Diff&3) { case 0: goto WriteTBit0; case 1: goto WriteTBit1; case 2: goto WriteTBit2; default: goto WriteTBit3; } else switch (Diff&3) { case 0: goto WriteBit0; case 1: goto WriteBit1; case 2: goto WriteBit2; default: goto WriteBit3; } /* Write without transparency */ WriteBit0: lcd_SetPoint(x+0, y, *(pTrans+(pixels>>6))); if (!--xsize) return; WriteBit1: lcd_SetPoint(x+1, y, *(pTrans+(3&(pixels>>4)))); if (!--xsize) return; WriteBit2: lcd_SetPoint(x+2, y, *(pTrans+(3&(pixels>>2)))); if (!--xsize) return; WriteBit3: lcd_SetPoint(x+3, y, *(pTrans+(3&(pixels)))); if (!--xsize) return; pixels = *(++p); x+=4; goto WriteBit0; /* Write with transparency */ WriteTBit0: if (pixels&(3<<6)) lcd_SetPoint(x+0, y, *(pTrans+(pixels>>6))); if (!--xsize) return; WriteTBit1: if (pixels&(3<<4)) lcd_SetPoint(x+1, y, *(pTrans+(3&(pixels>>4)))); if (!--xsize) return; WriteTBit2: if (pixels&(3<<2)) lcd_SetPoint(x+2, y, *(pTrans+(3&(pixels>>2)))); if (!--xsize) return; WriteTBit3: if (pixels&(3<<0)) lcd_SetPoint(x+3, y, *(pTrans+(3&(pixels)))); if (!--xsize) return; pixels = *(++p); x+=4; goto WriteTBit0; } else { /* without palette */ if (GUI_Context.DrawMode & LCD_DRAWMODE_TRANS) switch (Diff&3) { case 0: goto WriteDDPTBit0; case 1: goto WriteDDPTBit1; case 2: goto WriteDDPTBit2; default: goto WriteDDPTBit3; } else switch (Diff&3) { case 0: goto WriteDDPBit0; case 1: goto WriteDDPBit1; case 2: goto WriteDDPBit2; default: goto WriteDDPBit3; } /* Write without transparency */ WriteDDPBit0: lcd_SetPoint(x+0, y, (pixels>>6)); if (!--xsize) return; WriteDDPBit1: lcd_SetPoint(x+1, y, (3&(pixels>>4))); if (!--xsize) return; WriteDDPBit2: lcd_SetPoint(x+2, y, (3&(pixels>>2))); if (!--xsize) return; WriteDDPBit3: lcd_SetPoint(x+3, y, (3&(pixels))); if (!--xsize) return; pixels = *(++p); x+=4; goto WriteDDPBit0; /* Write with transparency */ WriteDDPTBit0: if (pixels&(3<<6)) lcd_SetPoint(x+0, y, (pixels>>6)); if (!--xsize) return; WriteDDPTBit1: if (pixels&(3<<4)) lcd_SetPoint(x+1, y, (3&(pixels>>4))); if (!--xsize) return; WriteDDPTBit2: if (pixels&(3<<2)) lcd_SetPoint(x+2, y, (3&(pixels>>2))); if (!--xsize) return; WriteDDPTBit3: if (pixels&(3<<0)) lcd_SetPoint(x+3, y, (3&(pixels))); if (!--xsize) return; pixels = *(++p); x+=4; goto WriteDDPTBit0; }}void DrawBitLine4BPP(int x, int y, U8 const*p, int Diff, int xsize, const LCD_PIXELINDEX*pTrans){ LCD_PIXELINDEX pixels; pixels = *p; if (pTrans) { if (GUI_Context.DrawMode & LCD_DRAWMODE_TRANS) { if ((Diff&1) ==0) goto WriteTBit0; goto WriteTBit1; } else { if ((Diff&1) ==0) goto WriteBit0; goto WriteBit1; } WriteBit0: lcd_SetPoint(x+0, y, *(pTrans+(pixels>>4))); if (!--xsize) return; WriteBit1: lcd_SetPoint(x+1, y, *(pTrans+(pixels&0xf))); if (!--xsize) return; x+=2; pixels = *(++p); goto WriteBit0; /* Write with transparency */ WriteTBit0: if (pixels>>4) lcd_SetPoint(x+0, y, *(pTrans+(pixels>>4))); if (!--xsize) return; WriteTBit1: if (pixels&0xf) lcd_SetPoint(x+1, y, *(pTrans+(pixels&0xf))); if (!--xsize) return; x+=2; pixels = *(++p); goto WriteTBit0; } else { /* without palette */ if (GUI_Context.DrawMode & LCD_DRAWMODE_TRANS) { if ((Diff&1) ==0) goto WriteDDPTBit0; goto WriteDDPTBit1; } else { if ((Diff&1) ==0) goto WriteDDPBit0; goto WriteDDPBit1; } /* Write without transparency */ WriteDDPBit0: lcd_SetPoint(x+0, y, (pixels>>4)); if (!--xsize) return; WriteDDPBit1: lcd_SetPoint(x+1, y, (pixels&0xf)); if (!--xsize) return; x+=2; pixels = *(++p); goto WriteDDPBit0; /* Write with transparency */ WriteDDPTBit0: if (pixels>>4) lcd_SetPoint(x+0, y, (pixels>>4)); if (!--xsize) return; WriteDDPTBit1: if (pixels&0xf) lcd_SetPoint(x+1, y, (pixels&0xf)); if (!--xsize) return; x+=2; pixels = *(++p); goto WriteDDPTBit0; }}void DrawBitLine8BPP(int x, int y, U8 const*p, int xsize, const LCD_PIXELINDEX*pTrans) { LCD_PIXELINDEX pixel; if ((GUI_Context.DrawMode & LCD_DRAWMODE_TRANS)==0) { if (pTrans) { for (;xsize > 0; xsize--,x++,p++) { pixel = *p; lcd_SetPoint(x, y, *(pTrans+pixel)); } } else { for (;xsize > 0; xsize--,x++,p++) { lcd_SetPoint(x, y, *p); } } } else { /* Handle transparent bitmap */ if (pTrans) { for (; xsize > 0; xsize--, x++, p++) { pixel = *p; if (pixel) { lcd_SetPoint(x+0, y, *(pTrans+pixel)); } } } else { for (; xsize > 0; xsize--, x++, p++) { pixel = *p; if (pixel) { lcd_SetPoint(x+0, y, pixel); } } } }}void DrawBitLine16BPP(int x, int y, U16 const*p, int xsize){ LCD_PIXELINDEX Index; if ((GUI_Context.DrawMode & LCD_DRAWMODE_TRANS)==0) { for (;xsize > 0; xsize--,x++,p++) { lcd_SetPoint(x, y, *p); } } else { /* Handle transparent bitmap */ for (; xsize > 0; xsize--, x++, p++) { Index = *p; if (Index) { lcd_SetPoint(x+0, y, Index); } } }}
当然了,最核心的就是方法LCD_Init_realize和lcd_SetPoint,只要能画点,其他就好办了
并添加lcddriver.h文件:
#ifndef __LCDCONFIG_H__#define __LCDCONFIG_H__#include "stm32f10x_gpio.h"#include <LCD_ConfDefaults.h>#include <LCD.h>#include "GUI_Private.h"void lcd_SetPoint(u16 StartX,u16 StartY,u16 Color);void GUI_Line(u16 x0,u16 y0,u16 x1,u16 y1,u16);void LCD_Init_realize(void);void DrawBitLine1BPP(int x, int y, u8 const*p, int Diff, int xsize, const LCD_PIXELINDEX*pTrans);void DrawBitLine2BPP(int x, int y, U8 const*p, int Diff, int xsize, const LCD_PIXELINDEX*pTrans);void DrawBitLine4BPP(int x, int y, U8 const*p, int Diff, int xsize, const LCD_PIXELINDEX*pTrans);void DrawBitLine8BPP(int x, int y, U8 const*p, int xsize, const LCD_PIXELINDEX*pTrans);void DrawBitLine16BPP(int x, int y, U16 const*p, int xsize);#endif
修改配置文件LCDConf.h
#ifndef LCDCONF_H#define LCDCONF_H#define LCD_XSIZE (400)#define LCD_YSIZE (240)#define LCD_CONTROLLER (9320)#define LCD_BITSPERPIXEL (16)#define LCD_FIXEDPALETTE (565)#define LCD_SWAP_RB (1)//#define LCD_SWAP_XY (1)#define LCD_INIT_CONTROLLER() LCD_Init_realize()#endif /* LCDCONF_H */
和配置文件GUIConf.h
#ifndef GUICONF_H#define GUICONF_H#define GUI_OS (1) /* Compile with multitasking support */#define GUI_SUPPORT_TOUCH (0) /* Support a touch screen (req. win-manager) */#define GUI_SUPPORT_UNICODE (1) /* Support mixed ASCII/UNICODE strings */#define GUI_DEFAULT_FONT &GUI_Font6x8#define GUI_ALLOC_SIZE 8000 /* Size of dynamic memory ... For WM and memory devices*//*********************************************************************** Configuration of available packages*/#define GUI_WINSUPPORT 1 /* Window manager package available */#define GUI_SUPPORT_MEMDEV 1 /* Memory devices available */#define GUI_SUPPORT_AA 1 /* Anti aliasing available */#endif /* Avoid multiple inclusion */
修改LCDNull.c文件
#include <stddef.h>#include "LCD_Private.h" /* private modul definitions & config */#include "GUI_Private.h"#include "GUIDebug.h"#include "lcddriver.h"#if (LCD_CONTROLLER == 9320)/*********************************************************************** Exported functions************************************************************************//*********************************************************************** LCD_L0_SetPixelIndex*/void LCD_L0_SetPixelIndex(int x, int y, int PixelIndex) { lcd_SetPoint(x,y,PixelIndex);}/*********************************************************************** LCD_L0_GetPixelIndex*/unsigned int LCD_L0_GetPixelIndex(int x, int y) {return 1;}/*********************************************************************** LCD_L0_XorPixel*/void LCD_L0_XorPixel(int x, int y) { return;}/*********************************************************************** LCD_L0_DrawHLine*/void LCD_L0_DrawHLine(int x0, int y, int x1) { GUI_Line(x0,y,x1,y,LCD_COLORINDEX);}/*********************************************************************** LCD_L0_DrawVLine*/void LCD_L0_DrawVLine(int x, int y0, int y1) { GUI_Line(x,y0,x,y1,LCD_COLORINDEX);}/*********************************************************************** LCD_L0_FillRect*/void LCD_L0_FillRect(int x0, int y0, int x1, int y1) {#if !LCD_SWAP_XY for (; y0 <= y1; y0++) { LCD_L0_DrawHLine(x0,y0, x1); }#else for (; x0 <= x1; x0++) { LCD_L0_DrawVLine(x0,y0, y1); }#endif}/*********************************************************************** LCD_L0_DrawBitmap*/void LCD_L0_DrawBitmap(int x0, int y0, int xsize, int ysize, int BitsPerPixel, int BytesPerLine, const U8 GUI_UNI_PTR * pData, int Diff, const LCD_PIXELINDEX* pTrans){int i;switch (BitsPerPixel){case 1:for (i=0; i<ysize; i++){DrawBitLine1BPP(x0, i+y0, pData, Diff, xsize, pTrans);pData += BytesPerLine;}break;case 2:for (i=0; i<ysize; i++){DrawBitLine2BPP(x0, i+y0, pData, Diff, xsize, pTrans);pData += BytesPerLine;}break;case 4:for (i=0; i<ysize; i++){DrawBitLine4BPP(x0, i+y0, pData, Diff, xsize, pTrans);pData += BytesPerLine;}break;case 8:for (i=0; i<ysize; i++){DrawBitLine8BPP(x0, i+y0, pData, xsize, pTrans);pData += BytesPerLine;}break;case 16:for (i=0; i<ysize; i++){DrawBitLine16BPP(x0, i+y0, (U16*)pData, xsize);pData += BytesPerLine;}break;}}/*********************************************************************** LCD_L0_SetOrg*/void LCD_L0_SetOrg(int x, int y) { GUI_USE_PARA(x); GUI_USE_PARA(y);}/*********************************************************************** LCD_On / LCD_Off*/void LCD_On (void) {}void LCD_Off(void) {}/*********************************************************************** LCD_L0_Init*/int LCD_L0_Init(void) { LCD_Init_realize(); return 0;}/*********************************************************************** LCD_L0_SetLUTEntry*/void LCD_L0_SetLUTEntry(U8 Pos, LCD_COLOR Color) { GUI_USE_PARA(Pos); GUI_USE_PARA(Color);}/*********************************************************************** LCD_L0_GetDevFunc*/void * LCD_L0_GetDevFunc(int Index) { GUI_USE_PARA(Index); return NULL;}#elsevoid LCDNull_c(void);void LCDNull_c(void) {} /* avoid empty object files */#endif /* (LCD_CONTROLLER == -2) */
至此,移植就算完成了,下面是测试程序,如我们可以在main方法中添加命令:
#include <GUI.h>
GUI_Init(); //初始化GUI GUI_DispString("welcome");
就可以在屏幕上看到字符welcome了
如果我们修改下串口的中断方法:
stm32f10x_it.c文件:
void USART1_IRQHandler(void){unsigned int i;unsigned char msg[50];OS_CPU_SR cpu_sr;OS_ENTER_CRITICAL();OSIntNesting++;OS_EXIT_CRITICAL();if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET){if(RxCounter1>20)RxCounter1=1;// Read one byte from the receive data register msg[RxCounter1++]= USART_ReceiveData(USART1);SendChar(msg[RxCounter1-1]);GUI_DispChar(msg[RxCounter1-1]); //将接收到的字符输出到屏幕上if(msg[RxCounter1-1]=='\r') //如果接收到回车,就添加一个换行GUI_DispChar('\n');if(msg[RxCounter1-1]=='L'){msg[0]='L'; RxCounter1=1;}else if(msg[RxCounter1-1]=='F'){for(i=0; i< RxCounter1; i++){TxBuffer1[i]=msg[i];}TxBuffer1[RxCounter1]=0;RxCounter1=0;//OSSemPost(Com1_SEM); OSMboxPost(Com1_MBOX,(void *)&msg); }}if(USART_GetITStatus(USART1, USART_IT_TXE) != RESET) // { USART_ITConfig(USART1, USART_IT_TXE, DISABLE);}OSIntExit();}
那么,我们在终端每输入一个字符,即可在LCD上看到,并支持回车
本程序在奋斗V5开发板上测试通过,字符可以显示了,那么其他文本框之类的我还没有尝试,应该没有问题
- 4.移植ucGui
- ucgui 移植
- ucGUI 移植
- ucGUI移植
- ucgui移植
- ucGUI移植
- UCGUI移植
- 移植UCGUI 调试笔记
- 移植ucGUI到s3c2440
- ucgui移植记录
- ucgui移植LPC2478
- FL2440_uCOS-II+ucGUI移植
- UCGUI 移植 STM32 带触屏
- ucGUI 移植详解
- ucgui 移植(裸奔)
- stm32f4移植ucgui
- stm32 UCGUI 完美移植
- UCGUI的移植
- MySQL中DATETIME、DATE和TIMESTAMP的区别
- 在Ubuntu14.04下配置jdk1.7
- Entity Framework With Oracle
- CountDownLatch
- iOS常用加密方法(aes、md5、base64)
- 4.移植ucGui
- EMC ScaleIO 1.2版本常见问题集
- code[vs] 1205 单词翻转
- hdu 5044 树链剖分
- MyEclipse使用之编写编码提示设置
- 如何启动/停止/重启MySQL
- objective-c 中数据类型之二 字符串(NSString)
- [安卓]iOS 和 Android 的静态库架构是不同的
- 在重新安装时提示:错误1923,无法安装服务“office software protection”(osppsvc)