Prusa MINI Firmware overview
selftest_cool.c File Reference
#include "selftest_cool.h"
#include "config.h"
#include "marlin_client.h"
#include "wizard_config.h"
#include "wizard_ui.h"
#include "guitypes.h"
#include "wizard_progress_bar.h"

Functions

void _wizard_cool_actualize_temperatures (selftest_cool_data_t *p_data)
 
void wizard_init_screen_selftest_cool (int16_t id_body, selftest_cool_screen_t *p_screen, selftest_cool_data_t *p_data)
 
int wizard_selftest_cool (int16_t id_body, selftest_cool_screen_t *p_screen, selftest_cool_data_t *p_data)
 

Function Documentation

◆ _wizard_cool_actualize_temperatures()

void _wizard_cool_actualize_temperatures ( selftest_cool_data_t p_data)
62  {
63 
64  //uint32_t t_noz_raw = analogRead(4);
65  //uint32_t t_bed_raw = analogRead(32);
68  float t_noz = vars->temp_nozzle;
69  float t_bed = vars->temp_bed;
70 
71  if (t_noz < p_data->temp_noz)
72  p_data->temp_noz = t_noz;
73  if (t_bed < p_data->temp_bed)
74  p_data->temp_bed = t_bed;
75 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ wizard_init_screen_selftest_cool()

void wizard_init_screen_selftest_cool ( int16_t  id_body,
selftest_cool_screen_t p_screen,
selftest_cool_data_t p_data 
)
17  {
18 
19  int16_t id;
20  window_destroy_children(id_body);
21  window_show(id_body);
22  window_invalidate(id_body);
23 
24  uint16_t y = 40;
25  uint16_t x = WIZARD_MARGIN_LEFT;
26 
27  id = window_create_ptr(WINDOW_CLS_TEXT, id_body, rect_ui16(x, y, WIZARD_X_SPACE, 22), &(p_screen->text_waiting_cd));
28  window_set_text(id, "Waiting for cooldown");
29 
30  y += 22;
31 
32  id = window_create_ptr(WINDOW_CLS_PROGRESS, id_body, rect_ui16(x, y, WIZARD_X_SPACE, 8), &(p_screen->progress));
33 
34  y += 22;
35 
36  id = window_create_ptr(WINDOW_CLS_NUMB, id_body, rect_ui16(10, y, WIZARD_X_SPACE, 22), &(p_screen->curr_nozzle_temp));
37  window_set_format(id, (const char *)"Nozzle: %.1f\177C");
38 
39  y += 22;
40 
41  id = window_create_ptr(WINDOW_CLS_NUMB, id_body, rect_ui16(10, y, WIZARD_X_SPACE, 22), &(p_screen->curr_bed_temp));
42  window_set_format(id, (const char *)"Bed: %.1f\177C");
43 
44  y += 22;
45 
46  id = window_create_ptr(WINDOW_CLS_NUMB, id_body, rect_ui16(10, y, WIZARD_X_SPACE - 10, 22), &(p_screen->target_nozzle));
47  window_set_format(id, (const char *)"Noz. target: %.0f\177C");
49 
50  y += 22;
51 
52  id = window_create_ptr(WINDOW_CLS_NUMB, id_body, rect_ui16(10, y, WIZARD_X_SPACE - 10, 22), &(p_screen->target_bed));
53  window_set_format(id, (const char *)"Bed. target: %.0f\177C");
55 
56  y += 35;
57 
58  id = window_create_ptr(WINDOW_CLS_ICON, id_body, rect_ui16(100, y, 40, 40), &(p_screen->icon_hourglass));
60 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ wizard_selftest_cool()

int wizard_selftest_cool ( int16_t  id_body,
selftest_cool_screen_t p_screen,
selftest_cool_data_t p_data 
)
77  {
78  if (p_data->state_cool == _TEST_START) {
79  p_data->temp_noz = 1000;
80  p_data->temp_bed = 1000;
82  if ((p_data->temp_bed < _CALIB_TEMP_BED) && (p_data->temp_noz < _CALIB_TEMP_NOZ)) {
83  p_data->state_cool = _TEST_PASSED;
84  return 100;
85  }
86  wizard_init_screen_selftest_cool(id_body, p_screen, p_data);
87 
88  p_data->start_nozzle_temp = 10 * (p_data->temp_noz - _CALIB_TEMP_NOZ);
89  p_data->start_bed_temp = 10 * (p_data->temp_bed - _CALIB_TEMP_BED);
90  //------------------------------------
92  hwio_fan_set_pwm(0, 255);
93  hwio_fan_set_pwm(1, 255);
94  //------------------------------------
95  } else
97 
98  float diff_n = (p_data->temp_noz - _CALIB_TEMP_NOZ) < 0 ? 0 : (p_data->temp_noz - _CALIB_TEMP_NOZ);
99  float diff_b = (p_data->temp_bed - _CALIB_TEMP_BED) < 0 ? 0 : (p_data->temp_bed - _CALIB_TEMP_BED);
100 
101  float nozzle_progress, bed_progress, nozzle_procentage, bed_procentage, lower_procentage;
102 
103  nozzle_progress = p_data->start_nozzle_temp - 10 * diff_n;
104  nozzle_procentage = (100 / p_data->start_nozzle_temp) * nozzle_progress;
105 
106  bed_progress = p_data->start_bed_temp - 10 * diff_b;
107  bed_procentage = (100 / p_data->start_bed_temp) * bed_progress;
108 
109  lower_procentage = nozzle_procentage < bed_procentage ? nozzle_procentage : bed_procentage;
110 
111  int time_progress = wizard_timer(&p_data->timer, _COOLDOWN_TIMEOUT, &(p_data->state_cool), _WIZ_TIMER_AUTOFAIL);
112 
113  float progress = lower_procentage >= time_progress ? lower_procentage : time_progress;
114 
115  if (diff_n < 0.1F && diff_b < 0.1F) {
116  progress = 100;
117  p_data->state_cool = _TEST_PASSED;
118  }
119  //-------------------------------------
120  if (progress == 100) {
121  hwio_fan_set_pwm(0, 0);
122  hwio_fan_set_pwm(1, 0);
126  marlin_gcode("M501"); //restore settings
128  !marlin_event_clr(MARLIN_EVT_FactoryReset)) //wait for M501 done
129  gui_loop();
130  }
131  //-------------------------------------
132 
133  window_set_value(p_screen->curr_nozzle_temp.win.id, p_data->temp_noz);
134  window_set_value(p_screen->curr_bed_temp.win.id, p_data->temp_bed);
135  p_screen->progress.color_progress = lower_procentage >= time_progress ? COLOR_LIME : COLOR_ORANGE;
136  window_set_value(p_screen->progress.win.id, progress);
137  return progress;
138 }
Here is the call graph for this function:
Here is the caller graph for this function:
selftest_cool_data_t::start_nozzle_temp
float start_nozzle_temp
Definition: selftest_cool.h:36
_window_progress_t::color_progress
color_t color_progress
Definition: window_progress.h:19
MARLIN_EVT_LoadSettings
#define MARLIN_EVT_LoadSettings
Definition: marlin_events.h:22
WINDOW_CLS_NUMB
#define WINDOW_CLS_NUMB
Definition: window.h:11
selftest_cool_data_t::temp_noz
float temp_noz
Definition: selftest_cool.h:33
window_destroy_children
void window_destroy_children(int16_t id)
Definition: window.c:157
window_set_format
void window_set_format(int16_t id, const char *format)
Definition: window.c:403
selftest_cool_data_t::start_bed_temp
float start_bed_temp
Definition: selftest_cool.h:37
window_invalidate
void window_invalidate(int16_t id)
Definition: window.c:304
rect_ui16
static rect_ui16_t rect_ui16(uint16_t x, uint16_t y, uint16_t w, uint16_t h)
Definition: guitypes.h:159
WIZARD_MARGIN_LEFT
#define WIZARD_MARGIN_LEFT
Definition: wizard_ui.h:8
wizard_init_screen_selftest_cool
void wizard_init_screen_selftest_cool(int16_t id_body, selftest_cool_screen_t *p_screen, selftest_cool_data_t *p_data)
Definition: selftest_cool.c:17
selftest_cool_data_t::temp_bed
float temp_bed
Definition: selftest_cool.h:34
selftest_cool_screen_t::progress
window_progress_t progress
Definition: selftest_cool.h:19
selftest_cool_screen_t::target_bed
window_numb_t target_bed
Definition: selftest_cool.h:22
marlin_stop_processing
void marlin_stop_processing(void)
Definition: marlin_client.c:166
window_set_icon_id
void window_set_icon_id(int16_t id, uint16_t id_res)
Definition: window.c:659
COLOR_LIME
#define COLOR_LIME
Definition: guitypes.h:44
selftest_cool_data_t::state_cool
_TEST_STATE_t state_cool
Definition: selftest_cool.h:32
_CALIB_TEMP_BED
#define _CALIB_TEMP_BED
Definition: wizard_config.h:43
F
#define F(str)
Definition: UHS_macros.h:164
window_show
void window_show(int16_t id)
Definition: window.c:529
_window_t::id
int16_t id
Definition: window.h:79
_COOLDOWN_TIMEOUT
#define _COOLDOWN_TIMEOUT
Definition: wizard_config.h:45
selftest_cool_screen_t::text_waiting_cd
window_text_t text_waiting_cd
Definition: selftest_cool.h:20
_marlin_vars_t::temp_nozzle
float temp_nozzle
Definition: marlin_vars.h:83
WIZARD_X_SPACE
#define WIZARD_X_SPACE
Definition: wizard_ui.h:10
_wizard_cool_actualize_temperatures
void _wizard_cool_actualize_temperatures(selftest_cool_data_t *p_data)
Definition: selftest_cool.c:62
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
WINDOW_CLS_PROGRESS
#define WINDOW_CLS_PROGRESS
Definition: window.h:20
_CALIB_TEMP_NOZ
#define _CALIB_TEMP_NOZ
Definition: wizard_config.h:44
window_set_value
void window_set_value(int16_t id, float value)
Definition: window.c:363
marlin_manage_heater
void marlin_manage_heater(void)
Definition: marlin_client.c:459
_WIZ_TIMER_AUTOFAIL
Definition: wizard_ui.h:21
selftest_cool_screen_t::curr_bed_temp
window_numb_t curr_bed_temp
Definition: selftest_cool.h:25
marlin_gcode
void marlin_gcode(const char *gcode)
Definition: marlin_client.c:195
marlin_update_vars
marlin_vars_t * marlin_update_vars(uint64_t msk)
Definition: marlin_client.c:368
hwio_fan_set_pwm
void hwio_fan_set_pwm(int i_fan, int val)
Definition: hwio_a3ides_2209_02.c:447
selftest_cool_screen_t::curr_nozzle_temp
window_numb_t curr_nozzle_temp
Definition: selftest_cool.h:24
_marlin_vars_t::temp_bed
float temp_bed
Definition: marlin_vars.h:84
WINDOW_CLS_ICON
#define WINDOW_CLS_ICON
Definition: window.h:12
WINDOW_CLS_TEXT
#define WINDOW_CLS_TEXT
Definition: window.h:10
MARLIN_EVT_FactoryReset
#define MARLIN_EVT_FactoryReset
Definition: marlin_events.h:21
_TEST_START
Definition: wizard_types.h:85
MARLIN_VAR_MSK_TEMP_CURR
#define MARLIN_VAR_MSK_TEMP_CURR
Definition: marlin_vars.h:43
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
selftest_cool_screen_t::icon_hourglass
window_icon_t icon_hourglass
Definition: selftest_cool.h:23
_marlin_vars_t
Definition: marlin_vars.h:77
marlin_start_processing
void marlin_start_processing(void)
Definition: marlin_client.c:174
selftest_cool_screen_t::target_nozzle
window_numb_t target_nozzle
Definition: selftest_cool.h:21
wizard_timer
int wizard_timer(uint32_t *p_timer, uint32_t delay_ms, _TEST_STATE_t *pstate, _WIZ_TIMER_t type)
Definition: wizard_ui.c:58
selftest_cool_data_t::timer
uint32_t timer
Definition: selftest_cool.h:35
_window_progress_t::win
window_t win
Definition: window_progress.h:16
_window_numb_t::win
window_t win
Definition: window_numb.h:18
IDR_PNG_wizard_icon_hourglass
#define IDR_PNG_wizard_icon_hourglass
Definition: resource.h:56
_TEST_PASSED
Definition: wizard_types.h:87
marlin_event_clr
int marlin_event_clr(uint8_t evt_id)
Definition: marlin_client.c:252