Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
4ba03b80
R
rt-thread
项目概览
BaiXuePrincess
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4ba03b80
编写于
2月 24, 2013
作者:
B
Bernard Xiong
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #34 from grissiom/rtgui-cali
bsp/stm32f10x: remove the last calibration.c
上级
de569ec8
24649bfe
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
23 addition
and
285 deletion
+23
-285
bsp/stm32f10x/SConscript
bsp/stm32f10x/SConscript
+1
-1
bsp/stm32f10x/application.c
bsp/stm32f10x/application.c
+22
-0
bsp/stm32f10x/calibration.c
bsp/stm32f10x/calibration.c
+0
-284
未找到文件。
bsp/stm32f10x/SConscript
浏览文件 @
4ba03b80
...
...
@@ -15,7 +15,7 @@ if GetDepend('RT_USING_LWIP'):
src_drv
+=
[
'enc28j60.c'
]
+
[
'dm9000a.c'
]
if
GetDepend
(
'RT_USING_RTGUI'
):
src_drv
+=
[
'touch.c'
,
'calibration.c'
]
src_drv
+=
[
'touch.c'
]
if
GetDepend
(
'RT_USING_RTGUI'
):
if
rtconfig
.
RT_USING_LCD_TYPE
==
'FMT0371'
:
...
...
bsp/stm32f10x/application.c
浏览文件 @
4ba03b80
...
...
@@ -41,6 +41,7 @@
#include <rtgui/rtgui_server.h>
#include <rtgui/rtgui_system.h>
#include <rtgui/driver.h>
#include <rtgui/calibration.h>
#endif
#include "led.h"
...
...
@@ -73,6 +74,23 @@ static void led_thread_entry(void* parameter)
}
}
#ifdef RT_USING_RTGUI
rt_bool_t
cali_setup
(
void
)
{
rt_kprintf
(
"cali setup entered
\n
"
);
return
RT_FALSE
;
}
void
cali_store
(
struct
calibration_data
*
data
)
{
rt_kprintf
(
"cali finished (%d, %d), (%d, %d)
\n
"
,
data
->
min_x
,
data
->
max_x
,
data
->
min_y
,
data
->
max_y
);
}
#endif
void
rt_init_thread_entry
(
void
*
parameter
)
{
/* Filesystem Initialization */
...
...
@@ -149,6 +167,10 @@ void rt_init_thread_entry(void* parameter)
/* init rtgui system server */
rtgui_system_server_init
();
calibration_set_restore
(
cali_setup
);
calibration_set_after
(
cali_store
);
calibration_init
();
}
#endif
/* #ifdef RT_USING_RTGUI */
}
...
...
bsp/stm32f10x/calibration.c
已删除
100644 → 0
浏览文件 @
de569ec8
#include <rtgui/rtgui.h>
#include <rtgui/dc.h>
#include <rtgui/rtgui_system.h>
#include <rtgui/widgets/window.h>
#include "touch.h"
#define CALIBRATION_STEP_LEFTTOP 0
#define CALIBRATION_STEP_RIGHTTOP 1
#define CALIBRATION_STEP_RIGHTBOTTOM 2
#define CALIBRATION_STEP_LEFTBOTTOM 3
#define CALIBRATION_STEP_CENTER 4
#define TOUCH_WIN_UPDATE 1
#define TOUCH_WIN_CLOSE 2
#define CALIBRATION_WIDTH 15
#define CALIBRATION_HEIGHT 15
struct
calibration_session
{
rt_uint8_t
step
;
struct
calibration_data
data
;
rt_uint16_t
width
;
rt_uint16_t
height
;
rt_device_t
device
;
rt_thread_t
tid
;
};
static
struct
calibration_session
*
calibration_ptr
=
RT_NULL
;
static
void
calibration_data_post
(
rt_uint16_t
x
,
rt_uint16_t
y
)
{
if
(
calibration_ptr
!=
RT_NULL
)
{
switch
(
calibration_ptr
->
step
)
{
case
CALIBRATION_STEP_LEFTTOP
:
calibration_ptr
->
data
.
min_x
=
x
;
calibration_ptr
->
data
.
min_y
=
y
;
break
;
case
CALIBRATION_STEP_RIGHTTOP
:
calibration_ptr
->
data
.
max_x
=
x
;
calibration_ptr
->
data
.
min_y
=
(
calibration_ptr
->
data
.
min_y
+
y
)
/
2
;
break
;
case
CALIBRATION_STEP_LEFTBOTTOM
:
calibration_ptr
->
data
.
min_x
=
(
calibration_ptr
->
data
.
min_x
+
x
)
/
2
;
calibration_ptr
->
data
.
max_y
=
y
;
break
;
case
CALIBRATION_STEP_RIGHTBOTTOM
:
calibration_ptr
->
data
.
max_x
=
(
calibration_ptr
->
data
.
max_x
+
x
)
/
2
;
calibration_ptr
->
data
.
max_y
=
(
calibration_ptr
->
data
.
max_y
+
y
)
/
2
;
break
;
case
CALIBRATION_STEP_CENTER
:
/* calibration done */
{
rt_uint16_t
w
,
h
;
struct
rtgui_event_command
ecmd
;
RTGUI_EVENT_COMMAND_INIT
(
&
ecmd
);
ecmd
.
command_id
=
TOUCH_WIN_CLOSE
;
/* calculate calibrated data */
if
(
calibration_ptr
->
data
.
max_x
>
calibration_ptr
->
data
.
min_x
)
w
=
calibration_ptr
->
data
.
max_x
-
calibration_ptr
->
data
.
min_x
;
else
w
=
calibration_ptr
->
data
.
min_x
-
calibration_ptr
->
data
.
max_x
;
w
=
(
w
/
(
calibration_ptr
->
width
-
2
*
CALIBRATION_WIDTH
))
*
CALIBRATION_WIDTH
;
if
(
calibration_ptr
->
data
.
max_y
>
calibration_ptr
->
data
.
min_y
)
h
=
calibration_ptr
->
data
.
max_y
-
calibration_ptr
->
data
.
min_y
;
else
h
=
calibration_ptr
->
data
.
min_y
-
calibration_ptr
->
data
.
max_y
;
h
=
(
h
/
(
calibration_ptr
->
height
-
2
*
CALIBRATION_HEIGHT
))
*
CALIBRATION_HEIGHT
;
rt_kprintf
(
"w: %d, h: %d
\n
"
,
w
,
h
);
if
(
calibration_ptr
->
data
.
max_x
>
calibration_ptr
->
data
.
min_x
)
{
calibration_ptr
->
data
.
min_x
-=
w
;
calibration_ptr
->
data
.
max_x
+=
w
;
}
else
{
calibration_ptr
->
data
.
min_x
+=
w
;
calibration_ptr
->
data
.
max_x
-=
w
;
}
if
(
calibration_ptr
->
data
.
max_y
>
calibration_ptr
->
data
.
min_y
)
{
calibration_ptr
->
data
.
min_y
-=
h
;
calibration_ptr
->
data
.
max_y
+=
h
;
}
else
{
calibration_ptr
->
data
.
min_y
+=
h
;
calibration_ptr
->
data
.
max_y
-=
h
;
}
rt_kprintf
(
"calibration data: (%d, %d), (%d, %d)
\n
"
,
calibration_ptr
->
data
.
min_x
,
calibration_ptr
->
data
.
max_x
,
calibration_ptr
->
data
.
min_y
,
calibration_ptr
->
data
.
max_y
);
rtgui_thread_send
(
calibration_ptr
->
tid
,
&
ecmd
.
parent
,
sizeof
(
struct
rtgui_event_command
));
}
return
;
}
calibration_ptr
->
step
++
;
/* post command event */
{
struct
rtgui_event_command
ecmd
;
RTGUI_EVENT_COMMAND_INIT
(
&
ecmd
);
ecmd
.
command_id
=
TOUCH_WIN_UPDATE
;
rtgui_thread_send
(
calibration_ptr
->
tid
,
&
ecmd
.
parent
,
sizeof
(
struct
rtgui_event_command
));
}
}
}
rt_bool_t
calibration_event_handler
(
struct
rtgui_widget
*
widget
,
struct
rtgui_event
*
event
)
{
switch
(
event
->
type
)
{
case
RTGUI_EVENT_PAINT
:
{
struct
rtgui_dc
*
dc
;
struct
rtgui_rect
rect
;
dc
=
rtgui_dc_begin_drawing
(
widget
);
if
(
dc
==
RT_NULL
)
break
;
/* get rect information */
rtgui_widget_get_rect
(
widget
,
&
rect
);
/* clear whole window */
RTGUI_WIDGET_BACKGROUND
(
widget
)
=
white
;
rtgui_dc_fill_rect
(
dc
,
&
rect
);
/* reset color */
RTGUI_WIDGET_BACKGROUND
(
widget
)
=
green
;
RTGUI_WIDGET_FOREGROUND
(
widget
)
=
black
;
switch
(
calibration_ptr
->
step
)
{
case
CALIBRATION_STEP_LEFTTOP
:
rtgui_dc_draw_hline
(
dc
,
0
,
2
*
CALIBRATION_WIDTH
,
CALIBRATION_HEIGHT
);
rtgui_dc_draw_vline
(
dc
,
CALIBRATION_WIDTH
,
0
,
2
*
CALIBRATION_HEIGHT
);
RTGUI_WIDGET_FOREGROUND
(
widget
)
=
red
;
rtgui_dc_fill_circle
(
dc
,
CALIBRATION_WIDTH
,
CALIBRATION_HEIGHT
,
4
);
break
;
case
CALIBRATION_STEP_RIGHTTOP
:
rtgui_dc_draw_hline
(
dc
,
calibration_ptr
->
width
-
2
*
CALIBRATION_WIDTH
,
calibration_ptr
->
width
,
CALIBRATION_HEIGHT
);
rtgui_dc_draw_vline
(
dc
,
calibration_ptr
->
width
-
CALIBRATION_WIDTH
,
0
,
2
*
CALIBRATION_HEIGHT
);
RTGUI_WIDGET_FOREGROUND
(
widget
)
=
red
;
rtgui_dc_fill_circle
(
dc
,
calibration_ptr
->
width
-
CALIBRATION_WIDTH
,
CALIBRATION_HEIGHT
,
4
);
break
;
case
CALIBRATION_STEP_LEFTBOTTOM
:
rtgui_dc_draw_hline
(
dc
,
0
,
2
*
CALIBRATION_WIDTH
,
calibration_ptr
->
height
-
CALIBRATION_HEIGHT
);
rtgui_dc_draw_vline
(
dc
,
CALIBRATION_WIDTH
,
calibration_ptr
->
height
-
2
*
CALIBRATION_HEIGHT
,
calibration_ptr
->
height
);
RTGUI_WIDGET_FOREGROUND
(
widget
)
=
red
;
rtgui_dc_fill_circle
(
dc
,
CALIBRATION_WIDTH
,
calibration_ptr
->
height
-
CALIBRATION_HEIGHT
,
4
);
break
;
case
CALIBRATION_STEP_RIGHTBOTTOM
:
rtgui_dc_draw_hline
(
dc
,
calibration_ptr
->
width
-
2
*
CALIBRATION_WIDTH
,
calibration_ptr
->
width
,
calibration_ptr
->
height
-
CALIBRATION_HEIGHT
);
rtgui_dc_draw_vline
(
dc
,
calibration_ptr
->
width
-
CALIBRATION_WIDTH
,
calibration_ptr
->
height
-
2
*
CALIBRATION_HEIGHT
,
calibration_ptr
->
height
);
RTGUI_WIDGET_FOREGROUND
(
widget
)
=
red
;
rtgui_dc_fill_circle
(
dc
,
calibration_ptr
->
width
-
CALIBRATION_WIDTH
,
calibration_ptr
->
height
-
CALIBRATION_HEIGHT
,
4
);
break
;
case
CALIBRATION_STEP_CENTER
:
rtgui_dc_draw_hline
(
dc
,
calibration_ptr
->
width
/
2
-
CALIBRATION_WIDTH
,
calibration_ptr
->
width
/
2
+
CALIBRATION_WIDTH
,
calibration_ptr
->
height
/
2
);
rtgui_dc_draw_vline
(
dc
,
calibration_ptr
->
width
/
2
,
calibration_ptr
->
height
/
2
-
CALIBRATION_HEIGHT
,
calibration_ptr
->
height
/
2
+
CALIBRATION_HEIGHT
);
RTGUI_WIDGET_FOREGROUND
(
widget
)
=
red
;
rtgui_dc_fill_circle
(
dc
,
calibration_ptr
->
width
/
2
,
calibration_ptr
->
height
/
2
,
4
);
break
;
}
rtgui_dc_end_drawing
(
dc
);
}
break
;
case
RTGUI_EVENT_COMMAND
:
{
struct
rtgui_event_command
*
ecmd
=
(
struct
rtgui_event_command
*
)
event
;
switch
(
ecmd
->
command_id
)
{
case
TOUCH_WIN_UPDATE
:
rtgui_widget_update
(
widget
);
break
;
case
TOUCH_WIN_CLOSE
:
rtgui_win_close
(
RTGUI_WIN
(
widget
));
break
;
}
}
return
RT_TRUE
;
default:
rtgui_win_event_handler
(
widget
,
event
);
}
return
RT_FALSE
;
}
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
;
}
void
calibration_init
()
{
rt_device_t
device
;
device
=
rt_device_find
(
"touch"
);
if
(
device
==
RT_NULL
)
return
;
/* no this device */
calibration_ptr
=
(
struct
calibration_session
*
)
rt_malloc
(
sizeof
(
struct
calibration_session
));
rt_memset
(
calibration_ptr
,
0
,
sizeof
(
struct
calibration_data
));
calibration_ptr
->
device
=
device
;
rt_device_control
(
calibration_ptr
->
device
,
RT_TOUCH_CALIBRATION
,
(
void
*
)
calibration_data_post
);
calibration_ptr
->
tid
=
rt_thread_create
(
"cali"
,
calibration_entry
,
RT_NULL
,
2048
,
20
,
5
);
if
(
calibration_ptr
->
tid
!=
RT_NULL
)
rt_thread_startup
(
calibration_ptr
->
tid
);
}
#ifdef RT_USING_FINSH
#include <finsh.h>
void
calibration
()
{
calibration_init
();
}
FINSH_FUNCTION_EXPORT
(
calibration
,
perform
touch
calibration
);
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录