Prusa MINI Firmware overview
screen_messages.c File Reference
#include "gui.h"
#include "screen_menu.h"
#include "marlin_server.h"
#include <stdlib.h>

Classes

struct  _screen_messages_data_t
 

Macros

#define pmsg   ((screen_messages_data_t *)screen->pdata)
 

Typedefs

typedef struct _screen_messages_data_t screen_messages_data_t
 

Functions

void _window_list_add_message_item (window_list_t *pwindow_list, uint16_t index, const char **pptext, uint16_t *msg_icon)
 
void _msg_stack_del (uint8_t del_index)
 
void screen_messages_init (screen_t *screen)
 
void screen_messages_draw (screen_t *screen)
 
int screen_messages_event (screen_t *screen, window_t *window, uint8_t event, void *param)
 
void screen_messages_done (screen_t *screen)
 

Variables

screen_t screen_messages
 
msg_stack_t msg_stack
 
const screen_tpscreen_messages = &screen_messages
 

Macro Definition Documentation

◆ pmsg

#define pmsg   ((screen_messages_data_t *)screen->pdata)

Typedef Documentation

◆ screen_messages_data_t

Function Documentation

◆ _window_list_add_message_item()

void _window_list_add_message_item ( window_list_t pwindow_list,
uint16_t  index,
const char **  pptext,
uint16_t *  msg_icon 
)
32  {
33  static const char empty_str[] = "";
34  static const char back_str[] = "BACK";
35  if (index == 0) {
36  *pptext = back_str;
37  //*pid_icon = IDR_PNG_filescreen_icon_up_folder;
38  } else {
39  if (index <= msg_stack.count)
40  *pptext = msg_stack.msg_data[index - 1];
41  else
42  *pptext = empty_str; // it shouldn't ever get here (safety measure)
43  }
44  *msg_icon = 0;
45 }
Here is the caller graph for this function:

◆ _msg_stack_del()

void _msg_stack_del ( uint8_t  del_index)
47  { // del_index = < 0 ; MSG_STACK_SIZE - 1 >
48 
49  // when we delete from last spot of the limited stack [MSG_STACK_SIZE - 1], no swapping is needed, for cycle won't start
50  for (uint8_t i = del_index; i + 1 < msg_stack.count; i++)
52  msg_stack.count--;
53 }

◆ screen_messages_init()

void screen_messages_init ( screen_t screen)
55  {
56 
57  int16_t id;
58  int16_t root = window_create_ptr(WINDOW_CLS_FRAME, -1,
59  rect_ui16(0, 0, 0, 0),
60  &(pmsg->root));
61  window_disable(root);
62 
63  id = window_create_ptr(WINDOW_CLS_HEADER, root, rect_ui16(0, 0, 240, 31), &(pmsg->header));
64  // p_window_header_set_icon(&(pmsg->header), IDR_PNG_status_icon_menu); ICONka od Michala Fanty
65  p_window_header_set_text(&(pmsg->header), "MESSAGES");
66 
67  id = window_create_ptr(WINDOW_CLS_LIST, root, rect_ui16(0, 32, 240, 320 - 83), &(pmsg->list));
69  window_set_item_index(id, 0);
71 
72  window_set_capture(pmsg->list.win.id);
73 
74  pmsg->pfooter = (status_footer_t *)gui_malloc(sizeof(status_footer_t));
75  status_footer_init(pmsg->pfooter, root);
76 }
Here is the call graph for this function:

◆ screen_messages_draw()

void screen_messages_draw ( screen_t screen)
78  {
79 }

◆ screen_messages_event()

int screen_messages_event ( screen_t screen,
window_t window,
uint8_t  event,
void param 
)
82  {
83 
84  switch (event) {
86  case WINDOW_EVENT_CLICK:
87  if (pmsg->list.index == 0) {
88  screen_close();
89  return 1;
90  } /*else if (pmsg->list.index <= msg_stack.count) { TODO: Deleted message stays on the screen
91  _msg_stack_del(pmsg->list.index - 1);
92  _window_invalidate((window_t*)&(pmsg->list));
93  } */
94  break;
95  default:
96  break;
97  }
98 
99  pmsg->list.count = msg_stack.count + 1;
100 
101  status_footer_event(pmsg->pfooter, window, event, param);
102 
103  return 0;
104 }
Here is the call graph for this function:

◆ screen_messages_done()

void screen_messages_done ( screen_t screen)
106  {
107  window_destroy(pmsg->root.win.id);
108  free(pmsg->pfooter);
109 }
Here is the call graph for this function:

Variable Documentation

◆ screen_messages

◆ msg_stack

◆ pscreen_messages

const screen_t* pscreen_messages = &screen_messages
msg_stack
Definition: marlin_server.h:26
rect_ui16
static rect_ui16_t rect_ui16(uint16_t x, uint16_t y, uint16_t w, uint16_t h)
Definition: guitypes.h:159
gui_malloc
void * gui_malloc(unsigned int size)
Definition: gui.c:35
window_destroy
void window_destroy(int16_t id)
Definition: window.c:132
i
uint8_t i
Definition: screen_test_graph.c:72
msg_stack::count
uint8_t count
Definition: marlin_server.h:29
screen_close
void screen_close(void)
Definition: screen.c:80
msg_stack::msg_data
char msg_data[MSG_STACK_SIZE][MSG_MAX_LENGTH]
Definition: marlin_server.h:28
WINDOW_CLS_LIST
#define WINDOW_CLS_LIST
Definition: window.h:13
window_disable
void window_disable(int16_t id)
Definition: window.c:523
screen_messages_done
void screen_messages_done(screen_t *screen)
Definition: screen_messages.c:106
WINDOW_CLS_FRAME
#define WINDOW_CLS_FRAME
Definition: window.h:9
window_set_capture
void window_set_capture(int16_t id)
Definition: window.c:500
screen_messages_data_t
struct _screen_messages_data_t screen_messages_data_t
screen_messages_init
void screen_messages_init(screen_t *screen)
Definition: screen_messages.c:55
uint8_t
const uint8_t[]
Definition: 404_html.c:3
MSG_MAX_LENGTH
#define MSG_MAX_LENGTH
Definition: marlin_server.h:19
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
screen_messages_event
int screen_messages_event(screen_t *screen, window_t *window, uint8_t event, void *param)
Definition: screen_messages.c:81
pmsg
#define pmsg
Definition: screen_messages.c:29
WINDOW_CLS_HEADER
int16_t WINDOW_CLS_HEADER
Definition: window_header.c:24
screen_messages_draw
void screen_messages_draw(screen_t *screen)
Definition: screen_messages.c:78
WINDOW_EVENT_BTN_DN
#define WINDOW_EVENT_BTN_DN
Definition: window.h:38
window_set_item_count
void window_set_item_count(int16_t id, int count)
Definition: window.c:573
window_set_item_callback
void window_set_item_callback(int16_t id, window_list_item_t *fnc)
Definition: window.c:787
_window_list_add_message_item
void _window_list_add_message_item(window_list_t *pwindow_list, uint16_t index, const char **pptext, uint16_t *msg_icon)
Definition: screen_messages.c:31
window_set_item_index
void window_set_item_index(int16_t id, int index)
Definition: window.c:598
p_window_header_set_text
void p_window_header_set_text(window_header_t *window, const char *text)
Definition: window_header.c:152