pinetime-lvgl 2.0.1

LVGL Bindings for Mynewt on PineTime Smart Watch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
/* 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);
        }
    }
}
pub const LV_INDEV_DEF_READ_PERIOD: u32 = 30;
pub const LV_INDEV_DEF_DRAG_LIMIT: u32 = 10;
pub const LV_INDEV_DEF_DRAG_THROW: u32 = 20;
pub const LV_INDEV_DEF_LONG_PRESS_TIME: u32 = 400;
pub const LV_INDEV_DEF_LONG_PRESS_REP_TIME: u32 = 100;
pub const LV_INDEV_DEF_GESTURE_LIMIT: u32 = 50;
pub const LV_INDEV_DEF_GESTURE_MIN_VELOCITY: u32 = 3;
pub type lv_coord_t = i16;
pub type lv_indev_drv_user_data_t = *mut ::cty::c_void;
#[doc = " Represents a point on the screen."]
#[repr(C)]
#[derive(Default, Copy, Clone)]
pub struct lv_point_t {
    pub x: lv_coord_t,
    pub y: lv_coord_t,
}
#[doc = " Tasks execute this type type of functions."]
pub type lv_task_cb_t = ::core::option::Option<unsafe extern "C" fn(arg1: *mut _lv_task_t)>;
#[doc = "      TYPEDEFS"]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct _lv_task_t {
    #[doc = "< How often the task should run"]
    pub period: u32,
    #[doc = "< Last time the task ran"]
    pub last_run: u32,
    #[doc = "< Task function"]
    pub task_cb: lv_task_cb_t,
    #[doc = "< Custom user data"]
    pub user_data: *mut ::cty::c_void,
    #[doc = "< 1: Task times;  -1 : infinity;  0 : stop ;  n>0: residual times"]
    pub repeat_count: i32,
    pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize], u8>,
    pub __bindgen_padding_0: [u8; 3usize],
}
impl Default for _lv_task_t {
    fn default() -> Self {
        unsafe { ::core::mem::zeroed() }
    }
}
impl _lv_task_t {
    #[inline]
    pub fn prio(&self) -> u8 {
        unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 3u8) as u8) }
    }
    #[inline]
    pub fn set_prio(&mut self, val: u8) {
        unsafe {
            let val: u8 = ::core::mem::transmute(val);
            self._bitfield_1.set(0usize, 3u8, val as u64)
        }
    }
    #[inline]
    pub fn new_bitfield_1(prio: u8) -> __BindgenBitfieldUnit<[u8; 1usize], u8> {
        let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize], u8> =
            Default::default();
        __bindgen_bitfield_unit.set(0usize, 3u8, {
            let prio: u8 = unsafe { ::core::mem::transmute(prio) };
            prio as u64
        });
        __bindgen_bitfield_unit
    }
}
pub type lv_task_t = _lv_task_t;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct _disp_t {
    _unused: [u8; 0],
}
#[doc = "< Uninitialized state"]
pub const LV_INDEV_TYPE_NONE: _bindgen_ty_4 = 0;
#[doc = "< Touch pad, mouse, external button"]
pub const LV_INDEV_TYPE_POINTER: _bindgen_ty_4 = 1;
#[doc = "< Keypad or keyboard"]
pub const LV_INDEV_TYPE_KEYPAD: _bindgen_ty_4 = 2;
#[doc = "< External (hardware button) which is assigned to a specific point of the"]
#[doc = "screen"]
pub const LV_INDEV_TYPE_BUTTON: _bindgen_ty_4 = 3;
#[doc = "< Encoder with only Left, Right turn and a Button"]
pub const LV_INDEV_TYPE_ENCODER: _bindgen_ty_4 = 4;
#[doc = " Possible input device types"]
pub type _bindgen_ty_4 = u32;
pub type lv_indev_type_t = u8;
pub const LV_INDEV_STATE_REL: _bindgen_ty_5 = 0;
pub const LV_INDEV_STATE_PR: _bindgen_ty_5 = 1;
#[doc = " States for input devices"]
pub type _bindgen_ty_5 = u32;
pub type lv_indev_state_t = u8;
pub type lv_drag_dir_t = u8;
pub type lv_gesture_dir_t = u8;
#[doc = " Data structure passed to an input driver to fill"]
#[repr(C)]
#[derive(Default, Copy, Clone)]
pub struct lv_indev_data_t {
    #[doc = "< For LV_INDEV_TYPE_POINTER the currently pressed point"]
    pub point: lv_point_t,
    #[doc = "< For LV_INDEV_TYPE_KEYPAD the currently pressed key"]
    pub key: u32,
    #[doc = "< For LV_INDEV_TYPE_BUTTON the currently pressed button"]
    pub btn_id: u32,
    #[doc = "< For LV_INDEV_TYPE_ENCODER number of steps since the previous read"]
    pub enc_diff: i16,
    #[doc = "< LV_INDEV_STATE_REL or LV_INDEV_STATE_PR"]
    pub state: lv_indev_state_t,
}
#[doc = " Initialized by the user and registered by 'lv_indev_add()'"]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct _lv_indev_drv_t {
    pub type_: lv_indev_type_t,
    pub read_cb: ::core::option::Option<
        unsafe extern "C" fn(indev_drv: *mut _lv_indev_drv_t, data: *mut lv_indev_data_t) -> bool,
    >,
    #[doc = " Called when an action happened on the input device."]
    #[doc = " The second parameter is the event from `lv_event_t`"]
    pub feedback_cb:
        ::core::option::Option<unsafe extern "C" fn(arg1: *mut _lv_indev_drv_t, arg2: u8)>,
    pub user_data: lv_indev_drv_user_data_t,
    pub disp: *mut _disp_t,
    pub read_task: *mut lv_task_t,
    pub drag_limit: u8,
    pub drag_throw: u8,
    pub gesture_min_velocity: u8,
    pub gesture_limit: u8,
    pub long_press_time: u16,
    pub long_press_rep_time: u16,
}
impl Default for _lv_indev_drv_t {
    fn default() -> Self {
        unsafe { ::core::mem::zeroed() }
    }
}
pub type lv_indev_drv_t = _lv_indev_drv_t;
#[doc = " Run time data of input devices"]
#[doc = " Internally used by the library, you should not need to touch it."]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct _lv_indev_proc_t {
    #[doc = "< Current state of the input device."]
    pub state: lv_indev_state_t,
    pub types: _lv_indev_proc_t__bindgen_ty_1,
    #[doc = "< Pressed time stamp"]
    pub pr_timestamp: u32,
    #[doc = "< Long press repeat time stamp"]
    pub longpr_rep_timestamp: u32,
    pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize], u8>,
    pub __bindgen_padding_0: [u8; 7usize],
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union _lv_indev_proc_t__bindgen_ty_1 {
    pub pointer: _lv_indev_proc_t__bindgen_ty_1__bindgen_ty_1,
    pub keypad: _lv_indev_proc_t__bindgen_ty_1__bindgen_ty_2,
    _bindgen_union_align: [u64; 7usize],
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct _lv_indev_proc_t__bindgen_ty_1__bindgen_ty_1 {
    #[doc = "< Current point of input device."]
    pub act_point: lv_point_t,
    #[doc = "< Last point of input device."]
    pub last_point: lv_point_t,
    #[doc = "< Difference between `act_point` and `last_point`."]
    pub vect: lv_point_t,
    pub drag_sum: lv_point_t,
    pub drag_throw_vect: lv_point_t,
    pub act_obj: *mut _lv_obj_t,
    pub last_obj: *mut _lv_obj_t,
    pub last_pressed: *mut _lv_obj_t,
    pub gesture_dir: lv_gesture_dir_t,
    pub gesture_sum: lv_point_t,
    pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize], u8>,
    pub __bindgen_padding_0: u8,
}
impl Default for _lv_indev_proc_t__bindgen_ty_1__bindgen_ty_1 {
    fn default() -> Self {
        unsafe { ::core::mem::zeroed() }
    }
}
impl _lv_indev_proc_t__bindgen_ty_1__bindgen_ty_1 {
    #[inline]
    pub fn drag_limit_out(&self) -> u8 {
        unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) }
    }
    #[inline]
    pub fn set_drag_limit_out(&mut self, val: u8) {
        unsafe {
            let val: u8 = ::core::mem::transmute(val);
            self._bitfield_1.set(0usize, 1u8, val as u64)
        }
    }
    #[inline]
    pub fn drag_in_prog(&self) -> u8 {
        unsafe { ::core::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) }
    }
    #[inline]
    pub fn set_drag_in_prog(&mut self, val: u8) {
        unsafe {
            let val: u8 = ::core::mem::transmute(val);
            self._bitfield_1.set(1usize, 1u8, val as u64)
        }
    }
    #[inline]
    pub fn drag_dir(&self) -> lv_drag_dir_t {
        unsafe { ::core::mem::transmute(self._bitfield_1.get(2usize, 3u8) as u8) }
    }
    #[inline]
    pub fn set_drag_dir(&mut self, val: lv_drag_dir_t) {
        unsafe {
            let val: u8 = ::core::mem::transmute(val);
            self._bitfield_1.set(2usize, 3u8, val as u64)
        }
    }
    #[inline]
    pub fn gesture_sent(&self) -> u8 {
        unsafe { ::core::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u8) }
    }
    #[inline]
    pub fn set_gesture_sent(&mut self, val: u8) {
        unsafe {
            let val: u8 = ::core::mem::transmute(val);
            self._bitfield_1.set(5usize, 1u8, val as u64)
        }
    }
    #[inline]
    pub fn new_bitfield_1(
        drag_limit_out: u8,
        drag_in_prog: u8,
        drag_dir: lv_drag_dir_t,
        gesture_sent: u8,
    ) -> __BindgenBitfieldUnit<[u8; 1usize], u8> {
        let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize], u8> =
            Default::default();
        __bindgen_bitfield_unit.set(0usize, 1u8, {
            let drag_limit_out: u8 = unsafe { ::core::mem::transmute(drag_limit_out) };
            drag_limit_out as u64
        });
        __bindgen_bitfield_unit.set(1usize, 1u8, {
            let drag_in_prog: u8 = unsafe { ::core::mem::transmute(drag_in_prog) };
            drag_in_prog as u64
        });
        __bindgen_bitfield_unit.set(2usize, 3u8, {
            let drag_dir: u8 = unsafe { ::core::mem::transmute(drag_dir) };
            drag_dir as u64
        });
        __bindgen_bitfield_unit.set(5usize, 1u8, {
            let gesture_sent: u8 = unsafe { ::core::mem::transmute(gesture_sent) };
            gesture_sent as u64
        });
        __bindgen_bitfield_unit
    }
}
#[repr(C)]
#[derive(Default, Copy, Clone)]
pub struct _lv_indev_proc_t__bindgen_ty_1__bindgen_ty_2 {
    pub last_state: lv_indev_state_t,
    pub last_key: u32,
}
impl Default for _lv_indev_proc_t__bindgen_ty_1 {
    fn default() -> Self {
        unsafe { ::core::mem::zeroed() }
    }
}
impl Default for _lv_indev_proc_t {
    fn default() -> Self {
        unsafe { ::core::mem::zeroed() }
    }
}
impl _lv_indev_proc_t {
    #[inline]
    pub fn long_pr_sent(&self) -> u8 {
        unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) }
    }
    #[inline]
    pub fn set_long_pr_sent(&mut self, val: u8) {
        unsafe {
            let val: u8 = ::core::mem::transmute(val);
            self._bitfield_1.set(0usize, 1u8, val as u64)
        }
    }
    #[inline]
    pub fn reset_query(&self) -> u8 {
        unsafe { ::core::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) }
    }
    #[inline]
    pub fn set_reset_query(&mut self, val: u8) {
        unsafe {
            let val: u8 = ::core::mem::transmute(val);
            self._bitfield_1.set(1usize, 1u8, val as u64)
        }
    }
    #[inline]
    pub fn disabled(&self) -> u8 {
        unsafe { ::core::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) }
    }
    #[inline]
    pub fn set_disabled(&mut self, val: u8) {
        unsafe {
            let val: u8 = ::core::mem::transmute(val);
            self._bitfield_1.set(2usize, 1u8, val as u64)
        }
    }
    #[inline]
    pub fn wait_until_release(&self) -> u8 {
        unsafe { ::core::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u8) }
    }
    #[inline]
    pub fn set_wait_until_release(&mut self, val: u8) {
        unsafe {
            let val: u8 = ::core::mem::transmute(val);
            self._bitfield_1.set(3usize, 1u8, val as u64)
        }
    }
    #[inline]
    pub fn new_bitfield_1(
        long_pr_sent: u8,
        reset_query: u8,
        disabled: u8,
        wait_until_release: u8,
    ) -> __BindgenBitfieldUnit<[u8; 1usize], u8> {
        let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize], u8> =
            Default::default();
        __bindgen_bitfield_unit.set(0usize, 1u8, {
            let long_pr_sent: u8 = unsafe { ::core::mem::transmute(long_pr_sent) };
            long_pr_sent as u64
        });
        __bindgen_bitfield_unit.set(1usize, 1u8, {
            let reset_query: u8 = unsafe { ::core::mem::transmute(reset_query) };
            reset_query as u64
        });
        __bindgen_bitfield_unit.set(2usize, 1u8, {
            let disabled: u8 = unsafe { ::core::mem::transmute(disabled) };
            disabled as u64
        });
        __bindgen_bitfield_unit.set(3usize, 1u8, {
            let wait_until_release: u8 = unsafe { ::core::mem::transmute(wait_until_release) };
            wait_until_release as u64
        });
        __bindgen_bitfield_unit
    }
}
pub type lv_indev_proc_t = _lv_indev_proc_t;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct _lv_group_t {
    _unused: [u8; 0],
}
#[doc = " The main input device descriptor with driver, runtime data ('proc') and some additional"]
#[doc = " information"]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct _lv_indev_t {
    pub driver: lv_indev_drv_t,
    pub proc_: lv_indev_proc_t,
    #[doc = "< Cursor for LV_INPUT_TYPE_POINTER"]
    pub cursor: *mut _lv_obj_t,
    #[doc = "< Keypad destination group"]
    pub group: *mut _lv_group_t,
    #[doc = "< Array points assigned to the button ()screen will be pressed"]
    #[doc = "here by the buttons"]
    pub btn_points: *const lv_point_t,
}
impl Default for _lv_indev_t {
    fn default() -> Self {
        unsafe { ::core::mem::zeroed() }
    }
}
pub type lv_indev_t = _lv_indev_t;
#[lvgl_macros::safe_wrap(attr)] extern "C" {
    #[doc = " Initialize an input device driver with default values."]
    #[doc = " It is used to surly have known values in the fields ant not memory junk."]
    #[doc = " After it you can set the fields."]
    #[doc = " - __`driver`__: pointer to driver variable to initialize"]
    pub fn lv_indev_drv_init(driver: *mut lv_indev_drv_t);
}
#[lvgl_macros::safe_wrap(attr)] extern "C" {
    #[doc = " Register an initialized input device driver."]
    #[doc = " - __`driver`__: pointer to an initialized 'lv_indev_drv_t' variable (can be local variable)"]
    #[doc = " Return: pointer to the new input device or NULL on error"]
    pub fn lv_indev_drv_register(driver: *mut lv_indev_drv_t) -> *mut lv_indev_t;
}
#[lvgl_macros::safe_wrap(attr)] extern "C" {
    #[doc = " Update the driver in run time."]
    #[doc = " - __`indev`__: pointer to a input device. (return value of `lv_indev_drv_register`)"]
    #[doc = " - __`new_drv`__: pointer to the new driver"]
    pub fn lv_indev_drv_update(indev: *mut lv_indev_t, new_drv: *mut lv_indev_drv_t);
}
#[lvgl_macros::safe_wrap(attr)] extern "C" {
    #[doc = " Get the next input device."]
    #[doc = " - __`indev`__: pointer to the current input device. NULL to initialize."]
    #[doc = " Return: the next input devise or NULL if no more. Give the first input device when the parameter"]
    #[doc = " is NULL"]
    pub fn lv_indev_get_next(indev: *mut lv_indev_t) -> *mut lv_indev_t;
}