Commit e82b1225 authored by MagoKimbra's avatar MagoKimbra

Fix

parent de8992bb
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
#define MSG_EXTRUDE "Extrude" #define MSG_EXTRUDE "Extrude"
#define MSG_RETRACT "Retract" #define MSG_RETRACT "Retract"
#define MSG_MOVE_AXIS "Move axis" #define MSG_MOVE_AXIS "Move axis"
#define MSG_LEVEL_BED "Level bed"
#define MSG_MOVE_X "Move X" #define MSG_MOVE_X "Move X"
#define MSG_MOVE_Y "Move Y" #define MSG_MOVE_Y "Move Y"
#define MSG_MOVE_Z "Move Z" #define MSG_MOVE_Z "Move Z"
......
...@@ -2345,87 +2345,27 @@ ...@@ -2345,87 +2345,27 @@
//32Mb //32Mb
#define SPI_FLASH_CS 23 //PA14 #define SPI_FLASH_CS 23 //PA14
#ifdef ULTRA_LCD /** Display **/
#ifdef NEWPANEL
#ifdef PANEL_ONE
#define LCD_PINS_RS 40
#define LCD_PINS_ENABLE 42
#define LCD_PINS_D4 65
#define LCD_PINS_D5 66
#define LCD_PINS_D6 44
#define LCD_PINS_D7 64
#else
#define LCD_PINS_RS 16
#define LCD_PINS_ENABLE 17
#define LCD_PINS_D4 23
#define LCD_PINS_D5 25
#define LCD_PINS_D6 27
#define LCD_PINS_D7 29
#endif //PANEL_ONE
#ifdef REPRAP_DISCOUNT_SMART_CONTROLLER // GLCD on expansion port
#define BEEPER 37 #ifdef REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
#define BTN_EN1 31 #define LCD_PINS_RS 18
#define BTN_EN2 33 #define LCD_PINS_ENABLE 15
#define BTN_ENC 35 #define LCD_PINS_D4 19
#define BEEPER 64
#define SDCARDDETECT 49 #define BTN_EN1 14
#elif defined(LCD_I2C_PANELOLU2) #define BTN_EN2 16
#define BTN_EN1 47 //reverse if the encoder turns the wrong way. #define BTN_ENC 17
#define BTN_EN2 43
#define BTN_ENC 32
#define LCD_SDSS 53
#define SDCARDDETECT -1
#define KILL_PIN 41
#elif defined(LCD_I2C_VIKI)
#define BTN_EN1 22 //reverse if the encoder turns the wrong way.
#define BTN_EN2 7
#define BTN_ENC -1
#define LCD_SDSS 53
#define SDCARDDETECT 49
#else
//arduino pin which triggers an piezzo beeper
#define BEEPER 33 // Beeper on AUX-4
//buttons are directly attached using AUX-2 #if UI_VOLTAGE_LEVEL != 1
#ifdef REPRAPWORLD_KEYPAD #undef UI_VOLTAGE_LEVEL
#define BTN_EN1 64 // encoder #define UI_VOLTAGE_LEVEL 1
#define BTN_EN2 59 // encoder
#define BTN_ENC 63 // enter button
#define SHIFT_OUT 40 // shift register
#define SHIFT_CLK 44 // shift register
#define SHIFT_LD 42 // shift register
#elif defined(PANEL_ONE)
#define BTN_EN1 59 // AUX2 PIN 3
#define BTN_EN2 63 // AUX2 PIN 4
#define BTN_ENC 49 // AUX3 PIN 7
#else
#define BTN_EN1 37
#define BTN_EN2 35
#define BTN_ENC 31 //the click
#endif
#endif #endif
#else //old style panel with shift register #endif //REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
//arduino pin witch triggers an piezzo beeper
#define BEEPER 33 //No Beeper added
//buttons are attached to a shift register
// Not wired this yet
//#define SHIFT_CLK 38
//#define SHIFT_LD 42
//#define SHIFT_OUT 40
//#define SHIFT_EN 17
#define LCD_PINS_RS 16
#define LCD_PINS_ENABLE 17
#define LCD_PINS_D4 23
#define LCD_PINS_D5 25
#define LCD_PINS_D6 27
#define LCD_PINS_D7 29
#endif //NEWPANEL
#endif //ULTRA_LCD
#endif //ALLIGATOR #endif //ALLIGATOR
/****************************************************************************************/ /****************************************************************************************/
......
...@@ -136,16 +136,34 @@ static void lcd_status_screen(); ...@@ -136,16 +136,34 @@ static void lcd_status_screen();
/** /**
* START_MENU generates the init code for a menu function * START_MENU generates the init code for a menu function
*/ */
#define START_MENU() do { \ #if defined(BTN_BACK) && BTN_BACK > 0
#define START_MENU(last_menu) do { \
encoderRateMultiplierEnabled = false; \ encoderRateMultiplierEnabled = false; \
if (encoderPosition > 0x8000) encoderPosition = 0; \ if (encoderPosition > 0x8000) encoderPosition = 0; \
uint8_t encoderLine = encoderPosition / ENCODER_STEPS_PER_MENU_ITEM; \ uint8_t encoderLine = encoderPosition / ENCODER_STEPS_PER_MENU_ITEM; \
if (encoderLine < currentMenuViewOffset) currentMenuViewOffset = encoderLine; \ if (encoderLine < currentMenuViewOffset) currentMenuViewOffset = encoderLine; \
uint8_t _lineNr = currentMenuViewOffset, _menuItemNr; \ uint8_t _lineNr = currentMenuViewOffset, _menuItemNr; \
bool wasClicked = LCD_CLICKED, itemSelected; \ bool wasClicked = LCD_CLICKED, itemSelected; \
bool wasBackClicked = LCD_BACK_CLICKED; \
if (wasBackClicked) { \
lcd_quick_feedback(); \
menu_action_back( last_menu ); \
return; } \
for (uint8_t _drawLineNr = 0; _drawLineNr < LCD_HEIGHT; _drawLineNr++, _lineNr++) { \ for (uint8_t _drawLineNr = 0; _drawLineNr < LCD_HEIGHT; _drawLineNr++, _lineNr++) { \
_menuItemNr = 0; _menuItemNr = 0;
#else
#define START_MENU(last_menu) do { \
encoderRateMultiplierEnabled = false; \
if (encoderPosition > 0x8000) encoderPosition = 0; \
uint8_t encoderLine = encoderPosition / ENCODER_STEPS_PER_MENU_ITEM; \
if (encoderLine < currentMenuViewOffset) currentMenuViewOffset = encoderLine; \
uint8_t _lineNr = currentMenuViewOffset, _menuItemNr; \
bool wasClicked = LCD_CLICKED, itemSelected; \
for (uint8_t _drawLineNr = 0; _drawLineNr < LCD_HEIGHT; _drawLineNr++, _lineNr++) { \
_menuItemNr = 0;
#endif
/** /**
* MENU_ITEM generates draw & handler code for a menu item, potentially calling: * MENU_ITEM generates draw & handler code for a menu item, potentially calling:
* *
...@@ -182,6 +200,9 @@ static void lcd_status_screen(); ...@@ -182,6 +200,9 @@ static void lcd_status_screen();
} while(0) } while(0)
#ifdef ENCODER_RATE_MULTIPLIER #ifdef ENCODER_RATE_MULTIPLIER
//#define ENCODER_RATE_MULTIPLIER_DEBUG // If defined, output the encoder steps per second value
/** /**
* MENU_MULTIPLIER_ITEM generates drawing and handling code for a multiplier menu item * MENU_MULTIPLIER_ITEM generates drawing and handling code for a multiplier menu item
*/ */
...@@ -255,6 +276,9 @@ menuFunc_t callbackFunc; ...@@ -255,6 +276,9 @@ menuFunc_t callbackFunc;
// place-holders for Ki and Kd edits // place-holders for Ki and Kd edits
float raw_Ki, raw_Kd; float raw_Ki, raw_Kd;
/**
* General function to go directly to a menu
*/
static void lcd_goto_menu(menuFunc_t menu, const bool feedback=false, const uint32_t encoder=0) { static void lcd_goto_menu(menuFunc_t menu, const bool feedback=false, const uint32_t encoder=0) {
if (currentMenu != menu) { if (currentMenu != menu) {
currentMenu = menu; currentMenu = menu;
...@@ -269,7 +293,13 @@ static void lcd_goto_menu(menuFunc_t menu, const bool feedback=false, const uint ...@@ -269,7 +293,13 @@ static void lcd_goto_menu(menuFunc_t menu, const bool feedback=false, const uint
} }
} }
/* Main status screen. It's up to the implementation specific part to show what is needed. As this is very display dependent */ /**
*
* "Info Screen"
*
* This is very display-dependent, so the lcd implementation draws this.
*/
static void lcd_status_screen() { static void lcd_status_screen() {
encoderRateMultiplierEnabled = false; encoderRateMultiplierEnabled = false;
...@@ -395,9 +425,14 @@ static void lcd_sdcard_stop() { ...@@ -395,9 +425,14 @@ static void lcd_sdcard_stop() {
lcd_setstatus(MSG_PRINT_ABORTED, true); lcd_setstatus(MSG_PRINT_ABORTED, true);
} }
/* Menu implementation */ /**
*
* "Main" menu
*
*/
static void lcd_main_menu() { static void lcd_main_menu() {
START_MENU(); START_MENU(lcd_status_screen);
MENU_ITEM(back, MSG_WATCH, lcd_status_screen); MENU_ITEM(back, MSG_WATCH, lcd_status_screen);
if (movesplanned() || IS_SD_PRINTING) { if (movesplanned() || IS_SD_PRINTING) {
MENU_ITEM(submenu, MSG_TUNE, lcd_tune_menu); MENU_ITEM(submenu, MSG_TUNE, lcd_tune_menu);
...@@ -477,8 +512,14 @@ void lcd_set_home_offsets() { ...@@ -477,8 +512,14 @@ void lcd_set_home_offsets() {
#endif //BABYSTEPPING #endif //BABYSTEPPING
/**
*
* "Tune" submenu
*
*/
static void lcd_tune_menu() { static void lcd_tune_menu() {
START_MENU(); START_MENU(lcd_main_menu);
MENU_ITEM(back, MSG_MAIN, lcd_main_menu); MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
MENU_ITEM_EDIT(int3, MSG_SPEED, &feedrate_multiplier, 10, 999); MENU_ITEM_EDIT(int3, MSG_SPEED, &feedrate_multiplier, 10, 999);
#if TEMP_SENSOR_0 != 0 #if TEMP_SENSOR_0 != 0
...@@ -600,7 +641,7 @@ void lcd_preheat_gum0() { _lcd_preheat(0, gumPreheatHotendTemp, gumPreheatHPBTem ...@@ -600,7 +641,7 @@ void lcd_preheat_gum0() { _lcd_preheat(0, gumPreheatHotendTemp, gumPreheatHPBTem
void lcd_preheat_gum_bedonly() { _lcd_preheat(0, 0, gumPreheatHPBTemp, gumPreheatFanSpeed); } void lcd_preheat_gum_bedonly() { _lcd_preheat(0, 0, gumPreheatHPBTemp, gumPreheatFanSpeed); }
static void lcd_preheat_pla_menu() { static void lcd_preheat_pla_menu() {
START_MENU(); START_MENU(lcd_prepare_menu);
MENU_ITEM(back, MSG_PREPARE, lcd_prepare_menu); MENU_ITEM(back, MSG_PREPARE, lcd_prepare_menu);
MENU_ITEM(function, MSG_PREHEAT_PLA " 1", lcd_preheat_pla0); MENU_ITEM(function, MSG_PREHEAT_PLA " 1", lcd_preheat_pla0);
#if TEMP_SENSOR_1 != 0 //2 extruder preheat #if TEMP_SENSOR_1 != 0 //2 extruder preheat
...@@ -620,7 +661,7 @@ void lcd_preheat_gum0() { _lcd_preheat(0, gumPreheatHotendTemp, gumPreheatHPBTem ...@@ -620,7 +661,7 @@ void lcd_preheat_gum0() { _lcd_preheat(0, gumPreheatHotendTemp, gumPreheatHPBTem
} }
static void lcd_preheat_abs_menu() { static void lcd_preheat_abs_menu() {
START_MENU(); START_MENU(lcd_prepare_menu);
MENU_ITEM(back, MSG_PREPARE, lcd_prepare_menu); MENU_ITEM(back, MSG_PREPARE, lcd_prepare_menu);
MENU_ITEM(function, MSG_PREHEAT_ABS " 1", lcd_preheat_abs0); MENU_ITEM(function, MSG_PREHEAT_ABS " 1", lcd_preheat_abs0);
#if TEMP_SENSOR_1 != 0 //2 extruder preheat #if TEMP_SENSOR_1 != 0 //2 extruder preheat
...@@ -671,8 +712,7 @@ void lcd_cooldown() { ...@@ -671,8 +712,7 @@ void lcd_cooldown() {
lcd_return_to_status(); lcd_return_to_status();
} }
void config_lcd_level_bed() void config_lcd_level_bed() {
{
setTargetHotend(0,0); setTargetHotend(0,0);
ECHO_EM("Leveling..."); ECHO_EM("Leveling...");
...@@ -681,8 +721,7 @@ void config_lcd_level_bed() ...@@ -681,8 +721,7 @@ void config_lcd_level_bed()
pageShowInfo = 0; pageShowInfo = 0;
} }
void lcd_level_bed() void lcd_level_bed() {
{
if(ChangeScreen) { if(ChangeScreen) {
lcd_implementation_clear; lcd_implementation_clear;
switch(pageShowInfo) { switch(pageShowInfo) {
...@@ -751,28 +790,70 @@ void lcd_level_bed() ...@@ -751,28 +790,70 @@ void lcd_level_bed()
} }
} }
/**
*
* "Prepare" submenu
*
*/
static void lcd_prepare_menu() { static void lcd_prepare_menu() {
START_MENU(); START_MENU(lcd_main_menu);
//
// ^ Main
//
MENU_ITEM(back, MSG_MAIN, lcd_main_menu); MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
#if defined( SDSUPPORT ) && defined( MENU_ADDAUTOSTART )
MENU_ITEM(function, MSG_AUTOSTART, lcd_autostart_sd); //
#endif // Auto Home
MENU_ITEM(gcode, MSG_DISABLE_STEPPERS, PSTR("M84")); //
MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28")); MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28"));
#ifndef DELTA #ifndef DELTA
MENU_ITEM(function, MSG_BED_SETTING, config_lcd_level_bed); MENU_ITEM(function, MSG_BED_SETTING, config_lcd_level_bed);
#endif #endif
//
// Set Home Offsets
//
MENU_ITEM(function, MSG_SET_HOME_OFFSETS, lcd_set_home_offsets); MENU_ITEM(function, MSG_SET_HOME_OFFSETS, lcd_set_home_offsets);
//MENU_ITEM(gcode, MSG_SET_ORIGIN, PSTR("G92 X0 Y0 Z0")); //MENU_ITEM(gcode, MSG_SET_ORIGIN, PSTR("G92 X0 Y0 Z0"));
//Add Preset menu for LASER setting '14. 7. 22 //Add Preset menu for LASER setting '14. 7. 22
#ifdef LASERBEAM #ifdef LASERBEAM
MENU_ITEM_EDIT(int3, MSG_LASER, &laser_ttl_modulation, 0, 255); MENU_ITEM_EDIT(int3, MSG_LASER, &laser_ttl_modulation, 0, 255);
if(laser_ttl_modulation == 0) { if(laser_ttl_modulation == 0) {
WRITE(LASER_PWR_PIN, LOW); WRITE(LASER_PWR_PIN, LOW);
} else { }
else {
WRITE(LASER_PWR_PIN, HIGH); WRITE(LASER_PWR_PIN, HIGH);
} }
#endif #endif
//
// Level Bed
//
#ifdef ENABLE_AUTO_BED_LEVELING
if (axis_known_position[X_AXIS] && axis_known_position[Y_AXIS])
MENU_ITEM(gcode, MSG_LEVEL_BED, PSTR("G29"));
#elif !defined(DELTA)
MENU_ITEM(function, MSG_BED_SETTING, config_lcd_level_bed);
#endif
//
// Move Axis
//
MENU_ITEM(submenu, MSG_MOVE_AXIS, lcd_move_menu);
//
// Disable Steppers
//
MENU_ITEM(gcode, MSG_DISABLE_STEPPERS, PSTR("M84"));
//
// Preheat PLA
// Preheat ABS
// Preheat GUM
//
#if TEMP_SENSOR_0 != 0 #if TEMP_SENSOR_0 != 0
#if TEMP_SENSOR_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_3 != 0 || TEMP_SENSOR_BED != 0 #if TEMP_SENSOR_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_3 != 0 || TEMP_SENSOR_BED != 0
MENU_ITEM(submenu, MSG_PREHEAT_PLA, lcd_preheat_pla_menu); MENU_ITEM(submenu, MSG_PREHEAT_PLA, lcd_preheat_pla_menu);
...@@ -784,13 +865,25 @@ static void lcd_prepare_menu() { ...@@ -784,13 +865,25 @@ static void lcd_prepare_menu() {
MENU_ITEM(function, MSG_PREHEAT_GUM, lcd_preheat_gum0); MENU_ITEM(function, MSG_PREHEAT_GUM, lcd_preheat_gum0);
#endif #endif
#endif #endif
//
// Cooldown
//
MENU_ITEM(function, MSG_COOLDOWN, lcd_cooldown); MENU_ITEM(function, MSG_COOLDOWN, lcd_cooldown);
//
// Easy Load
//
#if defined(EASY_LOAD) #if defined(EASY_LOAD)
MENU_ITEM(function, MSG_E_BOWDEN_LENGTH, lcd_easy_load); MENU_ITEM(function, MSG_E_BOWDEN_LENGTH, lcd_easy_load);
MENU_ITEM(function, MSG_R_BOWDEN_LENGTH, lcd_easy_unload); MENU_ITEM(function, MSG_R_BOWDEN_LENGTH, lcd_easy_unload);
MENU_ITEM(function, MSG_PURGE_XMM, lcd_purge); MENU_ITEM(function, MSG_PURGE_XMM, lcd_purge);
MENU_ITEM(function, MSG_RETRACT_XMM, lcd_retract); MENU_ITEM(function, MSG_RETRACT_XMM, lcd_retract);
#endif // EASY_LOAD #endif // EASY_LOAD
//
// Switch power on/off
//
#if HAS_POWER_SWITCH #if HAS_POWER_SWITCH
if (powersupply) if (powersupply)
MENU_ITEM(gcode, MSG_SWITCH_PS_OFF, PSTR("M81")); MENU_ITEM(gcode, MSG_SWITCH_PS_OFF, PSTR("M81"));
...@@ -798,14 +891,20 @@ static void lcd_prepare_menu() { ...@@ -798,14 +891,20 @@ static void lcd_prepare_menu() {
MENU_ITEM(gcode, MSG_SWITCH_PS_ON, PSTR("M80")); MENU_ITEM(gcode, MSG_SWITCH_PS_ON, PSTR("M80"));
#endif #endif
MENU_ITEM(submenu, MSG_MOVE_AXIS, lcd_move_menu); //
// Autostart
//
#if defined(SDSUPPORT) && defined(MENU_ADDAUTOSTART)
MENU_ITEM(function, MSG_AUTOSTART, lcd_autostart_sd);
#endif
END_MENU(); END_MENU();
} }
#ifdef DELTA #ifdef DELTA
static void lcd_delta_calibrate_menu()
{ static void lcd_delta_calibrate_menu() {
START_MENU(); START_MENU(lcd_main_menu);
MENU_ITEM(back, MSG_MAIN, lcd_main_menu); MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28")); MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28"));
MENU_ITEM(gcode, MSG_DELTA_CALIBRATE_X, PSTR("G0 F8000 X-77.94 Y-45 Z0")); MENU_ITEM(gcode, MSG_DELTA_CALIBRATE_X, PSTR("G0 F8000 X-77.94 Y-45 Z0"));
...@@ -814,6 +913,7 @@ static void lcd_prepare_menu() { ...@@ -814,6 +913,7 @@ static void lcd_prepare_menu() {
MENU_ITEM(gcode, MSG_DELTA_CALIBRATE_CENTER, PSTR("G0 F8000 X0 Y0 Z0")); MENU_ITEM(gcode, MSG_DELTA_CALIBRATE_CENTER, PSTR("G0 F8000 X0 Y0 Z0"));
END_MENU(); END_MENU();
} }
#endif // DELTA #endif // DELTA
inline void line_to_current(AxisEnum axis) { inline void line_to_current(AxisEnum axis) {
...@@ -825,6 +925,12 @@ inline void line_to_current(AxisEnum axis) { ...@@ -825,6 +925,12 @@ inline void line_to_current(AxisEnum axis) {
#endif #endif
} }
/**
*
* "Prepare" > "Move Axis" submenu
*
*/
float move_menu_scale; float move_menu_scale;
static void lcd_move_menu_axis(); static void lcd_move_menu_axis();
...@@ -855,8 +961,14 @@ static void lcd_move_e() { ...@@ -855,8 +961,14 @@ static void lcd_move_e() {
if (LCD_CLICKED) lcd_goto_menu(lcd_move_menu_axis); if (LCD_CLICKED) lcd_goto_menu(lcd_move_menu_axis);
} }
/**
*
* "Prepare" > "Move Xmm" > "Move XYZ" submenu
*
*/
static void lcd_move_menu_axis() { static void lcd_move_menu_axis() {
START_MENU(); START_MENU(lcd_move_menu);
MENU_ITEM(back, MSG_MOVE_AXIS, lcd_move_menu); MENU_ITEM(back, MSG_MOVE_AXIS, lcd_move_menu);
MENU_ITEM(submenu, MSG_MOVE_X, lcd_move_x); MENU_ITEM(submenu, MSG_MOVE_X, lcd_move_x);
MENU_ITEM(submenu, MSG_MOVE_Y, lcd_move_y); MENU_ITEM(submenu, MSG_MOVE_Y, lcd_move_y);
...@@ -880,8 +992,14 @@ static void lcd_move_menu_01mm() { ...@@ -880,8 +992,14 @@ static void lcd_move_menu_01mm() {
lcd_move_menu_axis(); lcd_move_menu_axis();
} }
/**
*
* "Prepare" > "Move Axis" submenu
*
*/
static void lcd_move_menu() { static void lcd_move_menu() {
START_MENU(); START_MENU(lcd_prepare_menu);
MENU_ITEM(back, MSG_PREPARE, lcd_prepare_menu); MENU_ITEM(back, MSG_PREPARE, lcd_prepare_menu);
MENU_ITEM(submenu, MSG_MOVE_10MM, lcd_move_menu_10mm); MENU_ITEM(submenu, MSG_MOVE_10MM, lcd_move_menu_10mm);
MENU_ITEM(submenu, MSG_MOVE_1MM, lcd_move_menu_1mm); MENU_ITEM(submenu, MSG_MOVE_1MM, lcd_move_menu_1mm);
...@@ -890,8 +1008,14 @@ static void lcd_move_menu() { ...@@ -890,8 +1008,14 @@ static void lcd_move_menu() {
END_MENU(); END_MENU();
} }
/**
*
* "Control" submenu
*
*/
static void lcd_control_menu() { static void lcd_control_menu() {
START_MENU(); START_MENU(lcd_main_menu);
MENU_ITEM(back, MSG_MAIN, lcd_main_menu); MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
MENU_ITEM(submenu, MSG_TEMPERATURE, lcd_control_temperature_menu); MENU_ITEM(submenu, MSG_TEMPERATURE, lcd_control_temperature_menu);
MENU_ITEM(submenu, MSG_MOTION, lcd_control_motion_menu); MENU_ITEM(submenu, MSG_MOTION, lcd_control_motion_menu);
...@@ -912,6 +1036,12 @@ static void lcd_control_menu() { ...@@ -912,6 +1036,12 @@ static void lcd_control_menu() {
END_MENU(); END_MENU();
} }
/**
*
* "Temperature" submenu
*
*/
#ifdef PIDTEMP #ifdef PIDTEMP
// Helpers for editing PID Ki & Kd values // Helpers for editing PID Ki & Kd values
...@@ -941,8 +1071,14 @@ static void lcd_control_menu() { ...@@ -941,8 +1071,14 @@ static void lcd_control_menu() {
#endif //PIDTEMP #endif //PIDTEMP
/**
*
* "Control" > "Temperature" submenu
*
*/
static void lcd_control_temperature_menu() { static void lcd_control_temperature_menu() {
START_MENU(); START_MENU(lcd_control_menu);
MENU_ITEM(back, MSG_CONTROL, lcd_control_menu); MENU_ITEM(back, MSG_CONTROL, lcd_control_menu);
#if TEMP_SENSOR_0 != 0 #if TEMP_SENSOR_0 != 0
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE, &target_temperature[0], 0, HEATER_0_MAXTEMP + LCD_MAX_TEMP_OFFSET); MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE, &target_temperature[0], 0, HEATER_0_MAXTEMP + LCD_MAX_TEMP_OFFSET);
...@@ -1017,15 +1153,21 @@ static void lcd_control_temperature_menu() { ...@@ -1017,15 +1153,21 @@ static void lcd_control_temperature_menu() {
END_MENU(); END_MENU();
} }
/**
*
* "Temperature" > "Preheat PLA conf" submenu
*
*/
static void lcd_control_temperature_preheat_pla_settings_menu() { static void lcd_control_temperature_preheat_pla_settings_menu() {
START_MENU(); START_MENU(lcd_control_temperature_menu);
MENU_ITEM(back, MSG_TEMPERATURE, lcd_control_temperature_menu); MENU_ITEM(back, MSG_TEMPERATURE, lcd_control_temperature_menu);
MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &plaPreheatFanSpeed, 0, 255); MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &plaPreheatFanSpeed, 0, 255);
#if TEMP_SENSOR_0 != 0 #if TEMP_SENSOR_0 != 0
MENU_ITEM_EDIT(int3, MSG_NOZZLE, &plaPreheatHotendTemp, 0, HEATER_0_MAXTEMP + LCD_MAX_TEMP_OFFSET); MENU_ITEM_EDIT(int3, MSG_NOZZLE, &plaPreheatHotendTemp, HEATER_0_MINTEMP, HEATER_0_MAXTEMP + LCD_MAX_TEMP_OFFSET);
#endif #endif
#if TEMP_SENSOR_BED != 0 #if TEMP_SENSOR_BED != 0
MENU_ITEM_EDIT(int3, MSG_BED, &plaPreheatHPBTemp, 0, BED_MAXTEMP + LCD_MAX_TEMP_OFFSET); MENU_ITEM_EDIT(int3, MSG_BED, &plaPreheatHPBTemp, BED_MINTEMP, BED_MAXTEMP + LCD_MAX_TEMP_OFFSET);
#endif #endif
#ifdef EEPROM_SETTINGS #ifdef EEPROM_SETTINGS
MENU_ITEM(function, MSG_STORE_EPROM, Config_StoreSettings); MENU_ITEM(function, MSG_STORE_EPROM, Config_StoreSettings);
...@@ -1033,15 +1175,21 @@ static void lcd_control_temperature_preheat_pla_settings_menu() { ...@@ -1033,15 +1175,21 @@ static void lcd_control_temperature_preheat_pla_settings_menu() {
END_MENU(); END_MENU();
} }
/**
*
* "Temperature" > "Preheat ABS conf" submenu
*
*/
static void lcd_control_temperature_preheat_abs_settings_menu() { static void lcd_control_temperature_preheat_abs_settings_menu() {
START_MENU(); START_MENU(lcd_control_temperature_menu);
MENU_ITEM(back, MSG_TEMPERATURE, lcd_control_temperature_menu); MENU_ITEM(back, MSG_TEMPERATURE, lcd_control_temperature_menu);
MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &absPreheatFanSpeed, 0, 255); MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &absPreheatFanSpeed, 0, 255);
#if TEMP_SENSOR_0 != 0 #if TEMP_SENSOR_0 != 0
MENU_ITEM_EDIT(int3, MSG_NOZZLE, &absPreheatHotendTemp, 0, HEATER_0_MAXTEMP + LCD_MAX_TEMP_OFFSET); MENU_ITEM_EDIT(int3, MSG_NOZZLE, &absPreheatHotendTemp, HEATER_0_MINTEMP, HEATER_0_MAXTEMP + LCD_MAX_TEMP_OFFSET);
#endif #endif
#if TEMP_SENSOR_BED != 0 #if TEMP_SENSOR_BED != 0
MENU_ITEM_EDIT(int3, MSG_BED, &absPreheatHPBTemp, 0, BED_MAXTEMP + LCD_MAX_TEMP_OFFSET); MENU_ITEM_EDIT(int3, MSG_BED, &absPreheatHPBTemp, BED_MINTEMP, BED_MAXTEMP + LCD_MAX_TEMP_OFFSET);
#endif #endif
#ifdef EEPROM_SETTINGS #ifdef EEPROM_SETTINGS
MENU_ITEM(function, MSG_STORE_EPROM, Config_StoreSettings); MENU_ITEM(function, MSG_STORE_EPROM, Config_StoreSettings);
...@@ -1049,15 +1197,20 @@ static void lcd_control_temperature_preheat_abs_settings_menu() { ...@@ -1049,15 +1197,20 @@ static void lcd_control_temperature_preheat_abs_settings_menu() {
END_MENU(); END_MENU();
} }
/**
*
* "Temperature" > "Preheat GUM conf" submenu
*
*/
static void lcd_control_temperature_preheat_gum_settings_menu() { static void lcd_control_temperature_preheat_gum_settings_menu() {
START_MENU(); START_MENU(lcd_control_temperature_menu);
MENU_ITEM(back, MSG_TEMPERATURE, lcd_control_temperature_menu); MENU_ITEM(back, MSG_TEMPERATURE, lcd_control_temperature_menu);
MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &gumPreheatFanSpeed, 0, 255); MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &gumPreheatFanSpeed, 0, 255);
#if TEMP_SENSOR_0 != 0 #if TEMP_SENSOR_0 != 0
MENU_ITEM_EDIT(int3, MSG_NOZZLE, &gumPreheatHotendTemp, 0, HEATER_0_MAXTEMP + LCD_MAX_TEMP_OFFSET); MENU_ITEM_EDIT(int3, MSG_NOZZLE, &gumPreheatHotendTemp, HEATER_0_MINTEMP, HEATER_0_MAXTEMP + LCD_MAX_TEMP_OFFSET);
#endif #endif
#if TEMP_SENSOR_BED != 0 #if TEMP_SENSOR_BED != 0
MENU_ITEM_EDIT(int3, MSG_BED, &gumPreheatHPBTemp, 0, BED_MAXTEMP + LCD_MAX_TEMP_OFFSET); MENU_ITEM_EDIT(int3, MSG_BED, &gumPreheatHPBTemp, BED_MINTEMP, BED_MAXTEMP + LCD_MAX_TEMP_OFFSET);
#endif #endif
#ifdef EEPROM_SETTINGS #ifdef EEPROM_SETTINGS
MENU_ITEM(function, MSG_STORE_EPROM, Config_StoreSettings); MENU_ITEM(function, MSG_STORE_EPROM, Config_StoreSettings);
...@@ -1065,8 +1218,14 @@ static void lcd_control_temperature_preheat_gum_settings_menu() { ...@@ -1065,8 +1218,14 @@ static void lcd_control_temperature_preheat_gum_settings_menu() {
END_MENU(); END_MENU();
} }
/**
*
* "Control" > "Motion" submenu
*
*/
static void lcd_control_motion_menu() { static void lcd_control_motion_menu() {
START_MENU(); START_MENU(lcd_control_menu);
MENU_ITEM(back, MSG_CONTROL, lcd_control_menu); MENU_ITEM(back, MSG_CONTROL, lcd_control_menu);
#ifdef ENABLE_AUTO_BED_LEVELING #ifdef ENABLE_AUTO_BED_LEVELING
MENU_ITEM_EDIT(float32, MSG_ZPROBE_ZOFFSET, &zprobe_zoffset, -50, 50); MENU_ITEM_EDIT(float32, MSG_ZPROBE_ZOFFSET, &zprobe_zoffset, -50, 50);
...@@ -1110,8 +1269,14 @@ static void lcd_control_motion_menu() { ...@@ -1110,8 +1269,14 @@ static void lcd_control_motion_menu() {
END_MENU(); END_MENU();
} }
/**
*
* "Control" > "Filament" submenu
*
*/
static void lcd_control_volumetric_menu() { static void lcd_control_volumetric_menu() {
START_MENU(); START_MENU(lcd_control_menu);
MENU_ITEM(back, MSG_CONTROL, lcd_control_menu); MENU_ITEM(back, MSG_CONTROL, lcd_control_menu);
MENU_ITEM_EDIT_CALLBACK(bool, MSG_VOLUMETRIC_ENABLED, &volumetric_enabled, calculate_volumetric_multipliers); MENU_ITEM_EDIT_CALLBACK(bool, MSG_VOLUMETRIC_ENABLED, &volumetric_enabled, calculate_volumetric_multipliers);
...@@ -1132,6 +1297,12 @@ static void lcd_control_volumetric_menu() { ...@@ -1132,6 +1297,12 @@ static void lcd_control_volumetric_menu() {
END_MENU(); END_MENU();
} }
/**
*
* "Control" > "Contrast" submenu
*
*/
#ifdef HAS_LCD_CONTRAST #ifdef HAS_LCD_CONTRAST
static void lcd_set_contrast() { static void lcd_set_contrast() {
if (encoderPosition != 0) { if (encoderPosition != 0) {
...@@ -1146,9 +1317,15 @@ static void lcd_control_volumetric_menu() { ...@@ -1146,9 +1317,15 @@ static void lcd_control_volumetric_menu() {
} }
#endif // HAS_LCD_CONTRAST #endif // HAS_LCD_CONTRAST
/**
*
* "Control" > "Retract" submenu
*
*/
#ifdef FWRETRACT #ifdef FWRETRACT
static void lcd_control_retract_menu() { static void lcd_control_retract_menu() {
START_MENU(); START_MENU(lcd_control_menu);
MENU_ITEM(back, MSG_CONTROL, lcd_control_menu); MENU_ITEM(back, MSG_CONTROL, lcd_control_menu);
MENU_ITEM_EDIT(bool, MSG_AUTORETRACT, &autoretract_enabled); MENU_ITEM_EDIT(bool, MSG_AUTORETRACT, &autoretract_enabled);
MENU_ITEM_EDIT(float52, MSG_CONTROL_RETRACT, &retract_length, 0, 100); MENU_ITEM_EDIT(float52, MSG_CONTROL_RETRACT, &retract_length, 0, 100);
...@@ -1178,10 +1355,16 @@ static void lcd_sd_updir() { ...@@ -1178,10 +1355,16 @@ static void lcd_sd_updir() {
currentMenuViewOffset = 0; currentMenuViewOffset = 0;
} }
/**
*
* "Print from SD" submenu
*
*/
void lcd_sdcard_menu() { void lcd_sdcard_menu() {
if (lcdDrawUpdate == 0 && LCD_CLICKED == 0) return; // nothing to do (so don't thrash the SD card) if (lcdDrawUpdate == 0 && LCD_CLICKED == 0) return; // nothing to do (so don't thrash the SD card)
uint16_t fileCnt = card.getnrfilenames(); uint16_t fileCnt = card.getnrfilenames();
START_MENU(); START_MENU(lcd_main_menu);
MENU_ITEM(back, MSG_MAIN, lcd_main_menu); MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
card.getWorkDirName(); card.getWorkDirName();
if (card.filename[0] == '/') { if (card.filename[0] == '/') {
...@@ -1213,6 +1396,11 @@ void lcd_sdcard_menu() { ...@@ -1213,6 +1396,11 @@ void lcd_sdcard_menu() {
END_MENU(); END_MENU();
} }
/**
*
* Functions for editing single values
*
*/
#define menu_edit_type(_type, _name, _strFunc, scale) \ #define menu_edit_type(_type, _name, _strFunc, scale) \
bool _menu_edit_ ## _name () { \ bool _menu_edit_ ## _name () { \
bool isClicked = LCD_CLICKED; \ bool isClicked = LCD_CLICKED; \
...@@ -1259,6 +1447,11 @@ menu_edit_type(float, float51, ftostr51, 10) ...@@ -1259,6 +1447,11 @@ menu_edit_type(float, float51, ftostr51, 10)
menu_edit_type(float, float52, ftostr52, 100) menu_edit_type(float, float52, ftostr52, 100)
menu_edit_type(unsigned long, long5, ftostr5, 0.01) menu_edit_type(unsigned long, long5, ftostr5, 0.01)
/**
*
* Handlers for RepRap World Keypad input
*
*/
#ifdef REPRAPWORLD_KEYPAD #ifdef REPRAPWORLD_KEYPAD
static void reprapworld_keypad_move_z_up() { static void reprapworld_keypad_move_z_up() {
encoderPosition = 1; encoderPosition = 1;
...@@ -1295,8 +1488,12 @@ menu_edit_type(unsigned long, long5, ftostr5, 0.01) ...@@ -1295,8 +1488,12 @@ menu_edit_type(unsigned long, long5, ftostr5, 0.01)
} }
#endif //REPRAPWORLD_KEYPAD #endif //REPRAPWORLD_KEYPAD
/** End of menus **/
/**
*
* Audio feedback for controller clicks
*
*/
void lcd_quick_feedback() { void lcd_quick_feedback() {
lcdDrawUpdate = 2; lcdDrawUpdate = 2;
next_button_update_ms = millis() + 500; next_button_update_ms = millis() + 500;
...@@ -1325,11 +1522,15 @@ void lcd_quick_feedback() { ...@@ -1325,11 +1522,15 @@ void lcd_quick_feedback() {
#endif #endif
} }
/** Menu action functions **/ /**
static void menu_action_back(menuFunc_t data) { lcd_goto_menu(data); } *
static void menu_action_submenu(menuFunc_t data) { lcd_goto_menu(data); } * Menu actions
*
*/
static void menu_action_back(menuFunc_t func) { lcd_goto_menu(func); }
static void menu_action_submenu(menuFunc_t func) { lcd_goto_menu(func); }
static void menu_action_gcode(const char* pgcode) { enqueuecommands_P(pgcode); } static void menu_action_gcode(const char* pgcode) { enqueuecommands_P(pgcode); }
static void menu_action_function(menuFunc_t data) { (*data)(); } static void menu_action_function(menuFunc_t func) { (*func)(); }
static void menu_action_sdfile(const char* filename, char* longFilename) { static void menu_action_sdfile(const char* filename, char* longFilename) {
char cmd[30]; char cmd[30];
char* c; char* c;
...@@ -1422,6 +1623,19 @@ int lcd_strlen_P(const char *s) { ...@@ -1422,6 +1623,19 @@ int lcd_strlen_P(const char *s) {
return j; return j;
} }
/**
* Update the LCD, read encoder buttons, etc.
* - Read button states
* - Check the SD Card slot state
* - Act on RepRap World keypad input
* - Update the encoder position
* - Apply acceleration to the encoder position
* - Reset the Info Screen timeout if there's any input
* - Update status indicators, if any
* - Clear the LCD if lcdDrawUpdate == 2
*
* Warning: This function is called from interrupt context!
*/
void lcd_update() { void lcd_update() {
#ifdef ULTIPANEL #ifdef ULTIPANEL
static millis_t return_to_status_ms = 0; static millis_t return_to_status_ms = 0;
...@@ -1546,7 +1760,7 @@ void lcd_update() { ...@@ -1546,7 +1760,7 @@ void lcd_update() {
if (lcdDrawUpdate == 2) lcd_implementation_clear(); if (lcdDrawUpdate == 2) lcd_implementation_clear();
if (lcdDrawUpdate) lcdDrawUpdate--; if (lcdDrawUpdate) lcdDrawUpdate--;
next_lcd_update_ms = millis() + LCD_UPDATE_INTERVAL; next_lcd_update_ms = ms + LCD_UPDATE_INTERVAL;
} }
} }
...@@ -1619,18 +1833,23 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; } ...@@ -1619,18 +1833,23 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
#ifdef ULTIPANEL #ifdef ULTIPANEL
// Setup Rotary Encoder Bit Values (for two pin encoders to indicate movement) /**
// These values are independent of which pins are used for EN_A and EN_B indications * Setup Rotary Encoder Bit Values (for two pin encoders to indicate movement)
// The rotary encoder part is also independent to the chipset used for the LCD * These values are independent of which pins are used for EN_A and EN_B indications
#if defined(EN_A) && defined(EN_B) * The rotary encoder part is also independent to the chipset used for the LCD
*/
#if defined(EN_A) && defined(EN_B)
#define encrot0 0 #define encrot0 0
#define encrot1 2 #define encrot1 2
#define encrot2 3 #define encrot2 3
#define encrot3 1 #define encrot3 1
#endif #endif
/* Warning: This function is called from interrupt context */ /**
void lcd_buttons_update() { * Read encoder buttons from the hardware registers
* Warning: This function is called from interrupt context!
*/
void lcd_buttons_update() {
#ifdef NEWPANEL #ifdef NEWPANEL
uint8_t newbutton = 0; uint8_t newbutton = 0;
#ifdef INVERT_ROTARY_SWITCH #ifdef INVERT_ROTARY_SWITCH
...@@ -1641,7 +1860,11 @@ void lcd_buttons_update() { ...@@ -1641,7 +1860,11 @@ void lcd_buttons_update() {
if (READ(BTN_EN2) == 0) newbutton |= EN_B; if (READ(BTN_EN2) == 0) newbutton |= EN_B;
#endif #endif
#if BTN_ENC > 0 #if BTN_ENC > 0
if (millis() > next_button_update_ms && READ(BTN_ENC) == 0) newbutton |= EN_C; millis_t ms = millis();
if (ms > next_button_update_ms && READ(BTN_ENC) == 0) newbutton |= EN_C;
#if defined(BTN_BACK) && BTN_BACK > 0
if (ms > next_button_update_ms && READ(BTN_BACK) == 0) newbutton |= EN_D;
#endif
#endif #endif
buttons = newbutton; buttons = newbutton;
#ifdef LCD_HAS_SLOW_BUTTONS #ifdef LCD_HAS_SLOW_BUTTONS
...@@ -1699,22 +1922,23 @@ void lcd_buttons_update() { ...@@ -1699,22 +1922,23 @@ void lcd_buttons_update() {
} }
} }
lastEncoderBits = enc; lastEncoderBits = enc;
} }
bool lcd_detected(void) { bool lcd_detected(void) {
#if (defined(LCD_I2C_TYPE_MCP23017) || defined(LCD_I2C_TYPE_MCP23008)) && defined(DETECT_DEVICE) #if (defined(LCD_I2C_TYPE_MCP23017) || defined(LCD_I2C_TYPE_MCP23008)) && defined(DETECT_DEVICE)
return lcd.LcdDetected() == 1; return lcd.LcdDetected() == 1;
#else #else
return true; return true;
#endif #endif
} }
void lcd_buzz(long duration, uint16_t freq) { void lcd_buzz(long duration, uint16_t freq) {
if (freq > 0) { if (freq > 0) {
#if BEEPER > 0 #if BEEPER > 0
SET_OUTPUT(BEEPER); SET_OUTPUT(BEEPER);
tone(BEEPER, freq, duration); tone(BEEPER, freq);
delay(duration); delay(duration);
noTone(BEEPER);
#elif defined(LCD_USE_I2C_BUZZER) #elif defined(LCD_USE_I2C_BUZZER)
lcd.buzz(duration, freq); lcd.buzz(duration, freq);
#else #else
...@@ -1724,11 +1948,11 @@ void lcd_buzz(long duration, uint16_t freq) { ...@@ -1724,11 +1948,11 @@ void lcd_buzz(long duration, uint16_t freq) {
else { else {
delay(duration); delay(duration);
} }
} }
bool lcd_clicked() { return LCD_CLICKED; } bool lcd_clicked() { return LCD_CLICKED; }
#endif //ULTIPANEL #endif // ULTIPANEL
/*********************************/ /*********************************/
/** Number to string conversion **/ /** Number to string conversion **/
...@@ -1790,8 +2014,7 @@ char *ftostr32(const float &x) { ...@@ -1790,8 +2014,7 @@ char *ftostr32(const float &x) {
} }
// Convert float to string with 1.234 format // Convert float to string with 1.234 format
char *ftostr43(const float &x) char *ftostr43(const float &x) {
{
long xx = x * 1000; long xx = x * 1000;
if (xx >= 0) if (xx >= 0)
conv[0] = (xx / 1000) % 10 + '0'; conv[0] = (xx / 1000) % 10 + '0';
...@@ -1807,8 +2030,7 @@ char *ftostr43(const float &x) ...@@ -1807,8 +2030,7 @@ char *ftostr43(const float &x)
} }
// Convert float to string with 1.23 format // Convert float to string with 1.23 format
char *ftostr12ns(const float &x) char *ftostr12ns(const float &x) {
{
long xx=x*100; long xx=x*100;
xx=abs(xx); xx=abs(xx);
......
...@@ -73,6 +73,10 @@ ...@@ -73,6 +73,10 @@
#define EN_A BIT(BLEN_A) #define EN_A BIT(BLEN_A)
#define LCD_CLICKED (buttons&EN_C) #define LCD_CLICKED (buttons&EN_C)
#if defined(BTN_BACK) && BTN_BACK > 0
#define EN_D BIT(BLEN_D)
#define LCD_BACK_CLICKED (buttons&EN_D)
#endif
#ifdef REPRAPWORLD_KEYPAD #ifdef REPRAPWORLD_KEYPAD
#define EN_REPRAPWORLD_KEYPAD_F3 (BIT(BLEN_REPRAPWORLD_KEYPAD_F3)) #define EN_REPRAPWORLD_KEYPAD_F3 (BIT(BLEN_REPRAPWORLD_KEYPAD_F3))
#define EN_REPRAPWORLD_KEYPAD_F2 (BIT(BLEN_REPRAPWORLD_KEYPAD_F2)) #define EN_REPRAPWORLD_KEYPAD_F2 (BIT(BLEN_REPRAPWORLD_KEYPAD_F2))
......
...@@ -399,6 +399,11 @@ static void lcd_implementation_init( ...@@ -399,6 +399,11 @@ static void lcd_implementation_init(
lcd.backlight(); lcd.backlight();
#else #else
#if (LCD_PINS_RS != -1) && (LCD_PINS_ENABLE != -1)
// required for RAMPS-FD, but does no harm for other targets
SET_OUTPUT(LCD_PINS_RS);
SET_OUTPUT(LCD_PINS_ENABLE);
#endif
lcd.begin(LCD_WIDTH, LCD_HEIGHT); lcd.begin(LCD_WIDTH, LCD_HEIGHT);
#endif #endif
......
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