mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-01-11 23:39:29 -05:00
Expose MAX2837 registers, show registers in debug view.
This commit is contained in:
parent
a6fbd1c5ef
commit
c7d49eb190
@ -251,4 +251,8 @@ reg_t MAX2837::temp_sense() {
|
||||
return value;
|
||||
}
|
||||
|
||||
RegisterMap MAX2837::registers() {
|
||||
return _map;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -880,6 +880,8 @@ public:
|
||||
|
||||
reg_t temp_sense();
|
||||
|
||||
RegisterMap registers();
|
||||
|
||||
private:
|
||||
spi::arbiter::Target& _target;
|
||||
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "radio.hpp"
|
||||
|
||||
#include "rf_path.hpp"
|
||||
#include "max2837.hpp"
|
||||
#include "max5864.hpp"
|
||||
#include "baseband_cpld.hpp"
|
||||
#include "baseband_sgpio.hpp"
|
||||
@ -88,7 +87,7 @@ static spi::arbiter::Target ssp1_target_max5864 {
|
||||
|
||||
static rf::path::Path rf_path;
|
||||
rffc507x::RFFC507x first_if;
|
||||
static max2837::MAX2837 second_if { ssp1_target_max2837 };
|
||||
max2837::MAX2837 second_if { ssp1_target_max2837 };
|
||||
static max5864::MAX5864 baseband_codec { ssp1_target_max5864 };
|
||||
static baseband::CPLD baseband_cpld;
|
||||
static baseband::SGPIO baseband_sgpio;
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <cstddef>
|
||||
|
||||
#include "rffc507x.hpp"
|
||||
#include "max2837.hpp"
|
||||
|
||||
namespace radio {
|
||||
|
||||
@ -47,6 +48,7 @@ void streaming_disable();
|
||||
void disable();
|
||||
|
||||
extern rffc507x::RFFC507x first_if;
|
||||
extern max2837::MAX2837 second_if;
|
||||
|
||||
} /* namespace radio */
|
||||
|
||||
|
@ -55,6 +55,53 @@ void DebugMemoryView::focus() {
|
||||
button_done.focus();
|
||||
}
|
||||
|
||||
void DebugMAX2837RegistersWidget::update() {
|
||||
set_dirty();
|
||||
}
|
||||
|
||||
void DebugMAX2837RegistersWidget::paint(Painter& painter) {
|
||||
draw_legend(painter);
|
||||
|
||||
const auto registers = radio::second_if.registers();
|
||||
draw_values(painter, registers);
|
||||
}
|
||||
|
||||
void DebugMAX2837RegistersWidget::draw_legend(Painter& painter) {
|
||||
for(size_t i=0; i<registers_count; i+=registers_per_row) {
|
||||
const Point offset {
|
||||
0, static_cast<Coord>((i / registers_per_row) * row_height)
|
||||
};
|
||||
|
||||
const auto text = to_string_hex(i, legend_length);
|
||||
painter.draw_string(
|
||||
screen_pos() + offset,
|
||||
style(),
|
||||
text
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void DebugMAX2837RegistersWidget::draw_values(
|
||||
Painter& painter,
|
||||
const max2837::RegisterMap registers
|
||||
) {
|
||||
for(size_t i=0; i<registers_count; i++) {
|
||||
const Point offset = {
|
||||
static_cast<Coord>(legend_width + 8 + (i % registers_per_row) * (value_width + 8)),
|
||||
static_cast<Coord>((i / registers_per_row) * row_height)
|
||||
};
|
||||
|
||||
const uint16_t value = registers.w[i];
|
||||
|
||||
const auto text = to_string_hex(value, value_length);
|
||||
painter.draw_string(
|
||||
screen_pos() + offset,
|
||||
style(),
|
||||
text
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void DebugRFFC5072RegistersWidget::update() {
|
||||
set_dirty();
|
||||
}
|
||||
@ -109,7 +156,7 @@ DebugMenuView::DebugMenuView(NavigationView& nav) {
|
||||
{ "Radio State", [&nav](){ nav.push(new NotImplementedView { nav }); } },
|
||||
{ "SD Card", [&nav](){ nav.push(new NotImplementedView { nav }); } },
|
||||
{ "RFFC5072", [&nav](){ nav.push(new DebugRFFC5072View { nav }); } },
|
||||
{ "MAX2837", [&nav](){ nav.push(new NotImplementedView { nav }); } },
|
||||
{ "MAX2837", [&nav](){ nav.push(new DebugMAX2837View { nav }); } },
|
||||
{ "Si5351C", [&nav](){ nav.push(new NotImplementedView { nav }); } },
|
||||
{ "WM8731", [&nav](){ nav.push(new NotImplementedView { nav }); } },
|
||||
} });
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "ui_navigation.hpp"
|
||||
|
||||
#include "rffc507x.hpp"
|
||||
#include "max2837.hpp"
|
||||
|
||||
namespace ui {
|
||||
|
||||
@ -117,6 +118,40 @@ private:
|
||||
void draw_values(Painter& painter, const rffc507x::RegisterMap registers);
|
||||
};
|
||||
|
||||
class DebugMAX2837RegistersWidget : public Widget {
|
||||
public:
|
||||
constexpr DebugMAX2837RegistersWidget(
|
||||
Rect parent_rect
|
||||
) : Widget { parent_rect }
|
||||
{
|
||||
}
|
||||
|
||||
void update();
|
||||
|
||||
void paint(Painter& painter) override;
|
||||
|
||||
static constexpr const char* const name = "MAX2837";
|
||||
|
||||
private:
|
||||
static constexpr size_t registers_count = 32;
|
||||
|
||||
static constexpr size_t legend_length = 2;
|
||||
static constexpr Dim legend_width = legend_length * 8;
|
||||
|
||||
static constexpr size_t value_length = 3;
|
||||
static constexpr Dim value_width = value_length * 8;
|
||||
|
||||
static constexpr size_t registers_per_row = 4;
|
||||
static constexpr size_t registers_row_length = (registers_per_row * (value_length + 1)) - 1;
|
||||
static constexpr Dim registers_row_width = registers_row_length * 8;
|
||||
|
||||
static constexpr size_t rows = registers_count / registers_per_row;
|
||||
static constexpr Dim row_height = 16;
|
||||
|
||||
void draw_legend(Painter& painter);
|
||||
void draw_values(Painter& painter, const max2837::RegisterMap registers);
|
||||
};
|
||||
|
||||
template<class RegistersWidget>
|
||||
class RegistersView : public View {
|
||||
public:
|
||||
@ -160,6 +195,7 @@ private:
|
||||
};
|
||||
|
||||
using DebugRFFC5072View = RegistersView<DebugRFFC5072RegistersWidget>;
|
||||
using DebugMAX2837View = RegistersView<DebugMAX2837RegistersWidget>;
|
||||
|
||||
class DebugMenuView : public MenuView {
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user