This commit is contained in:
bmy
2024-01-08 22:16:40 +08:00
5 changed files with 228 additions and 149 deletions

View File

@@ -30,6 +30,7 @@
int main(void) int main(void)
{ {
clock_init(SYSTEM_CLOCK_120M); clock_init(SYSTEM_CLOCK_120M);
system_delay_init(); system_delay_init();
debug_init(); debug_init();
@@ -49,7 +50,6 @@ int main(void)
Page_Run(); Page_Run();
queue_pop_read(); queue_pop_read();
if (mt9v03x_finish_flag) { if (mt9v03x_finish_flag) {
// 该操作消耗大概 1970 个 tick折合约 110us // 该操作消耗大概 1970 个 tick折合约 110us
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)));

View File

@@ -17,8 +17,10 @@ void Print_Curser(uint8_t Curser_In, uint8_t Curser_Last_In)
ips200_draw_point(10 + i, Curser_Last_In * 18 + 19, IPS200_DEFAULT_BGCOLOR); ips200_draw_point(10 + i, Curser_Last_In * 18 + 19, IPS200_DEFAULT_BGCOLOR);
// system_delay_us(200); // system_delay_us(200);
} }
ips200_draw_rect(10, Curser_Last_In * 18 + 19, 170, Curser_Last_In * 18 + 19, IPS200_DEFAULT_BGCOLOR);
for (uint8_t i = 0; i < 160; i++) { for (uint8_t i = 0; i < 160; i++) {
ips200_draw_point(10 + i, Curser_In * 18 + 19, RGB565_WHITE); ips200_draw_point(10 + i, Curser_In * 18 + 19, RGB565_PURPLE);
system_delay_ms(1); system_delay_ms(1);
} }
} }
@@ -146,15 +148,76 @@ void Show_Marked_Image(void)
float vertical_zoom_rate = ((float)(IMAGE_DISPLAY_HEIGHT)) / ((float)(MT9V03X_H)); 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); ips200_show_gray_image(START_X, START_Y, mt9v03x_image_copy[0], MT9V03X_W, MT9V03X_H, IMAGE_DISPLAY_WIDTH, IMAGE_DISPLAY_HEIGHT, 0);
ips200_draw_frame(START_X - 3, START_Y - 3, START_X + IMAGE_DISPLAY_WIDTH + 2, START_Y + IMAGE_DISPLAY_HEIGHT + 2, 2, RGB565_BLUE);
// 确认边线数组在显示前不会清空 // 确认边线数组在显示前不会清空
for (uint i = 0; i < PT_MAXLEN; i++) { for (uint i = 0; i < PT_MAXLEN; i++) {
ips200_draw_point(START_X + (uint16_t)((float)pts_right[i][1] * horizontal_zoom_rate), START_Y + (uint16_t)((float)pts_right[i][0] * vertical_zoom_rate), RGB565_GREEN); uint16_t l_x = START_X + (uint16_t)((float)pts_right[i][1] * horizontal_zoom_rate);
ips200_draw_point(START_X + (uint16_t)((float)pts_right[i][1] * horizontal_zoom_rate) - 1, START_Y + (uint16_t)((float)pts_right[i][0] * vertical_zoom_rate), RGB565_GREEN); uint16_t l_y = START_Y + (uint16_t)((float)pts_right[i][0] * vertical_zoom_rate);
ips200_draw_point(START_X + (uint16_t)((float)pts_left[i][1] * horizontal_zoom_rate), START_Y + (uint16_t)((float)pts_left[i][0] * vertical_zoom_rate), RGB565_YELLOW); uint16_t r_x = START_X + (uint16_t)((float)pts_left[i][1] * horizontal_zoom_rate);
ips200_draw_point(START_X + (uint16_t)((float)pts_left[i][1] * horizontal_zoom_rate) + 1, START_Y + (uint16_t)((float)pts_left[i][0] * vertical_zoom_rate), RGB565_YELLOW); uint16_t r_y = START_Y + (uint16_t)((float)pts_left[i][0] * vertical_zoom_rate);
ips200_draw_rect(l_x, l_y, l_x + 2, l_y, RGB565_RED);
ips200_draw_rect(r_x - 2, r_y, r_x, r_y, RGB565_BLUE);
// ips200_draw_point(START_X + (uint16_t)((float)pts_right[i][1] * horizontal_zoom_rate), START_Y + (uint16_t)((float)pts_right[i][0] * vertical_zoom_rate), RGB565_GREEN);
// ips200_draw_point(START_X + (uint16_t)((float)pts_right[i][1] * horizontal_zoom_rate) - 1, START_Y + (uint16_t)((float)pts_right[i][0] * vertical_zoom_rate), RGB565_GREEN);
// ips200_draw_point(START_X + (uint16_t)((float)pts_left[i][1] * horizontal_zoom_rate), START_Y + (uint16_t)((float)pts_left[i][0] * vertical_zoom_rate), RGB565_YELLOW);
// ips200_draw_point(START_X + (uint16_t)((float)pts_left[i][1] * horizontal_zoom_rate) + 1, START_Y + (uint16_t)((float)pts_left[i][0] * vertical_zoom_rate), RGB565_YELLOW);
} }
#undef IMAGE_DISPLAY_WIDTH #undef IMAGE_DISPLAY_WIDTH
#undef START_X #undef START_X
#undef START_Y #undef START_Y
} }
uint16_t rgb_gradient(uint16_t i)
{
#define STEP1 (32.0f / 33.0f)
#define STEP2 (64.0f / 33.0f)
static uint16_t color = 0;
static uint16_t i_last;
static float r = 32;
static float g = 0;
static float b = 0;
uint8_t r_h = 0;
uint8_t g_h = 0;
uint8_t b_h = 0;
if (i == i_last) {
return color;
}
if (i < 33) {
if (0 == i) {
r = 32;
g = 0;
b = 0;
}
r = r - STEP1;
g = g + STEP2;
b = 0;
} else if (i > 33) {
if (i < 67) {
r = 0;
g = g - STEP2;
b = b + STEP1;
} else {
r = r + STEP1;
g = 0;
b = b - STEP1;
}
}
color = 0;
r_h = (uint8_t)r;
g_h = (uint8_t)g;
b_h = (uint8_t)b;
printf("%d - r:%d, g:%d, b:%d\r\n", i, r_h, g_h, b_h);
color |= (r_h & 0x1F) << 11;
color |= (g_h & 0x3F) << 5;
color |= (b_h & 0x1F);
i_last = i;
return color;
#undef STEP1
#undef STEP2
}

View File

@@ -13,5 +13,6 @@ void Print_Menu(const ITEM* item, uint8_t item_sum);
void Print_Value(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 Set_Vaule(ITEM *item, uint8_t item_num, float step);
void Show_Marked_Image(void); void Show_Marked_Image(void);
uint16_t rgb_gradient(uint16_t i);
#endif #endif

View File

@@ -497,6 +497,27 @@ void ips200_draw_point(uint16 x, uint16 y, const uint16 color)
} }
} }
void ips200_draw_rect(uint16 x1, uint16 y1, uint16 x2, uint16 y2, const uint16 color)
{
if (IPS200_TYPE_SPI == ips200_display_type) {
IPS200_CS(0);
}
ips200_set_region(x1, y1, x2, y2);
for (uint16_t i = ((x2 - x1 + 1) * (y2 - y1 + 1)); i > 0; i--) {
ips200_write_16bit_data(color);
}
if (IPS200_TYPE_SPI == ips200_display_type) {
IPS200_CS(1);
}
}
void ips200_draw_frame(uint16 x1, uint16 y1, uint16 x2, uint16 y2, uint16_t d, const uint16 color)
{
ips200_draw_rect(x1, y1, x2, y1 + d, color);
ips200_draw_rect(x1, y2 - d, x2, y2, color);
ips200_draw_rect(x1, y1, x1 + d, y2, color);
ips200_draw_rect(x2 - d, y1, x2, y2, color);
}
//------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------
// 函数简介 IPS200 画线 // 函数简介 IPS200 画线
// 参数说明 x_start 坐标 x 方向的起点 [0, ips200_x_max-1] // 参数说明 x_start 坐标 x 方向的起点 [0, ips200_x_max-1]

View File

@@ -63,7 +63,6 @@
#include "zf_common_typedef.h" #include "zf_common_typedef.h"
// --------------------单排两寸屏幕 SPI 接口引脚定义--------------------// // --------------------单排两寸屏幕 SPI 接口引脚定义--------------------//
#define IPS200_USE_SOFT_SPI (0) // 默认使用硬件 SPI 方式驱动 建议使用硬件 SPI 方式驱动 #define IPS200_USE_SOFT_SPI (0) // 默认使用硬件 SPI 方式驱动 建议使用硬件 SPI 方式驱动
@@ -90,11 +89,8 @@
#define IPS200_CS_PIN_SPI (D10) #define IPS200_CS_PIN_SPI (D10)
#define IPS200_BLk_PIN_SPI (D11) #define IPS200_BLk_PIN_SPI (D11)
// --------------------单排两寸屏幕 SPI 接口引脚定义--------------------// // --------------------单排两寸屏幕 SPI 接口引脚定义--------------------//
// --------------------双排两寸屏幕并口引脚定义--------------------// // --------------------双排两寸屏幕并口引脚定义--------------------//
#define IPS200_RD_PIN_PARALLEL8 (B13) #define IPS200_RD_PIN_PARALLEL8 (B13)
#define IPS200_WR_PIN_PARALLEL8 (B15) #define IPS200_WR_PIN_PARALLEL8 (B15)
@@ -129,23 +125,19 @@
#define IPS200_DC(x) ((x) ? (gpio_high(IPS200_DC_PIN_SPI)) : (gpio_low(IPS200_DC_PIN_SPI))) #define IPS200_DC(x) ((x) ? (gpio_high(IPS200_DC_PIN_SPI)) : (gpio_low(IPS200_DC_PIN_SPI)))
#define IPS200_CS(x) ((x) ? (gpio_high(ips_cs_pin)) : (gpio_low(ips_cs_pin))) #define IPS200_CS(x) ((x) ? (gpio_high(ips_cs_pin)) : (gpio_low(ips_cs_pin)))
typedef enum {
typedef enum
{
IPS200_TYPE_SPI, // SPI 驱动 IPS200_TYPE_SPI, // SPI 驱动
IPS200_TYPE_PARALLEL8, // 并口驱动 IPS200_TYPE_PARALLEL8, // 并口驱动
} ips200_type_enum; } ips200_type_enum;
typedef enum typedef enum {
{
IPS200_PORTAIT = 0, // 竖屏模式 IPS200_PORTAIT = 0, // 竖屏模式
IPS200_PORTAIT_180 = 1, // 竖屏模式 旋转 180 IPS200_PORTAIT_180 = 1, // 竖屏模式 旋转 180
IPS200_CROSSWISE = 2, // 横屏模式 IPS200_CROSSWISE = 2, // 横屏模式
IPS200_CROSSWISE_180 = 3, // 横屏模式 旋转 180 IPS200_CROSSWISE_180 = 3, // 横屏模式 旋转 180
} ips200_dir_enum; } ips200_dir_enum;
typedef enum typedef enum {
{
IPS200_6X8_FONT = 0, // 6x8 字体 IPS200_6X8_FONT = 0, // 6x8 字体
IPS200_8X16_FONT = 1, // 8x16 字体 IPS200_8X16_FONT = 1, // 8x16 字体
IPS200_16X16_FONT = 2, // 16x16 字体 目前不支持 IPS200_16X16_FONT = 2, // 16x16 字体 目前不支持
@@ -157,6 +149,8 @@ void ips200_set_dir (ips200_dir_enum dir);
void ips200_set_font(ips200_font_size_enum font); void ips200_set_font(ips200_font_size_enum font);
void ips200_set_color(const uint16 pen, const uint16 bgcolor); void ips200_set_color(const uint16 pen, const uint16 bgcolor);
void ips200_draw_point(uint16 x, uint16 y, const uint16 color); void ips200_draw_point(uint16 x, uint16 y, const uint16 color);
void ips200_draw_rect(uint16 x1, uint16 y1, uint16 x2, uint16 y2, const uint16 color);
void ips200_draw_frame(uint16 x1, uint16 y1, uint16 x2, uint16 y2, uint16_t d, const uint16 color);
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);
void ips200_show_char(uint16 x, uint16 y, const char dat); void ips200_show_char(uint16 x, uint16 y, const char dat);