加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
key.c 28.41 KB
一键复制 编辑 原始数据 按行查看 历史
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864
#include "ti_msp_dl_config.h"
#include "sensor.h"
#include "developer_mode.h"
#include "nclink.h"
#include "bsp_eeprom.h"
#include "w25qxx.h"
#include "bsp_led.h"
#include "drv_expand.h"
#include "systick.h"
#include "drv_oled.h"
#include "key.h"
int16_t Page_Number = 0;
#define Page_Number_Max 5
button _button;
float Button_ADCResult[2];
uint16_t adc_value[3] = {0, 0, 0};
uint8_t Key_Value[2];
void Key_Init(void)
{
_button.state[UP].port = keyup_port;
_button.state[UP].pin = keyup_pin;
_button.state[UP].value = 1;
_button.state[UP].last_value = 1;
_button.state[DOWN].port = keydown_port;
_button.state[DOWN].pin = keydown_pin;
_button.state[DOWN].value = 1;
_button.state[DOWN].last_value = 1;
//3D
_button.state[UP_3D].port = PORTB_PORT;
_button.state[UP_3D].pin = PORTB_D3_5_PIN;
_button.state[UP_3D].value = 1;
_button.state[UP_3D].last_value = 1;
_button.state[DN_3D].port = PORTB_PORT;
_button.state[DN_3D].pin = PORTB_D3_1_PIN;
_button.state[DN_3D].value = 1;
_button.state[DN_3D].last_value = 1;
_button.state[LT_3D].port = PORTB_PORT;
_button.state[LT_3D].pin = PORTB_D3_2_PIN;
_button.state[LT_3D].value = 1;
_button.state[LT_3D].last_value = 1;
_button.state[RT_3D].port = PORTB_PORT;
_button.state[RT_3D].pin = PORTB_D3_3_PIN;
_button.state[RT_3D].value = 1;
_button.state[RT_3D].last_value = 1;
_button.state[ME_3D].port = PORTB_PORT;
_button.state[ME_3D].pin = PORTB_D3_4_PIN;
_button.state[ME_3D].value = 1;
_button.state[ME_3D].last_value = 1;
}
void Read_Button_State_One(button_state *button)
{
if(button->pin == KEYA_S2_PIN) button->value = (DL_GPIO_readPins(button->port, button->pin) != 0 ? 0x00 : 0x01);
else button->value = (DL_GPIO_readPins(button->port, button->pin) != 0 ? 0x01 : 0x00);
if(button->value==0)
{
if(button->last_value!=0)//首次按下
{
button->press_time=millis();//记录按下的时间点
button->in_time=millis();//记录按下的时间点
button->in_press_cnt=0;
}
else
{
if(millis()-button->press_time>KEEP_LONG_PRESS_LIMIT)//达到持续长按时间限制,声音提示可以松开了
{
// beep.period=20;//20*5ms
// beep.light_on_percent=0.5f;
// beep.reset=1;
// beep.times=1;
}
else if(millis()-button->in_time>IN_PRESS_LIMIT)//持续按下
{
button->in_time=millis();
button->press=IN_PRESS;
if(button->press==IN_PRESS) button->in_press_cnt++;
}
}
}
else
{
if(button->last_value==0)//按下后释放
{
button->release_time=millis();//记录释放时的时间
if(button->release_time-button->press_time>KEEP_LONG_PRESS_LIMIT)//持续长按按键5S
{
button->press=KEEP_LONG_PRESS;
button->state_lock_time=0;
buzzer_setup(1000,0.5f,4);
}
else if(button->release_time-button->press_time>LONG_PRESS_LIMIT)//长按按键1S
{
button->press=LONG_PRESS;
button->state_lock_time=0;//5ms*300=1.5S
buzzer_setup(1000,0.5f,1);
}
else
{
button->press=SHORT_PRESS;
button->state_lock_time=0;//5ms*300=1.5S
buzzer_setup(100,0.5f,1);
}
}
}
button->last_value=button->value;
if(button->press==LONG_PRESS
||button->press==SHORT_PRESS)//按下释放后,程序后台1.5S内无响应,复位按键状态
{
button->state_lock_time++;
if(button->state_lock_time>=300)
{
button->press=NO_PRESS;
button->state_lock_time=0;
}
}
}
void Read_Button_State_All(void)
{
for(uint16_t i = 0; i < BUTTON_NUM; i++)
{
Read_Button_State_One(&_button.state[i]);
}
}
void key_delay(int32_t period)
{
while(period--)
{
delay_us(1);
}
}
bool Key_Scan(uint8_t release)
{
if(release == 1) return false;
if(_button.state[UP].press == SHORT_PRESS)
{
Page_Number--;
if(Page_Number < 0) Page_Number = Page_Number_Max;
_button.state[UP].press = NO_PRESS;
OLED_CLS();
//buzzer_setup(200, 0.5, 1);
}
if(_button.state[DOWN].press == SHORT_PRESS)
{
Page_Number++;
if(Page_Number > Page_Number_Max) Page_Number = 0;
_button.state[DOWN].press = NO_PRESS;
OLED_CLS();
//buzzer_setup(200, 0.5, 1);
}
return true;
}
extern uint16_t w25qxx_id;
extern systime t_g0;
void oled_page_show(void)
{
switch(Page_Number)
{
case 0:
{
LCD_clear_L(0, 0);
write_6_8_number_f1(0, 0, t_g0.period);
display_6_8_string(30, 0, "SDK:");
display_6_8_number(55, 0, SDK1_Mode_Setup);
display_6_8_string(75, 0, "INC:");
display_6_8_number(105, 0, task_select_cnt);
display_6_8_number(115, 0, Page_Number + 1);
LCD_clear_L(0, 1);
display_6_8_string(0, 1, "Y:");
display_6_8_number(15, 1, uav_ahrs.yaw);
if(uav_ahrs.rpy_gyro_dps[2] < 0) display_6_8_string(55, 1, "-");
else display_6_8_string(55, 1, "+");
display_6_8_number(63, 1, ABS(uav_ahrs.rpy_gyro_dps[2]));
display_6_8_number(105, 1, uav_ahrs.quaternion_init_ok);
LCD_clear_L(0, 2);
display_6_8_string(0, 2, "P:");
display_6_8_number(15, 2, uav_ahrs.pitch);
if(uav_ahrs.rpy_gyro_dps[1] < 0) display_6_8_string(55, 2, "-");
else display_6_8_string(55, 2, "+");
display_6_8_number(63, 2, ABS(uav_ahrs.rpy_gyro_dps[1]));
display_6_8_number(105, 2, current_state.rec_update_flag);
LCD_clear_L(0, 3);
display_6_8_string(0, 3, "R:");
display_6_8_number(15, 3, uav_ahrs.roll);
if(uav_ahrs.rpy_gyro_dps[0] < 0) display_6_8_string(55, 3, "-");
else display_6_8_string(55, 3, "+");
display_6_8_number(63, 3, ABS(uav_ahrs.rpy_gyro_dps[0]));
display_6_8_number(105, 3, offboard_start_flag);
LCD_clear_L(0, 4);
display_6_8_string(0, 4, "EPV:");
write_6_8_number_f1(30, 4, uav_ins.position[_EAST]);
write_6_8_number_f1(60, 4, uav_ins.speed[_EAST]);
LCD_clear_L(0, 5);
display_6_8_string(0, 5, "NPV:");
write_6_8_number_f1(30, 5, uav_ins.position[_NORTH]);
write_6_8_number_f1(60, 5, uav_ins.speed[_NORTH]);
LCD_clear_L(0, 6);
display_6_8_string(0, 6, "UPV:");
write_6_8_number_f1(30, 6, uav_ins.position[_UP]);
write_6_8_number_f1(60, 6, uav_ins.speed[_UP]);
LCD_clear_L(0, 7);
display_6_8_string(0, 7, "AC:");
write_6_8_number_f1(20, 7, uav_ins.accel_cmpss[_EAST]);
write_6_8_number_f1(55, 7, uav_ins.accel_cmpss[_NORTH]);
write_6_8_number_f1(90, 7, uav_ins.accel_cmpss[_UP]);
/***********************************************************************************/
if(_button.state[DN_3D].press == SHORT_PRESS)//下键长按,实现对SDK1_Mode_Setup的调整
{
_button.state[DN_3D].press = NO_PRESS;
SDK1_Mode_Setup++;
if(SDK1_Mode_Setup > SDK_MODE_VALID_MAX) SDK1_Mode_Setup = 0;
WriteFlashParameter(SDK1_MODE_DEFAULT, SDK1_Mode_Setup);
Bling_Set(&Light_Blue, 500, 50, 0.5, 0, BLING_B_PORT, GPIO_RGB_BLUE_PIN, 0);//蓝色
}
if(_button.state[UP_3D].press == SHORT_PRESS)//上按键长按,实现对SDK1_Mode_Setup的调整
{
_button.state[UP_3D].press = NO_PRESS;
SDK1_Mode_Setup--;
if(SDK1_Mode_Setup < 0) SDK1_Mode_Setup = SDK_MODE_VALID_MAX;
WriteFlashParameter(SDK1_MODE_DEFAULT, SDK1_Mode_Setup);
Bling_Set(&Light_Blue, 500, 50, 0.5, 0, BLING_B_PORT, GPIO_RGB_BLUE_PIN, 0);//蓝色
}
/***********************************************************************************/
if(_button.state[RT_3D].press==SHORT_PRESS)//3D右键短按,实现对task_select_cnt的调整
{
_button.state[RT_3D].press=NO_PRESS;
task_select_cnt++;
if(task_select_cnt>5) task_select_cnt=0;
WriteFlashParameter(TASK_SELECT_AFTER_TAKEOFF,task_select_cnt);
Bling_Set(&Light_Blue, 500, 50, 0.5, 0, BLING_B_PORT, GPIO_RGB_BLUE_PIN, 0);//蓝色
}
if(_button.state[LT_3D].press==SHORT_PRESS)//3D左键短按,实现对task_select_cnt的调整
{
_button.state[LT_3D].press=NO_PRESS;
task_select_cnt--;
if(task_select_cnt<0) task_select_cnt=5;
WriteFlashParameter(TASK_SELECT_AFTER_TAKEOFF,task_select_cnt);
Bling_Set(&Light_Blue, 500, 50, 0.5, 0, BLING_B_PORT, GPIO_RGB_BLUE_PIN, 0);//蓝色
}
/***********************************************************************************/
if(_button.state[ME_3D].press == LONG_PRESS)
{
_button.state[ME_3D].press = NO_PRESS;
AT24CXX_Erase_All();//清空eeprom
w25qxx_erase_all(); //清空flash
}
};
break;
case 1:
{
uint16_t base_item = 50;
LCD_clear_L(0, 0);
display_6_8_string(0, 0, "nav_point:1/7 e-n-u");
write_6_8_number(115, 0, Page_Number + 1);
LCD_clear_L(0, 1);
display_6_8_string(0, 1, "p1");
write_6_8_number(25, 1, param_value[base_item + 0]);
write_6_8_number(60, 1, param_value[base_item + 1]);
write_6_8_number(95, 1, param_value[base_item + 2]);
LCD_clear_L(0, 2);
display_6_8_string(0, 2, "p2");
write_6_8_number(25, 2, param_value[base_item + 3]);
write_6_8_number(60, 2, param_value[base_item + 4]);
write_6_8_number(95, 2, param_value[base_item + 5]);
LCD_clear_L(0, 3);
display_6_8_string(0, 3, "p3");
write_6_8_number(25, 3, param_value[base_item + 6]);
write_6_8_number(60, 3, param_value[base_item + 7]);
write_6_8_number(95, 3, param_value[base_item + 8]);
LCD_clear_L(0, 4);
display_6_8_string(0, 4, "p4");
write_6_8_number(25, 4, param_value[base_item + 9]);
write_6_8_number(60, 4, param_value[base_item + 10]);
write_6_8_number(95, 4, param_value[base_item + 11]);
LCD_clear_L(0, 5);
display_6_8_string(0, 5, "p5");
write_6_8_number(25, 5, param_value[base_item + 12]);
write_6_8_number(60, 5, param_value[base_item + 13]);
write_6_8_number(95, 5, param_value[base_item + 14]);
LCD_clear_L(0, 6);
display_6_8_string(0, 6, "p6");
write_6_8_number(25, 6, param_value[base_item + 15]);
write_6_8_number(60, 6, param_value[base_item + 16]);
write_6_8_number(95, 6, param_value[base_item + 17]);
LCD_clear_L(0, 7);
display_6_8_string(0, 7, "p7");
write_6_8_number(25, 7, param_value[base_item + 18]);
write_6_8_number(60, 7, param_value[base_item + 19]);
write_6_8_number(95, 7, param_value[base_item + 20]);
static uint16_t ver_item = 1;
if(ver_item == 1) display_6_8_string(18, 1, "*");
else if(ver_item == 2) display_6_8_string(53, 1, "*");
else if(ver_item == 3) display_6_8_string(88, 1, "*");
if(ver_item == 4) display_6_8_string(18, 2, "*");
else if(ver_item == 5) display_6_8_string(53, 2, "*");
else if(ver_item == 6) display_6_8_string(88, 2, "*");
if(ver_item == 7) display_6_8_string(18, 3, "*");
else if(ver_item == 8) display_6_8_string(53, 3, "*");
else if(ver_item == 9) display_6_8_string(88, 3, "*");
if(ver_item == 10) display_6_8_string(18, 4, "*");
else if(ver_item == 11) display_6_8_string(53, 4, "*");
else if(ver_item == 12) display_6_8_string(88, 4, "*");
if(ver_item == 13) display_6_8_string(18, 5, "*");
else if(ver_item == 14) display_6_8_string(53, 5, "*");
else if(ver_item == 15) display_6_8_string(88, 5, "*");
if(ver_item == 16) display_6_8_string(18, 6, "*");
else if(ver_item == 17) display_6_8_string(53, 6, "*");
else if(ver_item == 18) display_6_8_string(88, 6, "*");
if(ver_item == 19) display_6_8_string(18, 7, "*");
else if(ver_item == 20) display_6_8_string(53, 7, "*");
else if(ver_item == 21) display_6_8_string(88, 7, "*");
//通过3D按键来实现换行选中待修改参数
if(_button.state[UP_3D].press == SHORT_PRESS)
{
_button.state[UP_3D].press = NO_PRESS;
ver_item--;
if(ver_item < 1) ver_item = 21;
Bling_Set(&Light_Blue, 500, 50, 0.5, 0, BLING_B_PORT, GPIO_RGB_BLUE_PIN, 0); //蓝色
}
if(_button.state[DN_3D].press == SHORT_PRESS)
{
_button.state[DN_3D].press = NO_PRESS;
ver_item++;
if(ver_item > 21) ver_item = 1;
Bling_Set(&Light_Blue, 500, 50, 0.5, 0, BLING_B_PORT, GPIO_RGB_BLUE_PIN, 0); //蓝色
}
//通过左按键短按可以实现选中的参数行自减小1调整
if(_button.state[LT_3D].press == SHORT_PRESS)
{
_button.state[LT_3D].press = NO_PRESS;
param_value[base_item + ver_item - 1] -= 1;
}
//通过右按键短按可以实现选中的参数行自增加1调整
if(_button.state[RT_3D].press == SHORT_PRESS)
{
_button.state[RT_3D].press = NO_PRESS;
param_value[base_item + ver_item - 1] += 1;
}
//通过左按键短按可以实现选中的参数行自减小50调整
if(_button.state[LT_3D].press == LONG_PRESS)
{
_button.state[LT_3D].press = NO_PRESS;
param_value[base_item + ver_item - 1] -= 50;
}
//通过右按键短按可以实现选中的参数行自增加50调整
if(_button.state[RT_3D].press == LONG_PRESS)
{
_button.state[RT_3D].press = NO_PRESS;
param_value[base_item + ver_item - 1] += 50;
}
//通过中间按键长按可以实现此页设置的所有参数保存
if(_button.state[ME_3D].press == LONG_PRESS)
{
_button.state[ME_3D].press = NO_PRESS;
//按下后对参数进行保存
for(uint16_t i = 0; i < 21; i++)
{
WriteFlashParameter(RESERVED_PARAM + base_item + i, param_value[base_item + i]);
}
}
}
break;
case 2:
{
uint16_t base_item = 50 + 21 * 1;
LCD_clear_L(0, 0);
display_6_8_string(0, 0, "nav_point:8/14 e-n-u");
write_6_8_number(115, 0, Page_Number + 1);
LCD_clear_L(0, 1);
display_6_8_string(0, 1, "p8");
write_6_8_number(25, 1, param_value[base_item + 0]);
write_6_8_number(60, 1, param_value[base_item + 1]);
write_6_8_number(95, 1, param_value[base_item + 2]);
LCD_clear_L(0, 2);
display_6_8_string(0, 2, "p9");
write_6_8_number(25, 2, param_value[base_item + 3]);
write_6_8_number(60, 2, param_value[base_item + 4]);
write_6_8_number(95, 2, param_value[base_item + 5]);
LCD_clear_L(0, 3);
display_6_8_string(0, 3, "p10");
write_6_8_number(25, 3, param_value[base_item + 6]);
write_6_8_number(60, 3, param_value[base_item + 7]);
write_6_8_number(95, 3, param_value[base_item + 8]);
LCD_clear_L(0, 4);
display_6_8_string(0, 4, "p11");
write_6_8_number(25, 4, param_value[base_item + 9]);
write_6_8_number(60, 4, param_value[base_item + 10]);
write_6_8_number(95, 4, param_value[base_item + 11]);
LCD_clear_L(0, 5);
display_6_8_string(0, 5, "p12");
write_6_8_number(25, 5, param_value[base_item + 12]);
write_6_8_number(60, 5, param_value[base_item + 13]);
write_6_8_number(95, 5, param_value[base_item + 14]);
LCD_clear_L(0, 6);
display_6_8_string(0, 6, "p13");
write_6_8_number(25, 6, param_value[base_item + 15]);
write_6_8_number(60, 6, param_value[base_item + 16]);
write_6_8_number(95, 6, param_value[base_item + 17]);
LCD_clear_L(0, 7);
display_6_8_string(0, 7, "p14");
write_6_8_number(25, 7, param_value[base_item + 18]);
write_6_8_number(60, 7, param_value[base_item + 19]);
write_6_8_number(95, 7, param_value[base_item + 20]);
static uint16_t ver_item = 1;
if(ver_item == 1) display_6_8_string(18, 1, "*");
else if(ver_item == 2) display_6_8_string(53, 1, "*");
else if(ver_item == 3) display_6_8_string(88, 1, "*");
if(ver_item == 4) display_6_8_string(18, 2, "*");
else if(ver_item == 5) display_6_8_string(53, 2, "*");
else if(ver_item == 6) display_6_8_string(88, 2, "*");
if(ver_item == 7) display_6_8_string(18, 3, "*");
else if(ver_item == 8) display_6_8_string(53, 3, "*");
else if(ver_item == 9) display_6_8_string(88, 3, "*");
if(ver_item == 10) display_6_8_string(18, 4, "*");
else if(ver_item == 11) display_6_8_string(53, 4, "*");
else if(ver_item == 12) display_6_8_string(88, 4, "*");
if(ver_item == 13) display_6_8_string(18, 5, "*");
else if(ver_item == 14) display_6_8_string(53, 5, "*");
else if(ver_item == 15) display_6_8_string(88, 5, "*");
if(ver_item == 16) display_6_8_string(18, 6, "*");
else if(ver_item == 17) display_6_8_string(53, 6, "*");
else if(ver_item == 18) display_6_8_string(88, 6, "*");
if(ver_item == 19) display_6_8_string(18, 7, "*");
else if(ver_item == 20) display_6_8_string(53, 7, "*");
else if(ver_item == 21) display_6_8_string(88, 7, "*");
//通过3D按键来实现换行选中待修改参数
if(_button.state[UP_3D].press == SHORT_PRESS)
{
_button.state[UP_3D].press = NO_PRESS;
ver_item--;
if(ver_item < 1) ver_item = 21;
Bling_Set(&Light_Blue, 500, 50, 0.5, 0, BLING_B_PORT, GPIO_RGB_BLUE_PIN, 0); //蓝色
Bling_Set(&Light_Blue, 500, 50, 0.2, 0, BLING_B_PORT, GPIO_RGB_BLUE_PIN, 0); //蓝色
}
if(_button.state[DN_3D].press == SHORT_PRESS)
{
_button.state[DN_3D].press = NO_PRESS;
ver_item++;
if(ver_item > 21) ver_item = 1;
Bling_Set(&Light_Blue, 500, 50, 0.5, 0, BLING_B_PORT, GPIO_RGB_BLUE_PIN, 0); //蓝色
}
//通过左按键短按可以实现选中的参数行自减小1调整
if(_button.state[LT_3D].press == SHORT_PRESS)
{
_button.state[LT_3D].press = NO_PRESS;
param_value[base_item + ver_item - 1] -= 1;
}
//通过右按键短按可以实现选中的参数行自增加1调整
if(_button.state[RT_3D].press == SHORT_PRESS)
{
_button.state[RT_3D].press = NO_PRESS;
param_value[base_item + ver_item - 1] += 1;
}
//通过左按键短按可以实现选中的参数行自减小50调整
if(_button.state[LT_3D].press == LONG_PRESS)
{
_button.state[LT_3D].press = NO_PRESS;
param_value[base_item + ver_item - 1] -= 50;
}
//通过右按键短按可以实现选中的参数行自增加50调整
if(_button.state[RT_3D].press == LONG_PRESS)
{
_button.state[RT_3D].press = NO_PRESS;
param_value[base_item + ver_item - 1] += 50;
}
//通过中间按键长按可以实现此页设置的所有参数保存
if(_button.state[ME_3D].press == LONG_PRESS)
{
_button.state[ME_3D].press = NO_PRESS;
//按下后对参数进行保存
for(uint16_t i = 0; i < 21; i++)
{
WriteFlashParameter(RESERVED_PARAM + base_item + i, param_value[base_item + i]);
}
}
}
break;
case 3:
{
uint16_t base_item = 50 + 21 * 2;
LCD_clear_L(0, 0);
display_6_8_string(0, 0, "nav_point:15/21 e-n-u");
write_6_8_number(115, 0, Page_Number + 1);
LCD_clear_L(0, 1);
display_6_8_string(0, 1, "p15");
write_6_8_number(25, 1, param_value[base_item + 0]);
write_6_8_number(60, 1, param_value[base_item + 1]);
write_6_8_number(95, 1, param_value[base_item + 2]);
LCD_clear_L(0, 2);
display_6_8_string(0, 2, "p16");
write_6_8_number(25, 2, param_value[base_item + 3]);
write_6_8_number(60, 2, param_value[base_item + 4]);
write_6_8_number(95, 2, param_value[base_item + 5]);
LCD_clear_L(0, 3);
display_6_8_string(0, 3, "p17");
write_6_8_number(25, 3, param_value[base_item + 6]);
write_6_8_number(60, 3, param_value[base_item + 7]);
write_6_8_number(95, 3, param_value[base_item + 8]);
LCD_clear_L(0, 4);
display_6_8_string(0, 4, "p18");
write_6_8_number(25, 4, param_value[base_item + 9]);
write_6_8_number(60, 4, param_value[base_item + 10]);
write_6_8_number(95, 4, param_value[base_item + 11]);
LCD_clear_L(0, 5);
display_6_8_string(0, 5, "p19");
write_6_8_number(25, 5, param_value[base_item + 12]);
write_6_8_number(60, 5, param_value[base_item + 13]);
write_6_8_number(95, 5, param_value[base_item + 14]);
LCD_clear_L(0, 6);
display_6_8_string(0, 6, "p20");
write_6_8_number(25, 6, param_value[base_item + 15]);
write_6_8_number(60, 6, param_value[base_item + 16]);
write_6_8_number(95, 6, param_value[base_item + 17]);
LCD_clear_L(0, 7);
display_6_8_string(0, 7, "p21");
write_6_8_number(25, 7, param_value[base_item + 18]);
write_6_8_number(60, 7, param_value[base_item + 19]);
write_6_8_number(95, 7, param_value[base_item + 20]);
static uint16_t ver_item = 1;
if(ver_item == 1) display_6_8_string(18, 1, "*");
else if(ver_item == 2) display_6_8_string(53, 1, "*");
else if(ver_item == 3) display_6_8_string(88, 1, "*");
if(ver_item == 4) display_6_8_string(18, 2, "*");
else if(ver_item == 5) display_6_8_string(53, 2, "*");
else if(ver_item == 6) display_6_8_string(88, 2, "*");
if(ver_item == 7) display_6_8_string(18, 3, "*");
else if(ver_item == 8) display_6_8_string(53, 3, "*");
else if(ver_item == 9) display_6_8_string(88, 3, "*");
if(ver_item == 10) display_6_8_string(18, 4, "*");
else if(ver_item == 11) display_6_8_string(53, 4, "*");
else if(ver_item == 12) display_6_8_string(88, 4, "*");
if(ver_item == 13) display_6_8_string(18, 5, "*");
else if(ver_item == 14) display_6_8_string(53, 5, "*");
else if(ver_item == 15) display_6_8_string(88, 5, "*");
if(ver_item == 16) display_6_8_string(18, 6, "*");
else if(ver_item == 17) display_6_8_string(53, 6, "*");
else if(ver_item == 18) display_6_8_string(88, 6, "*");
if(ver_item == 19) display_6_8_string(18, 7, "*");
else if(ver_item == 20) display_6_8_string(53, 7, "*");
else if(ver_item == 21) display_6_8_string(88, 7, "*");
//通过3D按键来实现换行选中待修改参数
if(_button.state[UP_3D].press == SHORT_PRESS)
{
_button.state[UP_3D].press = NO_PRESS;
ver_item--;
if(ver_item < 1) ver_item = 21;
Bling_Set(&Light_Blue, 500, 50, 0.5, 0, BLING_B_PORT, GPIO_RGB_BLUE_PIN, 0); //蓝色
}
if(_button.state[DN_3D].press == SHORT_PRESS)
{
_button.state[DN_3D].press = NO_PRESS;
ver_item++;
if(ver_item > 21) ver_item = 1;
Bling_Set(&Light_Blue, 500, 50, 0.5, 0, BLING_B_PORT, GPIO_RGB_BLUE_PIN, 0);//蓝色
}
//通过左按键短按可以实现选中的参数行自减小1调整
if(_button.state[LT_3D].press == SHORT_PRESS)
{
_button.state[LT_3D].press = NO_PRESS;
param_value[base_item + ver_item - 1] -= 1;
}
//通过右按键短按可以实现选中的参数行自增加1调整
if(_button.state[RT_3D].press == SHORT_PRESS)
{
_button.state[RT_3D].press = NO_PRESS;
param_value[base_item + ver_item - 1] += 1;
}
//通过左按键短按可以实现选中的参数行自减小50调整
if(_button.state[LT_3D].press == LONG_PRESS)
{
_button.state[LT_3D].press = NO_PRESS;
param_value[base_item + ver_item - 1] -= 50;
}
//通过右按键短按可以实现选中的参数行自增加50调整
if(_button.state[RT_3D].press == LONG_PRESS)
{
_button.state[RT_3D].press = NO_PRESS;
param_value[base_item + ver_item - 1] += 50;
}
//通过中间按键长按可以实现此页设置的所有参数保存
if(_button.state[ME_3D].press == LONG_PRESS)
{
_button.state[ME_3D].press = NO_PRESS;
//按下后对参数进行保存
for(uint16_t i = 0; i < 21; i++)
{
WriteFlashParameter(RESERVED_PARAM + base_item + i, param_value[base_item + i]);
}
}
}
break;
case 4:
{
uint16_t base_item = 50 + 21 * 3;
LCD_clear_L(0, 0);
display_6_8_string(0, 0, "nav_point:22/28 e-n-u");
write_6_8_number(115, 0, Page_Number + 1);
LCD_clear_L(0, 1);
display_6_8_string(0, 1, "p22");
write_6_8_number(25, 1, param_value[base_item + 0]);
write_6_8_number(60, 1, param_value[base_item + 1]);
write_6_8_number(95, 1, param_value[base_item + 2]);
LCD_clear_L(0, 2);
display_6_8_string(0, 2, "p23");
write_6_8_number(25, 2, param_value[base_item + 3]);
write_6_8_number(60, 2, param_value[base_item + 4]);
write_6_8_number(95, 2, param_value[base_item + 5]);
LCD_clear_L(0, 3);
display_6_8_string(0, 3, "p24");
write_6_8_number(25, 3, param_value[base_item + 6]);
write_6_8_number(60, 3, param_value[base_item + 7]);
write_6_8_number(95, 3, param_value[base_item + 8]);
LCD_clear_L(0, 4);
display_6_8_string(0, 4, "p25");
write_6_8_number(25, 4, param_value[base_item + 9]);
write_6_8_number(60, 4, param_value[base_item + 10]);
write_6_8_number(95, 4, param_value[base_item + 11]);
LCD_clear_L(0, 5);
display_6_8_string(0, 5, "p26");
write_6_8_number(25, 5, param_value[base_item + 12]);
write_6_8_number(60, 5, param_value[base_item + 13]);
write_6_8_number(95, 5, param_value[base_item + 14]);
LCD_clear_L(0, 6);
display_6_8_string(0, 6, "p27");
write_6_8_number(25, 6, param_value[base_item + 15]);
write_6_8_number(60, 6, param_value[base_item + 16]);
write_6_8_number(95, 6, param_value[base_item + 17]);
LCD_clear_L(0, 7);
display_6_8_string(0, 7, "p28");
write_6_8_number(25, 7, param_value[base_item + 18]);
write_6_8_number(60, 7, param_value[base_item + 19]);
write_6_8_number(95, 7, param_value[base_item + 20]);
static uint16_t ver_item = 1;
if(ver_item == 1) display_6_8_string(18, 1, "*");
else if(ver_item == 2) display_6_8_string(53, 1, "*");
else if(ver_item == 3) display_6_8_string(88, 1, "*");
if(ver_item == 4) display_6_8_string(18, 2, "*");
else if(ver_item == 5) display_6_8_string(53, 2, "*");
else if(ver_item == 6) display_6_8_string(88, 2, "*");
if(ver_item == 7) display_6_8_string(18, 3, "*");
else if(ver_item == 8) display_6_8_string(53, 3, "*");
else if(ver_item == 9) display_6_8_string(88, 3, "*");
if(ver_item == 10) display_6_8_string(18, 4, "*");
else if(ver_item == 11) display_6_8_string(53, 4, "*");
else if(ver_item == 12) display_6_8_string(88, 4, "*");
if(ver_item == 13) display_6_8_string(18, 5, "*");
else if(ver_item == 14) display_6_8_string(53, 5, "*");
else if(ver_item == 15) display_6_8_string(88, 5, "*");
if(ver_item == 16) display_6_8_string(18, 6, "*");
else if(ver_item == 17) display_6_8_string(53, 6, "*");
else if(ver_item == 18) display_6_8_string(88, 6, "*");
if(ver_item == 19) display_6_8_string(18, 7, "*");
else if(ver_item == 20) display_6_8_string(53, 7, "*");
else if(ver_item == 21) display_6_8_string(88, 7, "*");
//通过3D按键来实现换行选中待修改参数
if(_button.state[UP_3D].press == SHORT_PRESS)
{
_button.state[UP_3D].press = NO_PRESS;
ver_item--;
if(ver_item < 1) ver_item = 21;
Bling_Set(&Light_Blue, 500, 50, 0.5, 0, BLING_B_PORT, GPIO_RGB_BLUE_PIN, 0); //蓝色
}
if(_button.state[DN_3D].press == SHORT_PRESS)
{
_button.state[DN_3D].press = NO_PRESS;
ver_item++;
if(ver_item > 21) ver_item = 1;
Bling_Set(&Light_Blue, 500, 50, 0.5, 0, BLING_B_PORT, GPIO_RGB_BLUE_PIN, 0); //蓝色
}
//通过左按键短按可以实现选中的参数行自减小1调整
if(_button.state[LT_3D].press == SHORT_PRESS)
{
_button.state[LT_3D].press = NO_PRESS;
param_value[base_item + ver_item - 1] -= 1;
}
//通过右按键短按可以实现选中的参数行自增加1调整
if(_button.state[RT_3D].press == SHORT_PRESS)
{
_button.state[RT_3D].press = NO_PRESS;
param_value[base_item + ver_item - 1] += 1;
}
//通过左按键短按可以实现选中的参数行自减小50调整
if(_button.state[LT_3D].press == LONG_PRESS)
{
_button.state[LT_3D].press = NO_PRESS;
param_value[base_item + ver_item - 1] -= 50;
}
//通过右按键短按可以实现选中的参数行自增加50调整
if(_button.state[RT_3D].press == LONG_PRESS)
{
_button.state[RT_3D].press = NO_PRESS;
param_value[base_item + ver_item - 1] += 50;
}
//通过中间按键长按可以实现此页设置的所有参数保存
if(_button.state[ME_3D].press == LONG_PRESS)
{
_button.state[ME_3D].press = NO_PRESS;
//按下后对参数进行保存
for(uint16_t i = 0; i < 21; i++)
{
WriteFlashParameter(RESERVED_PARAM + base_item + i, param_value[base_item + i]);
}
}
}
break;
default://空白页面提示,提醒用户保持镇定
{
LCD_clear_L(0, 0);
display_6_8_string(0, 0, "Reserved Show Page:");
write_6_8_number(115, 0, Page_Number + 1);
LCD_clear_L(0, 2);
display_6_8_string(0, 2, " Don't Worry ");
LCD_clear_L(0, 4);
display_6_8_string(0, 4, " Continue Press To");
LCD_clear_L(0, 6);
display_6_8_string(0, 6, " Page Up/Down");
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化