Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom mode support #208

Open
MateuszJanda opened this issue Feb 27, 2024 · 0 comments
Open

Custom mode support #208

MateuszJanda opened this issue Feb 27, 2024 · 0 comments

Comments

@MateuszJanda
Copy link

  • 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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant