当前位置:网站首页>use. Net drives the OLED display of Jetson nano
use. Net drives the OLED display of Jetson nano
2022-07-06 20:31:00 【Sang Yu Xiao Wu】
background
Recent years , The demand for edge computing has exploded . Artificial intelligence 、 Internet of things and 5G The evolution of brings infinite possibilities to edge computing . Because of work , I'm lucky to be here 2019 Began to contact NVIDIA Jetson Family of edge computing devices :Nano,TX2,AGX,NX etc. , Its operating system uses Ubuntu 18.02. We can use it as an independent small server , Which programmer would refuse to own a small computer of his own ? On top of it , Especially having GPU On , We can toss about infinite possibilities .
stay Jetson The development version of the equipment is on the board , There is usually one 40 Pin pin SPIO And GPIO, Through it, we can expand more interesting things . for instance : A piece of I2C Of OLED display , And then through .Net To drive it to show something fun ( Software status , Equipment status , Other key data indicators ).
Screen installation
The screen here is a piece 0.96 Inch yellow and blue OLED LCD module , altogether 4 Interface :3.3V Positive pole VCC, Negative pole GND, And responsible for I2C Communicating SDA and SCL.
So how to connect the monitor with Jetson The equipment is connected ? The demonstration here is based on the earlier Nano Carrier board of Developer Suite , The pins of other series of official carrier boards are basically similar , You can also find the hardware specification or Refer to the guidelines on the official website To find the I2C Interface can .
I'm using I2C1, The pin connected is 1,3,5,6 , Install as defined OLED display .
To configure I2C Bus
After installing the screen , Must be configured I2C, Only our own login account can be in non Root Access... Under permission I2C Bus .
Put the following command username Change to your login account name
sudo usermod -aG i2c username
Better restart the device , If you execute the following command, it can be displayed normally , Then there's no problem .
i2cdetect -y -r 1
In the following illustration ,OLED Address of the display 3c Be particularly highlighted .
use .NET Drive display
Drive this oled Screen we need to use Microsoft IoT Related libraries “System.Device.Gpio” , Through this library, we can realize the connection with external devices I2C Communications , Of course drive OLED The display needs to use various instructions familiar with its driver chip , The driver chip here is SSD1306, Have the biggest 128*64 Pixel support , Widely used in small size OLED The drive of the display screen .
Here we won't introduce the related drivers and instructions , I have encapsulated the relevant instructions into a library , You can use it directly , Open source library , Interested students can consult relevant knowledge and source code by themselves .
Now let's go through Jetson Nano Show how to use “Sang.IoT.SSD1306” Library to control OLED display frame .
install .Net development environment
because Jetson yes arm64 The equipment , Let's go straight to .Net Choose to download from the official website .Net6 Of Arm64 edition .
Execution and installation
mkdir -p $HOME/dotnet && tar zxf dotnet-sdk-6.0.301-linux-arm64.tar.gz -C $HOME/dotnet
Then change the user directory .bashrc
file , Add the following environment configuration at the end :
export DOTNET_ROOT=$HOME/dotnet
export PATH=$PATH:$HOME/dotnet
function dotnet
Command to check the installation .
Using the demonstration
Create a console program
dotnet new console -o i2c_oled
Add driver library
dotnet add package Sang.IoT.SSD1306
Modify the code
using Sang.IoT.SSD1306;
using (var oled = new SSD1306_128_64(1)) {
oled.Begin();
// The display content that needs to be sent to the display
byte[] c = new byte[128*64]{
...};
oled.SetBuffer(c);
oled.Display();
}
To display the array data to the screen , You need to store the data in SSD1306 Of RAM. there RAM The size is 128x64 position , It is divided into 8 page , from 0 Page to 7 page , For monochrome 128x64 The dot matrix shows .
The above code may not be used at ordinary times , It is mainly a customized content display interface .
Picture shows
The class library here uses Microsoft SkiaSharp Cross platform image processing library , About cross platform image processing library , If you have a need , Sure Look at this article to compare .
The pictures used for demonstration here are as follows , We put it in OLED The display shows .
Original image address :https://raw.githubusercontent.com/marin1993/Sang.IoT.SSD1306/master/assets/test.png
using Sang.IoT.SSD1306;
using (var oled = new SSD1306_128_64(1)) {
oled.Begin();
oled.Image("assets/test.png");
oled.Display();
}
The effect is as follows :
According to the text
that , How to display text ? Of course , The same way of thinking , We first pass SkiaSharp Create a bitmap , Then display it , So it's not difficult to load font files to display Chinese fonts .
using Sang.IoT.SSD1306;
using SkiaSharp;
using (var oled = new SSD1306_128_64(1)) {
oled.Begin();
oled.Clear();
using(var bitmap = new SKBitmap(128, 64, true)){
SKCanvas canvas = new SKCanvas(bitmap);
SKPaint paint = new SKPaint() {
Color = new SKColor(255, 255, 255),
StrokeWidth = 1, // The width of the brush
Typeface = SKTypeface.FromFile("/home/sangsq/i2c_led/SourceHanSansCN-Normal.ttf"),
TextSize = 13, // font size
Style = SKPaintStyle.Fill,
};
canvas.DrawText(" official account :sangxiao99 ", 0, 13, paint);
paint.TextSize = 30;
canvas.DrawText(" Sang Yu Xiao Wu ", 0, 50, paint);
oled.Image(bitmap.Encode(SKEncodedImageFormat.Png, 100).ToArray());
}
oled.Display();
}
The effect is as follows :
Clear the display
oled.Clear();
Conclusion
If the IoT If you are interested in this field or want to toss the development board at hand , You can go to the official website to learn more .Net Of IoT resources .
Just arrived at a SPI Interface LCD Color display , There are new toys to play with .
边栏推荐
- Anaconda安裝後Jupyter launch 沒反應&網頁打開運行沒執行
- Digital triangle model acwing 1018 Minimum toll
- Value of APS application in food industry
- BUUCTF---Reverse---easyre
- Quel genre de programmation les enfants apprennent - ils?
- 【每周一坑】输出三角形
- (work record) March 11, 2020 to March 15, 2021
- Introduction of Xia Zhigang
- Leetcode question 283 Move zero
- 知识图谱之实体对齐二
猜你喜欢
Discussion on beegfs high availability mode
“罚点球”小游戏
使用.Net分析.Net达人挑战赛参与情况
Implementation of packaging video into MP4 format and storing it in TF Card
01 基础入门-概念名词
Force deduction brush question - 98 Validate binary search tree
[DIY]如何制作一款个性的收音机
Node.js: express + MySQL实现注册登录,身份认证
Tencent T2 Daniel explained in person and doubled his job hopping salary
Continuous test (CT) practical experience sharing
随机推荐
Basic knowledge of lists
使用.Net分析.Net达人挑战赛参与情况
recyclerview gridlayout 平分中间空白区域
I've seen many tutorials, but I still can't write a program well. How can I break it?
为什么新手在编程社区提问经常得不到回答,甚至还会被嘲讽?
Why do novices often fail to answer questions in the programming community, and even get ridiculed?
Number of schemes from the upper left corner to the lower right corner of the chessboard (2)
RT thread I2C tutorial
Tencent T3 Daniel will teach you hand-in-hand, the internal information of the factory
Boder radius has four values, and boder radius exceeds four values
[weekly pit] positive integer factorization prime factor + [solution] calculate the sum of prime numbers within 100
01 基础入门-概念名词
【云原生与5G】微服务加持5G核心网
看过很多教程,却依然写不好一个程序,怎么破?
Introduction of Xia Zhigang
Cesium Click to draw a circle (dynamically draw a circle)
Value of APS application in food industry
HMS core machine learning service creates a new "sound" state of simultaneous interpreting translation, and AI makes international exchanges smoother
【计网】第三章 数据链路层(3)信道划分介质访问控制
Detailed introduction of distributed pressure measurement system VIII: basic introduction of akka actor model