0001-lv-build-with-LVGL-9.2.patch 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. From 11f311332ab8307607884ce176d2b8ac05a623a9 Mon Sep 17 00:00:00 2001
  2. From: Stefano Babic <stefano.babic@swupdate.org>
  3. Date: Fri, 23 Oct 2026 13:59:43 +0200
  4. Subject: [PATCH] lv: build with LVGL 9.2
  5. LVGL 9.2 declares lv_state_t as uint16_t, while bindgen emits the
  6. LV_STATE_* values as u32. Accept any integer convertible to u32 in the
  7. state helpers and cast it to lv_state_t.
  8. lv_slider_set_value() takes an lv_anim_enable_t up to 9.2 and a bool
  9. in later versions: pass the default value, that is "animation off"
  10. for both.
  11. Upstream-Status: Pending
  12. Signed-off-by: Stefano Babic <stefano.babic@swupdate.org>
  13. ---
  14. src/lv.rs | 17 ++++++++++-------
  15. 1 file changed, 10 insertions(+), 7 deletions(-)
  16. diff --git a/src/lv.rs b/src/lv.rs
  17. index 55d7fe3..6eb41e0 100644
  18. --- a/src/lv.rs
  19. +++ b/src/lv.rs
  20. @@ -215,16 +215,17 @@ impl Obj {
  21. self.remove_flag(sys::LV_OBJ_FLAG_SCROLLABLE);
  22. }
  23. - pub fn add_state(self, state: sys::lv_state_t) {
  24. - unsafe { sys::lv_obj_add_state(self.raw(), state) }
  25. + /* LVGL 9.2: lv_state_t is u16 but bindgen emits the LV_STATE_* values as u32 */
  26. + pub fn add_state(self, state: impl Into<u32>) {
  27. + unsafe { sys::lv_obj_add_state(self.raw(), state.into() as sys::lv_state_t) }
  28. }
  29. - pub fn remove_state(self, state: sys::lv_state_t) {
  30. - unsafe { sys::lv_obj_remove_state(self.raw(), state) }
  31. + pub fn remove_state(self, state: impl Into<u32>) {
  32. + unsafe { sys::lv_obj_remove_state(self.raw(), state.into() as sys::lv_state_t) }
  33. }
  34. - pub fn has_state(self, state: sys::lv_state_t) -> bool {
  35. - unsafe { sys::lv_obj_has_state(self.raw(), state) }
  36. + pub fn has_state(self, state: impl Into<u32>) -> bool {
  37. + unsafe { sys::lv_obj_has_state(self.raw(), state.into() as sys::lv_state_t) }
  38. }
  39. /* styles */
  40. @@ -292,8 +293,10 @@ impl Obj {
  41. /* slider */
  42. + /* The animation flag is lv_anim_enable_t up to LVGL 9.2 and bool later:
  43. + * the default value is "off" for both */
  44. pub fn slider_set_value(self, value: i32) {
  45. - unsafe { sys::lv_slider_set_value(self.raw(), value, false) }
  46. + unsafe { sys::lv_slider_set_value(self.raw(), value, Default::default()) }
  47. }
  48. /* text area */
  49. --
  50. 2.53.0