Commit aaf8a30d authored by MagoKimbra's avatar MagoKimbra

Update menu LCD

parent 3b222416
...@@ -134,64 +134,84 @@ static void menu_action_setting_edit_callback_long5(const char* pstr, unsigned l ...@@ -134,64 +134,84 @@ static void menu_action_setting_edit_callback_long5(const char* pstr, unsigned l
/* Helper macros for menus */ /* Helper macros for menus */
/**
* START_MENU generates the init code for a menu function
*/
#define START_MENU() do { \ #define START_MENU() do { \
encoderRateMultiplierEnabled = false; \ encoderRateMultiplierEnabled = false; \
if (encoderPosition > 0x8000) encoderPosition = 0; \ if (encoderPosition > 0x8000) encoderPosition = 0; \
if (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM < currentMenuViewOffset) currentMenuViewOffset = encoderPosition / ENCODER_STEPS_PER_MENU_ITEM;\ uint8_t encoderLine = encoderPosition / ENCODER_STEPS_PER_MENU_ITEM; \
uint8_t _lineNr = currentMenuViewOffset, _menuItemNr; \ if (encoderLine < currentMenuViewOffset) currentMenuViewOffset = encoderLine; \
bool wasClicked = LCD_CLICKED;\ uint8_t _lineNr = currentMenuViewOffset, _menuItemNr; \
for(uint8_t _drawLineNr = 0; _drawLineNr < LCD_HEIGHT; _drawLineNr++, _lineNr++) { \ bool wasClicked = LCD_CLICKED, itemSelected; \
_menuItemNr = 0; if (wasClicked) lcd_quick_feedback(); \
for (uint8_t _drawLineNr = 0; _drawLineNr < LCD_HEIGHT; _drawLineNr++, _lineNr++) { \
_menuItemNr = 0;
/**
* MENU_ITEM generates draw & handler code for a menu item, potentially calling:
*
* lcd_implementation_drawmenu_[type](sel, row, label, arg3...)
* menu_action_[type](arg3...)
*
* Examples:
* MENU_ITEM(back, MSG_WATCH, lcd_status_screen)
* lcd_implementation_drawmenu_back(sel, row, PSTR(MSG_WATCH), lcd_status_screen)
* menu_action_back(lcd_status_screen)
*
* MENU_ITEM(function, MSG_PAUSE_PRINT, lcd_sdcard_pause)
* lcd_implementation_drawmenu_function(sel, row, PSTR(MSG_PAUSE_PRINT), lcd_sdcard_pause)
* menu_action_function(lcd_sdcard_pause)
*
* MENU_ITEM_EDIT(int3, MSG_SPEED, &feedmultiply, 10, 999)
* MENU_ITEM(setting_edit_int3, MSG_SPEED, PSTR(MSG_SPEED), &feedmultiply, 10, 999)
* lcd_implementation_drawmenu_setting_edit_int3(sel, row, PSTR(MSG_SPEED), PSTR(MSG_SPEED), &feedmultiply, 10, 999)
* menu_action_setting_edit_int3(PSTR(MSG_SPEED), &feedmultiply, 10, 999)
*
*/
#define MENU_ITEM(type, label, args...) do { \ #define MENU_ITEM(type, label, args...) do { \
if (_menuItemNr == _lineNr) { \ if (_menuItemNr == _lineNr) { \
if (lcdDrawUpdate) { \ itemSelected = encoderLine == _menuItemNr; \
const char* _label_pstr = PSTR(label); \ if (lcdDrawUpdate) \
if ((encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) == _menuItemNr) { \ lcd_implementation_drawmenu_ ## type(itemSelected, _drawLineNr, PSTR(label), ## args); \
lcd_implementation_drawmenu_ ## type ## _selected (_drawLineNr, _label_pstr , ## args ); \ if (wasClicked && itemSelected) { \
}else{\ menu_action_ ## type(args); \
lcd_implementation_drawmenu_ ## type (_drawLineNr, _label_pstr , ## args ); \ return; \
}\ } \
}\ } \
if (wasClicked && (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) == _menuItemNr) {\ _menuItemNr++; \
lcd_quick_feedback(); \
menu_action_ ## type ( args ); \
return;\
}\
}\
_menuItemNr++;\
} while(0) } while(0)
#ifdef ENCODER_RATE_MULTIPLIER #ifdef ENCODER_RATE_MULTIPLIER
/**
* MENU_MULTIPLIER_ITEM generates drawing and handling code for a multiplier menu item
*/
#define MENU_MULTIPLIER_ITEM(type, label, args...) do { \ #define MENU_MULTIPLIER_ITEM(type, label, args...) do { \
if (_menuItemNr == _lineNr) { \ if (_menuItemNr == _lineNr) { \
if (lcdDrawUpdate) { \ itemSelected = encoderLine == _menuItemNr; \
const char* _label_pstr = PSTR(label); \ if (lcdDrawUpdate) \
if ((encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) == _menuItemNr) { \ lcd_implementation_drawmenu_ ## type(itemSelected, _drawLineNr, PSTR(label), ## args); \
lcd_implementation_drawmenu_ ## type ## _selected (_drawLineNr, _label_pstr , ## args ); \ if (wasClicked && itemSelected) { \
} \
else { \
lcd_implementation_drawmenu_ ## type (_drawLineNr, _label_pstr , ## args ); \
} \
} \
if (wasClicked && (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM) == _menuItemNr) { \
lcd_quick_feedback(); \
encoderRateMultiplierEnabled = true; \ encoderRateMultiplierEnabled = true; \
lastEncoderMovementMillis = 0; \ lastEncoderMovementMillis = 0; \
menu_action_ ## type ( args ); \ menu_action_ ## type(args); \
return; \ return; \
} \ } \
} \ } \
_menuItemNr++; \ _menuItemNr++; \
} while(0) } while(0)
#endif //ENCODER_RATE_MULTIPLIER #endif //ENCODER_RATE_MULTIPLIER
#define MENU_ITEM_DUMMY() do { _menuItemNr++; } while(0) #define MENU_ITEM_DUMMY() do { _menuItemNr++; } while(0)
#define MENU_ITEM_EDIT(type, label, args...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label) , ## args ) #define MENU_ITEM_EDIT(type, label, args...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label), ## args)
#define MENU_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label) , ## args ) #define MENU_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label), ## args)
#ifdef ENCODER_RATE_MULTIPLIER #ifdef ENCODER_RATE_MULTIPLIER
#define MENU_MULTIPLIER_ITEM_EDIT(type, label, args...) MENU_MULTIPLIER_ITEM(setting_edit_ ## type, label, PSTR(label) , ## args ) #define MENU_MULTIPLIER_ITEM_EDIT(type, label, args...) MENU_MULTIPLIER_ITEM(setting_edit_ ## type, label, PSTR(label), ## args)
#define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(type, label, args...) MENU_MULTIPLIER_ITEM(setting_edit_callback_ ## type, label, PSTR(label) , ## args ) #define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(type, label, args...) MENU_MULTIPLIER_ITEM(setting_edit_callback_ ## type, label, PSTR(label), ## args)
#else //!ENCODER_RATE_MULTIPLIER #else //!ENCODER_RATE_MULTIPLIER
#define MENU_MULTIPLIER_ITEM_EDIT(type, label, args...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label) , ## args ) #define MENU_MULTIPLIER_ITEM_EDIT(type, label, args...) MENU_ITEM(setting_edit_ ## type, label, PSTR(label), ## args)
#define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label) , ## args ) #define MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(type, label, args...) MENU_ITEM(setting_edit_callback_ ## type, label, PSTR(label), ## args)
#endif //!ENCODER_RATE_MULTIPLIER #endif //!ENCODER_RATE_MULTIPLIER
#define END_MENU() \ #define END_MENU() \
if (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM >= _menuItemNr) encoderPosition = _menuItemNr * ENCODER_STEPS_PER_MENU_ITEM - 1; \ if (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM >= _menuItemNr) encoderPosition = _menuItemNr * ENCODER_STEPS_PER_MENU_ITEM - 1; \
...@@ -365,16 +385,11 @@ static void lcd_sdcard_pause() { card.pauseSDPrint(); } ...@@ -365,16 +385,11 @@ static void lcd_sdcard_pause() { card.pauseSDPrint(); }
static void lcd_sdcard_resume() { card.startFileprint(); } static void lcd_sdcard_resume() { card.startFileprint(); }
static void lcd_sdcard_stop() { static void lcd_sdcard_stop() {
quickStop();
card.sdprinting = false; card.sdprinting = false;
card.closefile(); card.closefile();
quickStop();
if (SD_FINISHED_STEPPERRELEASE) {
enquecommands_P(PSTR(SD_FINISHED_RELEASECOMMAND));
}
autotempShutdown(); autotempShutdown();
cancel_heatup = true; cancel_heatup = true;
lcd_setstatus(MSG_PRINT_ABORTED); lcd_setstatus(MSG_PRINT_ABORTED);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment