张高兴的 Windows 10 IoT 开发笔记:0.96 寸 I2C OLED


This is a Windows 10 IoT Core project on the Raspberry Pi 2/3, coded by C#.

GitHub:https://github.com/ZhangGaoxing/windows-iot-demo/tree/master/OLED

Image

Connect

  • SDA - Pin3
  • SCL - Pin5
  • VCC - 5V
  • GND - GND

Reference

https://github.com/ZhangGaoxing/windows-iot-demo/tree/master/OLED/Reference

What Contains

In OLED.cs file

/// 
/// Initialize the OLED
/// 
public async Task InitializeAsync();

/// 
/// Show character on OLED
/// 
/// x-coordinate
/// y-coordinate / 8 !!!
/// Character Width
/// Character Height
/// Character Data (common-cathode, column-row, and reverse ou
public void ShowChar(int x, int y, byte width, byte height, byte[] charData);

/// 
/// Send command
/// 
/// Command
private void WriteCommand(byte command);

/// 
/// Send the data which you want to show on the OLED
/// 
/// Data
public void WriteData(byte data);

/// 
/// Set start point (cursor)
/// 
/// x-coordinate
/// y-coordinate / 8 !!!
public void SetPoint(int x, int y);

/// 
/// Fill the OLED with data (input 0xFF to fill, 0x00 to clear)
/// 
public void FillScreen(byte data1, byte data2);

/// 
/// Cleanup
/// 
public void Dispose();

/// 
/// Init command
/// 
private void InitCommand();

How to Use

  • First, you need to create a OLED object. After that you should call InitializeAsync() to initialize.
OLED oled = new OLED();
await oled.InitializeAsync();
  • Secondly
oled.ShowChar(0, 0, 16, 16, bytes);
  • If you want to close the sensor, call Dispose().
oled.Dispose();