This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
#include "gl_headfile.h"
|
#include "gl_headfile.h"
|
||||||
|
|
||||||
|
|
||||||
sint32 limit(sint32 x, sint32 low, sint32 up)
|
int32_t limit(int32_t x, int32_t low, int32_t up)
|
||||||
{
|
{
|
||||||
return x > up ? up : x < low ? low : x;
|
return x > up ? up : x < low ? low : x;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,10 +23,7 @@
|
|||||||
#define FRAMETOLEFT (5)
|
#define FRAMETOLEFT (5)
|
||||||
#define FRAMETORIGHT (5)
|
#define FRAMETORIGHT (5)
|
||||||
|
|
||||||
typedef signed int sint32;
|
int32_t limit(int32_t x, int32_t low, int32_t up);
|
||||||
typedef float float32;
|
|
||||||
|
|
||||||
sint32 limit(sint32 x, sint32 low, sint32 up);
|
|
||||||
int clip(int x, int low, int 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) ;
|
||||||
|
|
||||||
|
|||||||
@@ -5,12 +5,12 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
const sint32 direction_front[4][2] = {{0, -1},{1, 0},{0, 1},{-1, 0}};
|
const int32_t direction_front[4][2] = {{0, -1},{1, 0},{0, 1},{-1, 0}};
|
||||||
const sint32 direction_frontleft[4][2] = {{-1, -1},{1, -1},{1, 1},{-1, 1}};
|
const int32_t direction_frontleft[4][2] = {{-1, -1},{1, -1},{1, 1},{-1, 1}};
|
||||||
const sint32 direction_frontright[4][2] ={{1, -1},{1, 1},{-1, 1},{-1, -1}};
|
const int32_t direction_frontright[4][2] ={{1, -1},{1, 1},{-1, 1},{-1, -1}};
|
||||||
|
|
||||||
|
|
||||||
void SearchLineAdaptive_Left(uint8 img_gray[], sint32 block_size, sint32 down_value, sint32 h, sint32 w, sint32 pts[][2], sint32* line_num)
|
void SearchLineAdaptive_Left(uint8_t img_gray[], int32_t block_size, int32_t down_value, int32_t h, int32_t w, int32_t pts[][2], int32_t* line_num)
|
||||||
{
|
{
|
||||||
int half = block_size / 2;
|
int half = block_size / 2;
|
||||||
int step = 0, dir = 0, turn = 0;
|
int step = 0, dir = 0, turn = 0;
|
||||||
@@ -53,7 +53,7 @@ void SearchLineAdaptive_Left(uint8 img_gray[], sint32 block_size, sint32 down_va
|
|||||||
*line_num = step;
|
*line_num = step;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchLineAdaptive_Right(uint8 img_gray[], sint32 block_size, sint32 down_value, sint32 h, sint32 w, sint32 pts[][2], sint32* line_num)
|
void SearchLineAdaptive_Right(uint8_t img_gray[], int32_t block_size, int32_t down_value, int32_t h, int32_t w, int32_t pts[][2], int32_t* line_num)
|
||||||
{
|
{
|
||||||
int half = block_size / 2;
|
int half = block_size / 2;
|
||||||
int step = 0, dir = 0, turn = 0;
|
int step = 0, dir = 0, turn = 0;
|
||||||
@@ -100,7 +100,7 @@ void SearchLineAdaptive_Right(uint8 img_gray[], sint32 block_size, sint32 down_v
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void GetLinesFilter(float32 pts_in[][2], sint32 pts_in_count, float32 pts_out[][2], sint32 kernelsize)
|
void GetLinesFilter(float pts_in[][2], int32_t pts_in_count, float pts_out[][2], int32_t kernelsize)
|
||||||
{
|
{
|
||||||
int half = kernelsize / 2;
|
int half = kernelsize / 2;
|
||||||
for (int i = 0; i < pts_in_count; i++) {
|
for (int i = 0; i < pts_in_count; i++) {
|
||||||
@@ -115,7 +115,7 @@ void GetLinesFilter(float32 pts_in[][2], sint32 pts_in_count, float32 pts_out[][
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetLinesResample(float32 pts_in[][2], sint32 num1, float32 pts_out[][2], sint32* num2, float32 dist)
|
void GetLinesResample(float pts_in[][2], int32_t num1, float pts_out[][2], int32_t* num2, float dist)
|
||||||
{
|
{
|
||||||
if (num1 < 0) {
|
if (num1 < 0) {
|
||||||
*num2 = 0;
|
*num2 = 0;
|
||||||
@@ -192,7 +192,7 @@ void nms_angle(float angle_in[], int num, float angle_out[], int kernel) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetMidLine_Left(float32 pts_left[][2], sint32 pts_left_count, float32 mid_left[][2], sint32 approx_num, float32 dist)
|
void GetMidLine_Left(float pts_left[][2], int32_t pts_left_count, float mid_left[][2], int32_t approx_num, float dist)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < pts_left_count; i++) {
|
for (int i = 0; i < pts_left_count; i++) {
|
||||||
float dx = pts_left[clip(i + approx_num, 0, pts_left_count - 1)][1] - pts_left[clip(i - approx_num, 0, pts_left_count - 1)][1];
|
float dx = pts_left[clip(i + approx_num, 0, pts_left_count - 1)][1] - pts_left[clip(i - approx_num, 0, pts_left_count - 1)][1];
|
||||||
@@ -207,7 +207,7 @@ void GetMidLine_Left(float32 pts_left[][2], sint32 pts_left_count, float32 mid_l
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GetMidLine_Right(float32 pts_right[][2], sint32 pts_right_count, float32 mid_right[][2], sint32 approx_num, float32 dist)
|
void GetMidLine_Right(float pts_right[][2], int32_t pts_right_count, float mid_right[][2], int32_t approx_num, float dist)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < pts_right_count; i++) {
|
for (int i = 0; i < pts_right_count; i++) {
|
||||||
float dx = pts_right[clip(i + approx_num, 0, pts_right_count -1)][1] - pts_right[clip(i - approx_num, 0, pts_right_count -1 )][1];
|
float dx = pts_right[clip(i + approx_num, 0, pts_right_count -1)][1] - pts_right[clip(i - approx_num, 0, pts_right_count -1 )][1];
|
||||||
@@ -223,10 +223,10 @@ void GetMidLine_Right(float32 pts_right[][2], sint32 pts_right_count, float32 mi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int is_curve(float32 angle[], int n, float32 threshold) {
|
int is_curve(float angle[], int n, float threshold) {
|
||||||
for (int i = 1; i < n - 1; i++) {
|
for (int i = 1; i < n - 1; i++) {
|
||||||
float32 da = fabs(angle[i] - angle[i-1]);
|
float da = fabs(angle[i] - angle[i-1]);
|
||||||
float32 db = fabs(angle[i+1] - angle[i]);
|
float db = fabs(angle[i+1] - angle[i]);
|
||||||
if (da > threshold && db > threshold) {
|
if (da > threshold && db > threshold) {
|
||||||
return 1; // 是弯道
|
return 1; // 是弯道
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,13 +3,13 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void SearchStartPoint_Left(uint8 img_gray[], sint32* h_start, sint32* w_start, uint8 threshold);
|
void SearchStartPoint_Left(uint8_t img_gray[], int32_t* h_start, int32_t* w_start, uint8_t threshold);
|
||||||
void GetLinesFilter(float32 pts_in[][2], sint32 pts_in_count, float32 pts_out[][2], sint32 kernelsize);
|
void GetLinesFilter(float pts_in[][2], int32_t pts_in_count, float pts_out[][2], int32_t kernelsize);
|
||||||
void GetLinesResample(float32 pts_in[][2], sint32 num1, float32 pts_out[][2], sint32* num2, float32 dist);
|
void GetLinesResample(float pts_in[][2], int32_t num1, float pts_out[][2], int32_t* num2, float dist);
|
||||||
void local_angle_points(float pts_in[][2], int num, float angle_out[], int dist);
|
void local_angle_points(float pts_in[][2], int num, float angle_out[], int dist);
|
||||||
void nms_angle(float angle_in[], int num, float angle_out[], int kernel);
|
void nms_angle(float angle_in[], int num, float angle_out[], int kernel);
|
||||||
void GetMidLine_Left(float32 pts_left[][2], sint32 pts_left_count, float32 mid_left[][2], sint32 approx_num, float32 dist);
|
void GetMidLine_Left(float pts_left[][2], int32_t pts_left_count, float mid_left[][2], int32_t approx_num, float dist);
|
||||||
void GetMidLine_Right(float32 pts_right[][2], sint32 pts_right_count, float32 mid_right[][2], sint32 approx_num, float32 dist);
|
void GetMidLine_Right(float pts_right[][2], int32_t pts_right_count, float mid_right[][2], int32_t approx_num, float dist);
|
||||||
int is_curve(float32 angle[], int n, float32 threshold) ;
|
int is_curve(float angle[], int n, float threshold) ;
|
||||||
|
|
||||||
#endif /* COMMON_H_ */
|
#endif /* COMMON_H_ */
|
||||||
@@ -5,9 +5,6 @@
|
|||||||
/*
|
/*
|
||||||
@author: glz
|
@author: glz
|
||||||
@brief:
|
@brief:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,8 @@
|
|||||||
|
|
||||||
#include "zf_common_headfile.h"
|
#include "zf_common_headfile.h"
|
||||||
|
|
||||||
typedef signed int sint32;
|
|
||||||
|
|
||||||
void img_processing(void);
|
void img_processing(void);
|
||||||
void SearchLineAdaptive_Left(uint8 img_gray[], sint32 block_size, sint32 down_value, sint32 h, sint32 w, sint32 pts[][2], sint32* line_num);
|
void SearchLineAdaptive_Left(uint8_t img_gray[], int32_t block_size, int32_t down_value, int32_t h, int32_t w, int32_t pts[][2], int32_t* line_num);
|
||||||
void SearchLineAdaptive_Right(uint8 img_gray[], sint32 block_size, sint32 down_value, sint32 h, sint32 w, sint32 pts[][2], sint32* line_num);
|
void SearchLineAdaptive_Right(uint8_t img_gray[], int32_t block_size, int32_t down_value, int32_t h, int32_t w, int32_t pts[][2], int32_t* line_num);
|
||||||
|
|
||||||
#endif /* STATE_H_ */
|
#endif /* STATE_H_ */
|
||||||
|
|||||||
95
app/main.c
95
app/main.c
@@ -1,69 +1,66 @@
|
|||||||
/*********************************************************************************************************************
|
/*********************************************************************************************************************
|
||||||
* CH32V307VCT6 Opensourec Library <EFBFBD><EFBFBD><EFBFBD><EFBFBD>CH32V307VCT6 <EFBFBD><EFBFBD>Դ<EFBFBD>⣩<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڹٷ<EFBFBD> SDK <20>ӿڵĵ<DAB5><C4B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4>
|
* CH32V307VCT6 Opensourec Library ????CH32V307VCT6 ???????????????? SDK ??????????????
|
||||||
* Copyright (c) 2022 SEEKFREE <EFBFBD><EFBFBD><EFBFBD>ɿƼ<EFBFBD>
|
* Copyright (c) 2022 SEEKFREE ?????
|
||||||
*
|
*
|
||||||
* <EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD> CH32V307VCT6 <EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
* ??????? CH32V307VCT6 ???????????
|
||||||
*
|
*
|
||||||
* CH32V307VCT6 <EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
* CH32V307VCT6 ????? ?????????
|
||||||
* <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> GPL<EFBFBD><EFBFBD>GNU General Public License<EFBFBD><EFBFBD><EFBFBD><EFBFBD> GNU ͨ<EFBFBD>ù<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
* ?????????????????????????? GPL??GNU General Public License???? GNU ??锟斤拷????????????????
|
||||||
* <EFBFBD><EFBFBD> GPL <EFBFBD>ĵ<EFBFBD> 3 <20>棨<EFBFBD><E6A3A8> 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>
|
* ?? GPL ??? 3 ?锟斤拷?? 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><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><EFBFBD>ʺ<EFBFBD><EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD>;<EFBFBD>ı<EFBFBD>֤
|
* ?????????????????????????????????
|
||||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>μ<EFBFBD> GPL
|
* ?????????锟斤拷?GPL
|
||||||
*
|
*
|
||||||
* <EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬʱ<EFBFBD>յ<EFBFBD>һ<EFBFBD><EFBFBD> GPL <20>ĸ<EFBFBD><C4B8><EFBFBD>
|
* ?????????????????????????? GPL ?????
|
||||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>У<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><https://www.gnu.org/licenses/>
|
* ?????锟斤拷??????<https://www.gnu.org/licenses/>
|
||||||
*
|
*
|
||||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
* ?????????
|
||||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD> GPL3.0 <20><>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD>֤Э<D6A4><D0AD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>İ汾
|
* ?????????? GPL3.0 ????????锟斤拷?? ?????????????????锟斤拷
|
||||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӣ<EFBFBD>İ<EFBFBD><EFBFBD><EFBFBD> libraries/doc <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD> GPL3_permission_statement.txt <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
|
* ?????????????? libraries/doc ???????? GPL3_permission_statement.txt ?????
|
||||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> libraries <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>µ<EFBFBD> LICENSE <EFBFBD>ļ<EFBFBD>
|
* ??????????? libraries ??????? ???????????? LICENSE ???
|
||||||
* <EFBFBD><EFBFBD>ӭ<EFBFBD><EFBFBD>λʹ<EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>뱣<EFBFBD><EBB1A3><EFBFBD><EFBFBD><EFBFBD>ɿƼ<C9BF><C6BC>İ<EFBFBD>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
* ?????锟斤拷??锟斤拷??????????? ?????????????????????????????????????????
|
||||||
*
|
*
|
||||||
* <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> main
|
* ??????? main
|
||||||
* <EFBFBD><EFBFBD>˾<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>ɶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɿƼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˾
|
* ??????? ??????????????
|
||||||
* <EFBFBD>汾<EFBFBD><EFBFBD>Ϣ <EFBFBD>鿴 libraries/doc <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> version <EFBFBD>ļ<EFBFBD> <20>汾˵<E6B1BE><CBB5>
|
* ?锟斤拷??? ?? libraries/doc ??????? version ??? ?锟斤拷???
|
||||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> MounRiver Studio V1.8.1
|
* ???????? MounRiver Studio V1.8.1
|
||||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ̨ CH32V307VCT6
|
* ?????? CH32V307VCT6
|
||||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> https://seekfree.taobao.com/
|
* ???????? https://seekfree.taobao.com/
|
||||||
*
|
*
|
||||||
* <EFBFBD>ļ<EFBFBD>¼
|
* ?????
|
||||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>ע
|
* ???? ???? ???
|
||||||
* 2022-09-15 <EFBFBD><EFBFBD> W first version
|
* 2022-09-15 ?? W first version
|
||||||
********************************************************************************************************************/
|
********************************************************************************************************************/
|
||||||
#include "zf_common_headfile.h"
|
#include "zf_common_headfile.h"
|
||||||
#include "gl_headfile.h"
|
#include "gl_headfile.h"
|
||||||
#include "cw_servo.h"
|
|
||||||
#include "by_pt_button.h"
|
#include "by_pt_button.h"
|
||||||
#include "by_fan_control.h"
|
#include "by_fan_control.h"
|
||||||
#include "by_imu.h"
|
#include "cw_servo.h"
|
||||||
|
#include "./page/cw_page.h"
|
||||||
|
|
||||||
uint8 (*Img_Gray)[MT9V03X_W]; // <20><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD> MT9V03X_W <20>е<EFBFBD> uint8 <20><><EFBFBD>͵Ķ<CDB5>ά<EFBFBD><CEAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
|
uint8_t (*Img_Gray)[MT9V03X_W];
|
||||||
// uint8 *mt9v03x_image_copy[0]; // <20><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8> uint8 <20><><EFBFBD>͵<EFBFBD>һά<D2BB><CEAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
|
int32_t pts_left[PT_MAXLEN][2];
|
||||||
sint32 pts_left[PT_MAXLEN][2], pts_right[PT_MAXLEN][2];
|
int32_t pts_right[PT_MAXLEN][2];
|
||||||
sint32 pts_left_count, pts_right_count;
|
int32_t pts_left_count, pts_right_count;
|
||||||
float32 pts_inv_l[PT_MAXLEN][2], pts_inv_r[PT_MAXLEN][2];
|
float pts_inv_l[PT_MAXLEN][2], pts_inv_r[PT_MAXLEN][2];
|
||||||
sint32 pts_inv_l_count, pts_inv_r_count;
|
int32_t pts_inv_l_count, pts_inv_r_count;
|
||||||
float32 pts_filter_l[PT_MAXLEN][2], pts_filter_r[PT_MAXLEN][2];
|
float pts_filter_l[PT_MAXLEN][2], pts_filter_r[PT_MAXLEN][2];
|
||||||
sint32 pts_filter_l_count, pts_filter_r_count;
|
int32_t pts_filter_l_count, pts_filter_r_count;
|
||||||
float32 pts_resample_left[PT_MAXLEN][2], pts_resample_right[PT_MAXLEN][2];
|
float pts_resample_left[PT_MAXLEN][2], pts_resample_right[PT_MAXLEN][2];
|
||||||
sint32 pts_resample_left_count, pts_resample_right_count;
|
int32_t pts_resample_left_count, pts_resample_right_count;
|
||||||
float32 mid_left[PT_MAXLEN][2], mid_right[PT_MAXLEN][2];
|
float mid_left[PT_MAXLEN][2], mid_right[PT_MAXLEN][2];
|
||||||
sint32 mid_left_count, mid_right_count;
|
int32_t mid_left_count, mid_right_count;
|
||||||
|
|
||||||
// <20><><EFBFBD>ұ<EFBFBD><D2B1>߾ֲ<DFBE><D6B2>Ƕȱ仯<C8B1><E4BBAF> + <20>Ǽ<EFBFBD><C7BC><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>
|
|
||||||
float angle_new_left[PT_MAXLEN];
|
float angle_new_left[PT_MAXLEN];
|
||||||
float angle_new_right[PT_MAXLEN];
|
float angle_new_right[PT_MAXLEN];
|
||||||
int angle_new_left_num, angle_new_right_num;
|
int angle_new_left_num, angle_new_right_num;
|
||||||
uint8_t mt9v03x_image_copy[MT9V03X_H][MT9V03X_W];
|
uint8_t mt9v03x_image_copy[MT9V03X_H][MT9V03X_W];
|
||||||
|
|
||||||
// <20><><EFBFBD>ұ<EFBFBD><D2B1>߾ֲ<DFBE><D6B2>Ƕȱ仯<C8B1><E4BBAF>
|
|
||||||
float angle_left[PT_MAXLEN];
|
float angle_left[PT_MAXLEN];
|
||||||
float angle_right[PT_MAXLEN];
|
float angle_right[PT_MAXLEN];
|
||||||
int angle_left_num, angle_right_num;
|
int angle_left_num, angle_right_num;
|
||||||
|
|
||||||
// L <20>ǵ<EFBFBD>
|
|
||||||
int Lpt0_rpts0s_id, Lpt1_rpts1s_id;
|
int Lpt0_rpts0s_id, Lpt1_rpts1s_id;
|
||||||
bool Lpt0_found, Lpt1_found;
|
bool Lpt0_found, Lpt1_found;
|
||||||
int Lpt1[2], Lpt0[2];
|
int Lpt1[2], Lpt0[2];
|
||||||
@@ -72,13 +69,10 @@ int Lpt_in0_rpts0s_id, Lpt_in1_rpts1s_id;
|
|||||||
bool Lpt_in0_found, Lpt_in1_found;
|
bool Lpt_in0_found, Lpt_in1_found;
|
||||||
int Lpt_in1[2], Lpt_in0[2];
|
int Lpt_in1[2], Lpt_in0[2];
|
||||||
|
|
||||||
// <20><>ֱ<EFBFBD><D6B1>
|
|
||||||
bool is_straight0, is_straight1;
|
bool is_straight0, is_straight1;
|
||||||
|
|
||||||
// <20><><EFBFBD><EFBFBD>
|
|
||||||
bool is_turn0, is_turn1;
|
bool is_turn0, is_turn1;
|
||||||
|
|
||||||
// <20><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
float rptsn[PT_MAXLEN][2];
|
float rptsn[PT_MAXLEN][2];
|
||||||
int rptsn_num;
|
int rptsn_num;
|
||||||
float aim_distance;
|
float aim_distance;
|
||||||
@@ -95,8 +89,8 @@ void adaptiveThreshold(uint8_t* img_data, uint8_t* output_data, int width, int h
|
|||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
clock_init(SYSTEM_CLOCK_120M); // <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>оƬʱ<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>Ϊ 120MHz
|
clock_init(SYSTEM_CLOCK_120M); // 初始化芯片时钟 工作频率为 120MHz
|
||||||
debug_init(); // <EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڳ<EFBFBD>ʼ<EFBFBD><EFBFBD> MPU ʱ<><CAB1> <20><><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD>
|
debug_init(); // 务必保留,本函数用于初始化 MPU 时钟 调试串口
|
||||||
//mt9v03x_init();
|
//mt9v03x_init();
|
||||||
// system_delay_ms(2000);
|
// system_delay_ms(2000);
|
||||||
ips200_init(IPS200_TYPE_SPI);
|
ips200_init(IPS200_TYPE_SPI);
|
||||||
@@ -148,9 +142,6 @@ int main(void)
|
|||||||
|
|
||||||
//MidLineTrack();
|
//MidLineTrack();
|
||||||
}
|
}
|
||||||
// // by_imu_data_get();
|
|
||||||
// // by_ips_show();
|
|
||||||
// // system_delay_ms(200);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,7 +151,7 @@ void adaptiveThreshold(uint8_t* img_data, uint8_t* output_data, int width, int h
|
|||||||
int half_block = block / 2;
|
int half_block = block / 2;
|
||||||
for(int y=half_block; y<height-half_block; y++){
|
for(int y=half_block; y<height-half_block; y++){
|
||||||
for(int x=half_block; x<width-half_block; x++){
|
for(int x=half_block; x<width-half_block; x++){
|
||||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֲ<EFBFBD><EFBFBD><EFBFBD>ֵ
|
// 计算局部阈值
|
||||||
int thres = 0;
|
int thres = 0;
|
||||||
for(int dy=-half_block; dy<=half_block; dy++){
|
for(int dy=-half_block; dy<=half_block; dy++){
|
||||||
for(int dx=-half_block; dx<=half_block; dx++){
|
for(int dx=-half_block; dx<=half_block; dx++){
|
||||||
@@ -168,7 +159,7 @@ void adaptiveThreshold(uint8_t* img_data, uint8_t* output_data, int width, int h
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
thres = thres / (block * block) - clip_value;
|
thres = thres / (block * block) - clip_value;
|
||||||
// <EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>ֵ<EFBFBD><EFBFBD>
|
// 进行二值化
|
||||||
output_data[x+y*width] = img_data[x+y*width]>thres ? 255 : 0;
|
output_data[x+y*width] = img_data[x+y*width]>thres ? 255 : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
32
app/main.h
32
app/main.h
@@ -2,35 +2,32 @@
|
|||||||
#define MAIN_H
|
#define MAIN_H
|
||||||
|
|
||||||
#include "zf_common_headfile.h"
|
#include "zf_common_headfile.h"
|
||||||
|
#include "gl_common.h"
|
||||||
|
|
||||||
|
// extern uint8 *mt9v03x_image_copy[0];
|
||||||
//extern uint8 *mt9v03x_image_copy[0];
|
extern int32_t pts_left[PT_MAXLEN][2], pts_right[PT_MAXLEN][2]; // 0:H,1:W
|
||||||
extern sint32 pts_left[PT_MAXLEN][2], pts_right[PT_MAXLEN][2]; //0:H,1:W
|
extern int32_t pts_left_count, pts_right_count;
|
||||||
extern sint32 pts_left_count, pts_right_count;
|
extern float pts_inv_l[PT_MAXLEN][2], pts_inv_r[PT_MAXLEN][2];
|
||||||
extern float32 pts_inv_l[PT_MAXLEN][2], pts_inv_r[PT_MAXLEN][2];
|
extern int32_t pts_inv_l_count, pts_inv_r_count;
|
||||||
extern sint32 pts_inv_l_count, pts_inv_r_count;
|
extern float pts_filter_l[PT_MAXLEN][2], pts_filter_r[PT_MAXLEN][2];
|
||||||
extern float32 pts_filter_l[PT_MAXLEN][2], pts_filter_r[PT_MAXLEN][2];
|
extern int32_t pts_filter_l_count, pts_filter_r_count;
|
||||||
extern sint32 pts_filter_l_count, pts_filter_r_count;
|
extern float pts_resample_left[PT_MAXLEN][2], pts_resample_right[PT_MAXLEN][2];
|
||||||
extern float32 pts_resample_left[PT_MAXLEN][2], pts_resample_right[PT_MAXLEN][2];
|
extern int32_t pts_resample_left_count, pts_resample_right_count;
|
||||||
extern sint32 pts_resample_left_count, pts_resample_right_count;
|
|
||||||
extern uint8_t mt9v03x_image_copy[MT9V03X_H][MT9V03X_W];
|
extern uint8_t mt9v03x_image_copy[MT9V03X_H][MT9V03X_W];
|
||||||
extern float32 mid_left[PT_MAXLEN][2], mid_right[PT_MAXLEN][2];
|
extern float mid_left[PT_MAXLEN][2], mid_right[PT_MAXLEN][2];
|
||||||
extern sint32 mid_left_count, mid_right_count;
|
extern int32_t mid_left_count, mid_right_count;
|
||||||
|
|
||||||
|
|
||||||
extern float angle_left[PT_MAXLEN];
|
extern float angle_left[PT_MAXLEN];
|
||||||
extern float angle_right[PT_MAXLEN];
|
extern float angle_right[PT_MAXLEN];
|
||||||
extern int angle_left_num, angle_right_num;
|
extern int angle_left_num, angle_right_num;
|
||||||
|
|
||||||
|
|
||||||
extern float angle_new_left[PT_MAXLEN];
|
extern float angle_new_left[PT_MAXLEN];
|
||||||
extern float angle_new_right[PT_MAXLEN];
|
extern float angle_new_right[PT_MAXLEN];
|
||||||
extern int angle_new_left_num, angle_new_right_num;
|
extern int angle_new_left_num, angle_new_right_num;
|
||||||
|
|
||||||
|
|
||||||
extern int Lpt0_rpts0s_id, Lpt1_rpts1s_id;
|
extern int Lpt0_rpts0s_id, Lpt1_rpts1s_id;
|
||||||
extern bool Lpt0_found, Lpt1_found;
|
extern bool Lpt0_found, Lpt1_found;
|
||||||
extern int Lpt1[2],Lpt0[2];
|
extern int Lpt1[2], Lpt0[2];
|
||||||
|
|
||||||
extern int Lpt_in0_rpts0s_id, Lpt_in1_rpts1s_id;
|
extern int Lpt_in0_rpts0s_id, Lpt_in1_rpts1s_id;
|
||||||
extern bool Lpt_in0_found, Lpt_in1_found;
|
extern bool Lpt_in0_found, Lpt_in1_found;
|
||||||
@@ -44,9 +41,6 @@ extern float rptsn[PT_MAXLEN][2];
|
|||||||
extern int rptsn_num;
|
extern int rptsn_num;
|
||||||
extern float aim_distance;
|
extern float aim_distance;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
enum track_type_e {
|
enum track_type_e {
|
||||||
TRACK_LEFT,
|
TRACK_LEFT,
|
||||||
TRACK_RIGHT,
|
TRACK_RIGHT,
|
||||||
|
|||||||
120
app/page/cw_page.c
Normal file
120
app/page/cw_page.c
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
#include "cw_page.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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 注册一个基本页面,包含一个初始化函数,循环函数,退出函数,事件函数
|
||||||
|
* @param pageID: 页面编号
|
||||||
|
* @param pageText: 页面标题的指针
|
||||||
|
* @param setupCallback: 初始化函数回调
|
||||||
|
* @param loopCallback: 循环函数回调
|
||||||
|
* @param exitCallback: 退出函数回调
|
||||||
|
* @param eventCallback: 事件函数回调
|
||||||
|
* @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;
|
||||||
|
pagelist[pageID].SetupCallback = setupCallback;
|
||||||
|
pagelist[pageID].LoopCallback = loopCallback;
|
||||||
|
pagelist[pageID].ExitCallback = exitCallback;
|
||||||
|
pagelist[pageID].EventCallback = eventCallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 页面事件传递
|
||||||
|
* @param event: 事件编号
|
||||||
|
* @retval 无
|
||||||
|
*/
|
||||||
|
void Page_EventTransmit(unsigned char event) {
|
||||||
|
/*将事件传递到当前页面*/
|
||||||
|
if (pagelist[now_page].EventCallback != 0)
|
||||||
|
pagelist[now_page].EventCallback(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 页面切换
|
||||||
|
* @param pageID:页面号
|
||||||
|
* @retval 1:成功 0:失败
|
||||||
|
*/
|
||||||
|
void Page_Shift(unsigned char pageID) {
|
||||||
|
if (page_busy == 0) {
|
||||||
|
new_page = pageID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 关闭当前页面
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void Page_CloseCurrentPage() {
|
||||||
|
pagelist[now_page].ExitCallback();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 打开当前页面
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void Page_OpenCurrentPage() {
|
||||||
|
pagelist[now_page].SetupCallback();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 获取页面状态
|
||||||
|
*
|
||||||
|
* @return uint8_t 页面忙返回1 空闲返回0
|
||||||
|
*/
|
||||||
|
uint8_t Page_GetStatus(void) {
|
||||||
|
if (page_busy)
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 页面运行函数
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void Page_Run(void) {
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
now_page = new_page;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (page_busy == 0) {
|
||||||
|
//执行循环函数
|
||||||
|
pagelist[now_page].LoopCallback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 页面初始化(注册,构建) //ATTENTION 在此处添加新加入的页面
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void Page_Init(void) {
|
||||||
|
PAGE_REG(page_menu);
|
||||||
|
// PAGE_REG(page_argv);
|
||||||
|
// PAGE_REG(page_sys);
|
||||||
|
// PAGE_REG(page_run);
|
||||||
|
|
||||||
|
Page_Shift(page_menu);
|
||||||
|
|
||||||
|
pagelist[now_page].SetupCallback(); //先构建一遍
|
||||||
|
}
|
||||||
64
app/page/cw_page.h
Normal file
64
app/page/cw_page.h
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* @Author: CaoWangrenbo cao.wangrenbo@yandex.com
|
||||||
|
* @Date: 2023-03-19 18:28:44
|
||||||
|
* @LastEditors: CaoWangrenbo cao.wangrenbo@yandex.com
|
||||||
|
* @LastEditTime: 2023-03-19 20:43:00
|
||||||
|
* @FilePath: \icr18_btl143_ch32v_slave\project\code\page\fd_page.h
|
||||||
|
* @Description:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#ifndef _FD_PAGE_H__
|
||||||
|
#define _FD_PAGE_H__
|
||||||
|
|
||||||
|
#include "zf_common_headfile.h"
|
||||||
|
|
||||||
|
enum PageID {
|
||||||
|
PAGE_NULL = -1,
|
||||||
|
//......
|
||||||
|
page_menu,
|
||||||
|
// page_argv,
|
||||||
|
// page_sys,
|
||||||
|
// page_run,
|
||||||
|
//......
|
||||||
|
page_max,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef enum page_event{
|
||||||
|
page_event_forward,
|
||||||
|
page_event_backward,
|
||||||
|
page_event_press
|
||||||
|
} page_event;
|
||||||
|
|
||||||
|
typedef void (*CallbackFunction_t)(void);
|
||||||
|
typedef void (*EventFunction_t)(page_event);
|
||||||
|
typedef struct {
|
||||||
|
char *Text;
|
||||||
|
CallbackFunction_t SetupCallback;
|
||||||
|
CallbackFunction_t LoopCallback;
|
||||||
|
CallbackFunction_t ExitCallback;
|
||||||
|
EventFunction_t EventCallback;
|
||||||
|
} PAGE_LIST;
|
||||||
|
|
||||||
|
//页面注册函数
|
||||||
|
#define PAGE_REG(name)\
|
||||||
|
do{\
|
||||||
|
extern void PageRegister_##name(unsigned char pageID);\
|
||||||
|
PageRegister_##name(name);\
|
||||||
|
}while(0)
|
||||||
|
|
||||||
|
void Page_Register(uint8_t pageID, char *pageText,
|
||||||
|
CallbackFunction_t setupCallback, CallbackFunction_t loopCallback,
|
||||||
|
CallbackFunction_t exitCallback, EventFunction_t eventCallback);
|
||||||
|
|
||||||
|
void Page_EventTransmit(unsigned char event);
|
||||||
|
void Page_Shift(unsigned char pageID);
|
||||||
|
void Page_CloseCurrentPage(void);
|
||||||
|
void Page_OpenCurrentPage(void);
|
||||||
|
uint8_t Page_GetStatus(void);
|
||||||
|
void Page_Run(void);
|
||||||
|
void Page_Init(void);
|
||||||
|
|
||||||
|
extern PAGE_LIST pagelist[page_max];
|
||||||
|
|
||||||
|
#endif
|
||||||
107
app/page/cw_page_menu.c
Normal file
107
app/page/cw_page_menu.c
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
#include "zf_common_headfile.h"
|
||||||
|
#include "cw_page_ui_widget.h"
|
||||||
|
#include "cw_page.h"
|
||||||
|
|
||||||
|
#define LINE_HEAD 1
|
||||||
|
#define LINE_END 7
|
||||||
|
|
||||||
|
static char Text[] = "Menu";
|
||||||
|
|
||||||
|
static int8_t Curser = 1; // 定义光标位置
|
||||||
|
static int8_t Curser_Last = 1; // 定义光标位置
|
||||||
|
static void Print_Menu_p(void);
|
||||||
|
/***************************************************************************************
|
||||||
|
*
|
||||||
|
* 以下为页面模板函数
|
||||||
|
*
|
||||||
|
***************************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 页面初始化事件
|
||||||
|
* @param 无
|
||||||
|
* @retval 无
|
||||||
|
*/
|
||||||
|
static void Setup()
|
||||||
|
{
|
||||||
|
ips114_clear();
|
||||||
|
Print_Menu_p();
|
||||||
|
Print_Curser(Curser, Curser_Last);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 页面退出事件
|
||||||
|
* @param 无
|
||||||
|
* @retval 无
|
||||||
|
*/
|
||||||
|
static void Exit()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 页面循环执行的内容
|
||||||
|
* @param 无
|
||||||
|
* @retval 无
|
||||||
|
*/
|
||||||
|
static void Loop()
|
||||||
|
{
|
||||||
|
Show_Marked_Image();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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 == event) {
|
||||||
|
if (page_max > Curser && page_menu < Curser) {
|
||||||
|
Page_Shift(Curser); // 切换到光标选中的页面
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Curser < LINE_HEAD) {
|
||||||
|
Curser = LINE_END;
|
||||||
|
} else if (Curser > LINE_END) {
|
||||||
|
Curser = LINE_HEAD;
|
||||||
|
}
|
||||||
|
|
||||||
|
Print_Curser(Curser, Curser_Last);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 页面注册函数
|
||||||
|
*
|
||||||
|
* @param pageID
|
||||||
|
*/
|
||||||
|
void PageRegister_page_menu(unsigned char pageID)
|
||||||
|
{
|
||||||
|
Page_Register(pageID, Text, Setup, Loop, Exit, Event);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************************************************************************
|
||||||
|
*
|
||||||
|
* 以下为页面自定义功能函数
|
||||||
|
*
|
||||||
|
***************************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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);
|
||||||
|
}
|
||||||
|
}
|
||||||
106
app/page/cw_page_rtcam.c
Normal file
106
app/page/cw_page_rtcam.c
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
#include "zf_common_headfile.h"
|
||||||
|
#include "cw_page_ui_widget.h"
|
||||||
|
#include "cw_page.h"
|
||||||
|
|
||||||
|
#define LINE_HEAD 1
|
||||||
|
#define LINE_END 7
|
||||||
|
|
||||||
|
static char Text[] = "RealTime Image";
|
||||||
|
|
||||||
|
static int8_t Curser = 1; // 定义光标位置
|
||||||
|
static int8_t Curser_Last = 1; // 定义光标位置
|
||||||
|
static void Print_Menu_p(void);
|
||||||
|
/***************************************************************************************
|
||||||
|
*
|
||||||
|
* 以下为页面模板函数
|
||||||
|
*
|
||||||
|
***************************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 页面初始化事件
|
||||||
|
* @param 无
|
||||||
|
* @retval 无
|
||||||
|
*/
|
||||||
|
static void Setup()
|
||||||
|
{
|
||||||
|
ips114_clear();
|
||||||
|
Print_Menu_p();
|
||||||
|
Print_Curser(Curser, Curser_Last);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 页面退出事件
|
||||||
|
* @param 无
|
||||||
|
* @retval 无
|
||||||
|
*/
|
||||||
|
static void Exit()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 页面循环执行的内容
|
||||||
|
* @param 无
|
||||||
|
* @retval 无
|
||||||
|
*/
|
||||||
|
static void Loop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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 == event) {
|
||||||
|
if (page_max > Curser && page_menu < Curser) {
|
||||||
|
Page_Shift(Curser); // 切换到光标选中的页面
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Curser < LINE_HEAD) {
|
||||||
|
Curser = LINE_END;
|
||||||
|
} else if (Curser > LINE_END) {
|
||||||
|
Curser = LINE_HEAD;
|
||||||
|
}
|
||||||
|
|
||||||
|
Print_Curser(Curser, Curser_Last);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 页面注册函数
|
||||||
|
*
|
||||||
|
* @param pageID
|
||||||
|
*/
|
||||||
|
void PageRegister_page_rtcam(unsigned char pageID)
|
||||||
|
{
|
||||||
|
Page_Register(pageID, Text, Setup, Loop, Exit, Event);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***************************************************************************************
|
||||||
|
*
|
||||||
|
* 以下为页面自定义功能函数
|
||||||
|
*
|
||||||
|
***************************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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);
|
||||||
|
}
|
||||||
|
}
|
||||||
150
app/page/cw_page_ui_widget.c
Normal file
150
app/page/cw_page_ui_widget.c
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
#include "cw_page_ui_widget.h"
|
||||||
|
#include "zf_common_headfile.h"
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 绘制光标
|
||||||
|
*
|
||||||
|
* @param Curser_In 当前光标位置
|
||||||
|
* @param Curser_Last_In 上一时刻光标位置
|
||||||
|
*/
|
||||||
|
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, ">");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 打印菜单项
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 打印数值项
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void Print_Value(const ITEM *item, uint8_t item_sum)
|
||||||
|
{
|
||||||
|
// for (uint8_t i = 0; i < item_sum; i++) {
|
||||||
|
// switch (Param_Data[item[i].data_tag].type) {
|
||||||
|
// case EINT8:
|
||||||
|
// ips200_show_int(128, i + 1,
|
||||||
|
// *((int8_t *)Param_Data[item[i].data_tag].p_data), 5);
|
||||||
|
// break;
|
||||||
|
// case EINT16:
|
||||||
|
// ips200_show_int(128, i + 1,
|
||||||
|
// *((int16_t *)Param_Data[item[i].data_tag].p_data), 5);
|
||||||
|
// break;
|
||||||
|
// case EINT32:
|
||||||
|
// ips200_show_int(128, i + 1,
|
||||||
|
// *((int32_t *)Param_Data[item[i].data_tag].p_data), 5);
|
||||||
|
// break;
|
||||||
|
// case EUINT8:
|
||||||
|
// ips200_show_int(128, i + 1,
|
||||||
|
// *((uint8_t *)Param_Data[item[i].data_tag].p_data), 5);
|
||||||
|
// break;
|
||||||
|
// case EUINT16:
|
||||||
|
// ips200_show_int(128, i + 1,
|
||||||
|
// *((uint16_t *)Param_Data[item[i].data_tag].p_data), 5);
|
||||||
|
// break;
|
||||||
|
// case EUINT32:
|
||||||
|
// ips200_show_int(128, i + 1,
|
||||||
|
// *((uint32_t *)Param_Data[item[i].data_tag].p_data), 5);
|
||||||
|
// case EFLOAT:
|
||||||
|
// ips200_show_float(128, i + 1,
|
||||||
|
// *((float *)Param_Data[item[i].data_tag].p_data), 5, 2);
|
||||||
|
// break;
|
||||||
|
// default:
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief
|
||||||
|
*
|
||||||
|
* @param item_num
|
||||||
|
* @param dir
|
||||||
|
*/
|
||||||
|
void Set_Vaule(ITEM *item, uint8_t item_num, float step)
|
||||||
|
{
|
||||||
|
|
||||||
|
// if (EFLOAT == Param_Data[item[item_num].data_tag].type) { // 待修改变量为浮点
|
||||||
|
// *((float *)Param_Data[item[item_num].data_tag].p_data) += step;
|
||||||
|
// ips200_show_float(128, item_num + 1,
|
||||||
|
// *((float *)Param_Data[item[item_num].data_tag].p_data), 6,
|
||||||
|
// 2);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (0 < step &&
|
||||||
|
// 1 > step) { // 避免步进值小于 1 时截尾为 0,不知道为啥 ceil 函数不可用
|
||||||
|
// step = 1;
|
||||||
|
// } else if (0 > step && -1 < step) {
|
||||||
|
// step = -1;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// switch (Param_Data[item[item_num].data_tag].type) {
|
||||||
|
// case EINT8:
|
||||||
|
// *((int8_t *)Param_Data[item[item_num].data_tag].p_data) += (int8_t)step;
|
||||||
|
// ips200_show_int(128, item_num + 1,
|
||||||
|
// *((int8_t *)Param_Data[item[item_num].data_tag].p_data), 5);
|
||||||
|
// break;
|
||||||
|
// case EINT16:
|
||||||
|
// *((int16_t *)Param_Data[item[item_num].data_tag].p_data) += (int16_t)step;
|
||||||
|
// ips200_show_int(128, item_num + 1,
|
||||||
|
// *((int16_t *)Param_Data[item[item_num].data_tag].p_data), 5);
|
||||||
|
// break;
|
||||||
|
// case EINT32:
|
||||||
|
// *((int32_t *)Param_Data[item[item_num].data_tag].p_data) += (int32_t)step;
|
||||||
|
// ips200_show_int(128, item_num + 1,
|
||||||
|
// *((int32_t *)Param_Data[item[item_num].data_tag].p_data), 5);
|
||||||
|
// break;
|
||||||
|
// case EUINT8:
|
||||||
|
// *((uint8_t *)Param_Data[item[item_num].data_tag].p_data) += (uint8_t)step;
|
||||||
|
// ips200_show_int(128, item_num + 1,
|
||||||
|
// *((uint8_t *)Param_Data[item[item_num].data_tag].p_data), 5);
|
||||||
|
// break;
|
||||||
|
// case EUINT16:
|
||||||
|
// *((uint16_t *)Param_Data[item[item_num].data_tag].p_data) += (uint16_t)step;
|
||||||
|
// ips200_show_int(128, item_num + 1,
|
||||||
|
// *((uint16_t *)Param_Data[item[item_num].data_tag].p_data), 5);
|
||||||
|
// break;
|
||||||
|
// case EUINT32:
|
||||||
|
// *((uint32_t *)Param_Data[item[item_num].data_tag].p_data) += (uint32_t)step;
|
||||||
|
// ips200_show_int(128, item_num + 1,
|
||||||
|
// *((uint32_t *)Param_Data[item[item_num].data_tag].p_data), 5);
|
||||||
|
// break;
|
||||||
|
// default:
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
void Show_Marked_Image(void)
|
||||||
|
{
|
||||||
|
#define IMAGE_DISPLAY_WIDTH (230U)
|
||||||
|
#define IMAGE_DISPLAY_HEIGHT (146U)
|
||||||
|
#define START_X ((240U - IMAGE_DISPLAY_WIDTH) / 2U)
|
||||||
|
#define START_Y (16U)
|
||||||
|
|
||||||
|
float horizontal_zoom_rate = ((float)(IMAGE_DISPLAY_WIDTH)) / ((float)(MT9V03X_W));
|
||||||
|
float vertical_zoom_rate = ((float)(IMAGE_DISPLAY_HEIGHT)) / ((float)(MT9V03X_H));
|
||||||
|
|
||||||
|
ips200_show_gray_image(START_X, START_Y, mt9v03x_image_copy[0], MT9V03X_W, MT9V03X_H, IMAGE_DISPLAY_WIDTH, IMAGE_DISPLAY_HEIGHT, 0);
|
||||||
|
|
||||||
|
// 确认边线数组在显示前不会清空
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
#undef IMAGE_DISPLAY_WIDTH
|
||||||
|
#undef START_X
|
||||||
|
#undef START_Y
|
||||||
|
}
|
||||||
17
app/page/cw_page_ui_widget.h
Normal file
17
app/page/cw_page_ui_widget.h
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#ifndef _FD_SCREEN_WIDGET_H__
|
||||||
|
#define _FD_SCREEN_WIDGET_H__
|
||||||
|
|
||||||
|
#include "zf_common_headfile.h"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char *text; //变量显示名
|
||||||
|
uint8_t data_tag; //变量结构体
|
||||||
|
} ITEM;
|
||||||
|
|
||||||
|
void Print_Curser(uint8_t Curser_In, uint8_t Curser_Last_In);
|
||||||
|
void Print_Menu(const ITEM* item, uint8_t item_sum);
|
||||||
|
void Print_Value(const ITEM* item, uint8_t item_sum);
|
||||||
|
void Set_Vaule(ITEM* item, uint8_t item_num, float step);
|
||||||
|
void Show_Marked_Image(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -64,7 +64,7 @@
|
|||||||
#include "zf_common_typedef.h"
|
#include "zf_common_typedef.h"
|
||||||
|
|
||||||
|
|
||||||
// --------------------单排两寸屏幕SPI接口引脚定义--------------------//
|
// --------------------单排两寸屏幕 SPI 接口引脚定义--------------------//
|
||||||
|
|
||||||
#define IPS200_USE_SOFT_SPI (0 ) // 默认使用硬件 SPI 方式驱动 建议使用硬件 SPI 方式驱动
|
#define IPS200_USE_SOFT_SPI (0 ) // 默认使用硬件 SPI 方式驱动 建议使用硬件 SPI 方式驱动
|
||||||
#if IPS200_USE_SOFT_SPI // 这两段 颜色正常的才是正确的 颜色灰的就是没有用的
|
#if IPS200_USE_SOFT_SPI // 这两段 颜色正常的才是正确的 颜色灰的就是没有用的
|
||||||
@@ -91,7 +91,7 @@
|
|||||||
#define IPS200_BLk_PIN_SPI (D11 )
|
#define IPS200_BLk_PIN_SPI (D11 )
|
||||||
|
|
||||||
|
|
||||||
// --------------------单排两寸屏幕SPI接口引脚定义--------------------//
|
// --------------------单排两寸屏幕 SPI 接口引脚定义--------------------//
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -103,16 +103,16 @@
|
|||||||
#define IPS200_CS_PIN_PARALLEL8 (D4 )
|
#define IPS200_CS_PIN_PARALLEL8 (D4 )
|
||||||
#define IPS200_BL_PIN_PARALLEL8 (D0 )
|
#define IPS200_BL_PIN_PARALLEL8 (D0 )
|
||||||
|
|
||||||
//8个数据引脚必须连续 例如B0-B7,B6-B13等等。
|
//8 个数据引脚必须连续 例如 B0-B7,B6-B13 等等。
|
||||||
//--------------数据端口寄存器--------------
|
//--------------数据端口寄存器--------------
|
||||||
#define IPS200_DATAPORT GPIOE
|
#define IPS200_DATAPORT GPIOE
|
||||||
|
|
||||||
//--------------数据端口起始地址偏移--------------
|
//--------------数据端口起始地址偏移--------------
|
||||||
#define DATA_START_NUM 0
|
#define DATA_START_NUM 0
|
||||||
|
|
||||||
//例:D1-D8 IPS200_DATAPORT设置为GPIOD DATA_START_NUM设置为1
|
//例:D1-D8 IPS200_DATAPORT 设置为 GPIOD DATA_START_NUM 设置为 1
|
||||||
//例:C5-C12 IPS200_DATAPORT设置为GPIOC DATA_START_NUM设置为5
|
//例:C5-C12 IPS200_DATAPORT 设置为 GPIOC DATA_START_NUM 设置为 5
|
||||||
// --------------------双排SPI接口两寸屏幕引脚定义--------------------//
|
// --------------------双排 SPI 接口两寸屏幕引脚定义--------------------//
|
||||||
|
|
||||||
#define IPS200_DEFAULT_DISPLAY_DIR (IPS200_PORTAIT) // 默认的显示方向
|
#define IPS200_DEFAULT_DISPLAY_DIR (IPS200_PORTAIT) // 默认的显示方向
|
||||||
#define IPS200_DEFAULT_PENCOLOR (RGB565_RED ) // 默认的画笔颜色
|
#define IPS200_DEFAULT_PENCOLOR (RGB565_RED ) // 默认的画笔颜色
|
||||||
@@ -139,9 +139,9 @@ typedef enum
|
|||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
IPS200_PORTAIT = 0, // 竖屏模式
|
IPS200_PORTAIT = 0, // 竖屏模式
|
||||||
IPS200_PORTAIT_180 = 1, // 竖屏模式 旋转180
|
IPS200_PORTAIT_180 = 1, // 竖屏模式 旋转 180
|
||||||
IPS200_CROSSWISE = 2, // 横屏模式
|
IPS200_CROSSWISE = 2, // 横屏模式
|
||||||
IPS200_CROSSWISE_180 = 3, // 横屏模式 旋转180
|
IPS200_CROSSWISE_180 = 3, // 横屏模式 旋转 180
|
||||||
}ips200_dir_enum;
|
}ips200_dir_enum;
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
|
|||||||
Reference in New Issue
Block a user