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

Attribute macros for lvgl-rs #68

Open
nia-e opened this issue Mar 4, 2023 · 1 comment
Open

Attribute macros for lvgl-rs #68

nia-e opened this issue Mar 4, 2023 · 1 comment
Labels
enhancement New feature or request question Further information is requested

Comments

@nia-e
Copy link
Collaborator

nia-e commented Mar 4, 2023

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?

@nia-e nia-e added enhancement New feature or request question Further information is requested labels Mar 4, 2023
@rafaelcaricio
Copy link
Collaborator

Looks very useful. I like the idea!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants