From 2033967dc61ddbb0aa68dde699c8b182050560a1 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Tue, 8 Aug 2017 10:33:55 -0700 Subject: [PATCH] RegistersWidget: Fix type warnings. --- firmware/application/ui_debug.cpp | 10 +++++----- firmware/application/ui_debug.hpp | 24 ++++++++++++------------ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/firmware/application/ui_debug.cpp b/firmware/application/ui_debug.cpp index 3e439367be..621933e530 100644 --- a/firmware/application/ui_debug.cpp +++ b/firmware/application/ui_debug.cpp @@ -173,9 +173,9 @@ void RegistersWidget::paint(Painter& painter) { void RegistersWidget::draw_legend(const Coord left, Painter& painter) { const auto pos = screen_pos(); - for(int i=0; i((i / config.registers_per_row()) * row_height) }; const auto text = to_string_hex(i, config.legend_length()); @@ -193,10 +193,10 @@ void RegistersWidget::draw_values( ) { const auto pos = screen_pos(); - for(int i=0; i(left + config.legend_width() + 8 + (i % config.registers_per_row()) * (config.value_width() + 8)), + static_cast((i / config.registers_per_row()) * row_height) }; const auto value = reader(i); diff --git a/firmware/application/ui_debug.hpp b/firmware/application/ui_debug.hpp index 67251ce381..04b9bbe069 100644 --- a/firmware/application/ui_debug.hpp +++ b/firmware/application/ui_debug.hpp @@ -130,42 +130,42 @@ class TemperatureView : public View { }; struct RegistersWidgetConfig { - int registers_count; - int register_bits; + size_t registers_count; + size_t register_bits; - constexpr int legend_length() const { + constexpr size_t legend_length() const { return (registers_count >= 0x10) ? 2 : 1; } - constexpr int legend_width() const { + constexpr size_t legend_width() const { return legend_length() * 8; } - constexpr int value_length() const { + constexpr size_t value_length() const { return (register_bits + 3) / 4; } - constexpr int value_width() const { + constexpr size_t value_width() const { return value_length() * 8; } - constexpr int registers_per_row() const { + constexpr size_t registers_per_row() const { return (value_length() >= 3) ? 4 : 8; } - constexpr int registers_row_length() const { + constexpr size_t registers_row_length() const { return (registers_per_row() * (value_length() + 1)) - 1; } - constexpr int registers_row_width() const { + constexpr size_t registers_row_width() const { return registers_row_length() * 8; } - constexpr int row_width() const { + constexpr size_t row_width() const { return legend_width() + 8 + registers_row_width(); } - constexpr int rows() const { + constexpr size_t rows() const { return registers_count / registers_per_row(); } }; @@ -185,7 +185,7 @@ class RegistersWidget : public Widget { const RegistersWidgetConfig config; const std::function reader; - static constexpr int row_height = 16; + static constexpr size_t row_height = 16; void draw_legend(const Coord left, Painter& painter); void draw_values(const Coord left, Painter& painter);