Prusa MINI Firmware overview
gui_timer.h File Reference
#include <inttypes.h>

Go to the source code of this file.

Functions

int8_t gui_timer_create_periodical (uint32_t ms, int16_t win_id)
 
int8_t gui_timer_create_oneshot (uint32_t ms, int16_t win_id)
 
int8_t gui_timer_create_timeout (uint32_t ms, int16_t win_id)
 
void gui_timer_delete (int8_t id)
 
void gui_timers_delete_by_window_id (int16_t win_id)
 
uint32_t gui_timers_cycle (void)
 
void gui_timer_reset (int8_t id)
 
int8_t gui_timer_expired (int8_t id)
 
int8_t gui_get_menu_timeout_id (void)
 

Function Documentation

◆ gui_timer_create_periodical()

int8_t gui_timer_create_periodical ( uint32_t  ms,
int16_t  win_id 
)
70  {
71  return gui_timer_new(GUI_TIMER_PERI, ms, win_id);
72 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ gui_timer_create_oneshot()

int8_t gui_timer_create_oneshot ( uint32_t  ms,
int16_t  win_id 
)
66  {
67  return gui_timer_new(GUI_TIMER_1SHT, ms, win_id);
68 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ gui_timer_create_timeout()

int8_t gui_timer_create_timeout ( uint32_t  ms,
int16_t  win_id 
)
74  {
76  return gui_menu_timeout_id;
77 }
Here is the call graph for this function:

◆ gui_timer_delete()

void gui_timer_delete ( int8_t  id)
79  {
80  if ((id >= 0) && (id < GUI_MAX_TIMERS) && (gui_timers[id].f_timer != GUI_TIMER_NONE)) {
81  gui_timers[id].start = 0;
82  gui_timers[id].delay = 0;
83  if (gui_timers[id].f_timer == GUI_MENU_TIMEOUT)
86  gui_timers[id].win_id = 0;
87  gui_timer_count--; //decrement count
88  }
89 }
Here is the caller graph for this function:

◆ gui_timers_delete_by_window_id()

void gui_timers_delete_by_window_id ( int16_t  win_id)
91  {
92  int8_t id;
93  for (id = 0; id < GUI_MAX_TIMERS; id++)
94  if (gui_timers[id].win_id == win_id)
95  gui_timer_delete(id);
96 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ gui_timers_cycle()

uint32_t gui_timers_cycle ( void  )
98  {
99  uint32_t tick = HAL_GetTick();
100  uint32_t delay;
101  uint32_t diff;
102  uint32_t diff_min = 0xffffffff;
103  uint8_t f_timer;
104  uint8_t count = 0;
105  int8_t id;
106  for (id = 0; (id < GUI_MAX_TIMERS); id++)
107  if ((f_timer = gui_timers[id].f_timer) != GUI_TIMER_NONE) {
108  if ((delay = gui_timers[id].delay) > 0) {
109  diff = tick - gui_timers[id].start;
110  if (delay <= diff) {
111  switch (gui_timers[id].f_timer) {
112  case GUI_TIMER_1SHT:
113  screen_dispatch_event(window_ptr(gui_timers[id].win_id), WINDOW_EVENT_TIMER, (void *)(int)id);
114  gui_timers[id].delay = 0;
115  break;
116  case GUI_TIMER_PERI:
117  screen_dispatch_event(window_ptr(gui_timers[id].win_id), WINDOW_EVENT_TIMER, (void *)(int)id);
118  gui_timers[id].start += delay;
119  break;
120  case GUI_MENU_TIMEOUT:
121  gui_timers[id].delay = 0;
122  break;
123  }
124  } else if (diff_min < diff)
125  diff_min = diff;
126  }
127  if (++count >= gui_timer_count)
128  break;
129  }
130  return diff_min;
131 }
Here is the call graph for this function:

◆ gui_timer_reset()

void gui_timer_reset ( int8_t  id)
133  {
134 
135  if ((id >= 0) && (id < GUI_MAX_TIMERS) && (gui_timers[id].f_timer != GUI_TIMER_NONE))
136  gui_timers[id].start = HAL_GetTick();
137 }
Here is the call graph for this function:

◆ gui_timer_expired()

int8_t gui_timer_expired ( int8_t  id)
139  {
140 
141  if ((id >= 0) && (id < GUI_MAX_TIMERS) && (gui_timers[id].f_timer != GUI_TIMER_NONE))
142  return gui_timers[id].delay == 0 ? 1 : 0;
143 
144  return -1;
145 }
Here is the caller graph for this function:

◆ gui_get_menu_timeout_id()

int8_t gui_get_menu_timeout_id ( void  )
147  {
148  return gui_menu_timeout_id;
149 }
Here is the caller graph for this function:
_gui_timer_t::delay
uint32_t delay
Definition: gui_timer.c:20
_gui_timer_t::f_timer
uint32_t f_timer
Definition: gui_timer.c:26
gui_menu_timeout_id
int8_t gui_menu_timeout_id
Definition: gui_timer.c:36
GUI_MAX_TIMERS
#define GUI_MAX_TIMERS
Definition: gui_timer.c:8
gui_timer_delete
void gui_timer_delete(int8_t id)
Definition: gui_timer.c:79
GUI_TIMER_NONE
#define GUI_TIMER_NONE
Definition: gui_timer.c:10
gui_timer_count
int8_t gui_timer_count
Definition: gui_timer.c:35
HAL_GetTick
uint32_t HAL_GetTick(void)
Provides a tick value in millisecond.
Definition: stm32f4xx_hal.c:339
GUI_TIMER_1SHT
#define GUI_TIMER_1SHT
Definition: gui_timer.c:11
window_ptr
window_t * window_ptr(int16_t id)
Definition: window.c:82
uint8_t
const uint8_t[]
Definition: 404_html.c:3
delay
void delay(uint32_t ms)
Definition: wiring_time.c:42
_gui_timer_t::win_id
int16_t win_id
Definition: gui_timer.c:29
GUI_MENU_TIMEOUT
#define GUI_MENU_TIMEOUT
Definition: gui_timer.c:13
GUI_TIMER_PERI
#define GUI_TIMER_PERI
Definition: gui_timer.c:12
gui_timer_new
int8_t gui_timer_new(uint8_t timer, uint32_t ms, int16_t win_id)
Definition: gui_timer.c:38
WINDOW_EVENT_TIMER
#define WINDOW_EVENT_TIMER
Definition: window.h:50
gui_timers
gui_timer_t gui_timers[GUI_MAX_TIMERS]
Definition: gui_timer.c:34
screen_dispatch_event
void screen_dispatch_event(window_t *window, uint8_t event, void *param)
Definition: screen.c:103
_gui_timer_t::start
uint32_t start
Definition: gui_timer.c:19