mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-12-24 06:49:24 -05:00
Add debug_log, fix tx_bht (#1149)
This commit is contained in:
parent
3db2053c21
commit
19491ce3f7
@ -36,19 +36,6 @@ namespace fs = std::filesystem;
|
||||
using namespace portapack;
|
||||
using namespace std::literals;
|
||||
|
||||
/*#include "log_file.hpp"
|
||||
LogFile* g_pLog = nullptr;
|
||||
static void log_it(const std::string& msg) {
|
||||
static LogFile s_log;
|
||||
if (g_pLog == nullptr) {
|
||||
delete_file("appset.txt");
|
||||
s_log.append("appset.txt");
|
||||
g_pLog = &s_log;
|
||||
}
|
||||
|
||||
g_pLog->write_entry(msg);
|
||||
}*/
|
||||
|
||||
namespace app_settings {
|
||||
|
||||
template <typename T>
|
||||
|
@ -220,7 +220,6 @@ EPARView::EPARView(
|
||||
|
||||
field_city.set_value(0);
|
||||
field_group.set_selected_index(2);
|
||||
|
||||
field_city.on_change = [this](int32_t) { generate_message(); };
|
||||
field_group.on_change = [this](size_t, int32_t) { generate_message(); };
|
||||
|
||||
@ -230,11 +229,11 @@ EPARView::EPARView(
|
||||
|
||||
size_t n = 0;
|
||||
for (auto& relay_state : relay_states) {
|
||||
relay_state.on_change = relay_state_fn;
|
||||
relay_state.set_parent_rect({static_cast<Coord>(90 + (n * 36)),
|
||||
80,
|
||||
24, 24});
|
||||
relay_state.set_options(relay_options);
|
||||
relay_state.on_change = relay_state_fn; // NB: set after set_options to avoid startup call.
|
||||
add_child(&relay_state);
|
||||
n++;
|
||||
}
|
||||
@ -303,11 +302,11 @@ XylosView::XylosView(
|
||||
};
|
||||
|
||||
field_header_a.on_change = field_fn;
|
||||
field_header_b.on_change = [this](int32_t) { generate_message(); };
|
||||
field_city.on_change = [this](int32_t) { generate_message(); };
|
||||
field_family.on_change = [this](int32_t) { generate_message(); };
|
||||
field_subfamily.on_change = [this](int32_t) { generate_message(); };
|
||||
field_receiver.on_change = [this](int32_t) { generate_message(); };
|
||||
field_header_b.on_change = field_fn;
|
||||
field_city.on_change = field_fn;
|
||||
field_family.on_change = field_fn;
|
||||
field_subfamily.on_change = field_fn;
|
||||
field_receiver.on_change = field_fn;
|
||||
|
||||
checkbox_wcsubfamily.on_select = [this](Checkbox&, bool v) {
|
||||
field_subfamily.set_focusable(!v);
|
||||
@ -328,11 +327,11 @@ XylosView::XylosView(
|
||||
|
||||
size_t n = 0;
|
||||
for (auto& relay_state : relay_states) {
|
||||
relay_state.on_change = relay_state_fn;
|
||||
relay_state.set_parent_rect({static_cast<Coord>(54 + (n * 36)),
|
||||
134,
|
||||
24, 24});
|
||||
relay_state.set_options(relay_options);
|
||||
relay_state.on_change = relay_state_fn; // NB: set after set_options to avoid startup call.
|
||||
add_child(&relay_state);
|
||||
n++;
|
||||
}
|
||||
|
@ -26,12 +26,26 @@
|
||||
#include <hal.h>
|
||||
#include <string>
|
||||
|
||||
#include "log_file.hpp"
|
||||
#include "portapack.hpp"
|
||||
#include "string_format.hpp"
|
||||
#include "ui_styles.hpp"
|
||||
|
||||
using namespace ui;
|
||||
|
||||
#define DEBUG_LOG_FILE "debug_log.txt"
|
||||
LogFile* pg_debug_log = nullptr;
|
||||
void __debug_log(const std::string& msg) {
|
||||
static LogFile s_log;
|
||||
if (pg_debug_log == nullptr) {
|
||||
delete_file(DEBUG_LOG_FILE);
|
||||
s_log.append(DEBUG_LOG_FILE);
|
||||
pg_debug_log = &s_log;
|
||||
}
|
||||
|
||||
pg_debug_log->write_entry(msg);
|
||||
}
|
||||
|
||||
void runtime_error(LED);
|
||||
std::string number_to_hex_string(uint32_t);
|
||||
void draw_line(int32_t, const char*, regarm_t);
|
||||
|
@ -24,6 +24,12 @@
|
||||
#define __DEBUG_H__
|
||||
|
||||
#include "hackrf_gpio.hpp"
|
||||
#include <string>
|
||||
|
||||
void __debug_log(const std::string& msg);
|
||||
#define __LOG2(l, msg) __debug_log(std::string{#l} + ":" + msg)
|
||||
#define __LOG1(l, msg) __LOG2(l, msg)
|
||||
#define DEBUG_LOG(msg) __LOG1(__LINE__, msg)
|
||||
|
||||
extern void draw_guru_meditation(uint8_t, const char*);
|
||||
extern void draw_guru_meditation(uint8_t, const char*, struct extctx*, uint32_t);
|
||||
|
@ -28,7 +28,9 @@ size_t gen_message_ep(uint8_t city_code, size_t family_code_ep, uint32_t relay_n
|
||||
const encoder_def_t* um3750_def;
|
||||
uint8_t bits[12];
|
||||
std::string ep_fragments;
|
||||
// char ep_message[13] = { 0 };
|
||||
|
||||
// Pre-allocate to avoid fragmentation.
|
||||
ep_fragments.reserve(384);
|
||||
|
||||
// Repeated 2x 26 times
|
||||
// Whole frame + space = 128ms, data only = 64ms
|
||||
|
@ -1358,7 +1358,7 @@ void ImageOptionsField::set_selected_index(const size_t new_index) {
|
||||
}
|
||||
|
||||
void ImageOptionsField::set_by_value(value_t v) {
|
||||
size_t new_index{0};
|
||||
size_t new_index = 0;
|
||||
for (const auto& option : options) {
|
||||
if (option.second == v) {
|
||||
set_selected_index(new_index);
|
||||
@ -1377,7 +1377,7 @@ void ImageOptionsField::set_options(options_t new_options) {
|
||||
|
||||
// Set an invalid index to force on_change.
|
||||
selected_index_ = (size_t)-1;
|
||||
set_by_value(0);
|
||||
set_selected_index(0);
|
||||
set_dirty();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user