Align code style (#40)

- Mutex -> Mutex*
- Cleanup enum names
- Other small changes
This commit is contained in:
Ken Van Hoeylandt 2024-02-11 00:58:43 +01:00 committed by GitHub
parent 9327d61427
commit e0db8767c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
30 changed files with 117 additions and 121 deletions

View File

@ -133,5 +133,5 @@ const SdCard tdeck_sdcard = {
.mount = &sdcard_init_and_mount,
.unmount = &sdcard_unmount,
.is_mounted = &sdcard_is_mounted,
.mount_behaviour = SDCARD_MOUNT_BEHAVIOUR_AT_BOOT
.mount_behaviour = SdcardMountBehaviourAtBoot
};

View File

@ -75,5 +75,5 @@ const SdCard twodotfour_sdcard = {
.mount = &sdcard_mount,
.unmount = &sdcard_unmount,
.is_mounted = &sdcard_is_mounted,
.mount_behaviour = SDCARD_MOUNT_BEHAVIOUR_ANYTIME
.mount_behaviour = SdcardMountBehaviourAnytime
};

View File

@ -6,11 +6,11 @@
- Show a warning screen when a user plugs in the SD card on a device that only supports mounting at boot.
- Try out Waveshare S3 120MHz mode for PSRAM (see "enabling 120M PSRAM is necessary" in [docs](https://www.waveshare.com/wiki/ESP32-S3-Touch-LCD-4.3#Other_Notes))
- T-Deck has random sdcard SPI crashes due to sharing bus with screen SPI: make it use the LVGL lock for sdcard operations?
- Wi-Fi connect app should show info about connection result
# Core Ideas
- Make a HAL? It would mainly be there to support PC development. It's a lot of effort for supporting what's effectively a dev-only feature.
- Support for displays with different DPI. Consider the layer-based system like on Android.
- Display orientation support for Display app
- If present, use LED to show boot status
- 2 wire speaker support
- tt_app_start() and similar functions as proxies for Loader app start/stop/etc.
@ -22,10 +22,11 @@
- Light/dark mode selection in Display settings app.
# App Ideas
- Chip 8 emulator
- Discord bot
- BadUSB
- IR transceiver app
- File viewer (images, text... binary?)
- GPIO status viewer
- BlueTooth keyboard app
- Chip 8 emulator
- BadUSB
- Discord bot
- IR transceiver app
- Investigate CSI https://stevenmhernandez.github.io/ESP32-CSI-Tool/

View File

@ -7,9 +7,9 @@
// region BundleEntry
typedef enum {
BUNDLE_ENTRY_TYPE_BOOL,
BUNDLE_ENTRY_TYPE_INT32,
BUNDLE_ENTRY_TYPE_STRING,
BundleEntryTypeBool,
BundleEntryTypeInt32,
BundleEntryTypeString,
} BundleEntryType;
typedef struct {
@ -23,21 +23,21 @@ typedef struct {
BundleEntry* bundle_entry_alloc_bool(bool value) {
BundleEntry* entry = malloc(sizeof(BundleEntry));
entry->type = BUNDLE_ENTRY_TYPE_BOOL;
entry->type = BundleEntryTypeBool;
entry->bool_value = value;
return entry;
}
BundleEntry* bundle_entry_alloc_int32(int32_t value) {
BundleEntry* entry = malloc(sizeof(BundleEntry));
entry->type = BUNDLE_ENTRY_TYPE_INT32;
entry->type = BundleEntryTypeInt32;
entry->int32_value = value;
return entry;
}
BundleEntry* bundle_entry_alloc_string(const char* text) {
BundleEntry* entry = malloc(sizeof(BundleEntry));
entry->type = BUNDLE_ENTRY_TYPE_STRING;
entry->type = BundleEntryTypeString;
entry->string_ptr = malloc(strlen(text) + 1);
strcpy(entry->string_ptr, text);
return entry;
@ -46,7 +46,7 @@ BundleEntry* bundle_entry_alloc_string(const char* text) {
BundleEntry* bundle_entry_alloc_copy(BundleEntry* source) {
BundleEntry* entry = malloc(sizeof(BundleEntry));
entry->type = source->type;
if (source->type == BUNDLE_ENTRY_TYPE_STRING) {
if (source->type == BundleEntryTypeString) {
entry->string_ptr = malloc(strlen(source->string_ptr) + 1);
strcpy(entry->string_ptr, source->string_ptr);
} else {
@ -56,7 +56,7 @@ BundleEntry* bundle_entry_alloc_copy(BundleEntry* source) {
}
void bundle_entry_free(BundleEntry* entry) {
if (entry->type == BUNDLE_ENTRY_TYPE_STRING) {
if (entry->type == BundleEntryTypeString) {
free(entry->string_ptr);
}
free(entry);
@ -129,19 +129,19 @@ const char* tt_bundle_get_string(Bundle bundle, const char* key) {
bool tt_bundle_has_bool(Bundle bundle, const char* key) {
BundleData* data = (BundleData*)bundle;
BundleEntry** entry = BundleDict_get(data->dict, key);
return (entry != NULL) && ((*entry)->type == BUNDLE_ENTRY_TYPE_BOOL);
return (entry != NULL) && ((*entry)->type == BundleEntryTypeBool);
}
bool tt_bundle_has_int32(Bundle bundle, const char* key) {
BundleData* data = (BundleData*)bundle;
BundleEntry** entry = BundleDict_get(data->dict, key);
return (entry != NULL) && ((*entry)->type == BUNDLE_ENTRY_TYPE_INT32);
return (entry != NULL) && ((*entry)->type == BundleEntryTypeInt32);
}
bool tt_bundle_has_string(Bundle bundle, const char* key) {
BundleData* data = (BundleData*)bundle;
BundleEntry** entry = BundleDict_get(data->dict, key);
return (entry != NULL) && ((*entry)->type == BUNDLE_ENTRY_TYPE_STRING);
return (entry != NULL) && ((*entry)->type == BundleEntryTypeString);
}
bool tt_bundle_opt_bool(Bundle bundle, const char* key, bool* out) {
@ -149,7 +149,7 @@ bool tt_bundle_opt_bool(Bundle bundle, const char* key, bool* out) {
BundleEntry** entry_ptr = BundleDict_get(data->dict, key);
if (entry_ptr != NULL) {
BundleEntry* entry = *entry_ptr;
if (entry->type == BUNDLE_ENTRY_TYPE_BOOL) {
if (entry->type == BundleEntryTypeBool) {
*out = entry->bool_value;
return true;
} else {
@ -165,7 +165,7 @@ bool tt_bundle_opt_int32(Bundle bundle, const char* key, int32_t* out) {
BundleEntry** entry_ptr = BundleDict_get(data->dict, key);
if (entry_ptr != NULL) {
BundleEntry* entry = *entry_ptr;
if (entry->type == BUNDLE_ENTRY_TYPE_INT32) {
if (entry->type == BundleEntryTypeInt32) {
*out = entry->int32_value;
return true;
} else {
@ -181,7 +181,7 @@ bool tt_bundle_opt_string(Bundle bundle, const char* key, char** out) {
BundleEntry** entry_ptr = BundleDict_get(data->dict, key);
if (entry_ptr != NULL) {
BundleEntry* entry = *entry_ptr;
if (entry->type == BUNDLE_ENTRY_TYPE_STRING) {
if (entry->type == BundleEntryTypeString) {
*out = entry->string_ptr;
return true;
} else {
@ -197,7 +197,7 @@ void tt_bundle_put_bool(Bundle bundle, const char* key, bool value) {
BundleEntry** entry_handle = BundleDict_get(data->dict, key);
if (entry_handle != NULL) {
BundleEntry* entry = *entry_handle;
tt_assert(entry->type == BUNDLE_ENTRY_TYPE_BOOL);
tt_assert(entry->type == BundleEntryTypeBool);
entry->bool_value = value;
} else {
BundleEntry* entry = bundle_entry_alloc_bool(value);
@ -210,7 +210,7 @@ void tt_bundle_put_int32(Bundle bundle, const char* key, int32_t value) {
BundleEntry** entry_handle = BundleDict_get(data->dict, key);
if (entry_handle != NULL) {
BundleEntry* entry = *entry_handle;
tt_assert(entry->type == BUNDLE_ENTRY_TYPE_INT32);
tt_assert(entry->type == BundleEntryTypeInt32);
entry->int32_value = value;
} else {
BundleEntry* entry = bundle_entry_alloc_int32(value);
@ -223,7 +223,7 @@ void tt_bundle_put_string(Bundle bundle, const char* key, const char* value) {
BundleEntry** entry_handle = BundleDict_get(data->dict, key);
if (entry_handle != NULL) {
BundleEntry* entry = *entry_handle;
tt_assert(entry->type == BUNDLE_ENTRY_TYPE_STRING);
tt_assert(entry->type == BundleEntryTypeString);
if (entry->string_ptr != NULL) {
free(entry->string_ptr);
}

View File

@ -197,8 +197,8 @@ void tt_delay_us(uint32_t microseconds) {
Platform tt_get_platform() {
#ifdef ESP_PLATFORM
return PLATFORM_ESP;
return PlatformEsp;
#else
return PLATFORM_PC;
return PlatformPc;
#endif
}

View File

@ -7,8 +7,8 @@ extern "C" {
#endif
typedef enum {
PLATFORM_ESP,
PLATFORM_PC
PlatformEsp,
PlatformPc
} Platform;
/** Check if CPU is in IRQ or kernel running and IRQ is masked

View File

@ -13,15 +13,15 @@
static char tt_loglevel_to_prefix(LogLevel level) {
switch (level) {
case LOG_LEVEL_ERROR:
case LogLevelError:
return 'E';
case LOG_LEVEL_WARNING:
case LogLevelWarning:
return 'W';
case LOG_LEVEL_INFO:
case LogLevelInfo:
return 'I';
case LOG_LEVEL_DEBUG:
case LogLevelDebug:
return 'D';
case LOG_LEVEL_TRACE:
case LogLevelTrace:
return 'T';
default:
return '?';
@ -30,15 +30,15 @@ static char tt_loglevel_to_prefix(LogLevel level) {
static const char* tt_loglevel_to_colour(LogLevel level) {
switch (level) {
case LOG_LEVEL_ERROR:
case LogLevelError:
return "\033[1;31m";
case LOG_LEVEL_WARNING:
case LogLevelWarning:
return "\033[33m";
case LOG_LEVEL_INFO:
case LogLevelInfo:
return "\033[32m";
case LOG_LEVEL_DEBUG:
case LogLevelDebug:
return "\033[1;37m";
case LOG_LEVEL_TRACE:
case LogLevelTrace:
return "\033[37m";
default:
return "";

View File

@ -27,23 +27,23 @@ extern "C" {
#else
typedef enum {
LOG_LEVEL_ERROR,
LOG_LEVEL_WARNING,
LOG_LEVEL_INFO,
LOG_LEVEL_DEBUG,
LOG_LEVEL_TRACE
LogLevelError,
LogLevelWarning,
LogLevelInfo,
LogLevelDebug,
LogLevelTrace
} LogLevel;
void tt_log(LogLevel level, const char* tag, const char* format, ...);
#define TT_LOG_E(tag, format, ...) \
tt_log(LOG_LEVEL_ERROR, tag, format, ##__VA_ARGS__)
tt_log(LogLevelError, tag, format, ##__VA_ARGS__)
#define TT_LOG_W(tag, format, ...) \
tt_log(LOG_LEVEL_WARNING, tag, format, ##__VA_ARGS__)
tt_log(LogLevelWarning, tag, format, ##__VA_ARGS__)
#define TT_LOG_I(tag, format, ...) \
tt_log(LOG_LEVEL_INFO, tag, format, ##__VA_ARGS__)
tt_log(LogLevelInfo, tag, format, ##__VA_ARGS__)
#define TT_LOG_D(tag, format, ...) \
tt_log(LOG_LEVEL_DEBUG, tag, format, ##__VA_ARGS__)
tt_log(LogLevelDebug, tag, format, ##__VA_ARGS__)
#define TT_LOG_T(tag, format, ...) \
tt_log(LOG_LEVEL_TRACE, tag, format, ##__VA_ARGS__)

View File

@ -33,7 +33,7 @@ void tt_mutex_info(Mutex mutex, const char* label) {
#define tt_mutex_info(mutex, text)
#endif
Mutex tt_mutex_alloc(MutexType type) {
Mutex* tt_mutex_alloc(MutexType type) {
tt_assert(!TT_IS_IRQ_MODE());
MutexData* data = malloc(sizeof(MutexData));
@ -52,10 +52,10 @@ Mutex tt_mutex_alloc(MutexType type) {
tt_check(data->handle != NULL);
tt_mutex_info(data, "alloc ");
return (Mutex)data;
return (Mutex*)data;
}
void tt_mutex_free(Mutex mutex) {
void tt_mutex_free(Mutex* mutex) {
tt_assert(!TT_IS_IRQ_MODE());
tt_assert(mutex);
@ -66,7 +66,7 @@ void tt_mutex_free(Mutex mutex) {
free(data);
}
TtStatus tt_mutex_acquire(Mutex mutex, uint32_t timeout) {
TtStatus tt_mutex_acquire(Mutex* mutex, uint32_t timeout) {
tt_assert(mutex);
tt_assert(!TT_IS_IRQ_MODE());
MutexData* data = (MutexData*)mutex;
@ -101,7 +101,7 @@ TtStatus tt_mutex_acquire(Mutex mutex, uint32_t timeout) {
return status;
}
TtStatus tt_mutex_release(Mutex mutex) {
TtStatus tt_mutex_release(Mutex* mutex) {
tt_assert(mutex);
assert(!TT_IS_IRQ_MODE());
MutexData* data = (MutexData*)mutex;
@ -129,7 +129,7 @@ TtStatus tt_mutex_release(Mutex mutex) {
return status;
}
ThreadId tt_mutex_get_owner(Mutex mutex) {
ThreadId tt_mutex_get_owner(Mutex* mutex) {
tt_assert(mutex != NULL);
tt_assert(!TT_IS_IRQ_MODE());
MutexData* data = (MutexData*)mutex;

View File

@ -16,7 +16,7 @@ typedef enum {
MutexTypeRecursive,
} MutexType;
typedef void* Mutex;
typedef void Mutex;
/** Allocate Mutex
*
@ -24,13 +24,13 @@ typedef void* Mutex;
*
* @return pointer to Mutex instance
*/
Mutex tt_mutex_alloc(MutexType type);
Mutex* tt_mutex_alloc(MutexType type);
/** Free Mutex
*
* @param mutex The Mutex instance
*/
void tt_mutex_free(Mutex mutex);
void tt_mutex_free(Mutex* mutex);
/** Acquire mutex
*
@ -39,7 +39,7 @@ void tt_mutex_free(Mutex mutex);
*
* @return The status.
*/
TtStatus tt_mutex_acquire(Mutex mutex, uint32_t timeout);
TtStatus tt_mutex_acquire(Mutex* mutex, uint32_t timeout);
/** Release mutex
*
@ -47,7 +47,7 @@ TtStatus tt_mutex_acquire(Mutex mutex, uint32_t timeout);
*
* @return The status.
*/
TtStatus tt_mutex_release(Mutex mutex);
TtStatus tt_mutex_release(Mutex* mutex);
/** Get mutex owner thread id
*
@ -55,7 +55,7 @@ TtStatus tt_mutex_release(Mutex mutex);
*
* @return The thread identifier.
*/
ThreadId tt_mutex_get_owner(Mutex mutex);
ThreadId tt_mutex_get_owner(Mutex* mutex);
#ifdef __cplusplus
}

View File

@ -13,7 +13,7 @@ LIST_DEF(PubSubSubscriptionList, PubSubSubscription, M_POD_OPLIST);
struct PubSub {
PubSubSubscriptionList_t items;
Mutex mutex;
Mutex* mutex;
};
PubSub* tt_pubsub_alloc() {

View File

@ -12,7 +12,7 @@ extern "C" {
typedef struct {
PubSubSubscription* wifi_subscription;
Mutex mutex;
Mutex* mutex;
WifiConnectState state;
WifiConnectView view;
bool view_enabled;

View File

@ -10,7 +10,7 @@ extern "C" {
typedef struct {
PubSubSubscription* wifi_subscription;
Mutex mutex;
Mutex* mutex;
WifiManageState state;
WifiManageView view;
bool view_enabled;

View File

@ -19,7 +19,7 @@
typedef struct {
/** @brief Locking mechanism for modifying the Wifi instance */
Mutex mutex;
Mutex* mutex;
/** @brief The public event bus */
PubSub* pubsub;
/** @brief The internal message queue */

View File

@ -15,7 +15,7 @@ static void hash_reset_all();
// region Hash
static Mutex hash_mutex = NULL;
static Mutex* hash_mutex = NULL;
static int8_t hash_index = -1;
static uint32_t hashes[TT_WIFI_CREDENTIALS_LIMIT] = { 0 };

View File

@ -22,7 +22,7 @@ App tt_app_alloc(const AppManifest* manifest, Bundle* _Nullable parameters) {
AppData* data = malloc(sizeof(AppData));
*data = (AppData) {
.mutex = tt_mutex_alloc(MutexTypeNormal),
.state = APP_STATE_INITIAL,
.state = AppStateInitial,
.flags = tt_app_get_flags_default(manifest->type),
.manifest = manifest,
.parameters = parameters,

View File

@ -8,11 +8,11 @@ extern "C" {
#endif
typedef enum {
APP_STATE_INITIAL, // App is being activated in loader
APP_STATE_STARTED, // App is in memory
APP_STATE_SHOWING, // App view is created
APP_STATE_HIDING, // App view is destroyed
APP_STATE_STOPPED // App is not in memory
AppStateInitial, // App is being activated in loader
AppStateStarted, // App is in memory
AppStateShowing, // App view is created
AppStateHiding, // App view is destroyed
AppStateStopped // App is not in memory
} AppState;
typedef union {

View File

@ -11,7 +11,7 @@ extern "C" {
#endif
typedef struct {
Mutex mutex;
Mutex* mutex;
const AppManifest* manifest;
AppState state;
/** @brief Memory marker at start of app, to detect memory leaks */

View File

@ -21,7 +21,7 @@ DICT_DEF2(AppManifestDict, const char*, M_CSTR_DUP_OPLIST, const AppManifest*, M
}
AppManifestDict_t app_manifest_dict;
Mutex hash_mutex = NULL;
Mutex* hash_mutex = NULL;
void tt_app_manifest_registry_init() {
tt_assert(hash_mutex == NULL);

View File

@ -66,7 +66,7 @@ bool files_data_set_entries_for_path(FilesData* data, const char* path) {
* ESP32 does not have a root directory, so we have to create it manually.
* We'll add the NVS Flash partitions and the binding for the sdcard.
*/
if (tt_get_platform() == PLATFORM_ESP && strcmp(path, "/") == 0) {
if (tt_get_platform() == PlatformEsp && strcmp(path, "/") == 0) {
int dir_entries_count = 3;
struct dirent** dir_entries = malloc(sizeof(struct dirent*) * 3);

View File

@ -5,7 +5,7 @@
#define TAG "sdcard"
static Mutex mutex = NULL;
static Mutex* mutex = NULL;
typedef struct {
const SdCard* sdcard;
@ -59,16 +59,11 @@ bool tt_sdcard_mount(const SdCard* sdcard) {
SdcardState tt_sdcard_get_state() {
if (data.context == NULL) {
return SDCARD_STATE_UNMOUNTED;
return SdcardStateUnmounted;
} else if (data.sdcard->is_mounted(data.context)) {
return SdcardStateMounted;
} else {
// TODO: Side-effects are not great - consider refactoring this, so:
// Consider making tt_sdcard_get_status() that can return an error state
// The sdcard service can then auto-dismount
if (data.sdcard->is_mounted(data.context)) {
return SDCARD_STATE_MOUNTED;
} else {
return SDCARD_STATE_ERROR;
}
return SdcardStateError;
}
}

View File

@ -13,14 +13,14 @@ typedef void (*SdcardUnmount)(void* context);
typedef bool (*SdcardIsMounted)(void* context);
typedef enum {
SDCARD_STATE_MOUNTED,
SDCARD_STATE_UNMOUNTED,
SDCARD_STATE_ERROR,
SdcardStateMounted,
SdcardStateUnmounted,
SdcardStateError,
} SdcardState;
typedef enum {
SDCARD_MOUNT_BEHAVIOUR_AT_BOOT, /** Only mount at boot */
SDCARD_MOUNT_BEHAVIOUR_ANYTIME /** Mount/dismount any time */
SdcardMountBehaviourAtBoot, /** Only mount at boot */
SdcardMountBehaviourAnytime /** Mount/dismount any time */
} SdcardMountBehaviour;
typedef struct {

View File

@ -6,7 +6,7 @@
#include "service_manifest.h"
typedef struct {
Mutex mutex;
Mutex* mutex;
const ServiceManifest* manifest;
void* data;
} ServiceData;

View File

@ -25,8 +25,8 @@ DICT_DEF2(ServiceInstanceDict, const char*, M_CSTR_DUP_OPLIST, const ServiceData
static ServiceManifestDict_t service_manifest_dict;
static ServiceInstanceDict_t service_instance_dict;
static Mutex manifest_mutex = NULL;
static Mutex instance_mutex = NULL;
static Mutex* manifest_mutex = NULL;
static Mutex* instance_mutex = NULL;
void tt_service_registry_init() {
tt_assert(manifest_mutex == NULL);

View File

@ -17,7 +17,7 @@
struct Gui {
// Thread and lock
Thread* thread;
Mutex mutex;
Mutex* mutex;
// Layers and Canvas
lv_obj_t* lvgl_parent;

View File

@ -109,15 +109,15 @@ PubSub* loader_get_pubsub() {
static const char* app_state_to_string(AppState state) {
switch (state) {
case APP_STATE_INITIAL:
case AppStateInitial:
return "initial";
case APP_STATE_STARTED:
case AppStateStarted:
return "started";
case APP_STATE_SHOWING:
case AppStateShowing:
return "showing";
case APP_STATE_HIDING:
case AppStateHiding:
return "hiding";
case APP_STATE_STOPPED:
case AppStateStopped:
return "stopped";
default:
return "?";
@ -137,33 +137,33 @@ static void app_transition_to_state(App app, AppState state) {
);
switch (state) {
case APP_STATE_INITIAL:
tt_app_set_state(app, APP_STATE_INITIAL);
case AppStateInitial:
tt_app_set_state(app, AppStateInitial);
break;
case APP_STATE_STARTED:
case AppStateStarted:
if (manifest->on_start != NULL) {
manifest->on_start(app);
}
tt_app_set_state(app, APP_STATE_STARTED);
tt_app_set_state(app, AppStateStarted);
break;
case APP_STATE_SHOWING:
case AppStateShowing:
gui_show_app(
app,
manifest->on_show,
manifest->on_hide
);
tt_app_set_state(app, APP_STATE_SHOWING);
tt_app_set_state(app, AppStateShowing);
break;
case APP_STATE_HIDING:
case AppStateHiding:
gui_hide_app();
tt_app_set_state(app, APP_STATE_HIDING);
tt_app_set_state(app, AppStateHiding);
break;
case APP_STATE_STOPPED:
case AppStateStopped:
if (manifest->on_stop) {
manifest->on_stop(app);
}
tt_app_set_data(app, NULL);
tt_app_set_state(app, APP_STATE_STOPPED);
tt_app_set_state(app, AppStateStopped);
break;
}
}
@ -187,16 +187,16 @@ LoaderStatus loader_do_start_app_with_manifest(
App app = tt_app_alloc(manifest, bundle);
tt_assert(loader_singleton->app_stack[loader_singleton->app_stack_index] == NULL);
loader_singleton->app_stack[loader_singleton->app_stack_index] = app;
app_transition_to_state(app, APP_STATE_INITIAL);
app_transition_to_state(app, APP_STATE_STARTED);
app_transition_to_state(app, AppStateInitial);
app_transition_to_state(app, AppStateStarted);
// We might have to hide the previous app first
if (previous_index != -1) {
App previous_app = loader_singleton->app_stack[previous_index];
app_transition_to_state(previous_app, APP_STATE_HIDING);
app_transition_to_state(previous_app, AppStateHiding);
}
app_transition_to_state(app, APP_STATE_SHOWING);
app_transition_to_state(app, AppStateShowing);
loader_unlock();
@ -240,8 +240,8 @@ static void loader_do_stop_app() {
// Stop current app
App app_to_stop = loader_singleton->app_stack[current_app_index];
app_transition_to_state(app_to_stop, APP_STATE_HIDING);
app_transition_to_state(app_to_stop, APP_STATE_STOPPED);
app_transition_to_state(app_to_stop, AppStateHiding);
app_transition_to_state(app_to_stop, AppStateStopped);
tt_app_free(app_to_stop);
loader_singleton->app_stack[current_app_index] = NULL;
@ -254,7 +254,7 @@ static void loader_do_stop_app() {
// Resume previous app
tt_assert(loader_singleton->app_stack[loader_singleton->app_stack_index] != NULL);
App app_to_resume = loader_singleton->app_stack[loader_singleton->app_stack_index];
app_transition_to_state(app_to_resume, APP_STATE_SHOWING);
app_transition_to_state(app_to_resume, AppStateShowing);
loader_unlock();

View File

@ -22,7 +22,7 @@ struct Loader {
Thread* thread;
PubSub* pubsub;
MessageQueue* queue;
Mutex mutex;
Mutex* mutex;
int8_t app_stack_index;
App app_stack[APP_STACK_SIZE];
};

View File

@ -12,7 +12,7 @@
static int32_t sdcard_task(TT_UNUSED void* context);
typedef struct {
Mutex mutex;
Mutex* mutex;
Thread* thread;
SdcardState last_state;
int8_t statusbar_icon_id;
@ -65,14 +65,14 @@ static int32_t sdcard_task(void* context) {
SdcardState new_state = tt_sdcard_get_state();
if (new_state == SDCARD_STATE_ERROR) {
if (new_state == SdcardStateError) {
TT_LOG_W(TAG, "Sdcard error - unmounting. Did you eject the card in an unsafe manner?");
tt_sdcard_unmount();
}
if (new_state != data->last_state) {
TT_LOG_I(TAG, "State change %d -> %d", data->last_state, new_state);
if (new_state == SDCARD_STATE_MOUNTED) {
if (new_state == SdcardStateMounted) {
tt_statusbar_icon_set_image(data->statusbar_icon_id, TT_ASSETS_ICON_SDCARD);
} else {
tt_statusbar_icon_set_image(data->statusbar_icon_id, TT_ASSETS_ICON_SDCARD_ALERT);

View File

@ -18,7 +18,7 @@ typedef struct {
} StatusbarIcon;
typedef struct {
Mutex mutex;
Mutex* mutex;
PubSub* pubsub;
StatusbarIcon icons[STATUSBAR_ICON_LIMIT];
} StatusbarData;

View File

@ -3,13 +3,13 @@
#include "mutex.h"
static int thread_with_mutex_parameter(void* parameter) {
Mutex mutex = (Mutex)parameter;
Mutex* mutex = (Mutex*)parameter;
tt_mutex_acquire(mutex, TtWaitForever);
return 0;
}
TEST_CASE("a mutex can block a thread") {
Mutex mutex = tt_mutex_alloc(MutexTypeNormal);
Mutex* mutex = tt_mutex_alloc(MutexTypeNormal);
tt_mutex_acquire(mutex, TtWaitForever);
Thread* thread = tt_thread_alloc_ex(