diff --git a/app/gl_common.c b/app/gl_common.c
index 29a3138..e35e349 100644
--- a/app/gl_common.c
+++ b/app/gl_common.c
@@ -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;
}
diff --git a/app/gl_common.h b/app/gl_common.h
index 1bd003a..1cfda26 100644
--- a/app/gl_common.h
+++ b/app/gl_common.h
@@ -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) ;
diff --git a/app/gl_handle_img.c b/app/gl_handle_img.c
index 1e12c62..5e0c293 100644
--- a/app/gl_handle_img.c
+++ b/app/gl_handle_img.c
@@ -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; // 是弯道
}
diff --git a/app/gl_handle_img.h b/app/gl_handle_img.h
index 05f9470..2707caa 100644
--- a/app/gl_handle_img.h
+++ b/app/gl_handle_img.h
@@ -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_ */
\ No newline at end of file
diff --git a/app/gl_img_process.c b/app/gl_img_process.c
index c0bcbad..9705fa0 100644
--- a/app/gl_img_process.c
+++ b/app/gl_img_process.c
@@ -5,9 +5,6 @@
/*
@author: glz
@brief:
-
-
-
*/
diff --git a/app/gl_img_process.h b/app/gl_img_process.h
index 968f2e5..e745ce1 100644
--- a/app/gl_img_process.h
+++ b/app/gl_img_process.h
@@ -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_ */
diff --git a/app/main.c b/app/main.c
index a15630e..18d6832 100644
--- a/app/main.c
+++ b/app/main.c
@@ -2,11 +2,11 @@
* CH32V307VCT6 Opensourec Library CH32V307VCT6 Դ⣩һڹٷ SDK ӿڵĵԴ
* Copyright (c) 2022 SEEKFREE ɿƼ
*
- * ļCH32V307VCT6 Դһ
+ * ļ CH32V307VCT6 Դһ
*
* CH32V307VCT6 Դ
- * Ըᷢ GPLGNU General Public License GNUͨù֤
- * GPL ĵ3棨 GPL3.0ѡģκκİ汾·/
+ * Ըᷢ GPLGNU General Public License GNU ͨù֤
+ * GPL ĵ 3 棨 GPL3.0ѡģκκİ汾·/
*
* Դķϣܷãδκεı֤
* ûԻʺض;ı֤
@@ -34,25 +34,25 @@
********************************************************************************************************************/
#include "zf_common_headfile.h"
#include "gl_headfile.h"
-#include "cw_servo.h"
#include "by_pt_button.h"
#include "by_fan_control.h"
+#include "cw_servo.h"
+#include "./page/cw_page.h"
-uint8 (*Img_Gray)[MT9V03X_W]; // ָ MT9V03X_W е uint8 ͵Ķάָ
-//uint8 *mt9v03x_image_copy[0]; // ָ uint8 ͵һάָ
-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]; // ָ MT9V03X_W е uint8_t ͵Ķάָ
+// uint8_t *mt9v03x_image_copy[0]; // ָ uint8_t ͵һάָ
+int32_t pts_left[PT_MAXLEN][2], pts_right[PT_MAXLEN][2];
+int32_t pts_left_count, pts_right_count;
+float pts_inv_l[PT_MAXLEN][2], pts_inv_r[PT_MAXLEN][2];
+int32_t pts_inv_l_count, pts_inv_r_count;
+float pts_filter_l[PT_MAXLEN][2], pts_filter_r[PT_MAXLEN][2];
+int32_t pts_filter_l_count, pts_filter_r_count;
+float pts_resample_left[PT_MAXLEN][2], pts_resample_right[PT_MAXLEN][2];
+int32_t pts_resample_left_count, pts_resample_right_count;
+float mid_left[PT_MAXLEN][2], mid_right[PT_MAXLEN][2];
+int32_t mid_left_count, mid_right_count;
-
-//ұ߾ֲǶȱ仯+Ǽֵ
+// ұ߾ֲǶȱ仯 + Ǽֵ
float angle_new_left[PT_MAXLEN];
float angle_new_right[PT_MAXLEN];
int angle_new_left_num, angle_new_right_num;
@@ -63,10 +63,10 @@ float angle_left[PT_MAXLEN];
float angle_right[PT_MAXLEN];
int angle_left_num, angle_right_num;
-// Lǵ
+// L ǵ
int Lpt0_rpts0s_id, Lpt1_rpts1s_id;
bool Lpt0_found, Lpt1_found;
-int Lpt1[2],Lpt0[2];
+int Lpt1[2], Lpt0[2];
int Lpt_in0_rpts0s_id, Lpt_in1_rpts1s_id;
bool Lpt_in0_found, Lpt_in1_found;
@@ -85,41 +85,43 @@ float aim_distance;
enum track_type_e track_type = TRACK_RIGHT;
-
int frame_count = 0;
void img_processing();
void get_corners();
-
int main(void)
{
clock_init(SYSTEM_CLOCK_120M); // ʼоƬʱ ƵΪ 120MHz
debug_init(); // رڳʼ MPU ʱ Դ
mt9v03x_init();
- ips114_init();
+ ips200_init(IPS200_TYPE_SPI);
by_gpio_init();
by_exit_init();
by_pwm_init();
cw_servo_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_Init();
+ while (1) {
+ Page_Run();
+ // 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++;
+ // }
//}
+
+ /************************ ͼغ ***************************/
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];
+ 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;
+ // mt9v03x_image_copy[0] = Img_Gray[0];
mt9v03x_finish_flag = 0;
state_type = COMMON_STATE;
@@ -130,9 +132,7 @@ int main(void)
ElementJudge();
ElementRun();
MidLineTrack();
-
}
-
-
+ /************************ ͼغ ***************************/
}
}
\ No newline at end of file
diff --git a/app/main.h b/app/main.h
index ec7ba00..10353da 100644
--- a/app/main.h
+++ b/app/main.h
@@ -2,35 +2,32 @@
#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 uint8 *mt9v03x_image_copy[0];
+extern int32_t pts_left[PT_MAXLEN][2], pts_right[PT_MAXLEN][2]; // 0:H,1:W
+extern int32_t pts_left_count, pts_right_count;
+extern float pts_inv_l[PT_MAXLEN][2], pts_inv_r[PT_MAXLEN][2];
+extern int32_t pts_inv_l_count, pts_inv_r_count;
+extern float pts_filter_l[PT_MAXLEN][2], pts_filter_r[PT_MAXLEN][2];
+extern int32_t pts_filter_l_count, pts_filter_r_count;
+extern float pts_resample_left[PT_MAXLEN][2], pts_resample_right[PT_MAXLEN][2];
+extern int32_t pts_resample_left_count, pts_resample_right_count;
extern uint8_t mt9v03x_image_copy[MT9V03X_H][MT9V03X_W];
-extern 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];
+extern int Lpt1[2], Lpt0[2];
extern int Lpt_in0_rpts0s_id, Lpt_in1_rpts1s_id;
extern bool Lpt_in0_found, Lpt_in1_found;
@@ -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,
diff --git a/app/page/cw_page.c b/app/page/cw_page.c
index 34cb8e0..d948d63 100644
--- a/app/page/cw_page.c
+++ b/app/page/cw_page.c
@@ -1,9 +1,9 @@
#include "cw_page.h"
PAGE_LIST pagelist[page_max];
-static uint8 page_busy = 0;
-static int8 now_page = page_menu;
-static int8 new_page = page_menu;
+static uint8_t page_busy = 0;
+static int8_t now_page = page_menu;
+static int8_t new_page = page_menu;
/**
* @brief 注册一个基本页面,包含一个初始化函数,循环函数,退出函数,事件函数
@@ -15,7 +15,7 @@ static int8 new_page = page_menu;
* @param eventCallback: 事件函数回调
* @retval 无
*/
-void Page_Register(uint8 pageID, char *pageText,
+void Page_Register(uint8_t pageID, char *pageText,
CallbackFunction_t setupCallback, CallbackFunction_t loopCallback,
CallbackFunction_t exitCallback, EventFunction_t eventCallback) {
pagelist[pageID].Text = pageText;
@@ -66,9 +66,9 @@ void Page_OpenCurrentPage() {
/**
* @brief 获取页面状态
*
- * @return uint8 页面忙返回1 空闲返回0
+ * @return uint8_t 页面忙返回1 空闲返回0
*/
-uint8 Page_GetStatus(void) {
+uint8_t Page_GetStatus(void) {
if (page_busy)
return 1;
else
diff --git a/app/page/cw_page.h b/app/page/cw_page.h
index 39159b1..cd4f20e 100644
--- a/app/page/cw_page.h
+++ b/app/page/cw_page.h
@@ -47,7 +47,7 @@ do{\
PageRegister_##name(name);\
}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 exitCallback, EventFunction_t eventCallback);
@@ -55,7 +55,7 @@ void Page_EventTransmit(unsigned char event);
void Page_Shift(unsigned char pageID);
void Page_CloseCurrentPage(void);
void Page_OpenCurrentPage(void);
-uint8 Page_GetStatus(void);
+uint8_t Page_GetStatus(void);
void Page_Run(void);
void Page_Init(void);
diff --git a/app/page/cw_page_menu.c b/app/page/cw_page_menu.c
index bc12d4d..4296ba6 100644
--- a/app/page/cw_page_menu.c
+++ b/app/page/cw_page_menu.c
@@ -44,6 +44,7 @@ static void Exit()
*/
static void Loop()
{
+ Show_Marked_Image();
}
/**
@@ -98,9 +99,9 @@ void PageRegister_page_menu(unsigned char pageID)
static void Print_Menu_p(void)
{
// SCREEN_showstr_style(5 * 8, 0, RED, WHITE, "#### MAIN MENU ####");
- ips114_show_string(0, 0, Text);
- for (uint8 i = page_menu + 1; i < page_max; i++) {
- ips114_show_string(8, i, pagelist[i].Text);
+ 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);
}
}
diff --git a/app/page/cw_page_rtcam.c b/app/page/cw_page_rtcam.c
new file mode 100644
index 0000000..969963d
--- /dev/null
+++ b/app/page/cw_page_rtcam.c
@@ -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);
+ }
+}
diff --git a/app/page/cw_page_ui_widget.c b/app/page/cw_page_ui_widget.c
index 69db196..d5222f8 100644
--- a/app/page/cw_page_ui_widget.c
+++ b/app/page/cw_page_ui_widget.c
@@ -1,4 +1,6 @@
#include "cw_page_ui_widget.h"
+#include "zf_common_headfile.h"
+#include "main.h"
/**
* @brief 绘制光标
@@ -6,60 +8,63 @@
* @param Curser_In 当前光标位置
* @param Curser_Last_In 上一时刻光标位置
*/
-void Print_Curser(uint8 Curser_In, uint8 Curser_Last_In) {
- ips114_show_string(0, Curser_Last_In, " ");
- ips114_show_string(0, Curser_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 item_sum) {
- ips114_show_string(0, 0, " --return--");
- for (uint8 i = 0; i < item_sum; i++) {
- ips114_show_string(8, i + 1, item[i].text);
- }
+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 item_sum) {
-// for (uint8 i = 0; i < item_sum; i++) {
-// switch (Param_Data[item[i].data_tag].type) {
-// case EINT8:
-// ips114_show_int(128, i + 1,
-// *((int8 *)Param_Data[item[i].data_tag].p_data), 5);
-// break;
-// case EINT16:
-// ips114_show_int(128, i + 1,
-// *((int16 *)Param_Data[item[i].data_tag].p_data), 5);
-// break;
-// case EINT32:
-// ips114_show_int(128, i + 1,
-// *((int32 *)Param_Data[item[i].data_tag].p_data), 5);
-// break;
-// case EUINT8:
-// ips114_show_int(128, i + 1,
-// *((uint8 *)Param_Data[item[i].data_tag].p_data), 5);
-// break;
-// case EUINT16:
-// ips114_show_int(128, i + 1,
-// *((uint16 *)Param_Data[item[i].data_tag].p_data), 5);
-// break;
-// case EUINT32:
-// ips114_show_int(128, i + 1,
-// *((uint32 *)Param_Data[item[i].data_tag].p_data), 5);
-// case EFLOAT:
-// ips114_show_float(128, i + 1,
-// *((float *)Param_Data[item[i].data_tag].p_data), 5, 2);
-// break;
-// default:
-// break;
-// }
-// }
+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;
+ // }
+ // }
}
/**
@@ -68,56 +73,78 @@ void Print_Value(const ITEM *item, uint8 item_sum) {
* @param item_num
* @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) { // 待修改变量为浮点
- // *((float *)Param_Data[item[item_num].data_tag].p_data) += step;
- // ips114_show_float(128, item_num + 1,
- // *((float *)Param_Data[item[item_num].data_tag].p_data), 6,
- // 2);
- // return;
- // }
+ // 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;
- // }
+ // 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 *)Param_Data[item[item_num].data_tag].p_data) += (int8)step;
- // ips114_show_int(128, item_num + 1,
- // *((int8 *)Param_Data[item[item_num].data_tag].p_data), 5);
- // break;
- // case EINT16:
- // *((int16 *)Param_Data[item[item_num].data_tag].p_data) += (int16)step;
- // ips114_show_int(128, item_num + 1,
- // *((int16 *)Param_Data[item[item_num].data_tag].p_data), 5);
- // break;
- // case EINT32:
- // *((int32 *)Param_Data[item[item_num].data_tag].p_data) += (int32)step;
- // ips114_show_int(128, item_num + 1,
- // *((int32 *)Param_Data[item[item_num].data_tag].p_data), 5);
- // break;
- // case EUINT8:
- // *((uint8 *)Param_Data[item[item_num].data_tag].p_data) += (uint8)step;
- // ips114_show_int(128, item_num + 1,
- // *((uint8 *)Param_Data[item[item_num].data_tag].p_data), 5);
- // break;
- // case EUINT16:
- // *((uint16 *)Param_Data[item[item_num].data_tag].p_data) += (uint16)step;
- // ips114_show_int(128, item_num + 1,
- // *((uint16 *)Param_Data[item[item_num].data_tag].p_data), 5);
- // break;
- // case EUINT32:
- // *((uint32 *)Param_Data[item[item_num].data_tag].p_data) += (uint32)step;
- // ips114_show_int(128, item_num + 1,
- // *((uint32 *)Param_Data[item[item_num].data_tag].p_data), 5);
- // break;
- // default:
- // break;
- // }
+ // 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
+}
diff --git a/app/page/cw_page_ui_widget.h b/app/page/cw_page_ui_widget.h
index 84634dc..666ef27 100644
--- a/app/page/cw_page_ui_widget.h
+++ b/app/page/cw_page_ui_widget.h
@@ -5,12 +5,13 @@
typedef struct {
char *text; //变量显示名
- uint8 data_tag; //变量结构体
+ uint8_t data_tag; //变量结构体
} ITEM;
-void Print_Curser(uint8 Curser_In, uint8 Curser_Last_In);
-void Print_Menu(const ITEM* item, uint8 item_sum);
-void Print_Value(const ITEM* item, uint8 item_sum);
-void Set_Vaule(ITEM* item, uint8 item_num, float step);
+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
diff --git a/libraries/zf_device/zf_device_ips200.c b/libraries/zf_device/zf_device_ips200.c
index 8f0a342..3fd0c1a 100644
--- a/libraries/zf_device/zf_device_ips200.c
+++ b/libraries/zf_device/zf_device_ips200.c
@@ -1,64 +1,64 @@
/*********************************************************************************************************************
-* CH32V307VCT6 Opensourec Library 即(CH32V307VCT6 开源库)是一个基于官方 SDK 接口的第三方开源库
-* Copyright (c) 2022 SEEKFREE 逐飞科技
-*
-* 本文件是CH32V307VCT6 开源库的一部分
-*
-* CH32V307VCT6 开源库 是免费软件
-* 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU通用公共许可证)的条款
-* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
-*
-* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
-* 甚至没有隐含的适销性或适合特定用途的保证
-* 更多细节请参见 GPL
-*
-* 您应该在收到本开源库的同时收到一份 GPL 的副本
-* 如果没有,请参阅
-*
-* 额外注明:
-* 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
-* 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
-* 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
-* 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
-*
-* 文件名称 zf_device_ips200
-* 公司名称 成都逐飞科技有限公司
-* 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
-* 开发环境 MounRiver Studio V1.8.1
-* 适用平台 CH32V307VCT6
-* 店铺链接 https://seekfree.taobao.com/
-*
-* 修改记录
-* 日期 作者 备注
-* 2022-09-15 大W first version
-********************************************************************************************************************/
+ * CH32V307VCT6 Opensourec Library 即(CH32V307VCT6 开源库)是一个基于官方 SDK 接口的第三方开源库
+ * Copyright (c) 2022 SEEKFREE 逐飞科技
+ *
+ * 本文件是 CH32V307VCT6 开源库的一部分
+ *
+ * CH32V307VCT6 开源库 是免费软件
+ * 您可以根据自由软件基金会发布的 GPL(GNU General Public License,即 GNU 通用公共许可证)的条款
+ * 即 GPL 的第 3 版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
+ *
+ * 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
+ * 甚至没有隐含的适销性或适合特定用途的保证
+ * 更多细节请参见 GPL
+ *
+ * 您应该在收到本开源库的同时收到一份 GPL 的副本
+ * 如果没有,请参阅
+ *
+ * 额外注明:
+ * 本开源库使用 GPL3.0 开源许可证协议 以上许可申明为译文版本
+ * 许可申明英文版在 libraries/doc 文件夹下的 GPL3_permission_statement.txt 文件中
+ * 许可证副本在 libraries 文件夹下 即该文件夹下的 LICENSE 文件
+ * 欢迎各位使用并传播本程序 但修改内容时必须保留逐飞科技的版权声明(即本声明)
+ *
+ * 文件名称 zf_device_ips200
+ * 公司名称 成都逐飞科技有限公司
+ * 版本信息 查看 libraries/doc 文件夹内 version 文件 版本说明
+ * 开发环境 MounRiver Studio V1.8.1
+ * 适用平台 CH32V307VCT6
+ * 店铺链接 https://seekfree.taobao.com/
+ *
+ * 修改记录
+ * 日期 作者 备注
+ * 2022-09-15 大 W first version
+ ********************************************************************************************************************/
/*********************************************************************************************************************
-* 接线定义:
-* ------------------------------------
-* 模块管脚 单片机管脚
-* // 双排排针 并口两寸屏 硬件引脚
-* RD 查看 zf_device_ips200.h 中 IPS200_RD_PIN_PARALLEL8 宏定义
-* WR 查看 zf_device_ips200.h 中 IPS200_WR_PIN_PARALLEL8 宏定义
-* RS 查看 zf_device_ips200.h 中 IPS200_RS_PIN_PARALLEL8 宏定义
-* RST 查看 zf_device_ips200.h 中 IPS200_RST_PIN_PARALLEL8 宏定义
-* CS 查看 zf_device_ips200.h 中 IPS200_CS_PIN_PARALLEL8 宏定义
-* BL 查看 zf_device_ips200.h 中 IPS200_BL_PIN_PARALLEL8 宏定义
-* D0-D7 查看 zf_device_ips200.h 中 IPS200_Dx_PIN_PARALLEL8 宏定义
-* VCC 3.3V电源
-* GND 电源地
-*
-* // 单排排针 SPI 两寸屏 硬件引脚
-* SCL 查看 zf_device_ips200.h 中 IPS200_SCL_PIN_SPI 宏定义
-* SDA 查看 zf_device_ips200.h 中 IPS200_SDA_PIN_SPI 宏定义
-* RST 查看 zf_device_ips200.h 中 IPS200_RST_PIN_SPI 宏定义
-* DC 查看 zf_device_ips200.h 中 IPS200_DC_PIN_SPI 宏定义
-* CS 查看 zf_device_ips200.h 中 IPS200_CS_PIN_SPI 宏定义
-* BLk 查看 zf_device_ips200.h 中 IPS200_BLk_PIN_SPI 宏定义
-* VCC 3.3V电源
-* GND 电源地
-* 最大分辨率 320 * 240
-* ------------------------------------
-********************************************************************************************************************/
+ * 接线定义:
+ * ------------------------------------
+ * 模块管脚 单片机管脚
+ * // 双排排针 并口两寸屏 硬件引脚
+ * RD 查看 zf_device_ips200.h 中 IPS200_RD_PIN_PARALLEL8 宏定义
+ * WR 查看 zf_device_ips200.h 中 IPS200_WR_PIN_PARALLEL8 宏定义
+ * RS 查看 zf_device_ips200.h 中 IPS200_RS_PIN_PARALLEL8 宏定义
+ * RST 查看 zf_device_ips200.h 中 IPS200_RST_PIN_PARALLEL8 宏定义
+ * CS 查看 zf_device_ips200.h 中 IPS200_CS_PIN_PARALLEL8 宏定义
+ * BL 查看 zf_device_ips200.h 中 IPS200_BL_PIN_PARALLEL8 宏定义
+ * D0-D7 查看 zf_device_ips200.h 中 IPS200_Dx_PIN_PARALLEL8 宏定义
+ * VCC 3.3V 电源
+ * GND 电源地
+ *
+ * // 单排排针 SPI 两寸屏 硬件引脚
+ * SCL 查看 zf_device_ips200.h 中 IPS200_SCL_PIN_SPI 宏定义
+ * SDA 查看 zf_device_ips200.h 中 IPS200_SDA_PIN_SPI 宏定义
+ * RST 查看 zf_device_ips200.h 中 IPS200_RST_PIN_SPI 宏定义
+ * DC 查看 zf_device_ips200.h 中 IPS200_DC_PIN_SPI 宏定义
+ * CS 查看 zf_device_ips200.h 中 IPS200_CS_PIN_SPI 宏定义
+ * BLk 查看 zf_device_ips200.h 中 IPS200_BLk_PIN_SPI 宏定义
+ * VCC 3.3V 电源
+ * GND 电源地
+ * 最大分辨率 320 * 240
+ * ------------------------------------
+ ********************************************************************************************************************/
#include "zf_common_clock.h"
#include "zf_common_debug.h"
@@ -72,21 +72,21 @@
#include "zf_device_ips200.h"
static uint16 ips200_pencolor = IPS200_DEFAULT_PENCOLOR;
-static uint16 ips200_bgcolor = IPS200_DEFAULT_BGCOLOR;
+static uint16 ips200_bgcolor = IPS200_DEFAULT_BGCOLOR;
-static ips200_type_enum ips200_display_type = IPS200_TYPE_SPI;
-static ips200_dir_enum ips200_display_dir = IPS200_DEFAULT_DISPLAY_DIR;
-static ips200_font_size_enum ips200_display_font = IPS200_DEFAULT_DISPLAY_FONT;
+static ips200_type_enum ips200_display_type = IPS200_TYPE_SPI;
+static ips200_dir_enum ips200_display_dir = IPS200_DEFAULT_DISPLAY_DIR;
+static ips200_font_size_enum ips200_display_font = IPS200_DEFAULT_DISPLAY_FONT;
static uint16 ips200_x_max = 240;
static uint16 ips200_y_max = 320;
-static gpio_pin_enum ips_rst_pin = IPS200_RST_PIN_SPI;
-static gpio_pin_enum ips_bl_pin = IPS200_BLk_PIN_SPI;
-static gpio_pin_enum ips_cs_pin = IPS200_CS_PIN_SPI;
+static gpio_pin_enum ips_rst_pin = IPS200_RST_PIN_SPI;
+static gpio_pin_enum ips_bl_pin = IPS200_BLk_PIN_SPI;
+static gpio_pin_enum ips_cs_pin = IPS200_CS_PIN_SPI;
#if IPS200_USE_SOFT_SPI
-static soft_spi_info_struct ips200_spi;
+static soft_spi_info_struct ips200_spi;
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 IPS200 SPI 写 8bit 数据
// 参数说明 data 数据
@@ -94,7 +94,7 @@ static soft_spi_info_struct ips200_spi;
// 使用示例 ips200_write_8bit_data_spi(command);
// 备注信息 内部调用
//-------------------------------------------------------------------------------------------------------------------
-#define ips200_write_8bit_data_spi(data) (soft_spi_write_8bit(&ips200_spi, (data)))
+#define ips200_write_8bit_data_spi(data) (soft_spi_write_8bit(&ips200_spi, (data)))
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 IPS200 SPI 写 8bit 数据数组
@@ -104,7 +104,7 @@ static soft_spi_info_struct ips200_spi;
// 使用示例 ips200_write_8bit_data_spi_array(data, len);
// 备注信息 内部调用
//-------------------------------------------------------------------------------------------------------------------
-#define ips200_write_8bit_data_spi_array(data, len) (soft_spi_write_8bit_array(&ips200_spi, (data), (len)))
+#define ips200_write_8bit_data_spi_array(data, len) (soft_spi_write_8bit_array(&ips200_spi, (data), (len)))
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 IPS200 SPI 写 16bit 数据
@@ -113,7 +113,7 @@ static soft_spi_info_struct ips200_spi;
// 使用示例 ips200_write_16bit_data_spi(dat);
// 备注信息 内部调用
//-------------------------------------------------------------------------------------------------------------------
-#define ips200_write_16bit_data_spi(data) (soft_spi_write_16bit(&ips200_spi, (data)))
+#define ips200_write_16bit_data_spi(data) (soft_spi_write_16bit(&ips200_spi, (data)))
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 IPS200 SPI 写 16bit 数据数组
@@ -123,7 +123,7 @@ static soft_spi_info_struct ips200_spi;
// 使用示例 ips200_write_16bit_data_spi_array(data, len);
// 备注信息 内部调用
//-------------------------------------------------------------------------------------------------------------------
-#define ips200_write_16bit_data_spi_array(data, len) (soft_spi_write_16bit_array(&ips200_spi, (data), (len)))
+#define ips200_write_16bit_data_spi_array(data, len) (soft_spi_write_16bit_array(&ips200_spi, (data), (len)))
#else
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 IPS200 SPI 写 8bit 数据
@@ -132,7 +132,7 @@ static soft_spi_info_struct ips200_spi;
// 使用示例 ips200_write_8bit_data_spi(command);
// 备注信息 内部调用
//-------------------------------------------------------------------------------------------------------------------
-#define ips200_write_8bit_data_spi(data) (spi_write_8bit(IPS200_SPI, (data)))
+#define ips200_write_8bit_data_spi(data) (spi_write_8bit(IPS200_SPI, (data)))
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 IPS200 SPI 写 8bit 数据数组
@@ -142,7 +142,7 @@ static soft_spi_info_struct ips200_spi;
// 使用示例 ips200_write_8bit_data_spi_array(data, len);
// 备注信息 内部调用
//-------------------------------------------------------------------------------------------------------------------
-#define ips200_write_8bit_data_spi_array(data, len) (spi_write_8bit_array(IPS200_SPI, (data), (len)))
+#define ips200_write_8bit_data_spi_array(data, len) (spi_write_8bit_array(IPS200_SPI, (data), (len)))
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 IPS200 SPI 写 16bit 数据
@@ -151,7 +151,7 @@ static soft_spi_info_struct ips200_spi;
// 使用示例 ips200_write_16bit_data_spi(dat);
// 备注信息 内部调用
//-------------------------------------------------------------------------------------------------------------------
-#define ips200_write_16bit_data_spi(data) (spi_write_16bit(IPS200_SPI, (data)))
+#define ips200_write_16bit_data_spi(data) (spi_write_16bit(IPS200_SPI, (data)))
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 IPS200 SPI 写 16bit 数据数组
@@ -161,7 +161,7 @@ static soft_spi_info_struct ips200_spi;
// 使用示例 ips200_write_16bit_data_spi_array(data, len);
// 备注信息 内部调用
//-------------------------------------------------------------------------------------------------------------------
-#define ips200_write_16bit_data_spi_array(data, len) (spi_write_16bit_array(IPS200_SPI, (data), (len)))
+#define ips200_write_16bit_data_spi_array(data, len) (spi_write_16bit_array(IPS200_SPI, (data), (len)))
#endif
//-------------------------------------------------------------------------------------------------------------------
@@ -171,13 +171,12 @@ static soft_spi_info_struct ips200_spi;
// 使用示例 ips200_write_16bit_data_spi(dat);
// 备注信息 内部调用
//-------------------------------------------------------------------------------------------------------------------
-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))
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 IPS200 写命令
@@ -186,10 +185,9 @@ static void ips200_write_data (const uint8 dat)
// 使用示例 ips200_write_command(0x2a);
// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
-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(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);
@@ -218,14 +214,11 @@ static void ips200_write_command (const uint8 command)
// 使用示例 ips200_write_8bit_data(0x0C);
// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
-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);
- }
- else
- {
+ } else {
IPS200_CS(0);
IPS200_RD(1);
IPS200_WR(0);
@@ -241,22 +234,18 @@ static void ips200_write_8bit_data (const uint8 dat)
// 使用示例 ips200_write_8bit_data(dat,1);
// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
-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);
- }
- else
- {
+ } else {
IPS200_CS(0);
IPS200_RD(1);
- while(len --)
- {
+ while (len--) {
IPS200_WR(0);
ips200_write_data((uint8)*dat);
IPS200_WR(1);
- dat ++;
+ dat++;
}
IPS200_CS(1);
}
@@ -269,14 +258,11 @@ static void ips200_write_8bit_data_array (const uint8 *dat, uint32 len)
// 使用示例 ips200_write_16bit_data(x1);
// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
-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);
- }
- else
- {
+ } else {
IPS200_CS(0);
IPS200_RD(1);
IPS200_WR(0);
@@ -295,25 +281,21 @@ static void ips200_write_16bit_data (const uint16 dat)
// 使用示例 ips200_write_16bit_data(x1);
// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
-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);
- }
- else
- {
+ } else {
IPS200_CS(0);
IPS200_RD(1);
- while(len --)
- {
+ while (len--) {
IPS200_WR(0);
ips200_write_data((uint8)(*dat >> 8));
IPS200_WR(1);
IPS200_WR(0);
ips200_write_data((uint8)(*dat & 0xFF));
IPS200_WR(1);
- dat ++;
+ dat++;
}
IPS200_CS(1);
}
@@ -321,15 +303,15 @@ static void ips200_write_16bit_data_array (const uint16 *dat, uint32 len)
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 设置显示区域
-// 参数说明 x1 起始x轴坐标
-// 参数说明 y1 起始y轴坐标
-// 参数说明 x2 结束x轴坐标
-// 参数说明 y2 结束y轴坐标
+// 参数说明 x1 起始 x 轴坐标
+// 参数说明 y1 起始 y 轴坐标
+// 参数说明 x2 结束 x 轴坐标
+// 参数说明 y2 结束 y 轴坐标
// 返回参数 void
// 使用示例 ips200_set_region(0, 0, ips200_x_max - 1, ips200_y_max - 1);
// 备注信息 内部调用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
-static void ips200_set_region (uint16 x1, uint16 y1, uint16 x2, uint16 y2)
+static void ips200_set_region(uint16 x1, uint16 y1, uint16 x2, uint16 y2)
{
// 如果程序在输出了断言信息 并且提示出错位置在这里
// 那么一般是屏幕显示的时候超过屏幕分辨率范围了
@@ -342,50 +324,46 @@ static void ips200_set_region (uint16 x1, uint16 y1, uint16 x2, uint16 y2)
ips200_write_command(0x2a);
ips200_write_16bit_data(x1);
ips200_write_16bit_data(x2);
-
+
ips200_write_command(0x2b);
ips200_write_16bit_data(y1);
ips200_write_16bit_data(y2);
-
+
ips200_write_command(0x2c);
}
//-------------------------------------------------------------------------------------------------------------------
-// 函数简介 IPS200 显示DEBUG信息初始化
+// 函数简介 IPS200 显示 DEBUG 信息初始化
// 参数说明 void
// 返回参数 void
// 使用示例 ips200_debug_init();
// 备注信息 内部使用 用户无需关心
//-------------------------------------------------------------------------------------------------------------------
-static void ips200_debug_init (void)
+static void ips200_debug_init(void)
{
debug_output_struct info;
debug_output_struct_init(&info);
- info.type_index = 1;
+ info.type_index = 1;
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:
- {
+ } break;
+ case IPS200_8X16_FONT: {
info.font_x_size = 8;
info.font_y_size = 16;
- }break;
- case IPS200_16X16_FONT:
- {
+ } break;
+ case IPS200_16X16_FONT: {
// 暂不支持
- }break;
+ } break;
}
- info.output_screen = ips200_show_string;
+ info.output_screen = ips200_show_string;
info.output_screen_clear = ips200_clear;
-
+
debug_output_init(&info);
}
@@ -396,26 +374,22 @@ static void ips200_debug_init (void)
// 使用示例 ips200_clear();
// 备注信息 将屏幕清空成背景颜色
//-------------------------------------------------------------------------------------------------------------------
-void ips200_clear (void)
+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);
}
}
@@ -427,26 +401,22 @@ void ips200_clear (void)
// 使用示例 ips200_full(RGB565_BLACK);
// 备注信息 将屏幕填充成指定颜色
//-------------------------------------------------------------------------------------------------------------------
-void ips200_full (const uint16 color)
+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);
}
}
@@ -458,23 +428,20 @@ void ips200_full (const uint16 color)
// 使用示例 ips200_set_dir(IPS200_PORTAIT);
// 备注信息 这个函数只有在初始化屏幕之前调用才生效
//-------------------------------------------------------------------------------------------------------------------
-void ips200_set_dir (ips200_dir_enum dir)
+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;
+ } break;
case IPS200_CROSSWISE:
- case IPS200_CROSSWISE_180:
- {
+ case IPS200_CROSSWISE_180: {
ips200_x_max = 320;
ips200_y_max = 240;
- }break;
+ } break;
}
}
@@ -485,7 +452,7 @@ void ips200_set_dir (ips200_dir_enum dir)
// 使用示例 ips200_set_font(IPS200_8x16_FONT);
// 备注信息 字体可以随时自由设置 设置后生效 后续显示就是新的字体大小
//-------------------------------------------------------------------------------------------------------------------
-void ips200_set_font (ips200_font_size_enum font)
+void ips200_set_font(ips200_font_size_enum font)
{
ips200_display_font = font;
}
@@ -498,52 +465,50 @@ void ips200_set_font (ips200_font_size_enum font)
// 使用示例 ips200_set_color(RGB565_RED, RGB565_GRAY);
// 备注信息 字体颜色和背景颜色也可以随时自由设置 设置后生效
//-------------------------------------------------------------------------------------------------------------------
-void ips200_set_color (const uint16 pen, const uint16 bgcolor)
+void ips200_set_color(const uint16 pen, const uint16 bgcolor)
{
ips200_pencolor = pen;
- ips200_bgcolor = bgcolor;
+ ips200_bgcolor = bgcolor;
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 IPS200 画点
-// 参数说明 x 坐标x方向的起点 [0, ips200_x_max-1]
-// 参数说明 y 坐标y方向的起点 [0, ips200_y_max-1]
+// 参数说明 x 坐标 x 方向的起点 [0, ips200_x_max-1]
+// 参数说明 y 坐标 y 方向的起点 [0, ips200_y_max-1]
// 参数说明 color 颜色格式 RGB565 或者可以使用 zf_common_font.h 内 rgb565_color_enum 枚举值或者自行写入
// 返回参数 void
-// 使用示例 ips200_draw_point(0, 0, RGB565_RED); //坐标0,0画一个红色的点
+// 使用示例 ips200_draw_point(0, 0, RGB565_RED); //坐标 0,0 画一个红色的点
// 备注信息
//-------------------------------------------------------------------------------------------------------------------
-void ips200_draw_point (uint16 x, uint16 y, const uint16 color)
+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);
}
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 IPS200 画线
-// 参数说明 x_start 坐标x方向的起点 [0, ips200_x_max-1]
-// 参数说明 y_start 坐标y方向的起点 [0, ips200_y_max-1]
-// 参数说明 x_end 坐标x方向的终点 [0, ips200_x_max-1]
-// 参数说明 y_end 坐标y方向的终点 [0, ips200_y_max-1]
+// 参数说明 x_start 坐标 x 方向的起点 [0, ips200_x_max-1]
+// 参数说明 y_start 坐标 y 方向的起点 [0, ips200_y_max-1]
+// 参数说明 x_end 坐标 x 方向的终点 [0, ips200_x_max-1]
+// 参数说明 y_end 坐标 y 方向的终点 [0, ips200_y_max-1]
// 参数说明 color 颜色格式 RGB565 或者可以使用 zf_common_font.h 内 rgb565_color_enum 枚举值或者自行写入
// 返回参数 void
// 使用示例 ips200_draw_line(0, 0, 10, 10, RGB565_RED); // 坐标 0,0 到 10,10 画一条红色的线
// 备注信息
//-------------------------------------------------------------------------------------------------------------------
-void ips200_draw_line (uint16 x_start, uint16 y_start, uint16 x_end, uint16 y_end, const uint16 color)
+void ips200_draw_line(uint16 x_start, uint16 y_start, uint16 x_end, uint16 y_end, const uint16 color)
{
// 如果程序在输出了断言信息 并且提示出错位置在这里
// 那么一般是屏幕显示的时候超过屏幕分辨率范围了
@@ -552,61 +517,51 @@ void ips200_draw_line (uint16 x_start, uint16 y_start, uint16 x_end, uint16 y_en
zf_assert(x_end < ips200_x_max);
zf_assert(y_end < ips200_y_max);
- int16 x_dir = (x_start < x_end ? 1 : -1);
- int16 y_dir = (y_start < y_end ? 1 : -1);
+ int16 x_dir = (x_start < x_end ? 1 : -1);
+ int16 y_dir = (y_start < y_end ? 1 : -1);
float temp_rate = 0;
- float temp_b = 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)
- {
+ temp_b = (float)y_start - (float)x_start * temp_rate;
+ } 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);
}
ips200_draw_point(x_start, y_start, color);
}
- }while(0);
+ } while (0);
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 IPS200 显示字符
-// 参数说明 x 坐标x方向的起点 参数范围 [0, ips200_x_max-1]
-// 参数说明 y 坐标y方向的起点 参数范围 [0, ips200_y_max-1]
+// 参数说明 x 坐标 x 方向的起点 参数范围 [0, ips200_x_max-1]
+// 参数说明 y 坐标 y 方向的起点 参数范围 [0, ips200_y_max-1]
// 参数说明 dat 需要显示的字符
// 返回参数 void
-// 使用示例 ips200_show_char(0, 0, 'x'); // 坐标0,0写一个字符x
+// 使用示例 ips200_show_char(0, 0, 'x'); // 坐标 0,0 写一个字符 x
// 备注信息
//-------------------------------------------------------------------------------------------------------------------
-void ips200_show_char (uint16 x, uint16 y, const char dat)
+void ips200_show_char(uint16 x, uint16 y, const char dat)
{
// 如果程序在输出了断言信息 并且提示出错位置在这里
// 那么一般是屏幕显示的时候超过屏幕分辨率范围了
@@ -615,121 +570,104 @@ 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:
- {
- uint16 display_buffer[6*8];
+ 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;
}
}
- ips200_write_16bit_data_array(display_buffer, 6*8);
- }break;
- case IPS200_8X16_FONT:
- {
- uint16 display_buffer[8*16];
+ ips200_write_16bit_data_array(display_buffer, 6 * 8);
+ } break;
+ case IPS200_8X16_FONT: {
+ uint16 display_buffer[8 * 16];
ips200_set_region(x, y, x + 7, y + 15);
- for(i = 0; 8 > i; i ++)
- {
- uint8 temp_top = ascii_font_8x16[dat - 32][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;
}
}
ips200_write_16bit_data_array(display_buffer, 8 * 16);
- }break;
- case IPS200_16X16_FONT:
- {
+ } break;
+ case IPS200_16X16_FONT: {
// 暂不支持
- }break;
+ } break;
}
- if(IPS200_TYPE_SPI == ips200_display_type)
- {
+ if (IPS200_TYPE_SPI == ips200_display_type) {
IPS200_CS(1);
}
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 IPS200 显示字符串
-// 参数说明 x 坐标x方向的起点 参数范围 [0, ips200_x_max-1]
-// 参数说明 y 坐标y方向的起点 参数范围 [0, ips200_y_max-1]
+// 参数说明 x 坐标 x 方向的起点 参数范围 [0, ips200_x_max-1]
+// 参数说明 y 坐标 y 方向的起点 参数范围 [0, ips200_y_max-1]
// 参数说明 dat 需要显示的字符串
// 返回参数 void
// 使用示例 ips200_show_string(0, 0, "seekfree");
// 备注信息
//-------------------------------------------------------------------------------------------------------------------
-void ips200_show_string (uint16 x, uint16 y, const char dat[])
+void ips200_show_string(uint16 x, uint16 y, const char dat[])
{
// 如果程序在输出了断言信息 并且提示出错位置在这里
// 那么一般是屏幕显示的时候超过屏幕分辨率范围了
zf_assert(x < ips200_x_max);
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 ++;
+ j++;
}
}
//-------------------------------------------------------------------------------------------------------------------
-// 函数简介 IPS200 显示32位有符号 (去除整数部分无效的0)
-// 参数说明 x 坐标x方向的起点 参数范围 [0, ips200_x_max-1]
-// 参数说明 y 坐标y方向的起点 参数范围 [0, ips200_y_max-1]
+// 函数简介 IPS200 显示 32 位有符号 (去除整数部分无效的 0)
+// 参数说明 x 坐标 x 方向的起点 参数范围 [0, ips200_x_max-1]
+// 参数说明 y 坐标 y 方向的起点 参数范围 [0, ips200_y_max-1]
// 参数说明 dat 需要显示的变量 数据类型 int32
-// 参数说明 num 需要显示的位数 最高10位 不包含正负号
+// 参数说明 num 需要显示的位数 最高 10 位 不包含正负号
// 返回参数 void
// 使用示例 ips200_show_int(0, 0, x, 3); // x 可以为 int32 int16 int8 类型
-// 备注信息 负数会显示一个 ‘-’号
+// 备注信息 负数会显示一个‘-’号
//-------------------------------------------------------------------------------------------------------------------
-void ips200_show_int (uint16 x, uint16 y, const int32 dat, uint8 num)
+void ips200_show_int(uint16 x, uint16 y, const int32 dat, uint8 num)
{
// 如果程序在输出了断言信息 并且提示出错位置在这里
// 那么一般是屏幕显示的时候超过屏幕分辨率范围了
@@ -739,17 +677,15 @@ void ips200_show_int (uint16 x, uint16 y, const int32 dat, uint8 num)
zf_assert(10 >= num);
int32 dat_temp = dat;
- int32 offset = 1;
+ int32 offset = 1;
char data_buffer[12];
memset(data_buffer, 0, 12);
- memset(data_buffer, ' ', num+1);
+ 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;
@@ -759,16 +695,16 @@ void ips200_show_int (uint16 x, uint16 y, const int32 dat, uint8 num)
}
//-------------------------------------------------------------------------------------------------------------------
-// 函数简介 IPS200 显示32位无符号 (去除整数部分无效的0)
-// 参数说明 x 坐标x方向的起点 参数范围 [0, ips114_x_max-1]
-// 参数说明 y 坐标y方向的起点 参数范围 [0, ips114_y_max-1]
+// 函数简介 IPS200 显示 32 位无符号 (去除整数部分无效的 0)
+// 参数说明 x 坐标 x 方向的起点 参数范围 [0, ips114_x_max-1]
+// 参数说明 y 坐标 y 方向的起点 参数范围 [0, ips114_y_max-1]
// 参数说明 dat 需要显示的变量 数据类型 uint32
-// 参数说明 num 需要显示的位数 最高10位 不包含正负号
+// 参数说明 num 需要显示的位数 最高 10 位 不包含正负号
// 返回参数 void
// 使用示例 ips200_show_uint(0, 0, x, 3); // x 可以为 uint32 uint16 uint8 类型
// 备注信息
//-------------------------------------------------------------------------------------------------------------------
-void ips200_show_uint (uint16 x, uint16 y, const uint32 dat, uint8 num)
+void ips200_show_uint(uint16 x, uint16 y, const uint32 dat, uint8 num)
{
// 如果程序在输出了断言信息 并且提示出错位置在这里
// 那么一般是屏幕显示的时候超过屏幕分辨率范围了
@@ -778,16 +714,14 @@ void ips200_show_uint (uint16 x, uint16 y, const uint32 dat, uint8 num)
zf_assert(10 >= num);
uint32 dat_temp = dat;
- int32 offset = 1;
+ int32 offset = 1;
char data_buffer[12];
memset(data_buffer, 0, 12);
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;
@@ -797,20 +731,20 @@ void ips200_show_uint (uint16 x, uint16 y, const uint32 dat, uint8 num)
}
//-------------------------------------------------------------------------------------------------------------------
-// 函数简介 IPS200 显示浮点数(去除整数部分无效的0)
-// 参数说明 x 坐标x方向的起点 参数范围 [0, ips200_x_max-1]
-// 参数说明 y 坐标y方向的起点 参数范围 [0, ips200_y_max-1]
+// 函数简介 IPS200 显示浮点数 (去除整数部分无效的 0)
+// 参数说明 x 坐标 x 方向的起点 参数范围 [0, ips200_x_max-1]
+// 参数说明 y 坐标 y 方向的起点 参数范围 [0, ips200_y_max-1]
// 参数说明 dat 需要显示的变量 数据类型 double
-// 参数说明 num 整数位显示长度 最高8位
-// 参数说明 pointnum 小数位显示长度 最高6位
+// 参数说明 num 整数位显示长度 最高 8 位
+// 参数说明 pointnum 小数位显示长度 最高 6 位
// 返回参数 void
-// 使用示例 ips200_show_float(0, 0, x, 2, 3); // 显示浮点数 整数显示2位 小数显示三位
+// 使用示例 ips200_show_float(0, 0, x, 2, 3); // 显示浮点数 整数显示 2 位 小数显示三位
// 备注信息 特别注意当发现小数部分显示的值与你写入的值不一样的时候,
// 可能是由于浮点数精度丢失问题导致的,这并不是显示函数的问题,
// 有关问题的详情,请自行百度学习 浮点数精度丢失问题。
-// 负数会显示一个 ‘-’号
+// 负数会显示一个‘-’号
//-------------------------------------------------------------------------------------------------------------------
-void ips200_show_float (uint16 x, uint16 y, const double dat, uint8 num, uint8 pointnum)
+void ips200_show_float(uint16 x, uint16 y, const double dat, uint8 num, uint8 pointnum)
{
// 如果程序在输出了断言信息 并且提示出错位置在这里
// 那么一般是屏幕显示的时候超过屏幕分辨率范围了
@@ -822,14 +756,13 @@ void ips200_show_float (uint16 x, uint16 y, const double dat, uint8 num, uint8 p
zf_assert(6 >= pointnum);
double dat_temp = dat;
- double offset = 1.0;
+ double offset = 1.0;
char data_buffer[17];
memset(data_buffer, 0, 17);
- memset(data_buffer, ' ', num+pointnum+2);
+ 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;
@@ -839,8 +772,8 @@ void ips200_show_float (uint16 x, uint16 y, const double dat, uint8 num, uint8 p
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 IPS200 显示二值图像 数据每八个点组成一个字节数据
-// 参数说明 x 坐标x方向的起点 参数范围 [0, ips200_x_max-1]
-// 参数说明 y 坐标y方向的起点 参数范围 [0, ips200_y_max-1]
+// 参数说明 x 坐标 x 方向的起点 参数范围 [0, ips200_x_max-1]
+// 参数说明 y 坐标 y 方向的起点 参数范围 [0, ips200_y_max-1]
// 参数说明 *image 图像数组指针
// 参数说明 width 图像实际宽度
// 参数说明 height 图像实际高度
@@ -853,7 +786,7 @@ void ips200_show_float (uint16 x, uint16 y, const double dat, uint8 num, uint8 p
// 这个函数不可以用来直接显示总钻风的未压缩的二值化图像
// 这个函数不可以用来直接显示总钻风的未压缩的二值化图像
//-------------------------------------------------------------------------------------------------------------------
-void ips200_show_binary_image (uint16 x, uint16 y, const uint8 *image, uint16 width, uint16 height, uint16 dis_width, uint16 dis_height)
+void ips200_show_binary_image(uint16 x, uint16 y, const uint8 *image, uint16 width, uint16 height, uint16 dis_width, uint16 dis_height)
{
// 如果程序在输出了断言信息 并且提示出错位置在这里
// 那么一般是屏幕显示的时候超过屏幕分辨率范围了
@@ -862,45 +795,38 @@ void ips200_show_binary_image (uint16 x, uint16 y, const uint8 *image, uint16 wi
zf_assert(NULL != image);
uint32 i = 0, j = 0;
- uint8 temp = 0;
+ uint8 temp = 0;
uint32 width_index = 0;
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); // 设置显示区域
+ ips200_set_region(x, y, x + dis_width - 1, y + dis_height - 1); // 设置显示区域
- 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 (j = 0; j < dis_height; j++) {
+ image_temp = image + j * height / dis_height * width / 8; // 直接对 image 操作会 Hardfault 暂时不知道为什么
+ 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)))
- {
+ temp = *(image_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);
}
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 IPS200 显示 8bit 灰度图像 带二值化阈值
-// 参数说明 x 坐标x方向的起点 参数范围 [0, ips200_x_max-1]
-// 参数说明 y 坐标y方向的起点 参数范围 [0, ips200_y_max-1]
+// 参数说明 x 坐标 x 方向的起点 参数范围 [0, ips200_x_max-1]
+// 参数说明 y 坐标 y 方向的起点 参数范围 [0, ips200_y_max-1]
// 参数说明 *image 图像数组指针
// 参数说明 width 图像实际宽度
// 参数说明 height 图像实际高度
@@ -914,7 +840,7 @@ void ips200_show_binary_image (uint16 x, uint16 y, const uint8 *image, uint16 wi
// 如果要显示二值化图像 直接修改最后一个参数为需要的二值化阈值即可
// 如果要显示二值化图像 直接修改最后一个参数为需要的二值化阈值即可
//-------------------------------------------------------------------------------------------------------------------
-void ips200_show_gray_image (uint16 x, uint16 y, const uint8 *image, uint16 width, uint16 height, uint16 dis_width, uint16 dis_height, uint8 threshold)
+void ips200_show_gray_image(uint16 x, uint16 y, const uint8 *image, uint16 width, uint16 height, uint16 dis_width, uint16 dis_height, uint8 threshold)
{
// 如果程序在输出了断言信息 并且提示出错位置在这里
// 那么一般是屏幕显示的时候超过屏幕分辨率范围了
@@ -923,50 +849,41 @@ void ips200_show_gray_image (uint16 x, uint16 y, const uint8 *image, uint16 widt
zf_assert(NULL != image);
uint32 i = 0, j = 0;
- uint16 color = 0,temp = 0;
+ uint16 color = 0, temp = 0;
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); // 设置显示区域
+ ips200_set_region(x, y, x + dis_width - 1, y + dis_height - 1); // 设置显示区域
- for(j = 0; j < dis_height; j ++)
- {
- image_temp = image + j * height / dis_height * width; // 直接对 image 操作会 Hardfault 暂时不知道为什么
- for(i = 0; i < dis_width; i ++)
- {
- temp = *(image_temp + i * width / dis_width); // 读取像素点
- if(threshold == 0)
- {
- color = (0x001f & ((temp) >> 3)) << 11;
- color = color | (((0x003f) & ((temp) >> 2)) << 5);
- color = color | (0x001f & ((temp) >> 3));
+ for (j = 0; j < dis_height; j++) {
+ image_temp = image + j * height / dis_height * width; // 直接对 image 操作会 Hardfault 暂时不知道为什么
+ for (i = 0; i < dis_width; i++) {
+ temp = *(image_temp + i * width / dis_width); // 读取像素点
+ 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);
}
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 IPS200 显示 RGB565 彩色图像
-// 参数说明 x 坐标x方向的起点 参数范围 [0, ips200_x_max-1]
-// 参数说明 y 坐标y方向的起点 参数范围 [0, ips200_y_max-1]
+// 参数说明 x 坐标 x 方向的起点 参数范围 [0, ips200_x_max-1]
+// 参数说明 y 坐标 y 方向的起点 参数范围 [0, ips200_y_max-1]
// 参数说明 *image 图像数组指针
// 参数说明 width 图像实际宽度
// 参数说明 height 图像实际高度
@@ -980,7 +897,7 @@ void ips200_show_gray_image (uint16 x, uint16 y, const uint8 *image, uint16 widt
// 如果要显示低位在前的其他 RGB565 图像 修改最后一个参数即可
// 如果要显示低位在前的其他 RGB565 图像 修改最后一个参数即可
//-------------------------------------------------------------------------------------------------------------------
-void ips200_show_rgb565_image (uint16 x, uint16 y, const uint16 *image, uint16 width, uint16 height, uint16 dis_width, uint16 dis_height, uint8 color_mode)
+void ips200_show_rgb565_image(uint16 x, uint16 y, const uint16 *image, uint16 width, uint16 height, uint16 dis_width, uint16 dis_height, uint8 color_mode)
{
// 如果程序在输出了断言信息 并且提示出错位置在这里
// 那么一般是屏幕显示的时候超过屏幕分辨率范围了
@@ -992,38 +909,31 @@ 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); // 设置显示区域
+ ips200_set_region(x, y, x + dis_width - 1, y + dis_height - 1); // 设置显示区域
- for(j = 0; j < dis_height; j ++)
- {
- image_temp = image + j * height / dis_height * width; // 直接对 image 操作会 Hardfault 暂时不知道为什么
- for(i = 0; i < dis_width; i ++)
- {
- data_buffer[i] = *(image_temp + i * width / dis_width); // 读取像素点
+ for (j = 0; j < dis_height; j++) {
+ image_temp = image + j * height / dis_height * width; // 直接对 image 操作会 Hardfault 暂时不知道为什么
+ 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);
}
}
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 IPS200 显示波形
-// 参数说明 x 坐标x方向的起点 参数范围 [0, ips200_x_max-1]
-// 参数说明 y 坐标y方向的起点 参数范围 [0, ips200_y_max-1]
+// 参数说明 x 坐标 x 方向的起点 参数范围 [0, ips200_x_max-1]
+// 参数说明 y 坐标 y 方向的起点 参数范围 [0, ips200_y_max-1]
// 参数说明 *wave 波形数组指针
// 参数说明 width 波形实际宽度
// 参数说明 value_max 波形实际最大值
@@ -1033,7 +943,7 @@ void ips200_show_rgb565_image (uint16 x, uint16 y, const uint16 *image, uint16 w
// 使用示例 ips200_show_wave(0, 0, data, 128, 64, 64, 32);
// 备注信息
//-------------------------------------------------------------------------------------------------------------------
-void ips200_show_wave (uint16 x, uint16 y, const uint16 *wave, uint16 width, uint16 value_max, uint16 dis_width, uint16 dis_value_max)
+void ips200_show_wave(uint16 x, uint16 y, const uint16 *wave, uint16 width, uint16 value_max, uint16 dis_width, uint16 dis_value_max)
{
// 如果程序在输出了断言信息 并且提示出错位置在这里
// 那么一般是屏幕显示的时候超过屏幕分辨率范围了
@@ -1045,28 +955,22 @@ 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 ++)
- {
- data_buffer[i] = (ips200_bgcolor);
+ 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++) {
+ 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 ++)
- {
- width_index = i * width / dis_width;
+ 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);
}
@@ -1074,17 +978,17 @@ void ips200_show_wave (uint16 x, uint16 y, const uint16 *wave, uint16 width, uin
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 汉字显示
-// 参数说明 x 坐标x方向的起点 参数范围 [0, ips200_x_max-1]
-// 参数说明 y 坐标y方向的起点 参数范围 [0, ips200_y_max-1]
+// 参数说明 x 坐标 x 方向的起点 参数范围 [0, ips200_x_max-1]
+// 参数说明 y 坐标 y 方向的起点 参数范围 [0, ips200_y_max-1]
// 参数说明 size 取模的时候设置的汉字字体大小 也就是一个汉字占用的点阵长宽为多少个点 取模的时候需要长宽是一样的
// 参数说明 *chinese_buffer 需要显示的汉字数组
// 参数说明 number 需要显示多少位
// 参数说明 color 颜色格式 RGB565 或者可以使用 zf_common_font.h 内 rgb565_color_enum 枚举值或者自行写入
// 返回参数 void
-// 使用示例 ips200_show_chinese(0, 0, 16, chinese_test[0], 4, RGB565_RED);//显示font文件里面的 示例
-// 备注信息 使用PCtoLCD2002软件取模 阴码、逐行式、顺向 16*16
+// 使用示例 ips200_show_chinese(0, 0, 16, chinese_test[0], 4, RGB565_RED);//显示 font 文件里面的 示例
+// 备注信息 使用 PCtoLCD2002 软件取模 阴码、逐行式、顺向 16*16
//-------------------------------------------------------------------------------------------------------------------
-void ips200_show_chinese (uint16 x, uint16 y, uint8 size, const uint8 *chinese_buffer, uint8 number, const uint16 color)
+void ips200_show_chinese(uint16 x, uint16 y, uint8 size, const uint8 *chinese_buffer, uint8 number, const uint16 color)
{
// 如果程序在输出了断言信息 并且提示出错位置在这里
// 那么一般是屏幕显示的时候超过屏幕分辨率范围了
@@ -1092,64 +996,54 @@ void ips200_show_chinese (uint16 x, uint16 y, uint8 size, const uint8 *chinese_b
zf_assert(y < ips200_y_max);
zf_assert(NULL != chinese_buffer);
- int i = 0, j = 0, k = 0;
+ int i = 0, j = 0, k = 0;
uint8 temp = 0, temp1 = 0, temp2 = 0;
const uint8 *p_data = chinese_buffer;
-
+
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 ++)
- {
- temp1 = number;
+
+ 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);
}
}
- p_data ++;
+ p_data++;
}
p_data = p_data - temp2 + temp2 * size;
- }
+ }
}
- if(IPS200_TYPE_SPI == ips200_display_type)
- {
+ if (IPS200_TYPE_SPI == ips200_display_type) {
IPS200_CS(1);
}
}
//-------------------------------------------------------------------------------------------------------------------
-// 函数简介 2寸 IPS液晶初始化
+// 函数简介 2 寸 IPS 液晶初始化
// 参数说明 type_select 两寸屏接口类型 IPS200_TYPE_SPI 为 SPI 接口串口两寸屏 IPS200_TYPE_PARALLEL8 为 8080 协议八位并口两寸屏
// 返回参数 void
// 使用示例 ips200_init(IPS200_TYPE_PARALLEL8);
// 备注信息
//-------------------------------------------------------------------------------------------------------------------
-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;
- ips_rst_pin = IPS200_RST_PIN_SPI;
- ips_bl_pin = IPS200_BLk_PIN_SPI;
- ips_cs_pin = IPS200_CS_PIN_SPI;
+ ips_rst_pin = IPS200_RST_PIN_SPI;
+ ips_bl_pin = IPS200_BLk_PIN_SPI;
+ ips_cs_pin = IPS200_CS_PIN_SPI;
#if IPS200_USE_SOFT_SPI
soft_spi_init(&ips200_spi, 0, IPS200_SOFT_SPI_DELAY, IPS200_SCL_PIN, IPS200_SDA_PIN, SOFT_SPI_PIN_NULL, SOFT_SPI_PIN_NULL);
#else
@@ -1160,65 +1054,68 @@ 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;
- ips_cs_pin = IPS200_CS_PIN_PARALLEL8;
+ ips_rst_pin = IPS200_RST_PIN_PARALLEL8;
+ ips_bl_pin = IPS200_BL_PIN_PARALLEL8;
+ ips_cs_pin = IPS200_CS_PIN_PARALLEL8;
- gpio_init(IPS200_RD_PIN_PARALLEL8, GPO, 1, GPO_PUSH_PULL);
- gpio_init(IPS200_WR_PIN_PARALLEL8, GPO, 1, GPO_PUSH_PULL);
- gpio_init(IPS200_RS_PIN_PARALLEL8, GPO, 1, GPO_PUSH_PULL);
+ gpio_init(IPS200_RD_PIN_PARALLEL8, GPO, 1, GPO_PUSH_PULL);
+ gpio_init(IPS200_WR_PIN_PARALLEL8, GPO, 1, GPO_PUSH_PULL);
+ gpio_init(IPS200_RS_PIN_PARALLEL8, GPO, 1, GPO_PUSH_PULL);
gpio_init(IPS200_RST_PIN_PARALLEL8, GPO, 1, GPO_PUSH_PULL);
- gpio_init(IPS200_CS_PIN_PARALLEL8, GPO, 1, GPO_PUSH_PULL);
- gpio_init(IPS200_BL_PIN_PARALLEL8, GPO, 1, GPO_PUSH_PULL);
- //#define GPIOA_BASE (APB2PERIPH_BASE + 0x0800)
- //#define GPIOB_BASE (APB2PERIPH_BASE + 0x0C00)
- //#define GPIOC_BASE (APB2PERIPH_BASE + 0x1000)
- //#define GPIOD_BASE (APB2PERIPH_BASE + 0x1400)
- //#define GPIOE_BASE (APB2PERIPH_BASE + 0x1800)
- //#define GPIOF_BASE (APB2PERIPH_BASE + 0x1C00)
- //#define GPIOG_BASE (APB2PERIPH_BASE + 0x2000)
+ gpio_init(IPS200_CS_PIN_PARALLEL8, GPO, 1, GPO_PUSH_PULL);
+ gpio_init(IPS200_BL_PIN_PARALLEL8, GPO, 1, GPO_PUSH_PULL);
+ // #define GPIOA_BASE (APB2PERIPH_BASE + 0x0800)
+ // #define GPIOB_BASE (APB2PERIPH_BASE + 0x0C00)
+ // #define GPIOC_BASE (APB2PERIPH_BASE + 0x1000)
+ // #define GPIOD_BASE (APB2PERIPH_BASE + 0x1400)
+ // #define GPIOE_BASE (APB2PERIPH_BASE + 0x1800)
+ // #define GPIOF_BASE (APB2PERIPH_BASE + 0x1C00)
+ // #define GPIOG_BASE (APB2PERIPH_BASE + 0x2000)
- uint8 i = 0;
- uint8 pin_value = (((uint32)IPS200_DATAPORT - GPIOA_BASE)/0x400) * 0x20 + DATA_START_NUM; // 获取端口的枚举体值
+ 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);
}
}
ips200_set_dir(ips200_display_dir);
ips200_set_color(ips200_pencolor, ips200_bgcolor);
-
+
IPS200_BL(1);
- IPS200_RST(0);
+ IPS200_RST(0);
system_delay_ms(5);
- IPS200_RST(1);
+ 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);
ips200_write_8bit_data(0x05);
-
+
ips200_write_command(0xB2);
ips200_write_8bit_data(0x0C);
ips200_write_8bit_data(0x0C);
@@ -1230,27 +1127,27 @@ void ips200_init (ips200_type_enum type_select)
ips200_write_8bit_data(0x35);
ips200_write_command(0xBB);
- ips200_write_8bit_data(0x29); // 32 Vcom=1.35V
+ ips200_write_8bit_data(0x29); // 32 Vcom=1.35V
ips200_write_command(0xC2);
ips200_write_8bit_data(0x01);
ips200_write_command(0xC3);
- ips200_write_8bit_data(0x19); // GVDD=4.8V
+ ips200_write_8bit_data(0x19); // GVDD=4.8V
ips200_write_command(0xC4);
- ips200_write_8bit_data(0x20); // VDV, 0x20:0v
+ ips200_write_8bit_data(0x20); // VDV, 0x20:0v
ips200_write_command(0xC5);
- ips200_write_8bit_data(0x1A); // VCOM Offset Set
+ ips200_write_8bit_data(0x1A); // VCOM Offset Set
ips200_write_command(0xC6);
- ips200_write_8bit_data(0x01F); // 0x0F:60Hz
+ ips200_write_8bit_data(0x01F); // 0x0F:60Hz
ips200_write_command(0xD0);
ips200_write_8bit_data(0xA4);
ips200_write_8bit_data(0xA1);
-
+
ips200_write_command(0xE0);
ips200_write_8bit_data(0xD0);
ips200_write_8bit_data(0x08);
@@ -1267,7 +1164,7 @@ void ips200_init (ips200_type_enum type_select)
ips200_write_8bit_data(0x31);
ips200_write_8bit_data(0x34);
- ips200_write_command(0xE1);
+ ips200_write_command(0xE1);
ips200_write_8bit_data(0xD0);
ips200_write_8bit_data(0x08);
ips200_write_8bit_data(0x0E);
@@ -1284,13 +1181,12 @@ void ips200_init (ips200_type_enum type_select)
ips200_write_8bit_data(0x34);
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);
}
- ips200_clear(); // 初始化为白屏
+ ips200_clear(); // 初始化为白屏
ips200_debug_init();
}
diff --git a/libraries/zf_device/zf_device_ips200.h b/libraries/zf_device/zf_device_ips200.h
index 8a4c04d..3ff2843 100644
--- a/libraries/zf_device/zf_device_ips200.h
+++ b/libraries/zf_device/zf_device_ips200.h
@@ -64,7 +64,7 @@
#include "zf_common_typedef.h"
-// --------------------单排两寸屏幕SPI接口引脚定义--------------------//
+// --------------------单排两寸屏幕 SPI 接口引脚定义--------------------//
#define IPS200_USE_SOFT_SPI (0 ) // 默认使用硬件 SPI 方式驱动 建议使用硬件 SPI 方式驱动
#if IPS200_USE_SOFT_SPI // 这两段 颜色正常的才是正确的 颜色灰的就是没有用的
@@ -85,13 +85,18 @@
#endif
// 如果使用的是单排排针的两寸屏幕 SPI 驱动控制引脚 可以修改
-#define IPS200_RST_PIN_SPI (B7 ) // 液晶复位引脚定义
-#define IPS200_DC_PIN_SPI (D7 ) // 液晶命令位引脚定义
-#define IPS200_CS_PIN_SPI (D4 )
-#define IPS200_BLk_PIN_SPI (D0 )
+// #define IPS200_RST_PIN_SPI (B7 ) // 液晶复位引脚定义
+// #define IPS200_DC_PIN_SPI (D7 ) // 液晶命令位引脚定义
+// #define IPS200_CS_PIN_SPI (D4 )
+// #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 接口引脚定义--------------------//
@@ -103,16 +108,16 @@
#define IPS200_CS_PIN_PARALLEL8 (D4 )
#define IPS200_BL_PIN_PARALLEL8 (D0 )
-//8个数据引脚必须连续 例如B0-B7,B6-B13等等。
+//8 个数据引脚必须连续 例如 B0-B7,B6-B13 等等。
//--------------数据端口寄存器--------------
#define IPS200_DATAPORT GPIOE
//--------------数据端口起始地址偏移--------------
#define DATA_START_NUM 0
-//例:D1-D8 IPS200_DATAPORT设置为GPIOD DATA_START_NUM设置为1
-//例:C5-C12 IPS200_DATAPORT设置为GPIOC DATA_START_NUM设置为5
-// --------------------双排SPI接口两寸屏幕引脚定义--------------------//
+//例:D1-D8 IPS200_DATAPORT 设置为 GPIOD DATA_START_NUM 设置为 1
+//例:C5-C12 IPS200_DATAPORT 设置为 GPIOC DATA_START_NUM 设置为 5
+// --------------------双排 SPI 接口两寸屏幕引脚定义--------------------//
#define IPS200_DEFAULT_DISPLAY_DIR (IPS200_PORTAIT) // 默认的显示方向
#define IPS200_DEFAULT_PENCOLOR (RGB565_RED ) // 默认的画笔颜色
@@ -139,9 +144,9 @@ typedef enum
typedef enum
{
IPS200_PORTAIT = 0, // 竖屏模式
- IPS200_PORTAIT_180 = 1, // 竖屏模式 旋转180
+ IPS200_PORTAIT_180 = 1, // 竖屏模式 旋转 180
IPS200_CROSSWISE = 2, // 横屏模式
- IPS200_CROSSWISE_180 = 3, // 横屏模式 旋转180
+ IPS200_CROSSWISE_180 = 3, // 横屏模式 旋转 180
}ips200_dir_enum;
typedef enum