pomodoro_10.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include "../pomodoro_timer.h"
  2. #include "pomodoro_10.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_10_draw_callback(Canvas* canvas, void* context) {
  8. int max_seconds = 60 * 10;
  9. int max_seconds_rest = 60 * 2;
  10. pomodoro_draw_callback(canvas, context, max_seconds, max_seconds_rest);
  11. }
  12. static bool pomodoro_10_input_callback(InputEvent* event, void* context) {
  13. furi_assert(context);
  14. PomodoroTimer* pomodoro_10 = context;
  15. if(event->type == InputTypeLong && event->key == InputKeyBack) {
  16. return false;
  17. } else {
  18. pomodoro_timer_process(pomodoro_10, event);
  19. return true;
  20. }
  21. }
  22. PomodoroTimer* pomodoro_10_alloc() {
  23. PomodoroTimer* pomodoro_10 = malloc(sizeof(PomodoroTimer));
  24. pomodoro_10->view = view_alloc();
  25. view_set_context(pomodoro_10->view, pomodoro_10);
  26. view_allocate_model(pomodoro_10->view, ViewModelTypeLocking, sizeof(PomodoroTimerModel));
  27. view_set_draw_callback(pomodoro_10->view, pomodoro_10_draw_callback);
  28. view_set_input_callback(pomodoro_10->view, pomodoro_10_input_callback);
  29. return pomodoro_10;
  30. }
  31. void pomodoro_10_free(PomodoroTimer* pomodoro_10) {
  32. furi_assert(pomodoro_10);
  33. view_free(pomodoro_10->view);
  34. free(pomodoro_10);
  35. }
  36. View* pomodoro_10_get_view(PomodoroTimer* pomodoro_10) {
  37. furi_assert(pomodoro_10);
  38. return pomodoro_10->view;
  39. }