如何通过Ucos的任务来更新EMWIN控件的构建基块库内容控件

博客访问: 1821620
博文数量: 1009
博客积分: 0
博客等级: 民兵
技术积分: 5959
注册时间:
技术的乐趣在于分享,欢迎多多交流,多多沟通。
IT168企业级官微
微信号:IT168qiye
系统架构师大会
微信号:SACC2013
分类: 嵌入式
.cn/s/blog_98ee3a9301016dyn.html
基于UCOS-III+emWin+FatFs+Lwip(uip)+USB的综合例程主界面设计
&( 09:00:02)
完整设计,视频演示以及代码下载,看这个帖子:(1)一共设计了20个图标,,图标大小64*64,图标采用带Alpha通道的BMP图片,本打算用PNG,但是现在的
&&&&&5.16版本不支持,使用了相应的函数提示函数不存在,可以确定是库的问题,貌似5.18修正了,我提
&&&&&供的emWin移植方法无法在这个5.18上面使用,需要等到MDK上自带的emWin升级到5.18就可以使用了。
(2)图标的显示采用了ICONVIEW控件,简单好用
(3)图标下面建立了一个水平窗口,用于显示时间和CPU的使用率
(4)背景图标采用在回调函数里面重绘的方式实现,这样实现的话,好处多多。
(5)右下角的RTC显示还没有做,后面逐渐添加上去。
最终界面如下,右下角添加WM8978的音量调节,网络设置,RTC.
阅读(1861) | 评论(0) | 转发(0) |
相关热门文章
给主人留下些什么吧!~~
请登录后评论。EMWIN 在EDIT窗口,设置光标使能,并设置了闪烁时间,但是没有闪烁效果的出现。请老大帮忙看看|uCOS &
emWin - 安富莱电子论坛 - Powered by phpwind
查看完整版本: [--
EMWIN 在EDIT窗口,设置光标使能,并设置了闪烁时间,但是没有闪烁效果的出现。请老大帮忙看看
&&&&&&&&EDIT_EnableBlink(WM_GetDialogItem(hWin,GUI_ID_EDIT0), 300, ON);&&&&&&&&EDIT_SetFont&&&&(WM_GetDialogItem(hWin,GUI_ID_EDIT0),&GUI_Font24B_ASCII);&&&&&&&&EDIT_SetMaxLen&&(WM_GetDialogItem(hWin,GUI_ID_EDIT0),15);&&&&&&&&&&&&EDIT_SetText&&&&(WM_GetDialogItem(hWin,GUI_ID_EDIT0),“5000”);
另外,如果EDIT窗口中有字符串如&192.168.1.88& 如何取出这个字符串?
:另外,如果EDIT窗口中有字符串如&192.168.1.88& 如何取出这个字符串? ( 16:17) 有个API EDIT_GetText的函数的。
:有个API EDIT_GetText的函数的。 ( 16:19) 谢谢,实验,可以的,谢谢大神
光标闪烁可能与RA8875的驱动函数有关。 如果没有特别要求,建议不用闪烁这个功能。我以前用的时候,光标闪烁频率不均匀,时快时慢,可能运行的任务太多了。
关于光标闪烁要改下这个驱动:
:光标闪烁可能与RA8875的驱动函数有关。 如果没有特别要求,建议不用闪烁这个功能。我以前用的时候,光标闪烁频率不均匀,时快时慢,可能运行的任务太多了。 ( 16:45) 谢谢
:关于光标闪烁要改下这个驱动:/read.php?tid=10160 ( 00:04) 谢谢
查看完整版本: [--
Powered by
Time 0.047657 second(s),query:2 Gzip enabled原始的例程没有竖屏,
自己做了个四向变换(编译时确定)
有需要的可以拿去,不用打招呼。
基于旺宝红牛版开发板做的。
&修改 LCDConf.h &文件里的 ORIENTATION 宏 则可改变方向。
(注意,横竖屏切换后,对于固定大小显示的emWin界面并不能直接适应屏幕)。
http://download.csdn.net/detail/godyde/9680713
请使用Keilc MDK打开
如何移植 emWin 网上有大量的列子和教材,我就不在这里说明。
emWin 是不开方源代码的,所以 ucgui 使用三个宏来切换的横竖屏的方法不使用。而且即使可用运行效率也不高。
我说下我的横竖屏切换是如何做到的。
首先我们观察 emWin &和 & 显示屏驱动之间如何连接的。 emWin 到底调用了那些驱动函数来显示界面。
_SetPixelIndex 里调用了 &LCD_PutPixel(x,y,PixelIndex);
_GetPixelIndex 里调用了 &LCD_GetPixel(x,y);
_DrawHLine & & 里调用了 &LCD_DrawLineH(x0, y, x1, LCD_COLORINDEX);&
_DrawVLine & & 里调用了 &LCD_DrawLineV(x, y0, y1, LCD_COLORINDEX);//该函数我自己重写的,原例程里没有
_FillRect & & & & &里调用了 & &LCD_SetTarBlock(x0, y0, x1, y1);
//该函数我自己重写的,用来替代RA8875_SetTarBlock .让程序更模块化
//这个很多新接触emWin 的人很容易漏掉下面这个地方。如果移植后,基础GUI接口显示正常,而图片,wigt 控件显示不正常,都是下面这个被调用的函数不正确。
_DrawBitLine16BPP 里调用了&LCD_DrawHColorLine(x, y, xsize, (uint16_t *)p); &//这个函数实现最麻烦,RA8875 没有找到垂直自增长的填充方式,最后用的画图的方式实现了。
_DrawBitLine32BPP 里也调用了LCD_DrawHColorLine(x, y, xsize, (uint16_t *)p) //这个调用是错误的,会导致颜色显示不对。但是我用的16位(565)色深,所以不会调用到这个。使用真彩色的需要注意,凡是带了color 的地方都要改成32位才能正确显示颜色。
打开GUIDRV_Template.c 这个文件咱们看看调用关系。
/*********************************************************************
* & & & & & & & &SEGGER Microcontroller GmbH & Co. KG & & & & & & & &*
* & & & &Solutions for real time microcontroller applications & & & &*
**********************************************************************
* & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & &*
* & & & &(c) 1996 - 2012 &SEGGER Microcontroller GmbH & Co. KG & & & *
* & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & &*
* & & & &Internet:
& &Support: & & &*
* & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & &*
**********************************************************************
** emWin V5.16 - Graphical user interface for embedded applications **
All &Intellectual Property rights &in the Software belongs to &SEGGER.
emWin is protected by &international copyright laws. &Knowledge of the
source code may not be used to write a similar product. &This file may
only be used in accordance with the following terms:
The software has been licensed to &ARM LIMITED whose registered office
is situated at &110 Fulbourn Road, &Cambridge CB1 9NJ, &England solely
for &the &purposes &of &creating &libraries &for &ARM7, ARM9, Cortex-M
series, &and & Cortex-R4 & processor-based &devices, &sublicensed &and
distributed as part of the &MDK-ARM &Professional &under the terms and
conditions &of &the & End &User &License &supplied &with &the &MDK-ARM
Professional.&
Full source code is available at:
We appreciate your understanding and fairness.
----------------------------------------------------------------------
File & & & &: GUIDRV_Template.c
Purpose & & : Template driver, should be used as starting point
& & & & & & & for new display drivers.
---------------------------END-OF-HEADER------------------------------
#include &stddef.h&
#include &stm32f10x.h&
#include &LCD_Private.h&
#include &GUI_Private.h&
#include &LCD_SIM.h&
#include &LCD_ConfDefaults.h&
#include &LCD_RA8875.h&
#define emWin_Optimize & 1 & /* used for emWin optimize */
__IO uint8_t RA8875BusyNow = 0;
********************************************************************
* & & & Defines
********************************************************************
********************************************************************
* & & & Macros for MIRROR_, SWAP_ and LUT_
********************************************************************
//下面的宏,我劝大家别用,越用越乱。 效率也不高。
#if (!defined (LCD_LUT_COM) && !defined(LCD_LUT_SEG))
& #if & (!LCD_MIRROR_X && !LCD_MIRROR_Y && !LCD_SWAP_XY)&
& & #define LOG2PHYS_X(x, y) x
& & #define LOG2PHYS_Y(x, y) y
& #elif (!LCD_MIRROR_X && !LCD_MIRROR_Y && &LCD_SWAP_XY)&
& & #define LOG2PHYS_X(x, y) y
& & #define LOG2PHYS_Y(x, y) x
& #elif (!LCD_MIRROR_X && &LCD_MIRROR_Y && !LCD_SWAP_XY)&
& & #define LOG2PHYS_X(x, y) x
& & #define LOG2PHYS_Y(x, y) LCD_YSIZE - 1 - (y)
& #elif (!LCD_MIRROR_X && &LCD_MIRROR_Y && &LCD_SWAP_XY)&
& & #define LOG2PHYS_X(x, y) y
& & #define LOG2PHYS_Y(x, y) LCD_XSIZE - 1 - (x)
& #elif ( LCD_MIRROR_X && !LCD_MIRROR_Y && !LCD_SWAP_XY)&
& & #define LOG2PHYS_X(x, y) LCD_XSIZE - 1 - (x)
& & #define LOG2PHYS_Y(x, y) y
& #elif ( LCD_MIRROR_X && !LCD_MIRROR_Y && &LCD_SWAP_XY)&
& & #define LOG2PHYS_X(x, y) LCD_YSIZE - 1 - (y)
& & #define LOG2PHYS_Y(x, y) x
& #elif ( LCD_MIRROR_X && &LCD_MIRROR_Y && !LCD_SWAP_XY)&
& & #define LOG2PHYS_X(x, y) LCD_XSIZE - 1 - (x)
& & #define LOG2PHYS_Y(x, y) LCD_YSIZE - 1 - (y)
& #elif ( LCD_MIRROR_X && &LCD_MIRROR_Y && &LCD_SWAP_XY)&
& & #define LOG2PHYS_X(x, y) LCD_YSIZE - 1 - (y)
& & #define LOG2PHYS_Y(x, y) LCD_XSIZE - 1 - (x)
& #if & ( defined (LCD_LUT_COM) && !defined(LCD_LUT_SEG))
& & #define LOG2PHYS_X(x, y) x
& & #define LOG2PHYS_Y(x, y) LCD__aLine2Com0[y]
& #elif (!defined (LCD_LUT_COM) && &defined(LCD_LUT_SEG))
& & #define LOG2PHYS_X(x, y) LCD__aCol2Seg0[x]
& & #define LOG2PHYS_Y(x, y) y
& #elif ( defined (LCD_LUT_COM) && &defined(LCD_LUT_SEG))
& & #define LOG2PHYS_X(x, y) LCD__aCol2Seg0[x]
& & #define LOG2PHYS_Y(x, y) LCD__aLine2Com0[y]
**********************************************************************
* & & & Types
**********************************************************************
typedef struct {
& U32 VRAMA
& int xSize, yS
& int vxSize, vyS
& int vxSizeP
& int BitsPerP
} DRIVER_CONTEXT;
**********************************************************************
* & & & Static functions
**********************************************************************
*************************************************************************
* & & & _SetPixelIndex
* Purpose:
* & Sets the index of the given pixel. The upper layers
* & calling this routine make sure that the coordinates are in range, so
* & that no check on the parameters needs to be performed.
*************************************************************************
static void _SetPixelIndex(GUI_DEVICE * pDevice, int x, int y, int PixelIndex) {
& #ifdef WIN32
& & LCDSIM_SetPixelIndex(x, y, PixelIndex, pDevice-&LayerIndex);
& & // Convert logical into physical coordinates (Dep. on LCDConf.h)
& & #if (LCD_MIRROR_X == 1) || (LCD_MIRROR_Y == 1) || (LCD_SWAP_XY == 1)
& & & int xPhys, yP
& & & xPhys = LOG2PHYS_X(x, y);
& & & yPhys = LOG2PHYS_Y(x, y);
& & & #define xPhys x
& & & #define yPhys y
& & #endif
& & GUI_USE_PARA(pDevice);
& & GUI_USE_PARA(x);
& & GUI_USE_PARA(y);
& & GUI_USE_PARA(PixelIndex);
& & & // Write into hardware ... Adapt to your system
& & & // TBD by customer...
& RA8875BusyNow = 1;
& & LCD_PutPixel(x,y,PixelIndex);
& RA8875BusyNow = 0;
& & #if (LCD_MIRROR_X == 0) && (LCD_MIRROR_Y == 0) && (LCD_SWAP_XY == 0)
& & & #undef xPhys
& & & #undef yPhys
& & #endif
*************************************************************************
* & & & _GetPixelIndex
* Purpose:
* & Returns the index of the given pixel. The upper layers
* & calling this routine make sure that the coordinates are in range, so
* & that no check on the parameters needs to be performed.
*************************************************************************
static unsigned int _GetPixelIndex(GUI_DEVICE * pDevice, int x, int y) {
& unsigned int PixelI
& #ifdef WIN32
& & PixelIndex = LCDSIM_GetPixelIndex(x, y, pDevice-&LayerIndex);
& & // Convert logical into physical coordinates (Dep. on LCDConf.h)
& & #if (LCD_MIRROR_X == 1) || (LCD_MIRROR_Y == 1) || (LCD_SWAP_XY == 1)
& & & int xPhys, yP
& & & xPhys = LOG2PHYS_X(x, y);
& & & yPhys = LOG2PHYS_Y(x, y);
& & & #define xPhys x
& & & #define yPhys y
& & #endif
& & GUI_USE_PARA(pDevice);
& & GUI_USE_PARA(x);
& & GUI_USE_PARA(y);
& & & // Write into hardware ... Adapt to your system
& & & // TBD by customer...
&RA8875BusyNow = 1;
&PixelIndex = LCD_GetPixel(x,y);
&RA8875BusyNow = 0;
& & #if (LCD_MIRROR_X == 0) && (LCD_MIRROR_Y == 0) && (LCD_SWAP_XY == 0)
& & & #undef xPhys
& & & #undef yPhys
& & #endif
& return PixelI
********************************************************************
* & & & _XorPixel
********************************************************************
static void _XorPixel(GUI_DEVICE * pDevice, int x, int y) {
& LCD_PIXELINDEX PixelI
& LCD_PIXELINDEX IndexM
& PixelIndex = _GetPixelIndex(pDevice, x, y);
& IndexMask &= pDevice-&pColorConvAPI-&pfGetIndexMask();
& _SetPixelIndex(pDevice, x, y, PixelIndex ^ IndexMask);
********************************************************************
* & & & _DrawHLine
*******************************************************************
static void _DrawHLine &(GUI_DEVICE * pDevice, int x0, int y, &int x1) {
& if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR) {
& & for (; x0 &= x1; x0++) {
& & & _XorPixel(pDevice, x0, y);
& } else {
& #if emWin_Optimize
RA8875BusyNow = 1;
LCD_DrawLineH(x0, y, x1, LCD_COLORINDEX);
RA8875BusyNow = 0;
& & LCD_PIXELINDEX ColorI
& & ColorIndex = LCD__GetColorIndex();
& & for (; x0 &= x1; x0++) {
& & & _SetPixelIndex(pDevice, x0, y, ColorIndex);
*************************************************************************
* & & & _DrawVLine, not optimized
*************************************************************************
static void _DrawVLine &(GUI_DEVICE * pDevice, int x, int y0, &int y1) {
& if (GUI_Context.DrawMode & LCD_DRAWMODE_XOR) {
& & for (; y0 &= y1; y0++) {
& & & _XorPixel(pDevice, x, y0);
& } else {
#if emWin_Optimize
RA8875BusyNow = 1;
LCD_DrawLineV(x, y0, y1, LCD_COLORINDEX);
RA8875BusyNow = 0;
LCD_PIXELINDEX ColorI
ColorIndex = LCD__GetColorIndex();
& &for (; y0 &= y1; y0++) {
& & &_SetPixelIndex(pDevice, x, y0, ColorIndex);
static void _FillRect(GUI_DEVICE * pDevice, int x0, int y0, int x1, int y1)&
#if emWin_Optimize
RA8875BusyNow = 1;
LCD_SetTarBlock(x0, y0, x1, y1);
& & & &//?è??BTE?>>?????í??,ss??(?????á?úAE?×?????,??(C)
BTE_SetOperateCode(0x0C);
& & & & &//?è?¨BTE ??×÷???????¤?????? &REG[51h] Bit[3:0] = 0Ch&
RA8875_SetFrontColor(LCD_COLORINDEX);
//?è??BTE?° 3/4 °?<<&
BTE_Start();
& & & & & & & &//??AE?BTE ????&
BTE_Wait();
& & & & & & & &//u?????×÷ 1/2 á??&
RA8875BusyNow = 0;
for (; y0 &= y1; y0&#43;&#43;)&
_DrawHLine(pDevice, x0, y0, x1);
********************************************************************
* & & & Draw Bitmap 1 BPP
********************************************************************
static void _DrawBitLine1BPP(GUI_DEVICE * pDevice, unsigned x, unsigned y, U8 const GUI_UNI_PTR * p, int Diff, int xsize, const LCD_PIXELINDEX * pTrans) {
& LCD_PIXELINDEX IndexMask, Index0, Index1, P
& Index0 = *(pTrans &#43; 0);
& Index1 = *(pTrans &#43; 1);
& x &#43;= D
& switch (GUI_Context.DrawMode & (LCD_DRAWMODE_TRANS | LCD_DRAWMODE_XOR)) {
& & & _SetPixelIndex(pDevice, x&#43;&#43;, y, (*p & (0x80 && Diff)) ? Index1 : Index0);
& & & if (&#43;&#43;Diff == 8) {
& & & & Diff = 0;
& & & & p&#43;&#43;;
& & } while (--xsize);
& case LCD_DRAWMODE_TRANS:
& & & if (*p & (0x80 && Diff))
& & & & _SetPixelIndex(pDevice, x, y, Index1);
& & & x&#43;&#43;;
& & & if (&#43;&#43;Diff == 8) {
& & & & Diff = 0;
& & & & p&#43;&#43;;
& & } while (--xsize);
& case LCD_DRAWMODE_XOR | LCD_DRAWMODE_TRANS:
& case LCD_DRAWMODE_XOR:
& & IndexMask = pDevice-&pColorConvAPI-&pfGetIndexMask();
& & & if (*p & (0x80 && Diff)) {
& & & & Pixel = _GetPixelIndex(pDevice, x, y);
& & & & _SetPixelIndex(pDevice, x, y, Pixel ^ IndexMask);
& & & x&#43;&#43;;
& & & if (&#43;&#43;Diff == 8) {
& & & & Diff = 0;
& & & & p&#43;&#43;;
& & } while (--xsize);
**************************************************************************
* & & & Draw Bitmap 2 BPP
**************************************************************************
static void &_DrawBitLine2BPP(GUI_DEVICE * pDevice, int x, int y, U8 const GUI_UNI_PTR * p, int Diff, int xsize, const LCD_PIXELINDEX * pTrans) {
& LCD_PIXELINDEX Pixels, PixelI
& int CurrentPixel, Shift, I
& Pixels = *p;
& CurrentPixel = D
& x &#43;= D
& switch (GUI_Context.DrawMode & (LCD_DRAWMODE_TRANS | LCD_DRAWMODE_XOR)) {
& & if (pTrans) {
& & & do {
& & & & Shift = (3 - CurrentPixel) && 1;
& & & & Index = (Pixels & (0xC0 && (6 - Shift))) && S
& & & & PixelIndex = *(pTrans &#43; Index);
& & & & _SetPixelIndex(pDevice, x&#43;&#43;, y, PixelIndex);
& & & & if (&#43;&#43;CurrentPixel == 4) {
& & & & & CurrentPixel = 0;
& & & & & Pixels = *(&#43;&#43;p);
& & & } while (--xsize);
& & } else {
& & & do {
& & & & Shift = (3 - CurrentPixel) && 1;
& & & & Index = (Pixels & (0xC0 && (6 - Shift))) && S
& & & & _SetPixelIndex(pDevice, x&#43;&#43;, y, Index);
& & & & if (&#43;&#43;CurrentPixel == 4) {
& & & & & CurrentPixel = 0;
& & & & & Pixels = *(&#43;&#43;p);
& & & } while (--xsize);
& case LCD_DRAWMODE_TRANS:
& & if (pTrans) {
& & & do {
& & & & Shift = (3 - CurrentPixel) && 1;
& & & & Index = (Pixels & (0xC0 && (6 - Shift))) && S
& & & & if (Index) {
& & & & & PixelIndex = *(pTrans &#43; Index);
& & & & & _SetPixelIndex(pDevice, x, y, PixelIndex);
& & & & x&#43;&#43;;
& & & & if (&#43;&#43;CurrentPixel == 4) {
& & & & & CurrentPixel = 0;
& & & & & Pixels = *(&#43;&#43;p);
& & & } while (--xsize);
& & } else {
& & & do {
& & & & Shift = (3 - CurrentPixel) && 1;
& & & & Index = (Pixels & (0xC0 && (6 - Shift))) && S
& & & & if (Index) {
& & & & & _SetPixelIndex(pDevice, x, y, Index);
& & & & x&#43;&#43;;
& & & & if (&#43;&#43;CurrentPixel == 4) {
& & & & & CurrentPixel = 0;
& & & & & Pixels = *(&#43;&#43;p);
& & & } while (--xsize);
**************************************************************************
* & & & Draw Bitmap 4 BPP
**************************************************************************
static void &_DrawBitLine4BPP(GUI_DEVICE * pDevice, int x, int y, U8 const GUI_UNI_PTR * p, int Diff, int xsize, const LCD_PIXELINDEX * pTrans) {
& LCD_PIXELINDEX Pixels, PixelI
& int CurrentPixel, Shift, I
& Pixels = *p;
& CurrentPixel = D
& x &#43;= D
& switch (GUI_Context.DrawMode & (LCD_DRAWMODE_TRANS | LCD_DRAWMODE_XOR)) {
& & if (pTrans) {
& & & do {
& & & & Shift = (1 - CurrentPixel) && 2;
& & & & Index = (Pixels & (0xF0 && (4 - Shift))) && S
& & & & PixelIndex = *(pTrans &#43; Index);
& & & & _SetPixelIndex(pDevice, x&#43;&#43;, y, PixelIndex);
& & & & if (&#43;&#43;CurrentPixel == 2) {
& & & & & CurrentPixel = 0;
& & & & & Pixels = *(&#43;&#43;p);
& & & } while (--xsize);
& & } else {
& & & do {
& & & & Shift = (1 - CurrentPixel) && 2;
& & & & Index = (Pixels & (0xF0 && (4 - Shift))) && S
& & & & _SetPixelIndex(pDevice, x&#43;&#43;, y, Index);
& & & & if (&#43;&#43;CurrentPixel == 2) {
& & & & & CurrentPixel = 0;
& & & & & Pixels = *(&#43;&#43;p);
& & & } while (--xsize);
& case LCD_DRAWMODE_TRANS:
& & if (pTrans) {
& & & do {
& & & & Shift = (1 - CurrentPixel) && 2;
& & & & Index = (Pixels & (0xF0 && (4 - Shift))) && S
& & & & if (Index) {
& & & & & PixelIndex = *(pTrans &#43; Index);
& & & & & _SetPixelIndex(pDevice, x, y, PixelIndex);
& & & & x&#43;&#43;;
& & & & if (&#43;&#43;CurrentPixel == 2) {
& & & & & CurrentPixel = 0;
& & & & & Pixels = *(&#43;&#43;p);
& & & } while (--xsize);
& & } else {
& & & do {
& & & & Shift = (1 - CurrentPixel) && 2;
& & & & Index = (Pixels & (0xF0 && (4 - Shift))) && S
& & & & if (Index) {
& & & & & _SetPixelIndex(pDevice, x, y, Index);
& & & & x&#43;&#43;;
& & & & if (&#43;&#43;CurrentPixel == 2) {
& & & & & CurrentPixel = 0;
& & & & & Pixels = *(&#43;&#43;p);
& & & } while (--xsize);
**************************************************************************
* & & & Draw Bitmap 8 BPP
**************************************************************************
static void &_DrawBitLine8BPP(GUI_DEVICE * pDevice, int x, int y, U8 const GUI_UNI_PTR * p, int xsize, const LCD_PIXELINDEX * pTrans) {
& LCD_PIXELINDEX P
& switch (GUI_Context.DrawMode & (LCD_DRAWMODE_TRANS | LCD_DRAWMODE_XOR)) {
& & if (pTrans) {
& & & for (; xsize & 0; xsize--, x&#43;&#43;, p&#43;&#43;) {
& & & & Pixel = *p;
& & & & _SetPixelIndex(pDevice, x, y, *(pTrans &#43; Pixel));
& & } else {
& & & for (; xsize & 0; xsize--, x&#43;&#43;, p&#43;&#43;) {
& & & & _SetPixelIndex(pDevice, x, y, *p);
& case LCD_DRAWMODE_TRANS:
& & if (pTrans) {
& & & for (; xsize & 0; xsize--, x&#43;&#43;, p&#43;&#43;) {
& & & & Pixel = *p;
& & & & if (Pixel) {
& & & & & _SetPixelIndex(pDevice, x, y, *(pTrans &#43; Pixel));
& & } else {
& & & for (; xsize & 0; xsize--, x&#43;&#43;, p&#43;&#43;) {
& & & & Pixel = *p;
& & & & if (Pixel) {
& & & & & _SetPixelIndex(pDevice, x, y, Pixel);
**************************************************************************
* & & & Draw Bitmap 16 BPP, not optimized
**************************************************************************
static void _DrawBitLine16BPP(GUI_DEVICE * pDevice, int x, int y, U16 const GUI_UNI_PTR * p, int xsize)&
#if emWin_Optimize
// RA8875_SetCursor(x,y);
// RA8875_REG = 0x02;
// for (;xsize & 0; xsize--,p&#43;&#43;)
// RA8875_RAM = *p;
RA8875BusyNow = 1;
LCD_DrawHColorLine(x, y, xsize, (uint16_t *)p);
RA8875BusyNow = 0;
for (;xsize & 0; xsize--, x&#43;&#43;, p&#43;&#43;)&
_SetPixelIndex(pDevice, x, y, *p);
**************************************************************************
* & & & Draw Bitmap 32 BPP, not optimized
**************************************************************************
static void _DrawBitLine32BPP(GUI_DEVICE * pDevice, int x, int y, U32 const GUI_UNI_PTR * p, int xsize)&
#if emWin_Optimize
// RA8875_SetCursor(x,y);
// RA8875_REG = 0x02;
// for (;xsize & 0; xsize--,p&#43;&#43;)
// RA8875_RAM = *p;
RA8875BusyNow = 1;
LCD_DrawHColorLine(x, y, xsize, (uint16_t *)p);
RA8875BusyNow = 0;
for (;xsize & 0; xsize--, x&#43;&#43;, p&#43;&#43;)&
_SetPixelIndex(pDevice, x, y, *p);
**************************************************************************
* & & & _DrawBitmap
**************************************************************************
static void _DrawBitmap(GUI_DEVICE * pDevice, int x0, int y0,
& & & & & & & & & & & &int xSize, int ySize,
& & & & & & & & & & & &int BitsPerPixel,&
& & & & & & & & & & & &int BytesPerLine,
& & & & & & & & & & & &const U8 GUI_UNI_PTR * pData, int Diff,
& & & & & & & & & & & &const LCD_PIXELINDEX* pTrans) {
& switch (BitsPerPixel) {
& & for (i = 0; i & yS i&#43;&#43;) {
& & & _DrawBitLine1BPP(pDevice, x0, i &#43; y0, pData, Diff, xSize, pTrans);
& & & pData &#43;= BytesPerL
& & for (i = 0; i & yS i&#43;&#43;) {
& & & _DrawBitLine2BPP(pDevice, x0, i &#43; y0, pData, Diff, xSize, pTrans);
& & & pData &#43;= BytesPerL
& & for (i = 0; i & yS i&#43;&#43;) {
& & & _DrawBitLine4BPP(pDevice, x0, i &#43; y0, pData, Diff, xSize, pTrans);
& & & pData &#43;= BytesPerL
& & for (i = 0; i & yS i&#43;&#43;) {
& & & _DrawBitLine8BPP(pDevice, x0, i &#43; y0, pData, xSize, pTrans);
& & & pData &#43;= BytesPerL
& case 16:
& & for (i = 0; i & yS i&#43;&#43;) {
& & & _DrawBitLine16BPP(pDevice, x0, i &#43; y0, (const U16 *)pData, xSize);
& & & pData &#43;= BytesPerL
& case 32:
& & for (i = 0; i & yS i&#43;&#43;) {
& & & _DrawBitLine32BPP(pDevice, x0, i &#43; y0, (const U32 *)pData, xSize);
& & & pData &#43;= BytesPerL
********************************************************************
* & & & _InitOnce
* Purpose:
* & Allocates a fixed block for the context of the driver
* Return value:
* & 0 on success, 1 on error
********************************************************************
static int _InitOnce(GUI_DEVICE * pDevice) {
& DRIVER_CONTEXT * pC
& if (pDevice-&u.pContext == NULL) {
& & pDevice-&u.pContext = GUI_ALLOC_GetFixedBlock(sizeof(DRIVER_CONTEXT));
& & pContext = (DRIVER_CONTEXT *)pDevice-&u.pC
& & pContext-&BitsPerPixel = LCD__GetBPP(pDevice-&pColorConvAPI-&pfGetIndexMask());
& return pDevice-&u.pContext ? 0 : 1;
**************************************************************************
* & & & _GetDevProp
**************************************************************************
static I32 _GetDevProp(GUI_DEVICE * pDevice, int Index) {
& DRIVER_CONTEXT * pC
& pContext = (DRIVER_CONTEXT *)pDevice-&u.pC
& switch (Index) {
& case LCD_DEVCAP_XSIZE:
& & return pContext-&xS
& case LCD_DEVCAP_YSIZE:
& & return pContext-&yS
& case LCD_DEVCAP_VXSIZE:
& & return pContext-&vxS
& case LCD_DEVCAP_VYSIZE:
& & return pContext-&vyS
& case LCD_DEVCAP_BITSPERPIXEL:
& & return pContext-&BitsPerP
& case LCD_DEVCAP_NUMCOLORS:
& & return 0;
& case LCD_DEVCAP_XMAG:
& & return 1;
& case LCD_DEVCAP_YMAG:
& & return 1;
& case LCD_DEVCAP_MIRROR_X:
& & return 0;
& case LCD_DEVCAP_MIRROR_Y:
& & return 0;
& case LCD_DEVCAP_SWAP_XY:
& & return 0;
& return -1;
**************************************************************************
* & & & _GetDevData
**************************************************************************
static void * _GetDevData(GUI_DEVICE * pDevice, int Index) {
& GUI_USE_PARA(pDevice);
& #if GUI_SUPPORT_MEMDEV
& & switch (Index) {
& & case LCD_DEVDATA_MEMDEV:
// TBD: Has to be adapted to the right memory device depending on the used color depth!
&return (void *)&GUI_MEMDEV_DEVICE_16;&
& & GUI_USE_PARA(Index);
& return NULL;
**************************************************************************
* & & & _GetRect
**************************************************************************
static void _GetRect(GUI_DEVICE * pDevice, LCD_RECT * pRect) {
& DRIVER_CONTEXT * pC
& pContext = (DRIVER_CONTEXT *)pDevice-&u.pC
& pRect-&x0 = 0;
& pRect-&y0 = 0;
& pRect-&x1 = pContext-&vxSize - 1;
& pRect-&y1 = pContext-&vySize - 1;
**************************************************************************
* & & & _SetOrg
**************************************************************************
static void _SetOrg(GUI_DEVICE * pDevice, int x, int y) {
& LCD_X_SETORG_INFO Data = {0};
& Data.xPos =
& Data.yPos =
& LCD_X_DisplayDriver(pDevice-&LayerIndex, LCD_X_SETORG, (void *)&Data);
**********************************************************************
* & & & Static code: Functions available by _GetDevFunc()
**********************************************************************
*********************************************************************
* & & & _SetVRAMAddr
*********************************************************************
static void _SetVRAMAddr(GUI_DEVICE * pDevice, void * pVRAM) {
& DRIVER_CONTEXT * pC
& LCD_X_SETVRAMADDR_INFO Data = {0};
& _InitOnce(pDevice);
& if (pDevice-&u.pContext) {
& & pContext = (DRIVER_CONTEXT *)pDevice-&u.pC
& & pContext-&VRAMAddr = (U32)pVRAM;
& & Data.pVRAM = pVRAM;
& & LCD_X_DisplayDriver(pDevice-&LayerIndex, LCD_X_SETVRAMADDR, (void *)&Data);
********************************************************************
* & & & _SetVSize
********************************************************************
static void _SetVSize(GUI_DEVICE * pDevice, int xSize, int ySize) {
& DRIVER_CONTEXT * pC
& _InitOnce(pDevice);
& if (pDevice-&u.pContext) {
& & pContext = (DRIVER_CONTEXT *)pDevice-&u.pC
& & pContext-&vxSize = xS
& & pContext-&vySize = yS
& & pContext-&vxSizePhys = xS
********************************************************************
* & & & _SetSize
********************************************************************
static void _SetSize(GUI_DEVICE * pDevice, int xSize, int ySize) {
& DRIVER_CONTEXT * pC
& LCD_X_SETSIZE_INFO Data = {0};
& _InitOnce(pDevice);
& if (pDevice-&u.pContext) {
& & pContext = (DRIVER_CONTEXT *)pDevice-&u.pC
& & pContext-&vxSizePhys = (pContext-&vxSizePhys == 0) ? xSize : pContext-&vxSizeP
& & pContext-&xSize = xS
& & pContext-&ySize = yS
& & Data.xSize = xS
& & Data.ySize = yS
& & LCD_X_DisplayDriver(pDevice-&LayerIndex, LCD_X_SETSIZE, (void *)&Data);
*********************************************************************
* & & & _Init
*********************************************************************
static int &_Init(GUI_DEVICE * pDevice) {
& r = _InitOnce(pDevice);
& r |= LCD_X_DisplayDriver(pDevice-&LayerIndex, LCD_X_INITCONTROLLER, NULL);
*********************************************************************
* & & & _On
*********************************************************************
static void _On (GUI_DEVICE * pDevice) {
& LCD_X_DisplayDriver(pDevice-&LayerIndex, LCD_X_ON, NULL);
*********************************************************************
* & & & _Off
*********************************************************************
static void _Off (GUI_DEVICE * pDevice) {
& LCD_X_DisplayDriver(pDevice-&LayerIndex, LCD_X_OFF, NULL);
*********************************************************************
* & & & _SetLUTEntry
*********************************************************************
static void _SetLUTEntry(GUI_DEVICE * pDevice, U8 Pos, LCD_COLOR Color) {
& LCD_X_SETLUTENTRY_INFO Data = {0};
& Data.Pos & = P
& Data.Color = C
& LCD_X_DisplayDriver(pDevice-&LayerIndex, LCD_X_SETLUTENTRY, (void *)&Data);
*********************************************************************
* & & & _GetDevFunc
*********************************************************************
static void (* _GetDevFunc(GUI_DEVICE ** ppDevice, int Index))(void) {
& GUI_USE_PARA(ppDevice);
& switch (Index) {
& case LCD_DEVFUNC_SET_VRAM_ADDR:
& & return (void (*)(void))_SetVRAMA
& case LCD_DEVFUNC_SET_VSIZE:
& & return (void (*)(void))_SetVS
& case LCD_DEVFUNC_SET_SIZE:
& & return (void (*)(void))_SetS
& case LCD_DEVFUNC_INIT:
& & return (void (*)(void))_I
& case LCD_DEVFUNC_ON:
& & return (void (*)(void))_On;
& case LCD_DEVFUNC_OFF:
& & return (void (*)(void))_O
& case LCD_DEVFUNC_SETLUTENTRY:
& & return (void (*)(void))_SetLUTE
& return NULL;
**********************************************************************
* & & & Public data
**********************************************************************
***********************************************************************
* & & & GUI_DEVICE_API structure
***********************************************************************
const GUI_DEVICE_API GUIDRV_Template_API = {
& DEVICE_CLASS_DRIVER,
& // Drawing functions
& _DrawBitmap,
& _DrawHLine,
& _DrawVLine,
& _FillRect,
& _GetPixelIndex,
& _SetPixelIndex,
& _XorPixel,
& // Set origin
& _SetOrg,
& // Request information
& _GetDevFunc,
& _GetDevProp,
& _GetDevData,
& _GetRect,
/*************************** End of file ****************************/
好了,所有关联函数都在这了,就是前面提到的六个函数
这六个函数的位置都放置在&bsp_tft_lcd.c 文件里,我们接着看bsp_tft_lcd.c 文件
我用了一个宏_LCD_SWAP_XY .来决定编译时是编译成横屏还是竖屏。_LCD_SWAP_XY =0 时为横屏。
各位可以直接在下面的代码里看看横屏和竖屏执行的代码的不同。
而 横屏和竖屏能正确显示后,剩余的两个方向,只是 XY 轴翻转的问题,我使用RA8875 自带的设置其扫描方向来实现翻转(省了好多事,只需设置好RAh寄存器就可以了)
/*******************************************************************************
& * Company: Wang Electronic Technology Co., Ltd.
& ******************************************************************************
& * ?? 1/4 ????AE??bsp_tft_lcd.c
& * ?????u?÷???ì?ú103 7??LCD &FSMC????
& * °ae & &± 3/4 ??V1.0
* ×÷ & &?ss??openmcu
& * ?? & &AE???
********************************************************************************
& * ?? 1/4 ????AE??
& * ?????u?÷??
& * °ae & &± 3/4 ??
* ,ü??×÷?ss:
& * ?? & &AE???
* ,ü????????
********************************************************************************/
#include &stm32f10x.h&
#include &stdio.h&
#include &string.h&
#include &LCD_RA8875.h&
#include &fonts.h&
uint16_t g_LcdWidth = 800; // ??? 3/4 AE?·?±ae??-?í??
uint16_t g_LcdHeight = 480; // ??? 3/4 AE?·?±ae??-,ss??&
uint8_t s_ucB & &//±???????????&
/**************************************************************************************
** Function name: & & & void Delay(uint16_t nCount)
** Descriptions: & & & &??????? 1/4 >>?LCD
** input parameters: & &nCount ???± 1/4 AE?? & & & & & & & &&
** output parameters: & ??
** Returned value: & & &??
***************************************************************************************/
static void Delay(uint16_t nCount)
& & uint16_t TimingD
& & while(nCount--)
& & & for(TimingDelay=0;TimingDelay&10000;TimingDelay&#43;&#43;);
/**************************************************************************************
** Function name: & & & void LCD_GPIOConfig(void)
** Descriptions: & & & &????LCD???AE???ss??FSMC?? 1/2 ??è????,???????
** input parameters: & &??
** output parameters: & ??
** Returned value: & & &??
***************************************************************************************/
static void LCD_GPIOConfig(void)
GPIO_InitTypeDef GPIO_InitS
/* Enable FSMC, GPIOD, GPIOE, GPIOF, GPIOG and AFIO clocks */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE |
& & & & & & & & & & & RCC_APB2Periph_GPIOF | RCC_APB2Periph_GPIOG |
& & & & & & & & & & & RCC_APB2Periph_AFIO, ENABLE);
/* Set &PD.00(D2), PD.01(D3), PD.04(NOE)--LCD_RD ?¨???(C), PD.05(NWE)--LCD_WR?¨???(C),
& & &PD.08(D13),PD.09(D14),PD.10(D15),PD.14(D0),PD.15(D1) */
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 &;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
& & & & & & & &//,????AE?ì????
GPIO_Init(GPIOD, &GPIO_InitStructure);
/* Set PE.07(D4), PE.08(D5), PE.09(D6), PE.10(D7), PE.11(D8), PE.12(D9), PE.13(D10),
PE.14(D11), PE.15(D12) as alternate function push pull */
GPIO_InitStructure.GPIO_Pin = &GPIO_Pin_6 | 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);
/* Set PF.00(A0 (RS)) as alternate function push pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
GPIO_Init(GPIOF, &GPIO_InitStructure);
& /* Set PG.12(NE4 (LCD/CS)) as alternate function push pull - CE3(LCD /CS) */
& /* NE4 configuration */
& GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
& GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
& GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
& GPIO_Init(GPIOG, &GPIO_InitStructure);
/**************************************************************************************
** Function name: & & & void LCD_FSMCConfig(void)
** Descriptions: & & & &????FSMC????·????±?ò
** input parameters: & &??
** output parameters: & ??
** Returned value: & & &??
***************************************************************************************/
static void LCD_FSMCConfig(void)
FSMC_NORSRAMInitTypeDef &I
FSMC_NORSRAMTimingInitTypeDef &T
/*-- FSMC Configuration ------------------------------------------------------*/
/*----------------------- SRAM Bank 4 ----------------------------------------*/
/* FSMC_Bank1_NORSRAM4 configuration */
Time.FSMC_AddressSetupTime = 1;
Time.FSMC_AddressHoldTime = 1;
Time.FSMC_DataSetupTime = 2;
Time.FSMC_BusTurnAroundDuration = 0;
Time.FSMC_CLKDivision = 0;
Time.FSMC_DataLatency = 0;
Time.FSMC_AccessMode = FSMC_AccessMode_A;
LCD configured as follow:
& &- Data/Address MUX = Disable
& &- Memory Type = SRAM
& &- Data Width = 16bit
& &- Write Operation = Enable
& &- Extended Mode = Enable
& &- Asynchronous Wait = Disable
Init.FSMC_Bank = FSMC_Bank1_NORSRAM4;
Init.FSMC_DataAddressMux = FSMC_DataAddressMux_D
Init.FSMC_MemoryType = FSMC_MemoryType_SRAM;
Init.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
Init.FSMC_BurstAccessMode = FSMC_BurstAccessMode_D
Init.FSMC_AsynchronousWait = FSMC_AsynchronousWait_D
Init.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_L
Init.FSMC_WrapMode = FSMC_WrapMode_D
Init.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitS
Init.FSMC_WriteOperation = FSMC_WriteOperation_E
Init.FSMC_WaitSignal = FSMC_WaitSignal_D
Init.FSMC_ExtendedMode = FSMC_ExtendedMode_D
Init.FSMC_WriteBurst = FSMC_WriteBurst_D
Init.FSMC_ReadWriteTimingStruct = &T
Init.FSMC_WriteTimingStruct = &T
FSMC_NORSRAMInit(&Init);
FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM4, ENABLE);
/**************************************************************************************
** Function name: & & & void LCD_InitHard(void)
** Descriptions: & & & &??? 1/4 >>?8875
** input parameters: & &??
** output parameters: & ??
** Returned value: & & &??
***************************************************************************************/
void LCD_InitHard(void)
LCD_GPIOConfig(); & & & & //????LCD???AE???ssGPIO&
LCD_FSMCConfig(); & & & & //????FSMC 1/2 ??????? 3/4 ?×??ss&
& Delay(10);
RA8875_InitHard();
& & &//??? 1/4 >>?RA AE?
RA8875_SetFillV(_LCD_SWAP_XY);
// &这里必须根据横屏或竖屏来设置显示屏的绘图填充方向,(实测不设置其实也没啥鸟事)
//下面的代码用来设置显示屏的扫描方向, XY的镜像是通过显示屏的设置实现的。
#if(!_LCD_SWAP_XY && !LCD_FLIP) &
RA8875_SetXY(2&&2);
#elif(_LCD_SWAP_XY && !LCD_FLIP)
RA8875_SetXY(0&&2);
#elif(!_LCD_SWAP_XY && LCD_FLIP)
RA8875_SetXY(1&&2);
#elif(_LCD_SWAP_XY && LCD_FLIP)
RA8875_SetXY(3&&2);
/**************************************************************************************
** Function name: & & & LCD_PutPixel(uint16_t X, uint16_t Y, uint16_t Color)
** Descriptions: & & & &>>ae?AE1,?????
** input parameters: & &x, y &??????×?±ê
** & & & & & & & & & & &Color ?????????<< & & &
** output parameters: & ??
** Returned value: & & &??
***************************************************************************************/
void LCD_PutPixel(uint16_t x, uint16_t y, uint16_t Color)
#if(!_LCD_SWAP_XY)
RA8875_PutPixel(x, y, Color);//横屏时调用
RA8875_PutPixel(y, x, Color);//竖屏时调用
#if(!_LCD_SWAP_XY)
/**************************************************************************************
** Function name: & & & LCD_PutPixel(uint16_t x, uint16_t y, uint16_t Color)
** Descriptions: & & & &????1,?????
** input parameters: & &x, y &??????×?±ê & & & & & & & & & & & & &&
** output parameters: & ??
** Returned value: & & &RGB ?????????<<&
***************************************************************************************/
uint16_t LCD_GetPixel(uint16_t x, uint16_t y)
uint16_t RGB;
#if(!_LCD_SWAP_XY)
RGB = RA8875_GetPixel(x, y);
RGB = RA8875_GetPixel(y, x);
return RGB;
/**************************************************************************************
** Function name: & & & void LCD_DrawLine(uint16_t X1 , uint16_t Y1 , uint16_t X2 , uint16_t Y2 , uint16_t Color)
** Descriptions: & & & &???? Bresenham ??·¨????2u? 1/4 ?>>-?>>???±?ss??
** input parameters: & &X1, Y1 ??AE?? 1/4 u?×?±ê
** & & & & & & & & &X2, Y2 ??????u?Y×?±ê
** & & & & & & & & & & &Color:>>-?ss???<<
** output parameters: & ??
** Returned value: & & &??
***************************************************************************************/
void LCD_DrawLine(uint16_t X1 , uint16_t Y1 , uint16_t X2 , uint16_t Y2 , uint16_t Color)
#if(!_LCD_SWAP_XY)
RA8875_DrawLine(X1 , Y1 , X2 , Y2 ,Color);
RA8875_DrawLine(Y1 , X1 , Y2 , X2 , Color);
/**************************************************************************************
** Function name: & & & void LCD_DrawLineH(uint16_t X1 , uint16_t Y1 , uint16_t X2, uint16_t Color)
** Descriptions: & & & &>>ae?AE?>>???(R)AE 1/2 ?ss ????UCGUIu? 1/2 ???????
** input parameters: & &X1 ??AE?? 1/4 u?X×?±ê
** & & & & & & & &Y1 ???(R)AE 1/2 ?ssu?Y×?±ê
** & & & & & & & &X2 ?? 1/2 á??u?X×?±ê
** & & & & & & & Color : ???<< & & & & & & & & & & &
** output parameters: & ??
** Returned value: & & &??
***************************************************************************************/
void LCD_DrawLineH(uint16_t X1 , uint16_t Y1 , uint16_t X2, uint16_t Color)
#if(!_LCD_SWAP_XY)
RA8875_DrawHLine(X1, Y1, X2, Color);
&RA8875_DrawVLine(Y1, X1, X2, Color);
#if(!_LCD_SWAP_XY)
/**************************************************************************************
** Function name: & & & void LCD_DrawHColorLine(uint16_t X1 , uint16_t Y1, uint16_t Width, uint16_t *pColor)
** Descriptions: & & & &>>ae?AE?>>?????<<?(R)AE 1/2 ?ss ????UCGUIu? 1/2 ???????
** input parameters: & &X1 & &??AE?? 1/4 u?X×?±ê
** & & & & & & & &Y1 & &???(R)AE 1/2 ?ssu?Y×?±ê
** & & & & & & & &Width ???±?ssu??í??
** & & & & & & & &pColor : ???<>????? & & & & & & & &
** output parameters: & ??
** Returned value: & & &??
***************************************************************************************/
void LCD_DrawHColorLine(uint16_t X1 , uint16_t Y1, uint16_t Width, uint16_t *pColor)
//这个函数是重点,emWin 所有的控件(wigt) 最终都是通过该函数画出来的。
#if(!_LCD_SWAP_XY)
&RA8875_DrawHColorLine(X1, Y1, Width, pColor);
RA8875_DrawBMP(Y1, X1, Width,1, pColor);//竖屏时,使用RA8875 的画图函数来实现(一个点一个点的画,那刷新效率不敢直视)
/**************************************************************************************
** Function name: & & & void LCD_DrawLineV(uint16_t X1 , uint16_t Y1 , uint16_t Y2, uint16_t Color)
** Descriptions: & & & &>>ae?AE?>>?????<<???±?ss ????UCGUIu? 1/2 ???????
** input parameters: & &X1 & &: ???±?ssu?X×?±ê
** & & & & & & & &Y1 & &: AE?? 1/4 u?Y×?±ê
** & & & & & & & &Y2 & &:
1/2 á??u?Y×?±ê
** & & & & & & & &Color : ???<< & & & & &&
** output parameters: & ??
** Returned value: & & &??
***************************************************************************************/
void LCD_DrawLineV(uint16_t X1 , uint16_t Y1 , uint16_t Y2, uint16_t Color)
#if(!_LCD_SWAP_XY)
RA8875_DrawVLine(X1 , Y1 , Y2 , Color);
RA8875_DrawHLine(Y1, X1, Y2, Color); //竖屏时画垂直线实际上时画水平线(从显示屏的角度讲)。
/**************************************************************************************
** Function name: & & & void LCD_FillRect(uint16_t X, uint16_t Y, uint16_t Height, uint16_t Width, uint16_t Color)
** Descriptions: & & & &>>- 3/4 ???
** input parameters: & &X, Y & ?? 3/4 ???×ó?? 1/2 ?×?±ê
** & & & & & & & &Height :
3/4 ???u?,ss?? & &
** & & & & & & & & & & &Width &?? 3/4 ???u??í??
** & & & & & & & & & Color &?????????<<
** output parameters: & ??
** Returned value: & & &??
***************************************************************************************/
void LCD_SetTarBlock(uint16_t X1, uint16_t Y1, uint16_t X2, uint16_t Y2)
//色块填充时用到该函数
#if(!_LCD_SWAP_XY)
BTE_SetTarBlock(X1, Y1, Y2-Y1&#43;1, X2-X1&#43;1, 0);
//?è??BTE?>>?????í??,ss??
BTE_SetTarBlock(Y1, X1, X2-X1&#43;1, Y2-Y1&#43;1, 0);
//?è??BTE?>>?????í??,ss??
这个文件完了,我还在 显示屏的驱动文件LCD_RA8875.c 里增加了一个 设置 显示屏扫描方向的函数(RA8875 的 0x40H &寄存器)
/**************************************************************************************
** Function name: & & & void RA8875_SetXY(uint16_t t)
** Descriptions: & & & &???±· 1/2 ?ò???(R)AE 1/2 ?¨?è· 1/2 ?ò?è?¨
** input parameters: & &t & : ?è??
** & & & & & & &
** output parameters: & ??
** Returned value: & & &??
***************************************************************************************/
void RA8875_SetXY(uint16_t t)
RA8875_WriteReg(0x20, t);
& &// ???±· 1/2 ?ò???(R)AE 1/2 ?¨?è· 1/2 ?ò?è?¨
接下来就是触摸屏坐标的映射,不同的显示方向。需要映射不同的触摸点 X,Y 的&#20540;。否则 触摸就是乱来的。
在触摸屏驱动文件gt9xx.c 中,我将
point_x = ((point_data[5]&&8) | point_data[4]);
point_y = ((point_data[3]&&8) | point_data[2]);
#if(!_LCD_SWAP_XY && !LCD_FLIP)
point_x = _LCD_WIDTH - 1 - ((point_data[5]&&8) | point_data[4]);
& & & & point_y = _LCD_HEIGHT - 1 - ((point_data[3]&&8) | point_data[2]);
#elif(_LCD_SWAP_XY && !LCD_FLIP)
point_x =_LCD_WIDTH - 1 - ((point_data[3]&&8) | point_data[2]);
point_y = ((point_data[5]&&8) | point_data[4]);
#elif(!_LCD_SWAP_XY && LCD_FLIP)
point_x = ((point_data[5]&&8) | point_data[4]);
point_y = ((point_data[3]&&8) | point_data[2]);
#elif(_LCD_SWAP_XY && LCD_FLIP)
point_x = ((point_data[3]&&8) | point_data[2]);
point_y = &_LCD_HEIGHT - 1 - ((point_data[5]&&8) | point_data[4]);
好了,到这里驱动上的修改基本完成。
接下来就是 LCDConf.c 和 LCDConf.H 两个文件。
我在 &LCDConf.H&文件中 进行宏定义如下:
#define &ORIENTATION & 0 & // 屏幕显示方向 & 取&#20540;范围 0 90 180 270
#if &ORIENTATION==0
#define _LCD_SWAP_XY 0
#define LCD_FLIP 0
#elif &ORA==90
#define _LCD_SWAP_XY 0
#define LCD_FLIP 1
#elif &ORA==180
#define _LCD_SWAP_XY 1
#define LCD_FLIP 1
#elif &ORA==270
#define _LCD_SWAP_XY 1
#define LCD_FLIP 0
#define LCD_HEIGHT 480
&//屏幕的高(和显示无关的高度)
#define LCD_WIDTH & & & & 800
&//屏幕的宽度(和显示无关的宽度)
#if _LCD_SWAP_XY ==0
#define _LCD_HEIGHT &LCD_HEIGHT
& &//屏幕的高(和显示方向相关)
#define _LCD_WIDTH &LCD_WIDTH
& //屏幕的宽(和显示方向相关)
#define _LCD_HEIGHT &LCD_WIDTH &
#define _LCD_WIDTH &LCD_HEIGHT
ORIENTATION & 宏 即使控制屏幕显示方向的总开关。
在LCDConf.C 中,屏幕(emWin 所感知到的屏幕)的高度和宽度,以及 触摸 的 限&#20540;需要根据 宏定义进行调整,
我修改成下面这样。
#define XSIZE_PHYS &_LCD_WIDTH
#define YSIZE_PHYS &_LCD_HEIGHT
#define VXSIZE_PHYS _LCD_WIDTH
#define VYSIZE_PHYS _LCD_HEIGHT
#define GUI_TOUCH_AD_TOP & & 0 &
#define GUI_TOUCH_AD_BOTTOM &_LCD_HEIGHT
#define GUI_TOUCH_AD_LEFT & &0 &&
#define GUI_TOUCH_AD_RIGHT & _LCD_WIDTH
到这里,所有的工作都完成了。
http://download.csdn.net/detail/godyde/9680713
请使用Keilc MDK打开.
本文已收录于以下专栏:
相关文章推荐
使用stm32F429,内部屏幕驱动器驱动RGB屏,使用EMWIN做界面,直接使用429的刷图函数刷底色显示正常,但是使用GUI_Init();后 到maintask();函数中间,做一些界面显示或者...
首先,XY轴的调换
在这个函数LCD_X_Config()中,
GUI_DEVICE_CreateAndLink(DISPLAY_DRIVER_0, COLOR_CONVERSION_0, 0,...
在网上看到不少人反映RA8875的触摸屏界面并不好用,并有不少人反映根本用不了的情况的。过年无聊在玩STM32F407和一个RA8875为核心的7寸屏幕的时候也遇到了不少的问题,就写出来跟大家分享一下...
曾经遇到过一个面试题,让你写出横屏切换竖屏Activity的生命周期。现在给大家分析一下他切换时具体的生命周期是怎么样的:
1、新建一个Activity,并把各个生命周期打印出来
2、运行...
Android横屏竖屏切换的问题
一、禁止横竖屏转换
Android横竖屏切换在手机开发中比较常见,很多软件在开发过程中为了避免横竖屏切换时引发不必要的麻烦,通常禁止掉横竖屏的切换,
在Android中要让一个程序的界面始终保持一个方向,不随手机方向转动而变化的办法: 只要在AndroidManifest.xml里面配置一下就可以了。在AndroidManifest.xml的act...
在Android中要让一个程序的界面始终保持一个方向,不随手机方向转动而变化的办法: 只要在AndroidManifest.xml里面配置一下就可以了。
在AndroidManifest.xml...
1、不同的layout
&#160;&#160;&#160;&#160;&#160;&#160;Android手机屏幕大小不一,有480x320,640x360,800x480.怎样才能让App自动适应不同的屏幕呢?&#160;其实很简单,只需要在...
他的最新文章
讲师:刘文志
讲师:陈伟
您举报文章:
举报原因:
原文地址:
原因补充:
(最多只允许输入30个字)

我要回帖

更多关于 word下拉列表内容控件 的文章

 

随机推荐