Prusa MINI Firmware overview
status_footer.cpp File Reference
#include "config.h"
#include "status_footer.h"
#include "filament.h"
#include "../Marlin/src/module/temperature.h"
#include "../Marlin/src/module/planner.h"

Macros

#define HEATING_DIFFERENCE   2
 

Functions

void status_footer_timer (status_footer_t *footer, uint32_t mseconds)
 
void status_footer_update_temperatures (status_footer_t *footer, bool &heating_nozzle, bool &heating_heatbed, bool &cooling_nozzle, bool &cooling_heatbed)
 
void status_footer_update_feedrate (status_footer_t *footer)
 
void status_footer_update_z_axis (status_footer_t *footer)
 
void status_footer_update_filament (status_footer_t *footer)
 
void status_footer_indicate_nozzle (window_text_t *nozzle, bool heating, bool cooling)
 
void status_footer_indicate_heatbed (window_text_t *heatbed, bool heating, bool cooling)
 
void status_footer_init (status_footer_t *footer, int16_t parent)
 
int status_footer_event (status_footer_t *footer, window_t *window, uint8_t event, const void *param)
 

Macro Definition Documentation

◆ HEATING_DIFFERENCE

#define HEATING_DIFFERENCE   2

Function Documentation

◆ status_footer_timer()

void status_footer_timer ( status_footer_t footer,
uint32_t  mseconds 
)
137  {
138  bool heating_nozzle = false;
139  bool cooling_nozzle = false;
140  bool heating_heatbed = false;
141  bool cooling_heatbed = false;
142 
143  //if (mseconds % 1000 == 0){ // this is not OK, it assumes, that the timer ticks are coming in regularly
144  // which is not the case here
145  if ((mseconds - footer->last_timer_repaint_temperatures) >= 1000) {
146  status_footer_update_temperatures(footer, heating_nozzle, heating_heatbed,
147  cooling_nozzle, cooling_heatbed);
150  footer->last_timer_repaint_temperatures = mseconds;
151  }
152 
153  if ((mseconds - footer->last_timer_repaint_z) >= 500) {
155  // WTF - heating_nozzle is false and occasionally true - is that what we want?
156  status_footer_indicate_nozzle(&(footer->wt_nozzle), heating_nozzle, cooling_nozzle);
157  status_footer_indicate_heatbed(&(footer->wt_heatbed), heating_heatbed, cooling_heatbed);
158  footer->last_timer_repaint_z = mseconds;
159  }
160 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ status_footer_update_temperatures()

void status_footer_update_temperatures ( status_footer_t footer,
bool &  heating_nozzle,
bool &  heating_heatbed,
bool &  cooling_nozzle,
bool &  cooling_heatbed 
)
164  {
165  /*
166  float actual_nozzle = ExtUI::getActualTemp_celsius(ExtUI::extruder_t::E0);
167  float target_nozzle = ExtUI::getTargetTemp_celsius(ExtUI::extruder_t::E0);
168  float actual_heatbed = ExtUI::getActualTemp_celsius(ExtUI::heater_t::BED);
169  float target_heatbed = ExtUI::getTargetTemp_celsius(ExtUI::heater_t::BED);
170  */
171 
172  float actual_nozzle = thermalManager.degHotend(0);
173  float target_nozzle = thermalManager.degTargetHotend(0);
174  float actual_heatbed = thermalManager.degBed();
175  float target_heatbed = thermalManager.degTargetBed();
176 
177  heating_nozzle = (target_nozzle > (actual_nozzle + HEATING_DIFFERENCE));
178  cooling_nozzle = (target_nozzle < (actual_nozzle - HEATING_DIFFERENCE) && actual_nozzle > 50);
179  heating_heatbed = (target_heatbed > (actual_heatbed + HEATING_DIFFERENCE));
180  cooling_heatbed = (target_heatbed < (actual_heatbed - HEATING_DIFFERENCE) && actual_heatbed > 45);
181 
182  if (heating_nozzle && target_nozzle != footer->nozzle) {
183  footer->nozzle = target_nozzle;
184  } else if (!heating_nozzle && actual_nozzle != footer->nozzle) {
185  footer->nozzle = actual_nozzle;
186  }
187  sprintf(footer->text_nozzle, "%.0f/%.0f\177C", (double)actual_nozzle, (double)target_nozzle);
188  window_set_text(footer->wt_nozzle.win.id, footer->text_nozzle);
189 
190  if (heating_heatbed && target_heatbed != footer->heatbed) {
191  footer->heatbed = target_heatbed;
192  } else if (!heating_heatbed && actual_heatbed != footer->heatbed) {
193  footer->heatbed = actual_heatbed;
194  }
195  sprintf(footer->text_heatbed, "%.0f/%.0f\177C", (double)actual_heatbed, (double)target_heatbed);
196  window_set_text(footer->wt_heatbed.win.id, footer->text_heatbed);
197 
198 #ifdef LCD_HEATBREAK_TO_FILAMENT
199  float actual_heatbreak = thermalManager.degHeatbreak();
200  //float actual_heatbreak = analogRead(6);
201  sprintf(footer->text_heatbreak, "%.0f\177C", (double)actual_heatbreak);
202  window_set_text(footer->wt_filament.win.id, footer->text_heatbreak);
203 #endif //LCD_HEATBREAK_TO_FILAMENT
204 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ status_footer_update_feedrate()

void status_footer_update_feedrate ( status_footer_t footer)
206  {
207  if ((uint16_t)feedrate_percentage <= 999)
208  snprintf(footer->text_prnspeed, sizeof(footer->text_prnspeed) / sizeof(footer->text_prnspeed[0]), "%d%%", feedrate_percentage);
209  else
210  snprintf(footer->text_prnspeed, sizeof(footer->text_prnspeed) / sizeof(footer->text_prnspeed[0]), "ERR");
211  window_set_text(footer->wt_prnspeed.win.id, footer->text_prnspeed);
212 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ status_footer_update_z_axis()

void status_footer_update_z_axis ( status_footer_t footer)
214  {
215  sprintf(footer->text_z_axis, "%.2f", (double)current_position[2]);
216  window_set_text(footer->wt_z_axis.win.id, footer->text_z_axis);
217 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ status_footer_update_filament()

void status_footer_update_filament ( status_footer_t footer)
219  {
221 #ifndef LCD_HEATBREAK_TO_FILAMENT
223 #endif
224 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ status_footer_indicate_nozzle()

void status_footer_indicate_nozzle ( window_text_t nozzle,
bool  heating,
bool  cooling 
)
226  {
228  || window_get_color_text(nozzle->win.id) == COLOR_BLUE) {
230  } else if (heating) {
232  } else if (cooling) {
234  }
235 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ status_footer_indicate_heatbed()

void status_footer_indicate_heatbed ( window_text_t heatbed,
bool  heating,
bool  cooling 
)
237  {
238  if (window_get_color_text(heatbed->win.id) == COLOR_ORANGE
239  || window_get_color_text(heatbed->win.id) == COLOR_BLUE) {
241  } else if (heating) {
243  } else if (cooling) {
245  }
246 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ status_footer_init()

void status_footer_init ( status_footer_t footer,
int16_t  parent 
)
27  {
28  int16_t id;
29 
30  strcpy(footer->text_nozzle, "0/0\177C");
31  strcpy(footer->text_heatbed, "0/0\177C");
32  strcpy(footer->text_prnspeed, "0%");
33  strcpy(footer->text_z_axis, "999.95");
34 
35  id = window_create_ptr( // nozzle
36  WINDOW_CLS_ICON, parent,
37  rect_ui16(8, 270, 16, 16), // 2px padding from right
38  &(footer->wi_nozzle));
41  // window_enable(id);
42 
43  id = window_create_ptr(
44  WINDOW_CLS_TEXT, parent,
45  rect_ui16(24, 269, 85, 20),
46  &(footer->wt_nozzle));
49  window_set_text(id, footer->text_nozzle);
50 
51  id = window_create_ptr( // heatbed
52  WINDOW_CLS_ICON, parent,
53  rect_ui16(128, 270, 20, 16),
54  &(footer->wi_heatbed));
57  //window_enable(id);
58 
59  id = window_create_ptr(
60  WINDOW_CLS_TEXT, parent,
61  rect_ui16(150, 269, 85, 22),
62  &(footer->wt_heatbed));
65  window_set_text(id, footer->text_heatbed);
66 
67  id = window_create_ptr( // prnspeed
68  WINDOW_CLS_ICON, parent,
69  rect_ui16(10, 297, 16, 12),
70  &(footer->wi_prnspeed));
73  //window_enable(id);
74 
75  id = window_create_ptr(
76  WINDOW_CLS_TEXT, parent,
77  rect_ui16(28, 296, 40, 22),
78  &(footer->wt_prnspeed));
81  window_set_text(id, footer->text_prnspeed);
82 
83  id = window_create_ptr( // z-axis
84  WINDOW_CLS_ICON, parent,
85  rect_ui16(80, 297, 16, 16),
86  &(footer->wi_z_axis));
89  //window_enable(id);
90 
91  id = window_create_ptr(
92  WINDOW_CLS_TEXT, parent,
93  rect_ui16(102, 296, 58, 22),
94  &(footer->wt_z_axis));
97  window_set_text(id, footer->text_z_axis);
98 
99  id = window_create_ptr( // filament
100  WINDOW_CLS_ICON, parent,
101  rect_ui16(163, 297, 16, 16),
102  &(footer->wi_filament));
105  //window_enable(id);
106 
107  id = window_create_ptr(
108  WINDOW_CLS_TEXT, parent,
109  rect_ui16(181, 296, 49, 22),
110  &(footer->wt_filament));
114 
115  status_footer_timer(footer, 0); // do update
116 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ status_footer_event()

int status_footer_event ( status_footer_t footer,
window_t window,
uint8_t  event,
const void param 
)
119  {
120  status_footer_timer(footer, (HAL_GetTick() / 50) * 50);
121 
122  if (event != WINDOW_EVENT_CLICK) {
123  return 0;
124  }
125 
126  switch ((int)param) {
132  return 0;
133  }
134  return 0;
135 }
Here is the call graph for this function:
Here is the caller graph for this function:
IDR_PNG_status_icon_heatbed
#define IDR_PNG_status_icon_heatbed
Definition: resource.h:21
window_set_alignment
void window_set_alignment(int16_t id, uint8_t alignment)
Definition: window.c:561
Temperature::degTargetHotend
static FORCE_INLINE int16_t degTargetHotend(const uint8_t E_NAME)
Definition: temperature.h:562
COLOR_WHITE
#define COLOR_WHITE
Definition: guitypes.h:41
ALIGN_CENTER
#define ALIGN_CENTER
Definition: guitypes.h:19
rect_ui16
static rect_ui16_t rect_ui16(uint16_t x, uint16_t y, uint16_t w, uint16_t h)
Definition: guitypes.h:159
IDR_PNG_status_icon_prnspeed
#define IDR_PNG_status_icon_prnspeed
Definition: resource.h:22
IDR_FNT_SPECIAL
#define IDR_FNT_SPECIAL
Definition: resource.h:13
window_set_icon_id
void window_set_icon_id(int16_t id, uint16_t id_res)
Definition: window.c:659
Temperature::degHotend
static FORCE_INLINE float degHotend(const uint8_t E_NAME)
Definition: temperature.h:544
IDR_PNG_status_icon_z_axis
#define IDR_PNG_status_icon_z_axis
Definition: resource.h:24
filaments
const filament_t filaments[FILAMENTS_END]
Definition: filament.cpp:20
IDR_PNG_status_icon_nozzle
#define IDR_PNG_status_icon_nozzle
Definition: resource.h:20
HAL_GetTick
uint32_t HAL_GetTick(void)
Provides a tick value in millisecond.
Definition: stm32f4xx_hal.c:339
_window_t::id
int16_t id
Definition: window.h:79
current_position
xyze_pos_t current_position
Definition: motion.cpp:102
feedrate_percentage
int16_t feedrate_percentage
Definition: motion.cpp:139
window_set_text
void window_set_text(int16_t id, const char *text)
Definition: window.c:340
COLOR_ORANGE
#define COLOR_ORANGE
Definition: guitypes.h:57
get_filament
FILAMENT_t get_filament()
Definition: filament.cpp:41
netif::name
char name[2]
Definition: netif.h:307
window_set_tag
void window_set_tag(int16_t id, uint8_t tag)
Definition: window.c:329
COLOR_BLUE
#define COLOR_BLUE
Definition: guitypes.h:45
WINDOW_CLS_ICON
#define WINDOW_CLS_ICON
Definition: window.h:12
WINDOW_CLS_TEXT
#define WINDOW_CLS_TEXT
Definition: window.h:10
resource_font
font_t * resource_font(uint16_t id)
Definition: guitypes.c:186
WINDOW_EVENT_CLICK
#define WINDOW_EVENT_CLICK
Definition: window.h:46
window_create_ptr
int16_t window_create_ptr(int16_t cls_id, int16_t id_parent, rect_ui16_t rect, void *ptr)
Definition: window.c:102
window_get_color_text
color_t window_get_color_text(int16_t id)
Definition: window.c:469
_window_text_t::font
font_t * font
Definition: window_text.h:19
nozzle
Nozzle nozzle
Definition: nozzle.cpp:29
thermalManager
Temperature thermalManager
Definition: temperature.cpp:89
window_set_color_text
void window_set_color_text(int16_t id, color_t clr)
Definition: window.c:457
IDR_PNG_status_icon_filament
#define IDR_PNG_status_icon_filament
Definition: resource.h:23
_window_text_t::win
window_t win
Definition: window_text.h:16