2015-07-08 15:39:24 +00: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 19:50:06 +00:00
|
|
|
#include "max2837.hpp"
|
2015-12-13 20:34:51 +00:00
|
|
|
#include "portapack.hpp"
|
2015-07-08 15:39:24 +00:00
|
|
|
|
2015-12-14 05:28:39 +00:00
|
|
|
#include <functional>
|
|
|
|
#include <utility>
|
|
|
|
|
2015-07-08 15:39:24 +00:00
|
|
|
namespace ui {
|
|
|
|
|
|
|
|
class DebugMemoryView : public View {
|
|
|
|
public:
|
|
|
|
DebugMemoryView(NavigationView& nav);
|
|
|
|
|
|
|
|
void focus() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
Text text_title {
|
|
|
|
{ 96, 96, 48, 16 },
|
|
|
|
"Memory",
|
|
|
|
};
|
|
|
|
|
2016-02-12 21:51:14 +00:00
|
|
|
Text text_label_m0_core_free {
|
|
|
|
{ 0, 128, 144, 16 },
|
|
|
|
"M0 Core Free Bytes",
|
2015-07-08 15:39:24 +00:00
|
|
|
};
|
|
|
|
|
2016-02-12 21:51:14 +00:00
|
|
|
Text text_label_m0_core_free_value {
|
2015-07-08 15:39:24 +00:00
|
|
|
{ 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-17 06:36:51 +00:00
|
|
|
class TemperatureWidget : public Widget {
|
|
|
|
public:
|
|
|
|
explicit constexpr TemperatureWidget(
|
|
|
|
Rect parent_rect
|
|
|
|
) : Widget { parent_rect }
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void paint(Painter& painter) override;
|
|
|
|
|
|
|
|
private:
|
2015-12-18 04:36:58 +00:00
|
|
|
using sample_t = uint32_t;
|
|
|
|
using temperature_t = int32_t;
|
|
|
|
|
|
|
|
temperature_t temperature(const sample_t sensor_value) const;
|
|
|
|
Coord screen_y(const temperature_t temperature, const Rect& screen_rect) const;
|
|
|
|
|
|
|
|
std::string temperature_str(const temperature_t temperature) const;
|
|
|
|
|
|
|
|
static constexpr temperature_t display_temp_min = 0;
|
|
|
|
static constexpr temperature_t display_temp_scale = 3;
|
2016-01-24 01:53:16 +00:00
|
|
|
static constexpr int bar_width = 1;
|
|
|
|
static constexpr int temp_len = 3;
|
2015-12-17 06:36:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class TemperatureView : public View {
|
|
|
|
public:
|
|
|
|
explicit TemperatureView(NavigationView& nav);
|
|
|
|
|
|
|
|
void focus() override;
|
|
|
|
|
|
|
|
private:
|
2015-12-18 04:36:58 +00:00
|
|
|
Text text_title {
|
|
|
|
{ 76, 16, 240, 16 },
|
|
|
|
"Temperature",
|
|
|
|
};
|
|
|
|
|
2015-12-17 06:36:51 +00:00
|
|
|
TemperatureWidget temperature_widget {
|
2015-12-18 04:36:58 +00:00
|
|
|
{ 0, 40, 240, 180 },
|
2015-12-17 06:36:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Button button_done {
|
2015-12-18 04:36:58 +00:00
|
|
|
{ 72, 264, 96, 24 },
|
2015-12-17 06:36:51 +00:00
|
|
|
"Done"
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2015-12-13 21:22:09 +00:00
|
|
|
struct RegistersWidgetConfig {
|
2016-01-24 01:53:16 +00:00
|
|
|
int registers_count;
|
|
|
|
int legend_length;
|
|
|
|
int value_length;
|
|
|
|
int registers_per_row;
|
2015-12-13 21:22:09 +00:00
|
|
|
|
2016-01-24 01:53:16 +00:00
|
|
|
constexpr int legend_width() const {
|
2015-12-13 21:22:09 +00:00
|
|
|
return legend_length * 8;
|
2015-07-08 15:39:24 +00:00
|
|
|
}
|
|
|
|
|
2016-01-24 01:53:16 +00:00
|
|
|
constexpr int value_width() const {
|
2015-12-13 21:22:09 +00:00
|
|
|
return value_length * 8;
|
|
|
|
}
|
2015-07-08 15:39:24 +00:00
|
|
|
|
2016-01-24 01:53:16 +00:00
|
|
|
constexpr int registers_row_length() const {
|
2015-12-13 21:22:09 +00:00
|
|
|
return (registers_per_row * (value_length + 1)) - 1;
|
|
|
|
}
|
2015-07-08 15:39:24 +00:00
|
|
|
|
2016-01-24 01:53:16 +00:00
|
|
|
constexpr int registers_row_width() const {
|
2015-12-13 21:22:09 +00:00
|
|
|
return registers_row_length() * 8;
|
|
|
|
}
|
2015-07-08 15:39:24 +00:00
|
|
|
|
2016-01-24 01:53:16 +00:00
|
|
|
constexpr int row_width() const {
|
2015-12-14 19:47:43 +00:00
|
|
|
return legend_width() + 8 + registers_row_width();
|
|
|
|
}
|
|
|
|
|
2016-01-24 01:53:16 +00:00
|
|
|
constexpr int rows() const {
|
2015-12-13 21:22:09 +00:00
|
|
|
return registers_count / registers_per_row;
|
|
|
|
}
|
2015-07-08 15:39:24 +00:00
|
|
|
};
|
|
|
|
|
2015-12-13 21:22:09 +00:00
|
|
|
class RegistersWidget : public Widget {
|
2015-12-13 19:50:06 +00:00
|
|
|
public:
|
2015-12-14 05:28:39 +00:00
|
|
|
RegistersWidget(
|
|
|
|
RegistersWidgetConfig&& config,
|
|
|
|
std::function<uint32_t(const size_t register_number)>&& reader
|
2015-12-14 19:30:24 +00:00
|
|
|
);
|
2015-12-13 19:50:06 +00:00
|
|
|
|
|
|
|
void update();
|
|
|
|
|
|
|
|
void paint(Painter& painter) override;
|
|
|
|
|
|
|
|
private:
|
2015-12-13 21:22:09 +00:00
|
|
|
const RegistersWidgetConfig config;
|
2015-12-14 05:28:39 +00:00
|
|
|
const std::function<uint32_t(const size_t register_number)> reader;
|
2015-12-13 19:50:06 +00:00
|
|
|
|
2016-01-24 01:53:16 +00:00
|
|
|
static constexpr int row_height = 16;
|
2015-12-13 19:50:06 +00:00
|
|
|
|
2015-12-14 19:47:43 +00:00
|
|
|
void draw_legend(const Coord left, Painter& painter);
|
|
|
|
void draw_values(const Coord left, Painter& painter);
|
2015-12-13 19:50:06 +00:00
|
|
|
};
|
|
|
|
|
2015-12-13 19:48:39 +00:00
|
|
|
class RegistersView : public View {
|
2015-07-08 15:39:24 +00:00
|
|
|
public:
|
2015-12-14 05:28:39 +00:00
|
|
|
RegistersView(
|
|
|
|
NavigationView& nav,
|
|
|
|
const std::string& title,
|
|
|
|
RegistersWidgetConfig&& config,
|
|
|
|
std::function<uint32_t(const size_t register_number)>&& reader
|
2015-12-14 19:30:24 +00:00
|
|
|
);
|
2015-07-08 15:39:24 +00:00
|
|
|
|
2015-12-14 19:30:24 +00:00
|
|
|
void focus();
|
2015-07-08 15:39:24 +00:00
|
|
|
|
|
|
|
private:
|
2015-12-13 21:22:09 +00:00
|
|
|
Text text_title;
|
2015-07-08 15:39:24 +00:00
|
|
|
|
2015-12-14 05:28:39 +00:00
|
|
|
RegistersWidget registers_widget;
|
2015-07-08 15:39:24 +00:00
|
|
|
|
|
|
|
Button button_update {
|
2015-12-13 20:34:51 +00:00
|
|
|
{ 16, 256, 96, 24 },
|
2015-07-08 15:39:24 +00:00
|
|
|
"Update"
|
|
|
|
};
|
|
|
|
|
|
|
|
Button button_done {
|
2015-12-13 20:34:51 +00:00
|
|
|
{ 128, 256, 96, 24 },
|
2015-07-08 15:39:24 +00:00
|
|
|
"Done"
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2016-02-12 23:05:47 +00:00
|
|
|
class DebugPeripheralsMenuView : public MenuView {
|
|
|
|
public:
|
|
|
|
DebugPeripheralsMenuView(NavigationView& nav);
|
|
|
|
};
|
|
|
|
|
2015-07-08 15:39:24 +00:00
|
|
|
class DebugMenuView : public MenuView {
|
|
|
|
public:
|
|
|
|
DebugMenuView(NavigationView& nav);
|
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace ui */
|
|
|
|
|
|
|
|
#endif/*__UI_DEBUG_H__*/
|