pomodoro_25.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include "../pomodoro_timer.h"
  2. #include "pomodoro_25.h"
  3. #include <furi.h>
  4. #include <furi_hal.h>
  5. #include <gui/elements.h>
  6. #include <notification/notification_messages.h>
  7. static void pomodoro_25_draw_callback(Canvas* canvas, void* context) {
  8. int max_seconds = 60 * 25;
  9. int max_seconds_rest = 60 * 5;
  10. pomodoro_draw_callback(canvas, context, max_seconds, max_seconds_rest);
  11. }
  12. static bool pomodoro_25_input_callback(InputEvent* event, void* context) {
  13. furi_assert(context);
  14. PomodoroTimer* pomodoro_25 = context;
  15. if(event->type == InputTypeLong && event->key == InputKeyBack) {
  16. return false;
  17. } else {
  18. pomodoro_timer_process(pomodoro_25, event);
  19. return true;
  20. }
  21. }
  22. PomodoroTimer* pomodoro_25_alloc() {
  23. PomodoroTimer* pomodoro_25 = malloc(sizeof(PomodoroTimer));
  24. pomodoro_25->view = view_alloc();
  25. view_set_context(pomodoro_25->view, pomodoro_25);
  26. view_allocate_model(pomodoro_25->view, ViewModelTypeLocking, sizeof(PomodoroTimerModel));
  27. view_set_draw_callback(pomodoro_25->view, pomodoro_25_draw_callback);
  28. view_set_input_callback(pomodoro_25->view, pomodoro_25_input_callback);
  29. return pomodoro_25;
  30. }
  31. void pomodoro_25_free(PomodoroTimer* pomodoro_25) {
  32. furi_assert(pomodoro_25);
  33. view_free(pomodoro_25->view);
  34. free(pomodoro_25);
  35. }
  36. View* pomodoro_25_get_view(PomodoroTimer* pomodoro_25) {
  37. furi_assert(pomodoro_25);
  38. return pomodoro_25->view;
  39. }