forked from achimdoebler/UGUI
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathugui_port.c
65 lines (56 loc) · 1.76 KB
/
ugui_port.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "lcd.h"//用户自己的LCD驱动显示接口
#include "ugui.h"
/*********************************************************************
*
* Public code,
*
* LCD_FIXEDPALETTE == 565, 65536 colors, RRRRRGGGGGGBBBBB
*
**********************************************************************
*/
#define B_BITS 5
#define G_BITS 6
#define R_BITS 5
#define R_MASK ((1 << R_BITS) -1)
#define G_MASK ((1 << G_BITS) -1)
#define B_MASK ((1 << B_BITS) -1)
/*********************************************************************
*
* Public code,
*
* LCD_FIXEDPALETTE == 565, 65536 colors, BBBBBGGGGGGRRRRR
*
**********************************************************************
*/
/*********************************************************************
*
* LCD_Color2Index_565
*/
unsigned LCD_Color2Index_565(UG_COLOR Color) {
int r,g,b;
r = (Color>> (8 - R_BITS)) & R_MASK;
g = (Color>> (16 - G_BITS)) & G_MASK;
b = (Color>> (24 - B_BITS)) & B_MASK;
return r + (g << R_BITS) + (b << (G_BITS + R_BITS));
}
/* Hardware accelerator for UG_DrawLine */
UG_RESULT _HW_DrawLine( UG_S16 x1, UG_S16 y1, UG_S16 x2, UG_S16 y2, UG_COLOR c )
{
LCD_DrawLine(x1,y1,x2,y2,c);//LCD_Color2Index_565(c) //用户自己的LCD驱动显示接口
return UG_RESULT_OK;
}
/* Hardware accelerator for UG_FillFrame*/
UG_RESULT _HW_FillFrame( UG_S16 x1, UG_S16 y1, UG_S16 x2, UG_S16 y2, UG_COLOR c )
{
LCD_Fill(x1,y1,x2,y2,c);//用户自己的LCD驱动显示接口
return UG_RESULT_OK;
}
void _HW_DrawPoint(UG_S16 x, UG_S16 y, UG_COLOR c)
{
LCD_DrawPoint(x,y,c);//用户自己的LCD驱动显示接口
}
void *_HW_FillAREA( UG_S16 x1, UG_S16 y1, UG_S16 x2, UG_S16 y2)
{
LCD_SetWindows(x1,y1,x2,y2);//用户自己的LCD驱动显示接口
return (void (*)(UG_COLOR))LCD_WR_DATA;
}