CubeNano driver library

CubeNano driver libraryI. IntroductionII. Installation of dependent libraries1. smbus library2. Adafruit_SSD1306 libraryIII. Python driver library filesTransferring files to the motherboard systemV. Driver Library InstallationVI. Importing Library FilesVII. Querying the firmware version number1. Query the version number2. bot = CubeNano(i2c_bus=1)VIII. API Introduction

I. Introduction

With the CubeNano driver library installed, you can implement RGB light and fan peripheral control by calling the corresponding API functions.

Driver library update can also follow the steps below!

Please refer to the following steps to install the driver library, and here we take the V1.0.1 version installation as an example.

Note: CubeNano chassis power on the switch will automatically turn on the RGB lighting effects and fans.

II. Installation of dependent libraries

1. smbus library

CubeNano driver library installation needs to import time library and smbus library, which time library is python comes with, do not need to install their own, terminal input the following command to install smbus library.

python smbus library functions to access serial I2C devices, using smbus library functions can be used to read and write I2C device information.

2. Adafruit_SSD1306 library

Since the OLED display also needs to use the relevant dependency libraries, we can install the required dependency libraries together, terminal input the following command to install the Adafruit_SSD1306 library.

The python Adafruit_SSD1306 library is used to control the data display of our OLED display.

Note: If you are prompted for a missing PIL library in the OLED display tutorial, the following solution can be taken.

III. Python driver library files

The latest version of the CubeNano Python driver library is provided inside this course material, named CubeNanoLib_V1.0.1.

image-20230714180310668

Transferring files to the motherboard system

The following is only a brief introduction to several methods of transferring files, specific how to operate choose your own familiar way can be.

Choose one of these methods to transfer the CubeNanoLib_V1.0.1.zip file to the motherboard system.

V. Driver Library Installation

Open a terminal in the directory of the folder where the zip file is located and enter the following command:

The purpose of this command is to unzip and enter the file setup.py directory to run the installation command, no need to dwell on whether the version number is the same or not.

image-20230714181607653

If you see the installation version number at the end, it means the installation is successful. This command will overwrite the CubeNanoLib driver library that has been installed before.

VI. Importing Library Files

The name of the CubeNano driver library is CubeNanoLib, use CubeNanoLib to import the library in the programme.

VII. Querying the firmware version number

1. Query the version number

(python interactive interface: each statement needs to be run separately)

Enter python in the terminal to enter the interactive interface.

image-20230717201747013

2. bot = CubeNano(i2c_bus=1)

Using the smbus library function, we need to create an object, where i2c_bus = 1 in the 1 represents i2c - 1, we are currently using the I2C device is mounted under this device bus.

We can query the bus and address of the specific device through the following steps.

Query I2C bus

The list displayed by the system needs to be queried all over again, we need to find the bus on which the two devices are mounted.

Query I2C devices

Find the device bus with I2C addresses 0e and 3c, this bus is the device bus object we need to create

image-20230717204338694

VIII. API Introduction

The following is a brief introduction to the API of the CubeNano driver library. Functional usage and parameter contents are introduced later in the control course.