countdown_view.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #ifndef __COUNTDOWN_VIEW_H__
  2. #define __COUNTDOWN_VIEW_H__
  3. #include <furi.h>
  4. #include <furi_hal.h>
  5. #include <gui/view.h>
  6. #include <gui/elements.h>
  7. #define SCREEN_WIDTH 128
  8. #define SCREEN_HEIGHT 64
  9. #define SCREEN_CENTER_X (SCREEN_WIDTH / 2)
  10. #define SCREEN_CENTER_Y (SCREEN_HEIGHT / 2)
  11. #define INIT_COUNT 10
  12. typedef enum {
  13. CountDownTimerMinuteUp,
  14. CountDownTimerMinuteDown,
  15. CountDownTimerSecDown,
  16. CountDownTimerSecUp,
  17. CountDownTimerHourUp,
  18. CountDownTimerHourDown,
  19. CountDownTimerReset,
  20. CountDownTimerTimeUp,
  21. CountDownTimerToggleCounting,
  22. } CountDownViewCmd;
  23. typedef enum {
  24. CountDownTimerSelectSec,
  25. CountDownTimerSelectMinute,
  26. CountDownTimerSelectHour,
  27. } CountDownViewSelect;
  28. typedef struct {
  29. int32_t count;
  30. int32_t saved_count_setting;
  31. CountDownViewSelect select; // setting
  32. } CountDownModel;
  33. typedef struct {
  34. View* view;
  35. FuriTimer* timer; // 1Hz tick timer
  36. bool counting;
  37. } CountDownTimView;
  38. // functions
  39. // allocate helloworld view
  40. CountDownTimView* countdown_timer_view_new();
  41. // delete helloworld view
  42. void countdown_timer_view_delete(CountDownTimView* cdv);
  43. // return view
  44. View* countdown_timer_view_get_view(CountDownTimView* cdv);
  45. void countdown_timer_view_state_reset(CountDownTimView* cdv); // set initial state
  46. void countdown_timer_state_toggle(CountDownTimView* cdv);
  47. #endif // __COUNTDOWN_VIEW_H__