Commit 9bb65516 authored by MagoKimbra's avatar MagoKimbra

Fix

parent 4ca763b5
...@@ -103,7 +103,7 @@ ...@@ -103,7 +103,7 @@
* M300 - Play beep sound S[frequency Hz] P[duration ms] * M300 - Play beep sound S[frequency Hz] P[duration ms]
* M301 - Set PID parameters P I and D * M301 - Set PID parameters P I and D
* M302 - Allow cold extrudes * M302 - Allow cold extrudes
* M303 - PID relay autotune S<temperature> sets the target temperature (default target temperature = 150C). H<hotend> C<cycles> * M303 - PID relay autotune S<temperature> sets the target temperature (default target temperature = 150C). H<hotend> C<cycles> U<Apply result>
* M304 - Set bed PID parameters P I and D * M304 - Set bed PID parameters P I and D
* M350 - Set microstepping mode. * M350 - Set microstepping mode.
* M351 - Toggle MS1 MS2 pins directly. * M351 - Toggle MS1 MS2 pins directly.
......
...@@ -169,9 +169,10 @@ ...@@ -169,9 +169,10 @@
// Comment the following line to disable PID and enable bang-bang. // Comment the following line to disable PID and enable bang-bang.
#define PIDTEMP #define PIDTEMP
//#define PID_DEBUG // Sends debug data to the serial port. //#define PID_AUTOTUNE_MENU // Add PID Autotune to the LCD "Temperature" menu to run M303 and apply the result.
//#define PID_OPENLOOP 1 // Puts PID in open loop. M104/M140 sets the output power from 0 to PID_MAX //#define PID_DEBUG // Sends debug data to the serial port.
//#define SLOW_PWM_HEATERS // PWM with very low frequency (roughly 0.125Hz=8s) and minimum state time of approximately 1s useful for heaters driven by a relay //#define PID_OPENLOOP 1 // Puts PID in open loop. M104/M140 sets the output power from 0 to PID_MAX
//#define SLOW_PWM_HEATERS // PWM with very low frequency (roughly 0.125Hz=8s) and minimum state time of approximately 1s useful for heaters driven by a relay
// If the temperature difference between the target temperature and the actual temperature // If the temperature difference between the target temperature and the actual temperature
// is more then PID_FUNCTIONAL_RANGE then the PID will be shut off and the heater will be set to min/max. // is more then PID_FUNCTIONAL_RANGE then the PID will be shut off and the heater will be set to min/max.
#define PID_FUNCTIONAL_RANGE 10 // degC #define PID_FUNCTIONAL_RANGE 10 // degC
...@@ -1092,7 +1093,7 @@ ...@@ -1092,7 +1093,7 @@
//#define INVERT_CLICK_BUTTON // Option for invert encoder button logic //#define INVERT_CLICK_BUTTON // Option for invert encoder button logic
//#define INVERT_BACK_BUTTON // Option for invert back button logic if avaible //#define INVERT_BACK_BUTTON // Option for invert back button logic if avaible
//#define INVERT_ROTARY_SWITCH // Option for invert rotary encoder //#define INVERT_ROTARY_SWITCH // Option for reverses the encoder direction for navigating LCD menus.
#define ENCODER_RATE_MULTIPLIER // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly #define ENCODER_RATE_MULTIPLIER // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly
#define ENCODER_10X_STEPS_PER_SEC 75 // If the encoder steps per sec exceeds this value, multiply steps moved x10 to quickly advance the value #define ENCODER_10X_STEPS_PER_SEC 75 // If the encoder steps per sec exceeds this value, multiply steps moved x10 to quickly advance the value
#define ENCODER_100X_STEPS_PER_SEC 160 // If the encoder steps per sec exceeds this value, multiply steps moved x100 to really quickly advance the value #define ENCODER_100X_STEPS_PER_SEC 160 // If the encoder steps per sec exceeds this value, multiply steps moved x100 to really quickly advance the value
......
...@@ -146,7 +146,7 @@ ...@@ -146,7 +146,7 @@
* M300 - Play beep sound S<frequency Hz> P<duration ms> * M300 - Play beep sound S<frequency Hz> P<duration ms>
* M301 - Set PID parameters P I D and C * M301 - Set PID parameters P I D and C
* M302 - Allow cold extrudes, or set the minimum extrude S<temperature>. * M302 - Allow cold extrudes, or set the minimum extrude S<temperature>.
* M303 - PID relay autotune S<temperature> sets the target temperature (default target temperature = 150C). H<hotend> C<cycles> * M303 - PID relay autotune S<temperature> sets the target temperature (default target temperature = 150C). H<hotend> C<cycles> U<Apply result>
* M304 - Set bed PID parameters P I and D * M304 - Set bed PID parameters P I and D
* M350 - Set microstepping mode. * M350 - Set microstepping mode.
* M351 - Toggle MS1 MS2 pins directly. * M351 - Toggle MS1 MS2 pins directly.
......
...@@ -5424,15 +5424,9 @@ inline void gcode_M109() { ...@@ -5424,15 +5424,9 @@ inline void gcode_M109() {
inline void gcode_M111() { inline void gcode_M111() {
mk_debug_flags = code_seen('S') ? code_value_short() : DEBUG_NONE; mk_debug_flags = code_seen('S') ? code_value_short() : DEBUG_NONE;
const static char str_debug_1[] PROGMEM = SERIAL_DEBUG_ECHO; const static char* const debug_strings[] {
const static char str_debug_2[] PROGMEM = SERIAL_DEBUG_INFO; SERIAL_DEBUG_ECHO, SERIAL_DEBUG_INFO, SERIAL_DEBUG_ERRORS,
const static char str_debug_4[] PROGMEM = SERIAL_DEBUG_ERRORS; SERIAL_DEBUG_DRYRUN, SERIAL_DEBUG_COMMUNICATION, SERIAL_DEBUG_DEBUG
const static char str_debug_8[] PROGMEM = SERIAL_DEBUG_DRYRUN;
const static char str_debug_16[] PROGMEM = SERIAL_DEBUG_COMMUNICATION;
const static char str_debug_32[] PROGMEM = SERIAL_DEBUG_DEBUG;
const static char* const debug_strings[] PROGMEM = {
str_debug_1, str_debug_2, str_debug_4, str_debug_8, str_debug_16, str_debug_32
}; };
ECHO_M(SERIAL_DEBUG_PREFIX); ECHO_M(SERIAL_DEBUG_PREFIX);
...@@ -5490,11 +5484,11 @@ inline void gcode_M114() { ...@@ -5490,11 +5484,11 @@ inline void gcode_M114() {
CRITICAL_SECTION_END; CRITICAL_SECTION_END;
#if MECH(COREXY) || MECH(COREYX) || MECH(COREXZ) || MECH(COREZX) #if MECH(COREXY) || MECH(COREYX) || MECH(COREXZ) || MECH(COREZX)
ECHO_M(MSG_COUNT_A); ECHO_M(SERIAL_COUNT_A);
#elif MECH(DELTA) #elif MECH(DELTA)
ECHO_M(MSG_COUNT_ALPHA); ECHO_M(SERIAL_COUNT_ALPHA);
#else #else
ECHO_M(MSG_COUNT_X); ECHO_M(SERIAL_COUNT_X);
#endif #endif
ECHO_V(xpos); ECHO_V(xpos);
...@@ -6255,22 +6249,26 @@ inline void gcode_M226() { ...@@ -6255,22 +6249,26 @@ inline void gcode_M226() {
} }
#endif // PREVENT_DANGEROUS_EXTRUDE #endif // PREVENT_DANGEROUS_EXTRUDE
#if ENABLED(PIDTEMP) || ENABLED(PIDTEMPBED) #if HAS(PID_HEATING)
/** /**
* M303: PID relay autotune * M303: PID relay autotune
* S<temperature> sets the target temperature. (default target temperature = 150C) * S<temperature> sets the target temperature. (default target temperature = 150C)
* H<hotend> (-1 for the bed) * H<hotend> (-1 for the bed) (default 0)
* C<cycles> * C<cycles>
* U<bool> with a non-zero value will apply the result to current settings
*/ */
inline void gcode_M303() { inline void gcode_M303() {
int h = code_seen('H') ? code_value_short() : 0; int h = code_seen('H') ? code_value_short() : 0;
int c = code_seen('C') ? code_value_short() : 5; int c = code_seen('C') ? code_value_short() : 5;
bool u = code_seen('U') && code_value_short() != 0;
float temp = code_seen('S') ? code_value() : (h < 0 ? 70.0 : 150.0); float temp = code_seen('S') ? code_value() : (h < 0 ? 70.0 : 150.0);
if (h >= 0 && h < HOTENDS) target_extruder = h; if (h >= 0 && h < HOTENDS) target_extruder = h;
KEEPALIVE_STATE(NOT_BUSY); // don't send "busy: processing" messages during autotune output KEEPALIVE_STATE(NOT_BUSY); // don't send "busy: processing" messages during autotune output
PID_autotune(temp, h, c); PID_autotune(temp, h, c, u);
KEEPALIVE_STATE(IN_HANDLER); KEEPALIVE_STATE(IN_HANDLER);
} }
...@@ -8002,7 +8000,7 @@ void process_next_command() { ...@@ -8002,7 +8000,7 @@ void process_next_command() {
gcode_M302(); break; gcode_M302(); break;
#endif // PREVENT_DANGEROUS_EXTRUDE #endif // PREVENT_DANGEROUS_EXTRUDE
#if ENABLED(PIDTEMP) || ENABLED(PIDTEMPBED) #if HAS(PID_HEATING)
case 303: // M303 PID autotune case 303: // M303 PID autotune
gcode_M303(); break; gcode_M303(); break;
#endif #endif
......
...@@ -593,6 +593,12 @@ ...@@ -593,6 +593,12 @@
#define HEATER_USES_AD595 (ENABLED(HEATER_0_USES_AD595) || ENABLED(HEATER_1_USES_AD595) || ENABLED(HEATER_2_USES_AD595) || ENABLED(HEATER_3_USES_AD595)) #define HEATER_USES_AD595 (ENABLED(HEATER_0_USES_AD595) || ENABLED(HEATER_1_USES_AD595) || ENABLED(HEATER_2_USES_AD595) || ENABLED(HEATER_3_USES_AD595))
/**
* Flags for PID handling
*/
#define HAS_PID_HEATING (ENABLED(PIDTEMP) || ENABLED(PIDTEMPBED))
#define HAS_PID_FOR_BOTH (ENABLED(PIDTEMP) && ENABLED(PIDTEMPBED))
/** /**
* ARRAY_BY_EXTRUDERS based on EXTRUDERS * ARRAY_BY_EXTRUDERS based on EXTRUDERS
*/ */
......
...@@ -130,9 +130,9 @@ ...@@ -130,9 +130,9 @@
#define SERIAL_ACTIVE_DRIVER "Active Driver: " #define SERIAL_ACTIVE_DRIVER "Active Driver: "
#define SERIAL_ACTIVE_EXTRUDER "Active Extruder: " #define SERIAL_ACTIVE_EXTRUDER "Active Extruder: "
#define SERIAL_ACTIVE_COLOR "Active Color: " #define SERIAL_ACTIVE_COLOR "Active Color: "
#define MSG_COUNT_X " Count X:" #define SERIAL_COUNT_X " Count X:"
#define MSG_COUNT_A " Count A:" #define SERIAL_COUNT_A " Count A:"
#define MSG_COUNT_ALPHA " Count Alpha:" #define SERIAL_COUNT_ALPHA " Count Alpha:"
#define SERIAL_X_MIN "x_min: " #define SERIAL_X_MIN "x_min: "
#define SERIAL_X_MAX "x_max: " #define SERIAL_X_MAX "x_max: "
#define SERIAL_Y_MIN "y_min: " #define SERIAL_Y_MIN "y_min: "
...@@ -180,6 +180,7 @@ ...@@ -180,6 +180,7 @@
#define SERIAL_ENDSTOPS_HIT "endstops hit: " #define SERIAL_ENDSTOPS_HIT "endstops hit: "
#define SERIAL_ERR_COLD_EXTRUDE_STOP "cold extrusion prevented" #define SERIAL_ERR_COLD_EXTRUDE_STOP "cold extrusion prevented"
#define SERIAL_ERR_LONG_EXTRUDE_STOP "too long extrusion prevented" #define SERIAL_ERR_LONG_EXTRUDE_STOP "too long extrusion prevented"
#define SERIAL_MICROSTEP_MS1_MS2 "MS1,MS2 Pins" #define SERIAL_MICROSTEP_MS1_MS2 "MS1,MS2 Pins"
#define SERIAL_MICROSTEP_X "X:" #define SERIAL_MICROSTEP_X "X:"
#define SERIAL_MICROSTEP_Y "Y:" #define SERIAL_MICROSTEP_Y "Y:"
......
...@@ -12,17 +12,20 @@ ...@@ -12,17 +12,20 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
// BitMap for splashscreen /**
// Generated with: http://www.digole.com/tools/PicturetoC_Hex_converter.php * BitMap for splashscreen
// Please note that using the high-res version takes 402Bytes of PROGMEM. * Generated with: http://www.digole.com/tools/PicturetoC_Hex_converter.php
* Please note that using the high-res version takes 402Bytes of PROGMEM.
*/
#define START_BMPHIGH #define START_BMPHIGH
#if ENABLED(SHOW_BOOTSCREEN) #if ENABLED(SHOW_BOOTSCREEN)
......
/* /**
* MK & MK4due 3D Printer Firmware
*
* Based on Marlin, Sprinter and grbl
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
* Copyright (C) 2013 - 2016 Alberto Cotronei @MagoKimbra
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
Fontname: -Misc-Fixed-Medium-R-Normal--9-90-75-75-C-60-ISO10646-1 Fontname: -Misc-Fixed-Medium-R-Normal--9-90-75-75-C-60-ISO10646-1
Copyright: Public domain font. Share and enjoy. Copyright: Public domain font. Share and enjoy.
Capital A Height: 6, '1' Height: 6 Capital A Height: 6, '1' Height: 6
......
/* /**
* MK & MK4due 3D Printer Firmware
*
* Based on Marlin, Sprinter and grbl
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
* Copyright (C) 2013 - 2016 Alberto Cotronei @MagoKimbra
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
Fontname: HD44780_C v1.2 Fontname: HD44780_C v1.2
Copyright: A. Hardtung, public domain Copyright: A. Hardtung, public domain
Capital A Height: 7, '1' Height: 7 Capital A Height: 7, '1' Height: 7
......
/* /**
* MK & MK4due 3D Printer Firmware
*
* Based on Marlin, Sprinter and grbl
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
* Copyright (C) 2013 - 2016 Alberto Cotronei @MagoKimbra
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
Fontname: HD44780_J Fontname: HD44780_J
Copyright: A. Hardtung, public domain Copyright: A. Hardtung, public domain
Capital A Height: 7, '1' Height: 7 Capital A Height: 7, '1' Height: 7
Calculated Max Values w= 6 h=10 x= 2 y= 8 dx= 6 dy= 0 ascent= 8 len= 8 Calculated Max Values w= 6 h=10 x= 2 y= 5 dx= 6 dy= 0 ascent= 8 len= 8
Font Bounding box w= 6 h= 9 x= 0 y=-2 Font Bounding box w= 6 h= 9 x= 0 y=-2
Calculated Min Values x= 0 y=-2 dx= 0 dy= 0 Calculated Min Values x= 0 y=-2 dx= 0 dy= 0
Pure Font ascent = 7 descent=-1 Pure Font ascent = 7 descent=-1
...@@ -10,9 +32,9 @@ ...@@ -10,9 +32,9 @@
Max Font ascent = 8 descent=-2 Max Font ascent = 8 descent=-2
*/ */
#include <U8glib.h> #include <U8glib.h>
const u8g_fntpgm_uint8_t HD44780_J_5x7[2491] U8G_SECTION(".progmem.HD44780_J_5x7") = { const u8g_fntpgm_uint8_t HD44780_J_5x7[2492] U8G_SECTION(".progmem.HD44780_J_5x7") = {
0, 6, 9, 0, 254, 7, 1, 145, 3, 34, 32, 255, 255, 8, 254, 7, 0, 6, 9, 0, 254, 7, 1, 145, 3, 34, 32, 255, 255, 8, 254, 7,
255, 0, 0, 0, 6, 0, 8, 1, 7, 7, 6, 2, 0, 128, 128, 128, 255, 0, 0, 0, 6, 0, 0, 1, 7, 7, 6, 2, 0, 128, 128, 128,
128, 128, 0, 128, 3, 2, 2, 6, 1, 5, 160, 160, 5, 7, 7, 6, 128, 128, 0, 128, 3, 2, 2, 6, 1, 5, 160, 160, 5, 7, 7, 6,
0, 0, 80, 80, 248, 80, 248, 80, 80, 5, 7, 7, 6, 0, 0, 32, 0, 0, 80, 80, 248, 80, 248, 80, 80, 5, 7, 7, 6, 0, 0, 32,
120, 160, 112, 40, 240, 32, 5, 7, 7, 6, 0, 0, 192, 200, 16, 32, 120, 160, 112, 40, 240, 32, 5, 7, 7, 6, 0, 0, 192, 200, 16, 32,
...@@ -84,19 +106,19 @@ const u8g_fntpgm_uint8_t HD44780_J_5x7[2491] U8G_SECTION(".progmem.HD44780_J_5x7 ...@@ -84,19 +106,19 @@ const u8g_fntpgm_uint8_t HD44780_J_5x7[2491] U8G_SECTION(".progmem.HD44780_J_5x7
128, 64, 64, 32, 1, 7, 7, 6, 2, 0, 128, 128, 128, 128, 128, 128, 128, 64, 64, 32, 1, 7, 7, 6, 2, 0, 128, 128, 128, 128, 128, 128,
128, 3, 7, 7, 6, 1, 0, 128, 64, 64, 32, 64, 64, 128, 5, 5, 128, 3, 7, 7, 6, 1, 0, 128, 64, 64, 32, 64, 64, 128, 5, 5,
5, 6, 0, 1, 32, 16, 248, 16, 32, 5, 5, 5, 6, 0, 1, 32, 5, 6, 0, 1, 32, 16, 248, 16, 32, 5, 5, 5, 6, 0, 1, 32,
64, 248, 64, 32, 0, 0, 0, 6, 0, 8, 0, 0, 0, 6, 0, 8, 64, 248, 64, 32, 0, 0, 0, 6, 0, 0, 0, 0, 0, 6, 0, 0,
0, 0, 0, 6, 0, 8, 0, 0, 0, 6, 0, 8, 0, 0, 0, 6, 0, 0, 0, 6, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 6,
0, 8, 0, 0, 0, 6, 0, 8, 0, 0, 0, 6, 0, 8, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0,
0, 6, 0, 8, 0, 0, 0, 6, 0, 8, 0, 0, 0, 6, 0, 8, 0, 6, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 6, 0, 0,
0, 0, 0, 6, 0, 8, 0, 0, 0, 6, 0, 8, 0, 0, 0, 6, 0, 0, 0, 6, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 6,
0, 8, 0, 0, 0, 6, 0, 8, 0, 0, 0, 6, 0, 8, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0,
0, 6, 0, 8, 0, 0, 0, 6, 0, 8, 0, 0, 0, 6, 0, 8, 0, 6, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 6, 0, 0,
0, 0, 0, 6, 0, 8, 0, 0, 0, 6, 0, 8, 0, 0, 0, 6, 0, 0, 0, 6, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 6,
0, 8, 0, 0, 0, 6, 0, 8, 0, 0, 0, 6, 0, 8, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0,
0, 6, 0, 8, 0, 0, 0, 6, 0, 8, 0, 0, 0, 6, 0, 8, 0, 6, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 6, 0, 0,
0, 0, 0, 6, 0, 8, 0, 0, 0, 6, 0, 8, 0, 0, 0, 6, 0, 0, 0, 6, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 6,
0, 8, 0, 0, 0, 6, 0, 8, 0, 0, 0, 6, 0, 8, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0,
0, 6, 0, 8, 0, 0, 0, 6, 0, 8, 3, 3, 3, 6, 0, 0, 0, 6, 0, 0, 0, 0, 0, 6, 0, 0, 3, 3, 3, 6, 0, 0,
224, 160, 224, 3, 4, 4, 6, 2, 3, 224, 128, 128, 128, 3, 4, 4, 224, 160, 224, 3, 4, 4, 6, 2, 3, 224, 128, 128, 128, 3, 4, 4,
6, 0, 0, 32, 32, 32, 224, 3, 3, 3, 6, 0, 0, 128, 64, 32, 6, 0, 0, 32, 32, 32, 224, 3, 3, 3, 6, 0, 0, 128, 64, 32,
2, 2, 2, 6, 1, 2, 192, 192, 5, 6, 6, 6, 0, 0, 248, 8, 2, 2, 2, 6, 1, 2, 192, 192, 5, 6, 6, 6, 0, 0, 248, 8,
...@@ -106,7 +128,7 @@ const u8g_fntpgm_uint8_t HD44780_J_5x7[2491] U8G_SECTION(".progmem.HD44780_J_5x7 ...@@ -106,7 +128,7 @@ const u8g_fntpgm_uint8_t HD44780_J_5x7[2491] U8G_SECTION(".progmem.HD44780_J_5x7
5, 5, 6, 0, 0, 16, 248, 48, 80, 144, 5, 5, 5, 6, 0, 0, 5, 5, 6, 0, 0, 16, 248, 48, 80, 144, 5, 5, 5, 6, 0, 0,
64, 248, 72, 80, 64, 5, 4, 4, 6, 0, 0, 112, 16, 16, 248, 4, 64, 248, 72, 80, 64, 5, 4, 4, 6, 0, 0, 112, 16, 16, 248, 4,
5, 5, 6, 0, 0, 240, 16, 240, 16, 240, 5, 4, 4, 6, 0, 0, 5, 5, 6, 0, 0, 240, 16, 240, 16, 240, 5, 4, 4, 6, 0, 0,
168, 168, 8, 48, 5, 1, 1, 6, 0, 4, 248, 5, 7, 7, 6, 0, 168, 168, 8, 48, 5, 1, 1, 6, 0, 3, 248, 5, 7, 7, 6, 0,
0, 248, 8, 40, 48, 32, 32, 64, 5, 7, 7, 6, 0, 0, 8, 16, 0, 248, 8, 40, 48, 32, 32, 64, 5, 7, 7, 6, 0, 0, 8, 16,
32, 96, 160, 32, 32, 5, 7, 7, 6, 0, 0, 32, 248, 136, 136, 8, 32, 96, 160, 32, 32, 5, 7, 7, 6, 0, 0, 32, 248, 136, 136, 8,
16, 32, 5, 6, 6, 6, 0, 0, 248, 32, 32, 32, 32, 248, 5, 7, 16, 32, 5, 6, 6, 6, 0, 0, 248, 32, 32, 32, 32, 248, 5, 7,
...@@ -124,47 +146,47 @@ const u8g_fntpgm_uint8_t HD44780_J_5x7[2491] U8G_SECTION(".progmem.HD44780_J_5x7 ...@@ -124,47 +146,47 @@ const u8g_fntpgm_uint8_t HD44780_J_5x7[2491] U8G_SECTION(".progmem.HD44780_J_5x7
6, 0, 0, 112, 0, 248, 32, 32, 32, 64, 3, 7, 7, 6, 1, 0, 6, 0, 0, 112, 0, 248, 32, 32, 32, 64, 3, 7, 7, 6, 1, 0,
128, 128, 128, 192, 160, 128, 128, 5, 7, 7, 6, 0, 0, 32, 32, 248, 128, 128, 128, 192, 160, 128, 128, 5, 7, 7, 6, 0, 0, 32, 32, 248,
32, 32, 64, 128, 5, 6, 6, 6, 0, 0, 112, 0, 0, 0, 0, 248, 32, 32, 64, 128, 5, 6, 6, 6, 0, 0, 112, 0, 0, 0, 0, 248,
5, 6, 6, 6, 0, 0, 248, 8, 80, 32, 80, 128, 5, 6, 6, 6, 5, 6, 6, 6, 0, 0, 248, 8, 80, 32, 80, 128, 5, 7, 7, 6,
0, 1, 32, 248, 16, 32, 112, 168, 3, 7, 7, 6, 1, 0, 32, 32, 0, 0, 32, 248, 16, 32, 112, 168, 32, 3, 7, 7, 6, 1, 0, 32,
32, 32, 32, 64, 128, 5, 6, 6, 6, 0, 0, 32, 16, 136, 136, 136, 32, 32, 32, 32, 64, 128, 5, 6, 6, 6, 0, 0, 32, 16, 136, 136,
136, 5, 7, 7, 6, 0, 0, 128, 128, 248, 128, 128, 128, 120, 5, 6, 136, 136, 5, 7, 7, 6, 0, 0, 128, 128, 248, 128, 128, 128, 120, 5,
6, 6, 0, 0, 248, 8, 8, 8, 16, 96, 5, 5, 5, 6, 0, 1, 6, 6, 6, 0, 0, 248, 8, 8, 8, 16, 96, 5, 5, 5, 6, 0,
64, 160, 16, 8, 8, 5, 7, 7, 6, 0, 0, 32, 248, 32, 32, 168, 1, 64, 160, 16, 8, 8, 5, 7, 7, 6, 0, 0, 32, 248, 32, 32,
168, 32, 5, 6, 6, 6, 0, 0, 248, 8, 8, 80, 32, 16, 4, 6, 168, 168, 32, 5, 6, 6, 6, 0, 0, 248, 8, 8, 80, 32, 16, 4,
6, 6, 1, 0, 224, 0, 224, 0, 224, 16, 5, 6, 6, 6, 0, 0, 6, 6, 6, 1, 0, 224, 0, 224, 0, 224, 16, 5, 6, 6, 6, 0,
32, 64, 128, 136, 248, 8, 5, 6, 6, 6, 0, 0, 8, 8, 80, 32, 0, 32, 64, 128, 136, 248, 8, 5, 6, 6, 6, 0, 0, 8, 8, 80,
80, 128, 5, 6, 6, 6, 0, 0, 248, 64, 248, 64, 64, 56, 5, 7, 32, 80, 128, 5, 6, 6, 6, 0, 0, 248, 64, 248, 64, 64, 56, 5,
7, 6, 0, 0, 64, 64, 248, 72, 80, 64, 64, 5, 7, 7, 6, 0, 7, 7, 6, 0, 0, 64, 64, 248, 72, 80, 64, 64, 5, 7, 7, 6,
0, 112, 16, 16, 16, 16, 16, 248, 5, 6, 6, 6, 0, 0, 248, 8, 0, 0, 112, 16, 16, 16, 16, 16, 248, 5, 6, 6, 6, 0, 0, 248,
248, 8, 8, 248, 5, 7, 7, 6, 0, 0, 112, 0, 248, 8, 8, 16, 8, 248, 8, 8, 248, 5, 7, 7, 6, 0, 0, 112, 0, 248, 8, 8,
32, 4, 7, 7, 6, 0, 0, 144, 144, 144, 144, 16, 32, 64, 5, 6, 16, 32, 4, 7, 7, 6, 0, 0, 144, 144, 144, 144, 16, 32, 64, 5,
6, 6, 0, 0, 32, 160, 160, 168, 168, 176, 5, 7, 7, 6, 0, 0, 6, 6, 6, 0, 0, 32, 160, 160, 168, 168, 176, 5, 7, 7, 6, 0,
128, 128, 128, 136, 144, 160, 192, 5, 6, 6, 6, 0, 0, 248, 136, 136, 0, 128, 128, 128, 136, 144, 160, 192, 5, 6, 6, 6, 0, 0, 248, 136,
136, 136, 248, 5, 6, 6, 6, 0, 0, 248, 136, 136, 8, 16, 32, 5, 136, 136, 136, 248, 5, 6, 6, 6, 0, 0, 248, 136, 136, 8, 16, 32,
6, 6, 6, 0, 0, 192, 0, 8, 8, 16, 224, 4, 3, 3, 6, 0, 5, 6, 6, 6, 0, 0, 192, 0, 8, 8, 16, 224, 4, 3, 3, 6,
4, 32, 144, 64, 3, 3, 3, 6, 0, 4, 224, 160, 224, 5, 5, 5, 0, 4, 32, 144, 64, 3, 3, 3, 6, 0, 4, 224, 160, 224, 5, 5,
6, 0, 1, 72, 168, 144, 144, 104, 5, 7, 7, 6, 0, 0, 80, 0, 5, 6, 0, 1, 72, 168, 144, 144, 104, 5, 7, 7, 6, 0, 0, 80,
112, 8, 120, 136, 120, 4, 8, 8, 6, 1, 255, 96, 144, 144, 224, 144, 0, 112, 8, 120, 136, 120, 4, 8, 8, 6, 1, 255, 96, 144, 144, 224,
144, 224, 128, 5, 5, 5, 6, 0, 0, 112, 128, 96, 136, 112, 5, 6, 144, 144, 224, 128, 5, 5, 5, 6, 0, 0, 112, 128, 96, 136, 112, 5,
6, 6, 0, 255, 136, 136, 152, 232, 136, 128, 5, 5, 5, 6, 0, 0, 6, 6, 6, 0, 255, 136, 136, 152, 232, 136, 128, 5, 5, 5, 6, 0,
120, 160, 144, 136, 112, 5, 7, 7, 6, 0, 254, 48, 72, 136, 136, 240, 0, 120, 160, 144, 136, 112, 5, 7, 7, 6, 0, 254, 48, 72, 136, 136,
128, 128, 5, 8, 8, 6, 0, 254, 120, 136, 136, 136, 120, 8, 8, 112, 240, 128, 128, 5, 8, 8, 6, 0, 254, 120, 136, 136, 136, 120, 8, 8,
5, 5, 5, 6, 0, 1, 56, 32, 32, 160, 64, 4, 3, 3, 6, 0, 112, 5, 5, 5, 6, 0, 1, 56, 32, 32, 160, 64, 4, 3, 3, 6,
3, 16, 208, 16, 4, 8, 8, 6, 0, 255, 16, 0, 48, 16, 16, 16, 0, 3, 16, 208, 16, 4, 8, 8, 6, 0, 255, 16, 0, 48, 16, 16,
144, 96, 3, 3, 3, 6, 0, 4, 160, 64, 160, 5, 7, 7, 6, 0, 16, 144, 96, 3, 3, 3, 6, 0, 4, 160, 64, 160, 5, 7, 7, 6,
0, 32, 112, 160, 160, 168, 112, 32, 5, 7, 7, 6, 0, 0, 64, 64, 0, 0, 32, 112, 160, 160, 168, 112, 32, 5, 7, 7, 6, 0, 0, 64,
224, 64, 224, 64, 120, 5, 7, 7, 6, 0, 0, 112, 0, 176, 200, 136, 64, 224, 64, 224, 64, 120, 5, 7, 7, 6, 0, 0, 112, 0, 176, 200,
136, 136, 5, 7, 7, 6, 0, 0, 80, 0, 112, 136, 136, 136, 112, 5, 136, 136, 136, 5, 7, 7, 6, 0, 0, 80, 0, 112, 136, 136, 136, 112,
7, 7, 6, 0, 255, 176, 200, 136, 136, 240, 128, 128, 5, 7, 7, 6, 5, 7, 7, 6, 0, 255, 176, 200, 136, 136, 240, 128, 128, 5, 7, 7,
0, 255, 104, 152, 136, 136, 120, 8, 8, 5, 6, 6, 6, 0, 0, 112, 6, 0, 255, 104, 152, 136, 136, 120, 8, 8, 5, 6, 6, 6, 0, 0,
136, 248, 136, 136, 112, 5, 3, 3, 6, 0, 2, 88, 168, 208, 5, 5, 112, 136, 248, 136, 136, 112, 5, 3, 3, 6, 0, 2, 88, 168, 208, 5,
5, 6, 0, 0, 112, 136, 136, 80, 216, 5, 7, 7, 6, 0, 0, 80, 5, 5, 6, 0, 0, 112, 136, 136, 80, 216, 5, 7, 7, 6, 0, 0,
0, 136, 136, 136, 152, 104, 5, 7, 7, 6, 0, 0, 248, 128, 64, 32, 80, 0, 136, 136, 136, 152, 104, 5, 7, 7, 6, 0, 0, 248, 128, 64,
64, 128, 248, 5, 5, 5, 6, 0, 0, 248, 80, 80, 80, 152, 5, 7, 32, 64, 128, 248, 5, 5, 5, 6, 0, 0, 248, 80, 80, 80, 152, 5,
7, 6, 0, 0, 248, 0, 136, 80, 32, 80, 136, 5, 7, 7, 6, 0, 7, 7, 6, 0, 0, 248, 0, 136, 80, 32, 80, 136, 5, 7, 7, 6,
255, 136, 136, 136, 136, 120, 8, 112, 5, 6, 6, 6, 0, 1, 8, 240, 0, 255, 136, 136, 136, 136, 120, 8, 112, 5, 6, 6, 6, 0, 0, 8,
32, 248, 32, 32, 5, 5, 5, 6, 0, 0, 248, 64, 120, 72, 136, 5, 240, 32, 248, 32, 32, 5, 5, 5, 6, 0, 0, 248, 64, 120, 72, 136,
5, 5, 6, 0, 0, 248, 168, 248, 136, 136, 5, 5, 5, 6, 0, 1, 5, 5, 5, 6, 0, 0, 248, 168, 248, 136, 136, 5, 5, 5, 6, 0,
32, 0, 248, 0, 32, 0, 0, 0, 6, 0, 8, 6, 10, 10, 6, 0, 1, 32, 0, 248, 0, 32, 0, 0, 0, 6, 0, 0, 6, 10, 10, 6,
254, 252, 252, 252, 252, 252, 252, 252, 252, 252, 252 0, 254, 252, 252, 252, 252, 252, 252, 252, 252, 252, 252
}; };
/* /**
* MK & MK4due 3D Printer Firmware
*
* Based on Marlin, Sprinter and grbl
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
* Copyright (C) 2013 - 2016 Alberto Cotronei @MagoKimbra
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
Fontname: HD44780_W Fontname: HD44780_W
Copyright: A.Hardtung, public domain Copyright: A.Hardtung, public domain
Capital A Height: 7, '1' Height: 7 Capital A Height: 7, '1' Height: 7
......
/* /**
* MK & MK4due 3D Printer Firmware
*
* Based on Marlin, Sprinter and grbl
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
* Copyright (C) 2013 - 2016 Alberto Cotronei @MagoKimbra
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
Fontname: ISO10646-1 Fontname: ISO10646-1
Copyright: A.Hardtung, public domain Copyright: A.Hardtung, public domain
Capital A Height: 7, '1' Height: 7 Capital A Height: 7, '1' Height: 7
......
/* /**
* MK & MK4due 3D Printer Firmware
*
* Based on Marlin, Sprinter and grbl
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
* Copyright (C) 2013 - 2016 Alberto Cotronei @MagoKimbra
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
Fontname: ISO10646_5_Cyrillic Fontname: ISO10646_5_Cyrillic
Copyright: A. Hardtung, public domain Copyright: A. Hardtung, public domain
Capital A Height: 7, '1' Height: 7 Capital A Height: 7, '1' Height: 7
......
/* /**
* MK & MK4due 3D Printer Firmware
*
* Based on Marlin, Sprinter and grbl
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
* Copyright (C) 2013 - 2016 Alberto Cotronei @MagoKimbra
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
Fontname: ISO10646_Kana Fontname: ISO10646_Kana
Copyright: A. Hardtung, public domain Copyright: A. Hardtung, public domain
Capital A Height: 7, '1' Height: 7 Capital A Height: 7, '1' Height: 7
Calculated Max Values w= 5 h= 9 x= 2 y= 5 dx= 6 dy= 0 ascent= 8 len= 9 Calculated Max Values w= 5 h= 8 x= 2 y= 5 dx= 6 dy= 0 ascent= 8 len= 8
Font Bounding box w= 6 h= 9 x= 0 y=-2 Font Bounding box w= 6 h= 9 x= 0 y=-2
Calculated Min Values x= 0 y=-1 dx= 0 dy= 0 Calculated Min Values x= 0 y=-1 dx= 0 dy= 0
Pure Font ascent = 7 descent=-1 Pure Font ascent = 7 descent=-1
...@@ -10,7 +32,7 @@ ...@@ -10,7 +32,7 @@
Max Font ascent = 8 descent=-1 Max Font ascent = 8 descent=-1
*/ */
#include <U8glib.h> #include <U8glib.h>
const u8g_fntpgm_uint8_t ISO10646_Kana_5x7[2549] U8G_SECTION(".progmem.ISO10646_Kana_5x7") = { const u8g_fntpgm_uint8_t ISO10646_Kana_5x7[2482] U8G_SECTION(".progmem.ISO10646_Kana_5x7") = {
0, 6, 9, 0, 254, 7, 1, 145, 3, 32, 32, 255, 255, 8, 255, 7, 0, 6, 9, 0, 254, 7, 1, 145, 3, 32, 32, 255, 255, 8, 255, 7,
255, 0, 0, 0, 6, 0, 0, 1, 7, 7, 6, 2, 0, 128, 128, 128, 255, 0, 0, 0, 6, 0, 0, 1, 7, 7, 6, 2, 0, 128, 128, 128,
128, 128, 0, 128, 3, 2, 2, 6, 1, 5, 160, 160, 5, 7, 7, 6, 128, 128, 0, 128, 3, 2, 2, 6, 1, 5, 160, 160, 5, 7, 7, 6,
...@@ -95,80 +117,76 @@ const u8g_fntpgm_uint8_t ISO10646_Kana_5x7[2549] U8G_SECTION(".progmem.ISO10646_ ...@@ -95,80 +117,76 @@ const u8g_fntpgm_uint8_t ISO10646_Kana_5x7[2549] U8G_SECTION(".progmem.ISO10646_
0, 6, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 6, 0, 0, 0, 6, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 6, 0, 0,
0, 0, 0, 6, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 6, 0, 0, 0, 6, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 6,
0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0,
0, 6, 0, 0, 0, 0, 0, 6, 0, 0, 5, 3, 3, 6, 0, 2, 0, 6, 0, 0, 0, 0, 0, 6, 0, 0, 5, 3, 3, 6, 0, 1,
248, 0, 248, 5, 6, 6, 6, 0, 0, 248, 8, 40, 48, 32, 64, 5, 248, 0, 248, 4, 4, 4, 6, 0, 0, 240, 16, 96, 64, 5, 6, 6,
7, 7, 6, 0, 0, 248, 8, 40, 48, 32, 32, 64, 4, 5, 5, 6, 6, 0, 0, 248, 8, 40, 48, 32, 64, 3, 4, 4, 6, 1, 0, 32,
0, 0, 16, 32, 96, 160, 32, 5, 7, 7, 6, 0, 0, 8, 16, 32, 64, 192, 64, 4, 6, 6, 6, 0, 0, 16, 32, 96, 160, 32, 32, 4,
96, 160, 32, 32, 5, 5, 5, 6, 0, 0, 32, 248, 136, 8, 48, 5, 4, 4, 6, 0, 0, 32, 240, 144, 32, 5, 6, 6, 6, 0, 0, 32,
7, 7, 6, 0, 0, 32, 248, 136, 136, 8, 16, 32, 5, 4, 4, 6, 248, 136, 8, 16, 32, 3, 4, 4, 6, 1, 0, 224, 64, 64, 224, 5,
0, 0, 248, 32, 32, 248, 5, 6, 6, 6, 0, 0, 248, 32, 32, 32, 5, 5, 6, 0, 0, 248, 32, 32, 32, 248, 4, 4, 4, 6, 0, 0,
32, 248, 5, 5, 5, 6, 0, 0, 16, 248, 48, 80, 144, 5, 7, 7, 32, 240, 96, 160, 5, 6, 6, 6, 0, 0, 16, 248, 48, 80, 144, 16,
6, 0, 0, 16, 248, 16, 48, 80, 144, 16, 5, 5, 5, 6, 0, 0, 5, 6, 6, 6, 0, 0, 64, 248, 72, 72, 72, 144, 5, 8, 8, 6,
64, 248, 72, 80, 64, 5, 7, 7, 6, 0, 0, 40, 0, 64, 248, 72, 0, 0, 40, 0, 64, 248, 72, 72, 72, 144, 5, 6, 6, 6, 0, 0,
80, 64, 5, 7, 7, 6, 0, 0, 32, 248, 32, 248, 32, 32, 32, 5, 32, 248, 32, 248, 32, 32, 5, 8, 8, 6, 0, 0, 40, 0, 32, 248,
8, 8, 6, 0, 0, 40, 0, 32, 248, 32, 248, 32, 32, 4, 6, 6, 32, 248, 32, 32, 4, 5, 5, 6, 0, 0, 112, 144, 16, 32, 192, 5,
6, 0, 0, 64, 112, 144, 16, 16, 32, 5, 8, 8, 6, 0, 0, 40, 7, 7, 6, 0, 0, 40, 0, 112, 144, 16, 32, 192, 5, 6, 6, 6,
0, 64, 112, 144, 16, 16, 32, 5, 6, 6, 6, 0, 0, 64, 120, 144, 0, 0, 64, 120, 144, 16, 16, 32, 5, 8, 8, 6, 0, 0, 40, 0,
16, 16, 32, 5, 8, 8, 6, 0, 0, 40, 0, 64, 120, 144, 16, 16, 64, 120, 144, 16, 16, 32, 5, 5, 5, 6, 0, 0, 248, 8, 8, 8,
32, 5, 5, 5, 6, 0, 0, 248, 8, 8, 8, 248, 5, 7, 7, 6, 248, 5, 7, 7, 6, 0, 0, 40, 0, 248, 8, 8, 8, 248, 5, 6,
0, 0, 40, 0, 248, 8, 8, 8, 248, 5, 7, 7, 6, 0, 255, 80, 6, 6, 0, 0, 80, 248, 80, 16, 32, 64, 5, 8, 8, 6, 0, 0,
248, 80, 80, 16, 32, 64, 5, 9, 9, 6, 0, 255, 40, 0, 80, 248, 40, 0, 80, 248, 80, 16, 32, 64, 5, 5, 5, 6, 0, 0, 192, 8,
80, 80, 16, 32, 64, 5, 6, 6, 6, 0, 0, 192, 8, 200, 8, 16, 200, 16, 224, 5, 7, 7, 6, 0, 0, 40, 0, 192, 8, 200, 16, 224,
224, 5, 8, 8, 6, 0, 0, 40, 0, 192, 8, 200, 8, 16, 224, 5, 5, 5, 5, 6, 0, 0, 248, 16, 32, 80, 136, 5, 7, 7, 6, 0,
6, 6, 6, 0, 0, 248, 8, 16, 32, 80, 136, 5, 8, 8, 6, 0, 0, 40, 0, 248, 16, 32, 80, 136, 5, 6, 6, 6, 0, 0, 64, 248,
0, 40, 0, 248, 8, 16, 32, 80, 136, 5, 6, 6, 6, 0, 0, 64, 72, 80, 64, 56, 5, 8, 8, 6, 0, 0, 40, 0, 64, 248, 72, 80,
248, 72, 80, 64, 120, 5, 8, 8, 6, 0, 0, 40, 0, 64, 248, 72, 64, 56, 5, 5, 5, 6, 0, 0, 136, 136, 72, 16, 96, 5, 7, 7,
80, 64, 120, 4, 4, 4, 6, 0, 1, 16, 208, 16, 224, 5, 7, 7, 6, 0, 0, 40, 0, 136, 136, 72, 16, 96, 5, 5, 5, 6, 0, 0,
6, 0, 0, 40, 0, 8, 200, 8, 16, 224, 5, 7, 7, 6, 0, 255, 120, 72, 168, 16, 96, 5, 7, 7, 6, 0, 0, 40, 0, 120, 72, 168,
32, 120, 136, 40, 16, 40, 64, 5, 9, 9, 6, 0, 255, 40, 0, 32, 16, 96, 5, 6, 6, 6, 0, 0, 16, 224, 32, 248, 32, 64, 5, 8,
120, 136, 40, 16, 40, 64, 5, 6, 6, 6, 0, 0, 240, 32, 248, 32, 8, 6, 0, 0, 40, 0, 16, 224, 32, 248, 32, 64, 5, 4, 4, 6,
64, 128, 5, 8, 8, 6, 0, 0, 40, 0, 240, 32, 248, 32, 64, 128, 0, 0, 168, 168, 8, 48, 5, 5, 5, 6, 0, 0, 168, 168, 8, 16,
4, 5, 5, 6, 0, 1, 192, 16, 208, 16, 224, 5, 6, 6, 6, 0, 32, 5, 7, 7, 6, 0, 0, 40, 0, 168, 168, 8, 16, 32, 5, 6,
0, 192, 8, 200, 8, 16, 224, 5, 8, 8, 6, 0, 0, 40, 0, 192, 6, 6, 0, 0, 112, 0, 248, 32, 32, 64, 5, 8, 8, 6, 0, 0,
8, 200, 8, 16, 224, 5, 6, 6, 6, 0, 0, 112, 0, 248, 32, 32, 40, 0, 112, 0, 248, 32, 32, 64, 3, 6, 6, 6, 1, 0, 128, 128,
64, 5, 8, 8, 6, 0, 0, 40, 0, 112, 0, 248, 32, 32, 64, 3, 192, 160, 128, 128, 4, 8, 8, 6, 1, 0, 80, 0, 128, 128, 192, 160,
7, 7, 6, 1, 0, 128, 128, 128, 192, 160, 128, 128, 4, 8, 8, 6, 128, 128, 5, 6, 6, 6, 0, 0, 32, 248, 32, 32, 64, 128, 5, 5,
1, 0, 80, 0, 128, 128, 192, 160, 128, 128, 5, 7, 7, 6, 0, 0, 5, 6, 0, 0, 112, 0, 0, 0, 248, 5, 5, 5, 6, 0, 0, 248,
32, 32, 248, 32, 32, 64, 128, 5, 6, 6, 6, 0, 0, 112, 0, 0, 8, 80, 32, 208, 5, 6, 6, 6, 0, 0, 32, 248, 16, 32, 112, 168,
0, 0, 248, 5, 6, 6, 6, 0, 0, 248, 8, 80, 32, 80, 128, 5, 3, 6, 6, 6, 1, 0, 32, 32, 32, 32, 64, 128, 5, 5, 5, 6,
7, 7, 6, 0, 255, 32, 248, 8, 16, 32, 112, 168, 3, 7, 7, 6, 0, 0, 16, 136, 136, 136, 136, 5, 7, 7, 6, 0, 0, 40, 0, 16,
1, 0, 32, 32, 32, 32, 32, 64, 128, 5, 5, 5, 6, 0, 0, 16, 136, 136, 136, 136, 5, 8, 8, 6, 0, 0, 24, 24, 0, 16, 136, 136,
136, 136, 136, 136, 5, 7, 7, 6, 0, 0, 40, 0, 16, 136, 136, 136, 136, 136, 5, 6, 6, 6, 0, 0, 128, 128, 248, 128, 128, 120, 5, 7,
136, 5, 8, 8, 6, 0, 0, 24, 24, 0, 16, 136, 136, 136, 136, 5, 7, 6, 0, 0, 40, 128, 128, 248, 128, 128, 120, 5, 7, 7, 6, 0,
7, 7, 6, 0, 0, 128, 128, 248, 128, 128, 128, 120, 5, 8, 8, 6, 0, 24, 152, 128, 248, 128, 128, 120, 5, 5, 5, 6, 0, 0, 248, 8,
0, 0, 40, 128, 128, 248, 128, 128, 128, 120, 5, 8, 8, 6, 0, 0, 8, 16, 96, 5, 7, 7, 6, 0, 0, 40, 0, 248, 8, 8, 16, 96,
24, 152, 128, 248, 128, 128, 128, 120, 5, 6, 6, 6, 0, 0, 248, 8, 5, 8, 8, 6, 0, 0, 24, 24, 0, 248, 8, 8, 16, 96, 5, 4,
8, 8, 16, 96, 5, 8, 8, 6, 0, 0, 40, 0, 248, 8, 8, 8, 4, 6, 0, 1, 64, 160, 16, 8, 5, 6, 6, 6, 0, 1, 40, 0,
16, 96, 5, 8, 8, 6, 0, 0, 24, 24, 248, 8, 8, 8, 16, 96, 64, 160, 16, 8, 5, 6, 6, 6, 0, 1, 24, 24, 64, 160, 16, 8,
5, 5, 5, 6, 0, 1, 64, 160, 16, 8, 8, 5, 7, 7, 6, 0, 5, 6, 6, 6, 0, 0, 32, 248, 32, 168, 168, 32, 5, 8, 8, 6,
1, 40, 0, 64, 160, 16, 8, 8, 5, 7, 7, 6, 0, 1, 24, 24, 0, 0, 40, 0, 32, 248, 32, 168, 168, 32, 5, 8, 8, 6, 0, 0,
64, 160, 16, 8, 8, 5, 6, 6, 6, 0, 0, 32, 248, 32, 32, 168, 24, 24, 32, 248, 32, 168, 168, 32, 5, 5, 5, 6, 0, 0, 248, 8,
168, 5, 8, 8, 6, 0, 0, 40, 0, 32, 248, 32, 32, 168, 168, 5, 80, 32, 16, 4, 5, 5, 6, 1, 0, 224, 0, 224, 0, 240, 5, 5,
8, 8, 6, 0, 0, 24, 24, 32, 248, 32, 32, 168, 168, 5, 6, 6, 5, 6, 0, 0, 32, 64, 136, 248, 8, 5, 5, 5, 6, 0, 0, 8,
6, 0, 0, 248, 8, 8, 80, 32, 16, 4, 6, 6, 6, 1, 0, 224, 40, 16, 40, 192, 5, 5, 5, 6, 0, 0, 248, 64, 248, 64, 56, 5,
0, 224, 0, 224, 16, 5, 6, 6, 6, 0, 0, 32, 64, 128, 144, 248, 4, 4, 6, 0, 0, 64, 248, 80, 64, 5, 6, 6, 6, 0, 0, 64,
8, 5, 6, 6, 6, 0, 0, 8, 8, 80, 32, 80, 128, 5, 6, 6, 248, 72, 80, 64, 64, 4, 4, 4, 6, 0, 0, 96, 32, 32, 240, 5,
6, 0, 0, 120, 32, 248, 32, 32, 56, 5, 7, 7, 6, 0, 0, 64, 5, 5, 6, 0, 0, 112, 16, 16, 16, 248, 4, 5, 5, 6, 0, 0,
64, 248, 72, 80, 64, 64, 5, 7, 7, 6, 0, 0, 64, 248, 72, 80, 240, 16, 240, 16, 240, 5, 5, 5, 6, 0, 0, 248, 8, 248, 8, 248,
64, 64, 64, 5, 5, 5, 6, 0, 0, 112, 16, 16, 16, 248, 5, 7, 5, 6, 6, 6, 0, 0, 112, 0, 248, 8, 16, 32, 4, 6, 6, 6,
7, 6, 0, 0, 112, 16, 16, 16, 16, 16, 248, 4, 5, 5, 6, 1, 0, 0, 144, 144, 144, 144, 16, 32, 5, 5, 5, 6, 0, 0, 32, 160,
0, 240, 16, 240, 16, 240, 5, 7, 7, 6, 0, 0, 248, 8, 8, 248, 168, 168, 176, 4, 5, 5, 6, 0, 0, 128, 128, 144, 160, 192, 5, 5,
8, 8, 248, 5, 6, 6, 6, 0, 0, 112, 0, 248, 8, 16, 32, 3, 5, 6, 0, 0, 248, 136, 136, 136, 248, 4, 4, 4, 6, 0, 0, 240,
6, 6, 6, 1, 0, 160, 160, 160, 160, 32, 64, 5, 6, 6, 6, 0, 144, 16, 32, 5, 5, 5, 6, 0, 0, 248, 136, 8, 16, 32, 5, 6,
0, 80, 80, 80, 80, 88, 144, 4, 6, 6, 6, 1, 0, 128, 128, 128, 6, 6, 0, 0, 16, 248, 80, 80, 248, 16, 5, 5, 5, 6, 0, 0,
144, 160, 192, 5, 6, 6, 6, 0, 0, 248, 136, 136, 136, 248, 136, 5, 248, 8, 48, 32, 248, 5, 5, 5, 6, 0, 0, 248, 8, 248, 8, 48,
5, 5, 6, 0, 0, 248, 136, 8, 16, 96, 5, 6, 6, 6, 0, 0, 5, 5, 5, 6, 0, 0, 192, 8, 8, 16, 224, 5, 8, 8, 6, 0,
248, 136, 8, 8, 16, 96, 5, 6, 6, 6, 0, 0, 16, 248, 80, 80, 0, 40, 0, 32, 248, 136, 8, 16, 32, 4, 4, 4, 6, 0, 0, 64,
248, 16, 5, 6, 6, 6, 0, 0, 248, 8, 80, 96, 64, 248, 5, 6, 240, 80, 160, 4, 4, 4, 6, 0, 0, 64, 240, 32, 64, 5, 7, 7,
6, 6, 0, 0, 248, 8, 248, 8, 16, 32, 5, 6, 6, 6, 0, 0, 6, 0, 0, 40, 0, 248, 136, 8, 16, 96, 5, 8, 8, 6, 0, 0,
128, 64, 8, 8, 16, 224, 5, 8, 8, 6, 0, 0, 40, 0, 32, 248, 40, 0, 16, 248, 80, 80, 248, 16, 5, 7, 7, 6, 0, 0, 40, 0,
136, 8, 24, 32, 5, 6, 6, 6, 0, 0, 64, 248, 72, 72, 136, 144, 248, 8, 48, 32, 248, 5, 7, 7, 6, 0, 0, 40, 0, 248, 8, 248,
4, 5, 5, 6, 1, 0, 128, 240, 160, 32, 32, 5, 8, 8, 6, 0, 8, 48, 2, 2, 2, 6, 2, 2, 192, 192, 5, 1, 1, 6, 0, 2,
0, 40, 0, 248, 136, 8, 8, 16, 96, 5, 8, 8, 6, 0, 0, 40, 248, 5, 4, 4, 6, 0, 1, 128, 96, 16, 8, 5, 5, 5, 6, 0,
0, 16, 248, 80, 80, 248, 16, 5, 7, 7, 6, 0, 0, 40, 0, 248, 1, 40, 128, 96, 16, 8, 5, 6, 6, 6, 0, 0, 248, 8, 8, 8,
16, 32, 32, 248, 5, 8, 8, 6, 0, 0, 40, 0, 248, 8, 248, 8, 8, 8
16, 32, 2, 2, 2, 6, 2, 2, 192, 192, 5, 1, 1, 6, 0, 3,
248, 5, 5, 5, 6, 0, 1, 128, 64, 32, 16, 8, 5, 6, 6, 6,
0, 1, 40, 128, 64, 32, 16, 8, 5, 7, 7, 6, 0, 0, 248, 8,
8, 8, 8, 8, 8
}; };
/* /**
* MK & MK4due 3D Printer Firmware
*
* Based on Marlin, Sprinter and grbl
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
* Copyright (C) 2013 - 2016 Alberto Cotronei @MagoKimbra
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
Fontname: Marlin_symbols Fontname: Marlin_symbols
Copyright: Created with Fony 1.4.7 Copyright: Created with Fony 1.4.7
Capital A Height: 0, '1' Height: 0 Capital A Height: 0, '1' Height: 0
......
...@@ -290,8 +290,13 @@ FORCE_INLINE void _draw_centered_temp(int temp, int x, int y) { ...@@ -290,8 +290,13 @@ FORCE_INLINE void _draw_centered_temp(int temp, int x, int y) {
lcd_printPGM(PSTR(LCD_STR_DEGREE " ")); lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
} }
static void _draw_heater_status(int x, int heater) { FORCE_INLINE void _draw_heater_status(int x, int heater) {
bool isBed = heater < 0; #if HAS(TEMP_BED)
bool isBed = heater < 0;
#else
const bool isBed = false;
#endif
int y = 17 + (isBed ? 1 : 0); int y = 17 + (isBed ? 1 : 0);
lcd_setFont(FONT_STATUSMENU); lcd_setFont(FONT_STATUSMENU);
...@@ -650,7 +655,7 @@ void lcd_implementation_drawedit(const char* pstr, char* value) { ...@@ -650,7 +655,7 @@ void lcd_implementation_drawedit(const char* pstr, char* value) {
#endif //SDSUPPORT #endif //SDSUPPORT
#define lcd_implementation_drawmenu_back(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0]) #define lcd_implementation_drawmenu_back(sel, row, pstr) lcd_implementation_drawmenu_generic(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0])
#define lcd_implementation_drawmenu_submenu(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0]) #define lcd_implementation_drawmenu_submenu(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0])
#define lcd_implementation_drawmenu_gcode(sel, row, pstr, gcode) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ') #define lcd_implementation_drawmenu_gcode(sel, row, pstr, gcode) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
#define lcd_implementation_drawmenu_function(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ') #define lcd_implementation_drawmenu_function(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
......
...@@ -21,10 +21,28 @@ ...@@ -21,10 +21,28 @@
*/ */
#include "../../base.h" #include "../../base.h"
#include "ultralcd.h"
#if ENABLED(ULTRA_LCD) #if ENABLED(ULTRA_LCD)
#include "ultralcd.h" /**
* INVERT_ROTARY_SWITCH
*
* To reverse the menu direction we need a general way to reverse
* the direction of the encoder everywhere. So encoderDirection is
* added to allow the encoder to go the other way.
*
* This behavior is limited to scrolling Menus and SD card listings,
* and is disabled in other contexts.
*/
#if ENABLED(INVERT_ROTARY_SWITCH)
int8_t encoderDirection = 1;
#define ENCODER_DIRECTION_NORMAL() (encoderDirection = 1)
#define ENCODER_DIRECTION_MENUS() (encoderDirection = -1)
#else
#define ENCODER_DIRECTION_NORMAL() ;
#define ENCODER_DIRECTION_MENUS() ;
#endif
int8_t encoderDiff; // updated from interrupt context and added to encoderPosition every LCD update int8_t encoderDiff; // updated from interrupt context and added to encoderPosition every LCD update
...@@ -91,9 +109,11 @@ static void lcd_status_screen(); ...@@ -91,9 +109,11 @@ static void lcd_status_screen();
static void lcd_control_temperature_preheat_gum_settings_menu(); static void lcd_control_temperature_preheat_gum_settings_menu();
static void lcd_control_motion_menu(); static void lcd_control_motion_menu();
static void lcd_control_volumetric_menu(); static void lcd_control_volumetric_menu();
#if HAS(LCD_CONTRAST) #if HAS(LCD_CONTRAST)
static void lcd_set_contrast(); static void lcd_set_contrast();
#endif #endif
#if ENABLED(FWRETRACT) #if ENABLED(FWRETRACT)
static void lcd_control_retract_menu(); static void lcd_control_retract_menu();
#endif #endif
...@@ -103,10 +123,10 @@ static void lcd_status_screen(); ...@@ -103,10 +123,10 @@ static void lcd_status_screen();
#elif !MECH(DELTA) && DISABLED(Z_SAFE_HOMING) && Z_HOME_DIR < 0 #elif !MECH(DELTA) && DISABLED(Z_SAFE_HOMING) && Z_HOME_DIR < 0
static void lcd_level_bed(); static void lcd_level_bed();
static void config_lcd_level_bed(); static void config_lcd_level_bed();
#endif // DELTA #endif // !DELTA
/* Different types of actions that can be used in menu items. */ /* Different types of actions that can be used in menu items. */
static void menu_action_back(menuFunc_t data); static void menu_action_back();
static void menu_action_submenu(menuFunc_t data); static void menu_action_submenu(menuFunc_t data);
static void menu_action_gcode(const char* pgcode); static void menu_action_gcode(const char* pgcode);
static void menu_action_function(menuFunc_t data); static void menu_action_function(menuFunc_t data);
...@@ -160,7 +180,8 @@ static void lcd_status_screen(); ...@@ -160,7 +180,8 @@ 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
*/ */
#if ENABLED(BTN_BACK) && BTN_BACK > 0 #if ENABLED(BTN_BACK) && BTN_BACK > 0
#define START_MENU(last_menu) do { \ #define START_MENU() do { \
ENCODER_DIRECTION_MENUS(); \
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; \
...@@ -170,12 +191,13 @@ static void lcd_status_screen(); ...@@ -170,12 +191,13 @@ static void lcd_status_screen();
bool wasBackClicked = LCD_BACK_CLICKED; \ bool wasBackClicked = LCD_BACK_CLICKED; \
if (wasBackClicked) { \ if (wasBackClicked) { \
lcd_quick_feedback(); \ lcd_quick_feedback(); \
menu_action_back( last_menu ); \ menu_action_back(); \
return; } \ 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 #else
#define START_MENU(last_menu) do { \ #define START_MENU() do { \
ENCODER_DIRECTION_MENUS(); \
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; \
...@@ -193,9 +215,9 @@ static void lcd_status_screen(); ...@@ -193,9 +215,9 @@ static void lcd_status_screen();
* menu_action_[type](arg3...) * menu_action_[type](arg3...)
* *
* Examples: * Examples:
* MENU_ITEM(back, MSG_WATCH, lcd_status_screen) * MENU_ITEM(back, MSG_WATCH)
* lcd_implementation_drawmenu_back(sel, row, PSTR(MSG_WATCH), lcd_status_screen) * lcd_implementation_drawmenu_back(sel, row, PSTR(MSG_WATCH))
* menu_action_back(lcd_status_screen) * menu_action_back()
* *
* MENU_ITEM(function, MSG_PAUSE_PRINT, lcd_sdcard_pause) * MENU_ITEM(function, MSG_PAUSE_PRINT, lcd_sdcard_pause)
* lcd_implementation_drawmenu_function(sel, row, PSTR(MSG_PAUSE_PRINT), lcd_sdcard_pause) * lcd_implementation_drawmenu_function(sel, row, PSTR(MSG_PAUSE_PRINT), lcd_sdcard_pause)
...@@ -207,19 +229,25 @@ static void lcd_status_screen(); ...@@ -207,19 +229,25 @@ static void lcd_status_screen();
* menu_action_setting_edit_int3(PSTR(MSG_SPEED), &feedrate_multiplier, 10, 999) * menu_action_setting_edit_int3(PSTR(MSG_SPEED), &feedrate_multiplier, 10, 999)
* *
*/ */
#define MENU_ITEM(type, label, args...) do { \ #define _MENU_ITEM_PART_1(type, label, args...) \
if (_menuItemNr == _lineNr) { \ if (_menuItemNr == _lineNr) { \
itemSelected = encoderLine == _menuItemNr; \ itemSelected = encoderLine == _menuItemNr; \
if (lcdDrawUpdate) \ if (lcdDrawUpdate) \
lcd_implementation_drawmenu_ ## type(itemSelected, _drawLineNr, PSTR(label), ## args); \ lcd_implementation_drawmenu_ ## type(itemSelected, _drawLineNr, PSTR(label), ## args); \
if (wasClicked && itemSelected) { \ if (wasClicked && itemSelected) { \
lcd_quick_feedback(); \ lcd_quick_feedback()
#define _MENU_ITEM_PART_2(type, args...) \
menu_action_ ## type(args); \ menu_action_ ## type(args); \
return; \ return; \
} \ } \
} \ } \
_menuItemNr++; \ _menuItemNr++
} while(0)
#define MENU_ITEM(type, label, args...) do { \
_MENU_ITEM_PART_1(type, label, ## args); \
_MENU_ITEM_PART_2(type, ## args); \
} while(0)
#if ENABLED(ENCODER_RATE_MULTIPLIER) #if ENABLED(ENCODER_RATE_MULTIPLIER)
...@@ -229,21 +257,13 @@ static void lcd_status_screen(); ...@@ -229,21 +257,13 @@ static void lcd_status_screen();
* 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
*/ */
#define MENU_MULTIPLIER_ITEM(type, label, args...) do { \ #define MENU_MULTIPLIER_ITEM(type, label, args...) do { \
if (_menuItemNr == _lineNr) { \ _MENU_ITEM_PART_1(type, label, ## args); \
itemSelected = encoderLine == _menuItemNr; \ encoderRateMultiplierEnabled = true; \
if (lcdDrawUpdate) \ lastEncoderMovementMillis = 0; \
lcd_implementation_drawmenu_ ## type(itemSelected, _drawLineNr, PSTR(label), ## args); \ _MENU_ITEM_PART_2(type, ## args); \
if (wasClicked && itemSelected) { \ } while(0)
lcd_quick_feedback(); \
encoderRateMultiplierEnabled = true; \ #endif // ENCODER_RATE_MULTIPLIER
lastEncoderMovementMillis = 0; \
menu_action_ ## type(args); \
return; \
} \
} \
_menuItemNr++; \
} while(0)
#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)
...@@ -251,13 +271,13 @@ static void lcd_status_screen(); ...@@ -251,13 +271,13 @@ static void lcd_status_screen();
#if ENABLED(ENCODER_RATE_MULTIPLIER) #if ENABLED(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 (encoderLine >= _menuItemNr) { encoderPosition = _menuItemNr * ENCODER_STEPS_PER_MENU_ITEM - 1; encoderLine = encoderPosition / ENCODER_STEPS_PER_MENU_ITEM; }\ if (encoderLine >= _menuItemNr) { encoderPosition = _menuItemNr * (ENCODER_STEPS_PER_MENU_ITEM) - 1; encoderLine = _menuItemNr - 1; }\
if (encoderLine >= currentMenuViewOffset + LCD_HEIGHT) { currentMenuViewOffset = encoderLine - LCD_HEIGHT + 1; lcdDrawUpdate = 1; _lineNr = currentMenuViewOffset - 1; _drawLineNr = -1; } \ if (encoderLine >= currentMenuViewOffset + LCD_HEIGHT) { currentMenuViewOffset = encoderLine - (LCD_HEIGHT) + 1; lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT; _lineNr = currentMenuViewOffset - 1; _drawLineNr = -1; } \
} } while(0) } } while(0)
/** Used variables to keep track of the menu */ /** Used variables to keep track of the menu */
...@@ -279,16 +299,34 @@ static void lcd_status_screen(); ...@@ -279,16 +299,34 @@ static void lcd_status_screen();
#endif // ULTIPANEL #endif // ULTIPANEL
typedef struct {
menuFunc_t menu_function;
#if ENABLED(ULTIPANEL)
uint32_t encoder_position;
#endif
} menuPosition;
menuFunc_t currentMenu = lcd_status_screen; /* function pointer to the currently active menu */ menuFunc_t currentMenu = lcd_status_screen; /* function pointer to the currently active menu */
menuPosition menu_history[10];
uint8_t menu_history_depth = 0;
millis_t next_lcd_update_ms; millis_t next_lcd_update_ms;
uint8_t lcd_status_update_delay; uint8_t lcd_status_update_delay;
bool ignore_click = false; bool ignore_click = false;
bool wait_for_unclick; bool wait_for_unclick;
uint8_t lcdDrawUpdate = 2; /* Set to none-zero when the LCD needs to draw, decreased after every draw. Set to 2 in LCD routines so the LCD gets at least 1 full redraw (first redraw is partial) */ bool defer_return_to_status = false;
enum LCDViewAction {
LCDVIEW_NONE,
LCDVIEW_REDRAW_NOW,
LCDVIEW_CALL_REDRAW_NEXT,
LCDVIEW_CLEAR_CALL_REDRAW,
LCDVIEW_CALL_NO_REDRAW
};
uint8_t lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; // Set when the LCD needs to draw, decrements after every draw. Set to 2 in LCD routines so the LCD gets at least 1 full redraw (first redraw is partial)
//prevMenu and prevEncoderPosition are used to store the previous menu location when editing settings.
menuFunc_t prevMenu = NULL;
uint16_t prevEncoderPosition;
//Variables used when editing values. //Variables used when editing values.
const char* editLabel; const char* editLabel;
void* editValue; void* editValue;
...@@ -300,21 +338,52 @@ float raw_Ki, raw_Kd; ...@@ -300,21 +338,52 @@ float raw_Ki, raw_Kd;
/** /**
* General function to go directly to a menu * General function to go directly to a menu
* Remembers the previous position
*/ */
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;
lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
#if ENABLED(NEWPANEL) #if ENABLED(NEWPANEL)
encoderPosition = encoder; encoderPosition = encoder;
if (feedback) lcd_quick_feedback(); if (feedback) lcd_quick_feedback();
#endif #endif
// For LCD_PROGRESS_BAR re-initialize the custom characters if (menu == lcd_status_screen) {
defer_return_to_status = false;
menu_history_depth = 0;
}
#if ENABLED(LCD_PROGRESS_BAR) #if ENABLED(LCD_PROGRESS_BAR)
// For LCD_PROGRESS_BAR re-initialize the custom characters
lcd_set_custom_characters(menu == lcd_status_screen); lcd_set_custom_characters(menu == lcd_status_screen);
#endif #endif
} }
} }
static void lcd_return_to_status() { lcd_goto_menu(lcd_status_screen); }
inline void lcd_save_previous_menu() {
if (menu_history_depth < COUNT(menu_history)) {
menu_history[menu_history_depth].menu_function = currentMenu;
#if ENABLED(ULTIPANEL)
menu_history[menu_history_depth].encoder_position = encoderPosition;
#endif
++menu_history_depth;
}
}
static void lcd_goto_previous_menu(bool feedback = false) {
if (menu_history_depth > 0) {
--menu_history_depth;
lcd_goto_menu(menu_history[menu_history_depth].menu_function, feedback
#if ENABLED(ULTIPANEL)
, menu_history[menu_history_depth].encoder_position
#endif
);
}
else
lcd_return_to_status();
}
/** /**
* *
* "Info Screen" * "Info Screen"
...@@ -323,12 +392,13 @@ static void lcd_goto_menu(menuFunc_t menu, const bool feedback = false, const ui ...@@ -323,12 +392,13 @@ static void lcd_goto_menu(menuFunc_t menu, const bool feedback = false, const ui
*/ */
static void lcd_status_screen() { static void lcd_status_screen() {
ENCODER_DIRECTION_NORMAL();
encoderRateMultiplierEnabled = false; encoderRateMultiplierEnabled = false;
#if ENABLED(LCD_PROGRESS_BAR) #if ENABLED(LCD_PROGRESS_BAR)
millis_t ms = millis(); millis_t ms = millis();
#if DISABLED(PROGRESS_MSG_ONCE) #if DISABLED(PROGRESS_MSG_ONCE)
if (ms > progress_bar_ms + PROGRESS_BAR_MSG_TIME + PROGRESS_BAR_BAR_TIME) { if (ELAPSED(ms, progress_bar_ms + PROGRESS_BAR_MSG_TIME + PROGRESS_BAR_BAR_TIME)) {
progress_bar_ms = ms; progress_bar_ms = ms;
} }
#endif #endif
...@@ -406,24 +476,24 @@ static void lcd_status_screen() { ...@@ -406,24 +476,24 @@ static void lcd_status_screen() {
} }
#if ENABLED(ULTIPANEL_FEEDMULTIPLY) #if ENABLED(ULTIPANEL_FEEDMULTIPLY)
int new_frm = feedrate_multiplier + (int32_t)encoderPosition;
// Dead zone at 100% feedrate // Dead zone at 100% feedrate
if ((feedrate_multiplier < 100 && (feedrate_multiplier + int(encoderPosition)) > 100) || if ((feedrate_multiplier < 100 && new_frm > 100) || (feedrate_multiplier > 100 && new_frm < 100)) {
(feedrate_multiplier > 100 && (feedrate_multiplier + int(encoderPosition)) < 100)) {
encoderPosition = 0;
feedrate_multiplier = 100; feedrate_multiplier = 100;
encoderPosition = 0;
} }
if (feedrate_multiplier == 100) { else if (feedrate_multiplier == 100) {
if (int(encoderPosition) > ENCODER_FEEDRATE_DEADZONE) { if ((int32_t)encoderPosition > ENCODER_FEEDRATE_DEADZONE) {
feedrate_multiplier += int(encoderPosition) - ENCODER_FEEDRATE_DEADZONE; feedrate_multiplier += (int32_t)encoderPosition - (ENCODER_FEEDRATE_DEADZONE);
encoderPosition = 0; encoderPosition = 0;
} }
else if (int(encoderPosition) < -ENCODER_FEEDRATE_DEADZONE) { else if ((int32_t)encoderPosition < -(ENCODER_FEEDRATE_DEADZONE)) {
feedrate_multiplier += int(encoderPosition) + ENCODER_FEEDRATE_DEADZONE; feedrate_multiplier += (int32_t)encoderPosition + ENCODER_FEEDRATE_DEADZONE;
encoderPosition = 0; encoderPosition = 0;
} }
} }
else { else {
feedrate_multiplier += int(encoderPosition); feedrate_multiplier = new_frm;
encoderPosition = 0; encoderPosition = 0;
} }
#endif // ULTIPANEL_FEEDMULTIPLY #endif // ULTIPANEL_FEEDMULTIPLY
...@@ -435,7 +505,14 @@ static void lcd_status_screen() { ...@@ -435,7 +505,14 @@ static void lcd_status_screen() {
#if ENABLED(ULTIPANEL) #if ENABLED(ULTIPANEL)
static void lcd_return_to_status() { lcd_goto_menu(lcd_status_screen); } inline void line_to_current(AxisEnum axis) {
#if MECH(DELTA)
calculate_delta(current_position);
plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS], manual_feedrate[axis]/60, active_extruder, active_driver);
#else
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], manual_feedrate[axis]/60, active_extruder, active_driver);
#endif
}
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
...@@ -461,8 +538,8 @@ static void lcd_return_to_status() { lcd_goto_menu(lcd_status_screen); } ...@@ -461,8 +538,8 @@ static void lcd_return_to_status() { lcd_goto_menu(lcd_status_screen); }
*/ */
static void lcd_main_menu() { static void lcd_main_menu() {
START_MENU(lcd_status_screen); START_MENU();
MENU_ITEM(back, MSG_WATCH, lcd_status_screen); MENU_ITEM(back, MSG_WATCH);
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);
} }
...@@ -474,6 +551,7 @@ static void lcd_main_menu() { ...@@ -474,6 +551,7 @@ static void lcd_main_menu() {
} }
MENU_ITEM(submenu, MSG_CONTROL, lcd_control_menu); MENU_ITEM(submenu, MSG_CONTROL, lcd_control_menu);
MENU_ITEM(submenu, MSG_STATS, lcd_stats_menu); MENU_ITEM(submenu, MSG_STATS, lcd_stats_menu);
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
if (card.cardOK) { if (card.cardOK) {
if (card.isFileOpen()) { if (card.isFileOpen()) {
...@@ -507,6 +585,12 @@ static void lcd_main_menu() { ...@@ -507,6 +585,12 @@ static void lcd_main_menu() {
} }
#endif #endif
/**
*
* "Tune" submenu items
*
*/
/** /**
* Set the home offset based on the current_position * Set the home offset based on the current_position
*/ */
...@@ -518,18 +602,53 @@ void lcd_set_home_offsets() { ...@@ -518,18 +602,53 @@ void lcd_set_home_offsets() {
#if ENABLED(BABYSTEPPING) #if ENABLED(BABYSTEPPING)
static void _lcd_babystep(int axis, const char* msg) { int babysteps_done = 0;
if (encoderPosition != 0) {
babystepsTodo[axis] += BABYSTEP_MULTIPLICATOR * (int)encoderPosition; static void _lcd_babystep(const int axis, const char* msg) {
ENCODER_DIRECTION_NORMAL();
if (encoderPosition) {
int distance = (int32_t)encoderPosition * BABYSTEP_MULTIPLICATOR;
encoderPosition = 0; encoderPosition = 0;
lcdDrawUpdate = 1; lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
#if MECH(COREXY) || MECH(COREYX)|| MECH(COREXZ) || MECH(COREZX)
#if ENABLED(BABYSTEP_XY)
switch(axis) {
case X_AXIS: // X on CoreXY, Core YX, CoreXZ and CoreZZ
babystepsTodo[A_AXIS] += distance * 2;
babystepsTodo[CORE_AXIS_2] += distance * 2;
break;
case CORE_AXIS_2: // Y on CoreXY and CoreYX, Z on CoreXZ and CoreZX
babystepsTodo[A_AXIS] += distance * 2;
babystepsTodo[CORE_AXIS_2] -= distance * 2;
break;
case CORE_AXIS_3: // Z on CoreXY and CoreYX, Y on CoreXZ and CoreZX
babystepsTodo[CORE_AXIS_3] += distance;
break;
}
#elif MECH(COREXZ) || MECH(COREZX)
babystepsTodo[A_AXIS] += distance * 2;
babystepsTodo[C_AXIS] -= distance * 2;
#else
babystepsTodo[Z_AXIS] += distance;
#endif
#else
babystepsTodo[axis] += distance;
#endif
babysteps_done += distance;
} }
if (lcdDrawUpdate) lcd_implementation_drawedit(msg, (char*)""); if (lcdDrawUpdate) lcd_implementation_drawedit(msg, itostr3sign(babysteps_done));
if (LCD_CLICKED) lcd_goto_menu(lcd_tune_menu); if (LCD_CLICKED) lcd_goto_previous_menu(true);
} }
static void lcd_babystep_x() { _lcd_babystep(X_AXIS, PSTR(MSG_BABYSTEPPING_X)); }
static void lcd_babystep_y() { _lcd_babystep(Y_AXIS, PSTR(MSG_BABYSTEPPING_Y)); } #if ENABLED(BABYSTEP_XY)
static void lcd_babystep_z() { _lcd_babystep(Z_AXIS, PSTR(MSG_BABYSTEPPING_Z)); } static void _lcd_babystep_x() { _lcd_babystep(X_AXIS, PSTR(MSG_BABYSTEPPING_X)); }
static void _lcd_babystep_y() { _lcd_babystep(Y_AXIS, PSTR(MSG_BABYSTEPPING_Y)); }
static void lcd_babystep_x() { babysteps_done = 0; lcd_goto_menu(_lcd_babystep_x); }
static void lcd_babystep_y() { babysteps_done = 0; lcd_goto_menu(_lcd_babystep_y); }
#endif
static void _lcd_babystep_z() { _lcd_babystep(Z_AXIS, PSTR(MSG_BABYSTEPPING_Z)); }
static void lcd_babystep_z() { babysteps_done = 0; lcd_goto_menu(_lcd_babystep_z); }
#endif // BABYSTEPPING #endif // BABYSTEPPING
...@@ -578,12 +697,12 @@ static void lcd_tune_fixstep() { ...@@ -578,12 +697,12 @@ static void lcd_tune_fixstep() {
* *
*/ */
static void lcd_tune_menu() { static void lcd_tune_menu() {
START_MENU(lcd_main_menu); START_MENU();
// //
// ^ Main // ^ Main
// //
MENU_ITEM(back, MSG_MAIN, lcd_main_menu); MENU_ITEM(back, MSG_MAIN);
// //
// Speed: // Speed:
...@@ -702,6 +821,8 @@ void _lcd_preheat(int endnum, const float temph, const float tempb, const int fa ...@@ -702,6 +821,8 @@ void _lcd_preheat(int endnum, const float temph, const float tempb, const int fa
if (temph > 0) setTargetHotend(temph, endnum); if (temph > 0) setTargetHotend(temph, endnum);
#if TEMP_SENSOR_BED != 0 #if TEMP_SENSOR_BED != 0
setTargetBed(tempb); setTargetBed(tempb);
#else
UNUSED(tempb);
#endif #endif
fanSpeed = fan; fanSpeed = fan;
lcd_return_to_status(); lcd_return_to_status();
...@@ -758,8 +879,8 @@ void _lcd_preheat(int endnum, const float temph, const float tempb, const int fa ...@@ -758,8 +879,8 @@ void _lcd_preheat(int endnum, const float temph, const float tempb, const int fa
#if TEMP_SENSOR_0 != 0 && (TEMP_SENSOR_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_3 != 0 || TEMP_SENSOR_BED != 0) #if TEMP_SENSOR_0 != 0 && (TEMP_SENSOR_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_3 != 0 || TEMP_SENSOR_BED != 0)
static void lcd_preheat_pla_menu() { static void lcd_preheat_pla_menu() {
START_MENU(lcd_prepare_menu); START_MENU();
MENU_ITEM(back, MSG_PREPARE, lcd_prepare_menu); MENU_ITEM(back, MSG_PREPARE);
#if HOTENDS == 1 #if HOTENDS == 1
MENU_ITEM(function, MSG_PREHEAT_PLA, lcd_preheat_pla0); MENU_ITEM(function, MSG_PREHEAT_PLA, lcd_preheat_pla0);
#else #else
...@@ -780,8 +901,8 @@ void _lcd_preheat(int endnum, const float temph, const float tempb, const int fa ...@@ -780,8 +901,8 @@ void _lcd_preheat(int endnum, const float temph, const float tempb, const int fa
} }
static void lcd_preheat_abs_menu() { static void lcd_preheat_abs_menu() {
START_MENU(lcd_prepare_menu); START_MENU();
MENU_ITEM(back, MSG_TEMPERATURE, lcd_prepare_menu); MENU_ITEM(back, MSG_TEMPERATURE);
#if HOTENDS == 1 #if HOTENDS == 1
MENU_ITEM(function, MSG_PREHEAT_ABS, lcd_preheat_abs0); MENU_ITEM(function, MSG_PREHEAT_ABS, lcd_preheat_abs0);
#else #else
...@@ -802,8 +923,8 @@ void _lcd_preheat(int endnum, const float temph, const float tempb, const int fa ...@@ -802,8 +923,8 @@ void _lcd_preheat(int endnum, const float temph, const float tempb, const int fa
} }
static void lcd_preheat_gum_menu() { static void lcd_preheat_gum_menu() {
START_MENU(lcd_prepare_menu); START_MENU();
MENU_ITEM(back, MSG_TEMPERATURE, lcd_prepare_menu); MENU_ITEM(back, MSG_TEMPERATURE);
#if HOTENDS == 1 #if HOTENDS == 1
MENU_ITEM(function, MSG_PREHEAT_GUM, lcd_preheat_gum0); MENU_ITEM(function, MSG_PREHEAT_GUM, lcd_preheat_gum0);
#else #else
...@@ -838,12 +959,12 @@ void lcd_cooldown() { ...@@ -838,12 +959,12 @@ void lcd_cooldown() {
*/ */
static void lcd_prepare_menu() { static void lcd_prepare_menu() {
START_MENU(lcd_main_menu); START_MENU();
// //
// ^ Main // ^ Main
// //
MENU_ITEM(back, MSG_MAIN, lcd_main_menu); MENU_ITEM(back, MSG_MAIN);
// //
// Auto Home // Auto Home
...@@ -860,8 +981,9 @@ static void lcd_prepare_menu() { ...@@ -860,8 +981,9 @@ static void lcd_prepare_menu() {
// Level Bed // Level Bed
// //
#if ENABLED(AUTO_BED_LEVELING_FEATURE) #if ENABLED(AUTO_BED_LEVELING_FEATURE)
if (axis_known_position & (_BV(X_AXIS)|_BV(Y_AXIS)) == (_BV(X_AXIS)|_BV(Y_AXIS))) MENU_ITEM(gcode, MSG_LEVEL_BED,
MENU_ITEM(gcode, MSG_LEVEL_BED, PSTR("G29")); axis_homed[X_AXIS] && axis_homed[Y_AXIS] ? PSTR("G29") : PSTR("G28\nG29")
);
#elif !MECH(DELTA) && DISABLED(Z_SAFE_HOMING) && Z_HOME_DIR < 0 #elif !MECH(DELTA) && DISABLED(Z_SAFE_HOMING) && Z_HOME_DIR < 0
MENU_ITEM(submenu, MSG_MBL_SETTING, config_lcd_level_bed); MENU_ITEM(submenu, MSG_MBL_SETTING, config_lcd_level_bed);
#endif #endif
...@@ -944,8 +1066,8 @@ static void lcd_prepare_menu() { ...@@ -944,8 +1066,8 @@ static void lcd_prepare_menu() {
#if MECH(DELTA) #if MECH(DELTA)
static void lcd_delta_calibrate_menu() { static void lcd_delta_calibrate_menu() {
START_MENU(lcd_main_menu); START_MENU();
MENU_ITEM(back, MSG_MAIN, lcd_main_menu); MENU_ITEM(back, MSG_MAIN);
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"));
MENU_ITEM(gcode, MSG_DELTA_CALIBRATE_Y, PSTR("G0 F8000 X77.94 Y-45 Z0")); MENU_ITEM(gcode, MSG_DELTA_CALIBRATE_Y, PSTR("G0 F8000 X77.94 Y-45 Z0"));
...@@ -956,15 +1078,6 @@ static void lcd_prepare_menu() { ...@@ -956,15 +1078,6 @@ static void lcd_prepare_menu() {
#endif // DELTA #endif // DELTA
inline void line_to_current(float feedrate) {
#if MECH(DELTA)
calculate_delta(current_position);
plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], current_position[E_AXIS], feedrate/60, active_extruder, active_driver);
#else
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate/60, active_extruder, active_driver);
#endif
}
/** /**
* *
* "Prepare" > "Move Axis" submenu * "Prepare" > "Move Axis" submenu
...@@ -972,20 +1085,21 @@ inline void line_to_current(float feedrate) { ...@@ -972,20 +1085,21 @@ inline void line_to_current(float feedrate) {
*/ */
float move_menu_scale; float move_menu_scale;
static void lcd_move_menu_axis();
static void _lcd_move(const char* name, AxisEnum axis, int min, int max) { static void _lcd_move(const char* name, AxisEnum axis, int min, int max) {
ENCODER_DIRECTION_NORMAL();
if (encoderPosition != 0) { if (encoderPosition != 0) {
refresh_cmd_timeout(); refresh_cmd_timeout();
current_position[axis] += float((int)encoderPosition) * move_menu_scale; current_position[axis] += float((int)encoderPosition) * move_menu_scale;
if (SOFTWARE_MIN_ENDSTOPS) NOLESS(current_position[axis], min); if (SOFTWARE_MIN_ENDSTOPS) NOLESS(current_position[axis], min);
if (SOFTWARE_MAX_ENDSTOPS) NOMORE(current_position[axis], max); if (SOFTWARE_MAX_ENDSTOPS) NOMORE(current_position[axis], max);
encoderPosition = 0; encoderPosition = 0;
line_to_current(manual_feedrate[axis]); line_to_current(axis);
lcdDrawUpdate = 1; lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
} }
encoderPosition = 0;
if (lcdDrawUpdate) lcd_implementation_drawedit(name, ftostr31(current_position[axis])); if (lcdDrawUpdate) lcd_implementation_drawedit(name, ftostr31(current_position[axis]));
if (LCD_CLICKED) lcd_goto_menu(lcd_move_menu_axis); if (LCD_CLICKED) lcd_goto_previous_menu(true);
} }
#if MECH(DELTA) #if MECH(DELTA)
...@@ -1003,6 +1117,7 @@ static void lcd_move_e( ...@@ -1003,6 +1117,7 @@ static void lcd_move_e(
uint8_t e uint8_t e
#endif #endif
) { ) {
ENCODER_DIRECTION_NORMAL();
#if EXTRUDERS > 1 #if EXTRUDERS > 1
unsigned short original_active_extruder = active_extruder; unsigned short original_active_extruder = active_extruder;
active_extruder = e; active_extruder = e;
...@@ -1012,10 +1127,10 @@ static void lcd_move_e( ...@@ -1012,10 +1127,10 @@ static void lcd_move_e(
IDLE_OOZING_retract(false); IDLE_OOZING_retract(false);
#endif #endif
current_position[E_AXIS] += float((int)encoderPosition) * move_menu_scale; current_position[E_AXIS] += float((int)encoderPosition) * move_menu_scale;
encoderPosition = 0; line_to_current(E_AXIS);
line_to_current(manual_feedrate[E_AXIS]); lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
lcdDrawUpdate = 1;
} }
encoderPosition = 0;
if (lcdDrawUpdate) { if (lcdDrawUpdate) {
PGM_P pos_label; PGM_P pos_label;
#if EXTRUDERS == 1 #if EXTRUDERS == 1
...@@ -1034,7 +1149,7 @@ static void lcd_move_e( ...@@ -1034,7 +1149,7 @@ static void lcd_move_e(
#endif // EXTRUDERS > 1 #endif // EXTRUDERS > 1
lcd_implementation_drawedit(pos_label, ftostr31(current_position[E_AXIS])); lcd_implementation_drawedit(pos_label, ftostr31(current_position[E_AXIS]));
} }
if (LCD_CLICKED) lcd_goto_menu(lcd_move_menu_axis); if (LCD_CLICKED) lcd_goto_previous_menu(true);
#if EXTRUDERS > 1 #if EXTRUDERS > 1
active_extruder = original_active_extruder; active_extruder = original_active_extruder;
#endif #endif
...@@ -1056,12 +1171,22 @@ static void lcd_move_e( ...@@ -1056,12 +1171,22 @@ static void lcd_move_e(
* "Prepare" > "Move Xmm" > "Move XYZ" submenu * "Prepare" > "Move Xmm" > "Move XYZ" submenu
* *
*/ */
#if MECH(DELTA) || MECH(SCARA)
#define _MOVE_XYZ_ALLOWED (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS])
#else
#define _MOVE_XYZ_ALLOWED true
#endif
static void lcd_move_menu_axis() { static void lcd_move_menu_axis() {
START_MENU(lcd_move_menu); START_MENU();
MENU_ITEM(back, MSG_MOVE_AXIS, lcd_move_menu); MENU_ITEM(back, MSG_MOVE_AXIS);
MENU_ITEM(submenu, MSG_MOVE_X, lcd_move_x);
MENU_ITEM(submenu, MSG_MOVE_Y, lcd_move_y); if (_MOVE_XYZ_ALLOWED) {
MENU_ITEM(submenu, MSG_MOVE_Z, lcd_move_z); MENU_ITEM(submenu, MSG_MOVE_X, lcd_move_x);
MENU_ITEM(submenu, MSG_MOVE_Y, lcd_move_y);
MENU_ITEM(submenu, MSG_MOVE_Z, lcd_move_z);
}
if (move_menu_scale < 10.0) { if (move_menu_scale < 10.0) {
#if EXTRUDERS == 1 #if EXTRUDERS == 1
MENU_ITEM(submenu, MSG_MOVE_E, lcd_move_e); MENU_ITEM(submenu, MSG_MOVE_E, lcd_move_e);
...@@ -1099,9 +1224,12 @@ static void lcd_move_menu_01mm() { ...@@ -1099,9 +1224,12 @@ static void lcd_move_menu_01mm() {
*/ */
static void lcd_move_menu() { static void lcd_move_menu() {
START_MENU(lcd_prepare_menu); START_MENU();
MENU_ITEM(back, MSG_MOTION, lcd_prepare_menu); MENU_ITEM(back, MSG_PREPARE);
MENU_ITEM(submenu, MSG_MOVE_10MM, lcd_move_menu_10mm);
if (_MOVE_XYZ_ALLOWED)
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);
MENU_ITEM(submenu, MSG_MOVE_01MM, lcd_move_menu_01mm); MENU_ITEM(submenu, MSG_MOVE_01MM, lcd_move_menu_01mm);
// TODO:X,Y,Z,E // TODO:X,Y,Z,E
...@@ -1115,8 +1243,8 @@ static void lcd_move_menu() { ...@@ -1115,8 +1243,8 @@ static void lcd_move_menu() {
*/ */
static void lcd_control_menu() { static void lcd_control_menu() {
START_MENU(lcd_main_menu); START_MENU();
MENU_ITEM(back, MSG_MAIN, lcd_main_menu); MENU_ITEM(back, MSG_MAIN);
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);
MENU_ITEM(submenu, MSG_FILAMENT, lcd_control_volumetric_menu); MENU_ITEM(submenu, MSG_FILAMENT, lcd_control_volumetric_menu);
...@@ -1167,6 +1295,33 @@ static void lcd_stats_menu() { ...@@ -1167,6 +1295,33 @@ static void lcd_stats_menu() {
* *
*/ */
#if ENABLED(PID_AUTOTUNE_MENU)
#if ENABLED(PIDTEMP)
int autotune_temp[HOTENDS] = { 150 };
const int heater_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP);
#endif
#if ENABLED(PIDTEMPBED)
int autotune_temp_bed = 70;
#endif
static void _lcd_autotune(int h) {
char cmd[30];
sprintf_P(cmd, PSTR("M303 U1 H%i S%i"), h,
#if HAS_PID_FOR_BOTH
h < 0 ? autotune_temp_bed : autotune_temp[h]
#elif ENABLED(PIDTEMPBED)
autotune_temp_bed
#else
autotune_temp[h]
#endif
);
enqueue_and_echo_command(cmd);
}
#endif //PID_AUTOTUNE_MENU
#if ENABLED(PIDTEMP) #if ENABLED(PIDTEMP)
// Helpers for editing PID Ki & Kd values // Helpers for editing PID Ki & Kd values
...@@ -1179,16 +1334,25 @@ static void lcd_stats_menu() { ...@@ -1179,16 +1334,25 @@ static void lcd_stats_menu() {
PID_PARAM(Kd, h) = scalePID_d(raw_Kd); PID_PARAM(Kd, h) = scalePID_d(raw_Kd);
updatePID(); updatePID();
} }
#define COPY_AND_SCALE(hindex) \ #define _PIDTEMP_BASE_FUNCTIONS(hindex) \
void copy_and_scalePID_i_H ## hindex() { copy_and_scalePID_i(hindex); } \ void copy_and_scalePID_i_H ## hindex() { copy_and_scalePID_i(hindex); } \
void copy_and_scalePID_d_H ## hindex() { copy_and_scalePID_d(hindex); } void copy_and_scalePID_d_H ## hindex() { copy_and_scalePID_d(hindex); }
COPY_AND_SCALE(0);
#if ENABLED(PID_AUTOTUNE_MENU)
#define _PIDTEMP_FUNCTIONS(hindex) \
_PIDTEMP_BASE_FUNCTIONS(hindex); \
void lcd_autotune_callback_H ## hindex() { _lcd_autotune(hindex); }
#else
#define _PIDTEMP_FUNCTIONS(hindex) _PIDTEMP_BASE_FUNCTIONS(hindex)
#endif
_PIDTEMP_FUNCTIONS(0);
#if HOTENDS > 1 #if HOTENDS > 1
COPY_AND_SCALE(1); _PIDTEMP_FUNCTIONS(1);
#if HOTENDS > 2 #if HOTENDS > 2
COPY_AND_SCALE(2); _PIDTEMP_FUNCTIONS(2);
#if HOTENDS > 3 #if HOTENDS > 3
COPY_AND_SCALE(3); _PIDTEMP_FUNCTIONS(3);
#endif // HOTENDS > 3 #endif // HOTENDS > 3
#endif // HOTENDS > 2 #endif // HOTENDS > 2
#endif // HOTENDS > 1 #endif // HOTENDS > 1
...@@ -1201,12 +1365,12 @@ static void lcd_stats_menu() { ...@@ -1201,12 +1365,12 @@ static void lcd_stats_menu() {
* *
*/ */
static void lcd_control_temperature_menu() { static void lcd_control_temperature_menu() {
START_MENU(lcd_control_menu); START_MENU();
// //
// ^ Control // ^ Control
// //
MENU_ITEM(back, MSG_CONTROL, lcd_control_menu); MENU_ITEM(back, MSG_CONTROL);
// //
// Nozzle: // Nozzle:
...@@ -1257,40 +1421,43 @@ static void lcd_control_temperature_menu() { ...@@ -1257,40 +1421,43 @@ static void lcd_control_temperature_menu() {
#endif #endif
// //
// PID-P, PID-I, PID-D // PID-P, PID-I, PID-D, PID-C, PID Autotune
// PID-P H1, PID-I H1, PID-D H1, PID-C H1, PID Autotune H1
// PID-P H2, PID-I H2, PID-D H2, PID-C H2, PID Autotune H2
// PID-P H3, PID-I H3, PID-D H3, PID-C H3, PID Autotune H3
// PID-P H4, PID-I H4, PID-D H4, PID-C H4, PID Autotune H4
// //
#if ENABLED(PIDTEMP) #if ENABLED(PIDTEMP)
// set up temp variables - undo the default scaling #define _PID_BASE_MENU_ITEMS(HLABEL, hindex) \
raw_Ki = unscalePID_i(PID_PARAM(Ki, 0)); raw_Ki = unscalePID_i(PID_PARAM(Ki, hindex)); \
raw_Kd = unscalePID_d(PID_PARAM(Kd, 0)); raw_Kd = unscalePID_d(PID_PARAM(Kd, hindex)); \
MENU_ITEM_EDIT(float52, MSG_PID_P, &PID_PARAM(Kp,0), 1, 9990); MENU_ITEM_EDIT(float52, MSG_PID_P HLABEL, &PID_PARAM(Kp, hindex), 1, 9990); \
// i is typically a small value so allows values below 1 MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_I HLABEL, &raw_Ki, 0.01, 9990, copy_and_scalePID_i_H ## hindex); \
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_I, &raw_Ki, 0.01, 9990, copy_and_scalePID_i_H0); MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D HLABEL, &raw_Kd, 1, 9990, copy_and_scalePID_d_H ## hindex)
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D, &raw_Kd, 1, 9990, copy_and_scalePID_d_H0);
#if ENABLED(PID_ADD_EXTRUSION_RATE)
#define _PID_MENU_ITEMS(HLABEL, hindex) \
_PID_BASE_MENU_ITEMS(HLABEL, hindex); \
MENU_ITEM_EDIT(float3, MSG_PID_C HLABEL, &PID_PARAM(Kc, hindex), 1, 9990)
#else
#define _PID_MENU_ITEMS(HLABEL, hindex) _PID_BASE_MENU_ITEMS(HLABEL, hindex)
#endif
#if ENABLED(PID_AUTOTUNE_MENU)
#define PID_MENU_ITEMS(HLABEL, hindex) \
_PID_MENU_ITEMS(HLABEL, hindex); \
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, SERIAL_PID_AUTOTUNE HLABEL, &autotune_temp[hindex], 150, heater_maxtemp[hindex] - 15, lcd_autotune_callback_H ## hindex)
#else
#define PID_MENU_ITEMS(HLABEL, hindex) _PID_MENU_ITEMS(HLABEL, hindex)
#endif
PID_MENU_ITEMS("", 0);
#if HOTENDS > 1 #if HOTENDS > 1
// set up temp variables - undo the default scaling PID_MENU_ITEMS(MSG_H1, 1);
raw_Ki = unscalePID_i(PID_PARAM(Ki, 1));
raw_Kd = unscalePID_d(PID_PARAM(Kd, 1));
MENU_ITEM_EDIT(float52, MSG_PID_P MSG_H1, &PID_PARAM(Kp,1), 1, 9990);
// i is typically a small value so allows values below 1
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_I MSG_H1, &raw_Ki, 0.01, 9990, copy_and_scalePID_i_H1);
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D MSG_H1, &raw_Kd, 1, 9990, copy_and_scalePID_d_H1);
#if HOTENDS > 2 #if HOTENDS > 2
// set up temp variables - undo the default scaling PID_MENU_ITEMS(MSG_H2, 2);
raw_Ki = unscalePID_i(PID_PARAM(Ki, 2));
raw_Kd = unscalePID_d(PID_PARAM(Kd, 2));
MENU_ITEM_EDIT(float52, MSG_PID_P MSG_H2, &PID_PARAM(Kp,2), 1, 9990);
// i is typically a small value so allows values below 1
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_I MSG_H2, &raw_Ki, 0.01, 9990, copy_and_scalePID_i_H2);
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D MSG_H2, &raw_Kd, 1, 9990, copy_and_scalePID_d_H2);
#if HOTENDS > 3 #if HOTENDS > 3
// set up temp variables - undo the default scaling PID_MENU_ITEMS(MSG_H3, 3);
raw_Ki = unscalePID_i(PID_PARAM(Ki, 3));
raw_Kd = unscalePID_d(PID_PARAM(Kd, 3));
MENU_ITEM_EDIT(float52, MSG_PID_P MSG_H3, &PID_PARAM(Kp,3), 1, 9990);
// i is typically a small value so allows values below 1
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_I MSG_H3, &raw_Ki, 0.01, 9990, copy_and_scalePID_i_H3);
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D MSG_H3, &raw_Kd, 1, 9990, copy_and_scalePID_d_H3);
#endif // HOTENDS > 3 #endif // HOTENDS > 3
#endif // HOTENDS > 2 #endif // HOTENDS > 2
#endif // HOTENDS > 1 #endif // HOTENDS > 1
...@@ -1326,8 +1493,8 @@ static void lcd_control_temperature_menu() { ...@@ -1326,8 +1493,8 @@ static void lcd_control_temperature_menu() {
* *
*/ */
static void lcd_control_temperature_preheat_pla_settings_menu() { static void lcd_control_temperature_preheat_pla_settings_menu() {
START_MENU(lcd_control_temperature_menu); START_MENU();
MENU_ITEM(back, MSG_TEMPERATURE, lcd_control_temperature_menu); MENU_ITEM(back, MSG_TEMPERATURE);
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, HEATER_0_MINTEMP, HEATER_0_MAXTEMP - 15); MENU_ITEM_EDIT(int3, MSG_NOZZLE, &plaPreheatHotendTemp, HEATER_0_MINTEMP, HEATER_0_MAXTEMP - 15);
...@@ -1347,8 +1514,8 @@ static void lcd_control_temperature_preheat_pla_settings_menu() { ...@@ -1347,8 +1514,8 @@ static void lcd_control_temperature_preheat_pla_settings_menu() {
* *
*/ */
static void lcd_control_temperature_preheat_abs_settings_menu() { static void lcd_control_temperature_preheat_abs_settings_menu() {
START_MENU(lcd_control_temperature_menu); START_MENU();
MENU_ITEM(back, MSG_TEMPERATURE, lcd_control_temperature_menu); MENU_ITEM(back, MSG_TEMPERATURE);
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, HEATER_0_MINTEMP, HEATER_0_MAXTEMP - 15); MENU_ITEM_EDIT(int3, MSG_NOZZLE, &absPreheatHotendTemp, HEATER_0_MINTEMP, HEATER_0_MAXTEMP - 15);
...@@ -1368,8 +1535,8 @@ static void lcd_control_temperature_preheat_abs_settings_menu() { ...@@ -1368,8 +1535,8 @@ static void lcd_control_temperature_preheat_abs_settings_menu() {
* *
*/ */
static void lcd_control_temperature_preheat_gum_settings_menu() { static void lcd_control_temperature_preheat_gum_settings_menu() {
START_MENU(lcd_control_temperature_menu); START_MENU();
MENU_ITEM(back, MSG_TEMPERATURE, lcd_control_temperature_menu); MENU_ITEM(back, MSG_TEMPERATURE);
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, HEATER_0_MINTEMP, HEATER_0_MAXTEMP - 15); MENU_ITEM_EDIT(int3, MSG_NOZZLE, &gumPreheatHotendTemp, HEATER_0_MINTEMP, HEATER_0_MAXTEMP - 15);
...@@ -1389,8 +1556,8 @@ static void lcd_control_temperature_preheat_gum_settings_menu() { ...@@ -1389,8 +1556,8 @@ static void lcd_control_temperature_preheat_gum_settings_menu() {
* *
*/ */
static void lcd_control_motion_menu() { static void lcd_control_motion_menu() {
START_MENU(lcd_control_menu); START_MENU();
MENU_ITEM(back, MSG_CONTROL, lcd_control_menu); MENU_ITEM(back, MSG_CONTROL);
#if ENABLED(AUTO_BED_LEVELING_FEATURE) #if ENABLED(AUTO_BED_LEVELING_FEATURE)
MENU_ITEM_EDIT(float32, MSG_ZPROBE_ZOFFSET, &zprobe_zoffset, -50, 50); MENU_ITEM_EDIT(float32, MSG_ZPROBE_ZOFFSET, &zprobe_zoffset, -50, 50);
#endif #endif
...@@ -1454,8 +1621,8 @@ static void lcd_control_motion_menu() { ...@@ -1454,8 +1621,8 @@ static void lcd_control_motion_menu() {
* *
*/ */
static void lcd_control_volumetric_menu() { static void lcd_control_volumetric_menu() {
START_MENU(lcd_control_menu); START_MENU();
MENU_ITEM(back, MSG_CONTROL, lcd_control_menu); MENU_ITEM(back, MSG_CONTROL);
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);
...@@ -1484,6 +1651,7 @@ static void lcd_control_volumetric_menu() { ...@@ -1484,6 +1651,7 @@ static void lcd_control_volumetric_menu() {
*/ */
#if HAS(LCD_CONTRAST) #if HAS(LCD_CONTRAST)
static void lcd_set_contrast() { static void lcd_set_contrast() {
ENCODER_DIRECTION_NORMAL();
if (encoderPosition != 0) { if (encoderPosition != 0) {
#if ENABLED(U8GLIB_LM6059_AF) #if ENABLED(U8GLIB_LM6059_AF)
lcd_contrast += encoderPosition; lcd_contrast += encoderPosition;
...@@ -1503,7 +1671,7 @@ static void lcd_control_volumetric_menu() { ...@@ -1503,7 +1671,7 @@ static void lcd_control_volumetric_menu() {
lcd_implementation_drawedit(PSTR(MSG_CONTRAST), itostr2(lcd_contrast)); lcd_implementation_drawedit(PSTR(MSG_CONTRAST), itostr2(lcd_contrast));
#endif #endif
} }
if (LCD_CLICKED) lcd_goto_menu(lcd_control_menu); if (LCD_CLICKED) lcd_goto_previous_menu(true);
} }
#endif // HAS(LCD_CONTRAST) #endif // HAS(LCD_CONTRAST)
...@@ -1514,8 +1682,8 @@ static void lcd_control_volumetric_menu() { ...@@ -1514,8 +1682,8 @@ static void lcd_control_volumetric_menu() {
*/ */
#if ENABLED(FWRETRACT) #if ENABLED(FWRETRACT)
static void lcd_control_retract_menu() { static void lcd_control_retract_menu() {
START_MENU(lcd_control_menu); START_MENU();
MENU_ITEM(back, MSG_CONTROL, lcd_control_menu); MENU_ITEM(back, MSG_CONTROL);
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);
#if EXTRUDERS > 1 #if EXTRUDERS > 1
...@@ -1554,8 +1722,8 @@ static void lcd_control_volumetric_menu() { ...@@ -1554,8 +1722,8 @@ static void lcd_control_volumetric_menu() {
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(lcd_main_menu); START_MENU();
MENU_ITEM(back, MSG_MAIN, lcd_main_menu); MENU_ITEM(back, MSG_MAIN);
card.getWorkDirName(); card.getWorkDirName();
if (fullName[0] == '/') { if (fullName[0] == '/') {
#if !PIN_EXISTS(SD_DETECT) #if !PIN_EXISTS(SD_DETECT)
...@@ -1592,9 +1760,31 @@ static void lcd_control_volumetric_menu() { ...@@ -1592,9 +1760,31 @@ static void lcd_control_volumetric_menu() {
* *
* Functions for editing single values * Functions for editing single values
* *
* The "menu_edit_type" macro generates the functions needed to edit a numerical value.
*
* For example, menu_edit_type(int, int3, itostr3, 1) expands into these functions:
*
* bool _menu_edit_int3();
* void menu_edit_int3(); // edit int (interactively)
* void menu_edit_callback_int3(); // edit int (interactively) with callback on completion
* static void _menu_action_setting_edit_int3(const char* pstr, int* ptr, int minValue, int maxValue);
* static void menu_action_setting_edit_int3(const char* pstr, int* ptr, int minValue, int maxValue);
* static void menu_action_setting_edit_callback_int3(const char* pstr, int* ptr, int minValue, int maxValue, menuFunc_t callback); // edit int with callback
*
* You can then use one of the menu macros to present the edit interface:
* MENU_ITEM_EDIT(int3, MSG_SPEED, &feedrate_multiplier, 10, 999)
*
* This expands into a more primitive menu item:
* MENU_ITEM(setting_edit_int3, MSG_SPEED, PSTR(MSG_SPEED), &feedrate_multiplier, 10, 999)
*
*
* Also: MENU_MULTIPLIER_ITEM_EDIT, MENU_ITEM_EDIT_CALLBACK, and MENU_MULTIPLIER_ITEM_EDIT_CALLBACK
*
* menu_action_setting_edit_int3(PSTR(MSG_SPEED), &feedrate_multiplier, 10, 999)
*/ */
#define menu_edit_type(_type, _name, _strFunc, scale) \ #define menu_edit_type(_type, _name, _strFunc, scale) \
bool _menu_edit_ ## _name () { \ bool _menu_edit_ ## _name () { \
ENCODER_DIRECTION_NORMAL(); \
bool isClicked = LCD_CLICKED; \ bool isClicked = LCD_CLICKED; \
if ((int32_t)encoderPosition < 0) encoderPosition = 0; \ if ((int32_t)encoderPosition < 0) encoderPosition = 0; \
if ((int32_t)encoderPosition > maxEditValue) encoderPosition = maxEditValue; \ if ((int32_t)encoderPosition > maxEditValue) encoderPosition = maxEditValue; \
...@@ -1602,18 +1792,16 @@ static void lcd_control_volumetric_menu() { ...@@ -1602,18 +1792,16 @@ static void lcd_control_volumetric_menu() {
lcd_implementation_drawedit(editLabel, _strFunc(((_type)((int32_t)encoderPosition + minEditValue)) / scale)); \ lcd_implementation_drawedit(editLabel, _strFunc(((_type)((int32_t)encoderPosition + minEditValue)) / scale)); \
if (isClicked) { \ if (isClicked) { \
*((_type*)editValue) = ((_type)((int32_t)encoderPosition + minEditValue)) / scale; \ *((_type*)editValue) = ((_type)((int32_t)encoderPosition + minEditValue)) / scale; \
lcd_goto_menu(prevMenu, prevEncoderPosition); \ lcd_goto_previous_menu(true); \
} \ } \
return isClicked; \ return isClicked; \
} \ } \
void menu_edit_ ## _name () { _menu_edit_ ## _name(); } \ void menu_edit_ ## _name () { _menu_edit_ ## _name(); } \
void menu_edit_callback_ ## _name () { if (_menu_edit_ ## _name ()) (*callbackFunc)(); } \ void menu_edit_callback_ ## _name () { if (_menu_edit_ ## _name ()) (*callbackFunc)(); } \
static void _menu_action_setting_edit_ ## _name (const char* pstr, _type* ptr, _type minValue, _type maxValue) { \ static void _menu_action_setting_edit_ ## _name (const char* pstr, _type* ptr, _type minValue, _type maxValue) { \
prevMenu = currentMenu; \ lcd_save_previous_menu(); \
prevEncoderPosition = encoderPosition; \
\ \
lcdDrawUpdate = 2; \ lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW; \
currentMenu = menu_edit_ ## _name; \
\ \
editLabel = pstr; \ editLabel = pstr; \
editValue = ptr; \ editValue = ptr; \
...@@ -1726,8 +1914,8 @@ void lcd_quick_feedback() { ...@@ -1726,8 +1914,8 @@ void lcd_quick_feedback() {
* Menu actions * Menu actions
* *
*/ */
static void menu_action_back(menuFunc_t func) { lcd_goto_menu(func); } static void menu_action_back() { lcd_goto_previous_menu(); }
static void menu_action_submenu(menuFunc_t func) { lcd_goto_menu(func); } static void menu_action_submenu(menuFunc_t func) { lcd_save_previous_menu(); lcd_goto_menu(func); }
static void menu_action_gcode(const char* pgcode) { enqueue_and_echo_commands_P(pgcode); } static void menu_action_gcode(const char* pgcode) { enqueue_and_echo_commands_P(pgcode); }
static void menu_action_function(menuFunc_t func) { (*func)(); } static void menu_action_function(menuFunc_t func) { (*func)(); }
...@@ -1764,13 +1952,17 @@ void lcd_init() { ...@@ -1764,13 +1952,17 @@ void lcd_init() {
lcd_implementation_init(); lcd_implementation_init();
#if ENABLED(NEWPANEL) #if ENABLED(NEWPANEL)
#if BUTTON_EXISTS(EN1)
SET_INPUT(BTN_EN1);
PULLUP(BTN_EN1, HIGH);
#endif
SET_INPUT(BTN_EN1); #if BUTTON_EXISTS(EN2)
SET_INPUT(BTN_EN2); SET_INPUT(BTN_EN2);
PULLUP(BTN_EN1, HIGH); PULLUP(BTN_EN2, HIGH);
PULLUP(BTN_EN2, HIGH); #endif
#if BTN_ENC > 0 #if BUTTON_EXISTS(ENC)
SET_INPUT(BTN_ENC); SET_INPUT(BTN_ENC);
PULLUP(BTN_ENC, HIGH); PULLUP(BTN_ENC, HIGH);
#endif #endif
...@@ -1783,6 +1975,13 @@ void lcd_init() { ...@@ -1783,6 +1975,13 @@ void lcd_init() {
WRITE(SHIFT_LD, HIGH); WRITE(SHIFT_LD, HIGH);
#endif #endif
#ifdef RIGIDBOT_PANEL
SET_INPUT(BTN_UP);
SET_INPUT(BTN_DWN);
SET_INPUT(BTN_LFT);
SET_INPUT(BTN_RT);
#endif
#else // Not NEWPANEL #else // Not NEWPANEL
#if ENABLED(SR_LCD_2W_NL) // Non latching 2 wire shift register #if ENABLED(SR_LCD_2W_NL) // Non latching 2 wire shift register
...@@ -1817,7 +2016,7 @@ void lcd_init() { ...@@ -1817,7 +2016,7 @@ void lcd_init() {
#endif #endif
} }
int lcd_strlen(char* s) { int lcd_strlen(const char* s) {
int i = 0, j = 0; int i = 0, j = 0;
while (s[i]) { while (s[i]) {
if ((s[i] & 0xc0) != 0x80) j++; if ((s[i] & 0xc0) != 0x80) j++;
...@@ -1859,7 +2058,7 @@ void lcd_update() { ...@@ -1859,7 +2058,7 @@ void lcd_update() {
bool sd_status = IS_SD_INSERTED; bool sd_status = IS_SD_INSERTED;
if (sd_status != lcd_sd_status && lcd_detected()) { if (sd_status != lcd_sd_status && lcd_detected()) {
lcdDrawUpdate = 2; lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
lcd_implementation_init( // to maybe revive the LCD if static electricity killed it. lcd_implementation_init( // to maybe revive the LCD if static electricity killed it.
#if ENABLED(LCD_PROGRESS_BAR) #if ENABLED(LCD_PROGRESS_BAR)
currentMenu == lcd_status_screen currentMenu == lcd_status_screen
...@@ -1881,7 +2080,13 @@ void lcd_update() { ...@@ -1881,7 +2080,13 @@ void lcd_update() {
#endif // SDSUPPORT && SD_DETECT_PIN #endif // SDSUPPORT && SD_DETECT_PIN
millis_t ms = millis(); millis_t ms = millis();
if (ms > next_lcd_update_ms) { if (ELAPSED(ms, next_lcd_update_ms)) {
next_lcd_update_ms = ms + LCD_UPDATE_INTERVAL;
#if ENABLED(LCD_HAS_STATUS_INDICATORS)
lcd_implementation_update_indicators();
#endif
#if ENABLED(LCD_HAS_SLOW_BUTTONS) #if ENABLED(LCD_HAS_SLOW_BUTTONS)
slow_buttons = lcd_implementation_read_slow_buttons(); // buttons which take too long to read in interrupt context slow_buttons = lcd_implementation_read_slow_buttons(); // buttons which take too long to read in interrupt context
...@@ -1890,13 +2095,22 @@ void lcd_update() { ...@@ -1890,13 +2095,22 @@ void lcd_update() {
#if ENABLED(ULTIPANEL) #if ENABLED(ULTIPANEL)
#if ENABLED(REPRAPWORLD_KEYPAD) #if ENABLED(REPRAPWORLD_KEYPAD)
if (REPRAPWORLD_KEYPAD_MOVE_Z_UP) reprapworld_keypad_move_z_up();
if (REPRAPWORLD_KEYPAD_MOVE_Z_DOWN) reprapworld_keypad_move_z_down(); #if ENABLED(DELTA) || ENABLED(SCARA)
if (REPRAPWORLD_KEYPAD_MOVE_X_LEFT) reprapworld_keypad_move_x_left(); #define _KEYPAD_MOVE_ALLOWED (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS])
if (REPRAPWORLD_KEYPAD_MOVE_X_RIGHT) reprapworld_keypad_move_x_right(); #else
if (REPRAPWORLD_KEYPAD_MOVE_Y_DOWN) reprapworld_keypad_move_y_down(); #define _KEYPAD_MOVE_ALLOWED true
if (REPRAPWORLD_KEYPAD_MOVE_Y_UP) reprapworld_keypad_move_y_up(); #endif
if (REPRAPWORLD_KEYPAD_MOVE_HOME) reprapworld_keypad_move_home();
if (REPRAPWORLD_KEYPAD_MOVE_HOME) reprapworld_keypad_move_home();
if (_KEYPAD_MOVE_ALLOWED) {
if (REPRAPWORLD_KEYPAD_MOVE_Z_UP) reprapworld_keypad_move_z_up();
if (REPRAPWORLD_KEYPAD_MOVE_Z_DOWN) reprapworld_keypad_move_z_down();
if (REPRAPWORLD_KEYPAD_MOVE_X_LEFT) reprapworld_keypad_move_x_left();
if (REPRAPWORLD_KEYPAD_MOVE_X_RIGHT) reprapworld_keypad_move_x_right();
if (REPRAPWORLD_KEYPAD_MOVE_Y_DOWN) reprapworld_keypad_move_y_down();
if (REPRAPWORLD_KEYPAD_MOVE_Y_UP) reprapworld_keypad_move_y_up();
}
#endif #endif
bool encoderPastThreshold = (abs(encoderDiff) >= ENCODER_PULSES_PER_STEP); bool encoderPastThreshold = (abs(encoderDiff) >= ENCODER_PULSES_PER_STEP);
...@@ -1933,59 +2147,70 @@ void lcd_update() { ...@@ -1933,59 +2147,70 @@ void lcd_update() {
encoderDiff = 0; encoderDiff = 0;
} }
return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS; return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS;
lcdDrawUpdate = 1; lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
} }
#endif //ULTIPANEL #endif // ULTIPANEL
if (currentMenu == lcd_status_screen) { // Simply redraw the Info Screen 10 times a second
if (!lcd_status_update_delay) { if (currentMenu == lcd_status_screen && !(++lcd_status_update_delay % 10))
lcdDrawUpdate = 1; lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
lcd_status_update_delay = 10; /* redraw the main screen every second. This is easier then trying keep track of all things that change on the screen */
} if (lcdDrawUpdate) {
else { switch (lcdDrawUpdate) {
lcd_status_update_delay--; case LCDVIEW_CALL_NO_REDRAW:
lcdDrawUpdate = LCDVIEW_NONE;
break;
case LCDVIEW_CLEAR_CALL_REDRAW: // set by handlers, then altered after (rarely occurs here)
case LCDVIEW_CALL_REDRAW_NEXT: // set by handlers, then altered after (never occurs here?)
lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
case LCDVIEW_REDRAW_NOW: // set above, or by a handler through LCDVIEW_CALL_REDRAW_NEXT
case LCDVIEW_NONE:
break;
} }
}
#if ENABLED(DOGLCD) // Changes due to different driver architecture of the DOGM display #if ENABLED(DOGLCD) // Changes due to different driver architecture of the DOGM display
if (lcdDrawUpdate) { static int8_t dot_color = 0;
blink++; // Variable for fan animation and alive dot dot_color = 1 - dot_color;
u8g.firstPage(); u8g.firstPage();
do { do {
lcd_setFont(FONT_MENU); lcd_setFont(FONT_MENU);
u8g.setPrintPos(125, 0); u8g.setPrintPos(125, 0);
if (blink % 2) u8g.setColorIndex(1); else u8g.setColorIndex(0); // Set color for the alive dot u8g.setColorIndex(dot_color); // Set color for the alive dot
u8g.drawPixel(127, 63); // draw alive dot u8g.drawPixel(127, 63); // draw alive dot
u8g.setColorIndex(1); // black on white u8g.setColorIndex(1); // black on white
(*currentMenu)(); (*currentMenu)();
} while(u8g.nextPage()); } while (u8g.nextPage());
} #else
#else
if (lcdDrawUpdate)
(*currentMenu)(); (*currentMenu)();
#endif #endif
}
#if ENABLED(LCD_HAS_STATUS_INDICATORS)
lcd_implementation_update_indicators();
#endif
#if ENABLED(ULTIPANEL) #if ENABLED(ULTIPANEL)
// Return to Status Screen after a timeout // Return to Status Screen after a timeout
if (currentMenu != lcd_status_screen && if (currentMenu == lcd_status_screen || defer_return_to_status
#if !MECH(DELTA) && DISABLED(Z_SAFE_HOMING) && Z_HOME_DIR < 0 #if !MECH(DELTA) && DISABLED(Z_SAFE_HOMING) && Z_HOME_DIR < 0
currentMenu != lcd_level_bed && || currentMenu == lcd_level_bed
#endif #endif
millis() > return_to_status_ms )
) { return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS;
else if (ELAPSED(ms, return_to_status_ms))
lcd_return_to_status(); lcd_return_to_status();
lcdDrawUpdate = 2;
}
#endif // ULTIPANEL #endif // ULTIPANEL
if (lcdDrawUpdate == 2) lcd_implementation_clear(); switch (lcdDrawUpdate) {
if (lcdDrawUpdate) lcdDrawUpdate--; case LCDVIEW_CLEAR_CALL_REDRAW:
next_lcd_update_ms = ms + LCD_UPDATE_INTERVAL; lcd_implementation_clear();
case LCDVIEW_CALL_REDRAW_NEXT:
lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
break;
case LCDVIEW_REDRAW_NOW:
lcdDrawUpdate = LCDVIEW_NONE;
break;
case LCDVIEW_NONE:
break;
}
} }
} }
...@@ -1995,13 +2220,17 @@ void lcd_ignore_click(bool b) { ...@@ -1995,13 +2220,17 @@ void lcd_ignore_click(bool b) {
} }
void lcd_finishstatus(bool persist = false) { void lcd_finishstatus(bool persist = false) {
#if !(ENABLED(LCD_PROGRESS_BAR) && (PROGRESS_MSG_EXPIRE > 0))
UNUSED(persist);
#endif
#if ENABLED(LCD_PROGRESS_BAR) #if ENABLED(LCD_PROGRESS_BAR)
progress_bar_ms = millis(); progress_bar_ms = millis();
#if PROGRESS_MSG_EXPIRE > 0 #if PROGRESS_MSG_EXPIRE > 0
expire_status_ms = persist ? 0 : progress_bar_ms + PROGRESS_MSG_EXPIRE; expire_status_ms = persist ? 0 : progress_bar_ms + PROGRESS_MSG_EXPIRE;
#endif #endif
#endif #endif
lcdDrawUpdate = 2; lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
#if HAS(LCD_FILAMENT_SENSOR) || HAS(LCD_POWER_SENSOR) #if HAS(LCD_FILAMENT_SENSOR) || HAS(LCD_POWER_SENSOR)
previous_lcd_status_ms = millis(); //get status message to show up for a while previous_lcd_status_ms = millis(); //get status message to show up for a while
...@@ -2063,13 +2292,26 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; } ...@@ -2063,13 +2292,26 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
* These values are independent of which pins are used for EN_A and EN_B indications * These values are independent of which pins are used for EN_A and EN_B indications
* The rotary encoder part is also independent to the chipset used for the LCD * The rotary encoder part is also independent to the chipset used for the LCD
*/ */
#if ENABLED(EN_A) && ENABLED(EN_B) #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
#define GET_BUTTON_STATES(DST) \
uint8_t new_##DST = 0; \
WRITE(SHIFT_LD, LOW); \
WRITE(SHIFT_LD, HIGH); \
for (int8_t i = 0; i < 8; i++) { \
new_##DST >>= 1; \
if (READ(SHIFT_OUT)) SBI(new_##DST, 7); \
WRITE(SHIFT_CLK, HIGH); \
WRITE(SHIFT_CLK, LOW); \
} \
DST = ~new_##DST; //invert it, because a pressed switch produces a logical 0
/** /**
* Read encoder buttons from the hardware registers * Read encoder buttons from the hardware registers
* Warning: This function is called from interrupt context! * Warning: This function is called from interrupt context!
...@@ -2077,73 +2319,68 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; } ...@@ -2077,73 +2319,68 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
void lcd_buttons_update() { void lcd_buttons_update() {
#if ENABLED(NEWPANEL) #if ENABLED(NEWPANEL)
uint8_t newbutton = 0; uint8_t newbutton = 0;
#if ENABLED(INVERT_ROTARY_SWITCH) #if BUTTON_EXISTS(EN1)
if (READ(BTN_EN1) == 0) newbutton |= EN_B; if (BUTTON_PRESSED(EN1)) newbutton |= EN_A;
if (READ(BTN_EN2) == 0) newbutton |= EN_A;
#else
if (READ(BTN_EN1) == 0) newbutton |= EN_A;
if (READ(BTN_EN2) == 0) newbutton |= EN_B;
#endif #endif
#if BTN_ENC > 0 #if BUTTON_EXISTS(EN2)
millis_t ms = millis(); if (BUTTON_PRESSED(EN2)) newbutton |= EN_B;
if (ms > next_button_update_ms && READ(BTN_ENC) == 0) newbutton |= EN_C; #endif
#if ENABLED(BTN_BACK) && BTN_BACK > 0 #if ENABLED(RIGIDBOT_PANEL) || BUTTON_EXISTS(ENC)
if (ms > next_button_update_ms && READ(BTN_BACK) == 0) newbutton |= EN_D; millis_t now = millis();
#endif #endif
#if ENABLED(RIGIDBOT_PANEL)
if (ELAPSED(now, next_button_update_ms)) {
if (BUTTON_PRESSED(UP)) {
encoderDiff = -(ENCODER_STEPS_PER_MENU_ITEM);
next_button_update_ms = now + 300;
}
else if (BUTTON_PRESSED(DWN)) {
encoderDiff = ENCODER_STEPS_PER_MENU_ITEM;
next_button_update_ms = now + 300;
}
else if (BUTTON_PRESSED(LFT)) {
encoderDiff = -(ENCODER_PULSES_PER_STEP);
next_button_update_ms = now + 300;
}
else if (BUTTON_PRESSED(RT)) {
encoderDiff = ENCODER_PULSES_PER_STEP;
next_button_update_ms = now + 300;
}
}
#endif
#if BUTTON_EXISTS(ENC)
if (ELAPSED(now, next_button_update_ms) && BUTTON_PRESSED(ENC)) newbutton |= EN_C;
#endif #endif
buttons = newbutton; buttons = newbutton;
#if ENABLED(LCD_HAS_SLOW_BUTTONS) #if ENABLED(LCD_HAS_SLOW_BUTTONS)
buttons |= slow_buttons; buttons |= slow_buttons;
#endif #endif
#if ENABLED(REPRAPWORLD_KEYPAD) #if ENABLED(REPRAPWORLD_KEYPAD)
// for the reprapworld_keypad GET_BUTTON_STATES(buttons_reprapworld_keypad);
uint8_t newbutton_reprapworld_keypad = 0;
WRITE(SHIFT_LD, LOW);
WRITE(SHIFT_LD, HIGH);
for (uint8_t i = 0; i < 8; i++) {
newbutton_reprapworld_keypad >>= 1;
if (READ(SHIFT_OUT)) BITSET(newbutton_reprapworld_keypad, 7);
WRITE(SHIFT_CLK, HIGH);
WRITE(SHIFT_CLK, LOW);
}
buttons_reprapworld_keypad = ~newbutton_reprapworld_keypad; //invert it, because a pressed switch produces a logical 0
#endif #endif
#else //read it from the shift register #else //read it from the shift register
uint8_t newbutton = 0; GET_BUTTON_STATES(buttons);
WRITE(SHIFT_LD, LOW);
WRITE(SHIFT_LD, HIGH);
unsigned char tmp_buttons = 0;
for (uint8_t i = 0; i < 8; i++) {
newbutton >>= 1;
if (READ(SHIFT_OUT)) BITSET(newbutton, 7);
WRITE(SHIFT_CLK, HIGH);
WRITE(SHIFT_CLK, LOW);
}
buttons = ~newbutton; //invert it, because a pressed switch produces a logical 0
#endif //!NEWPANEL #endif //!NEWPANEL
#if ENABLED(INVERT_ROTARY_SWITCH)
#define ENCODER_DIFF_CW (encoderDiff += encoderDirection)
#define ENCODER_DIFF_CCW (encoderDiff -= encoderDirection)
#else
#define ENCODER_DIFF_CW (encoderDiff++)
#define ENCODER_DIFF_CCW (encoderDiff--)
#endif
#define ENCODER_SPIN(_E1, _E2) switch (lastEncoderBits) { case _E1: ENCODER_DIFF_CW; break; case _E2: ENCODER_DIFF_CCW; }
//manage encoder rotation //manage encoder rotation
uint8_t enc = 0; uint8_t enc = 0;
if (buttons & EN_A) enc |= B01; if (buttons & EN_A) enc |= B01;
if (buttons & EN_B) enc |= B10; if (buttons & EN_B) enc |= B10;
if (enc != lastEncoderBits) { if (enc != lastEncoderBits) {
switch (enc) { switch (enc) {
case encrot0: case encrot0: ENCODER_SPIN(encrot3, encrot1); break;
if (lastEncoderBits == encrot3) encoderDiff++; case encrot1: ENCODER_SPIN(encrot0, encrot2); break;
else if (lastEncoderBits == encrot1) encoderDiff--; case encrot2: ENCODER_SPIN(encrot1, encrot3); break;
break; case encrot3: ENCODER_SPIN(encrot2, encrot0); break;
case encrot1:
if (lastEncoderBits == encrot0) encoderDiff++;
else if (lastEncoderBits == encrot2) encoderDiff--;
break;
case encrot2:
if (lastEncoderBits == encrot1) encoderDiff++;
else if (lastEncoderBits == encrot3) encoderDiff--;
break;
case encrot3:
if (lastEncoderBits == encrot2) encoderDiff++;
else if (lastEncoderBits == encrot0) encoderDiff--;
break;
} }
} }
lastEncoderBits = enc; lastEncoderBits = enc;
......
...@@ -28,7 +28,10 @@ ...@@ -28,7 +28,10 @@
#include "buzzer.h" #include "buzzer.h"
#endif #endif
int lcd_strlen(char* s); #define BUTTON_EXISTS(BN) (defined(BTN_## BN) && BTN_## BN >= 0)
#define BUTTON_PRESSED(BN) !READ(BTN_## BN)
int lcd_strlen(const char* s);
int lcd_strlen_P(const char* s); int lcd_strlen_P(const char* s);
void lcd_update(); void lcd_update();
void lcd_init(); void lcd_init();
...@@ -64,10 +67,7 @@ ...@@ -64,10 +67,7 @@
#if ENABLED(ULTIPANEL) #if ENABLED(ULTIPANEL)
void lcd_buttons_update(); void lcd_buttons_update();
extern volatile uint8_t buttons; //the last checked buttons in a bit array. extern volatile uint8_t buttons; // the last checked buttons in a bit array.
#if ENABLED(REPRAPWORLD_KEYPAD)
extern volatile uint8_t buttons_reprapworld_keypad; // to store the keypad shift register values
#endif
#else #else
FORCE_INLINE void lcd_buttons_update() {} FORCE_INLINE void lcd_buttons_update() {}
#endif #endif
...@@ -89,18 +89,54 @@ ...@@ -89,18 +89,54 @@
#endif #endif
void lcd_quick_feedback(); // Audible feedback for a button click - could also be visual void lcd_quick_feedback(); // Audible feedback for a button click - could also be visual
bool lcd_clicked(); bool lcd_clicked();
void lcd_ignore_click(bool b = true);
void lcd_ignore_click(bool b=true); bool lcd_blink();
#if ENABLED(ULTIPANEL) && ENABLED(REPRAPWORLD_KEYPAD)
#define REPRAPWORLD_BTN_OFFSET 0 // bit offset into buttons for shift register values
#define BLEN_REPRAPWORLD_KEYPAD_F3 0
#define BLEN_REPRAPWORLD_KEYPAD_F2 1
#define BLEN_REPRAPWORLD_KEYPAD_F1 2
#define BLEN_REPRAPWORLD_KEYPAD_DOWN 3
#define BLEN_REPRAPWORLD_KEYPAD_RIGHT 4
#define BLEN_REPRAPWORLD_KEYPAD_MIDDLE 5
#define BLEN_REPRAPWORLD_KEYPAD_UP 6
#define BLEN_REPRAPWORLD_KEYPAD_LEFT 7
#define EN_REPRAPWORLD_KEYPAD_F3 (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_F3))
#define EN_REPRAPWORLD_KEYPAD_F2 (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_F2))
#define EN_REPRAPWORLD_KEYPAD_F1 (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_F1))
#define EN_REPRAPWORLD_KEYPAD_DOWN (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_DOWN))
#define EN_REPRAPWORLD_KEYPAD_RIGHT (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_RIGHT))
#define EN_REPRAPWORLD_KEYPAD_MIDDLE (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_MIDDLE))
#define EN_REPRAPWORLD_KEYPAD_UP (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_UP))
#define EN_REPRAPWORLD_KEYPAD_LEFT (_BV(REPRAPWORLD_BTN_OFFSET + BLEN_REPRAPWORLD_KEYPAD_LEFT))
#define REPRAPWORLD_KEYPAD_MOVE_Z_DOWN (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_F3)
#define REPRAPWORLD_KEYPAD_MOVE_Z_UP (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_F2)
#define REPRAPWORLD_KEYPAD_MOVE_Y_DOWN (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_DOWN)
#define REPRAPWORLD_KEYPAD_MOVE_X_RIGHT (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_RIGHT)
#define REPRAPWORLD_KEYPAD_MOVE_HOME (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_MIDDLE)
#define REPRAPWORLD_KEYPAD_MOVE_Y_UP (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_UP)
#define REPRAPWORLD_KEYPAD_MOVE_X_LEFT (buttons_reprapworld_keypad & EN_REPRAPWORLD_KEYPAD_LEFT)
#endif // ULTIPANEL && REPRAPWORLD_KEYPAD
#if ENABLED(NEWPANEL) #if ENABLED(NEWPANEL)
#define EN_C (_BV(BLEN_C)) #define EN_C (_BV(BLEN_C))
#define EN_B (_BV(BLEN_B)) #define EN_B (_BV(BLEN_B))
#define EN_A (_BV(BLEN_A)) #define EN_A (_BV(BLEN_A))
#if ENABLED(INVERT_CLICK_BUTTON)
#define LCD_CLICKED !(buttons&EN_C) #if ENABLED(REPRAPWORLD_KEYPAD)
#define LCD_CLICKED ((buttons&EN_C) || (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_F1))
#else #else
#define LCD_CLICKED (buttons&EN_C) #if ENABLED(INVERT_CLICK_BUTTON)
#define LCD_CLICKED !(buttons&EN_C)
#else
#define LCD_CLICKED (buttons&EN_C)
#endif
#endif #endif
#if ENABLED(BTN_BACK) && BTN_BACK > 0 #if ENABLED(BTN_BACK) && BTN_BACK > 0
#define EN_D (_BV(BLEN_D)) #define EN_D (_BV(BLEN_D))
#if ENABLED(INVERT_BACK_BUTTON) #if ENABLED(INVERT_BACK_BUTTON)
...@@ -109,30 +145,10 @@ ...@@ -109,30 +145,10 @@
#define LCD_BACK_CLICKED (buttons&EN_D) #define LCD_BACK_CLICKED (buttons&EN_D)
#endif #endif
#endif #endif
#if ENABLED(REPRAPWORLD_KEYPAD)
#define EN_REPRAPWORLD_KEYPAD_F3 (_BV(BLEN_REPRAPWORLD_KEYPAD_F3)) #else // !NEWPANEL
#define EN_REPRAPWORLD_KEYPAD_F2 (_BV(BLEN_REPRAPWORLD_KEYPAD_F2))
#define EN_REPRAPWORLD_KEYPAD_F1 (_BV(BLEN_REPRAPWORLD_KEYPAD_F1)) // atomic, do not change
#define EN_REPRAPWORLD_KEYPAD_UP (_BV(BLEN_REPRAPWORLD_KEYPAD_UP))
#define EN_REPRAPWORLD_KEYPAD_RIGHT (_BV(BLEN_REPRAPWORLD_KEYPAD_RIGHT))
#define EN_REPRAPWORLD_KEYPAD_MIDDLE (_BV(BLEN_REPRAPWORLD_KEYPAD_MIDDLE))
#define EN_REPRAPWORLD_KEYPAD_DOWN (_BV(BLEN_REPRAPWORLD_KEYPAD_DOWN))
#define EN_REPRAPWORLD_KEYPAD_LEFT (_BV(BLEN_REPRAPWORLD_KEYPAD_LEFT))
#if ENABLED(INVERT_CLICK_BUTTON)
#define LCD_CLICKED !((buttons&EN_C) || (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_F1))
#else
#define LCD_CLICKED ((buttons&EN_C) || (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_F1))
#endif
#define REPRAPWORLD_KEYPAD_MOVE_Z_UP (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_F2)
#define REPRAPWORLD_KEYPAD_MOVE_Z_DOWN (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_F3)
#define REPRAPWORLD_KEYPAD_MOVE_X_LEFT (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_LEFT)
#define REPRAPWORLD_KEYPAD_MOVE_X_RIGHT (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_RIGHT)
#define REPRAPWORLD_KEYPAD_MOVE_Y_DOWN (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_DOWN)
#define REPRAPWORLD_KEYPAD_MOVE_Y_UP (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_UP)
#define REPRAPWORLD_KEYPAD_MOVE_HOME (buttons_reprapworld_keypad&EN_REPRAPWORLD_KEYPAD_MIDDLE)
#endif //REPRAPWORLD_KEYPAD
#else
//atomic, do not change
#define B_LE (_BV(BL_LE)) #define B_LE (_BV(BL_LE))
#define B_UP (_BV(BL_UP)) #define B_UP (_BV(BL_UP))
#define B_MI (_BV(BL_MI)) #define B_MI (_BV(BL_MI))
...@@ -142,9 +158,9 @@ ...@@ -142,9 +158,9 @@
#define EN_B (_BV(BLEN_B)) #define EN_B (_BV(BLEN_B))
#define EN_A (_BV(BLEN_A)) #define EN_A (_BV(BLEN_A))
#define LCD_CLICKED (buttons&(B_MI|B_ST)) #define LCD_CLICKED ((buttons&B_MI)||(buttons&B_ST))
#endif//NEWPANEL #endif // NEWPANEL
char* itostr2(const uint8_t& x); char* itostr2(const uint8_t& x);
char* itostr31(const int& xx); char* itostr31(const int& xx);
......
...@@ -933,7 +933,7 @@ void lcd_implementation_drawedit(const char* pstr, char* value) { ...@@ -933,7 +933,7 @@ void lcd_implementation_drawedit(const char* pstr, char* value) {
#endif // SDSUPPORT #endif // SDSUPPORT
#define lcd_implementation_drawmenu_back(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0]) #define lcd_implementation_drawmenu_back(sel, row, pstr) lcd_implementation_drawmenu_generic(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0])
#define lcd_implementation_drawmenu_submenu(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0]) #define lcd_implementation_drawmenu_submenu(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0])
#define lcd_implementation_drawmenu_gcode(sel, row, pstr, gcode) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ') #define lcd_implementation_drawmenu_gcode(sel, row, pstr, gcode) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
#define lcd_implementation_drawmenu_function(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ') #define lcd_implementation_drawmenu_function(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
......
...@@ -226,8 +226,8 @@ void autotempShutdown() { ...@@ -226,8 +226,8 @@ void autotempShutdown() {
#endif #endif
} }
#if ENABLED(PIDTEMP) || ENABLED(PIDTEMPBED) #if HAS(PID_HEATING)
void PID_autotune(float temp, int hotend, int ncycles) { void PID_autotune(float temp, int hotend, int ncycles, bool set_result/*=false*/) {
float input = 0.0; float input = 0.0;
int cycles = 0; int cycles = 0;
bool heating = true; bool heating = true;
...@@ -237,7 +237,7 @@ void autotempShutdown() { ...@@ -237,7 +237,7 @@ void autotempShutdown() {
long bias = 0, d = 0; long bias = 0, d = 0;
float Ku = 0, Tu = 0; float Ku = 0, Tu = 0;
float Kp_temp = 0, Ki_temp = 0, Kd_temp = 0; float workKp = 0, workKi = 0, workKd = 0;
float max = 0, min = 10000; float max = 0, min = 10000;
#if HAS(AUTO_FAN) #if HAS(AUTO_FAN)
...@@ -323,23 +323,29 @@ void autotempShutdown() { ...@@ -323,23 +323,29 @@ void autotempShutdown() {
Tu = ((float)(t_low + t_high) / 1000.0); Tu = ((float)(t_low + t_high) / 1000.0);
ECHO_MV(SERIAL_KU, Ku); ECHO_MV(SERIAL_KU, Ku);
ECHO_EMV(SERIAL_TU, Tu); ECHO_EMV(SERIAL_TU, Tu);
Kp_temp = 0.6 * Ku; workKp = 0.6 * Ku;
Ki_temp = 2 * Kp_temp / Tu; workKi = 2 * workKp / Tu;
Kd_temp = Kp_temp * Tu / 8; workKd = workKp * Tu / 8;
ECHO_EM(SERIAL_CLASSIC_PID); ECHO_EM(SERIAL_CLASSIC_PID);
ECHO_MV(SERIAL_KP, Kp_temp); ECHO_MV(SERIAL_KP, workKp);
ECHO_MV(SERIAL_KI, Ki_temp); ECHO_MV(SERIAL_KI, workKi);
ECHO_EMV(SERIAL_KD, Kd_temp); ECHO_EMV(SERIAL_KD, workKd);
} }
else { else {
ECHO_E; ECHO_E;
} }
} }
if (hotend < 0) #if HAS(PID_FOR_BOTH)
soft_pwm_bed = (bias + d) >> 1; if (hotend < 0)
else soft_pwm_bed = (bias + d) >> 1;
else
soft_pwm[hotend] = (bias + d) >> 1;
#elif ENABLED(PIDTEMP)
soft_pwm[hotend] = (bias + d) >> 1; soft_pwm[hotend] = (bias + d) >> 1;
#else
soft_pwm_bed = (bias + d) >> 1;
#endif
cycles++; cycles++;
min = temp; min = temp;
} }
...@@ -351,7 +357,7 @@ void autotempShutdown() { ...@@ -351,7 +357,7 @@ void autotempShutdown() {
} }
// Every 2 seconds... // Every 2 seconds...
if (ms > temp_ms + 2000) { if (ELAPSED(ms, temp_ms + 2000UL)) {
#if HAS(TEMP_0) || HAS(TEMP_BED) || ENABLED(HEATER_0_USES_MAX6675) #if HAS(TEMP_0) || HAS(TEMP_BED) || ENABLED(HEATER_0_USES_MAX6675)
print_heaterstates(); print_heaterstates();
ECHO_E; ECHO_E;
...@@ -367,23 +373,51 @@ void autotempShutdown() { ...@@ -367,23 +373,51 @@ void autotempShutdown() {
} }
if (cycles > ncycles) { if (cycles > ncycles) {
ECHO_LM(DB, SERIAL_PID_AUTOTUNE_FINISHED); ECHO_LM(DB, SERIAL_PID_AUTOTUNE_FINISHED);
#if ENABLED(PIDTEMP) #if HAS(PID_FOR_BOTH)
if (hotend >= 0) { if (hotend >= 0) {
PID_PARAM(Kp, hotend) = Kp_temp;
PID_PARAM(Ki, hotend) = scalePID_i(Ki_temp);
PID_PARAM(Kd, hotend) = scalePID_d(Kd_temp);
updatePID();
ECHO_SMV(DB, SERIAL_KP, PID_PARAM(Kp, hotend)); ECHO_SMV(DB, SERIAL_KP, PID_PARAM(Kp, hotend));
ECHO_MV(SERIAL_KI, unscalePID_i(PID_PARAM(Ki, hotend))); ECHO_MV(SERIAL_KI, unscalePID_i(PID_PARAM(Ki, hotend)));
ECHO_EMV(SERIAL_KD, unscalePID_d(PID_PARAM(Kd, hotend))); ECHO_EMV(SERIAL_KD, unscalePID_d(PID_PARAM(Kd, hotend)));
if (set_result) {
PID_PARAM(Kp, hotend) = workKp;
PID_PARAM(Ki, hotend) = scalePID_i(workKi);
PID_PARAM(Kd, hotend) = scalePID_d(workKd);
updatePID();
}
} }
else { else {
ECHO_LMV(DB, "#define DEFAULT_bedKp ", Kp_temp); ECHO_LMV(DB, "#define DEFAULT_bedKp ", workKp);
ECHO_LMV(DB, "#define DEFAULT_bedKi ", unscalePID_i(Ki_temp)); ECHO_LMV(DB, "#define DEFAULT_bedKi ", unscalePID_i(workKi));
ECHO_LMV(DB, "#define DEFAULT_bedKd ", unscalePID_d(Kd_temp)); ECHO_LMV(DB, "#define DEFAULT_bedKd ", unscalePID_d(workKd));
if (set_result) {
bedKp = workKp;
bedKi = scalePID_i(workKi);
bedKd = scalePID_d(workKd);
updatePID();
}
}
#elif ENABLED(PIDTEMP)
ECHO_SMV(DB, SERIAL_KP, PID_PARAM(Kp, hotend));
ECHO_MV(SERIAL_KI, unscalePID_i(PID_PARAM(Ki, hotend)));
ECHO_EMV(SERIAL_KD, unscalePID_d(PID_PARAM(Kd, hotend)));
if (set_result) {
PID_PARAM(Kp, hotend) = workKp;
PID_PARAM(Ki, hotend) = scalePID_i(workKi);
PID_PARAM(Kd, hotend) = scalePID_d(workKd);
updatePID();
}
#else
ECHO_LMV(DB, "#define DEFAULT_bedKp ", workKp);
ECHO_LMV(DB, "#define DEFAULT_bedKi ", unscalePID_i(workKi));
ECHO_LMV(DB, "#define DEFAULT_bedKd ", unscalePID_d(workKd));
if (set_result) {
bedKp = workKp;
bedKi = scalePID_i(workKi);
bedKd = scalePID_d(workKd);
updatePID();
} }
#endif #endif
return; return;
} }
lcd_update(); lcd_update();
......
...@@ -168,7 +168,9 @@ int getHeaterPower(int heater); ...@@ -168,7 +168,9 @@ int getHeaterPower(int heater);
void disable_all_heaters(); void disable_all_heaters();
void updatePID(); void updatePID();
void PID_autotune(float temp, int hotend, int ncycles); #if HAS(PID_HEATING)
void PID_autotune(float temp, int hotend, int ncycles, bool set_result = false);
#endif
void setExtruderAutoFanState(int pin, bool state); void setExtruderAutoFanState(int pin, bool state);
void checkExtruderAutoFans(); void checkExtruderAutoFans();
......
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