优化窗口移动的逻辑,显示还是有问题,需要继续优化

This commit is contained in:
2021-08-16 23:36:56 +08:00
parent 398d16f69f
commit 2eb96d763e
16 changed files with 13476 additions and 13390 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
66BE74F758C12D739921AEA421D593D3=3
8DF89ED150041C4CBC7CB9A9CAA90856=E458F13A42239457B89B956144879229
DC22A860405A8BF2F2C095E5B6529F12=E458F13A42239457B89B956144879229
8DF89ED150041C4CBC7CB9A9CAA90856=49D03C461CB58C358FC38377BBF9225B
DC22A860405A8BF2F2C095E5B6529F12=49D03C461CB58C358FC38377BBF9225B
eclipse.preferences.version=1
+9 -3
View File
@@ -204,11 +204,11 @@ static void MX_GPIO_Init(void)
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOB, TCLK_Pin|TCS_Pin, GPIO_PIN_SET);
/*Configure GPIO pins : TDOUT_Pin TPEN_Pin */
GPIO_InitStruct.Pin = TDOUT_Pin|TPEN_Pin;
/*Configure GPIO pin : TDOUT_Pin */
GPIO_InitStruct.Pin = TDOUT_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
HAL_GPIO_Init(TDOUT_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pin : TDIN_Pin */
GPIO_InitStruct.Pin = TDIN_Pin;
@@ -217,6 +217,12 @@ static void MX_GPIO_Init(void)
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(TDIN_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pin : TPEN_Pin */
GPIO_InitStruct.Pin = TPEN_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_PULLUP;
HAL_GPIO_Init(TPEN_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pin : LCD_BL_Pin */
GPIO_InitStruct.Pin = LCD_BL_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
+2 -2
View File
@@ -2,5 +2,5 @@ main.c:69:5:main 8 static
main.c:114:6:SystemClock_Config 72 static
main.c:153:13:MX_I2C2_Init 8 static
main.c:187:13:MX_GPIO_Init 48 static
main.c:237:13:MX_FSMC_Init 40 static
main.c:301:6:Error_Handler 4 static,ignoring_inline_asm
main.c:243:13:MX_FSMC_Init 40 static
main.c:307:6:Error_Handler 4 static,ignoring_inline_asm
+3 -3
View File
@@ -4,6 +4,6 @@ touch.c:70:10:TP_Read_XOY 48 static
touch.c:97:6:TP_Read_XY_ADC 24 static
touch.c:111:9:TP_Read_XY2 24 static
touch.c:131:6:TP_Server 16 static
touch.c:142:6:TP_XY 24 static
touch.c:155:6:TP_DrwaTrage 40 static
touch.c:165:6:TP_adjustment 160 static
touch.c:154:6:TP_XY 24 static
touch.c:167:6:TP_DrwaTrage 40 static
touch.c:177:6:TP_adjustment 160 static
+1 -1
View File
@@ -1 +1 @@
Main_APP.c:17:6:main_app 32 static
Main_APP.c:17:6:main_app 96 static
+11 -11
View File
@@ -1,11 +1,11 @@
windows.c:12:6:Inteface_SetCursor 16 static
windows.c:18:6:Inteface_SetColor 16 static
windows.c:24:5:UI_Init 24 static
windows.c:64:9:New_Window 40 static
windows.c:111:6:Close_Windows_Stack 16 static
windows.c:151:6:Set_Windows_Title 24 static
windows.c:159:6:Set_Windows_XY_BY_ACC 24 static
windows.c:166:6:Refresh_Window 32 static
windows.c:209:6:Refresh_UI 32 static
windows.c:285:9:Chack 32 static
windows.c:305:6:UI_Server 40 static
windows.c:13:6:Inteface_SetCursor 16 static
windows.c:19:6:Inteface_SetColor 16 static
windows.c:25:5:UI_Init 24 static
windows.c:67:9:New_Window 40 static
windows.c:114:6:Close_Windows_Stack 16 static
windows.c:154:6:Set_Windows_Title 24 static
windows.c:162:6:Set_Windows_XY_BY_ACC 24 static
windows.c:169:6:Refresh_Window 32 static
windows.c:212:6:Refresh_UI 32 static
windows.c:288:9:Chack 32 static
windows.c:308:6:UI_Server 40 static
BIN
View File
Binary file not shown.
+12767 -12738
View File
File diff suppressed because it is too large Load Diff
+560 -561
View File
File diff suppressed because it is too large Load Diff
+15 -3
View File
@@ -132,10 +132,22 @@ void TP_Server()
{
if(TPEN==0) //如果有触摸
{
TP_Read_XY2(&t0.adc_x,&t0.adc_y); //先读取ad值
t0.pix_x=(t0.adc_x/tconfig.x_acc)-tconfig.x_offset;//转换为像素坐标
t0.pix_y=(t0.adc_y/tconfig.y_acc)-tconfig.y_offset;
if(TP_Read_XY2(&t0.adc_x,&t0.adc_y))
{//先读取ad值
t0.pix_x=(t0.adc_x/tconfig.x_acc)-tconfig.x_offset;//转换为像素坐标
t0.pix_y=(t0.adc_y/tconfig.y_acc)-tconfig.y_offset;
t0.d=1;
}else
{
t0.d=0;
}
t0.c=1;
}else
{
t0.c=0;
t0.pix_x=-1;
t0.pix_y=-1;
}
}
//直接读取
+3 -1
View File
@@ -32,7 +32,9 @@ typedef struct
uint16_t adc_y;
int pix_x;
int pix_y;
char move_flag;
char move_flag:1;
char c:1; //有按键按下
char d:1; //成功读取adc值
}touch_device;
+2 -2
View File
@@ -39,8 +39,8 @@ ENTRY(Reset_Handler)
/* Highest address of the user mode stack */
_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
_Min_Heap_Size = 0x200 ; /* required amount of heap */
_Min_Stack_Size = 0x400 ; /* required amount of stack */
_Min_Heap_Size = 0x400 ; /* required amount of heap */
_Min_Stack_Size = 0x800 ; /* required amount of stack */
/* Memories definition */
MEMORY
+3
View File
@@ -16,6 +16,7 @@ task run_loop;//
void main_app()
{
char str[64];
LCDx_Init();
EPPROM_SLOWWRITE_INIT();
@@ -34,6 +35,8 @@ void main_app()
while(1)
{
LCD_set_dot(t0.pix_x, t0.pix_y, RED);
sprintf(str,"%04d\n%04d\n%04d",t0.pix_x,t0.pix_y,t0.c);
LCD_ShowString(0, 0, &str, 16, RED, BLUE);
/*
switch(run_loop.sw)
{
+85 -55
View File
@@ -7,6 +7,7 @@
#include "windows.h"
#include "touch.h"
extern touch_device t0;
//接口
//设置屏幕像素坐标
void Inteface_SetCursor(uint16_t Xpos, uint16_t Ypos)
@@ -35,6 +36,8 @@ UI *UI_Init(COLOR_16 background)
ui->windows=NULL;
ui->last_windows=NULL;
ui->refresh_ui_flag=1;
ui->moveed_windwos=NULL;
ui->First_click_flag==0;
/*
ui->touch=(touch_device*)malloc(sizeof(touch_device));
if(ui->touch!=NULL)
@@ -314,76 +317,103 @@ void UI_Server(UI *ui)
int t_x,t_y;
//touch
//temp_touch=ui->touch;
if(TP_XY(&t_x, &t_y))//Touch_Server(temp_touch))
if(t0.c)//TP_XY(&t_x, &t_y))
{
temp_window=NULL;
temp_windows_stack=ui->last_windows; //获取ui中最前端的窗口 从前往后扫描
do
if(t0.d)
{
if(temp_windows_stack!=NULL) //如果有窗口就开始扫描
t_x=t0.pix_x;
t_y=t0.pix_y;
temp_window=NULL;
if(ui->moveed_windwos==NULL)
{
flag=1; //检查到有窗口 需要循环一次以检查是否有下一个窗口
//
temp_window=temp_windows_stack->window; //取出这个窗口
hit_flag=Chack(temp_window,t_x,t_y); //检查触摸是否命中 直接返回命中窗口的位置
if(hit_flag) // 命中继续
if(ui->First_click_flag==0)
{
if(temp_windows_stack!=ui->last_windows) //检查是否最前端的窗口 如果不是就放最前面
ui->First_click_flag=1;
temp_windows_stack=ui->last_windows; //获取ui中最前端的窗口 从前往后扫描
do
{
if(temp_windows_stack!=ui->windows) //检查是否最后端的窗口 因为显示是从最后端往前显示的 所以ui有最后端窗口的入口
if(temp_windows_stack!=NULL) //如果有窗口就开始扫描
{
temp_windows_stack->up->next=temp_windows_stack->next; //取出这个节点 把节点的上下补上链接
temp_windows_stack->next->up=temp_windows_stack->up;
flag=1; //检查到有窗口 需要循环一次以检查是否有下一个窗口
//
temp_window=temp_windows_stack->window; //取出这个窗口
hit_flag=Chack(temp_window,t_x,t_y); //检查触摸是否命中 直接返回命中窗口的位置
if(hit_flag) // 命中继续
{
if(temp_windows_stack!=ui->last_windows) //检查是否最前端的窗口 如果不是就放最前面
{
if(temp_windows_stack!=ui->windows) //检查是否最后端的窗口 因为显示是从最后端往前显示的 所以ui有最后端窗口的入口
{
temp_windows_stack->up->next=temp_windows_stack->next; //取出这个节点 把节点的上下补上链接
temp_windows_stack->next->up=temp_windows_stack->up;
}else
{
ui->windows=temp_windows_stack->next; //如果是最后端的窗口 则取出这个节点后入口就变下一个节点了
ui->windows->up=NULL; //倒数第二变最后端 在走就没了 所以要清空指针
}
temp_windows_stack->next=NULL; //取出的节点要放在最前端 所以 无法再往前 清空往前的指针
temp_windows_stack->up=ui->last_windows; //上一个指针就是原来的最后一个
ui->last_windows->next=temp_windows_stack; //原来的最后一个指向现在的最后一个
ui->last_windows=temp_windows_stack; //更新ui中的最后一个的入口
ui->refresh_ui_flag=1; //发生了变化 刷新ui的显示
}
//检查标中窗口的什么位置
switch(hit_flag)
{
case CLOSE:
Close_Windows_Stack(ui,temp_windows_stack);
ui->refresh_ui_flag=1; //发生了变化 刷新ui的显示
break;
case BAR:
ui->moveed_windwos=temp_window;
ui->move_x=t_x-temp_window->x;
ui->move_y=t_y-temp_window->y;
break;
case BODY:
//ui->background=temp_windows_stack->window->background;
//ui->refresh_ui_flag=1;
break;
}
flag=0; //结束扫描 防止穿透当前窗口
}
temp_windows_stack=temp_windows_stack->up; //往前扫描
}else
{
ui->windows=temp_windows_stack->next; //如果是最后端的窗口 则取出这个节点后入口就变下一个节点了
ui->windows->up=NULL; //倒数第二变最后端 在走就没了 所以要清空指针
flag=0; //一个窗口都没有 直接结束循环
}
temp_windows_stack->next=NULL; //取出的节点要放在最前端 所以 无法再往前 清空往前的指针
temp_windows_stack->up=ui->last_windows; //上一个指针就是原来的最后一个
ui->last_windows->next=temp_windows_stack; //原来的最后一个指向现在的最后一个
ui->last_windows=temp_windows_stack; //更新ui中的最后一个的入口
ui->refresh_ui_flag=1; //发生了变化 刷新ui的显示
}
//检查标中窗口的什么位置
switch(hit_flag)
{
case CLOSE:
Close_Windows_Stack(ui,temp_windows_stack);
ui->refresh_ui_flag=1; //发生了变化 刷新ui的显示
break;
case BAR:
if(ui->window_move_lock==0)
{
ui->window_move_x=t_x;
ui->window_move_y=t_y;
}
Set_Windows_XY_BY_ACC(temp_windows_stack->window,t_x-ui->window_move_x,t_y-ui->window_move_y);
ui->window_move_x=t_x;
ui->window_move_y=t_y;
ui->refresh_ui_flag=1; //发生了变化 刷新ui的显示
break;
case BODY:
//ui->background=temp_windows_stack->window->background;
//ui->refresh_ui_flag=1;
break;
}
flag=0; //结束扫描 防止穿透当前窗口
}while(flag);
}
temp_windows_stack=temp_windows_stack->up; //往前扫描
}else
{
flag=0; //一个窗口都没有 直接结束循环
temp_window=ui->moveed_windwos;
temp_window->x=t_x-ui->move_x;
temp_window->y=t_y-ui->move_y;
ui->refresh_ui_flag=1;
//发生了变化 刷新ui的显示
}
}while(flag);
ui->window_move_lock=1;
}
}else
{
ui->window_move_lock=0;
if(ui->First_click_flag==1)
{
ui->First_click_flag=0;
}
if(ui->moveed_windwos!=NULL)
{
ui->moveed_windwos=NULL;
}
}
//display
if(ui->refresh_ui_flag==1)
+8 -4
View File
@@ -18,6 +18,8 @@ typedef struct
uint16_t high;
COLOR_16 background;
char title[16];
}window;
@@ -38,11 +40,13 @@ typedef struct
uint16_t high;
windows_stack *windows;
windows_stack *last_windows;
//touch_device *touch; //Ò»¸öUI¹ÒÔØÒ»¸ö´¥¿ØÉ豸
int window_move_x;
int window_move_y;
window *moveed_windwos;//¼Ç¼ÕýÔÚ±»Òƶ¯µÄ´°¿Ú
int move_x;
int move_y;
uint8_t move_lock:1;
uint8_t First_click_flag:1;
uint8_t refresh_ui_flag:1;
uint8_t window_move_lock:1;
}UI;
void Inteface_SetCursor(uint16_t Xpos, uint16_t Ypos);
+5 -4
View File
@@ -105,8 +105,9 @@ PE15.Signal=FSMC_D12_DA12
PE7.Signal=FSMC_D4_DA4
PE8.Signal=FSMC_D5_DA5
PE9.Signal=FSMC_D6_DA6
PF10.GPIOParameters=GPIO_Label
PF10.GPIOParameters=GPIO_PuPd,GPIO_Label
PF10.GPIO_Label=TPEN
PF10.GPIO_PuPd=GPIO_PULLUP
PF10.Locked=true
PF10.Signal=GPIO_Input
PF8.GPIOParameters=GPIO_Label
@@ -135,7 +136,7 @@ ProjectManager.DeviceId=STM32F103ZETx
ProjectManager.FirmwarePackage=STM32Cube FW_F1 V1.8.4
ProjectManager.FreePins=false
ProjectManager.HalAssertFull=false
ProjectManager.HeapSize=0x200
ProjectManager.HeapSize=0x400
ProjectManager.KeepUserCode=true
ProjectManager.LastFirmware=true
ProjectManager.LibraryCopy=1
@@ -146,11 +147,11 @@ ProjectManager.ProjectBuild=false
ProjectManager.ProjectFileName=m3s.ioc
ProjectManager.ProjectName=m3s
ProjectManager.RegisterCallBack=
ProjectManager.StackSize=0x400
ProjectManager.StackSize=0x800
ProjectManager.TargetToolchain=STM32CubeIDE
ProjectManager.ToolChainLocation=
ProjectManager.UnderRoot=true
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_FSMC_Init-FSMC-false-HAL-true
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_FSMC_Init-FSMC-false-HAL-true,4-MX_I2C2_Init-I2C2-false-HAL-true
RCC.ADCFreqValue=36000000
RCC.AHBFreq_Value=72000000
RCC.APB1CLKDivider=RCC_HCLK_DIV2