lvgl / lv_binding_rust

LVGL bindings for Rust. A powerful and easy-to-use embedded GUI with many widgets, advanced visual effects (opacity, antialiasing, animations) and low memory requirements (16K RAM, 64K Flash).
MIT License
687 stars 71 forks source link

Request: implement lv_pct and friends #129

Closed cydergoth closed 1 year ago

cydergoth commented 1 year ago

LV_PCT, lv_pct and other special functions are used to specify values other than e.g. absolute pixels for width and height. These don't appear to be implemented yet

Possible implementation :

  88 const _LV_COORD_TYPE_SHIFT: i32 = 13i32;
  89 const _LV_COORD_TYPE_SPEC: i32 = 1 << _LV_COORD_TYPE_SHIFT;
  90
  91 fn lv_coord_set_spec(x: i32) -> u32 {
  92     ((x) | _LV_COORD_TYPE_SPEC) as u32
  93 }
  94
  95 fn lv_pct(pct: i32) -> u32 {
  96     if pct < 0 {
  97         lv_coord_set_spec(1000 - (pct))
  98     } else {
  99         lv_coord_set_spec(pct)
 100     }
 101 }
nia-e commented 1 year ago

Thanks! I'll open a PR in a minute and add this in.