const micro = @import("microzig"); const SCREEN_HEIGHT: u16 = 64; const SCREEN_WIDTH: u16 = 128; const SCREEN_SIZE: u16 = SCREEN_HEIGHT * SCREEN_WIDTH / @bitSizeOf(u8); const I2C_ADDR = 0x3C; const Command = enum(u8) { SET_LOW_COLUMN = 0x00, SET_HIGH_COLUMN = 0x10, MEMORY_MODE = 0x20, COLUMN_ADDR = 0x21, PAGE_ADDR = 0x22, SET_START_LINE = 0x40, DEFAULT_ADDRESS = 0x78, SET_CONTRAST = 0x81, CHARGE_PUMP = 0x8D, SEG_REMAP = 0xA0, DISPLAY_RESUME = 0xA4, DISPLAY_ALL_ON = 0xA5, NORMAL_DISPLAY = 0xA6, INVERT_DISPLAY = 0xA7, SET_MUX = 0xA8, DISPLAY_OFF = 0xAE, DISPLAY_ON = 0xAF, SET_PAGE = 0xB0, COM_SCAN_DIR = 0xC0, SET_DISPLAY_OFFSET = 0xD3, SET_DISPLAY_CLOCK_DIV = 0xD5, SET_PRECHARGE = 0xD9, SET_COM_PINS = 0xDA, SET_VCOM_DESELECT = 0xDB, SWITCH_CAP_VCC = 0x02, NOP = 0xE3, }; pub const Config = struct { contrast: u8 = 127, display_start_line: u6 = 0, seg_remap: bool = false, mux_ratio: u6 = 63, // can't go lower than 15 com_scan_dir: bool = 0, display_offset: u6 = 0, com_pin_config: bool = 1, com_left_right_remap: bool = false, display_clock_div_ratio: u4 = 0x0, oscillator_freq: u4 = 0xF, precharge_period_1: u4 = 0x2, precharge_period_2: u4 = 0x2, vcomh_deselect_level: u2 = 0b10, // can't be 0b01 }; pub const SSD1306 = struct { i2c: *micro.hal.i2c.I2C, pub fn init(self: *SSD1306, i2c_index: usize, pins: Pins, config: Config) SSD1306 { } } pub const I2CConfig = struct { index: ?u1 = 0, scl: ?type = null, sda: ?type = null, };