Skip to content

Attribute macros for lvgl-rs #68

Open
@nia-e

Description

@nia-e

In light of #24 it might be a good idea to allow for common bolierplate-y things like LVGL initialization, task/timer handler updates, etc. to be abstracted away. My idea is doing something like:

/* use ... */

static shared_native_display: RefCell<SimulatorDisplay<ColorSpace>> =
    RefCell::new(SimulatorDisplay::new(Size::new(240 as u32, 240 as u32)));

fn disp_handler<N>(refresh: &DisplayRefresh<N>) {
    shared_native_display.borrow_mut().draw_iter(refresh.as_pixels()).unwrap();
}

#[lvgl_main]
fn main() {
    let output_settings = OutputSettingsBuilder::new().scale(2).build();
    let mut window = Window::new("Macro Example", &output_settings);

    #[lvgl_display(hor = 240, ver = 240, handler = disp_handler)]
    let display;

    let screen = display.get_scr_act()?

    /* Styling, widgets. etc */

    #[lvgl_event_loop(frame_time = 16)]
    'running: loop {
        /* GUI logic */
    }
}

More could certainly be done (interesting ideas might include attribute macros for widgets as well, to be able to specify e.g. event handlers) but this might be a start.

Is this something worth working on?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions