Skip to content

Commit

Permalink
clangformat
Browse files Browse the repository at this point in the history
  • Loading branch information
akopachov committed Jul 5, 2023
1 parent ab7bbb9 commit 7054937
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
2 changes: 1 addition & 1 deletion features_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#endif
// End of FlipC.org definition checks

// If target firmware is not yet set, default it to OFW because there is no chance to force Flipper Devices to update their build pipelines :angry:.
// If target firmware is not yet set, default it to OFW because there is no chance to force Flipper Devices to update their build pipelines :angry:.
// I'm still using Xtreme firmware, it is still the best one and I highly recommend it to everybody.
#ifndef TOTP_TARGET_FIRMWARE
#define TOTP_TARGET_FIRMWARE TOTP_FIRMWARE_OFFICIAL_STABLE
Expand Down
22 changes: 13 additions & 9 deletions services/idle_timeout/idle_timeout.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <furi/core/timer.h>

#define IDLE_TIMER_CHECK_PERIODICITY_SEC (1)
#define SEC_TO_TICKS(sec) ((sec) * 1000)
#define SEC_TO_TICKS(sec) ((sec)*1000)

struct IdleTimeoutContext {
FuriTimer* timer;
Expand All @@ -17,25 +17,29 @@ struct IdleTimeoutContext {

static void idle_timer_callback(void* context) {
IdleTimeoutContext* instance = context;
if (instance->activity_reported) {
if(instance->activity_reported) {
instance->idle_period_sec = 0;
instance->idle_handled = false;
instance->activity_reported = false;
} else if (!instance->idle_handled) {
if (instance->idle_period_sec >= instance->timeout_sec) {
instance->idle_handled = instance->on_idle_callback(instance->on_idle_callback_context);
} else if(!instance->idle_handled) {
if(instance->idle_period_sec >= instance->timeout_sec) {
instance->idle_handled =
instance->on_idle_callback(instance->on_idle_callback_context);
} else {
instance->idle_period_sec += IDLE_TIMER_CHECK_PERIODICITY_SEC;
}
}
}
}

IdleTimeoutContext* idle_timeout_alloc(uint16_t timeout_sec, IDLE_TIMEOUT_CALLBACK on_idle_callback, void* on_idle_callback_context) {
IdleTimeoutContext* idle_timeout_alloc(
uint16_t timeout_sec,
IDLE_TIMEOUT_CALLBACK on_idle_callback,
void* on_idle_callback_context) {
IdleTimeoutContext* instance = malloc(sizeof(IdleTimeoutContext));
if (instance == NULL) return NULL;
if(instance == NULL) return NULL;

instance->timer = furi_timer_alloc(&idle_timer_callback, FuriTimerTypePeriodic, instance);
if (instance->timer == NULL) return NULL;
if(instance->timer == NULL) return NULL;

instance->timeout_sec = timeout_sec;
instance->on_idle_callback = on_idle_callback;
Expand Down
5 changes: 4 additions & 1 deletion services/idle_timeout/idle_timeout.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ typedef bool (*IDLE_TIMEOUT_CALLBACK)(void* context);
* @param on_idle_callback_context callback function context
* @return IDLE timeout context
*/
IdleTimeoutContext* idle_timeout_alloc(uint16_t timeout_sec, IDLE_TIMEOUT_CALLBACK on_idle_callback, void* on_idle_callback_context);
IdleTimeoutContext* idle_timeout_alloc(
uint16_t timeout_sec,
IDLE_TIMEOUT_CALLBACK on_idle_callback,
void* on_idle_callback_context);

/**
* @brief Starts IDLE timeout
Expand Down
9 changes: 5 additions & 4 deletions totp_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static bool totp_activate_initial_scene(PluginState* const plugin_state) {
static bool on_user_idle(void* context) {
PluginState* plugin_state = context;
if(plugin_state->current_scene != TotpSceneAuthentication &&
plugin_state->current_scene != TotpSceneStandby) {
plugin_state->current_scene != TotpSceneStandby) {
totp_scene_director_activate_scene(plugin_state, TotpSceneAuthentication);
return true;
}
Expand Down Expand Up @@ -136,8 +136,9 @@ static bool totp_plugin_state_init(PluginState* const plugin_state) {
}
#endif

if (plugin_state->pin_set) {
plugin_state->idle_timeout_context = idle_timeout_alloc(TOTP_AUTO_LOCK_IDLE_TIMEOUT_SEC, &on_user_idle, plugin_state);
if(plugin_state->pin_set) {
plugin_state->idle_timeout_context =
idle_timeout_alloc(TOTP_AUTO_LOCK_IDLE_TIMEOUT_SEC, &on_user_idle, plugin_state);
idle_timeout_start(plugin_state->idle_timeout_context);
} else {
plugin_state->idle_timeout_context = NULL;
Expand All @@ -147,7 +148,7 @@ static bool totp_plugin_state_init(PluginState* const plugin_state) {
}

static void totp_plugin_state_free(PluginState* plugin_state) {
if (plugin_state->idle_timeout_context != NULL) {
if(plugin_state->idle_timeout_context != NULL) {
idle_timeout_stop(plugin_state->idle_timeout_context);
idle_timeout_free(plugin_state->idle_timeout_context);
}
Expand Down

0 comments on commit 7054937

Please sign in to comment.