Merge pull request '日常更新 2312191657' (#6) from define/firmware_violet_zf:master into master
Reviewed-on: http://git.isthmus.tk:441/btl143/firmware_violet_zf/pulls/6
This commit is contained in:
10
.vscode/launch.json
vendored
10
.vscode/launch.json
vendored
@@ -5,13 +5,13 @@
|
||||
"cwd": "${workspaceRoot}",
|
||||
"type": "cortex-debug",
|
||||
"request": "launch",
|
||||
"name": "jlink",
|
||||
"servertype": "jlink",
|
||||
"interface": "swd",
|
||||
"name": "openocd",
|
||||
"servertype": "openocd",
|
||||
"executable": "build\\Debug\\violet_firmware_zf.elf",
|
||||
"runToEntryPoint": "main",
|
||||
"device": "null",
|
||||
"toolchainPrefix": "riscv-none-embed"
|
||||
"configFiles": [
|
||||
"${workspaceFolder}/tools/wch-riscv.cfg"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
#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;
|
||||
}
|
||||
|
||||
@@ -23,10 +23,7 @@
|
||||
#define FRAMETOLEFT (5)
|
||||
#define FRAMETORIGHT (5)
|
||||
|
||||
typedef signed int sint32;
|
||||
typedef float float32;
|
||||
|
||||
sint32 limit(sint32 x, sint32 low, sint32 up);
|
||||
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) ;
|
||||
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
|
||||
|
||||
|
||||
const sint32 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 sint32 direction_frontright[4][2] ={{1, -1},{1, 1},{-1, 1},{-1, -1}};
|
||||
const int32_t direction_front[4][2] = {{0, -1},{1, 0},{0, 1},{-1, 0}};
|
||||
const int32_t direction_frontleft[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 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;
|
||||
}
|
||||
|
||||
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 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;
|
||||
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) {
|
||||
*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++) {
|
||||
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++) {
|
||||
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++) {
|
||||
float32 da = fabs(angle[i] - angle[i-1]);
|
||||
float32 db = fabs(angle[i+1] - angle[i]);
|
||||
float da = fabs(angle[i] - angle[i-1]);
|
||||
float db = fabs(angle[i+1] - angle[i]);
|
||||
if (da > threshold && db > threshold) {
|
||||
return 1; // 是弯道
|
||||
}
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
|
||||
|
||||
|
||||
void SearchStartPoint_Left(uint8 img_gray[], sint32* h_start, sint32* w_start, uint8 threshold);
|
||||
void GetLinesFilter(float32 pts_in[][2], sint32 pts_in_count, float32 pts_out[][2], sint32 kernelsize);
|
||||
void GetLinesResample(float32 pts_in[][2], sint32 num1, float32 pts_out[][2], sint32* num2, float32 dist);
|
||||
void SearchStartPoint_Left(uint8_t img_gray[], int32_t* h_start, int32_t* w_start, uint8_t threshold);
|
||||
void GetLinesFilter(float pts_in[][2], int32_t pts_in_count, float pts_out[][2], int32_t kernelsize);
|
||||
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 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_Right(float32 pts_right[][2], sint32 pts_right_count, float32 mid_right[][2], sint32 approx_num, float32 dist);
|
||||
int is_curve(float32 angle[], int n, float32 threshold) ;
|
||||
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(float pts_right[][2], int32_t pts_right_count, float mid_right[][2], int32_t approx_num, float dist);
|
||||
int is_curve(float angle[], int n, float threshold) ;
|
||||
|
||||
#endif /* COMMON_H_ */
|
||||
@@ -5,9 +5,6 @@
|
||||
/*
|
||||
@author: glz
|
||||
@brief:
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -3,10 +3,8 @@
|
||||
|
||||
#include "zf_common_headfile.h"
|
||||
|
||||
typedef signed int sint32;
|
||||
|
||||
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_Right(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_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_ */
|
||||
|
||||
122
app/main.c
122
app/main.c
@@ -1,69 +1,67 @@
|
||||
/*********************************************************************************************************************
|
||||
* 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>
|
||||
* Copyright (c) 2022 SEEKFREE <EFBFBD><EFBFBD><EFBFBD>ɿƼ<EFBFBD>
|
||||
* CH32V307VCT6 Opensourec Library ????CH32V307VCT6 ???????????????? SDK ??????????????
|
||||
* 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>
|
||||
* <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>
|
||||
* <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>
|
||||
* CH32V307VCT6 ????? ?????????
|
||||
* ?????????????????????????? GPL??GNU General Public License???? GNU ??<3F><><EFBFBD><EFBFBD>???????????????
|
||||
* ?? GPL ??? 3 ?<3F><><EFBFBD><EFBFBD>? GPL3.0????????????<3F>ʦ<EFBFBD><CAA6><EFBFBD>????<3F><><EFBFBD><EFBFBD>????<3F><><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><EFBFBD>μ<EFBFBD> GPL
|
||||
* ????????????????????????????????<3F><><EFBFBD><EFBFBD>??????<3F>ʦ<EFBFBD><CAA6><EFBFBD>??
|
||||
* ?????????????????????????????????
|
||||
* ?????????<EFBFBD><EFBFBD><EFBFBD><EFBFBD>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>
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>У<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><https://www.gnu.org/licenses/>
|
||||
* ?????????????????????????? GPL ?????
|
||||
* ?????<3F><><EFBFBD><EFBFBD>?????<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>İ汾
|
||||
* <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>
|
||||
* <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>
|
||||
* <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>
|
||||
* ?????????
|
||||
* ?????????? GPL3.0 ????????<3F><><EFBFBD><EFBFBD>? ?????????????????<3F><>
|
||||
* ?????????????? libraries/doc ???????? GPL3_permission_statement.txt ?????
|
||||
* ??????????? libraries ??????? ???????????? LICENSE ???
|
||||
* ?????<EFBFBD><EFBFBD><EFBFBD><EFBFBD>?<EFBFBD><EFBFBD><EFBFBD><EFBFBD>?????????? ?????????????????????????????????????????
|
||||
*
|
||||
* <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 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>
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> MounRiver Studio V1.8.1
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ̨ CH32V307VCT6
|
||||
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> https://seekfree.taobao.com/
|
||||
* ??????? main
|
||||
* ??????? ??????????????
|
||||
* ?<3F><><EFBFBD><EFBFBD>?? ?? libraries/doc ??????? version ??? ?<3F><><EFBFBD><EFBFBD>??
|
||||
* ???????? MounRiver Studio V1.8.1
|
||||
* ?????? CH32V307VCT6
|
||||
* ???????? 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 "gl_headfile.h"
|
||||
#include "cw_servo.h"
|
||||
#include "by_pt_button.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 *mt9v03x_image_copy[0]; // <20><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8> uint8 <20><><EFBFBD>͵<EFBFBD>һά<D2BB><CEAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
|
||||
sint32 pts_left[PT_MAXLEN][2], pts_right[PT_MAXLEN][2];
|
||||
sint32 pts_left_count, pts_right_count;
|
||||
float32 pts_inv_l[PT_MAXLEN][2], pts_inv_r[PT_MAXLEN][2];
|
||||
sint32 pts_inv_l_count, pts_inv_r_count;
|
||||
float32 pts_filter_l[PT_MAXLEN][2], pts_filter_r[PT_MAXLEN][2];
|
||||
sint32 pts_filter_l_count, pts_filter_r_count;
|
||||
float32 pts_resample_left[PT_MAXLEN][2], pts_resample_right[PT_MAXLEN][2];
|
||||
sint32 pts_resample_left_count, pts_resample_right_count;
|
||||
float32 mid_left[PT_MAXLEN][2], mid_right[PT_MAXLEN][2];
|
||||
sint32 mid_left_count, mid_right_count;
|
||||
uint8_t (*Img_Gray)[MT9V03X_W];
|
||||
// uint8_t *mt9v03x_image_copy[0];
|
||||
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;
|
||||
|
||||
// <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_right[PT_MAXLEN];
|
||||
int angle_new_left_num, angle_new_right_num;
|
||||
uint8_t mt9v03x_image_copy[MT9V03X_H][MT9V03X_W];
|
||||
|
||||
// <20><><EFBFBD>ұ<EFBFBD><D2B1>߾ֲ<DFBE><D6B2>Ƕȱ仯<C8B1><E4BBAF>
|
||||
float angle_left[PT_MAXLEN];
|
||||
float angle_right[PT_MAXLEN];
|
||||
int angle_left_num, angle_right_num;
|
||||
|
||||
// L <20>ǵ<EFBFBD>
|
||||
int Lpt0_rpts0s_id, Lpt1_rpts1s_id;
|
||||
bool Lpt0_found, Lpt1_found;
|
||||
int Lpt1[2], Lpt0[2];
|
||||
@@ -72,13 +70,10 @@ int Lpt_in0_rpts0s_id, Lpt_in1_rpts1s_id;
|
||||
bool Lpt_in0_found, Lpt_in1_found;
|
||||
int Lpt_in1[2], Lpt_in0[2];
|
||||
|
||||
// <20><>ֱ<EFBFBD><D6B1>
|
||||
bool is_straight0, is_straight1;
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>
|
||||
bool is_turn0, is_turn1;
|
||||
|
||||
// <20><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
float rptsn[PT_MAXLEN][2];
|
||||
int rptsn_num;
|
||||
float aim_distance;
|
||||
@@ -92,57 +87,34 @@ void get_corners();
|
||||
|
||||
int main(void)
|
||||
{
|
||||
clock_init(SYSTEM_CLOCK_120M); // <20><>ʼ<EFBFBD><CABC>оƬʱ<C6AC><CAB1> <20><><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>Ϊ 120MHz
|
||||
debug_init(); // <20><><EFBFBD>ر<EFBFBD><D8B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڳ<EFBFBD>ʼ<EFBFBD><CABC> MPU ʱ<><CAB1> <20><><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD>
|
||||
// mt9v03x_init();
|
||||
clock_init(SYSTEM_CLOCK_120M);
|
||||
debug_init();
|
||||
mt9v03x_init();
|
||||
ips200_init(IPS200_TYPE_SPI);
|
||||
by_gpio_init();
|
||||
by_exit_init();
|
||||
by_pwm_init();
|
||||
cw_servo_init();
|
||||
while (imu660ra_init())
|
||||
;
|
||||
// while (imu660ra_init())
|
||||
// ;
|
||||
|
||||
system_delay_ms(2000);
|
||||
gyroOffset_init();
|
||||
pit_ms_init(TIM6_PIT, 2);
|
||||
Page_Init();
|
||||
|
||||
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);
|
||||
// ips114_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) {
|
||||
// ips114_show_gray_image(0, 0, mt9v03x_image[0], 188, 120, 188, 120,0);
|
||||
memcpy(mt9v03x_image_copy[0], mt9v03x_image[0], (sizeof(mt9v03x_image_copy) / sizeof(uint8_t)));
|
||||
// Img_Gray = mt9v03x_image;
|
||||
// mt9v03x_image_copy[0] = Img_Gray[0];
|
||||
mt9v03x_finish_flag = 0;
|
||||
|
||||
state_type = COMMON_STATE;
|
||||
img_processing();
|
||||
|
||||
get_corners();
|
||||
|
||||
aim_distance = COMMON_AIM;
|
||||
|
||||
tracking();
|
||||
|
||||
ElementJudge();
|
||||
|
||||
ElementRun();
|
||||
|
||||
MidLineTrack();
|
||||
}
|
||||
// by_imu_data_get();
|
||||
by_ips_show();
|
||||
system_delay_ms(200);
|
||||
}
|
||||
}
|
||||
28
app/main.h
28
app/main.h
@@ -2,32 +2,29 @@
|
||||
#define MAIN_H
|
||||
|
||||
#include "zf_common_headfile.h"
|
||||
|
||||
#include "gl_common.h"
|
||||
|
||||
// extern uint8 *mt9v03x_image_copy[0];
|
||||
extern sint32 pts_left[PT_MAXLEN][2], pts_right[PT_MAXLEN][2]; //0:H,1:W
|
||||
extern sint32 pts_left_count, pts_right_count;
|
||||
extern float32 pts_inv_l[PT_MAXLEN][2], pts_inv_r[PT_MAXLEN][2];
|
||||
extern sint32 pts_inv_l_count, pts_inv_r_count;
|
||||
extern float32 pts_filter_l[PT_MAXLEN][2], pts_filter_r[PT_MAXLEN][2];
|
||||
extern sint32 pts_filter_l_count, pts_filter_r_count;
|
||||
extern float32 pts_resample_left[PT_MAXLEN][2], pts_resample_right[PT_MAXLEN][2];
|
||||
extern sint32 pts_resample_left_count, pts_resample_right_count;
|
||||
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 float32 mid_left[PT_MAXLEN][2], mid_right[PT_MAXLEN][2];
|
||||
extern sint32 mid_left_count, mid_right_count;
|
||||
|
||||
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];
|
||||
@@ -44,9 +41,6 @@ extern float rptsn[PT_MAXLEN][2];
|
||||
extern int rptsn_num;
|
||||
extern float aim_distance;
|
||||
|
||||
|
||||
|
||||
|
||||
enum track_type_e {
|
||||
TRACK_LEFT,
|
||||
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
|
||||
@@ -174,7 +174,6 @@ static soft_spi_info_struct ips200_spi;
|
||||
static void ips200_write_data(const uint8 dat)
|
||||
{
|
||||
IPS200_DATAPORT->OUTDR = ((dat << DATA_START_NUM) | (IPS200_DATAPORT->OUTDR & ~((uint32)(0xFF << DATA_START_NUM))));
|
||||
|
||||
}
|
||||
|
||||
// #define ips200_write_data(x) (*(volatile uint16 *)IPS200_DATA_ADD = (((uint16)x & 0x00FF) << 8))
|
||||
@@ -188,8 +187,7 @@ static void ips200_write_data (const uint8 dat)
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
static void ips200_write_command(const uint8 command)
|
||||
{
|
||||
if(IPS200_TYPE_SPI == ips200_display_type)
|
||||
{
|
||||
if (IPS200_TYPE_SPI == ips200_display_type) {
|
||||
IPS200_CS(1);
|
||||
IPS200_CS(0);
|
||||
IPS200_DC(0);
|
||||
@@ -197,9 +195,7 @@ static void ips200_write_command (const uint8 command)
|
||||
IPS200_DC(1);
|
||||
IPS200_CS(1);
|
||||
IPS200_CS(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
IPS200_CS(0);
|
||||
IPS200_RS(0);
|
||||
IPS200_RD(1);
|
||||
@@ -220,12 +216,9 @@ static void ips200_write_command (const uint8 command)
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
static void ips200_write_8bit_data(const uint8 dat)
|
||||
{
|
||||
if(IPS200_TYPE_SPI == ips200_display_type)
|
||||
{
|
||||
if (IPS200_TYPE_SPI == ips200_display_type) {
|
||||
ips200_write_8bit_data_spi(dat);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
IPS200_CS(0);
|
||||
IPS200_RD(1);
|
||||
IPS200_WR(0);
|
||||
@@ -243,16 +236,12 @@ static void ips200_write_8bit_data (const uint8 dat)
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
static void ips200_write_8bit_data_array(const uint8 *dat, uint32 len)
|
||||
{
|
||||
if(IPS200_TYPE_SPI == ips200_display_type)
|
||||
{
|
||||
if (IPS200_TYPE_SPI == ips200_display_type) {
|
||||
ips200_write_8bit_data_spi_array(dat, len);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
IPS200_CS(0);
|
||||
IPS200_RD(1);
|
||||
while(len --)
|
||||
{
|
||||
while (len--) {
|
||||
IPS200_WR(0);
|
||||
ips200_write_data((uint8)*dat);
|
||||
IPS200_WR(1);
|
||||
@@ -271,12 +260,9 @@ static void ips200_write_8bit_data_array (const uint8 *dat, uint32 len)
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
static void ips200_write_16bit_data(const uint16 dat)
|
||||
{
|
||||
if(IPS200_TYPE_SPI == ips200_display_type)
|
||||
{
|
||||
if (IPS200_TYPE_SPI == ips200_display_type) {
|
||||
ips200_write_16bit_data_spi(dat);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
IPS200_CS(0);
|
||||
IPS200_RD(1);
|
||||
IPS200_WR(0);
|
||||
@@ -297,16 +283,12 @@ static void ips200_write_16bit_data (const uint16 dat)
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
static void ips200_write_16bit_data_array(const uint16 *dat, uint32 len)
|
||||
{
|
||||
if(IPS200_TYPE_SPI == ips200_display_type)
|
||||
{
|
||||
if (IPS200_TYPE_SPI == ips200_display_type) {
|
||||
ips200_write_16bit_data_spi_array(dat, len);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
IPS200_CS(0);
|
||||
IPS200_RD(1);
|
||||
while(len --)
|
||||
{
|
||||
while (len--) {
|
||||
IPS200_WR(0);
|
||||
ips200_write_data((uint8)(*dat >> 8));
|
||||
IPS200_WR(1);
|
||||
@@ -366,20 +348,16 @@ static void ips200_debug_init (void)
|
||||
info.display_x_max = ips200_x_max;
|
||||
info.display_y_max = ips200_y_max;
|
||||
|
||||
switch(ips200_display_font)
|
||||
{
|
||||
case IPS200_6X8_FONT:
|
||||
{
|
||||
switch (ips200_display_font) {
|
||||
case IPS200_6X8_FONT: {
|
||||
info.font_x_size = 6;
|
||||
info.font_y_size = 8;
|
||||
} break;
|
||||
case IPS200_8X16_FONT:
|
||||
{
|
||||
case IPS200_8X16_FONT: {
|
||||
info.font_x_size = 8;
|
||||
info.font_y_size = 16;
|
||||
} break;
|
||||
case IPS200_16X16_FONT:
|
||||
{
|
||||
case IPS200_16X16_FONT: {
|
||||
// 暂不支持
|
||||
} break;
|
||||
}
|
||||
@@ -401,21 +379,17 @@ void ips200_clear (void)
|
||||
uint16 color_buffer[ips200_x_max];
|
||||
uint16 i = 0, j = 0;
|
||||
|
||||
if(IPS200_TYPE_SPI == ips200_display_type)
|
||||
{
|
||||
if (IPS200_TYPE_SPI == ips200_display_type) {
|
||||
IPS200_CS(0);
|
||||
}
|
||||
ips200_set_region(0, 0, ips200_x_max - 1, ips200_y_max - 1);
|
||||
for(i = 0; i < ips200_x_max; i ++)
|
||||
{
|
||||
for (i = 0; i < ips200_x_max; i++) {
|
||||
color_buffer[i] = ips200_bgcolor;
|
||||
}
|
||||
for (j = 0; j < ips200_y_max; j ++)
|
||||
{
|
||||
for (j = 0; j < ips200_y_max; j++) {
|
||||
ips200_write_16bit_data_array(color_buffer, ips200_x_max);
|
||||
}
|
||||
if(IPS200_TYPE_SPI == ips200_display_type)
|
||||
{
|
||||
if (IPS200_TYPE_SPI == ips200_display_type) {
|
||||
IPS200_CS(1);
|
||||
}
|
||||
}
|
||||
@@ -432,21 +406,17 @@ void ips200_full (const uint16 color)
|
||||
uint16 color_buffer[ips200_x_max];
|
||||
uint16 i = 0, j = 0;
|
||||
|
||||
if(IPS200_TYPE_SPI == ips200_display_type)
|
||||
{
|
||||
if (IPS200_TYPE_SPI == ips200_display_type) {
|
||||
IPS200_CS(0);
|
||||
}
|
||||
ips200_set_region(0, 0, ips200_x_max - 1, ips200_y_max - 1);
|
||||
for(i = 0; i < ips200_x_max; i ++)
|
||||
{
|
||||
for (i = 0; i < ips200_x_max; i++) {
|
||||
color_buffer[i] = color;
|
||||
}
|
||||
for (j = 0; j < ips200_y_max; j ++)
|
||||
{
|
||||
for (j = 0; j < ips200_y_max; j++) {
|
||||
ips200_write_16bit_data_array(color_buffer, ips200_x_max);
|
||||
}
|
||||
if(IPS200_TYPE_SPI == ips200_display_type)
|
||||
{
|
||||
if (IPS200_TYPE_SPI == ips200_display_type) {
|
||||
IPS200_CS(1);
|
||||
}
|
||||
}
|
||||
@@ -461,17 +431,14 @@ void ips200_full (const uint16 color)
|
||||
void ips200_set_dir(ips200_dir_enum dir)
|
||||
{
|
||||
ips200_display_dir = dir;
|
||||
switch(ips200_display_dir)
|
||||
{
|
||||
switch (ips200_display_dir) {
|
||||
case IPS200_PORTAIT:
|
||||
case IPS200_PORTAIT_180:
|
||||
{
|
||||
case IPS200_PORTAIT_180: {
|
||||
ips200_x_max = 240;
|
||||
ips200_y_max = 320;
|
||||
} break;
|
||||
case IPS200_CROSSWISE:
|
||||
case IPS200_CROSSWISE_180:
|
||||
{
|
||||
case IPS200_CROSSWISE_180: {
|
||||
ips200_x_max = 320;
|
||||
ips200_y_max = 240;
|
||||
} break;
|
||||
@@ -520,14 +487,12 @@ void ips200_draw_point (uint16 x, uint16 y, const uint16 color)
|
||||
zf_assert(x < ips200_x_max);
|
||||
zf_assert(y < ips200_y_max);
|
||||
|
||||
if(IPS200_TYPE_SPI == ips200_display_type)
|
||||
{
|
||||
if (IPS200_TYPE_SPI == ips200_display_type) {
|
||||
IPS200_CS(0);
|
||||
}
|
||||
ips200_set_region(x, y, x, y);
|
||||
ips200_write_16bit_data(color);
|
||||
if(IPS200_TYPE_SPI == ips200_display_type)
|
||||
{
|
||||
if (IPS200_TYPE_SPI == ips200_display_type) {
|
||||
IPS200_CS(1);
|
||||
}
|
||||
}
|
||||
@@ -557,37 +522,27 @@ void ips200_draw_line (uint16 x_start, uint16 y_start, uint16 x_end, uint16 y_en
|
||||
float temp_rate = 0;
|
||||
float temp_b = 0;
|
||||
|
||||
do
|
||||
{
|
||||
if(x_start != x_end)
|
||||
{
|
||||
do {
|
||||
if (x_start != x_end) {
|
||||
temp_rate = (float)(y_start - y_end) / (float)(x_start - x_end);
|
||||
temp_b = (float)y_start - (float)x_start * temp_rate;
|
||||
}
|
||||
else
|
||||
{
|
||||
while(y_start != y_end)
|
||||
{
|
||||
} else {
|
||||
while (y_start != y_end) {
|
||||
ips200_draw_point(x_start, y_start, color);
|
||||
y_start += y_dir;
|
||||
}
|
||||
ips200_draw_point(x_start, y_start, color);
|
||||
break;
|
||||
}
|
||||
if(func_abs(y_start - y_end) > func_abs(x_start - x_end))
|
||||
{
|
||||
while(y_start != y_end)
|
||||
{
|
||||
if (func_abs(y_start - y_end) > func_abs(x_start - x_end)) {
|
||||
while (y_start != y_end) {
|
||||
ips200_draw_point(x_start, y_start, color);
|
||||
y_start += y_dir;
|
||||
x_start = (int16)(((float)y_start - temp_b) / temp_rate);
|
||||
}
|
||||
ips200_draw_point(x_start, y_start, color);
|
||||
}
|
||||
else
|
||||
{
|
||||
while(x_start != x_end)
|
||||
{
|
||||
} else {
|
||||
while (x_start != x_end) {
|
||||
ips200_draw_point(x_start, y_start, color);
|
||||
x_start += x_dir;
|
||||
y_start = (int16)((float)x_start * temp_rate + temp_b);
|
||||
@@ -615,28 +570,20 @@ void ips200_show_char (uint16 x, uint16 y, const char dat)
|
||||
|
||||
uint8 i = 0, j = 0;
|
||||
|
||||
if(IPS200_TYPE_SPI == ips200_display_type)
|
||||
{
|
||||
if (IPS200_TYPE_SPI == ips200_display_type) {
|
||||
IPS200_CS(0);
|
||||
}
|
||||
switch(ips200_display_font)
|
||||
{
|
||||
case IPS200_6X8_FONT:
|
||||
{
|
||||
switch (ips200_display_font) {
|
||||
case IPS200_6X8_FONT: {
|
||||
uint16 display_buffer[6 * 8];
|
||||
ips200_set_region(x, y, x + 5, y + 7);
|
||||
for(i = 0; 6 > i; i ++)
|
||||
{
|
||||
for (i = 0; 6 > i; i++) {
|
||||
// 减 32 因为是取模是从空格开始取得 空格在 ascii 中序号是 32
|
||||
uint8 temp_top = ascii_font_6x8[dat - 32][i];
|
||||
for(j = 0; 8 > j; j ++)
|
||||
{
|
||||
if(temp_top & 0x01)
|
||||
{
|
||||
for (j = 0; 8 > j; j++) {
|
||||
if (temp_top & 0x01) {
|
||||
display_buffer[i + j * 6] = (ips200_pencolor);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
display_buffer[i + j * 6] = (ips200_bgcolor);
|
||||
}
|
||||
temp_top >>= 1;
|
||||
@@ -644,34 +591,24 @@ void ips200_show_char (uint16 x, uint16 y, const char dat)
|
||||
}
|
||||
ips200_write_16bit_data_array(display_buffer, 6 * 8);
|
||||
} break;
|
||||
case IPS200_8X16_FONT:
|
||||
{
|
||||
case IPS200_8X16_FONT: {
|
||||
uint16 display_buffer[8 * 16];
|
||||
ips200_set_region(x, y, x + 7, y + 15);
|
||||
for(i = 0; 8 > i; i ++)
|
||||
{
|
||||
for (i = 0; 8 > i; i++) {
|
||||
uint8 temp_top = ascii_font_8x16[dat - 32][i];
|
||||
uint8 temp_bottom = ascii_font_8x16[dat - 32][i + 8];
|
||||
for(j = 0; 8 > j; j ++)
|
||||
{
|
||||
if(temp_top & 0x01)
|
||||
{
|
||||
for (j = 0; 8 > j; j++) {
|
||||
if (temp_top & 0x01) {
|
||||
display_buffer[i + j * 8] = (ips200_pencolor);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
display_buffer[i + j * 8] = (ips200_bgcolor);
|
||||
}
|
||||
temp_top >>= 1;
|
||||
}
|
||||
for(j = 0; 8 > j; j ++)
|
||||
{
|
||||
if(temp_bottom & 0x01)
|
||||
{
|
||||
for (j = 0; 8 > j; j++) {
|
||||
if (temp_bottom & 0x01) {
|
||||
display_buffer[i + j * 8 + 4 * 16] = (ips200_pencolor);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
display_buffer[i + j * 8 + 4 * 16] = (ips200_bgcolor);
|
||||
}
|
||||
temp_bottom >>= 1;
|
||||
@@ -679,13 +616,11 @@ void ips200_show_char (uint16 x, uint16 y, const char dat)
|
||||
}
|
||||
ips200_write_16bit_data_array(display_buffer, 8 * 16);
|
||||
} break;
|
||||
case IPS200_16X16_FONT:
|
||||
{
|
||||
case IPS200_16X16_FONT: {
|
||||
// 暂不支持
|
||||
} break;
|
||||
}
|
||||
if(IPS200_TYPE_SPI == ips200_display_type)
|
||||
{
|
||||
if (IPS200_TYPE_SPI == ips200_display_type) {
|
||||
IPS200_CS(1);
|
||||
}
|
||||
}
|
||||
@@ -707,13 +642,16 @@ void ips200_show_string (uint16 x, uint16 y, const char dat[])
|
||||
zf_assert(y < ips200_y_max);
|
||||
|
||||
uint16 j = 0;
|
||||
while('\0' != dat[j])
|
||||
{
|
||||
switch(ips200_display_font)
|
||||
{
|
||||
case IPS200_6X8_FONT: ips200_show_char(x + 6 * j, y, dat[j]); break;
|
||||
case IPS200_8X16_FONT: ips200_show_char(x + 8 * j, y, dat[j]); break;
|
||||
case IPS200_16X16_FONT: break; // 暂不支持
|
||||
while ('\0' != dat[j]) {
|
||||
switch (ips200_display_font) {
|
||||
case IPS200_6X8_FONT:
|
||||
ips200_show_char(x + 6 * j, y, dat[j]);
|
||||
break;
|
||||
case IPS200_8X16_FONT:
|
||||
ips200_show_char(x + 8 * j, y, dat[j]);
|
||||
break;
|
||||
case IPS200_16X16_FONT:
|
||||
break; // 暂不支持
|
||||
}
|
||||
j++;
|
||||
}
|
||||
@@ -746,10 +684,8 @@ void ips200_show_int (uint16 x, uint16 y, const int32 dat, uint8 num)
|
||||
memset(data_buffer, ' ', num + 1);
|
||||
|
||||
// 用来计算余数显示 123 显示 2 位则应该显示 23
|
||||
if(10 > num)
|
||||
{
|
||||
for(; 0 < num; num --)
|
||||
{
|
||||
if (10 > num) {
|
||||
for (; 0 < num; num--) {
|
||||
offset *= 10;
|
||||
}
|
||||
dat_temp %= offset;
|
||||
@@ -784,10 +720,8 @@ void ips200_show_uint (uint16 x, uint16 y, const uint32 dat, uint8 num)
|
||||
memset(data_buffer, ' ', num);
|
||||
|
||||
// 用来计算余数显示 123 显示 2 位则应该显示 23
|
||||
if(10 > num)
|
||||
{
|
||||
for(; 0 < num; num --)
|
||||
{
|
||||
if (10 > num) {
|
||||
for (; 0 < num; num--) {
|
||||
offset *= 10;
|
||||
}
|
||||
dat_temp %= offset;
|
||||
@@ -828,8 +762,7 @@ void ips200_show_float (uint16 x, uint16 y, const double dat, uint8 num, uint8 p
|
||||
memset(data_buffer, ' ', num + pointnum + 2);
|
||||
|
||||
// 用来计算余数显示 123 显示 2 位则应该显示 23
|
||||
for(; 0 < num; num --)
|
||||
{
|
||||
for (; 0 < num; num--) {
|
||||
offset *= 10;
|
||||
}
|
||||
dat_temp = dat_temp - ((int)dat_temp / (int)offset) * offset;
|
||||
@@ -867,32 +800,25 @@ void ips200_show_binary_image (uint16 x, uint16 y, const uint8 *image, uint16 wi
|
||||
uint16 data_buffer[dis_width];
|
||||
const uint8 *image_temp;
|
||||
|
||||
if(IPS200_TYPE_SPI == ips200_display_type)
|
||||
{
|
||||
if (IPS200_TYPE_SPI == ips200_display_type) {
|
||||
IPS200_CS(0);
|
||||
}
|
||||
ips200_set_region(x, y, x + dis_width - 1, y + dis_height - 1); // 设置显示区域
|
||||
|
||||
for(j = 0; j < dis_height; j ++)
|
||||
{
|
||||
for (j = 0; j < dis_height; j++) {
|
||||
image_temp = image + j * height / dis_height * width / 8; // 直接对 image 操作会 Hardfault 暂时不知道为什么
|
||||
for(i = 0; i < dis_width; i ++)
|
||||
{
|
||||
for (i = 0; i < dis_width; i++) {
|
||||
width_index = i * width / dis_width;
|
||||
temp = *(image_temp + width_index / 8); // 读取像素点
|
||||
if(0x80 & (temp << (width_index % 8)))
|
||||
{
|
||||
if (0x80 & (temp << (width_index % 8))) {
|
||||
data_buffer[i] = (RGB565_WHITE);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
data_buffer[i] = (RGB565_BLACK);
|
||||
}
|
||||
}
|
||||
ips200_write_16bit_data_array(data_buffer, dis_width);
|
||||
}
|
||||
if(IPS200_TYPE_SPI == ips200_display_type)
|
||||
{
|
||||
if (IPS200_TYPE_SPI == ips200_display_type) {
|
||||
IPS200_CS(1);
|
||||
}
|
||||
}
|
||||
@@ -927,38 +853,29 @@ void ips200_show_gray_image (uint16 x, uint16 y, const uint8 *image, uint16 widt
|
||||
uint16 data_buffer[dis_width];
|
||||
const uint8 *image_temp;
|
||||
|
||||
if(IPS200_TYPE_SPI == ips200_display_type)
|
||||
{
|
||||
if (IPS200_TYPE_SPI == ips200_display_type) {
|
||||
IPS200_CS(0);
|
||||
}
|
||||
ips200_set_region(x, y, x + dis_width - 1, y + dis_height - 1); // 设置显示区域
|
||||
|
||||
for(j = 0; j < dis_height; j ++)
|
||||
{
|
||||
for (j = 0; j < dis_height; j++) {
|
||||
image_temp = image + j * height / dis_height * width; // 直接对 image 操作会 Hardfault 暂时不知道为什么
|
||||
for(i = 0; i < dis_width; i ++)
|
||||
{
|
||||
for (i = 0; i < dis_width; i++) {
|
||||
temp = *(image_temp + i * width / dis_width); // 读取像素点
|
||||
if(threshold == 0)
|
||||
{
|
||||
if (threshold == 0) {
|
||||
color = (0x001f & ((temp) >> 3)) << 11;
|
||||
color = color | (((0x003f) & ((temp) >> 2)) << 5);
|
||||
color = color | (0x001f & ((temp) >> 3));
|
||||
data_buffer[i] = (color);
|
||||
}
|
||||
else if(temp < threshold)
|
||||
{
|
||||
} else if (temp < threshold) {
|
||||
data_buffer[i] = (RGB565_BLACK);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
data_buffer[i] = (RGB565_WHITE);
|
||||
}
|
||||
}
|
||||
ips200_write_16bit_data_array(data_buffer, dis_width);
|
||||
}
|
||||
if(IPS200_TYPE_SPI == ips200_display_type)
|
||||
{
|
||||
if (IPS200_TYPE_SPI == ips200_display_type) {
|
||||
IPS200_CS(1);
|
||||
}
|
||||
}
|
||||
@@ -992,30 +909,23 @@ void ips200_show_rgb565_image (uint16 x, uint16 y, const uint16 *image, uint16 w
|
||||
uint16 data_buffer[dis_width];
|
||||
const uint16 *image_temp;
|
||||
|
||||
if(IPS200_TYPE_SPI == ips200_display_type)
|
||||
{
|
||||
if (IPS200_TYPE_SPI == ips200_display_type) {
|
||||
IPS200_CS(0);
|
||||
}
|
||||
ips200_set_region(x, y, x + dis_width - 1, y + dis_height - 1); // 设置显示区域
|
||||
|
||||
for(j = 0; j < dis_height; j ++)
|
||||
{
|
||||
for (j = 0; j < dis_height; j++) {
|
||||
image_temp = image + j * height / dis_height * width; // 直接对 image 操作会 Hardfault 暂时不知道为什么
|
||||
for(i = 0; i < dis_width; i ++)
|
||||
{
|
||||
for (i = 0; i < dis_width; i++) {
|
||||
data_buffer[i] = *(image_temp + i * width / dis_width); // 读取像素点
|
||||
}
|
||||
if(color_mode)
|
||||
{
|
||||
if (color_mode) {
|
||||
ips200_write_8bit_data_array((uint8 *)data_buffer, dis_width * 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
ips200_write_16bit_data_array(data_buffer, dis_width);
|
||||
}
|
||||
}
|
||||
if(IPS200_TYPE_SPI == ips200_display_type)
|
||||
{
|
||||
if (IPS200_TYPE_SPI == ips200_display_type) {
|
||||
IPS200_CS(1);
|
||||
}
|
||||
}
|
||||
@@ -1045,27 +955,21 @@ void ips200_show_wave (uint16 x, uint16 y, const uint16 *wave, uint16 width, uin
|
||||
uint32 width_index = 0, value_max_index = 0;
|
||||
uint16 data_buffer[dis_width];
|
||||
|
||||
|
||||
if(IPS200_TYPE_SPI == ips200_display_type)
|
||||
{
|
||||
if (IPS200_TYPE_SPI == ips200_display_type) {
|
||||
IPS200_CS(0);
|
||||
}
|
||||
ips200_set_region(x, y, x + dis_width - 1, y + dis_value_max - 1); // 设置显示区域
|
||||
for(j = 0; j < dis_value_max; j ++)
|
||||
{
|
||||
for(i = 0; i < dis_width; i ++)
|
||||
{
|
||||
for (j = 0; j < dis_value_max; j++) {
|
||||
for (i = 0; i < dis_width; i++) {
|
||||
data_buffer[i] = (ips200_bgcolor);
|
||||
}
|
||||
ips200_write_16bit_data_array(data_buffer, dis_width);
|
||||
}
|
||||
if(IPS200_TYPE_SPI == ips200_display_type)
|
||||
{
|
||||
if (IPS200_TYPE_SPI == ips200_display_type) {
|
||||
IPS200_CS(1);
|
||||
}
|
||||
|
||||
for(i = 0; i < dis_width; i ++)
|
||||
{
|
||||
for (i = 0; i < dis_width; i++) {
|
||||
width_index = i * width / dis_width;
|
||||
value_max_index = *(wave + width_index) * (dis_value_max - 1) / value_max;
|
||||
ips200_draw_point(i + x, (dis_value_max - 1) - value_max_index + y, ips200_pencolor);
|
||||
@@ -1098,29 +1002,21 @@ void ips200_show_chinese (uint16 x, uint16 y, uint8 size, const uint8 *chinese_b
|
||||
|
||||
temp2 = size / 8;
|
||||
|
||||
if(IPS200_TYPE_SPI == ips200_display_type)
|
||||
{
|
||||
if (IPS200_TYPE_SPI == ips200_display_type) {
|
||||
IPS200_CS(0);
|
||||
}
|
||||
ips200_set_region(x, y, number * size - 1 + x, y + size - 1);
|
||||
|
||||
for(i = 0; i < size; i ++)
|
||||
{
|
||||
for (i = 0; i < size; i++) {
|
||||
temp1 = number;
|
||||
p_data = chinese_buffer + i * temp2;
|
||||
while(temp1 --)
|
||||
{
|
||||
for(k = 0; k < temp2; k ++)
|
||||
{
|
||||
for(j = 8; 0 < j; j --)
|
||||
{
|
||||
while (temp1--) {
|
||||
for (k = 0; k < temp2; k++) {
|
||||
for (j = 8; 0 < j; j--) {
|
||||
temp = (*p_data >> (j - 1)) & 0x01;
|
||||
if(temp)
|
||||
{
|
||||
if (temp) {
|
||||
ips200_write_16bit_data(color);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
ips200_write_16bit_data(ips200_bgcolor);
|
||||
}
|
||||
}
|
||||
@@ -1129,8 +1025,7 @@ void ips200_show_chinese (uint16 x, uint16 y, uint8 size, const uint8 *chinese_b
|
||||
p_data = p_data - temp2 + temp2 * size;
|
||||
}
|
||||
}
|
||||
if(IPS200_TYPE_SPI == ips200_display_type)
|
||||
{
|
||||
if (IPS200_TYPE_SPI == ips200_display_type) {
|
||||
IPS200_CS(1);
|
||||
}
|
||||
}
|
||||
@@ -1144,8 +1039,7 @@ void ips200_show_chinese (uint16 x, uint16 y, uint8 size, const uint8 *chinese_b
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
void ips200_init(ips200_type_enum type_select)
|
||||
{
|
||||
if(IPS200_TYPE_SPI == type_select)
|
||||
{
|
||||
if (IPS200_TYPE_SPI == type_select) {
|
||||
ips200_display_type = IPS200_TYPE_SPI;
|
||||
ips_rst_pin = IPS200_RST_PIN_SPI;
|
||||
ips_bl_pin = IPS200_BLk_PIN_SPI;
|
||||
@@ -1160,9 +1054,7 @@ void ips200_init (ips200_type_enum type_select)
|
||||
gpio_init(ips_rst_pin, GPO, GPIO_LOW, GPO_PUSH_PULL);
|
||||
gpio_init(IPS200_CS_PIN_SPI, GPO, GPIO_LOW, GPO_PUSH_PULL);
|
||||
gpio_init(ips_bl_pin, GPO, GPIO_HIGH, GPO_PUSH_PULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
ips200_display_type = IPS200_TYPE_PARALLEL8;
|
||||
ips_rst_pin = IPS200_RST_PIN_PARALLEL8;
|
||||
ips_bl_pin = IPS200_BL_PIN_PARALLEL8;
|
||||
@@ -1185,8 +1077,7 @@ void ips200_init (ips200_type_enum type_select)
|
||||
uint8 i = 0;
|
||||
uint8 pin_value = (((uint32)IPS200_DATAPORT - GPIOA_BASE) / 0x400) * 0x20 + DATA_START_NUM; // 获取端口的枚举体值
|
||||
|
||||
for(i = 0;i < 8;i++)
|
||||
{
|
||||
for (i = 0; i < 8; i++) {
|
||||
gpio_init((gpio_pin_enum)(pin_value + i), GPO, 0, GPO_PUSH_PULL);
|
||||
}
|
||||
}
|
||||
@@ -1200,20 +1091,26 @@ void ips200_init (ips200_type_enum type_select)
|
||||
IPS200_RST(1);
|
||||
system_delay_ms(120);
|
||||
|
||||
if(IPS200_TYPE_SPI == ips200_display_type)
|
||||
{
|
||||
if (IPS200_TYPE_SPI == ips200_display_type) {
|
||||
IPS200_CS(0);
|
||||
}
|
||||
ips200_write_command(0x11);
|
||||
system_delay_ms(120);
|
||||
|
||||
ips200_write_command(0x36);
|
||||
switch(ips200_display_dir)
|
||||
{
|
||||
case IPS200_PORTAIT: ips200_write_8bit_data(0x00); break;
|
||||
case IPS200_PORTAIT_180: ips200_write_8bit_data(0xC0); break;
|
||||
case IPS200_CROSSWISE: ips200_write_8bit_data(0x70); break;
|
||||
case IPS200_CROSSWISE_180: ips200_write_8bit_data(0xA0); break;
|
||||
switch (ips200_display_dir) {
|
||||
case IPS200_PORTAIT:
|
||||
ips200_write_8bit_data(0x00);
|
||||
break;
|
||||
case IPS200_PORTAIT_180:
|
||||
ips200_write_8bit_data(0xC0);
|
||||
break;
|
||||
case IPS200_CROSSWISE:
|
||||
ips200_write_8bit_data(0x70);
|
||||
break;
|
||||
case IPS200_CROSSWISE_180:
|
||||
ips200_write_8bit_data(0xA0);
|
||||
break;
|
||||
}
|
||||
|
||||
ips200_write_command(0x3A);
|
||||
@@ -1286,8 +1183,7 @@ void ips200_init (ips200_type_enum type_select)
|
||||
ips200_write_command(0x21);
|
||||
|
||||
ips200_write_command(0x29);
|
||||
if(IPS200_TYPE_SPI == ips200_display_type)
|
||||
{
|
||||
if (IPS200_TYPE_SPI == ips200_display_type) {
|
||||
IPS200_CS(1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user