mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2026-08-18 21:53:59 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| da21ea7866 | |||
| 2c434946cd | |||
| f3aee44e3b | |||
| 165c190d92 | |||
| 8f9246c1ea | |||
| f1d52ae78f |
@@ -1,58 +1,80 @@
|
||||
<!--
|
||||
👋 Thank you for your contribution!
|
||||
|
||||
⚠️ Before you start, please review our Contributing Guidelines:
|
||||
https://github.com/portapack-mayhem/mayhem-firmware/wiki/Contributing-Guidelines
|
||||
-->
|
||||
|
||||
## Brief description of what you did
|
||||
<!--
|
||||
Replace this line with a description of your changes. What problem does this PR solve? What does it add or fix?
|
||||
Don't forget to describe how maintainers can test your modifications!
|
||||
-->
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Replace this line with a description of your changes. What problem does this PR solve? What does it add or fix?
|
||||
Don't forget to describe how maintainers can test your modifications! -->
|
||||
|
||||
---
|
||||
|
||||
## Proof that your changes work
|
||||
<!--
|
||||
1. PRs without proof will not be merged. Please provide evidence for every section below that applies to your change.
|
||||
2. Trusted contributors: If you have a track record of merged PRs that were properly tested and documented, maintainers may waive one or more of the proof sections below at their discretion. You are still encouraged to include whatever evidence you have, but sections may be marked `N/A — trusted contributor` with a short note.
|
||||
3. First-time contributors must provide full proof. See the Contributing Guidelines(https://github.com/portapack-mayhem/mayhem-firmware/wiki/Contributing-Guidelines) and Trusted Contributors (https://github.com/portapack-mayhem/mayhem-firmware/wiki/Trusted-Contributors) articles for details.
|
||||
-->
|
||||
|
||||
|
||||
|
||||
|
||||
> ⚠️ **PRs without proof will not be merged.** Please provide evidence for every section below that applies to your change.
|
||||
>
|
||||
> 🛈 **Trusted contributors:** If you have a track record of merged PRs that were properly tested and documented, maintainers may waive one or more of the proof sections below at their discretion. You are still encouraged to include whatever evidence you have, but sections may be marked `N/A — trusted contributor` with a short note. First-time contributors must provide full proof. See the [Contributing Guidelines](https://github.com/portapack-mayhem/mayhem-firmware/wiki/Contributing-Guidelines) and [Trusted Contributors](https://github.com/portapack-mayhem/mayhem-firmware/wiki/Trusted-Contributors) articles for details.
|
||||
|
||||
### 🖥️ Proof it compiles
|
||||
|
||||
<!--
|
||||
Attach a log snippet showing a successful build from the final firmware size/space summary in the build output. Example: `Space remaining in flash ROM: 19552 bytes ( 1.9 % )`.
|
||||
Paste log below.
|
||||
-->
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Paste log below -->
|
||||
|
||||
### 📱 Proof of testing on a real device
|
||||
<!--
|
||||
Attach photos, screenshots, or a short video of your changes running on actual PortaPack hardware. Emulator or simulator output is not a substitute for real-device testing.
|
||||
Paste photo / video / screenshot below
|
||||
-->
|
||||
|
||||
|
||||
|
||||
Attach photos, screenshots, or a short video of your changes running on actual PortaPack hardware. **Emulator or simulator output is not a substitute for real-device testing.**
|
||||
|
||||
<!-- Paste photo / video / screenshot below -->
|
||||
|
||||
### 📡 Proof against a real emitter/receiver (if applicable)
|
||||
<!--
|
||||
1. If your PR involves RX/TX, protocol decoding, signal generation, or any RF-related functionality, you **must** demonstrate it working against a real emitter or receiver. Include photos, videos, logs, or waterfall/spectrum screenshots.
|
||||
2. If this section does not apply to your PR, write `N/A` below and briefly explain why.
|
||||
3. Paste RF evidence, or write N/A with a short justification
|
||||
-->
|
||||
|
||||
|
||||
If your PR involves RX/TX, protocol decoding, signal generation, or any RF-related functionality, you **must** demonstrate it working against a real emitter or receiver. Include photos, videos, logs, or waterfall/spectrum screenshots.
|
||||
|
||||
If this section does not apply to your PR, write `N/A` below and briefly explain why.
|
||||
|
||||
<!-- Paste RF evidence, or write N/A with a short justification -->
|
||||
|
||||
---
|
||||
|
||||
## 📚 Wiki documentation commitment
|
||||
|
||||
**By submitting this PR, you acknowledge that once it is merged you are responsible for creating or updating the corresponding page on the [project wiki](https://github.com/portapack-mayhem/mayhem-firmware/wiki).**
|
||||
|
||||
<!--
|
||||
By submitting this PR, you acknowledge that once it is merged you are responsible for creating or updating the corresponding page on the project wiki(https://github.com/portapack-mayhem/mayhem-firmware/wiki).
|
||||
Your wiki article should include:
|
||||
|
||||
- A **screenshot of the main app screen** (strongly recommended)
|
||||
- A clear **description** of what the app does
|
||||
- An explanation of the **controls** and UI elements
|
||||
- Any known **limitations**, quirks, or caveats
|
||||
- A screenshot of the main app screen (strongly recommended)
|
||||
- A clear description of what the app does
|
||||
- An explanation of the controls and UI elements
|
||||
- Any known limitations, quirks, or caveats
|
||||
- Anything else a user should know to use the app effectively (dependencies, required hardware, file formats, etc.)
|
||||
- If you are modifying an existing app, make sure the wiki page reflects your changes.
|
||||
-->
|
||||
|
||||
|
||||
- [ ] I will (or already) create(d) wiki document for my newly added feature
|
||||
|
||||
If you are modifying an existing app, make sure the wiki page reflects your changes.
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -332,6 +332,7 @@ set(CPPSRC
|
||||
${CPLD_H4M_DATA_CPP}
|
||||
${HACKRF_CPLD_DATA_CPP}
|
||||
ui_external_items_menu_loader.cpp
|
||||
view_factory_base.cpp
|
||||
)
|
||||
|
||||
set_source_files_properties(${CPPSRC} PROPERTIES COMPILE_FLAGS -flto) # Add lto flag to the non-external sources only
|
||||
|
||||
@@ -116,7 +116,7 @@ static std::uint64_t get_freq_by_channel_number(uint8_t channel_number) {
|
||||
freq_hz = 2'428'000'000ull + (channel_number - 11) * 2'000'000ull;
|
||||
break;
|
||||
default:
|
||||
freq_hz = UINT64_MAX;
|
||||
freq_hz = 2'402'000'000ull; // Default to channel 37 frequency if invalid channel number
|
||||
}
|
||||
|
||||
return freq_hz;
|
||||
@@ -254,7 +254,7 @@ void BLETxView::send_packet() {
|
||||
}
|
||||
|
||||
void BLETxView::start() {
|
||||
if (file_path.empty()) {
|
||||
if (file_path.empty() || num_packets == 0) {
|
||||
file_error();
|
||||
check_loop.set_value(false);
|
||||
return;
|
||||
@@ -266,6 +266,8 @@ void BLETxView::start() {
|
||||
button_play.set_bitmap(&bitmap_stop);
|
||||
is_running = true;
|
||||
|
||||
advCount = 0;
|
||||
|
||||
send_packet();
|
||||
}
|
||||
|
||||
@@ -296,55 +298,61 @@ void BLETxView::on_timer() {
|
||||
void BLETxView::on_tx_progress(const bool done, uint32_t progress) {
|
||||
// TODO: make use of progress variable
|
||||
(void)progress;
|
||||
if (!is_active() || num_packets == 0) {
|
||||
return;
|
||||
}
|
||||
if (done) {
|
||||
if (is_active()) {
|
||||
transmitter_model.disable();
|
||||
|
||||
if (auto_channel) {
|
||||
switch (advCount) {
|
||||
case 0:
|
||||
channel_number = 37;
|
||||
break;
|
||||
case 1:
|
||||
channel_number = 38;
|
||||
break;
|
||||
case 2:
|
||||
channel_number = 39;
|
||||
break;
|
||||
}
|
||||
|
||||
field_frequency.set_value(get_freq_by_channel_number(channel_number));
|
||||
|
||||
advCount++;
|
||||
if (advCount == 3) {
|
||||
channel_number = 37;
|
||||
packet_counter--;
|
||||
field_frequency.set_value(get_freq_by_channel_number(channel_number));
|
||||
if (packet_counter > 0) packet_counter--;
|
||||
packetDone = true;
|
||||
advCount = 0;
|
||||
} else {
|
||||
channel_number = 37 + advCount;
|
||||
field_frequency.set_value(get_freq_by_channel_number(channel_number));
|
||||
send_packet();
|
||||
}
|
||||
} else if (all_channels) {
|
||||
advCount++;
|
||||
if (advCount == 40) {
|
||||
channel_number = 0;
|
||||
field_frequency.set_value(get_freq_by_channel_number(channel_number));
|
||||
if (packet_counter > 0) packet_counter--;
|
||||
packetDone = true;
|
||||
advCount = 0;
|
||||
} else {
|
||||
channel_number = advCount;
|
||||
field_frequency.set_value(get_freq_by_channel_number(channel_number));
|
||||
send_packet();
|
||||
advCount++;
|
||||
}
|
||||
} else {
|
||||
packet_counter--;
|
||||
if (packet_counter > 0) packet_counter--;
|
||||
packetDone = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Reached end of current packet repeats.
|
||||
if (packet_counter == 0) {
|
||||
// Done sending all packets.
|
||||
if (current_packet == (num_packets - 1)) {
|
||||
current_packet = 0;
|
||||
// Reached end of current packet repeats.
|
||||
if (packet_counter == 0) {
|
||||
// Done sending all packets.
|
||||
current_packet++;
|
||||
if (current_packet >= num_packets) {
|
||||
current_packet = 0;
|
||||
|
||||
// If looping, restart from beginning.
|
||||
if (check_loop.value()) {
|
||||
update_current_packet(packets[current_packet], current_packet);
|
||||
} else {
|
||||
stop();
|
||||
}
|
||||
} else {
|
||||
current_packet++;
|
||||
// If looping, restart from beginning.
|
||||
if (check_loop.value()) {
|
||||
update_current_packet(packets[current_packet], current_packet);
|
||||
} else {
|
||||
stop();
|
||||
}
|
||||
} else {
|
||||
update_current_packet(packets[current_packet], current_packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -385,16 +393,20 @@ BLETxView::BLETxView(NavigationView& nav)
|
||||
};
|
||||
|
||||
options_channel.on_change = [this](size_t, int32_t i) {
|
||||
// If we selected Auto don't do anything and Auto will handle changing.
|
||||
if (i == 40) {
|
||||
auto_channel = true;
|
||||
return;
|
||||
auto_channel = (i == BLT_CHAN_AUTO);
|
||||
all_channels = (i == BLT_CHAN_ALL);
|
||||
|
||||
advCount = 0;
|
||||
|
||||
if (auto_channel) {
|
||||
channel_number = 37;
|
||||
} else if (all_channels) {
|
||||
channel_number = 0;
|
||||
} else {
|
||||
auto_channel = false;
|
||||
channel_number = i;
|
||||
}
|
||||
|
||||
field_frequency.set_value(get_freq_by_channel_number(i));
|
||||
channel_number = i;
|
||||
field_frequency.set_value(get_freq_by_channel_number(channel_number));
|
||||
};
|
||||
|
||||
options_speed.on_change = [this](size_t, int32_t i) {
|
||||
@@ -403,7 +415,7 @@ BLETxView::BLETxView(NavigationView& nav)
|
||||
};
|
||||
|
||||
options_speed.set_selected_index(0);
|
||||
options_channel.set_selected_index(3);
|
||||
options_channel.set_by_value(BLT_CHAN_AUTO);
|
||||
|
||||
check_rand_mac.set_value(false);
|
||||
check_rand_mac.on_select = [this](Checkbox&, bool v) {
|
||||
@@ -413,8 +425,7 @@ BLETxView::BLETxView(NavigationView& nav)
|
||||
button_open.on_select = [this](Button&) {
|
||||
auto open_view = nav_.push<FileLoadView>(".TXT");
|
||||
open_view->on_changed = [this](std::filesystem::path new_file_path) {
|
||||
on_file_changed(new_file_path);
|
||||
|
||||
this->on_file_changed(new_file_path);
|
||||
nav_.set_on_pop([this]() { button_play.focus(); });
|
||||
};
|
||||
};
|
||||
@@ -427,7 +438,7 @@ BLETxView::BLETxView(NavigationView& nav)
|
||||
64,
|
||||
ENTER_KEYBOARD_MODE_ALPHA,
|
||||
[this](std::string& buffer) {
|
||||
on_save_file(buffer);
|
||||
this->on_save_file(buffer);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -506,10 +517,10 @@ void BLETxView::on_file_changed(const fs::path& new_file_path) {
|
||||
}
|
||||
|
||||
do {
|
||||
readUntil(data_file, packets[num_packets].macAddress, mac_address_size_str, ' ');
|
||||
readUntil(data_file, packets[num_packets].advertisementData, max_packet_size_str, ' ');
|
||||
readUntil(data_file, packets[num_packets].packetType, max_packet_type_str, ' ');
|
||||
readUntil(data_file, packets[num_packets].packetCount, max_packet_repeat_str, '\n');
|
||||
readUntil(data_file, packets[num_packets].macAddress, sizeof(packets[num_packets].macAddress), ' ');
|
||||
readUntil(data_file, packets[num_packets].advertisementData, sizeof(packets[num_packets].advertisementData), ' ');
|
||||
readUntil(data_file, packets[num_packets].packetType, sizeof(packets[num_packets].packetType), ' ');
|
||||
readUntil(data_file, packets[num_packets].packetCount, sizeof(packets[num_packets].packetCount), '\n');
|
||||
|
||||
uint64_t macAddressSize = strlen(packets[num_packets].macAddress);
|
||||
uint64_t advertisementDataSize = strlen(packets[num_packets].advertisementData);
|
||||
@@ -542,10 +553,8 @@ void BLETxView::on_file_changed(const fs::path& new_file_path) {
|
||||
num_packets++;
|
||||
|
||||
} while (num_packets < max_num_packets);
|
||||
|
||||
update_current_packet(packets[0], 0);
|
||||
|
||||
data_file.close();
|
||||
update_current_packet(packets[0], 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -570,6 +579,9 @@ void BLETxView::update_current_packet(BLETxPacket packet, uint32_t currentIndex)
|
||||
|
||||
std::vector<std::string> strings = splitIntoStrings(packet.advertisementData);
|
||||
|
||||
packet_counter = packet.packet_count;
|
||||
current_packet = currentIndex;
|
||||
|
||||
text_packet_index.set(to_string_dec_uint(current_packet));
|
||||
|
||||
text_packets_sent.set(to_string_dec_uint(packet.packet_count));
|
||||
@@ -578,9 +590,6 @@ void BLETxView::update_current_packet(BLETxPacket packet, uint32_t currentIndex)
|
||||
|
||||
progressbar.set_max(packet.packet_count);
|
||||
|
||||
packet_counter = packet.packet_count;
|
||||
current_packet = currentIndex;
|
||||
|
||||
dataFile.create(dataTempFilePath);
|
||||
|
||||
for (const std::string& str : strings) {
|
||||
|
||||
@@ -45,6 +45,9 @@
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
#define BLT_CHAN_AUTO 40
|
||||
#define BLT_CHAN_ALL 41
|
||||
|
||||
class BLELoggerTx {
|
||||
public:
|
||||
Optional<File::Error> append(const std::filesystem::path& filename) {
|
||||
@@ -94,7 +97,7 @@ struct BLETxPacket {
|
||||
char advertisementData[63];
|
||||
char packetCount[11];
|
||||
char packetType[17];
|
||||
uint32_t packet_count;
|
||||
uint32_t packet_count; // repeat the same packet count times
|
||||
PKT_TYPE pduType;
|
||||
};
|
||||
|
||||
@@ -145,6 +148,7 @@ class BLETxView : public View {
|
||||
std::filesystem::path packet_save_path{bletx_dir / u"BLETX_????.TXT"};
|
||||
uint8_t channel_number = 37;
|
||||
bool auto_channel = false;
|
||||
bool all_channels = false;
|
||||
|
||||
char randomMac[13] = "010203040506";
|
||||
|
||||
@@ -156,10 +160,10 @@ class BLETxView : public View {
|
||||
int16_t auto_channel_period{6};
|
||||
|
||||
bool repeatLoop = false;
|
||||
uint32_t packet_counter{0};
|
||||
uint32_t num_packets{0};
|
||||
uint32_t current_packet{0};
|
||||
uint8_t packetTxCount{0};
|
||||
uint32_t packet_counter{0}; // the counter (decr) of the actual packet as it can be sent multiple times
|
||||
uint32_t num_packets{0}; // how many packets in the file
|
||||
uint32_t current_packet{0}; // the actual packet's num, i'm sending if i have multiple packets
|
||||
uint8_t packetTxCount{0}; // not used
|
||||
bool packetDone = false;
|
||||
bool random_mac = false;
|
||||
bool file_override = false;
|
||||
@@ -241,10 +245,48 @@ class BLETxView : public View {
|
||||
OptionsField options_channel{
|
||||
{11 * 8, 6 * 8},
|
||||
5,
|
||||
{{"Ch.37 ", 37},
|
||||
{{"Ch.0", 0},
|
||||
{"Ch.1", 1},
|
||||
{"Ch.2", 2},
|
||||
{"Ch.3", 3},
|
||||
{"Ch.4", 4},
|
||||
{"Ch.5", 5},
|
||||
{"Ch.6", 6},
|
||||
{"Ch.7", 7},
|
||||
{"Ch.8", 8},
|
||||
{"Ch.9", 9},
|
||||
{"Ch.10", 10},
|
||||
{"Ch.11", 11},
|
||||
{"Ch.12", 12},
|
||||
{"Ch.13", 13},
|
||||
{"Ch.14", 14},
|
||||
{"Ch.15", 15},
|
||||
{"Ch.16", 16},
|
||||
{"Ch.17", 17},
|
||||
{"Ch.18", 18},
|
||||
{"Ch.19", 19},
|
||||
{"Ch.20", 20},
|
||||
{"Ch.21", 21},
|
||||
{"Ch.22", 22},
|
||||
{"Ch.23", 23},
|
||||
{"Ch.24", 24},
|
||||
{"Ch.25", 25},
|
||||
{"Ch.26", 26},
|
||||
{"Ch.27", 27},
|
||||
{"Ch.28", 28},
|
||||
{"Ch.29", 29},
|
||||
{"Ch.30", 30},
|
||||
{"Ch.31", 31},
|
||||
{"Ch.32", 32},
|
||||
{"Ch.33", 33},
|
||||
{"Ch.34", 34},
|
||||
{"Ch.35", 35},
|
||||
{"Ch.36", 36},
|
||||
{"Ch.37", 37},
|
||||
{"Ch.38", 38},
|
||||
{"Ch.39", 39},
|
||||
{"Auto", 40}}};
|
||||
{"Auto", BLT_CHAN_AUTO},
|
||||
{"All", BLT_CHAN_ALL}}};
|
||||
|
||||
OptionsField options_adv_type{
|
||||
{17 * 8, 6 * 8},
|
||||
|
||||
@@ -103,7 +103,8 @@ DfuMenu2::DfuMenu2(NavigationView& nav)
|
||||
&text_info_line_8,
|
||||
&text_info_line_9,
|
||||
&text_info_line_10,
|
||||
&text_info_line_11});
|
||||
&text_info_line_11,
|
||||
&text_info_line_12});
|
||||
}
|
||||
|
||||
void DfuMenu2::paint(Painter& painter) {
|
||||
@@ -118,9 +119,12 @@ void DfuMenu2::paint(Painter& painter) {
|
||||
text_info_line_9.set(to_string_dec_uint(portapack::transmitter_model.target_frequency(), 10));
|
||||
text_info_line_10.set(to_string_dec_uint(portapack::transmitter_model.baseband_bandwidth(), 10));
|
||||
text_info_line_11.set(to_string_dec_uint(portapack::transmitter_model.sampling_rate(), 10));
|
||||
text_info_line_12.set(std::string("M") + (radio::get_mixer_invert() ? "Y" : "N") +
|
||||
" B" + (radio::get_baseband_invert() ? "Y" : "N") +
|
||||
" IQ" + ((radio::get_mixer_invert() ^ radio::get_baseband_invert()) ? "Y" : "N"));
|
||||
|
||||
constexpr auto margin = 5;
|
||||
constexpr auto lines = 11 + 2;
|
||||
constexpr auto lines = 12 + 2;
|
||||
|
||||
painter.fill_rectangle(
|
||||
{{5 * CHARACTER_WIDTH - margin, 3 * LINE_HEIGHT - margin},
|
||||
|
||||
@@ -96,6 +96,7 @@ class DfuMenu2 : public View {
|
||||
{{5 * CHARACTER_WIDTH, 13 * LINE_HEIGHT}, "TX Freq:", Theme::getInstance()->fg_darkcyan->foreground},
|
||||
{{5 * CHARACTER_WIDTH, 14 * LINE_HEIGHT}, "TX BW:", Theme::getInstance()->fg_darkcyan->foreground},
|
||||
{{5 * CHARACTER_WIDTH, 15 * LINE_HEIGHT}, "TX SampR:", Theme::getInstance()->fg_darkcyan->foreground},
|
||||
{{5 * CHARACTER_WIDTH, 16 * LINE_HEIGHT}, "IQ Inv:", Theme::getInstance()->fg_darkcyan->foreground},
|
||||
};
|
||||
|
||||
Text text_info_line_1{{14 * CHARACTER_WIDTH, 5 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT}, ""};
|
||||
@@ -109,6 +110,7 @@ class DfuMenu2 : public View {
|
||||
Text text_info_line_9{{14 * CHARACTER_WIDTH, 13 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT}, ""};
|
||||
Text text_info_line_10{{14 * CHARACTER_WIDTH, 14 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT}, ""};
|
||||
Text text_info_line_11{{14 * CHARACTER_WIDTH, 15 * LINE_HEIGHT, 10 * CHARACTER_WIDTH, 1 * LINE_HEIGHT}, ""};
|
||||
Text text_info_line_12{{(14 + 1) * CHARACTER_WIDTH, 16 * LINE_HEIGHT, (10 - 1) * CHARACTER_WIDTH, 1 * LINE_HEIGHT}, ""};
|
||||
};
|
||||
|
||||
} /* namespace ui */
|
||||
|
||||
@@ -404,6 +404,14 @@ void set_antenna_bias(const bool on) {
|
||||
#endif
|
||||
}
|
||||
|
||||
bool get_mixer_invert() {
|
||||
return mixer_invert;
|
||||
}
|
||||
|
||||
bool get_baseband_invert() {
|
||||
return baseband_invert;
|
||||
}
|
||||
|
||||
void set_tx_max283x_iq_phase_calibration(const size_t v) {
|
||||
second_if->set_tx_LO_iq_phase_calibration(v);
|
||||
}
|
||||
|
||||
@@ -54,6 +54,8 @@ void set_baseband_filter_bandwidth_rx(const uint32_t bandwidth_minimum);
|
||||
void set_baseband_filter_bandwidth_tx(const uint32_t bandwidth_minimum);
|
||||
void set_baseband_rate(const uint32_t rate);
|
||||
void set_antenna_bias(const bool on);
|
||||
bool get_mixer_invert();
|
||||
bool get_baseband_invert();
|
||||
void set_tx_max283x_iq_phase_calibration(const size_t v);
|
||||
void set_rx_max283x_iq_phase_calibration(const size_t v);
|
||||
|
||||
|
||||
@@ -72,19 +72,31 @@ void TransmitterModel::set_channel_bandwidth(uint32_t v) {
|
||||
}
|
||||
|
||||
uint8_t TransmitterModel::tx_gain() const {
|
||||
if (persistent_memory::config_tx_disabled()) {
|
||||
return 0;
|
||||
}
|
||||
return std::min(settings_.tx_gain_db, portapack::persistent_memory::config_tx_gain_max_db());
|
||||
}
|
||||
|
||||
void TransmitterModel::set_tx_gain(uint8_t v_db) {
|
||||
settings_.tx_gain_db = v_db;
|
||||
uint8_t newgain = v_db;
|
||||
if (persistent_memory::config_tx_disabled()) {
|
||||
newgain = 0;
|
||||
} else if (v_db > portapack::persistent_memory::config_tx_gain_max_db()) {
|
||||
newgain = portapack::persistent_memory::config_tx_gain_max_db();
|
||||
}
|
||||
settings_.tx_gain_db = newgain;
|
||||
update_tx_gain();
|
||||
}
|
||||
|
||||
bool TransmitterModel::rf_amp() const {
|
||||
return settings_.rf_amp && !portapack::persistent_memory::config_tx_amp_disabled();
|
||||
return settings_.rf_amp && !portapack::persistent_memory::config_tx_amp_disabled() && !portapack::persistent_memory::config_tx_disabled();
|
||||
}
|
||||
|
||||
void TransmitterModel::set_rf_amp(bool enabled) {
|
||||
if (enabled && (portapack::persistent_memory::config_tx_amp_disabled() || portapack::persistent_memory::config_tx_disabled())) {
|
||||
return;
|
||||
}
|
||||
settings_.rf_amp = enabled;
|
||||
update_rf_amp();
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include "rtc_time.hpp"
|
||||
#include "sd_card.hpp"
|
||||
#include <algorithm>
|
||||
#include "ui_external_items_menu_loader.hpp"
|
||||
|
||||
namespace ui {
|
||||
|
||||
@@ -61,7 +60,6 @@ BtnGridView::BtnGridView(
|
||||
}
|
||||
|
||||
BtnGridView::~BtnGridView() {
|
||||
ExternalItemsMenuLoader::unload_external_items();
|
||||
}
|
||||
|
||||
void BtnGridView::set_max_rows(int rows) {
|
||||
@@ -89,7 +87,6 @@ void BtnGridView::set_parent_rect(const Rect new_parent_rect) {
|
||||
remove_child(item.get());
|
||||
|
||||
menu_item_views.clear();
|
||||
menu_item_views.shrink_to_fit();
|
||||
}
|
||||
|
||||
button_w = screen_width / rows_;
|
||||
@@ -138,17 +135,15 @@ void BtnGridView::set_arrow_down_enabled(bool enabled) {
|
||||
};
|
||||
|
||||
void BtnGridView::clear() {
|
||||
// clear vector and release memory, not using swap since it's causing capture to glitch/fault
|
||||
// clear vector, not using swap since it's causing capture to glitch/fault
|
||||
menu_items.clear();
|
||||
menu_items.shrink_to_fit();
|
||||
|
||||
// TODO(u-foka): Clean up my mess, move this somewhere to clear memory when the view is not visible, but not to be confused with clearing the menu items...
|
||||
for (auto& item : menu_item_views)
|
||||
remove_child(item.get());
|
||||
|
||||
// clear vector and release memory, not using swap since it's causing capture to glitch/fault
|
||||
// clear vector, not using swap since it's causing capture to glitch/fault
|
||||
menu_item_views.clear();
|
||||
menu_item_views.shrink_to_fit();
|
||||
}
|
||||
|
||||
void BtnGridView::add_items(std::initializer_list<GridItem> new_items, bool inhibit_update) {
|
||||
|
||||
@@ -39,7 +39,13 @@ using namespace portapack;
|
||||
namespace ui {
|
||||
|
||||
/* Gets a style indicating total TX gain level. */
|
||||
static const Style* get_style_for_gain(uint8_t tot_gain) {
|
||||
static const Style* get_style_for_gain(uint8_t tot_gain, uint8_t gain) {
|
||||
if (persistent_memory::config_tx_disabled()) {
|
||||
return Theme::getInstance()->fg_dark; // disabled color
|
||||
}
|
||||
if (gain == persistent_memory::config_tx_gain_max_db() && gain != max2837::tx::gain_db_range.maximum) { // only if limited
|
||||
return Theme::getInstance()->fg_cyan;
|
||||
}
|
||||
if (tot_gain > POWER_THRESHOLD_HIGH) return Theme::getInstance()->fg_red;
|
||||
|
||||
if (tot_gain > POWER_THRESHOLD_MED)
|
||||
@@ -50,7 +56,21 @@ static const Style* get_style_for_gain(uint8_t tot_gain) {
|
||||
|
||||
return nullptr; // Uses default.
|
||||
}
|
||||
static const Style* get_style_for_amp(uint8_t tot_gain) {
|
||||
if (persistent_memory::config_tx_disabled() || persistent_memory::config_tx_amp_disabled()) {
|
||||
return Theme::getInstance()->fg_dark; // disabled color
|
||||
}
|
||||
|
||||
if (tot_gain > POWER_THRESHOLD_HIGH) return Theme::getInstance()->fg_red;
|
||||
|
||||
if (tot_gain > POWER_THRESHOLD_MED)
|
||||
return Theme::getInstance()->fg_orange;
|
||||
|
||||
if (tot_gain > POWER_THRESHOLD_LOW)
|
||||
return Theme::getInstance()->fg_yellow;
|
||||
|
||||
return nullptr; // Uses default.
|
||||
}
|
||||
/* TransmitterView *******************************************************/
|
||||
|
||||
void TransmitterView::paint(Painter& painter) {
|
||||
@@ -95,12 +115,12 @@ void TransmitterView::on_tx_amp_changed(bool rf_amp) {
|
||||
|
||||
void TransmitterView::update_gainlevel_styles() {
|
||||
int8_t tot_gain = transmitter_model.tx_gain() + (transmitter_model.rf_amp() ? 14 : 0);
|
||||
auto style = get_style_for_gain(tot_gain);
|
||||
|
||||
auto style = get_style_for_gain(tot_gain, transmitter_model.tx_gain());
|
||||
auto styleamp = get_style_for_amp(tot_gain);
|
||||
field_gain.set_style(style);
|
||||
text_gain.set_style(style);
|
||||
field_amp.set_style(style);
|
||||
text_amp.set_style(style);
|
||||
field_amp.set_style(styleamp);
|
||||
text_amp.set_style(styleamp);
|
||||
}
|
||||
|
||||
void TransmitterView::set_transmitting(const bool transmitting) {
|
||||
@@ -199,6 +219,24 @@ TransmitterView::TransmitterView(
|
||||
on_start();
|
||||
}
|
||||
};
|
||||
|
||||
if (persistent_memory::config_tx_amp_disabled() || persistent_memory::config_tx_disabled()) { // amp disabled / tx disabled
|
||||
field_amp.set_value(0);
|
||||
field_amp.set_focusable(false);
|
||||
}
|
||||
|
||||
if (persistent_memory::config_tx_disabled()) { // tx disabled
|
||||
field_gain.set_value(0);
|
||||
field_gain.set_focusable(false);
|
||||
} else {
|
||||
if (persistent_memory::config_tx_gain_max_db() < max2837::tx::gain_db_range.maximum) {
|
||||
field_gain.set_range(max2837::tx::gain_db_range.minimum, persistent_memory::config_tx_gain_max_db());
|
||||
if (field_gain.value() > persistent_memory::config_tx_gain_max_db()) {
|
||||
field_gain.set_value(persistent_memory::config_tx_gain_max_db());
|
||||
}
|
||||
}
|
||||
}
|
||||
update_gainlevel_styles();
|
||||
}
|
||||
|
||||
TransmitterView::~TransmitterView() {
|
||||
@@ -252,16 +290,34 @@ TransmitterView2::TransmitterView2(Point pos, bool short_ui) {
|
||||
update_gainlevel_styles();
|
||||
};
|
||||
|
||||
if (persistent_memory::config_tx_amp_disabled() || persistent_memory::config_tx_disabled()) { // amp disabled / tx disabled
|
||||
field_amp.set_value(0);
|
||||
field_amp.set_focusable(false);
|
||||
}
|
||||
|
||||
if (persistent_memory::config_tx_disabled()) { // tx disabled
|
||||
field_gain.set_value(0);
|
||||
field_gain.set_focusable(false);
|
||||
} else {
|
||||
if (persistent_memory::config_tx_gain_max_db() < max2837::tx::gain_db_range.maximum) {
|
||||
field_gain.set_range(max2837::tx::gain_db_range.minimum, persistent_memory::config_tx_gain_max_db());
|
||||
if (field_gain.value() > persistent_memory::config_tx_gain_max_db()) {
|
||||
field_gain.set_value(persistent_memory::config_tx_gain_max_db());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
update_gainlevel_styles();
|
||||
}
|
||||
|
||||
void TransmitterView2::update_gainlevel_styles() {
|
||||
int8_t tot_gain = transmitter_model.tx_gain() + (transmitter_model.rf_amp() ? 14 : 0);
|
||||
auto style = get_style_for_gain(tot_gain);
|
||||
auto style = get_style_for_gain(tot_gain, transmitter_model.tx_gain());
|
||||
auto styleamp = get_style_for_amp(tot_gain);
|
||||
|
||||
text_labels.set_style(style);
|
||||
field_gain.set_style(style);
|
||||
field_amp.set_style(style);
|
||||
field_amp.set_style(styleamp);
|
||||
}
|
||||
|
||||
} /* namespace ui */
|
||||
@@ -9,13 +9,7 @@
|
||||
|
||||
namespace ui {
|
||||
|
||||
/* static */ std::vector<std::unique_ptr<DynamicBitmap<16, 16>>> ExternalItemsMenuLoader::bitmaps;
|
||||
|
||||
// to save ram when entering an app
|
||||
void ExternalItemsMenuLoader::unload_external_items() {
|
||||
bitmaps.clear();
|
||||
bitmaps.shrink_to_fit();
|
||||
}
|
||||
/* static */ std::vector<DynamicBitmap<16, 16>> ExternalItemsMenuLoader::bitmaps;
|
||||
|
||||
// iterates over all possible ext apps-s, and if it is runnable on the current system, it'll call the callback, and pass minimal info. used to print to console, and for autostart setting's app list. where the minimal info is enough
|
||||
// please keep in sync with load_external_items
|
||||
@@ -103,9 +97,8 @@ void ExternalItemsMenuLoader::unload_external_items() {
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<ExternalItemsMenuLoader::GridItemEx> ExternalItemsMenuLoader::load_external_items(app_location_t app_location, NavigationView& nav) {
|
||||
/* static */ std::vector<ExternalItemsMenuLoader::GridItemEx> ExternalItemsMenuLoader::load_external_items(app_location_t app_location, NavigationView& nav) {
|
||||
bitmaps.clear();
|
||||
bitmaps.shrink_to_fit();
|
||||
|
||||
std::vector<GridItemEx> external_apps;
|
||||
|
||||
@@ -133,8 +126,8 @@ std::vector<ExternalItemsMenuLoader::GridItemEx> ExternalItemsMenuLoader::load_e
|
||||
|
||||
gridItem.color = Color((uint16_t)appInfo->icon_color);
|
||||
|
||||
auto dyn_bmp = std::make_unique<DynamicBitmap<16, 16>>(appInfo->bitmap_data);
|
||||
gridItem.bitmap = dyn_bmp->bitmap();
|
||||
auto dyn_bmp = DynamicBitmap<16, 16>{appInfo->bitmap_data};
|
||||
gridItem.bitmap = dyn_bmp.bitmap();
|
||||
bitmaps.push_back(std::move(dyn_bmp));
|
||||
|
||||
gridItem.on_select = [&nav, appInfo, i]() {
|
||||
@@ -211,8 +204,8 @@ std::vector<ExternalItemsMenuLoader::GridItemEx> ExternalItemsMenuLoader::load_e
|
||||
if (versionMatches) {
|
||||
gridItem.color = Color((uint16_t)application_information.icon_color);
|
||||
|
||||
auto dyn_bmp = std::make_unique<DynamicBitmap<16, 16>>(application_information.bitmap_data);
|
||||
gridItem.bitmap = dyn_bmp->bitmap();
|
||||
auto dyn_bmp = DynamicBitmap<16, 16>{application_information.bitmap_data};
|
||||
gridItem.bitmap = dyn_bmp.bitmap();
|
||||
bitmaps.push_back(std::move(dyn_bmp));
|
||||
|
||||
gridItem.on_select = [&nav, app_location, filePath]() {
|
||||
@@ -262,8 +255,8 @@ std::vector<ExternalItemsMenuLoader::GridItemEx> ExternalItemsMenuLoader::load_e
|
||||
|
||||
gridItem.color = Color((uint16_t)application_information.icon_color);
|
||||
|
||||
auto dyn_bmp = std::make_unique<DynamicBitmap<16, 16>>(application_information.bitmap_data);
|
||||
gridItem.bitmap = dyn_bmp->bitmap();
|
||||
auto dyn_bmp = DynamicBitmap<16, 16>{application_information.bitmap_data};
|
||||
gridItem.bitmap = dyn_bmp.bitmap();
|
||||
bitmaps.push_back(std::move(dyn_bmp));
|
||||
|
||||
gridItem.on_select = [&nav, app_location, filePath]() {
|
||||
@@ -357,8 +350,6 @@ std::vector<ExternalItemsMenuLoader::GridItemEx> ExternalItemsMenuLoader::load_e
|
||||
if (checksum != EXT_APP_EXPECTED_CHECKSUM)
|
||||
return false;
|
||||
|
||||
nav.pop();
|
||||
nav.set_last_menu_went_deeper(true);
|
||||
application_information.externalAppEntry(nav);
|
||||
return true;
|
||||
}
|
||||
@@ -395,8 +386,7 @@ std::vector<ExternalItemsMenuLoader::GridItemEx> ExternalItemsMenuLoader::load_e
|
||||
}
|
||||
}
|
||||
|
||||
nav.set_last_menu_went_deeper(true);
|
||||
nav.replace<StandaloneView>(app_image);
|
||||
nav.push<StandaloneView>(app_image);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -410,8 +400,7 @@ std::vector<ExternalItemsMenuLoader::GridItemEx> ExternalItemsMenuLoader::load_e
|
||||
}
|
||||
}
|
||||
|
||||
nav.set_last_menu_went_deeper(true);
|
||||
nav.replace<StandaloneView>(app_image);
|
||||
nav.push<StandaloneView>(app_image);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,38 +33,24 @@
|
||||
#define EXT_APP_EXPECTED_CHECKSUM 0x00000000
|
||||
|
||||
namespace ui {
|
||||
|
||||
template <size_t Width, size_t Height>
|
||||
class DynamicBitmap {
|
||||
public:
|
||||
static constexpr size_t buffer_size = Width * Height / (sizeof(uint8_t) * 8);
|
||||
static constexpr size_t buffer_size = Width * Height / (sizeof(uint8_t) * 8); // one bit per pixel
|
||||
|
||||
// Main constructor
|
||||
DynamicBitmap(const uint8_t data[buffer_size])
|
||||
: _bitmap{{Width, Height}, _buffer.data()} {
|
||||
std::memcpy(_buffer.data(), data, buffer_size);
|
||||
: _buffer(buffer_size, 0),
|
||||
_bitmap{new Bitmap{{Width, Height}, &_buffer[0]}} {
|
||||
memcpy(&_buffer[0], data, buffer_size);
|
||||
}
|
||||
|
||||
DynamicBitmap(const DynamicBitmap& other)
|
||||
: _buffer(other._buffer),
|
||||
_bitmap{{Width, Height}, _buffer.data()} {}
|
||||
|
||||
DynamicBitmap(DynamicBitmap&& other) noexcept
|
||||
: _buffer(std::move(other._buffer)),
|
||||
_bitmap{{Width, Height}, _buffer.data()} {}
|
||||
|
||||
DynamicBitmap& operator=(const DynamicBitmap& other) = delete;
|
||||
DynamicBitmap& operator=(DynamicBitmap&& other) noexcept = delete;
|
||||
|
||||
// Destructor (Default is fine, no heap memory to free manually)
|
||||
~DynamicBitmap() = default;
|
||||
|
||||
const Bitmap* bitmap() const { return &_bitmap; }
|
||||
const Bitmap* bitmap() { return _bitmap.get(); }
|
||||
|
||||
private:
|
||||
// Order matters: _buffer must be declared before _bitmap
|
||||
// so it is initialized first and its .data() pointer is valid.
|
||||
std::array<uint8_t, buffer_size> _buffer{};
|
||||
Bitmap _bitmap{};
|
||||
// Allocating both members so the class is movable without invalidation.
|
||||
std::vector<uint8_t> _buffer;
|
||||
std::unique_ptr<Bitmap> _bitmap;
|
||||
};
|
||||
|
||||
class ExternalItemsMenuLoader {
|
||||
@@ -79,10 +65,9 @@ class ExternalItemsMenuLoader {
|
||||
static bool run_standalone_app(ui::NavigationView&, std::filesystem::path);
|
||||
static bool run_module_app(ui::NavigationView&, uint8_t*, size_t);
|
||||
static void load_all_external_items_callback(std::function<void(AppInfoConsole&)> callback, bool module_included = false);
|
||||
static void unload_external_items();
|
||||
|
||||
private:
|
||||
static std::vector<std::unique_ptr<DynamicBitmap<16, 16>>> bitmaps;
|
||||
static std::vector<DynamicBitmap<16, 16>> bitmaps;
|
||||
};
|
||||
|
||||
} // namespace ui
|
||||
|
||||
@@ -85,47 +85,44 @@ namespace ui {
|
||||
// TODO(u-foka): Check consistency of command names (where we add rx/tx postfix)
|
||||
const NavigationView::AppList NavigationView::appList = {
|
||||
/* HOME ******************************************************************/
|
||||
{nullptr, "Receive", HOME, Color::cyan(), &bitmap_icon_receivers, [](NavigationView& nav) -> std::unique_ptr<View> { return std::make_unique<ReceiversMenuView>(nav); }},
|
||||
{nullptr, "Transmit", HOME, Color::cyan(), &bitmap_icon_transmit, [](NavigationView& nav) -> std::unique_ptr<View> { return std::make_unique<TransmittersMenuView>(nav); }},
|
||||
{nullptr, "Transceiver", HOME, Color::cyan(), &bitmap_icon_transceivers, [](NavigationView& nav) -> std::unique_ptr<View> { return std::make_unique<TransceiversMenuView>(nav); }},
|
||||
{"recon", "Recon", HOME, Color::green(), &bitmap_icon_scanner, [](NavigationView& nav) -> std::unique_ptr<View> { return std::make_unique<ReconView>(nav); }},
|
||||
{"capture", "Capture", HOME, Color::red(), &bitmap_icon_capture, [](NavigationView& nav) -> std::unique_ptr<View> { return std::make_unique<CaptureAppView>(nav); }},
|
||||
{"replay", "Replay", HOME, Color::green(), &bitmap_icon_replay, [](NavigationView& nav) -> std::unique_ptr<View> { return std::make_unique<PlaylistView>(nav); }},
|
||||
{"lookingglass", "Looking Glass", HOME, Color::green(), &bitmap_icon_looking, [](NavigationView& nav) -> std::unique_ptr<View> { return std::make_unique<GlassView>(nav); }},
|
||||
{nullptr, "Utilities", HOME, Color::cyan(), &bitmap_icon_utilities, [](NavigationView& nav) -> std::unique_ptr<View> { return std::make_unique<UtilitiesMenuView>(nav); }},
|
||||
{nullptr, "Games", HOME, Color::cyan(), &bitmap_icon_games, [](NavigationView& nav) -> std::unique_ptr<View> { return std::make_unique<GamesMenuView>(nav); }},
|
||||
{nullptr, "Settings", HOME, Color::cyan(), &bitmap_icon_setup, [](NavigationView& nav) -> std::unique_ptr<View> { return std::make_unique<SettingsMenuView>(nav); }},
|
||||
|
||||
{nullptr, "Receive", HOME, Color::cyan(), &bitmap_icon_receivers, new ViewFactory<ReceiversMenuView>()},
|
||||
{nullptr, "Transmit", HOME, Color::cyan(), &bitmap_icon_transmit, new ViewFactory<TransmittersMenuView>()},
|
||||
{nullptr, "Transceiver", HOME, Color::cyan(), &bitmap_icon_transceivers, new ViewFactory<TransceiversMenuView>()},
|
||||
{"recon", "Recon", HOME, Color::green(), &bitmap_icon_scanner, new ViewFactory<ReconView>()},
|
||||
{"capture", "Capture", HOME, Color::red(), &bitmap_icon_capture, new ViewFactory<CaptureAppView>()},
|
||||
{"replay", "Replay", HOME, Color::green(), &bitmap_icon_replay, new ViewFactory<PlaylistView>()},
|
||||
{"lookingglass", "Looking Glass", HOME, Color::green(), &bitmap_icon_looking, new ViewFactory<GlassView>()},
|
||||
{nullptr, "Utilities", HOME, Color::cyan(), &bitmap_icon_utilities, new ViewFactory<UtilitiesMenuView>()},
|
||||
{nullptr, "Games", HOME, Color::cyan(), &bitmap_icon_games, new ViewFactory<GamesMenuView>()},
|
||||
{nullptr, "Settings", HOME, Color::cyan(), &bitmap_icon_setup, new ViewFactory<SettingsMenuView>()},
|
||||
/* RX ********************************************************************/
|
||||
{"adsbrx", "ADS-B", RX, Color::green(), &bitmap_icon_adsb, [](NavigationView& nav) -> std::unique_ptr<View> { return std::make_unique<ADSBRxView>(nav); }},
|
||||
{"ais", "AIS Boats", RX, Color::green(), &bitmap_icon_ais, [](NavigationView& nav) -> std::unique_ptr<View> { return std::make_unique<AISAppView>(nav); }},
|
||||
{"aprsrx", "APRS", RX, Color::green(), &bitmap_icon_aprs, [](NavigationView& nav) -> std::unique_ptr<View> { return std::make_unique<APRSRXView>(nav); }},
|
||||
{"audio", "Audio", RX, Color::green(), &bitmap_icon_speaker, [](NavigationView& nav) -> std::unique_ptr<View> { return std::make_unique<AnalogAudioView>(nav); }},
|
||||
{"blerx", "BLE Rx", RX, Color::green(), &bitmap_icon_btle, [](NavigationView& nav) -> std::unique_ptr<View> { return std::make_unique<BLERxView>(nav); }},
|
||||
{"pocsag", "POCSAG", RX, Color::green(), &bitmap_icon_pocsag, [](NavigationView& nav) -> std::unique_ptr<View> { return std::make_unique<POCSAGAppView>(nav); }},
|
||||
{"radiosonde", "Radiosnde", RX, Color::green(), &bitmap_icon_sonde, [](NavigationView& nav) -> std::unique_ptr<View> { return std::make_unique<SondeView>(nav); }},
|
||||
{"search", "Search", RX, Color::yellow(), &bitmap_icon_search, [](NavigationView& nav) -> std::unique_ptr<View> { return std::make_unique<SearchView>(nav); }},
|
||||
{"subghzd", "SubGhzD", RX, Color::yellow(), &bitmap_icon_remote, [](NavigationView& nav) -> std::unique_ptr<View> { return std::make_unique<SubGhzDView>(nav); }},
|
||||
{"weather", "Weather", RX, Color::green(), &bitmap_icon_thermometer, [](NavigationView& nav) -> std::unique_ptr<View> { return std::make_unique<WeatherView>(nav); }},
|
||||
|
||||
{"adsbrx", "ADS-B", RX, Color::green(), &bitmap_icon_adsb, new ViewFactory<ADSBRxView>()},
|
||||
{"ais", "AIS Boats", RX, Color::green(), &bitmap_icon_ais, new ViewFactory<AISAppView>()},
|
||||
{"aprsrx", "APRS", RX, Color::green(), &bitmap_icon_aprs, new ViewFactory<APRSRXView>()},
|
||||
{"audio", "Audio", RX, Color::green(), &bitmap_icon_speaker, new ViewFactory<AnalogAudioView>()},
|
||||
{"blerx", "BLE Rx", RX, Color::green(), &bitmap_icon_btle, new ViewFactory<BLERxView>()},
|
||||
{"pocsag", "POCSAG", RX, Color::green(), &bitmap_icon_pocsag, new ViewFactory<POCSAGAppView>()},
|
||||
{"radiosonde", "Radiosnde", RX, Color::green(), &bitmap_icon_sonde, new ViewFactory<SondeView>()},
|
||||
{"search", "Search", RX, Color::yellow(), &bitmap_icon_search, new ViewFactory<SearchView>()},
|
||||
{"subghzd", "SubGhzD", RX, Color::yellow(), &bitmap_icon_remote, new ViewFactory<SubGhzDView>()},
|
||||
{"weather", "Weather", RX, Color::green(), &bitmap_icon_thermometer, new ViewFactory<WeatherView>()},
|
||||
/* TX ********************************************************************/
|
||||
{"aprstx", "APRS TX", TX, ui::Color::green(), &bitmap_icon_aprs, [](NavigationView& nav) -> std::unique_ptr<View> { return std::make_unique<APRSTXView>(nav); }},
|
||||
{"bletx", "BLE Tx", TX, ui::Color::green(), &bitmap_icon_btle, [](NavigationView& nav) -> std::unique_ptr<View> { return std::make_unique<BLETxView>(nav); }},
|
||||
{"ooktx", "OOK", TX, ui::Color::yellow(), &bitmap_icon_remote, [](NavigationView& nav) -> std::unique_ptr<View> { return std::make_unique<EncodersView>(nav); }},
|
||||
{"rdstx", "RDS", TX, ui::Color::green(), &bitmap_icon_rds, [](NavigationView& nav) -> std::unique_ptr<View> { return std::make_unique<RDSView>(nav); }},
|
||||
{"touchtune", "TouchTune", TX, ui::Color::green(), &bitmap_icon_touchtunes, [](NavigationView& nav) -> std::unique_ptr<View> { return std::make_unique<TouchTunesView>(nav); }},
|
||||
|
||||
{"aprstx", "APRS TX", TX, ui::Color::green(), &bitmap_icon_aprs, new ViewFactory<APRSTXView>()},
|
||||
{"bletx", "BLE Tx", TX, ui::Color::green(), &bitmap_icon_btle, new ViewFactory<BLETxView>()},
|
||||
{"ooktx", "OOK", TX, ui::Color::yellow(), &bitmap_icon_remote, new ViewFactory<EncodersView>()},
|
||||
{"rdstx", "RDS", TX, ui::Color::green(), &bitmap_icon_rds, new ViewFactory<RDSView>()},
|
||||
{"touchtune", "TouchTune", TX, ui::Color::green(), &bitmap_icon_touchtunes, new ViewFactory<TouchTunesView>()},
|
||||
/* TRX ********************************************************************/
|
||||
{"microphone", "Mic", TRX, Color::green(), &bitmap_icon_microphone, [](NavigationView& nav) -> std::unique_ptr<View> { return std::make_unique<MicTXView>(nav); }},
|
||||
|
||||
{"microphone", "Mic", TRX, Color::green(), &bitmap_icon_microphone, new ViewFactory<MicTXView>()},
|
||||
/* UTILITIES *************************************************************/
|
||||
{"filemanager", "File Manager", UTILITIES, Color::green(), &bitmap_icon_dir, [](NavigationView& nav) -> std::unique_ptr<View> { return std::make_unique<FileManagerView>(nav); }},
|
||||
{"freqman", "Freq. Manager", UTILITIES, Color::green(), &bitmap_icon_freqman, [](NavigationView& nav) -> std::unique_ptr<View> { return std::make_unique<FrequencyManagerView>(nav); }},
|
||||
{"iqtrim", "IQ Trim", UTILITIES, Color::orange(), &bitmap_icon_trim, [](NavigationView& nav) -> std::unique_ptr<View> { return std::make_unique<IQTrimView>(nav); }},
|
||||
{"notepad", "Notepad", UTILITIES, Color::dark_cyan(), &bitmap_icon_notepad, [](NavigationView& nav) -> std::unique_ptr<View> { return std::make_unique<TextEditorView>(nav); }},
|
||||
{nullptr, "Debug", UTILITIES, Color::light_grey(), &bitmap_icon_debug, [](NavigationView& nav) -> std::unique_ptr<View> { return std::make_unique<DebugMenuView>(nav); }},
|
||||
{"filemanager", "File Manager", UTILITIES, Color::green(), &bitmap_icon_dir, new ViewFactory<FileManagerView>()},
|
||||
{"freqman", "Freq. Manager", UTILITIES, Color::green(), &bitmap_icon_freqman, new ViewFactory<FrequencyManagerView>()},
|
||||
{"iqtrim", "IQ Trim", UTILITIES, Color::orange(), &bitmap_icon_trim, new ViewFactory<IQTrimView>()},
|
||||
{"notepad", "Notepad", UTILITIES, Color::dark_cyan(), &bitmap_icon_notepad, new ViewFactory<TextEditorView>()},
|
||||
{nullptr, "Debug", UTILITIES, Color::light_grey(), &bitmap_icon_debug, new ViewFactory<DebugMenuView>()},
|
||||
//{"testapp", "Test App", UTILITIES, Color::dark_grey(), nullptr, new ViewFactory<TestView>()},
|
||||
// Dangerous apps.
|
||||
{nullptr, "Flash Utility", UTILITIES, Color::red(), &bitmap_icon_peripherals_details, [](NavigationView& nav) -> std::unique_ptr<View> { return std::make_unique<FlashUtilityView>(nav); }},
|
||||
{nullptr, "Flash Utility", UTILITIES, Color::red(), &bitmap_icon_peripherals_details, new ViewFactory<FlashUtilityView>()},
|
||||
};
|
||||
|
||||
bool NavigationView::StartAppByName(const char* name) {
|
||||
@@ -133,7 +130,7 @@ bool NavigationView::StartAppByName(const char* name) {
|
||||
|
||||
for (const auto& app : appList) {
|
||||
if (app.id != nullptr && strcmp(app.id, name) == 0) {
|
||||
push_view(app.producer(*this));
|
||||
push_view(app.viewFactory->produce(*this));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -633,7 +630,6 @@ void NavigationView::pop(bool trigger_update) {
|
||||
|
||||
free_view();
|
||||
view_stack.pop_back();
|
||||
view_stack.shrink_to_fit();
|
||||
|
||||
// NB: These are executed _after_ the view has been
|
||||
// destroyed. The old view MUST NOT be referenced in
|
||||
@@ -757,22 +753,10 @@ void NavigationView::handle_autostart() {
|
||||
void add_apps(NavigationView& nav, BtnGridView& grid, app_location_t loc) {
|
||||
for (auto& app : NavigationView::appList) {
|
||||
if (app.menuLocation == loc) {
|
||||
const AppInfo* p_app = &app;
|
||||
grid.add_item({app.displayName, app.iconColor, app.icon,
|
||||
[&nav, p_app]() {
|
||||
NavigationView& local_nav = nav;
|
||||
if (p_app->menuLocation == HOME) {
|
||||
local_nav.store_last_menu_name(p_app->displayName);
|
||||
local_nav.set_last_menu_went_deeper(false);
|
||||
auto new_view = p_app->producer(local_nav);
|
||||
local_nav.push_view(std::move(new_view));
|
||||
} else {
|
||||
auto new_view = p_app->producer(local_nav);
|
||||
local_nav.pop();
|
||||
local_nav.set_last_menu_went_deeper(true);
|
||||
local_nav.push_view(std::move(new_view));
|
||||
}
|
||||
}},
|
||||
[&nav, &app]() {
|
||||
i2cdev::I2CDevManager::set_autoscan_interval(0); //if i navigate away from any menu, turn off autoscan
|
||||
nav.push_view(app.viewFactory->produce(nav)); }},
|
||||
true);
|
||||
}
|
||||
};
|
||||
@@ -799,7 +783,7 @@ void add_external_items(NavigationView& nav, app_location_t location, BtnGridVie
|
||||
return a.desired_position < b.desired_position;
|
||||
});
|
||||
|
||||
for (auto & gridItem : externalItems) {
|
||||
for (auto const& gridItem : externalItems) {
|
||||
if (gridItem.desired_position < 0) {
|
||||
grid.add_item(std::move(gridItem), true);
|
||||
} else {
|
||||
@@ -931,27 +915,6 @@ SystemView::SystemView(
|
||||
{{0, 0},
|
||||
{parent_rect.width(), status_view_height}});
|
||||
status_view.on_back = [this]() {
|
||||
if (this->navigation_view.view_stack_size() == 2) {
|
||||
const AppInfo* lastmenu = nullptr;
|
||||
const auto last_menu_name = this->navigation_view.get_last_menu_name();
|
||||
this->navigation_view.store_last_menu_name("");
|
||||
if (!last_menu_name.empty()) {
|
||||
for (const auto& app : NavigationView::appList) {
|
||||
if (app.displayName == last_menu_name) {
|
||||
lastmenu = &app;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (lastmenu && this->navigation_view.get_last_menu_went_deeper()) {
|
||||
this->navigation_view.pop();
|
||||
this->navigation_view.push_view(lastmenu->producer(this->navigation_view));
|
||||
this->navigation_view.store_last_menu_name(lastmenu->displayName); // since we opened it again, store it again
|
||||
this->navigation_view.set_last_menu_went_deeper(false); // not yet
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
this->navigation_view.pop();
|
||||
};
|
||||
|
||||
@@ -968,7 +931,6 @@ SystemView::SystemView(
|
||||
navigation_view.on_view_changed = [this](const View& new_view) {
|
||||
if (!this->navigation_view.is_top()) {
|
||||
remove_child(&info_view);
|
||||
i2cdev::I2CDevManager::set_autoscan_interval(0);
|
||||
} else {
|
||||
add_child(&info_view);
|
||||
info_view.refresh();
|
||||
@@ -1029,15 +991,16 @@ void SystemView::toggle_overlay() {
|
||||
this->set_dirty();
|
||||
shared_memory.request_m4_performance_counter = last_perf_counter_status;
|
||||
overlay_active = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SystemView::paint_overlay() {
|
||||
static bool last_paint_state = false;
|
||||
if (overlay_active) {
|
||||
// paint background only every other second
|
||||
if ((((chTimeNow() >> 10) & 0x01) == 0x01) == last_paint_state)
|
||||
return;
|
||||
|
||||
last_paint_state = !last_paint_state;
|
||||
if (overlay_active == 1 && overlay)
|
||||
overlay->set_dirty();
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
#include "lfsr_random.hpp"
|
||||
#include "sd_card.hpp"
|
||||
#include "external_app.hpp"
|
||||
#include "view_factory.hpp"
|
||||
#include "battery.hpp"
|
||||
|
||||
// for incrementing fake date when RTC battery is dead
|
||||
@@ -59,9 +60,6 @@ using namespace sd_card;
|
||||
|
||||
namespace ui {
|
||||
|
||||
class NavigationView;
|
||||
using ViewProducer = std::unique_ptr<View> (*)(NavigationView&);
|
||||
|
||||
void add_apps(NavigationView& nav, BtnGridView& grid, app_location_t loc);
|
||||
void add_external_items(NavigationView& nav, app_location_t location, BtnGridView& grid, uint8_t error_tile_pos, bool show_error_tile = true);
|
||||
|
||||
@@ -71,7 +69,7 @@ enum modal_t {
|
||||
ABORT
|
||||
};
|
||||
|
||||
// Should only be used as part of the appList in NavigationView.
|
||||
// Should only be used as part of the appList in NavigationView, the viewFactory will never be destroyed.
|
||||
class AppInfo {
|
||||
public:
|
||||
const char* id; // MUST be unique! Used by serial command to start the app so it also has to make sense
|
||||
@@ -79,7 +77,7 @@ class AppInfo {
|
||||
app_location_t menuLocation;
|
||||
Color iconColor;
|
||||
const Bitmap* icon;
|
||||
ViewProducer producer;
|
||||
ViewFactoryBase* viewFactory; // Never destroyed, and I believe it's ok ;) Having a unique_ptr here breaks the initializer list of appList
|
||||
};
|
||||
|
||||
struct AppInfoConsole {
|
||||
@@ -140,13 +138,6 @@ class NavigationView : public View {
|
||||
bool StartAppByName(const char* name); // Starts a View (app) by name stored in appListFC. This is to start apps from console
|
||||
void handle_autostart();
|
||||
|
||||
void store_last_menu_name(const std::string& name) { last_menu_name_ = name; }
|
||||
std::string get_last_menu_name() const { return last_menu_name_; }
|
||||
size_t view_stack_size() const { return view_stack.size(); }
|
||||
|
||||
bool get_last_menu_went_deeper() { return last_menu_went_deeper; }
|
||||
void set_last_menu_went_deeper(bool went_deeper) { last_menu_went_deeper = went_deeper; }
|
||||
|
||||
private:
|
||||
struct ViewState {
|
||||
std::unique_ptr<View> view;
|
||||
@@ -159,8 +150,6 @@ class NavigationView : public View {
|
||||
|
||||
void free_view();
|
||||
void update_view();
|
||||
std::string last_menu_name_{}; // this stores the last menu name, when we replace the menu with the app, we'll know, where to navigate back
|
||||
bool last_menu_went_deeper = false;
|
||||
};
|
||||
|
||||
/* Holds widgets and grows dynamically toward the left.
|
||||
|
||||
@@ -157,7 +157,7 @@ static void cmd_flash(BaseSequentialStream* chp, int argc, char* argv[]) {
|
||||
// call nav with flash
|
||||
auto open_view = nav->push<ui::FlashUtilityView>();
|
||||
chprintf(chp, "Flashing started\r\n");
|
||||
chThdSleepMilliseconds(50); // to give display some time to paint the screen
|
||||
chThdSleepMilliseconds(150); // to give display some time to paint the screen
|
||||
open_view->wait_till_loaded(); // also wait for first frame sync
|
||||
if (!open_view->flash_firmware(path.native())) {
|
||||
chprintf(chp, "error\r\n");
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2024 Tamas Eisenberger <e.tamas@iwstudio.hu>
|
||||
*
|
||||
* 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 __VIEW_FACTORY_HPP__
|
||||
#define __VIEW_FACTORY_HPP__
|
||||
|
||||
#include "view_factory_base.hpp"
|
||||
|
||||
namespace ui {
|
||||
|
||||
template <typename T>
|
||||
class ViewFactory : public ViewFactoryBase {
|
||||
public:
|
||||
virtual std::unique_ptr<View> produce(NavigationView& nav) const override {
|
||||
return std::unique_ptr<View>(new T(nav));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace ui
|
||||
|
||||
#endif //__VIEW_FACTORY_HPP__
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2024 Tamas Eisenberger <e.tamas@iwstudio.hu>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "view_factory_base.hpp"
|
||||
|
||||
namespace ui {
|
||||
|
||||
ViewFactoryBase::~ViewFactoryBase() {}
|
||||
|
||||
} // namespace ui
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2024 Tamas Eisenberger <e.tamas@iwstudio.hu>
|
||||
*
|
||||
* 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 __VIEW_FACTORY_BASE_HPP__
|
||||
#define __VIEW_FACTORY_BASE_HPP__
|
||||
|
||||
#include <memory>
|
||||
#include "ui_widget.hpp"
|
||||
|
||||
namespace ui {
|
||||
|
||||
class NavigationView;
|
||||
|
||||
class ViewFactoryBase {
|
||||
public:
|
||||
virtual ~ViewFactoryBase();
|
||||
virtual std::unique_ptr<View> produce(NavigationView& nav) const = 0;
|
||||
};
|
||||
|
||||
} // namespace ui
|
||||
|
||||
#endif //__VIEW_FACTORY_BASE_HPP__
|
||||
@@ -148,8 +148,8 @@ static struct gpio gpio_h1r9_hw_sync_enable = GPIO(5, 5);
|
||||
#endif
|
||||
// clang-format on
|
||||
|
||||
/* i2c0, i2c1, and i2c_config_si5351c_fast_clock are defined in
|
||||
* hackrf/firmware/common/i2c_bus.c and si5351c.c; use those instead of
|
||||
/* i2c0, i2c1, and i2c_config_fast_clock are defined in
|
||||
* hackrf/firmware/common/i2c_bus.c and i2c_lpc.c; use those instead of
|
||||
* redefining them here to avoid multiple-definition link errors. */
|
||||
|
||||
si5351c_driver_t clock_gen = {
|
||||
@@ -553,7 +553,7 @@ void cpu_clock_init(void) {
|
||||
/* use IRC as clock source for APB3 */
|
||||
CGU_BASE_APB3_CLK = CGU_BASE_APB3_CLK_CLK_SEL(CGU_SRC_IRC);
|
||||
|
||||
i2c_bus_start(clock_gen.bus, &i2c_config_si5351c_fast_clock);
|
||||
i2c_bus_start(clock_gen.bus, &i2c_config_fast_clock);
|
||||
|
||||
si5351c_init(&clock_gen);
|
||||
si5351c_disable_all_outputs(&clock_gen);
|
||||
@@ -561,8 +561,7 @@ void cpu_clock_init(void) {
|
||||
si5351c_power_down_all_clocks(&clock_gen);
|
||||
si5351c_set_crystal_configuration(&clock_gen);
|
||||
si5351c_enable_xo_and_ms_fanout(&clock_gen);
|
||||
si5351c_configure_pll_sources(&clock_gen, PLL_SOURCE_XTAL);
|
||||
si5351c_configure_pll_multisynth(&clock_gen, PLL_SOURCE_XTAL);
|
||||
si5351c_configure_pll_multisynth(&clock_gen, SI5351C_INPUT_XTAL);
|
||||
|
||||
/*
|
||||
* Clocks on HackRF One r9:
|
||||
@@ -615,14 +614,15 @@ void cpu_clock_init(void) {
|
||||
/* Set to 10 MHz, the common rate between Jawbreaker and HackRF One. */
|
||||
sample_rate_set(10000000 * (fp_40_24_t)FP_ONE_HZ, true);
|
||||
|
||||
si5351c_set_clock_source(&clock_gen, PLL_SOURCE_XTAL);
|
||||
si5351c_configure_clock_control(&clock_gen);
|
||||
si5351c_change_input(&clock_gen, SI5351C_INPUT_XTAL);
|
||||
// soft reset
|
||||
si5351c_reset_pll(&clock_gen, SI5351C_PLL_BOTH);
|
||||
si5351c_reset_plls(&clock_gen, SI5351C_PLL_MASK_BOTH);
|
||||
si5351c_enable_clock_outputs(&clock_gen);
|
||||
|
||||
// FIXME disable I2C
|
||||
/* Kick I2C0 down to 400kHz when we switch over to APB1 clock = 204MHz */
|
||||
i2c_bus_start(clock_gen.bus, &i2c_config_si5351c_fast_clock);
|
||||
i2c_bus_start(clock_gen.bus, &i2c_config_fast_clock);
|
||||
|
||||
/*
|
||||
* 12MHz clock is entering LPC XTAL1/OSC input now.
|
||||
@@ -784,9 +784,9 @@ clock_source_t activate_best_clock_source(void) {
|
||||
/* No external or PortaPack clock was found. Use HackRF Si5351C crystal. */
|
||||
}
|
||||
|
||||
si5351c_set_clock_source(
|
||||
si5351c_change_input(
|
||||
&clock_gen,
|
||||
(source == CLOCK_SOURCE_HACKRF) ? PLL_SOURCE_XTAL : PLL_SOURCE_CLKIN);
|
||||
(source == CLOCK_SOURCE_HACKRF) ? SI5351C_INPUT_XTAL : SI5351C_INPUT_CLKIN);
|
||||
hackrf_ui()->set_clock_source(source);
|
||||
return source;
|
||||
}
|
||||
|
||||
+1
-1
Submodule hackrf updated: 0bf478ed25...f526ddf4eb
Reference in New Issue
Block a user