feat: 新增边线显示控件(未测试)
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_ */
|
||||||
|
|||||||
44
app/main.c
44
app/main.c
@@ -34,23 +34,23 @@
|
|||||||
********************************************************************************************************************/
|
********************************************************************************************************************/
|
||||||
#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 "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]; // <20><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD> MT9V03X_W <20>е<EFBFBD> uint8_t <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>
|
// uint8_t *mt9v03x_image_copy[0]; // <20><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8> uint8_t <20><><EFBFBD>͵<EFBFBD>һά<D2BB><CEAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
|
||||||
sint32 pts_left[PT_MAXLEN][2], pts_right[PT_MAXLEN][2];
|
int32_t pts_left[PT_MAXLEN][2], 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>
|
// <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];
|
||||||
@@ -85,25 +85,26 @@ float aim_distance;
|
|||||||
|
|
||||||
enum track_type_e track_type = TRACK_RIGHT;
|
enum track_type_e track_type = TRACK_RIGHT;
|
||||||
|
|
||||||
|
|
||||||
int frame_count = 0;
|
int frame_count = 0;
|
||||||
|
|
||||||
void img_processing();
|
void img_processing();
|
||||||
void get_corners();
|
void get_corners();
|
||||||
|
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
clock_init(SYSTEM_CLOCK_120M); // <20><>ʼ<EFBFBD><CABC>оƬʱ<C6AC><CAB1> <20><><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>Ϊ 120MHz
|
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>
|
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();
|
mt9v03x_init();
|
||||||
ips114_init();
|
ips200_init(IPS200_TYPE_SPI);
|
||||||
by_gpio_init();
|
by_gpio_init();
|
||||||
by_exit_init();
|
by_exit_init();
|
||||||
by_pwm_init();
|
by_pwm_init();
|
||||||
cw_servo_init();
|
cw_servo_init();
|
||||||
|
|
||||||
|
Page_Init();
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
Page_Run();
|
||||||
// while (frame_count < 20) {
|
// while (frame_count < 20) {
|
||||||
// if (mt9v03x_finish_flag) {
|
// if (mt9v03x_finish_flag) {
|
||||||
// memcpy(mt9v03x_image_copy[0], mt9v03x_image[0], (sizeof(mt9v03x_image_copy) / sizeof(uint8_t)));
|
// memcpy(mt9v03x_image_copy[0], mt9v03x_image[0], (sizeof(mt9v03x_image_copy) / sizeof(uint8_t)));
|
||||||
@@ -113,11 +114,12 @@ int main(void)
|
|||||||
// mt9v03x_finish_flag = 0;
|
// mt9v03x_finish_flag = 0;
|
||||||
// frame_count++;
|
// frame_count++;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
/************************ ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>غ<EFBFBD><D8BA><EFBFBD> ***************************/
|
||||||
if (mt9v03x_finish_flag) {
|
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)));
|
memcpy(mt9v03x_image_copy[0], mt9v03x_image[0], (sizeof(mt9v03x_image_copy) / sizeof(uint8_t)));
|
||||||
|
// ips114_show_gray_image(0, 0, mt9v03x_image[0], 188, 120, 188, 120,0);
|
||||||
// Img_Gray = mt9v03x_image;
|
// Img_Gray = mt9v03x_image;
|
||||||
// mt9v03x_image_copy[0] = Img_Gray[0];
|
// mt9v03x_image_copy[0] = Img_Gray[0];
|
||||||
mt9v03x_finish_flag = 0;
|
mt9v03x_finish_flag = 0;
|
||||||
@@ -130,9 +132,7 @@ int main(void)
|
|||||||
ElementJudge();
|
ElementJudge();
|
||||||
ElementRun();
|
ElementRun();
|
||||||
MidLineTrack();
|
MidLineTrack();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/************************ ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>غ<EFBFBD><D8BA><EFBFBD> ***************************/
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
28
app/main.h
28
app/main.h
@@ -2,32 +2,29 @@
|
|||||||
#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 sint32 pts_left[PT_MAXLEN][2], pts_right[PT_MAXLEN][2]; //0:H,1:W
|
extern int32_t pts_left[PT_MAXLEN][2], pts_right[PT_MAXLEN][2]; // 0:H,1:W
|
||||||
extern sint32 pts_left_count, pts_right_count;
|
extern int32_t pts_left_count, pts_right_count;
|
||||||
extern float32 pts_inv_l[PT_MAXLEN][2], pts_inv_r[PT_MAXLEN][2];
|
extern float pts_inv_l[PT_MAXLEN][2], pts_inv_r[PT_MAXLEN][2];
|
||||||
extern sint32 pts_inv_l_count, pts_inv_r_count;
|
extern int32_t pts_inv_l_count, pts_inv_r_count;
|
||||||
extern float32 pts_filter_l[PT_MAXLEN][2], pts_filter_r[PT_MAXLEN][2];
|
extern float pts_filter_l[PT_MAXLEN][2], pts_filter_r[PT_MAXLEN][2];
|
||||||
extern sint32 pts_filter_l_count, pts_filter_r_count;
|
extern int32_t pts_filter_l_count, pts_filter_r_count;
|
||||||
extern float32 pts_resample_left[PT_MAXLEN][2], pts_resample_right[PT_MAXLEN][2];
|
extern float 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_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];
|
||||||
@@ -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,
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#include "cw_page.h"
|
#include "cw_page.h"
|
||||||
|
|
||||||
PAGE_LIST pagelist[page_max];
|
PAGE_LIST pagelist[page_max];
|
||||||
static uint8 page_busy = 0;
|
static uint8_t page_busy = 0;
|
||||||
static int8 now_page = page_menu;
|
static int8_t now_page = page_menu;
|
||||||
static int8 new_page = page_menu;
|
static int8_t new_page = page_menu;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 注册一个基本页面,包含一个初始化函数,循环函数,退出函数,事件函数
|
* @brief 注册一个基本页面,包含一个初始化函数,循环函数,退出函数,事件函数
|
||||||
@@ -15,7 +15,7 @@ static int8 new_page = page_menu;
|
|||||||
* @param eventCallback: 事件函数回调
|
* @param eventCallback: 事件函数回调
|
||||||
* @retval 无
|
* @retval 无
|
||||||
*/
|
*/
|
||||||
void Page_Register(uint8 pageID, char *pageText,
|
void Page_Register(uint8_t pageID, char *pageText,
|
||||||
CallbackFunction_t setupCallback, CallbackFunction_t loopCallback,
|
CallbackFunction_t setupCallback, CallbackFunction_t loopCallback,
|
||||||
CallbackFunction_t exitCallback, EventFunction_t eventCallback) {
|
CallbackFunction_t exitCallback, EventFunction_t eventCallback) {
|
||||||
pagelist[pageID].Text = pageText;
|
pagelist[pageID].Text = pageText;
|
||||||
@@ -66,9 +66,9 @@ void Page_OpenCurrentPage() {
|
|||||||
/**
|
/**
|
||||||
* @brief 获取页面状态
|
* @brief 获取页面状态
|
||||||
*
|
*
|
||||||
* @return uint8 页面忙返回1 空闲返回0
|
* @return uint8_t 页面忙返回1 空闲返回0
|
||||||
*/
|
*/
|
||||||
uint8 Page_GetStatus(void) {
|
uint8_t Page_GetStatus(void) {
|
||||||
if (page_busy)
|
if (page_busy)
|
||||||
return 1;
|
return 1;
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ do{\
|
|||||||
PageRegister_##name(name);\
|
PageRegister_##name(name);\
|
||||||
}while(0)
|
}while(0)
|
||||||
|
|
||||||
void Page_Register(uint8 pageID, char *pageText,
|
void Page_Register(uint8_t pageID, char *pageText,
|
||||||
CallbackFunction_t setupCallback, CallbackFunction_t loopCallback,
|
CallbackFunction_t setupCallback, CallbackFunction_t loopCallback,
|
||||||
CallbackFunction_t exitCallback, EventFunction_t eventCallback);
|
CallbackFunction_t exitCallback, EventFunction_t eventCallback);
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ void Page_EventTransmit(unsigned char event);
|
|||||||
void Page_Shift(unsigned char pageID);
|
void Page_Shift(unsigned char pageID);
|
||||||
void Page_CloseCurrentPage(void);
|
void Page_CloseCurrentPage(void);
|
||||||
void Page_OpenCurrentPage(void);
|
void Page_OpenCurrentPage(void);
|
||||||
uint8 Page_GetStatus(void);
|
uint8_t Page_GetStatus(void);
|
||||||
void Page_Run(void);
|
void Page_Run(void);
|
||||||
void Page_Init(void);
|
void Page_Init(void);
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ static void Exit()
|
|||||||
*/
|
*/
|
||||||
static void Loop()
|
static void Loop()
|
||||||
{
|
{
|
||||||
|
Show_Marked_Image();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -98,9 +99,9 @@ void PageRegister_page_menu(unsigned char pageID)
|
|||||||
static void Print_Menu_p(void)
|
static void Print_Menu_p(void)
|
||||||
{
|
{
|
||||||
// SCREEN_showstr_style(5 * 8, 0, RED, WHITE, "#### MAIN MENU ####");
|
// SCREEN_showstr_style(5 * 8, 0, RED, WHITE, "#### MAIN MENU ####");
|
||||||
ips114_show_string(0, 0, Text);
|
ips200_show_string(0, 0, Text);
|
||||||
for (uint8 i = page_menu + 1; i < page_max; i++) {
|
for (uint8_t i = page_menu + 1; i < page_max; i++) {
|
||||||
ips114_show_string(8, i, pagelist[i].Text);
|
ips200_show_string(8, i, pagelist[i].Text);
|
||||||
// SCREEN_showstr(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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
#include "cw_page_ui_widget.h"
|
#include "cw_page_ui_widget.h"
|
||||||
|
#include "zf_common_headfile.h"
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 绘制光标
|
* @brief 绘制光标
|
||||||
@@ -6,19 +8,21 @@
|
|||||||
* @param Curser_In 当前光标位置
|
* @param Curser_In 当前光标位置
|
||||||
* @param Curser_Last_In 上一时刻光标位置
|
* @param Curser_Last_In 上一时刻光标位置
|
||||||
*/
|
*/
|
||||||
void Print_Curser(uint8 Curser_In, uint8 Curser_Last_In) {
|
void Print_Curser(uint8_t Curser_In, uint8_t Curser_Last_In)
|
||||||
ips114_show_string(0, Curser_Last_In, " ");
|
{
|
||||||
ips114_show_string(0, Curser_In, ">");
|
ips200_show_string(0, Curser_Last_In * 16, " ");
|
||||||
|
ips200_show_string(0, Curser_In * 16, ">");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 打印菜单项
|
* @brief 打印菜单项
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void Print_Menu(const ITEM *item, uint8 item_sum) {
|
void Print_Menu(const ITEM *item, uint8_t item_sum)
|
||||||
ips114_show_string(0, 0, " --return--");
|
{
|
||||||
for (uint8 i = 0; i < item_sum; i++) {
|
ips200_show_string(0, 0, " --return--");
|
||||||
ips114_show_string(8, i + 1, item[i].text);
|
for (uint8_t i = 0; i < item_sum; i++) {
|
||||||
|
ips200_show_string(8, i * 16 + 16, item[i].text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,34 +30,35 @@ void Print_Menu(const ITEM *item, uint8 item_sum) {
|
|||||||
* @brief 打印数值项
|
* @brief 打印数值项
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void Print_Value(const ITEM *item, uint8 item_sum) {
|
void Print_Value(const ITEM *item, uint8_t item_sum)
|
||||||
// for (uint8 i = 0; i < item_sum; i++) {
|
{
|
||||||
|
// for (uint8_t i = 0; i < item_sum; i++) {
|
||||||
// switch (Param_Data[item[i].data_tag].type) {
|
// switch (Param_Data[item[i].data_tag].type) {
|
||||||
// case EINT8:
|
// case EINT8:
|
||||||
// ips114_show_int(128, i + 1,
|
// ips200_show_int(128, i + 1,
|
||||||
// *((int8 *)Param_Data[item[i].data_tag].p_data), 5);
|
// *((int8_t *)Param_Data[item[i].data_tag].p_data), 5);
|
||||||
// break;
|
// break;
|
||||||
// case EINT16:
|
// case EINT16:
|
||||||
// ips114_show_int(128, i + 1,
|
// ips200_show_int(128, i + 1,
|
||||||
// *((int16 *)Param_Data[item[i].data_tag].p_data), 5);
|
// *((int16_t *)Param_Data[item[i].data_tag].p_data), 5);
|
||||||
// break;
|
// break;
|
||||||
// case EINT32:
|
// case EINT32:
|
||||||
// ips114_show_int(128, i + 1,
|
// ips200_show_int(128, i + 1,
|
||||||
// *((int32 *)Param_Data[item[i].data_tag].p_data), 5);
|
// *((int32_t *)Param_Data[item[i].data_tag].p_data), 5);
|
||||||
// break;
|
// break;
|
||||||
// case EUINT8:
|
// case EUINT8:
|
||||||
// ips114_show_int(128, i + 1,
|
// ips200_show_int(128, i + 1,
|
||||||
// *((uint8 *)Param_Data[item[i].data_tag].p_data), 5);
|
// *((uint8_t *)Param_Data[item[i].data_tag].p_data), 5);
|
||||||
// break;
|
// break;
|
||||||
// case EUINT16:
|
// case EUINT16:
|
||||||
// ips114_show_int(128, i + 1,
|
// ips200_show_int(128, i + 1,
|
||||||
// *((uint16 *)Param_Data[item[i].data_tag].p_data), 5);
|
// *((uint16_t *)Param_Data[item[i].data_tag].p_data), 5);
|
||||||
// break;
|
// break;
|
||||||
// case EUINT32:
|
// case EUINT32:
|
||||||
// ips114_show_int(128, i + 1,
|
// ips200_show_int(128, i + 1,
|
||||||
// *((uint32 *)Param_Data[item[i].data_tag].p_data), 5);
|
// *((uint32_t *)Param_Data[item[i].data_tag].p_data), 5);
|
||||||
// case EFLOAT:
|
// case EFLOAT:
|
||||||
// ips114_show_float(128, i + 1,
|
// ips200_show_float(128, i + 1,
|
||||||
// *((float *)Param_Data[item[i].data_tag].p_data), 5, 2);
|
// *((float *)Param_Data[item[i].data_tag].p_data), 5, 2);
|
||||||
// break;
|
// break;
|
||||||
// default:
|
// default:
|
||||||
@@ -68,11 +73,12 @@ void Print_Value(const ITEM *item, uint8 item_sum) {
|
|||||||
* @param item_num
|
* @param item_num
|
||||||
* @param dir
|
* @param dir
|
||||||
*/
|
*/
|
||||||
void Set_Vaule(ITEM *item, uint8 item_num, float step) {
|
void Set_Vaule(ITEM *item, uint8_t item_num, float step)
|
||||||
|
{
|
||||||
|
|
||||||
// if (EFLOAT == Param_Data[item[item_num].data_tag].type) { // 待修改变量为浮点
|
// if (EFLOAT == Param_Data[item[item_num].data_tag].type) { // 待修改变量为浮点
|
||||||
// *((float *)Param_Data[item[item_num].data_tag].p_data) += step;
|
// *((float *)Param_Data[item[item_num].data_tag].p_data) += step;
|
||||||
// ips114_show_float(128, item_num + 1,
|
// ips200_show_float(128, item_num + 1,
|
||||||
// *((float *)Param_Data[item[item_num].data_tag].p_data), 6,
|
// *((float *)Param_Data[item[item_num].data_tag].p_data), 6,
|
||||||
// 2);
|
// 2);
|
||||||
// return;
|
// return;
|
||||||
@@ -87,37 +93,58 @@ void Set_Vaule(ITEM *item, uint8 item_num, float step) {
|
|||||||
|
|
||||||
// switch (Param_Data[item[item_num].data_tag].type) {
|
// switch (Param_Data[item[item_num].data_tag].type) {
|
||||||
// case EINT8:
|
// case EINT8:
|
||||||
// *((int8 *)Param_Data[item[item_num].data_tag].p_data) += (int8)step;
|
// *((int8_t *)Param_Data[item[item_num].data_tag].p_data) += (int8_t)step;
|
||||||
// ips114_show_int(128, item_num + 1,
|
// ips200_show_int(128, item_num + 1,
|
||||||
// *((int8 *)Param_Data[item[item_num].data_tag].p_data), 5);
|
// *((int8_t *)Param_Data[item[item_num].data_tag].p_data), 5);
|
||||||
// break;
|
// break;
|
||||||
// case EINT16:
|
// case EINT16:
|
||||||
// *((int16 *)Param_Data[item[item_num].data_tag].p_data) += (int16)step;
|
// *((int16_t *)Param_Data[item[item_num].data_tag].p_data) += (int16_t)step;
|
||||||
// ips114_show_int(128, item_num + 1,
|
// ips200_show_int(128, item_num + 1,
|
||||||
// *((int16 *)Param_Data[item[item_num].data_tag].p_data), 5);
|
// *((int16_t *)Param_Data[item[item_num].data_tag].p_data), 5);
|
||||||
// break;
|
// break;
|
||||||
// case EINT32:
|
// case EINT32:
|
||||||
// *((int32 *)Param_Data[item[item_num].data_tag].p_data) += (int32)step;
|
// *((int32_t *)Param_Data[item[item_num].data_tag].p_data) += (int32_t)step;
|
||||||
// ips114_show_int(128, item_num + 1,
|
// ips200_show_int(128, item_num + 1,
|
||||||
// *((int32 *)Param_Data[item[item_num].data_tag].p_data), 5);
|
// *((int32_t *)Param_Data[item[item_num].data_tag].p_data), 5);
|
||||||
// break;
|
// break;
|
||||||
// case EUINT8:
|
// case EUINT8:
|
||||||
// *((uint8 *)Param_Data[item[item_num].data_tag].p_data) += (uint8)step;
|
// *((uint8_t *)Param_Data[item[item_num].data_tag].p_data) += (uint8_t)step;
|
||||||
// ips114_show_int(128, item_num + 1,
|
// ips200_show_int(128, item_num + 1,
|
||||||
// *((uint8 *)Param_Data[item[item_num].data_tag].p_data), 5);
|
// *((uint8_t *)Param_Data[item[item_num].data_tag].p_data), 5);
|
||||||
// break;
|
// break;
|
||||||
// case EUINT16:
|
// case EUINT16:
|
||||||
// *((uint16 *)Param_Data[item[item_num].data_tag].p_data) += (uint16)step;
|
// *((uint16_t *)Param_Data[item[item_num].data_tag].p_data) += (uint16_t)step;
|
||||||
// ips114_show_int(128, item_num + 1,
|
// ips200_show_int(128, item_num + 1,
|
||||||
// *((uint16 *)Param_Data[item[item_num].data_tag].p_data), 5);
|
// *((uint16_t *)Param_Data[item[item_num].data_tag].p_data), 5);
|
||||||
// break;
|
// break;
|
||||||
// case EUINT32:
|
// case EUINT32:
|
||||||
// *((uint32 *)Param_Data[item[item_num].data_tag].p_data) += (uint32)step;
|
// *((uint32_t *)Param_Data[item[item_num].data_tag].p_data) += (uint32_t)step;
|
||||||
// ips114_show_int(128, item_num + 1,
|
// ips200_show_int(128, item_num + 1,
|
||||||
// *((uint32 *)Param_Data[item[item_num].data_tag].p_data), 5);
|
// *((uint32_t *)Param_Data[item[item_num].data_tag].p_data), 5);
|
||||||
// break;
|
// break;
|
||||||
// default:
|
// default:
|
||||||
// break;
|
// 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
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,12 +5,13 @@
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *text; //变量显示名
|
char *text; //变量显示名
|
||||||
uint8 data_tag; //变量结构体
|
uint8_t data_tag; //变量结构体
|
||||||
} ITEM;
|
} ITEM;
|
||||||
|
|
||||||
void Print_Curser(uint8 Curser_In, uint8 Curser_Last_In);
|
void Print_Curser(uint8_t Curser_In, uint8_t Curser_Last_In);
|
||||||
void Print_Menu(const ITEM* item, uint8 item_sum);
|
void Print_Menu(const ITEM* item, uint8_t item_sum);
|
||||||
void Print_Value(const ITEM* item, uint8 item_sum);
|
void Print_Value(const ITEM* item, uint8_t item_sum);
|
||||||
void Set_Vaule(ITEM* item, uint8 item_num, float step);
|
void Set_Vaule(ITEM* item, uint8_t item_num, float step);
|
||||||
|
void Show_Marked_Image(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -174,7 +174,6 @@ static soft_spi_info_struct ips200_spi;
|
|||||||
static void ips200_write_data(const uint8 dat)
|
static void ips200_write_data(const uint8 dat)
|
||||||
{
|
{
|
||||||
IPS200_DATAPORT->OUTDR = ((dat << DATA_START_NUM) | (IPS200_DATAPORT->OUTDR & ~((uint32)(0xFF << DATA_START_NUM))));
|
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))
|
// #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)
|
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(1);
|
||||||
IPS200_CS(0);
|
IPS200_CS(0);
|
||||||
IPS200_DC(0);
|
IPS200_DC(0);
|
||||||
@@ -197,9 +195,7 @@ static void ips200_write_command (const uint8 command)
|
|||||||
IPS200_DC(1);
|
IPS200_DC(1);
|
||||||
IPS200_CS(1);
|
IPS200_CS(1);
|
||||||
IPS200_CS(0);
|
IPS200_CS(0);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
IPS200_CS(0);
|
IPS200_CS(0);
|
||||||
IPS200_RS(0);
|
IPS200_RS(0);
|
||||||
IPS200_RD(1);
|
IPS200_RD(1);
|
||||||
@@ -220,12 +216,9 @@ static void ips200_write_command (const uint8 command)
|
|||||||
//-------------------------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------------------------
|
||||||
static void ips200_write_8bit_data(const uint8 dat)
|
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);
|
ips200_write_8bit_data_spi(dat);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
IPS200_CS(0);
|
IPS200_CS(0);
|
||||||
IPS200_RD(1);
|
IPS200_RD(1);
|
||||||
IPS200_WR(0);
|
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)
|
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);
|
ips200_write_8bit_data_spi_array(dat, len);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
IPS200_CS(0);
|
IPS200_CS(0);
|
||||||
IPS200_RD(1);
|
IPS200_RD(1);
|
||||||
while(len --)
|
while (len--) {
|
||||||
{
|
|
||||||
IPS200_WR(0);
|
IPS200_WR(0);
|
||||||
ips200_write_data((uint8)*dat);
|
ips200_write_data((uint8)*dat);
|
||||||
IPS200_WR(1);
|
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)
|
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);
|
ips200_write_16bit_data_spi(dat);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
IPS200_CS(0);
|
IPS200_CS(0);
|
||||||
IPS200_RD(1);
|
IPS200_RD(1);
|
||||||
IPS200_WR(0);
|
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)
|
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);
|
ips200_write_16bit_data_spi_array(dat, len);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
IPS200_CS(0);
|
IPS200_CS(0);
|
||||||
IPS200_RD(1);
|
IPS200_RD(1);
|
||||||
while(len --)
|
while (len--) {
|
||||||
{
|
|
||||||
IPS200_WR(0);
|
IPS200_WR(0);
|
||||||
ips200_write_data((uint8)(*dat >> 8));
|
ips200_write_data((uint8)(*dat >> 8));
|
||||||
IPS200_WR(1);
|
IPS200_WR(1);
|
||||||
@@ -366,20 +348,16 @@ static void ips200_debug_init (void)
|
|||||||
info.display_x_max = ips200_x_max;
|
info.display_x_max = ips200_x_max;
|
||||||
info.display_y_max = ips200_y_max;
|
info.display_y_max = ips200_y_max;
|
||||||
|
|
||||||
switch(ips200_display_font)
|
switch (ips200_display_font) {
|
||||||
{
|
case IPS200_6X8_FONT: {
|
||||||
case IPS200_6X8_FONT:
|
|
||||||
{
|
|
||||||
info.font_x_size = 6;
|
info.font_x_size = 6;
|
||||||
info.font_y_size = 8;
|
info.font_y_size = 8;
|
||||||
} break;
|
} break;
|
||||||
case IPS200_8X16_FONT:
|
case IPS200_8X16_FONT: {
|
||||||
{
|
|
||||||
info.font_x_size = 8;
|
info.font_x_size = 8;
|
||||||
info.font_y_size = 16;
|
info.font_y_size = 16;
|
||||||
} break;
|
} break;
|
||||||
case IPS200_16X16_FONT:
|
case IPS200_16X16_FONT: {
|
||||||
{
|
|
||||||
// 暂不支持
|
// 暂不支持
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
@@ -401,21 +379,17 @@ void ips200_clear (void)
|
|||||||
uint16 color_buffer[ips200_x_max];
|
uint16 color_buffer[ips200_x_max];
|
||||||
uint16 i = 0, j = 0;
|
uint16 i = 0, j = 0;
|
||||||
|
|
||||||
if(IPS200_TYPE_SPI == ips200_display_type)
|
if (IPS200_TYPE_SPI == ips200_display_type) {
|
||||||
{
|
|
||||||
IPS200_CS(0);
|
IPS200_CS(0);
|
||||||
}
|
}
|
||||||
ips200_set_region(0, 0, ips200_x_max - 1, ips200_y_max - 1);
|
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;
|
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);
|
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);
|
IPS200_CS(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -432,21 +406,17 @@ void ips200_full (const uint16 color)
|
|||||||
uint16 color_buffer[ips200_x_max];
|
uint16 color_buffer[ips200_x_max];
|
||||||
uint16 i = 0, j = 0;
|
uint16 i = 0, j = 0;
|
||||||
|
|
||||||
if(IPS200_TYPE_SPI == ips200_display_type)
|
if (IPS200_TYPE_SPI == ips200_display_type) {
|
||||||
{
|
|
||||||
IPS200_CS(0);
|
IPS200_CS(0);
|
||||||
}
|
}
|
||||||
ips200_set_region(0, 0, ips200_x_max - 1, ips200_y_max - 1);
|
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;
|
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);
|
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);
|
IPS200_CS(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -461,17 +431,14 @@ void ips200_full (const uint16 color)
|
|||||||
void ips200_set_dir(ips200_dir_enum dir)
|
void ips200_set_dir(ips200_dir_enum dir)
|
||||||
{
|
{
|
||||||
ips200_display_dir = dir;
|
ips200_display_dir = dir;
|
||||||
switch(ips200_display_dir)
|
switch (ips200_display_dir) {
|
||||||
{
|
|
||||||
case IPS200_PORTAIT:
|
case IPS200_PORTAIT:
|
||||||
case IPS200_PORTAIT_180:
|
case IPS200_PORTAIT_180: {
|
||||||
{
|
|
||||||
ips200_x_max = 240;
|
ips200_x_max = 240;
|
||||||
ips200_y_max = 320;
|
ips200_y_max = 320;
|
||||||
} break;
|
} break;
|
||||||
case IPS200_CROSSWISE:
|
case IPS200_CROSSWISE:
|
||||||
case IPS200_CROSSWISE_180:
|
case IPS200_CROSSWISE_180: {
|
||||||
{
|
|
||||||
ips200_x_max = 320;
|
ips200_x_max = 320;
|
||||||
ips200_y_max = 240;
|
ips200_y_max = 240;
|
||||||
} break;
|
} break;
|
||||||
@@ -520,14 +487,12 @@ void ips200_draw_point (uint16 x, uint16 y, const uint16 color)
|
|||||||
zf_assert(x < ips200_x_max);
|
zf_assert(x < ips200_x_max);
|
||||||
zf_assert(y < ips200_y_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_CS(0);
|
||||||
}
|
}
|
||||||
ips200_set_region(x, y, x, y);
|
ips200_set_region(x, y, x, y);
|
||||||
ips200_write_16bit_data(color);
|
ips200_write_16bit_data(color);
|
||||||
if(IPS200_TYPE_SPI == ips200_display_type)
|
if (IPS200_TYPE_SPI == ips200_display_type) {
|
||||||
{
|
|
||||||
IPS200_CS(1);
|
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_rate = 0;
|
||||||
float temp_b = 0;
|
float temp_b = 0;
|
||||||
|
|
||||||
do
|
do {
|
||||||
{
|
if (x_start != x_end) {
|
||||||
if(x_start != x_end)
|
|
||||||
{
|
|
||||||
temp_rate = (float)(y_start - y_end) / (float)(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;
|
temp_b = (float)y_start - (float)x_start * temp_rate;
|
||||||
}
|
} else {
|
||||||
else
|
while (y_start != y_end) {
|
||||||
{
|
|
||||||
while(y_start != y_end)
|
|
||||||
{
|
|
||||||
ips200_draw_point(x_start, y_start, color);
|
ips200_draw_point(x_start, y_start, color);
|
||||||
y_start += y_dir;
|
y_start += y_dir;
|
||||||
}
|
}
|
||||||
ips200_draw_point(x_start, y_start, color);
|
ips200_draw_point(x_start, y_start, color);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(func_abs(y_start - y_end) > func_abs(x_start - x_end))
|
if (func_abs(y_start - y_end) > func_abs(x_start - x_end)) {
|
||||||
{
|
while (y_start != y_end) {
|
||||||
while(y_start != y_end)
|
|
||||||
{
|
|
||||||
ips200_draw_point(x_start, y_start, color);
|
ips200_draw_point(x_start, y_start, color);
|
||||||
y_start += y_dir;
|
y_start += y_dir;
|
||||||
x_start = (int16)(((float)y_start - temp_b) / temp_rate);
|
x_start = (int16)(((float)y_start - temp_b) / temp_rate);
|
||||||
}
|
}
|
||||||
ips200_draw_point(x_start, y_start, color);
|
ips200_draw_point(x_start, y_start, color);
|
||||||
}
|
} else {
|
||||||
else
|
while (x_start != x_end) {
|
||||||
{
|
|
||||||
while(x_start != x_end)
|
|
||||||
{
|
|
||||||
ips200_draw_point(x_start, y_start, color);
|
ips200_draw_point(x_start, y_start, color);
|
||||||
x_start += x_dir;
|
x_start += x_dir;
|
||||||
y_start = (int16)((float)x_start * temp_rate + temp_b);
|
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;
|
uint8 i = 0, j = 0;
|
||||||
|
|
||||||
if(IPS200_TYPE_SPI == ips200_display_type)
|
if (IPS200_TYPE_SPI == ips200_display_type) {
|
||||||
{
|
|
||||||
IPS200_CS(0);
|
IPS200_CS(0);
|
||||||
}
|
}
|
||||||
switch(ips200_display_font)
|
switch (ips200_display_font) {
|
||||||
{
|
case IPS200_6X8_FONT: {
|
||||||
case IPS200_6X8_FONT:
|
|
||||||
{
|
|
||||||
uint16 display_buffer[6 * 8];
|
uint16 display_buffer[6 * 8];
|
||||||
ips200_set_region(x, y, x + 5, y + 7);
|
ips200_set_region(x, y, x + 5, y + 7);
|
||||||
for(i = 0; 6 > i; i ++)
|
for (i = 0; 6 > i; i++) {
|
||||||
{
|
|
||||||
// 减 32 因为是取模是从空格开始取得 空格在 ascii 中序号是 32
|
// 减 32 因为是取模是从空格开始取得 空格在 ascii 中序号是 32
|
||||||
uint8 temp_top = ascii_font_6x8[dat - 32][i];
|
uint8 temp_top = ascii_font_6x8[dat - 32][i];
|
||||||
for(j = 0; 8 > j; j ++)
|
for (j = 0; 8 > j; j++) {
|
||||||
{
|
if (temp_top & 0x01) {
|
||||||
if(temp_top & 0x01)
|
|
||||||
{
|
|
||||||
display_buffer[i + j * 6] = (ips200_pencolor);
|
display_buffer[i + j * 6] = (ips200_pencolor);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
display_buffer[i + j * 6] = (ips200_bgcolor);
|
display_buffer[i + j * 6] = (ips200_bgcolor);
|
||||||
}
|
}
|
||||||
temp_top >>= 1;
|
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);
|
ips200_write_16bit_data_array(display_buffer, 6 * 8);
|
||||||
} break;
|
} break;
|
||||||
case IPS200_8X16_FONT:
|
case IPS200_8X16_FONT: {
|
||||||
{
|
|
||||||
uint16 display_buffer[8 * 16];
|
uint16 display_buffer[8 * 16];
|
||||||
ips200_set_region(x, y, x + 7, y + 15);
|
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_top = ascii_font_8x16[dat - 32][i];
|
||||||
uint8 temp_bottom = ascii_font_8x16[dat - 32][i + 8];
|
uint8 temp_bottom = ascii_font_8x16[dat - 32][i + 8];
|
||||||
for(j = 0; 8 > j; j ++)
|
for (j = 0; 8 > j; j++) {
|
||||||
{
|
if (temp_top & 0x01) {
|
||||||
if(temp_top & 0x01)
|
|
||||||
{
|
|
||||||
display_buffer[i + j * 8] = (ips200_pencolor);
|
display_buffer[i + j * 8] = (ips200_pencolor);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
display_buffer[i + j * 8] = (ips200_bgcolor);
|
display_buffer[i + j * 8] = (ips200_bgcolor);
|
||||||
}
|
}
|
||||||
temp_top >>= 1;
|
temp_top >>= 1;
|
||||||
}
|
}
|
||||||
for(j = 0; 8 > j; j ++)
|
for (j = 0; 8 > j; j++) {
|
||||||
{
|
if (temp_bottom & 0x01) {
|
||||||
if(temp_bottom & 0x01)
|
|
||||||
{
|
|
||||||
display_buffer[i + j * 8 + 4 * 16] = (ips200_pencolor);
|
display_buffer[i + j * 8 + 4 * 16] = (ips200_pencolor);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
display_buffer[i + j * 8 + 4 * 16] = (ips200_bgcolor);
|
display_buffer[i + j * 8 + 4 * 16] = (ips200_bgcolor);
|
||||||
}
|
}
|
||||||
temp_bottom >>= 1;
|
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);
|
ips200_write_16bit_data_array(display_buffer, 8 * 16);
|
||||||
} break;
|
} break;
|
||||||
case IPS200_16X16_FONT:
|
case IPS200_16X16_FONT: {
|
||||||
{
|
|
||||||
// 暂不支持
|
// 暂不支持
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
if(IPS200_TYPE_SPI == ips200_display_type)
|
if (IPS200_TYPE_SPI == ips200_display_type) {
|
||||||
{
|
|
||||||
IPS200_CS(1);
|
IPS200_CS(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -707,13 +642,16 @@ void ips200_show_string (uint16 x, uint16 y, const char dat[])
|
|||||||
zf_assert(y < ips200_y_max);
|
zf_assert(y < ips200_y_max);
|
||||||
|
|
||||||
uint16 j = 0;
|
uint16 j = 0;
|
||||||
while('\0' != dat[j])
|
while ('\0' != dat[j]) {
|
||||||
{
|
switch (ips200_display_font) {
|
||||||
switch(ips200_display_font)
|
case IPS200_6X8_FONT:
|
||||||
{
|
ips200_show_char(x + 6 * j, y, dat[j]);
|
||||||
case IPS200_6X8_FONT: ips200_show_char(x + 6 * j, y, dat[j]); break;
|
break;
|
||||||
case IPS200_8X16_FONT: ips200_show_char(x + 8 * j, y, dat[j]); break;
|
case IPS200_8X16_FONT:
|
||||||
case IPS200_16X16_FONT: break; // 暂不支持
|
ips200_show_char(x + 8 * j, y, dat[j]);
|
||||||
|
break;
|
||||||
|
case IPS200_16X16_FONT:
|
||||||
|
break; // 暂不支持
|
||||||
}
|
}
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
@@ -746,10 +684,8 @@ void ips200_show_int (uint16 x, uint16 y, const int32 dat, uint8 num)
|
|||||||
memset(data_buffer, ' ', num + 1);
|
memset(data_buffer, ' ', num + 1);
|
||||||
|
|
||||||
// 用来计算余数显示 123 显示 2 位则应该显示 23
|
// 用来计算余数显示 123 显示 2 位则应该显示 23
|
||||||
if(10 > num)
|
if (10 > num) {
|
||||||
{
|
for (; 0 < num; num--) {
|
||||||
for(; 0 < num; num --)
|
|
||||||
{
|
|
||||||
offset *= 10;
|
offset *= 10;
|
||||||
}
|
}
|
||||||
dat_temp %= offset;
|
dat_temp %= offset;
|
||||||
@@ -784,10 +720,8 @@ void ips200_show_uint (uint16 x, uint16 y, const uint32 dat, uint8 num)
|
|||||||
memset(data_buffer, ' ', num);
|
memset(data_buffer, ' ', num);
|
||||||
|
|
||||||
// 用来计算余数显示 123 显示 2 位则应该显示 23
|
// 用来计算余数显示 123 显示 2 位则应该显示 23
|
||||||
if(10 > num)
|
if (10 > num) {
|
||||||
{
|
for (; 0 < num; num--) {
|
||||||
for(; 0 < num; num --)
|
|
||||||
{
|
|
||||||
offset *= 10;
|
offset *= 10;
|
||||||
}
|
}
|
||||||
dat_temp %= offset;
|
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);
|
memset(data_buffer, ' ', num + pointnum + 2);
|
||||||
|
|
||||||
// 用来计算余数显示 123 显示 2 位则应该显示 23
|
// 用来计算余数显示 123 显示 2 位则应该显示 23
|
||||||
for(; 0 < num; num --)
|
for (; 0 < num; num--) {
|
||||||
{
|
|
||||||
offset *= 10;
|
offset *= 10;
|
||||||
}
|
}
|
||||||
dat_temp = dat_temp - ((int)dat_temp / (int)offset) * offset;
|
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];
|
uint16 data_buffer[dis_width];
|
||||||
const uint8 *image_temp;
|
const uint8 *image_temp;
|
||||||
|
|
||||||
if(IPS200_TYPE_SPI == ips200_display_type)
|
if (IPS200_TYPE_SPI == ips200_display_type) {
|
||||||
{
|
|
||||||
IPS200_CS(0);
|
IPS200_CS(0);
|
||||||
}
|
}
|
||||||
ips200_set_region(x, y, x + dis_width - 1, y + dis_height - 1); // 设置显示区域
|
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 暂时不知道为什么
|
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;
|
width_index = i * width / dis_width;
|
||||||
temp = *(image_temp + width_index / 8); // 读取像素点
|
temp = *(image_temp + width_index / 8); // 读取像素点
|
||||||
if(0x80 & (temp << (width_index % 8)))
|
if (0x80 & (temp << (width_index % 8))) {
|
||||||
{
|
|
||||||
data_buffer[i] = (RGB565_WHITE);
|
data_buffer[i] = (RGB565_WHITE);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
data_buffer[i] = (RGB565_BLACK);
|
data_buffer[i] = (RGB565_BLACK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ips200_write_16bit_data_array(data_buffer, dis_width);
|
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);
|
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];
|
uint16 data_buffer[dis_width];
|
||||||
const uint8 *image_temp;
|
const uint8 *image_temp;
|
||||||
|
|
||||||
if(IPS200_TYPE_SPI == ips200_display_type)
|
if (IPS200_TYPE_SPI == ips200_display_type) {
|
||||||
{
|
|
||||||
IPS200_CS(0);
|
IPS200_CS(0);
|
||||||
}
|
}
|
||||||
ips200_set_region(x, y, x + dis_width - 1, y + dis_height - 1); // 设置显示区域
|
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 暂时不知道为什么
|
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); // 读取像素点
|
temp = *(image_temp + i * width / dis_width); // 读取像素点
|
||||||
if(threshold == 0)
|
if (threshold == 0) {
|
||||||
{
|
|
||||||
color = (0x001f & ((temp) >> 3)) << 11;
|
color = (0x001f & ((temp) >> 3)) << 11;
|
||||||
color = color | (((0x003f) & ((temp) >> 2)) << 5);
|
color = color | (((0x003f) & ((temp) >> 2)) << 5);
|
||||||
color = color | (0x001f & ((temp) >> 3));
|
color = color | (0x001f & ((temp) >> 3));
|
||||||
data_buffer[i] = (color);
|
data_buffer[i] = (color);
|
||||||
}
|
} else if (temp < threshold) {
|
||||||
else if(temp < threshold)
|
|
||||||
{
|
|
||||||
data_buffer[i] = (RGB565_BLACK);
|
data_buffer[i] = (RGB565_BLACK);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
data_buffer[i] = (RGB565_WHITE);
|
data_buffer[i] = (RGB565_WHITE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ips200_write_16bit_data_array(data_buffer, dis_width);
|
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);
|
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];
|
uint16 data_buffer[dis_width];
|
||||||
const uint16 *image_temp;
|
const uint16 *image_temp;
|
||||||
|
|
||||||
if(IPS200_TYPE_SPI == ips200_display_type)
|
if (IPS200_TYPE_SPI == ips200_display_type) {
|
||||||
{
|
|
||||||
IPS200_CS(0);
|
IPS200_CS(0);
|
||||||
}
|
}
|
||||||
ips200_set_region(x, y, x + dis_width - 1, y + dis_height - 1); // 设置显示区域
|
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 暂时不知道为什么
|
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); // 读取像素点
|
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);
|
ips200_write_8bit_data_array((uint8 *)data_buffer, dis_width * 2);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
ips200_write_16bit_data_array(data_buffer, dis_width);
|
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);
|
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;
|
uint32 width_index = 0, value_max_index = 0;
|
||||||
uint16 data_buffer[dis_width];
|
uint16 data_buffer[dis_width];
|
||||||
|
|
||||||
|
if (IPS200_TYPE_SPI == ips200_display_type) {
|
||||||
if(IPS200_TYPE_SPI == ips200_display_type)
|
|
||||||
{
|
|
||||||
IPS200_CS(0);
|
IPS200_CS(0);
|
||||||
}
|
}
|
||||||
ips200_set_region(x, y, x + dis_width - 1, y + dis_value_max - 1); // 设置显示区域
|
ips200_set_region(x, y, x + dis_width - 1, y + dis_value_max - 1); // 设置显示区域
|
||||||
for(j = 0; j < dis_value_max; j ++)
|
for (j = 0; j < dis_value_max; j++) {
|
||||||
{
|
for (i = 0; i < dis_width; i++) {
|
||||||
for(i = 0; i < dis_width; i ++)
|
|
||||||
{
|
|
||||||
data_buffer[i] = (ips200_bgcolor);
|
data_buffer[i] = (ips200_bgcolor);
|
||||||
}
|
}
|
||||||
ips200_write_16bit_data_array(data_buffer, dis_width);
|
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);
|
IPS200_CS(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i < dis_width; i ++)
|
for (i = 0; i < dis_width; i++) {
|
||||||
{
|
|
||||||
width_index = i * width / dis_width;
|
width_index = i * width / dis_width;
|
||||||
value_max_index = *(wave + width_index) * (dis_value_max - 1) / value_max;
|
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);
|
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;
|
temp2 = size / 8;
|
||||||
|
|
||||||
if(IPS200_TYPE_SPI == ips200_display_type)
|
if (IPS200_TYPE_SPI == ips200_display_type) {
|
||||||
{
|
|
||||||
IPS200_CS(0);
|
IPS200_CS(0);
|
||||||
}
|
}
|
||||||
ips200_set_region(x, y, number * size - 1 + x, y + size - 1);
|
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;
|
temp1 = number;
|
||||||
p_data = chinese_buffer + i * temp2;
|
p_data = chinese_buffer + i * temp2;
|
||||||
while(temp1 --)
|
while (temp1--) {
|
||||||
{
|
for (k = 0; k < temp2; k++) {
|
||||||
for(k = 0; k < temp2; k ++)
|
for (j = 8; 0 < j; j--) {
|
||||||
{
|
|
||||||
for(j = 8; 0 < j; j --)
|
|
||||||
{
|
|
||||||
temp = (*p_data >> (j - 1)) & 0x01;
|
temp = (*p_data >> (j - 1)) & 0x01;
|
||||||
if(temp)
|
if (temp) {
|
||||||
{
|
|
||||||
ips200_write_16bit_data(color);
|
ips200_write_16bit_data(color);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
ips200_write_16bit_data(ips200_bgcolor);
|
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;
|
p_data = p_data - temp2 + temp2 * size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(IPS200_TYPE_SPI == ips200_display_type)
|
if (IPS200_TYPE_SPI == ips200_display_type) {
|
||||||
{
|
|
||||||
IPS200_CS(1);
|
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)
|
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;
|
ips200_display_type = IPS200_TYPE_SPI;
|
||||||
ips_rst_pin = IPS200_RST_PIN_SPI;
|
ips_rst_pin = IPS200_RST_PIN_SPI;
|
||||||
ips_bl_pin = IPS200_BLk_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(ips_rst_pin, GPO, GPIO_LOW, GPO_PUSH_PULL);
|
||||||
gpio_init(IPS200_CS_PIN_SPI, 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);
|
gpio_init(ips_bl_pin, GPO, GPIO_HIGH, GPO_PUSH_PULL);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
ips200_display_type = IPS200_TYPE_PARALLEL8;
|
ips200_display_type = IPS200_TYPE_PARALLEL8;
|
||||||
ips_rst_pin = IPS200_RST_PIN_PARALLEL8;
|
ips_rst_pin = IPS200_RST_PIN_PARALLEL8;
|
||||||
ips_bl_pin = IPS200_BL_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 i = 0;
|
||||||
uint8 pin_value = (((uint32)IPS200_DATAPORT - GPIOA_BASE) / 0x400) * 0x20 + DATA_START_NUM; // 获取端口的枚举体值
|
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);
|
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);
|
IPS200_RST(1);
|
||||||
system_delay_ms(120);
|
system_delay_ms(120);
|
||||||
|
|
||||||
if(IPS200_TYPE_SPI == ips200_display_type)
|
if (IPS200_TYPE_SPI == ips200_display_type) {
|
||||||
{
|
|
||||||
IPS200_CS(0);
|
IPS200_CS(0);
|
||||||
}
|
}
|
||||||
ips200_write_command(0x11);
|
ips200_write_command(0x11);
|
||||||
system_delay_ms(120);
|
system_delay_ms(120);
|
||||||
|
|
||||||
ips200_write_command(0x36);
|
ips200_write_command(0x36);
|
||||||
switch(ips200_display_dir)
|
switch (ips200_display_dir) {
|
||||||
{
|
case IPS200_PORTAIT:
|
||||||
case IPS200_PORTAIT: ips200_write_8bit_data(0x00); break;
|
ips200_write_8bit_data(0x00);
|
||||||
case IPS200_PORTAIT_180: ips200_write_8bit_data(0xC0); break;
|
break;
|
||||||
case IPS200_CROSSWISE: ips200_write_8bit_data(0x70); break;
|
case IPS200_PORTAIT_180:
|
||||||
case IPS200_CROSSWISE_180: ips200_write_8bit_data(0xA0); break;
|
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);
|
ips200_write_command(0x3A);
|
||||||
@@ -1286,8 +1183,7 @@ void ips200_init (ips200_type_enum type_select)
|
|||||||
ips200_write_command(0x21);
|
ips200_write_command(0x21);
|
||||||
|
|
||||||
ips200_write_command(0x29);
|
ips200_write_command(0x29);
|
||||||
if(IPS200_TYPE_SPI == ips200_display_type)
|
if (IPS200_TYPE_SPI == ips200_display_type) {
|
||||||
{
|
|
||||||
IPS200_CS(1);
|
IPS200_CS(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -85,10 +85,15 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// 如果使用的是单排排针的两寸屏幕 SPI 驱动控制引脚 可以修改
|
// 如果使用的是单排排针的两寸屏幕 SPI 驱动控制引脚 可以修改
|
||||||
#define IPS200_RST_PIN_SPI (B7 ) // 液晶复位引脚定义
|
// #define IPS200_RST_PIN_SPI (B7 ) // 液晶复位引脚定义
|
||||||
#define IPS200_DC_PIN_SPI (D7 ) // 液晶命令位引脚定义
|
// #define IPS200_DC_PIN_SPI (D7 ) // 液晶命令位引脚定义
|
||||||
#define IPS200_CS_PIN_SPI (D4 )
|
// #define IPS200_CS_PIN_SPI (D4 )
|
||||||
#define IPS200_BLk_PIN_SPI (D0 )
|
// #define IPS200_BLk_PIN_SPI (D0 )
|
||||||
|
|
||||||
|
#define IPS200_RST_PIN_SPI (D8 ) // 液晶复位引脚定义
|
||||||
|
#define IPS200_DC_PIN_SPI (D9 ) // 液晶命令位引脚定义
|
||||||
|
#define IPS200_CS_PIN_SPI (D10 )
|
||||||
|
#define IPS200_BLk_PIN_SPI (D11 )
|
||||||
|
|
||||||
|
|
||||||
// --------------------单排两寸屏幕 SPI 接口引脚定义--------------------//
|
// --------------------单排两寸屏幕 SPI 接口引脚定义--------------------//
|
||||||
|
|||||||
Reference in New Issue
Block a user