2007 views|4 replies

6818

Posts

11

Resources
The OP
 

[National Technology N32G457 Review] RT-Thread drives SSD1306 [Copy link]

 

RT_Thread's software package center conveniently provides users with commonly used drivers. Today we use the software package center to drive the SSD1306 OLED screen.

1. Create a new project and choose the development board:

Open RT-Thread Settings:

Select Add Package:

Open the interface, search for ssd1306, and add the software package:

Select detailed configuration on the software package:

钩选sample

Check ENABLE I2C

Return to the interface

Enable C++ libc

Close the configuration and save it.

Change SCL SDA to Pin 92 93

Modify the configuration of drv_gpio.c to 100pin

Modify main.c to:

/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2015-07-29     Arda.Fu      first implementation
 */
#include <stdint.h>
#include <rtthread.h>
#include <rtdevice.h>
#include <board.h>

#include <string.h>
#include <stdio.h>
#include "ssd1306.h"



/* defined the LED1 pin: PB5 */
#define LED1_PIN    91

int main(void)
{
    uint32_t Speed = 200;
    /* set LED1 pin mode to output */
    rt_pin_mode(LED1_PIN, PIN_MODE_OUTPUT);
    rt_kprintf("start ssd1306\r\n");
    ssd1306_Init();
    ssd1306_Fill(Black);
    ssd1306_SetCursor(2,0);
    ssd1306_WriteString("HELLO NG32!", Font_11x18, White);
    ssd1306_SetCursor(2,18);
    ssd1306_WriteString("HAPPY NEW YEAR!", Font_7x10, White);
    ssd1306_UpdateScreen();
    while (1)
    {
        rt_pin_write(LED1_PIN, PIN_LOW);
        rt_thread_mdelay(Speed);
        rt_pin_write(LED1_PIN, PIN_HIGH);
        rt_thread_mdelay(Speed);
    }
}

Then compile and download:

Successfully light up the LED

You can successfully drive SSD1306 by following these steps. The main thing here is to modify the SCL SDA pins, which is a bit troublesome because the software package gives 23 and 24. I searched drv_gpio.c and found that there is no pin 23. By checking the data sheet, it is 92 (PB6) 93 (PB7). After half a day of tossing, the screen finally lights up! I hope to guide you.

image.png (40.5 KB, downloads: 0)

image.png
This post is from Domestic Chip Exchange

Latest reply

RT-THREAD is simpler to implement. Looking forward to the follow-up  Details Published on 2022-1-25 16:52
 
 

1127

Posts

17

Resources
2
 
Great, are you using soft I2C or hard I2C?
This post is from Domestic Chip Exchange

Comments

RTThread's IIC is generally implemented using software.  Details Published on 2022-1-25 14:54
RTThread's IIC is generally implemented using software.  Details Published on 2022-1-25 14:11
 
 
 

6742

Posts

2

Resources
3
 
fxyc87 posted on 2022-1-25 13:44 Like, are you using soft I2C or hard I2C?

RTThread's IIC is generally implemented using software.

This post is from Domestic Chip Exchange
 
 
 

6818

Posts

11

Resources
4
 
fxyc87 posted on 2022-1-25 13:44 Like, are you using soft I2C or hard I2C?

It can be hard or soft, and there are routines for both. The routines for U8G2 are more clear.

This post is from Domestic Chip Exchange
 
 
 

1412

Posts

3

Resources
5
 
RT-THREAD is simpler to implement. Looking forward to the follow-up
This post is from Domestic Chip Exchange
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list