Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recording fix #71

Merged
merged 2 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/orgasm_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,12 @@ void orgasm_control_startRecording() {
}

char* logfile_name = NULL;
asiprintf(&logfile_name, "/log-%s.csv", filename_date);
asiprintf(&logfile_name, "%s/log-%s.csv", eom_hal_get_sd_mount_point(), filename_date);

if (!logfile_name) {
ESP_LOGE(TAG, "Logfile filename buffer issues.");
ui_toast("%s", _("Error opening logfile!"));
}

ESP_LOGI(TAG, "Opening logfile: %s", logfile_name);
logger_state.logfile = fopen(logfile_name, "w+");
Expand All @@ -416,22 +421,26 @@ void orgasm_control_startRecording() {
);

ui_set_icon(UI_ICON_RECORD, RECORD_ICON_RECORDING);
ui_toast(_("Recording started:\n%s"), logfile_name);
char* fntok = basename(logfile_name);
ui_toast(_("Recording started:\n%s"), fntok);
}

free(logfile_name);
}

void orgasm_control_stopRecording() {
if (logger_state.logfile != NULL) {
ui_toast_blocking("%s", _("Stopping..."));
ESP_LOGI(TAG, "Closing logfile.");
fclose(logger_state.logfile);
logger_state.logfile = NULL;
ui_set_icon(UI_ICON_RECORD, -1);
ui_toast("%s", _("Recording stopped."));
}
}

oc_bool_t orgasm_control_isRecording() {
return (oc_bool_t)logger_state.logfile;
return (oc_bool_t) !!logger_state.logfile;
}

void orgasm_control_tick() {
Expand Down
8 changes: 7 additions & 1 deletion src/ui/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ static SemaphoreHandle_t _insert_mutex = NULL;
void ui_menu_cb_open_page(
const ui_menu_t* m, const ui_menu_item_t* item, UI_MENU_ARG_TYPE menu_arg
) {
if (item == NULL) return;
const ui_page_t* page = (const ui_page_t*)item->arg;
ui_open_page(page, NULL);
ui_close_all_menu();
}

void ui_menu_cb_open_menu(
Expand Down Expand Up @@ -178,7 +182,9 @@ ui_menu_item_t* ui_menu_add_item(
}

ui_menu_item_t* ui_menu_add_page(const ui_menu_t* m, const ui_page_t* page) {
return NULL;
if (m == NULL || page == NULL) return NULL;

return ui_menu_add_item(m, _(page->title), ui_menu_cb_open_page, (void*)page);
}

ui_menu_item_t* ui_menu_add_menu(const ui_menu_t* m, const ui_menu_t* menu) {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/toast.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ static size_t text_wrap(size_t col, const char* text, text_wrap_cb_t cb, void* c

i = 0;
text_lines++;
} else if (*ptr == ' ') {
} else if (*ptr == ' ' || *ptr == '-') {
space = ptr + 1;
}
}
Expand Down
Loading