Difference between revisions of "Matrix - 0.96' 128x64 OLED"

From FriendlyELEC WiKi
Jump to: navigation, search
(Linux下的C示例)
(Applications)
 
(26 intermediate revisions by 3 users not shown)
Line 3: Line 3:
 
==Introduction==
 
==Introduction==
 
[[File:Oled.png|thumb|0.96inch 128x64 OLED]]
 
[[File:Oled.png|thumb|0.96inch 128x64 OLED]]
This is a tiny single color OLED. It is 0.96" and its resolution is 128 x 64. It can display text and graphics.It is high contrast and low power consumption. This module is powered by 5V which is converted to 3.3V to OLED. It communicates via SPI or I2C. Its signal level is 3.3V. By default it communicates via SPI. If you want to set its communication interface to I2C you can change module's resistors.
+
This is a tiny single color OLED. Its dimension is 0.96". Its resolution is 128 x 64. It can display text and graphics.It is high contrast and low power consumption. This module is powered by 5V which is then converted to 3.3V to OLED. It communicates via SPI or I2C. Its signal level is 3.3V. By default it communicates via SPI. If you want to set it to I2C you can change the module's resistor configuration.
  
 
==Features==
 
==Features==
Line 10: Line 10:
 
* SPI/I2C
 
* SPI/I2C
 
* 2.54mm spacing pin header
 
* 2.54mm spacing pin header
 +
* PCB Dimension(mm): 27 x 32
 +
[[File:oledpcb.png|frameless|400px|OLEDPCB]]
  
==How To Use It==
+
* Pin Description:
===Connection===
+
{| class="wikitable"
*Connect to Tiny4412 SDK (1506)
+
|-
::GND:  Gound
+
|Pin || Description
::VCC:  5V
+
|-
::CLK: SPI CLK
+
|CS    || Chip Selection
::MOSI: SPI MOSI
+
|-
::RES:  GPIO PIN1
+
|DC    || Data/Command
::DC:   GPIO PIN2
+
|-
::CS:   SPI CS
+
|RES  || Reset
 +
|-
 +
|MOSI || SPI MOSI
 +
|-
 +
|CLK   || SPI Clock
 +
|-
 +
|5V    || Power Supply 5V
 +
|-
 +
|GND   || Ground
 +
|}
  
===Code Sample in C with Linux===
+
==Basic Device Operation==
<syntaxhighlight lang="c">
+
#include <stdio.h>
+
#include "libfahw.h"
+
  
int display(int x, int y, char* str)
+
<!---
 +
 
 +
==Download Matrix Source Code==
 +
All the matrix modules' code samples are open source. They are maintained on GitHub --https://github.com/friendlyarm/matrix.git <br>
 +
Each branch in this hub contains the matrix modules' code samples for a board that the matrix modules can work with.<br>
 +
* The nanopi branch contains the matrix modules' code samples for the NanoPi
 +
* The nanopi 2 branch contains the matrix modules' code samples for the NanoPi 2
 +
* The tiny4412 branch contains the matrix modules' code samples for the Tiny4412
 +
* The raspberrypi branch contains the matrix modules' code samples for the RaspberryPi
 +
 
 +
Please follow the steps below to get the source code:<br>
 +
Install the git utility on a PC running Ubuntu14.04
 +
<syntaxhighlight lang="bash">
 +
$ sudo apt-get install git
 +
</syntaxhighlight>
 +
 
 +
Clone the matrix code from GitHub
 +
<syntaxhighlight lang="bash">
 +
$ git clone https://github.com/friendlyarm/matrix.git
 +
</syntaxhighlight>
 +
If this is successful a "matrix" directory will be generated, which will contain all the matrix modules' code samples.
 +
 
 +
--->
 +
 
 +
==Applications==
 +
===Connect to NanoPi M1===
 +
Refer to the following connection diagram to connect the module to the NanoPi M1<br>
 +
[[File:Matrix-0.96'_128x64_OLED_nanopi_m1.jpg|frameless|600px|Matrix-0.96'_128x64_OLED_nanopi_m1]]
 +
 
 +
Connection Details
 +
{| class="wikitable"
 +
|-
 +
|Matrix-0.96'_128x64_OLED || NanoPi M1
 +
|-
 +
|CS    || Pin24
 +
|-
 +
|DC    || Pin7
 +
|-
 +
|RES  || Pin11
 +
|-
 +
|MOSI  || Pin19
 +
|-
 +
|CLK  || Pin23
 +
|-
 +
|5V    || Pin2
 +
|-
 +
|GND  || Pin6
 +
|}
 +
 
 +
===Connect to NanoPi 2===
 +
Refer to the following connection diagram to connect the module to the NanoPi 2:<br>
 +
[[File:Matrix-0.96'_128x64_OLED_nanopi_2.jpg|frameless|600px|Matrix-0.96'_128x64_OLED_nanopi_2]]
 +
 
 +
Connection Details:
 +
{| class="wikitable"
 +
|-
 +
|Matrix-0.96'_128x64_OLED || NanoPi     
 +
|-
 +
|CS    || Pin24
 +
|-
 +
|DC    || Pin7
 +
|-
 +
|RES  || Pin11
 +
|-
 +
|MOSI  || SPI MOSI
 +
|-
 +
|CLK  || SPI Clock
 +
|-
 +
|5V    || Supply Voltage 5V
 +
|-
 +
|GND  || Ground
 +
|}
 +
 
 +
==Compile & Run Test Program==
 +
Boot your ARM board with Debian and copy the matrix code
 +
<syntaxhighlight lang="bash">
 +
$ apt-get update && apt-get install git
 +
$ git clone https://github.com/friendlyarm/matrix.git
 +
</syntaxhighlight>
 +
 
 +
If your cloning is done successfully a "matrix" directory will be generated.
 +
 
 +
Compile and install Matrix:
 +
<syntaxhighlight lang="bash">
 +
$ cd matrix
 +
$ make && make install
 +
</syntaxhighlight>
 +
 
 +
Run test program:
 +
<syntaxhighlight lang="bash">
 +
$ matrix-oled
 +
</syntaxhighlight>
 +
Here is what you should expect:<br>
 +
[[File:matrix-oled_result.png|frameless|600px|matrix-oled_result]] <br>
 +
The OLED displays the following two lines:<br>
 +
"ABCDEFGHIJKLMN"    <br>
 +
"123456789"
 +
 
 +
==Code Sample==
 +
This Matrix code sample can work with all the ARM boards mentioned in this module's wiki. The name of this code sample is "matrix-0.96_128x64_oled". Here is its source code:
 +
<syntaxhighlight lang="c">
 +
int main(int argc, char *argv[])  
 
{
 
{
 
     int devFD;
 
     int devFD;
     if ((devFD = OLEDInit(TINY4412_GPIO_PIN1, TINY4412_GPIO_PIN2)) == -1) {
+
   
 +
    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");
 
         printf("Fail to init OLED\n");
 
         return -1;
 
         return -1;
 
     }
 
     }
 +
    OLEDCleanScreen(devFD);
 
     // Char bitmap: 8x16
 
     // Char bitmap: 8x16
     OLEDDisp8x16Str(devFD, x, y, str);
+
     OLEDDisp8x16Str(devFD, 0, 0, "ABCDEFGHIJKLMN");
 +
    OLEDDisp8x16Str(devFD, 0, 16, "123456789");
 
     OLEDDeInit(devFD);
 
     OLEDDeInit(devFD);
     return 0;
+
      
}
+
 
+
int main(int argc, char *argv[]) {
+
    display(0, 0, "1234567890");
+
    display(0, 16, "ABCDEFGHIJK");
+
 
     return 0;
 
     return 0;
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
For more details about this APIs called in this code sample refer to :[[Matrix API reference manual]] <br>
  
===编译并运行示例===
+
==Resources==
<syntaxhighlight lang="bash">
+
 
git clone http://github.com/friendlyarm/fa-hardware.git
+
==Update Log==
cd fa-hardware
+
===Feb-19-2016===
cd demo
+
* Added Sections 3, 4, 5, 6 and 7
cd matrix-0.96inch_128x64_oled
+
make
+
</syntaxhighlight>
+
将编译生成的OLED通过ftp上传到开发板上运行即可测试。
+
  
==相关资料==
+
===June-16-2016===
 +
* Re-organized & simplified the wiki

Latest revision as of 10:21, 19 June 2016

查看中文

1 Introduction

0.96inch 128x64 OLED

This is a tiny single color OLED. Its dimension is 0.96". Its resolution is 128 x 64. It can display text and graphics.It is high contrast and low power consumption. This module is powered by 5V which is then converted to 3.3V to OLED. It communicates via SPI or I2C. Its signal level is 3.3V. By default it communicates via SPI. If you want to set it to I2C you can change the module's resistor configuration.

2 Features

  • Tiny
  • High contrast, low power consumption
  • SPI/I2C
  • 2.54mm spacing pin header
  • PCB Dimension(mm): 27 x 32

OLEDPCB

  • Pin Description:
Pin Description
CS Chip Selection
DC Data/Command
RES Reset
MOSI SPI MOSI
CLK SPI Clock
5V Power Supply 5V
GND Ground

3 Basic Device Operation

4 Applications

4.1 Connect to NanoPi M1

Refer to the following connection diagram to connect the module to the NanoPi M1
Matrix-0.96'_128x64_OLED_nanopi_m1

Connection Details

Matrix-0.96'_128x64_OLED NanoPi M1
CS Pin24
DC Pin7
RES Pin11
MOSI Pin19
CLK Pin23
5V Pin2
GND Pin6

4.2 Connect to NanoPi 2

Refer to the following connection diagram to connect the module to the NanoPi 2:
Matrix-0.96'_128x64_OLED_nanopi_2

Connection Details:

Matrix-0.96'_128x64_OLED NanoPi
CS Pin24
DC Pin7
RES Pin11
MOSI SPI MOSI
CLK SPI Clock
5V Supply Voltage 5V
GND Ground

5 Compile & Run Test Program

Boot your ARM board with Debian and copy the matrix code

$ apt-get update && apt-get install git
$ git clone https://github.com/friendlyarm/matrix.git

If your cloning is done successfully a "matrix" directory will be generated.

Compile and install Matrix:

$ cd matrix
$ make && make install

Run test program:

$ matrix-oled

Here is what you should expect:
matrix-oled_result
The OLED displays the following two lines:
"ABCDEFGHIJKLMN"
"123456789"

6 Code Sample

This Matrix code sample can work with all the ARM boards mentioned in this module's wiki. The name of this code sample is "matrix-0.96_128x64_oled". Here is its source code:

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;
}

For more details about this APIs called in this code sample refer to :Matrix API reference manual

7 Resources

8 Update Log

8.1 Feb-19-2016

  • Added Sections 3, 4, 5, 6 and 7

8.2 June-16-2016

  • Re-organized & simplified the wiki