NanoHat OLED/zh

From FriendlyELEC WiKi
Revision as of 07:56, 18 April 2017 by Kangjing (Talk | contribs) (介绍)

Jump to: navigation, search

English

1 介绍

0.96inch 128x64 OLED

NanoHat OLED是一款精致小巧的单色OLED显示屏,只有0.96英寸,分辨率是128x64,对比度高,功耗低,可以用来显示文字或图案。 NanoHat OLED和NanoPi NEO/Air/NEO2的外形尺寸和接口完全相同,可直接堆叠在NanoPi NEO/Air/NEO2上。通过I2C和NanoPi NEO/Air/NEO2通讯。

2 特性

  • 精致小巧
  • 高对比度,低功耗
  • SPI/I2C
  • 2.54mm排针接口,接线方便,通用性强
  • PCB尺寸(mm):27x32

OLEDPCB

  • 引脚说明:
名称 描述
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

7 相关资料