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
/* 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_COLOR_DEPTH: u32 = 16;
pub const LV_COLOR_16_SWAP: u32 = 1;
pub const LV_COLOR_SCREEN_TRANSP: u32 = 0;
pub const LV_COLOR_SIZE: u32 = 16;
pub const LV_COLOR_MIX_ROUND_OFS: u32 = 128;
#[doc = "      TYPEDEFS"]
#[repr(C)]
#[derive(Copy, Clone)]
pub union lv_color1_t {
    pub ch: lv_color1_t__bindgen_ty_1,
    pub full: u8,
    _bindgen_union_align: u8,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union lv_color1_t__bindgen_ty_1 {
    pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize], u8>,
    _bindgen_union_align: u8,
}
impl Default for lv_color1_t__bindgen_ty_1 {
    fn default() -> Self {
        unsafe { ::core::mem::zeroed() }
    }
}
impl lv_color1_t__bindgen_ty_1 {
    #[inline]
    pub fn blue(&self) -> u8 {
        unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) }
    }
    #[inline]
    pub fn set_blue(&mut self, val: u8) {
        unsafe {
            let val: u8 = ::core::mem::transmute(val);
            self._bitfield_1.set(0usize, 1u8, val as u64)
        }
    }
    #[inline]
    pub fn green(&self) -> u8 {
        unsafe { ::core::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) }
    }
    #[inline]
    pub fn set_green(&mut self, val: u8) {
        unsafe {
            let val: u8 = ::core::mem::transmute(val);
            self._bitfield_1.set(1usize, 1u8, val as u64)
        }
    }
    #[inline]
    pub fn red(&self) -> u8 {
        unsafe { ::core::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) }
    }
    #[inline]
    pub fn set_red(&mut self, val: u8) {
        unsafe {
            let val: u8 = ::core::mem::transmute(val);
            self._bitfield_1.set(2usize, 1u8, val as u64)
        }
    }
    #[inline]
    pub fn new_bitfield_1(blue: u8, green: u8, red: u8) -> __BindgenBitfieldUnit<[u8; 1usize], u8> {
        let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize], u8> =
            Default::default();
        __bindgen_bitfield_unit.set(0usize, 1u8, {
            let blue: u8 = unsafe { ::core::mem::transmute(blue) };
            blue as u64
        });
        __bindgen_bitfield_unit.set(1usize, 1u8, {
            let green: u8 = unsafe { ::core::mem::transmute(green) };
            green as u64
        });
        __bindgen_bitfield_unit.set(2usize, 1u8, {
            let red: u8 = unsafe { ::core::mem::transmute(red) };
            red as u64
        });
        __bindgen_bitfield_unit
    }
}
impl Default for lv_color1_t {
    fn default() -> Self {
        unsafe { ::core::mem::zeroed() }
    }
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union lv_color8_t {
    pub ch: lv_color8_t__bindgen_ty_1,
    pub full: u8,
    _bindgen_union_align: u8,
}
#[repr(C, packed)]
#[derive(Default, Copy, Clone)]
pub struct lv_color8_t__bindgen_ty_1 {
    pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize], u8>,
}
impl lv_color8_t__bindgen_ty_1 {
    #[inline]
    pub fn blue(&self) -> u8 {
        unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 2u8) as u8) }
    }
    #[inline]
    pub fn set_blue(&mut self, val: u8) {
        unsafe {
            let val: u8 = ::core::mem::transmute(val);
            self._bitfield_1.set(0usize, 2u8, val as u64)
        }
    }
    #[inline]
    pub fn green(&self) -> u8 {
        unsafe { ::core::mem::transmute(self._bitfield_1.get(2usize, 3u8) as u8) }
    }
    #[inline]
    pub fn set_green(&mut self, val: u8) {
        unsafe {
            let val: u8 = ::core::mem::transmute(val);
            self._bitfield_1.set(2usize, 3u8, val as u64)
        }
    }
    #[inline]
    pub fn red(&self) -> u8 {
        unsafe { ::core::mem::transmute(self._bitfield_1.get(5usize, 3u8) as u8) }
    }
    #[inline]
    pub fn set_red(&mut self, val: u8) {
        unsafe {
            let val: u8 = ::core::mem::transmute(val);
            self._bitfield_1.set(5usize, 3u8, val as u64)
        }
    }
    #[inline]
    pub fn new_bitfield_1(blue: u8, green: u8, red: u8) -> __BindgenBitfieldUnit<[u8; 1usize], u8> {
        let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize], u8> =
            Default::default();
        __bindgen_bitfield_unit.set(0usize, 2u8, {
            let blue: u8 = unsafe { ::core::mem::transmute(blue) };
            blue as u64
        });
        __bindgen_bitfield_unit.set(2usize, 3u8, {
            let green: u8 = unsafe { ::core::mem::transmute(green) };
            green as u64
        });
        __bindgen_bitfield_unit.set(5usize, 3u8, {
            let red: u8 = unsafe { ::core::mem::transmute(red) };
            red as u64
        });
        __bindgen_bitfield_unit
    }
}
impl Default for lv_color8_t {
    fn default() -> Self {
        unsafe { ::core::mem::zeroed() }
    }
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union lv_color16_t {
    pub ch: lv_color16_t__bindgen_ty_1,
    pub full: u16,
    _bindgen_union_align: u16,
}
#[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
    }
}
impl Default for lv_color16_t {
    fn default() -> Self {
        unsafe { ::core::mem::zeroed() }
    }
}
#[repr(C)]
#[derive(Copy, Clone)]
pub union lv_color32_t {
    pub ch: lv_color32_t__bindgen_ty_1,
    pub full: u32,
    _bindgen_union_align: u32,
}
#[repr(C)]
#[derive(Default, Copy, Clone)]
pub struct lv_color32_t__bindgen_ty_1 {
    pub blue: u8,
    pub green: u8,
    pub red: u8,
    pub alpha: u8,
}
impl Default for lv_color32_t {
    fn default() -> Self {
        unsafe { ::core::mem::zeroed() }
    }
}
pub type lv_color_int_t = u16;
pub type lv_color_t = lv_color16_t;
#[repr(C)]
#[derive(Default, Copy, Clone)]
pub struct lv_color_hsv_t {
    pub h: u16,
    pub s: u8,
    pub v: u8,
}
#[doc = "! @cond Doxygen_Suppress"]
pub type lv_opa_t = u8;
#[lvgl_macros::safe_wrap(attr)] extern "C" {
    #[doc = " GLOBAL PROTOTYPES"]
    pub fn lv_color_to1(color: lv_color_t) -> u8;
}
#[lvgl_macros::safe_wrap(attr)] extern "C" {
    pub fn lv_color_to8(color: lv_color_t) -> u8;
}
#[lvgl_macros::safe_wrap(attr)] extern "C" {
    pub fn lv_color_to16(color: lv_color_t) -> u16;
}
#[lvgl_macros::safe_wrap(attr)] extern "C" {
    pub fn lv_color_to32(color: lv_color_t) -> u32;
}
#[lvgl_macros::safe_wrap(attr)] extern "C" {
    #[doc = " Mix two colors with a given ratio."]
    #[doc = " - __`c1`__: the first color to mix (usually the foreground)"]
    #[doc = " - __`c2`__: the second color to mix (usually the background)"]
    #[doc = " - __`mix`__: The ratio of the colors. 0: full `c2`, 255: full `c1`, 127: half `c1` and half`c2`"]
    #[doc = " Return: the mixed color"]
    pub fn lv_color_mix(c1: lv_color_t, c2: lv_color_t, mix: u8) -> lv_color_t;
}
#[lvgl_macros::safe_wrap(attr)] extern "C" {
    pub fn lv_color_premult(c: lv_color_t, mix: u8, out: *mut u16);
}
#[lvgl_macros::safe_wrap(attr)] extern "C" {
    #[doc = " Mix two colors with a given ratio. It runs faster then `lv_color_mix` but requires some pre computation."]
    #[doc = " - __`c1`__: The first color. Should be preprocessed with `lv_color_premult(c1)`"]
    #[doc = " - __`c2`__: The second color. As it is no pre computation required on it"]
    #[doc = " - __`mix`__: The ratio of the colors. 0: full `c2`, 255: full `c1`, 127: half `c1` and half `c2`."]
    #[doc = "            Should be modified like mix = `255 - mix`"]
    #[doc = " Return: the mixed color"]
    #[doc = " __Note:__ 255 won't give clearly `c1`."]
    pub fn lv_color_mix_premult(premult_c1: *mut u16, c2: lv_color_t, mix: u8) -> lv_color_t;
}
#[lvgl_macros::safe_wrap(attr)] extern "C" {
    #[doc = " Mix two colors. Both color can have alpha value. It requires ARGB888 colors."]
    #[doc = " - __`bg_color`__: background color"]
    #[doc = " - __`bg_opa`__: alpha of the background color"]
    #[doc = " - __`fg_color`__: foreground color"]
    #[doc = " - __`fg_opa`__: alpha of the foreground color"]
    #[doc = " - __`res_color`__: the result color"]
    #[doc = " - __`res_opa`__: the result opacity"]
    pub fn lv_color_mix_with_alpha(
        bg_color: lv_color_t,
        bg_opa: lv_opa_t,
        fg_color: lv_color_t,
        fg_opa: lv_opa_t,
        res_color: *mut lv_color_t,
        res_opa: *mut lv_opa_t,
    );
}
#[lvgl_macros::safe_wrap(attr)] extern "C" {
    #[doc = " Get the brightness of a color"]
    #[doc = " - __`color`__: a color"]
    #[doc = " Return: the brightness [0..255]"]
    pub fn lv_color_brightness(color: lv_color_t) -> u8;
}
#[lvgl_macros::safe_wrap(attr)] extern "C" {
    pub fn lv_color_make(r: u8, g: u8, b: u8) -> lv_color_t;
}
#[lvgl_macros::safe_wrap(attr)] extern "C" {
    pub fn lv_color_hex(c: u32) -> lv_color_t;
}
#[lvgl_macros::safe_wrap(attr)] extern "C" {
    pub fn lv_color_hex3(c: u32) -> lv_color_t;
}
#[lvgl_macros::safe_wrap(attr)] extern "C" {
    #[doc = "! @cond Doxygen_Suppress"]
    #[doc = "!"]
    pub fn lv_color_fill(buf: *mut lv_color_t, color: lv_color_t, px_num: u32);
}
#[lvgl_macros::safe_wrap(attr)] extern "C" {
    #[doc = "! @endcond"]
    pub fn lv_color_lighten(c: lv_color_t, lvl: lv_opa_t) -> lv_color_t;
}
#[lvgl_macros::safe_wrap(attr)] extern "C" {
    pub fn lv_color_darken(c: lv_color_t, lvl: lv_opa_t) -> lv_color_t;
}
#[lvgl_macros::safe_wrap(attr)] extern "C" {
    #[doc = " Convert a HSV color to RGB"]
    #[doc = " - __`h`__: hue [0..359]"]
    #[doc = " - __`s`__: saturation [0..100]"]
    #[doc = " - __`v`__: value [0..100]"]
    #[doc = " Return: the given RGB color in RGB (with LV_COLOR_DEPTH depth)"]
    pub fn lv_color_hsv_to_rgb(h: u16, s: u8, v: u8) -> lv_color_t;
}
#[lvgl_macros::safe_wrap(attr)] extern "C" {
    #[doc = " Convert a 32-bit RGB color to HSV"]
    #[doc = " - __`r8`__: 8-bit red"]
    #[doc = " - __`g8`__: 8-bit green"]
    #[doc = " - __`b8`__: 8-bit blue"]
    #[doc = " Return: the given RGB color in HSV"]
    pub fn lv_color_rgb_to_hsv(r8: u8, g8: u8, b8: u8) -> lv_color_hsv_t;
}
#[lvgl_macros::safe_wrap(attr)] extern "C" {
    #[doc = " Convert a color to HSV"]
    #[doc = " - __`color`__: color"]
    #[doc = " Return: the given color in HSV"]
    pub fn lv_color_to_hsv(color: lv_color_t) -> lv_color_hsv_t;
}