OLED Display (SSD130x) support for libDaisy Nim wrapper
Wraps libDaisy's SSD130xDriver template by using its pre-instantiated typedefs. This matches libDaisy's own approach and works reliably with Nim's C++ interop.
LibDaisy defines typedefs like: using SSD130xI2c128x64Driver = SSD130xDriver<128, 64, SSD130xI2CTransport> We wrap these typedefs and provide a clean Nim API that selects the right one at compile time.
Example - I2C display:
var display = initOledI2c(128, 64) display.fill(false) display.drawPixel(64, 32, true) display.update()
Example - SPI display (faster):
var display = initOledSpi(128, 64) while true: display.fill(false) display.drawCircle(64, 32, 10, true) display.update() hw.delay(50)
Types
OledDisplay = OledDisplay128x64I2c | OledDisplay128x32I2c | OledDisplay64x48I2c | OledDisplay64x32I2c | OledDisplay128x64Spi | OledDisplay128x32Spi | OledDisplay64x48Spi | OledDisplay64x32Spi
- Source Edit
OledDisplay64x32I2c {.importcpp: "daisy::SSD130xI2c64x32Driver".} = object
- Source Edit
OledDisplay64x32Spi {.importcpp: "daisy::SSD130x4WireSpi64x32Driver".} = object
- Source Edit
OledDisplay64x48I2c {.importcpp: "daisy::SSD130xI2c64x48Driver".} = object
- Source Edit
OledDisplay64x48Spi {.importcpp: "daisy::SSD130x4WireSpi64x48Driver".} = object
- Source Edit
OledDisplay128x32I2c {.importcpp: "daisy::SSD130xI2c128x32Driver".} = object
- Source Edit
OledDisplay128x32Spi {.importcpp: "daisy::SSD130x4WireSpi128x32Driver".} = object
- Source Edit
OledDisplay128x64I2c {.importcpp: "daisy::SSD130xI2c128x64Driver".} = object
- Source Edit
OledDisplay128x64Spi {.importcpp: "daisy::SSD130x4WireSpi128x64Driver".} = object
- Source Edit
OledDisplayI2cConfig {.importcpp: "daisy::SSD130xI2c128x64Driver::Config", bycopy.} = object transport_config* {.importc: "transport_config".}: SSD130xI2CTransportConfig
- Source Edit
OledDisplaySpiConfig {.importcpp: "daisy::SSD130x4WireSpi128x64Driver::Config", bycopy.} = object transport_config* {.importc: "transport_config".}: SSD130x4WireSpiTransportConfig
- Source Edit
SSD130x4WireSpiTransportConfig {.importcpp: "daisy::SSD130x4WireSpiTransport::Config", bycopy.} = object spi_config* {.importc: "spi_config".}: SpiConfig pin_config* {.importc: "pin_config".}: SSD130xSpiPinConfig useDma* {.importc: "useDma".}: bool
- Source Edit
SSD130xI2CTransportConfig {.importcpp: "daisy::SSD130xI2CTransport::Config", bycopy.} = object i2c_config* {.importc: "i2c_config".}: I2CConfig i2c_address* {.importc: "i2c_address".}: uint8
- Source Edit
SSD130xSpiPinConfig {.importcpp: "daisy::SSD130x4WireSpiTransport::Config::pin_config", bycopy.} = object dc* {.importc: "dc".}: Pin reset* {.importc: "reset".}: Pin
- Source Edit
Consts
OLED_I2C_ADDRESS_ALT = 0x0000003D
- Source Edit
OLED_I2C_ADDRESS_DEFAULT = 0x0000003C
- Source Edit
Procs
proc Defaults(config: var SSD130x4WireSpiTransportConfig) {. importcpp: "#.Defaults()", header: "daisy_seed.h", ...raises: [], tags: [], forbids: [].}
- Source Edit
proc Defaults(config: var SSD130xI2CTransportConfig) {. importcpp: "#.Defaults()", header: "daisy_seed.h", ...raises: [], tags: [], forbids: [].}
- Source Edit
proc drawCircle(display: var OledDisplay; x0, y0, radius: int; on: bool = true)
- Source Edit
proc drawLine(display: var OledDisplay; x0, y0, x1, y1: int; on: bool = true)
- Source Edit
proc drawPixel(display: var OledDisplay; x, y: int; on: bool = true)
- Source Edit
proc drawRect(display: var OledDisplay; x, y, w, h: int; on: bool = true)
- Source Edit
proc fill(display: var OledDisplay; on: bool = true)
- Source Edit
proc fillRect(display: var OledDisplay; x, y, w, h: int; on: bool = true)
- Source Edit
proc height(display: OledDisplay): int {.inline.}
- Source Edit
proc update(display: var OledDisplay)
- Source Edit
proc width(display: OledDisplay): int {.inline.}
- Source Edit
Templates
template initOledI2c(width, height: static[int]; sclPin: Pin = newPin(PORTB, 8); sdaPin: Pin = newPin(PORTB, 9); address: uint8 = 0x0000003C): untyped
- Initialize OLED via I2C - selects correct template instantiation at compile time Source Edit
template initOledSpi(width, height: static[int]; dcPin: Pin = newPin(PORTB, 4); resetPin: Pin = newPin(PORTB, 15); sclkPin: Pin = newPin(PORTG, 11); mosiPin: Pin = newPin(PORTB, 5); nssPin: Pin = newPin(PORTG, 10)): untyped
- Initialize OLED via SPI - selects correct template instantiation at compile time Source Edit