feat:
增加发车和停车菜单 增加停车相关条件开关功能 pref: 弯道速度控制一次函数->二次函数 删除图像下发无意义的0状态 fix: 修复下位机多次复位才能触发上位机复位
This commit is contained in:
@@ -130,6 +130,8 @@ void Page_Init(void)
|
||||
PAGE_REG(page_param_pid2);
|
||||
PAGE_REG(page_param_pid3);
|
||||
PAGE_REG(page_dparam);
|
||||
PAGE_REG(page_gocar);
|
||||
PAGE_REG(page_stopcar);
|
||||
Page_Shift(page_menu);
|
||||
|
||||
pagelist[now_page].SetupCallback(); // 先构建一遍
|
||||
|
||||
@@ -25,6 +25,9 @@ enum PageID {
|
||||
page_param_pid2,
|
||||
page_param_pid3,
|
||||
page_dparam,
|
||||
page_stopcar,
|
||||
page_gocar,
|
||||
|
||||
// page_argv,
|
||||
// page_sys,
|
||||
// page_run,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "page_ui_widget.h"
|
||||
#include "jj_motion.h"
|
||||
#include "page.h"
|
||||
#include"jj_voltage.h"
|
||||
#include "jj_voltage.h"
|
||||
#include <math.h>
|
||||
|
||||
#define LINE_HEAD 0
|
||||
@@ -61,9 +61,11 @@ static void Loop()
|
||||
ips200_show_string(0, 160, "outpos");
|
||||
ips200_show_float(80, 160, out_pos, 4, 1);
|
||||
ips200_show_string(0, 180, "vol");
|
||||
ips200_show_float(80, 180, (float)now_vol, 4,2);
|
||||
ips200_show_string(0, 200, "setsp");
|
||||
ips200_show_float(80, 200, set_speed, 4,2);
|
||||
ips200_show_float(80, 180, (float)now_vol, 4, 2);
|
||||
ips200_show_string(0, 200, "setsp");
|
||||
ips200_show_float(80, 200, set_speed, 4, 2);
|
||||
ips200_show_string(0, 220, "dis");
|
||||
ips200_show_float(80, 220, start_dis, 4, 2);
|
||||
|
||||
ips200_show_string(180, 0, "ls");
|
||||
ips200_show_float(220, 0, pwm_duty_ls, 4, 1);
|
||||
|
||||
120
app/page/page_gocar.c
Normal file
120
app/page/page_gocar.c
Normal file
@@ -0,0 +1,120 @@
|
||||
#include "zf_common_headfile.h"
|
||||
#include "page_ui_widget.h"
|
||||
#include "page.h"
|
||||
#include "by_frame.h"
|
||||
#include "jj_blueteeth.h"
|
||||
#include "jj_motion.h"
|
||||
|
||||
#define LINE_HEAD 1
|
||||
#define LINE_END 6
|
||||
|
||||
static char Text[] = "gocar";
|
||||
|
||||
static int8_t Curser = LINE_HEAD; // 定义光标位置
|
||||
static int8_t Curser_Last = LINE_HEAD; // 定义光标位置
|
||||
static int8_t last_go = 0;
|
||||
static int8_t last_cnt = 0;
|
||||
static int8_t last_fly = 0;
|
||||
/***************************************************************************************
|
||||
*
|
||||
* 以下为页面模板函数
|
||||
*
|
||||
***************************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief 页面初始化事件
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
static void Setup()
|
||||
{
|
||||
|
||||
ips200_clear();
|
||||
Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
|
||||
ips200_show_string(10, 200, "go_flag:");
|
||||
ips200_show_int(80, 200, go_cnt, 1);
|
||||
ips200_show_string(10, 180, "ru_flag:");
|
||||
ips200_show_int(80, 180, bt_run_flag, 1);
|
||||
ips200_show_string(10, 160, "fl_flag:");
|
||||
ips200_show_int(80, 160, bt_fly_flag, 1);
|
||||
ips200_show_string(10, 18, "fan_test");
|
||||
ips200_show_string(10, 2 * 18, "run");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 页面退出事件
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
static void Exit()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 页面循环执行的内容
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
static void Loop()
|
||||
{
|
||||
if (last_cnt != go_cnt) {
|
||||
ips200_show_int(80, 200, go_cnt, 1);
|
||||
}
|
||||
last_cnt = go_cnt;
|
||||
if (last_go != bt_run_flag) {
|
||||
ips200_show_int(80, 180, bt_run_flag, 1);
|
||||
}
|
||||
last_go = bt_run_flag;
|
||||
if (last_fly != bt_fly_flag) {
|
||||
ips200_show_int(80, 160, bt_fly_flag, 1);
|
||||
}
|
||||
last_fly = bt_fly_flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 页面事件
|
||||
* @param btn:发出事件的按键
|
||||
* @param event:事件编号
|
||||
* @retval 无
|
||||
*/
|
||||
static void Event(page_event event)
|
||||
{
|
||||
Curser_Last = Curser;
|
||||
|
||||
if (page_event_forward == event) {
|
||||
Curser--; // 光标上移
|
||||
} else if (page_event_backward == event) {
|
||||
Curser++; // 光标下移
|
||||
} else if (page_event_press_short == event) {
|
||||
if (go_cnt == 1 && Curser == 1) {
|
||||
go_cnt = 0; // 起步拖动失败。重新开始
|
||||
} else if (go_cnt == 0 && Curser == 1) {
|
||||
go_cnt = 1;
|
||||
bt_fly_flag = 1;
|
||||
}
|
||||
if (go_cnt == 1 && Curser == 2) {
|
||||
go_cnt = 2;
|
||||
}
|
||||
|
||||
} else if (page_event_press_long == event) {
|
||||
Page_Shift(page_menu);
|
||||
}
|
||||
|
||||
if (Curser < LINE_HEAD) {
|
||||
Curser = LINE_END;
|
||||
} else if (Curser > LINE_END) {
|
||||
Curser = LINE_HEAD;
|
||||
}
|
||||
|
||||
Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 页面注册函数
|
||||
*
|
||||
* @param pageID
|
||||
*/
|
||||
void PageRegister_page_gocar(unsigned char pageID)
|
||||
{
|
||||
Page_Register(pageID, Text, Setup, Loop, Exit, Event);
|
||||
}
|
||||
@@ -6,15 +6,13 @@
|
||||
#include "jj_motion.h"
|
||||
|
||||
#define LINE_HEAD 1
|
||||
#define LINE_END 5
|
||||
#define LINE_END 7
|
||||
|
||||
static char Text[] = "Menu";
|
||||
|
||||
static int8_t Curser = LINE_HEAD; // 定义光标位置
|
||||
static int8_t Curser_Last = LINE_HEAD; // 定义光标位置
|
||||
uint32_t cnt = 0;
|
||||
|
||||
uint32_t reset[3];
|
||||
static void Print_Menu_p(void);
|
||||
/***************************************************************************************
|
||||
*
|
||||
@@ -29,10 +27,10 @@ static void Print_Menu_p(void);
|
||||
*/
|
||||
static void Setup()
|
||||
{
|
||||
|
||||
ips200_clear();
|
||||
Print_Menu_p();
|
||||
Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
|
||||
reset[0] = 0x01;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,15 +49,6 @@ static void Exit()
|
||||
*/
|
||||
static void Loop()
|
||||
{
|
||||
ips200_show_string(0, 200, "go_flag:");
|
||||
ips200_show_int(180, 200, go_flag, 2);
|
||||
if (go_flag == 1) {
|
||||
bt_fly_flag = 1;
|
||||
|
||||
} else if (go_flag == 2) {
|
||||
system_delay_ms(2000);
|
||||
bt_run_flag = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,18 +70,6 @@ static void Event(page_event event)
|
||||
Page_Shift(Curser); // 切换到光标选中的页面
|
||||
}
|
||||
} else if (page_event_press_long == event) {
|
||||
if (go_flag == 0) {
|
||||
go_flag = 1;
|
||||
} else if (go_flag == 1) {
|
||||
go_flag = 2;
|
||||
}
|
||||
|
||||
// uint32_t temp = 0x5c;
|
||||
// for (int i = 0; i < 3; i++) {
|
||||
// by_frame_send(&temp);
|
||||
// }
|
||||
|
||||
// ips200_clear();
|
||||
}
|
||||
|
||||
if (Curser < LINE_HEAD) {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <math.h>
|
||||
|
||||
#define LINE_HEAD 1
|
||||
#define LINE_END DATA_IN_FLASH_NUM - Page4_head
|
||||
#define LINE_END Page5_head - Page4_head
|
||||
#define Strat_param Page4_head
|
||||
static char Text[] = "barr_pid";
|
||||
static int event_flag = 0;
|
||||
|
||||
137
app/page/page_stopcar.c
Normal file
137
app/page/page_stopcar.c
Normal file
@@ -0,0 +1,137 @@
|
||||
#include "jj_param.h"
|
||||
#include "page_ui_widget.h"
|
||||
#include "jj_motion.h"
|
||||
#include "page.h"
|
||||
#include <math.h>
|
||||
|
||||
#define LINE_HEAD 1
|
||||
#define LINE_END DATA_IN_FLASH_NUM - Page5_head
|
||||
#define Strat_param Page5_head
|
||||
static char Text[] = "stop_sw";
|
||||
static int event_flag = 0;
|
||||
static int index_power = 0;
|
||||
static int8_t Curser = LINE_HEAD; // 定义光标位置
|
||||
static int8_t Curser_Last = LINE_HEAD; // 定义光标位置
|
||||
static void jj_param_show();
|
||||
/***************************************************************************************
|
||||
*
|
||||
* 以下为页面模板函数
|
||||
*
|
||||
***************************************************************************************/
|
||||
/**
|
||||
* @brief 页面初始化事件
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
static void Setup()
|
||||
{
|
||||
ips200_clear();
|
||||
ips200_show_string(0, 2,"barrir");
|
||||
Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
|
||||
for (int16 i = 0; i < LINE_END; i++) {
|
||||
ips200_show_string(0, i * 18 + 20, Param_Data[i +Strat_param ].text);
|
||||
if (Param_Data[i + Strat_param].type == EINT32)
|
||||
ips200_show_int(50, i * 18 + 20, *((int32 *)(Param_Data[i + Strat_param].p_data)), 5);
|
||||
else if (Param_Data[i + Strat_param].type == EFLOAT)
|
||||
ips200_show_float(50, i * 18 + 20, *((float *)(Param_Data[i + Strat_param].p_data)), 4, 5);
|
||||
}
|
||||
ips200_show_int(100, 2, index_power, 5);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 页面退出事件
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
static void Exit()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 页面循环执行的内容
|
||||
* @param 无
|
||||
* @retval 无
|
||||
*/
|
||||
static void Loop()
|
||||
{
|
||||
}
|
||||
/**
|
||||
* @brief 页面事件
|
||||
* @param btn:发出事件的按键
|
||||
* @param event:事件编号
|
||||
* @retval 无
|
||||
*/
|
||||
static void Event(page_event event)
|
||||
{
|
||||
|
||||
if (0 == event_flag) {
|
||||
|
||||
Curser_Last = Curser;
|
||||
if (page_event_forward == event) {
|
||||
Curser--; // 光标上移
|
||||
} else if (page_event_backward == event) {
|
||||
Curser++; // 光标下移
|
||||
} else if (page_event_press_short == event) {
|
||||
event_flag = 1; // 选中参数
|
||||
Print_Curser(Curser, Curser_Last, RGB565_RED);
|
||||
return;
|
||||
} else if (page_event_press_long == event) {
|
||||
jj_param_write();
|
||||
sport_pid_init();
|
||||
Page_Shift(page_menu);
|
||||
return;
|
||||
}
|
||||
if (Curser < LINE_HEAD) {
|
||||
Curser = LINE_END;
|
||||
} else if (Curser > LINE_END) {
|
||||
Curser = LINE_HEAD;
|
||||
}
|
||||
Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
|
||||
} else if (1 == event_flag) {
|
||||
if (page_event_forward == event) {
|
||||
if (Param_Data[Curser + Strat_param-1].type == EFLOAT) {
|
||||
*((float *)(Param_Data[Curser + Strat_param-1].p_data)) += powf(10.0f, (float)index_power);
|
||||
} else if (Param_Data[Curser + Strat_param-1].type == EINT32) {
|
||||
*((int32 *)(Param_Data[Curser + Strat_param-1].p_data)) += 1;
|
||||
} else if (Param_Data[Curser + Strat_param-1].type == EUINT32) {
|
||||
*((uint32 *)(Param_Data[Curser + Strat_param-1].p_data)) += 1;
|
||||
}
|
||||
} else if (page_event_backward == event) {
|
||||
if (Param_Data[Curser + Strat_param-1].type == EFLOAT) {
|
||||
*((float *)(Param_Data[Curser + Strat_param-1].p_data)) -= powf(10.0f, (float)index_power);
|
||||
} else if (Param_Data[Curser + Strat_param-1].type == EINT32) {
|
||||
*((int32 *)(Param_Data[Curser + Strat_param-1].p_data)) -= 1;
|
||||
} else if (Param_Data[Curser + Strat_param-1].type == EUINT32) {
|
||||
*((uint32 *)(Param_Data[Curser + Strat_param-1].p_data)) -= 1;
|
||||
}
|
||||
} else if (page_event_press_short == event) {
|
||||
index_power++;
|
||||
if (index_power > 2) {
|
||||
index_power = -2;
|
||||
}
|
||||
ips200_show_int(100, 2, index_power, 5);
|
||||
} else if (page_event_press_long == event) {
|
||||
event_flag = 0;
|
||||
Print_Curser(Curser, Curser_Last, RGB565_PURPLE);
|
||||
}
|
||||
jj_param_show();
|
||||
}
|
||||
}
|
||||
static void jj_param_show()
|
||||
{
|
||||
if (EINT32 == Param_Data[Curser + Strat_param-1].type)
|
||||
ips200_show_int(50, Curser * 18 + 2, *((int32 *)(Param_Data[Curser + Strat_param-1].p_data)), 5);
|
||||
else if (EUINT32 == Param_Data[Curser + Strat_param-1].type)
|
||||
ips200_show_uint(50, Curser * 18 + 2, *((int32 *)(Param_Data[Curser + Strat_param-1].p_data)), 5);
|
||||
else if (EFLOAT == Param_Data[Curser + Strat_param-1].type)
|
||||
ips200_show_float(50, Curser * 18 + 2, *((float *)(Param_Data[Curser + Strat_param-1].p_data)), 4, 5);
|
||||
}
|
||||
/**
|
||||
* @brief 页面注册函数
|
||||
*
|
||||
* @param pageID
|
||||
*/
|
||||
void PageRegister_page_stopcar(unsigned char pageID)
|
||||
{
|
||||
Page_Register(pageID, Text, Setup, Loop, Exit, Event);
|
||||
}
|
||||
Reference in New Issue
Block a user