mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-08-18 20:48:41 +08:00
add ili9341 lcd device and simple gui demo
This commit is contained in:
@@ -32,12 +32,18 @@
|
||||
#include <lwip/sys.h>
|
||||
#include <lwip/api.h>
|
||||
#include <netif/ethernetif.h>
|
||||
#include "stm32f4xx_eth.h"
|
||||
#include "drv_eth.h"
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_GDB
|
||||
#include <gdb_stub.h>
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_GUIENGINE
|
||||
#include "rtgui_demo.h"
|
||||
#include <rtgui/driver.h>
|
||||
#endif
|
||||
|
||||
//rt_module_t module_ptr;
|
||||
#define DATA_PATH "/Data"
|
||||
void rt_init_thread_entry(void* parameter)
|
||||
@@ -89,20 +95,17 @@ void rt_init_thread_entry(void* parameter)
|
||||
#endif /* RT_USING_DFS_ELMFAT */
|
||||
|
||||
#endif /* DFS */
|
||||
/* LwIP Initialization */
|
||||
#ifdef RT_USING_LWIP
|
||||
{
|
||||
extern void lwip_sys_init(void);
|
||||
|
||||
#ifdef RT_USING_GUIENGINE
|
||||
{
|
||||
rt_device_t device;
|
||||
|
||||
/* register ethernetif device */
|
||||
eth_system_device_init();
|
||||
|
||||
rt_hw_stm32_eth_init();
|
||||
|
||||
/* init lwip system */
|
||||
lwip_sys_init();
|
||||
rt_kprintf("TCP/IP initialized!\n");
|
||||
}
|
||||
device = rt_device_find("lcd");
|
||||
/* re-set graphic device */
|
||||
rtgui_graphic_set_device(device);
|
||||
|
||||
rt_gui_demo_init();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
int rt_application_init()
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* File : application.c
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rt-thread.org/license/LICENSE
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <rtgui/rtgui.h>
|
||||
#include <rtgui/rtgui_system.h>
|
||||
#include <rtgui/rtgui_app.h>
|
||||
|
||||
#include <rtgui/widgets/window.h>
|
||||
#include <rtgui/dc.h>
|
||||
#include <rtgui/dc_hw.h>
|
||||
|
||||
#include "finsh.h"
|
||||
#include "rtgui_demo.h"
|
||||
|
||||
#define DEBUG
|
||||
|
||||
#ifdef DEBUG
|
||||
#define DEBUG_PRINTF(...) rt_kprintf(__VA_ARGS__)
|
||||
#else
|
||||
#define DEBUG_PRINTF(...)
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_GUIENGINE
|
||||
|
||||
struct rtgui_win *main_win;
|
||||
rt_bool_t dc_event_handler(struct rtgui_object *object, rtgui_event_t *event);
|
||||
|
||||
static void rt_gui_demo_entry(void *parameter)
|
||||
{
|
||||
struct rtgui_app *app;
|
||||
//struct rtgui_dc *dc;
|
||||
|
||||
DEBUG_PRINTF("gui demo entry\n");
|
||||
|
||||
/* create gui app */
|
||||
app = rtgui_app_create("gui_demo");
|
||||
if (app == RT_NULL)
|
||||
{
|
||||
DEBUG_PRINTF("rtgui_app_create faild\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* create main window */
|
||||
main_win = rtgui_mainwin_create(RT_NULL,
|
||||
"UiWindow", RTGUI_WIN_STYLE_NO_TITLE | RTGUI_WIN_STYLE_NO_BORDER);
|
||||
if (main_win == RT_NULL)
|
||||
{
|
||||
DEBUG_PRINTF("main_win is null\n");
|
||||
rtgui_app_destroy(app);
|
||||
return;
|
||||
}
|
||||
|
||||
rtgui_object_set_event_handler(RTGUI_OBJECT(main_win), dc_event_handler);
|
||||
|
||||
DEBUG_PRINTF("rtgui_win_show\n");
|
||||
rtgui_win_show(main_win, RT_FALSE);
|
||||
|
||||
DEBUG_PRINTF("rtgui_app_run\n");
|
||||
rtgui_app_run(app);
|
||||
|
||||
DEBUG_PRINTF("rtgui_win_destroy\n");
|
||||
rtgui_win_destroy(main_win);
|
||||
|
||||
DEBUG_PRINTF("rtgui_app_destroy\n");
|
||||
rtgui_app_destroy(app);
|
||||
}
|
||||
|
||||
rt_bool_t dc_event_handler(struct rtgui_object *object, rtgui_event_t *event)
|
||||
{
|
||||
struct rtgui_widget *widget = RTGUI_WIDGET(object);
|
||||
|
||||
if (event->type == RTGUI_EVENT_PAINT)
|
||||
{
|
||||
struct rtgui_dc *dc;
|
||||
rtgui_rect_t rect;
|
||||
|
||||
rt_kprintf("\r\n RTGUI_EVENT_PAINT \r\n");
|
||||
rtgui_win_event_handler(RTGUI_OBJECT(widget), event);
|
||||
|
||||
rtgui_widget_get_rect(widget, &rect);
|
||||
DEBUG_PRINTF("widget react x1: %d, y1: %d, x2: %d, y2: %d\r\n",
|
||||
rect.x1, rect.y1, rect.x2, rect.y2);
|
||||
|
||||
dc = rtgui_dc_begin_drawing(widget);
|
||||
if(dc == RT_NULL)
|
||||
{
|
||||
DEBUG_PRINTF("\r\n dc is null \r\n");
|
||||
return RT_FALSE;
|
||||
}
|
||||
|
||||
rtgui_dc_draw_line(dc,0,0,240,320);
|
||||
rtgui_dc_draw_line(dc,0,320,240,0);
|
||||
//rtgui_dc_draw_text(dc, __DATE__, &rect);
|
||||
rtgui_dc_draw_text_stroke(dc, __DATE__, &rect, HIGH_LIGHT, BLUE);
|
||||
|
||||
rect.y1 += 20;
|
||||
rect.y2 += 20;
|
||||
rtgui_dc_draw_text_stroke(dc, __TIME__, &rect, HIGH_LIGHT, BLACK);
|
||||
|
||||
|
||||
rtgui_dc_end_drawing(dc);
|
||||
}
|
||||
return RT_FALSE;
|
||||
}
|
||||
|
||||
int rt_gui_demo_init(void)
|
||||
{
|
||||
rt_thread_t tid;
|
||||
tid = rt_thread_create("mygui",
|
||||
rt_gui_demo_entry, RT_NULL,
|
||||
2048, 25, 10);
|
||||
|
||||
if (tid != RT_NULL)
|
||||
rt_thread_startup(tid);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* RT_USING_GUIENGINE */
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* File : dc.h
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rt-thread.org/license/LICENSE
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2017-06-02 tanek first version
|
||||
*/
|
||||
#ifndef __APP_GUI_DEMO_H__
|
||||
#define __APP_GUI_DEMO_H__
|
||||
|
||||
extern int rt_gui_demo_init(void);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -18,7 +18,7 @@ drv_mpu.c
|
||||
|
||||
# add Ethernet drivers.
|
||||
if GetDepend('RT_USING_LWIP'):
|
||||
src += ['stm32f4xx_eth.c']
|
||||
src += ['drv_eth.c']
|
||||
|
||||
# add gpio drivers.
|
||||
if GetDepend('RT_USING_PIN'):
|
||||
@@ -32,6 +32,10 @@ if GetDepend('RT_USING_SPI'):
|
||||
if GetDepend('RT_USING_SFUD'):
|
||||
src += ['drv_spi_flash.c']
|
||||
|
||||
# add lcd drivers.
|
||||
if GetDepend('RT_USING_GUIENGINE'):
|
||||
src += ['drv_lcd.c']
|
||||
|
||||
CPPPATH = [cwd]
|
||||
|
||||
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,14 @@
|
||||
#ifndef __DRV_LCD_H__
|
||||
#define __DRV_LCD_H__
|
||||
|
||||
#include <rtdevice.h>
|
||||
#include "stm32f4xx_hal.h"
|
||||
|
||||
int rt_lcd_init(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -58,11 +58,11 @@
|
||||
/* #define HAL_DAC_MODULE_ENABLED */
|
||||
/* #define HAL_DCMI_MODULE_ENABLED */
|
||||
/* #define HAL_DMA2D_MODULE_ENABLED */
|
||||
/* #define HAL_ETH_MODULE_ENABLED */
|
||||
#define HAL_ETH_MODULE_ENABLED
|
||||
#define HAL_NAND_MODULE_ENABLED
|
||||
/* #define HAL_NOR_MODULE_ENABLED */
|
||||
/* #define HAL_PCCARD_MODULE_ENABLED */
|
||||
/* #define HAL_SRAM_MODULE_ENABLED */
|
||||
#define HAL_SRAM_MODULE_ENABLED
|
||||
#define HAL_SDRAM_MODULE_ENABLED
|
||||
/* #define HAL_HASH_MODULE_ENABLED */
|
||||
/* #define HAL_I2C_MODULE_ENABLED */
|
||||
|
||||
@@ -66,6 +66,29 @@
|
||||
#define RT_USING_DEVICE
|
||||
#define RT_USING_DEVICE_IPC
|
||||
|
||||
/* SECTION: RTGUI support */
|
||||
/* using RTGUI support */
|
||||
#define RT_USING_GUIENGINE
|
||||
|
||||
/* name length of RTGUI object */
|
||||
#define RTGUI_NAME_MAX 16
|
||||
/* support 16 weight font */
|
||||
#define RTGUI_USING_FONT16
|
||||
/* support 16 weight font */
|
||||
#define RTGUI_USING_FONT12
|
||||
/* support Chinese font */
|
||||
#define RTGUI_USING_FONTHZ
|
||||
/* use DFS as file interface */
|
||||
#define RTGUI_USING_DFS_FILERW
|
||||
/* use font file as Chinese font */
|
||||
/* #define RTGUI_USING_HZ_FILE */
|
||||
/* use Chinese bitmap font */
|
||||
#define RTGUI_USING_HZ_BMP
|
||||
/* use small size in RTGUI */
|
||||
/* #define RTGUI_USING_SMALL_SIZE */
|
||||
/* use mouse cursor */
|
||||
/* #define RTGUI_USING_MOUSE_CURSOR */
|
||||
|
||||
|
||||
/* Using serial framework */
|
||||
#define RT_USING_SERIAL
|
||||
@@ -151,7 +174,7 @@
|
||||
// #define RT_USING_DFS_ROMFS
|
||||
|
||||
/* SECTION: lwip, a lighwight TCP/IP protocol stack */
|
||||
/* #define RT_USING_LWIP */
|
||||
#define RT_USING_LWIP
|
||||
/* LwIP uses RT-Thread Memory Management */
|
||||
#define RT_LWIP_USING_RT_MEM
|
||||
/* Enable ICMP protocol*/
|
||||
@@ -162,6 +185,8 @@
|
||||
#define RT_LWIP_TCP
|
||||
/* Enable DNS */
|
||||
#define RT_LWIP_DNS
|
||||
/* Enable DHCP */
|
||||
//#define RT_LWIP_DHCP
|
||||
|
||||
/* the number of simulatenously active TCP connections*/
|
||||
#define RT_LWIP_TCP_PCB_NUM 5
|
||||
|
||||
Reference in New Issue
Block a user