Skip to content

Cannot infer type for Option<BLPin> if no backlight is used #4

@andber1

Description

@andber1

When I pass None for the backlight control pin, I get the error

    |
37  |     let mut lcd_sender = ParallelSender::new_4pin_write_only(
    |                          -------------- type must be known at this point
38  |         rs_pin, en_pin, db4_pin, db5_pin, db6_pin, db7_pin, None,
    |                                                             ^^^^ cannot infer type of the type parameter `T` declared on the enum `Option`
    |
    = note: cannot satisfy `_: StatefulOutputPin`

A workaround is to write something like this (at least I did not find another solution): None::<atmega_hal::port::Pin<atmega_hal::port::mode::Output>> instead of just None.

I experimented here with separating the backlight control. The advantage is that you cannot even call set_backlight if you haven't specified the pin (error: method cannot be called due to unsatisfied trait bounds). However, it has some other drawbacks (new constructor functions, init is missing the backlight initialization). Feel free to use and extend this if you like.

BTW: Great crate! I like the animations. You should consider adding this to the awesome embedded rust page.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions