This commit is contained in:
@@ -12,11 +12,13 @@ void by_pwm_init(void)
|
||||
|
||||
void by_pwm_update_duty(uint32_t update_pwm_duty)
|
||||
{
|
||||
if (7000UL > update_pwm_duty) {
|
||||
update_pwm_duty = 7000UL;
|
||||
if (4000UL < update_pwm_duty) {
|
||||
update_pwm_duty = 4000UL;
|
||||
}
|
||||
pwm_set_duty(TIM4_PWM_MAP1_CH1_D12, update_pwm_duty);
|
||||
pwm_set_duty(TIM4_PWM_MAP1_CH2_D13, update_pwm_duty);
|
||||
// pwm_set_duty(TIM4_PWM_MAP1_CH3_D14, update_pwm_duty);
|
||||
// pwm_set_duty(TIM4_PWM_MAP1_CH4_D15, update_pwm_duty);
|
||||
}
|
||||
|
||||
void by_pwm_power_duty(uint32_t power_pwm_duty_l, uint32_t power_pwm_duty_r)
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
#ifndef _BY_PT_BUTTON_H__
|
||||
#define _BY_PT_BUTTON_H__
|
||||
|
||||
#include "stdio.h"
|
||||
#include "ch32v30x.h"
|
||||
#define POTATE_BUTTOM_PRESS 1
|
||||
#define POTATE_BUTTOM_FOREWARD 2
|
||||
#define POTATE_BUTTOM_BACKWARD 3
|
||||
extern uint8_t potate_button;
|
||||
|
||||
|
||||
extern void by_exit_init(void);
|
||||
extern void by_gpio_init(void);
|
||||
extern uint8_t by_get_statu(void);
|
||||
extern void by_ips_show(void);
|
||||
|
||||
#endif
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "by_pt_button.h"
|
||||
#include "by_rt_button.h"
|
||||
#include "zf_common_headfile.h"
|
||||
#include "by_imu.h"
|
||||
uint8_t potate_button;
|
||||
uint8_t rotate_button;
|
||||
|
||||
void by_gpio_init(void)
|
||||
{
|
||||
@@ -11,21 +11,26 @@ void by_gpio_init(void)
|
||||
void by_exit_init(void)
|
||||
{
|
||||
exti_init(E9, EXTI_TRIGGER_FALLING);
|
||||
exti_init(E11, EXTI_TRIGGER_FALLING);
|
||||
exti_init(E11, EXTI_TRIGGER_BOTH);
|
||||
}
|
||||
|
||||
uint8_t by_get_pb_statu(void)
|
||||
/**
|
||||
* @brief 查询旋钮状态 - 查询后状态归零
|
||||
*
|
||||
* @return uint8_t 当前旋钮状态
|
||||
*/
|
||||
uint8_t by_get_rb_status(void)
|
||||
{
|
||||
uint8_t temp_s = potate_button;
|
||||
potate_button = 0;
|
||||
uint8_t temp_s = rotate_button;
|
||||
rotate_button = 0;
|
||||
return temp_s;
|
||||
}
|
||||
|
||||
void by_ips_show(void)
|
||||
{
|
||||
ips200_show_string(0, 0, "button statu:");
|
||||
// ips200_show_uint(104, 0, by_get_pb_statu(), 1);
|
||||
switch (by_get_pb_statu()) {
|
||||
ips200_show_string(0, 0, "button status:");
|
||||
// ips200_show_uint(104, 0, by_get_rb_status(), 1);
|
||||
switch (by_get_rb_status()) {
|
||||
case 1:
|
||||
ips200_show_string(104, 0, "press");
|
||||
break;
|
||||
@@ -45,7 +50,7 @@ void by_ips_show(void)
|
||||
ips200_show_float(46, 32, eulerAngle.pitch, 3, 2);
|
||||
ips200_show_float(46, 48, eulerAngle.roll, 3, 2);
|
||||
ips200_show_float(46, 64, eulerAngle.yaw, 3, 2);
|
||||
// ips200_show_float(46 , 32, icm_data.gyro_x, 2, 2);
|
||||
// ips200_show_float(46 , 32, icm_data.gyro_x, 2, 2);
|
||||
// ips200_show_float(106, 32, icm_data.gyro_y, 2, 2);
|
||||
// ips200_show_float(166, 32, icm_data.gyro_z, 2, 2);
|
||||
ips200_show_float(46, 80, imu660ra_temperature, 2, 2);
|
||||
24
app/by_rt_button.h
Normal file
24
app/by_rt_button.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef _BY_RT_BUTTON_H__
|
||||
#define _BY_RT_BUTTON_H__
|
||||
|
||||
#include "stdio.h"
|
||||
#include "ch32v30x.h"
|
||||
|
||||
#define LONG_PRESS_THRESHOLD_MS (300ULL)
|
||||
#define LONG_PRESS_THRESHOLD_TICK (LONG_PRESS_THRESHOLD_MS * 18000ULL)
|
||||
|
||||
typedef enum rotate_button_event {
|
||||
rotate_button_press_short = 1,
|
||||
rotate_button_press_long = 2,
|
||||
rotate_button_forward = 3,
|
||||
rotate_button_backward = 4,
|
||||
} rotate_button_event;
|
||||
|
||||
extern uint8_t rotate_button;
|
||||
|
||||
extern void by_exit_init(void);
|
||||
extern void by_gpio_init(void);
|
||||
extern uint8_t by_get_rb_status(void);
|
||||
extern void by_ips_show(void);
|
||||
|
||||
#endif
|
||||
@@ -1,17 +0,0 @@
|
||||
#include "zf_common_headfile.h"
|
||||
#include "cw_servo.h"
|
||||
|
||||
void cw_servo_init(void)
|
||||
{
|
||||
pwm_init(SERVO_L_PWM_CHANNEL, 50, 1000);
|
||||
pwm_init(SERVO_R_PWM_CHANNEL, 50, 1000);
|
||||
}
|
||||
|
||||
void cw_servo_set_angle(float servo_l_angle, float servo_r_angle)
|
||||
{
|
||||
uint32_t servo_l_duty_s = (uint32_t)(servo_l_angle * SERVO_L_DUTY_PER_ANGLE);
|
||||
uint32_t servo_r_duty_s = (uint32_t)(servo_r_angle * SERVO_R_DUTY_PER_ANGLE);
|
||||
|
||||
pwm_set_duty(SERVO_L_PWM_CHANNEL, servo_l_duty_s);
|
||||
pwm_set_duty(SERVO_R_PWM_CHANNEL, servo_r_duty_s);
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
#ifndef _CW_SERVO_H__
|
||||
#define _CW_SERVO_H__
|
||||
|
||||
#include "zf_common_headfile.h"
|
||||
|
||||
#define SERVO_L_PWM_CHANNEL TIM2_PWM_MAP0_CH1_A0
|
||||
#define SERVO_R_PWM_CHANNEL TIM2_PWM_MAP0_CH2_A1
|
||||
|
||||
#define SERVO_MAX_ANGLE_RANGE (90.0F)
|
||||
#define SERVO_L_DUTY_MAX (1100.0F)
|
||||
#define SERVO_L_DUTY_MIN (900.0F)
|
||||
#define SERVO_R_DUTY_MAX (1100.0F)
|
||||
#define SERVO_R_DUTY_MIN (900.0F)
|
||||
#define SERVO_L_DUTY_PER_ANGLE ((SERVO_L_DUTY_MAX - SERVO_L_DUTY_MIN) / SERVO_MAX_ANGLE_RANGE)
|
||||
#define SERVO_R_DUTY_PER_ANGLE ((SERVO_R_DUTY_MAX - SERVO_R_DUTY_MIN) / SERVO_MAX_ANGLE_RANGE)
|
||||
|
||||
extern void cw_servo_init(void);
|
||||
extern void cw_servo_set_angle(float servo_l_angle, float servo_r_angle);
|
||||
|
||||
#endif
|
||||
@@ -1,32 +1,28 @@
|
||||
#ifndef COMMON_H_
|
||||
#define COMMON_H_
|
||||
|
||||
|
||||
|
||||
#define IMAGE_H (MT9V03X_H)
|
||||
#define IMAGE_W (MT9V03X_W)
|
||||
#define BEGINH_L (80)
|
||||
#define BEGINH_R (80)
|
||||
#define BEGINW_L (-18)
|
||||
#define BEGINW_R (-12)
|
||||
#define PT_MAXLEN (75)
|
||||
#define GET_PIX_1C(IMG, H, W) (IMG[(H) * MT9V03X_W + (W)]) //获取像素点的值
|
||||
#define FIX_BINTHRESHOLD (140) //设置最开始的阈值
|
||||
#define SELFADAPT_KERNELSIZE (7) //巡线区域核大小
|
||||
#define FILTER_KERNELSIZE (7) //滤波核大小
|
||||
#define SELFADAPT_OFFSET (8) //适应性块大小
|
||||
#define PIXPERMETER (56)
|
||||
#define RESAMPLEDIST (0.02)
|
||||
#define ANGLEDIST (0.2)
|
||||
#define ROADWIDTH (0.45)
|
||||
#define FRAMENONE (1)
|
||||
#define FRAMETOLEFT (5)
|
||||
#define FRAMETORIGHT (5)
|
||||
#define IMAGE_H (MT9V03X_H)
|
||||
#define IMAGE_W (MT9V03X_W)
|
||||
#define BEGINH_L (61)
|
||||
#define BEGINH_R (61)
|
||||
#define BEGINW_L (-18)
|
||||
#define BEGINW_R (-12)
|
||||
#define PT_MAXLEN (75)
|
||||
#define GET_PIX_1C(IMG, H, W) (IMG[(H) * MT9V03X_W + (W)]) // 获取像素点的值
|
||||
#define FIX_BINTHRESHOLD (140) // 设置最开始的阈值
|
||||
#define SELFADAPT_KERNELSIZE (7) // 巡线区域核大小
|
||||
#define FILTER_KERNELSIZE (7) // 滤波核大小
|
||||
#define SELFADAPT_OFFSET (8) // 适应性块大小
|
||||
#define PIXPERMETER (56)
|
||||
#define RESAMPLEDIST (0.02f)
|
||||
#define ANGLEDIST (0.2f)
|
||||
#define ROADWIDTH (0.45f)
|
||||
#define FRAMENONE (1)
|
||||
#define FRAMETOLEFT (5)
|
||||
#define FRAMETORIGHT (5)
|
||||
|
||||
int32_t limit(int32_t x, int32_t low, int32_t up);
|
||||
int clip(int x, int low, int up);
|
||||
float fclip(float x, float low, float up) ;
|
||||
|
||||
|
||||
float fclip(float x, float low, float up);
|
||||
|
||||
#endif /* COMMON_H_ */
|
||||
62
app/gl_data.c
Normal file
62
app/gl_data.c
Normal file
@@ -0,0 +1,62 @@
|
||||
#include "gl_data.h"
|
||||
|
||||
uint8_t (*Img_Gray)[MT9V03X_W];
|
||||
int32_t pts_left[PT_MAXLEN][2];
|
||||
int32_t pts_right[PT_MAXLEN][2];
|
||||
int32_t pts_left_count;
|
||||
int32_t pts_right_count;
|
||||
float pts_inv_l[PT_MAXLEN][2];
|
||||
float pts_inv_r[PT_MAXLEN][2];
|
||||
int32_t pts_inv_l_count;
|
||||
int32_t pts_inv_r_count;
|
||||
float pts_filter_l[PT_MAXLEN][2];
|
||||
float pts_filter_r[PT_MAXLEN][2];
|
||||
int32_t pts_filter_l_count;
|
||||
int32_t pts_filter_r_count;
|
||||
float pts_resample_left[PT_MAXLEN][2];
|
||||
float pts_resample_right[PT_MAXLEN][2];
|
||||
int32_t pts_resample_left_count;
|
||||
int32_t pts_resample_right_count;
|
||||
|
||||
float mid_left[PT_MAXLEN][2];
|
||||
float mid_right[PT_MAXLEN][2];
|
||||
|
||||
int32_t mid_left_count;
|
||||
int32_t mid_right_count;
|
||||
|
||||
float angle_new_left[PT_MAXLEN];
|
||||
float angle_new_right[PT_MAXLEN];
|
||||
int angle_new_left_num;
|
||||
int angle_new_right_num;
|
||||
uint8_t mt9v03x_image_copy[MT9V03X_H][MT9V03X_W];
|
||||
|
||||
float angle_left[PT_MAXLEN];
|
||||
float angle_right[PT_MAXLEN];
|
||||
int angle_left_num;
|
||||
int angle_right_num;
|
||||
|
||||
int Lpt0_rpts0s_id;
|
||||
int Lpt1_rpts1s_id;
|
||||
bool Lpt0_found;
|
||||
bool Lpt1_found;
|
||||
int Lpt1[2];
|
||||
int Lpt0[2];
|
||||
|
||||
int Lpt_in0_rpts0s_id;
|
||||
int Lpt_in1_rpts1s_id;
|
||||
bool Lpt_in0_found;
|
||||
bool Lpt_in1_found;
|
||||
int Lpt_in1[2];
|
||||
int Lpt_in0[2];
|
||||
|
||||
bool is_straight0;
|
||||
bool is_straight1;
|
||||
|
||||
bool is_turn0;
|
||||
bool is_turn1;
|
||||
|
||||
float rptsn[PT_MAXLEN][2];
|
||||
int32_t rptsn_num;
|
||||
float aim_distance;
|
||||
|
||||
track_type_e track_type = TRACK_RIGHT;
|
||||
74
app/gl_data.h
Normal file
74
app/gl_data.h
Normal file
@@ -0,0 +1,74 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef _GL_DATA_H
|
||||
#define _GL_DATA_H
|
||||
|
||||
#include "gl_headfile.h"
|
||||
|
||||
typedef enum track_type_e {
|
||||
TRACK_LEFT = 0,
|
||||
TRACK_RIGHT,
|
||||
} track_type_e;
|
||||
|
||||
extern uint8_t (*Img_Gray)[MT9V03X_W];
|
||||
extern int32_t pts_left[PT_MAXLEN][2];
|
||||
extern int32_t pts_right[PT_MAXLEN][2];
|
||||
extern int32_t pts_left_count;
|
||||
extern int32_t pts_right_count;
|
||||
extern float pts_inv_l[PT_MAXLEN][2];
|
||||
extern float pts_inv_r[PT_MAXLEN][2];
|
||||
extern int32_t pts_inv_l_count;
|
||||
extern int32_t pts_inv_r_count;
|
||||
extern float pts_filter_l[PT_MAXLEN][2];
|
||||
extern float pts_filter_r[PT_MAXLEN][2];
|
||||
extern int32_t pts_filter_l_count;
|
||||
extern int32_t pts_filter_r_count;
|
||||
extern float pts_resample_left[PT_MAXLEN][2];
|
||||
extern float pts_resample_right[PT_MAXLEN][2];
|
||||
extern int32_t pts_resample_left_count;
|
||||
extern int32_t pts_resample_right_count;
|
||||
|
||||
extern float mid_left[PT_MAXLEN][2];
|
||||
extern float mid_right[PT_MAXLEN][2];
|
||||
|
||||
extern int32_t mid_left_count;
|
||||
extern int32_t mid_right_count;
|
||||
|
||||
extern float angle_new_left[PT_MAXLEN];
|
||||
extern float angle_new_right[PT_MAXLEN];
|
||||
extern int angle_new_left_num;
|
||||
extern int angle_new_right_num;
|
||||
extern uint8_t mt9v03x_image_copy[MT9V03X_H][MT9V03X_W];
|
||||
|
||||
extern float angle_left[PT_MAXLEN];
|
||||
extern float angle_right[PT_MAXLEN];
|
||||
extern int angle_left_num;
|
||||
extern int angle_right_num;
|
||||
|
||||
extern int Lpt0_rpts0s_id;
|
||||
extern int Lpt1_rpts1s_id;
|
||||
extern bool Lpt0_found;
|
||||
extern bool Lpt1_found;
|
||||
extern int Lpt1[2];
|
||||
extern int Lpt0[2];
|
||||
|
||||
extern int Lpt_in0_rpts0s_id;
|
||||
extern int Lpt_in1_rpts1s_id;
|
||||
extern bool Lpt_in0_found;
|
||||
extern bool Lpt_in1_found;
|
||||
extern int Lpt_in1[2];
|
||||
extern int Lpt_in0[2];
|
||||
|
||||
extern bool is_straight0;
|
||||
extern bool is_straight1;
|
||||
|
||||
extern bool is_turn0;
|
||||
extern bool is_turn1;
|
||||
|
||||
extern float rptsn[PT_MAXLEN][2];
|
||||
extern int32_t rptsn_num;
|
||||
extern float aim_distance;
|
||||
|
||||
extern track_type_e track_type;
|
||||
|
||||
#endif
|
||||
@@ -1,8 +1,6 @@
|
||||
#ifndef GL_HEADFILE
|
||||
#define GL_HEADFILE
|
||||
|
||||
|
||||
|
||||
#include "gl_state.h"
|
||||
#include "gl_img_process.h"
|
||||
#include "gl_common.h"
|
||||
@@ -14,8 +12,7 @@
|
||||
#include "gl_tracking.h"
|
||||
#include "gl_circle.h"
|
||||
#include "gl_cross.h"
|
||||
#include "gl_data.h"
|
||||
#include "math.h"
|
||||
|
||||
|
||||
|
||||
#endif /* STATE_H_ */
|
||||
@@ -2,21 +2,27 @@
|
||||
#define STATE_H_
|
||||
|
||||
enum state_type_e {
|
||||
COMMON_STATE = 0,
|
||||
CROSS_STATE,HALF_STATE,
|
||||
CIRCLE_IN_STATE,CIRCLE_BEGIN_STATE,
|
||||
CIRCLE_RUNNING_STATE,CIRCLE_OUT_STATE,
|
||||
TURN_STATE,STRAIGHT_STATE,
|
||||
BREAK_STATE,BAR_STATE,
|
||||
RAMP_STATE,GARAGE_OUT_STATE,
|
||||
GARAGE_IN_STATE,GARAGE_STOP_STATE,
|
||||
GARAGE_PASS_STATE,
|
||||
COMMON_STATE = 0,
|
||||
CROSS_STATE,
|
||||
HALF_STATE,
|
||||
CIRCLE_IN_STATE,
|
||||
CIRCLE_BEGIN_STATE,
|
||||
CIRCLE_RUNNING_STATE,
|
||||
CIRCLE_OUT_STATE,
|
||||
TURN_STATE,
|
||||
STRAIGHT_STATE,
|
||||
BREAK_STATE,
|
||||
BAR_STATE,
|
||||
RAMP_STATE,
|
||||
GARAGE_OUT_STATE,
|
||||
GARAGE_IN_STATE,
|
||||
GARAGE_STOP_STATE,
|
||||
GARAGE_PASS_STATE,
|
||||
};
|
||||
|
||||
extern enum state_type_e state_type;
|
||||
|
||||
#define CROSS_AIM (0.49)
|
||||
#define COMMON_AIM (0.31)
|
||||
|
||||
#define CROSS_AIM (0.49f)
|
||||
#define COMMON_AIM (0.31f)
|
||||
|
||||
#endif /* STATE_H_ */
|
||||
|
||||
@@ -65,11 +65,11 @@ void MidLineTrack() {
|
||||
}
|
||||
}
|
||||
|
||||
// 车轮对应点(纯跟踪起始点)
|
||||
// 车轮对应点 (纯跟踪起始点)
|
||||
float cx = UndistInverseMapW[(int) (IMAGE_H * 0.90f)][78];
|
||||
float cy = UndistInverseMapH[(int) (IMAGE_H * 0.90f)][78];
|
||||
|
||||
// 找最近点(起始点中线归一化)
|
||||
// 找最近点 (起始点中线归一化)
|
||||
float min_dist = 1e10;
|
||||
|
||||
int begin_id = -1;
|
||||
|
||||
80
app/isr.c
80
app/isr.c
@@ -2,11 +2,11 @@
|
||||
* CH32V307VCT6 Opensourec Library <20><><EFBFBD><EFBFBD>CH32V307VCT6 <20><>Դ<EFBFBD>⣩<EFBFBD><E2A3A9>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ڹٷ<DAB9> SDK <20>ӿڵĵ<DAB5><C4B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4>
|
||||
* Copyright (c) 2022 SEEKFREE <20><><EFBFBD>ɿƼ<C9BF>
|
||||
*
|
||||
* <20><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>CH32V307VCT6 <20><>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>
|
||||
* <20><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD> CH32V307VCT6 <20><>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>
|
||||
*
|
||||
* CH32V307VCT6 <20><>Դ<EFBFBD><D4B4> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD>Ը<EFBFBD><D4B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ᷢ<EFBFBD><E1B7A2><EFBFBD><EFBFBD> GPL<50><4C>GNU General Public License<73><65><EFBFBD><EFBFBD> GNUͨ<55>ù<EFBFBD><C3B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><D6A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <20><> GPL <20>ĵ<EFBFBD>3<EFBFBD>棨<EFBFBD><EFBFBD> GPL3.0<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD>κκ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>İ汾<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><DEB8><EFBFBD>
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD>Ը<EFBFBD><D4B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ᷢ<EFBFBD><E1B7A2><EFBFBD><EFBFBD> GPL<50><4C>GNU General Public License<73><65><EFBFBD><EFBFBD> GNU ͨ<EFBFBD>ù<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <20><> GPL <20>ĵ<EFBFBD> 3 <EFBFBD>棨<EFBFBD><EFBFBD> GPL3.0<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD>κκ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>İ汾<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><DEB8><EFBFBD>
|
||||
*
|
||||
* <20><><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD><CFA3><EFBFBD><EFBFBD><EFBFBD>ܷ<EFBFBD><DCB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>κεı<CEB5>֤
|
||||
* <20><><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ի<EFBFBD><D4BB>ʺ<EFBFBD><CABA>ض<EFBFBD><D8B6><EFBFBD>;<EFBFBD>ı<EFBFBD>֤
|
||||
@@ -30,11 +30,12 @@
|
||||
*
|
||||
* <20>ļ<DEB8>¼
|
||||
* <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><>ע
|
||||
* 2022-09-15 <20><>W first version
|
||||
* 2022-09-15 <20><> W first version
|
||||
********************************************************************************************************************/
|
||||
|
||||
#include "zf_common_headfile.h"
|
||||
#include "by_pt_button.h"
|
||||
#include "by_rt_button.h"
|
||||
#include "by_imu.h"
|
||||
|
||||
void NMI_Handler(void) __attribute__((interrupt()));
|
||||
void HardFault_Handler(void) __attribute__((interrupt()));
|
||||
@@ -197,10 +198,10 @@ void EXTI9_5_IRQHandler(void)
|
||||
if (SET == EXTI_GetITStatus(EXTI_Line9)) {
|
||||
|
||||
if (SET == gpio_get_level(E10)) {
|
||||
potate_button = POTATE_BUTTOM_BACKWARD;
|
||||
rotate_button = rotate_button_backward;
|
||||
|
||||
} else {
|
||||
potate_button = POTATE_BUTTOM_FOREWARD;
|
||||
rotate_button = rotate_button_forward;
|
||||
}
|
||||
EXTI_ClearITPendingBit(EXTI_Line9);
|
||||
}
|
||||
@@ -217,37 +218,46 @@ void EXTI15_10_IRQHandler(void)
|
||||
EXTI_ClearITPendingBit(EXTI_Line10);
|
||||
}
|
||||
if (SET == EXTI_GetITStatus(EXTI_Line11)) {
|
||||
|
||||
system_delay_us(200);
|
||||
if (SET == !gpio_get_level(E11)) {
|
||||
potate_button = POTATE_BUTTOM_PRESS;
|
||||
static uint64_t time_via = 0;
|
||||
system_delay_ms(10);
|
||||
if (RESET == gpio_get_level(E11)) {
|
||||
time_via = system_get_tick();
|
||||
EXTI_ClearITPendingBit(EXTI_Line11);
|
||||
} else if (SET == gpio_get_level(E11)) {
|
||||
time_via = system_get_tick() - time_via;
|
||||
if (time_via > LONG_PRESS_THRESHOLD_TICK) {
|
||||
rotate_button = rotate_button_press_long;
|
||||
} else {
|
||||
rotate_button = rotate_button_press_short;
|
||||
}
|
||||
time_via = 0;
|
||||
EXTI_ClearITPendingBit(EXTI_Line11);
|
||||
}
|
||||
EXTI_ClearITPendingBit(EXTI_Line11);
|
||||
}
|
||||
if (SET == EXTI_GetITStatus(EXTI_Line12)) {
|
||||
EXTI_ClearITPendingBit(EXTI_Line12);
|
||||
}
|
||||
if (SET == EXTI_GetITStatus(EXTI_Line13)) {
|
||||
// -----------------* ToF INT <20><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD> Ԥ<><D4A4><EFBFBD>жϴ<D0B6><CFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> *-----------------
|
||||
tof_module_exti_handler();
|
||||
// -----------------* ToF INT <20><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD> Ԥ<><D4A4><EFBFBD>жϴ<D0B6><CFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> *-----------------
|
||||
// <20>˴<EFBFBD><CBB4><EFBFBD>д<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD> (A13/B13..E13) <20><><EFBFBD>Ŵ<EFBFBD><C5B4><EFBFBD>
|
||||
if (SET == EXTI_GetITStatus(EXTI_Line12)) {
|
||||
EXTI_ClearITPendingBit(EXTI_Line12);
|
||||
}
|
||||
if (SET == EXTI_GetITStatus(EXTI_Line13)) {
|
||||
// -----------------* ToF INT <20><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD> Ԥ<><D4A4><EFBFBD>жϴ<D0B6><CFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> *-----------------
|
||||
tof_module_exti_handler();
|
||||
// -----------------* ToF INT <20><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD> Ԥ<><D4A4><EFBFBD>жϴ<D0B6><CFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> *-----------------
|
||||
// <20>˴<EFBFBD><CBB4><EFBFBD>д<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD> (A13/B13..E13) <20><><EFBFBD>Ŵ<EFBFBD><C5B4><EFBFBD>
|
||||
|
||||
// <20>˴<EFBFBD><CBB4><EFBFBD>д<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD> (A13/B13..E13) <20><><EFBFBD>Ŵ<EFBFBD><C5B4><EFBFBD>
|
||||
// <20>˴<EFBFBD><CBB4><EFBFBD>д<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD> (A13/B13..E13) <20><><EFBFBD>Ŵ<EFBFBD><C5B4><EFBFBD>
|
||||
|
||||
EXTI_ClearITPendingBit(EXTI_Line13);
|
||||
}
|
||||
if (SET == EXTI_GetITStatus(EXTI_Line14)) {
|
||||
// -----------------* DM1XA <20><><EFBFBD>ź<EFBFBD> Ԥ<><D4A4><EFBFBD>жϴ<D0B6><CFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> *-----------------
|
||||
dm1xa_light_callback();
|
||||
// -----------------* DM1XA <20><><EFBFBD>ź<EFBFBD> Ԥ<><D4A4><EFBFBD>жϴ<D0B6><CFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> *-----------------
|
||||
EXTI_ClearITPendingBit(EXTI_Line14);
|
||||
}
|
||||
if (SET == EXTI_GetITStatus(EXTI_Line15)) {
|
||||
// -----------------* DM1XA <20><>/<2F><><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD> Ԥ<><D4A4><EFBFBD>жϴ<D0B6><CFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> *-----------------
|
||||
dm1xa_sound_callback();
|
||||
// -----------------* DM1XA <20><>/<2F><><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD> Ԥ<><D4A4><EFBFBD>жϴ<D0B6><CFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> *-----------------
|
||||
EXTI_ClearITPendingBit(EXTI_Line15);
|
||||
EXTI_ClearITPendingBit(EXTI_Line13);
|
||||
}
|
||||
if (SET == EXTI_GetITStatus(EXTI_Line14)) {
|
||||
// -----------------* DM1XA <20><><EFBFBD>ź<EFBFBD> Ԥ<><D4A4><EFBFBD>жϴ<D0B6><CFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> *-----------------
|
||||
dm1xa_light_callback();
|
||||
// -----------------* DM1XA <20><><EFBFBD>ź<EFBFBD> Ԥ<><D4A4><EFBFBD>жϴ<D0B6><CFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> *-----------------
|
||||
EXTI_ClearITPendingBit(EXTI_Line14);
|
||||
}
|
||||
if (SET == EXTI_GetITStatus(EXTI_Line15)) {
|
||||
// -----------------* DM1XA <20><>/<2F><><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD> Ԥ<><D4A4><EFBFBD>жϴ<D0B6><CFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> *-----------------
|
||||
dm1xa_sound_callback();
|
||||
// -----------------* DM1XA <20><>/<2F><><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD> Ԥ<><D4A4><EFBFBD>жϴ<D0B6><CFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> *-----------------
|
||||
EXTI_ClearITPendingBit(EXTI_Line15);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
124
app/main.c
124
app/main.c
@@ -1,105 +1,42 @@
|
||||
/*********************************************************************************************************************
|
||||
* CH32V307VCT6 Opensourec Library ????CH32V307VCT6 ???????????????? SDK ??????????????
|
||||
* Copyright (c) 2022 SEEKFREE ?????
|
||||
* CH32V307VCT6 Opensourec Library 即(CH32V307VCT6 开源库)是一个基于官方 SDK 接口的第三方开源库
|
||||
* Copyright (c) 2022 SEEKFREE 逐飞科技
|
||||
*
|
||||
* ??????? CH32V307VCT6 ???????????
|
||||
* 本文件是 CH32V307VCT6 开源库的一部分
|
||||
*
|
||||
* CH32V307VCT6 ????? ?????????
|
||||
* ?????????????????????????? GPL??GNU General Public License???? GNU ??锟斤拷????????????????
|
||||
* ?? GPL ??? 3 ?锟斤拷?? GPL3.0????????????锟绞︼拷?????锟斤拷?????锟斤拷?????/???????
|
||||
* CH32V307VCT6 开源库 是免费软件
|
||||
* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU 通用公共许可证)的条款
|
||||
* 即 GPL 的第 3 版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
|
||||
*
|
||||
* ????????????????????????????????锟斤拷???????锟绞︼拷???
|
||||
* ?????????????????????????????????
|
||||
* ?????????锟斤拷?GPL
|
||||
* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
|
||||
* 甚至没有隐含的适销性或适合特定用途的保证
|
||||
* 更多细节请参见 GPL
|
||||
*
|
||||
* ?????????????????????????? GPL ?????
|
||||
* ?????锟斤拷??????<https://www.gnu.org/licenses/>
|
||||
* 您应该在收到本开源库的同时收到一份 GPL 的副本
|
||||
* 如果没有,请参阅<https://www.gnu.org/licenses/>
|
||||
*
|
||||
* ?????????
|
||||
* ?????????? GPL3.0 ????????锟斤拷?? ?????????????????锟斤拷
|
||||
* ?????????????? libraries/doc ???????? GPL3_permission_statement.txt ?????
|
||||
* ??????????? libraries ??????? ???????????? LICENSE ???
|
||||
* ?????锟斤拷??锟斤拷??????????? ?????????????????????????????????????????
|
||||
*
|
||||
* ??????? main
|
||||
* ??????? ??????????????
|
||||
* ?锟斤拷??? ?? libraries/doc ??????? version ??? ?锟斤拷???
|
||||
* ???????? MounRiver Studio V1.8.1
|
||||
* ?????? CH32V307VCT6
|
||||
* ???????? https://seekfree.taobao.com/
|
||||
*
|
||||
* ?????
|
||||
* ???? ???? ???
|
||||
* 2022-09-15 ?? W first version
|
||||
* 额外注明:
|
||||
* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
|
||||
* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
|
||||
* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
|
||||
* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
|
||||
********************************************************************************************************************/
|
||||
#include "zf_common_headfile.h"
|
||||
#include "gl_headfile.h"
|
||||
#include "by_pt_button.h"
|
||||
#include "by_rt_button.h"
|
||||
#include "by_fan_control.h"
|
||||
#include "cw_servo.h"
|
||||
#include "./page/cw_page.h"
|
||||
|
||||
uint8_t (*Img_Gray)[MT9V03X_W];
|
||||
int32_t pts_left[PT_MAXLEN][2];
|
||||
int32_t pts_right[PT_MAXLEN][2];
|
||||
int32_t pts_left_count, pts_right_count;
|
||||
float pts_inv_l[PT_MAXLEN][2], pts_inv_r[PT_MAXLEN][2];
|
||||
int32_t pts_inv_l_count, pts_inv_r_count;
|
||||
float pts_filter_l[PT_MAXLEN][2], pts_filter_r[PT_MAXLEN][2];
|
||||
int32_t pts_filter_l_count, pts_filter_r_count;
|
||||
float pts_resample_left[PT_MAXLEN][2], pts_resample_right[PT_MAXLEN][2];
|
||||
int32_t pts_resample_left_count, pts_resample_right_count;
|
||||
float mid_left[PT_MAXLEN][2], mid_right[PT_MAXLEN][2];
|
||||
int32_t mid_left_count, mid_right_count;
|
||||
|
||||
float angle_new_left[PT_MAXLEN];
|
||||
float angle_new_right[PT_MAXLEN];
|
||||
int angle_new_left_num, angle_new_right_num;
|
||||
uint8_t mt9v03x_image_copy[MT9V03X_H][MT9V03X_W];
|
||||
|
||||
float angle_left[PT_MAXLEN];
|
||||
float angle_right[PT_MAXLEN];
|
||||
int angle_left_num, angle_right_num;
|
||||
|
||||
int Lpt0_rpts0s_id, Lpt1_rpts1s_id;
|
||||
bool Lpt0_found, Lpt1_found;
|
||||
int Lpt1[2], Lpt0[2];
|
||||
|
||||
int Lpt_in0_rpts0s_id, Lpt_in1_rpts1s_id;
|
||||
bool Lpt_in0_found, Lpt_in1_found;
|
||||
int Lpt_in1[2], Lpt_in0[2];
|
||||
|
||||
bool is_straight0, is_straight1;
|
||||
|
||||
bool is_turn0, is_turn1;
|
||||
|
||||
float rptsn[PT_MAXLEN][2];
|
||||
int rptsn_num;
|
||||
float aim_distance;
|
||||
|
||||
enum track_type_e track_type = TRACK_RIGHT;
|
||||
|
||||
int frame_count = 0;
|
||||
|
||||
void img_processing();
|
||||
void get_corners();
|
||||
void adaptiveThreshold(uint8_t* img_data, uint8_t* output_data, int width, int height, int block, uint8_t clip_value);
|
||||
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
clock_init(SYSTEM_CLOCK_120M); // 初始化芯片时钟 工作频率为 120MHz
|
||||
debug_init(); // 务必保留,本函数用于初始化 MPU 时钟 调试串口
|
||||
//mt9v03x_init();
|
||||
// system_delay_ms(2000);
|
||||
ips200_init(IPS200_TYPE_SPI);
|
||||
clock_init(SYSTEM_CLOCK_120M);
|
||||
system_delay_init();
|
||||
debug_init();
|
||||
mt9v03x_init();
|
||||
// by_gpio_init();
|
||||
// by_exit_init();
|
||||
// by_pwm_init();
|
||||
// cw_servo_init();
|
||||
//printf("hello world\n");
|
||||
ips200_init(IPS200_TYPE_SPI);
|
||||
by_gpio_init();
|
||||
by_exit_init();
|
||||
by_pwm_init();
|
||||
// while (imu660ra_init())
|
||||
// ;
|
||||
|
||||
@@ -108,18 +45,11 @@ int main(void)
|
||||
// pit_ms_init(TIM6_PIT, 2);
|
||||
|
||||
while (1) {
|
||||
// while (frame_count < 20) {
|
||||
// if (mt9v03x_finish_flag) {
|
||||
// memcpy(mt9v03x_image_copy[0], mt9v03x_image[0], (sizeof(mt9v03x_image_copy) / sizeof(uint8_t)));
|
||||
// adaptiveThreshold((uint8_t*)mt9v03x_image_copy, (uint8_t*)mt9v03x_image_copy, 188, 120, 7, 8);
|
||||
// //threshold((uint8_t*)mt9v03x_image_copy, (uint8_t*)mt9v03x_image_copy, MT9V03X_W, MT9V03X_H, 110);
|
||||
// ips200_show_gray_image(0, 0, mt9v03x_image_copy[0], MT9V03X_W, MT9V03X_H, MT9V03X_W, MT9V03X_H, 0);
|
||||
// mt9v03x_finish_flag = 0;
|
||||
// frame_count++;
|
||||
// }
|
||||
|
||||
//}
|
||||
Page_Run();
|
||||
|
||||
if (mt9v03x_finish_flag) {
|
||||
// 该操作消耗大概 1970 个 tick,折合约 110us
|
||||
memcpy(mt9v03x_image_copy[0], mt9v03x_image[0], (sizeof(mt9v03x_image_copy) / sizeof(uint8_t)));
|
||||
adaptiveThreshold((uint8_t*)mt9v03x_image_copy, (uint8_t*)mt9v03x_image_copy, 188, 120, 7, 17);
|
||||
ips200_show_gray_image(0, 0, mt9v03x_image_copy[0], MT9V03X_W, MT9V03X_H, MT9V03X_W, MT9V03X_H, 0);
|
||||
|
||||
45
app/main.h
45
app/main.h
@@ -2,50 +2,5 @@
|
||||
#define MAIN_H
|
||||
|
||||
#include "zf_common_headfile.h"
|
||||
#include "gl_common.h"
|
||||
|
||||
// extern uint8 *mt9v03x_image_copy[0];
|
||||
extern int32_t pts_left[PT_MAXLEN][2], pts_right[PT_MAXLEN][2]; // 0:H,1:W
|
||||
extern int32_t pts_left_count, pts_right_count;
|
||||
extern float pts_inv_l[PT_MAXLEN][2], pts_inv_r[PT_MAXLEN][2];
|
||||
extern int32_t pts_inv_l_count, pts_inv_r_count;
|
||||
extern float pts_filter_l[PT_MAXLEN][2], pts_filter_r[PT_MAXLEN][2];
|
||||
extern int32_t pts_filter_l_count, pts_filter_r_count;
|
||||
extern float pts_resample_left[PT_MAXLEN][2], pts_resample_right[PT_MAXLEN][2];
|
||||
extern int32_t pts_resample_left_count, pts_resample_right_count;
|
||||
extern uint8_t mt9v03x_image_copy[MT9V03X_H][MT9V03X_W];
|
||||
extern float mid_left[PT_MAXLEN][2], mid_right[PT_MAXLEN][2];
|
||||
extern int32_t mid_left_count, mid_right_count;
|
||||
|
||||
extern float angle_left[PT_MAXLEN];
|
||||
extern float angle_right[PT_MAXLEN];
|
||||
extern int angle_left_num, angle_right_num;
|
||||
|
||||
extern float angle_new_left[PT_MAXLEN];
|
||||
extern float angle_new_right[PT_MAXLEN];
|
||||
extern int angle_new_left_num, angle_new_right_num;
|
||||
|
||||
extern int Lpt0_rpts0s_id, Lpt1_rpts1s_id;
|
||||
extern bool Lpt0_found, Lpt1_found;
|
||||
extern int Lpt1[2], Lpt0[2];
|
||||
|
||||
extern int Lpt_in0_rpts0s_id, Lpt_in1_rpts1s_id;
|
||||
extern bool Lpt_in0_found, Lpt_in1_found;
|
||||
extern int Lpt_in1[2], Lpt_in0[2];
|
||||
|
||||
extern bool is_straight0, is_straight1;
|
||||
|
||||
extern bool is_turn0, is_turn1;
|
||||
|
||||
extern float rptsn[PT_MAXLEN][2];
|
||||
extern int rptsn_num;
|
||||
extern float aim_distance;
|
||||
|
||||
enum track_type_e {
|
||||
TRACK_LEFT,
|
||||
TRACK_RIGHT,
|
||||
};
|
||||
|
||||
extern enum track_type_e track_type;
|
||||
|
||||
#endif // MAIN_H
|
||||
@@ -1,9 +1,11 @@
|
||||
#include "cw_page.h"
|
||||
|
||||
#include "by_rt_button.h"
|
||||
|
||||
PAGE_LIST pagelist[page_max];
|
||||
static uint8_t page_busy = 0;
|
||||
static int8_t now_page = page_menu;
|
||||
static int8_t new_page = page_menu;
|
||||
static int8_t now_page = page_menu;
|
||||
static int8_t new_page = page_menu;
|
||||
|
||||
/**
|
||||
* @brief 注册一个基本页面,包含一个初始化函数,循环函数,退出函数,事件函数
|
||||
@@ -16,12 +18,13 @@ static int8_t new_page = page_menu;
|
||||
* @retval 无
|
||||
*/
|
||||
void Page_Register(uint8_t pageID, char *pageText,
|
||||
CallbackFunction_t setupCallback, CallbackFunction_t loopCallback,
|
||||
CallbackFunction_t exitCallback, EventFunction_t eventCallback) {
|
||||
pagelist[pageID].Text = pageText;
|
||||
CallbackFunction_t setupCallback, CallbackFunction_t loopCallback,
|
||||
CallbackFunction_t exitCallback, EventFunction_t eventCallback)
|
||||
{
|
||||
pagelist[pageID].Text = pageText;
|
||||
pagelist[pageID].SetupCallback = setupCallback;
|
||||
pagelist[pageID].LoopCallback = loopCallback;
|
||||
pagelist[pageID].ExitCallback = exitCallback;
|
||||
pagelist[pageID].LoopCallback = loopCallback;
|
||||
pagelist[pageID].ExitCallback = exitCallback;
|
||||
pagelist[pageID].EventCallback = eventCallback;
|
||||
}
|
||||
|
||||
@@ -30,7 +33,8 @@ void Page_Register(uint8_t pageID, char *pageText,
|
||||
* @param event: 事件编号
|
||||
* @retval 无
|
||||
*/
|
||||
void Page_EventTransmit(unsigned char event) {
|
||||
void Page_EventTransmit(unsigned char event)
|
||||
{
|
||||
/*将事件传递到当前页面*/
|
||||
if (pagelist[now_page].EventCallback != 0)
|
||||
pagelist[now_page].EventCallback(event);
|
||||
@@ -41,7 +45,8 @@ void Page_EventTransmit(unsigned char event) {
|
||||
* @param pageID:页面号
|
||||
* @retval 1:成功 0:失败
|
||||
*/
|
||||
void Page_Shift(unsigned char pageID) {
|
||||
void Page_Shift(unsigned char pageID)
|
||||
{
|
||||
if (page_busy == 0) {
|
||||
new_page = pageID;
|
||||
}
|
||||
@@ -51,7 +56,8 @@ void Page_Shift(unsigned char pageID) {
|
||||
* @brief 关闭当前页面
|
||||
*
|
||||
*/
|
||||
void Page_CloseCurrentPage() {
|
||||
void Page_CloseCurrentPage()
|
||||
{
|
||||
pagelist[now_page].ExitCallback();
|
||||
}
|
||||
|
||||
@@ -59,16 +65,18 @@ void Page_CloseCurrentPage() {
|
||||
* @brief 打开当前页面
|
||||
*
|
||||
*/
|
||||
void Page_OpenCurrentPage() {
|
||||
void Page_OpenCurrentPage()
|
||||
{
|
||||
pagelist[now_page].SetupCallback();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 获取页面状态
|
||||
*
|
||||
* @return uint8_t 页面忙返回1 空闲返回0
|
||||
* @return uint8_t 页面忙返回 1 空闲返回 0
|
||||
*/
|
||||
uint8_t Page_GetStatus(void) {
|
||||
uint8_t Page_GetStatus(void)
|
||||
{
|
||||
if (page_busy)
|
||||
return 1;
|
||||
else
|
||||
@@ -79,18 +87,23 @@ uint8_t Page_GetStatus(void) {
|
||||
* @brief 页面运行函数
|
||||
*
|
||||
*/
|
||||
void Page_Run(void) {
|
||||
void Page_Run(void)
|
||||
{
|
||||
uint8_t temp_status = by_get_rb_status(); // 轮询旋钮状态
|
||||
if(temp_status){
|
||||
pagelist[now_page].EventCallback(temp_status);
|
||||
}
|
||||
|
||||
if (now_page != new_page) {
|
||||
if (new_page >= page_max && new_page < page_menu) {
|
||||
new_page = page_menu;
|
||||
}
|
||||
|
||||
//执行当前页面退出回调函数
|
||||
// 执行当前页面退出回调函数
|
||||
if ((pagelist[now_page].ExitCallback != 0)) {
|
||||
pagelist[now_page].ExitCallback();
|
||||
}
|
||||
//执行新页面构造回调函数
|
||||
// 执行新页面构造回调函数
|
||||
if (pagelist[new_page].SetupCallback != 0) {
|
||||
pagelist[new_page].SetupCallback();
|
||||
}
|
||||
@@ -99,7 +112,7 @@ void Page_Run(void) {
|
||||
}
|
||||
|
||||
if (page_busy == 0) {
|
||||
//执行循环函数
|
||||
// 执行循环函数
|
||||
pagelist[now_page].LoopCallback();
|
||||
}
|
||||
}
|
||||
@@ -108,13 +121,15 @@ void Page_Run(void) {
|
||||
* @brief 页面初始化(注册,构建) //ATTENTION 在此处添加新加入的页面
|
||||
*
|
||||
*/
|
||||
void Page_Init(void) {
|
||||
void Page_Init(void)
|
||||
{
|
||||
PAGE_REG(page_menu);
|
||||
PAGE_REG(page_rtcam);
|
||||
// PAGE_REG(page_argv);
|
||||
// PAGE_REG(page_sys);
|
||||
// PAGE_REG(page_run);
|
||||
|
||||
Page_Shift(page_menu);
|
||||
|
||||
pagelist[now_page].SetupCallback(); //先构建一遍
|
||||
pagelist[now_page].SetupCallback(); // 先构建一遍
|
||||
}
|
||||
|
||||
@@ -13,10 +13,13 @@
|
||||
|
||||
#include "zf_common_headfile.h"
|
||||
|
||||
#include "by_rt_button.h"
|
||||
|
||||
enum PageID {
|
||||
PAGE_NULL = -1,
|
||||
//......
|
||||
page_menu,
|
||||
page_rtcam,
|
||||
// page_argv,
|
||||
// page_sys,
|
||||
// page_run,
|
||||
@@ -25,9 +28,10 @@ enum PageID {
|
||||
};
|
||||
|
||||
typedef enum page_event{
|
||||
page_event_forward,
|
||||
page_event_backward,
|
||||
page_event_press
|
||||
page_event_forward = rotate_button_forward,
|
||||
page_event_backward = rotate_button_backward,
|
||||
page_event_press_short = rotate_button_press_short,
|
||||
page_event_press_long = rotate_button_press_long,
|
||||
} page_event;
|
||||
|
||||
typedef void (*CallbackFunction_t)(void);
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
|
||||
static char Text[] = "Menu";
|
||||
|
||||
static int8_t Curser = 1; // 定义光标位置
|
||||
static int8_t Curser_Last = 1; // 定义光标位置
|
||||
static int8_t Curser = LINE_HEAD; // 定义光标位置
|
||||
static int8_t Curser_Last = LINE_HEAD; // 定义光标位置
|
||||
static void Print_Menu_p(void);
|
||||
/***************************************************************************************
|
||||
*
|
||||
@@ -23,7 +23,7 @@ static void Print_Menu_p(void);
|
||||
*/
|
||||
static void Setup()
|
||||
{
|
||||
ips114_clear();
|
||||
ips200_clear();
|
||||
Print_Menu_p();
|
||||
Print_Curser(Curser, Curser_Last);
|
||||
}
|
||||
@@ -44,7 +44,6 @@ static void Exit()
|
||||
*/
|
||||
static void Loop()
|
||||
{
|
||||
Show_Marked_Image();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,7 +60,7 @@ static void Event(page_event event)
|
||||
Curser--; // 光标上移
|
||||
} else if (page_event_backward == event) {
|
||||
Curser++; // 光标下移
|
||||
} else if (page_event_press == event) {
|
||||
} else if (page_event_press_short == event) {
|
||||
if (page_max > Curser && page_menu < Curser) {
|
||||
Page_Shift(Curser); // 切换到光标选中的页面
|
||||
}
|
||||
@@ -101,7 +100,7 @@ static void Print_Menu_p(void)
|
||||
// SCREEN_showstr_style(5 * 8, 0, RED, WHITE, "#### MAIN MENU ####");
|
||||
ips200_show_string(0, 0, Text);
|
||||
for (uint8_t i = page_menu + 1; i < page_max; i++) {
|
||||
ips200_show_string(8, i, pagelist[i].Text);
|
||||
ips200_show_string(10, i * 18, pagelist[i].Text);
|
||||
// SCREEN_showstr(8, i, pagelist[i].Text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,14 +2,13 @@
|
||||
#include "cw_page_ui_widget.h"
|
||||
#include "cw_page.h"
|
||||
|
||||
#define LINE_HEAD 1
|
||||
#define LINE_END 7
|
||||
#define LINE_HEAD 11
|
||||
#define LINE_END 16
|
||||
|
||||
static char Text[] = "RealTime Image";
|
||||
|
||||
static int8_t Curser = 1; // 定义光标位置
|
||||
static int8_t Curser_Last = 1; // 定义光标位置
|
||||
static void Print_Menu_p(void);
|
||||
static int8_t Curser = LINE_HEAD; // 定义光标位置
|
||||
static int8_t Curser_Last = LINE_HEAD; // 定义光标位置
|
||||
/***************************************************************************************
|
||||
*
|
||||
* 以下为页面模板函数
|
||||
@@ -23,8 +22,7 @@ static void Print_Menu_p(void);
|
||||
*/
|
||||
static void Setup()
|
||||
{
|
||||
ips114_clear();
|
||||
Print_Menu_p();
|
||||
ips200_clear();
|
||||
Print_Curser(Curser, Curser_Last);
|
||||
}
|
||||
|
||||
@@ -44,6 +42,7 @@ static void Exit()
|
||||
*/
|
||||
static void Loop()
|
||||
{
|
||||
Show_Marked_Image();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,10 +59,10 @@ static void Event(page_event event)
|
||||
Curser--; // 光标上移
|
||||
} else if (page_event_backward == event) {
|
||||
Curser++; // 光标下移
|
||||
} else if (page_event_press == event) {
|
||||
if (page_max > Curser && page_menu < Curser) {
|
||||
Page_Shift(Curser); // 切换到光标选中的页面
|
||||
}
|
||||
} else if (page_event_press_short == event) {
|
||||
|
||||
} else if (page_event_press_long == event) {
|
||||
Page_Shift(page_menu);
|
||||
}
|
||||
|
||||
if (Curser < LINE_HEAD) {
|
||||
@@ -90,17 +89,3 @@ void PageRegister_page_rtcam(unsigned char pageID)
|
||||
* 以下为页面自定义功能函数
|
||||
*
|
||||
***************************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief 打印菜单项
|
||||
*
|
||||
*/
|
||||
static void Print_Menu_p(void)
|
||||
{
|
||||
// SCREEN_showstr_style(5 * 8, 0, RED, WHITE, "#### MAIN MENU ####");
|
||||
ips200_show_string(0, 0, Text);
|
||||
for (uint8_t i = page_menu + 1; i < page_max; i++) {
|
||||
ips200_show_string(8, i, pagelist[i].Text);
|
||||
// SCREEN_showstr(8, i, pagelist[i].Text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "cw_page_ui_widget.h"
|
||||
#include "zf_common_headfile.h"
|
||||
#include "main.h"
|
||||
#include "gl_data.h"
|
||||
|
||||
/**
|
||||
* @brief 绘制光标
|
||||
@@ -10,8 +10,17 @@
|
||||
*/
|
||||
void Print_Curser(uint8_t Curser_In, uint8_t Curser_Last_In)
|
||||
{
|
||||
ips200_show_string(0, Curser_Last_In * 16, " ");
|
||||
ips200_show_string(0, Curser_In * 16, ">");
|
||||
// ips200_show_string(0, Curser_Last_In * 18, " ");
|
||||
// ips200_show_string(0, Curser_In * 18, ">");
|
||||
|
||||
for (uint8_t i = 0; i < 160; i++) {
|
||||
ips200_draw_point(10 + i, Curser_Last_In * 18 + 19, IPS200_DEFAULT_BGCOLOR);
|
||||
// system_delay_us(200);
|
||||
}
|
||||
for (uint8_t i = 0; i < 160; i++) {
|
||||
ips200_draw_point(10 + i, Curser_In * 18 + 19, RGB565_WHITE);
|
||||
system_delay_ms(1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -20,9 +29,8 @@ void Print_Curser(uint8_t Curser_In, uint8_t Curser_Last_In)
|
||||
*/
|
||||
void Print_Menu(const ITEM *item, uint8_t item_sum)
|
||||
{
|
||||
ips200_show_string(0, 0, " --return--");
|
||||
for (uint8_t i = 0; i < item_sum; i++) {
|
||||
ips200_show_string(8, i * 16 + 16, item[i].text);
|
||||
ips200_show_string(8, i * 18 + 16, item[i].text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,8 +149,10 @@ void Show_Marked_Image(void)
|
||||
|
||||
// 确认边线数组在显示前不会清空
|
||||
for (uint i = 0; i < PT_MAXLEN; i++) {
|
||||
ips200_draw_point(START_X + (uint16_t)(mid_right[i][0] * horizontal_zoom_rate), START_Y + (uint16_t)(mid_right[i][1] * vertical_zoom_rate), RGB565_GREEN);
|
||||
ips200_draw_point(START_X + (uint16_t)(mid_left[i][0] * horizontal_zoom_rate), START_Y + (uint16_t)(mid_left[i][1] * vertical_zoom_rate), RGB565_GREEN);
|
||||
ips200_draw_point(START_X + (uint16_t)((float)pts_right[i][1] * horizontal_zoom_rate), START_Y + (uint16_t)((float)pts_right[i][0] * vertical_zoom_rate), RGB565_GREEN);
|
||||
ips200_draw_point(START_X + (uint16_t)((float)pts_right[i][1] * horizontal_zoom_rate) - 1, START_Y + (uint16_t)((float)pts_right[i][0] * vertical_zoom_rate), RGB565_GREEN);
|
||||
ips200_draw_point(START_X + (uint16_t)((float)pts_left[i][1] * horizontal_zoom_rate), START_Y + (uint16_t)((float)pts_left[i][0] * vertical_zoom_rate), RGB565_YELLOW);
|
||||
ips200_draw_point(START_X + (uint16_t)((float)pts_left[i][1] * horizontal_zoom_rate) + 1, START_Y + (uint16_t)((float)pts_left[i][0] * vertical_zoom_rate), RGB565_YELLOW);
|
||||
}
|
||||
#undef IMAGE_DISPLAY_WIDTH
|
||||
#undef START_X
|
||||
|
||||
Reference in New Issue
Block a user