improve lcd rotation

This commit is contained in:
lixianjing 2022-02-22 10:33:13 +08:00
parent 0545906c9f
commit 173f166fff
6 changed files with 22 additions and 14 deletions

View File

@ -1,4 +1,8 @@
# 最新动态
2022/02/22
* 统一lcd旋转的方向为逆时针和增加相关接口的说明感谢智明提供补丁
2022/02/21
* 修复fscript global对象初始化的问题。
* 修复value\_int64/value\_uint64对大数的处理。

View File

@ -99,7 +99,7 @@ bool_t tk_is_pointer_pressed(void);
/**
* @method tk_set_lcd_orientation
* (XXX:090)
* (XXX:0,90,180270)
* @param {int} orientation
*
* @return {ret_t} RET_OK表示成功

View File

@ -99,13 +99,8 @@ ret_t pointer_event_rotate(pointer_event_t* evt, system_info_t* info) {
switch (info->lcd_orientation) {
case LCD_ORIENTATION_90: {
#ifdef WITH_GPU
evt->y = info->lcd_w - x - 1;
evt->x = y;
#else
evt->y = x;
evt->x = info->lcd_h - y - 1;
#endif
break;
}
case LCD_ORIENTATION_180: {
@ -114,13 +109,8 @@ ret_t pointer_event_rotate(pointer_event_t* evt, system_info_t* info) {
break;
}
case LCD_ORIENTATION_270: {
#ifdef WITH_GPU
evt->y = x;
evt->x = info->lcd_h - y - 1;
#else
evt->y = info->lcd_w - x - 1;
evt->x = y;
#endif
break;
}
default:

View File

@ -970,7 +970,7 @@ event_t* window_event_init(window_event_t* event, uint32_t type, void* target, w
/**
* @method pointer_event_rotate
* pointer_event中的坐标
* pointer_event中的坐标()
* @param {pointer_event_t*} evt
* @param {system_info_t*} info
*

View File

@ -40,13 +40,13 @@ static ret_t vgcanvas_nanovg_begin_frame(vgcanvas_t* vgcanvas, const dirty_rects
angle = 0.0f;
break;
case LCD_ORIENTATION_90:
angle = TK_D2R(90);
angle = TK_D2R(270);
break;
case LCD_ORIENTATION_180:
angle = TK_D2R(180);
break;
case LCD_ORIENTATION_270:
angle = TK_D2R(270);
angle = TK_D2R(90);
break;
}

View File

@ -19,6 +19,20 @@ TEST(Events, pointer_event_rotate) {
e.y = 20;
info.lcd_orientation = LCD_ORIENTATION_90;
ASSERT_EQ(pointer_event_rotate(&e, &info), RET_OK);
ASSERT_EQ(e.y, 10);
ASSERT_EQ(e.x, 459);
e.x = 10;
e.y = 20;
info.lcd_orientation = LCD_ORIENTATION_180;
ASSERT_EQ(pointer_event_rotate(&e, &info), RET_OK);
ASSERT_EQ(e.y, 459);
ASSERT_EQ(e.x, 309);
e.x = 10;
e.y = 20;
info.lcd_orientation = LCD_ORIENTATION_270;
ASSERT_EQ(pointer_event_rotate(&e, &info), RET_OK);
ASSERT_EQ(e.y, 309);
ASSERT_EQ(e.x, 20);
}