This repository has been archived on 2024-05-05. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
ABS-Peripheral-Drive/硬件驱动/OLED显示屏/AbsDrive_OLED.h
2023-10-18 22:36:02 +08:00

157 lines
5.1 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*文件AbsDrive_OLED.h
* 作者:你遇了我
* 联系321640253@qq.com
* 描述抽象硬件OLED屏幕只需要实现指定的抽象函数即可使用
* 使用1、在配置区选择配置
2、按照配置到AbsDrive_OLED.c实现抽象函数
*@版本:v0.1.0
*/
#ifndef __ABS_DRIVE_OLED_H
#define __ABS_DRIVE_OLED_H
#include "stdint.h"
#include "stdlib.h"
#define ABSDrive_OLED_ON 0
#if(ABSDrive_OLED_ON)
/**************************配置区(BEGIN)***************************/
/*------------你的头文件(BEGIN)----------------*/
//#include "spi.h"
#include "gpio.h"
#include "i2c.h"
#include "main.h"
#include "stdio.h"
/*------------你的头文件(END)------------------*/
/*----1、选择驱动芯片----*/
/*
根据你的OLED屏幕选择其中一种
目前支持SSD1306、SSD1315
*/
#define ABS_SSD1306
//#define ABS_SSD1315
/*----2、选择你实现的通信方式----*/
/*根据你所实现的抽象函数的方式选择4线SPI、3线SPI、软件IIC、硬件IIC
*/
//#define ABSDrive_4SPI
//#define ABSDrive_3SPI
//#define ABSDrive_SoftIIC
#define ABSDrive_HardIIC
/*----3、设置屏幕相关硬件参数----*/
#define ABS_OLED_WIDTH 128 //屏幕分辨率宽
#define ABS_OLED_HEIGHT 64 //屏幕分辨率高
#define ABS_OLED_PAGE_SIZE 8 //屏幕页结构,页数
#if (defined ABSDrive_HardIIC)||(defined ABSDrive_SoftIIC)
#define ABS_OLED_ADDR 0x1E //IIC地址
#endif
/*----4、是否启动延时函数----*/
/*不需要延时函数时可以注释掉
*/
#define Enable_ABS_OLED_Delay
/*----5、是否启用复位信号引脚----*/
/*不需要控制复位信号可以注释掉
*/
//#define Enable_ABS_OLED_RES
/*----5、是否启用DC信号引脚----*/
/*不需要控制DC信号可以注释掉
*/
//#define Enable_ABS_OLED_DC
/**************************配置区(END)***************************/
/*----------------------------------------------分割线(以下内容非开发人员切勿改动)---------------------------------------------------------*/
/*************************数据定义区(BEGIN)*****************************/
#define u8 uint8_t
#define u16 uint16_t
#define u32 uint32_t
typedef struct _ABS_OLED_Drive{
void (*ShowString)(u8 x,u8 y,char *chr,u8 size1,u8 mode);
void (*ShowNum)(u8 x,u8 y,u32 num,u8 len,u8 size1,u8 mode);
void (*ShowChinese)(u8 x,u8 y,u8 num,u8 size1,u8 mode);
void (*DrawPoint)(u8 x,u8 y,u8 t);
void (*DrawLine)(u8 x1,u8 y1,u8 x2,u8 y2,u8 mode);
void (*DrawCircle)(u8 x,u8 y,u8 r);
void (*ShowImage)(u8 x,u8 y,u8 sizex,u8 sizey,u8 BMP[],u8 mode);
void (*Clear)(void);
void (*Refresh)(void);
} ABS_OLED_Drive;
/*
*OLED的状态
*/
typedef enum _OLED_STATE{
ABS_OLED_OK =0x00U, //状态正确
ABS_OLED_ERROR =0x01U, //状态异常
} AbsDriveOLED_STATE;
/*************************数据定义区(END)*******************************/
/***********************命令区(BEGIN)*****************************/
#if (defined ABS_SSD1306)||(defined ABS_SSD1315)
//设置类
//-------基本命令--------------
#define CMD_OFF_OLED 0xAE //关闭OLED屏幕
#define CMD_ON_OLED 0xAF //打开OLED屏幕
#define CMD_EntireDisplay_OLED 0xA4 //整个屏幕显示(按照GRAM内容)
#define CMD_EntireDisplayOnRAM_OLED 0xA5 //整个屏幕显示(忽视GRAM内容全部亮起)
#define CMD_Normal_display_OLED 0xA6 //正常显示
#define CMD_Inverse_display_OLED 0xA7 //反向显示
#define CMD_Set_Contrast_Control_OLED 0x81 //设置对比度
//-------寻址设置命令----------
#define CMD_LColAddr_OLED 0x00 //设置列地址开始的起始地址,低位寻址,次命令仅适用于页寻址模式
#define CMD_HColAddr_OLED 0x10 //设置列地址开始的起始地址,高位寻址,次命令仅适用于页寻址模式
#define CMD_Memory_Addr_Mode_OLED 0x20 //设置内存寻址模式,A[1,0],00b水平寻址01b垂直寻址11b重置寻址模式
#define CMD_SetColumnAddr_OLED 0x21 //设置列开始和结束地址
#endif
/***********************命令区(END)*******************************/
/***********************函数区(BEGIN)*****************************/
void ABS_OLED_ClearPoint(u8 x,u8 y);
void ABS_OLED_ColorTurn(u8 i);
void ABS_OLED_DisplayTurn(u8 i);
void ABS_OLED_DisPlay_On(void);
void ABS_OLED_DisPlay_Off(void);
AbsDriveOLED_STATE AbsOledWriteCMD(u8 ABScmd);
AbsDriveOLED_STATE AbsOledWriteDATA(u8 ABSdata);
void ABS_OLED_Refresh(void);
void ABS_OLED_Clear(void);
void ABS_OLED_DrawPoint(u8 x,u8 y,u8 t);
void ABS_OLED_DrawLine(u8 x1,u8 y1,u8 x2,u8 y2,u8 mode);
void ABS_OLED_DrawCircle(u8 x,u8 y,u8 r);
void ABS_OLED_ShowChar(u8 x,u8 y,u8 chr,u8 size1,u8 mode);
void ABS_OLED_ShowString(u8 x,u8 y,char *chr,u8 size1,u8 mode);
void ABS_OLED_ShowNum(u8 x,u8 y,u32 num,u8 len,u8 size1,u8 mode);
void ABS_OLED_ShowChinese(u8 x,u8 y,u8 num,u8 size1,u8 mode);
void ABS_OLED_ScrollDisplay(u8 num,u8 space,u8 mode);
void ABS_OLED_ShowPicture(u8 x,u8 y,u8 sizex,u8 sizey,u8 BMP[],u8 mode);
void ABS_OLED_Init(void);
ABS_OLED_Drive Create_OLED(void); //创建OLED设备
/***********************函数区(END)*******************************/
#endif
#endif //__ABS_DRIVE_OLED_H