diff --git a/firmware/application/ui_debug.cpp b/firmware/application/ui_debug.cpp index 11aff219..907e85b4 100644 --- a/firmware/application/ui_debug.cpp +++ b/firmware/application/ui_debug.cpp @@ -173,12 +173,12 @@ void RegistersWidget::paint(Painter& painter) { void RegistersWidget::draw_legend(const Coord left, Painter& painter) { const auto pos = screen_pos(); - for(int i=0; i( - "RFFC5072", RegistersWidgetConfig { 31, 2, 4, 4 }, + "RFFC5072", RegistersWidgetConfig { 31, 16 }, [](const size_t register_number) { return radio::debug::first_if::register_read(register_number); } ); } }, { "MAX2837", [&nav](){ nav.push( - "MAX2837", RegistersWidgetConfig { 32, 2, 3, 4 }, + "MAX2837", RegistersWidgetConfig { 32, 10 }, [](const size_t register_number) { return radio::debug::second_if::register_read(register_number); } ); } }, { "Si5351C", [&nav](){ nav.push( - "Si5351C", RegistersWidgetConfig { 96, 2, 2, 8 }, + "Si5351C", RegistersWidgetConfig { 96, 8 }, [](const size_t register_number) { return portapack::clock_generator.read_register(register_number); } ); } }, - { "WM8731", [&nav](){ nav.push( - "WM8731", RegistersWidgetConfig { audio::debug::reg_count(), 1, 3, 4 }, + { "WM8731", [&nav](){ nav.push( + "WM8731", RegistersWidgetConfig { audio::debug::reg_count(), 9 }, [](const size_t register_number) { return audio::debug::reg_read(register_number); } ); } }, }); diff --git a/firmware/application/ui_debug.hpp b/firmware/application/ui_debug.hpp index 33108dcc..67251ce3 100644 --- a/firmware/application/ui_debug.hpp +++ b/firmware/application/ui_debug.hpp @@ -131,20 +131,30 @@ private: struct RegistersWidgetConfig { int registers_count; - int legend_length; - int value_length; - int registers_per_row; + int register_bits; + + constexpr int legend_length() const { + return (registers_count >= 0x10) ? 2 : 1; + } constexpr int legend_width() const { - return legend_length * 8; + return legend_length() * 8; + } + + constexpr int value_length() const { + return (register_bits + 3) / 4; } constexpr int value_width() const { - return value_length * 8; + return value_length() * 8; + } + + constexpr int registers_per_row() const { + return (value_length() >= 3) ? 4 : 8; } constexpr int registers_row_length() const { - return (registers_per_row * (value_length + 1)) - 1; + return (registers_per_row() * (value_length() + 1)) - 1; } constexpr int registers_row_width() const { @@ -156,7 +166,7 @@ struct RegistersWidgetConfig { } constexpr int rows() const { - return registers_count / registers_per_row; + return registers_count / registers_per_row(); } };