|
@@ -30,6 +30,7 @@ typedef struct
|
|
|
FlippPomodoroState *state;
|
|
FlippPomodoroState *state;
|
|
|
size_t scroll_counter;
|
|
size_t scroll_counter;
|
|
|
char *current_hint;
|
|
char *current_hint;
|
|
|
|
|
+ uint32_t hint_open_timestamp;
|
|
|
} FlippPomodoroTimerViewModel;
|
|
} FlippPomodoroTimerViewModel;
|
|
|
|
|
|
|
|
static const Icon *stage_background_image[] = {
|
|
static const Icon *stage_background_image[] = {
|
|
@@ -113,10 +114,13 @@ static void flipp_pomodoro_view_timer_draw_current_stage_label(Canvas *canvas, F
|
|
|
|
|
|
|
|
static void flipp_pomodoro_view_timer_draw_hint(Canvas *canvas, FlippPomodoroTimerViewModel *model)
|
|
static void flipp_pomodoro_view_timer_draw_hint(Canvas *canvas, FlippPomodoroTimerViewModel *model)
|
|
|
{
|
|
{
|
|
|
- size_t MAX_SCROLL_COUNTER = 300;
|
|
|
|
|
- uint8_t SCROLL_DELAY_FRAMES = 3;
|
|
|
|
|
|
|
+ uint8_t FRAMES_PER_SECOND = 3;
|
|
|
|
|
+ uint8_t HINT_MAX_DURATION_SECONDS = 30;
|
|
|
|
|
+ uint8_t SCROLL_DELAY_SECONDS = 2;
|
|
|
|
|
|
|
|
- if (model->scroll_counter >= MAX_SCROLL_COUNTER || model->current_hint == NULL)
|
|
|
|
|
|
|
+ uint8_t hint_duration = time_now() - model->hint_open_timestamp;
|
|
|
|
|
+
|
|
|
|
|
+ if (hint_duration > HINT_MAX_DURATION_SECONDS || model->current_hint == NULL)
|
|
|
{
|
|
{
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -134,16 +138,10 @@ static void flipp_pomodoro_view_timer_draw_hint(Canvas *canvas, FlippPomodoroTim
|
|
|
"%s",
|
|
"%s",
|
|
|
model->current_hint);
|
|
model->current_hint);
|
|
|
|
|
|
|
|
- size_t perfect_duration = furi_string_size(displayed_hint_string) * 1.5;
|
|
|
|
|
|
|
|
|
|
- if (model->scroll_counter > perfect_duration)
|
|
|
|
|
- {
|
|
|
|
|
- model->scroll_counter = MAX_SCROLL_COUNTER;
|
|
|
|
|
- furi_string_free(displayed_hint_string);
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ size_t scroll_offset_base_max = (hint_duration < SCROLL_DELAY_SECONDS) ? 0 : ((hint_duration - SCROLL_DELAY_SECONDS) * FRAMES_PER_SECOND);
|
|
|
|
|
|
|
|
- size_t scroll_offset = (model->scroll_counter < SCROLL_DELAY_FRAMES) ? 0 : model->scroll_counter - SCROLL_DELAY_FRAMES;
|
|
|
|
|
|
|
+ size_t scroll_offset = (scroll_offset_base_max <= model->scroll_counter ? scroll_offset_base_max : model->scroll_counter + 1);
|
|
|
|
|
|
|
|
canvas_set_color(canvas, ColorWhite);
|
|
canvas_set_color(canvas, ColorWhite);
|
|
|
canvas_draw_box(canvas, hint_x, hint_y, hint_width + 3, hint_height);
|
|
canvas_draw_box(canvas, hint_x, hint_y, hint_width + 3, hint_height);
|
|
@@ -160,7 +158,7 @@ static void flipp_pomodoro_view_timer_draw_hint(Canvas *canvas, FlippPomodoroTim
|
|
|
scroll_offset,
|
|
scroll_offset,
|
|
|
true);
|
|
true);
|
|
|
furi_string_free(displayed_hint_string);
|
|
furi_string_free(displayed_hint_string);
|
|
|
- model->scroll_counter++;
|
|
|
|
|
|
|
+ model->scroll_counter = scroll_offset;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static void flipp_pomodoro_view_timer_draw_callback(Canvas *canvas, void *_model)
|
|
static void flipp_pomodoro_view_timer_draw_callback(Canvas *canvas, void *_model)
|
|
@@ -231,6 +229,7 @@ void flipp_pomodoro_view_timer_display_hint(View *view, char *hint)
|
|
|
{
|
|
{
|
|
|
model->scroll_counter = 0;
|
|
model->scroll_counter = 0;
|
|
|
model->current_hint = hint;
|
|
model->current_hint = hint;
|
|
|
|
|
+ model->hint_open_timestamp = time_now();
|
|
|
},
|
|
},
|
|
|
true);
|
|
true);
|
|
|
}
|
|
}
|