- #define LCD_SCK_High() GPIOSetBitValue(LPC_GPIO_PORT->PIN0, 24, 1 );
- #define LCD_SCK_Low() GPIOSetBitValue(LPC_GPIO_PORT->PIN0, 24, 0 );
- #define LCD_SDI_High() GPIOSetBitValue(LPC_GPIO_PORT->PIN0, 25, 1 );
- #define LCD_SDI_Low() GPIOSetBitValue(LPC_GPIO_PORT->PIN0, 25, 0 );
- #define LCD_CS_High() GPIOSetBitValue(LPC_GPIO_PORT->PIN0, 22, 1 );
- #define LCD_CS_Low() GPIOSetBitValue(LPC_GPIO_PORT->PIN0, 22, 0 );
- #define LCD_DC_High() GPIOSetBitValue(LPC_GPIO_PORT->PIN0, 21, 1 );
- #define LCD_DC_Low() GPIOSetBitValue(LPC_GPIO_PORT->PIN0, 21, 0 );
- #define LCD_REST_High() GPIOSetBitValue(LPC_GPIO_PORT->PIN0, 20, 1 );
- #define LCD_REST_Low() GPIOSetBitValue(LPC_GPIO_PORT->PIN0, 20, 0 );
在自定义小字库的情况下,实现32*32点阵汉字显示的函数为:
- void showhanzi32(unsigned int x,unsigned int y,unsigned char index)
- {
- unsigned char i,j,k;
- const unsigned char *temp=hanzi32;
- temp+=index*128;
- for(j=0;j<32;j++)
- {
- LCD_SetCursor(x,y+j);
- LCD_WriteRAM_Prepare();
- for(k=0;k<4;k++)
- {
- for(i=0;i<8;i++)
- {
- if((*temp&(1<<i))!=0)
- {
- LCD_WR_DATA(POINT_COLOR);
- }
- else
- {
- LCD_WR_DATA(BACK_COLOR);
- }
- }
- temp++;
- }
- }
- }
而对应的字库结构则为:
- unsigned char hanzi32[]=
- {
- //心
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x60, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x80, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00,
- 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x0c, 0x06, 0x00, 0x00, 0x1c, 0x02, 0x00,
- 0x00, 0x0c, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x40, 0x0c, 0x00, 0x02, 0x40, 0x0c, 0x00, 0x06,
- 0x60, 0x0c, 0x00, 0x0c, 0x60, 0x0c, 0x00, 0x1c, 0x60, 0x0c, 0x00, 0x18, 0x70, 0x0c, 0x00, 0x38,
- 0x38, 0x0c, 0x80, 0x38, 0x3c, 0x0c, 0x80, 0x10, 0x00, 0x0c, 0x80, 0x00, 0x00, 0x0c, 0x80, 0x00,
- 0x00, 0x0c, 0x80, 0x00, 0x00, 0x0c, 0x80, 0x00, 0x00, 0x0c, 0xc0, 0x01, 0x00, 0xf8, 0xff, 0x01,
- 0x00, 0xf8, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- //率
- ......
- }
那在LPC824 lite开发板上能否实现图片显示呢?
答案是可以的,但图片不能过大,其效果如图2所示。
如果图片较大又如何处理呢?目标是板上的4MB的SPI FLASH!但要将大图片查分成小若干片,再分批倒到SPI FLASH中,以供读取使用。
以显示40*40像素的16位色图片为例,其显示程序为:
- void showimage(unsigned int x,unsigned int y)
- { // 显示40*40像素图片
- unsigned int i,j,k;
- unsigned int da;
- k=0;
- for(i=0;i<40;i++)
- {
- LCD_SetCursor(x,y+i);
- LCD_WriteRAM_Prepare();
- for(j=0;j<40;j++)
- {
- da=qqimage[k*2+1];
- da<<=8;
- da|=qqimage[k*2];
- LCD_WR_DATA(da);
- k++;
- }
- }
- }
图2 图片显示效果