“0.96 OLED”的版本间的差异
来自YFRobotwiki
第57行: | 第57行: | ||
===应用示例=== | ===应用示例=== | ||
+ | |||
+ | '''示例代码''' | ||
+ | <br><br> | ||
+ | <font color="darkcyan">'''示例一'''</font>:基本显示 | ||
+ | <br><br> | ||
+ | <font color="seagreen">'''Face.ino:'''</font> | ||
+ | <pre > | ||
+ | /************************************************** | ||
+ | Face | ||
+ | ( 8x8 Led Dot Matrix with two 74HC595 on Arduino) | ||
+ | |||
+ | by YFROBOT | ||
+ | ***************************************************/ | ||
+ | |||
+ | #include "TimerOne.h" | ||
+ | #include "face.h" | ||
+ | // 默认显示 | ||
+ | #define ROW_DATA ((row[0]<<7)|(row[1]<<6)|(row[2]<<5)|(row[3]<<4)|(row[4]<<3)|(row[5]<<2)|(row[6]<<1)|(row[7]<<0)) | ||
+ | #define COL_DATA ((col[0]<<7)|(col[1]<<6)|(col[2]<<5)|(col[3]<<4)|(col[4]<<3)|(col[5]<<2)|(col[6]<<1)|(col[7]<<0)) | ||
+ | // 垂直翻转 | ||
+ | //#define ROW_DATA ((row[0]<<0)|(row[1]<<1)|(row[2]<<2)|(row[3]<<3)|(row[4]<<4)|(row[5]<<5)|(row[6]<<6)|(row[7]<<7)) | ||
+ | //#define COL_DATA ((col[0]<<0)|(col[1]<<1)|(col[2]<<2)|(col[3]<<3)|(col[4]<<4)|(col[5]<<5)|(col[6]<<6)|(col[7]<<7)) | ||
+ | |||
+ | // flip horizontal | ||
+ | #define flip_horizontal 7-screenCol // 默认显示 | ||
+ | //#define flip_horizontal screenCol // 水平翻转 | ||
+ | |||
+ | //Pin connected to DS of 74HC595 | ||
+ | int SER = 10; | ||
+ | //Pin connected to ST_CP of 74HC595 | ||
+ | int RCK = 11; | ||
+ | //Pin connected to SH_CP of 74HC595 | ||
+ | int SRCK = 12; | ||
+ | int row[8] = { | ||
+ | 0, 0, 0, 0, 0, 0, 0, 0 | ||
+ | }; | ||
+ | int col[8] = { | ||
+ | 0, 0, 0, 0, 0, 0, 0, 0 | ||
+ | }; | ||
+ | byte screen[8] = { | ||
+ | 0, 0, 0, 0, 0, 0, 0, 0 | ||
+ | }; | ||
+ | volatile byte screenRow = 0; | ||
+ | volatile byte screenCol = 0; | ||
+ | |||
+ | // A counter to know what frame we're showing | ||
+ | int animationIndex = 0; | ||
+ | // 8x8 Point temporary array | ||
+ | byte brightnesses[64]; | ||
+ | |||
+ | void setup() { | ||
+ | // Timer1.initialize(100); | ||
+ | pinMode(RCK, OUTPUT); | ||
+ | pinMode(SRCK, OUTPUT); | ||
+ | pinMode(SER, OUTPUT); | ||
+ | // Timer1.attachInterrupt(doubleBuffer); | ||
+ | Serial.begin(9600); | ||
+ | } | ||
+ | |||
+ | void doubleBuffer() { | ||
+ | int k = 8; | ||
+ | while (k--) { | ||
+ | row[screenRow] = 0; | ||
+ | col[screenCol] = 1; | ||
+ | |||
+ | screenCol++; | ||
+ | if (screenCol >= 8) { | ||
+ | screenCol = 0; | ||
+ | screenRow++; | ||
+ | if (screenRow >= 8) { | ||
+ | screenRow = 0; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | if ((screen[screenRow] >> flip_horizontal) & B1 == B1) { | ||
+ | row[screenRow] = 1; | ||
+ | col[screenCol] = 0; | ||
+ | digitalWrite(RCK, LOW); | ||
+ | shiftOut(SER, SRCK, MSBFIRST, COL_DATA); //先选择列 | ||
+ | shiftOut(SER, SRCK, MSBFIRST, ROW_DATA); //再送行数据 | ||
+ | digitalWrite(RCK, HIGH); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | void UpdataDate() { | ||
+ | if (animationIndex < animationFrames) { | ||
+ | for (int i = 0; i < 64; i++) { | ||
+ | int Dot = (animation[animationIndex][i / 4] >> (i % 4 * 2)); | ||
+ | brightnesses[i] = (Dot & B1) || (Dot & B10); | ||
+ | screen[7 - i / 8] |= (brightnesses[i] << (i % 8)) ; | ||
+ | } | ||
+ | } | ||
+ | unsigned long startime = millis(); | ||
+ | while (millis() - startime < animationDelays[animationIndex]) | ||
+ | { | ||
+ | doubleBuffer(); | ||
+ | } | ||
+ | animationIndex ++; | ||
+ | if (animationIndex >= animationFrames) { | ||
+ | //restart animation index | ||
+ | animationIndex = 0; | ||
+ | } | ||
+ | for (int i = 0; i < 8; i++) | ||
+ | screen[i] = B0; | ||
+ | } | ||
+ | |||
+ | void loop() { | ||
+ | UpdataDate(); | ||
+ | } | ||
+ | </pre> | ||
+ | <br> | ||
+ | <font color="seagreen">'''face.h:'''</font> | ||
+ | <br> | ||
+ | <pre> | ||
+ | int animationFrames = 2; | ||
+ | |||
+ | int animationDelays[] = { 1000, 1000 }; | ||
+ | |||
+ | // Animation is designed for 8x8 pixels | ||
+ | uint8_t animation[][16] = { | ||
+ | { 0x55, 0x55, 0x11, 0x44, 0x5, 0x50, 0x1, 0x40, 0x51, 0x45, 0x11, 0x44, 0x11, 0x44, 0x55, 0x55 }, | ||
+ | { 0x5, 0x50, 0x5, 0x50, 0x0, 0x0, 0x40, 0x1, 0x40, 0x1, 0x0, 0x0, 0x4, 0x10, 0x50, 0x5 } | ||
+ | }; | ||
+ | </pre> | ||
+ | |||
+ | |||
[http://www.yfrobot.com/thread-11774-1-1.html 0.96OLED模块使用资料]] | [http://www.yfrobot.com/thread-11774-1-1.html 0.96OLED模块使用资料]] | ||
2017年9月2日 (六) 14:01的版本
产品简介
OLED(Organic Light-Emitting Diode):有机发光二极管又称为有机电激光显示,由美籍华裔教授邓青云在实验室中发现,由此展开了对OLED的研究。OLED显示技术具有自发光的特性,采用非常薄的有机材料涂层和玻璃基板,当有电流通过时,这些有机材料就会发光,而且OLED显示屏幕可视角度大,并且能够节省电能。OLED由于同时具备自发光、不需背光源、对比度高、厚度薄、视角广、反应速度快、可用于挠曲面板、使用温度范围广、结构及制程简单等优异之特性,被认为下一代平面显示器新兴应用技术。
最先接触的12864屏都是LCD的,需要背光,功耗较高,而OLED的功耗低,更加适合小系统;由于两者发光材料的不同,在不同的环境中,OLED的显示效果更佳。
规格参数
- 兼容3.3V~5V电压
- 三色可选:模块有两种单色和黄蓝双色两种颜色可选,单色为纯白色和纯蓝色,双色为黄蓝双色
- 高分辨率:分辨率为128*64
- 接口模式:4线串行SPI接口模式
- 字库:可显示标准的国标简体(GB2312)汉字、8*16点ASCII粗体字库、7*8点ASCII字库、5*7点ASCII字库
- 超小尺寸:显示尺寸为0.96寸,模块尺寸为27mm(长)*26mm(宽)*4mm(高)
引脚说明
名称 | 说明 |
GND | 地 |
VCC | 电源(3.3-5V) |
CLK | 4线ISP接口模式:时钟线
GT20L16S1Y的时钟线 |
DIN | 4线ISP接口模式:串行数据线
GT20L16S1Y的串行数据输入端口 |
D/C | 4线ISP接口模式:命令/数据标志位 |
CS1 | 4线ISP接口模式:OLED片选 |
SO | GT20L16S1Y的串行数据输出端口 |
CS2 | GT20L16S1Y的片选端口 |
应用示例
示例代码
示例一:基本显示
Face.ino:
/************************************************** Face ( 8x8 Led Dot Matrix with two 74HC595 on Arduino) by YFROBOT ***************************************************/ #include "TimerOne.h" #include "face.h" // 默认显示 #define ROW_DATA ((row[0]<<7)|(row[1]<<6)|(row[2]<<5)|(row[3]<<4)|(row[4]<<3)|(row[5]<<2)|(row[6]<<1)|(row[7]<<0)) #define COL_DATA ((col[0]<<7)|(col[1]<<6)|(col[2]<<5)|(col[3]<<4)|(col[4]<<3)|(col[5]<<2)|(col[6]<<1)|(col[7]<<0)) // 垂直翻转 //#define ROW_DATA ((row[0]<<0)|(row[1]<<1)|(row[2]<<2)|(row[3]<<3)|(row[4]<<4)|(row[5]<<5)|(row[6]<<6)|(row[7]<<7)) //#define COL_DATA ((col[0]<<0)|(col[1]<<1)|(col[2]<<2)|(col[3]<<3)|(col[4]<<4)|(col[5]<<5)|(col[6]<<6)|(col[7]<<7)) // flip horizontal #define flip_horizontal 7-screenCol // 默认显示 //#define flip_horizontal screenCol // 水平翻转 //Pin connected to DS of 74HC595 int SER = 10; //Pin connected to ST_CP of 74HC595 int RCK = 11; //Pin connected to SH_CP of 74HC595 int SRCK = 12; int row[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; int col[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; byte screen[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; volatile byte screenRow = 0; volatile byte screenCol = 0; // A counter to know what frame we're showing int animationIndex = 0; // 8x8 Point temporary array byte brightnesses[64]; void setup() { // Timer1.initialize(100); pinMode(RCK, OUTPUT); pinMode(SRCK, OUTPUT); pinMode(SER, OUTPUT); // Timer1.attachInterrupt(doubleBuffer); Serial.begin(9600); } void doubleBuffer() { int k = 8; while (k--) { row[screenRow] = 0; col[screenCol] = 1; screenCol++; if (screenCol >= 8) { screenCol = 0; screenRow++; if (screenRow >= 8) { screenRow = 0; } } if ((screen[screenRow] >> flip_horizontal) & B1 == B1) { row[screenRow] = 1; col[screenCol] = 0; digitalWrite(RCK, LOW); shiftOut(SER, SRCK, MSBFIRST, COL_DATA); //先选择列 shiftOut(SER, SRCK, MSBFIRST, ROW_DATA); //再送行数据 digitalWrite(RCK, HIGH); } } } void UpdataDate() { if (animationIndex < animationFrames) { for (int i = 0; i < 64; i++) { int Dot = (animation[animationIndex][i / 4] >> (i % 4 * 2)); brightnesses[i] = (Dot & B1) || (Dot & B10); screen[7 - i / 8] |= (brightnesses[i] << (i % 8)) ; } } unsigned long startime = millis(); while (millis() - startime < animationDelays[animationIndex]) { doubleBuffer(); } animationIndex ++; if (animationIndex >= animationFrames) { //restart animation index animationIndex = 0; } for (int i = 0; i < 8; i++) screen[i] = B0; } void loop() { UpdataDate(); }
face.h:
int animationFrames = 2; int animationDelays[] = { 1000, 1000 }; // Animation is designed for 8x8 pixels uint8_t animation[][16] = { { 0x55, 0x55, 0x11, 0x44, 0x5, 0x50, 0x1, 0x40, 0x51, 0x45, 0x11, 0x44, 0x11, 0x44, 0x55, 0x55 }, { 0x5, 0x50, 0x5, 0x50, 0x0, 0x0, 0x40, 0x1, 0x40, 0x1, 0x0, 0x0, 0x4, 0x10, 0x50, 0x5 } };
参考资料
更多建议和问题欢迎反馈至 YFRobot论坛
购买方式:YFRobot 电子工作室