Add Si5351C register view, make more space in all register views.

This commit is contained in:
Jared Boone 2015-12-13 12:34:51 -08:00
parent 5df1665994
commit 74aa2112f4
4 changed files with 91 additions and 5 deletions

View File

@ -27,7 +27,6 @@
#include "hackrf_gpio.hpp"
using namespace hackrf::one;
#include "si5351.hpp"
#include "clock_manager.hpp"
#include "i2c_pp.hpp"

View File

@ -25,6 +25,7 @@
#include "spi_pp.hpp"
#include "wm8731.hpp"
#include "si5351.hpp"
#include "lcd_ili9341.hpp"
#include "radio.hpp"
@ -40,6 +41,8 @@ extern SPI ssp1;
extern wolfson::wm8731::WM8731 audio_codec;
extern si5351::Si5351 clock_generator;
extern ReceiverModel receiver_model;
void init();

View File

@ -155,6 +155,54 @@ void DebugRFFC5072RegistersWidget::draw_values(
}
}
/* DebugSi5351CRegistersWidget ******************************************/
void DebugSi5351CRegistersWidget::update() {
set_dirty();
}
void DebugSi5351CRegistersWidget::paint(Painter& painter) {
draw_legend(painter);
draw_values(painter, portapack::clock_generator);
}
void DebugSi5351CRegistersWidget::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 DebugSi5351CRegistersWidget::draw_values(
Painter& painter,
si5351::Si5351& device
) {
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 auto value = device.read_register(i);
const auto text = to_string_hex(value, value_length);
painter.draw_string(
screen_pos() + offset,
style(),
text
);
}
}
/* DebugMenuView *********************************************************/
DebugMenuView::DebugMenuView(NavigationView& nav) {
@ -164,7 +212,7 @@ DebugMenuView::DebugMenuView(NavigationView& nav) {
{ "SD Card", [&nav](){ nav.push(new NotImplementedView { nav }); } },
{ "RFFC5072", [&nav](){ nav.push(new DebugRFFC5072View { nav }); } },
{ "MAX2837", [&nav](){ nav.push(new DebugMAX2837View { nav }); } },
{ "Si5351C", [&nav](){ nav.push(new NotImplementedView { nav }); } },
{ "Si5351C", [&nav](){ nav.push(new DebugSi5351CView { nav }); } },
{ "WM8731", [&nav](){ nav.push(new NotImplementedView { nav }); } },
} });
on_left = [&nav](){ nav.pop(); };

View File

@ -30,6 +30,7 @@
#include "rffc507x.hpp"
#include "max2837.hpp"
#include "portapack.hpp"
namespace ui {
@ -152,6 +153,40 @@ private:
void draw_values(Painter& painter, const max2837::RegisterMap registers);
};
class DebugSi5351CRegistersWidget : public Widget {
public:
constexpr DebugSi5351CRegistersWidget(
Rect parent_rect
) : Widget { parent_rect }
{
}
void update();
void paint(Painter& painter) override;
static constexpr const char* const name = "Si5351C";
private:
static constexpr size_t registers_count = 96;
static constexpr size_t legend_length = 2;
static constexpr Dim legend_width = legend_length * 8;
static constexpr size_t value_length = 2;
static constexpr Dim value_width = value_length * 8;
static constexpr size_t registers_per_row = 8;
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, si5351::Si5351& device);
};
template<class RegistersWidget>
class RegistersView : public View {
public:
@ -180,22 +215,23 @@ private:
};
RegistersWidget widget_registers {
{ 32, 48, 176, 128 }
{ 0, 48, 240, 192 }
};
Button button_update {
{ 16, 192, 96, 24 },
{ 16, 256, 96, 24 },
"Update"
};
Button button_done {
{ 128, 192, 96, 24 },
{ 128, 256, 96, 24 },
"Done"
};
};
using DebugRFFC5072View = RegistersView<DebugRFFC5072RegistersWidget>;
using DebugMAX2837View = RegistersView<DebugMAX2837RegistersWidget>;
using DebugSi5351CView = RegistersView<DebugSi5351CRegistersWidget>;
class DebugMenuView : public MenuView {
public: