You have no items in your shopping cart.



Profile Informations

Login Datas

or login

First name is required!
Last name is required!
First name is not valid!
Last name is not valid!
This is not an email address!
Email address is required!
This email is already registered!
Password is required!
Enter a valid password!
Please enter 6 or more characters!
Please enter 16 or less characters!
Passwords are not same!
Terms and Conditions are required!
Email or Password is wrong!
Captcha is required!
Captcha is wrong!

Use OLED With Iteaduino Plus By ITEAD OS SDK

In the previous blog, we made a brief introduction to structure and function of ITEAD OS and SDK, and now we want to experience how to use SDK API to realize display function of OLED screen on Iteaduino Plus.

To do the test, we offer a dynamic link library called "liboledtest.so" in which there are four simple functions:

  • ssd1306_begin()

The initialization function of OLED screen. You only need to execute it once when starting, it will complete the initialization of the screen and then proceed with the display operations.

  • ssd1306_fill(unsigned char dat)

Parameter can only be 0 or 1. This function is used to fill the entire OLED screen with white or black, and we use it as a screen-clearing function .

  • setCursor(unsigned char column, unsigned char line)

Set the cursor position which includes the row and column coordinates .

  • oled_write_str(char * str)

Display strings behind the cursor.

With the library and Arduino Plug, we do not need to know about the various connection configurations of hardware, we simply connect Plug with Iteaduino Plus via cable and then we can manipulate OLED screen displays with the four library functions. Here, we would like to use python to demonstrate displaying "hello world" on the OLED screen.

First, start a terminal window, and then use command su to enter the root privileges , run the python:

Then enter the following codes:

from ctypes import *
clib.oled_write_str(c_char_p("Hello World"))

Import ctypes standard library on the first row, next call the functions in the standard library to import the dynamic link library, and then call the library functions to initialize, to clear screen, to locate and to display in sequence. Once a function is successfully run, there will be a return value 0, and finally you can see Hello World displaying on the screen.

With these API functions , it will be quite easy to control the OLED screen display. For example, we can read the CPU load situation and then display the real-time information on the OLED screen . Operation is also very simple, create a new . Py suffixed file first , and then write the following codes:

from ctypes import *
import os

while 1:
  info=os.popen('top -bi -n 2 -d 0.02').read().split('\n\n\n')[1].split('\n')[2].split(',')[0][7:]

It is actually much like with the above test code, we need to import os standard library, and then to read and to analyze the function of cpu occupacy, and finally display the information on the OLED screen cyclically. After saving the file, you can use the following command to execute the code in the terminal window

	python CPU.py

After running the code, you can see the real-time CPU occupancy on the OLED screen as shown in the picture. We are using a test library now, in which there are only four demo functions. In the official version, there will be more than 10 operating functions which can be used for more complex operations such as to draw lines and points and to change fonts, etc. So stay tuned.