import type { DisplayController, DisplayUpdateCommand } from "../index.js"; import { type Font } from "./fonts/font5x7.js"; import { I2cDevice, type I2cDeviceOptions } from "./I2cDevice.js"; export interface SSD1306Options extends I2cDeviceOptions { width?: number; height?: number; controller?: DisplayController; columnOffset?: number; pageOffset?: number; } /** * SSD1306 OLED display driver * * Manages a local framebuffer and provides drawing methods. * Call toDisplayCommand() to generate a command that sends the * entire display contents in a single network call. * * @example * const display = new SSD1306({ address: "0x3C", width: 128, height: 64 }); * display.clear().drawText(0, 0, "Hello!").drawLine(0, 10, 127, 10); * await device.sendCommand(display.toDisplayCommand({ init: true })); */ export declare class SSD1306 extends I2cDevice { private buffer; private _width; private _height; private controller; private columnOffset; private pageOffset; constructor(options: SSD1306Options); /** * Preset for the 72×40 OLED that ships built-in on common ESP32-C3 * "FN4 / 0.42-inch OLED" boards. The visible glass sits at column offset * 28 in the controller's 128-wide RAM — without this offset, pixels render * into the non-visible region. * * Pair with `i2c_configure({ bus: 0, sda_pin: 5, scl_pin: 6 })` for the * default DevKit pinout (verify against your board's silkscreen — some * variants swap SDA/SCL). * * @example * const display = SSD1306.esp32c3OledVariant(); * display.clear().drawText(0, 0, "Hello!"); * await device.sendCommand(display.toDisplayCommand({ init: true })); */ static esp32c3OledVariant(opts?: { bus?: number; address?: string; }): SSD1306; get width(): number; get height(): number; /** * Clear the display buffer (all pixels off) */ clear(): this; /** * Fill the display buffer (all pixels on) */ fill(): this; /** * Set a single pixel * @param x X coordinate (0 = left) * @param y Y coordinate (0 = top) * @param on true = pixel on, false = pixel off */ setPixel(x: number, y: number, on?: boolean): this; /** * Get a pixel value */ getPixel(x: number, y: number): boolean; /** * Draw a line using Bresenham's algorithm */ drawLine(x0: number, y0: number, x1: number, y1: number, on?: boolean): this; /** * Draw a horizontal line (optimized) */ drawHLine(x: number, y: number, length: number, on?: boolean): this; /** * Draw a vertical line (optimized) */ drawVLine(x: number, y: number, length: number, on?: boolean): this; /** * Draw a rectangle * @param fill If true, fill the rectangle; otherwise draw outline only */ drawRect(x: number, y: number, w: number, h: number, fill?: boolean, on?: boolean): this; /** * Draw a circle using midpoint algorithm */ drawCircle(cx: number, cy: number, r: number, fill?: boolean, on?: boolean): this; /** * Draw a single character * @returns The x position after the character (for chaining text) */ drawChar(x: number, y: number, char: string, font?: Font, on?: boolean): number; /** * Draw text string * @param x Starting X position * @param y Starting Y position * @param text The text to draw * @param font Font to use (default: font5x7) */ drawText(x: number, y: number, text: string, font?: Font, on?: boolean): this; /** * Draw a bitmap * @param bitmap Raw bitmap data (1 bit per pixel, row-major, MSB first) * @param bitmapWidth Width of the bitmap * @param bitmapHeight Height of the bitmap */ drawBitmap(x: number, y: number, bitmap: Uint8Array, bitmapWidth: number, bitmapHeight: number, on?: boolean): this; /** * Invert all pixels in the buffer */ invert(): this; /** * Get the raw framebuffer */ getBuffer(): Uint8Array; /** * Set the raw framebuffer */ setBuffer(buffer: Uint8Array): this; /** * Generate a display update command with sparse encoding * Only sends non-zero segments to reduce payload size * @param options.init If true, firmware should run init sequence before displaying * @param options.compress If true (default), use sparse encoding; if false, send full buffer */ toDisplayCommand(options?: { init?: boolean; compress?: boolean; }): Omit; /** * Sparse encode a buffer, extracting only non-zero segments * Groups consecutive non-zero bytes into segments with offset and base64 data */ private sparseEncodeBuffer; /** * Encode Uint8Array to base64 string * Uses a pure JavaScript implementation for portability */ private encodeBase64; } //# sourceMappingURL=SSD1306.d.ts.map