countdown_view.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 sec_expected;
  32. uint8_t select; // setting
  33. } CountDownModel;
  34. typedef struct {
  35. View* view;
  36. FuriTimer* timer; // 1Hz tick timer
  37. bool counting;
  38. } CountDownTimView;
  39. // functions
  40. // allocate helloworld view
  41. CountDownTimView* helloworld_view_new();
  42. // delete helloworld view
  43. void countdown_timer_view_delete(CountDownTimView* hwv);
  44. // return view
  45. View* countdown_timer_view_get_view(CountDownTimView* hwv);
  46. void countdown_timer_view_state_reset(CountDownTimView* hwv); // set initial state
  47. void countdown_timer_state_toggle(CountDownTimView* hwv);
  48. #endif // __COUNTDOWN_VIEW_H__