LinkIt One 驱动SSd1306屏
时间:10-02
整理:3721RD
点击:
在linkit One开发板上使用SPI驱动SSD1306屏,纯为了测试屏幕
有几个是GPIO端口模拟
*************************************************************
能够正常的显示logo“UniV OLED”,其他功能还没有实现
************************************************************
#include <SPI.h>
const int RES=1;//REST
const int DC=0;//Data or Command
const int CS=2;
unsigned char UniV[][48]={ // UniV OLED
0x00,0x00,0xFC,0xFC,0xFC,0xFC,0x00,0x00,0x00,0xFC,0xFC,0xFC,0xFC,0x00,0x00,0x00,0xE0,0xE0,0xE0,0xE0,0x60,0xE0,0xE0,0xE0,0xC0,0x00,0x00,0x00,0xEC,0xEC,0xEC,0xEC,0x00,0x00,0x00,0x04,0x3C,0xFC,0xFC,0xF0,0x80,0x80,0xF0,0xFC,0xFC,0x3C,0x04,0x00,
0x00,0x00,0x07,0x0F,0x1F,0x1F,0x1C,0x18,0x1C,0x1F,0x1F,0x0F,0x07,0x00,0x00,0x00,0x1F,0x1F,0x1F,0x1F,0x00,0x1F,0x1F,0x1F,0x1F,0x00,0x00,0x00,0x1F,0x1F,0x1F,0x1F,0x00,0x00,0x00,0x00,0x00,0x01,0x0F,0x1F,0x1F,0x1F,0x1F,0x0F,0x01,0x00,0x00,0x00,
0x00,0x80,0xE0,0xE0,0xF0,0x70,0X30,0x70,0xF0,0xE0,0xE0,0x80,0x00,0x00,0x00,0xF0,0xF0,0xF0,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0xF0,0xF0,0xF0,0x30,0x30,0x30,0x30,0x30,0x00,0x00,0x00,0xF0,0xF0,0xF0,0xF0,0x30,0x70,0xF0,0xF0,0xE0,0x80,
0x00,0x0F,0x3F,0x3F,0x7F,0x70,0x60,0x70,0x7F,0x3F,0x3F,0x0F,0x00,0x00,0x00,0x7F,0x7F,0x7F,0x7F,0x60,0x60,0x60,0x60,0x00,0x00,0x00,0x7F,0x7F,0x7F,0x7F,0x63,0x63,0x63,0x63,0x60,0x00,0x00,0x00,0x7F,0x7F,0x7F,0x7F,0x60,0x70,0x7F,0x7F,0x3F,0x0F,
};
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// Global Variables
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#define XLevelL 0x00
#define XLevelH 0x12
#define XLevel ((XLevelH&0x0F)*16+XLevelL)
#define Max_Column 64
#define Max_Row 48
#define Brightness 0xCF
void setup() {
// put your setup code here, to run once:
pinMode(RES,OUTPUT);
pinMode(DC,OUTPUT);
pinMode(CS,OUTPUT);
SPI.begin();
SPI.setDataMode(SPI_MODE0); //0 or 3 Mode
SPI.setBitOrder(MSBFIRST); //(MSBFIRST or LSBFIRST)
SPI.setClockDivider(SPI_CLOCK_div16);
LCD_Init();
Show_Pattern(&UniV[0][0],0x01,0x04,XLevel+0x08,0x30);
Delay(1);
Set_Display_On_Off(0x01);
}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// Delay Time
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
void uDelay(unsigned char l)
{
while(l--);
}
void Delay(unsigned char n)
{
unsigned char i,j,k;
for(k=0;k<n;k++)
{
for(i=0;i<131;i++)
{
for(j=0;j<15;j++)
{
uDelay(203);
}
}
}
}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// Read/Write Sequence
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
void Write_Command(unsigned char Data)
{
unsigned char i;
digitalWrite(CS,LOW);
digitalWrite(DC,LOW);
SPI.transfer(Data);
uDelay(20);
digitalWrite(DC,HIGH);
digitalWrite(CS,HIGH);
}
void Write_Data(unsigned char Data)
{
unsigned char i;
digitalWrite(CS,LOW);
digitalWrite(DC,HIGH);
SPI.transfer(Data);
uDelay(20);
digitalWrite(DC,HIGH);
digitalWrite(CS,HIGH);
}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// Instruction Setting
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
void Set_Start_Column(unsigned char d)
{
Write_Command(0x00+d%16); // Set Lower Column Start Address for Page Addressing Mode
// Default => 0x00
Write_Command(0x10+d/16); // Set Higher Column Start Address for Page Addressing Mode
// Default => 0x10
}
void Set_Addressing_Mode(unsigned char d)
{
Write_Command(0X20); // Set memory Addressing Mode
Write_Command(d); // Default => 0x02
// 0x00 => Horizontal Addressing Mode
// 0x01 => Vertical Addressing Mode
// 0x02 => Page Addressing Mode
}
void Set_Column_Address(unsigned char a, unsigned char b)
{
Write_Command(0x21); // Set Column Address
Write_Command(a); // Default => 0x00 (Column Start Address)
Write_Command(b); // Default => 0x7F (Column End Address)
}
void Set_Page_Address(unsigned char a, unsigned char b)
{
Write_Command(0x22); // Set Page Address
Write_Command(a); // Default => 0x00 (Page Start Address)
Write_Command(b); // Default => 0x07 (Page End Address)
}
void Set_Start_Line(unsigned char d)
{
Write_Command(0x40|d); // Set Display Start Line
// Default => 0x40 (0x00)
}
void Set_Contrast_Control(unsigned char d)
{
Write_Command(0x81); // Set Contrast Control
Write_Command(d); // Default => 0x7F
}
void Set_Charge_Pump(unsigned char d)
{
Write_Command(0x8D); // Set Charge Pump
Write_Command(0x10|d); // Default => 0x10
// 0x10 (0x00) => Disable Charge Pump
// 0x14 (0x04) => Enable Charge Pump
}
void Set_Segment_Remap(unsigned char d)
{
Write_Command(0xA0|d); // Set Segment Re-Map
// Default => 0xA0
// 0xA0 (0x00) => Column Address 0 Mapped to SEG0
// 0xA1 (0x01) => Column Address 0 Mapped to SEG127
}
void Set_Entire_Display(unsigned char d)
{
Write_Command(0xA4|d); // Set Entire Display On / Off
// Default => 0xA4
// 0xA4 (0x00) => Normal Display
// 0xA5 (0x01) => Entire Display On
}
void Set_Inverse_Display(unsigned char d)
{
Write_Command(0xA6|d); // Set Inverse Display On/Off
// Default => 0xA6
// 0xA6 (0x00) => Normal Display
// 0xA7 (0x01) => Inverse Display On
}
void Set_Multiplex_Ratio(unsigned char d)
{
Write_Command(0xA8); // Set Multiplex Ratio
Write_Command(d); // Default => 0x3F (1/64 Duty)
}
void Set_Display_On_Off(unsigned char d)
{
Write_Command(0xAE|d); // Set Display On/Off
// Default => 0xAE
// 0xAE (0x00) => Display Off
// 0xAF (0x01) => Display On
}
void Set_Start_Page(unsigned char d)
{
Write_Command(0xB0|d); // Set Page Start Address for Page Addressing Mode
// Default => 0xB0 (0x00)
}
void Set_Common_Remap(unsigned char d)
{
Write_Command(0xC0|d); // Set COM Output Scan Direction
// Default => 0xC0
// 0xC0 (0x00) => Scan fROM COM0 to 63
// 0xC8 (0x08) => Scan from COM63 to 0
}
void Set_Display_Offset(unsigned char d)
{
Write_Command(0xD3); // Set Display Offset
Write_Command(d); // Default => 0x00
}
void Set_Display_Clock(unsigned char d)
{
Write_Command(0xD5); // Set Display Clock Divide Ratio / Oscillator Frequency
Write_Command(d); // Default => 0x80
// D[3:0] => Display Clock Divider
// D[7:4] => Oscillator Frequency
}
void Set_Precharge_Period(unsigned char d)
{
Write_Command(0xD9); // Set Pre-Charge Period
Write_Command(d); // Default => 0x22 (2 Display Clocks [Phase 2] / 2 Display Clocks [Phase 1])
// D[3:0] => Phase 1 Period in 1~15 Display Clocks
// D[7:4] => Phase 2 Period in 1~15 Display Clocks
}
void Set_Common_Config(unsigned char d)
{
Write_Command(0xDA); // Set COM Pins Hardware Configuration
Write_Command(0x02|d); // Default => 0x12 (0x10)
// ALTErnative COM Pin Configuration
// Disable COM Left/Right Re-Map
}
void Set_VCOMH(unsigned char d)
{
Write_Command(0xDB); // Set VCOMH Deselect Level
Write_Command(d); // Default => 0x20 (0.77*VCC)
}
void Set_NOP()
{
Write_Command(0xE3); // Command for No Operation
}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// Show Pattern (Partial or Full Screen)
//
// a: Start Page
// b: End Page
// c: Start Column
// d: Total Columns
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
void Show_Pattern(unsigned char *Data_Pointer, unsigned char a, unsigned char b, unsigned char c, unsigned char d)
{
unsigned char *Src_Pointer;
unsigned char i,j;
Src_Pointer=Data_Pointer;
for(i=a;i<(b+1);i++)
{
Set_Start_Page(i);
Set_Start_Column(c);
for(j=0;j<d;j++)
{
Write_Data(*Src_Pointer);
Src_Pointer++;
}
}
}
void LCD_Init()
{
unsigned char i;
digitalWrite(RES,LOW);
for(i=0;i<200;i++)
{
uDelay(200);//200
}
digitalWrite(RES,HIGH);
Set_Display_On_Off(0x00); // Display Off (0x00/0x01)
Set_Display_Clock(0x80); // Set Clock as 100 Frames/Sec
Set_Multiplex_Ratio(0x2F); // 1/48 Duty (0x0F~0x3F)
Set_Display_Offset(0x00); // Shift Mapping RAM Counter (0x00~0x3F)
Set_Start_Line(0x00); // Set Mapping RAM Display Start Line (0x00~0x3F)
Set_Charge_Pump(0x04); // Disable Embedded DC/DC Converter (0x00/0x04)
Set_Addressing_Mode(0x02); // Set Page Addressing Mode (0x00/0x01/0x02)
Set_Segment_Remap(0x01); // Set SEG/Column Mapping (0x00/0x01)
Set_Common_Remap(0x08); // Set COM/Row Scan Direction (0x00/0x08)
Set_Common_Config(0x10); // Set Sequential Configuration (0x00/0x10)
Set_Contrast_Control(Brightness); // Set SEG Output Current
Set_Precharge_Period(0x22); // Set Pre-Charge as 2 Clocks & Discharge as 2 Clock
Set_VCOMH(0x00); // Set VCOM Deselect Level
Set_Entire_Display(0x00); // Disable Entire Display On (0x00/0x01)
Set_Inverse_Display(0x00); // Disable Inverse Display On (0x00/0x01)
Fill_RAM(0x00); // Clear Screen
Set_Display_On_Off(0x01); // Display On (0x00/0x01)
}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// Show Regular Pattern (Full Screen)
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
void Fill_RAM(unsigned char Data)
{
unsigned char i,j;
for(i=0;i<8;i++)
{
Set_Start_Page(i);
Set_Start_Column(0x00);
for(j=0;j<64;j++)
{
Write_Data(Data);
}
}
}
void loop() {}
/*本人刚入mtk,程序还需要改进很多地方,希望路过的大虾能够给予建议*/
有几个是GPIO端口模拟
*************************************************************
能够正常的显示logo“UniV OLED”,其他功能还没有实现
************************************************************
#include <SPI.h>
const int RES=1;//REST
const int DC=0;//Data or Command
const int CS=2;
unsigned char UniV[][48]={ // UniV OLED
0x00,0x00,0xFC,0xFC,0xFC,0xFC,0x00,0x00,0x00,0xFC,0xFC,0xFC,0xFC,0x00,0x00,0x00,0xE0,0xE0,0xE0,0xE0,0x60,0xE0,0xE0,0xE0,0xC0,0x00,0x00,0x00,0xEC,0xEC,0xEC,0xEC,0x00,0x00,0x00,0x04,0x3C,0xFC,0xFC,0xF0,0x80,0x80,0xF0,0xFC,0xFC,0x3C,0x04,0x00,
0x00,0x00,0x07,0x0F,0x1F,0x1F,0x1C,0x18,0x1C,0x1F,0x1F,0x0F,0x07,0x00,0x00,0x00,0x1F,0x1F,0x1F,0x1F,0x00,0x1F,0x1F,0x1F,0x1F,0x00,0x00,0x00,0x1F,0x1F,0x1F,0x1F,0x00,0x00,0x00,0x00,0x00,0x01,0x0F,0x1F,0x1F,0x1F,0x1F,0x0F,0x01,0x00,0x00,0x00,
0x00,0x80,0xE0,0xE0,0xF0,0x70,0X30,0x70,0xF0,0xE0,0xE0,0x80,0x00,0x00,0x00,0xF0,0xF0,0xF0,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0xF0,0xF0,0xF0,0x30,0x30,0x30,0x30,0x30,0x00,0x00,0x00,0xF0,0xF0,0xF0,0xF0,0x30,0x70,0xF0,0xF0,0xE0,0x80,
0x00,0x0F,0x3F,0x3F,0x7F,0x70,0x60,0x70,0x7F,0x3F,0x3F,0x0F,0x00,0x00,0x00,0x7F,0x7F,0x7F,0x7F,0x60,0x60,0x60,0x60,0x00,0x00,0x00,0x7F,0x7F,0x7F,0x7F,0x63,0x63,0x63,0x63,0x60,0x00,0x00,0x00,0x7F,0x7F,0x7F,0x7F,0x60,0x70,0x7F,0x7F,0x3F,0x0F,
};
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// Global Variables
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#define XLevelL 0x00
#define XLevelH 0x12
#define XLevel ((XLevelH&0x0F)*16+XLevelL)
#define Max_Column 64
#define Max_Row 48
#define Brightness 0xCF
void setup() {
// put your setup code here, to run once:
pinMode(RES,OUTPUT);
pinMode(DC,OUTPUT);
pinMode(CS,OUTPUT);
SPI.begin();
SPI.setDataMode(SPI_MODE0); //0 or 3 Mode
SPI.setBitOrder(MSBFIRST); //(MSBFIRST or LSBFIRST)
SPI.setClockDivider(SPI_CLOCK_div16);
LCD_Init();
Show_Pattern(&UniV[0][0],0x01,0x04,XLevel+0x08,0x30);
Delay(1);
Set_Display_On_Off(0x01);
}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// Delay Time
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
void uDelay(unsigned char l)
{
while(l--);
}
void Delay(unsigned char n)
{
unsigned char i,j,k;
for(k=0;k<n;k++)
{
for(i=0;i<131;i++)
{
for(j=0;j<15;j++)
{
uDelay(203);
}
}
}
}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// Read/Write Sequence
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
void Write_Command(unsigned char Data)
{
unsigned char i;
digitalWrite(CS,LOW);
digitalWrite(DC,LOW);
SPI.transfer(Data);
uDelay(20);
digitalWrite(DC,HIGH);
digitalWrite(CS,HIGH);
}
void Write_Data(unsigned char Data)
{
unsigned char i;
digitalWrite(CS,LOW);
digitalWrite(DC,HIGH);
SPI.transfer(Data);
uDelay(20);
digitalWrite(DC,HIGH);
digitalWrite(CS,HIGH);
}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// Instruction Setting
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
void Set_Start_Column(unsigned char d)
{
Write_Command(0x00+d%16); // Set Lower Column Start Address for Page Addressing Mode
// Default => 0x00
Write_Command(0x10+d/16); // Set Higher Column Start Address for Page Addressing Mode
// Default => 0x10
}
void Set_Addressing_Mode(unsigned char d)
{
Write_Command(0X20); // Set memory Addressing Mode
Write_Command(d); // Default => 0x02
// 0x00 => Horizontal Addressing Mode
// 0x01 => Vertical Addressing Mode
// 0x02 => Page Addressing Mode
}
void Set_Column_Address(unsigned char a, unsigned char b)
{
Write_Command(0x21); // Set Column Address
Write_Command(a); // Default => 0x00 (Column Start Address)
Write_Command(b); // Default => 0x7F (Column End Address)
}
void Set_Page_Address(unsigned char a, unsigned char b)
{
Write_Command(0x22); // Set Page Address
Write_Command(a); // Default => 0x00 (Page Start Address)
Write_Command(b); // Default => 0x07 (Page End Address)
}
void Set_Start_Line(unsigned char d)
{
Write_Command(0x40|d); // Set Display Start Line
// Default => 0x40 (0x00)
}
void Set_Contrast_Control(unsigned char d)
{
Write_Command(0x81); // Set Contrast Control
Write_Command(d); // Default => 0x7F
}
void Set_Charge_Pump(unsigned char d)
{
Write_Command(0x8D); // Set Charge Pump
Write_Command(0x10|d); // Default => 0x10
// 0x10 (0x00) => Disable Charge Pump
// 0x14 (0x04) => Enable Charge Pump
}
void Set_Segment_Remap(unsigned char d)
{
Write_Command(0xA0|d); // Set Segment Re-Map
// Default => 0xA0
// 0xA0 (0x00) => Column Address 0 Mapped to SEG0
// 0xA1 (0x01) => Column Address 0 Mapped to SEG127
}
void Set_Entire_Display(unsigned char d)
{
Write_Command(0xA4|d); // Set Entire Display On / Off
// Default => 0xA4
// 0xA4 (0x00) => Normal Display
// 0xA5 (0x01) => Entire Display On
}
void Set_Inverse_Display(unsigned char d)
{
Write_Command(0xA6|d); // Set Inverse Display On/Off
// Default => 0xA6
// 0xA6 (0x00) => Normal Display
// 0xA7 (0x01) => Inverse Display On
}
void Set_Multiplex_Ratio(unsigned char d)
{
Write_Command(0xA8); // Set Multiplex Ratio
Write_Command(d); // Default => 0x3F (1/64 Duty)
}
void Set_Display_On_Off(unsigned char d)
{
Write_Command(0xAE|d); // Set Display On/Off
// Default => 0xAE
// 0xAE (0x00) => Display Off
// 0xAF (0x01) => Display On
}
void Set_Start_Page(unsigned char d)
{
Write_Command(0xB0|d); // Set Page Start Address for Page Addressing Mode
// Default => 0xB0 (0x00)
}
void Set_Common_Remap(unsigned char d)
{
Write_Command(0xC0|d); // Set COM Output Scan Direction
// Default => 0xC0
// 0xC0 (0x00) => Scan fROM COM0 to 63
// 0xC8 (0x08) => Scan from COM63 to 0
}
void Set_Display_Offset(unsigned char d)
{
Write_Command(0xD3); // Set Display Offset
Write_Command(d); // Default => 0x00
}
void Set_Display_Clock(unsigned char d)
{
Write_Command(0xD5); // Set Display Clock Divide Ratio / Oscillator Frequency
Write_Command(d); // Default => 0x80
// D[3:0] => Display Clock Divider
// D[7:4] => Oscillator Frequency
}
void Set_Precharge_Period(unsigned char d)
{
Write_Command(0xD9); // Set Pre-Charge Period
Write_Command(d); // Default => 0x22 (2 Display Clocks [Phase 2] / 2 Display Clocks [Phase 1])
// D[3:0] => Phase 1 Period in 1~15 Display Clocks
// D[7:4] => Phase 2 Period in 1~15 Display Clocks
}
void Set_Common_Config(unsigned char d)
{
Write_Command(0xDA); // Set COM Pins Hardware Configuration
Write_Command(0x02|d); // Default => 0x12 (0x10)
// ALTErnative COM Pin Configuration
// Disable COM Left/Right Re-Map
}
void Set_VCOMH(unsigned char d)
{
Write_Command(0xDB); // Set VCOMH Deselect Level
Write_Command(d); // Default => 0x20 (0.77*VCC)
}
void Set_NOP()
{
Write_Command(0xE3); // Command for No Operation
}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// Show Pattern (Partial or Full Screen)
//
// a: Start Page
// b: End Page
// c: Start Column
// d: Total Columns
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
void Show_Pattern(unsigned char *Data_Pointer, unsigned char a, unsigned char b, unsigned char c, unsigned char d)
{
unsigned char *Src_Pointer;
unsigned char i,j;
Src_Pointer=Data_Pointer;
for(i=a;i<(b+1);i++)
{
Set_Start_Page(i);
Set_Start_Column(c);
for(j=0;j<d;j++)
{
Write_Data(*Src_Pointer);
Src_Pointer++;
}
}
}
void LCD_Init()
{
unsigned char i;
digitalWrite(RES,LOW);
for(i=0;i<200;i++)
{
uDelay(200);//200
}
digitalWrite(RES,HIGH);
Set_Display_On_Off(0x00); // Display Off (0x00/0x01)
Set_Display_Clock(0x80); // Set Clock as 100 Frames/Sec
Set_Multiplex_Ratio(0x2F); // 1/48 Duty (0x0F~0x3F)
Set_Display_Offset(0x00); // Shift Mapping RAM Counter (0x00~0x3F)
Set_Start_Line(0x00); // Set Mapping RAM Display Start Line (0x00~0x3F)
Set_Charge_Pump(0x04); // Disable Embedded DC/DC Converter (0x00/0x04)
Set_Addressing_Mode(0x02); // Set Page Addressing Mode (0x00/0x01/0x02)
Set_Segment_Remap(0x01); // Set SEG/Column Mapping (0x00/0x01)
Set_Common_Remap(0x08); // Set COM/Row Scan Direction (0x00/0x08)
Set_Common_Config(0x10); // Set Sequential Configuration (0x00/0x10)
Set_Contrast_Control(Brightness); // Set SEG Output Current
Set_Precharge_Period(0x22); // Set Pre-Charge as 2 Clocks & Discharge as 2 Clock
Set_VCOMH(0x00); // Set VCOM Deselect Level
Set_Entire_Display(0x00); // Disable Entire Display On (0x00/0x01)
Set_Inverse_Display(0x00); // Disable Inverse Display On (0x00/0x01)
Fill_RAM(0x00); // Clear Screen
Set_Display_On_Off(0x01); // Display On (0x00/0x01)
}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// Show Regular Pattern (Full Screen)
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
void Fill_RAM(unsigned char Data)
{
unsigned char i,j;
for(i=0;i<8;i++)
{
Set_Start_Page(i);
Set_Start_Column(0x00);
for(j=0;j<64;j++)
{
Write_Data(Data);
}
}
}
void loop() {}
/*本人刚入mtk,程序还需要改进很多地方,希望路过的大虾能够给予建议*/
小编有试过linkit的蓝牙吗