This commit is contained in:
Totoo
2026-02-24 11:23:41 +01:00
committed by GitHub
parent b09efb4d3c
commit e63f54c0a2
24 changed files with 96 additions and 63 deletions
+1
View File
@@ -199,6 +199,7 @@ void BLETxView::send_packet() {
generateRandomMacAddress(randomMac);
char advertisementData[63] = {0};
packets[current_packet].advertisementData[62] = '\0';
strcpy(advertisementData, packets[current_packet].advertisementData);
// TODO: Make this a checkbox.
@@ -34,7 +34,7 @@
namespace ui {
void create_thread(int32_t (*fn)(void*), void* arg, size_t stack_size, int priority) {
// TODO: collect memory on terminate, once this is used
// TODO: collect memory on terminate, once this is used. This is a HUGE TODO! need to call chThdWait on all of them!
chThdCreateFromHeap(NULL, stack_size, priority, fn, arg);
}
+4 -1
View File
@@ -36,8 +36,11 @@ WipeSDView::WipeSDView(NavigationView& nav)
}
WipeSDView::~WipeSDView() {
if (thread)
if (thread) {
chThdTerminate(thread);
chThdWait(thread);
thread = nullptr;
}
}
void WipeSDView::focus() {
+3 -2
View File
@@ -161,7 +161,7 @@ Optional<File::Error> File::sync() {
File::Result<std::string> File::read_file(const std::filesystem::path& filename) {
constexpr size_t buffer_size = 0x80;
char* buffer[buffer_size];
char buffer[buffer_size];
File f;
auto error = f.open(filename);
@@ -205,6 +205,7 @@ static std::filesystem::path find_last_ordinal_match(
const std::filesystem::path& pattern,
pattern_range range) {
auto last_match = std::filesystem::path();
if (range.start == std::string::npos || range.end == std::string::npos || range.start > range.end) return last_match;
auto can_increment = [range](const auto& path) {
for (auto i = range.start; i <= range.end; ++i)
if (!isdigit(path.native()[i]))
@@ -230,7 +231,7 @@ static std::filesystem::path increment_filename_ordinal(
const std::filesystem::path& path,
pattern_range range) {
auto name = path.filename().native();
if (range.start == std::string::npos || range.end == std::string::npos || range.start > range.end) return {name};
for (auto i = range.end; i >= range.start; --i) {
auto& c = name[i];
+1 -1
View File
@@ -117,7 +117,7 @@ class BufferLineReader {
std::strncpy(&it.line_data_[offset], buf, len);
offset += len;
if (len < buf_size)
if (len < buf_size || buf[len - 1] == '\n')
break;
}
+1 -2
View File
@@ -84,8 +84,7 @@ void Gradient::step(int16_t index, int16_t r, int16_t g, int16_t b) {
int16_t new_r = prev_r * y + r * x;
int16_t new_g = prev_g * y + g * x;
int16_t new_b = prev_b * y + b * x;
lut[i] = ui::Color(new_r, new_g, new_b);
if (i <= 255) lut[i] = ui::Color(new_r, new_g, new_b);
}
prev_index = index;
+2 -1
View File
@@ -81,7 +81,8 @@ struct header_t {
struct tags_t {
constexpr tags_t(
const std::string& title_str) {
strcpy(title, title_str.c_str());
strncpy(title, title_str.c_str(), sizeof(title) - 1);
title[sizeof(title) - 1] = '\0';
cksize = sizeof(tags_t) - 8;
}
+1 -1
View File
@@ -91,7 +91,7 @@ Continuous (Fox-oring)
// TODO: ADS-B draw trajectory + GPS coordinates + scale, and playback
// TODO: RDS multiple groups (sequence)
// TODO: Use ModalMessageView confirmation for TX ?
// TODO: Use msgpack for settings, lists... on sd card
// TODO: Use msgpack for settings, lists... on sd card. and make it safe, since now it has a lot of oob potentials
// Multimon-style stuff:
// TODO: DMR detector
+3 -2
View File
@@ -108,9 +108,10 @@ void resetFilteredEntries(ContainerType& entries, KeySelector keySelector) {
auto it = entries.begin();
while (it != entries.end()) {
if (keySelector(*it)) {
entries.erase(it); // Add a new entry to filteredEntries
it = entries.erase(it); // Add a new entry to filteredEntries
} else {
++it; // Move to the next element, outside of the if block
}
++it; // Move to the next element, outside of the if block
}
}
+2 -1
View File
@@ -100,7 +100,8 @@ std::string to_string_dec_uint(uint64_t n) {
std::string to_string_bin(
const uint32_t n,
const uint8_t l) {
uint8_t l) {
if (l >= 33) l = 32;
char p[33];
for (uint8_t c = 0; c < l; c++) {
if (n & (1 << (l - 1 - c)))
+1 -1
View File
@@ -50,7 +50,7 @@ char* to_string_dec_uint(uint64_t n, StringFormatBuffer& buffer, size_t& length)
std::string to_string_dec_int(int64_t n);
std::string to_string_dec_uint(uint64_t n);
std::string to_string_bin(const uint32_t n, const uint8_t l = 0);
std::string to_string_bin(const uint32_t n, uint8_t l = 0);
std::string to_string_dec_uint(const uint32_t n, const int32_t l, const char fill = ' ');
std::string to_string_dec_int(const int32_t n, const int32_t l, const char fill = 0);
std::string to_string_decimal(float decimal, int8_t precision);
+27 -27
View File
@@ -32,40 +32,40 @@ namespace ui {
class ThemeTemplate {
public:
~ThemeTemplate();
Style* bg_lightest;
Style* bg_lightest_small;
Style* bg_light;
Style* bg_medium;
Style* bg_dark;
Style* bg_darker;
virtual ~ThemeTemplate();
Style* bg_lightest = nullptr;
Style* bg_lightest_small = nullptr;
Style* bg_light = nullptr;
Style* bg_medium = nullptr;
Style* bg_dark = nullptr;
Style* bg_darker = nullptr;
Style* bg_darkest;
Style* bg_darkest_small;
Style* bg_darkest = nullptr;
Style* bg_darkest_small = nullptr;
Style* bg_important_small;
Style* bg_important_small = nullptr;
Style* error_dark;
Style* warning_dark;
Style* ok_dark;
Style* error_dark = nullptr;
Style* warning_dark = nullptr;
Style* ok_dark = nullptr;
Style* fg_dark;
Style* fg_medium;
Style* fg_light;
Style* fg_dark = nullptr;
Style* fg_medium = nullptr;
Style* fg_light = nullptr;
Style* fg_red;
Style* fg_green;
Style* fg_yellow;
Style* fg_orange;
Style* fg_blue;
Style* fg_cyan;
Style* fg_darkcyan;
Style* fg_magenta;
Style* fg_red = nullptr;
Style* fg_green = nullptr;
Style* fg_yellow = nullptr;
Style* fg_orange = nullptr;
Style* fg_blue = nullptr;
Style* fg_cyan = nullptr;
Style* fg_darkcyan = nullptr;
Style* fg_magenta = nullptr;
Style* option_active;
Style* option_active = nullptr;
Color* status_active; // green, the status bar icons when active
Color* bg_table_header;
Color* status_active = nullptr; // green, the status bar icons when active
Color* bg_table_header = nullptr;
};
class ThemeDefault : public ThemeTemplate {
+2 -2
View File
@@ -92,7 +92,7 @@ void BMPViewer::get_line(ui::Color* line, uint32_t bx, uint32_t by, uint32_t cnt
for (uint32_t x = 0; x < cnt; x++) {
uint32_t targetx = (zoom < 0) ? bx + x * -1 * zoom : bx + x / zoom; // on zoom out could probably avg the pixels, or apply some smoothing, but this is way faster.
if (last_targetx == targetx) {
line[x] = line[x - 1];
if (x > 0) line[x] = line[x - 1];
continue;
}
last_targetx = targetx;
@@ -123,7 +123,7 @@ void BMPViewer::paint(Painter& painter) {
last_by = by;
portapack::display.draw_pixels({rect.left(), rect.top() + y, d_width, 1}, line, d_width);
}
delete line;
delete[] line;
}
int8_t BMPViewer::get_zoom() {
+1 -1
View File
@@ -1141,7 +1141,7 @@ static void cmd_gotenv(BaseSequentialStream* chp, int argc, char* argv[]) {
uint16_t light = 0;
if (argc > 1) humi = atof(argv[1]);
if (argc > 2) pressure = atof(argv[2]);
if (argc > 3) light = strtol(argv[0], NULL, 10);
if (argc > 3) light = strtol(argv[3], NULL, 10);
EnvironmentDataMessage msg{temp, humi, pressure};
EventDispatcher::send_message(msg);
// compatibility:
@@ -148,7 +148,11 @@ void cmd_sd_open(BaseSequentialStream* chp, int argc, char* argv[]) {
auto path = path_from_string8((char*)full_fn_from_args(argc, argv).c_str());
shell_file = new File();
auto error = shell_file->open(path, false, true);
if (report_on_error(chp, error)) return;
if (report_on_error(chp, error)) {
delete shell_file;
shell_file = nullptr;
return;
}
chprintf(chp, "ok\r\n");
}