mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-10-01 01:26:06 -04:00
Rearrange TPMS app/UI code.
This commit is contained in:
parent
1a280149e2
commit
be328c5f38
@ -28,15 +28,6 @@ using namespace portapack;
|
|||||||
|
|
||||||
#include "string_format.hpp"
|
#include "string_format.hpp"
|
||||||
|
|
||||||
TPMSModel::TPMSModel() {
|
|
||||||
receiver_model.set_baseband_configuration({
|
|
||||||
.mode = 5,
|
|
||||||
.sampling_rate = 2457600,
|
|
||||||
.decimation_factor = 1,
|
|
||||||
});
|
|
||||||
receiver_model.set_baseband_bandwidth(1750000);
|
|
||||||
}
|
|
||||||
|
|
||||||
ManchesterFormatted TPMSModel::on_packet(const TPMSPacketMessage& message) {
|
ManchesterFormatted TPMSModel::on_packet(const TPMSPacketMessage& message) {
|
||||||
const ManchesterDecoder decoder(message.packet, 1);
|
const ManchesterDecoder decoder(message.packet, 1);
|
||||||
const auto hex_formatted = format_manchester(decoder);
|
const auto hex_formatted = format_manchester(decoder);
|
||||||
@ -55,8 +46,10 @@ ManchesterFormatted TPMSModel::on_packet(const TPMSPacketMessage& message) {
|
|||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
void TPMSAppView::on_show() {
|
TPMSAppView::TPMSAppView() {
|
||||||
Console::on_show();
|
add_children({ {
|
||||||
|
&console,
|
||||||
|
} });
|
||||||
|
|
||||||
EventDispatcher::message_map().register_handler(Message::ID::TPMSPacket,
|
EventDispatcher::message_map().register_handler(Message::ID::TPMSPacket,
|
||||||
[this](Message* const p) {
|
[this](Message* const p) {
|
||||||
@ -64,16 +57,26 @@ void TPMSAppView::on_show() {
|
|||||||
this->log(this->model.on_packet(*message));
|
this->log(this->model.on_packet(*message));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
receiver_model.set_baseband_configuration({
|
||||||
|
.mode = 5,
|
||||||
|
.sampling_rate = 2457600,
|
||||||
|
.decimation_factor = 1,
|
||||||
|
});
|
||||||
|
receiver_model.set_baseband_bandwidth(1750000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TPMSAppView::on_hide() {
|
TPMSAppView::~TPMSAppView() {
|
||||||
EventDispatcher::message_map().unregister_handler(Message::ID::TPMSPacket);
|
EventDispatcher::message_map().unregister_handler(Message::ID::TPMSPacket);
|
||||||
|
}
|
||||||
|
|
||||||
Console::on_hide();
|
void TPMSAppView::set_parent_rect(const Rect new_parent_rect) {
|
||||||
|
View::set_parent_rect(new_parent_rect);
|
||||||
|
console.set_parent_rect({ 0, 0, new_parent_rect.width(), new_parent_rect.height() });
|
||||||
}
|
}
|
||||||
|
|
||||||
void TPMSAppView::log(const ManchesterFormatted& formatted) {
|
void TPMSAppView::log(const ManchesterFormatted& formatted) {
|
||||||
writeln(formatted.data.substr(0, 240 / 8));
|
console.writeln(formatted.data.substr(0, 240 / 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace ui */
|
} /* namespace ui */
|
||||||
|
@ -30,8 +30,6 @@
|
|||||||
|
|
||||||
class TPMSModel {
|
class TPMSModel {
|
||||||
public:
|
public:
|
||||||
TPMSModel();
|
|
||||||
|
|
||||||
ManchesterFormatted on_packet(const TPMSPacketMessage& message);
|
ManchesterFormatted on_packet(const TPMSPacketMessage& message);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -40,14 +38,18 @@ private:
|
|||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
class TPMSAppView : public Console {
|
class TPMSAppView : public View {
|
||||||
public:
|
public:
|
||||||
void on_show() override;
|
TPMSAppView();
|
||||||
void on_hide() override;
|
~TPMSAppView();
|
||||||
|
|
||||||
|
void set_parent_rect(const Rect new_parent_rect) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TPMSModel model;
|
TPMSModel model;
|
||||||
|
|
||||||
|
Console console;
|
||||||
|
|
||||||
void log(const ManchesterFormatted& formatted);
|
void log(const ManchesterFormatted& formatted);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user