2015-07-08 11:39:24 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
|
|
|
*
|
|
|
|
* This file is part of PortaPack.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; see the file COPYING. If not, write to
|
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __UI_DEBUG_H__
|
|
|
|
#define __UI_DEBUG_H__
|
|
|
|
|
|
|
|
#include "ui.hpp"
|
|
|
|
#include "ui_widget.hpp"
|
|
|
|
#include "ui_painter.hpp"
|
|
|
|
#include "ui_menu.hpp"
|
|
|
|
#include "ui_navigation.hpp"
|
|
|
|
|
|
|
|
#include "rffc507x.hpp"
|
2015-12-13 14:50:06 -05:00
|
|
|
#include "max2837.hpp"
|
2015-12-13 15:34:51 -05:00
|
|
|
#include "portapack.hpp"
|
2015-07-08 11:39:24 -04:00
|
|
|
|
2015-12-14 00:28:39 -05:00
|
|
|
#include <functional>
|
|
|
|
#include <utility>
|
|
|
|
|
2015-07-08 11:39:24 -04:00
|
|
|
namespace ui {
|
|
|
|
|
|
|
|
class DebugMemoryView : public View {
|
|
|
|
public:
|
|
|
|
DebugMemoryView(NavigationView& nav);
|
|
|
|
|
|
|
|
void focus() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
Text text_title {
|
|
|
|
{ 96, 96, 48, 16 },
|
|
|
|
"Memory",
|
|
|
|
};
|
|
|
|
|
|
|
|
Text text_label_m0_free {
|
|
|
|
{ 0, 128, 104, 16 },
|
|
|
|
"M0 Free Bytes",
|
|
|
|
};
|
|
|
|
|
|
|
|
Text text_label_m0_free_value {
|
|
|
|
{ 200, 128, 40, 16 },
|
|
|
|
};
|
|
|
|
|
|
|
|
Text text_label_m0_heap_fragmented_free {
|
|
|
|
{ 0, 144, 184, 16 },
|
|
|
|
"M0 Heap Fragmented Free",
|
|
|
|
};
|
|
|
|
|
|
|
|
Text text_label_m0_heap_fragmented_free_value {
|
|
|
|
{ 200, 144, 40, 16 },
|
|
|
|
};
|
|
|
|
|
|
|
|
Text text_label_m0_heap_fragments {
|
|
|
|
{ 0, 160, 136, 16 },
|
|
|
|
"M0 Heap Fragments",
|
|
|
|
};
|
|
|
|
|
|
|
|
Text text_label_m0_heap_fragments_value {
|
|
|
|
{ 200, 160, 40, 16 },
|
|
|
|
};
|
|
|
|
|
|
|
|
Button button_done {
|
|
|
|
{ 72, 192, 96, 24 },
|
|
|
|
"Done"
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2015-12-13 16:22:09 -05:00
|
|
|
struct RegistersWidgetConfig {
|
|
|
|
size_t registers_count;
|
|
|
|
size_t legend_length;
|
|
|
|
size_t value_length;
|
|
|
|
size_t registers_per_row;
|
|
|
|
|
|
|
|
constexpr Dim legend_width() const {
|
|
|
|
return legend_length * 8;
|
2015-07-08 11:39:24 -04:00
|
|
|
}
|
|
|
|
|
2015-12-13 16:22:09 -05:00
|
|
|
constexpr Dim value_width() const {
|
|
|
|
return value_length * 8;
|
|
|
|
}
|
2015-07-08 11:39:24 -04:00
|
|
|
|
2015-12-13 16:22:09 -05:00
|
|
|
constexpr size_t registers_row_length() const {
|
|
|
|
return (registers_per_row * (value_length + 1)) - 1;
|
|
|
|
}
|
2015-07-08 11:39:24 -04:00
|
|
|
|
2015-12-13 16:22:09 -05:00
|
|
|
constexpr Dim registers_row_width() const {
|
|
|
|
return registers_row_length() * 8;
|
|
|
|
}
|
2015-07-08 11:39:24 -04:00
|
|
|
|
2015-12-13 16:22:09 -05:00
|
|
|
constexpr size_t rows() const {
|
|
|
|
return registers_count / registers_per_row;
|
|
|
|
}
|
2015-07-08 11:39:24 -04:00
|
|
|
};
|
|
|
|
|
2015-12-13 16:22:09 -05:00
|
|
|
class RegistersWidget : public Widget {
|
2015-12-13 14:50:06 -05:00
|
|
|
public:
|
2015-12-14 00:28:39 -05:00
|
|
|
RegistersWidget(
|
|
|
|
RegistersWidgetConfig&& config,
|
|
|
|
std::function<uint32_t(const size_t register_number)>&& reader
|
|
|
|
) : Widget { },
|
|
|
|
config(std::move(config)),
|
|
|
|
reader(std::move(reader))
|
2015-12-13 14:50:06 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void update();
|
|
|
|
|
|
|
|
void paint(Painter& painter) override;
|
|
|
|
|
|
|
|
private:
|
2015-12-13 16:22:09 -05:00
|
|
|
const RegistersWidgetConfig config;
|
2015-12-14 00:28:39 -05:00
|
|
|
const std::function<uint32_t(const size_t register_number)> reader;
|
2015-12-13 14:50:06 -05:00
|
|
|
|
|
|
|
static constexpr Dim row_height = 16;
|
|
|
|
|
|
|
|
void draw_legend(Painter& painter);
|
2015-12-13 16:22:09 -05:00
|
|
|
void draw_values(Painter& painter);
|
2015-12-13 14:50:06 -05:00
|
|
|
};
|
|
|
|
|
2015-12-13 14:48:39 -05:00
|
|
|
class RegistersView : public View {
|
2015-07-08 11:39:24 -04:00
|
|
|
public:
|
2015-12-14 00:28:39 -05:00
|
|
|
RegistersView(
|
|
|
|
NavigationView& nav,
|
|
|
|
const std::string& title,
|
|
|
|
RegistersWidgetConfig&& config,
|
|
|
|
std::function<uint32_t(const size_t register_number)>&& reader
|
|
|
|
) : registers_widget { std::move(config), std::move(reader) }
|
|
|
|
{
|
2015-12-13 14:48:39 -05:00
|
|
|
add_children({ {
|
|
|
|
&text_title,
|
2015-12-14 00:28:39 -05:00
|
|
|
®isters_widget,
|
2015-12-13 14:48:39 -05:00
|
|
|
&button_update,
|
|
|
|
&button_done,
|
|
|
|
} });
|
|
|
|
|
|
|
|
button_update.on_select = [this](Button&){
|
2015-12-14 00:28:39 -05:00
|
|
|
this->registers_widget.update();
|
2015-12-13 14:48:39 -05:00
|
|
|
};
|
|
|
|
button_done.on_select = [&nav](Button&){ nav.pop(); };
|
2015-12-13 16:22:09 -05:00
|
|
|
|
2015-12-14 00:28:39 -05:00
|
|
|
registers_widget.set_parent_rect({ 0, 48, 240, 192 });
|
|
|
|
|
2015-12-13 16:22:09 -05:00
|
|
|
text_title.set_parent_rect({
|
|
|
|
static_cast<Coord>((240 - title.size() * 8) / 2), 16,
|
|
|
|
static_cast<Dim>(title.size() * 8), 16
|
|
|
|
});
|
|
|
|
text_title.set(title);
|
2015-12-13 14:48:39 -05:00
|
|
|
}
|
2015-07-08 11:39:24 -04:00
|
|
|
|
2015-12-13 14:48:39 -05:00
|
|
|
void focus() {
|
|
|
|
button_done.focus();
|
|
|
|
}
|
2015-07-08 11:39:24 -04:00
|
|
|
|
|
|
|
private:
|
2015-12-13 16:22:09 -05:00
|
|
|
Text text_title;
|
2015-07-08 11:39:24 -04:00
|
|
|
|
2015-12-14 00:28:39 -05:00
|
|
|
RegistersWidget registers_widget;
|
2015-07-08 11:39:24 -04:00
|
|
|
|
|
|
|
Button button_update {
|
2015-12-13 15:34:51 -05:00
|
|
|
{ 16, 256, 96, 24 },
|
2015-07-08 11:39:24 -04:00
|
|
|
"Update"
|
|
|
|
};
|
|
|
|
|
|
|
|
Button button_done {
|
2015-12-13 15:34:51 -05:00
|
|
|
{ 128, 256, 96, 24 },
|
2015-07-08 11:39:24 -04:00
|
|
|
"Done"
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
class DebugMenuView : public MenuView {
|
|
|
|
public:
|
|
|
|
DebugMenuView(NavigationView& nav);
|
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace ui */
|
|
|
|
|
|
|
|
#endif/*__UI_DEBUG_H__*/
|