Skip to content

Commit b7ca82a

Browse files
committed
Squashed 'pomodoro/' changes from d329978..b408703
b408703 fix catalog versions 2f006ba bump version e4d9959 Update apps 7bfa94d bump versions 5cee3bd fix cnt down timer & update pomodoro 793f8fa categories part 1 63f561c more manifestos, xbox controller and videopoker ufbt fixes a7b41b1 Add Screenshots 0a1b42c API 31 / unzip sources REVERT: d329978 feat: on-demand contextual chatting (#211) REVERT: 52cc11a feat: display stats (#97) REVERT: ddda80f ci(build): fix missing deed method (#198) REVERT: 2f2962d feat: long cycle (#42) (#45) REVERT: 925ebc6 feat: animated stage background (#39)(#32) REVERT: 70e3a71 refactor: modules structure (#11) REVERT: fa63582 feat: add happiness management (#10) REVERT: 57b1487 update images art REVERT: 621c6fd complete MVP REVERT: b3f442d add timer stage toggl REVERT: f49e172 add build infrastructure git-subtree-dir: pomodoro git-subtree-split: b408703
1 parent d329978 commit b7ca82a

19 files changed

+277
-373
lines changed

application.fam

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ App(
55
entry_point="flipp_pomodoro_app",
66
requires=["gui", "notification", "dolphin"],
77
stack_size=1 * 1024,
8-
fap_category="Productivity",
8+
fap_category="Tools",
99
fap_icon_assets="images",
1010
fap_icon="flipp_pomodoro_10.png",
11+
fap_author="@Th3Un1q3",
12+
fap_weburl="https://github.com/Th3Un1q3/flipp_pomodoro",
13+
fap_version="1.3",
14+
fap_description="Boost Your Productivity with the Pomodoro Timer",
1115
)

flipp_pomodoro_app.c

+25-31
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,36 @@
22

33
#define TAG "FlippPomodoro"
44

5-
enum
6-
{
5+
enum {
76
CustomEventConsumed = true,
87
CustomEventNotConsumed = false,
98
};
109

11-
static bool flipp_pomodoro_app_back_event_callback(void *ctx)
12-
{
10+
static bool flipp_pomodoro_app_back_event_callback(void* ctx) {
1311
furi_assert(ctx);
14-
FlippPomodoroApp *app = ctx;
12+
FlippPomodoroApp* app = ctx;
1513
return scene_manager_handle_back_event(app->scene_manager);
1614
};
1715

18-
static void flipp_pomodoro_app_tick_event_callback(void *ctx)
19-
{
16+
static void flipp_pomodoro_app_tick_event_callback(void* ctx) {
2017
furi_assert(ctx);
21-
FlippPomodoroApp *app = ctx;
18+
FlippPomodoroApp* app = ctx;
2219

2320
scene_manager_handle_custom_event(app->scene_manager, FlippPomodoroAppCustomEventTimerTick);
2421
};
2522

26-
static bool flipp_pomodoro_app_custom_event_callback(void *ctx, uint32_t event)
27-
{
23+
static bool flipp_pomodoro_app_custom_event_callback(void* ctx, uint32_t event) {
2824
furi_assert(ctx);
29-
FlippPomodoroApp *app = ctx;
25+
FlippPomodoroApp* app = ctx;
3026

31-
switch (event)
32-
{
27+
switch(event) {
3328
case FlippPomodoroAppCustomEventStageSkip:
3429
flipp_pomodoro__toggle_stage(app->state);
3530
view_dispatcher_send_custom_event(
36-
app->view_dispatcher,
37-
FlippPomodoroAppCustomEventStateUpdated);
31+
app->view_dispatcher, FlippPomodoroAppCustomEventStateUpdated);
3832
return CustomEventConsumed;
3933
case FlippPomodoroAppCustomEventStageComplete:
40-
if (flipp_pomodoro__get_stage(app->state) == FlippPomodoroStageFocus)
41-
{
34+
if(flipp_pomodoro__get_stage(app->state) == FlippPomodoroStageFocus) {
4235
// REGISTER a deed on work stage complete to get an acheivement
4336
dolphin_deed(DolphinDeedPluginGameWin);
4437
FURI_LOG_I(TAG, "Focus stage reward added");
@@ -47,20 +40,20 @@ static bool flipp_pomodoro_app_custom_event_callback(void *ctx, uint32_t event)
4740
};
4841

4942
flipp_pomodoro__toggle_stage(app->state);
50-
notification_message(app->notification_app, stage_start_notification_sequence_map[flipp_pomodoro__get_stage(app->state)]);
43+
notification_message(
44+
app->notification_app,
45+
stage_start_notification_sequence_map[flipp_pomodoro__get_stage(app->state)]);
5146
view_dispatcher_send_custom_event(
52-
app->view_dispatcher,
53-
FlippPomodoroAppCustomEventStateUpdated);
47+
app->view_dispatcher, FlippPomodoroAppCustomEventStateUpdated);
5448
return CustomEventConsumed;
5549
default:
5650
break;
5751
}
5852
return scene_manager_handle_custom_event(app->scene_manager, event);
5953
};
6054

61-
FlippPomodoroApp *flipp_pomodoro_app_alloc()
62-
{
63-
FlippPomodoroApp *app = malloc(sizeof(FlippPomodoroApp));
55+
FlippPomodoroApp* flipp_pomodoro_app_alloc() {
56+
FlippPomodoroApp* app = malloc(sizeof(FlippPomodoroApp));
6457
app->state = flipp_pomodoro__new();
6558

6659
app->scene_manager = scene_manager_alloc(&flipp_pomodoro_scene_handlers, app);
@@ -72,10 +65,13 @@ FlippPomodoroApp *flipp_pomodoro_app_alloc()
7265

7366
view_dispatcher_enable_queue(app->view_dispatcher);
7467
view_dispatcher_set_event_callback_context(app->view_dispatcher, app);
75-
view_dispatcher_set_custom_event_callback(app->view_dispatcher, flipp_pomodoro_app_custom_event_callback);
76-
view_dispatcher_set_tick_event_callback(app->view_dispatcher, flipp_pomodoro_app_tick_event_callback, 1000);
68+
view_dispatcher_set_custom_event_callback(
69+
app->view_dispatcher, flipp_pomodoro_app_custom_event_callback);
70+
view_dispatcher_set_tick_event_callback(
71+
app->view_dispatcher, flipp_pomodoro_app_tick_event_callback, 1000);
7772
view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
78-
view_dispatcher_set_navigation_event_callback(app->view_dispatcher, flipp_pomodoro_app_back_event_callback);
73+
view_dispatcher_set_navigation_event_callback(
74+
app->view_dispatcher, flipp_pomodoro_app_back_event_callback);
7975

8076
app->timer_view = flipp_pomodoro_view_timer_alloc();
8177
app->info_view = flipp_pomodoro_info_view_alloc();
@@ -95,8 +91,7 @@ FlippPomodoroApp *flipp_pomodoro_app_alloc()
9591
return app;
9692
};
9793

98-
void flipp_pomodoro_app_free(FlippPomodoroApp *app)
99-
{
94+
void flipp_pomodoro_app_free(FlippPomodoroApp* app) {
10095
view_dispatcher_remove_view(app->view_dispatcher, FlippPomodoroAppViewTimer);
10196
view_dispatcher_remove_view(app->view_dispatcher, FlippPomodoroAppViewInfo);
10297
view_dispatcher_free(app->view_dispatcher);
@@ -110,11 +105,10 @@ void flipp_pomodoro_app_free(FlippPomodoroApp *app)
110105
furi_record_close(RECORD_NOTIFICATION);
111106
};
112107

113-
int32_t flipp_pomodoro_app(void *p)
114-
{
108+
int32_t flipp_pomodoro_app(void* p) {
115109
UNUSED(p);
116110
FURI_LOG_I(TAG, "Initial");
117-
FlippPomodoroApp *app = flipp_pomodoro_app_alloc();
111+
FlippPomodoroApp* app = flipp_pomodoro_app_alloc();
118112

119113
FURI_LOG_I(TAG, "Run deed added");
120114
dolphin_deed(DolphinDeedPluginGameStart);

flipp_pomodoro_app.h

+11-14
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
#include "modules/flipp_pomodoro.h"
1313
#include "modules/flipp_pomodoro_statistics.h"
1414

15-
typedef enum
16-
{
15+
typedef enum {
1716
// Reserve first 100 events for button types and indexes, starting from 0
1817
FlippPomodoroAppCustomEventStageSkip = 100,
1918
FlippPomodoroAppCustomEventStageComplete, // By Expiration
@@ -23,20 +22,18 @@ typedef enum
2322
FlippPomodoroAppCustomEventResumeTimer,
2423
} FlippPomodoroAppCustomEvent;
2524

26-
typedef struct
27-
{
28-
SceneManager *scene_manager;
29-
ViewDispatcher *view_dispatcher;
30-
Gui *gui;
31-
NotificationApp *notification_app;
32-
FlippPomodoroTimerView *timer_view;
33-
FlippPomodoroInfoView *info_view;
34-
FlippPomodoroState *state;
35-
FlippPomodoroStatistics *statistics;
25+
typedef struct {
26+
SceneManager* scene_manager;
27+
ViewDispatcher* view_dispatcher;
28+
Gui* gui;
29+
NotificationApp* notification_app;
30+
FlippPomodoroTimerView* timer_view;
31+
FlippPomodoroInfoView* info_view;
32+
FlippPomodoroState* state;
33+
FlippPomodoroStatistics* statistics;
3634
} FlippPomodoroApp;
3735

38-
typedef enum
39-
{
36+
typedef enum {
4037
FlippPomodoroAppViewTimer,
4138
FlippPomodoroAppViewInfo,
4239
} FlippPomodoroAppView;

helpers/notifications.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ extern const NotificationSequence work_start_notification;
77
extern const NotificationSequence rest_start_notification;
88

99
/// @brief Defines a notification sequence that should indicate start of specific pomodoro stage.
10-
const NotificationSequence *stage_start_notification_sequence_map[] = {
10+
const NotificationSequence* stage_start_notification_sequence_map[] = {
1111
[FlippPomodoroStageFocus] = &work_start_notification,
1212
[FlippPomodoroStageRest] = &rest_start_notification,
1313
[FlippPomodoroStageLongBreak] = &rest_start_notification,

helpers/time.c

+4-5
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,16 @@
55
const int TIME_SECONDS_IN_MINUTE = 60;
66
const int TIME_MINUTES_IN_HOUR = 60;
77

8-
uint32_t time_now()
9-
{
8+
uint32_t time_now() {
109
return furi_hal_rtc_get_timestamp();
1110
};
1211

13-
TimeDifference time_difference_seconds(uint32_t begin, uint32_t end)
14-
{
12+
TimeDifference time_difference_seconds(uint32_t begin, uint32_t end) {
1513
const uint32_t duration_seconds = end - begin;
1614

1715
uint32_t minutes = (duration_seconds / TIME_MINUTES_IN_HOUR) % TIME_MINUTES_IN_HOUR;
1816
uint32_t seconds = duration_seconds % TIME_SECONDS_IN_MINUTE;
1917

20-
return (TimeDifference){.total_seconds = duration_seconds, .minutes = minutes, .seconds = seconds};
18+
return (
19+
TimeDifference){.total_seconds = duration_seconds, .minutes = minutes, .seconds = seconds};
2120
};

helpers/time.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ extern const int TIME_SECONDS_IN_MINUTE;
77
extern const int TIME_MINUTES_IN_HOUR;
88

99
/// @brief Container for a time period
10-
typedef struct
11-
{
10+
typedef struct {
1211
uint8_t seconds;
1312
uint8_t minutes;
1413
uint32_t total_seconds;

img/1.png

2.66 KB
Loading

img/2.png

2.59 KB
Loading

modules/flipp_pomodoro.c

+13-23
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ PomodoroStage stages_sequence[] = {
1717
FlippPomodoroStageLongBreak,
1818
};
1919

20-
char *current_stage_label[] = {
20+
char* current_stage_label[] = {
2121
[FlippPomodoroStageFocus] = "Focusing...",
2222
[FlippPomodoroStageRest] = "Short Break...",
2323
[FlippPomodoroStageLongBreak] = "Long Break...",
2424
};
2525

26-
char *next_stage_label[] = {
26+
char* next_stage_label[] = {
2727
[FlippPomodoroStageFocus] = "Focus",
2828
[FlippPomodoroStageRest] = "Short Break",
2929
[FlippPomodoroStageLongBreak] = "Long Break",
@@ -34,39 +34,33 @@ PomodoroStage flipp_pomodoro__stage_by_index(int index) {
3434
return stages_sequence[index % one_loop_size];
3535
}
3636

37-
void flipp_pomodoro__toggle_stage(FlippPomodoroState *state)
38-
{
37+
void flipp_pomodoro__toggle_stage(FlippPomodoroState* state) {
3938
furi_assert(state);
4039
state->current_stage_index = state->current_stage_index + 1;
4140
state->started_at_timestamp = time_now();
4241
};
4342

44-
PomodoroStage flipp_pomodoro__get_stage(FlippPomodoroState *state)
45-
{
43+
PomodoroStage flipp_pomodoro__get_stage(FlippPomodoroState* state) {
4644
furi_assert(state);
4745
return flipp_pomodoro__stage_by_index(state->current_stage_index);
4846
};
4947

50-
char *flipp_pomodoro__current_stage_label(FlippPomodoroState *state)
51-
{
48+
char* flipp_pomodoro__current_stage_label(FlippPomodoroState* state) {
5249
furi_assert(state);
5350
return current_stage_label[flipp_pomodoro__get_stage(state)];
5451
};
5552

56-
char *flipp_pomodoro__next_stage_label(FlippPomodoroState *state)
57-
{
53+
char* flipp_pomodoro__next_stage_label(FlippPomodoroState* state) {
5854
furi_assert(state);
5955
return next_stage_label[flipp_pomodoro__stage_by_index(state->current_stage_index + 1)];
6056
};
6157

62-
void flipp_pomodoro__destroy(FlippPomodoroState *state)
63-
{
58+
void flipp_pomodoro__destroy(FlippPomodoroState* state) {
6459
furi_assert(state);
6560
free(state);
6661
};
6762

68-
uint32_t flipp_pomodoro__current_stage_total_duration(FlippPomodoroState *state)
69-
{
63+
uint32_t flipp_pomodoro__current_stage_total_duration(FlippPomodoroState* state) {
7064
const int32_t stage_duration_seconds_map[] = {
7165
[FlippPomodoroStageFocus] = 25 * TIME_SECONDS_IN_MINUTE,
7266
[FlippPomodoroStageRest] = 5 * TIME_SECONDS_IN_MINUTE,
@@ -76,27 +70,23 @@ uint32_t flipp_pomodoro__current_stage_total_duration(FlippPomodoroState *state)
7670
return stage_duration_seconds_map[flipp_pomodoro__get_stage(state)];
7771
};
7872

79-
uint32_t flipp_pomodoro__stage_expires_timestamp(FlippPomodoroState *state)
80-
{
73+
uint32_t flipp_pomodoro__stage_expires_timestamp(FlippPomodoroState* state) {
8174
return state->started_at_timestamp + flipp_pomodoro__current_stage_total_duration(state);
8275
};
8376

84-
TimeDifference flipp_pomodoro__stage_remaining_duration(FlippPomodoroState *state)
85-
{
77+
TimeDifference flipp_pomodoro__stage_remaining_duration(FlippPomodoroState* state) {
8678
const uint32_t stage_ends_at = flipp_pomodoro__stage_expires_timestamp(state);
8779
return time_difference_seconds(time_now(), stage_ends_at);
8880
};
8981

90-
bool flipp_pomodoro__is_stage_expired(FlippPomodoroState *state)
91-
{
82+
bool flipp_pomodoro__is_stage_expired(FlippPomodoroState* state) {
9283
const uint32_t expired_by = flipp_pomodoro__stage_expires_timestamp(state);
9384
const uint8_t seamless_change_span_seconds = 1;
9485
return (time_now() - seamless_change_span_seconds) >= expired_by;
9586
};
9687

97-
FlippPomodoroState *flipp_pomodoro__new()
98-
{
99-
FlippPomodoroState *state = malloc(sizeof(FlippPomodoroState));
88+
FlippPomodoroState* flipp_pomodoro__new() {
89+
FlippPomodoroState* state = malloc(sizeof(FlippPomodoroState));
10090
const uint32_t now = time_now();
10191
state->started_at_timestamp = now;
10292
state->current_stage_index = 0;

modules/flipp_pomodoro.h

+10-12
Original file line numberDiff line numberDiff line change
@@ -4,52 +4,50 @@
44
#include "../helpers/time.h"
55

66
/// @brief Options of pomodoro stages
7-
typedef enum
8-
{
7+
typedef enum {
98
FlippPomodoroStageFocus,
109
FlippPomodoroStageRest,
1110
FlippPomodoroStageLongBreak,
1211
} PomodoroStage;
1312

1413
/// @brief State of the pomodoro timer
15-
typedef struct
16-
{
14+
typedef struct {
1715
uint8_t current_stage_index;
1816
uint32_t started_at_timestamp;
1917
} FlippPomodoroState;
2018

2119
/// @brief Generates initial state
2220
/// @returns A new pre-populated state for pomodoro timer
23-
FlippPomodoroState *flipp_pomodoro__new();
21+
FlippPomodoroState* flipp_pomodoro__new();
2422

2523
/// @brief Extract current stage of pomodoro
2624
/// @param state - pointer to the state of pomorodo
2725
/// @returns Current stage value
28-
PomodoroStage flipp_pomodoro__get_stage(FlippPomodoroState *state);
26+
PomodoroStage flipp_pomodoro__get_stage(FlippPomodoroState* state);
2927

3028
/// @brief Destroys state of timer and it's dependencies
31-
void flipp_pomodoro__destroy(FlippPomodoroState *state);
29+
void flipp_pomodoro__destroy(FlippPomodoroState* state);
3230

3331
/// @brief Get remaining stage time.
3432
/// @param state - pointer to the state of pomorodo
3533
/// @returns Time difference to the end of current stage
36-
TimeDifference flipp_pomodoro__stage_remaining_duration(FlippPomodoroState *state);
34+
TimeDifference flipp_pomodoro__stage_remaining_duration(FlippPomodoroState* state);
3735

3836
/// @brief Label of currently active stage
3937
/// @param state - pointer to the state of pomorodo
4038
/// @returns A string that explains current stage
41-
char *flipp_pomodoro__current_stage_label(FlippPomodoroState *state);
39+
char* flipp_pomodoro__current_stage_label(FlippPomodoroState* state);
4240

4341
/// @brief Label of transition to the next stage
4442
/// @param state - pointer to the state of pomorodo.
4543
/// @returns string with the label of the "skipp" button
46-
char *flipp_pomodoro__next_stage_label(FlippPomodoroState *state);
44+
char* flipp_pomodoro__next_stage_label(FlippPomodoroState* state);
4745

4846
/// @brief Check if current stage is expired
4947
/// @param state - pointer to the state of pomorodo.
5048
/// @returns expriations status - true means stage is expired
51-
bool flipp_pomodoro__is_stage_expired(FlippPomodoroState *state);
49+
bool flipp_pomodoro__is_stage_expired(FlippPomodoroState* state);
5250

5351
/// @brief Rotate stage of the timer
5452
/// @param state - pointer to the state of pomorodo.
55-
void flipp_pomodoro__toggle_stage(FlippPomodoroState *state);
53+
void flipp_pomodoro__toggle_stage(FlippPomodoroState* state);

0 commit comments

Comments
 (0)