Skip to content

Commit

Permalink
Roll back to previous method signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
Master92 committed Nov 18, 2024
1 parent c95dd78 commit 5f9243c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/core/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "util/sdcard.h"
#include "util/system.h"

void (*sdcard_ready_cb)(void(*)()) = NULL;
void (*sdcard_ready_cb)() = NULL;

///////////////////////////////////////////////////////////////////////////////
// SD card exist
Expand All @@ -51,7 +51,7 @@ static void detect_sdcard(void) {
if (g_init_done) {
if (sdcard_init_scan && g_sdcard_enable) {
if (sdcard_ready_cb) {
sdcard_ready_cb(NULL);
sdcard_ready_cb();
}
sdcard_init_scan = false;
} else if (!g_sdcard_enable && sdcard_enable_last) {
Expand Down
20 changes: 12 additions & 8 deletions src/ui/page_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "util/sdcard.h"
#include "util/system.h"

extern void (*sdcard_ready_cb)(void(*)());
extern void (*sdcard_ready_cb)();

/**
* Types
Expand Down Expand Up @@ -551,6 +551,14 @@ static void page_storage_on_click(uint8_t key, int sel) {
static void page_storage_on_right_button(bool is_short) {
}

static void page_storage_post_bootup_action(void (*complete_callback)()) {
page_storage_init_auto_sd_repair();

if (complete_callback != NULL) {
complete_callback();
}
}

/**
* Main Menu page data structure, notice max is set to zero
* in order to allow us to override default user input logic.
Expand All @@ -570,14 +578,13 @@ page_pack_t pp_storage = {
.on_click = page_storage_on_click,
.on_right_button = page_storage_on_right_button,
.post_bootup_run_priority = 50,
.post_bootup_run_function = page_storage_init_auto_sd_repair,
.post_bootup_run_function = page_storage_post_bootup_action,
};

/**
* Worker thread for repairing SD Card.
*/
static void *page_storage_repair_thread(void *arg) {
void (*complete_callback)() = arg;
char buf[128];
if (!page_storage.disable_controls) {
page_storage.is_auto_sd_repair_active = true;
Expand All @@ -592,9 +599,6 @@ static void *page_storage_repair_thread(void *arg) {
page_storage.is_sd_repair_complete = true;
sdcard_ready_cb = page_storage_init_auto_sd_repair;

if (complete_callback != NULL) {
complete_callback();
}
pthread_exit(NULL);
}

Expand All @@ -608,11 +612,11 @@ bool page_storage_is_sd_repair_active() {
/**
* Once initialized detach until completed.
*/
void page_storage_init_auto_sd_repair(void (*complete_callback)()) {
void page_storage_init_auto_sd_repair() {
page_storage.is_sd_repair_complete = false;
if (!page_storage.is_auto_sd_repair_active) {
pthread_t tid;
if (!pthread_create(&tid, NULL, page_storage_repair_thread, complete_callback)) {
if (!pthread_create(&tid, NULL, page_storage_repair_thread, NULL)) {
pthread_detach(tid);
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/page_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ extern "C" {
extern page_pack_t pp_storage;

bool page_storage_is_sd_repair_active();
void page_storage_init_auto_sd_repair(void(*complete_callback)());
void page_storage_init_auto_sd_repair();

#ifdef __cplusplus
}
Expand Down
14 changes: 11 additions & 3 deletions src/ui/page_wifi.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ static void page_wifi_mask_password(lv_obj_t *obj, int size) {
* Note: This function will be invoked asynchronously post bootup and may
* require additional APP_STATE checks to ensure integrity of execution.
*/
static void page_wifi_update_settings(void (*complete_callback)()) {
static void page_wifi_update_settings() {
g_setting.wifi.enable = btn_group_get_sel(&page_wifi.page_1.enable.button) == 0;
g_setting.wifi.mode = btn_group_get_sel(&page_wifi.page_1.mode.button);
g_setting.wifi.dhcp = btn_group_get_sel(&page_wifi.page_2.dhcp.button) == 0;
Expand Down Expand Up @@ -589,7 +589,7 @@ static void page_wifi_apply_settings_pending_cb(struct _lv_timer_t *timer) {
* Callback invoked once `Apply Settings` is triggered and confirmed via the menu.
*/
static void page_wifi_apply_settings_timer_cb(struct _lv_timer_t *timer) {
page_wifi_update_settings(NULL);
page_wifi_update_settings();
page_wifi_dirty_flag_reset();
page_wifi_apply_settings_reset();
}
Expand Down Expand Up @@ -1147,6 +1147,14 @@ static void page_wifi_on_right_button(bool is_short) {
}
}

void page_wifi_post_bootup_action(void (*complete_callback)()) {
page_wifi_update_settings();

if (complete_callback != NULL) {
complete_callback();
}
}

/**
* Main Menu page data structure, notice max is set to zero
* in order to allow us to override default user input logic.
Expand All @@ -1166,7 +1174,7 @@ page_pack_t pp_wifi = {
.on_click = page_wifi_on_click,
.on_right_button = page_wifi_on_right_button,
.post_bootup_run_priority = 100,
.post_bootup_run_function = page_wifi_update_settings,
.post_bootup_run_function = page_wifi_post_bootup_action,
};

/**
Expand Down

0 comments on commit 5f9243c

Please sign in to comment.