mirror of
https://github.com/lvgl/lvgl.git
synced 2026-03-23 14:03:13 +08:00
chore(gdb): add LVTimer wrapper with freq column and dump timers command
This commit is contained in:
@@ -35,6 +35,7 @@ from .lvgl import (
|
||||
event_code_name,
|
||||
EVENT_CODE_NAMES,
|
||||
LVAnim,
|
||||
LVTimer,
|
||||
)
|
||||
from . import cmds as cmds
|
||||
|
||||
@@ -73,4 +74,5 @@ __all__ = [
|
||||
"event_code_name",
|
||||
"EVENT_CODE_NAMES",
|
||||
"LVAnim",
|
||||
"LVTimer",
|
||||
]
|
||||
|
||||
@@ -9,6 +9,7 @@ from .misc import (
|
||||
CheckPrefix,
|
||||
CheckCache,
|
||||
DumpAnim,
|
||||
DumpTimer,
|
||||
)
|
||||
from .debugger import Debugger
|
||||
from .drivers import Lvglobal
|
||||
@@ -32,6 +33,7 @@ DumpCache()
|
||||
CheckPrefix()
|
||||
CheckCache()
|
||||
DumpAnim()
|
||||
DumpTimer()
|
||||
DumpDrawTask()
|
||||
|
||||
# Infos
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from .lv_style import InfoStyle
|
||||
from .lv_cache import DumpCache, CheckPrefix, CheckCache
|
||||
from .lv_anim import DumpAnim
|
||||
from .lv_timer import DumpTimer
|
||||
|
||||
__all__ = [
|
||||
"InfoStyle",
|
||||
@@ -8,4 +9,5 @@ __all__ = [
|
||||
"CheckPrefix",
|
||||
"CheckCache",
|
||||
"DumpAnim",
|
||||
"DumpTimer",
|
||||
]
|
||||
|
||||
16
scripts/gdb/lvglgdb/cmds/misc/lv_timer.py
Normal file
16
scripts/gdb/lvglgdb/cmds/misc/lv_timer.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import gdb
|
||||
|
||||
from lvglgdb.lvgl import curr_inst
|
||||
from lvglgdb.lvgl.misc.lv_timer import LVTimer
|
||||
|
||||
|
||||
class DumpTimer(gdb.Command):
|
||||
"""dump all active timers"""
|
||||
|
||||
def __init__(self):
|
||||
super(DumpTimer, self).__init__(
|
||||
"dump timers", gdb.COMMAND_USER, gdb.COMPLETE_EXPRESSION
|
||||
)
|
||||
|
||||
def invoke(self, args, from_tty):
|
||||
LVTimer.print_entries(curr_inst().timers())
|
||||
@@ -36,6 +36,7 @@ from .misc import (
|
||||
event_code_name,
|
||||
EVENT_CODE_NAMES,
|
||||
LVAnim,
|
||||
LVTimer,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
@@ -78,4 +79,5 @@ __all__ = [
|
||||
"event_code_name",
|
||||
"EVENT_CODE_NAMES",
|
||||
"LVAnim",
|
||||
"LVTimer",
|
||||
]
|
||||
|
||||
@@ -67,6 +67,14 @@ class LVGL:
|
||||
for anim in LVList(self.lv_global.anim_state.anim_ll, "lv_anim_t"):
|
||||
yield LVAnim(anim)
|
||||
|
||||
def timers(self):
|
||||
from ..misc.lv_timer import LVTimer
|
||||
|
||||
for timer in LVList(self.lv_global.timer_state.timer_ll, "lv_timer_t"):
|
||||
yield LVTimer(timer)
|
||||
|
||||
|
||||
|
||||
def image_header_cache(self):
|
||||
from ..misc.lv_image_header_cache import LVImageHeaderCache
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ from .lv_event import (
|
||||
EVENT_CODE_NAMES,
|
||||
)
|
||||
from .lv_anim import LVAnim
|
||||
from .lv_timer import LVTimer
|
||||
|
||||
__all__ = [
|
||||
"LVList",
|
||||
@@ -53,4 +54,5 @@ __all__ = [
|
||||
"event_code_name",
|
||||
"EVENT_CODE_NAMES",
|
||||
"LVAnim",
|
||||
"LVTimer",
|
||||
]
|
||||
|
||||
66
scripts/gdb/lvglgdb/lvgl/misc/lv_timer.py
Normal file
66
scripts/gdb/lvglgdb/lvgl/misc/lv_timer.py
Normal file
@@ -0,0 +1,66 @@
|
||||
from prettytable import PrettyTable
|
||||
|
||||
from lvglgdb.value import Value, ValueInput
|
||||
|
||||
|
||||
class LVTimer(Value):
|
||||
"""LVGL timer wrapper"""
|
||||
|
||||
def __init__(self, timer: ValueInput):
|
||||
super().__init__(Value.normalize(timer, "lv_timer_t"))
|
||||
|
||||
@property
|
||||
def period(self) -> int:
|
||||
return int(self.super_value("period"))
|
||||
|
||||
@property
|
||||
def last_run(self) -> int:
|
||||
return int(self.super_value("last_run"))
|
||||
|
||||
@property
|
||||
def timer_cb(self) -> Value:
|
||||
return self.super_value("timer_cb")
|
||||
|
||||
@property
|
||||
def repeat_count(self) -> int:
|
||||
return int(self.super_value("repeat_count"))
|
||||
|
||||
@property
|
||||
def paused(self) -> bool:
|
||||
return bool(int(self.super_value("paused")))
|
||||
|
||||
@property
|
||||
def user_data(self) -> Value:
|
||||
return self.super_value("user_data")
|
||||
|
||||
@property
|
||||
def auto_delete(self) -> bool:
|
||||
return bool(int(self.super_value("auto_delete")))
|
||||
|
||||
@staticmethod
|
||||
def print_entries(timers):
|
||||
"""Print timers as a PrettyTable."""
|
||||
table = PrettyTable()
|
||||
table.field_names = ["#", "callback", "period", "freq", "last_run", "repeat", "paused"]
|
||||
table.align = "l"
|
||||
|
||||
for i, timer in enumerate(timers):
|
||||
cb_str = timer.timer_cb.format_string(symbols=True, address=True)
|
||||
repeat = "inf" if timer.repeat_count == -1 else str(timer.repeat_count)
|
||||
freq = f"{1000 / timer.period:.1f}Hz" if timer.period > 0 else "-"
|
||||
table.add_row(
|
||||
[
|
||||
i,
|
||||
cb_str,
|
||||
timer.period,
|
||||
freq,
|
||||
timer.last_run,
|
||||
repeat,
|
||||
timer.paused,
|
||||
]
|
||||
)
|
||||
|
||||
if not table.rows:
|
||||
print("No active timers.")
|
||||
else:
|
||||
print(table)
|
||||
Reference in New Issue
Block a user