Skip to content

Commit

Permalink
feat: add settings for logs output
Browse files Browse the repository at this point in the history
  • Loading branch information
DeimosHall committed Dec 23, 2024
1 parent 61e3008 commit dd378a7
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 3 deletions.
2 changes: 1 addition & 1 deletion firmware/main/modules/cat_dos/cat_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void cat_console_begin() {
/* Register commands */
esp_console_register_help_command();
register_wifi();
cmd_control_register_launch_cmd_();
cmd_control_register_launch_cmd();
cmd_control_register_uart_bridge_commands();
cmd_control_register_system_commands();

Expand Down
2 changes: 1 addition & 1 deletion firmware/main/modules/cmd_control/cmd_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ static int launch_app(int argc, char** argv) {
return 0;
}

void cmd_control_register_launch_cmd_() {
void cmd_control_register_launch_cmd() {
message_args.app = arg_str1(NULL, NULL, "<app>", "Name of the app to launch");
message_args.end = arg_end(1);

Expand Down
2 changes: 1 addition & 1 deletion firmware/main/modules/cmd_control/cmd_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <stdio.h>

void cmd_control_register_launch_cmd_();
void cmd_control_register_launch_cmd();

void cmd_control_register_uart_bridge_commands();

Expand Down
9 changes: 9 additions & 0 deletions firmware/main/modules/menus_module/menus_include/menus.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "gps_module.h"
#include "gps_screens.h"
#include "i2c_scanner.h"
#include "logs_output.h"
#include "open_thread_module.h"
#include "ota_module.h"
#include "sd_card_settings_module.h"
Expand Down Expand Up @@ -98,6 +99,7 @@ typedef enum {
MENU_FILE_MANAGER_LOCAL,
MENU_FILE_MANAGER_WEB,
MENU_SETTINGS_SYSTEM,
MENU_SETTINGS_LOGS_OUTPUT,
MENU_SETTINGS_TIME_ZONE,
MENU_SETTINGS_WIFI,
MENU_SETTINGS_SD_CARD,
Expand Down Expand Up @@ -519,6 +521,13 @@ menu_t menus[] = { //////////////////////////////////
.on_enter_cb = NULL,
.on_exit_cb = NULL,
.is_visible = true},
{.display_name = "Logs Output",
.menu_idx = MENU_SETTINGS_LOGS_OUTPUT,
.parent_idx = MENU_SETTINGS_SYSTEM,
.last_selected_submenu = 0,
.on_enter_cb = logs_output,
.on_exit_cb = NULL,
.is_visible = true},
#ifdef CONFIG_GPS_APPS_ENABLE
{.display_name = "Time zone",
.menu_idx = MENU_SETTINGS_TIME_ZONE,
Expand Down
50 changes: 50 additions & 0 deletions firmware/main/modules/settings/logs/logs_output.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include "logs_output.h"
#include "esp_log.h"
#include "general_radio_selection.h"
#include "menus_module.h"
#include "preferences.h"
#include "uart_bridge.h"

static char* logs_output_options[] = {
"USB",
"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) {
switch (selected_option) {
case USB:
uart_bridge_set_logs_to_usb();
preferences_put_uchar("logs_output", USB);
break;
case UART:
uart_bridge_set_logs_to_uart();
preferences_put_uchar("logs_output", UART);
break;
default:
break;
}
}

void logs_output() {
general_radio_selection_menu_t logs_output_menu = {
.options = logs_output_options,
.banner = "Logs Output",
.current_option = logs_output_get_option(),
.options_count = sizeof(logs_output_options) / sizeof(char*),
.select_cb = logs_output_set_logs_output,
.exit_cb = menus_module_exit_app,
.style = RADIO_SELECTION_OLD_STYLE,
};

general_radio_selection(logs_output_menu);
}
3 changes: 3 additions & 0 deletions firmware/main/modules/settings/logs/logs_output.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

void logs_output();

0 comments on commit dd378a7

Please sign in to comment.