Skip to content

smdn/Smdn.Devices.US2066

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Smdn.Devices.US2066

GitHub license GitHub issues tests/main CodeQL NuGet Smdn.Devices.US2066

Smdn.Devices.US2066

Smdn.Devices.US2066 is a .NET library for controlling WiseChip US2066 OLED Driver with Controller.

This library enables you to control OLED character display modules which has US2066 controller chip.

The supported display modules are listed in tested and supported display modules.

Hardware supports

Smdn.Devices.US2066 is based on Iot.Device.Bindings. This library enables you to control OLED character displays connected to the board like Raspberry Pi which Iot.Device.Bindings supports.

Also combined with the library Smdn.Devices.MCP2221.GpioAdapter, you can control the OLED displays via USB connection even on generic PCs without using the specific board like Arduino. See MCP2221 example.

Library API features

string to byte[] conversion

Smdn.Devices.US2066 can output strings directly. Symbols and non-ASCII characters are automatically converted to the appropriate bytes, and are displayed on the OLED display.

As an example, the string "ÄÁΩ⏫→" will be displayed like Ä Á Ω ⏫ →.

For more information about character mapping, see this document.

(⚠The character mapping of CGROM-B and some other characters, especially alphabets with diacritical marks, are incomplete. Contributions are welcome! See issue #2)

Japanese and Russian conversion

Smdn.Devices.US2066 also supports Japanese full-width Hiragana/Katakana to half-width Katakana conversion(全角かな/全角カナ→半角カナ変換), Russian lower case to upper case conversion.

As an example, the following strings will be displayed like below.

string Characters on display
"こんにちは、せかい!" こんにちは、せかい!
"Привет, мир!" Привет, мир!

See example of helloworld-ja and helloworld-ru.

Custom characters

US2066 supports registering custom characters. Smdn.Devices.US2066 can map custom characters to any characters including emojis on registration.

using Smdn.Devices.US2066;

using var display = SO1602A.Create(SO1602A.DefaultI2CAddress);

display.CGRamUsage = CGRamUsage.UserDefined6Characters;

// define and register a custom character, and map to the emoji
display.CreateCustomCharacter(
  CGRamCharacter.Character0,
  "🙂", // emoji for this custom character
  new byte[8] {
    0b_00000, // 🟪🟪🟪🟪🟪
    0b_01010, // 🟪🟨🟪🟨🟪
    0b_01010, // 🟪🟨🟪🟨🟪
    0b_00000, // 🟪🟪🟪🟪🟪
    0b_10001, // 🟨🟪🟪🟪🟨
    0b_01110, // 🟪🟨🟨🟨🟪
    0b_00000, // 🟪🟪🟪🟪🟪
    0b_00000, // 🟪🟪🟪🟪🟪
  }
);

// display the registered custom character by specifying mapped emoji
display.Write("🙂");

See example of customcharacters for detail.

Supported US2066 features/commands

  • Interface
    • 4/b bit 6800/8080
    • SPI
    • I2C
  • Fundamental Command Set
    • Clear Display
    • Return Home
    • Entry Mode Set
    • Display ON/OFF Control
    • Extended Function Set
    • Cursor or Display Shift
    • Double Height / Display dot shift
    • Shift Enable
    • Scroll Enable
    • Function Set
    • Set CGRAM address
    • Set DDRAM address
    • Set Scroll Quantity
    • Read Busy Flag and Address/Part ID
      • not tested
    • Write data
    • Read data
      • not tested
  • Extended Command Set
    • Function Selection A
    • Function Selection B
    • OLED Characterization
  • OLED Command Set
    • Set Contrast Control
    • Set Display Clock Divide Ratio / Oscillator Frequency
    • Set Phase Length
    • Set SEG Pins Hardware Configuration
    • Set VCOMH Deselect Level
    • Function Selection C
    • Set Fade Out and Blinking

Tested and supported OLED display modules

Series Model No. Size Image
SUNLIKE DISPLAY SO Series (SOXXXXA) SO1602A 16×2 SO1602A
SO2002A 20×2 SO2002A

By deriving from the class US2066DisplayModuleBase, other display modules can also be worked.

Getting started and examples

Firstly, add package Smdn.Devices.US2066 to your project.

dotnet add package Smdn.Devices.US2066

Nextly, write your codes. The simpliest Hello, world! code is like below. This code uses the display module SO1602A.

using Smdn.Devices.US2066;

using var display = SO1602A.Create(SO1602A.DefaultI2CAddress);

display.Write("Hello, world!");

For detailed instructions, including wiring of the devices and parts, see examples/helloworld.

More examples can be found in examples directory.