Files
QD4C-firmware/libraries/zf_device/zf_device_tft180.h

160 lines
10 KiB
C
Raw Normal View History

2023-12-11 21:45:06 +08:00
/*********************************************************************************************************************
* CH32V307VCT6 Opensourec Library CH32V307VCT6 SDK
* Copyright (c) 2022 SEEKFREE
*
* CH32V307VCT6
*
* CH32V307VCT6
* GPLGNU General Public License GNU通用公共许可证
* GPL 3 GPL3.0/
*
*
*
* GPL
*
* GPL
* <https://www.gnu.org/licenses/>
*
*
* 使 GPL3.0
* libraries/doc GPL3_permission_statement.txt
* libraries LICENSE
* 使
*
* zf_device_tft180
*
* libraries/doc version
* MounRiver Studio V1.8.1
* CH32V307VCT6
* https://seekfree.taobao.com/
*
*
*
* 2022-09-15 W first version
********************************************************************************************************************/
/*********************************************************************************************************************
* 线
* ------------------------------------
*
* SCL zf_device_tft180.h TFT180_SCL_PIN
* SDA zf_device_tft180.h TFT180_SDA_PIN
* RES zf_device_tft180.h TFT180_RES_PIN
* DC zf_device_tft180.h TFT180_DC_PIN
* CS zf_device_tft180.h TFT180_CS_PIN
* BL zf_device_tft180.h TFT180_BL_PIN
* VCC 3.3V电源
* GND
* 160*128
* ------------------------------------
********************************************************************************************************************/
#ifndef _zf_device_tft180_h_
#define _zf_device_tft180_h_
#include "zf_common_typedef.h"
#define TFT180_USE_SOFT_SPI (0) // 默认使用硬件 SPI 方式驱动 建议使用硬件 SPI 方式驱动
#if TFT180_USE_SOFT_SPI // 这两段 颜色正常的才是正确的 颜色灰的就是没有用的
//====================================================软件 SPI 驱动====================================================
#define TFT180_SOFT_SPI_DELAY (1 ) // 软件 SPI 的时钟延时周期 数值越小 SPI 通信速率越快
#define TFT180_SCL_PIN (B13) // 软件 SPI SCK 引脚
#define TFT180_SDA_PIN (B15) // 软件 SPI MOSI 引脚
//====================================================软件 SPI 驱动====================================================
#else
//====================================================硬件 SPI 驱动====================================================
#define TFT180_SPI_SPEED (72 * 1000 * 1000) // 硬件 SPI 速率
#define TFT180_SPI (SPI_2) // 硬件 SPI 号
#define TFT180_SCL_PIN (SPI2_MAP0_SCK_B13) // 硬件 SPI SCK 引脚
#define TFT180_SDA_PIN (SPI2_MAP0_MOSI_B15) // 硬件 SPI MOSI 引脚
//====================================================硬件 SPI 驱动====================================================
#endif
#define TFT180_RES_PIN (B7) // 液晶复位引脚定义
#define TFT180_DC_PIN (D7) // 液晶命令位引脚定义
#define TFT180_CS_PIN (D4) // CS 片选引脚
#define TFT180_BL_PIN (D0) // 液晶背光引脚定义
#define TFT180_DEFAULT_DISPLAY_DIR (TFT180_PORTAIT) // 默认的显示方向
#define TFT180_DEFAULT_PENCOLOR (RGB565_RED) // 默认的画笔颜色
#define TFT180_DEFAULT_BGCOLOR (RGB565_WHITE) // 默认的背景颜色
#define TFT180_DEFAULT_DISPLAY_FONT (TFT180_8X16_FONT) // 默认的字体模式
#define TFT180_DC(x) ((x) ? (gpio_high(TFT180_DC_PIN)) : (gpio_low(TFT180_DC_PIN)))
#define TFT180_RST(x) ((x) ? (gpio_high(TFT180_RES_PIN)) : (gpio_low(TFT180_RES_PIN)))
#define TFT180_CS(x) ((x) ? (gpio_high(TFT180_CS_PIN)) : (gpio_low(TFT180_CS_PIN)))
#define TFT180_BLK(x) ((x) ? (gpio_high(TFT180_BL_PIN)) : (gpio_low(TFT180_BL_PIN)))
typedef enum
{
TFT180_PORTAIT = 0, // 竖屏模式
TFT180_PORTAIT_180 = 1, // 竖屏模式 旋转180
TFT180_CROSSWISE = 2, // 横屏模式
TFT180_CROSSWISE_180 = 3, // 横屏模式 旋转180
}tft180_dir_enum;
typedef enum
{
TFT180_6X8_FONT = 0, // 6x8 字体
TFT180_8X16_FONT = 1, // 8x16 字体
TFT180_16X16_FONT = 2, // 16x16 字体 目前不支持
}tft180_font_size_enum;
void tft180_clear (void);
void tft180_full (const uint16 color);
void tft180_set_dir (tft180_dir_enum dir);
void tft180_set_font (tft180_font_size_enum font);
void tft180_set_color (const uint16 pen, const uint16 bgcolor);
void tft180_draw_point (uint16 x, uint16 y, const uint16 color);
void tft180_draw_line (uint16 x_start, uint16 y_start, uint16 x_end, uint16 y_end, const uint16 color);
void tft180_show_char (uint16 x, uint16 y, const char dat);
void tft180_show_string (uint16 x, uint16 y, const char dat[]);
void tft180_show_int (uint16 x,uint16 y, const int32 dat, uint8 num);
void tft180_show_uint (uint16 x,uint16 y, const uint32 dat, uint8 num);
void tft180_show_float (uint16 x,uint16 y, const double dat, uint8 num, uint8 pointnum);
void tft180_show_binary_image (uint16 x, uint16 y, const uint8 *image, uint16 width, uint16 height, uint16 dis_width, uint16 dis_height);
void tft180_show_gray_image (uint16 x, uint16 y, const uint8 *image, uint16 width, uint16 height, uint16 dis_width, uint16 dis_height, uint8 threshold);
void tft180_show_rgb565_image (uint16 x, uint16 y, const uint16 *image, uint16 width, uint16 height, uint16 dis_width, uint16 dis_height, uint8 color_mode);
void tft180_show_wave (uint16 x, uint16 y, const uint16 *wave, uint16 width, uint16 value_max, uint16 dis_width, uint16 dis_value_max);
void tft180_show_chinese (uint16 x, uint16 y, uint8 size, const uint8 *chinese_buffer, uint8 number, const uint16 color);
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 TFT180 显示小钻风图像
// 参数说明 p 图像数组
// 参数说明 width 显示宽度
// 参数说明 height 显示高度
// 返回参数 void
// 使用示例 tft180_displayimage7725(ov7725_image_binary[0], 80, 60);
// 备注信息
//-------------------------------------------------------------------------------------------------------------------
#define tft180_displayimage7725(p, width, height) (tft180_show_binary_image(0, 0, (p), OV7725_W, OV7725_H, (width), (height)))
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 TFT180 显示总钻风图像 不带二值化 显示灰度图像
// 参数说明 p 图像数组
// 参数说明 width 显示宽度
// 参数说明 height 显示高度
// 返回参数 void
// 使用示例 tft180_displayimage03x(mt9v03x_image[0], 94, 60);
// 备注信息 如果要显示二值化图像就去调用 tft180_show_gray_image 函数
//-------------------------------------------------------------------------------------------------------------------
#define tft180_displayimage03x(p, width, height) (tft180_show_gray_image(0, 0, (p), MT9V03X_W, MT9V03X_H, (width), (height), 0))
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 TFT180 显示凌瞳图像
// 参数说明 p 图像数组
// 参数说明 width 显示宽度
// 参数说明 height 显示高度
// 返回参数 void
// 使用示例 tft180_displayimage8660(scc8660_image[0], 80, 60);
// 备注信息
//-------------------------------------------------------------------------------------------------------------------
#define tft180_displayimage8660(p, width, height) (tft180_show_rgb565_image(0, 0, (p), SCC8660_W, SCC8660_H, (width), (height), 1))
void tft180_init (void);
#endif