Skip to content

Custom mode support #208

@MateuszJanda

Description

@MateuszJanda
  • Version of ssd1306 in use (if applicable): 0.8.4
  • MCU/other hardware in use: Arduino UNO R3/OLED Waveshare 0.96 cala (A)
  • Display resolution and interface: SPI, 128x64

Description of feature request

I tried create (in my project) custom mode (NonBufferedGraphicsMode) due to limitation of SRAM in my Arduino UNO R3. However Ssd1306 offer only into_buffered_graphics_mode and into_terminal_mode. I think public into_mode or public members of Ssd1306 can be helpful (I don't know, I don't have solution yet). Or maybe this is possible, but I don't know some rusty trick? If not (possible), what do you think about such improvement? GO, NOGO - and fork is my only option? I don't think that pushing more modes into driver code is good idea, but interface for customization looks handy.

Loose skeleton, how this could look like at the end.

#[derive(Clone, Debug)]
pub struct NonBufferedGraphicsMode
{
    // ...
}

impl NonBufferedGraphicsMode
{
    // ...
}


// Trick to extend Ssd1306 (which is in his own crate)
pub struct NonBufferedGraphicsModeWrapper<DI, SIZE>(Ssd1306<DI, SIZE, NonBufferedGraphicsMode>);

impl<DI, SIZE> NonBufferedGraphicsModeWrapper<DI, SIZE>
where
    DI: WriteOnlyDataCommand,
    SIZE: DisplaySize,
{
    // ...
}

impl<DI, SIZE> DrawTarget for NonBufferedGraphicsModeWrapper<DI, SIZE>
where
    DI: WriteOnlyDataCommand,
    SIZE: DisplaySize,
{
    fn draw_iter<I>(&mut self, pixels: I) -> Result<(), Self::Error>
    where
        I: IntoIterator<Item = Pixel<Self::Color>>,
    {
        // ...
    }
}

// Integration 
let mut custom_mode = NonBufferedGraphicsModeWrapper::new();
let mut display = Ssd1306::new(interface, DisplaySize128x64, DisplayRotation::Rotate0)
    .into_mode(custom_mode);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions