pinetime-lvgl 2.0.1

LVGL Bindings for Mynewt on PineTime Smart Watch
/* automatically generated by rust-bindgen */

use
super::*;

#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct __BindgenBitfieldUnit<Storage, Align>
where
    Storage: AsRef<[u8]> + AsMut<[u8]>,
{
    storage: Storage,
    align: [Align; 0],
}
impl<Storage, Align> __BindgenBitfieldUnit<Storage, Align>
where
    Storage: AsRef<[u8]> + AsMut<[u8]>,
{
    #[inline]
    pub fn new(storage: Storage) -> Self {
        Self { storage, align: [] }
    }
    #[inline]
    pub fn get_bit(&self, index: usize) -> bool {
        debug_assert!(index / 8 < self.storage.as_ref().len());
        let byte_index = index / 8;
        let byte = self.storage.as_ref()[byte_index];
        let bit_index = if cfg!(target_endian = "big") {
            7 - (index % 8)
        } else {
            index % 8
        };
        let mask = 1 << bit_index;
        byte & mask == mask
    }
    #[inline]
    pub fn set_bit(&mut self, index: usize, val: bool) {
        debug_assert!(index / 8 < self.storage.as_ref().len());
        let byte_index = index / 8;
        let byte = &mut self.storage.as_mut()[byte_index];
        let bit_index = if cfg!(target_endian = "big") {
            7 - (index % 8)
        } else {
            index % 8
        };
        let mask = 1 << bit_index;
        if val {
            *byte |= mask;
        } else {
            *byte &= !mask;
        }
    }
    #[inline]
    pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 {
        debug_assert!(bit_width <= 64);
        debug_assert!(bit_offset / 8 < self.storage.as_ref().len());
        debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len());
        let mut val = 0;
        for i in 0..(bit_width as usize) {
            if self.get_bit(i + bit_offset) {
                let index = if cfg!(target_endian = "big") {
                    bit_width as usize - 1 - i
                } else {
                    i
                };
                val |= 1 << index;
            }
        }
        val
    }
    #[inline]
    pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) {
        debug_assert!(bit_width <= 64);
        debug_assert!(bit_offset / 8 < self.storage.as_ref().len());
        debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len());
        for i in 0..(bit_width as usize) {
            let mask = 1 << i;
            let val_bit_is_set = val & mask == mask;
            let index = if cfg!(target_endian = "big") {
                bit_width as usize - 1 - i
            } else {
                i
            };
            self.set_bit(index + bit_offset, val_bit_is_set);
        }
    }
}
#[repr(C)]
#[repr(align(2))]
#[derive(Default, Copy, Clone)]
pub struct lv_color16_t__bindgen_ty_1 {
    pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize], u8>,
}
impl lv_color16_t__bindgen_ty_1 {
    #[inline]
    pub fn green_h(&self) -> u16 {
        unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 3u8) as u16) }
    }
    #[inline]
    pub fn set_green_h(&mut self, val: u16) {
        unsafe {
            let val: u16 = ::core::mem::transmute(val);
            self._bitfield_1.set(0usize, 3u8, val as u64)
        }
    }
    #[inline]
    pub fn red(&self) -> u16 {
        unsafe { ::core::mem::transmute(self._bitfield_1.get(3usize, 5u8) as u16) }
    }
    #[inline]
    pub fn set_red(&mut self, val: u16) {
        unsafe {
            let val: u16 = ::core::mem::transmute(val);
            self._bitfield_1.set(3usize, 5u8, val as u64)
        }
    }
    #[inline]
    pub fn blue(&self) -> u16 {
        unsafe { ::core::mem::transmute(self._bitfield_1.get(8usize, 5u8) as u16) }
    }
    #[inline]
    pub fn set_blue(&mut self, val: u16) {
        unsafe {
            let val: u16 = ::core::mem::transmute(val);
            self._bitfield_1.set(8usize, 5u8, val as u64)
        }
    }
    #[inline]
    pub fn green_l(&self) -> u16 {
        unsafe { ::core::mem::transmute(self._bitfield_1.get(13usize, 3u8) as u16) }
    }
    #[inline]
    pub fn set_green_l(&mut self, val: u16) {
        unsafe {
            let val: u16 = ::core::mem::transmute(val);
            self._bitfield_1.set(13usize, 3u8, val as u64)
        }
    }
    #[inline]
    pub fn new_bitfield_1(
        green_h: u16,
        red: u16,
        blue: u16,
        green_l: u16,
    ) -> __BindgenBitfieldUnit<[u8; 2usize], u8> {
        let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize], u8> =
            Default::default();
        __bindgen_bitfield_unit.set(0usize, 3u8, {
            let green_h: u16 = unsafe { ::core::mem::transmute(green_h) };
            green_h as u64
        });
        __bindgen_bitfield_unit.set(3usize, 5u8, {
            let red: u16 = unsafe { ::core::mem::transmute(red) };
            red as u64
        });
        __bindgen_bitfield_unit.set(8usize, 5u8, {
            let blue: u16 = unsafe { ::core::mem::transmute(blue) };
            blue as u64
        });
        __bindgen_bitfield_unit.set(13usize, 3u8, {
            let green_l: u16 = unsafe { ::core::mem::transmute(green_l) };
            green_l as u64
        });
        __bindgen_bitfield_unit
    }
}
#[doc = " Display Driver structure to be registered by HAL"]
#[repr(C)]
pub struct _disp_drv_t {
    #[doc = "< Horizontal resolution."]
    pub hor_res: lv_coord_t,
    #[doc = "< Vertical resolution."]
    pub ver_res: lv_coord_t,
    #[doc = " Pointer to a buffer initialized with `lv_disp_buf_init()`."]
    #[doc = " LVGL will use this buffer(s) to draw the screens contents"]
    pub buffer: *mut lv_disp_buf_t,
    pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize], u16>,
    #[doc = " MANDATORY: Write the internal buffer (VDB) to the display. 'lv_disp_flush_ready()' has to be"]
    #[doc = " called when finished"]
    pub flush_cb: ::core::option::Option<
        unsafe extern "C" fn(
            disp_drv: *mut _disp_drv_t,
            area: *const lv_area_t,
            color_p: *mut lv_color_t,
        ),
    >,
    #[doc = " OPTIONAL: Extend the invalidated areas to match with the display drivers requirements"]
    #[doc = " E.g. round `y` to, 8, 16 ..) on a monochrome display"]
    pub rounder_cb: ::core::option::Option<
        unsafe extern "C" fn(disp_drv: *mut _disp_drv_t, area: *mut lv_area_t),
    >,
    #[doc = " OPTIONAL: Set a pixel in a buffer according to the special requirements of the display"]
    #[doc = " Can be used for color format not supported in LittelvGL. E.g. 2 bit -> 4 gray scales"]
    #[doc = " __Note:__ Much slower then drawing with supported color formats."]
    pub set_px_cb: ::core::option::Option<
        unsafe extern "C" fn(
            disp_drv: *mut _disp_drv_t,
            buf: *mut u8,
            buf_w: lv_coord_t,
            x: lv_coord_t,
            y: lv_coord_t,
            color: lv_color_t,
            opa: lv_opa_t,
        ),
    >,
    #[doc = " OPTIONAL: Called after every refresh cycle to tell the rendering and flushing time + the"]
    #[doc = " number of flushed pixels"]
    pub monitor_cb: ::core::option::Option<
        unsafe extern "C" fn(disp_drv: *mut _disp_drv_t, time: u32, px: u32),
    >,
    #[doc = " OPTIONAL: Called periodically while lvgl waits for operation to be completed."]
    #[doc = " For example flushing or GPU"]
    #[doc = " User can execute very simple tasks here or yield the task"]
    pub wait_cb: ::core::option::Option<unsafe extern "C" fn(disp_drv: *mut _disp_drv_t)>,
    #[doc = " OPTIONAL: Called when lvgl needs any CPU cache that affects rendering to be cleaned"]
    pub clean_dcache_cb: ::core::option::Option<unsafe extern "C" fn(disp_drv: *mut _disp_drv_t)>,
    #[doc = " OPTIONAL: called to wait while the gpu is working"]
    pub gpu_wait_cb: ::core::option::Option<unsafe extern "C" fn(disp_drv: *mut _disp_drv_t)>,
    #[doc = " On CHROMA_KEYED images this color will be transparent."]
    #[doc = " `LV_COLOR_TRANSP` by default. (lv_conf.h)"]
    pub color_chroma_key: lv_color_t,
    #[doc = "< Custom display driver user data"]
    pub user_data: lv_disp_drv_user_data_t,
}
impl Default for _disp_drv_t {
    fn default() -> Self {
        unsafe { ::core::mem::zeroed() }
    }
}
impl _disp_drv_t {
    #[inline]
    pub fn antialiasing(&self) -> u32 {
        unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u32) }
    }
    #[inline]
    pub fn set_antialiasing(&mut self, val: u32) {
        unsafe {
            let val: u32 = ::core::mem::transmute(val);
            self._bitfield_1.set(0usize, 1u8, val as u64)
        }
    }
    #[inline]
    pub fn rotated(&self) -> u32 {
        unsafe { ::core::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u32) }
    }
    #[inline]
    pub fn set_rotated(&mut self, val: u32) {
        unsafe {
            let val: u32 = ::core::mem::transmute(val);
            self._bitfield_1.set(1usize, 1u8, val as u64)
        }
    }
    #[inline]
    pub fn dpi(&self) -> u32 {
        unsafe { ::core::mem::transmute(self._bitfield_1.get(2usize, 10u8) as u32) }
    }
    #[inline]
    pub fn set_dpi(&mut self, val: u32) {
        unsafe {
            let val: u32 = ::core::mem::transmute(val);
            self._bitfield_1.set(2usize, 10u8, val as u64)
        }
    }
    #[inline]
    pub fn new_bitfield_1(
        antialiasing: u32,
        rotated: u32,
        dpi: u32,
    ) -> __BindgenBitfieldUnit<[u8; 2usize], u16> {
        let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize], u16> =
            Default::default();
        __bindgen_bitfield_unit.set(0usize, 1u8, {
            let antialiasing: u32 = unsafe { ::core::mem::transmute(antialiasing) };
            antialiasing as u64
        });
        __bindgen_bitfield_unit.set(1usize, 1u8, {
            let rotated: u32 = unsafe { ::core::mem::transmute(rotated) };
            rotated as u64
        });
        __bindgen_bitfield_unit.set(2usize, 10u8, {
            let dpi: u32 = unsafe { ::core::mem::transmute(dpi) };
            dpi as u64
        });
        __bindgen_bitfield_unit
    }
}
#[doc = "      TYPEDEFS"]
#[repr(C)]
pub struct _disp_t {
    pub driver: lv_disp_drv_t,
    pub refr_task: *mut lv_task_t,
    #[doc = " Screens of the display"]
    pub scr_ll: lv_ll_t,
    #[doc = "< Currently active screen on this display"]
    pub act_scr: *mut _lv_obj_t,
    #[doc = "< Previous screen. Used during screen animations"]
    pub prev_scr: *mut _lv_obj_t,
    #[doc = "< @see lv_disp_get_layer_top"]
    pub top_layer: *mut _lv_obj_t,
    #[doc = "< @see lv_disp_get_layer_sys"]
    pub sys_layer: *mut _lv_obj_t,
    pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize], u8>,
    #[doc = "< Default display color when screens are transparent"]
    pub bg_color: lv_color_t,
    #[doc = "< An image source to display as wallpaper"]
    pub bg_img: *const ::cty::c_void,
    #[doc = "<Opacity of the background color or wallpaper"]
    pub bg_opa: lv_opa_t,
    #[doc = " Invalidated (marked to redraw) areas"]
    pub inv_areas: [lv_area_t; 32usize],
    pub inv_area_joined: [u8; 32usize],
    pub _bitfield_2: __BindgenBitfieldUnit<[u8; 2usize], u16>,
    #[doc = "< Last time there was activity on this display"]
    pub last_activity_time: u32,
}
impl Default for _disp_t {
    fn default() -> Self {
        unsafe { ::core::mem::zeroed() }
    }
}
impl _disp_t {
    #[inline]
    pub fn del_prev(&self) -> u8 {
        unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) }
    }
    #[inline]
    pub fn set_del_prev(&mut self, val: u8) {
        unsafe {
            let val: u8 = ::core::mem::transmute(val);
            self._bitfield_1.set(0usize, 1u8, val as u64)
        }
    }
    #[inline]
    pub fn new_bitfield_1(del_prev: u8) -> __BindgenBitfieldUnit<[u8; 1usize], u8> {
        let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize], u8> =
            Default::default();
        __bindgen_bitfield_unit.set(0usize, 1u8, {
            let del_prev: u8 = unsafe { ::core::mem::transmute(del_prev) };
            del_prev as u64
        });
        __bindgen_bitfield_unit
    }
    #[inline]
    pub fn inv_p(&self) -> u32 {
        unsafe { ::core::mem::transmute(self._bitfield_2.get(0usize, 10u8) as u32) }
    }
    #[inline]
    pub fn set_inv_p(&mut self, val: u32) {
        unsafe {
            let val: u32 = ::core::mem::transmute(val);
            self._bitfield_2.set(0usize, 10u8, val as u64)
        }
    }
    #[inline]
    pub fn new_bitfield_2(inv_p: u32) -> __BindgenBitfieldUnit<[u8; 2usize], u16> {
        let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize], u16> =
            Default::default();
        __bindgen_bitfield_unit.set(0usize, 10u8, {
            let inv_p: u32 = unsafe { ::core::mem::transmute(inv_p) };
            inv_p as u64
        });
        __bindgen_bitfield_unit
    }
}
#[lvgl_macros::safe_wrap(attr)] extern "C" {
    #[doc = " Redraw the invalidated areas now."]
    #[doc = " Normally the redrawing is periodically executed in `lv_task_handler` but a long blocking process"]
    #[doc = " can prevent the call of `lv_task_handler`. In this case if the the GUI is updated in the process"]
    #[doc = " (e.g. progress bar) this function can be called when the screen should be updated."]
    #[doc = " - __`disp`__: pointer to display to refresh. NULL to refresh all displays."]
    pub fn lv_refr_now(disp: *mut lv_disp_t);
}