Difference between revisions of "Matrix - 0.96' 128x64 OLED/zh"
From FriendlyELEC WiKi
(11 intermediate revisions by 2 users not shown) | |||
Line 35: | Line 35: | ||
==工作原理== | ==工作原理== | ||
− | == | + | ==硬件连接== |
− | + | ===连接NanoPi M1=== | |
− | + | 参考下图连接模块:<br> | |
− | + | [[File:Matrix-0.96'_128x64_OLED_nanopi_m1.jpg|frameless|600px|Matrix-0.96'_128x64_OLED_nanopi_m1]] | |
− | + | ||
− | + | ||
− | + | ||
− | + | 连接说明: | |
− | + | {| class="wikitable" | |
− | + | |- | |
− | + | |Matrix-0.96'_128x64_OLED || NanoPi M1 | |
− | + | |- | |
− | + | |CS || Pin24 | |
− | + | |- | |
− | + | |DC || Pin7 | |
− | + | |- | |
− | + | |RES || Pin11 | |
+ | |- | ||
+ | |MOSI || Pin19 | ||
+ | |- | ||
+ | |CLK || Pin23 | ||
+ | |- | ||
+ | |5V || Pin2 | ||
+ | |- | ||
+ | |GND || Pin6 | ||
+ | |} | ||
− | == | + | ===连接NanoPi 2=== |
− | + | 参考下图连接模块:<br> | |
− | + | ||
[[File:Matrix-0.96'_128x64_OLED_nanopi_2.jpg|frameless|600px|Matrix-0.96'_128x64_OLED_nanopi_2]] | [[File:Matrix-0.96'_128x64_OLED_nanopi_2.jpg|frameless|600px|Matrix-0.96'_128x64_OLED_nanopi_2]] | ||
Line 62: | Line 67: | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
− | |Matrix-0.96'_128x64_OLED || NanoPi | + | |Matrix-0.96'_128x64_OLED || NanoPi 2 |
|- | |- | ||
|CS || Pin24 | |CS || Pin24 | ||
Line 70: | Line 75: | ||
|RES || Pin11 | |RES || Pin11 | ||
|- | |- | ||
− | |MOSI || | + | |MOSI || Pin19 |
|- | |- | ||
− | |CLK || | + | |CLK || Pin23 |
|- | |- | ||
− | |5V || | + | |5V || Pin2 |
|- | |- | ||
− | |GND || | + | |GND || Pin6 |
|} | |} | ||
− | == | + | ==编译运行测试程序== |
− | + | 启动开发板并运行Debian系统,进入系统后克隆Matrix代码仓库: | |
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
− | $ | + | $ apt-get update && apt-get install git |
− | $ git | + | $ git clone https://github.com/friendlyarm/matrix.git |
</syntaxhighlight> | </syntaxhighlight> | ||
+ | 克隆完成后会得到一个名为matrix的目录。 | ||
− | + | 编译并安装Matrix: | |
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
− | $ | + | $ cd matrix |
− | $ make | + | $ make && make install |
− | + | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | + | 运行测试程序: | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
$ matrix-oled | $ matrix-oled | ||
Line 114: | Line 108: | ||
"123456789" | "123456789" | ||
− | == | + | ==代码说明== |
+ | 所有的开发板都共用一套Matrix代码,本模块的测试示例代码为matrix-0.96_128x64_oled,内容如下: | ||
<syntaxhighlight lang="c"> | <syntaxhighlight lang="c"> | ||
int main(int argc, char *argv[]) | int main(int argc, char *argv[]) | ||
{ | { | ||
int devFD; | int devFD; | ||
+ | |||
+ | if (boardInit() < 0) { | ||
+ | printf("Fail to init board\n"); | ||
+ | return -1; | ||
+ | } | ||
+ | |||
if ((devFD = OLEDInit(GPIO_PIN(7), GPIO_PIN(11))) == -1) { | if ((devFD = OLEDInit(GPIO_PIN(7), GPIO_PIN(11))) == -1) { | ||
printf("Fail to init OLED\n"); | printf("Fail to init OLED\n"); | ||
Line 128: | Line 129: | ||
OLEDDisp8x16Str(devFD, 0, 16, "123456789"); | OLEDDisp8x16Str(devFD, 0, 16, "123456789"); | ||
OLEDDeInit(devFD); | OLEDDeInit(devFD); | ||
+ | |||
return 0; | return 0; | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | API说明参考维基:[[Matrix API reference manual/zh|Matrix API reference manual]] <br> | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
==相关资料== | ==相关资料== |
Latest revision as of 02:42, 3 June 2016
1 介绍
这是一款精致小巧的单色OLED显示屏,只有0.96英寸,分辨率是128x64,可以用来显示文字或图案。因为OLED是自发光的,所以无需背光,对比度高,功耗低。此配件5V供电,PCB上的电源转换芯片输出3.3V给OLED,通讯接口是SPI或I2C,信号电平为3.3V。默认通讯方式是SPI,如果需要改为I2C,您可以通过修改PCB上的配置电阻实现。
2 特性
- 精致小巧
- 高对比度,低功耗
- SPI/I2C
- 2.54mm排针接口,接线方便,通用性强
- PCB尺寸(mm):27x32
- 引脚说明:
名称 | 描述 |
CS | 片选 |
DC | 数据命令选择 |
RES | 复位 |
MOSI | SPI MOSI |
CLK | SPI Clock |
5V | 电源5V |
GND | 地 |
3 工作原理
4 硬件连接
4.1 连接NanoPi M1
参考下图连接模块:
Matrix-0.96'_128x64_OLED_nanopi_m1
连接说明:
Matrix-0.96'_128x64_OLED | NanoPi M1 |
CS | Pin24 |
DC | Pin7 |
RES | Pin11 |
MOSI | Pin19 |
CLK | Pin23 |
5V | Pin2 |
GND | Pin6 |
4.2 连接NanoPi 2
参考下图连接模块:
Matrix-0.96'_128x64_OLED_nanopi_2
连接说明:
Matrix-0.96'_128x64_OLED | NanoPi 2 |
CS | Pin24 |
DC | Pin7 |
RES | Pin11 |
MOSI | Pin19 |
CLK | Pin23 |
5V | Pin2 |
GND | Pin6 |
5 编译运行测试程序
启动开发板并运行Debian系统,进入系统后克隆Matrix代码仓库:
$ apt-get update && apt-get install git $ git clone https://github.com/friendlyarm/matrix.git
克隆完成后会得到一个名为matrix的目录。
编译并安装Matrix:
$ cd matrix $ make && make install
运行测试程序:
$ matrix-oled
运行效果如下:
matrix-oled_result
OLED上会显示下列2行字符:
"ABCDEFGHIJKLMN"
"123456789"
6 代码说明
所有的开发板都共用一套Matrix代码,本模块的测试示例代码为matrix-0.96_128x64_oled,内容如下:
int main(int argc, char *argv[]) { int devFD; if (boardInit() < 0) { printf("Fail to init board\n"); return -1; } if ((devFD = OLEDInit(GPIO_PIN(7), GPIO_PIN(11))) == -1) { printf("Fail to init OLED\n"); return -1; } OLEDCleanScreen(devFD); // Char bitmap: 8x16 OLEDDisp8x16Str(devFD, 0, 0, "ABCDEFGHIJKLMN"); OLEDDisp8x16Str(devFD, 0, 16, "123456789"); OLEDDeInit(devFD); return 0; }
API说明参考维基:Matrix API reference manual