1762 views|1 replies

46

Posts

0

Resources
The OP
 

[Atria AT32WB415 Series Bluetooth BLE 5.0 MCU] Part 3: Lightble Control OLED Display [Copy link]

This post was last edited by lingxin_yuhe on 2022-8-13 11:54

Preface: Bluetooth controls the display of OLED. First, drive the OLED. I wanted to use the MCU's I2C driver + u8g2 for display, but there was a problem. The compilation problem is shown in the figure below. Various troubleshooting did not solve it. I can only use IO simulation display without using the u8g2 library. I have used this library in other microcontrollers without any problems. I don't know where the problem is. I will study it slowly later. If there are partners who know where the problem is, please leave a message to tell me. The header file and the file are added to the project. It says to add extern "C", and it is also added, but this error is always prompted.

Look at the demonstration effect at the bottom. If you want to achieve the following effect, analyze the principle:

According to the control principle of the light in the demo, the mobile phone lightble writes the corresponding 0 and 1 through C101 to control the light off and on, and writes 3456 to control the four functions of displaying the first line, displaying the second line, displaying the third line and clearing the screen respectively. Then let's write the specific implementation process.

1. MCU modification work

  1. OLED drive test

There are many OLED IO analog control drivers on the Internet. Here is the driver I modified before, and the source code will be provided later. The pin connection is as follows:

#define OLED_SCL GPIO_PINS_9 //PB9

#define OLED_SDA GPIO_PINS_8 //PB8

GND------GND

VCC-------VDD

Add the OLED driver to the MCU demo, compile and download, and the display is as shown in the figure.

  1. Increased controlled functions

Add macro definitions of four functions and write them in at_cmd.h according to the IO control logic, as shown in the figure.

Add control functions in the main.c function, as shown in the figure below. First, add the logic of the four functions in at_cmd_list.

Initialize OLED in the main function as shown in the figure.

Add four kinds of logic processing in the serial port processing function, as shown in the figure.

After downloading to MCU, it still cannot be controlled by Bluetooth. You need to modify the logic of BLE end and add 3456 to send messages to MCU.

2. Modification work on BLE end

The BLE end can be modified according to its own logic function. For the simple function implemented now, only two places need to be modified: app.h and custom_task.c. As shown in the figure below, modify app.h to imitate IO control and send.

Modify the gattc_write_req_ind_handler function in the Custom_task.c file to process the data received from Lightble and send it to the MCU, as shown in the figure.

After the modification is completed, download the two files of MCU and BLE end to the board, restart, send 03 through lightble to display the first line of AT32WB415, send 04 to display the second line of OLED TEST, send 05 to display the third line of EEWORLD, send 06 to clear the screen, and here you can repeat the lightble to send instructions to control the display of OLED.

oled_ble

This post is from RF/Wirelessly

Latest reply

Lightble controls the OLED display and tests well [attach]632167[/attach]   Details Published on 2022-8-13 17:43
 

6593

Posts

0

Resources
2
 

Lightble controls the OLED display and tests well

This post is from RF/Wirelessly
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

快速回复 返回顶部 Return list