diff --git a/scripts/gdb/lvglgdb/__init__.py b/scripts/gdb/lvglgdb/__init__.py index ed9d79a025..a840d2c94c 100644 --- a/scripts/gdb/lvglgdb/__init__.py +++ b/scripts/gdb/lvglgdb/__init__.py @@ -36,6 +36,7 @@ from .lvgl import ( EVENT_CODE_NAMES, LVAnim, LVTimer, + LVImageDecoder, LVFsDrv, ) from . import cmds as cmds @@ -76,5 +77,6 @@ __all__ = [ "EVENT_CODE_NAMES", "LVAnim", "LVTimer", + "LVImageDecoder", "LVFsDrv", ] diff --git a/scripts/gdb/lvglgdb/cmds/__init__.py b/scripts/gdb/lvglgdb/cmds/__init__.py index 3c16e420f8..8625cada31 100644 --- a/scripts/gdb/lvglgdb/cmds/__init__.py +++ b/scripts/gdb/lvglgdb/cmds/__init__.py @@ -10,6 +10,7 @@ from .misc import ( CheckCache, DumpAnim, DumpTimer, + DumpImageDecoder, DumpFsDrv, ) from .debugger import Debugger @@ -35,6 +36,7 @@ CheckPrefix() CheckCache() DumpAnim() DumpTimer() +DumpImageDecoder() DumpFsDrv() DumpDrawTask() diff --git a/scripts/gdb/lvglgdb/cmds/misc/__init__.py b/scripts/gdb/lvglgdb/cmds/misc/__init__.py index 7c3de9b818..1af324effa 100644 --- a/scripts/gdb/lvglgdb/cmds/misc/__init__.py +++ b/scripts/gdb/lvglgdb/cmds/misc/__init__.py @@ -2,6 +2,7 @@ from .lv_style import InfoStyle from .lv_cache import DumpCache, CheckPrefix, CheckCache from .lv_anim import DumpAnim from .lv_timer import DumpTimer +from .lv_image_decoder import DumpImageDecoder from .lv_fs import DumpFsDrv __all__ = [ @@ -11,5 +12,6 @@ __all__ = [ "CheckCache", "DumpAnim", "DumpTimer", + "DumpImageDecoder", "DumpFsDrv", ] diff --git a/scripts/gdb/lvglgdb/cmds/misc/lv_image_decoder.py b/scripts/gdb/lvglgdb/cmds/misc/lv_image_decoder.py new file mode 100644 index 0000000000..5bbd46f474 --- /dev/null +++ b/scripts/gdb/lvglgdb/cmds/misc/lv_image_decoder.py @@ -0,0 +1,16 @@ +import gdb + +from lvglgdb.lvgl import curr_inst +from lvglgdb.lvgl.misc.lv_image_decoder import LVImageDecoder + + +class DumpImageDecoder(gdb.Command): + """dump all registered image decoders""" + + def __init__(self): + super(DumpImageDecoder, self).__init__( + "dump image_decoder", gdb.COMMAND_USER, gdb.COMPLETE_EXPRESSION + ) + + def invoke(self, args, from_tty): + LVImageDecoder.print_entries(curr_inst().image_decoders()) diff --git a/scripts/gdb/lvglgdb/lvgl/__init__.py b/scripts/gdb/lvglgdb/lvgl/__init__.py index 91690bdb01..a444431456 100644 --- a/scripts/gdb/lvglgdb/lvgl/__init__.py +++ b/scripts/gdb/lvglgdb/lvgl/__init__.py @@ -37,6 +37,7 @@ from .misc import ( EVENT_CODE_NAMES, LVAnim, LVTimer, + LVImageDecoder, LVFsDrv, ) @@ -81,5 +82,6 @@ __all__ = [ "EVENT_CODE_NAMES", "LVAnim", "LVTimer", + "LVImageDecoder", "LVFsDrv", ] diff --git a/scripts/gdb/lvglgdb/lvgl/core/lv_global.py b/scripts/gdb/lvglgdb/lvgl/core/lv_global.py index 92501a6ec4..268665e6a9 100644 --- a/scripts/gdb/lvglgdb/lvgl/core/lv_global.py +++ b/scripts/gdb/lvglgdb/lvgl/core/lv_global.py @@ -73,6 +73,12 @@ class LVGL: for timer in LVList(self.lv_global.timer_state.timer_ll, "lv_timer_t"): yield LVTimer(timer) + def image_decoders(self): + from ..misc.lv_image_decoder import LVImageDecoder + + for dec in LVList(self.lv_global.img_decoder_ll, "lv_image_decoder_t"): + yield LVImageDecoder(dec) + def fs_drivers(self): from ..misc.lv_fs import LVFsDrv diff --git a/scripts/gdb/lvglgdb/lvgl/misc/__init__.py b/scripts/gdb/lvglgdb/lvgl/misc/__init__.py index 9233105dc0..1d08840b39 100644 --- a/scripts/gdb/lvglgdb/lvgl/misc/__init__.py +++ b/scripts/gdb/lvglgdb/lvgl/misc/__init__.py @@ -25,6 +25,7 @@ from .lv_event import ( ) from .lv_anim import LVAnim from .lv_timer import LVTimer +from .lv_image_decoder import LVImageDecoder from .lv_fs import LVFsDrv __all__ = [ @@ -56,5 +57,6 @@ __all__ = [ "EVENT_CODE_NAMES", "LVAnim", "LVTimer", + "LVImageDecoder", "LVFsDrv", ] diff --git a/scripts/gdb/lvglgdb/lvgl/misc/lv_image_decoder.py b/scripts/gdb/lvglgdb/lvgl/misc/lv_image_decoder.py new file mode 100644 index 0000000000..4e0ea30182 --- /dev/null +++ b/scripts/gdb/lvglgdb/lvgl/misc/lv_image_decoder.py @@ -0,0 +1,62 @@ +from prettytable import PrettyTable + +from lvglgdb.value import Value, ValueInput + + +class LVImageDecoder(Value): + """LVGL image decoder wrapper""" + + def __init__(self, decoder: ValueInput): + super().__init__(Value.normalize(decoder, "lv_image_decoder_t")) + + @property + def name(self) -> str: + n = self.super_value("name") + return n.string() if int(n) else "(unnamed)" + + @property + def info_cb(self) -> Value: + return self.super_value("info_cb") + + @property + def open_cb(self) -> Value: + return self.super_value("open_cb") + + @property + def close_cb(self) -> Value: + return self.super_value("close_cb") + + @property + def get_area_cb(self) -> Value: + return self.super_value("get_area_cb") + + @property + def custom_draw_cb(self) -> Value: + return self.super_value("custom_draw_cb") + + @property + def user_data(self) -> Value: + return self.super_value("user_data") + + @staticmethod + def print_entries(decoders): + """Print image decoders as a PrettyTable.""" + table = PrettyTable() + table.field_names = ["#", "name", "info_cb", "open_cb", "close_cb"] + table.align = "l" + + for i, dec in enumerate(decoders): + table.add_row( + [ + i, + dec.name, + dec.info_cb.format_string(symbols=True), + dec.open_cb.format_string(symbols=True), + dec.close_cb.format_string(symbols=True), + ] + ) + + if not table.rows: + print("No registered image decoders.") + else: + print(table)