Пример #1
0
void net_buf_init(rt_size_t size)
{
    rt_thread_t tid;

    /* init net buffer structure */
    _netbuf.read_index = _netbuf.save_index = 0;
    _netbuf.size = size; /* net buffer size */

    /* allocate buffer */
    _netbuf.buffer_data = rt_malloc(_netbuf.size);
	_netbuf.data_length = 0;

	/* set ready and resume water mater */
	_netbuf.ready_wm = _netbuf.size * 90/100;
	_netbuf.resume_wm = _netbuf.size * 80/100;

	/* set init stat */
	_netbuf.stat = NETBUF_STAT_STOPPED;
	rt_kprintf("stat -> stopped\n");

	_netbuf.wait_ready  = rt_sem_create("nready", 0, RT_IPC_FLAG_FIFO);
	_netbuf.wait_resume = rt_sem_create("nresum", 0, RT_IPC_FLAG_FIFO);
	_netbuf.is_wait_ready = RT_FALSE;

	/* crate message queue */
	_netbuf_mq = rt_mq_create("njob", sizeof(struct net_buffer_job),
		4, RT_IPC_FLAG_FIFO);

    /* create net buffer thread */
    tid = rt_thread_create("nbuf",
        net_buf_thread_entry, RT_NULL,
        1024, 22, 5);
    if (tid != RT_NULL)
        rt_thread_startup(tid);
}
Пример #2
0
void rt_appManager_thread_entry(void* parameter) {
	
	rt_err_t result = RT_EOK;
	CommunicationProtocol *cp;
		/* 创建一个信号量,初始值是0 */	
	protocalData_mq = rt_mq_create("protocalMQ",TX_PLOAD_WIDTH,2,RT_IPC_FLAG_FIFO);
	
	while (1)
	{
		result = rt_mq_recv(protocalData_mq, &buff[0], TX_PLOAD_WIDTH, RT_WAITING_FOREVER);
		if(result != RT_EOK) {
			rt_kprintf("recv mq error !");
			return;
		}
		
		//deal msg from nRF2401
		cp = (CommunicationProtocol *)buff;
		if(cp->authentication	== 0x7a79 && cp->type == 1) //yz
		{
			//这里应该检测CRC16
				
			//电机,采用写信的方式吧。
			rt_mq_send(machineData_mq,&cp->m1pwm,4);
			//LED,采用写信的方式吧。
			rt_mq_send(ledData_mq,&cp->LEDS,1);
		}
	}
}
Пример #3
0
void crtpInitTaskQueue(CRTPPort portId)
{
    RT_ASSERT(queues[portId] == RT_NULL);

    //queues[portId] = xQueueCreate(1, sizeof(CRTPPacket));
    queues[portId]=rt_mq_create("queues", sizeof(CRTPPacket), 1, RT_IPC_FLAG_FIFO);
}
Пример #4
0
void window_entry(void* parameter)
{
	rt_mq_t mq;
	char name[32];
	rtgui_win_t *win;
	rtgui_rect_t rect = {10, 30, 110, 130};

	mq = rt_mq_create("wmq", 256, 8, RT_IPC_FLAG_FIFO);
	/* 注册当前线程为GUI线程 */
	rtgui_thread_register(rt_thread_self(), mq);

	snprintf(name, sizeof(name), "win %d", (rt_uint32_t)parameter);
	win = rtgui_win_create(RT_NULL, name, &rect, RTGUI_WIN_STYLE_DEFAULT);
	/* 显示窗口 */
	rtgui_win_show(win, RT_FALSE);

	/* 执行窗口的事件循环 */
	rtgui_win_event_loop(win);

	/* 去注册GUI线程 */
	rtgui_thread_deregister(rt_thread_self());

	/* delete message queue */
	rt_mq_delete(mq);
}
Пример #5
0
void update_radio_list_view_init(rtgui_workbench_t* workbench)
{
    rtgui_view_t *view;
    rt_thread_t update_radio_list_thread;

    if(update_radio_mq == RT_NULL)
    {
        update_radio_mq = rt_mq_create("updateRadioList", sizeof(struct player_request),
                                       1, RT_IPC_FLAG_FIFO);
        RT_ASSERT(update_radio_mq != RT_NULL);

        update_radio_list_thread = rt_thread_create("update_bg", update_radio_thread, RT_NULL,
                                   2048 ,20, 5);

        if (update_radio_list_thread == RT_NULL) rt_kprintf("updateRadioList thread init failed\n");
        else
        {
            rt_thread_startup(update_radio_list_thread);
            update_radio_list_req();
        }
    }

    view = update_radio_list_view_create(workbench);
    if (view != RT_NULL)
    {
        rtgui_view_show(view, RT_FALSE);
    }
}
Пример #6
0
static void today_entry(void* parameter)
{
	rt_mq_t mq;
	struct rtgui_view* view;
	struct rtgui_workbench* workbench;

	mq = rt_mq_create("qToday", 256, 4, RT_IPC_FLAG_FIFO);
	rtgui_thread_register(rt_thread_self(), mq);

    /* create background image */
    background = rtgui_image_create_from_file("png",
        "/bg.png", RT_FALSE);

	workbench = rtgui_workbench_create("main", "workbench");
	if (workbench == RT_NULL) return;

	view = rtgui_view_create("Today");
	rtgui_widget_set_event_handler(RTGUI_WIDGET(view), view_event_handler);

	rtgui_workbench_add_view(workbench, view);

	rtgui_view_show(view);

	rtgui_workbench_event_loop(workbench);

	rtgui_thread_deregister(rt_thread_self());
	rt_mq_delete(mq);
}
Пример #7
0
static void info_entry(void* parameter)
{
	rt_mq_t mq;
	struct rtgui_view* view;
	struct rtgui_workbench* workbench;

	mq = rt_mq_create("qInfo", 256, 4, RT_IPC_FLAG_FIFO);
	rtgui_thread_register(rt_thread_self(), mq);

    network_image = rtgui_image_create_from_mem("xpm",
		(rt_uint8_t*)network_xpm, sizeof(network_xpm), RT_TRUE);
	workbench = rtgui_workbench_create("info", "workbench");
	if (workbench == RT_NULL) return;

	view = rtgui_view_create("view");
	RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(view)) = white;
	rtgui_widget_set_event_handler(RTGUI_WIDGET(view), view_event_handler);

	rtgui_workbench_add_view(workbench, view);

	rtgui_view_show(view, RT_FALSE);

	rtgui_workbench_event_loop(workbench);

	rtgui_thread_deregister(rt_thread_self());
	rt_mq_delete(mq);
}
Пример #8
0
static void info_entry(void* parameter)
{
	rt_mq_t mq;
	struct rtgui_view* view;
	struct rtgui_workbench* workbench;

	mq = rt_mq_create("qInfo", 256, 4, RT_IPC_FLAG_FIFO);
	rtgui_thread_register(rt_thread_self(), mq);

	workbench = rtgui_workbench_create("info", "workbench");
	if(workbench == RT_NULL) 
        return;

	view = rtgui_view_create("view");
	RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(view)) = white;
    RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(view)) = black;
	rtgui_widget_set_event_handler(RTGUI_WIDGET(view), view_event_handler);

	rtgui_workbench_add_view(workbench, view);
    /* this view can be focused */
    RTGUI_WIDGET(view)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;
    /* set widget focus */
    rtgui_widget_focus(RTGUI_WIDGET(view));    

	rtgui_view_show(view, RT_FALSE);

	rtgui_workbench_event_loop(workbench);

	rtgui_thread_deregister(rt_thread_self());
	rt_mq_delete(mq);
}
Пример #9
0
struct rtgui_app *rtgui_app_create(const char *title)
{
    rt_thread_t tid = rt_thread_self();
    struct rtgui_app *app;
    struct rtgui_app *srv_app;
    struct rtgui_event_application event;
    char mq_name[RT_NAME_MAX];

    RT_ASSERT(tid != RT_NULL);
    RT_ASSERT(title != RT_NULL);

    /* create application */
    app = RTGUI_APP(rtgui_object_create(RTGUI_APP_TYPE));
    if (app == RT_NULL)
        return RT_NULL;

    /* one thread only can create one rtgui application */
    RT_ASSERT(tid->user_data == 0);
    app->tid = tid;

    rt_snprintf(mq_name, RT_NAME_MAX, "g%s", title);
    app->mq = rt_mq_create(mq_name, sizeof(union rtgui_event_generic), 32, RT_IPC_FLAG_FIFO);
    if (app->mq == RT_NULL)
    {
        rt_kprintf("create msgq failed.\n");
        goto __mq_err;
    }

    /* set application title */
    app->name = (unsigned char *)rt_strdup((char *)title);
    if (app->name == RT_NULL)
        goto __err;

    /* the first app should be the server */
    srv_app = rtgui_get_server();
    if (srv_app == RT_NULL)
    {
        /* set user thread */
        tid->user_data = (rt_uint32_t)app;
        return app;
    }

    RTGUI_EVENT_APP_CREATE_INIT(&event);
    event.app = app;

    /* notify rtgui server to one application has been created */
    if (rtgui_send_sync(srv_app, RTGUI_EVENT(&event), sizeof(event)) == RT_EOK)
    {
        /* set user thread */
        tid->user_data = (rt_uint32_t)app;
        return app;
    }

__err:
__mq_err:
    rtgui_object_destroy(RTGUI_OBJECT(app));
    return RT_NULL;
}
Пример #10
0
static void led_thread_entry(void* parameter)
{
		rt_uint8_t ledStatus;
	
    rt_hw_led_init();		
		ledData_mq = rt_mq_create("LEDMQ",1,2,RT_IPC_FLAG_FIFO);
		
    while (1)
    {
				if(rt_mq_recv(ledData_mq,&ledStatus,1,RT_WAITING_FOREVER) == RT_EOK)
				{
					if(ledStatus &0x10)
					{
						rt_hw_led_on(4);											
					}
					else
					{
						rt_hw_led_off(4);			
					}
					
					if(ledStatus &0x08)
					{
						rt_hw_led_on(3);											
					}
					else
					{
						rt_hw_led_off(3);			
					}
					
					if(ledStatus &0x04)
					{
						rt_hw_led_on(2);											
					}
					else
					{
						rt_hw_led_off(2);			
					}
					if(ledStatus &0x2)
					{
						rt_hw_led_on(1);											
					}
					else
					{
						rt_hw_led_off(1);			
					}
					if(ledStatus &0x01)
					{
						rt_hw_led_on(0);											
					}
					else
					{
						rt_hw_led_off(0);			
					}					
				}        			
    }
}
Пример #11
0
void start_com_thread(void)
{
	rt_thread_t tid;

	s_payload_queue = rt_mq_create("comqueue", MAX_RECV_PACKET_SIZE - (sizeof(PACKET) - 1), MSG_QUEUE_LEN, RT_IPC_FLAG_FIFO);
	RT_ASSERT(s_payload_queue != RT_NULL);
	
	tid = rt_thread_create("com", com_thread_entry, RT_NULL, 512, COM_THREAD_PRIORITY, 10);

	RT_ASSERT(tid != RT_NULL);
	rt_thread_startup(tid);
}
Пример #12
0
static void player_entry(void* parameter)
{
    rt_mq_t mq;
    rtgui_rect_t rect;

    mq = rt_mq_create("ply_ui", 256, 4, RT_IPC_FLAG_FIFO);
    rtgui_thread_register(rt_thread_self(), mq);

    /* create information timer */
    info_timer = rtgui_timer_create(RT_TICK_PER_SECOND, RT_TIMER_FLAG_PERIODIC, info_timer_timeout, RT_NULL);

    workbench = rtgui_workbench_create("main", "workbench");
    if (workbench == RT_NULL) return;
    rtgui_widget_set_event_handler(RTGUI_WIDGET(workbench), player_workbench_event_handler);

    /* add home view */
    home_view = rtgui_view_create("Home");
    rtgui_widget_set_event_handler(RTGUI_WIDGET(home_view), home_view_event_handler);

    rtgui_workbench_add_view(workbench, home_view);
    /* this view can be focused */
    RTGUI_WIDGET(home_view)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;
    /* set widget focus */
    rtgui_widget_focus(RTGUI_WIDGET(home_view));

	rtgui_widget_get_rect(RTGUI_WIDGET(home_view), &rect);
	rect.x1 += 6; rect.y1 += 150 + 25;
	rect.x2 = rect.x1 + 228; rect.y2 = rect.y1 + 145;
	music_listbox = rtgui_listbox_create(RT_NULL, 0, &rect);
	/* none focusable widget */
	RTGUI_WIDGET(music_listbox)->flag &= ~RTGUI_WIDGET_FLAG_FOCUSABLE;
	RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(music_listbox)) = black;
	RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(music_listbox)) = white;
	rtgui_container_add_child(RTGUI_CONTAINER(home_view), RTGUI_WIDGET(music_listbox));
	rtgui_listbox_set_onitem(music_listbox, player_play_list_onitem);

    rtgui_view_show(home_view, RT_FALSE);

    /* add function view */
    rtgui_widget_get_rect(RTGUI_WIDGET(workbench), &rect);
    function_view = rtgui_list_view_create(function_list,
                                           sizeof(function_list)/sizeof(struct rtgui_list_item),
                                           &rect,
										   RTGUI_LIST_VIEW_LIST);
    rtgui_workbench_add_view(workbench, RTGUI_VIEW(function_view));

    rtgui_workbench_event_loop(workbench);

    rtgui_thread_deregister(rt_thread_self());
    rt_mq_delete(mq);
}
Пример #13
0
void crtpInit(void)
{
    rt_thread_t crtp_tx_thread, crtp_rx_thread;
    if(isInit)
        return;

    //tmpQueue = xQueueCreate(CRTP_TX_QUEUE_SIZE, sizeof(CRTPPacket));
    tmpQueue = rt_mq_create("crtp_tmp", sizeof(CRTPPacket), CRTP_TX_QUEUE_SIZE, RT_IPC_FLAG_FIFO);
    //rxQueue = xQueueCreate(CRTP_RX_QUEUE_SIZE, sizeof(CRTPPacket));
    rxQueue = rt_mq_create("crtp_rx", sizeof(CRTPPacket), CRTP_RX_QUEUE_SIZE, RT_IPC_FLAG_FIFO);
    /* Start Rx/Tx tasks */
    //xTaskCreate(crtpTxTask, (const signed char * const)"CRTP-Tx",
    //            configMINIMAL_STACK_SIZE, NULL, /*priority*/2, NULL);
// xTaskCreate(crtpRxTask, (const signed char * const)"CRTP-Rx",
    //          configMINIMAL_STACK_SIZE, NULL, /*priority*/2, NULL);
    crtp_tx_thread = rt_thread_create("crtp_tx", crtpTxTask, RT_NULL, 512, 10, 5);
    crtp_rx_thread = rt_thread_create("crtp_rx", crtpRxTask, RT_NULL, 512, 10, 5);
    if (crtp_tx_thread != RT_NULL)
        rt_thread_startup(crtp_tx_thread);
    if (crtp_rx_thread != RT_NULL)
        rt_thread_startup(crtp_rx_thread);

    isInit = RT_TRUE;
}
Пример #14
0
/* init */
void usbd_msc_init ()
{
    rt_thread_t tid;
    struct rt_device_blk_geometry geometry;
    
    msd_mq = rt_mq_create("msd_mq", sizeof(msd_msg_t), 20, RT_IPC_FLAG_FIFO);

    rt_device_control(dev, RT_DEVICE_CTRL_BLK_GETGEOME, &geometry);
    
    USBD_MSC_MemorySize = geometry.block_size*geometry.sector_count;
    USBD_MSC_BlockSize  = geometry.block_size;
    USBD_MSC_BlockGroup = 1;
    USBD_MSC_BlockCount = geometry.sector_count;
    USBD_MSC_BlockBuf   = rt_malloc(geometry.block_size);
    USBD_MSC_MediaReady = __TRUE;
}
Пример #15
0
/**
 * This function will initialize usb hub thread.
 *
 * @return none.
 * 
 */
void rt_usbh_hub_init(void)
{
    rt_thread_t thread;
    
    /* create usb message queue */
    usb_mq = rt_mq_create("usbh", 32, 16, RT_IPC_FLAG_FIFO);
    
    /* create usb hub thread */
    thread = rt_thread_create("usbh", rt_usbh_hub_thread_entry, RT_NULL, 
        USB_THREAD_STACK_SIZE, 8, 20);
    if(thread != RT_NULL)
    {
        /* startup usb host thread */
        rt_thread_startup(thread);
    }
}
Пример #16
0
void workbench_panel1(void* parameter)
{
	rt_mq_t mq;
	rtgui_view_t* view;
	rtgui_label_t* label;
	struct rtgui_workbench* workbench;
	rtgui_rect_t rect;

	mq = rt_mq_create("wmq", 256, 8, RT_IPC_FLAG_FIFO);
	/* 注册当前线程为GUI线程 */
	rtgui_thread_register(rt_thread_self(), mq);
	/* 创建一个工作台 */
	workbench = rtgui_workbench_create("main", "workbench #1");
	if (workbench == RT_NULL) return;

	view = rtgui_view_create("view");
	if (view == RT_NULL) return;
	/* 指定视图的背景色 */
	RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(view)) = white;

	/* 添加一个label */
	label = rtgui_label_create("hello RT-Thread!");
	rect.x1 = 10; rect.y1 = 10;
	rect.x2 = 210; rect.y2 = 30;
	/* 设置label的位置 */
	rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect);
	rtgui_container_add_child(RTGUI_CONTAINER(view), RTGUI_WIDGET(label));

	/* 添加到父workbench中 */
	rtgui_workbench_add_view(workbench, view);
	/* 创建图片视图 */
	view = picture_view_create(workbench);
	
	/* 非模式方式显示视图 */
	rtgui_view_show(view, RT_FALSE);

	/* 执行工作台事件循环 */
	rtgui_workbench_event_loop(workbench);

	/* 去注册GUI线程 */
	rtgui_thread_deregister(rt_thread_self());

	/* delete message queue */
	rt_mq_delete(mq);
}
Пример #17
0
static void gui_win_entry(void* parameter)
{
	const struct rtgui_graphic_driver* gd = rtgui_graphic_driver_get_default();
	struct rt_messagequeue *mq;
	rtgui_win_t *win;
	rtgui_button_t *button;
	rtgui_point_t p;
	rtgui_rect_t rect = {0,0,200,180};
	rtgui_label_t *label;
	rtgui_font_t *font;
	
	/* 创建GUI应用需要的消息队列 */
	mq = rt_mq_create("demo_win", 256, 32, RT_IPC_FLAG_FIFO);
	/* 注册当前线程 */
	rtgui_thread_register(rt_thread_self(), mq);

	/* 窗口居中 */
	rtgui_rect_moveto(&rect, (gd->width - rtgui_rect_width(rect))/2, (gd->height - rtgui_rect_height(rect))/2);
	/* 创建窗口 */
	win = rtgui_win_create(RT_NULL,"demo_win",&rect,RTGUI_WIN_DEFAULT);
	if(win == RT_NULL) return;
 
	/* 取得客户区坐标零点 */
	p = rtgui_win_get_client_zero(win);
	label = rtgui_label_create(win, "hello world!", p.x+5, p.y+5, 100,25);
	font = rtgui_font_refer("asc", 12);	
	RTGUI_WIDGET_FONT(label) = font;

	button = rtgui_button_create(win, "Exit", (rtgui_rect_width(rect)-50)/2,
								rtgui_rect_height(rect)-40,50,25);
	rtgui_button_set_onbutton(button,rtgui_win_close);

	rtgui_widget_set_event_handler(win, demo_gui_win_event_handler);
	
	rtgui_win_show(win,RT_FALSE);
	
	/* 执行工作台事件循环 */
	rtgui_win_event_loop(win);

	demo_win_inited = RT_FALSE;
	
	/* 去注册GUI线程 */
	rtgui_thread_deregister(rt_thread_self());
	rt_mq_delete(mq);
}
Пример #18
0
void calibration_entry(void* parameter)
{
	rt_mq_t mq;
	rtgui_win_t* win;
	struct rtgui_rect rect;

	mq = rt_mq_create("cali", 40, 8, RT_IPC_FLAG_FIFO);
	if (mq == RT_NULL) return;

	rtgui_thread_register(rt_thread_self(), mq);

	rtgui_graphic_driver_get_rect(rtgui_graphic_driver_get_default(), &rect);

	/* set screen rect */
	calibration_ptr->width = rect.x2;
	calibration_ptr->height = rect.y2;

	/* create calibration window */
	win = rtgui_win_create(RT_NULL,
		"calibration", &rect, RTGUI_WIN_STYLE_NO_TITLE | RTGUI_WIN_STYLE_NO_BORDER);
	rtgui_widget_set_event_handler(RTGUI_WIDGET(win), calibration_event_handler);
	if (win != RT_NULL)
	{
		rtgui_win_show(win, RT_FALSE);
		// rtgui_widget_update(RTGUI_WIDGET(win));
		rtgui_win_event_loop(win);
	}

	rtgui_thread_deregister(rt_thread_self());
	rt_mq_delete(mq);

	/* set calibration data */
	rt_device_control(calibration_ptr->device, RT_TOUCH_CALIBRATION_DATA, &calibration_ptr->data);

	/* recover to normal */
	rt_device_control(calibration_ptr->device, RT_TOUCH_NORMAL, RT_NULL);

	/* release memory */
	rt_free(calibration_ptr);
	calibration_ptr = RT_NULL;
    /* tell other thread that we finished calibration */
    rt_sem_release(touch_screen_calibrated);
}
Пример #19
0
void player_init()
{
    rt_err_t result;

	/* create player thread */
	player_thread_mq = rt_mq_create("player", sizeof(struct player_request),
		8, RT_IPC_FLAG_FIFO);
	RT_ASSERT(player_thread_mq != RT_NULL);

	result = rt_thread_init(&player_thread_tid, "ply_bg", player_thread, RT_NULL,
		player_thread_stack, sizeof(player_thread_stack),
		13, 5);

	if (result != RT_EOK) rt_kprintf("player thread init failed\n");
	else
	{
		rt_thread_startup(&player_thread_tid);
		player_ui_init();
	}
}
Пример #20
0
void rt_mq_system_init()
{
	_rtgui_mq = rt_mq_create(256, 32);
}
/// Create and Initialize Message Queue
osMessageQId osMessageCreate(osMessageQDef_t *queue_def, osThreadId thread_id)
{
	return rt_mq_create(queue_def->name, queue_def->msg_size, queue_def->max_msgs, queue_def->flag);
}
Пример #22
0
static void workbench_entry(void* parameter)
{
	rt_mq_t mq;
	struct rtgui_workbench* workbench;

	/* 创建GUI应用需要的消息队列 */
#ifdef RTGUI_USING_SMALL_SIZE
	mq = rt_mq_create("workbench", 32, 32, RT_IPC_FLAG_FIFO);
#else
	mq = rt_mq_create("workbench", 256, 32, RT_IPC_FLAG_FIFO);
#endif
	/* 注册当前线程为GUI线程 */
	rtgui_thread_register(rt_thread_self(), mq);

	/* 创建一个工作台 */
	workbench = rtgui_workbench_create("main", "workbench");
	if (workbench == RT_NULL) return;

	rtgui_widget_set_event_handler(RTGUI_WIDGET(workbench), demo_workbench_event_handler);

	/* 初始化各个例子的视图 */
#if RT_VERSION == 4
	demo_view_benchmark(workbench);
#endif

	demo_view_dc(workbench);
#if RT_VERSION == 4
#ifdef RTGUI_USING_TTF
	demo_view_ttf(workbench);
#endif
#endif

#ifndef RTGUI_USING_SMALL_SIZE
	demo_view_dc_buffer(workbench);
#endif
	demo_view_animation(workbench);
#ifndef RTGUI_USING_SMALL_SIZE
	demo_view_buffer_animation(workbench);
	// demo_view_instrument_panel(workbench);
#endif
	demo_view_window(workbench);
	demo_view_label(workbench);
	demo_view_button(workbench);
	demo_view_checkbox(workbench);
	demo_view_progressbar(workbench);
	demo_view_scrollbar(workbench);
	demo_view_radiobox(workbench);
	demo_view_textbox(workbench);
	demo_view_listbox(workbench);
	demo_view_menu(workbench);
	demo_view_listctrl(workbench);
	demo_view_combobox(workbench);
	demo_view_slider(workbench);
	demo_view_notebook(workbench);
	demo_view_mywidget(workbench);
#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW)
	demo_view_image(workbench);
#endif
#ifdef RT_USING_MODULE	
#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW)
	demo_view_module(workbench);
#endif
#endif
	demo_listview_view(workbench);
	demo_listview_icon_view(workbench);
#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW)
	demo_fn_view(workbench);
#endif

	/* 显示视图 */
	demo_view_show();

	/* 执行工作台事件循环 */
	rtgui_workbench_event_loop(workbench);

	/* 去注册GUI线程 */
	rtgui_thread_deregister(rt_thread_self());
	rt_mq_delete(mq);
}
Пример #23
0
struct rtgui_app* rtgui_app_create(
        rt_thread_t tid,
        const char *title)
{
	rt_thread_t srv_tid;
	struct rtgui_app *app;
	struct rtgui_event_application event;

	RT_ASSERT(tid != RT_NULL);
	RT_ASSERT(title != RT_NULL);

	/* create application */
	app = RTGUI_APP(rtgui_object_create(RTGUI_APP_TYPE));
	if (app == RT_NULL)
		return RT_NULL;

	/* one thread only can create one rtgui application */
	RT_ASSERT(tid->user_data == 0);
	app->tid = tid;
	/* set user thread */
	tid->user_data = (rt_uint32_t)app;

	app->mq = rt_mq_create("rtgui", sizeof(union rtgui_event_generic), 32, RT_IPC_FLAG_FIFO);
	if (app->mq == RT_NULL)
	{
		rt_kprintf("create msgq failed.\n");
		goto __mq_err;
	}

	/* set application title */
	app->name = (unsigned char*)rt_strdup((char*)title);
	if (app->name == RT_NULL)
		goto __err;

	/* send a message to notify rtgui server */
	srv_tid = rtgui_get_server();
	if (srv_tid == RT_NULL)
	{
		rt_kprintf("gui server is not running.\n");
		goto __err;
	}

	/* create the rtgui server application */
	if (srv_tid == rt_thread_self())
		return app;

	RTGUI_EVENT_APP_CREATE_INIT(&event);
	event.app = app;

	/* notify rtgui server to one application has been created */
	if (rtgui_send_sync(srv_tid, RTGUI_EVENT(&event), sizeof(event)) == RT_EOK)
	{
		return app;
	}

__err:
__mq_err:
	rtgui_object_destroy(RTGUI_OBJECT(app));
	tid->user_data = 0;
	return RT_NULL;
}