Prusa MINI Firmware overview
screen_mesh_bed_lv.cpp File Reference
#include "gui.h"
#include "config.h"
#include "status_footer.h"
#include "math.h"
#include "marlin_client.h"

Classes

struct  screen_mesh_bed_lv_data_t
 

Macros

#define pd   ((screen_mesh_bed_lv_data_t *)screen->pdata)
 
#define btnMeshStrings_sz   (sizeof(btnMeshStrings) / sizeof(const char *))
 
#define meshStrings_sz   (sizeof(meshStrings) / sizeof(const char *))
 
#define MESH_DEFAULT_CL   COLOR_WHITE
 
#define MESH_ACTIVE_CL   COLOR_RED
 

Enumerations

enum  mesh_state_t {
  MS_idle, MS_home, MS_homeing, MS_homed,
  MS_mesh, MS_meshing, MS_meshed
}
 
enum  { TAG_QUIT = 10, TAG_MESH }
 

Functions

static void gui_state_mesh_off (screen_t *screen)
 
static void gui_state_mesh_on (screen_t *screen)
 
void screen_mesh_bed_lv_init (screen_t *screen)
 
void screen_mesh_bed_lv_done (screen_t *screen)
 
void screen_mesh_bed_lv_draw (screen_t *screen)
 
int screen_mesh_bed_lv_event (screen_t *screen, window_t *window, uint8_t event, void *param)
 

Variables

const char * btnMeshStrings [] = { "Run mesh", "Mesh in progress" }
 
const char * meshStrings [] = { "Mesh not in failed state", "Mesh in failed state" }
 
screen_t screen_mesh_bed_lv
 
const screen_tpscreen_mesh_bed_lv = &screen_mesh_bed_lv
 

Macro Definition Documentation

◆ pd

#define pd   ((screen_mesh_bed_lv_data_t *)screen->pdata)

◆ btnMeshStrings_sz

#define btnMeshStrings_sz   (sizeof(btnMeshStrings) / sizeof(const char *))

◆ meshStrings_sz

#define meshStrings_sz   (sizeof(meshStrings) / sizeof(const char *))

◆ MESH_DEFAULT_CL

#define MESH_DEFAULT_CL   COLOR_WHITE

◆ MESH_ACTIVE_CL

#define MESH_ACTIVE_CL   COLOR_RED

Enumeration Type Documentation

◆ mesh_state_t

Enumerator
MS_idle 
MS_home 
MS_homeing 
MS_homed 
MS_mesh 
MS_meshing 
MS_meshed 
17  {
18  MS_idle,
19  MS_home,
20  MS_homeing,
21  MS_homed,
22  MS_mesh,
23  MS_meshing,
24  MS_meshed //,
25  //MS_done
26 } mesh_state_t;

◆ anonymous enum

anonymous enum
Enumerator
TAG_QUIT 
TAG_MESH 
86  {
87  TAG_QUIT = 10,
88  TAG_MESH
89 
90 };

Function Documentation

◆ gui_state_mesh_off()

static void gui_state_mesh_off ( screen_t screen)
static
67  {
68  //if (pd->mesh_bt_id == -1)return;
69  //if (pd->exit_bt_id == -1)return;
71  window_set_text(pd->mesh_bt_id, btnMeshStrings[0]);
73  window_enable(pd->exit_bt_id);
74  window_enable(pd->mesh_bt_id);
75  //pd->mesh_state = MS_idle;
76 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ gui_state_mesh_on()

static void gui_state_mesh_on ( screen_t screen)
static
78  {
79  window_disable(pd->exit_bt_id);
81  window_disable(pd->mesh_bt_id);
82  window_set_text(pd->mesh_bt_id, btnMeshStrings[1]);
84 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ screen_mesh_bed_lv_init()

void screen_mesh_bed_lv_init ( screen_t screen)
92  {
93  pd->mesh_state = MS_idle;
94  pd->exit_bt_id = -1;
95  pd->mesh_bt_id = -1;
96 
97  int16_t id;
98  uint16_t row_h = 25;
99 
100  int16_t id0 = window_create_ptr(WINDOW_CLS_FRAME,
101  -1, rect_ui16(0, 0, 0, 0), &(pd->frame));
102 
104  id0, rect_ui16(0, 0, display->w, row_h), &(pd->textMenuName));
105  pd->textMenuName.font = resource_font(IDR_FNT_BIG);
106  window_set_text(id, (const char *)"MESH LEVELING");
107 
109  id0, rect_ui16(2, 50, 200, row_h), &(pd->btMesh));
111  window_enable(id);
113 
115  id0, rect_ui16(2, 75, 200, row_h),
116  &(pd->text_mesh_state));
117 
118  //terminal
119  id = window_create_ptr(WINDOW_CLS_TERM, id0, rect_ui16(10, 28, 11 * 20, 18 * 16), &(pd->term));
120  pd->id_term = id;
121  term_init(&(pd->terminal), 20, 16, pd->term_buff);
122  pd->term.term = &(pd->terminal);
123 
124  //exit and footer
125 
127  id0, rect_ui16(2, 245, 60, 22), &(pd->textExit));
128  pd->textExit.font = resource_font(IDR_FNT_BIG);
129  window_set_text(id, (const char *)"EXIT");
130  window_enable(id);
132  pd->exit_bt_id = id;
133 
134  status_footer_init(&(pd->footer), id0);
135 }
Here is the call graph for this function:

◆ screen_mesh_bed_lv_done()

void screen_mesh_bed_lv_done ( screen_t screen)
137  {
138  window_destroy(pd->frame.win.id);
139 }
Here is the call graph for this function:

◆ screen_mesh_bed_lv_draw()

void screen_mesh_bed_lv_draw ( screen_t screen)
141  {
142 }

◆ screen_mesh_bed_lv_event()

int screen_mesh_bed_lv_event ( screen_t screen,
window_t window,
uint8_t  event,
void param 
)
144  {
145  if (status_footer_event(&(pd->footer), window, event, param)) {
146  return 1;
147  }
148 
149  status_footer_event(&(pd->footer), window, event, param);
150  if (event == WINDOW_EVENT_CLICK)
151  switch ((int)param) {
152  case TAG_QUIT:
153  if (pd->mesh_state != MS_idle)
154  return 0; //button should not be accessible
155  screen_close();
156  return 1;
157 
158  case TAG_MESH:
159  if (pd->mesh_state == MS_idle) {
160  gui_state_mesh_on(screen);
161  pd->mesh_state = MS_home;
162  }
163  break;
164  }
165  if (event == WINDOW_EVENT_CHANGE) {
166  switch ((int)param) {
167  case TAG_MESH:
168  break;
169  }
170  }
171  if (event == WINDOW_EVENT_LOOP) {
173  window_set_text(pd->text_mesh_state.win.id, meshStrings[1]);
174  } else {
175  window_set_text(pd->text_mesh_state.win.id, meshStrings[0]);
176  }
177  switch (pd->mesh_state) {
178  case MS_idle:
179  //do nothing
180  break;
181  case MS_home:
183  marlin_gcode_printf("G28");
184  pd->mesh_state = MS_homeing;
185  break;
186  case MS_homeing:
188  pd->mesh_state = MS_homed;
190  }
191  break;
192  case MS_homed:
193  pd->mesh_state = MS_mesh;
194  //there is no break;
195  case MS_mesh:
196  marlin_gcode_printf("G29");
197  pd->mesh_state = MS_meshing;
198  break;
199  case MS_meshing:
201  pd->mesh_state = MS_meshed;
203  }
204  break;
205  case MS_meshed:
206  gui_state_mesh_off(screen);
207  pd->mesh_state = MS_idle;
208  break;
209  }
210  }
211 
212  return 0;
213 }
Here is the call graph for this function:

Variable Documentation

◆ btnMeshStrings

const char* btnMeshStrings[] = { "Run mesh", "Mesh in progress" }

◆ meshStrings

const char* meshStrings[] = { "Mesh not in failed state", "Mesh in failed state" }

◆ screen_mesh_bed_lv

◆ pscreen_mesh_bed_lv

const screen_t* pscreen_mesh_bed_lv = &screen_mesh_bed_lv
WINDOW_CLS_TERM
#define WINDOW_CLS_TERM
Definition: window.h:17
marlin_event
int marlin_event(uint8_t evt_id)
Definition: marlin_client.c:232
MS_home
Definition: screen_mesh_bed_lv.cpp:19
MS_mesh
Definition: screen_mesh_bed_lv.cpp:22
MS_idle
Definition: screen_mesh_bed_lv.cpp:18
rect_ui16
static rect_ui16_t rect_ui16(uint16_t x, uint16_t y, uint16_t w, uint16_t h)
Definition: guitypes.h:159
window_destroy
void window_destroy(int16_t id)
Definition: window.c:132
MS_meshed
Definition: screen_mesh_bed_lv.cpp:24
WINDOW_EVENT_CHANGE
#define WINDOW_EVENT_CHANGE
Definition: window.h:47
marlin_error_clr
int marlin_error_clr(uint8_t err_id)
Definition: marlin_client.c:324
screen_mesh_bed_lv_data_t
Definition: screen_mesh_bed_lv.cpp:28
screen_close
void screen_close(void)
Definition: screen.c:80
MARLIN_ERR_ProbingFailed
#define MARLIN_ERR_ProbingFailed
Definition: marlin_errors.h:9
window_disable
void window_disable(int16_t id)
Definition: window.c:523
screen_mesh_bed_lv_init
void screen_mesh_bed_lv_init(screen_t *screen)
Definition: screen_mesh_bed_lv.cpp:92
mesh_state_t
mesh_state_t
Definition: screen_mesh_bed_lv.cpp:17
window_set_text
void window_set_text(int16_t id, const char *text)
Definition: window.c:340
gui_state_mesh_off
static void gui_state_mesh_off(screen_t *screen)
Definition: screen_mesh_bed_lv.cpp:67
gui_state_mesh_on
static void gui_state_mesh_on(screen_t *screen)
Definition: screen_mesh_bed_lv.cpp:78
WINDOW_CLS_FRAME
#define WINDOW_CLS_FRAME
Definition: window.h:9
TAG_QUIT
Definition: screen_mesh_bed_lv.cpp:87
window_set_tag
void window_set_tag(int16_t id, uint8_t tag)
Definition: window.c:329
IDR_FNT_BIG
#define IDR_FNT_BIG
Definition: resource.h:11
display
display_t * display
Definition: display.c:6
TAG_MESH
Definition: screen_mesh_bed_lv.cpp:88
MS_homeing
Definition: screen_mesh_bed_lv.cpp:20
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
term_init
void term_init(term_t *pt, uint8_t cols, uint8_t rows, uint8_t *buff)
Definition: term.c:6
meshStrings
const char * meshStrings[]
Definition: screen_mesh_bed_lv.cpp:58
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_enable
void window_enable(int16_t id)
Definition: window.c:517
screen_mesh_bed_lv_draw
void screen_mesh_bed_lv_draw(screen_t *screen)
Definition: screen_mesh_bed_lv.cpp:141
MARLIN_EVT_Ready
#define MARLIN_EVT_Ready
Definition: marlin_events.h:31
_display_t::w
uint16_t w
Definition: display.h:25
pd
#define pd
Definition: screen_mesh_bed_lv.cpp:53
WINDOW_EVENT_LOOP
#define WINDOW_EVENT_LOOP
Definition: window.h:49
MS_meshing
Definition: screen_mesh_bed_lv.cpp:23
marlin_error
int marlin_error(uint8_t err_id)
Definition: marlin_client.c:304
btnMeshStrings
const char * btnMeshStrings[]
Definition: screen_mesh_bed_lv.cpp:55
MESH_DEFAULT_CL
#define MESH_DEFAULT_CL
Definition: screen_mesh_bed_lv.cpp:63
marlin_gcode_printf
int marlin_gcode_printf(const char *format,...)
Definition: marlin_client.c:206
MESH_ACTIVE_CL
#define MESH_ACTIVE_CL
Definition: screen_mesh_bed_lv.cpp:64
window_set_color_text
void window_set_color_text(int16_t id, color_t clr)
Definition: window.c:457
marlin_event_clr
int marlin_event_clr(uint8_t evt_id)
Definition: marlin_client.c:252
screen_mesh_bed_lv_event
int screen_mesh_bed_lv_event(screen_t *screen, window_t *window, uint8_t event, void *param)
Definition: screen_mesh_bed_lv.cpp:144
screen_mesh_bed_lv_done
void screen_mesh_bed_lv_done(screen_t *screen)
Definition: screen_mesh_bed_lv.cpp:137
MS_homed
Definition: screen_mesh_bed_lv.cpp:21