Skip to content
This repository has been archived by the owner on Jan 2, 2024. It is now read-only.

Commit

Permalink
RegistersWidget: Fix type warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
jboone committed Aug 8, 2017
1 parent 74ecff1 commit 2033967
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
10 changes: 5 additions & 5 deletions firmware/application/ui_debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<config.registers_count; i+=config.registers_per_row()) {
for(size_t i=0; i<config.registers_count; i+=config.registers_per_row()) {
const Point offset {
left, (i / config.registers_per_row()) * row_height
left, static_cast<int>((i / config.registers_per_row()) * row_height)
};

const auto text = to_string_hex(i, config.legend_length());
Expand All @@ -193,10 +193,10 @@ void RegistersWidget::draw_values(
) {
const auto pos = screen_pos();

for(int i=0; i<config.registers_count; i++) {
for(size_t i=0; i<config.registers_count; i++) {
const Point offset = {
left + config.legend_width() + 8 + (i % config.registers_per_row()) * (config.value_width() + 8),
(i / config.registers_per_row()) * row_height
static_cast<int>(left + config.legend_width() + 8 + (i % config.registers_per_row()) * (config.value_width() + 8)),
static_cast<int>((i / config.registers_per_row()) * row_height)
};

const auto value = reader(i);
Expand Down
24 changes: 12 additions & 12 deletions firmware/application/ui_debug.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
};
Expand All @@ -185,7 +185,7 @@ class RegistersWidget : public Widget {
const RegistersWidgetConfig config;
const std::function<uint32_t(const size_t register_number)> 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);
Expand Down

0 comments on commit 2033967

Please sign in to comment.