stm32_ota/OLED显示屏资料/03中景园电子1.3英寸OLED显示屏测试程序/05中景园电子1.3英寸OLED显示屏STC89C52RC系列_SPI_例程/SRC/oled.h
2024-12-17 20:03:43 +08:00

108 lines
2.7 KiB
C
Raw Permalink 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.

//////////////////////////////////////////////////////////////////////////////////
//本程序只供学习使用,未经作者许可,不得用于其它任何用途
//中景园电子
//店铺地址http://shop73023976.taobao.com/?spm=2013.1.0.0.M4PqC2
//
// 文 件 名 : main.c
// 版 本 号 : v2.0
// 作 者 : HuangKai
// 生成日期 : 2014-0101
// 最近修改 :
// 功能描述 : OLED 4接口演示例程(51系列)
// 说明:
// ----------------------------------------------------------------
// GND 电源地
// VCC 接5V或3.3v电源
// D0 P1^4SCL
// D1 P1^3SDA
// RES 接P12
// DC 接P11
// CS 接P10
// ----------------------------------------------------------------
// 修改历史 :
// 日 期 :
// 作 者 : HuangKai
// 修改内容 : 创建文件
//版权所有,盗版必究。
//Copyright(C) 中景园电子2014/3/16
//All rights reserved
//******************************************************************************/
#include "REG51.h"
#ifndef __OLED_H
#define __OLED_H
//#include "sys.h"
//#include "stdlib.h"
#define u8 unsigned char
#define u32 unsigned int
#define OLED_CMD 0 //写命令
#define OLED_DATA 1 //写数据
#define OLED_MODE 0
sbit OLED_CS=P1^0; //片选
sbit OLED_RST =P1^2;//复位
sbit OLED_DC =P1^1;//数据/命令控制
sbit OLED_SCL=P1^4;//时钟 D0SCLK<4C>
sbit OLED_SDIN=P1^3;//D1MOSI 数据
sbit LED_D5 =P3^2;//用户LED灯
sbit LED_D6 =P3^3;//用户LED灯
#define OLED_CS_Clr() OLED_CS=0
#define OLED_CS_Set() OLED_CS=1
#define OLED_RST_Clr() OLED_RST=0
#define OLED_RST_Set() OLED_RST=1
#define OLED_DC_Clr() OLED_DC=0
#define OLED_DC_Set() OLED_DC=1
#define OLED_SCLK_Clr() OLED_SCL=0
#define OLED_SCLK_Set() OLED_SCL=1
#define OLED_SDIN_Clr() OLED_SDIN=0
#define OLED_SDIN_Set() OLED_SDIN=1;
//OLED模式设置
//0:4线串行模式
//1:并行8080模式
#define SIZE 16
#define XLevelL 0x02
#define XLevelH 0x10
#define Max_Column 128
#define Max_Row 64
#define Brightness 0xFF
#define X_WIDTH 128
#define Y_WIDTH 64
//-----------------OLED端口定义----------------
void delay_ms(unsigned int ms);
//OLED控制用函数
void OLED_WR_Byte(u8 dat,u8 cmd);
void OLED_Display_On(void);
void OLED_Display_Off(void);
void OLED_Init(void);
void OLED_Clear(void);
void OLED_DrawPoint(u8 x,u8 y,u8 t);
void OLED_Fill(u8 x1,u8 y1,u8 x2,u8 y2,u8 dot);
void OLED_ShowChar(u8 x,u8 y,u8 chr);
void OLED_ShowNum(u8 x,u8 y,u32 num,u8 len,u8 size2);
void OLED_ShowString(u8 x,u8 y, u8 *p);
void OLED_Set_Pos(unsigned char x, unsigned char y);
void OLED_ShowCHinese(u8 x,u8 y,u8 no);
void OLED_DrawBMP(unsigned char x0, unsigned char y0,unsigned char x1, unsigned char y1,unsigned char BMP[]);
#endif