Skip to content

Commit

Permalink
Merge pull request prusa3d#3494 from wavexx/lcd_temperature_jumping
Browse files Browse the repository at this point in the history
Jump to PLA temps in LCD temperature settings when starting from zero
  • Loading branch information
3d-gussner authored Aug 2, 2023
2 parents 491d4d2 + 719db8f commit b1da068
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 21 deletions.
36 changes: 24 additions & 12 deletions Firmware/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,12 +461,21 @@ void menu_draw_float13(const char* str, float val)
lcd_printf_P(menu_fmt_float13, ' ', str, val);
}

template <typename T>
static void _menu_edit_P(void)
static void _menu_edit_P()
{
menu_data_edit_t* _md = (menu_data_edit_t*)&(menu_data[0]);
if (lcd_draw_update)
{
// handle initial value jumping
if (_md->minJumpValue && lcd_encoder) {
if (lcd_encoder > 0 && _md->currentValue == _md->minEditValue) {
_md->currentValue = _md->minJumpValue;
lcd_encoder = 0;
}
// disable after first use and/or if the initial value is not minEditValue
_md->minJumpValue = 0;
}

_md->currentValue += lcd_encoder;
lcd_encoder = 0; // Consume knob rotation event

Expand All @@ -477,40 +486,43 @@ static void _menu_edit_P(void)
}
if (lcd_clicked())
{
*((T)(_md->editValue)) = _md->currentValue;
if (_md->editValueBits == 8)
*((uint8_t*)(_md->editValuePtr)) = _md->currentValue;
else
*((int16_t*)(_md->editValuePtr)) = _md->currentValue;
menu_back_no_reset();
}
}

template <typename T>
void menu_item_edit_P(const char* str, T pval, int16_t min_val, int16_t max_val)
void menu_item_edit_P(const char* str, void* pval, uint8_t pbits, int16_t min_val, int16_t max_val, int16_t jmp_val)
{
menu_data_edit_t* _md = (menu_data_edit_t*)&(menu_data[0]);
if (menu_item == menu_line)
{
int16_t cur_val = (pbits == 8 ? *((uint8_t*)pval) : *((int16_t*)pval));

if (lcd_draw_update)
{
lcd_set_cursor(0, menu_row);
menu_draw_P(menu_selection_mark(), str, *pval);
menu_draw_P(menu_selection_mark(), str, cur_val);
}
if (menu_clicked && (lcd_encoder == menu_item))
{
menu_submenu_no_reset(_menu_edit_P<T>);
menu_submenu_no_reset(_menu_edit_P);
_md->editLabel = str;
_md->editValue = pval;
_md->currentValue = *pval;
_md->editValuePtr = pval;
_md->editValueBits = pbits;
_md->currentValue = cur_val;
_md->minEditValue = min_val;
_md->maxEditValue = max_val;
_md->minJumpValue = jmp_val;
menu_item_ret();
return;
}
}
menu_item++;
}

template void menu_item_edit_P<int16_t*>(const char* str, int16_t *pval, int16_t min_val, int16_t max_val);
template void menu_item_edit_P<uint8_t*>(const char* str, uint8_t *pval, int16_t min_val, int16_t max_val);

static uint8_t progressbar_block_count = 0;
static uint16_t progressbar_total = 0;
void menu_progressbar_init(uint16_t total, const char* title)
Expand Down
12 changes: 6 additions & 6 deletions Firmware/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ typedef struct
{
//Variables used when editing values.
const char* editLabel;
void* editValue;
uint8_t editValueBits; // 8 or 16
void* editValuePtr;
int16_t currentValue;
int16_t minEditValue;
int16_t maxEditValue;
int16_t minJumpValue;
} menu_data_edit_t;

extern uint8_t menu_data[MENU_DATA_SIZE];
Expand Down Expand Up @@ -143,11 +145,9 @@ struct SheetFormatBuffer

extern void menu_format_sheet_E(const Sheet &sheet_E, SheetFormatBuffer &buffer);


#define MENU_ITEM_EDIT_int3_P(str, pval, minval, maxval) do { menu_item_edit_P(str, pval, minval, maxval); } while (0)
//#define MENU_ITEM_EDIT_int3_P(str, pval, minval, maxval) MENU_ITEM_EDIT(int3, str, pval, minval, maxval)
template <typename T>
extern void menu_item_edit_P(const char* str, T pval, int16_t min_val, int16_t max_val);
#define MENU_ITEM_EDIT_int3_P(str, pval, minval, maxval) do { menu_item_edit_P(str, pval, sizeof(*pval)*8, minval, maxval, 0); } while (0)
#define MENU_ITEM_EDIT_int3_jmp_P(str, pval, minval, maxval, jmpval) do { menu_item_edit_P(str, pval, sizeof(*pval)*8, minval, maxval, jmpval); } while (0)
extern void menu_item_edit_P(const char* str, void* pval, uint8_t pbits, int16_t min_val, int16_t max_val, int16_t jmp_val);

extern void menu_progressbar_init(uint16_t total, const char* title);
extern void menu_progressbar_update(uint16_t newVal);
Expand Down
6 changes: 3 additions & 3 deletions Firmware/ultralcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4152,12 +4152,12 @@ static void SETTINGS_SILENT_MODE()

static void menuitems_temperature_common() {
#if TEMP_SENSOR_0 != 0
MENU_ITEM_EDIT_int3_P(_T(MSG_NOZZLE), &target_temperature[0], 0, HEATER_0_MAXTEMP - 10);
MENU_ITEM_EDIT_int3_jmp_P(_T(MSG_NOZZLE), &target_temperature[0], 0, HEATER_0_MAXTEMP - 10, LCD_JUMP_HOTEND_TEMP);
#endif
#if TEMP_SENSOR_BED != 0
MENU_ITEM_EDIT_int3_P(_T(MSG_BED), &target_temperature_bed, 0, BED_MAXTEMP - 5);
MENU_ITEM_EDIT_int3_jmp_P(_T(MSG_BED), &target_temperature_bed, 0, BED_MAXTEMP - 5, LCD_JUMP_BED_TEMP);
#endif
MENU_ITEM_EDIT_int3_P(_T(MSG_FAN_SPEED), &fanSpeed, 0, 255);
MENU_ITEM_EDIT_int3_jmp_P(_T(MSG_FAN_SPEED), &fanSpeed, 0, 255, LCD_JUMP_FAN_SPEED);
}

void SETTINGS_FANS_CHECK() {
Expand Down
4 changes: 4 additions & 0 deletions Firmware/variants/MK25-RAMBo10a.h
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,10 @@
#define FLEX_PREHEAT_HOTEND_TEMP 240
#define FLEX_PREHEAT_HPB_TEMP 50

#define LCD_JUMP_HOTEND_TEMP 200
#define LCD_JUMP_BED_TEMP 50
#define LCD_JUMP_FAN_SPEED 127

/*------------------------------------
THERMISTORS SETTINGS
*------------------------------------*/
Expand Down
4 changes: 4 additions & 0 deletions Firmware/variants/MK25-RAMBo13a.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,10 @@
#define FLEX_PREHEAT_HOTEND_TEMP 240
#define FLEX_PREHEAT_HPB_TEMP 50

#define LCD_JUMP_HOTEND_TEMP 200
#define LCD_JUMP_BED_TEMP 50
#define LCD_JUMP_FAN_SPEED 127

/*------------------------------------
THERMISTORS SETTINGS
*------------------------------------*/
Expand Down
4 changes: 4 additions & 0 deletions Firmware/variants/MK25S-RAMBo10a.h
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,10 @@
#define FLEX_PREHEAT_HOTEND_TEMP 240
#define FLEX_PREHEAT_HPB_TEMP 50

#define LCD_JUMP_HOTEND_TEMP 200
#define LCD_JUMP_BED_TEMP 50
#define LCD_JUMP_FAN_SPEED 127

/*------------------------------------
THERMISTORS SETTINGS
*------------------------------------*/
Expand Down
4 changes: 4 additions & 0 deletions Firmware/variants/MK25S-RAMBo13a.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,10 @@
#define FLEX_PREHEAT_HOTEND_TEMP 240
#define FLEX_PREHEAT_HPB_TEMP 50

#define LCD_JUMP_HOTEND_TEMP 200
#define LCD_JUMP_BED_TEMP 50
#define LCD_JUMP_FAN_SPEED 127

/*------------------------------------
THERMISTORS SETTINGS
*------------------------------------*/
Expand Down
4 changes: 4 additions & 0 deletions Firmware/variants/MK3-E3DREVO.h
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,10 @@
#define FLEX_PREHEAT_HOTEND_TEMP 240
#define FLEX_PREHEAT_HPB_TEMP 50

#define LCD_JUMP_HOTEND_TEMP 200
#define LCD_JUMP_BED_TEMP 50
#define LCD_JUMP_FAN_SPEED 127

/*------------------------------------
THERMISTORS SETTINGS
*------------------------------------*/
Expand Down
4 changes: 4 additions & 0 deletions Firmware/variants/MK3-E3DREVO_HF_60W.h
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,10 @@
#define FLEX_PREHEAT_HOTEND_TEMP 240
#define FLEX_PREHEAT_HPB_TEMP 50

#define LCD_JUMP_HOTEND_TEMP 200
#define LCD_JUMP_BED_TEMP 50
#define LCD_JUMP_FAN_SPEED 127

/*------------------------------------
THERMISTORS SETTINGS
*------------------------------------*/
Expand Down
4 changes: 4 additions & 0 deletions Firmware/variants/MK3.h
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,10 @@
#define FLEX_PREHEAT_HOTEND_TEMP 240
#define FLEX_PREHEAT_HPB_TEMP 50

#define LCD_JUMP_HOTEND_TEMP 200
#define LCD_JUMP_BED_TEMP 50
#define LCD_JUMP_FAN_SPEED 127

/*------------------------------------
THERMISTORS SETTINGS
*------------------------------------*/
Expand Down
4 changes: 4 additions & 0 deletions Firmware/variants/MK3S-E3DREVO.h
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,10 @@
#define FLEX_PREHEAT_HOTEND_TEMP 240
#define FLEX_PREHEAT_HPB_TEMP 50

#define LCD_JUMP_HOTEND_TEMP 200
#define LCD_JUMP_BED_TEMP 50
#define LCD_JUMP_FAN_SPEED 127

/*------------------------------------
THERMISTORS SETTINGS
*------------------------------------*/
Expand Down
4 changes: 4 additions & 0 deletions Firmware/variants/MK3S-E3DREVO_HF_60W.h
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,10 @@
#define FLEX_PREHEAT_HOTEND_TEMP 240
#define FLEX_PREHEAT_HPB_TEMP 50

#define LCD_JUMP_HOTEND_TEMP 200
#define LCD_JUMP_BED_TEMP 50
#define LCD_JUMP_FAN_SPEED 127

/*------------------------------------
THERMISTORS SETTINGS
*------------------------------------*/
Expand Down
4 changes: 4 additions & 0 deletions Firmware/variants/MK3S.h
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,10 @@
#define FLEX_PREHEAT_HOTEND_TEMP 240
#define FLEX_PREHEAT_HPB_TEMP 50

#define LCD_JUMP_HOTEND_TEMP 200
#define LCD_JUMP_BED_TEMP 50
#define LCD_JUMP_FAN_SPEED 127

/*------------------------------------
THERMISTORS SETTINGS
*------------------------------------*/
Expand Down

0 comments on commit b1da068

Please sign in to comment.