Skip to content

Commit 739a066

Browse files
committed
some updates
1 parent 6d9d8f9 commit 739a066

File tree

3 files changed

+86
-53
lines changed

3 files changed

+86
-53
lines changed

ext_mod/lcd_bus/esp32_src/rgb_bus_rotation.c

Lines changed: 75 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -116,20 +116,34 @@
116116
#define RGB_BUS_ROTATION_270 (3)
117117

118118

119-
__attribute__((always_inline)) static inline void rotate0(uint8_t *src, uint8_t *dst, uint32_t x_start, uint32_t y_start, uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height, uint8_t bytes_per_pixel);
120-
__attribute__((always_inline)) static inline void rotate_8bpp(uint8_t *src, uint8_t *dst, uint32_t x_start, uint32_t y_start, uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height, uint8_t rotate);
121-
__attribute__((always_inline)) static inline void rotate_16bpp(uint16_t *src, uint16_t *dst, uint32_t x_start, uint32_t y_start, uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height, uint8_t rotate);
122-
__attribute__((always_inline)) static inline void rotate_24bpp(uint8_t *src, uint8_t *dst, uint32_t x_start, uint32_t y_start, uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height, uint8_t rotate);
123-
__attribute__((always_inline)) static inline void rotate_32bpp(uint32_t *src, uint32_t *dst, uint32_t x_start, uint32_t y_start, uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height, uint8_t rotate);
119+
static void rotate0(uint8_t *src, uint8_t *dst, uint32_t x_start, uint32_t y_start,
120+
uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height,
121+
uint8_t bytes_per_pixel);
124122

123+
static void rotate_8bpp(uint8_t *src, uint8_t *dst, uint32_t x_start, uint32_t y_start,
124+
uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height,
125+
uint8_t rotate);
125126

126-
static void copy_pixels(
127-
void *dst, void *src, uint32_t x_start, uint32_t y_start,
128-
uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height,
129-
uint32_t bytes_per_pixel, uint8_t rotate);
127+
static void rotate_16bpp(uint16_t *src, uint16_t *dst, uint32_t x_start, uint32_t y_start,
128+
uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height,
129+
uint8_t rotate);
130130

131+
static void rotate_24bpp(uint8_t *src, uint8_t *dst, uint32_t x_start, uint32_t y_start,
132+
uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height,
133+
uint8_t rotate);
131134

132-
static bool rgb_bus_trans_done_cb(esp_lcd_panel_handle_t panel, const esp_lcd_rgb_panel_event_data_t *edata, void *user_ctx)
135+
static void rotate_32bpp(uint32_t *src, uint32_t *dst, uint32_t x_start, uint32_t y_start,
136+
uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height,
137+
uint8_t rotate);
138+
139+
140+
static void copy_pixels(void *dst, void *src, uint32_t x_start, uint32_t y_start,
141+
uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height,
142+
uint32_t bytes_per_pixel, uint8_t rotate);
143+
144+
145+
static bool rgb_bus_trans_done_cb(esp_lcd_panel_handle_t panel,
146+
const esp_lcd_rgb_panel_event_data_t *edata, void *user_ctx)
133147
{
134148
LCD_UNUSED(edata);
135149
mp_lcd_rgb_bus_obj_t *self = (mp_lcd_rgb_bus_obj_t *)user_ctx;
@@ -294,27 +308,27 @@
294308

295309

296310
__attribute__((always_inline))
297-
static inline void copy_8bpp(uint8_t *to, const uint8_t *from)
311+
static inline void copy_8bpp(uint8_t *from, uint8_t *to)
298312
{
299313
*to++ = *from++;
300314
}
301315

302316
__attribute__((always_inline))
303-
static inline void copy_16bpp(uint16_t *to, const uint16_t *from)
317+
static inline void copy_16bpp(uint16_t *from, uint16_t *to)
304318
{
305319
*to++ = *from++;
306320
}
307321

308322
__attribute__((always_inline))
309-
static inline void copy_24bpp(uint8_t *to, const uint8_t *from)
323+
static inline void copy_24bpp(uint8_t *from, uint8_t *to)
310324
{
311325
*to++ = *from++;
312326
*to++ = *from++;
313327
*to++ = *from++;
314328
}
315329

316330
__attribute__((always_inline))
317-
static inline void copy_32bpp(uint32_t *to, const uint32_t *from)
331+
static inline void copy_32bpp(uint32_t *from, uint32_t *to)
318332
{
319333
*to++ = *from++;
320334
}
@@ -354,7 +368,9 @@
354368
}
355369

356370

357-
void rotate0(uint8_t *src, uint8_t *dst, uint32_t x_start, uint32_t y_start, uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height, uint8_t bytes_per_pixel)
371+
void rotate0(uint8_t *src, uint8_t *dst, uint32_t x_start, uint32_t y_start,
372+
uint32_t x_end, uint32_t y_end, uint32_t dst_width,
373+
uint32_t dst_height, uint8_t bytes_per_pixel)
358374
{
359375
dst += ((y_start * dst_width + x_start) * bytes_per_pixel);
360376

@@ -372,10 +388,12 @@
372388
}
373389
}
374390

375-
void rotate_8bpp(uint8_t *src, uint8_t *dst, uint32_t x_start, uint32_t y_start, uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height, uint8_t rotate)
391+
void rotate_8bpp(uint8_t *src, uint8_t *dst, uint32_t x_start, uint32_t y_start,
392+
uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height,
393+
uint8_t rotate)
376394
{
377-
uint32_t j;
378395
uint32_t i;
396+
uint32_t j;
379397

380398
uint32_t src_bytes_per_line = x_end - x_start + 1;
381399
uint32_t offset = y_start * src_bytes_per_line + x_start;
@@ -384,9 +402,9 @@
384402
case RGB_BUS_ROTATION_90:
385403
for (uint32_t y = y_start; y < y_end; y++) {
386404
for (uint32_t x = x_start; x < x_end; x++) {
387-
j = y * src_bytes_per_line + x - offset;
388-
i = (dst_height - 1 - x) * dst_width + y;
389-
copy_8bpp(dst + i, src + j);
405+
i = y * src_bytes_per_line + x - offset;
406+
j = (dst_height - 1 - x) * dst_width + y;
407+
copy_8bpp(src + i, dst + j);
390408
}
391409
}
392410
break;
@@ -400,7 +418,7 @@
400418
for (uint32_t y = y_start; y < y_end; y++) {
401419
i = (dst_height - 1 - y) * dst_width + (dst_width - 1 - x_start);
402420
for (uint32_t x = x_start; x < x_end; x++) {
403-
copy_8bpp(dst + i, src);
421+
copy_8bpp(src, dst + i);
404422
src++;
405423
i--;
406424
}
@@ -411,9 +429,9 @@
411429
case RGB_BUS_ROTATION_270:
412430
for (uint32_t y = y_start; y < y_end; y++) {
413431
for (uint32_t x = x_start; x < x_end; x++) {
414-
j = y * src_bytes_per_line + x - offset;
415-
i = x * dst_width + dst_width - 1 - y;
416-
copy_8bpp(dst + i, src + j);
432+
i = y * src_bytes_per_line + x - offset;
433+
j = x * dst_width + dst_width - 1 - y;
434+
copy_8bpp(src + i, dst + j);
417435
}
418436
}
419437
break;
@@ -429,10 +447,12 @@
429447
}
430448

431449

432-
void rotate_16bpp(uint16_t *src, uint16_t *dst, uint32_t x_start, uint32_t y_start, uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height, uint8_t rotate)
450+
void rotate_16bpp(uint16_t *src, uint16_t *dst, uint32_t x_start, uint32_t y_start,
451+
uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height,
452+
uint8_t rotate)
433453
{
434-
uint32_t j;
435454
uint32_t i;
455+
uint32_t j;
436456

437457
uint32_t src_bytes_per_line = x_end - x_start + 1;
438458
uint32_t offset = y_start * src_bytes_per_line + x_start;
@@ -441,9 +461,9 @@
441461
case RGB_BUS_ROTATION_90:
442462
for (uint32_t y = y_start; y < y_end; y++) {
443463
for (uint32_t x = x_start; x < x_end; x++) {
444-
j = y * src_bytes_per_line + x - offset;
445-
i = (dst_height - 1 - x) * dst_width + y;
446-
copy_16bpp(dst + i, src + j);
464+
i = y * src_bytes_per_line + x - offset;
465+
j = (dst_height - 1 - x) * dst_width + y;
466+
copy_16bpp(src + i, dst + j);
447467
}
448468
}
449469
break;
@@ -457,7 +477,7 @@
457477
for (uint32_t y = y_start; y < y_end; y++) {
458478
i = (dst_height - 1 - y) * dst_width + (dst_width - 1 - x_start);
459479
for (uint32_t x = x_start; x < x_end; x++) {
460-
copy_16bpp(dst + i, src);
480+
copy_16bpp(src, dst + i);
461481
src++;
462482
i--;
463483
}
@@ -468,9 +488,9 @@
468488
case RGB_BUS_ROTATION_270:
469489
for (uint32_t y = y_start; y < y_end; y++) {
470490
for (uint32_t x = x_start; x < x_end; x++) {
471-
j = y * src_bytes_per_line + x - offset;
472-
i = (x * dst_width + dst_width - 1 - y);
473-
copy_16bpp(dst + i, src + j);
491+
i = y * src_bytes_per_line + x - offset;
492+
j = (x * dst_width + dst_width - 1 - y);
493+
copy_16bpp(src + i, dst + j);
474494
}
475495
}
476496
break;
@@ -485,10 +505,12 @@
485505
}
486506

487507

488-
void rotate_24bpp(uint8_t *src, uint8_t *dst, uint32_t x_start, uint32_t y_start, uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height, uint8_t rotate)
508+
void rotate_24bpp(uint8_t *src, uint8_t *dst, uint32_t x_start, uint32_t y_start,
509+
uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height,
510+
uint8_t rotate)
489511
{
490-
uint32_t j;
491512
uint32_t i;
513+
uint32_t j;
492514

493515
uint32_t src_bytes_per_line = (x_end - x_start + 1) * 3;
494516
uint32_t offset = y_start * src_bytes_per_line + x_start * 3;
@@ -498,9 +520,9 @@
498520
case RGB_BUS_ROTATION_90:
499521
for (uint32_t y = y_start; y < y_end; y++) {
500522
for (uint32_t x = x_start; x < x_end; x++) {
501-
j = y * src_bytes_per_line + x * 3 - offset;
502-
i = ((dst_height - 1 - x) * dst_width + y) * 3;
503-
copy_24bpp(dst + i, src + j);
523+
i = y * src_bytes_per_line + x * 3 - offset;
524+
j = ((dst_height - 1 - x) * dst_width + y) * 3;
525+
copy_24bpp(src + i, dst + j);
504526
}
505527
}
506528
break;
@@ -514,7 +536,7 @@
514536
for (int y = y_start; y < y_end; y++) {
515537
i = ((dst_height - 1 - y) * dst_width + (dst_width - 1 - x_start)) * 3;
516538
for (size_t x = x_start; x < x_end; x++) {
517-
copy_24bpp(dst + i, src);
539+
copy_24bpp(src, dst + i);
518540
src += 3;
519541
i -= 3;
520542
}
@@ -525,9 +547,9 @@
525547
case RGB_BUS_ROTATION_270:
526548
for (uint32_t y = y_start; y < y_end; y++) {
527549
for (uint32_t x = x_start; x < x_end; x++) {
528-
j = y * src_bytes_per_line + x * 3 - offset;
529-
i = (x * dst_width + dst_width - 1 - y) * 3;
530-
copy_24bpp(dst + i, src + j);
550+
i = y * src_bytes_per_line + x * 3 - offset;
551+
j = (x * dst_width + dst_width - 1 - y) * 3;
552+
copy_24bpp(src + i, dst + j);
531553
}
532554
}
533555
break;
@@ -542,10 +564,12 @@
542564
}
543565

544566

545-
void rotate_32bpp(uint32_t *src, uint32_t *dst, uint32_t x_start, uint32_t y_start, uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height, uint8_t rotate)
567+
void rotate_32bpp(uint32_t *src, uint32_t *dst, uint32_t x_start, uint32_t y_start,
568+
uint32_t x_end, uint32_t y_end, uint32_t dst_width, uint32_t dst_height,
569+
uint8_t rotate)
546570
{
547-
uint32_t j;
548571
uint32_t i;
572+
uint32_t j;
549573

550574
uint32_t src_bytes_per_line = x_end - x_start + 1;
551575
uint32_t offset = y_start * src_bytes_per_line + x_start;
@@ -554,9 +578,9 @@
554578
case RGB_BUS_ROTATION_90:
555579
for (uint32_t y = y_start; y < y_end; y++) {
556580
for (uint32_t x = x_start; x < x_end; x++) {
557-
j = y * src_bytes_per_line + x - offset;
558-
i = (dst_height - 1 - x) * dst_width + y;
559-
copy_32bpp(dst + i, src + j);
581+
i = y * src_bytes_per_line + x - offset;
582+
j = (dst_height - 1 - x) * dst_width + y;
583+
copy_32bpp(src + i, dst + j);
560584
}
561585
}
562586
break;
@@ -570,7 +594,7 @@
570594
for (uint32_t y = y_start; y < y_end; y++) {
571595
i = (dst_height - 1 - y) * dst_width + (dst_width - 1 - x_start);
572596
for (uint32_t x = x_start; x < x_end; x++) {
573-
copy_32bpp(dst + i, src);
597+
copy_32bpp(src, dst + i);
574598
src++;
575599
i--;
576600
}
@@ -581,9 +605,9 @@
581605
case RGB_BUS_ROTATION_270:
582606
for (uint32_t y = y_start; y < y_end; y++) {
583607
for (uint32_t x = x_start; x < x_end; x++) {
584-
j = y * src_bytes_per_line + x - offset;
585-
i = x * dst_width + dst_width - 1 - y;
586-
copy_32bpp(dst + i, src + j);
608+
i = y * src_bytes_per_line + x - offset;
609+
j = x * dst_width + dst_width - 1 - y;
610+
copy_32bpp(src + i, dst + j);
587611
}
588612
}
589613
break;

gen/python_api_gen_mpy.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3730,6 +3730,7 @@ def _iter_metadata(d, indent=0):
37303730

37313731

37323732
if args.metadata:
3733+
37333734
metadata = collections.OrderedDict()
37343735
metadata['objects'] = {obj_name: obj_metadata[obj_name] for obj_name in obj_names}
37353736
metadata['functions'] = {simplify_identifier(f.name): func_metadata[f.name] for f in module_funcs}
@@ -3746,9 +3747,16 @@ def _iter_metadata(d, indent=0):
37463747
with open(args.metadata, 'w') as metadata_file:
37473748
json.dump(metadata, metadata_file, indent=4)
37483749

3750+
build_path = os.path.split(args.metadata)[0]
3751+
3752+
api_json_path = os.path.join(build_path, 'lvgl_api.json')
3753+
3754+
with open(api_json_path, 'w') as metadata_file:
3755+
json.dump(lvgl_json, metadata_file, indent=4)
3756+
37493757
import stub_gen
37503758

3751-
stub_gen.run(args.metadata)
3759+
stub_gen.run(args.metadata, api_json_path)
37523760

37533761
stdout.close()
37543762

gen/stub_gen.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,8 @@ class mem_pool_t(object):
449449
'''
450450

451451

452-
def run(json_path):
452+
def run(json_path, lvgl_api_json_path):
453+
453454
with open(json_path, 'r') as f:
454455
data = f.read()
455456

0 commit comments

Comments
 (0)