Prusa MINI Firmware overview
screen_menu_service.c File Reference
#include "config.h"
#include "gui.h"
#include "screen_menu.h"
#include "stm32f4xx_hal.h"
#include "sys.h"
#include "dbg.h"
#include "bsod.h"
#include "eeprom.h"

Enumerations

enum  MI_t {
  MI_RETURN, MI_RETURN, MI_WIZARD, MI_Z_OFFSET,
  MI_AUTO_HOME, MI_MESH_BED, MI_SELFTEST, MI_CALIB_FIRST,
  MI_RETURN, MI_LOAD, MI_UNLOAD, MI_CHANGE,
  MI_PURGE, MI_RETURN, MI_ALWAYS, MI_ON_RESTART,
  MI_COUNT, MI_RETURN, MI_SYS_INFO, MI_VERSIONS,
  MI_RETURN, MI_MOVE_X, MI_MOVE_Y, MI_MOVE_Z,
  MI_MOVE_E, MI_RETURN, MI_SYS_RESET, MI_CLR_EEPROM,
  MI_WDG_TEST, MI_PLL, MI_SSCG, MI_SSCG_FREQ,
  MI_SSCG_DEPTH, MI_SPI_PRESC, MI_MESH, MI_BSOD,
  MI_BSOD_HARD_FAULT, MI_COUNT, MI_RETURN, MI_TEMPERATURE,
  MI_MOVE_AXIS, MI_DISABLE_STEP, MI_FACTORY_DEFAULTS, MI_FW_UPDATE,
  MI_FILAMENT_SENSOR, MI_TIMEOUT, MI_LAN_SETTINGS, MI_RETURN,
  MI_NOZZLE, MI_HEATBED, MI_PRINTFAN, MI_COOLDOWN,
  MI_RETURN, MI_NOZZLE, MI_HEAT_PWM_PERIOD, MI_HEATBED,
  MI_FAN_PWM_PERIOD, MI_PRINTFAN, MI_COOLDOWN, MI_COUNT
}
 

Functions

void screen_menu_service_init (screen_t *screen)
 
int screen_menu_service_event (screen_t *screen, window_t *window, uint8_t event, void *param)
 

Variables

screen_tpscreen_mesh_bed_lv
 
screen_tpscreen_test_disp_mem
 
int16_t sscg_freq_kHz = 5
 
int16_t sscg_depth = 5
 
int16_t spi_prescaler = 0
 
const char * opt_enable_disable [] = { "Enable", "Disable", NULL }
 
const int32_t opt_sscg_freq [] = { 5000, 150000, 1000 }
 
const int32_t opt_sscg_depth [] = { 1000, 20000, 1000 }
 
const char * opt_spi [] = { "21M", "10.5M", "5.25M", "2.63M", "1.31M", "656k", "328k", "164k", NULL }
 
screen_t screen_menu_service
 
const screen_tpscreen_menu_service = &screen_menu_service
 

Enumeration Type Documentation

◆ MI_t

enum MI_t
Enumerator
MI_RETURN 
MI_RETURN 
MI_WIZARD 
MI_Z_OFFSET 
MI_AUTO_HOME 
MI_MESH_BED 
MI_SELFTEST 
MI_CALIB_FIRST 
MI_RETURN 
MI_LOAD 
MI_UNLOAD 
MI_CHANGE 
MI_PURGE 
MI_RETURN 
MI_ALWAYS 
MI_ON_RESTART 
MI_COUNT 
MI_RETURN 
MI_SYS_INFO 
MI_VERSIONS 
MI_RETURN 
MI_MOVE_X 
MI_MOVE_Y 
MI_MOVE_Z 
MI_MOVE_E 
MI_RETURN 
MI_SYS_RESET 
MI_CLR_EEPROM 
MI_WDG_TEST 
MI_PLL 
MI_SSCG 
MI_SSCG_FREQ 
MI_SSCG_DEPTH 
MI_SPI_PRESC 
MI_MESH 
MI_BSOD 
MI_BSOD_HARD_FAULT 
MI_COUNT 
MI_RETURN 
MI_TEMPERATURE 
MI_MOVE_AXIS 
MI_DISABLE_STEP 
MI_FACTORY_DEFAULTS 
MI_FW_UPDATE 
MI_FILAMENT_SENSOR 
MI_TIMEOUT 
MI_LAN_SETTINGS 
MI_RETURN 
MI_NOZZLE 
MI_HEATBED 
MI_PRINTFAN 
MI_COOLDOWN 
MI_RETURN 
MI_NOZZLE 
MI_HEAT_PWM_PERIOD 
MI_HEATBED 
MI_FAN_PWM_PERIOD 
MI_PRINTFAN 
MI_COOLDOWN 
MI_COUNT 
18  {
19  MI_RETURN,
23  MI_PLL,
24  MI_SSCG,
28 #ifdef PIDCALIBRATION
29  MI_PID,
30 #endif //PIDCALIBRATION
31  MI_MESH,
32  MI_BSOD,
34  MI_COUNT
35 } MI_t;

Function Documentation

◆ screen_menu_service_init()

void screen_menu_service_init ( screen_t screen)
46  {
47  screen_menu_init(screen, "SERVICE", MI_COUNT, 0, 0);
48 
50  psmd->items[MI_SYS_RESET] = (menu_item_t) { { "System reset", 0, WI_LABEL }, SCREEN_MENU_NO_SCREEN };
51  psmd->items[MI_CLR_EEPROM] = (menu_item_t) { { "Clear EEPROM", 0, WI_LABEL }, SCREEN_MENU_NO_SCREEN };
52  psmd->items[MI_WDG_TEST] = (menu_item_t) { { "Watchdog test", 0, WI_LABEL }, SCREEN_MENU_NO_SCREEN };
53  psmd->items[MI_PLL] = (menu_item_t) { { "PLL", 0, WI_SWITCH, .wi_switch_select = { 0, opt_enable_disable } }, SCREEN_MENU_NO_SCREEN };
54  psmd->items[MI_SSCG] = (menu_item_t) { { "SSCG", 0, WI_SWITCH, .wi_switch_select = { 0, opt_enable_disable } }, SCREEN_MENU_NO_SCREEN };
55  psmd->items[MI_SSCG_FREQ] = (menu_item_t) { { "SSCG freq", 0, WI_SPIN, .wi_spin = { 0, opt_sscg_freq } }, SCREEN_MENU_NO_SCREEN };
56  psmd->items[MI_SSCG_DEPTH] = (menu_item_t) { { "SSCG depth", 0, WI_SPIN, .wi_spin = { 0, opt_sscg_depth } }, SCREEN_MENU_NO_SCREEN };
57  psmd->items[MI_SPI_PRESC] = (menu_item_t) { { "SPI freq", 0, WI_SELECT, .wi_switch_select = { 0, opt_spi } }, SCREEN_MENU_NO_SCREEN };
58 #ifdef PIDCALIBRATION
59  psmd->items[MI_PID] = (menu_item_t) { { "PID calibration", 0, WI_LABEL }, pscreen_PID };
60 #endif //PIDCALIBRATION
61  psmd->items[MI_MESH] = (menu_item_t) { { "Mesh bed leveling", 0, WI_LABEL }, pscreen_mesh_bed_lv };
62  psmd->items[MI_BSOD] = (menu_item_t) { { "BSOD", 0, WI_LABEL }, SCREEN_MENU_NO_SCREEN };
63  psmd->items[MI_BSOD_HARD_FAULT] = (menu_item_t) { { "BSOD_HARD_FAULT", 0, WI_LABEL }, SCREEN_MENU_NO_SCREEN };
64  psmd->items[MI_PLL].item.wi_switch_select.index = sys_pll_is_enabled() ? 1 : 0;
65  psmd->items[MI_SSCG].item.wi_switch_select.index = sys_sscg_is_enabled() ? 1 : 0;
66  psmd->items[MI_SSCG_FREQ].item.wi_spin.value = sscg_freq_kHz * 1000;
67  psmd->items[MI_SSCG_DEPTH].item.wi_spin.value = sscg_depth * 1000;
68  psmd->items[MI_SPI_PRESC].item.wi_switch_select.index = spi_prescaler;
69 }
Here is the call graph for this function:

◆ screen_menu_service_event()

int screen_menu_service_event ( screen_t screen,
window_t window,
uint8_t  event,
void param 
)
71  {
72 
73  if (screen_menu_event(screen, window, event, param)) {
74  return 1;
75  }
76  if (event == WINDOW_EVENT_CLICK) {
77  switch ((int)param) {
78  case MI_SYS_RESET:
79  sys_reset();
80  break;
81  case MI_CLR_EEPROM:
82  eeprom_clear();
83  break;
84  case MI_WDG_TEST:
85  __disable_irq();
86  while (1)
87  ;
88  break;
89  case MI_PLL:
90  if (psmd->items[MI_PLL].item.wi_switch_select.index)
92  else
94  break;
95  case MI_SSCG:
96  if (psmd->items[MI_SSCG].item.wi_switch_select.index) {
99  } else
101  break;
102  case MI_BSOD:
103  bsod("System error! Please restart the printer.");
104  break;
105  case MI_BSOD_HARD_FAULT: {
106  //this will cause hard fault
107  //0x08000000 - flash origin
108  volatile uint32_t *crash = (uint32_t *)0x20020000 + 4; //0x08000000;
109  *crash = 1;
110  for (int i = 0; i < 1000; ++i) {
111  psmd->items[i].item.wi_spin.value = i;
112  }
113  break;
114  }
115  }
116  } else if (event == WINDOW_EVENT_CHANGE) {
117  switch ((int)param) {
118  case MI_SSCG_FREQ:
119  case MI_SSCG_DEPTH:
120  sscg_freq_kHz = psmd->items[MI_SSCG_FREQ].item.wi_spin.value / 1000;
121  sscg_depth = psmd->items[MI_SSCG_DEPTH].item.wi_spin.value / 1000;
122  if (sys_sscg_is_enabled()) {
125  sys_sscg_enable();
126  }
127  break;
128  case MI_SPI_PRESC:
129  sys_spi_set_prescaler(psmd->items[MI_SPI_PRESC].item.wi_switch_select.index);
130  break;
131  }
132  }
133  return 0;
134 }
Here is the call graph for this function:

Variable Documentation

◆ pscreen_mesh_bed_lv

screen_t* pscreen_mesh_bed_lv

◆ pscreen_test_disp_mem

screen_t* pscreen_test_disp_mem

◆ sscg_freq_kHz

int16_t sscg_freq_kHz = 5

◆ sscg_depth

int16_t sscg_depth = 5

◆ spi_prescaler

int16_t spi_prescaler = 0

◆ opt_enable_disable

const char* opt_enable_disable[] = { "Enable", "Disable", NULL }

◆ opt_sscg_freq

const int32_t opt_sscg_freq[] = { 5000, 150000, 1000 }

◆ opt_sscg_depth

const int32_t opt_sscg_depth[] = { 1000, 20000, 1000 }

◆ opt_spi

const char* opt_spi[] = { "21M", "10.5M", "5.25M", "2.63M", "1.31M", "656k", "328k", "164k", NULL }

◆ screen_menu_service

◆ pscreen_menu_service

const screen_t* pscreen_menu_service = &screen_menu_service
MI_SPI_PRESC
Definition: screen_menu_service.c:27
opt_sscg_depth
const int32_t opt_sscg_depth[]
Definition: screen_menu_service.c:43
screen_menu_draw
void screen_menu_draw(screen_t *screen)
Definition: screen_menu.c:90
sys_spi_set_prescaler
void sys_spi_set_prescaler(int prescaler_num)
Definition: sys.cpp:230
sys_reset
void sys_reset(void)
Definition: sys.cpp:20
spi_prescaler
int16_t spi_prescaler
Definition: screen_menu_service.c:39
pscreen_mesh_bed_lv
screen_t * pscreen_mesh_bed_lv
Definition: screen_mesh_bed_lv.cpp:228
screen_menu_event
int screen_menu_event(screen_t *screen, window_t *window, uint8_t event, void *param)
Definition: screen_menu.c:92
screen_menu_done
void screen_menu_done(screen_t *screen)
Definition: screen_menu.c:78
i
uint8_t i
Definition: screen_test_graph.c:72
SCREEN_MENU_NO_SCREEN
#define SCREEN_MENU_NO_SCREEN
Definition: screen_menu.h:39
sscg_depth
int16_t sscg_depth
Definition: screen_menu_service.c:38
eeprom_clear
void eeprom_clear(void)
Definition: eeprom.c:201
MI_CLR_EEPROM
Definition: screen_menu_service.c:21
WI_SPIN
Definition: window_menu.h:15
MI_SYS_RESET
Definition: screen_menu_service.c:20
WINDOW_EVENT_CHANGE
#define WINDOW_EVENT_CHANGE
Definition: window.h:47
sys_pll_is_enabled
int sys_pll_is_enabled(void)
Definition: sys.cpp:48
MI_PLL
Definition: screen_menu_service.c:23
MI_COUNT
Definition: screen_menu_service.c:34
menu_item_t
struct _menu_item_t menu_item_t
sys_sscg_enable
void sys_sscg_enable(void)
Definition: sys.cpp:140
sys_pll_enable
void sys_pll_enable(void)
Definition: sys.cpp:78
MI_t
MI_t
Definition: screen_menu_service.c:18
screen_menu_init
void screen_menu_init(screen_t *screen, const char *label, int count, uint8_t footer, uint8_t help)
Definition: screen_menu.c:25
MI_WDG_TEST
Definition: screen_menu_service.c:22
screen_menu_service_event
int screen_menu_service_event(screen_t *screen, window_t *window, uint8_t event, void *param)
Definition: screen_menu_service.c:71
screen_menu_service_init
void screen_menu_service_init(screen_t *screen)
Definition: screen_menu_service.c:46
MI_SSCG
Definition: screen_menu_service.c:24
sscg_freq_kHz
int16_t sscg_freq_kHz
Definition: screen_menu_service.c:37
opt_sscg_freq
const int32_t opt_sscg_freq[]
Definition: screen_menu_service.c:42
MI_SSCG_FREQ
Definition: screen_menu_service.c:25
WI_SWITCH
Definition: window_menu.h:16
MI_MESH
Definition: screen_menu_service.c:31
psmd
#define psmd
Definition: screen_menu.h:40
MI_SSCG_DEPTH
Definition: screen_menu_service.c:26
WI_LABEL
Definition: window_menu.h:14
sys_sscg_set_config
void sys_sscg_set_config(int freq, int depth)
Definition: sys.cpp:159
sys_sscg_disable
void sys_sscg_disable(void)
Definition: sys.cpp:125
menu_item_return
const menu_item_t menu_item_return
Definition: screen_menu.c:14
sys_pll_disable
void sys_pll_disable(void)
Definition: sys.cpp:57
WINDOW_EVENT_CLICK
#define WINDOW_EVENT_CLICK
Definition: window.h:46
screen_menu_data_t
Definition: screen_menu.h:24
MI_RETURN
Definition: screen_menu_service.c:19
bsod
#define bsod(fmt,...)
Definition: bsod.h:20
WI_SELECT
Definition: window_menu.h:17
opt_spi
const char * opt_spi[]
Definition: screen_menu_service.c:44
MI_BSOD
Definition: screen_menu_service.c:32
opt_enable_disable
const char * opt_enable_disable[]
Definition: screen_menu_service.c:41
MI_BSOD_HARD_FAULT
Definition: screen_menu_service.c:33
sys_sscg_is_enabled
int sys_sscg_is_enabled(void)
Definition: sys.cpp:121