dsh-embedded-workbench 0.8.3 → 0.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,68 +1,68 @@
1
- # LVGL Common Pitfalls
2
-
3
- Non-obvious traps when working with LVGL on embedded targets.
4
-
5
- ## RGB565A8 Custom Decoder Layout
6
-
7
- **Pitfall**: Assuming a custom PNG decoder outputs interleaved RGBA pixels.
8
-
9
- **Reality**: On 16-bit color depth targets, the decoder separates color and alpha into distinct planes — RGB565 (2 bytes/pixel) for color and A8 (1 byte/pixel) for alpha. Reading as interleaved RGBA produces garbled output.
10
-
11
- **Check**: Verify the decoder's output format matches what the draw pipeline expects before writing draw callbacks.
12
-
13
- ## Alignment Flag Mixing
14
-
15
- **Pitfall**: Combining multiple LVGL alignment flags produces unexpected positioning.
16
-
17
- **Reality**: LVGL alignment flags are not freely bitwise-combinable. ORing two horizontal flags or two vertical flags produces undefined behavior that depends on internal evaluation order.
18
-
19
- **Fix**: Use exactly one horizontal flag ORed with exactly one vertical flag. For non-standard positioning, use `lv_obj_set_pos()` with explicit coordinates after layout.
20
-
21
- ## Object Cleanup Order and Stale Pointers
22
-
23
- **Pitfall**: `lv_obj_clean(parent)` recursively frees children but does not NULL any static pointers that reference those children.
24
-
25
- **Fix Pattern**:
26
-
27
- ```c
28
- anim_timer_del(); // 1. Kill async operations
29
- icon = NULL; // 2. NULL all static pointers
30
- label = NULL;
31
- lv_obj_clean(parent); // 3. Clean the parent last
32
- ```
33
-
34
- On page re-entry, always guard with NULL checks before using any cached LVGL object pointer.
35
-
36
- ## Menu Scroll with Fixed Elements
37
-
38
- **Pitfall**: A scrollable menu with header/footer inside the scroll container scrolls those elements along with the content.
39
-
40
- **Fix**: Move fixed elements outside the scrollable container:
41
-
42
- ```text
43
- Page (flex column)
44
- ├── Header (fixed, outside scroll)
45
- ├── Scroll container (flex grow)
46
- │ └── Items (scrollable)
47
- └── Footer (fixed, outside scroll)
48
- ```
49
-
50
- ## Draw Mask Lifecycle
51
-
52
- **Pitfall**: Creating an LVGL draw mask and not removing it before the next draw pass causes unrelated elements to be incorrectly masked.
53
-
54
- **Fix**: Always pair mask creation with removal:
55
-
56
- ```c
57
- int16_t mask_id = lv_draw_mask_angle_init(&param);
58
- // ... draw ...
59
- lv_draw_mask_remove_id(mask_id);
60
- ```
61
-
62
- For masks in animation callbacks, store the mask_id and ensure cleanup in the animation's end handler or page exit.
63
-
64
- ## Alpha Cache Staleness on Overlay Removal
65
-
66
- **Pitfall**: Removing a gap/clear overlay from a chart leaves ghost artifacts because the alpha blending cache retains intermediate values.
67
-
68
- **Fix**: After removing an overlay, call `lv_obj_invalidate()` on the parent to force a full redraw. For chart widgets, invalidate the entire chart rather than individual series.
1
+ # LVGL Common Pitfalls
2
+
3
+ Non-obvious traps when working with LVGL on embedded targets.
4
+
5
+ ## RGB565A8 Custom Decoder Layout
6
+
7
+ **Pitfall**: Assuming a custom PNG decoder outputs interleaved RGBA pixels.
8
+
9
+ **Reality**: On 16-bit color depth targets, the decoder separates color and alpha into distinct planes — RGB565 (2 bytes/pixel) for color and A8 (1 byte/pixel) for alpha. Reading as interleaved RGBA produces garbled output.
10
+
11
+ **Check**: Verify the decoder's output format matches what the draw pipeline expects before writing draw callbacks.
12
+
13
+ ## Alignment Flag Mixing
14
+
15
+ **Pitfall**: Combining multiple LVGL alignment flags produces unexpected positioning.
16
+
17
+ **Reality**: LVGL alignment flags are not freely bitwise-combinable. ORing two horizontal flags or two vertical flags produces undefined behavior that depends on internal evaluation order.
18
+
19
+ **Fix**: Use exactly one horizontal flag ORed with exactly one vertical flag. For non-standard positioning, use `lv_obj_set_pos()` with explicit coordinates after layout.
20
+
21
+ ## Object Cleanup Order and Stale Pointers
22
+
23
+ **Pitfall**: `lv_obj_clean(parent)` recursively frees children but does not NULL any static pointers that reference those children.
24
+
25
+ **Fix Pattern**:
26
+
27
+ ```c
28
+ anim_timer_del(); // 1. Kill async operations
29
+ icon = NULL; // 2. NULL all static pointers
30
+ label = NULL;
31
+ lv_obj_clean(parent); // 3. Clean the parent last
32
+ ```
33
+
34
+ On page re-entry, always guard with NULL checks before using any cached LVGL object pointer.
35
+
36
+ ## Menu Scroll with Fixed Elements
37
+
38
+ **Pitfall**: A scrollable menu with header/footer inside the scroll container scrolls those elements along with the content.
39
+
40
+ **Fix**: Move fixed elements outside the scrollable container:
41
+
42
+ ```text
43
+ Page (flex column)
44
+ ├── Header (fixed, outside scroll)
45
+ ├── Scroll container (flex grow)
46
+ │ └── Items (scrollable)
47
+ └── Footer (fixed, outside scroll)
48
+ ```
49
+
50
+ ## Draw Mask Lifecycle
51
+
52
+ **Pitfall**: Creating an LVGL draw mask and not removing it before the next draw pass causes unrelated elements to be incorrectly masked.
53
+
54
+ **Fix**: Always pair mask creation with removal:
55
+
56
+ ```c
57
+ int16_t mask_id = lv_draw_mask_angle_init(&param);
58
+ // ... draw ...
59
+ lv_draw_mask_remove_id(mask_id);
60
+ ```
61
+
62
+ For masks in animation callbacks, store the mask_id and ensure cleanup in the animation's end handler or page exit.
63
+
64
+ ## Alpha Cache Staleness on Overlay Removal
65
+
66
+ **Pitfall**: Removing a gap/clear overlay from a chart leaves ghost artifacts because the alpha blending cache retains intermediate values.
67
+
68
+ **Fix**: After removing an overlay, call `lv_obj_invalidate()` on the parent to force a full redraw. For chart widgets, invalidate the entire chart rather than individual series.