Skip to content

Commit

Permalink
Merge pull request #71 from MausTec/recording-fix
Browse files Browse the repository at this point in the history
recording fix
  • Loading branch information
MauAbata authored Feb 26, 2024
2 parents 088a986 + 6051860 commit db7d4c6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
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

0 comments on commit db7d4c6

Please sign in to comment.