git-svn-id: https://rt-thread.googlecode.com/svn/trunk@262 bbd45198-f89e-11dd-88c7-29a3b14d5316

This commit is contained in:
aganhx@gmail.com 2009-12-29 15:08:26 +00:00
parent 63d6608b85
commit 089427d9c5
8 changed files with 298 additions and 17 deletions

View File

@ -14,7 +14,6 @@ env = Environment(tools = ['mingw'],
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
env.AppendUnique(CPPPATH = bsp_path)
env.AppendUnique(CCFLAGS = ' -DUSE_STDPERIPH_DRIVER -DSTM32F10X_HD')
Export('env')
Export('RTT_ROOT')
@ -38,8 +37,8 @@ if rtconfig.RT_USING_LWIP:
if rtconfig.RT_USING_RTGUI:
objs = objs + SConscript(RTT_ROOT + '/rtgui/SConscript', variant_dir='build/rtgui', duplicate=0)
src_bsp = ['application.c', 'startup.c', 'board.c','led.c']
src_drv = ['console.c']
src_bsp = ['application.c', 'startup.c', 'board.c']
src_drv = ['console.c', 'led.c']
if rtconfig.RT_USING_DFS:
src_drv += ['sdcard.c']
@ -48,7 +47,16 @@ if rtconfig.RT_USING_LWIP:
src_drv += ['dm9000.c']
if rtconfig.RT_USING_RTGUI:
src_drv += ['touch.c']
src_drv += ['touch.c', 'key.c']
if rtconfig.RT_USING_RTGUI:
if rtconfig.RT_USING_LCD_TYPE == 'PNL_AT070TN84':
src_drv += ['lcd_at070.c']
elif rtconfig.RT_USING_LCD_TYPE == 'PNL_NEC320240':
src_drv += ['lcd.c']
if rtconfig.RT_USING_DEMO_GUI:
src_drv += ['demo_gui.c']
objs = objs + env.Object(src_bsp + src_drv)

View File

@ -20,6 +20,7 @@
#include <board.h>
#include <rtthread.h>
#include <rtgui/rtgui.h>
#include "led.h"
#ifdef RT_USING_DFS
@ -35,6 +36,11 @@
#include <netif/ethernetif.h>
#endif
#ifdef RT_USING_RTGUI
extern void rt_hw_lcd_init(void);
extern void rt_hw_key_init(void);
#endif
void rt_init_thread_entry(void* parameter)
{
/* Filesystem Initialization */
@ -69,6 +75,12 @@ void rt_init_thread_entry(void* parameter)
}
#endif
#ifdef RT_USING_RTGUI
{
rt_hw_key_init();
}
#endif
/* LwIP Initialization */
#ifdef RT_USING_LWIP
{
@ -105,11 +117,16 @@ void rt_led_thread_entry(void* parameter)
}
}
int rt_application_init()
{
rt_thread_t init_thread;
rt_thread_t led_thread;
#ifdef RT_USING_RTGUI
rt_hw_lcd_init();
#endif
#if (RT_THREAD_PRIORITY_MAX == 32)
init_thread = rt_thread_create("init",
rt_init_thread_entry, RT_NULL,

245
bsp/mini2440/demo_gui.c Normal file
View File

@ -0,0 +1,245 @@
#include <rtgui/rtgui.h>
#include <rtgui/rtgui_system.h>
#include <rtgui/widgets/window.h>
#include <rtgui/widgets/label.h>
#include <finsh.h>
static struct rtgui_timer *timer;
static struct rtgui_label* label;
static struct rtgui_win* msgbox;
static rt_uint8_t label_text[80];
static int cnt = 5;
void diag_close(struct rtgui_timer* timer, void* parameter)
{
rt_sprintf(label_text, "closed then %d second!", cnt);
rtgui_label_set_text(label, label_text);
rtgui_widget_update(RTGUI_WIDGET(label));
if (cnt == 0)
{
rtgui_win_destroy(msgbox);
rtgui_timer_stop(timer);
rtgui_timer_destory(timer);
}
cnt --;
}
void msg()
{
rt_mq_t mq;
rt_thread_t tid;
rt_uint32_t user_data;
struct rtgui_rect rect = {50, 50, 200, 200};
tid = rt_thread_self();
if (tid == RT_NULL) return; /* can't use in none-scheduler environement */
user_data = tid->user_data;
/* create gui message queue */
mq = rt_mq_create("msgbox", 256, 4, RT_IPC_FLAG_FIFO);
/* register message queue on current thread */
rtgui_thread_register(rt_thread_self(), mq);
msgbox = rtgui_win_create(RT_NULL, "Information", &rect, RTGUI_WIN_STYLE_DEFAULT);
if (msgbox != RT_NULL)
{
struct rtgui_box* box = rtgui_box_create(RTGUI_VERTICAL, RT_NULL);
cnt = 5;
rt_sprintf(label_text, "closed then %d second!", cnt);
label = rtgui_label_create(label_text);
rtgui_win_set_box(msgbox, box);
RTGUI_WIDGET(label)->align = RTGUI_ALIGN_CENTER_HORIZONTAL |
RTGUI_ALIGN_CENTER_VERTICAL;
rtgui_widget_set_miniwidth(RTGUI_WIDGET(label),130);
rtgui_box_append(box, RTGUI_WIDGET(label));
rtgui_box_layout(box);
rtgui_win_show(msgbox, RT_TRUE);
}
timer = rtgui_timer_create(200, RT_TIMER_FLAG_PERIODIC,
diag_close, RT_NULL);
rtgui_timer_start(timer);
rtgui_win_event_loop(msgbox);
rtgui_thread_deregister(rt_thread_self());
/* remove RTGUI message queue */
rt_mq_delete(mq);
/* recover user data */
tid->user_data = user_data;
}
FINSH_FUNCTION_EXPORT(msg, msg on gui)
#include <rtgui/rtgui.h>
#include <rtgui/rtgui_system.h>
#include <rtgui/widgets/box.h>
#include <rtgui/widgets/button.h>
#include <rtgui/widgets/window.h>
#include <rtgui/widgets/textbox.h>
#include <rtgui/widgets/iconbox.h>
#include <rtgui/widgets/view.h>
#include <rtgui/widgets/workbench.h>
/* XPM */
static const char *goto_xpm[] = {
/* columns rows colors chars-per-pixel */
"16 16 43 1",
". c Black",
"e c #0F0F0F",
"= c #2D2D2D",
"> c #3C3C3C",
"X c #010101",
"$ c #101010",
"% c #1F1F1F",
"r c #090909",
"- c #272727",
"3 c #363636",
"+ c #020202",
"# c #111111",
"2 c #3E3E3E",
"i c #4D4D4D",
"q c #191919",
", c #373737",
"f c #464646",
"o c #030303",
"u c #121212",
"p c #212121",
"; c #0B0B0B",
" c None",
"7 c #292929",
"O c #040404",
"6 c #131313",
"5 c #222222",
"t c #313131",
"4 c #4F4F4F",
"@ c #0C0C0C",
"a c #1B1B1B",
"* c #2A2A2A",
"0 c #141414",
"< c #0D0D0D",
": c #3A3A3A",
"9 c #060606",
"& c #151515",
"w c #242424",
"s c #424242",
"d c #1D1D1D",
"8 c #070707",
"1 c #161616",
"g c #252525",
"y c #343434",
/* pixels */
" .XX. ",
" oOOO+ ",
" @####o ",
" $%%%%& ",
" .*===-+ ",
" ;:>,; ",
" <# 12O ",
" 345 .X. ",
" 678 .X++X ",
" +9999o ",
" o0&&&6+ ",
" qwwwwe ",
" rtyy% ",
" +; uip ",
" asd o ",
" $fg "
};
static struct rtgui_image* image = RT_NULL;
static void rtgui_demo_workbench_entry(void* parameter)
{
rt_mq_t mq;
struct rtgui_view* view;
struct rtgui_workbench* workbench;
/* init rtgui demo message queue */
mq = rt_mq_create("mqWB", 256, 4, RT_IPC_FLAG_FIFO);
/* register thread and message queue */
rtgui_thread_register(rt_thread_self(), mq);
/* create container */
workbench = rtgui_workbench_create("main", "widget");
if (workbench == RT_NULL) return;
/************************************************************************/
/* Create View */
/************************************************************************/
view = rtgui_view_create("widget");
rtgui_workbench_add_view(workbench, view);
image = rtgui_image_create_from_mem("xpm", (rt_uint8_t*)goto_xpm, sizeof(goto_xpm), RT_TRUE);
{
struct rtgui_box *box = rtgui_box_create(RTGUI_VERTICAL, &rtgui_empty_rect);
struct rtgui_box *hbox = rtgui_box_create(RTGUI_HORIZONTAL, &rtgui_empty_rect);
struct rtgui_button* button = rtgui_button_create("OK");
struct rtgui_textbox *textbox = rtgui_textbox_create("text edit box");
struct rtgui_iconbox *iconbox = rtgui_iconbox_create(image, "icon",
RTGUI_ICONBOX_TEXT_RIGHT);
RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(view)) = RTGUI_RGB(255, 255, 224);
rtgui_view_set_box(view, box);
RTGUI_WIDGET(button)->align = RTGUI_ALIGN_CENTER_VERTICAL;
rtgui_widget_set_miniwidth(RTGUI_WIDGET(button), 80);
rtgui_widget_set_miniheight(RTGUI_WIDGET(button), 25);
rtgui_box_append(box, RTGUI_WIDGET(button));
/* add a horizontal box */
rtgui_widget_set_miniwidth(RTGUI_WIDGET(hbox), 20);
rtgui_widget_set_miniheight(RTGUI_WIDGET(hbox), 100);
RTGUI_WIDGET(hbox)->align = RTGUI_ALIGN_EXPAND;
rtgui_box_layout(hbox);
rtgui_box_append(box, RTGUI_WIDGET(hbox));
rtgui_box_append(box, RTGUI_WIDGET(textbox));
/* add icon box */
RTGUI_WIDGET(iconbox)->gc.font = rtgui_font_refer("hz", 16);
rtgui_box_append(box, RTGUI_WIDGET(iconbox));
rtgui_box_layout(box);
}
/* show view */
rtgui_view_show(view, RT_TRUE);
rtgui_workbench_event_loop(workbench);
}
void rtgui_demo_workbench_init()
{
static rt_bool_t inited = RT_FALSE;
if (inited == RT_FALSE)
{
rt_thread_t tid;
tid = rt_thread_create("tWB",
rtgui_demo_workbench_entry, RT_NULL,
2048, 25, 10);
if (tid != RT_NULL) rt_thread_startup(tid);
inited = RT_TRUE;
}
}
#ifdef RT_USING_RTGUI
#include <finsh.h>
void w()
{
rtgui_demo_workbench_init();
}
FINSH_FUNCTION_EXPORT(w, workbench demo)
#endif

View File

@ -17,9 +17,9 @@
#include <rtthread.h>
void rt_hw_lcd_init();
void rt_hw_lcd_draw_pixel(int x, int y, rt_uint32_t p);
void rt_hw_lcd_draw_hline(int x1, int x2, int y, rt_uint32_t p);
void rt_hw_lcd_draw_vline(int x, int y1, int y2, rt_uint32_t p);
void rt_hw_lcd_update();
void rt_hw_lcd_set_pixel(rtgui_color_t *c, int x, int y);
void rt_hw_lcd_draw_hline(rtgui_color_t *c, int x1, int x2, int y);
void rt_hw_lcd_draw_vline(rtgui_color_t *c, int x, int y1, int y2);
void rt_hw_lcd_update(rtgui_rect_t* rect);
#endif

View File

@ -350,10 +350,10 @@ void rt_hw_lcd_init(void)
lcd_envid_on_off(1);
/* clear framebuffer */
/* memset((void *)_rt_hw_framebuffer, 0, LCD_XSIZE_TFT_800480*LCD_YSIZE_TFT_800480*2); */
/* rt_memset((void *)_rt_hw_framebuffer, 0, LCD_XSIZE_TFT_800480*LCD_YSIZE_TFT_800480*2); */
for(y = 0; y < 480; y ++)
for(x = 0; x < 800; x++)
_rt_hw_framebuffer[y][x]=0x00FF00;
_rt_hw_framebuffer[y][x] = 0x0000;
/* add lcd driver into graphic driver */
rtgui_graphic_driver_add(&_rtgui_lcd_driver);

View File

@ -88,13 +88,13 @@
/* SECTION: RTGUI support */
/* using RTGUI support */
/* #define RT_USING_RTGUI */
#define RT_USING_RTGUI
/* SECTION: Device filesystem support */
/* using DFS support */
/* #define RT_USING_DFS */
#define RT_USING_DFS
#define RT_USING_DFS_EFSL
#define RT_USING_DFS_YAFFS2
/* #define RT_USING_DFS_YAFFS2 */
#define RT_USING_WORKDIR

View File

@ -4,7 +4,7 @@
RT_USING_FINSH = True
# device file system options
RT_USING_DFS = False
RT_USING_DFS = True
RT_USING_DFS_EFSL = True
RT_USING_DFS_ELMFAT = False
RT_USING_DFS_YAFFS2 = False
@ -13,7 +13,16 @@ RT_USING_DFS_YAFFS2 = False
RT_USING_LWIP = False
# rtgui options
RT_USING_RTGUI = False
RT_USING_RTGUI = True
# panel options
# 'PNL_AT070TN84','PNL_NEC320240'
RT_USING_LCD_TYPE = 'PNL_AT070TN84'
# rtgui demo options
RT_USING_DEMO_GUI = True
RT_USING_DEMO_TODAY = False
RT_USING_DEMO_WORKBENCH = False
# toolchains options
ARCH='arm'

View File

@ -1,6 +1,8 @@
#include <rthw.h>
#include <rtthread.h>
#include <s3c24x0.h>
#include <rtgui/event.h>
#include <rtgui/rtgui_server.h>
/* ADCCON Register Bits */
#define S3C2410_ADCCON_ECFLG (1<<15)
@ -101,7 +103,7 @@ void report_touch_input(int updown)
emouse.button |= RTGUI_MOUSE_BUTTON_LEFT;
rtgui_server_post_event(&emouse, sizeof(struct rtgui_event_mouse));
rtgui_server_post_event((&emouse.parent), sizeof(emouse));
}
#endif
@ -226,7 +228,7 @@ void rt_touch_handler(int irqno)
}
/* clear interrupt */
INTPND |= (1 << INTADC);
INTPND |= (rt_uint32_t)(1 << INTADC);
}
void rt_hw_touch_init()