Prusa MINI Firmware overview
window_header.c File Reference
#include <stdbool.h>
#include "window_header.h"
#include "config.h"
#include "marlin_client.h"
#include "lwip/netif.h"
#include "lwip/dhcp.h"

Functions

bool media_is_inserted ()
 
void window_frame_draw (window_frame_t *window)
 
void window_header_init (window_header_t *window)
 
void window_header_done (window_header_t *window)
 
void window_header_draw (window_header_t *window)
 
void p_window_header_set_icon (window_header_t *window, uint16_t id_res)
 
void p_window_header_icon_off (window_header_t *window, header_icons_t icon)
 
void p_window_header_icon_on (window_header_t *window, header_icons_t icon)
 
void p_window_header_icon_active (window_header_t *window, header_icons_t icon)
 
header_states_t p_window_header_get_state (window_header_t *window, header_icons_t icon)
 
void p_window_header_set_text (window_header_t *window, const char *text)
 
int p_window_header_event_clr (window_header_t *window, uint8_t evt_id)
 

Variables

struct netif eth0
 
int16_t WINDOW_CLS_HEADER = 0
 
const window_class_header_t window_class_header
 

Function Documentation

◆ media_is_inserted()

bool media_is_inserted ( )
17  {
18  return _media_inserted;
19 }
Here is the caller graph for this function:

◆ window_frame_draw()

void window_frame_draw ( window_frame_t window)
15  {
16  if (window->win.f_visible) {
17  if (window->win.f_invalid) {
18  rect_ui16_t rc = window->win.rect;
19  display->fill_rect(rc, window->color_back);
20  window->win.f_invalid = 0;
22  }
23  window_draw_children(window->win.id);
24  }
25 }
Here is the call graph for this function:

◆ window_header_init()

void window_header_init ( window_header_t window)
26  {
29  window->font = gui_defaults.font;
30  window->padding = gui_defaults.padding;
31  window->alignment = ALIGN_LEFT_CENTER;
32  window->id_res = IDR_NULL;
36  window->label = NULL;
37 
38  if (media_is_inserted()) {
40  }
41 
42  if (netif_is_up(&eth0)) {
43  if (dhcp_supplied_address(&eth0)) {
45  } else {
47  }
48  }
49 
50 #if 0
51  if (netif_is_up(&wlan0)) {
52  if (dhcp_supplied_address(&wlan0)){
54  } else {
56  }
57  }
58 #endif
59 }
Here is the call graph for this function:

◆ window_header_done()

void window_header_done ( window_header_t window)
61 {}

◆ window_header_draw()

void window_header_draw ( window_header_t window)
63  {
64  if (!((window->win.flg & (WINDOW_FLG_INVALID | WINDOW_FLG_VISIBLE))
66  return;
67  }
68 
69  rect_ui16_t rc = {
70  window->win.rect.x + 10, window->win.rect.y,
71  window->win.rect.h, window->win.rect.h
72  };
73 
74  if (window->id_res) { // first icon
75  render_icon_align(rc, window->id_res,
76  window->color_back, RENDER_FLG(ALIGN_CENTER, 0));
77  } else {
78  display->fill_rect(rc, window->color_back);
79  }
80 
81  uint16_t icons_width = 10 + 36;
82  rc = rect_ui16( // usb icon is showed always
83  window->win.rect.x + window->win.rect.w - 10 - 34, window->win.rect.y,
84  36, window->win.rect.h);
87  window->color_back, RENDER_FLG(ALIGN_CENTER, ropfn));
88 
89  for (int i = HEADER_ICON_USB + 1; i < HEADER_ICON_COUNT; i++) {
90  if (window->icons[i] > HEADER_ISTATE_OFF) {
91  icons_width += 20;
92  rc = rect_ui16(
93  window->win.rect.x + window->win.rect.w - icons_width,
94  window->win.rect.y, 20, window->win.rect.h);
95  ropfn = (window->icons[i] == HEADER_ISTATE_ACTIVE) ? 0 : ROPFN_DISABLE;
96  uint16_t id_res = 0;
97  switch (i) {
98  case HEADER_ICON_LAN:
99  id_res = IDR_PNG_header_icon_lan;
100  break;
101  case HEADER_ICON_WIFI:
102  id_res = IDR_PNG_header_icon_wifi;
103  break;
104  }
105  render_icon_align(rc, id_res,
106  window->color_back, RENDER_FLG(ALIGN_CENTER, ropfn));
107  }
108  }
109 
110  rc = window->win.rect;
111  rc.x += 10 + window->win.rect.h;
112  rc.w -= (icons_width + 10 + window->win.rect.h);
113 
114  if (window->label) { // label
115  render_text_align(rc, window->label, window->font,
116  window->color_back, window->color_text,
117  window->padding, window->alignment);
118  }
119 }
Here is the call graph for this function:

◆ p_window_header_set_icon()

void p_window_header_set_icon ( window_header_t window,
uint16_t  id_res 
)
121  {
122  window->id_res = id_res;
123  _window_invalidate((window_t *)window);
124 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ p_window_header_icon_off()

void p_window_header_icon_off ( window_header_t window,
header_icons_t  icon 
)
126  {
127  if (window->icons[icon] != HEADER_ISTATE_OFF) {
128  window->icons[icon] = HEADER_ISTATE_OFF;
129  _window_invalidate((window_t *)window);
130  }
131 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ p_window_header_icon_on()

void p_window_header_icon_on ( window_header_t window,
header_icons_t  icon 
)
133  {
134  if (window->icons[icon] != HEADER_ISTATE_ON) {
135  window->icons[icon] = HEADER_ISTATE_ON;
136  _window_invalidate((window_t *)window);
137  }
138 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ p_window_header_icon_active()

void p_window_header_icon_active ( window_header_t window,
header_icons_t  icon 
)
140  {
141  if (window->icons[icon] != HEADER_ISTATE_ACTIVE) {
142  window->icons[icon] = HEADER_ISTATE_ACTIVE;
143  _window_invalidate((window_t *)window);
144  }
145 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ p_window_header_get_state()

header_states_t p_window_header_get_state ( window_header_t window,
header_icons_t  icon 
)
148  {
149  return window->icons[icon];
150 }

◆ p_window_header_set_text()

void p_window_header_set_text ( window_header_t window,
const char *  text 
)
152  {
153  window->label = text;
154  _window_invalidate((window_t *)window);
155 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ p_window_header_event_clr()

int p_window_header_event_clr ( window_header_t window,
uint8_t  evt_id 
)
157  {
158  /* lwip fces only read states, invalid states by another thread never mind */
159  if (netif_is_up(&eth0)) {
160  if (dhcp_supplied_address(&eth0)) {
162  } else {
164  }
165  } else {
167  }
168 
169  if (marlin_event_clr(evt_id)) {
170  switch (evt_id) {
173  break;
176  break;
177  }
178  return 1;
179  }
180  return 0;
181 }
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ eth0

struct netif eth0

File Name : LWIP.h Description : This file provides code for the configuration of the LWIP.

This notice applies to any and all portions of this file that are not between comment pairs USER CODE BEGIN and USER CODE END. Other portions of this file, whether inserted by the user or by software development tools are owned by their respective copyright owners.

Copyright (c) 2019 STMicroelectronics International N.V. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted, provided that the following conditions are met:

  1. Redistribution of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of other contributors to this software may be used to endorse or promote products derived from this software without specific written permission.
  4. This software, including modifications and/or derivative works of this software, must execute solely and exclusively on microcontroller or microprocessor devices manufactured by or for STMicroelectronics.
  5. Redistribution and use of this software other than as permitted under this license is void and will automatically terminate your rights under this license.

THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

◆ WINDOW_CLS_HEADER

int16_t WINDOW_CLS_HEADER = 0

◆ window_class_header

RENDER_FLG
#define RENDER_FLG(a, r)
Definition: display_helper.h:10
window_draw_t
void() window_draw_t(void *window)
Definition: window.h:57
_rect_ui16_t::y
uint16_t y
Definition: guitypes.h:71
_rect_ui16_t::w
uint16_t w
Definition: guitypes.h:72
window_header_draw
void window_header_draw(window_header_t *window)
Definition: window_header.c:63
IDR_PNG_header_icon_usb
#define IDR_PNG_header_icon_usb
Definition: resource.h:63
_gui_defaults_t::color_text
color_t color_text
Definition: guitypes.h:108
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
_window_header_t::font
font_t * font
Definition: window_header.h:41
_gui_defaults_t::font
font_t * font
Definition: guitypes.h:110
HEADER_ISTATE_OFF
Definition: window_header.h:15
HEADER_ISTATE_ON
Definition: window_header.h:16
IDR_PNG_header_icon_lan
#define IDR_PNG_header_icon_lan
Definition: resource.h:64
i
uint8_t i
Definition: screen_test_graph.c:72
WINDOW_CLS_USER
#define WINDOW_CLS_USER
Definition: window.h:21
IDR_NULL
#define IDR_NULL
Definition: resource.h:6
WINDOW_FLG_VISIBLE
#define WINDOW_FLG_VISIBLE
Definition: window.h:24
window_header_done
void window_header_done(window_header_t *window)
Definition: window_header.c:61
_media_inserted
static bool _media_inserted
Definition: Marlin_CardReader.cpp:15
MARLIN_EVT_MediaInserted
#define MARLIN_EVT_MediaInserted
Definition: marlin_events.h:11
NULL
#define NULL
Definition: usbd_def.h:53
_window_frame_t::color_back
color_t color_back
Definition: window_frame.h:20
_display_t::fill_rect
display_fill_rect_t * fill_rect
Definition: display.h:33
_window_header_t::alignment
uint8_t alignment
Definition: window_header.h:43
_window_t::id
int16_t id
Definition: window.h:79
_gui_defaults_t::padding
padding_ui8_t padding
Definition: guitypes.h:112
_window_t::f_invalid
uint32_t f_invalid
Definition: window.h:87
_window_header_t::color_text
color_t color_text
Definition: window_header.h:40
window_header_init
void window_header_init(window_header_t *window)
Definition: window_header.c:26
window_done_t
void() window_done_t(void *window)
Definition: window.h:56
_window_header_t::icons
header_states_t icons[HEADER_ICON_COUNT]
Definition: window_header.h:45
eth0
struct netif eth0
Definition: lwip.c:72
HEADER_ICON_USB
Definition: window_header.h:21
_window_t
Definition: window.h:76
ROPFN_DISABLE
#define ROPFN_DISABLE
Definition: guitypes.h:33
media_is_inserted
bool media_is_inserted()
Definition: Marlin_CardReader.cpp:17
window_draw_children
void window_draw_children(int16_t id)
Definition: window.c:284
_gui_defaults_t::color_back
color_t color_back
Definition: guitypes.h:107
_window_header_t::color_back
color_t color_back
Definition: window_header.h:39
p_window_header_icon_off
void p_window_header_icon_off(window_header_t *window, header_icons_t icon)
Definition: window_header.c:126
_rect_ui16_t
Definition: guitypes.h:69
render_text_align
void render_text_align(rect_ui16_t rc, const char *text, font_t *font, color_t clr0, color_t clr1, padding_ui8_t padding, uint16_t flags)
Definition: display_helper.c:6
uint8_t
const uint8_t[]
Definition: 404_html.c:3
_window_header_t::padding
padding_ui8_t padding
Definition: window_header.h:42
display
display_t * display
Definition: display.c:6
_rect_ui16_t::h
uint16_t h
Definition: guitypes.h:73
_window_header_t::win
window_t win
Definition: window_header.h:37
_window_t::rect
rect_ui16_t rect
Definition: window.h:101
_window_frame_t::win
window_t win
Definition: window_frame.h:19
_window_header_t::id_res
uint16_t id_res
Definition: window_header.h:44
HEADER_ICON_WIFI
Definition: window_header.h:23
window_invalidate_children
void window_invalidate_children(int16_t id)
Definition: window.c:320
_window_t::f_visible
uint32_t f_visible
Definition: window.h:85
IDR_PNG_header_icon_wifi
#define IDR_PNG_header_icon_wifi
Definition: resource.h:65
_rect_ui16_t::x
uint16_t x
Definition: guitypes.h:70
window_init_t
void() window_init_t(void *window)
Definition: window.h:55
MARLIN_EVT_MediaRemoved
#define MARLIN_EVT_MediaRemoved
Definition: marlin_events.h:13
gui_defaults
gui_defaults_t gui_defaults
Definition: gui.c:20
render_icon_align
void render_icon_align(rect_ui16_t rc, uint16_t id_res, color_t clr0, uint16_t flags)
Definition: display_helper.c:55
p_window_header_icon_active
void p_window_header_icon_active(window_header_t *window, header_icons_t icon)
Definition: window_header.c:140
p_window_header_icon_on
void p_window_header_icon_on(window_header_t *window, header_icons_t icon)
Definition: window_header.c:133
window_header_t
struct _window_header_t window_header_t
HEADER_ISTATE_ACTIVE
Definition: window_header.h:17
HEADER_ICON_LAN
Definition: window_header.h:22
_window_t::flg
uint32_t flg
Definition: window.h:81
HEADER_ICON_COUNT
#define HEADER_ICON_COUNT
Definition: window_header.h:27
WINDOW_FLG_INVALID
#define WINDOW_FLG_INVALID
Definition: window.h:26
_window_invalidate
static void _window_invalidate(window_t *window)
Definition: window.h:257
marlin_event_clr
int marlin_event_clr(uint8_t evt_id)
Definition: marlin_client.c:252
netif_is_up
#define netif_is_up(netif)
Definition: netif.h:401
_window_header_t::label
const char * label
Definition: window_header.h:46
ALIGN_LEFT_CENTER
#define ALIGN_LEFT_CENTER
Definition: guitypes.h:21