change to graphic device

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1462 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
qiuyiuestc@gmail.com 2011-06-08 00:50:04 +00:00
parent d84cef41c4
commit 34d4a1bf2f
7 changed files with 113 additions and 520 deletions

View File

@ -114,8 +114,17 @@ void rt_init_thread_entry(void* parameter)
#endif
#endif
#if defined(RT_USING_DFS) && defined(RT_USING_LWIP) && defined(RT_USING_DFS_NFS)
/* NFSv3 Initialization */
nfs_init();
if (dfs_mount(RT_NULL, "/nfs", "nfs", 0, RT_NFS_HOST_EXPORT) == 0)
rt_kprintf("NFSv3 File System initialized!\n");
else
rt_kprintf("NFSv3 File System initialzation failed!\n");
#endif
#if defined(RT_USING_DFS_UFFS)
{
/* init the uffs filesystem */
dfs_uffs_init();
@ -124,13 +133,14 @@ void rt_init_thread_entry(void* parameter)
rt_kprintf("UFFS File System initialized!\n");
else
rt_kprintf("UFFS File System initialzation failed!\n");
}
#endif
}
#endif
#ifdef RT_USING_RTGUI
{
rt_device_t *lcd;
/* init lcd */
rt_hw_lcd_init();
@ -143,6 +153,12 @@ void rt_init_thread_entry(void* parameter)
/* re-init device driver */
rt_device_init_all();
/* find lcd device */
lcd = rt_device_find("lcd");
/* set lcd device as rtgui graphic driver */
rtgui_graphic_set_device(lcd);
/* startup rtgui */
rtgui_startup();
}
@ -242,23 +258,4 @@ int rt_application_init()
return 0;
}
/* NFSv3 Initialization */
#if defined(RT_USING_DFS) && defined(RT_USING_LWIP) && defined(RT_USING_DFS_NFS)
#include <dfs_nfs.h>
void nfs_start(void)
{
nfs_init();
if (dfs_mount(RT_NULL, "/nfs", "nfs", 0, RT_NFS_HOST_EXPORT) == 0)
{
rt_kprintf("NFSv3 File System initialized!\n");
}
else
rt_kprintf("NFSv3 File System initialzation failed!\n");
}
#include "finsh.h"
FINSH_FUNCTION_EXPORT(nfs_start, start net filesystem);
#endif
/*@}*/

View File

@ -176,7 +176,7 @@ void calibration_entry(void* parameter)
rtgui_thread_register(rt_thread_self(), mq);
rtgui_graphic_driver_get_default_rect(&rect);
rtgui_graphic_driver_get_rect(rtgui_graphic_driver_get_default(), &rect);
/* set screen rect */
calibration_ptr->width = rect.x2;

View File

@ -18,9 +18,4 @@
void rt_hw_lcd_init();
#define RT_DEVICE_CTRL_LCD_GET_WIDTH 0
#define RT_DEVICE_CTRL_LCD_GET_HEIGHT 1
#define RT_DEVICE_CTRL_LCD_GET_BPP 2
#define RT_DEVICE_CTRL_LCD_GET_FRAMEBUFFER 3
#endif

View File

@ -112,22 +112,8 @@
#define S3C2410_LCDINT_FRSYNC (1<<1)
static volatile rt_uint16_t _rt_framebuffer[RT_HW_LCD_HEIGHT][RT_HW_LCD_WIDTH];
static volatile rt_uint16_t _rt_hw_framebuffer[RT_HW_LCD_HEIGHT][RT_HW_LCD_WIDTH];
struct rtgui_lcd_device
{
struct rt_device parent;
/* byte per pixel */
rt_uint16_t byte_per_pixel;
/* screen width and height */
rt_uint16_t width;
rt_uint16_t height;
void* hw_framebuffer;
};
static struct rtgui_lcd_device *lcd = RT_NULL;
//static volatile rt_uint16_t _rt_hw_framebuffer[RT_HW_LCD_HEIGHT][RT_HW_LCD_WIDTH];
static struct rt_device_graphic_info _lcd_info;
static void lcd_power_enable(int invpwren, int pwren)
{
@ -179,119 +165,6 @@ static void LcdBkLtSet(rt_uint32_t HiRatio)
TCON = TCON & (~(0xf<<8)) | (0x0d<<8) ;
}
#ifdef RT_USING_RTGUI
#include <rtgui/driver.h>
#include <rtgui/color.h>
static void rt_hw_lcd_update(rtgui_rect_t *rect)
{
rt_uint32_t i, j;
for (i = rect->y1; i < rect->y2; i ++)
{
for(j = rect->x1; j < rect->x2; j++)
_rt_hw_framebuffer[i][j] = _rt_framebuffer[i][j];
}
}
static rt_uint8_t * rt_hw_lcd_get_framebuffer(void)
{
return (rt_uint8_t *)_rt_framebuffer;
}
static void rt_hw_lcd_set_pixel(rtgui_color_t *c, rt_base_t x, rt_base_t y)
{
if (x < RT_HW_LCD_WIDTH && y < RT_HW_LCD_HEIGHT)
{
_rt_framebuffer[(y)][(x)] = rtgui_color_to_565p(*c);
}
}
static void rt_hw_lcd_get_pixel(rtgui_color_t *c, rt_base_t x, rt_base_t y)
{
if (x < RT_HW_LCD_WIDTH && y < RT_HW_LCD_HEIGHT)
{
*c = rtgui_color_from_565p(_rt_framebuffer[(y)][(x)]);
}
}
static void rt_hw_lcd_draw_hline(rtgui_color_t *c, rt_base_t x1, rt_base_t x2, rt_base_t y)
{
rt_uint32_t idx;
rt_uint16_t color;
/* get color pixel */
color = rtgui_color_to_565p(*c);
for (idx = x1; idx < x2; idx ++)
{
_rt_framebuffer[y][idx] = color;
}
}
static void rt_hw_lcd_draw_vline(rtgui_color_t *c, rt_base_t x, rt_base_t y1, rt_base_t y2)
{
rt_uint32_t idy;
rt_uint16_t color;
/* get color pixel */
color = rtgui_color_to_565p(*c);
for (idy = y1; idy < y2; idy ++)
{
_rt_framebuffer[idy][x] = color;
}
}
static void rt_hw_lcd_draw_raw_hline(rt_uint8_t *pixels, rt_base_t x1, rt_base_t x2, rt_base_t y)
{
rt_memcpy((void*)&_rt_framebuffer[y][x1], pixels, (x2 - x1) * 2);
}
struct rtgui_graphic_driver _rtgui_lcd_driver =
{
"lcd",
2,
RT_HW_LCD_WIDTH,
RT_HW_LCD_HEIGHT,
rt_hw_lcd_update,
rt_hw_lcd_get_framebuffer,
rt_hw_lcd_set_pixel,
rt_hw_lcd_get_pixel,
rt_hw_lcd_draw_hline,
rt_hw_lcd_draw_vline,
rt_hw_lcd_draw_raw_hline
};
#include "finsh.h"
void hline(rt_uint32_t c, int x1, int x2, int y)
{
rtgui_color_t color = (rtgui_color_t)c;
rt_hw_lcd_draw_hline(&color, x1, x2, y);
}
FINSH_FUNCTION_EXPORT(hline, draw a hline);
void vline(rt_uint32_t c, int x, int y1, int y2)
{
rtgui_color_t color = (rtgui_color_t)c;
rt_hw_lcd_draw_vline(&color, x, y1, y2);
}
FINSH_FUNCTION_EXPORT(vline, draw a vline);
void clear()
{
int y;
for (y = 0; y < LCD_HEIGHT; y ++)
{
rt_hw_lcd_draw_hline((rtgui_color_t*)&white, 0, LCD_WIDTH, y);
}
}
FINSH_FUNCTION_EXPORT(clear, clear screen);
#endif
/* RT-Thread Device Interface */
static rt_err_t rt_lcd_init (rt_device_t dev)
{
@ -305,7 +178,7 @@ static rt_err_t rt_lcd_init (rt_device_t dev)
GPDCON = 0xaaaaaaaa;
#define M5D(n) ((n)&0x1fffff)
#define LCD_ADDR ((rt_uint32_t)_rt_hw_framebuffer)
#define LCD_ADDR ((rt_uint32_t)_rt_framebuffer)
LCDCON1 = (LCD_PIXCLOCK << 8) | (3 << 5) | (12 << 1);
LCDCON2 = (LCD_UPPER_MARGIN << 24) | ((LCD_HEIGHT - 1) << 14) | (LCD_LOWER_MARGIN << 6) | (LCD_VSYNC_LEN << 0);
LCDCON3 = (LCD_RIGHT_MARGIN << 19) | ((LCD_WIDTH - 1) << 8) | (LCD_LEFT_MARGIN << 0);
@ -334,21 +207,17 @@ static rt_err_t rt_lcd_control (rt_device_t dev, rt_uint8_t cmd, void *args)
{
switch (cmd)
{
case RT_DEVICE_CTRL_LCD_GET_WIDTH:
*((rt_uint16_t*)args) = lcd->width;
case RTGRAPHIC_CTRL_RECT_UPDATE:
break;
case RT_DEVICE_CTRL_LCD_GET_HEIGHT:
*((rt_uint16_t*)args) = lcd->height;
case RTGRAPHIC_CTRL_POWERON:
break;
case RT_DEVICE_CTRL_LCD_GET_BPP:
*((rt_uint16_t*)args) = lcd->byte_per_pixel;
case RTGRAPHIC_CTRL_POWEROFF:
break;
case RTGRAPHIC_CTRL_GET_INFO:
rt_memcpy(args, &_lcd_info, sizeof(_lcd_info));
break;
case RTGRAPHIC_CTRL_SET_MODE:
break;
case RT_DEVICE_CTRL_LCD_GET_FRAMEBUFFER:
*((rt_uint16_t*)args) = lcd->hw_framebuffer;
break;
}
return RT_EOK;
@ -356,25 +225,24 @@ static rt_err_t rt_lcd_control (rt_device_t dev, rt_uint8_t cmd, void *args)
void rt_hw_lcd_init(void)
{
lcd = (struct rtgui_lcd_device*)rt_malloc(sizeof(struct rtgui_lcd_device));
rt_device_t lcd = rt_malloc(sizeof(struct rt_device));
if (lcd == RT_NULL) return; /* no memory yet */
/* init device structure */
lcd->parent.type = RT_Device_Class_Unknown;
lcd->parent.init = rt_lcd_init;
lcd->parent.control = rt_lcd_control;
lcd->parent.user_data = RT_NULL;
lcd->byte_per_pixel = 2;
lcd->width = LCD_WIDTH;
lcd->height = LCD_HEIGHT;
lcd->hw_framebuffer = (void*)_rt_hw_framebuffer;
/* register touch device to RT-Thread */
rt_device_register(&(lcd->parent), "lcd", RT_DEVICE_FLAG_RDWR);
_lcd_info.bits_per_pixel = 16;
_lcd_info.pixel_format = RTGRAPHIC_PIXEL_FORMAT_RGB565;
_lcd_info.framebuffer = (void*)_rt_framebuffer;
_lcd_info.width = LCD_WIDTH;
_lcd_info.height = LCD_HEIGHT;
#ifdef RT_USING_RTGUI
/* add lcd driver into graphic driver */
rtgui_graphic_driver_add(&_rtgui_lcd_driver);
#endif
/* init device structure */
lcd->type = RT_Device_Class_Unknown;
lcd->init = rt_lcd_init;
lcd->open = RT_NULL;
lcd->close = RT_NULL;
lcd->control = rt_lcd_control;
lcd->user_data = (void*)&_lcd_info;
/* register lcd device to RT-Thread */
rt_device_register(lcd, "lcd", RT_DEVICE_FLAG_RDWR);
}

View File

@ -13,10 +13,10 @@
*/
#include <rtthread.h>
#include <s3c24x0.h>
#include "lcd.h"
/* LCD driver for N3'5 */
#define LCD_WIDTH 240
#define LCD_HEIGHT 320
@ -113,22 +113,8 @@
#define S3C2410_LCDINT_FRSYNC (1<<1)
static volatile rt_uint16_t _rt_framebuffer[RT_HW_LCD_HEIGHT][RT_HW_LCD_WIDTH];
static volatile rt_uint16_t _rt_hw_framebuffer[RT_HW_LCD_HEIGHT][RT_HW_LCD_WIDTH];
struct rtgui_lcd_device
{
struct rt_device parent;
/* byte per pixel */
rt_uint16_t byte_per_pixel;
/* screen width and height */
rt_uint16_t width;
rt_uint16_t height;
void* hw_framebuffer;
};
static struct rtgui_lcd_device *lcd = RT_NULL;
//static volatile rt_uint16_t _rt_hw_framebuffer[RT_HW_LCD_HEIGHT][RT_HW_LCD_WIDTH];
static struct rt_device_graphic_info _lcd_info;
static void lcd_power_enable(int invpwren, int pwren)
{
@ -180,119 +166,6 @@ static void LcdBkLtSet(rt_uint32_t HiRatio)
TCON = TCON & (~(0xf<<8)) | (0x0d<<8) ;
}
#ifdef RT_USING_RTGUI
#include <rtgui/driver.h>
#include <rtgui/color.h>
static void rt_hw_lcd_update(rtgui_rect_t *rect)
{
rt_uint32_t i, j;
for (i = rect->y1; i < rect->y2; i ++)
{
for(j = rect->x1; j < rect->x2; j++)
_rt_hw_framebuffer[i][j] = _rt_framebuffer[i][j];
}
}
static rt_uint8_t * rt_hw_lcd_get_framebuffer(void)
{
return (rt_uint8_t *)_rt_framebuffer;
}
static void rt_hw_lcd_set_pixel(rtgui_color_t *c, rt_base_t x, rt_base_t y)
{
if (x < RT_HW_LCD_WIDTH && y < RT_HW_LCD_HEIGHT)
{
_rt_framebuffer[(y)][(x)] = rtgui_color_to_565p(*c);
}
}
static void rt_hw_lcd_get_pixel(rtgui_color_t *c, rt_base_t x, rt_base_t y)
{
if (x < RT_HW_LCD_WIDTH && y < RT_HW_LCD_HEIGHT)
{
*c = rtgui_color_from_565p(_rt_framebuffer[(y)][(x)]);
}
}
static void rt_hw_lcd_draw_hline(rtgui_color_t *c, rt_base_t x1, rt_base_t x2, rt_base_t y)
{
rt_uint32_t idx;
rt_uint16_t color;
/* get color pixel */
color = rtgui_color_to_565p(*c);
for (idx = x1; idx < x2; idx ++)
{
_rt_framebuffer[y][idx] = color;
}
}
static void rt_hw_lcd_draw_vline(rtgui_color_t *c, rt_base_t x, rt_base_t y1, rt_base_t y2)
{
rt_uint32_t idy;
rt_uint16_t color;
/* get color pixel */
color = rtgui_color_to_565p(*c);
for (idy = y1; idy < y2; idy ++)
{
_rt_framebuffer[idy][x] = color;
}
}
static void rt_hw_lcd_draw_raw_hline(rt_uint8_t *pixels, rt_base_t x1, rt_base_t x2, rt_base_t y)
{
rt_memcpy((void*)&_rt_framebuffer[y][x1], pixels, (x2 - x1) * 2);
}
struct rtgui_graphic_driver _rtgui_lcd_driver =
{
"lcd",
2,
RT_HW_LCD_WIDTH,
RT_HW_LCD_HEIGHT,
rt_hw_lcd_update,
rt_hw_lcd_get_framebuffer,
rt_hw_lcd_set_pixel,
rt_hw_lcd_get_pixel,
rt_hw_lcd_draw_hline,
rt_hw_lcd_draw_vline,
rt_hw_lcd_draw_raw_hline
};
#include "finsh.h"
void hline(rt_uint32_t c, int x1, int x2, int y)
{
rtgui_color_t color = (rtgui_color_t)c;
rt_hw_lcd_draw_hline(&color, x1, x2, y);
}
FINSH_FUNCTION_EXPORT(hline, draw a hline);
void vline(rt_uint32_t c, int x, int y1, int y2)
{
rtgui_color_t color = (rtgui_color_t)c;
rt_hw_lcd_draw_vline(&color, x, y1, y2);
}
FINSH_FUNCTION_EXPORT(vline, draw a vline);
void clear()
{
int y;
for (y = 0; y < LCD_HEIGHT; y ++)
{
rt_hw_lcd_draw_hline((rtgui_color_t*)&white, 0, LCD_WIDTH, y);
}
}
FINSH_FUNCTION_EXPORT(clear, clear screen);
#endif
/* RT-Thread Device Interface */
static rt_err_t rt_lcd_init (rt_device_t dev)
{
@ -306,7 +179,7 @@ static rt_err_t rt_lcd_init (rt_device_t dev)
GPDCON = 0xaaaaaaaa;
#define M5D(n) ((n)&0x1fffff)
#define LCD_ADDR ((rt_uint32_t)_rt_hw_framebuffer)
#define LCD_ADDR ((rt_uint32_t)_rt_framebuffer)
LCDCON1 = (LCD_PIXCLOCK << 8) | (3 << 5) | (12 << 1);
LCDCON2 = (LCD_UPPER_MARGIN << 24) | ((LCD_HEIGHT - 1) << 14) | (LCD_LOWER_MARGIN << 6) | (LCD_VSYNC_LEN << 0);
LCDCON3 = (LCD_RIGHT_MARGIN << 19) | ((LCD_WIDTH - 1) << 8) | (LCD_LEFT_MARGIN << 0);
@ -335,47 +208,42 @@ static rt_err_t rt_lcd_control (rt_device_t dev, rt_uint8_t cmd, void *args)
{
switch (cmd)
{
case RT_DEVICE_CTRL_LCD_GET_WIDTH:
*((rt_uint16_t*)args) = lcd->width;
case RTGRAPHIC_CTRL_RECT_UPDATE:
break;
case RT_DEVICE_CTRL_LCD_GET_HEIGHT:
*((rt_uint16_t*)args) = lcd->height;
case RTGRAPHIC_CTRL_POWERON:
break;
case RT_DEVICE_CTRL_LCD_GET_BPP:
*((rt_uint16_t*)args) = lcd->byte_per_pixel;
case RTGRAPHIC_CTRL_POWEROFF:
break;
case RTGRAPHIC_CTRL_GET_INFO:
rt_memcpy(args, &_lcd_info, sizeof(_lcd_info));
break;
case RTGRAPHIC_CTRL_SET_MODE:
break;
case RT_DEVICE_CTRL_LCD_GET_FRAMEBUFFER:
*((rt_uint16_t*)args) = lcd->hw_framebuffer;
break;
}
return RT_EOK;
}
void rtgui_lcd_hw_init(void)
void rt_hw_lcd_init(void)
{
lcd = (struct rtgui_lcd_device*)rt_malloc(sizeof(struct rtgui_lcd_device));
rt_device_t lcd = rt_malloc(sizeof(struct rt_device));
if (lcd == RT_NULL) return; /* no memory yet */
/* init device structure */
lcd->parent.type = RT_Device_Class_Unknown;
lcd->parent.init = rt_lcd_init;
lcd->parent.control = rt_lcd_control;
lcd->parent.user_data = RT_NULL;
lcd->byte_per_pixel = 2;
lcd->width = LCD_WIDTH;
lcd->height = LCD_HEIGHT;
lcd->hw_framebuffer = (void*)_rt_hw_framebuffer;
/* register touch device to RT-Thread */
rt_device_register(&(lcd->parent), "lcd", RT_DEVICE_FLAG_RDWR);
_lcd_info.bits_per_pixel = 16;
_lcd_info.pixel_format = RTGRAPHIC_PIXEL_FORMAT_RGB565;
_lcd_info.framebuffer = (void*)_rt_framebuffer;
_lcd_info.width = LCD_WIDTH;
_lcd_info.height = LCD_HEIGHT;
#ifdef RT_USING_RTGUI
/* add lcd driver into graphic driver */
rtgui_graphic_driver_add(&_rtgui_lcd_driver);
#endif
/* init device structure */
lcd->type = RT_Device_Class_Unknown;
lcd->init = rt_lcd_init;
lcd->open = RT_NULL;
lcd->close = RT_NULL;
lcd->control = rt_lcd_control;
lcd->user_data = (void*)&_lcd_info;
/* register lcd device to RT-Thread */
rt_device_register(lcd, "lcd", RT_DEVICE_FLAG_RDWR);
}

View File

@ -15,7 +15,6 @@
#include <rtthread.h>
#include <s3c24x0.h>
#include "lcd.h"
/* LCD driver for T3'5 */
@ -114,22 +113,8 @@
#define S3C2410_LCDINT_FRSYNC (1<<1)
volatile rt_uint16_t _rt_framebuffer[RT_HW_LCD_HEIGHT][RT_HW_LCD_WIDTH];
volatile rt_uint16_t _rt_hw_framebuffer[RT_HW_LCD_HEIGHT][RT_HW_LCD_WIDTH];
struct rtgui_lcd_device
{
struct rt_device parent;
/* byte per pixel */
rt_uint16_t byte_per_pixel;
/* screen width and height */
rt_uint16_t width;
rt_uint16_t height;
void* hw_framebuffer;
};
static struct rtgui_lcd_device *lcd = RT_NULL;
//volatile rt_uint16_t _rt_hw_framebuffer[RT_HW_LCD_HEIGHT][RT_HW_LCD_WIDTH];
static struct rt_device_graphic_info _lcd_info;
static void lcd_power_enable(int invpwren, int pwren)
{
@ -181,119 +166,6 @@ static void LcdBkLtSet(rt_uint32_t HiRatio)
TCON = TCON & (~(0xf<<8)) | (0x0d<<8) ;
}
#ifdef RT_USING_RTGUI
#include <rtgui/driver.h>
#include <rtgui/color.h>
static void rt_hw_lcd_update(rtgui_rect_t *rect)
{
rt_uint32_t i, j;
for (i = rect->y1; i < rect->y2; i ++)
{
for(j = rect->x1; j < rect->x2; j++)
_rt_hw_framebuffer[i][j] = _rt_framebuffer[i][j];
}
}
static rt_uint8_t * rt_hw_lcd_get_framebuffer(void)
{
return (rt_uint8_t *)_rt_framebuffer;
}
static void rt_hw_lcd_set_pixel(rtgui_color_t *c, rt_base_t x, rt_base_t y)
{
if (x < RT_HW_LCD_WIDTH && y < RT_HW_LCD_HEIGHT)
{
_rt_framebuffer[(y)][(x)] = rtgui_color_to_565p(*c);
}
}
static void rt_hw_lcd_get_pixel(rtgui_color_t *c, rt_base_t x, rt_base_t y)
{
if (x < RT_HW_LCD_WIDTH && y < RT_HW_LCD_HEIGHT)
{
*c = rtgui_color_from_565p(_rt_framebuffer[(y)][(x)]);
}
}
static void rt_hw_lcd_draw_hline(rtgui_color_t *c, rt_base_t x1, rt_base_t x2, rt_base_t y)
{
rt_uint32_t idx;
rt_uint16_t color;
/* get color pixel */
color = rtgui_color_to_565p(*c);
for (idx = x1; idx < x2; idx ++)
{
_rt_framebuffer[y][idx] = color;
}
}
static void rt_hw_lcd_draw_vline(rtgui_color_t *c, rt_base_t x, rt_base_t y1, rt_base_t y2)
{
rt_uint32_t idy;
rt_uint16_t color;
/* get color pixel */
color = rtgui_color_to_565p(*c);
for (idy = y1; idy < y2; idy ++)
{
_rt_framebuffer[idy][x] = color;
}
}
static void rt_hw_lcd_draw_raw_hline(rt_uint8_t *pixels, rt_base_t x1, rt_base_t x2, rt_base_t y)
{
rt_memcpy((void*)&_rt_framebuffer[y][x1], pixels, (x2 - x1) * 2);
}
struct rtgui_graphic_driver _rtgui_lcd_driver =
{
"lcd",
2,
RT_HW_LCD_WIDTH,
RT_HW_LCD_HEIGHT,
rt_hw_lcd_update,
rt_hw_lcd_get_framebuffer,
rt_hw_lcd_set_pixel,
rt_hw_lcd_get_pixel,
rt_hw_lcd_draw_hline,
rt_hw_lcd_draw_vline,
rt_hw_lcd_draw_raw_hline
};
#include "finsh.h"
void hline(rt_uint32_t c, int x1, int x2, int y)
{
rtgui_color_t color = (rtgui_color_t)c;
rt_hw_lcd_draw_hline(&color, x1, x2, y);
}
FINSH_FUNCTION_EXPORT(hline, draw a hline);
void vline(rt_uint32_t c, int x, int y1, int y2)
{
rtgui_color_t color = (rtgui_color_t)c;
rt_hw_lcd_draw_vline(&color, x, y1, y2);
}
FINSH_FUNCTION_EXPORT(vline, draw a vline);
void clear()
{
int y;
for (y = 0; y < LCD_HEIGHT; y ++)
{
rt_hw_lcd_draw_hline((rtgui_color_t*)&white, 0, LCD_WIDTH, y);
}
}
FINSH_FUNCTION_EXPORT(clear, clear screen);
#endif
/* RT-Thread Device Interface */
static rt_err_t rt_lcd_init (rt_device_t dev)
{
@ -337,59 +209,42 @@ static rt_err_t rt_lcd_control (rt_device_t dev, rt_uint8_t cmd, void *args)
{
switch (cmd)
{
case RT_DEVICE_CTRL_LCD_GET_WIDTH:
*((rt_uint16_t*)args) = lcd->width;
case RTGRAPHIC_CTRL_RECT_UPDATE:
break;
case RT_DEVICE_CTRL_LCD_GET_HEIGHT:
*((rt_uint16_t*)args) = lcd->height;
case RTGRAPHIC_CTRL_POWERON:
break;
case RT_DEVICE_CTRL_LCD_GET_BPP:
*((rt_uint16_t*)args) = lcd->byte_per_pixel;
case RTGRAPHIC_CTRL_POWEROFF:
break;
case RTGRAPHIC_CTRL_GET_INFO:
rt_memcpy(args, &_lcd_info, sizeof(_lcd_info));
break;
case RTGRAPHIC_CTRL_SET_MODE:
break;
}
return RT_EOK;
}
static rt_err_t rt_lcd_open(rt_device_t dev, rt_uint16_t oflag)
{
RT_ASSERT(dev != RT_NULL);
return RT_EOK;
}
static rt_err_t rt_lcd_close(rt_device_t dev)
{
RT_ASSERT(dev != RT_NULL);
return RT_EOK;
}
void rt_hw_lcd_init(void)
{
lcd = (struct rtgui_lcd_device*)rt_malloc(sizeof(struct rtgui_lcd_device));
rt_device_t lcd = rt_malloc(sizeof(struct rt_device));
if (lcd == RT_NULL) return; /* no memory yet */
/* init device structure */
lcd->parent.type = RT_Device_Class_Unknown;
lcd->parent.init = rt_lcd_init;
lcd->parent.open = rt_lcd_open;
lcd->parent.close = rt_lcd_close;
lcd->parent.control = rt_lcd_control;
lcd->parent.user_data = RT_NULL;
lcd->byte_per_pixel = 2;
lcd->width = LCD_WIDTH;
lcd->height = LCD_HEIGHT;
lcd->hw_framebuffer = (void*)_rt_framebuffer;
/* register touch device to RT-Thread */
rt_device_register(&(lcd->parent), "lcd", RT_DEVICE_FLAG_RDWR);
_lcd_info.bits_per_pixel = 16;
_lcd_info.pixel_format = RTGRAPHIC_PIXEL_FORMAT_RGB565;
_lcd_info.framebuffer = (void*)_rt_framebuffer;
_lcd_info.width = LCD_WIDTH;
_lcd_info.height = LCD_HEIGHT;
#ifdef RT_USING_RTGUI
/* add lcd driver into graphic driver */
rtgui_graphic_driver_add(&_rtgui_lcd_driver);
#endif
/* init device structure */
lcd->type = RT_Device_Class_Unknown;
lcd->init = rt_lcd_init;
lcd->open = RT_NULL;
lcd->close = RT_NULL;
lcd->control = rt_lcd_control;
lcd->user_data = (void*)&_lcd_info;
/* register lcd device to RT-Thread */
rt_device_register(lcd, "lcd", RT_DEVICE_FLAG_RDWR);
}

View File

@ -415,7 +415,9 @@ static rt_err_t rtgui_touch_control (rt_device_t dev, rt_uint8_t cmd, void *args
void rtgui_touch_hw_init(void)
{
rt_err_t result = RT_FALSE;
rt_device_t device = RT_NULL;
struct rt_device_graphic_info info;
touch = (struct rtgui_touch_device*)rt_malloc (sizeof(struct rtgui_touch_device));
if (touch == RT_NULL) return; /* no memory yet */
@ -439,8 +441,16 @@ void rtgui_touch_hw_init(void)
device = rt_device_find("lcd");
if (device == RT_NULL) return; /* no this device */
rt_device_control(device, RT_DEVICE_CTRL_LCD_GET_WIDTH, (void*)&touch->width);
rt_device_control(device, RT_DEVICE_CTRL_LCD_GET_HEIGHT, (void*)&touch->height);
/* get graphic device info */
result = rt_device_control(device, RTGRAPHIC_CTRL_GET_INFO, &info);
if (result != RT_EOK)
{
/* get device information failed */
return;
}
touch->width = info.width;
touch->height = info.height;
/* create 1/8 second timer */
touch->poll_timer = rt_timer_create("touch", touch_timer_fire, RT_NULL,