Difference between revisions of "Matrix - 0.96' 128x64 OLED"
(→Resources) |
(→How To) |
||
Line 34: | Line 34: | ||
If this is successful a "matrix" directory will be generated, which will contain all the matrix modules' code samples. | If this is successful a "matrix" directory will be generated, which will contain all the matrix modules' code samples. | ||
− | == | + | ==Connect to NanoPi 2== |
− | ===Connection=== | + | ===Hardware Connection=== |
− | + | Please refer to the following connection diagram to connect the Matrix-0.96'_128x64_OLED 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 | ||
+ | |} | ||
− | int | + | ===Compile Test Program=== |
+ | Please login the matrix hub and enter the nanopi2 branch | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | $ cd matrix | ||
+ | $ git checkout nanopi2 | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | Compile the matrix code | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | $ make CROSS_COMPILE=arm-linux- clean | ||
+ | $ make CROSS_COMPILE=arm-linux- | ||
+ | $ make CROSS_COMPILE=arm-linux- install | ||
+ | </syntaxhighlight> | ||
+ | Note: please make sure to install the cross compiler "arm-linux-gcc-4.9.3" on your PC, which is used to compile files for the NanoPi2.<br> | ||
+ | Generated library files are under the "install/lib" directory. Applications are under the "install/usr/bin" directory. The test program for the "Matrix-0.96'_128x64_OLED" module is "matrix-oled".<br> | ||
+ | The driver is under the modules directory and its source code is in github: https://github.com/friendlyarm/linux-3.4.y.git <br> | ||
+ | |||
+ | ===Run Test Program=== | ||
+ | Please insert a TF card which is flashed with Debian to a Linux host and mount its boot and rootfs sections.<br> | ||
+ | We assume the rootfs is mounted to /media/rootfs then please run the following commands to copy the driver, library and test program to the card.<br> | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | $ cp modules /media/rootfs/ -r | ||
+ | $ cp install/lib/* /media/rootfs/lib/ -d | ||
+ | $ cp install/usr/bin/* /media/rootfs/usr/bin/ | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | Insert this TF card to your NanoPi 2, power on and run the following command to start matrix-oled.<br> | ||
+ | <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=== | ||
+ | <syntaxhighlight lang="c"> | ||
+ | int main(int argc, char *argv[]) | ||
{ | { | ||
int devFD; | int devFD; | ||
− | if ((devFD = OLEDInit( | + | 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, | + | OLEDDisp8x16Str(devFD, 0, 0, "ABCDEFGHIJKLMN"); |
+ | OLEDDisp8x16Str(devFD, 0, 16, "123456789"); | ||
OLEDDeInit(devFD); | OLEDDeInit(devFD); | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
return 0; | return 0; | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | === | + | ==Connect to NanoPi== |
− | + | ||
− | + | ==Connect to Tiny4412== | |
− | + | ||
− | + | ==Connect to RaspberryPi== | |
− | + | ||
− | + | ==Connect to Arduino== | |
− | + | ||
− | + | ||
==Resources== | ==Resources== |
Revision as of 09:24, 19 February 2016
Contents
1 Introduction
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
3 Basic Device Operation
4 Download Matrix Source Code
All the matrix modules' code samples are open source. They are maintained on GitHub --https://github.com/friendlyarm/matrix.git
Each branch in this hub contains the matrix modules' code samples for a board that the matrix modules can work with.
- 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:
Install the git utility on a PC running Ubuntu14.04
$ sudo apt-get install git
Clone the matrix code from GitHub
$ git clone https://github.com/friendlyarm/matrix.git
If this is successful a "matrix" directory will be generated, which will contain all the matrix modules' code samples.
5 Connect to NanoPi 2
5.1 Hardware Connection
Please refer to the following connection diagram to connect the Matrix-0.96'_128x64_OLED 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.2 Compile Test Program
Please login the matrix hub and enter the nanopi2 branch
$ cd matrix $ git checkout nanopi2
Compile the matrix code
$ make CROSS_COMPILE=arm-linux- clean $ make CROSS_COMPILE=arm-linux- $ make CROSS_COMPILE=arm-linux- install
Note: please make sure to install the cross compiler "arm-linux-gcc-4.9.3" on your PC, which is used to compile files for the NanoPi2.
Generated library files are under the "install/lib" directory. Applications are under the "install/usr/bin" directory. The test program for the "Matrix-0.96'_128x64_OLED" module is "matrix-oled".
The driver is under the modules directory and its source code is in github: https://github.com/friendlyarm/linux-3.4.y.git
5.3 Run Test Program
Please insert a TF card which is flashed with Debian to a Linux host and mount its boot and rootfs sections.
We assume the rootfs is mounted to /media/rootfs then please run the following commands to copy the driver, library and test program to the card.
$ cp modules /media/rootfs/ -r $ cp install/lib/* /media/rootfs/lib/ -d $ cp install/usr/bin/* /media/rootfs/usr/bin/
Insert this TF card to your NanoPi 2, power on and run the following command to start matrix-oled.
$ matrix-oled
Here is what you should expect:
matrix-oled_result
The OLED displays the following two lines:
"ABCDEFGHIJKLMN"
"123456789"
5.4 Code Sample
int main(int argc, char *argv[]) { int devFD; 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; }
6 Connect to NanoPi
7 Connect to Tiny4412
8 Connect to RaspberryPi
9 Connect to Arduino
10 Resources
11 Update Log
11.1 Feb-19-2016
- Added Sections 3, 4 and 5