Commit e92e02e0 authored by Simone Primarosa's avatar Simone Primarosa

Merge pull request #1 from MagoKimbra/master

Update 4.1.4 dev
parents 1bee3854 b5c2d02a
......@@ -18,7 +18,7 @@ If jumping the arduino Vcc do RAMPS 5V rail, take care to not use a power hungry
Instructions for Both Options
-----------------------------
Uncomment the "ENABLE_AUTO_BED_LEVELING" define (commented by default)
Uncomment the "AUTO_BED_LEVELING_FEATURE" define (commented by default)
The following options define the probing positions. These are good starting values.
I recommend to keep a better clearance from borders in the first run and then make the probes as close as possible to borders:
......@@ -52,9 +52,14 @@ In order to get the servo working, you need to enable:
* \#define NUM_SERVOS 1 // Servo index starts with 0 for M280 command
* \#define SERVO_ENDSTOPS {-1, -1, 0} // Servo index for X, Y, Z. Disable with -1
* \// Define nr servo for endstop -1 not define. Servo index start 0
* \#define X_ENDSTOP_SERVO_NR -1
* \#define Y_ENDSTOP_SERVO_NR -1
* \#define Z_ENDSTOP_SERVO_NR 0
* \#define SERVO_ENDSTOP_ANGLES {0,0, 0,0, 165,60} // X,Y,Z Axis Extend and Retract angles
* \#define X_ENDSTOP_SERVO_ANGLES {0,0} // X Axis Extend and Retract angles
* \#define Y_ENDSTOP_SERVO_ANGLES {0,0} // Y Axis Extend and Retract angles
* \#define Z_ENDSTOP_SERVO_ANGLES {90,0} // Z Axis Extend and Retract angles
The first define tells firmware how many servos you have.
The second tells what axis this servo will be attached to. In the example above, we have a servo in Z axis.
......
......@@ -12,8 +12,7 @@
* G28 - X0 Y0 Z0 Home all Axis. G28 M for bed manual setting with LCD.
* G29 - Detailed Z-Probe, probes the bed at 3 points or grid. You must be at the home position for this to work correctly.
G29 Fyyy Lxxx Rxxx Byyy for customer grid.
* G30 - Single Z Probe, probes bed at current XY location.
Bed Probe and Delta geometry Autocalibration G30 A
* G30 - Single Z Probe, probes bed at current XY location. Bed Probe and Delta geometry Autocalibration G30 A
* G31 - Dock Z Probe sled (if enabled)
* G32 - Undock Z Probe sled (if enabled)
* G60 - Save current position coordinates (all axes, for active extruder). S<SLOT> - specifies memory slot # (0-based) to save into (default 0).
......@@ -60,7 +59,7 @@
* M109 - S[xxx] Wait for extruder current temp to reach target temp. Waits only when heating - R[xxx] Wait for extruder current temp to reach target temp. Waits when heating and cooling
* M111 - Debug Dryrun Repetier
* M112 - Emergency stop
* M114 - Output current position to serial port, (V)erbose for user
* M114 - Output current position to serial port, (V)erbose for user
* M115 - Capabilities string
* M117 - display message
* M119 - Output Endstop status to serial port
......@@ -100,8 +99,8 @@
* M405 - Turn on Filament Sensor extrusion control. Optional D[delay in cm] to set delay in centimeters between sensor and extruder
* M406 - Turn off Filament Sensor extrusion control
* M407 - Displays measured filament diameter
* M410 - Quickstop. Abort all the planned moves
* M428 - Set the home_offset logically based on the current_position
* M410 - Quickstop. Abort all the planned moves
* M428 - Set the home_offset logically based on the current_position
* M500 - stores paramters in EEPROM
* M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).
* M502 - reverts to the default "factory settings". You still need to store them in EEPROM afterwards if you want to.
......
### Version 4.1.4
* Add support for Piggy Alligator board
* Add Debug_info. Repetier button info for enabled or disabled, or M111 S2 for enabled and M111 S0 for disabled.
* Improved Topography Auto Bed Level.
* Add Dryrun ABL and verbose width command G29 D or G29 V(0-4).
* Improve Autoconfiguration for Delta printer.
* Add support (test only) for NEXTION HMI LCD.
* Improved firmare test dialog.
* Bugfix for SDCONFIG routine. Now the configuration file will be readed and created only on the root of the SD.
* Improved "Thermal Runaway Protection" now the system will be halted also if the thermistor is missing before the temperature is reached as suggested in Issue #35.
......
......@@ -3,6 +3,7 @@
#include "boards.h"
#include "macros.h"
#include "Default_Version.h"
//===========================================================================
//============================= Getting Started =============================
......@@ -28,11 +29,10 @@
// User-specified version info of this build to display in [Pronterface, etc] terminal window during
// startup. Implementation of an idea by Prof Braino to inform user that any changes made to this
// build by the user have been successfully uploaded into firmware.
#define BUILD_VERSION "4.1.4 dev"
#define STRING_DISTRIBUTION_DATE __DATE__ " " __TIME__ // build date and time
#define STRING_CONFIG_H_AUTHOR "(none, default config)" // Who made the changes.
#define STRING_SPLASH_LINE1 "v" BUILD_VERSION // will be shown during bootup in line 1
#define STRING_SPLASH_LINE2 STRING_DISTRIBUTION_DATE // will be shown during bootup in line 2
#define SHOW_BOOTSCREEN
#define STRING_SPLASH_LINE1 "v" SHORT_BUILD_VERSION // will be shown during bootup in line 1
//#define STRING_SPLASH_LINE2 STRING_DISTRIBUTION_DATE // will be shown during bootup in line 2
// SERIAL_PORT selects which serial port should be used for communication with the host.
// This allows the connection of wireless adapters (for instance) to non-default port pins.
......@@ -43,8 +43,8 @@
// 2400,9600,19200,38400,57600,115200,250000
#define BAUDRATE 115200
// This enables the serial port associated to the Bluetooth interface on AT90USB devices
//#define BTENABLED
// Enable the Bluetooth serial interface on AT90USB devices
//#define BLUETOOTH
// Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines)
// You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4)
......@@ -425,7 +425,6 @@
/**
* Nextion HMI panel
*/
//
//#define NEXTION
// option for invert rotary switch
......
......@@ -14,9 +14,11 @@
//#define ENDSTOPPULLUP_XMIN
//#define ENDSTOPPULLUP_YMIN
//#define ENDSTOPPULLUP_ZMIN
//#define ENDSTOPPULLUP_Z2MIN
//#define ENDSTOPPULLUP_XMAX
//#define ENDSTOPPULLUP_YMAX
//#define ENDSTOPPULLUP_ZMAX
//#define ENDSTOPPULLUP_Z2MAX
//#define ENDSTOPPULLUP_ZPROBE
//#define ENDSTOPPULLUP_EMIN
#endif
......@@ -26,12 +28,12 @@
#define Y_MIN_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
#define Z_MIN_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
#define Z2_MIN_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
#define E_MIN_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
#define X_MAX_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
#define Y_MAX_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
#define Z_MAX_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
#define Z2_MAX_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
#define Z_PROBE_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
#define E_MIN_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
// ENDSTOP SETTINGS:
// Sets direction of endstop when homing; 1=MAX, -1=MIN
......@@ -90,15 +92,15 @@
//If you have enabled the Auto Bed Levelling and are using the same Z Probe for Z Homing,
//it is highly recommended you let this Z_SAFE_HOMING enabled!!!
//#define Z_SAFE_HOMING
#ifdef Z_SAFE_HOMING
#if ENABLED(Z_SAFE_HOMING)
#define Z_SAFE_HOMING_X_POINT ((X_MIN_POS + X_MAX_POS) / 2) // X point for Z homing when homing all axis (G28)
#define Z_SAFE_HOMING_Y_POINT ((Y_MIN_POS + Y_MAX_POS) / 2) // Y point for Z homing when homing all axis (G28)
#endif
//#define ENABLE_AUTO_BED_LEVELING // Delete the comment to enable (ABL)
//#define Z_PROBE_REPEATABILITY_TEST // Delete the comment to enable
//#define AUTO_BED_LEVELING_FEATURE // Delete the comment to enable (remove // at the start of the line)
//#define Z_PROBE_REPEATABILITY_TEST // If not commented out, Z-Probe Repeatability test will be included if Auto Bed Leveling is Enabled.
#ifdef ENABLE_AUTO_BED_LEVELING
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
// There are 2 different ways to specify probing locations
//
......@@ -115,7 +117,7 @@
// Note: this feature generates 10KB extra code size
#define AUTO_BED_LEVELING_GRID
#ifdef AUTO_BED_LEVELING_GRID
#if ENABLED(AUTO_BED_LEVELING_GRID)
#define MIN_PROBE_EDGE 10 // The probe square sides can be no smaller than this
......@@ -162,7 +164,7 @@
//#define Z_PROBE_ENDSTOP
#endif // ENABLE_AUTO_BED_LEVELING
#endif // AUTO_BED_LEVELING_FEATURE
// The position of the homing switches
......@@ -197,15 +199,3 @@
#define DEFAULT_XYJERK 10.0 // (mm/sec)
#define DEFAULT_ZJERK 0.4 // (mm/sec)
#define DEFAULT_EJERK {5.0,5.0,5.0,5.0} // E0... (mm/sec) per extruder, max initial speed for retract moves
//===========================================================================
//=============================Additional Features===========================
//===========================================================================
// Custom M code points
//#define CUSTOM_M_CODES
#ifdef CUSTOM_M_CODES
#define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
#define Z_PROBE_OFFSET_RANGE_MIN -20
#define Z_PROBE_OFFSET_RANGE_MAX 20
#endif
......@@ -6,6 +6,21 @@
//=============================Mechanical Settings===========================
//===========================================================================
/***********************************************************************
************************ CORE X (YZ) MOLTIPLICATOR ********************
***********************************************************************
* This define the moltiplicator axis from X to Y or Z in COREXY or
* COREXZ.
* Example:
* COREXY set COREX_XZ_FACTOR 1
* The result is:
* X = dX + COREX_YZ_FACTOR * dY = dX + 1 * dY = dX + dY
* Y = dX - COREX_YZ_FACTOR * dY = dX - 1 * dY = dX - dY
* Z = dZ
*/
#define COREX_YZ_FACTOR 1
// coarse Endstop Settings
#define ENDSTOPPULLUPS // Comment this out (using // at the start of the line) to disable the endstop pullup resistors
......@@ -14,9 +29,11 @@
//#define ENDSTOPPULLUP_XMIN
//#define ENDSTOPPULLUP_YMIN
//#define ENDSTOPPULLUP_ZMIN
//#define ENDSTOPPULLUP_Z2MIN
//#define ENDSTOPPULLUP_XMAX
//#define ENDSTOPPULLUP_YMAX
//#define ENDSTOPPULLUP_ZMAX
//#define ENDSTOPPULLUP_Z2MAX
//#define ENDSTOPPULLUP_ZPROBE
//#define ENDSTOPPULLUP_EMIN
#endif
......@@ -26,12 +43,12 @@
#define Y_MIN_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
#define Z_MIN_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
#define Z2_MIN_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
#define E_MIN_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
#define X_MAX_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
#define Y_MAX_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
#define Z_MAX_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
#define Z2_MAX_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
#define Z_PROBE_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
#define E_MIN_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
// ENDSTOP SETTINGS:
// Sets direction of endstop when homing; 1=MAX, -1=MIN
......@@ -95,10 +112,10 @@
#define Z_SAFE_HOMING_Y_POINT ((Y_MIN_POS + Y_MAX_POS) / 2) // Y point for Z homing when homing all axis (G28)
#endif
//#define ENABLE_AUTO_BED_LEVELING // Delete the comment to enable (ABL)
//#define Z_PROBE_REPEATABILITY_TEST // Delete the comment to enable
//#define AUTO_BED_LEVELING_FEATURE // Delete the comment to enable (remove // at the start of the line)
//#define Z_PROBE_REPEATABILITY_TEST // If not commented out, Z-Probe Repeatability test will be included if Auto Bed Leveling is Enabled.
#ifdef ENABLE_AUTO_BED_LEVELING
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
// There are 2 different ways to specify probing locations
//
......@@ -115,7 +132,7 @@
// Note: this feature generates 10KB extra code size
#define AUTO_BED_LEVELING_GRID
#ifdef AUTO_BED_LEVELING_GRID
#if ENABLED(AUTO_BED_LEVELING_GRID)
#define MIN_PROBE_EDGE 10 // The probe square sides can be no smaller than this
......@@ -162,7 +179,7 @@
//#define Z_PROBE_ENDSTOP
#endif // ENABLE_AUTO_BED_LEVELING
#endif // AUTO_BED_LEVELING_FEATURE
// The position of the homing switches
......@@ -197,15 +214,3 @@
#define DEFAULT_XYJERK 10.0 // (mm/sec)
#define DEFAULT_ZJERK 0.4 // (mm/sec)
#define DEFAULT_EJERK {5.0,5.0,5.0,5.0} // E0... (mm/sec) per extruder, max initial speed for retract moves
//===========================================================================
//=============================Additional Features===========================
//===========================================================================
// Custom M code points
//#define CUSTOM_M_CODES
#ifdef CUSTOM_M_CODES
#define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
#define Z_PROBE_OFFSET_RANGE_MIN -20
#define Z_PROBE_OFFSET_RANGE_MAX 20
#endif
......@@ -19,8 +19,8 @@
#define SCARA_offset_y -56 //mm
#define SCARA_RAD2DEG 57.2957795 // to convert RAD to degrees
#define THETA_HOMING_OFFSET 0 //calculatated from Calibration Guide and command M360 / M114 see picture in http://reprap.harleystudio.co.za/?page_id=1073
#define PSI_HOMING_OFFSET 0 // calculatated from Calibration Guide and command M364 / M114 see picture in http://reprap.harleystudio.co.za/?page_id=1073
#define THETA_HOMING_OFFSET 0 //calculatated from Calibration Guide and command M360 / M114 see picture in http://reprap.harleystudio.co.za/?page_id=1073
#define PSI_HOMING_OFFSET 0 // calculatated from Calibration Guide and command M364 / M114 see picture in http://reprap.harleystudio.co.za/?page_id=1073
//some helper variables to make kinematics faster
#define L1_2 sq(Linkage_1) // do not change
......@@ -118,10 +118,10 @@
#define Z_SAFE_HOMING_Y_POINT ((Y_MIN_POS + Y_MAX_POS) / 2) // Y point for Z homing when homing all axis (G28)
#endif
//#define ENABLE_AUTO_BED_LEVELING // Delete the comment to enable (ABL)
//#define Z_PROBE_REPEATABILITY_TEST // Delete the comment to enable
//#define AUTO_BED_LEVELING_FEATURE // Delete the comment to enable (remove // at the start of the line)
//#define Z_PROBE_REPEATABILITY_TEST // If not commented out, Z-Probe Repeatability test will be included if Auto Bed Leveling is Enabled.
#ifdef ENABLE_AUTO_BED_LEVELING
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
// There are 2 different ways to specify probing locations
//
......@@ -138,7 +138,7 @@
// Note: this feature generates 10KB extra code size
#define AUTO_BED_LEVELING_GRID
#ifdef AUTO_BED_LEVELING_GRID
#if ENABLED(AUTO_BED_LEVELING_GRID)
#define MIN_PROBE_EDGE 10 // The probe square sides can be no smaller than this
......@@ -185,7 +185,7 @@
//#define Z_PROBE_ENDSTOP
#endif // ENABLE_AUTO_BED_LEVELING
#endif // AUTO_BED_LEVELING_FEATURE
// The position of the homing switches
......@@ -221,15 +221,3 @@
#define DEFAULT_XYJERK 5 // (mm/sec)
#define DEFAULT_ZJERK 0.4 // (mm/sec)
#define DEFAULT_EJERK {3.0,3.0,3.0,3.0} // (mm/sec)
//===========================================================================
//=============================Additional Features===========================
//===========================================================================
// Custom M code points
//#define CUSTOM_M_CODES
#ifdef CUSTOM_M_CODES
#define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
#define Z_PROBE_OFFSET_RANGE_MIN -20
#define Z_PROBE_OFFSET_RANGE_MAX 20
#endif
......@@ -70,7 +70,7 @@
* some filament is retracted. The filament retracted is re-added before the next extrusion
* or when the target temperature is less than IDLE_OOZING_MINTEMP and the actual temperature
* is greater than IDLE_OOZING_MINTEMP.
* PS: Always remember to set your extruder target temperature to 0°C before shoudown the printer if you enable this feature.
* PS: Always remember to set your extruder target temperature to 0°C before shoudown the printer if you enable this feature.
*/
//#define IDLE_OOZING_PREVENT
#define IDLE_OOZING_MINTEMP EXTRUDE_MINTEMP + 5
......@@ -143,7 +143,7 @@
#if ENABLED(Z_DUAL_STEPPER_DRIVERS)
// Z_DUAL_ENDSTOPS is a feature to enable the use of 2 endstops for both Z steppers - Let's call them Z stepper and Z2 stepper.
// Z DUAL ENDSTOPS is a feature to enable the use of 2 endstops for both Z steppers - Let's call them Z stepper and Z2 stepper.
// That way the machine is capable to align the bed during home, since both Z steppers are homed.
// There is also an implementation of M666 (software endstops adjustment) to this feature.
// After Z homing, this adjustment is applied to just one of the steppers in order to align the bed.
......@@ -152,17 +152,7 @@
// Play a little bit with small adjustments (0.5mm) and check the behaviour.
// The M119 (endstops report) will start reporting the Z2 Endstop as well.
#define Z2_STEP_PIN E2_STEP_PIN // Stepper to be used to Z2 axis.
#define Z2_DIR_PIN E2_DIR_PIN
#define Z2_ENABLE_PIN E2_ENABLE_PIN
// #define Z_DUAL_ENDSTOPS
#if ENABLED(Z_DUAL_ENDSTOPS)
#define Z2_MAX_PIN 36 //Endstop used for Z2 axis. In this case I'm using XMAX in a Rumba Board (pin 36)
const bool Z2_MAX_ENDSTOP_INVERTING = false;
#define DISABLE_XMAX_ENDSTOP //Better to disable the XMAX to avoid conflict. Just rename "XMAX_ENDSTOP" by the endstop you are using for Z2 axis.
#endif
//#define Z_DUAL_ENDSTOPS
#endif // Z_DUAL_STEPPER_DRIVERS
......@@ -269,7 +259,7 @@
#define MICROSTEP_MODES {16, 16, 16, 16} // X Y Z E - [1,2,4,8,16,32]
// Motor Current setting (Only functional on ALLIGATOR BOARD)
#define MOTOR_CURRENT {1, 1, 1, 1} // X Y Z E - Values 0 - 2.5 A
#define MOTOR_CURRENT {1, 1, 1, 1, 1, 1, 1} // X Y Z E0 E1 E2 E3 - Values 0 - 2.5 A
// Motor Current setting (Only functional when motor driver current ref pins are connected to a digital trimpot on supported boards)
#define DIGIPOT_MOTOR_CURRENT {135,135,135,135,135} // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A)
......
/*
* This file is a placeholder for a file which could be distributed in an archive
* It takes the place of an automatically created "_Version.h" which is generated during the build process
*/
// #error "You must specify the following parameters related to your distribution"
#if true
#define SHORT_BUILD_VERSION "4.1.4 dev"
#define STRING_DISTRIBUTION_DATE __DATE__ " " __TIME__ // build date and time
// It might also be appropriate to define a location where additional information can be found
#define SOURCE_CODE_URL "https://github.com/MagoKimbra/MarlinKimbra"
#endif
\ No newline at end of file
......@@ -281,12 +281,12 @@ void MarlinSerial::printFloat(double number, uint8_t digits) {
// Preinstantiate Objects //////////////////////////////////////////////////////
MarlinSerial MSerial;
MarlinSerial customizedSerial;
#endif // whole file
#endif // !USBCON
// For AT90USB targets use the UART for BT interfacing
#if defined(USBCON) && ENABLED(BTENABLED)
HardwareSerial bt;
#if defined(USBCON) && ENABLED(BLUETOOTH)
HardwareSerial bluetoothSerial;
#endif
......@@ -30,8 +30,8 @@
// The presence of the UBRRH register is used to detect a UART.
#define UART_PRESENT(port) ((port == 0 && (defined(UBRRH) || defined(UBRR0H))) || \
(port == 1 && defined(UBRR1H)) || (port == 2 && defined(UBRR2H)) || \
(port == 3 && defined(UBRR3H)))
(port == 3 && defined(UBRR3H)))
// These are macros to build serial port register names for the selected SERIAL_PORT (C preprocessor
// requires two levels of indirection to expand macro values properly)
#define SERIAL_REGNAME(registerbase,number,suffix) SERIAL_REGNAME_INTERNAL(registerbase,number,suffix)
......@@ -149,12 +149,12 @@ class MarlinSerial { //: public Stream
void println(void);
};
extern MarlinSerial MSerial;
extern MarlinSerial customizedSerial;
#endif // !USBCON
// Use the UART for BT in AT90USB configurations
#if defined(USBCON) && ENABLED(BTENABLED)
extern HardwareSerial bt;
// Use the UART for Bluetooth in AT90USB configurations
#if defined(USBCON) && ENABLED(BLUETOOTH)
extern HardwareSerial bluetoothSerial;
#endif
#endif
......@@ -29,12 +29,12 @@
#include "Marlin.h"
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
#include "vector_3.h"
#if ENABLED(AUTO_BED_LEVELING_GRID)
#include "qr_solve.h"
#endif
#endif // ENABLE_AUTO_BED_LEVELING
#endif // AUTO_BED_LEVELING_FEATURE
#include "ultralcd.h"
......@@ -747,9 +747,6 @@ void setup() {
Config_RetrieveSettings();
lcd_init();
#ifndef NEXTION
delay(SPLASH_SCREEN_DURATION); // wait to display the splash screen
#endif
tp_init(); // Initialize temperature loop
plan_init(); // Initialize planner;
......@@ -767,11 +764,11 @@ void setup() {
enableStepperDrivers();
#endif
#ifdef DIGIPOT_I2C
#if ENABLED(DIGIPOT_I2C)
digipot_i2c_init();
#endif
#ifdef Z_PROBE_SLED
#if ENABLED(Z_PROBE_SLED)
pinMode(SLED_PIN, OUTPUT);
digitalWrite(SLED_PIN, LOW); // turn it off
#endif // Z_PROBE_SLED
......@@ -788,7 +785,7 @@ void setup() {
digitalWrite(STAT_LED_BLUE, LOW); // turn it off
#endif
#ifdef FIRMWARE_TEST
#if ENABLED(FIRMWARE_TEST)
FirmwareTest();
#endif // FIRMWARE_TEST
}
......@@ -865,7 +862,7 @@ void get_command() {
if (drain_queued_commands_P()) return; // priority is given to non-serial commands
#ifdef NO_TIMEOUTS
#if ENABLED(NO_TIMEOUTS)
static millis_t last_command_time = 0;
millis_t ms = millis();
......@@ -880,7 +877,7 @@ void get_command() {
//
while (MYSERIAL.available() > 0 && commands_in_queue < BUFSIZE) {
#ifdef NO_TIMEOUTS
#if ENABLED(NO_TIMEOUTS)
last_command_time = ms;
#endif
......@@ -905,15 +902,13 @@ void get_command() {
#endif
char *npos = strchr(command, 'N');
if (npos == NULL) npos = strchr(command, 'n');
char *apos = strchr(command, '*');
if (npos) {
boolean M110 = strstr_P(command, PSTR("M110")) != NULL || strstr_P(command, PSTR("m110")) != NULL;
boolean M110 = strstr_P(command, PSTR("M110")) != NULL;
if (M110) {
char *n2pos = strchr(command + 4, 'N');
if (n2pos == NULL) n2pos = strchr(command + 4, 'n');
if (n2pos) npos = n2pos;
}
......@@ -924,8 +919,6 @@ void get_command() {
return;
}
gcode_LastN = gcode_N;
if (apos) {
byte checksum = 0, count = 0;
while (command[count] != '*') checksum ^= command[count++];
......@@ -940,6 +933,9 @@ void get_command() {
gcode_line_error(PSTR(MSG_ERR_NO_CHECKSUM));
return;
}
gcode_LastN = gcode_N;
// if no errors, continue parsing
}
else if (apos) { // No '*' without 'N'
gcode_line_error(PSTR(MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM), false);
......@@ -949,7 +945,6 @@ void get_command() {
// Movement commands alert when stopped
if (IsStopped()) {
char *gpos = strchr(command, 'G');
if (gpos == NULL) gpos = strchr(command, 'g');
if (gpos) {
int codenum = strtol(gpos + 1, NULL, 10);
switch (codenum) {
......@@ -965,7 +960,7 @@ void get_command() {
}
// If command was e-stop process now
if (strcmp(command, "M112") == 0 || strcmp(command, "m112") == 0) kill(PSTR(MSG_KILLED));
if (strcmp(command, "M112") == 0) kill(PSTR(MSG_KILLED));
cmd_queue_index_w = (cmd_queue_index_w + 1) % BUFSIZE;
commands_in_queue += 1;
......@@ -1050,7 +1045,7 @@ bool code_has_value() {
float code_value() {
float ret;
char *e = strchr(seen_pointer, 'E'); if (e == NULL) e = strchr(seen_pointer, 'e');
char *e = strchr(seen_pointer, 'E');
if (e) {
*e = 0;
ret = strtod(seen_pointer + 1, NULL);
......@@ -1067,7 +1062,6 @@ int16_t code_value_short() { return (int16_t)strtol(seen_pointer + 1, NULL, 10);
bool code_seen(char code) {
seen_pointer = strchr(current_command_args, code); // +3 since "G0 " is the shortest prefix
if (seen_pointer == NULL) seen_pointer = strchr(current_command_args, code + ('a'-'A'));
return (seen_pointer != NULL); //Return True if a character was found
}
......@@ -1093,7 +1087,7 @@ XYZ_CONSTS_FROM_CONFIG(float, base_min_pos, MIN_POS);
XYZ_CONSTS_FROM_CONFIG(float, home_bump_mm, HOME_BUMP_MM);
XYZ_CONSTS_FROM_CONFIG(signed char, home_dir, HOME_DIR);
#ifdef DUAL_X_CARRIAGE
#if ENABLED(DUAL_X_CARRIAGE)
#define DXC_FULL_CONTROL_MODE 0
#define DXC_AUTO_PARK_MODE 1
......@@ -1126,9 +1120,21 @@ XYZ_CONSTS_FROM_CONFIG(signed char, home_dir, HOME_DIR);
#endif //DUAL_X_CARRIAGE
static void axis_is_at_home(AxisEnum axis) {
void print_xyz(const char *prefix, const float x, const float y, const float z, bool eol = true) {
ECHO_V(prefix);
ECHO_MV(": (", x);
ECHO_MV(", ", y);
ECHO_MV(", ", z);
ECHO_M(")");
if (eol) ECHO_E;
}
void print_xyz(const char *prefix, const float xyz[], bool eol = true) {
print_xyz(prefix, xyz[X_AXIS], xyz[Y_AXIS], xyz[Z_AXIS], eol);
}
#ifdef DUAL_X_CARRIAGE
static void set_axis_is_at_home(AxisEnum axis) {
#if ENABLED(DUAL_X_CARRIAGE)
if (axis == X_AXIS) {
if (active_extruder != 0) {
current_position[X_AXIS] = x_home_pos(active_extruder);
......@@ -1146,7 +1152,7 @@ static void axis_is_at_home(AxisEnum axis) {
}
#endif
#ifdef SCARA
#if ENABLED(SCARA)
if (axis == X_AXIS || axis == Y_AXIS) {
......@@ -1186,7 +1192,7 @@ static void axis_is_at_home(AxisEnum axis) {
min_pos[axis] = base_min_pos(axis) + home_offset[axis];
max_pos[axis] = base_max_pos(axis) + home_offset[axis];
}
#elif defined(DELTA)
#elif ENABLED(DELTA)
current_position[axis] = base_home_pos[axis] + home_offset[axis];
min_pos[axis] = base_min_pos(axis) + home_offset[axis];
max_pos[axis] = base_max_pos[axis] + home_offset[axis];
......@@ -1196,9 +1202,15 @@ static void axis_is_at_home(AxisEnum axis) {
max_pos[axis] = base_max_pos(axis) + home_offset[axis];
#endif
#if defined(ENABLE_AUTO_BED_LEVELING) && Z_HOME_DIR < 0
#if ENABLED(AUTO_BED_LEVELING_FEATURE) && Z_HOME_DIR < 0
if (axis == Z_AXIS) current_position[Z_AXIS] -= zprobe_zoffset;
#endif
if (debugLevel & DEBUG_INFO) {
ECHO_SMV(DB, "set_axis_is_at_home ", (unsigned long)axis);
ECHO_MV(" > (home_offset[axis]==", home_offset[axis]);
print_xyz(") > current_position", current_position);
}
}
/**
......@@ -1251,7 +1263,7 @@ static void setup_for_endstop_move() {
}
static void clean_up_after_endstop_move() {
#ifdef ENDSTOPS_ONLY_FOR_HOMING
#if ENABLED(ENDSTOPS_ONLY_FOR_HOMING)
enable_endstops(false);
#endif
feedrate = saved_feedrate;
......@@ -1260,7 +1272,7 @@ static void clean_up_after_endstop_move() {
refresh_cmd_timeout();
}
#if defined(CARTESIAN) || defined(COREXY) || defined(COREXZ) || defined(SCARA)
#if ENABLED(CARTESIAN) || ENABLED(COREXY) || ENABLED(COREXZ) || ENABLED(SCARA)
/**
* Plan a move to (X, Y, Z) and set the current_position
......@@ -1270,6 +1282,11 @@ static void clean_up_after_endstop_move() {
float oldFeedRate = feedrate;
feedrate = homing_feedrate[Z_AXIS];
if (debugLevel & DEBUG_INFO) {
ECHO_S(DB);
print_xyz("do_blocking_move_to", x, y, z);
}
current_position[Z_AXIS] = z;
line_to_current_position();
st_synchronize();
......@@ -1288,9 +1305,9 @@ static void clean_up_after_endstop_move() {
inline void do_blocking_move_to_x(float x) { do_blocking_move_to(x, current_position[Y_AXIS], current_position[Z_AXIS]); }
inline void do_blocking_move_to_z(float z) { do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z); }
#ifdef ENABLE_AUTO_BED_LEVELING
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
#ifdef AUTO_BED_LEVELING_GRID
#if ENABLED(AUTO_BED_LEVELING_GRID)
static void set_bed_level_equation_lsq(double *plane_equation_coefficients) {
vector_3 planeNormal = vector_3(-plane_equation_coefficients[0], -plane_equation_coefficients[1], 1);
planeNormal.debug("planeNormal");
......@@ -1307,6 +1324,11 @@ static void clean_up_after_endstop_move() {
current_position[Y_AXIS] = corrected_position.y;
current_position[Z_AXIS] = corrected_position.z;
if (debugLevel & DEBUG_INFO) {
ECHO_S(DB);
print_xyz("set_bed_level_equation_lsq > current_position", current_position);
}
sync_plan_position();
}
#else // not AUTO_BED_LEVELING_GRID
......@@ -1332,6 +1354,11 @@ static void clean_up_after_endstop_move() {
current_position[Y_AXIS] = corrected_position.y;
current_position[Z_AXIS] = corrected_position.z;
if (debugLevel & DEBUG_INFO) {
ECHO_S(DB);
print_xyz("set_bed_level_equation_3pts > current_position", current_position);
}
sync_plan_position();
}
......@@ -1368,9 +1395,18 @@ static void clean_up_after_endstop_move() {
// Get the current stepper position after bumping an endstop
current_position[Z_AXIS] = st_get_position_mm(Z_AXIS);
sync_plan_position();
if (debugLevel & DEBUG_INFO) {
ECHO_S(DB);
print_xyz("run_z_probe > current_position", current_position);
}
}
static void deploy_z_probe() {
if (debugLevel & DEBUG_INFO) {
ECHO_S(DB);
print_xyz("deploy_z_probe > current_position", current_position);
}
#if HAS_SERVO_ENDSTOPS
// Engage Z Servo endstop if enabled
if (servo_endstop_id[Z_AXIS] >= 0) servo[servo_endstop_id[Z_AXIS]].move(servo_endstop_angle[Z_AXIS][0]);
......@@ -1378,12 +1414,20 @@ static void clean_up_after_endstop_move() {
}
static void stow_z_probe(bool doRaise = true) {
if (debugLevel & DEBUG_INFO) {
ECHO_S(DB);
print_xyz("stow_z_probe > current_position", current_position);
}
#if HAS_SERVO_ENDSTOPS
// Retract Z Servo endstop if enabled
if (servo_endstop_id[Z_AXIS] >= 0) {
#if Z_RAISE_AFTER_PROBING > 0
if (doRaise) {
if (debugLevel & DEBUG_INFO) {
ECHO_LMV(DB, "Raise Z (after) by ", (float)Z_RAISE_AFTER_PROBING);
ECHO_LMV(DB, "> SERVO_ENDSTOPS > do_blocking_move_to_z ", current_position[Z_AXIS] + Z_RAISE_AFTER_PROBING);
}
do_blocking_move_to_z(current_position[Z_AXIS] + Z_RAISE_AFTER_PROBING); // this also updates current_position
st_synchronize();
}
......@@ -1404,19 +1448,39 @@ static void clean_up_after_endstop_move() {
// Probe bed height at position (x,y), returns the measured z value
static float probe_pt(float x, float y, float z_before, ProbeAction probe_action = ProbeDeployAndStow, int verbose_level = 1) {
// move to right place
if (debugLevel & DEBUG_INFO) {
ECHO_LM(DB, "probe_pt >>>");
ECHO_SMV(DB, "> ProbeAction:", (unsigned long)probe_action);
print_xyz(" > current_position", current_position);
ECHO_SMV(DB, "Z Raise to z_before ", z_before);
ECHO_EMV(" > do_blocking_move_to_z ", z_before);
}
// Move Z up to the z_before height, then move the probe to the given XY
do_blocking_move_to_z(z_before); // this also updates current_position
if (debugLevel & DEBUG_INFO) {
ECHO_SMV(DB, "> do_blocking_move_to_xy ", x - X_PROBE_OFFSET_FROM_EXTRUDER);
ECHO_EMV(", ", y - Y_PROBE_OFFSET_FROM_EXTRUDER);
}
do_blocking_move_to_xy(x - X_PROBE_OFFSET_FROM_EXTRUDER, y - Y_PROBE_OFFSET_FROM_EXTRUDER); // this also updates current_position
#ifndef Z_PROBE_SLED
if (probe_action & ProbeDeploy) deploy_z_probe();
#endif // Z_PROBE_SLED
#if DISABLED(Z_PROBE_SLED)
if (probe_action & ProbeDeploy) {
if (debugLevel & DEBUG_INFO) ECHO_LM(DB, "> ProbeDeploy");
deploy_z_probe();
}
#endif
run_z_probe();
float measured_z = current_position[Z_AXIS];
#ifndef Z_PROBE_SLED
if (probe_action & ProbeStow) stow_z_probe();
#if DISABLED(Z_PROBE_SLED)
if (probe_action & ProbeStow) {
if (debugLevel & DEBUG_INFO) ECHO_LM(DB, "> ProbeStow (stow_z_probe will do Z Raise)");
stow_z_probe();
}
#endif
if (verbose_level > 2) {
......@@ -1425,18 +1489,35 @@ static void clean_up_after_endstop_move() {
ECHO_MV(MSG_BED_LEVELLING_Y, y, 3);
ECHO_EMV(MSG_BED_LEVELLING_Z, measured_z, 3);
}
if (debugLevel & DEBUG_INFO) ECHO_LM(DB, "<<< probe_pt");
return measured_z;
}
#endif //ENABLE_AUTO_BED_LEVELING
#if HAS_SERVO_ENDSTOPS && DISABLED(Z_PROBE_SLED)
void raise_z_for_servo() {
float zpos = current_position[Z_AXIS], z_dest = Z_RAISE_BEFORE_PROBING;
z_dest += axis_known_position[Z_AXIS] ? zprobe_zoffset : zpos;
if (zpos < z_dest) do_blocking_move_to_z(z_dest); // also updates current_position
}
#endif
#endif //AUTO_BED_LEVELING_FEATURE
static void homeaxis(AxisEnum axis) {
#define HOMEAXIS_DO(LETTER) \
((LETTER##_MIN_PIN > -1 && LETTER##_HOME_DIR==-1) || (LETTER##_MAX_PIN > -1 && LETTER##_HOME_DIR==1))
if (debugLevel & DEBUG_INFO) {
ECHO_SMV(DB, ">>> homeaxis(", (unsigned long)axis);
ECHO_EM(")");
}
if (axis == X_AXIS ? HOMEAXIS_DO(X) : axis == Y_AXIS ? HOMEAXIS_DO(Y) : axis == Z_AXIS ? HOMEAXIS_DO(Z) : 0) {
int axis_home_dir =
#ifdef DUAL_X_CARRIAGE
#if ENABLED(DUAL_X_CARRIAGE)
(axis == X_AXIS) ? x_home_dir(active_extruder) :
#endif
home_dir(axis);
......@@ -1445,7 +1526,7 @@ static void clean_up_after_endstop_move() {
current_position[axis] = 0;
sync_plan_position();
#ifdef Z_PROBE_SLED
#if ENABLED(Z_PROBE_SLED)
// Get Probe
if (axis == Z_AXIS) {
if (axis_home_dir < 0) dock_sled(false);
......@@ -1466,7 +1547,7 @@ static void clean_up_after_endstop_move() {
#endif
// Set a flag for Z motor locking
#ifdef Z_DUAL_ENDSTOPS
#if ENABLED(Z_DUAL_ENDSTOPS)
if (axis == Z_AXIS) In_Homing_Process(true);
#endif
......@@ -1497,6 +1578,11 @@ static void clean_up_after_endstop_move() {
line_to_destination();
st_synchronize();
if (debugLevel & DEBUG_INFO) {
ECHO_S(DB);
print_xyz("> TRIGGER ENDSTOP > current_position", current_position);
}
#ifdef Z_DUAL_ENDSTOPS
if (axis == Z_AXIS) {
float adj = fabs(z_endstop_adj);
......@@ -1523,9 +1609,14 @@ static void clean_up_after_endstop_move() {
#endif
// Set the axis position to its home position (plus home offsets)
axis_is_at_home(axis);
set_axis_is_at_home(axis);
sync_plan_position();
if (debugLevel & DEBUG_INFO) {
ECHO_S(DB);
print_xyz("> AFTER set_axis_is_at_home > current_position", current_position);
}
destination[axis] = current_position[axis];
feedrate = 0.0;
endstops_hit_on_purpose(); // clear endstop hit flags
......@@ -1541,23 +1632,32 @@ static void clean_up_after_endstop_move() {
#if SERVO_LEVELING && DISABLED(Z_PROBE_SLED)
// Deploy a probe if there is one, and homing towards the bed
if (axis == Z_AXIS) {
if (axis_home_dir < 0) stow_z_probe();
if (axis_home_dir < 0) {
if (debugLevel & DEBUG_INFO) ECHO_LM(DB, "> SERVO_LEVELING > stow_z_probe");
stow_z_probe();
}
}
else
#endif
{
#if HAS_SERVO_ENDSTOPS
// Retract Servo endstop if enabled
if (servo_endstop_id[axis] >= 0)
servo[servo_endstop_id[axis]].move(servo_endstop_angle[axis][1]);
if (servo_endstop_id[axis] >= 0) {
if (debugLevel & DEBUG_INFO) ECHO_LM(DB, "> SERVO_ENDSTOPS > Stow with servo.move()");
servo[servo_endstop_id[axis]].move(servo_endstop_angle[axis][1]);
}
#endif
}
}
if (debugLevel & DEBUG_INFO) {
ECHO_SMV(DB, "<<< homeaxis(", (unsigned long)axis);
ECHO_EM(")");
}
}
#define HOMEAXIS(LETTER) homeaxis(LETTER##_AXIS)
#endif // CARTESIAN || COREXY || COREXZ || SCARA
#ifdef DELTA
#if ENABLED(DELTA)
static void homeaxis(AxisEnum axis) {
#define HOMEAXIS_DO(LETTER) \
......@@ -1601,15 +1701,26 @@ static void clean_up_after_endstop_move() {
enable_endstops(false); // Disable endstops while moving away
sync_plan_position();
destination[axis] = endstop_adj[axis];
if (debugLevel & DEBUG_INFO) {
ECHO_SMV(DB, "> endstop_adj = ", endstop_adj[axis]);
print_xyz(" > destination", destination);
}
line_to_destination();
st_synchronize();
enable_endstops(true); // Enable endstops for next homing move
}
if (debugLevel & DEBUG_INFO) ECHO_LMV(DB, "> endstop_adj * axis_home_dir = ", endstop_adj[axis] * axis_home_dir);
// Set the axis position to its home position (plus home offsets)
axis_is_at_home(axis);
set_axis_is_at_home(axis);
sync_plan_position();
if (debugLevel & DEBUG_INFO) {
ECHO_S(DB);
print_xyz("> AFTER set_axis_is_at_home > current_position", current_position);
}
destination[axis] = current_position[axis];
feedrate = 0.0;
endstops_hit_on_purpose(); // clear endstop hit flags
......@@ -1687,6 +1798,7 @@ static void clean_up_after_endstop_move() {
// Reset calibration results to zero.
void reset_bed_level() {
if (debugLevel & DEBUG_INFO) ECHO_LM(DB, "reset_bed_level");
for (int y = 0; y < AUTO_BED_LEVELING_GRID_POINTS; y++) {
for (int x = 0; x < AUTO_BED_LEVELING_GRID_POINTS; x++) {
bed_level[x][y] = 0.0;
......@@ -2471,6 +2583,10 @@ static void clean_up_after_endstop_move() {
}
void prepare_move_raw() {
if (debugLevel & DEBUG_INFO) {
ECHO_S(DB);
print_xyz("prepare_move_raw > destination", destination);
}
refresh_cmd_timeout();
calculate_delta(destination);
plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], feedrate*feedrate_multiplier/60/100.0, active_extruder, active_driver);
......@@ -2611,7 +2727,7 @@ static void clean_up_after_endstop_move() {
} // retract()
#endif //FWRETRACT
#ifdef Z_PROBE_SLED
#if ENABLED(Z_PROBE_SLED)
#ifndef SLED_DOCKING_OFFSET
#define SLED_DOCKING_OFFSET 0
......@@ -2624,6 +2740,8 @@ static void clean_up_after_endstop_move() {
* offset[in] The additional distance to move to adjust docking location
*/
static void dock_sled(bool dock, int offset=0) {
if (debugLevel & DEBUG_INFO) ECHO_LMV(DB, "dock_sled", dock);
if (!axis_known_position[X_AXIS] || !axis_known_position[Y_AXIS]) {
LCD_MESSAGEPGM(MSG_POSITION_UNKNOWN);
ECHO_LM(DB, MSG_POSITION_UNKNOWN);
......@@ -2871,11 +2989,13 @@ inline void gcode_G4() {
*/
inline void gcode_G28() {
if (debugLevel & DEBUG_INFO) ECHO_LM(DB, "gcode_G28 >>>");
// Wait for planner moves to finish!
st_synchronize();
// For auto bed leveling, clear the level matrix
#ifdef ENABLE_AUTO_BED_LEVELING
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
plan_bed_level_matrix.set_to_identity();
#elif defined(DELTA)
reset_bed_level();
......@@ -2904,7 +3024,7 @@ inline void gcode_G28() {
}
#endif
#ifdef DELTA
#if ENABLED(DELTA)
// A delta can only safely home all axis at the same time
// all axis have to home at the same time
......@@ -2929,6 +3049,11 @@ inline void gcode_G28() {
sync_plan_position_delta();
if (debugLevel & DEBUG_INFO) {
ECHO_S(DB);
print_xyz("(DELTA) > current_position", current_position);
}
#else // NOT DELTA
if (home_all_axis || homeZ) {
......@@ -2936,12 +3061,19 @@ inline void gcode_G28() {
#if Z_HOME_DIR > 0 // If homing away from BED do Z first
HOMEAXIS(Z);
if (debugLevel & DEBUG_INFO) {
ECHO_S(DB);
print_xyz("> HOMEAXIS(Z) > current_position", current_position);
}
#elif !defined(Z_SAFE_HOMING) && defined(Z_RAISE_BEFORE_HOMING) && Z_RAISE_BEFORE_HOMING > 0
#elif DISABLED(Z_SAFE_HOMING) && defined(Z_RAISE_BEFORE_HOMING) && Z_RAISE_BEFORE_HOMING > 0
// Raise Z before homing any other axes
destination[Z_AXIS] = -Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS); // Set destination away from bed
if (debugLevel & DEBUG_INFO) {
ECHO_SMV(DB, "Raise Z (before homing) by ", (float)Z_RAISE_BEFORE_HOMING);
print_xyz(" > (home_all_axis || homeZ) > destination", destination);
}
feedrate = max_feedrate[Z_AXIS] * 60;
line_to_destination();
st_synchronize();
......@@ -2974,10 +3106,15 @@ inline void gcode_G28() {
line_to_destination();
st_synchronize();
axis_is_at_home(X_AXIS);
axis_is_at_home(Y_AXIS);
set_axis_is_at_home(X_AXIS);
set_axis_is_at_home(Y_AXIS);
sync_plan_position();
if (debugLevel & DEBUG_INFO) {
ECHO_S(DB);
print_xyz("> QUICK_HOME > current_position 1", current_position);
}
destination[X_AXIS] = current_position[X_AXIS];
destination[Y_AXIS] = current_position[Y_AXIS];
line_to_destination();
......@@ -2987,11 +3124,15 @@ inline void gcode_G28() {
current_position[X_AXIS] = destination[X_AXIS];
current_position[Y_AXIS] = destination[Y_AXIS];
#ifndef SCARA
#if DISABLED(SCARA)
current_position[Z_AXIS] = destination[Z_AXIS];
#endif
}
if (debugLevel & DEBUG_INFO) {
ECHO_S(DB);
print_xyz("> QUICK_HOME > current_position 2", current_position);
}
}
#endif // QUICK_HOME
#ifdef HOME_Y_BEFORE_X
......@@ -3016,16 +3157,26 @@ inline void gcode_G28() {
#else
HOMEAXIS(X);
#endif
if (debugLevel & DEBUG_INFO) {
ECHO_S(DB);
print_xyz("> homeX", current_position);
}
}
#ifndef HOME_Y_BEFORE_X
#if DISABLED(HOME_Y_BEFORE_X)
// Home Y
if (home_all_axis || homeY) HOMEAXIS(Y);
if (home_all_axis || homeY) {
HOMEAXIS(Y);
if (debugLevel & DEBUG_INFO) {
ECHO_S(DB);
print_xyz("> homeY", current_position);
}
}
#endif
// Home Z last if homing towards the bed
#if Z_HOME_DIR < 0
#ifndef Z_SAFE_HOMING
#if DISABLED(Z_SAFE_HOMING)
if (code_seen('M') && !(homeX || homeY)) {
// Manual G28 bed level
#ifdef ULTIPANEL
......@@ -3116,8 +3267,17 @@ inline void gcode_G28() {
enqueuecommands_P(PSTR("G28"));
#endif // ULTIPANEL
}
else if (home_all_axis || homeZ) HOMEAXIS(Z);
#elif defined(Z_SAFE_HOMING) && defined(ENABLE_AUTO_BED_LEVELING)// Z Safe mode activated.
else if (home_all_axis || homeZ) {
HOMEAXIS(Z);
if (debugLevel & DEBUG_INFO) {
ECHO_S(DB);
print_xyz("> (home_all_axis || homeZ) > final", current_position);
}
}
#elif ENABLED(Z_SAFE_HOMING) && ENABLED(AUTO_BED_LEVELING_FEATURE)// Z Safe mode activated.
if (debugLevel & DEBUG_INFO) ECHO_LM(DB, "> Z_SAFE_HOMING >>>");
if (home_all_axis) {
current_position[Z_AXIS] = 0;
......@@ -3132,6 +3292,13 @@ inline void gcode_G28() {
destination[Y_AXIS] = round(Z_SAFE_HOMING_Y_POINT - Y_PROBE_OFFSET_FROM_EXTRUDER);
destination[Z_AXIS] = -Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS);
feedrate = xy_travel_speed;
if (debugLevel & DEBUG_INFO) {
ECHO_SMV(DB, "Raise Z (before homing) by ", (float)Z_RAISE_BEFORE_HOMING);
print_xyz(" > home_all_axis > current_position", current_position, false);
print_xyz(" > home_all_axis > destination", destination);
}
// This could potentially move X, Y, Z all together
line_to_destination();
st_synchronize();
......@@ -3161,6 +3328,13 @@ inline void gcode_G28() {
// Set Z destination away from bed and raise the axis
destination[Z_AXIS] = -Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS); // Set destination away from bed
feedrate = max_feedrate[Z_AXIS] * 60;
if (debugLevel & DEBUG_INFO) {
ECHO_SMV(DB, "Raise Z (before homing) by ", (float)Z_RAISE_BEFORE_HOMING);
print_xyz(" > homeZ > current_position", current_position, false);
print_xyz(" > homeZ > destination", destination);
}
line_to_destination();
st_synchronize();
......@@ -3177,7 +3351,8 @@ inline void gcode_G28() {
ECHO_LM(ER, MSG_POSITION_UNKNOWN);
}
}
#elif defined(Z_SAFE_HOMING)
if (debugLevel & DEBUG_INFO) ECHO_LM(DB, "<<< Z_SAFE_HOMING");
#elif ENABLED(Z_SAFE_HOMING)
if (home_all_axis || homeZ) {
// Let's see if X and Y are homed
......@@ -3189,6 +3364,13 @@ inline void gcode_G28() {
destination[Y_AXIS] = round(Z_SAFE_HOMING_Y_POINT);
destination[Z_AXIS] = current_position[Z_AXIS] = 0;
feedrate = xy_travel_speed;
if (debugLevel & DEBUG_INFO) {
ECHO_SMV(DB, "Raise Z (before homing) by ", (float)Z_RAISE_BEFORE_HOMING);
print_xyz(" > home_all_axis > current_position", current_position, false);
print_xyz(" > home_all_axis > destination", destination);
}
// This could potentially move X, Y, Z all together
line_to_destination();
st_synchronize();
......@@ -3203,6 +3385,7 @@ inline void gcode_G28() {
ECHO_LM(ER, MSG_POSITION_UNKNOWN);
}
}
if (debugLevel & DEBUG_INFO) ECHO_LM(DB, "<<< Z_SAFE_HOMING");
#endif //Z_SAFE_HOMING
#endif //Z_HOME_DIR < 0
......@@ -3210,14 +3393,14 @@ inline void gcode_G28() {
#endif // !DELTA
#ifdef SCARA
#if ENABLED(SCARA)
sync_plan_position_delta();
#endif
clean_up_after_endstop_move();
}
#ifdef ENABLE_AUTO_BED_LEVELING
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
void out_of_range_error(const char *p_edge) {
ECHO_M("?Probe ");
......@@ -3263,6 +3446,8 @@ inline void gcode_G28() {
*/
inline void gcode_G29() {
if (debugLevel & DEBUG_INFO) ECHO_LM(DB, "gcode_G29 >>>");
// Don't allow auto-leveling without homing first
if (!axis_known_position[X_AXIS] || !axis_known_position[Y_AXIS]) {
LCD_MESSAGEPGM(MSG_POSITION_UNKNOWN);
......@@ -3270,16 +3455,16 @@ inline void gcode_G28() {
return;
}
int verbose_level = code_seen('V') || code_seen('v') ? code_value_short() : 1;
int verbose_level = code_seen('V') ? code_value_short() : 1;
if (verbose_level < 0 || verbose_level > 4) {
ECHO_LM(ER,"?(V)erbose Level is implausible (0-4).");
return;
}
bool dryrun = code_seen('D') || code_seen('d'),
bool dryrun = code_seen('D'),
deploy_probe_for_each_reading = code_seen('E');
#ifdef AUTO_BED_LEVELING_GRID
#if ENABLED(AUTO_BED_LEVELING_GRID)
bool do_topography_map = verbose_level > 2 || code_seen('T');
......@@ -3332,7 +3517,7 @@ inline void gcode_G28() {
#endif // AUTO_BED_LEVELING_GRID
#ifdef Z_PROBE_SLED
#if ENABLED(Z_PROBE_SLED)
dock_sled(false); // engage (un-dock) the probe
#endif
......@@ -3355,7 +3540,7 @@ inline void gcode_G28() {
setup_for_endstop_move();
feedrate = homing_feedrate[Z_AXIS];
#ifdef AUTO_BED_LEVELING_GRID
#if ENABLED(AUTO_BED_LEVELING_GRID)
// probe at the points of a lattice grid
const int xGridSpacing = (right_probe_bed_position - left_probe_bed_position) / (auto_bed_leveling_grid_points - 1),
......@@ -3370,11 +3555,11 @@ inline void gcode_G28() {
int abl2 = auto_bed_leveling_grid_points * auto_bed_leveling_grid_points;
double eqnAMatrix[abl2 * 3], // "A" matrix of the linear system of equations
eqnBVector[abl2], // "B" vector of Z points
mean = 0.0;
eqnBVector[abl2]; // "B" vector of Z points
int8_t indexIntoAB[auto_bed_leveling_grid_points][auto_bed_leveling_grid_points];
int probePointCounter = 0;
bool zig = true;
bool zig = (auto_bed_leveling_grid_points & 1) ? true : false; //always end at [RIGHT_PROBE_BED_POSITION, BACK_PROBE_BED_POSITION]
for (int yCount = 0; yCount < auto_bed_leveling_grid_points; yCount++) {
double yProbe = front_probe_bed_position + yGridSpacing * yCount;
......@@ -3391,9 +3576,8 @@ inline void gcode_G28() {
xInc = -1;
}
// If do_topography_map is set then don't zig-zag. Just scan in one direction.
// This gets the probe points in more readable order.
if (!do_topography_map) zig = !zig;
zig = !zig;
for (int xCount = xStart; xCount != xStop; xCount += xInc) {
double xProbe = left_probe_bed_position + xGridSpacing * xCount;
......@@ -3401,6 +3585,13 @@ inline void gcode_G28() {
float measured_z,
z_before = probePointCounter ? Z_RAISE_BETWEEN_PROBINGS + current_position[Z_AXIS] : Z_RAISE_BEFORE_PROBING;
if (probePointCounter) {
if (debugLevel & DEBUG_INFO) ECHO_LMV(DB, "z_before = (between) ", (float)(Z_RAISE_BETWEEN_PROBINGS + current_position[Z_AXIS]));
}
else {
if (debugLevel & DEBUG_INFO) ECHO_LMV(DB, "z_before = (before) ", (float)Z_RAISE_BEFORE_PROBING);
}
// Enhanced G29 - Do not retract servo between probes
ProbeAction act;
if (deploy_probe_for_each_reading) // G29 E - Stow between probes
......@@ -3414,12 +3605,11 @@ inline void gcode_G28() {
measured_z = probe_pt(xProbe, yProbe, z_before, act, verbose_level);
mean += measured_z;
eqnBVector[probePointCounter] = measured_z;
eqnAMatrix[probePointCounter + 0 * abl2] = xProbe;
eqnAMatrix[probePointCounter + 1 * abl2] = yProbe;
eqnAMatrix[probePointCounter + 2 * abl2] = 1;
indexIntoAB[xCount][yCount] = probePointCounter;
probePointCounter++;
......@@ -3428,52 +3618,94 @@ inline void gcode_G28() {
} //xProbe
} //yProbe
if (debugLevel & DEBUG_INFO) {
ECHO_S(DB);
print_xyz("> probing complete > current_position", current_position);
}
clean_up_after_endstop_move();
// solve lsq problem
double plane_equation_coefficients[3];
qr_solve(plane_equation_coefficients, abl2, 3, eqnAMatrix, eqnBVector);
mean /= abl2;
double *plane_equation_coefficients = qr_solve(abl2, 3, eqnAMatrix, eqnBVector);
if (verbose_level) {
ECHO_SMV(DB, "Eqn coefficients: a: ", plane_equation_coefficients[0], 8);
ECHO_MV(" b: ", plane_equation_coefficients[1], 8);
ECHO_EMV(" d: ", plane_equation_coefficients[2], 8);
if (verbose_level > 2) {
ECHO_LMV(DB, "Mean of sampled points: ", mean, 8);
}
}
if (!dryrun) set_bed_level_equation_lsq(plane_equation_coefficients);
free(plane_equation_coefficients);
matrix_3x3 inverse_bed_level_matrix = matrix_3x3::transpose(plan_bed_level_matrix); // inverse bed level matrix
// In the special case of an rotation matrix "the inverse" = "the transposed" matrix.
// search minimum and maximum point on bed in rotated coordinates
float rot_min_diff = Z_MAX_POS,
rot_max_diff = -Z_MAX_POS,
min_diff = Z_MAX_POS;
for (int8_t i = 0; i < abl2; i++) {
vector_3 probe_point = vector_3(eqnAMatrix[i + 0 * abl2], eqnAMatrix[i + 1 * abl2], eqnBVector[i]);
probe_point.apply_rotation(inverse_bed_level_matrix);
rot_min_diff = min(rot_min_diff, probe_point.z);
rot_max_diff = max(rot_max_diff, probe_point.z);
min_diff = min(min_diff, eqnBVector[i]);
}
// Show the Topography map if enabled
if (do_topography_map) {
// search minimum measured Z
ECHO_LM(DB, "+-----------+");
ECHO_LM(DB, "|...Back....|");
ECHO_LM(DB, "|Left..Right|");
ECHO_LM(DB, "|...Front...|");
ECHO_LM(DB, "+-----------+");
ECHO_LM(DB, "Measured Bed Topography:");
for (int8_t yy = auto_bed_leveling_grid_points - 1; yy >= 0; yy--) {
ECHO_S(DB);
for (int8_t xx = 0; xx < auto_bed_leveling_grid_points; xx++) {
int8_t ind = indexIntoAB[xx][yy];
ECHO_LM(DB, "Bed Height Topography: \n");
ECHO_LM(DB, "+-----------+\n");
ECHO_LM(DB, "|...Back....|\n");
ECHO_LM(DB, "|Left..Right|\n");
ECHO_LM(DB, "|...Front...|\n");
ECHO_LM(DB, "+-----------+\n");
float diff = eqnBVector[ind];
float min_diff = 999;
if (diff >= 0.0)
ECHO_M(" +"); // Include + for column alignment
else
ECHO_M(" ");
ECHO_V(diff, 5);
} // xx
ECHO_E;
} // yy
ECHO_E;
for (int yy = auto_bed_leveling_grid_points - 1; yy >= 0; yy--) {
ECHO_LM(DB, "Corrected Bed Topography:");
for (int8_t yy = auto_bed_leveling_grid_points - 1; yy >= 0; yy--) {
ECHO_S(DB);
for (int xx = 0; xx < auto_bed_leveling_grid_points; xx++) {
int ind = yy * auto_bed_leveling_grid_points + xx;
float diff = eqnBVector[ind] - mean;
for (int8_t xx = 0; xx < auto_bed_leveling_grid_points; xx++) {
int8_t ind = indexIntoAB[xx][yy];
float x_tmp = eqnAMatrix[ind + 0 * abl2],
y_tmp = eqnAMatrix[ind + 1 * abl2],
z_tmp = 0;
float diff = eqnBVector[ind] - min_diff;
apply_rotation_xyz(plan_bed_level_matrix,x_tmp,y_tmp,z_tmp);
if (diff >= 0.0)
ECHO_M(" +"); // Include + for column alignment
else
ECHO_M(" ");
ECHO_V(diff, 5);
} // xx
ECHO_E;
} // yy
ECHO_E;
ECHO_LM(DB, "Corrected Bed Topography in new coordinates:");
for (int8_t yy = auto_bed_leveling_grid_points - 1; yy >= 0; yy--) {
ECHO_S(DB);
for (int8_t xx = 0; xx < auto_bed_leveling_grid_points; xx++) {
int8_t ind = indexIntoAB[xx][yy];
if (eqnBVector[ind] - z_tmp < min_diff)
min_diff = eqnBVector[ind] - z_tmp;
vector_3 probe_point = vector_3(eqnAMatrix[ind + 0 * abl2], eqnAMatrix[ind + 1 * abl2], eqnBVector[ind]);
probe_point.apply_rotation(inverse_bed_level_matrix);
float diff = probe_point.z - rot_min_diff;
if (diff >= 0.0)
ECHO_M(" +"); // Include + for column alignment
......@@ -3484,32 +3716,33 @@ inline void gcode_G28() {
ECHO_E;
} // yy
ECHO_E;
if (verbose_level > 3) {
ECHO_LM(DB, " Corrected Bed Height vs. Bed Topology: \n");
for (int yy = auto_bed_leveling_grid_points - 1; yy >= 0; yy--) {
ECHO_S(DB);
for (int xx = 0; xx < auto_bed_leveling_grid_points; xx++) {
int ind = yy * auto_bed_leveling_grid_points + xx;
float x_tmp = eqnAMatrix[ind + 0 * abl2],
y_tmp = eqnAMatrix[ind + 1 * abl2],
z_tmp = 0;
apply_rotation_xyz(plan_bed_level_matrix,x_tmp,y_tmp,z_tmp);
float diff = eqnBVector[ind] - z_tmp - min_diff;
if (diff >= 0.0)
ECHO_M(" +"); // Include + for column alignment
else
ECHO_M(" ");
ECHO_V(diff, 5);
} // xx
ECHO_E;
} // yy
ECHO_LM(DB, "Height from Bed to Nozzle");
ECHO_LM(DB, "(+) above, or (-) below surface :");
for (int8_t yy = auto_bed_leveling_grid_points - 1; yy >= 0; yy--) {
ECHO_S(DB);
for (int8_t xx = 0; xx < auto_bed_leveling_grid_points; xx++) {
int8_t ind = indexIntoAB[xx][yy];
vector_3 probe_point = vector_3(eqnAMatrix[ind + 0 * abl2], eqnAMatrix[ind + 1 * abl2], eqnBVector[ind]);
probe_point.apply_rotation(inverse_bed_level_matrix);
float diff = -(probe_point.z - rot_max_diff);
if (diff >= 0.0)
ECHO_M(" +"); // Include + for column alignment
else
ECHO_M(" ");
ECHO_V(diff, 5);
} // xx
ECHO_E;
}
} // yy
ECHO_E;
} //do_topography_map
#else // !AUTO_BED_LEVELING_GRID
if (debugLevel & DEBUG_INFO) ECHO_LM(DB, "> 3-point Leveling");
// Actions for each probe
ProbeAction p1, p2, p3;
if (deploy_probe_for_each_reading)
......@@ -3527,55 +3760,41 @@ inline void gcode_G28() {
#endif // !AUTO_BED_LEVELING_GRID
if (verbose_level > 0)
plan_bed_level_matrix.debug("Bed Level Correction Matrix:");
plan_bed_level_matrix.debug(" Bed Level Correction Matrix:");
if (!dryrun) {
// Correct the Z height difference from z-probe position and hotend tip position.
// The Z height on homing is measured by Z-Probe, but the probe is quite far from the hotend.
// When the bed is uneven, this height must be corrected.
float x_tmp = current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER,
y_tmp = current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER,
z_tmp = current_position[Z_AXIS],
real_z = st_get_position_mm(Z_AXIS); //get the real Z (since plan_get_position is now correcting the plane)
apply_rotation_xyz(plan_bed_level_matrix, x_tmp, y_tmp, z_tmp); // Apply the correction sending the probe offset
// Get the current Z position and send it to the planner.
//
// >> (z_tmp - real_z) : The rotated current Z minus the uncorrected Z (most recent plan_set_position/sync_plan_position)
//
// >> zprobe_zoffset : Z distance from nozzle to probe (set by default, M851, EEPROM, or Menu)
//
// >> Z_RAISE_AFTER_PROBING : The distance the probe will have lifted after the last probe
//
// >> Should home_offset[Z_AXIS] be included?
//
// Discussion: home_offset[Z_AXIS] was applied in G28 to set the starting Z.
// If Z is not tweaked in G29 -and- the Z probe in G29 is not actually "homing" Z...
// then perhaps it should not be included here. The purpose of home_offset[] is to
// adjust for inaccurate endstops, not for reasonably accurate probes. If it were
// added here, it could be seen as a compensating factor for the Z probe.
//
current_position[Z_AXIS] = -zprobe_zoffset + (z_tmp - real_z)
#if HAS_SERVO_ENDSTOPS || ENABLED(Z_PROBE_SLED)
+ Z_RAISE_AFTER_PROBING
#endif
;
// current_position[Z_AXIS] += home_offset[Z_AXIS]; // The probe determines Z=0, not "Z home"
uint8_t ind = abl2-1; // last point probe = current point
vector_3 probe_point = vector_3(eqnAMatrix[ind + 0 * abl2], eqnAMatrix[ind + 1 * abl2], eqnBVector[ind]);
probe_point.apply_rotation(inverse_bed_level_matrix);
current_position[Z_AXIS] = -zprobe_zoffset + (probe_point.z - rot_max_diff)
#if HAS_SERVO_ENDSTOPS || ENABLED(Z_PROBE_SLED)
+ Z_RAISE_AFTER_PROBING
#endif
;
sync_plan_position();
if (debugLevel & DEBUG_INFO) ECHO_LMV(DB, "> AFTER apply_rotation_xyz > current_position[Z_AXIS]= ", current_position[Z_AXIS], 5);
}
#ifdef Z_PROBE_SLED
#if ENABLED(Z_PROBE_SLED)
dock_sled(true); // dock the probe
#endif
if (debugLevel & DEBUG_INFO) ECHO_LM(DB, "<<< gcode_G29");
}
#if DISABLED(Z_PROBE_SLED)
/**
* G30: Do a single Z probe at the current XY
*/
inline void gcode_G30() {
#if HAS_SERVO_ENDSTOPS
raise_z_for_servo();
#endif
deploy_z_probe(); // Engage Z Servo endstop if available
st_synchronize();
// TODO: make sure the bed_level_rotation_matrix is identity or the planner will get set incorectly
// TODO: clear the leveling matrix or the planner will be set incorrectly
setup_for_endstop_move();
feedrate = homing_feedrate[Z_AXIS];
......@@ -3587,17 +3806,24 @@ inline void gcode_G28() {
ECHO_EMV(" Z: ", current_position[Z_AXIS] + 0.0001);
clean_up_after_endstop_move();
#if HAS_SERVO_ENDSTOPS
raise_z_for_servo();
#endif
stow_z_probe(); // Retract Z Servo endstop if available
}
#endif // !Z_PROBE_SLED
#endif // ENABLE_AUTO_BED_LEVELING
#endif // AUTO_BED_LEVELING_FEATURE
#if defined(DELTA) && defined(Z_PROBE_ENDSTOP)
#if ENABLED(DELTA) && ENABLED(Z_PROBE_ENDSTOP)
/**
* G29: Delta Z-Probe, probes the bed at more points.
*/
inline void gcode_G29() {
if (debugLevel & DEBUG_INFO) ECHO_LM(DB, "gcode_G29 >>>");
if (code_seen('D')) {
print_bed_level();
return;
......@@ -3612,6 +3838,8 @@ inline void gcode_G28() {
calibrate_print_surface(z_probe_offset[Z_AXIS] + (code_seen(axis_codes[Z_AXIS]) ? code_value() : 0.0));
retract_z_probe();
if (debugLevel & DEBUG_INFO) ECHO_LM(DB, "<<< gcode_G29");
clean_up_after_endstop_move();
}
......@@ -3646,14 +3874,16 @@ inline void gcode_G28() {
deploy_z_probe();
probe_value = probe_bed(x, y);
ECHO_SMV(DB, "Bed Z-Height at X:", x);
ECHO_MV(" Y:", y);
ECHO_EMV(" = ", probe_value, 4);
ECHO_SMV(DB, "Carriage Positions: [", saved_position[X_AXIS]);
ECHO_MV(", ", saved_position[Y_AXIS]);
ECHO_MV(", ", saved_position[Z_AXIS]);
ECHO_EM("]");
if (debugLevel & DEBUG_INFO) {
ECHO_SMV(DB, "Bed Z-Height at X:", x);
ECHO_MV(" Y:", y);
ECHO_EMV(" = ", probe_value, 4);
ECHO_SMV(DB, "Carriage Positions: [", saved_position[X_AXIS]);
ECHO_MV(", ", saved_position[Y_AXIS]);
ECHO_MV(", ", saved_position[Z_AXIS]);
ECHO_EM("]");
}
retract_z_probe();
return;
}
......@@ -4208,7 +4438,7 @@ inline void gcode_M42() {
} // code_seen('S')
}
#if defined(ENABLE_AUTO_BED_LEVELING) && defined(Z_PROBE_REPEATABILITY_TEST)
#if ENABLED(AUTO_BED_LEVELING_FEATURE) && ENABLED(Z_PROBE_REPEATABILITY_TEST)
/**
* M48: Z-Probe repeatability measurement function.
*
......@@ -4431,7 +4661,7 @@ inline void gcode_M42() {
}
#endif // ENABLE_AUTO_BED_LEVELING && Z_PROBE_REPEATABILITY_TEST
#endif // AUTO_BED_LEVELING_FEATURE && Z_PROBE_REPEATABILITY_TEST
#if HAS_POWER_SWITCH
......@@ -4674,12 +4904,17 @@ inline void gcode_M111() {
debugLevel = code_seen('S') ? code_value_short() : DEBUG_INFO|DEBUG_COMMUNICATION;
if (debugLevel & DEBUG_ECHO) ECHO_LM(DB, MSG_DEBUG_ECHO);
//if (debugLevel & DEBUG_INFO) ECHO_LM(DB, MSG_DEBUG_INFO);
if (debugLevel & DEBUG_INFO) ECHO_LM(DB, MSG_DEBUG_INFO);
//if (debugLevel & DEBUG_ERRORS) ECHO_LM(DB, MSG_DEBUG_ERRORS);
if (debugLevel & DEBUG_DRYRUN) {
ECHO_LM(DB, MSG_DEBUG_DRYRUN);
disable_all_heaters();
}
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (debugLevel & DEBUG_LEVELING) {
ECHO_LM(DB, MSG_DEBUG_LEVELING);
}
#endif
}
/**
......@@ -5539,21 +5774,13 @@ inline void gcode_M226() {
*/
inline void gcode_M400() { st_synchronize(); }
#if defined(ENABLE_AUTO_BED_LEVELING) && !defined(Z_PROBE_SLED) && SERVO_LEVELING
#if SERVO_LEVELING
void raise_z_for_servo() {
float zpos = current_position[Z_AXIS], z_dest = Z_RAISE_BEFORE_HOMING;
z_dest += axis_known_position[Z_AXIS] ? zprobe_zoffset : zpos;
if (zpos < z_dest) do_blocking_move_to_z(z_dest); // also updates current_position
}
#endif
#if ENABLED(AUTO_BED_LEVELING_FEATURE) && DISABLED(Z_PROBE_SLED) && HAS_SERVO_ENDSTOPS
/**
* M401: Engage Z Servo endstop if available
*/
inline void gcode_M401() {
#if SERVO_LEVELING
#if HAS_SERVO_ENDSTOPS
raise_z_for_servo();
#endif
deploy_z_probe();
......@@ -5563,13 +5790,13 @@ inline void gcode_M400() { st_synchronize(); }
* M402: Retract Z Servo endstop if enabled
*/
inline void gcode_M402() {
#if SERVO_LEVELING
#if HAS_SERVO_ENDSTOPS
raise_z_for_servo();
#endif
stow_z_probe(false);
}
#endif
#endif // AUTO_BED_LEVELING_FEATURE && (HAS_SERVO_ENDSTOPS && !Z_PROBE_SLED)
#ifdef FILAMENT_SENSOR
......@@ -5926,7 +6153,7 @@ inline void gcode_M503() {
}
#endif // DUAL_X_CARRIAGE
#ifdef ENABLE_AUTO_BED_LEVELING
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
//M666: Set Z probe offset
inline void gcode_M666() {
if (code_seen('P')) {
......@@ -5939,7 +6166,7 @@ inline void gcode_M503() {
}
#endif
#ifdef DELTA
#if ENABLED(DELTA)
//M666: Set delta endstop and geometry adjustment
inline void gcode_M666() {
if (code_seen('A')) {
......@@ -6094,29 +6321,6 @@ inline void gcode_M999() {
FlushSerialRequestResend();
}
#ifdef CUSTOM_M_CODE_SET_Z_PROBE_OFFSET
inline void gcode_SET_Z_PROBE_OFFSET() {
float value;
if (code_seen('Z')) {
value = code_value();
if (Z_PROBE_OFFSET_RANGE_MIN <= value && value <= Z_PROBE_OFFSET_RANGE_MAX) {
zprobe_zoffset = value;
ECHO_LM(DB, MSG_ZPROBE_ZOFFSET " " OK);
}
else {
ECHO_SM(DB, MSG_ZPROBE_ZOFFSET);
ECHO_MV(MSG_Z_MIN, Z_PROBE_OFFSET_RANGE_MIN);
ECHO_EMV(MSG_Z_MAX, Z_PROBE_OFFSET_RANGE_MAX);
}
}
else {
ECHO_LMV(DB, MSG_ZPROBE_ZOFFSET " : ", zprobe_zoffset);
}
}
#endif // CUSTOM_M_CODE_SET_Z_PROBE_OFFSET
/**
* T0-T3: Switch tool, usually switching extruders
*
......@@ -6125,7 +6329,7 @@ inline void gcode_M999() {
inline void gcode_T(uint8_t tmp_extruder) {
long csteps;
if (tmp_extruder >= EXTRUDERS) {
ECHO_SMV(DB, "T", tmp_extruder);
ECHO_SMV(DB, "T", (int)tmp_extruder);
ECHO_EM(" " MSG_INVALID_EXTRUDER);
}
else {
......@@ -6177,7 +6381,7 @@ inline void gcode_T(uint8_t tmp_extruder) {
active_extruder = target_extruder;
// This function resets the max/min values - the current position may be overwritten below.
axis_is_at_home(X_AXIS);
set_axis_is_at_home(X_AXIS);
if (dual_x_carriage_mode == DXC_FULL_CONTROL_MODE) {
current_position[X_AXIS] = inactive_extruder_x_pos;
......@@ -6328,10 +6532,10 @@ inline void gcode_T(uint8_t tmp_extruder) {
if (csteps > 0) colorstep(csteps,true);
old_color = active_extruder = target_extruder;
active_driver = 0;
ECHO_LMV(DB, MSG_ACTIVE_COLOR, active_extruder);
ECHO_LMV(DB, MSG_ACTIVE_COLOR, (int)active_extruder);
#else
active_driver = active_extruder = target_extruder;
ECHO_LMV(DB, MSG_ACTIVE_EXTRUDER, active_extruder);
ECHO_LMV(DB, MSG_ACTIVE_EXTRUDER, (int)active_extruder);
#endif // end MKR4 || NPR2
#endif // end no DUAL_X_CARRIAGE
......@@ -6429,10 +6633,10 @@ void process_next_command() {
case 28: //G28: Home all axes, one at a time
gcode_G28(); gcode_M114(); break;
#ifdef ENABLE_AUTO_BED_LEVELING
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
case 29: // G29 Detailed Z-Probe, probes the bed at 3 or more points.
gcode_G29(); gcode_M114(); break;
#ifndef Z_PROBE_SLED
#if DISABLED(Z_PROBE_SLED)
case 30: // G30 Single Z Probe
gcode_G30(); break;
#else // Z_PROBE_SLED
......@@ -6440,7 +6644,7 @@ void process_next_command() {
case 32: // G32: undock the sled
dock_sled(codenum == 31); break;
#endif // Z_PROBE_SLED
#endif // ENABLE_AUTO_BED_LEVELING
#endif // AUTO_BED_LEVELING_FEATURE
#if defined(DELTA) && defined(Z_PROBE_ENDSTOP)
case 29: // G29 Detailed Z-Probe, probes the bed at more points.
......@@ -6527,7 +6731,7 @@ void process_next_command() {
case 42: // M42 -Change pin status via gcode
gcode_M42(); break;
#if defined(ENABLE_AUTO_BED_LEVELING) && defined(Z_PROBE_REPEATABILITY_TEST)
#if ENABLED(AUTO_BED_LEVELING_FEATURE) && ENABLED(Z_PROBE_REPEATABILITY_TEST)
case 48: // M48 Z-Probe repeatability
gcode_M48(); break;
#endif
......@@ -6553,7 +6757,7 @@ void process_next_command() {
case 104: // M104
gcode_M104(); break;
case 105: // M105 Read current temperature
gcode_M105(); return; break; // "ok" already printed
gcode_M105(); return; // "ok" already printed
#if HAS_FAN
case 106: //M106 Fan On
......@@ -6775,7 +6979,7 @@ void process_next_command() {
gcode_M605(); break;
#endif
#if defined(ENABLE_AUTO_BED_LEVELING) || defined(DELTA)
#if ENABLED(AUTO_BED_LEVELING_FEATURE) || ENABLED(DELTA)
case 666: // M666 Set Z probe offset or set delta endstop and geometry adjustment
gcode_M666(); break;
#endif
......@@ -6793,13 +6997,8 @@ void process_next_command() {
gcode_M997(); break;
#endif // NPR2
case 999: // M999: Restart after being Stopped
case 999: // M999: Restart after being Stopped
gcode_M999(); break;
#ifdef CUSTOM_M_CODE_SET_Z_PROBE_OFFSET
case CUSTOM_M_CODE_SET_Z_PROBE_OFFSET:
gcode_SET_Z_PROBE_OFFSET(); break;
#endif // CUSTOM_M_CODE_SET_Z_PROBE_OFFSET
}
break;
......@@ -6845,7 +7044,7 @@ void clamp_to_software_endstops(float target[3]) {
NOLESS(target[Y_AXIS], min_pos[Y_AXIS]);
float negative_z_offset = 0;
#ifdef ENABLE_AUTO_BED_LEVELING
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
if (zprobe_zoffset < 0) negative_z_offset += zprobe_zoffset;
if (home_offset[Z_AXIS] < 0) negative_z_offset += home_offset[Z_AXIS];
#endif
......@@ -7024,7 +7223,12 @@ void prepare_move() {
#if defined(CARTESIAN) || defined(COREXY) || defined(COREXZ)
if (!prepare_move_cartesian()) return;
#endif
#ifdef IDLE_OOZING_PREVENT || EXTRUDER_RUNOUT_PREVENT
axis_last_activity = millis();
axis_is_moving = false;
#endif
set_current_to_destination();
}
......
/**
* @file NexButton.cpp
*
* API of NexButton.
* The implementation of class NexButton.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/7/10
* @date 2015/8/13
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
......@@ -15,23 +15,11 @@
#include "NexButton.h"
/**
* Constructor,inherited NexTouch's constructor function.
*
*/
NexButton::NexButton(NexPid pid, NexCid cid, char *name, NexTouchEventCb pop, void *pop_ptr)
:NexTouch(pid, cid, name, pop, pop_ptr)
NexButton::NexButton(uint8_t pid, uint8_t cid, const char *name)
:NexTouch(pid, cid, name)
{
}
/**
* Get text value from button component.
*
* @param buffer - text buffer.
* @param len - text buffer length.
*
* @return the text buffer length
*/
uint16_t NexButton::getText(char *buffer, uint16_t len)
{
String cmd;
......@@ -42,14 +30,6 @@ uint16_t NexButton::getText(char *buffer, uint16_t len)
return recvRetString(buffer,len);
}
/**
* Set text value of button component.
*
* @param buffer - text buffer.
*
* @retval true - success.
* @retval false - failed.
*/
bool NexButton::setText(const char *buffer)
{
String cmd;
......@@ -60,25 +40,3 @@ bool NexButton::setText(const char *buffer)
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
/**
* Register button pop callback function.
*
* @param pop - the pointer to button pop callback function.
* @param ptr - the parameter to be transmitted to button pop callback function.
*/
void NexButton::attachPop(NexTouchEventCb pop, void *ptr)
{
NexTouch::attachPop(pop, ptr);
}
/**
* Unload button pop callback function.
*
*/
void NexButton::detachPop(void)
{
NexTouch::detachPop();
}
/**
* @file NexButton.h
*
* API of NexButton.
* The definition of class NexButton.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/7/10
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
......@@ -15,24 +16,51 @@
#ifndef __NEXBUTTON_H__
#define __NEXBUTTON_H__
#ifdef __cplusplus
#include "NexTouch.h"
#include "NexHardware.h"
/**
* @addtogroup Component
* @{
*/
/**
* NexButton,subclass of NexTouch,provides simple methods to control button component.
* NexButton component.
*
* Commonly, you want to do something after push and pop it. It is recommanded that only
* call @ref NexTouch::attachPop to satisfy your purpose.
*
* @warning Please do not call @ref NexTouch::attachPush on this component, even though you can.
*/
class NexButton: public NexTouch
{
public: /* methods */
NexButton(NexPid pid, NexCid cid, char *name, NexTouchEventCb pop = NULL, void *pop_ptr = NULL);
void attachPop(NexTouchEventCb pop, void *ptr = NULL);
void detachPop(void);
uint16_t getText(char *buffer, uint16_t len);
bool setText(const char *buffer);
/**
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
*/
NexButton(uint8_t pid, uint8_t cid, const char *name);
/**
* Get text attribute of component.
*
* @param buffer - buffer storing text returned.
* @param len - length of buffer.
* @return The real length of text returned.
*/
uint16_t getText(char *buffer, uint16_t len);
/**
* Set text attribute of component.
*
* @param buffer - text buffer terminated with '\0'.
* @return true if success, false for failure.
*/
bool setText(const char *buffer);
};
/**
* @}
*/
#endif /* #ifdef __cplusplus */
#endif /* #ifndef __NEXBUTTON_H__ */
/**
* @file NexSerialConfig.h
* @file NexConfig.h
*
* Serial configure.
* Options for user can be found here.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/7/10
* @date 2015/8/13
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
......@@ -12,31 +12,49 @@
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*/
#ifndef __NEXCONFIG_H__
#define __NEXCONFIG_H__
#ifndef __NexSerialConfig_H__
#define __NexSerialConfig_H__
/**
* @addtogroup Configuration
* @{
*/
// Nextion Baudrate - default 9600
// 2400 - 4800 - 9600 - 19200 - 38400 - 57600 - 115200
/**
* Nextion Baudrate - default 9600
* 2400 - 4800 - 9600 - 19200 - 38400 - 57600 - 115200
*/
#define NEXTION_BAUDRATE 9600
/*enable debug serial*/
/**
* Define DEBUG_SERIAL_ENABLE to enable debug serial.
* Comment it to disable debug serial.
*/
//#define DEBUG_SERIAL_ENABLE
/*define serial for debug*/
/**
* Define dbSerial for the output of debug messages.
*/
#define dbSerial Serial
/**
* Define nexSerial for communicate with Nextion touch panel.
*/
#define nexSerial Serial1
#ifdef DEBUG_SERIAL_ENABLE
#define dbSerialPrint(a) dbSerial.print(a)
#define dbSerialPrintln(a) dbSerial.println(a)
#define dbSerialBegin(a) dbSerial.begin(a)
#else
#define dbSerialPrint(a)
#define dbSerialPrintln(a)
#define dbSerialBegin(a)
#define dbSerialPrint(a) do{}while(0)
#define dbSerialPrintln(a) do{}while(0)
#define dbSerialBegin(a) do{}while(0)
#endif
/*define serial for communicate with Nextion screen*/
#define nexSerial Serial1
/**
* @}
*/
#endif
#endif /* #ifndef __NEXCONFIG_H__ */
/**
* @file NexHardware.cpp
*
* The implementation of base API for using Nextion.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/11
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* 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 2 of
* the License, or (at your option) any later version.
*/
#include "NexHardware.h"
#define NEX_RET_CMD_FINISHED (0x01)
#define NEX_RET_EVENT_LAUNCHED (0x88)
#define NEX_RET_EVENT_UPGRADED (0x89)
#define NEX_RET_EVENT_TOUCH_HEAD (0x65)
#define NEX_RET_EVENT_POSITION_HEAD (0x67)
#define NEX_RET_EVENT_SLEEP_POSITION_HEAD (0x68)
#define NEX_RET_CURRENT_PAGE_ID_HEAD (0x66)
#define NEX_RET_STRING_HEAD (0x70)
#define NEX_RET_NUMBER_HEAD (0x71)
#define NEX_RET_INVALID_CMD (0x00)
#define NEX_RET_INVALID_COMPONENT_ID (0x02)
#define NEX_RET_INVALID_PAGE_ID (0x03)
#define NEX_RET_INVALID_PICTURE_ID (0x04)
#define NEX_RET_INVALID_FONT_ID (0x05)
#define NEX_RET_INVALID_BAUD (0x11)
#define NEX_RET_INVALID_VARIABLE (0x1A)
#define NEX_RET_INVALID_OPERATION (0x1B)
/*
* Receive uint32_t data.
*
* @param number - save uint32_t data.
* @param timeout - set timeout time.
*
* @retval true - success.
* @retval false - failed.
*
*/
bool recvRetNumber(uint32_t *number, uint32_t timeout)
{
bool ret = false;
uint8_t temp[8] = {0};
if (!number)
{
goto __return;
}
nexSerial.setTimeout(timeout);
if (sizeof(temp) != nexSerial.readBytes((char *)temp, sizeof(temp)))
{
goto __return;
}
if (temp[0] == NEX_RET_NUMBER_HEAD
&& temp[5] == 0xFF
&& temp[6] == 0xFF
&& temp[7] == 0xFF
)
{
*number = (temp[4] << 24) | (temp[3] << 16) | (temp[2] << 8) | (temp[1]);
ret = true;
}
__return:
if (ret)
{
dbSerialPrint("recvRetNumber :");
dbSerialPrintln(*number);
}
else
{
dbSerialPrintln("recvRetNumber err");
}
return ret;
}
/*
* Receive string data.
*
* @param buffer - save string data.
* @param len - string buffer length.
* @param timeout - set timeout time.
*
* @return the length of string buffer.
*
*/
uint16_t recvRetString(char *buffer, uint16_t len, uint32_t timeout)
{
uint16_t ret = 0;
bool str_start_flag = false;
uint8_t cnt_0xff = 0;
String temp = String("");
uint8_t c = 0;
long start;
if (!buffer || len == 0)
{
goto __return;
}
start = millis();
while (millis() - start <= timeout)
{
while (nexSerial.available())
{
c = nexSerial.read();
if (str_start_flag)
{
if (0xFF == c)
{
cnt_0xff++;
if (cnt_0xff >= 3)
{
break;
}
}
else
{
temp += (char)c;
}
}
else if (NEX_RET_STRING_HEAD == c)
{
str_start_flag = true;
}
}
if (cnt_0xff >= 3)
{
break;
}
}
ret = temp.length();
ret = ret > len ? len : ret;
strncpy(buffer, temp.c_str(), ret);
__return:
dbSerialPrint("recvRetString[");
dbSerialPrint(temp.length());
dbSerialPrint(",");
dbSerialPrint(temp);
dbSerialPrintln("]");
return ret;
}
/*
* Send command to Nextion.
*
* @param cmd - the string of command.
*/
void sendCommand(const char* cmd)
{
while (nexSerial.available())
{
nexSerial.read();
}
nexSerial.print(cmd);
nexSerial.write(0xFF);
nexSerial.write(0xFF);
nexSerial.write(0xFF);
}
/*
* Command is executed successfully.
*
* @param timeout - set timeout time.
*
* @retval true - success.
* @retval false - failed.
*
*/
bool recvRetCommandFinished(uint32_t timeout)
{
bool ret = false;
uint8_t temp[4] = {0};
nexSerial.setTimeout(timeout);
if (sizeof(temp) != nexSerial.readBytes((char *)temp, sizeof(temp)))
{
ret = false;
}
if (temp[0] == NEX_RET_CMD_FINISHED
&& temp[1] == 0xFF
&& temp[2] == 0xFF
&& temp[3] == 0xFF
)
{
ret = true;
}
if (ret)
{
dbSerialPrintln("recvRetCommandFinished ok");
}
else
{
dbSerialPrintln("recvRetCommandFinished err");
}
return ret;
}
bool nexInit(void)
{
bool ret1 = false;
bool ret2 = false;
dbSerialBegin(9600);
nexSerial.begin(NEXTION_BAUDRATE);
sendCommand("");
sendCommand("bkcmd=1");
ret1 = recvRetCommandFinished();
sendCommand("page 0");
ret2 = recvRetCommandFinished();
return ret1 && ret2;
}
void nexLoop(NexTouch *nex_listen_list[])
{
static uint8_t __buffer[10];
uint16_t i;
uint8_t c;
while (nexSerial.available() > 0)
{
delay(10);
c = nexSerial.read();
if (NEX_RET_EVENT_TOUCH_HEAD == c)
{
if (nexSerial.available() >= 6)
{
__buffer[0] = c;
for (i = 1; i < 7; i++)
{
__buffer[i] = nexSerial.read();
}
__buffer[i] = 0x00;
if (0xFF == __buffer[4] && 0xFF == __buffer[5] && 0xFF == __buffer[6])
{
NexTouch::iterate(nex_listen_list, __buffer[1], __buffer[2], (int32_t)__buffer[3]);
}
}
}
}
}
/**
* @file NexHardware.h
*
* The definition of base API for using Nextion.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/11
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* 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 2 of
* the License, or (at your option) any later version.
*/
#ifndef __NEXHARDWARE_H__
#define __NEXHARDWARE_H__
#include <Arduino.h>
#include "NexConfig.h"
#include "NexTouch.h"
/**
* @addtogroup CoreAPI
* @{
*/
/**
* Init Nextion.
*
* @return true if success, false for failure.
*/
bool nexInit(void);
/**
* Listen touch event and calling callbacks attached before.
*
* Supports push and pop at present.
*
* @param nex_listen_list - index to Nextion Components list.
* @return none.
*
* @warning This function must be called repeatedly to response touch events
* from Nextion touch panel. Actually, you should place it in your loop function.
*/
void nexLoop(NexTouch *nex_listen_list[]);
/**
* @}
*/
bool recvRetNumber(uint32_t *number, uint32_t timeout = 100);
uint16_t recvRetString(char *buffer, uint16_t len, uint32_t timeout = 100);
void sendCommand(const char* cmd);
bool recvRetCommandFinished(uint32_t timeout = 100);
#endif /* #ifndef __NEXHARDWARE_H__ */
/**
* @file NexHotspot.cpp
*
* API of NexHotspot.
* The implementation of class NexHotspot.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/7/10
* @date 2015/8/13
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
......@@ -15,53 +15,8 @@
#include "NexHotspot.h"
/**
* Constructor,inherited NexTouch's constructor function.
*
*/
NexHotspot::NexHotspot(NexPid pid, NexCid cid, char *name,
NexTouchEventCb pop, void *pop_ptr,
NexTouchEventCb push, void *push_ptr)
:NexTouch(pid, cid, name, pop, pop_ptr, push, push_ptr)
{
}
/**
* Register hotspot push callback function.
*
* @param push - the pointer to hotspot push callback function.
* @param ptr - the parameter to be transmitted to hotspot push callback function.
*/
void NexHotspot::attachPush(NexTouchEventCb push, void *ptr)
{
NexTouch::attachPush(push, ptr);
}
/**
* Unload hotsopt push callback function.
*
*/
void NexHotspot::detachPush(void)
NexHotspot::NexHotspot(uint8_t pid, uint8_t cid, const char *name)
:NexTouch(pid, cid, name)
{
NexTouch::detachPush();
}
/**
* Register hotspot pop callback function.
*
* @param pop - the pointer to hotspot pot callback function.
* @param ptr - the parameter to be transmitted to hotspot pop callback function.
*/
void NexHotspot::attachPop(NexTouchEventCb pop, void *ptr)
{
NexTouch::attachPop(pop, ptr);
}
/**
* Unload hotsopt pop callback function.
*
*/
void NexHotspot::detachPop(void)
{
NexTouch::detachPop();
}
/**
* @file NexHotspot.h
*
* API of NexHotspot.
* The definition of class NexHotspot.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/7/10
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
......@@ -15,26 +16,28 @@
#ifndef __NEXHOTSPOT_H__
#define __NEXHOTSPOT_H__
#ifdef __cplusplus
#include "NexTouch.h"
#include "NexHardware.h"
/**
* @addtogroup Component
* @{
*/
/**
* NexHotspot,subclass of NexTouch,provides simple methods to control hotspot component.
*
* NexHotspot component.
*/
class NexHotspot: public NexTouch
{
public: /* methods */
NexHotspot(NexPid pid, NexCid cid, char *name,
NexTouchEventCb pop = NULL, void *pop_ptr = NULL,
NexTouchEventCb push = NULL, void *push_ptr = NULL);
void attachPush(NexTouchEventCb push, void *ptr = NULL);
void detachPush(void);
void attachPop(NexTouchEventCb pop, void *ptr = NULL);
void detachPop(void);
/**
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
*/
NexHotspot(uint8_t pid, uint8_t cid, const char *name);
};
/**
* @}
*/
#endif /* #ifdef __cplusplus */
#endif /* #ifndef __NEXHOTSPOT_H__ */
/**
* @file NexObject.cpp
*
* The implementation of class NexObject.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* 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 2 of
* the License, or (at your option) any later version.
*/
#include "NexObject.h"
NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name)
{
this->__pid = pid;
this->__cid = cid;
this->__name = name;
}
uint8_t NexObject::getObjPid(void)
{
return __pid;
}
uint8_t NexObject::getObjCid(void)
{
return __cid;
}
const char* NexObject::getObjName(void)
{
return __name;
}
void NexObject::printObjInfo(void)
{
dbSerialPrint("[");
dbSerialPrint((uint32_t)this);
dbSerialPrint(":");
dbSerialPrint(__pid);
dbSerialPrint(",");
dbSerialPrint(__cid);
dbSerialPrint(",");
if (__name)
{
dbSerialPrint(__name);
}
else
{
dbSerialPrint("(null)");
}
dbSerialPrintln("]");
}
/**
* @file NexObject.h
*
* The definition of class NexObject.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
*
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* 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 2 of
* the License, or (at your option) any later version.
*/
#ifndef __NEXOBJECT_H__
#define __NEXOBJECT_H__
#include <Arduino.h>
#include "NexConfig.h"
/**
* @addtogroup CoreAPI
* @{
*/
/**
* Root class of all Nextion components.
*
* Provides the essential attributes of a Nextion component and the methods accessing
* them. At least, Page ID(pid), Component ID(pid) and an unique name are needed for
* creating a component in Nexiton library.
*/
class NexObject
{
public: /* methods */
/**
* Constructor.
*
* @param pid - page id.
* @param cid - component id.
* @param name - pointer to an unique name in range of all components.
*/
NexObject(uint8_t pid, uint8_t cid, const char *name);
/**
* Print current object'address, page id, component id and name.
*
* @warning this method does nothing, unless debug message enabled.
*/
void printObjInfo(void);
protected: /* methods */
/*
* Get page id.
*
* @return the id of page.
*/
uint8_t getObjPid(void);
/*
* Get component id.
*
* @return the id of component.
*/
uint8_t getObjCid(void);
/*
* Get component name.
*
* @return the name of component.
*/
const char *getObjName(void);
private: /* data */
uint8_t __pid; /* Page ID */
uint8_t __cid; /* Component ID */
const char *__name; /* An unique name */
};
/**
* @}
*/
#endif /* #ifndef __NEXOBJECT_H__ */
/**
* @file NexPage.cpp
*
* API of NexPage.
* The implementation of class NexPage.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/7/10
* @date 2015/8/13
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
......@@ -15,21 +15,11 @@
#include "NexPage.h"
/**
* Constructor,inherited NexTouch's constructor function.
*
*/
NexPage::NexPage(NexPid pid, NexCid cid, char *name, NexTouchEventCb pop, void *pop_ptr)
:NexTouch(pid, cid, name, pop, pop_ptr)
NexPage::NexPage(uint8_t pid, uint8_t cid, const char *name)
:NexTouch(pid, cid, name)
{
}
/**
* Change page.
*
* @retval true - success.
* @retval false - failed.
*/
bool NexPage::show(void)
{
uint8_t buffer[4] = {0};
......@@ -46,22 +36,3 @@ bool NexPage::show(void)
return recvRetCommandFinished();
}
/**
* Register page pop callback function.
*
* @param pop - the pointer to page pop callback function.
* @param ptr - the parameter to be transmitted to page pop callback function.
*/
void NexPage::attachPop(NexTouchEventCb pop, void *ptr)
{
NexTouch::attachPop(pop, ptr);
}
/**
* Unload page pop callback function.
*
*/
void NexPage::detachPop(void)
{
NexTouch::detachPop();
}
/**
* @file NexPage.h
*
* API of NexPage.
* The definition of class NexPage.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/7/10
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
......@@ -15,23 +16,35 @@
#ifndef __NEXPAGE_H__
#define __NEXPAGE_H__
#ifdef __cplusplus
#include "NexTouch.h"
#include "NexHardware.h"
/**
* @addtogroup Component
* @{
*/
/**
* NexPage,subclass of NexTouch,provides simple methods to control page component.
*
* A special component , which can contain other components such as NexButton,
* NexText and NexWaveform, etc.
*/
class NexPage: public NexTouch
{
public: /* methods */
NexPage(NexPid pid, NexCid cid, char *name, NexTouchEventCb pop = NULL, void *pop_ptr = NULL);
/**
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
*/
NexPage(uint8_t pid, uint8_t cid, const char *name);
/**
* Show itself.
*
* @return true if success, false for faileure.
*/
bool show(void);
void attachPop(NexTouchEventCb pop, void *ptr = NULL);
void detachPop(void);
};
/**
* @}
*/
#endif /* #ifdef __cplusplus */
#endif /* #ifndef __NEXPAGE_H__ */
/**
* @file NexPicture.cpp
*
* API of NexPicture.
* The implementation of class NexPicture.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/7/10
* @date 2015/8/13
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
......@@ -15,23 +15,11 @@
#include "NexPicture.h"
/**
* Constructor,inherited NexTouch's constructor function.
*
*/
NexPicture::NexPicture(NexPid pid, NexCid cid, char *name, NexTouchEventCb pop, void *pop_ptr)
:NexTouch(pid, cid, name, pop, pop_ptr)
NexPicture::NexPicture(uint8_t pid, uint8_t cid, const char *name)
:NexTouch(pid, cid, name)
{
}
/**
* Get picture's number.
*
* @param number - an output parameter to save picture number.
*
* @retval true - success.
* @retval false - failed.
*/
bool NexPicture::getPic(uint32_t *number)
{
String cmd = String("get ");
......@@ -41,14 +29,6 @@ bool NexPicture::getPic(uint32_t *number)
return recvRetNumber(number);
}
/**
* Set picture's number.
*
* @param number -the picture number.
*
* @retval true - success.
* @retval false - failed.
*/
bool NexPicture::setPic(uint32_t number)
{
char buf[10] = {0};
......@@ -62,24 +42,4 @@ bool NexPicture::setPic(uint32_t number)
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
/**
* Register picture pop callback function.
*
* @param pop - the pointer to picture pop callback function.
* @param ptr - the parameter to be transmitted to picture pop callback function.
*/
void NexPicture::attachPop(NexTouchEventCb pop, void *ptr)
{
NexTouch::attachPop(pop, ptr);
}
/**
* Unload picture pop callback function.
*
*/
void NexPicture::detachPop(void)
{
NexTouch::detachPop();
}
/**
* @file NexPicture.h
*
* API of NexPicture.
* The definition of class NexPicture.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/7/10
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
......@@ -15,24 +16,48 @@
#ifndef __NEXPICTURE_H__
#define __NEXPICTURE_H__
#ifdef __cplusplus
#include "NexTouch.h"
#include "NexHardware.h"
/**
* @addtogroup Component
* @{
*/
/**
* NexPicture,subclass of NexTouch,provides simple methods to control picture component.
*
* NexPicture component.
*/
class NexPicture: public NexTouch
{
public: /* methods */
NexPicture(NexPid pid, NexCid cid, char *name, NexTouchEventCb pop = NULL, void *pop_ptr = NULL);
/**
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
*/
NexPicture(uint8_t pid, uint8_t cid, const char *name);
void attachPop(NexTouchEventCb pop, void *ptr = NULL);
void detachPop(void);
/**
* Get picture's number.
*
* @param number - an output parameter to save picture number.
*
* @retval true - success.
* @retval false - failed.
*/
bool getPic(uint32_t *number);
/**
* Set picture's number.
*
* @param number -the picture number.
*
* @retval true - success.
* @retval false - failed.
*/
bool setPic(uint32_t number);
};
#endif /* #ifdef __cplusplus */
/**
* @}
*/
#endif /* #ifndef __NEXPICTURE_H__ */
#include "NexPointer.h"
/**
* Constructor,inherited NexTouch's constructor function.
*
*/
NexPointer::NexPointer(NexPid pid, NexCid cid, char *name)
:NexTouch(pid, cid, name)
{
}
/**
* Get the value of pointer.
*
* @param number - an output parameter to save pointer's value.
*
* @retval true - success.
* @retval false - failed.
*/
bool NexPointer::getValue(uint32_t *number)
{
String cmd = String("get ");
cmd += getObjName();
cmd += ".val";
sendCommand(cmd.c_str());
return recvRetNumber(number);
}
/**
* Set the value of pointer.
*
* @param number - the value of pointer.
*
* @retval true - success.
* @retval false - failed.
*/
bool NexPointer::setValue(uint32_t number)
{
char buf[10] = {0};
String cmd;
utoa(number, buf, 10);
cmd += getObjName();
cmd += ".val=";
cmd += buf;
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
#ifndef __NEXPOINTER_H__
#define __NEXPOINTER_H__
#ifdef __cplusplus
#include "NexTouch.h"
/**
* NexPointer,subclass of NexTouch,provides simple methods to control pointer component.
*
*/
class NexPointer: public NexTouch
{
public: /* methods */
NexPointer(NexPid pid, NexCid cid, char *name);
bool getValue(uint32_t *number);
bool setValue(uint32_t number);
};
#endif /* #ifdef __cplusplus */
#endif /* #ifndef __NEXPOINTER_H__ */
/**
* @file NexProgressBar.cpp
*
* API of NexProgressBar.
* The implementation of class NexProgressBar.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/7/10
* @date 2015/8/13
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
......@@ -15,23 +15,11 @@
#include "NexProgressBar.h"
/**
* Constructor,inherited NexTouch's constructor function.
*
*/
NexProgressBar::NexProgressBar(NexPid pid, NexCid cid, char *name)
:NexTouch(pid, cid, name)
NexProgressBar::NexProgressBar(uint8_t pid, uint8_t cid, const char *name)
:NexObject(pid, cid, name)
{
}
/**
* Get the value of progress bar.
*
* @param number - an output parameter to save the value of porgress bar.
*
* @retval true - success.
* @retval false - failed.
*/
bool NexProgressBar::getValue(uint32_t *number)
{
String cmd = String("get ");
......@@ -41,14 +29,6 @@ bool NexProgressBar::getValue(uint32_t *number)
return recvRetNumber(number);
}
/**
* Set the value of progress bar.
*
* @param number - the value of progress bar.
*
* @retval true - success.
* @retval false - failed.
*/
bool NexProgressBar::setValue(uint32_t number)
{
char buf[10] = {0};
......
/**
* @file NexProgressBar.h
*
* API of NexProgressBar.
* The definition of class NexProgressBar.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/7/10
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
......@@ -15,21 +16,48 @@
#ifndef __NEXPROGRESSBAR_H__
#define __NEXPROGRESSBAR_H__
#ifdef __cplusplus
#include "NexTouch.h"
#include "NexHardware.h"
/**
* @addtogroup Component
* @{
*/
/**
* NexProgressBar,subclass of NexTouch,provides simple methods to control progress bar component.
*
* NexProgressBar component.
*/
class NexProgressBar: public NexTouch
class NexProgressBar: public NexObject
{
public: /* methods */
NexProgressBar(NexPid pid, NexCid cid, char *name);
/**
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
*/
NexProgressBar(uint8_t pid, uint8_t cid, const char *name);
/**
* Get the value of progress bar.
*
* @param number - an output parameter to save the value of porgress bar.
*
* @retval true - success.
* @retval false - failed.
*/
bool getValue(uint32_t *number);
/**
* Set the value of progress bar.
*
* @param number - the value of progress bar.
*
* @retval true - success.
* @retval false - failed.
*/
bool setValue(uint32_t number);
};
#endif /* #ifdef __cplusplus */
/**
* @}
*/
#endif /* #ifndef __NEXPROGRESSBAR_H__ */
/**
* @file NexSlice.cpp
* @file NexSlider.cpp
*
* API of NexSlice.
* The implementation of class NexSlider.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/7/10
* @date 2015/8/13
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
......@@ -12,74 +12,33 @@
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*/
#include "NexSlider.h"
#include "NexSlice.h"
/**
* Constructor,inherited NexTouch's constructor function.
*
*/
NexSlice::NexSlice(NexPid pid, NexCid cid, char *name, NexTouchEventCb pop, void *pop_ptr)
:NexTouch(pid, cid, name, pop, pop_ptr)
NexSlider::NexSlider(uint8_t pid, uint8_t cid, const char *name)
:NexTouch(pid, cid, name)
{
}
/*
* Get the number of picture.
*
* @param number - an output parameter to save the number of picture.
*
* @retval true - success.
* @retval false - failed.
*/
bool NexSlice::getPic(uint32_t *number)
bool NexSlider::getValue(uint32_t *number)
{
String cmd = String("get ");
cmd += getObjName();
cmd += ".picc";
cmd += ".val";
sendCommand(cmd.c_str());
return recvRetNumber(number);
}
/*
* Set the number of picture.
*
* @param number - the number of picture.
*
* @retval true - success.
* @retval false - failed.
*/
bool NexSlice::setPic(uint32_t number)
bool NexSlider::setValue(uint32_t number)
{
char buf[10] = {0};
String cmd;
utoa(number, buf, 10);
cmd += getObjName();
cmd += ".picc=";
cmd += ".val=";
cmd += buf;
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
/**
* Register slice pop callback function.
*
* @param pop - the pointer to slice pop callback function.
* @param ptr - the parameter to be transmitted to slice pop callback function.
*/
void NexSlice::attachPop(NexTouchEventCb pop, void *ptr)
{
NexTouch::attachPop(pop, ptr);
}
/**
* Unload slice pop callback function.
*
*/
void NexSlice::detachPop(void)
{
NexTouch::detachPop();
}
/**
* @file NexSlider.h
*
* The definition of class NexSlider.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
*
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* 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 2 of
* the License, or (at your option) any later version.
*/
#ifndef __NEXSLIDER_H__
#define __NEXSLIDER_H__
#include "NexTouch.h"
#include "NexHardware.h"
/**
* @addtogroup Component
* @{
*/
/**
* NexSlider component.
*/
class NexSlider: public NexTouch
{
public: /* methods */
/**
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
*/
NexSlider(uint8_t pid, uint8_t cid, const char *name);
/**
* Get the value of slider.
*
* @param number - an output parameter to save the value of slider.
*
* @retval true - success.
* @retval false - failed.
*/
bool getValue(uint32_t *number);
/**
* Set the value of slider.
*
* @param number - the value of slider.
*
* @retval true - success.
* @retval false - failed.
*/
bool setValue(uint32_t number);
};
/**
* @}
*/
#endif /* #ifndef __NEXSLIDER_H__ */
/**
* @file NexText.cpp
*
* API of NexText.
* The implementation of class NexText.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/7/10
* @date 2015/8/13
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
......@@ -12,26 +12,13 @@
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*/
#include "NexText.h"
/**
* Constructor,inherited NexTouch's constructor function.
*
*/
NexText::NexText(NexPid pid, NexCid cid, char *name, NexTouchEventCb pop, void *pop_ptr)
:NexTouch(pid, cid, name, pop, pop_ptr)
NexText::NexText(uint8_t pid, uint8_t cid, const char *name)
:NexTouch(pid, cid, name)
{
}
/**
* Get the value of text.
*
* @param buffer - text value buffer.
* @param len - the length of text value buffer.
*
* @return the length of text value buffer.
*/
uint16_t NexText::getText(char *buffer, uint16_t len)
{
String cmd;
......@@ -42,14 +29,6 @@ uint16_t NexText::getText(char *buffer, uint16_t len)
return recvRetString(buffer,len);
}
/**
* Set the value of text.
*
* @param buffer - text value buffer.
*
* @retval true - success.
* @retval false - failed.
*/
bool NexText::setText(const char *buffer)
{
String cmd;
......@@ -61,14 +40,6 @@ bool NexText::setText(const char *buffer)
return recvRetCommandFinished();
}
/**
* Set the value of color.
*
* @param value - color value.
*
* @retval true - success.
* @retval false - failed.
*/
bool NexText::setColor(uint32_t value)
{
char buf[10] = {0};
......@@ -82,24 +53,3 @@ bool NexText::setColor(uint32_t value)
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
/**
* Register text pop callback function.
*
* @param pop - the pointer to text pop callback function.
* @param ptr - the parameter to be transmitted to text pop callback function.
*/
void NexText::attachPop(NexTouchEventCb pop, void *ptr)
{
NexTouch::attachPop(pop, ptr);
}
/**
* Unload text pop callback function.
*
*/
void NexText::detachPop(void)
{
NexTouch::detachPop();
}
/**
* @file NexText.h
*
* API of NexText.
* The definition of class NexText.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/7/10
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
......@@ -15,25 +16,46 @@
#ifndef __NEXTEXT_H__
#define __NEXTEXT_H__
#ifdef __cplusplus
#include "NexTouch.h"
#include "NexHardware.h"
/**
* @addtogroup Component
* @{
*/
/**
* NexText,subclass of NexTouch,provides simple methods to control text component.
*
* NexText component.
*/
class NexText: public NexTouch
{
public: /* methods */
NexText(NexPid pid, NexCid cid, char *name, NexTouchEventCb pop = NULL, void *pop_ptr = NULL);
/**
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
*/
NexText(uint8_t pid, uint8_t cid, const char *name);
void attachPop(NexTouchEventCb pop, void *ptr = NULL);
void detachPop(void);
/**
* Get text attribute of component.
*
* @param buffer - buffer storing text returned.
* @param len - length of buffer.
* @return The real length of text returned.
*/
uint16_t getText(char *buffer, uint16_t len);
/**
* Set text attribute of component.
*
* @param buffer - text buffer terminated with '\0'.
* @return true if success, false for failure.
*/
bool setText(const char *buffer);
bool setColor(uint32_t value);
};
#endif /* #ifdef __cplusplus */
/**
* @}
*/
#endif /* #ifndef __NEXTEXT_H__ */
/**
* @file NexTouch.cpp
*
* API of Nextion.
* The implementation of class NexTouch.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/7/10
* @date 2015/8/13
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
......@@ -12,689 +12,84 @@
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*/
#include "NexTouch.h"
uint8_t NexTouch::__buffer[256] = {0};
/**
* Watting for Nextion's touch event.
*
* @param list - index to Nextion Components list.
*
*/
uint8_t NexTouch::mainEventLoop(NexTouch **list) {
uint16_t i;
uint8_t c;
while (nexSerial.available() > 0) {
delay(10);
c = nexSerial.read();
if (NEX_RET_EVENT_TOUCH_HEAD == c) {
if (nexSerial.available() >= 6) {
//memset(__buffer, 0, sizeof(__buffer));
__buffer[0] = c;
for (i = 1; i < 7; i++) {
__buffer[i] = nexSerial.read();
}
__buffer[i] = 0x00;
if (0xFF == __buffer[4] && 0xFF == __buffer[5] && 0xFF == __buffer[6])
iterate(list, (NexPid)__buffer[1], (NexCid)__buffer[2], (NexEventType)__buffer[3]);
}
}
}
return 0;
}
/**
* Constructor of Nextouch.
*
* @param pid - page id.
* @param cid - component id.
* @param name - component name.
* @param pop - pop event function pointer.
* @param pop_ptr - the parameter was transmitted to pop event function pointer.
* @param push - push event function pointer.
* @param push_ptr - the parameter was transmitted to push event function pointer.
*
*/
NexTouch::NexTouch(NexPid pid, NexCid cid, char *name,
NexTouchEventCb pop, void *pop_ptr,
NexTouchEventCb push, void *push_ptr) {
this->pid = pid;
this->cid = cid;
this->name = name;
this->cbPush = push;
this->cbPop = pop;
this->__cbpop_ptr = pop_ptr;
this->__cbpush_ptr = push_ptr;
}
/**
* Get page id.
*
* @return the id of page.
*/
NexPid NexTouch::getPid(void) {
return pid;
}
/**
* Get component id.
*
* @return the id of component.
*/
NexCid NexTouch::getCid(void) {
return cid;
}
/**
* Get component name.
*
* @return the name of component.
*/
const char* NexTouch::getObjName(void) {
return name;
}
/**
* Print current object address,page id,component id,
* component name,pop event function address,push event function address.
*
*/
void NexTouch::print(void) {
dbSerialPrint("[");
dbSerialPrint((uint32_t)this);
dbSerialPrint(":");
dbSerialPrint(pid);
dbSerialPrint(",");
dbSerialPrint(cid);
dbSerialPrint(",");
if (name) {
dbSerialPrint(name);
}
else {
dbSerialPrint("(null)");
}
dbSerialPrint(",");
dbSerialPrint((uint32_t)cbPush);
dbSerialPrint(",");
dbSerialPrint((uint32_t)cbPop);
dbSerialPrintln("]");
}
void NexTouch::attachPush(NexTouchEventCb push, void *ptr) {
this->cbPush = push;
this->__cbpush_ptr = ptr;
}
void NexTouch::detachPush(void) {
this->cbPush = NULL;
this->__cbpush_ptr = NULL;
}
void NexTouch::attachPop(NexTouchEventCb pop, void *ptr) {
this->cbPop = pop;
this->__cbpop_ptr = ptr;
}
void NexTouch::detachPop(void) {
this->cbPop = NULL;
this->__cbpop_ptr = NULL;
}
void NexTouch::iterate(NexTouch **list, NexPid pid, NexCid cid, NexEventType event) {
NexTouch *e = NULL;
uint16_t i = 0;
if (NULL == list) {
return;
}
for(i = 0; (e = list[i]) != NULL; i++) {
if (e->getPid() == pid && e->getCid() == cid) {
e->print();
if (NEX_EVENT_PUSH == event) {
e->push();
}
else if (NEX_EVENT_POP == event) {
e->pop();
}
break;
}
}
}
void NexTouch::push(void) {
if (cbPush) {
cbPush(__cbpush_ptr);
}
}
void NexTouch::pop(void) {
if (cbPop) {
cbPop(__cbpop_ptr);
}
}
/**
* Command is executed successfully.
*
* @param timeout - set timeout time.
*
* @retval true - success.
* @retval false - failed.
*
*/
bool NexTouch::recvRetCommandFinished(uint32_t timeout) {
bool ret = false;
uint8_t temp[4] = {0};
nexSerial.setTimeout(timeout);
if (sizeof(temp) != nexSerial.readBytes((char *)temp, sizeof(temp)))
{
ret = false;
}
if (temp[0] == NEX_RET_CMD_FINISHED
&& temp[1] == 0xFF
&& temp[2] == 0xFF
&& temp[3] == 0xFF
) {
ret = true;
}
if (ret) {
dbSerialPrintln("recvRetCommandFinished ok");
}
else {
dbSerialPrintln("recvRetCommandFinished err");
}
return ret;
}
/**
* Send command to Nextion.
*
* @param cmd - the string of command.
*/
void NexTouch::sendCommand(const char* cmd)
{
while (nexSerial.available()) {
nexSerial.read();
}
nexSerial.print(cmd);
nexSerial.write(0xFF);
nexSerial.write(0xFF);
nexSerial.write(0xFF);
}
/**
* Receive string data.
*
* @param buffer - save string data.
* @param len - string buffer length.
* @param timeout - set timeout time.
*
* @return the length of string buffer.
*
*/
uint16_t NexTouch::recvRetString(char *buffer, uint16_t len, uint32_t timeout) {
uint16_t ret = 0;
bool str_start_flag = false;
uint8_t cnt_0xff = 0;
String temp = String("");
uint8_t c = 0;
long start;
if (!buffer || len == 0) {
goto __return;
}
start = millis();
while (millis() - start <= timeout) {
while (nexSerial.available()) {
c = nexSerial.read();
if (str_start_flag)
{
if (0xFF == c) {
cnt_0xff++;
if (cnt_0xff >= 3) {
break;
}
}
else {
temp += (char)c;
}
}
else if (NEX_RET_STRING_HEAD == c) {
str_start_flag = true;
}
}
if (cnt_0xff >= 3) {
break;
}
}
ret = temp.length();
ret = ret > len ? len : ret;
strncpy(buffer, temp.c_str(), ret);
__return:
dbSerialPrint("recvRetString[");
dbSerialPrint(temp.length());
dbSerialPrint(",");
dbSerialPrint(temp);
dbSerialPrintln("]");
return ret;
}
/**
* Receive uint32_t data.
*
* @param number - save uint32_t data.
* @param timeout - set timeout time.
*
* @retval true - success.
* @retval false - failed.
*
*/
bool NexTouch::recvRetNumber(uint32_t *number, uint32_t timeout)
{
bool ret = false;
uint8_t temp[8] = {0};
if (!number)
{
goto __return;
}
nexSerial.setTimeout(timeout);
if (sizeof(temp) != nexSerial.readBytes((char *)temp, sizeof(temp)))
{
goto __return;
}
if (temp[0] == NEX_RET_NUMBER_HEAD
&& temp[5] == 0xFF
&& temp[6] == 0xFF
&& temp[7] == 0xFF
)
{
*number = (temp[4] << 24) | (temp[3] << 16) | (temp[2] << 8) | (temp[1]);
ret = true;
}
__return:
if (ret)
{
dbSerialPrint("recvRetNumber :");
dbSerialPrintln(*number);
}
else
{
dbSerialPrintln("recvRetNumber err");
}
return ret;
}
bool NexTouch::getBrightness(uint32_t *brightness)
{
sendCommand("get dim");
return recvRetNumber(brightness);
}
/**
* Init Nextion's baudrate,page id.
*
* @retval true - success.
* @retval false - failed.
*/
bool nexInit(void)
NexTouch::NexTouch(uint8_t pid, uint8_t cid, const char *name)
:NexObject(pid, cid, name)
{
nexSerial.begin(NEXTION_BAUDRATE);
NexTouch::sendCommand("");
NexTouch::sendCommand("page 0");
delay(100);
return true;
this->__cb_push = NULL;
this->__cb_pop = NULL;
this->__cbpop_ptr = NULL;
this->__cbpush_ptr = NULL;
}
/**
* Call mainEventLoop,watting for Nextion's touch event.
*
* @param nexListenList - index to Nextion Components list.
*
* @retval false - failed.
*/
bool nexLoop(NexTouch **nexListenList)
void NexTouch::attachPush(NexTouchEventCb push, void *ptr)
{
NexTouch::mainEventLoop(nexListenList);
return false;
this->__cb_push = push;
this->__cbpush_ptr = ptr;
}
/**
* Return current page id.
*
* @param pageId - output parameter,to save page id.
*
* @retval true - success.
* @retval false - failed.
*/
bool sendCurrentPageId(uint8_t* pageId)
void NexTouch::detachPush(void)
{
bool ret = false;
uint8_t temp[5] = {0};
if (!pageId)
{
goto __return;
}
NexTouch::sendCommand("sendme");
delay(50);
nexSerial.setTimeout(500);
if (sizeof(temp) != nexSerial.readBytes((char *)temp, sizeof(temp)))
{
goto __return;
}
if (temp[0] == NEX_RET_CURRENT_PAGE_ID_HEAD
&& temp[2] == 0xFF
&& temp[3] == 0xFF
&& temp[4] == 0xFF
)
{
*pageId = temp[1];
ret = true;
}
__return:
if (ret)
{
dbSerialPrint("recvPageId :");
dbSerialPrintln(*pageId);
}
else
{
dbSerialPrintln("recvPageId err");
}
return ret;
this->__cb_push = NULL;
this->__cbpush_ptr = NULL;
}
/**
* Touch screen calibration.
*
* @retval true - success.
* @retval false - failed.
*/
bool touchCalibration(void)
void NexTouch::attachPop(NexTouchEventCb pop, void *ptr)
{
bool ret = false;
NexTouch::sendCommand("touch_j");
delay(10);
if(NexTouch::recvRetCommandFinished())
{
dbSerialPrintln("TouchCalibration ok ");
ret = true;
}
else
{
dbSerialPrintln("TouchCalibration err ");
}
return ret;
this->__cb_pop = pop;
this->__cbpop_ptr = ptr;
}
/**
* Disable all touch hot.
*
* @retval true - success.
* @retval false - failed.
*/
bool disableTouchFocus(void)
void NexTouch::detachPop(void)
{
bool ret = false;
NexTouch::sendCommand("cle_c");
delay(10);
if(NexTouch::recvRetCommandFinished())
{
dbSerialPrintln("disableTouchFocus ok ");
ret = true;
}
else
{
dbSerialPrintln("disableTouchFocus err ");
}
return ret;
this->__cb_pop = NULL;
this->__cbpop_ptr = NULL;
}
/**
* Pause serial instruction execution.
*
* @retval true - success.
* @retval false - failed.
*/
bool pauseSerialCommand(void)
void NexTouch::push(void)
{
bool ret = false;
NexTouch::sendCommand("com_stop");
delay(10);
if(NexTouch::recvRetCommandFinished())
if (__cb_push)
{
dbSerialPrintln("pauseSerialCommand ok ");
ret = true;
__cb_push(__cbpush_ptr);
}
else
{
dbSerialPrintln("pauseSerialCommand err ");
}
return ret;
}
/**
* Recovery serial instruction execution.
*
* @retval true - success.
* @retval false - failed.
*/
bool recoverySerialCommand(void)
{
bool ret = false;
NexTouch::sendCommand("com_star");
delay(10);
if(NexTouch::recvRetCommandFinished())
{
dbSerialPrintln("recoverySerialCommand ok ");
ret = true;
}
else
{
dbSerialPrintln("recoverySerialCommand err ");
}
return ret;
}
/**
* Set current backlight brightness value.
*
* @param dimValue - current backlight brightness value.
*
* @retval true - success.
* @retval false - failed.
*/
bool setCurrentBrightness(uint8_t dimValue)
void NexTouch::pop(void)
{
bool ret = false;
char buf[10] = {0};
String cmd;
utoa(dimValue, buf, 10);
cmd += "dim=";
cmd += buf;
NexTouch::sendCommand(cmd.c_str());
delay(10);
if(NexTouch::recvRetCommandFinished())
{
dbSerialPrint("setCurrentBrightness[ ");
dbSerialPrint(dimValue);
dbSerialPrintln("]ok ");
ret = true;
}
else
if (__cb_pop)
{
dbSerialPrintln("setCurrentBrightness err ");
__cb_pop(__cbpop_ptr);
}
return ret;
}
/**
* Set default backlight brightness value.
*
* @param dimDefaultValue - default backlight brightness value.
*
* @retval true - success.
* @retval false - failed.
*/
bool setDefaultBrightness(uint8_t dimDefaultValue)
void NexTouch::iterate(NexTouch **list, uint8_t pid, uint8_t cid, int32_t event)
{
bool ret = false;
char buf[10] = {0};
String cmd;
utoa(dimDefaultValue, buf, 10);
cmd += "dims=";
cmd += buf;
NexTouch::sendCommand(cmd.c_str());
delay(10);
NexTouch *e = NULL;
uint16_t i = 0;
if(NexTouch::recvRetCommandFinished())
{
dbSerialPrint("setDefaultBrightness[");
dbSerialPrint(dimDefaultValue);
dbSerialPrintln("]ok");
ret = true;
}
else
if (NULL == list)
{
dbSerialPrintln("setDefaultBrightness err ");
return;
}
return ret;
}
/**
* Set device in sleep mode.
*
* @param mode - 1:into sleep mode,0:exit sleep mode.
*
* @retval true - success.
* @retval false - failed.
*/
bool sleepMode(uint8_t mode)
{
bool ret = false;
char buf[10] = {0};
String cmd;
if(mode != 0 && mode != 1)
{
dbSerialPrintln("mode input ok ");
return ret;
}
utoa(mode, buf, 10);
cmd += "sleep=";
cmd += buf;
NexTouch::sendCommand(cmd.c_str());
delay(10);
if(NexTouch::recvRetCommandFinished())
{
dbSerialPrintln("sleepMode ok ");
ret = true;
}
else
{
dbSerialPrintln("sleepMode err ");
}
return ret;
}
/**
* Set current baudrate.
*
* @param baudrate - current baudrate,it supports 2400,4800,9600,19200,38400,57600,115200.
*
* @retval true - success.
* @retval false - failed.
*/
bool setCurrentBaudrate(uint32_t baudrate)
{
bool ret = false;
char buf[10] = {0};
String cmd;
utoa(baudrate, buf, 10);
cmd += "baud=";
cmd += buf;
NexTouch::sendCommand(cmd.c_str());
delay(10);
if(NexTouch::recvRetCommandFinished())
{
dbSerialPrintln("setCurrentBaudrate ok ");
ret = true;
}
else
{
dbSerialPrintln("setCurrentBaudrate err ");
for(i = 0; (e = list[i]) != NULL; i++)
{
if (e->getObjPid() == pid && e->getObjCid() == cid)
{
e->printObjInfo();
if (NEX_EVENT_PUSH == event)
{
e->push();
}
else if (NEX_EVENT_POP == event)
{
e->pop();
}
break;
}
}
return ret;
}
/**
* Set default baudrate.
*
* @param defaultBaudrate - default baudrate,it supports 2400,4800,9600,19200,38400,57600,115200.
*
* @retval true - success.
* @retval false - failed.
*/
bool setDefaultBaudrate(uint32_t defaultBaudrate)
{
bool ret = false;
char buf[10] = {0};
String cmd;
utoa(defaultBaudrate, buf, 10);
cmd += "bauds=";
cmd += buf;
NexTouch::sendCommand(cmd.c_str());
delay(10);
if(NexTouch::recvRetCommandFinished())
{
dbSerialPrintln("setDefaultBaudrate ok ");
ret = true;
}
else
{
dbSerialPrintln("setDefaultBaudrate err ");
}
return ret;
}
/**
* @file NexTouch.h
*
* API of Nextion.
* The definition of class NexTouch.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/7/10
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
......@@ -15,107 +16,101 @@
#ifndef __NEXTOUCH_H__
#define __NEXTOUCH_H__
#ifdef __cplusplus
#include <Arduino.h>
#include "NexSerialConfig.h"
typedef uint8_t NexPid;
typedef uint8_t NexCid;
#include <Arduino.h>
#include "NexConfig.h"
#include "NexObject.h"
typedef enum {
NEX_EVENT_POP = 0x00,
NEX_EVENT_PUSH = 0x01,
NEX_EVENT_NULL
} NexEventType;
/**
* @addtogroup TouchEvent
* @{
*/
/*The first byte of Nextoin's return value*/
#define NEX_RET_CMD_FINISHED (0x01)
#define NEX_RET_EVENT_LAUNCHED (0x88)
#define NEX_RET_EVENT_UPGRADED (0x89)
#define NEX_RET_EVENT_TOUCH_HEAD (0x65)
#define NEX_RET_EVENT_POSITION_HEAD (0x67)
#define NEX_RET_EVENT_SLEEP_POSITION_HEAD (0x68)
#define NEX_RET_CURRENT_PAGE_ID_HEAD (0x66)
#define NEX_RET_STRING_HEAD (0x70)
#define NEX_RET_NUMBER_HEAD (0x71)
#define NEX_RET_INVALID_CMD (0x00)
#define NEX_RET_INVALID_COMPONENT_ID (0x02)
#define NEX_RET_INVALID_PAGE_ID (0x03)
#define NEX_RET_INVALID_PICTURE_ID (0x04)
#define NEX_RET_INVALID_FONT_ID (0x05)
#define NEX_RET_INVALID_BAUD (0x11)
#define NEX_RET_INVALID_VARIABLE (0x1A)
#define NEX_RET_INVALID_OPERATION (0x1B)
/**
* Push touch event occuring when your finger or pen coming to Nextion touch pannel.
*/
#define NEX_EVENT_PUSH (0x01)
/**
* Pop touch event occuring when your finger or pen leaving from Nextion touch pannel.
*/
#define NEX_EVENT_POP (0x00)
/**
* Type of callback funciton when an touch event occurs.
*
* @param ptr - user pointer for any purpose. Commonly, it is a pointer to a object.
* @return none.
*/
typedef void (*NexTouchEventCb)(void *ptr);
/**
* Root Class of Nextion Components.
* Father class of the components with touch events.
*
* Derives from NexObject and provides methods allowing user to attach
* (or detach) a callback function called when push(or pop) touch event occurs.
*/
class NexTouch
class NexTouch: public NexObject
{
public: /* static methods */
static uint8_t mainEventLoop(NexTouch **list);
static void sendCommand(const char *cmd);
static bool recvRetCommandFinished(uint32_t timeout = 100);
static uint16_t recvRetString(char *buffer, uint16_t len, uint32_t timeout = 500);
static bool recvRetNumber(uint32_t *number, uint32_t timeout = 500);
public: /* static methods */
static void iterate(NexTouch **list, uint8_t pid, uint8_t cid, int32_t event);
public: /* methods */
NexTouch(NexPid pid, NexCid cid, char *name,
NexTouchEventCb pop = NULL, void *pop_ptr = NULL,
NexTouchEventCb push = NULL, void *push_ptr = NULL);
NexPid getPid(void);
NexCid getCid(void);
const char *getObjName(void);
void print(void);
protected: /* static methods */
static bool setBrightness(uint32_t brightness);
static bool getBrightness(uint32_t *brightness);
/**
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
*/
NexTouch(uint8_t pid, uint8_t cid, const char *name);
protected: /* methods */
/**
* Attach an callback function of push touch event.
*
* @param push - callback called with ptr when a push touch event occurs.
* @param ptr - parameter passed into push[default:NULL].
* @return none.
*
* @note If calling this method multiply, the last call is valid.
*/
void attachPush(NexTouchEventCb push, void *ptr = NULL);
/**
* Detach an callback function.
*
* @return none.
*/
void detachPush(void);
/**
* Attach an callback function of pop touch event.
*
* @param pop - callback called with ptr when a pop touch event occurs.
* @param ptr - parameter passed into pop[default:NULL].
* @return none.
*
* @note If calling this method multiply, the last call is valid.
*/
void attachPop(NexTouchEventCb pop, void *ptr = NULL);
void detachPop(void);
private: /* static methods */
static void iterate(NexTouch **list, NexPid pid, NexCid cid, NexEventType event);
/**
* Detach an callback function.
*
* @return none.
*/
void detachPop(void);
private: /* methods */
void push(void);
void pop(void);
private: /* static data */
static uint8_t __buffer[256];
private: /* data */
NexPid pid; /* Page ID */
NexCid cid; /* Component ID */
char *name; /* An unique name */
NexTouchEventCb cbPush;
NexTouchEventCb __cb_push;
void *__cbpush_ptr;
NexTouchEventCb cbPop;
NexTouchEventCb __cb_pop;
void *__cbpop_ptr;
};
bool nexInit(void);
bool nexLoop(NexTouch **nexListenList);
bool sendCurrentPageId(uint8_t* pageId);
bool touchCalibration(void);
bool disableTouchFocus(void);
bool pauseSerialCommand(void);
bool recoverySerialCommand(void);
bool clearSerialSurplusCommand(void);
bool setCurrentBrightness(uint8_t dimValue);
bool setDefaultBrightness(uint8_t dimDefaultValue);
bool sleepMode(uint8_t mode);
bool setCurrentBaudrate(uint32_t baudrate);
bool setDefaultBaudrate(uint32_t baudrate);
/**
* @}
*/
#endif /* #ifdef __cplusplus */
#endif /* #ifndef __NEXTOUCH_H__ */
/**
* @file NexWaveform.cpp
*
* The implementation of class NexWaveform.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* 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 2 of
* the License, or (at your option) any later version.
*/
#include "NexWaveform.h"
NexWaveform::NexWaveform(uint8_t pid, uint8_t cid, const char *name)
:NexObject(pid, cid, name)
{
}
bool NexWaveform::addValue(uint8_t ch, uint8_t number)
{
char buf[15] = {0};
if (ch > 3)
{
return false;
}
sprintf(buf, "add %u,%u,%u", getObjCid(), ch, number);
sendCommand(buf);
return true;
}
/**
* @file NexWaveform.h
*
* The definition of class NexWaveform.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
*
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* 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 2 of
* the License, or (at your option) any later version.
*/
#ifndef __NEXWAVEFORM_H__
#define __NEXWAVEFORM_H__
#include "NexTouch.h"
#include "NexHardware.h"
/**
* @addtogroup Component
* @{
*/
/**
* NexWaveform component.
*/
class NexWaveform: public NexObject
{
public: /* methods */
/**
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
*/
NexWaveform(uint8_t pid, uint8_t cid, const char *name);
/**
* Add value to show.
*
* @param ch - channel of waveform(0-3).
* @param number - the value of waveform.
*
* @retval true - success.
* @retval false - failed.
*/
bool addValue(uint8_t ch, uint8_t number);
};
/**
* @}
*/
#endif /* #ifndef __NEXWAVEFORM_H__ */
/**
* @file NexSlice.h
* @file Nextion.h
*
* API of NexSlice.
* The header file including all other header files provided by this library.
*
* Every example sketch should include this file.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/7/10
* @date 2015/8/12
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
......@@ -12,27 +14,23 @@
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*/
#ifndef __NEXTION_H__
#define __NEXTION_H__
#ifndef __NEXSLICE_H__
#define __NEXSLICE_H__
#ifdef __cplusplus
#include "Arduino.h"
#include "NexConfig.h"
#include "NexTouch.h"
#include "NexHardware.h"
/**
* NexSlice,subclass of NexTouch,provides simple methods to control slice component.
*
*/
class NexSlice: public NexTouch
{
public: /* methods */
NexSlice(NexPid pid, NexCid cid, char *name, NexTouchEventCb pop = NULL, void *pop_ptr = NULL);
void attachPop(NexTouchEventCb pop, void *ptr = NULL);
void detachPop(void);
bool getPic(uint32_t *number);
bool setPic(uint32_t number);
};
#include "NexButton.h"
//#include "NexCrop.h"
//#include "NexGauge.h"
#include "NexHotspot.h"
#include "NexPage.h"
#include "NexPicture.h"
#include "NexProgressBar.h"
#include "NexSlider.h"
#include "NexText.h"
#include "NexWaveform.h"
#endif /* #ifdef __cplusplus */
#endif /* #ifndef __NEXSLICE_H__ */
#endif /* #ifndef __NEXTION_H__ */
......@@ -316,8 +316,8 @@ void CardReader::openFile(char* name, bool read, bool replace_current/*=true*/,
subdirname[dirname_end - dirname_start] = 0;
ECHO_EV(subdirname);
if (!myDir.open(curDir, subdirname, O_READ)) {
ECHO_MV(MSG_SD_OPEN_FILE_FAIL, subdirname);
ECHO_C('.');
ECHO_SMV(ER, MSG_SD_OPEN_FILE_FAIL, subdirname);
ECHO_EM(".");
return;
}
else {
......@@ -357,12 +357,12 @@ void CardReader::openFile(char* name, bool read, bool replace_current/*=true*/,
}
else { //write
if (!file.open(curDir, fname, O_CREAT | O_APPEND | O_WRITE | O_TRUNC)) {
ECHO_MV(MSG_SD_OPEN_FILE_FAIL, fname);
ECHO_PGM(".\n");
ECHO_SMV(ER, MSG_SD_OPEN_FILE_FAIL, fname);
ECHO_EM(".");
}
else {
saving = true;
ECHO_EMV(MSG_SD_WRITE_TO_FILE, name);
ECHO_LMV(DB, MSG_SD_WRITE_TO_FILE, name);
if(lcd_status) lcd_setstatus(fname);
}
}
......@@ -389,8 +389,8 @@ void CardReader::removeFile(char* name) {
subdirname[dirname_end - dirname_start] = 0;
ECHO_EV(subdirname);
if (!myDir.open(curDir, subdirname, O_READ)) {
ECHO_MV(MSG_SD_OPEN_FILE_FAIL, subdirname);
ECHO_C('.');
ECHO_SMV(DB, MSG_SD_OPEN_FILE_FAIL, subdirname);
ECHO_EM(".");
return;
}
......@@ -509,7 +509,7 @@ void CardReader::parseKeyLine(char *key, char *value, int &len_k, int &len_v) {
int ln_buf = 0;
char ln_char;
bool ln_space = false, ln_ignore = false, key_found = false;
while(!eof()) { //READ KEY
while(!eof()) { //READ KEY
ln_char = (char)get();
if(ln_char == '\n') {
ln_buf = 0;
......@@ -542,7 +542,7 @@ void CardReader::parseKeyLine(char *key, char *value, int &len_k, int &len_v) {
}
ln_buf = 0;
ln_ignore = false;
while(!eof()) { //READ VALUE
while(!eof()) { //READ VALUE
ln_char = (char)get();
if(ln_char == '\n') {
value[ln_buf] = '\0';
......
......@@ -25,17 +25,17 @@
#include "WString.h"
#ifdef AT90USB
#ifdef BTENABLED
#define MYSERIAL bt
#ifdef USBCON
#if ENABLED(BLUETOOTH)
#define MYSERIAL bluetoothSerial
#else
#define MYSERIAL Serial
#endif // BTENABLED
#endif // BLUETOOTH
#else
#ifdef __SAM3X8E__
#define MYSERIAL Serial
#else
#define MYSERIAL MSerial
#define MYSERIAL customizedSerial
#endif
#endif
......
......@@ -223,14 +223,6 @@
#undef HAS_LCD_CONTRAST
#endif
#endif
/**
* SPLASH_SCREEN_DURATION for no DOGLCD display
*/
#if DISABLED(DOGLCD)
#undef SPLASH_SCREEN_DURATION
#define SPLASH_SCREEN_DURATION 500
#endif
#else // CONFIGURATION_LCD
#define CONDITIONALS_H
......@@ -265,14 +257,16 @@
* ENDSTOPPULLUPS
*/
#if ENABLED(ENDSTOPPULLUPS)
#define ENDSTOPPULLUP_XMAX
#define ENDSTOPPULLUP_YMAX
#define ENDSTOPPULLUP_ZMAX
#define ENDSTOPPULLUP_XMIN
#define ENDSTOPPULLUP_YMIN
#define ENDSTOPPULLUP_ZMIN
#define ENDSTOPPULLUP_EMIN
#define ENDSTOPPULLUP_Z2MIN
#define ENDSTOPPULLUP_XMAX
#define ENDSTOPPULLUP_YMAX
#define ENDSTOPPULLUP_ZMAX
#define ENDSTOPPULLUP_Z2MAX
#define ENDSTOPPULLUP_ZPROBE
#define ENDSTOPPULLUP_EMIN
#endif
/**
......@@ -366,7 +360,7 @@
/**
* Auto Bed Leveling
*/
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
// Boundaries for probing based on set limits
#define MIN_PROBE_X (max(X_MIN_POS, X_MIN_POS + X_PROBE_OFFSET_FROM_EXTRUDER))
#define MAX_PROBE_X (min(X_MAX_POS, X_MAX_POS + X_PROBE_OFFSET_FROM_EXTRUDER))
......
......@@ -455,16 +455,16 @@ void Config_ResetDefault() {
else
max_e_jerk[i] = tmp5[max_i - 1];
#if HOTENDS > 1
max_i = sizeof(tmp9) / sizeof(*tmp9);
if(i < max_i)
hotend_offset[X_AXIS][i] = tmp9[i];
else
hotend_offset[X_AXIS][i] = 0;
max_i = sizeof(tmp10) / sizeof(*tmp10);
if(i < max_i)
hotend_offset[Y_AXIS][i] = tmp10[i];
else
hotend_offset[Y_AXIS][i] = 0;
max_i = sizeof(tmp9) / sizeof(*tmp9);
if(i < max_i)
hotend_offset[X_AXIS][i] = tmp9[i];
else
hotend_offset[X_AXIS][i] = 0;
max_i = sizeof(tmp10) / sizeof(*tmp10);
if(i < max_i)
hotend_offset[Y_AXIS][i] = tmp10[i];
else
hotend_offset[Y_AXIS][i] = 0;
#endif // HOTENDS > 1
}
}
......@@ -488,7 +488,7 @@ void Config_ResetDefault() {
max_z_jerk = DEFAULT_ZJERK;
home_offset[X_AXIS] = home_offset[Y_AXIS] = home_offset[Z_AXIS] = 0;
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
zprobe_zoffset = Z_PROBE_OFFSET_FROM_EXTRUDER;
#elif !defined(DELTA)
zprobe_zoffset = 0;
......@@ -718,7 +718,7 @@ void Config_ResetDefault() {
ECHO_LM(DB, "Z2 Endstop adjustement (mm):");
}
ECHO_LMV(DB, " M666 Z", z_endstop_adj );
#elif ENABLED(ENABLE_AUTO_BED_LEVELING)
#elif ENABLED(AUTO_BED_LEVELING_FEATURE)
if (!forReplay) {
ECHO_LM(DB, "Z Probe offset (mm)");
}
......
......@@ -30,7 +30,7 @@ void ConfigSD_ResetDefault();
"TME",
};
enum cfgSD_ENUM { //This need to be in the same order as cfgSD_KEY
enum cfgSD_ENUM { //This need to be in the same order as cfgSD_KEY
#if HAS_POWER_CONSUMPTION_SENSOR
SD_CFG_PWR,
#endif
......
......@@ -3,30 +3,32 @@
// Please note that using the high-res version takes 402Bytes of PROGMEM.
#define START_BMPHIGH
#if ENABLED(START_BMPHIGH)
#define START_BMPWIDTH 112
#define START_BMPHEIGHT 38
#define START_BMPBYTEWIDTH 14
#define START_BMPBYTES 532 // START_BMPWIDTH * START_BMPHEIGHT / 8
const unsigned char start_bmp[START_BMPBYTES] PROGMEM = {
0x3,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xf,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0x1e,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x78,0x38,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0x70,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xe,0x60,0x0,0x0,0x0,0x0,0x30,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x6,0xe0,0x1f,0x7c,0x0,0x0,0x33,0x0,0x0,0x0,0x0,0x1,0x80,0x3,0x87,0xc0,0x3f,0xfe,0x0,0x0,0x33,0x0,0x0,0x0,0x0,0x1,0xc0,0x2,0x83,
0xc0,0x73,0xce,0x0,0x0,0x30,0x0,0x0,0x0,0x0,0x3,0xc0,0x3,0x83,0xc0,0xf3,0xce,0x3c,0xf,0x33,0xf,0x0,0x0,0x0,0x3,0xc0,0x2,0x83,0xc0,0xe3,0x8e,0x7e,0x1f,0xb3,0x1f,0x80,0x0,0x0,0x1f,0xe0,0x0,0x3,0xc0,0xe3,0x8e,0xe7,0x39,0xb3,0x39,0xc0,0x0,0x0,0xff,0xfc,0x3,0x83,0xc0,0xe3,0x8e,0xc3,0x31,0xb3,0x38,0xc0,0x0,0x0,0x3f,0xff,0x2,0x3,0xc0,0xe3,0x8e,0xc3,0x30,0x33,0x38,0xc0,0x0,0x0,0x7,0xf0,0x2,0x3,0xc0,0xe3,0x8e,0xe3,0x30,0x33,0x38,0xc0,0x0,0x1,0x7,0xf0,0x3,0x83,0xc0,0xe3,0x8e,0xfb,0xf0,0x3f,0xf8,0xc0,0x0,0x3,0x83,0xf0,0x0,0x3,
0xc0,0x63,0x8e,0x7b,0xf0,0x1f,0xf8,0xc0,0x0,0x7,0xc1,0xf8,0x0,0x3,0xc0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3,0x9f,0xfe,0x0,0x3,0xc0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0xff,0x80,0x43,0xe0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7f,0xff,0xf8,0xc3,0xf0,0x0,0x0,0x0,0x0,0x0,0x3,0x0,0x0,0x0,0x33,0xff,0xff,0xc3,0xf8,0x0,0x0,0x30,0xf0,0x0,0x3,0x0,0x0,0x0,0x19,0xff,0xff,0x83,0xfc,0x0,0x0,0x71,0xe6,0x0,0x3,0x0,0x0,0x0,0xc,0x7f,0xff,0x3,0xfe,0x0,0x0,0x73,0xc6,0x0,0x3,0x0,0x0,0x0,0x6,0x7f,0xff,0x3,
0xff,0x0,0x0,0x77,0x80,0x0,0x3,0x0,0x0,0x0,0x3,0x3f,0xfe,0x3,0xff,0x80,0x0,0x7f,0x6,0x7f,0xe3,0xf0,0xf0,0xf0,0x1,0x9f,0xfc,0x3,0xff,0xc0,0x0,0x7e,0x6,0xff,0xf3,0xf9,0xf9,0xf8,0x0,0xcf,0xf8,0x3,0xff,0xe0,0x0,0x7c,0x6,0xe7,0x33,0x9b,0x9b,0x9c,0x0,0x67,0xf0,0x3,0xff,0xf0,0x0,0x7e,0x6,0xe3,0x1b,0x1b,0x1b,0xc,0x0,0x33,0xc0,0x3,0xff,0xf8,0x0,0x7f,0x6,0xe3,0x1b,0x1b,0x3,0xc,0x0,0x19,0x0,0x3,0xff,0xfc,0x0,0x73,0x86,0xe3,0x1b,0x3b,0x3,0x8c,0x0,0xc,0x0,0x3,0xff,0xfe,0x0,0x71,0xc6,0xe3,0x1b,0xf3,0x3,0xef,0x0,0x6,0x0,0x7,
0xff,0xff,0x0,0x30,0xe6,0x63,0x19,0xe3,0x1,0xef,0x0,0x2,0x0,0x6,0xff,0xff,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xe,0xff,0xff,0xc0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0xff,0xff,0xe0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x78,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xc0
};
#else
#define START_BMPWIDTH 56
#define START_BMPHEIGHT 19
#define START_BMPBYTEWIDTH 7
#define START_BMPBYTES 133 // START_BMPWIDTH * START_BMPHEIGHT / 8
#if ENABLED(SHOW_BOOTSCREEN)
#if ENABLED(START_BMPHIGH)
#define START_BMPWIDTH 112
#define START_BMPHEIGHT 38
#define START_BMPBYTEWIDTH 14
#define START_BMPBYTES 532 // START_BMPWIDTH * START_BMPHEIGHT / 8
const unsigned char start_bmp[START_BMPBYTES] PROGMEM = {
0x1f,0xff,0xff,0xff,0xff,0xff,0xfc,0x30,0x0,0x0,0x0,0x0,0x0,0x6,0x60,0x0,0x0,0x0,0x0,0x0,0x3,0xc3,0x60,0x5,0x0,0x0,0x8,0x1,0x84,0x90,0x4,0x0,0x0,0x18,0x1,0x84,0x97,0x75,0x70,0x0,0x3c,0x1,0x84,0x95,0x45,0x50,0x0,0x7f,0x1,0x84,0x95,0x45,0x50,0x0,0x1c,0x1,
0x84,0x97,0xc5,0x50,0x1,0x8e,0x1,0x80,0x0,0x0,0x0,0x0,0xff,0x81,0xc0,0x0,0x0,0x10,0x0,0x5f,0xf9,0xe0,0x2,0xd0,0x10,0x0,0x27,0xf1,0xf0,0x3,0x80,0x10,0x0,0x17,0xf1,0xf8,0x3,0x17,0xde,0xee,0xb,0xe1,0xfc,0x3,0x15,0x52,0x8a,0x5,0x81,0xfe,0x3,0x95,0x52,0x8a,0x2,0x1,
0xff,0x2,0xd5,0x5e,0x8f,0x1,0x1,0xff,0x80,0x0,0x0,0x0,0x0,0x3,0xff,0xff,0xff,0xff,0xff,0xff,0xfe
};
const unsigned char start_bmp[START_BMPBYTES] PROGMEM = {
0x3,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xf,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0x1e,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x78,0x38,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0x70,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xe,0x60,0x0,0x0,0x0,0x0,0x30,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x6,0xe0,0x1f,0x7c,0x0,0x0,0x33,0x0,0x0,0x0,0x0,0x1,0x80,0x3,0x87,0xc0,0x3f,0xfe,0x0,0x0,0x33,0x0,0x0,0x0,0x0,0x1,0xc0,0x2,0x83,
0xc0,0x73,0xce,0x0,0x0,0x30,0x0,0x0,0x0,0x0,0x3,0xc0,0x3,0x83,0xc0,0xf3,0xce,0x3c,0xf,0x33,0xf,0x0,0x0,0x0,0x3,0xc0,0x2,0x83,0xc0,0xe3,0x8e,0x7e,0x1f,0xb3,0x1f,0x80,0x0,0x0,0x1f,0xe0,0x0,0x3,0xc0,0xe3,0x8e,0xe7,0x39,0xb3,0x39,0xc0,0x0,0x0,0xff,0xfc,0x3,0x83,0xc0,0xe3,0x8e,0xc3,0x31,0xb3,0x38,0xc0,0x0,0x0,0x3f,0xff,0x2,0x3,0xc0,0xe3,0x8e,0xc3,0x30,0x33,0x38,0xc0,0x0,0x0,0x7,0xf0,0x2,0x3,0xc0,0xe3,0x8e,0xe3,0x30,0x33,0x38,0xc0,0x0,0x1,0x7,0xf0,0x3,0x83,0xc0,0xe3,0x8e,0xfb,0xf0,0x3f,0xf8,0xc0,0x0,0x3,0x83,0xf0,0x0,0x3,
0xc0,0x63,0x8e,0x7b,0xf0,0x1f,0xf8,0xc0,0x0,0x7,0xc1,0xf8,0x0,0x3,0xc0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3,0x9f,0xfe,0x0,0x3,0xc0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0xff,0x80,0x43,0xe0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7f,0xff,0xf8,0xc3,0xf0,0x0,0x0,0x0,0x0,0x0,0x3,0x0,0x0,0x0,0x33,0xff,0xff,0xc3,0xf8,0x0,0x0,0x30,0xf0,0x0,0x3,0x0,0x0,0x0,0x19,0xff,0xff,0x83,0xfc,0x0,0x0,0x71,0xe6,0x0,0x3,0x0,0x0,0x0,0xc,0x7f,0xff,0x3,0xfe,0x0,0x0,0x73,0xc6,0x0,0x3,0x0,0x0,0x0,0x6,0x7f,0xff,0x3,
0xff,0x0,0x0,0x77,0x80,0x0,0x3,0x0,0x0,0x0,0x3,0x3f,0xfe,0x3,0xff,0x80,0x0,0x7f,0x6,0x7f,0xe3,0xf0,0xf0,0xf0,0x1,0x9f,0xfc,0x3,0xff,0xc0,0x0,0x7e,0x6,0xff,0xf3,0xf9,0xf9,0xf8,0x0,0xcf,0xf8,0x3,0xff,0xe0,0x0,0x7c,0x6,0xe7,0x33,0x9b,0x9b,0x9c,0x0,0x67,0xf0,0x3,0xff,0xf0,0x0,0x7e,0x6,0xe3,0x1b,0x1b,0x1b,0xc,0x0,0x33,0xc0,0x3,0xff,0xf8,0x0,0x7f,0x6,0xe3,0x1b,0x1b,0x3,0xc,0x0,0x19,0x0,0x3,0xff,0xfc,0x0,0x73,0x86,0xe3,0x1b,0x3b,0x3,0x8c,0x0,0xc,0x0,0x3,0xff,0xfe,0x0,0x71,0xc6,0xe3,0x1b,0xf3,0x3,0xef,0x0,0x6,0x0,0x7,
0xff,0xff,0x0,0x30,0xe6,0x63,0x19,0xe3,0x1,0xef,0x0,0x2,0x0,0x6,0xff,0xff,0x80,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xe,0xff,0xff,0xc0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1c,0xff,0xff,0xe0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x78,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xc0
};
#else
#define START_BMPWIDTH 56
#define START_BMPHEIGHT 19
#define START_BMPBYTEWIDTH 7
#define START_BMPBYTES 133 // START_BMPWIDTH * START_BMPHEIGHT / 8
const unsigned char start_bmp[START_BMPBYTES] PROGMEM = {
0x1f,0xff,0xff,0xff,0xff,0xff,0xfc,0x30,0x0,0x0,0x0,0x0,0x0,0x6,0x60,0x0,0x0,0x0,0x0,0x0,0x3,0xc3,0x60,0x5,0x0,0x0,0x8,0x1,0x84,0x90,0x4,0x0,0x0,0x18,0x1,0x84,0x97,0x75,0x70,0x0,0x3c,0x1,0x84,0x95,0x45,0x50,0x0,0x7f,0x1,0x84,0x95,0x45,0x50,0x0,0x1c,0x1,
0x84,0x97,0xc5,0x50,0x1,0x8e,0x1,0x80,0x0,0x0,0x0,0x0,0xff,0x81,0xc0,0x0,0x0,0x10,0x0,0x5f,0xf9,0xe0,0x2,0xd0,0x10,0x0,0x27,0xf1,0xf0,0x3,0x80,0x10,0x0,0x17,0xf1,0xf8,0x3,0x17,0xde,0xee,0xb,0xe1,0xfc,0x3,0x15,0x52,0x8a,0x5,0x81,0xfe,0x3,0x95,0x52,0x8a,0x2,0x1,
0xff,0x2,0xd5,0x5e,0x8f,0x1,0x1,0xff,0x80,0x0,0x0,0x0,0x0,0x3,0xff,0xff,0xff,0xff,0xff,0xff,0xfe
};
#endif
#endif
// Here comes a compile-time operation to match the extruder symbols
......@@ -37,8 +39,8 @@
#if HOTENDS == 1
#define STATUS_SCREENWIDTH 115 //Width in pixels
#define STATUS_SCREENHEIGHT 19 //Height in pixels
#define STATUS_SCREENBYTEWIDTH 15 //Width in bytes
#define STATUS_SCREENHEIGHT 19 //Height in pixels
#define STATUS_SCREENBYTEWIDTH 15 //Width in bytes
const unsigned char status_screen0_bmp[] PROGMEM = { //AVR-GCC, WinAVR
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xE0,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0xE0,
......@@ -62,8 +64,8 @@
};
#define STATUS_SCREENWIDTH 115 //Width in pixels
#define STATUS_SCREENHEIGHT 19 //Height in pixels
#define STATUS_SCREENBYTEWIDTH 15 //Width in bytes
#define STATUS_SCREENHEIGHT 19 //Height in pixels
#define STATUS_SCREENBYTEWIDTH 15 //Width in bytes
const unsigned char status_screen1_bmp[] PROGMEM = { //AVR-GCC, WinAVR
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xE0,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0xE0,
......@@ -87,8 +89,8 @@
};
#elif HOTENDS == 2
#define STATUS_SCREENWIDTH 115 //Width in pixels
#define STATUS_SCREENHEIGHT 19 //Height in pixels
#define STATUS_SCREENBYTEWIDTH 15 //Width in bytes
#define STATUS_SCREENHEIGHT 19 //Height in pixels
#define STATUS_SCREENBYTEWIDTH 15 //Width in bytes
const unsigned char status_screen0_bmp[] PROGMEM = { //AVR-GCC, WinAVR
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xE0,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0xE0,
......@@ -112,8 +114,8 @@
};
#define STATUS_SCREENWIDTH 115 //Width in pixels
#define STATUS_SCREENHEIGHT 19 //Height in pixels
#define STATUS_SCREENBYTEWIDTH 15 //Width in bytes
#define STATUS_SCREENHEIGHT 19 //Height in pixels
#define STATUS_SCREENBYTEWIDTH 15 //Width in bytes
const unsigned char status_screen1_bmp[] PROGMEM = { //AVR-GCC, WinAVR
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xE0,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0xE0,
......@@ -137,8 +139,8 @@
};
#else
#define STATUS_SCREENWIDTH 115 //Width in pixels
#define STATUS_SCREENHEIGHT 19 //Height in pixels
#define STATUS_SCREENBYTEWIDTH 15 //Width in bytes
#define STATUS_SCREENHEIGHT 19 //Height in pixels
#define STATUS_SCREENBYTEWIDTH 15 //Width in bytes
const unsigned char status_screen0_bmp[] PROGMEM = { //AVR-GCC, WinAVR
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xE0,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0xE0,
......@@ -162,8 +164,8 @@
};
#define STATUS_SCREENWIDTH 115 //Width in pixels
#define STATUS_SCREENHEIGHT 19 //Height in pixels
#define STATUS_SCREENBYTEWIDTH 15 //Width in bytes
#define STATUS_SCREENHEIGHT 19 //Height in pixels
#define STATUS_SCREENBYTEWIDTH 15 //Width in bytes
const unsigned char status_screen1_bmp[] PROGMEM = { //AVR-GCC, WinAVR
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xE0,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0xE0,
......@@ -186,5 +188,3 @@
0x0C,0x00,0x00,0x06,0x00,0x00,0x06,0x00,0x01,0xFF,0xFF,0x80,0x00,0x00,0x00
};
#endif // Extruders
......@@ -115,10 +115,8 @@
// LCD selection
#if ENABLED(U8GLIB_ST7920)
//U8GLIB_ST7920_128X64_RRD u8g(0,0,0);
//U8GLIB_ST7920_128X64_RRD u8g(0);
U8GLIB_ST7920_128X64_1X u8g(LCD_PINS_D4, LCD_PINS_ENABLE, LCD_PINS_RS);
#elif defined(U8GLIB_SSD1306)
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_DEV_0|U8G_I2C_OPT_NO_ACK|U8G_I2C_OPT_FAST);
U8GLIB_ST7920_128X64_RRD u8g(0);
//U8GLIB_ST7920_128X64_1X u8g(LCD_PINS_D4, LCD_PINS_ENABLE, LCD_PINS_RS);
#elif ENABLED(MAKRPANEL)
// The MaKrPanel display, ST7565 controller as well
U8GLIB_NHD_C12864 u8g(DOGLCD_CS, DOGLCD_A0);
......@@ -128,10 +126,10 @@
#elif ENABLED(U8GLIB_LM6059_AF)
// Based on the Adafruit ST7565 (http://www.adafruit.com/products/250)
U8GLIB_LM6059 u8g(DOGLCD_CS, DOGLCD_A0);
#elif defined U8GLIB_SSD1306
#elif ENABLED(U8GLIB_SSD1306)
// Generic support for SSD1306 OLED I2C LCDs
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE);
#elif defined(MINIPANEL)
#elif ENABLED(MINIPANEL)
// The MINIPanel display
U8GLIB_MINI12864 u8g(DOGLCD_CS, DOGLCD_A0);
#else
......@@ -193,7 +191,9 @@ char lcd_printPGM(const char* str) {
return n;
}
static bool show_splashscreen = true;
#if ENABLED(SHOW_BOOTSCREEN)
static bool show_bootscreen = true;
#endif
/* Warning: This function is called from interrupt context */
static void lcd_implementation_init() {
......@@ -207,7 +207,7 @@ static void lcd_implementation_init() {
pinMode(LCD_PIN_RESET, OUTPUT);
digitalWrite(LCD_PIN_RESET, HIGH);
#endif
#ifndef MINIPANEL//setContrast not working for Mini Panel
#if DISABLED(MINIPANEL) // setContrast not working for Mini Panel
u8g.setContrast(lcd_contrast);
#endif
// FIXME: remove this workaround
......@@ -223,31 +223,36 @@ static void lcd_implementation_init() {
u8g.setRot270(); // Rotate screen by 270°
#endif
// Show splashscreen
int offx = (u8g.getWidth() - START_BMPWIDTH) / 2;
#if ENABLED(START_BMPHIGH)
int offy = 0;
#else
int offy = DOG_CHAR_HEIGHT;
#endif
#if ENABLED(SHOW_BOOTSCREEN)
int offx = (u8g.getWidth() - START_BMPWIDTH) / 2;
#if ENABLED(START_BMPHIGH)
int offy = 0;
#else
int offy = DOG_CHAR_HEIGHT;
#endif
int txt1X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE1) - 1)*DOG_CHAR_WIDTH) / 2;
int txt1X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE1) - 1)*DOG_CHAR_WIDTH) / 2;
u8g.firstPage();
do {
if (show_bootscreen) {
u8g.drawBitmapP(offx, offy, START_BMPBYTEWIDTH, START_BMPHEIGHT, start_bmp);
lcd_setFont(FONT_MENU);
#ifndef STRING_SPLASH_LINE2
u8g.drawStr(txt1X, u8g.getHeight() - DOG_CHAR_HEIGHT, STRING_SPLASH_LINE1);
#else
int txt2X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE2) - 1)*DOG_CHAR_WIDTH) / 2;
u8g.drawStr(txt1X, u8g.getHeight() - DOG_CHAR_HEIGHT*3/2, STRING_SPLASH_LINE1);
u8g.drawStr(txt2X, u8g.getHeight() - DOG_CHAR_HEIGHT*1/2, STRING_SPLASH_LINE2);
#endif
}
} while (u8g.nextPage());
u8g.firstPage();
do {
if (show_splashscreen) {
u8g.drawBitmapP(offx, offy, START_BMPBYTEWIDTH, START_BMPHEIGHT, start_bmp);
lcd_setFont(FONT_MENU);
#ifndef STRING_SPLASH_LINE2
u8g.drawStr(txt1X, u8g.getHeight() - DOG_CHAR_HEIGHT, STRING_SPLASH_LINE1);
#else
int txt2X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE2) - 1)*DOG_CHAR_WIDTH) / 2;
u8g.drawStr(txt1X, u8g.getHeight() - DOG_CHAR_HEIGHT*3/2, STRING_SPLASH_LINE1);
u8g.drawStr(txt2X, u8g.getHeight() - DOG_CHAR_HEIGHT*1/2, STRING_SPLASH_LINE2);
#endif
if (show_bootscreen) {
delay(SPLASH_SCREEN_DURATION);
show_bootscreen = false;
}
} while (u8g.nextPage());
show_splashscreen = false;
#endif
}
static void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -29,6 +29,8 @@
#define LANGUAGE_CHOICE 7 // Pick your language from the list above
#endif
#include "Default_Version.h"
#define PROTOCOL_VERSION "1.0"
#if MB(ULTIMAKER)|| MB(ULTIMAKER_OLD)|| MB(ULTIMAIN_2)
......@@ -51,11 +53,6 @@
#define MACHINE_NAME "3D Printer"
#endif
#ifdef CUSTOM_MENDEL_NAME
#error CUSTOM_MENDEL_NAME deprecated - use CUSTOM_MACHINE_NAME
#define CUSTOM_MACHINE_NAME CUSTOM_MENDEL_NAME
#endif
#ifdef CUSTOM_MACHINE_NAME
#undef MACHINE_NAME
#define MACHINE_NAME CUSTOM_MACHINE_NAME
......@@ -109,11 +106,10 @@
#define MSG_INVALID_EXTRUDER "Invalid extruder"
#define MSG_INVALID_SOLENOID "Invalid solenoid"
#define MSG_ERR_NO_THERMISTORS "No thermistors - no temperature"
#define MSG_M115_REPORT "FIRMWARE_NAME:MarlinKimbra " BUILD_VERSION " SOURCE_CODE_URL:" SOURCE_CODE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:" MACHINE_NAME " EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " UUID:" MACHINE_UUID "\n"
#define MSG_M115_REPORT "FIRMWARE_NAME:MarlinKimbra " SHORT_BUILD_VERSION " SOURCE_CODE_URL:" SOURCE_CODE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:" MACHINE_NAME " EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " UUID:" MACHINE_UUID "\n"
#define MSG_COUNT_X " Count X: "
#define MSG_ERR_KILLED "Printer halted. kill() called!"
#define MSG_ERR_STOPPED "Printer stopped due to errors. Fix the error and use M999 to restart. (Temperature is reset. Set it after restarting)"
#define MSG_RESEND "Resend: "
#define MSG_UNKNOWN_COMMAND "Unknown command: \""
#define MSG_ACTIVE_DRIVER "Active Driver: "
#define MSG_ACTIVE_EXTRUDER "Active Extruder: "
......
......@@ -632,7 +632,7 @@
#define ORIG_TEMP_2_PIN 1 //ANALOG NUMBERING
#define ORIG_TEMP_BED_PIN 0 //ANALOG NUMBERING
#define BEEPER_PIN 36
#define BEEPER_PIN 36
#define KILL_PIN -1
......@@ -699,13 +699,13 @@
#if MB(GEN3_MONOLITHIC)
#define KNOWN_BOARD 1
#ifndef __AVR_ATmega644P__
#error Oops! Make sure you have 'Sanguino' selected from the 'Tools -> Boards' menu.
#endif
#define DEBUG_PIN 0
// x axis
#define ORIG_X_STEP_PIN 15
#define ORIG_X_DIR_PIN 18
......@@ -713,7 +713,7 @@
//Alex Checar #define X_STOP_PIN 20
#define ORIG_X_ENABLE_PIN 24 //actually uses ORIG_Y_DIR_PIN
#define X_MAX_PIN -1
// y axes
#define ORIG_Y_STEP_PIN 23
#define ORIG_Y_DIR_PIN 22
......@@ -721,7 +721,7 @@
//Alex Checar #define Y_STOP_PIN 25
#define ORIG_Y_ENABLE_PIN 24 //shared with ORIG_X_ENABLE_PIN
#define Y_MAX_PIN -1
// z axes
#define ORIG_Z_STEP_PIN 27
#define ORIG_Z_DIR_PIN 28
......@@ -729,33 +729,33 @@
//Alex Checar #define Z_STOP_PIN 30
#define ORIG_Z_ENABLE_PIN 29
#define Z_MAX_PIN -1
//extruder pins
#define ORIG_E0_STEP_PIN 12
#define ORIG_E0_DIR_PIN 17
#define ORIG_E0_ENABLE_PIN 3
#define ORIG_HEATER_0_PIN 16
#define ORIG_TEMP_0_PIN 0
#define ORIG_FAN_PIN -1
//bed pins
#define ORIG_HEATER_BED_PIN -1
#define ORIG_TEMP_BED_PIN -1
#define SDSS -1
#define SDPOWER -1
#define LED_PIN -1
#define SDSS -1
#define SDPOWER -1
#define LED_PIN -1
//pin for controlling the PSU.
#define PS_ON_PIN 14 //Alex, Do this work on the card?
#define PS_ON_PIN 14
//Alex extras from Gen3+
#define KILL_PIN -1
#define ORIG_TEMP_1_PIN -1
#define ORIG_TEMP_2_PIN -1
#define ORIG_HEATER_2_PIN -1
#define KILL_PIN -1
#define ORIG_TEMP_1_PIN -1
#define ORIG_TEMP_2_PIN -1
#define ORIG_HEATER_2_PIN -1
#endif // GEN3_MONOLITHIC
/****************************************************************************************/
......@@ -916,7 +916,7 @@
#define ORIG_HEATER_BED_PIN 8 // BED
#define ORIG_TEMP_BED_PIN 14 // ANALOG NUMBERING
#if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) || ENABLED(G3D_PANEL)
#if defined(REPRAP_DISCOUNT_SMART_CONTROLLER) || defined(G3D_PANEL)
#define KILL_PIN 41
#else
#define KILL_PIN -1
......@@ -2488,28 +2488,26 @@
#define Z_MS1_PIN 44 // PC19
#define Z_PROBE_PIN 39 // PC7
// E AXIS
// E0 AXIS
#define ORIG_E0_STEP_PIN 5 // PC25
#define ORIG_E0_DIR_PIN 4 // PC26
#define ORIG_E0_ENABLE_PIN 24 // PA15, motor RESET pin
#define E0_MS1_PIN 45 // PC18
/*
// E1 AXIS
#define ORIG_E1_STEP_PIN 28 // PD3 on piggy
#define ORIG_E1_DIR_PIN 27 // PD2 on piggy
#define ORIG_E1_ENABLE_PIN -1
#define E1_MS1_PIN -1
#define ORIG_E1_ENABLE_PIN 24 // PA15, motor RESET pin
// E2 AXIS
#define ORIG_E2_STEP_PIN 11 // PD7 on piggy
#define ORIG_E2_DIR_PIN 29 // PD6 on piggy
#define ORIG_E2_ENABLE_PIN -1
#define E2_MS_PIN -1
#define ORIG_E2_ENABLE_PIN 24 // PA15, motor RESET pin
// E3 AXIS
#define ORIG_E3_STEP_PIN 30 // PD9 on piggy
#define ORIG_E3_DIR_PIN 12 // PD8 on piggy
#define ORIG_E3_ENABLE_PIN -1
#define E3_MS_PIN -1
*/
#define ORIG_E3_ENABLE_PIN 24 // PA15, motor RESET pin
#define MOTOR_FAULT_PIN 22 // PB26 , motor X-Y-Z-E0 motor FAULT
......@@ -2525,25 +2523,19 @@
#define PS_ON_PIN -1
#define KILL_PIN -1
#define SUICIDE_PIN -1 //PIN that has to be turned on right after start, to keep power flowing.
#define HEAT_OFF_INT_PIN 50 // PC13 on raspberry expansion
// Note that on the Due pin A0 on the board is channel 2 on the ARM chip
#define ORIG_HEATER_BED_PIN 69 // PA0
#define ORIG_HEATER_0_PIN 68 // PA1
/*
#define ORIG_HEATER_1_PIN 8 // PC22 on piggy
#define ORIG_HEATER_2_PIN 9 // PC21 on piggy
#define ORIG_HEATER_3_PIN 97 // PC20 on piggy
*/
#define ORIG_TEMP_BED_PIN 0 // PA16
#define ORIG_TEMP_0_PIN 1 // PA24, analog pin
/*
#define ORIG_TEMP_1_PIN 5 // PA23 analog pin on piggy
#define ORIG_TEMP_2_PIN 4 // PA22, analog pin on piggy
#define ORIG_TEMP_3_PIN 3 // PA6, analog on piggy
*/
#define ORIG_HEATER_BED_PIN 69 // PA0
#define ORIG_HEATER_0_PIN 68 // PA1
#define ORIG_HEATER_1_PIN 8 // PC22 on piggy
#define ORIG_HEATER_2_PIN 9 // PC21 on piggy
#define ORIG_HEATER_3_PIN 97 // PC20 on piggy
#define ORIG_TEMP_BED_PIN 0 // PA16
#define ORIG_TEMP_0_PIN 1 // PA24, analog pin
#define ORIG_TEMP_1_PIN 2 // PA23 analog pin on piggy
#define ORIG_TEMP_2_PIN 3 // PA22, analog pin on piggy
#define ORIG_TEMP_3_PIN 4 // PA6, analog on piggy
#define LED_RED_PIN 40 // PC8
#define LED_GREEN_PIN 41 // PC9
......@@ -2551,7 +2543,8 @@
#define EXP_VOLTAGE_LEVEL_PIN 65
#define DAC_SYNC 53 // PB14
#define DAC0_SYNC 53 // PB14
#define DAC1_SYNC 6 // PC24
//64K SPI EEPROM
#define SPI_CHAN_EEPROM1 2
......@@ -3548,84 +3541,82 @@
#error Oops! Make sure you have 'Minitronics ' selected from the 'Tools -> Boards' menu.
#endif
#define LARGE_FLASH true
#define ORIG_X_STEP_PIN 48
#define ORIG_X_DIR_PIN 47
#define ORIG_X_ENABLE_PIN 49
#define X_MIN_PIN 5
#define X_MAX_PIN -1 //2 //Max endstops default to disabled "-1", set to commented value to enable.
#define ORIG_Y_STEP_PIN 39 // A6
#define ORIG_Y_DIR_PIN 40 // A0
#define ORIG_Y_ENABLE_PIN 38
#define Y_MIN_PIN 2
#define Y_MAX_PIN -1 //15
#define ORIG_Z_STEP_PIN 42 // A2
#define ORIG_Z_DIR_PIN 43 // A6
#define ORIG_Z_ENABLE_PIN 41 // A1
#define Z_MIN_PIN 6
#define Z_MAX_PIN -1
#define ORIG_E0_STEP_PIN 45
#define ORIG_E0_DIR_PIN 44
#define ORIG_E0_ENABLE_PIN 27
#define ORIG_E1_STEP_PIN 36
#define ORIG_E1_DIR_PIN 35
#define ORIG_E1_ENABLE_PIN 37
#define ORIG_E2_STEP_PIN -1
#define ORIG_E2_DIR_PIN -1
#define ORIG_E2_ENABLE_PIN -1
#define SDPOWER -1
#define SDSS 53
#define LARGE_FLASH true
#define LED_PIN 46
#define ORIG_FAN_PIN 9
#define FAN2_PIN -1
#define PS_ON_PIN -1
#define KILL_PIN -1
#define ORIG_HEATER_0_PIN 7 // EXTRUDER 1
#define ORIG_HEATER_1_PIN 8 // EXTRUDER 2
#define ORIG_HEATER_2_PIN 9 // thermo couple
#if TEMP_SENSOR_0 == -1
#define ORIG_TEMP_0_PIN 5 // ANALOG NUMBERING
#else
#define ORIG_TEMP_0_PIN 7 // ANALOG NUMBERING
#endif
#define ORIG_TEMP_1_PIN 6 // ANALOG NUMBERING
#define ORIG_TEMP_2_PIN -1 // ANALOG NUMBERING
#define ORIG_HEATER_BED_PIN 3 // BED
#define ORIG_TEMP_BED_PIN 6 // ANALOG NUMBERING
#define BEEPER_PIN -1
#define LCD_PINS_RS -1
#define LCD_PINS_ENABLE -1
#define LCD_PINS_D4 -1
#define LCD_PINS_D5 -1
#define LCD_PINS_D6 -1
#define LCD_PINS_D7 -1
#define ORIG_X_STEP_PIN 48
#define ORIG_X_DIR_PIN 47
#define ORIG_X_ENABLE_PIN 49
#define X_MIN_PIN 5
#define X_MAX_PIN -1 //2 //Max endstops default to disabled "-1", set to commented value to enable.
#define ORIG_Y_STEP_PIN 39 // A6
#define ORIG_Y_DIR_PIN 40 // A0
#define ORIG_Y_ENABLE_PIN 38
#define Y_MIN_PIN 2
#define Y_MAX_PIN -1 //15
//buttons are directly attached using keypad
#define BTN_EN1 -1
#define BTN_EN2 -1
#define BTN_ENC -1 //the click
#define ORIG_Z_STEP_PIN 42 // A2
#define ORIG_Z_DIR_PIN 43 // A6
#define ORIG_Z_ENABLE_PIN 41 // A1
#define Z_MIN_PIN 6
#define Z_MAX_PIN -1
#define BLEN_C 2
#define BLEN_B 1
#define BLEN_A 0
#define ORIG_E0_STEP_PIN 45
#define ORIG_E0_DIR_PIN 44
#define ORIG_E0_ENABLE_PIN 27
#define SD_DETECT_PIN -1 // Megatronics does not use this port
#define ORIG_E1_STEP_PIN 36
#define ORIG_E1_DIR_PIN 35
#define ORIG_E1_ENABLE_PIN 37
#define ORIG_E2_STEP_PIN -1
#define ORIG_E2_DIR_PIN -1
#define ORIG_E2_ENABLE_PIN -1
#define SDPOWER -1
#define SDSS 53
#define LED_PIN 46
#define ORIG_FAN_PIN 9
#define FAN2_PIN -1
#define PS_ON_PIN -1
#define KILL_PIN -1
#define ORIG_HEATER_0_PIN 7 // EXTRUDER 1
#define ORIG_HEATER_1_PIN 8 // EXTRUDER 2
#define ORIG_HEATER_2_PIN 9 // thermo couple
#if TEMP_SENSOR_0 == -1
#define ORIG_TEMP_0_PIN 5 // ANALOG NUMBERING
#else
#define ORIG_TEMP_0_PIN 7 // ANALOG NUMBERING
#endif
#define ORIG_TEMP_1_PIN 6 // ANALOG NUMBERING
#define ORIG_TEMP_2_PIN -1 // ANALOG NUMBERING
#define ORIG_HEATER_BED_PIN 3 // BED
#define ORIG_TEMP_BED_PIN 6 // ANALOG NUMBERING
#define BEEPER_PIN -1
#define LCD_PINS_RS -1
#define LCD_PINS_ENABLE -1
#define LCD_PINS_D4 -1
#define LCD_PINS_D5 -1
#define LCD_PINS_D6 -1
#define LCD_PINS_D7 -1
//buttons are directly attached using keypad
#define BTN_EN1 -1
#define BTN_EN2 -1
#define BTN_ENC -1 //the click
#define BLEN_C 2
#define BLEN_B 1
#define BLEN_A 0
#define SD_DETECT_PIN -1 // Megatronics does not use this port
#endif // MEGATRONICS_1
/****************************************************************************************/
......@@ -3731,7 +3722,7 @@
#define ORIG_TEMP_BED_PIN 14 // ANALOG NUMBERING
#endif
#define BEEPER_PIN 61
#define BEEPER_PIN 61
#define LCD_PINS_RS 32
#define LCD_PINS_ENABLE 31
......@@ -4651,7 +4642,7 @@ DaveX plan for Teensylu/printrboard-type pinouts (ref teensylu & sprinter) for a
#define ORIG_TEMP_2_PIN -1
#define SDPOWER -1
#define SD_DETECT_PIN -1
#define SD_DETECT_PIN -1
#define SDSS 20 // 8
#define LED_PIN 6
#define PS_ON_PIN 27
......@@ -5296,7 +5287,7 @@ DaveX plan for Teensylu/printrboard-type pinouts (ref teensylu & sprinter) for a
#ifdef LASERBEAM
#define LASER_PWR_PIN 41
#define LASER_TTL_PIN 42
#define LASER_TTL_PIN 42
#endif
#ifdef FILAMENT_RUNOUT_SENSOR
......
......@@ -74,14 +74,14 @@ float mintravelfeedrate;
unsigned long axis_steps_per_sqr_second[3 + EXTRUDERS];
uint8_t last_extruder;
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
// Transform required to compensate for bed level
matrix_3x3 plan_bed_level_matrix = {
1.0, 0.0, 0.0,
0.0, 1.0, 0.0,
0.0, 0.0, 1.0
};
#endif // ENABLE_AUTO_BED_LEVELING
#endif // AUTO_BED_LEVELING_FEATURE
#if ENABLED(AUTOTEMP)
float autotemp_max = 250;
......@@ -480,11 +480,11 @@ float junction_deviation = 0.1;
// Add a new linear movement to the buffer. steps[X_AXIS], _y and _z is the absolute position in
// mm. Microseconds specify how many microseconds the move should take to perform. To aid acceleration
// calculation the caller must also provide the physical length of the line in millimeters.
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate, const uint8_t &extruder, const uint8_t &driver)
#else
void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate, const uint8_t &extruder, const uint8_t &driver)
#endif // ENABLE_AUTO_BED_LEVELING
#endif // AUTO_BED_LEVELING_FEATURE
{
// Calculate the buffer head after we push this byte
int next_buffer_head = next_block_index(block_buffer_head);
......@@ -493,7 +493,7 @@ float junction_deviation = 0.1;
// Rest here until there is room in the buffer.
while (block_buffer_tail == next_buffer_head) idle();
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
apply_rotation_xyz(plan_bed_level_matrix, x, y, z);
#endif
......@@ -521,6 +521,13 @@ float junction_deviation = 0.1;
dy = target[Y_AXIS] - position[Y_AXIS],
dz = target[Z_AXIS] - position[Z_AXIS],
de = target[E_AXIS] - position[E_AXIS];
#if ENABLED(COREXY)
float da = dx + COREX_YZ_FACTOR * dy;
float db = dx - COREX_YZ_FACTOR * dy;
#elif ENABLED(COREXZ)
float da = dx + COREX_YZ_FACTOR * dz;
float dc = dx - COREX_YZ_FACTOR * dz;
#endif
#if ENABLED(PREVENT_DANGEROUS_EXTRUDE)
if (de) {
......@@ -562,14 +569,14 @@ float junction_deviation = 0.1;
#if ENABLED(COREXY)
// corexy planning
// these equations follow the form of the dA and dB equations on http://www.corexy.com/theory.html
block->steps[A_AXIS] = labs(dx + dy);
block->steps[B_AXIS] = labs(dx - dy);
block->steps[A_AXIS] = labs(da);
block->steps[B_AXIS] = labs(db);
block->steps[Z_AXIS] = labs(dz);
#elif ENABLED(COREXZ)
// corexz planning
block->steps[A_AXIS] = labs(dx + dz);
block->steps[A_AXIS] = labs(da);
block->steps[Y_AXIS] = labs(dy);
block->steps[C_AXIS] = labs(dx - dz);
block->steps[C_AXIS] = labs(dc);
#else
// default non-h-bot planning
block->steps[X_AXIS] = labs(dx);
......@@ -603,14 +610,14 @@ float junction_deviation = 0.1;
if (dx < 0) db |= BIT(X_HEAD); // Save the real Extruder (head) direction in X Axis
if (dy < 0) db |= BIT(Y_HEAD); // ...and Y
if (dz < 0) db |= BIT(Z_AXIS);
if (dx + dy < 0) db |= BIT(A_AXIS); // Motor A direction
if (dx - dy < 0) db |= BIT(B_AXIS); // Motor B direction
if (da < 0) db |= BIT(A_AXIS); // Motor A direction
if (db < 0) db |= BIT(B_AXIS); // Motor B direction
#elif ENABLED(COREXZ)
if (dx < 0) db |= BIT(X_HEAD); // Save the real Extruder (head) direction in X Axis
if (dy < 0) db |= BIT(Y_AXIS);
if (dz < 0) db |= BIT(Z_HEAD); // ...and Z
if (dx + dz < 0) db |= BIT(A_AXIS); // Motor A direction
if (dx - dz < 0) db |= BIT(C_AXIS); // Motor B direction
if (da < 0) db |= BIT(A_AXIS); // Motor A direction
if (dc < 0) db |= BIT(C_AXIS); // Motor B direction
#else
if (dx < 0) db |= BIT(X_AXIS);
if (dy < 0) db |= BIT(Y_AXIS);
......@@ -627,7 +634,7 @@ float junction_deviation = 0.1;
enable_x();
enable_y();
}
#ifndef Z_LATE_ENABLE
#if DISABLED(Z_LATE_ENABLE)
if (block->steps[Z_AXIS]) enable_z();
#endif
#elif ENABLED(COREXZ)
......@@ -639,14 +646,14 @@ float junction_deviation = 0.1;
#else
if (block->steps[X_AXIS]) enable_x();
if (block->steps[Y_AXIS]) enable_y();
#ifndef Z_LATE_ENABLE
#if DISABLED(Z_LATE_ENABLE)
if (block->steps[Z_AXIS]) enable_z();
#endif
#endif
// Enable extruder(s)
if (block->steps[E_AXIS]) {
#if !defined(MKR4) && !defined(NPR2)
#if DISABLED(MKR4) && DISABLED(NPR2)
if (DISABLE_INACTIVE_EXTRUDER) { //enable only selected extruder
for (int i = 0; i < EXTRUDERS; i++)
......@@ -745,15 +752,15 @@ float junction_deviation = 0.1;
delta_mm[X_HEAD] = dx / axis_steps_per_unit[A_AXIS];
delta_mm[Y_HEAD] = dy / axis_steps_per_unit[B_AXIS];
delta_mm[Z_AXIS] = dz / axis_steps_per_unit[Z_AXIS];
delta_mm[A_AXIS] = (dx + dy) / axis_steps_per_unit[A_AXIS];
delta_mm[B_AXIS] = (dx - dy) / axis_steps_per_unit[B_AXIS];
delta_mm[A_AXIS] = da / axis_steps_per_unit[A_AXIS];
delta_mm[B_AXIS] = db / axis_steps_per_unit[B_AXIS];
#elif ENABLED(COREXZ)
float delta_mm[6];
delta_mm[X_HEAD] = dx / axis_steps_per_unit[A_AXIS];
delta_mm[Y_AXIS] = dy / axis_steps_per_unit[Y_AXIS];
delta_mm[Z_HEAD] = dz / axis_steps_per_unit[C_AXIS];
delta_mm[A_AXIS] = (dx + dz) / axis_steps_per_unit[A_AXIS];
delta_mm[C_AXIS] = (dx - dz) / axis_steps_per_unit[C_AXIS];
delta_mm[A_AXIS] = da / axis_steps_per_unit[A_AXIS];
delta_mm[C_AXIS] = dc / axis_steps_per_unit[C_AXIS];
#else
float delta_mm[4];
delta_mm[X_AXIS] = dx / axis_steps_per_unit[X_AXIS];
......@@ -1040,7 +1047,7 @@ float junction_deviation = 0.1;
} // plan_buffer_line()
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
vector_3 plan_get_position() {
vector_3 position = vector_3(st_get_position_mm(X_AXIS), st_get_position_mm(Y_AXIS), st_get_position_mm(Z_AXIS));
......@@ -1053,15 +1060,15 @@ float junction_deviation = 0.1;
return position;
}
#endif // ENABLE_AUTO_BED_LEVELING
#endif // AUTO_BED_LEVELING_FEATURE
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
void plan_set_position(float x, float y, float z, const float &e)
#else
void plan_set_position(const float &x, const float &y, const float &z, const float &e)
#endif // ENABLE_AUTO_BED_LEVELING
#endif // AUTO_BED_LEVELING_FEATURE
{
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
apply_rotation_xyz(plan_bed_level_matrix, x, y, z);
#endif
......
......@@ -82,7 +82,7 @@ extern volatile unsigned char block_buffer_head;
extern volatile unsigned char block_buffer_tail;
FORCE_INLINE uint8_t movesplanned() { return BLOCK_MOD(block_buffer_head - block_buffer_tail + BLOCK_BUFFER_SIZE); }
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
#include "vector_3.h"
......@@ -110,7 +110,7 @@ FORCE_INLINE uint8_t movesplanned() { return BLOCK_MOD(block_buffer_head - block
#else
void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate, const uint8_t &extruder, const uint8_t &driver);
void plan_set_position(const float &x, const float &y, const float &z, const float &e);
#endif // ENABLE_AUTO_BED_LEVELING
#endif // AUTO_BED_LEVELING_FEATURE
void plan_set_e_position(const float &e);
......
......@@ -260,7 +260,7 @@ double r8mat_amax ( int m, int n, double a[] )
return value;
}
void r8mat_copy( double a2[], int m, int n, double a1[] )
double *r8mat_copy_new ( int m, int n, double a1[] )
/******************************************************************************/
/*
......@@ -294,9 +294,12 @@ void r8mat_copy( double a2[], int m, int n, double a1[] )
Output, double R8MAT_COPY_NEW[M*N], the copy of A1.
*/
{
double *a2;
int i;
int j;
a2 = ( double * ) malloc ( m * n * sizeof ( double ) );
for ( j = 0; j < n; j++ )
{
for ( i = 0; i < m; i++ )
......@@ -304,6 +307,8 @@ void r8mat_copy( double a2[], int m, int n, double a1[] )
a2[i+j*m] = a1[i+j*m];
}
}
return a2;
}
/******************************************************************************/
......@@ -721,13 +726,14 @@ void dqrank ( double a[], int lda, int m, int n, double tol, int *kr,
int j;
int job;
int k;
double work[n];
double *work;
for ( i = 0; i < n; i++ )
{
jpvt[i] = 0;
}
work = ( double * ) malloc ( n * sizeof ( double ) );
job = 1;
dqrdc ( a, lda, m, n, qraux, jpvt, work, job );
......@@ -744,6 +750,8 @@ void dqrank ( double a[], int lda, int m, int n, double tol, int *kr,
*kr = j + 1;
}
free ( work );
return;
}
/******************************************************************************/
......@@ -1837,7 +1845,7 @@ void dswap ( int n, double x[], int incx, double y[], int incy )
/******************************************************************************/
void qr_solve ( double x[], int m, int n, double a[], double b[] )
double *qr_solve ( int m, int n, double a[], double b[] )
/******************************************************************************/
/*
......@@ -1887,22 +1895,34 @@ void qr_solve ( double x[], int m, int n, double a[], double b[] )
Output, double QR_SOLVE[N], the least squares solution.
*/
{
double a_qr[n*m];
double *a_qr;
int ind;
int itask;
int jpvt[n];
int *jpvt;
int kr;
int lda;
double qraux[n];
double r[m];
double *qraux;
double *r;
double tol;
double *x;
r8mat_copy( a_qr, m, n, a );
a_qr = r8mat_copy_new ( m, n, a );
lda = m;
tol = r8_epsilon ( ) / r8mat_amax ( m, n, a_qr );
x = ( double * ) malloc ( n * sizeof ( double ) );
jpvt = ( int * ) malloc ( n * sizeof ( int ) );
qraux = ( double * ) malloc ( n * sizeof ( double ) );
r = ( double * ) malloc ( m * sizeof ( double ) );
itask = 1;
ind = dqrls ( a_qr, lda, m, n, tol, &kr, b, x, r, jpvt, qraux, itask );
free ( a_qr );
free ( jpvt );
free ( qraux );
free ( r );
return x;
}
/******************************************************************************/
......
......@@ -17,6 +17,6 @@ int dqrsl ( double a[], int lda, int n, int k, double qraux[], double y[],
double qy[], double qty[], double b[], double rsd[], double ab[], int job );
void dscal ( int n, double sa, double x[], int incx );
void dswap ( int n, double x[], int incx, double y[], int incy );
void qr_solve ( double x[], int m, int n, double a[], double b[] );
double *qr_solve ( int m, int n, double a[], double b[] );
#endif
......@@ -124,7 +124,7 @@
/**
* Auto Bed Leveling
*/
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
/**
* Require a Z Min pin
......@@ -134,7 +134,7 @@
#if ENABLED(Z_PROBE_REPEATABILITY_TEST)
#error You must have a Z_MIN or Z_PROBE endstop to enable Z_PROBE_REPEATABILITY_TEST.
#else
#error ENABLE_AUTO_BED_LEVELING requires a Z_MIN or Z_PROBE endstop. Z_MIN_PIN or Z_PROBE_PIN must point to a valid hardware pin.
#error AUTO_BED_LEVELING_FEATURE requires a Z_MIN or Z_PROBE endstop. Z_MIN_PIN or Z_PROBE_PIN must point to a valid hardware pin.
#endif
#endif
#endif
......@@ -203,7 +203,7 @@
#endif // !AUTO_BED_LEVELING_GRID
#endif // ENABLE_AUTO_BED_LEVELING
#endif // AUTO_BED_LEVELING_FEATURE
/**
* ULTIPANEL encoder
......@@ -298,11 +298,11 @@
#error Thermal Runaway Protection for the bed must now be enabled with THERMAL_PROTECTION_BED.
#endif
#ifdef PROBE_SERVO_DEACTIVATION_DELAY
#if ENABLED(PROBE_SERVO_DEACTIVATION_DELAY)
#error PROBE_SERVO_DEACTIVATION_DELAY has been replaced with DEACTIVATE_SERVOS_AFTER_MOVE and SERVO_DEACTIVATION_DELAY.
#endif
#if defined(COREXZ) && defined(Z_LATE_ENABLE)
#if ENABLED(COREXZ) && ENABLED(Z_LATE_ENABLE)
#error "Z_LATE_ENABLE can't be used with COREXZ."
#endif
......@@ -314,10 +314,10 @@
#error SDCARDDETECT is now SD_DETECT_PIN. Please update your pins definitions.
#endif
#ifdef SDCARDDETECTINVERTED
#if ENABLED(SDCARDDETECTINVERTED)
#error SDCARDDETECTINVERTED is now SD_DETECT_INVERTED. Please update your configuration.
#endif
#if ENABLED(POWER_CONSUMPTION) && !PIN_EXISTS(POWER_CONSUMPTION)
#error You have to set a valid POWER_CONSUMPTION_PIN in pins.h in order to use this feature.
#endif
......
......@@ -43,7 +43,7 @@
detach() - Stops an attached servos from pulsing its i/o pin.
*/
#include "Configuration.h"
#include "Configuration.h"
#if HAS_SERVOS
......
......@@ -289,12 +289,19 @@ void checkHitEndstops() {
}
}
void enable_endstops(bool check) { check_endstops = check; }
void enable_endstops(bool check) {
if (debugLevel & DEBUG_INFO) {
ECHO_SM(DB, "setup_for_endstop_move > enable_endstops");
if (check) ECHO_EM("(true)");
else ECHO_EM("(false)");
}
check_endstops = check;
}
// Check endstops
inline void update_endstops() {
#ifdef Z_DUAL_ENDSTOPS
#if ENABLED(Z_DUAL_ENDSTOPS)
uint16_t
#else
byte
......@@ -322,12 +329,12 @@ inline void update_endstops() {
step_events_completed = current_block->step_event_count; \
}
#ifdef COREXY
#if ENABLED(COREXY)
// Head direction in -X axis for CoreXY bots.
// If DeltaX == -DeltaY, the movement is only in Y axis
if ((current_block->steps[A_AXIS] != current_block->steps[B_AXIS]) || (TEST(out_bits, A_AXIS) == TEST(out_bits, B_AXIS))) {
if (TEST(out_bits, X_HEAD))
#elif defined(COREXZ)
#elif ENABLED(COREXZ)
// Head direction in -X axis for CoreXZ bots.
// If DeltaX == -DeltaZ, the movement is only in Z axis
if ((current_block->steps[A_AXIS] != current_block->steps[C_AXIS]) || (TEST(out_bits, A_AXIS) == TEST(out_bits, C_AXIS))) {
......@@ -336,7 +343,7 @@ inline void update_endstops() {
if (TEST(out_bits, X_AXIS)) // stepping along -X axis (regular Cartesian bot)
#endif
{ // -direction
#ifdef DUAL_X_CARRIAGE
#if ENABLED(DUAL_X_CARRIAGE)
// with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
if ((current_block->active_extruder == 0 && X_HOME_DIR == -1) || (current_block->active_extruder != 0 && X2_HOME_DIR == -1))
#endif
......@@ -347,7 +354,7 @@ inline void update_endstops() {
}
}
else { // +direction
#ifdef DUAL_X_CARRIAGE
#if ENABLED(DUAL_X_CARRIAGE)
// with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
if ((current_block->active_extruder == 0 && X_HOME_DIR == 1) || (current_block->active_extruder != 0 && X2_HOME_DIR == 1))
#endif
......@@ -357,11 +364,11 @@ inline void update_endstops() {
#endif
}
}
#if defined(COREXY) || defined(COREXZ)
#if ENABLED(COREXY) || ENABLED(COREXZ)
}
#endif
#ifdef COREXY
#if ENABLED(COREXY)
// Head direction in -Y axis for CoreXY bots.
// If DeltaX == DeltaY, the movement is only in X axis
if ((current_block->steps[A_AXIS] != current_block->steps[B_AXIS]) || (TEST(out_bits, A_AXIS) != TEST(out_bits, B_AXIS))) {
......@@ -379,11 +386,11 @@ inline void update_endstops() {
UPDATE_ENDSTOP(Y, MAX);
#endif
}
#if defined(COREXY)
#if ENABLED(COREXY)
}
#endif
#ifdef COREXZ
#if ENABLED(COREXZ)
// Head direction in -Z axis for CoreXZ bots.
// If DeltaX == DeltaZ, the movement is only in X axis
if ((current_block->steps[A_AXIS] != current_block->steps[C_AXIS]) || (TEST(out_bits, A_AXIS) != TEST(out_bits, C_AXIS))) {
......@@ -394,7 +401,7 @@ inline void update_endstops() {
{ // z -direction
#if HAS_Z_MIN
#ifdef Z_DUAL_ENDSTOPS
#if ENABLED(Z_DUAL_ENDSTOPS)
SET_ENDSTOP_BIT(Z, MIN);
#if HAS_Z2_MIN
SET_ENDSTOP_BIT(Z2, MIN);
......@@ -416,7 +423,7 @@ inline void update_endstops() {
#endif // !Z_DUAL_ENDSTOPS
#endif // Z_MIN_PIN
#ifdef Z_PROBE_ENDSTOP
#if ENABLED(Z_PROBE_ENDSTOP)
UPDATE_ENDSTOP(Z, PROBE);
if (TEST_ENDSTOP(Z_PROBE))
......@@ -429,13 +436,13 @@ inline void update_endstops() {
else { // z +direction
#if HAS_Z_MAX
#ifdef Z_DUAL_ENDSTOPS
#if ENABLED(Z_DUAL_ENDSTOPS)
SET_ENDSTOP_BIT(Z, MAX);
#if HAS_Z2_MAX
SET_ENDSTOP_BIT(Z2, MAX);
#else
COPY_BIT(current_endstop_bits, Z_MAX, Z2_MAX)
COPY_BIT(current_endstop_bits, Z_MAX, Z2_MAX);
#endif
byte z_test = TEST_ENDSTOP(Z_MAX) << 0 + TEST_ENDSTOP(Z2_MAX) << 1; // bit 0 for Z, bit 1 for Z2
......@@ -454,7 +461,7 @@ inline void update_endstops() {
#endif // !Z_DUAL_ENDSTOPS
#endif // Z_MAX_PIN
}
#if defined(COREXZ)
#if ENABLED(COREXZ)
}
#endif
old_endstop_bits = current_endstop_bits;
......@@ -640,7 +647,7 @@ ISR(TIMER1_COMPA_vect) {
// Take multiple steps per interrupt (For high speed moves)
for (int8_t i = 0; i < step_loops; i++) {
#ifndef USBCON
MSerial.checkRx(); // Check for serial chars.
customizedSerial.checkRx(); // Check for serial chars.
#endif
#if ENABLED(ADVANCE)
......@@ -666,7 +673,7 @@ ISR(TIMER1_COMPA_vect) {
STEP_START(e,E);
#endif
#ifdef STEPPER_HIGH_LOW_DELAY
#if ENABLED(STEPPER_HIGH_LOW_DELAY)
delayMicroseconds(STEPPER_HIGH_LOW_DELAY);
#endif
......@@ -958,6 +965,13 @@ void st_init() {
#endif
#endif
#if HAS_Z2_MIN
SET_INPUT(Z2_MIN_PIN);
#if ENABLED(ENDSTOPPULLUP_Z2MIN)
WRITE(Z2_MIN_PIN,HIGH);
#endif
#endif
#if HAS_E_MIN
SET_INPUT(E_MIN_PIN);
#if ENABLED(ENDSTOPPULLUP_EMIN)
......@@ -988,7 +1002,7 @@ void st_init() {
#if HAS_Z2_MAX
SET_INPUT(Z2_MAX_PIN);
#if ENABLED(ENDSTOPPULLUP_ZMAX)
#if ENABLED(ENDSTOPPULLUP_Z2MAX)
WRITE(Z2_MAX_PIN,HIGH);
#endif
#endif
......@@ -1251,7 +1265,7 @@ void digipot_init() {
#if MB(ALLIGATOR)
const float motor_current[] = MOTOR_CURRENT;
unsigned int digipot_motor = 0;
for (uint8_t i = 0; i < 4; i++) {
for (uint8_t i = 0; i < 3 + DRIVER_EXTRUDERS; i++) {
digipot_motor = 255 * (motor_current[i] / 2.5);
ExternalDac::setValue(i, digipot_motor);
}
......
......@@ -57,7 +57,7 @@
#endif
#if ENABLED(E3_IS_TMC)
TMC26XStepper stepperE3(200,E3_ENABLE_PIN,E3_STEP_PIN,E3_DIR_PIN,E3_MAX_CURRENT,E3_SENSE_RESISTOR);
#endif
#endif
#if ENABLED(HAVE_TMCDRIVER)
void tmc_init()
......@@ -142,7 +142,7 @@ void tmc_init()
#endif
#if ENABLED(E3_IS_L6470)
L6470 stepperE3(E3_ENABLE_PIN);
#endif
#endif
// init routine
......@@ -218,7 +218,6 @@ void L6470_init()
stepperE3.setMicroSteps(E3_MICROSTEPS);
stepperE3.setOverCurrent(E3_OVERCURRENT); //set overcurrent protection
stepperE3.setStallCurrent(E3_STALLCURRENT);
#endif
#endif
}
#endif
......@@ -141,7 +141,7 @@ static unsigned char soft_pwm[HOTENDS];
static int minttemp_raw[HOTENDS] = ARRAY_BY_HOTENDS( HEATER_0_RAW_LO_TEMP , HEATER_1_RAW_LO_TEMP , HEATER_2_RAW_LO_TEMP, HEATER_3_RAW_LO_TEMP);
static int maxttemp_raw[HOTENDS] = ARRAY_BY_HOTENDS( HEATER_0_RAW_HI_TEMP , HEATER_1_RAW_HI_TEMP , HEATER_2_RAW_HI_TEMP, HEATER_3_RAW_HI_TEMP);
static int minttemp[HOTENDS] = { 0 };
static int maxttemp[HOTENDS] = ARRAY_BY_HOTENDS( 16383, 16383, 16383, 16383 );
static int maxttemp[HOTENDS] = ARRAY_BY_HOTENDS1( 16383 );
#ifdef BED_MINTEMP
static int bed_minttemp_raw = HEATER_BED_RAW_LO_TEMP;
#endif
......
......@@ -626,69 +626,30 @@ const short temptable_11[][2] PROGMEM = {
// Hisens thermistor B25/50 =3950 +/-1%
const short temptable_13[][2] PROGMEM = {
{22.5 * OVERSAMPLENR, 300},
{24.125 * OVERSAMPLENR, 295},
{25.875 * OVERSAMPLENR, 290},
{27.8125 * OVERSAMPLENR, 285},
{29.9375 * OVERSAMPLENR, 280},
{32.25 * OVERSAMPLENR, 275},
{34.8125 * OVERSAMPLENR, 270},
{37.625 * OVERSAMPLENR, 265},
{40.6875 * OVERSAMPLENR, 260},
{44.0625 * OVERSAMPLENR, 255},
{47.75 * OVERSAMPLENR, 250},
{51.8125 * OVERSAMPLENR, 245},
{56.3125 * OVERSAMPLENR, 240},
{61.25 * OVERSAMPLENR, 235},
{66.75 * OVERSAMPLENR, 230},
{72.8125 * OVERSAMPLENR, 225},
{79.5 * OVERSAMPLENR, 220},
{87 * OVERSAMPLENR, 215},
{95.3125 * OVERSAMPLENR, 210},
{104.1875 * OVERSAMPLENR, 205},
{112.75 * OVERSAMPLENR, 200},
{123.125 * OVERSAMPLENR, 195},
{135.75 * OVERSAMPLENR, 190},
{148.3125 * OVERSAMPLENR, 185},
{163.8125 * OVERSAMPLENR, 180},
{179 * OVERSAMPLENR, 175},
{211.125 * OVERSAMPLENR, 170},
{216.125 * OVERSAMPLENR, 165},
{236.5625 * OVERSAMPLENR, 160},
{258.5 * OVERSAMPLENR, 155},
{279.875 * OVERSAMPLENR, 150},
{305.375 * OVERSAMPLENR, 145},
{333.25 * OVERSAMPLENR, 140},
{362.5625 * OVERSAMPLENR, 135},
{393.6875 * OVERSAMPLENR, 130},
{425 * OVERSAMPLENR, 125},
{460.625 * OVERSAMPLENR, 120},
{495.1875 * OVERSAMPLENR, 115},
{530.875 * OVERSAMPLENR, 110},
{567.25 * OVERSAMPLENR, 105},
{601.625 * OVERSAMPLENR, 100},
{637.875 * OVERSAMPLENR, 95},
{674.5625 * OVERSAMPLENR, 90},
{710 * OVERSAMPLENR, 85},
{744.125 * OVERSAMPLENR, 80},
{775.9375 * OVERSAMPLENR, 75},
{806.875 * OVERSAMPLENR, 70},
{835.1875 * OVERSAMPLENR, 65},
{861.125 * OVERSAMPLENR, 60},
{884.375 * OVERSAMPLENR, 55},
{904.5625 * OVERSAMPLENR, 50},
{923.8125 * OVERSAMPLENR, 45},
{940.375 * OVERSAMPLENR, 40},
{954.625 * OVERSAMPLENR, 35},
{966.875 * OVERSAMPLENR, 30},
{977.0625 * OVERSAMPLENR, 25},
{986 * OVERSAMPLENR, 20},
{993.375 * OVERSAMPLENR, 15},
{999.5 * OVERSAMPLENR, 10},
{1004.5 * OVERSAMPLENR, 5},
{1008.5 * OVERSAMPLENR, 0}
};
{20.04*OVERSAMPLENR, 300 },
{23.19*OVERSAMPLENR, 290 },
{26.71*OVERSAMPLENR, 280 },
{31.23*OVERSAMPLENR, 270 },
{36.52*OVERSAMPLENR, 260 },
{42.75*OVERSAMPLENR, 250 },
{50.68*OVERSAMPLENR, 240 },
{60.22*OVERSAMPLENR, 230 },
{72.03*OVERSAMPLENR, 220 },
{86.84*OVERSAMPLENR, 210 },
{102.79*OVERSAMPLENR, 200 },
{124.46*OVERSAMPLENR, 190 },
{151.02*OVERSAMPLENR, 180 },
{182.86*OVERSAMPLENR, 170 },
{220.72*OVERSAMPLENR, 160 },
{316.96*OVERSAMPLENR, 140 },
{447.17*OVERSAMPLENR, 120 },
{590.61*OVERSAMPLENR, 100 },
{737.31*OVERSAMPLENR, 80 },
{857.77*OVERSAMPLENR, 60 },
{939.52*OVERSAMPLENR, 40 },
{986.03*OVERSAMPLENR, 20 },
{1008.7*OVERSAMPLENR, 0}
};
#endif
#if (THERMISTORHEATER_0 == 20) || (THERMISTORHEATER_1 == 20) || (THERMISTORHEATER_2 == 20) || (THERMISTORBED == 20) // PT100 with INA826 amp on Ultimaker v2.0 electronics
......
......@@ -724,7 +724,7 @@ static void lcd_prepare_menu() {
//
// Level Bed
//
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
if (axis_known_position[X_AXIS] && axis_known_position[Y_AXIS])
MENU_ITEM(gcode, MSG_LEVEL_BED, PSTR("G29"));
#elif DISABLED(DELTA) && DISABLED(Z_SAFE_HOMING) && Z_HOME_DIR < 0
......@@ -1165,7 +1165,7 @@ static void lcd_control_temperature_preheat_gum_settings_menu() {
static void lcd_control_motion_menu() {
START_MENU(lcd_control_menu);
MENU_ITEM(back, MSG_CONTROL, lcd_control_menu);
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
MENU_ITEM_EDIT(float32, MSG_ZPROBE_ZOFFSET, &zprobe_zoffset, -50, 50);
#endif
MENU_ITEM_EDIT(float5, MSG_ACC, &acceleration, 10, 99000);
......@@ -1322,7 +1322,7 @@ static void lcd_sd_updir() {
*
*/
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();
START_MENU(lcd_main_menu);
MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
......@@ -2257,10 +2257,9 @@ char *ftostr52(const float &x) {
#include "temperature.h"
#include "stepper.h"
#include "configuration_store.h"
#include "NexText.h"
#include "NexHotspot.h"
#include "NexProgressBar.h"
#include "Nextion.h"
bool NextionON = false;
char buffer[100] = {0};
char lcd_status_message[30] = WELCOME_MSG; // worst case is kana with up to 3*LCD_WIDTH+1
uint8_t lcd_status_message_level = 0;
......@@ -2284,18 +2283,18 @@ NexProgressBar jp3 = NexProgressBar(1, 11, "jp3");
NexProgressBar jp4 = NexProgressBar(1, 14, "jp4");
// Touch area
NexHotspot homex = NexHotspot(1, 17, "homex", homePopCallback, &homex);
NexHotspot homey = NexHotspot(1, 18, "homey", homePopCallback, &homey);
NexHotspot homez = NexHotspot(1, 19, "homez", homePopCallback, &homez);
NexHotspot home0 = NexHotspot(1, 20, "home0", homePopCallback, &home0);
NexHotspot hot0 = NexHotspot(1, 21, "hot0", hotPopCallback, &hot0);
NexHotspot hot1 = NexHotspot(1, 22, "hot1", hotPopCallback, &hot1);
NexHotspot hot2 = NexHotspot(1, 23, "hot2", hotPopCallback, &hot2);
NexHotspot hot3 = NexHotspot(1, 24, "hot3", hotPopCallback, &hot3);
NexHotspot hot4 = NexHotspot(1, 25, "hot4", hotPopCallback, &hot4);
NexHotspot m11 = NexHotspot(2, 14, "m11", sethotPopCallback, &m11);
NexHotspot tup = NexHotspot(2, 16, "tup", settempPopCallback, &tup);
NexHotspot tdown = NexHotspot(2, 17, "tdown", settempPopCallback, &tdown);
NexHotspot homex = NexHotspot(1, 17, "homex");
NexHotspot homey = NexHotspot(1, 18, "homey");
NexHotspot homez = NexHotspot(1, 19, "homez");
NexHotspot home0 = NexHotspot(1, 20, "home0");
NexHotspot hot0 = NexHotspot(1, 21, "hot0");
NexHotspot hot1 = NexHotspot(1, 22, "hot1");
NexHotspot hot2 = NexHotspot(1, 23, "hot2");
NexHotspot hot3 = NexHotspot(1, 24, "hot3");
NexHotspot hot4 = NexHotspot(1, 25, "hot4");
NexHotspot m11 = NexHotspot(2, 14, "m11");
NexHotspot tup = NexHotspot(2, 16, "tup");
NexHotspot tdown = NexHotspot(2, 17, "tdown");
NexTouch *nexListenList[] =
{
......@@ -2326,7 +2325,7 @@ void homePopCallback(void *ptr) {
}
void hotPopCallback(void *ptr) {
NexTouch::sendCommand("page 2");
sendCommand("page 2");
memset(buffer, 0, sizeof(buffer));
if (ptr == &hot0) {
if (degTargetHotend(0) != 0) {
......@@ -2382,17 +2381,35 @@ void sethotPopCallback(void *ptr) {
memset(buffer, 0, sizeof(buffer));
set1.getText(buffer, sizeof(buffer));
enqueuecommands_P(buffer);
NexTouch::sendCommand("page menu");
sendCommand("page menu");
lcd_setstatus(lcd_status_message);
}
millis_t next_lcd_update_ms;
void lcd_init() {
nexInit();
delay(SPLASH_SCREEN_DURATION); // wait to display the splash screen
NexTouch::sendCommand("page menu");
lcd_setstatus(WELCOME_MSG);
NextionON = nexInit();
if (!NextionON) {
ECHO_LM(ER, "Nextion LCD not connected!");
}
else {
ECHO_LM(DB, "Nextion LCD connected!");
homex.attachPop(homePopCallback, &homex);
homey.attachPop(homePopCallback, &homey);
homez.attachPop(homePopCallback, &homez);
home0.attachPop(homePopCallback, &home0);
hot0.attachPop(hotPopCallback, &hot0);
hot1.attachPop(hotPopCallback, &hot1);
hot2.attachPop(hotPopCallback, &hot2);
hot3.attachPop(hotPopCallback, &hot3);
hot4.attachPop(hotPopCallback, &hot4);
m11.attachPop(sethotPopCallback, &m11);
tup.attachPop(settempPopCallback, &tup);
tdown.attachPop(settempPopCallback, &tdown);
delay(SPLASH_SCREEN_DURATION); // wait to display the splash screen
sendCommand("page menu");
lcd_setstatus(WELCOME_MSG);
}
}
static void temptoLCD(int h, int T1, int T2) {
......@@ -2494,6 +2511,9 @@ static void coordtoLCD() {
}
void lcd_update() {
if (!NextionON) return;
millis_t ms = millis();
if (ms > next_lcd_update_ms) {
......@@ -2513,13 +2533,13 @@ void lcd_update() {
}
void lcd_setstatus(const char* message, bool persist) {
if (lcd_status_message_level > 0) return;
if (lcd_status_message_level > 0 || !NextionON) return;
strncpy(lcd_status_message, message, 30);
LedStatus.setText(lcd_status_message);
}
void lcd_setstatuspgm(const char* message, uint8_t level) {
if (level >= lcd_status_message_level) {
if (level >= lcd_status_message_level && NextionON) {
strncpy_P(lcd_status_message, message, 30);
lcd_status_message_level = level;
LedStatus.setText(lcd_status_message);
......
......@@ -75,10 +75,10 @@
#define EN_A BIT(BLEN_A)
#define LCD_CLICKED (buttons&EN_C)
#if defined(BTN_BACK) && BTN_BACK > 0
#define EN_D BIT(BLEN_D)
#define LCD_BACK_CLICKED (buttons&EN_D)
#endif
#if defined(BTN_BACK) && BTN_BACK > 0
#define EN_D BIT(BLEN_D)
#define LCD_BACK_CLICKED (buttons&EN_D)
#endif
#if ENABLED(REPRAPWORLD_KEYPAD)
#define EN_REPRAPWORLD_KEYPAD_F3 (BIT(BLEN_REPRAPWORLD_KEYPAD_F3))
#define EN_REPRAPWORLD_KEYPAD_F2 (BIT(BLEN_REPRAPWORLD_KEYPAD_F2))
......
......@@ -19,7 +19,7 @@
#include <math.h>
#include "Marlin.h"
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
#include "vector_3.h"
vector_3::vector_3() : x(0), y(0), z(0) { }
......@@ -131,4 +131,4 @@ void matrix_3x3::debug(const char title[]) {
}
}
#endif // ENABLE_AUTO_BED_LEVELING
#endif // AUTO_BED_LEVELING_FEATURE
......@@ -19,7 +19,7 @@
#ifndef VECTOR_3_H
#define VECTOR_3_H
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
class matrix_3x3;
struct vector_3
......@@ -57,6 +57,6 @@ struct matrix_3x3
void apply_rotation_xyz(matrix_3x3 rotationMatrix, float &x, float& y, float& z);
#endif // ENABLE_AUTO_BED_LEVELING
#endif // AUTO_BED_LEVELING_FEATURE
#endif // VECTOR_3_H
......@@ -34,7 +34,7 @@ Adding commands to facilitate purging of hotend.
Step per unit varied for each extruder as well as the feedrate.
The addition of a different feedrate for retraction.
Adding Debug Dryrun used by repetier.
Added total Power on time writec in SD CARD.
Added total Power on time writed in SD CARD.
Added total Power consumption writed in SD CARD.
Added anti extruder idle oozing system.
## Credits
......
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