Skip to content

Commit

Permalink
feat: set log output at startup
Browse files Browse the repository at this point in the history
  • Loading branch information
DeimosHall committed Dec 23, 2024
1 parent 3548166 commit 6b403db
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions firmware/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ void app_main() {

uart_bridge_begin(uart_config, UART_BUFFER_SIZE);
preferences_begin();
logs_output_set_output(preferences_get_uchar("logs_output", USB));

bool stealth_mode = preferences_get_bool("stealth_mode", false);
if (!stealth_mode) {
Expand Down
10 changes: 2 additions & 8 deletions firmware/main/modules/settings/uart_bridge/logs_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,11 @@ static char* logs_output_options[] = {
"UART TXD/RXD",
};

// Same order as logs_output_options
typedef enum {
USB,
UART,
} logs_output_option_t;

uint8_t logs_output_get_option() {
return preferences_get_uchar("logs_output", USB);
}

void logs_output_set_logs_output(logs_output_option_t selected_option) {
void logs_output_set_output(logs_output_option_t selected_option) {
switch (selected_option) {
case USB:
uart_bridge_set_logs_to_usb();
Expand All @@ -41,7 +35,7 @@ void logs_output() {
.banner = "Logs Output",
.current_option = logs_output_get_option(),
.options_count = sizeof(logs_output_options) / sizeof(char*),
.select_cb = logs_output_set_logs_output,
.select_cb = logs_output_set_output,
.exit_cb = menus_module_exit_app,
.style = RADIO_SELECTION_OLD_STYLE,
};
Expand Down
7 changes: 7 additions & 0 deletions firmware/main/modules/settings/uart_bridge/logs_output.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#pragma once

// Same order as logs_output_options
typedef enum {
USB,
UART,
} logs_output_option_t;

void logs_output_set_output(logs_output_option_t selected_option);
void logs_output();

0 comments on commit 6b403db

Please sign in to comment.