countdown_view.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 MAX_SCALE 80
  12. #define MAX_MOVE_STEP 16
  13. #define MIN_MOVE_STEP 2
  14. typedef enum {
  15. CountDownTimerMinuteUp,
  16. CountDownTimerMinuteDown,
  17. CountDownTimerSecDown,
  18. CountDownTimerSecUp,
  19. CountDownTimerHourUp,
  20. CountDownTimerHourDown,
  21. CountDownTimerReset,
  22. CountDownTimerTimeUp,
  23. CountDownTimerToggleCounting,
  24. } CountDownViewCmd;
  25. typedef enum {
  26. CountDownTimerSelectSec,
  27. CountDownTimerSelectMinute,
  28. CountDownTimerSelectHour,
  29. } CountDownViewSelect;
  30. typedef struct {
  31. int32_t count;
  32. int32_t saved_count_setting;
  33. CountDownViewSelect select; // setting
  34. } CountDownModel;
  35. typedef struct {
  36. View* view;
  37. FuriTimer* timer; // 1Hz tick timer
  38. bool counting;
  39. } CountDownTimView;
  40. // functions
  41. // allocate helloworld view
  42. CountDownTimView* countdown_timer_view_new();
  43. // delete helloworld view
  44. void countdown_timer_view_delete(CountDownTimView* cdv);
  45. // return view
  46. View* countdown_timer_view_get_view(CountDownTimView* cdv);
  47. void countdown_timer_view_state_reset(CountDownTimView* cdv); // set initial state
  48. void countdown_timer_state_toggle(CountDownTimView* cdv);
  49. #endif // __COUNTDOWN_VIEW_H__