Merge branch 'Implement-M591-Configurable-Runout-Sensors' into CrealityDwin2.0_Bleeding
This commit is contained in:
@@ -113,10 +113,10 @@ jobs:
|
||||
steps:
|
||||
|
||||
- name: Check out the PR
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Cache pip
|
||||
uses: actions/cache@v2
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.cache/pip
|
||||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
|
||||
@@ -124,20 +124,20 @@ jobs:
|
||||
${{ runner.os }}-pip-
|
||||
|
||||
- name: Cache PlatformIO
|
||||
uses: actions/cache@v2
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.platformio
|
||||
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
|
||||
|
||||
- name: Select Python 3.7
|
||||
uses: actions/setup-python@v2
|
||||
uses: actions/setup-python@v3
|
||||
with:
|
||||
python-version: '3.7' # Version range or exact version of a Python version to use, using semvers version range syntax.
|
||||
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
|
||||
|
||||
- name: Install PlatformIO
|
||||
run: |
|
||||
pip install -U https://github.com/platformio/platformio-core/archive/develop.zip
|
||||
pip install -U https://github.com/platformio/platformio-core/archive/v5.2.5.zip
|
||||
platformio update
|
||||
|
||||
- name: Run ${{ matrix.test-platform }} Tests
|
||||
|
||||
+211
-101
@@ -299,7 +299,7 @@
|
||||
*
|
||||
* Advanced settings can be found in Configuration_adv.h
|
||||
*/
|
||||
#define CONFIGURATION_H_VERSION 02000903
|
||||
#define CONFIGURATION_H_VERSION 02010000
|
||||
|
||||
//===========================================================================
|
||||
//============================= Getting Started =============================
|
||||
@@ -794,9 +794,9 @@
|
||||
//#define MACHINE_UUID "00000000-0000-0000-0000-000000000000"
|
||||
|
||||
/**
|
||||
* Define the number of coordinated linear axes.
|
||||
* Define the number of coordinated axes.
|
||||
* See https://github.com/DerAndere1/Marlin/wiki
|
||||
* Each linear axis gets its own stepper control and endstop:
|
||||
* Each axis gets its own stepper control and endstop:
|
||||
*
|
||||
* Steppers: *_STEP_PIN, *_ENABLE_PIN, *_DIR_PIN, *_ENABLE_ON
|
||||
* Endstops: *_STOP_PIN, USE_*MIN_PLUG, USE_*MAX_PLUG
|
||||
@@ -805,31 +805,50 @@
|
||||
* DEFAULT_MAX_ACCELERATION, AXIS_RELATIVE_MODES,
|
||||
* MICROSTEP_MODES, MANUAL_FEEDRATE
|
||||
*
|
||||
* :[3, 4, 5, 6]
|
||||
* :[3, 4, 5, 6, 7, 8, 9]
|
||||
*/
|
||||
//#define LINEAR_AXES 3
|
||||
//#define NUM_AXES 3
|
||||
|
||||
/**
|
||||
* Axis codes for additional axes:
|
||||
* This defines the axis code that is used in G-code commands to
|
||||
* reference a specific axis.
|
||||
* 'A' for rotational axis parallel to X
|
||||
* 'B' for rotational axis parallel to Y
|
||||
* 'C' for rotational axis parallel to Z
|
||||
* 'U' for secondary linear axis parallel to X
|
||||
* 'V' for secondary linear axis parallel to Y
|
||||
* 'W' for secondary linear axis parallel to Z
|
||||
* Regardless of the settings, firmware-internal axis IDs are
|
||||
* I (AXIS4), J (AXIS5), K (AXIS6).
|
||||
* Additional Axis Settings
|
||||
*
|
||||
* Define AXISn_ROTATES for all axes that rotate or pivot.
|
||||
* Rotational axis coordinates are expressed in degrees.
|
||||
*
|
||||
* AXISn_NAME defines the letter used to refer to the axis in (most) G-code commands.
|
||||
* By convention the names and roles are typically:
|
||||
* 'A' : Rotational axis parallel to X
|
||||
* 'B' : Rotational axis parallel to Y
|
||||
* 'C' : Rotational axis parallel to Z
|
||||
* 'U' : Secondary linear axis parallel to X
|
||||
* 'V' : Secondary linear axis parallel to Y
|
||||
* 'W' : Secondary linear axis parallel to Z
|
||||
*
|
||||
* Regardless of these settings the axes are internally named I, J, K, U, V, W.
|
||||
*/
|
||||
#if LINEAR_AXES >= 4
|
||||
#if NUM_AXES >= 4
|
||||
#define AXIS4_NAME 'A' // :['A', 'B', 'C', 'U', 'V', 'W']
|
||||
#define AXIS4_ROTATES
|
||||
#endif
|
||||
#if LINEAR_AXES >= 5
|
||||
#define AXIS5_NAME 'B' // :['A', 'B', 'C', 'U', 'V', 'W']
|
||||
#if NUM_AXES >= 5
|
||||
#define AXIS5_NAME 'B' // :['B', 'C', 'U', 'V', 'W']
|
||||
#define AXIS5_ROTATES
|
||||
#endif
|
||||
#if LINEAR_AXES >= 6
|
||||
#define AXIS6_NAME 'C' // :['A', 'B', 'C', 'U', 'V', 'W']
|
||||
#if NUM_AXES >= 6
|
||||
#define AXIS6_NAME 'C' // :['C', 'U', 'V', 'W']
|
||||
#define AXIS6_ROTATES
|
||||
#endif
|
||||
#if NUM_AXES >= 7
|
||||
#define AXIS7_NAME 'U' // :['U', 'V', 'W']
|
||||
//#define AXIS7_ROTATES
|
||||
#endif
|
||||
#if NUM_AXES >= 8
|
||||
#define AXIS8_NAME 'V' // :['V', 'W']
|
||||
//#define AXIS8_ROTATES
|
||||
#endif
|
||||
#if NUM_AXES >= 9
|
||||
#define AXIS9_NAME 'W' // :['W']
|
||||
//#define AXIS9_ROTATES
|
||||
#endif
|
||||
|
||||
// @section extruder
|
||||
@@ -1120,6 +1139,7 @@
|
||||
* 61 : 100kΩ Formbot/Vivedino 350°C Thermistor - beta 3950
|
||||
* 66 : 4.7MΩ Dyze Design High Temperature Thermistor
|
||||
* 67 : 500kΩ SliceEngineering 450°C Thermistor
|
||||
* 68 : PT100 amplifier board from Dyze Design
|
||||
* 70 : 100kΩ bq Hephestos 2
|
||||
* 75 : 100kΩ Generic Silicon Heat Pad with NTC100K MGB18-104F39050L32
|
||||
* 2000 : 100kΩ Ultimachine Rambo TDK NTCG104LH104KT1 NTC100K motherboard Thermistor
|
||||
@@ -1292,10 +1312,12 @@
|
||||
//===========================================================================
|
||||
//============================= PID Settings ================================
|
||||
//===========================================================================
|
||||
// PID Tuning Guide here: https://reprap.org/wiki/PID_Tuning
|
||||
|
||||
// Comment the following line to disable PID and enable bang-bang.
|
||||
#define PIDTEMP
|
||||
// Enable PIDTEMP for PID control or MPCTEMP for Predictive Model.
|
||||
// temperature control. Disable both for bang-bang heating.
|
||||
#define PIDTEMP // See the PID Tuning Guide at https://reprap.org/wiki/PID_Tuning
|
||||
//#define MPCTEMP // ** EXPERIMENTAL **
|
||||
|
||||
#define BANG_MAX 255 // Limits current to nozzle while in bang-bang mode; 255=full current
|
||||
#define PID_MAX BANG_MAX // Limits current to nozzle while PID is active (see PID_FUNCTIONAL_RANGE below); 255=full current
|
||||
#define PID_K1 0.95 // Smoothing factor within any PID loop
|
||||
@@ -1376,7 +1398,45 @@
|
||||
//#define DEFAULT_Ki 2.25
|
||||
//#define DEFAULT_Kd 440
|
||||
#endif
|
||||
#endif // PIDTEMP
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Model Predictive Control for hotend
|
||||
*
|
||||
* Use a physical model of the hotend to control temperature. When configured correctly
|
||||
* this gives better responsiveness and stability than PID and it also removes the need
|
||||
* for PID_EXTRUSION_SCALING and PID_FAN_SCALING. Use M306 to autotune the model.
|
||||
*/
|
||||
#if ENABLED(MPCTEMP)
|
||||
#define MPC_MAX BANG_MAX // (0..255) Current to nozzle while MPC is active.
|
||||
#define MPC_HEATER_POWER { 40.0f } // (W) Heat cartridge powers.
|
||||
|
||||
#define MPC_INCLUDE_FAN // Model the fan speed?
|
||||
|
||||
// Measured physical constants from M306
|
||||
#define MPC_BLOCK_HEAT_CAPACITY { 16.7f } // (J/K) Heat block heat capacities.
|
||||
#define MPC_SENSOR_RESPONSIVENESS { 0.22f } // (K/s per ∆K) Rate of change of sensor temperature from heat block.
|
||||
#define MPC_AMBIENT_XFER_COEFF { 0.068f } // (W/K) Heat transfer coefficients from heat block to room air with fan off.
|
||||
#if ENABLED(MPC_INCLUDE_FAN)
|
||||
#define MPC_AMBIENT_XFER_COEFF_FAN255 { 0.097f } // (W/K) Heat transfer coefficients from heat block to room air with fan on full.
|
||||
#endif
|
||||
|
||||
// For one fan and multiple hotends MPC needs to know how to apply the fan cooling effect.
|
||||
#if ENABLED(MPC_INCLUDE_FAN)
|
||||
//#define MPC_FAN_0_ALL_HOTENDS
|
||||
//#define MPC_FAN_0_ACTIVE_HOTEND
|
||||
#endif
|
||||
|
||||
#define FILAMENT_HEAT_CAPACITY_PERMM 5.6e-3f // 0.0056 J/K/mm for 1.75mm PLA (0.0149 J/K/mm for 2.85mm PLA).
|
||||
//#define FILAMENT_HEAT_CAPACITY_PERMM 3.6e-3f // 0.0036 J/K/mm for 1.75mm PETG (0.0094 J/K/mm for 2.85mm PETG).
|
||||
|
||||
// Advanced options
|
||||
#define MPC_SMOOTHING_FACTOR 0.5f // (0.0...1.0) Noisy temperature sensors may need a lower value for stabilization.
|
||||
#define MPC_MIN_AMBIENT_CHANGE 1.0f // (K/s) Modeled ambient temperature rate of change, when correcting model inaccuracies.
|
||||
#define MPC_STEADYSTATE 0.5f // (K/s) Temperature change rate for steady state logic to be enforced.
|
||||
|
||||
#define MPC_TUNING_POS { X_CENTER, Y_CENTER, 1.0f } // (mm) M306 Autotuning position, ideally bed center just above the surface.
|
||||
#endif
|
||||
|
||||
//===========================================================================
|
||||
//====================== PID > Bed Temperature Control ======================
|
||||
@@ -1580,12 +1640,18 @@
|
||||
//#define USE_IMIN_PLUG
|
||||
//#define USE_JMIN_PLUG
|
||||
//#define USE_KMIN_PLUG
|
||||
//#define USE_UMIN_PLUG
|
||||
//#define USE_VMIN_PLUG
|
||||
//#define USE_WMIN_PLUG
|
||||
//#define USE_XMAX_PLUG
|
||||
//#define USE_YMAX_PLUG
|
||||
//#define USE_ZMAX_PLUG
|
||||
//#define USE_IMAX_PLUG
|
||||
//#define USE_JMAX_PLUG
|
||||
//#define USE_KMAX_PLUG
|
||||
//#define USE_UMAX_PLUG
|
||||
//#define USE_VMAX_PLUG
|
||||
//#define USE_WMAX_PLUG
|
||||
|
||||
// Enable pullup for all endstops to prevent a floating state
|
||||
#define ENDSTOPPULLUPS
|
||||
@@ -1597,12 +1663,18 @@
|
||||
//#define ENDSTOPPULLUP_IMIN
|
||||
//#define ENDSTOPPULLUP_JMIN
|
||||
//#define ENDSTOPPULLUP_KMIN
|
||||
//#define ENDSTOPPULLUP_UMIN
|
||||
//#define ENDSTOPPULLUP_VMIN
|
||||
//#define ENDSTOPPULLUP_WMIN
|
||||
//#define ENDSTOPPULLUP_XMAX
|
||||
//#define ENDSTOPPULLUP_YMAX
|
||||
//#define ENDSTOPPULLUP_ZMAX
|
||||
//#define ENDSTOPPULLUP_IMAX
|
||||
//#define ENDSTOPPULLUP_JMAX
|
||||
//#define ENDSTOPPULLUP_KMAX
|
||||
//#define ENDSTOPPULLUP_UMAX
|
||||
//#define ENDSTOPPULLUP_VMAX
|
||||
//#define ENDSTOPPULLUP_WMAX
|
||||
//#define ENDSTOPPULLUP_ZMIN_PROBE
|
||||
#endif
|
||||
|
||||
@@ -1616,12 +1688,18 @@
|
||||
//#define ENDSTOPPULLDOWN_IMIN
|
||||
//#define ENDSTOPPULLDOWN_JMIN
|
||||
//#define ENDSTOPPULLDOWN_KMIN
|
||||
//#define ENDSTOPPULLDOWN_UMIN
|
||||
//#define ENDSTOPPULLDOWN_VMIN
|
||||
//#define ENDSTOPPULLDOWN_WMIN
|
||||
//#define ENDSTOPPULLDOWN_XMAX
|
||||
//#define ENDSTOPPULLDOWN_YMAX
|
||||
//#define ENDSTOPPULLDOWN_ZMAX
|
||||
//#define ENDSTOPPULLDOWN_IMAX
|
||||
//#define ENDSTOPPULLDOWN_JMAX
|
||||
//#define ENDSTOPPULLDOWN_KMAX
|
||||
//#define ENDSTOPPULLDOWN_UMAX
|
||||
//#define ENDSTOPPULLDOWN_VMAX
|
||||
//#define ENDSTOPPULLDOWN_WMAX
|
||||
//#define ENDSTOPPULLDOWN_ZMIN_PROBE
|
||||
#endif
|
||||
|
||||
@@ -1639,12 +1717,17 @@
|
||||
#define I_MIN_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop.
|
||||
#define J_MIN_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop.
|
||||
#define K_MIN_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop.
|
||||
#define U_MIN_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop.
|
||||
#define V_MIN_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop.
|
||||
#define W_MIN_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop.
|
||||
#define X_MAX_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop.
|
||||
#define Y_MAX_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop.
|
||||
#define Z_MAX_ENDSTOP_INVERTING true // set to true to invert the logic of the endstop.
|
||||
#define I_MAX_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop.
|
||||
#define J_MAX_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop.
|
||||
#define K_MAX_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop.
|
||||
#define W_MAX_ENDSTOP_INVERTING false // Set to true to invert the logic of the endstop.
|
||||
#define Z_MIN_PROBE_ENDSTOP_INVERTING false // Set to true to invert the logic of the probe.
|
||||
|
||||
#if NONE(ABL_EZABL, MachineCR2020, MachineCR5)
|
||||
#define Z_MIN_ENDSTOP_INVERTING false // set to true to invert the logic of the endstop.
|
||||
@@ -1756,6 +1839,11 @@
|
||||
//#define I_DRIVER_TYPE A4988
|
||||
//#define J_DRIVER_TYPE A4988
|
||||
//#define K_DRIVER_TYPE A4988
|
||||
//#define U_DRIVER_TYPE A4988
|
||||
//#define V_DRIVER_TYPE A4988
|
||||
//#define W_DRIVER_TYPE A4988
|
||||
//#define E0_DRIVER_TYPE A4988
|
||||
//#define E1_DRIVER_TYPE A4988
|
||||
//#define E2_DRIVER_TYPE A4988
|
||||
//#define E3_DRIVER_TYPE A4988
|
||||
//#define E4_DRIVER_TYPE A4988
|
||||
@@ -1809,9 +1897,9 @@
|
||||
//#define DISTINCT_E_FACTORS
|
||||
|
||||
/**
|
||||
* Default Axis Steps Per Unit (steps/mm)
|
||||
* Default Axis Steps Per Unit (linear=steps/mm, rotational=steps/°)
|
||||
* Override with M92
|
||||
* X, Y, Z [, I [, J [, K]]], E0 [, E1[, E2...]]
|
||||
* X, Y, Z [, I [, J [, K...]]], E0 [, E1[, E2...]]
|
||||
*/
|
||||
|
||||
#if ENABLED(CrealityTitan)
|
||||
@@ -1861,9 +1949,9 @@
|
||||
#define DEFAULT_AXIS_STEPS_PER_UNIT { XYStepsmm, XYStepsmm, ZStepsmm, (EStepsmm*EstepMultiplier) }
|
||||
|
||||
/**
|
||||
* Default Max Feed Rate (mm/s)
|
||||
* Default Max Feed Rate (linear=mm/s, rotational=°/s)
|
||||
* Override with M203
|
||||
* X, Y, Z, E0 [, E1[, E2[, E3[, E4[, E5]]]]]
|
||||
* X, Y, Z [, I [, J [, K...]]], E0 [, E1[, E2...]]
|
||||
*/
|
||||
#if ANY(MachineCR20Pro, MachineEnder2Pro)
|
||||
#define DEFAULT_MAX_FEEDRATE { 750, 750, 10, 75 }
|
||||
@@ -1921,10 +2009,10 @@
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Default Max Acceleration (change/s) change = mm/s
|
||||
* Default Max Acceleration (speed change with time) (linear=mm/(s^2), rotational=°/(s^2))
|
||||
* (Maximum start speed for accelerated moves)
|
||||
* Override with M201
|
||||
* X, Y, Z [, I [, J [, K]]], E0 [, E1[, E2...]]
|
||||
* X, Y, Z [, I [, J [, K...]]], E0 [, E1[, E2...]]
|
||||
*/
|
||||
|
||||
//#define LIMITED_MAX_ACCEL_EDITING // Limit edit via M201 or LCD to DEFAULT_MAX_ACCELERATION * 2
|
||||
@@ -1933,7 +2021,7 @@
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Default Acceleration (change/s) change = mm/s
|
||||
* Default Acceleration (speed change with time) (linear=mm/(s^2), rotational=°/(s^2))
|
||||
* Override with M204
|
||||
*
|
||||
* M204 P Acceleration
|
||||
@@ -1943,7 +2031,7 @@
|
||||
|
||||
/**
|
||||
* Default Jerk limits (mm/s)
|
||||
* Override with M205 X Y Z E
|
||||
* Override with M205 X Y Z . . . E
|
||||
*
|
||||
* "Jerk" specifies the minimum speed change that requires acceleration.
|
||||
* When changing speed and direction, if the difference is less than the
|
||||
@@ -1965,6 +2053,9 @@
|
||||
//#define DEFAULT_IJERK 0.3
|
||||
//#define DEFAULT_JJERK 0.3
|
||||
//#define DEFAULT_KJERK 0.3
|
||||
//#define DEFAULT_UJERK 0.3
|
||||
//#define DEFAULT_VJERK 0.3
|
||||
//#define DEFAULT_WJERK 0.3
|
||||
|
||||
//#define TRAVEL_EXTRA_XYJERK 0.0 // Additional jerk allowance for all travel moves
|
||||
|
||||
@@ -2415,6 +2506,9 @@
|
||||
//#define I_ENABLE_ON 0
|
||||
//#define J_ENABLE_ON 0
|
||||
//#define K_ENABLE_ON 0
|
||||
//#define U_ENABLE_ON 0
|
||||
//#define V_ENABLE_ON 0
|
||||
//#define W_ENABLE_ON 0
|
||||
|
||||
// Disables axis stepper immediately when it's not being used.
|
||||
// WARNING: When motors turn off there is a chance of losing position accuracy!
|
||||
@@ -2424,6 +2518,9 @@
|
||||
//#define DISABLE_I false
|
||||
//#define DISABLE_J false
|
||||
//#define DISABLE_K false
|
||||
//#define DISABLE_U false
|
||||
//#define DISABLE_V false
|
||||
//#define DISABLE_W false
|
||||
|
||||
// Warn on display about possibly reduced accuracy
|
||||
//#define DISABLE_REDUCED_ACCURACY_WARNING
|
||||
@@ -2513,6 +2610,10 @@
|
||||
//#define INVERT_I_DIR false
|
||||
//#define INVERT_J_DIR false
|
||||
//#define INVERT_K_DIR false
|
||||
//#define INVERT_U_DIR false
|
||||
//#define INVERT_V_DIR false
|
||||
//#define INVERT_W_DIR false
|
||||
|
||||
// @section extruder
|
||||
|
||||
// For direct drive extruder v9 set to true, for geared extruder set to false.
|
||||
@@ -2565,6 +2666,9 @@
|
||||
//#define I_HOME_DIR -1
|
||||
//#define J_HOME_DIR -1
|
||||
//#define K_HOME_DIR -1
|
||||
//#define U_HOME_DIR -1
|
||||
//#define V_HOME_DIR -1
|
||||
//#define W_HOME_DIR -1
|
||||
|
||||
// @section machine
|
||||
|
||||
@@ -2750,7 +2854,7 @@
|
||||
#endif
|
||||
|
||||
|
||||
// Travel limits (mm) after homing, corresponding to endstop positions.
|
||||
// Travel limits (linear=mm, rotational=°) after homing, corresponding to endstop positions.
|
||||
#if ENABLED(MicroswissDirectDrive)
|
||||
#define X_MIN_POS -15
|
||||
#define Y_MIN_POS -10
|
||||
@@ -2786,6 +2890,12 @@
|
||||
//#define J_MAX_POS 50
|
||||
//#define K_MIN_POS 0
|
||||
//#define K_MAX_POS 50
|
||||
//#define U_MIN_POS 0
|
||||
//#define U_MAX_POS 50
|
||||
//#define V_MIN_POS 0
|
||||
//#define V_MAX_POS 50
|
||||
//#define W_MIN_POS 0
|
||||
//#define W_MAX_POS 50
|
||||
|
||||
/**
|
||||
* Software Endstops
|
||||
@@ -2805,6 +2915,9 @@
|
||||
#define MIN_SOFTWARE_ENDSTOP_I
|
||||
#define MIN_SOFTWARE_ENDSTOP_J
|
||||
#define MIN_SOFTWARE_ENDSTOP_K
|
||||
#define MIN_SOFTWARE_ENDSTOP_U
|
||||
#define MIN_SOFTWARE_ENDSTOP_V
|
||||
#define MIN_SOFTWARE_ENDSTOP_W
|
||||
#endif
|
||||
|
||||
// Max software endstops constrain movement within maximum coordinate bounds
|
||||
@@ -2816,6 +2929,9 @@
|
||||
#define MAX_SOFTWARE_ENDSTOP_I
|
||||
#define MAX_SOFTWARE_ENDSTOP_J
|
||||
#define MAX_SOFTWARE_ENDSTOP_K
|
||||
#define MAX_SOFTWARE_ENDSTOP_U
|
||||
#define MAX_SOFTWARE_ENDSTOP_V
|
||||
#define MAX_SOFTWARE_ENDSTOP_W
|
||||
#endif
|
||||
#if(NONE(MachineCR10Orig, LowMemoryBoard))
|
||||
#if EITHER(MIN_SOFTWARE_ENDSTOPS, MAX_SOFTWARE_ENDSTOPS)
|
||||
@@ -2831,17 +2947,16 @@
|
||||
* Marlin knows a print job is running when:
|
||||
* 1. Running a print job from media started with M24.
|
||||
* 2. The Print Job Timer has been started with M75.
|
||||
* 3. The heaters were turned on and PRINTJOB_TIMER_AUTOSTART is enabled.
|
||||
* 3. The heaters were turned on with a wait command (M109) and PRINTJOB_TIMER_AUTOSTART is enabled.
|
||||
*
|
||||
* RAMPS-based boards use SERVO3_PIN for the first runout sensor.
|
||||
* For other boards you may need to define FIL_RUNOUT_PIN, FIL_RUNOUT2_PIN, etc.
|
||||
*/
|
||||
#if NONE(MachineCR10Orig, MachineCR20, MachineEnder3, MachineEnder3V2, MachineEnder4, MachineEnder5, MachineCRX, Melzi_To_SBoardUpgrade) || ANY(AddonFilSensor, lerdgeFilSensor, DualFilSensors)
|
||||
#if DISABLED(MachineCR10Orig) || ANY(Melzi_To_SBoardUpgrade, AddonFilSensor, lerdgeFilSensor, DualFilSensors)
|
||||
#define FILAMENT_RUNOUT_SENSOR
|
||||
#endif
|
||||
#if ENABLED(FILAMENT_RUNOUT_SENSOR)
|
||||
#define FIL_RUNOUT_ENABLED_DEFAULT true // Enable the sensor on startup. Override with M412 followed by M500.
|
||||
#if ENABLED(DualFilSensors)
|
||||
#if ENABLED(DualFilSensors)
|
||||
#if DISABLED(SKR13, SKR14, SKR14Turbo, SKRPRO11, SKRE3Turbo)
|
||||
#define NUM_RUNOUT_SENSORS 2 // Number of sensors, up to one per extruder. Define a FIL_RUNOUT#_PIN for each.
|
||||
#endif
|
||||
@@ -2849,60 +2964,31 @@
|
||||
#else
|
||||
#define NUM_RUNOUT_SENSORS 1 // Number of sensors, up to one per extruder. Define a FIL_RUNOUT#_PIN for each.
|
||||
#endif
|
||||
#if ENABLED(lerdgeFilSensor)
|
||||
#define FIL_RUNOUT_STATE LOW // set to true to invert the logic of the sensor.
|
||||
#if NONE(MachineCR10Orig, MachineCR20, MachineEnder3, MachineEnder3V2, MachineEnder4, MachineEnder5, MachineCRX, Melzi_To_SBoardUpgrade) || ANY(AddonFilSensor, lerdgeFilSensor, DualFilSensors)
|
||||
#define FIL_RUNOUT_ENABLED { true } // Default enabled state for sensors E0[, E1[, E2[, E3...]]]. Override with M591EnnSn followed by M500.
|
||||
#else
|
||||
#define FIL_RUNOUT_STATE HIGH // set to true to invert the logic of the sensor.
|
||||
#define FIL_RUNOUT_ENABLED { false } // Default enabled state for sensors E0[, E1[, E2[, E3...]]]. Override with M591EnnSn followed by M500.
|
||||
#endif
|
||||
#if DISABLED(MachineEnder3S1)
|
||||
#define FIL_RUNOUT_PULLUP // Use internal pullup for filament runout pins.
|
||||
|
||||
#if ENABLED(FilamentEncoder)
|
||||
#define FIL_RUNOUT_MODE { 7 } // Default mode for sensors E0[, E1[, E2[, E3...]]]. 0:NONE 1:Switch NO 2:Switch NC 7:Motion Sensor Override with M591EnPnn
|
||||
#elif ENABLED(lerdgeFilSensor)
|
||||
#define FIL_RUNOUT_MODE { 1 } // Default mode for sensors E0[, E1[, E2[, E3...]]]. 0:NONE 1:Switch NO 2:Switch NC 7:Motion Sensor Override with M591EnPnn
|
||||
#else
|
||||
#define FIL_RUNOUT_PULLDOWN // Use internal pulldown for filament runout pins.
|
||||
#define FIL_RUNOUT_MODE { 2 } // Default mode for sensors E0[, E1[, E2[, E3...]]]. 0:NONE 1:Switch NO 2:Switch NC 7:Motion Sensor Override with M591EnPnn
|
||||
#endif
|
||||
//#define WATCH_ALL_RUNOUT_SENSORS // Execute runout script on any triggering sensor, not only for the active extruder.
|
||||
// This is automatically enabled for MIXING_EXTRUDERs.
|
||||
|
||||
// Override individually if the runout sensors vary
|
||||
//#define FIL_RUNOUT1_STATE LOW
|
||||
//#define FIL_RUNOUT1_PULLUP
|
||||
//#define FIL_RUNOUT1_PULLDOWN
|
||||
|
||||
//#define FIL_RUNOUT2_STATE LOW
|
||||
//#define FIL_RUNOUT2_PULLUP
|
||||
//#define FIL_RUNOUT2_PULLDOWN
|
||||
|
||||
//#define FIL_RUNOUT3_STATE LOW
|
||||
//#define FIL_RUNOUT3_PULLUP
|
||||
//#define FIL_RUNOUT3_PULLDOWN
|
||||
|
||||
//#define FIL_RUNOUT4_STATE LOW
|
||||
//#define FIL_RUNOUT4_PULLUP
|
||||
//#define FIL_RUNOUT4_PULLDOWN
|
||||
|
||||
//#define FIL_RUNOUT5_STATE LOW
|
||||
//#define FIL_RUNOUT5_PULLUP
|
||||
//#define FIL_RUNOUT5_PULLDOWN
|
||||
|
||||
//#define FIL_RUNOUT6_STATE LOW
|
||||
//#define FIL_RUNOUT6_PULLUP
|
||||
//#define FIL_RUNOUT6_PULLDOWN
|
||||
|
||||
//#define FIL_RUNOUT7_STATE LOW
|
||||
//#define FIL_RUNOUT7_PULLUP
|
||||
//#define FIL_RUNOUT7_PULLDOWN
|
||||
|
||||
//#define FIL_RUNOUT8_STATE LOW
|
||||
//#define FIL_RUNOUT8_PULLUP
|
||||
//#define FIL_RUNOUT8_PULLDOWN
|
||||
//#define WATCH_ALL_RUNOUT_SENSORS // Execute runout script on any triggering sensor, not only for the active extruder.
|
||||
// This is automatically enabled for MIXING_EXTRUDERs.
|
||||
|
||||
// Commands to execute on filament runout.
|
||||
// With multiple runout sensors use the %c placeholder for the current tool in commands (e.g., "M600 T%c")
|
||||
// NOTE: After 'M412 H1' the host handles filament runout and this script does not apply.
|
||||
// NOTE: After 'M591 H1' the host handles filament runout and this script does not apply.
|
||||
#define FILAMENT_RUNOUT_SCRIPT "M600"
|
||||
|
||||
// After a runout is detected, continue printing this length of filament
|
||||
// before executing the runout script. Useful for a sensor at the end of
|
||||
// a feed tube. Requires 4 bytes SRAM per sensor, plus 4 bytes overhead.
|
||||
// In Mode 1 or 2, continue printing this length of filament after a run out occurs before executing the
|
||||
// runout script. Useful for a sensor at the end of a feed tube or debounce on a flakey sensor.
|
||||
// In Mode 7, extrusion distance to expect a change of state.
|
||||
// Override with M591EnLnn
|
||||
#if ENABLED(FilamentEncoder)
|
||||
#define FILAMENT_RUNOUT_DISTANCE_MM 12
|
||||
#elif ANY(MachineEnder5Plus, MachineCR10SPro, MachineCR10SProV2)
|
||||
@@ -2911,14 +2997,36 @@
|
||||
#define FILAMENT_RUNOUT_DISTANCE_MM 5
|
||||
#endif
|
||||
|
||||
#ifdef FILAMENT_RUNOUT_DISTANCE_MM
|
||||
// Enable this option to use an encoder disc that toggles the runout pin
|
||||
// as the filament moves. (Be sure to set FILAMENT_RUNOUT_DISTANCE_MM
|
||||
// large enough to avoid false positives.)
|
||||
#if ENABLED(FilamentEncoder)
|
||||
#define FILAMENT_MOTION_SENSOR
|
||||
#endif
|
||||
#if DISABLED(MachineEnder3S1)
|
||||
#define FIL_RUNOUT_PULLUP // Use internal pullup for filament runout pins.
|
||||
#else
|
||||
#define FIL_RUNOUT_PULLDOWN // Use internal pulldown for filament runout pins.
|
||||
#endif
|
||||
|
||||
// Override individually if the runout sensors vary
|
||||
//#define FIL_RUNOUT1_PULLUP
|
||||
//#define FIL_RUNOUT1_PULLDOWN
|
||||
|
||||
//#define FIL_RUNOUT2_PULLUP
|
||||
//#define FIL_RUNOUT2_PULLDOWN
|
||||
|
||||
//#define FIL_RUNOUT3_PULLUP
|
||||
//#define FIL_RUNOUT3_PULLDOWN
|
||||
|
||||
//#define FIL_RUNOUT4_PULLUP
|
||||
//#define FIL_RUNOUT4_PULLDOWN
|
||||
|
||||
//#define FIL_RUNOUT5_PULLUP
|
||||
//#define FIL_RUNOUT5_PULLDOWN
|
||||
|
||||
//#define FIL_RUNOUT6_PULLUP
|
||||
//#define FIL_RUNOUT6_PULLDOWN
|
||||
|
||||
//#define FIL_RUNOUT7_PULLUP
|
||||
//#define FIL_RUNOUT7_PULLDOWN
|
||||
|
||||
//#define FIL_RUNOUT8_PULLUP
|
||||
//#define FIL_RUNOUT8_PULLDOWN
|
||||
#endif
|
||||
|
||||
//===========================================================================
|
||||
@@ -3194,6 +3302,9 @@
|
||||
//#define MANUAL_I_HOME_POS 0
|
||||
//#define MANUAL_J_HOME_POS 0
|
||||
//#define MANUAL_K_HOME_POS 0
|
||||
//#define MANUAL_U_HOME_POS 0
|
||||
//#define MANUAL_V_HOME_POS 0
|
||||
//#define MANUAL_W_HOME_POS 0
|
||||
|
||||
/**
|
||||
* Use "Z Safe Homing" to avoid homing with a Z probe outside the bed area.
|
||||
@@ -3211,7 +3322,7 @@
|
||||
#define Z_SAFE_HOMING_Y_POINT (Y_BED_SIZE / 2) // Y point for Z homing
|
||||
#endif
|
||||
|
||||
// Homing speeds (mm/min)
|
||||
// Homing speeds (linear=mm/min, rotational=°/min)
|
||||
#define HOMING_FEEDRATE_MM_M { (50*60), (50*60), (10*60) }
|
||||
|
||||
// Validate that endstops are triggered on homing moves
|
||||
@@ -3353,15 +3464,14 @@
|
||||
#define NOZZLE_PARK_FEATURE
|
||||
|
||||
#if ENABLED(NOZZLE_PARK_FEATURE)
|
||||
// Specify a park position as { X, Y, Z }
|
||||
#if(ENABLED(MachineEnder2))
|
||||
#define NOZZLE_PARK_POINT { (0), (0), 10 }
|
||||
#else
|
||||
#define NOZZLE_PARK_POINT { (50), (10), 10 }
|
||||
#endif
|
||||
// Specify a park position as { X, Y, Z_raise }
|
||||
#if(ENABLED(MachineEnder2))
|
||||
#define NOZZLE_PARK_POINT { (0), (0), 10 }
|
||||
#else
|
||||
#define NOZZLE_PARK_POINT { (50), (10), 10 }
|
||||
#endif
|
||||
|
||||
//#define NOZZLE_PARK_X_ONLY // X move only is required to park
|
||||
//#define NOZZLE_PARK_Y_ONLY // Y move only is required to park
|
||||
#define NOZZLE_PARK_MOVE 0 // Park motion: 0 = XY Move, 1 = X Only, 2 = Y Only, 3 = X before Y, 4 = Y before X
|
||||
#define NOZZLE_PARK_Z_RAISE_MIN 2 // (mm) Always raise Z by at least this distance
|
||||
#define NOZZLE_PARK_XY_FEEDRATE 50 // X and Y axes feedrate in mm/s (also used for delta printers Z axis)
|
||||
#define NOZZLE_PARK_Z_FEEDRATE 5 // Z axis feedrate in mm/s (not used for delta printers)
|
||||
@@ -4323,7 +4433,7 @@
|
||||
// Ender-3 v2 OEM display. A DWIN display with Rotary Encoder.
|
||||
//
|
||||
//#define DWIN_CREALITY_LCD // Creality UI
|
||||
//#define DWIN_CREALITY_LCD_ENHANCED // Enhanced UI
|
||||
//#define DWIN_LCD_PROUI // Pro UI by MRiscoC
|
||||
//#define DWIN_CREALITY_LCD_JYERSUI // Jyers UI by Jacob Myers
|
||||
//#define DWIN_MARLINUI_PORTRAIT // MarlinUI (portrait orientation)
|
||||
//#define DWIN_MARLINUI_LANDSCAPE // MarlinUI (landscape orientation)
|
||||
@@ -4336,7 +4446,7 @@
|
||||
#define BUTTON_DELAY_EDIT 50 // (ms) Button repeat delay for edit screens
|
||||
#define BUTTON_DELAY_MENU 250 // (ms) Button repeat delay for menus
|
||||
|
||||
//#define TOUCH_IDLE_SLEEP 300 // (secs) Turn off the TFT backlight if set (5mn)
|
||||
//#define TOUCH_IDLE_SLEEP 300 // (s) Turn off the TFT backlight if set (5mn)
|
||||
|
||||
#define TOUCH_SCREEN_CALIBRATION
|
||||
|
||||
|
||||
+200
-63
@@ -30,7 +30,7 @@
|
||||
*
|
||||
* Basic settings can be found in Configuration.h
|
||||
*/
|
||||
#define CONFIGURATION_ADV_H_VERSION 02000903
|
||||
#define CONFIGURATION_ADV_H_VERSION 02010000
|
||||
|
||||
//===========================================================================
|
||||
//============================= Thermal Settings ============================
|
||||
@@ -368,7 +368,11 @@
|
||||
#endif
|
||||
|
||||
#if ANY(THERMAL_PROTECTION_HOTENDS, THERMAL_PROTECTION_BED, THERMAL_PROTECTION_CHAMBER, THERMAL_PROTECTION_COOLER)
|
||||
//#define THERMAL_PROTECTION_VARIANCE_MONITOR // Detect a sensor malfunction preventing temperature updates
|
||||
/**
|
||||
* Thermal Protection Variance Monitor - EXPERIMENTAL.
|
||||
* Kill the machine on a stuck temperature sensor. Disable if you get false positives.
|
||||
*/
|
||||
//#define THERMAL_PROTECTION_VARIANCE_MONITOR // Detect a sensor malfunction preventing temperature updates
|
||||
#endif
|
||||
|
||||
#if ENABLED(PIDTEMP)
|
||||
@@ -847,18 +851,17 @@
|
||||
*/
|
||||
//#define DUAL_X_CARRIAGE
|
||||
#if ENABLED(DUAL_X_CARRIAGE)
|
||||
#define X1_MIN_POS X_MIN_POS // Set to X_MIN_POS
|
||||
#define X1_MAX_POS X_BED_SIZE // Set a maximum so the first X-carriage can't hit the parked second X-carriage
|
||||
#define X2_MIN_POS 80 // Set a minimum to ensure the second X-carriage can't hit the parked first X-carriage
|
||||
#define X2_MAX_POS 353 // Set this to the distance between toolheads when both heads are homed
|
||||
#define X2_HOME_DIR 1 // Set to 1. The second X-carriage always homes to the maximum endstop position
|
||||
#define X2_HOME_POS X2_MAX_POS // Default X2 home position. Set to X2_MAX_POS.
|
||||
// However: In this mode the HOTEND_OFFSET_X value for the second extruder provides a software
|
||||
// override for X2_HOME_POS. This also allow recalibration of the distance between the two endstops
|
||||
// without modifying the firmware (through the "M218 T1 X???" command).
|
||||
// Remember: you should set the second extruder x-offset to 0 in your slicer.
|
||||
#define X1_MIN_POS X_MIN_POS // Set to X_MIN_POS
|
||||
#define X1_MAX_POS X_BED_SIZE // A max coordinate so the X1 carriage can't hit the parked X2 carriage
|
||||
#define X2_MIN_POS 80 // A min coordinate so the X2 carriage can't hit the parked X1 carriage
|
||||
#define X2_MAX_POS 353 // The max position of the X2 carriage, typically also the home position
|
||||
#define X2_HOME_DIR 1 // Set to 1. The X2 carriage always homes to the max endstop position
|
||||
#define X2_HOME_POS X2_MAX_POS // Default X2 home position. Set to X2_MAX_POS.
|
||||
// NOTE: For Dual X Carriage use M218 T1 Xn to override the X2_HOME_POS.
|
||||
// This allows recalibration of endstops distance without a rebuild.
|
||||
// Remember to set the second extruder's X-offset to 0 in your slicer.
|
||||
|
||||
// This is the default power-up mode which can be later using M605.
|
||||
// This is the default power-up mode which can be changed later using M605 S<mode>.
|
||||
#define DEFAULT_DUAL_X_CARRIAGE_MODE DXC_AUTO_PARK_MODE
|
||||
|
||||
// Default x offset in duplication mode (typically set to half print bed width)
|
||||
@@ -880,12 +883,12 @@
|
||||
* the position of the toolhead relative to the workspace.
|
||||
*/
|
||||
|
||||
//#define SENSORLESS_BACKOFF_MM { 2, 2, 0 } // (mm) Backoff from endstops before sensorless homing
|
||||
//#define SENSORLESS_BACKOFF_MM { 2, 2, 0 } // (linear=mm, rotational=°) Backoff from endstops before sensorless homing
|
||||
|
||||
#define HOMING_BUMP_MM { 8, 8, 2 } // (mm) Backoff from endstops after first bump
|
||||
#define HOMING_BUMP_MM { 8, 8, 2 } // (linear=mm, rotational=°) Backoff from endstops after first bump
|
||||
#define HOMING_BUMP_DIVISOR { 2, 2, 4 } // Re-Bump Speed Divisor (Divides the Homing Feedrate)
|
||||
|
||||
#define HOMING_BACKOFF_POST_MM { 8, 8, 2 } // (mm) Backoff from endstops after homing
|
||||
#define HOMING_BACKOFF_POST_MM { 8, 8, 2 } // (linear=mm, rotational=°) Backoff from endstops after homing
|
||||
|
||||
#if DISABLED(MachineCR30)
|
||||
#define QUICK_HOME // If G28 contains XY do a diagonal move first
|
||||
@@ -1005,15 +1008,17 @@
|
||||
//#define Z_STEPPERS_ORIENTATION 0
|
||||
#endif
|
||||
|
||||
// Provide Z stepper positions for more rapid convergence in bed alignment.
|
||||
// Requires triple stepper drivers (i.e., set NUM_Z_STEPPER_DRIVERS to 3)
|
||||
//#define Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS
|
||||
#if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
|
||||
// Define Stepper XY positions for Z1, Z2, Z3 corresponding to
|
||||
// the Z screw positions in the bed carriage.
|
||||
// Define one position per Z stepper in stepper driver order.
|
||||
#define Z_STEPPER_ALIGN_STEPPER_XY { { 210.7, 102.5 }, { 152.6, 220.0 }, { 94.5, 102.5 } }
|
||||
#else
|
||||
/**
|
||||
* Z Stepper positions for more rapid convergence in bed alignment.
|
||||
* Requires NUM_Z_STEPPER_DRIVERS to be 3 or 4.
|
||||
*
|
||||
* Define Stepper XY positions for Z1, Z2, Z3... corresponding to the screw
|
||||
* positions in the bed carriage, with one position per Z stepper in stepper
|
||||
* driver order.
|
||||
*/
|
||||
//#define Z_STEPPER_ALIGN_STEPPER_XY { { 210.7, 102.5 }, { 152.6, 220.0 }, { 94.5, 102.5 } }
|
||||
|
||||
#ifndef Z_STEPPER_ALIGN_STEPPER_XY
|
||||
// Amplification factor. Used to scale the correction step up or down in case
|
||||
// the stepper (spindle) position is farther out than the test point.
|
||||
#define Z_STEPPER_ALIGN_AMP 1.0 // Use a value > 1.0 NOTE: This may cause instability!
|
||||
@@ -1075,6 +1080,9 @@
|
||||
#define INVERT_I_STEP_PIN false
|
||||
#define INVERT_J_STEP_PIN false
|
||||
#define INVERT_K_STEP_PIN false
|
||||
#define INVERT_U_STEP_PIN false
|
||||
#define INVERT_V_STEP_PIN false
|
||||
#define INVERT_W_STEP_PIN false
|
||||
#define INVERT_E_STEP_PIN false
|
||||
|
||||
/**
|
||||
@@ -1089,6 +1097,9 @@
|
||||
#define DISABLE_INACTIVE_I true
|
||||
#define DISABLE_INACTIVE_J true
|
||||
#define DISABLE_INACTIVE_K true
|
||||
#define DISABLE_INACTIVE_U true
|
||||
#define DISABLE_INACTIVE_V true
|
||||
#define DISABLE_INACTIVE_W true
|
||||
#define DISABLE_INACTIVE_E true
|
||||
|
||||
// If the Nozzle or Bed falls when the Z stepper is disabled, set its resting position here.
|
||||
@@ -1099,8 +1110,8 @@
|
||||
#endif
|
||||
|
||||
// Default Minimum Feedrates for printing and travel moves
|
||||
#define DEFAULT_MINIMUMFEEDRATE 0.0 // (mm/s) Minimum feedrate. Set with M205 S.
|
||||
#define DEFAULT_MINTRAVELFEEDRATE 0.0 // (mm/s) Minimum travel feedrate. Set with M205 T.
|
||||
#define DEFAULT_MINIMUMFEEDRATE 0.0 // (mm/s. °/s for rotational-only moves) Minimum feedrate. Set with M205 S.
|
||||
#define DEFAULT_MINTRAVELFEEDRATE 0.0 // (mm/s. °/s for rotational-only moves) Minimum travel feedrate. Set with M205 T.
|
||||
|
||||
// Minimum time that a segment needs to take as the buffer gets emptied
|
||||
#define DEFAULT_MINSEGMENTTIME 20000 // (µs) Set with M205 B.
|
||||
@@ -1142,7 +1153,7 @@
|
||||
#if ENABLED(BACKLASH_COMPENSATION)
|
||||
// Define values for backlash distance and correction.
|
||||
// If BACKLASH_GCODE is enabled these values are the defaults.
|
||||
#define BACKLASH_DISTANCE_MM { 0, 0, 0 } // (mm) One value for each linear axis
|
||||
#define BACKLASH_DISTANCE_MM { 0, 0, 0 } // (linear=mm, rotational=°) One value for each linear axis
|
||||
#define BACKLASH_CORRECTION 0.0 // 0.0 = no correction; 1.0 = full correction
|
||||
|
||||
// Add steps for motor direction changes on CORE kinematics
|
||||
@@ -1219,6 +1230,12 @@
|
||||
//#define CALIBRATION_MEASURE_JMAX
|
||||
//#define CALIBRATION_MEASURE_KMIN
|
||||
//#define CALIBRATION_MEASURE_KMAX
|
||||
//#define CALIBRATION_MEASURE_UMIN
|
||||
//#define CALIBRATION_MEASURE_UMAX
|
||||
//#define CALIBRATION_MEASURE_VMIN
|
||||
//#define CALIBRATION_MEASURE_VMAX
|
||||
//#define CALIBRATION_MEASURE_WMIN
|
||||
//#define CALIBRATION_MEASURE_WMAX
|
||||
|
||||
// Probing at the exact top center only works if the center is flat. If
|
||||
// probing on a screwhead or hollow washer, probe near the edges.
|
||||
@@ -1339,6 +1356,11 @@
|
||||
#define FEEDRATE_CHANGE_BEEP_FREQUENCY 440
|
||||
#endif
|
||||
|
||||
//
|
||||
// LCD Backlight Timeout
|
||||
//
|
||||
//#define LCD_BACKLIGHT_TIMEOUT 30 // (s) Timeout before turning off the backlight
|
||||
|
||||
#if HAS_BED_PROBE && EITHER(HAS_MARLINUI_MENU, HAS_TFT_LVGL_UI)
|
||||
//#define PROBE_OFFSET_WIZARD // Add a Probe Z Offset calibration option to the LCD menu
|
||||
#if ENABLED(PROBE_OFFSET_WIZARD)
|
||||
@@ -1356,7 +1378,7 @@
|
||||
|
||||
#if HAS_MARLINUI_MENU
|
||||
|
||||
#if BOTH(HAS_BED_PROBE, AUTO_BED_LEVELING_BILINEAR)
|
||||
#if HAS_BED_PROBE
|
||||
// Add calibration in the Probe Offsets menu to compensate for X-axis twist.
|
||||
//#define X_AXIS_TWIST_COMPENSATION
|
||||
#if ENABLED(X_AXIS_TWIST_COMPENSATION)
|
||||
@@ -1368,6 +1390,7 @@
|
||||
#define XATC_START_Z 0.0
|
||||
#define XATC_MAX_POINTS 3 // Number of points to probe in the wizard
|
||||
#define XATC_Y_POSITION Y_CENTER // (mm) Y position to probe
|
||||
#define XATC_Z_OFFSETS { 0, 0, 0 } // Z offsets for X axis sample points
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1387,18 +1410,18 @@
|
||||
|
||||
#endif // HAS_MARLINUI_MENU
|
||||
|
||||
#if ANY(HAS_DISPLAY, DWIN_CREALITY_LCD_ENHANCED, DWIN_CREALITY_LCD_JYERSUI)
|
||||
#if ANY(HAS_DISPLAY, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI)
|
||||
//#define SOUND_MENU_ITEM // Add a mute option to the LCD menu
|
||||
#endif
|
||||
|
||||
#if EITHER(HAS_DISPLAY, DWIN_CREALITY_LCD_ENHANCED)
|
||||
// The timeout (in ms) to return to the status screen from sub-menus
|
||||
//#define LCD_TIMEOUT_TO_STATUS 15000
|
||||
#if EITHER(HAS_DISPLAY, DWIN_LCD_PROUI)
|
||||
// The timeout to return to the status screen from sub-menus
|
||||
//#define LCD_TIMEOUT_TO_STATUS 15000 // (ms)
|
||||
|
||||
#if ENABLED(SHOW_BOOTSCREEN)
|
||||
#define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s)
|
||||
#define BOOTSCREEN_TIMEOUT 4000 // (ms) Total Duration to display the boot screen(s)
|
||||
#if EITHER(HAS_MARLINUI_U8GLIB, TFT_COLOR_UI)
|
||||
#define BOOT_MARLIN_LOGO_SMALL // Show a smaller Marlin logo on the Boot Screen (saving lots of flash)
|
||||
#define BOOT_MARLIN_LOGO_SMALL // Show a smaller Marlin logo on the Boot Screen (saving lots of flash)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1407,6 +1430,9 @@
|
||||
#define STATUS_MESSAGE_SCROLLING
|
||||
#endif
|
||||
|
||||
// Apply a timeout to low-priority status messages
|
||||
//#define STATUS_MESSAGE_TIMEOUT_SEC 30 // (seconds)
|
||||
|
||||
// On the Info Screen, display XY with one decimal place when possible
|
||||
//#define LCD_DECIMAL_SMALL_XY
|
||||
|
||||
@@ -1711,7 +1737,10 @@
|
||||
// Enable if SD detect is rendered useless (e.g., by using an SD extender)
|
||||
//#define NO_SD_DETECT
|
||||
|
||||
// Multiple volume support - EXPERIMENTAL.
|
||||
/**
|
||||
* Multiple volume support - EXPERIMENTAL.
|
||||
* Adds 'M21 Pm' / 'M21 S' / 'M21 U' to mount SD Card / USB Drive.
|
||||
*/
|
||||
//#define MULTI_VOLUME
|
||||
#if ENABLED(MULTI_VOLUME)
|
||||
#define VOLUME_SD_ONBOARD
|
||||
@@ -2107,6 +2136,21 @@
|
||||
|
||||
// @section leveling
|
||||
|
||||
/**
|
||||
* Use Safe Bed Leveling coordinates to move axes to a useful position before bed probing.
|
||||
* For example, after homing a rotational axis the Z probe might not be perpendicular to the bed.
|
||||
* Choose values the orient the bed horizontally and the Z-probe vertically.
|
||||
*/
|
||||
//#define SAFE_BED_LEVELING_START_X 0.0
|
||||
//#define SAFE_BED_LEVELING_START_Y 0.0
|
||||
//#define SAFE_BED_LEVELING_START_Z 0.0
|
||||
//#define SAFE_BED_LEVELING_START_I 0.0
|
||||
//#define SAFE_BED_LEVELING_START_J 0.0
|
||||
//#define SAFE_BED_LEVELING_START_K 0.0
|
||||
//#define SAFE_BED_LEVELING_START_U 0.0
|
||||
//#define SAFE_BED_LEVELING_START_V 0.0
|
||||
//#define SAFE_BED_LEVELING_START_W 0.0
|
||||
|
||||
/**
|
||||
* Points to probe for all 3-point Leveling procedures.
|
||||
* Override if the automatically selected points are inadequate.
|
||||
@@ -2471,6 +2515,15 @@
|
||||
// For serial echo, the number of digits after the decimal point
|
||||
//#define SERIAL_FLOAT_PRECISION 4
|
||||
|
||||
/**
|
||||
* Set the number of proportional font spaces required to fill up a typical character space.
|
||||
* This can help to better align the output of commands like `G29 O` Mesh Output.
|
||||
*
|
||||
* For clients that use a fixed-width font (like OctoPrint), leave this set to 1.0.
|
||||
* Otherwise, adjust according to your client and font.
|
||||
*/
|
||||
#define PROPORTIONAL_FONT_RATIO 1.0
|
||||
|
||||
// @section extras
|
||||
|
||||
/**
|
||||
@@ -2535,7 +2588,7 @@
|
||||
|
||||
/**
|
||||
* Extra G-code to run while executing tool-change commands. Can be used to use an additional
|
||||
* stepper motor (I axis, see option LINEAR_AXES in Configuration.h) to drive the tool-changer.
|
||||
* stepper motor (I axis, see option NUM_AXES in Configuration.h) to drive the tool-changer.
|
||||
*/
|
||||
//#define EVENT_GCODE_TOOLCHANGE_T0 "G28 A\nG1 A0" // Extra G-code to run while executing tool-change command T0
|
||||
//#define EVENT_GCODE_TOOLCHANGE_T1 "G1 A10" // Extra G-code to run while executing tool-change command T1
|
||||
@@ -2555,7 +2608,7 @@
|
||||
#if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
|
||||
// Load / Unload
|
||||
#define TOOLCHANGE_FS_LENGTH 80 // (mm) Load / Unload length
|
||||
#define TOOLCHANGE_FS_EXTRA_RESUME_LENGTH 0 // (mm) Extra length for better restart, fine tune by LCD/Gcode)
|
||||
#define TOOLCHANGE_FS_EXTRA_RESUME_LENGTH 0 // (mm) Extra length for better restart. Adjust with LCD or M217 B.
|
||||
#define TOOLCHANGE_FS_RETRACT_SPEED (50*60) // (mm/min) (Unloading)
|
||||
#define TOOLCHANGE_FS_UNRETRACT_SPEED (25*60) // (mm/min) (On SINGLENOZZLE or Bowden loading must be slowed down)
|
||||
|
||||
@@ -2569,12 +2622,12 @@
|
||||
#define TOOLCHANGE_FS_FAN_SPEED 255 // 0-255
|
||||
#define TOOLCHANGE_FS_FAN_TIME 10 // (seconds)
|
||||
|
||||
// Swap uninitialized extruder with TOOLCHANGE_FS_PRIME_SPEED for all lengths (recover + prime)
|
||||
// Swap uninitialized extruder (using TOOLCHANGE_FS_PRIME_SPEED feedrate)
|
||||
// (May break filament if not retracted beforehand.)
|
||||
//#define TOOLCHANGE_FS_INIT_BEFORE_SWAP
|
||||
|
||||
// Prime on the first T0 (If other, TOOLCHANGE_FS_INIT_BEFORE_SWAP applied)
|
||||
// Enable it (M217 V[0/1]) before printing, to avoid unwanted priming on host connect
|
||||
// Prime on the first T0 (For other tools use TOOLCHANGE_FS_INIT_BEFORE_SWAP)
|
||||
// Enable with M217 V1 before printing to avoid unwanted priming on host connect
|
||||
//#define TOOLCHANGE_FS_PRIME_FIRST_USED
|
||||
|
||||
/**
|
||||
@@ -2756,6 +2809,24 @@
|
||||
#define K_MICROSTEPS 16
|
||||
#endif
|
||||
|
||||
#if AXIS_DRIVER_TYPE_U(TMC26X)
|
||||
#define U_MAX_CURRENT 1000
|
||||
#define U_SENSE_RESISTOR 91
|
||||
#define U_MICROSTEPS 16
|
||||
#endif
|
||||
|
||||
#if AXIS_DRIVER_TYPE_V(TMC26X)
|
||||
#define V_MAX_CURRENT 1000
|
||||
#define V_SENSE_RESISTOR 91
|
||||
#define V_MICROSTEPS 16
|
||||
#endif
|
||||
|
||||
#if AXIS_DRIVER_TYPE_W(TMC26X)
|
||||
#define W_MAX_CURRENT 1000
|
||||
#define W_SENSE_RESISTOR 91
|
||||
#define W_MICROSTEPS 16
|
||||
#endif
|
||||
|
||||
#if AXIS_DRIVER_TYPE_E0(TMC26X)
|
||||
#define E0_MAX_CURRENT 1000
|
||||
#define E0_SENSE_RESISTOR 91
|
||||
@@ -2944,6 +3015,33 @@
|
||||
//#define K_HOLD_MULTIPLIER 0.5
|
||||
#endif
|
||||
|
||||
#if AXIS_IS_TMC(U)
|
||||
#define U_CURRENT 800
|
||||
#define U_CURRENT_HOME U_CURRENT
|
||||
#define U_MICROSTEPS 8
|
||||
#define U_RSENSE 0.11
|
||||
#define U_CHAIN_POS -1
|
||||
//#define U_INTERPOLATE true
|
||||
#endif
|
||||
|
||||
#if AXIS_IS_TMC(V)
|
||||
#define V_CURRENT 800
|
||||
#define V_CURRENT_HOME V_CURRENT
|
||||
#define V_MICROSTEPS 8
|
||||
#define V_RSENSE 0.11
|
||||
#define V_CHAIN_POS -1
|
||||
//#define V_INTERPOLATE true
|
||||
#endif
|
||||
|
||||
#if AXIS_IS_TMC(W)
|
||||
#define W_CURRENT 800
|
||||
#define W_CURRENT_HOME W_CURRENT
|
||||
#define W_MICROSTEPS 8
|
||||
#define W_RSENSE 0.11
|
||||
#define W_CHAIN_POS -1
|
||||
//#define W_INTERPOLATE true
|
||||
#endif
|
||||
|
||||
#if AXIS_IS_TMC(E0)
|
||||
#define E0_CURRENT 730
|
||||
#define E0_MICROSTEPS 16
|
||||
@@ -3031,6 +3129,9 @@
|
||||
//#define I_CS_PIN -1
|
||||
//#define J_CS_PIN -1
|
||||
//#define K_CS_PIN -1
|
||||
//#define U_CS_PIN -1
|
||||
//#define V_CS_PIN -1
|
||||
//#define W_CS_PIN -1
|
||||
//#define E0_CS_PIN -1
|
||||
//#define E1_CS_PIN -1
|
||||
//#define E2_CS_PIN -1
|
||||
@@ -3081,6 +3182,9 @@
|
||||
//#define I_SLAVE_ADDRESS 0
|
||||
//#define J_SLAVE_ADDRESS 0
|
||||
//#define K_SLAVE_ADDRESS 0
|
||||
//#define U_SLAVE_ADDRESS 0
|
||||
//#define V_SLAVE_ADDRESS 0
|
||||
//#define W_SLAVE_ADDRESS 0
|
||||
//#define E0_SLAVE_ADDRESS 0
|
||||
//#define E1_SLAVE_ADDRESS 0
|
||||
//#define E2_SLAVE_ADDRESS 0
|
||||
@@ -3109,6 +3213,9 @@
|
||||
#define STEALTHCHOP_I
|
||||
#define STEALTHCHOP_J
|
||||
#define STEALTHCHOP_K
|
||||
#define STEALTHCHOP_U
|
||||
#define STEALTHCHOP_V
|
||||
#define STEALTHCHOP_W
|
||||
//#define STEALTHCHOP_E
|
||||
|
||||
/**
|
||||
@@ -3135,9 +3242,12 @@
|
||||
//#define CHOPPER_TIMING_Z2 CHOPPER_TIMING_Z
|
||||
//#define CHOPPER_TIMING_Z3 CHOPPER_TIMING_Z
|
||||
//#define CHOPPER_TIMING_Z4 CHOPPER_TIMING_Z
|
||||
//#define CHOPPER_TIMING_I CHOPPER_TIMING
|
||||
//#define CHOPPER_TIMING_J CHOPPER_TIMING
|
||||
//#define CHOPPER_TIMING_K CHOPPER_TIMING
|
||||
//#define CHOPPER_TIMING_I CHOPPER_TIMING // For I Axis
|
||||
//#define CHOPPER_TIMING_J CHOPPER_TIMING // For J Axis
|
||||
//#define CHOPPER_TIMING_K CHOPPER_TIMING // For K Axis
|
||||
//#define CHOPPER_TIMING_U CHOPPER_TIMING // For U Axis
|
||||
//#define CHOPPER_TIMING_V CHOPPER_TIMING // For V Axis
|
||||
//#define CHOPPER_TIMING_W CHOPPER_TIMING // For W Axis
|
||||
//#define CHOPPER_TIMING_E CHOPPER_TIMING // For Extruders (override below)
|
||||
//#define CHOPPER_TIMING_E1 CHOPPER_TIMING_E
|
||||
//#define CHOPPER_TIMING_E2 CHOPPER_TIMING_E
|
||||
@@ -3185,9 +3295,12 @@
|
||||
#define Z2_HYBRID_THRESHOLD 10
|
||||
#define Z3_HYBRID_THRESHOLD 3
|
||||
#define Z4_HYBRID_THRESHOLD 3
|
||||
#define I_HYBRID_THRESHOLD 3
|
||||
#define J_HYBRID_THRESHOLD 3
|
||||
#define K_HYBRID_THRESHOLD 3
|
||||
#define I_HYBRID_THRESHOLD 3 // [linear=mm/s, rotational=°/s]
|
||||
#define J_HYBRID_THRESHOLD 3 // [linear=mm/s, rotational=°/s]
|
||||
#define K_HYBRID_THRESHOLD 3 // [linear=mm/s, rotational=°/s]
|
||||
#define U_HYBRID_THRESHOLD 3 // [mm/s]
|
||||
#define V_HYBRID_THRESHOLD 3
|
||||
#define W_HYBRID_THRESHOLD 3
|
||||
#define E0_HYBRID_THRESHOLD 30
|
||||
#define E1_HYBRID_THRESHOLD 30
|
||||
#define E2_HYBRID_THRESHOLD 30
|
||||
@@ -3237,6 +3350,9 @@
|
||||
//#define I_STALL_SENSITIVITY 8
|
||||
//#define J_STALL_SENSITIVITY 8
|
||||
//#define K_STALL_SENSITIVITY 8
|
||||
//#define U_STALL_SENSITIVITY 8
|
||||
//#define V_STALL_SENSITIVITY 8
|
||||
//#define W_STALL_SENSITIVITY 8
|
||||
//#define SPI_ENDSTOPS // TMC2130 only
|
||||
//#define IMPROVE_HOMING_RELIABILITY
|
||||
#endif
|
||||
@@ -3406,6 +3522,33 @@
|
||||
#define K_SLEW_RATE 1
|
||||
#endif
|
||||
|
||||
#if AXIS_IS_L64XX(U)
|
||||
#define U_MICROSTEPS 128
|
||||
#define U_OVERCURRENT 2000
|
||||
#define U_STALLCURRENT 1500
|
||||
#define U_MAX_VOLTAGE 127
|
||||
#define U_CHAIN_POS -1
|
||||
#define U_SLEW_RATE 1
|
||||
#endif
|
||||
|
||||
#if AXIS_IS_L64XX(V)
|
||||
#define V_MICROSTEPS 128
|
||||
#define V_OVERCURRENT 2000
|
||||
#define V_STALLCURRENT 1500
|
||||
#define V_MAX_VOLTAGE 127
|
||||
#define V_CHAIN_POS -1
|
||||
#define V_SLEW_RATE 1
|
||||
#endif
|
||||
|
||||
#if AXIS_IS_L64XX(W)
|
||||
#define W_MICROSTEPS 128
|
||||
#define W_OVERCURRENT 2000
|
||||
#define W_STALLCURRENT 1500
|
||||
#define W_MAX_VOLTAGE 127
|
||||
#define W_CHAIN_POS -1
|
||||
#define W_SLEW_RATE 1
|
||||
#endif
|
||||
|
||||
#if AXIS_IS_L64XX(E0)
|
||||
#define E0_MICROSTEPS 128
|
||||
#define E0_OVERCURRENT 2000
|
||||
@@ -3600,7 +3743,7 @@
|
||||
* You'll need to select a pin for the ON/OFF function and optionally choose a 0-5V
|
||||
* hardware PWM pin for the speed control and a pin for the rotation direction.
|
||||
*
|
||||
* See https://marlinfw.org/docs/configuration/laser_spindle.html for more config details.
|
||||
* See https://marlinfw.org/docs/configuration/2.0.9/laser_spindle.html for more config details.
|
||||
*/
|
||||
//#define SPINDLE_FEATURE
|
||||
//#define LASER_FEATURE
|
||||
@@ -3610,7 +3753,7 @@
|
||||
#define SPINDLE_LASER_USE_PWM // Enable if your controller supports setting the speed/power
|
||||
#if ENABLED(SPINDLE_LASER_USE_PWM)
|
||||
#define SPINDLE_LASER_PWM_INVERT false // Set to "true" if the speed/power goes up when you want it to go slower
|
||||
#define SPINDLE_LASER_FREQUENCY 2500 // (Hz) Spindle/laser frequency (only on supported HALs: AVR and LPC)
|
||||
#define SPINDLE_LASER_FREQUENCY 2500 // (Hz) Spindle/laser frequency (only on supported HALs: AVR, ESP32, and LPC)
|
||||
#endif
|
||||
|
||||
//#define AIR_EVACUATION // Cutter Vacuum / Laser Blower motor control with G-codes M10-M11
|
||||
@@ -3952,15 +4095,6 @@
|
||||
|
||||
//#define REPORT_FAN_CHANGE // Report the new fan speed when changed by M106 (and others)
|
||||
|
||||
/**
|
||||
* Set the number of proportional font spaces required to fill up a typical character space.
|
||||
* This can help to better align the output of commands like `G29 O` Mesh Output.
|
||||
*
|
||||
* For clients that use a fixed-width font (like OctoPrint), leave this set to 1.0.
|
||||
* Otherwise, adjust according to your client and font.
|
||||
*/
|
||||
#define PROPORTIONAL_FONT_RATIO 1.0
|
||||
|
||||
/**
|
||||
* Spend 28 bytes of SRAM to optimize the G-code parser
|
||||
*/
|
||||
@@ -4145,12 +4279,15 @@
|
||||
*/
|
||||
#define HOST_ACTION_COMMANDS
|
||||
#if ENABLED(HOST_ACTION_COMMANDS)
|
||||
//#define HOST_PAUSE_M76
|
||||
//#define HOST_PAUSE_M76 // Tell the host to pause in response to M76
|
||||
#if DISABLED(MachineCR10Orig) || ENABLED(MelziHostOnly)
|
||||
#define HOST_PROMPT_SUPPORT
|
||||
#define HOST_PROMPT_SUPPORT // Initiate host prompts to get user feedback
|
||||
#endif
|
||||
#define HOST_START_MENU_ITEM // Add a menu item that tells the host to start
|
||||
//#define HOST_SHUTDOWN_MENU_ITEM // Add a menu item that tells the host to shut down
|
||||
#if ENABLED(HOST_PROMPT_SUPPORT)
|
||||
#define HOST_STATUS_NOTIFICATIONS // Send some status messages to the host as notifications
|
||||
#endif
|
||||
#define HOST_START_MENU_ITEM // Add a menu item that tells the host to start
|
||||
//#define HOST_SHUTDOWN_MENU_ITEM // Add a menu item that tells the host to shut down
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -4287,12 +4424,12 @@
|
||||
|
||||
/**
|
||||
* Instant freeze / unfreeze functionality
|
||||
* Specified pin has pullup and connecting to ground will instantly pause motion.
|
||||
* Potentially useful for emergency stop that allows being resumed.
|
||||
*/
|
||||
//#define FREEZE_FEATURE
|
||||
#if ENABLED(FREEZE_FEATURE)
|
||||
//#define FREEZE_PIN 41 // Override the default (KILL) pin here
|
||||
#define FREEZE_STATE LOW // State of pin indicating freeze
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -132,7 +132,7 @@ CC_MIN:=$(shell $(CC) -dM -E - < /dev/null | grep __GNUC_MINOR__ | cut -f3 -d\ )
|
||||
CC_PATCHLEVEL:=$(shell $(CC) -dM -E - < /dev/null | grep __GNUC_PATCHLEVEL__ | cut -f3 -d\ )
|
||||
CC_VER:=$(shell echo $$(( $(CC_MAJ) * 10000 + $(CC_MIN) * 100 + $(CC_PATCHLEVEL) )))
|
||||
ifeq ($(shell test $(CC_VER) -lt 40901 && echo 1),1)
|
||||
@echo This version of GCC is likely broken. Enabling relocation workaround.
|
||||
$(warning This GCC version $(CC_VER) is likely broken. Enabling relocation workaround.)
|
||||
RELOC_WORKAROUND = 1
|
||||
endif
|
||||
|
||||
|
||||
+1
-1
@@ -131,7 +131,7 @@
|
||||
* here we define this default string as the date where the latest release
|
||||
* version was tagged.
|
||||
*/
|
||||
#define STRING_DISTRIBUTION_DATE "2022-02-05"
|
||||
#define STRING_DISTRIBUTION_DATE "2022-04-03"
|
||||
|
||||
/**
|
||||
* Defines a generic printer name to be output to the LCD after booting Marlin.
|
||||
|
||||
+19
-19
@@ -36,7 +36,7 @@
|
||||
// ------------------------
|
||||
|
||||
// Don't initialize/override variable (which would happen in .init4)
|
||||
uint8_t reset_reason __attribute__((section(".noinit")));
|
||||
uint8_t MarlinHAL::reset_reason __attribute__((section(".noinit")));
|
||||
|
||||
// ------------------------
|
||||
// Public functions
|
||||
@@ -45,22 +45,22 @@ uint8_t reset_reason __attribute__((section(".noinit")));
|
||||
__attribute__((naked)) // Don't output function pro- and epilogue
|
||||
__attribute__((used)) // Output the function, even if "not used"
|
||||
__attribute__((section(".init3"))) // Put in an early user definable section
|
||||
void HAL_save_reset_reason() {
|
||||
void save_reset_reason() {
|
||||
#if ENABLED(OPTIBOOT_RESET_REASON)
|
||||
__asm__ __volatile__(
|
||||
A("STS %0, r2")
|
||||
: "=m"(reset_reason)
|
||||
: "=m"(hal.reset_reason)
|
||||
);
|
||||
#else
|
||||
reset_reason = MCUSR;
|
||||
hal.reset_reason = MCUSR;
|
||||
#endif
|
||||
|
||||
// Clear within 16ms since WDRF bit enables a 16ms watchdog timer -> Boot loop
|
||||
MCUSR = 0;
|
||||
hal.clear_reset_source();
|
||||
wdt_disable();
|
||||
}
|
||||
|
||||
void HAL_init() {
|
||||
void MarlinHAL::init() {
|
||||
// Init Servo Pins
|
||||
#define INIT_SERVO(N) OUT_WRITE(SERVO##N##_PIN, LOW)
|
||||
#if HAS_SERVO_0
|
||||
@@ -79,7 +79,7 @@ void HAL_init() {
|
||||
init_pwm_timers(); // Init user timers to default frequency - 1000HZ
|
||||
}
|
||||
|
||||
void HAL_reboot() {
|
||||
void MarlinHAL::reboot() {
|
||||
#if ENABLED(USE_WATCHDOG)
|
||||
while (1) { /* run out the watchdog */ }
|
||||
#else
|
||||
@@ -95,20 +95,20 @@ void HAL_reboot() {
|
||||
|
||||
#else // !SDSUPPORT
|
||||
|
||||
extern "C" {
|
||||
extern char __bss_end;
|
||||
extern char __heap_start;
|
||||
extern void* __brkval;
|
||||
extern "C" {
|
||||
extern char __bss_end;
|
||||
extern char __heap_start;
|
||||
extern void* __brkval;
|
||||
|
||||
int freeMemory() {
|
||||
int free_memory;
|
||||
if ((int)__brkval == 0)
|
||||
free_memory = ((int)&free_memory) - ((int)&__bss_end);
|
||||
else
|
||||
free_memory = ((int)&free_memory) - ((int)__brkval);
|
||||
return free_memory;
|
||||
int freeMemory() {
|
||||
int free_memory;
|
||||
if ((int)__brkval == 0)
|
||||
free_memory = ((int)&free_memory) - ((int)&__bss_end);
|
||||
else
|
||||
free_memory = ((int)&free_memory) - ((int)__brkval);
|
||||
return free_memory;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // !SDSUPPORT
|
||||
|
||||
|
||||
+117
-81
@@ -74,9 +74,9 @@
|
||||
#define CRITICAL_SECTION_START() unsigned char _sreg = SREG; cli()
|
||||
#define CRITICAL_SECTION_END() SREG = _sreg
|
||||
#endif
|
||||
#define ISRS_ENABLED() TEST(SREG, SREG_I)
|
||||
#define ENABLE_ISRS() sei()
|
||||
#define DISABLE_ISRS() cli()
|
||||
|
||||
#define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment
|
||||
#define PWM_FREQUENCY 1000 // Default PWM frequency when set_pwm_duty() is called without set_pwm_frequency()
|
||||
|
||||
// ------------------------
|
||||
// Types
|
||||
@@ -84,16 +84,15 @@
|
||||
|
||||
typedef int8_t pin_t;
|
||||
|
||||
#define SHARED_SERVOS HAS_SERVOS
|
||||
#define HAL_SERVO_LIB Servo
|
||||
#define SHARED_SERVOS HAS_SERVOS // Use shared/servos.cpp
|
||||
|
||||
class Servo;
|
||||
typedef Servo hal_servo_t;
|
||||
|
||||
// ------------------------
|
||||
// Public Variables
|
||||
// ------------------------
|
||||
|
||||
extern uint8_t reset_reason;
|
||||
|
||||
// Serial ports
|
||||
// ------------------------
|
||||
|
||||
#ifdef USBCON
|
||||
#include "../../core/serial_hook.h"
|
||||
typedef ForwardSerial1Class< decltype(Serial) > DefaultSerial1;
|
||||
@@ -142,57 +141,15 @@ extern uint8_t reset_reason;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// ------------------------
|
||||
|
||||
void HAL_init();
|
||||
|
||||
//void cli();
|
||||
|
||||
//void _delay_ms(const int delay);
|
||||
|
||||
inline void HAL_clear_reset_source() { }
|
||||
inline uint8_t HAL_get_reset_source() { return reset_reason; }
|
||||
|
||||
void HAL_reboot();
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#if GCC_VERSION <= 50000
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#endif
|
||||
|
||||
extern "C" int freeMemory();
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
//
|
||||
// ADC
|
||||
#ifdef DIDR2
|
||||
#define HAL_ANALOG_SELECT(ind) do{ if (ind < 8) SBI(DIDR0, ind); else SBI(DIDR2, ind & 0x07); }while(0)
|
||||
#else
|
||||
#define HAL_ANALOG_SELECT(ind) SBI(DIDR0, ind);
|
||||
#endif
|
||||
|
||||
inline void HAL_adc_init() {
|
||||
ADCSRA = _BV(ADEN) | _BV(ADSC) | _BV(ADIF) | 0x07;
|
||||
DIDR0 = 0;
|
||||
#ifdef DIDR2
|
||||
DIDR2 = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#define SET_ADMUX_ADCSRA(ch) ADMUX = _BV(REFS0) | (ch & 0x07); SBI(ADCSRA, ADSC)
|
||||
#ifdef MUX5
|
||||
#define HAL_START_ADC(ch) if (ch > 7) ADCSRB = _BV(MUX5); else ADCSRB = 0; SET_ADMUX_ADCSRA(ch)
|
||||
#else
|
||||
#define HAL_START_ADC(ch) ADCSRB = 0; SET_ADMUX_ADCSRA(ch)
|
||||
#endif
|
||||
|
||||
//
|
||||
#define HAL_ADC_VREF 5.0
|
||||
#define HAL_ADC_RESOLUTION 10
|
||||
#define HAL_READ_ADC() ADC
|
||||
#define HAL_ADC_READY() !TEST(ADCSRA, ADSC)
|
||||
|
||||
//
|
||||
// Pin Mapping for M42, M43, M226
|
||||
//
|
||||
#define GET_PIN_MAP_PIN(index) index
|
||||
#define GET_PIN_MAP_INDEX(pin) pin
|
||||
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
|
||||
@@ -206,30 +163,109 @@ inline void HAL_adc_init() {
|
||||
// AVR compatibility
|
||||
#define strtof strtod
|
||||
|
||||
#define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment
|
||||
#define PWM_FREQUENCY 1000 // Default PWM frequency when set_pwm_duty() is called without set_pwm_frequency()
|
||||
// ------------------------
|
||||
// Class Utilities
|
||||
// ------------------------
|
||||
|
||||
/**
|
||||
* set_pwm_frequency
|
||||
* Sets the frequency of the timer corresponding to the provided pin
|
||||
* as close as possible to the provided desired frequency. Internally
|
||||
* calculates the required waveform generation mode, prescaler and
|
||||
* resolution values required and sets the timer registers accordingly.
|
||||
* NOTE that the frequency is applied to all pins on the timer (Ex OC3A, OC3B and OC3B)
|
||||
* NOTE that there are limitations, particularly if using TIMER2. (see Configuration_adv.h -> FAST FAN PWM Settings)
|
||||
*/
|
||||
void set_pwm_frequency(const pin_t pin, const uint16_t f_desired);
|
||||
#pragma GCC diagnostic push
|
||||
#if GCC_VERSION <= 50000
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* set_pwm_duty
|
||||
* Set the PWM duty cycle of the provided pin to the provided value
|
||||
* Optionally allows inverting the duty cycle [default = false]
|
||||
* Optionally allows changing the maximum size of the provided value to enable finer PWM duty control [default = 255]
|
||||
*/
|
||||
void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false);
|
||||
extern "C" int freeMemory();
|
||||
|
||||
/*
|
||||
* init_pwm_timers
|
||||
* sets the default frequency for timers 2-5 to 1000HZ
|
||||
*/
|
||||
void init_pwm_timers();
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
// ------------------------
|
||||
// MarlinHAL Class
|
||||
// ------------------------
|
||||
|
||||
class MarlinHAL {
|
||||
public:
|
||||
|
||||
// Earliest possible init, before setup()
|
||||
MarlinHAL() {}
|
||||
|
||||
static void init(); // Called early in setup()
|
||||
static void init_board() {} // Called less early in setup()
|
||||
static void reboot(); // Restart the firmware from 0x0
|
||||
|
||||
// Interrupts
|
||||
static bool isr_state() { return TEST(SREG, SREG_I); }
|
||||
static void isr_on() { sei(); }
|
||||
static void isr_off() { cli(); }
|
||||
|
||||
static void delay_ms(const int ms) { _delay_ms(ms); }
|
||||
|
||||
// Tasks, called from idle()
|
||||
static void idletask() {}
|
||||
|
||||
// Reset
|
||||
static uint8_t reset_reason;
|
||||
static uint8_t get_reset_source() { return reset_reason; }
|
||||
static void clear_reset_source() { MCUSR = 0; }
|
||||
|
||||
// Free SRAM
|
||||
static int freeMemory() { return ::freeMemory(); }
|
||||
|
||||
//
|
||||
// ADC Methods
|
||||
//
|
||||
|
||||
// Called by Temperature::init once at startup
|
||||
static void adc_init() {
|
||||
ADCSRA = _BV(ADEN) | _BV(ADSC) | _BV(ADIF) | 0x07;
|
||||
DIDR0 = 0;
|
||||
#ifdef DIDR2
|
||||
DIDR2 = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Called by Temperature::init for each sensor at startup
|
||||
static void adc_enable(const uint8_t ch) {
|
||||
#ifdef DIDR2
|
||||
if (ch > 7) { SBI(DIDR2, ch & 0x07); return; }
|
||||
#endif
|
||||
SBI(DIDR0, ch);
|
||||
}
|
||||
|
||||
// Begin ADC sampling on the given channel
|
||||
static void adc_start(const uint8_t ch) {
|
||||
#ifdef MUX5
|
||||
ADCSRB = ch > 7 ? _BV(MUX5) : 0;
|
||||
#else
|
||||
ADCSRB = 0;
|
||||
#endif
|
||||
ADMUX = _BV(REFS0) | (ch & 0x07);
|
||||
SBI(ADCSRA, ADSC);
|
||||
}
|
||||
|
||||
// Is the ADC ready for reading?
|
||||
static bool adc_ready() { return !TEST(ADCSRA, ADSC); }
|
||||
|
||||
// The current value of the ADC register
|
||||
static __typeof__(ADC) adc_value() { return ADC; }
|
||||
|
||||
/**
|
||||
* init_pwm_timers
|
||||
* Set the default frequency for timers 2-5 to 1000HZ
|
||||
*/
|
||||
static void init_pwm_timers();
|
||||
|
||||
/**
|
||||
* Set the PWM duty cycle for the pin to the given value.
|
||||
* Optionally invert the duty cycle [default = false]
|
||||
* Optionally change the scale of the provided value to enable finer PWM duty control [default = 255]
|
||||
*/
|
||||
static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false);
|
||||
|
||||
/**
|
||||
* Set the frequency of the timer for the given pin as close as
|
||||
* possible to the provided desired frequency. Internally calculate
|
||||
* the required waveform generation mode, prescaler, and resolution
|
||||
* values and set timer registers accordingly.
|
||||
* NOTE that the frequency is applied to all pins on the timer (Ex OC3A, OC3B and OC3B)
|
||||
* NOTE that there are limitations, particularly if using TIMER2. (see Configuration_adv.h -> FAST_PWM_FAN Settings)
|
||||
*/
|
||||
static void set_pwm_frequency(const pin_t pin, const uint16_t f_desired);
|
||||
};
|
||||
|
||||
@@ -486,7 +486,7 @@ void MarlinSerial<Cfg>::write(const uint8_t c) {
|
||||
const uint8_t i = (tx_buffer.head + 1) & (Cfg::TX_SIZE - 1);
|
||||
|
||||
// If global interrupts are disabled (as the result of being called from an ISR)...
|
||||
if (!ISRS_ENABLED()) {
|
||||
if (!hal.isr_state()) {
|
||||
|
||||
// Make room by polling if it is possible to transmit, and do so!
|
||||
while (i == tx_buffer.tail) {
|
||||
@@ -534,7 +534,7 @@ void MarlinSerial<Cfg>::flushTX() {
|
||||
if (!_written) return;
|
||||
|
||||
// If global interrupts are disabled (as the result of being called from an ISR)...
|
||||
if (!ISRS_ENABLED()) {
|
||||
if (!hal.isr_state()) {
|
||||
|
||||
// Wait until everything was transmitted - We must do polling, as interrupts are disabled
|
||||
while (tx_buffer.head != tx_buffer.tail || !B_TXC) {
|
||||
|
||||
@@ -191,13 +191,13 @@
|
||||
rx_framing_errors;
|
||||
static ring_buffer_pos_t rx_max_enqueued;
|
||||
|
||||
static FORCE_INLINE ring_buffer_pos_t atomic_read_rx_head();
|
||||
FORCE_INLINE static ring_buffer_pos_t atomic_read_rx_head();
|
||||
|
||||
static volatile bool rx_tail_value_not_stable;
|
||||
static volatile uint16_t rx_tail_value_backup;
|
||||
|
||||
static FORCE_INLINE void atomic_set_rx_tail(ring_buffer_pos_t value);
|
||||
static FORCE_INLINE ring_buffer_pos_t atomic_read_rx_tail();
|
||||
FORCE_INLINE static void atomic_set_rx_tail(ring_buffer_pos_t value);
|
||||
FORCE_INLINE static ring_buffer_pos_t atomic_read_rx_tail();
|
||||
|
||||
public:
|
||||
FORCE_INLINE static void store_rxd_char();
|
||||
|
||||
@@ -213,6 +213,51 @@ void setup_endstop_interrupts() {
|
||||
pciSetup(K_MIN_PIN);
|
||||
#endif
|
||||
#endif
|
||||
#if HAS_U_MAX
|
||||
#if (digitalPinToInterrupt(U_MAX_PIN) != NOT_AN_INTERRUPT)
|
||||
_ATTACH(U_MAX_PIN);
|
||||
#else
|
||||
static_assert(digitalPinHasPCICR(U_MAX_PIN), "U_MAX_PIN is not interrupt-capable");
|
||||
pciSetup(U_MAX_PIN);
|
||||
#endif
|
||||
#elif HAS_U_MIN
|
||||
#if (digitalPinToInterrupt(U_MIN_PIN) != NOT_AN_INTERRUPT)
|
||||
_ATTACH(U_MIN_PIN);
|
||||
#else
|
||||
static_assert(digitalPinHasPCICR(U_MIN_PIN), "U_MIN_PIN is not interrupt-capable");
|
||||
pciSetup(U_MIN_PIN);
|
||||
#endif
|
||||
#endif
|
||||
#if HAS_V_MAX
|
||||
#if (digitalPinToInterrupt(V_MAX_PIN) != NOT_AN_INTERRUPT)
|
||||
_ATTACH(V_MAX_PIN);
|
||||
#else
|
||||
static_assert(digitalPinHasPCICR(V_MAX_PIN), "V_MAX_PIN is not interrupt-capable");
|
||||
pciSetup(V_MAX_PIN);
|
||||
#endif
|
||||
#elif HAS_V_MIN
|
||||
#if (digitalPinToInterrupt(V_MIN_PIN) != NOT_AN_INTERRUPT)
|
||||
_ATTACH(V_MIN_PIN);
|
||||
#else
|
||||
static_assert(digitalPinHasPCICR(V_MIN_PIN), "V_MIN_PIN is not interrupt-capable");
|
||||
pciSetup(V_MIN_PIN);
|
||||
#endif
|
||||
#endif
|
||||
#if HAS_W_MAX
|
||||
#if (digitalPinToInterrupt(W_MAX_PIN) != NOT_AN_INTERRUPT)
|
||||
_ATTACH(W_MAX_PIN);
|
||||
#else
|
||||
static_assert(digitalPinHasPCICR(W_MAX_PIN), "W_MAX_PIN is not interrupt-capable");
|
||||
pciSetup(W_MAX_PIN);
|
||||
#endif
|
||||
#elif HAS_W_MIN
|
||||
#if (digitalPinToInterrupt(W_MIN_PIN) != NOT_AN_INTERRUPT)
|
||||
_ATTACH(W_MIN_PIN);
|
||||
#else
|
||||
static_assert(digitalPinHasPCICR(W_MIN_PIN), "W_MIN_PIN is not interrupt-capable");
|
||||
pciSetup(W_MIN_PIN);
|
||||
#endif
|
||||
#endif
|
||||
#if HAS_X2_MAX
|
||||
#if (digitalPinToInterrupt(X2_MAX_PIN) != NOT_AN_INTERRUPT)
|
||||
_ATTACH(X2_MAX_PIN);
|
||||
|
||||
@@ -107,7 +107,7 @@ const Timer get_pwm_timer(const pin_t pin) {
|
||||
return Timer();
|
||||
}
|
||||
|
||||
void set_pwm_frequency(const pin_t pin, const uint16_t f_desired) {
|
||||
void MarlinHAL::set_pwm_frequency(const pin_t pin, const uint16_t f_desired) {
|
||||
const Timer timer = get_pwm_timer(pin);
|
||||
if (timer.isProtected || !timer.isPWM) return; // Don't proceed if protected timer or not recognized
|
||||
|
||||
@@ -176,7 +176,7 @@ void set_pwm_frequency(const pin_t pin, const uint16_t f_desired) {
|
||||
_SET_ICRn(timer, res); // Set ICRn value (TOP) = res
|
||||
}
|
||||
|
||||
void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) {
|
||||
void MarlinHAL::set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) {
|
||||
// If v is 0 or v_size (max), digitalWrite to LOW or HIGH.
|
||||
// Note that digitalWrite also disables PWM output for us (sets COM bit to 0)
|
||||
if (v == 0)
|
||||
@@ -201,7 +201,7 @@ void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255
|
||||
}
|
||||
}
|
||||
|
||||
void init_pwm_timers() {
|
||||
void MarlinHAL::init_pwm_timers() {
|
||||
// Init some timer frequencies to a default 1KHz
|
||||
const pin_t pwm_pin[] = {
|
||||
#ifdef __AVR_ATmega2560__
|
||||
|
||||
@@ -71,3 +71,7 @@
|
||||
#if ENABLED(POSTMORTEM_DEBUGGING)
|
||||
#error "POSTMORTEM_DEBUGGING is not supported on AVR boards."
|
||||
#endif
|
||||
|
||||
#if USING_PULLDOWNS
|
||||
#error "PULLDOWN pin mode is not available on AVR boards."
|
||||
#endif
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
// C B A is longIn1
|
||||
// D C B A is longIn2
|
||||
//
|
||||
static FORCE_INLINE uint16_t MultiU24X32toH16(uint32_t longIn1, uint32_t longIn2) {
|
||||
FORCE_INLINE static uint16_t MultiU24X32toH16(uint32_t longIn1, uint32_t longIn2) {
|
||||
uint8_t tmp1;
|
||||
uint8_t tmp2;
|
||||
uint16_t intRes;
|
||||
@@ -89,7 +89,7 @@ static FORCE_INLINE uint16_t MultiU24X32toH16(uint32_t longIn1, uint32_t longIn2
|
||||
// uses:
|
||||
// r26 to store 0
|
||||
// r27 to store the byte 1 of the 24 bit result
|
||||
static FORCE_INLINE uint16_t MultiU16X8toH16(uint8_t charIn1, uint16_t intIn2) {
|
||||
FORCE_INLINE static uint16_t MultiU16X8toH16(uint8_t charIn1, uint16_t intIn2) {
|
||||
uint8_t tmp;
|
||||
uint16_t intRes;
|
||||
__asm__ __volatile__ (
|
||||
|
||||
@@ -109,12 +109,12 @@ FORCE_INLINE void HAL_timer_start(const uint8_t timer_num, const uint32_t) {
|
||||
* (otherwise, characters will be lost due to UART overflow).
|
||||
* Then: Stepper, Endstops, Temperature, and -finally- all others.
|
||||
*/
|
||||
#define HAL_timer_isr_prologue(T)
|
||||
#define HAL_timer_isr_epilogue(T)
|
||||
#define HAL_timer_isr_prologue(T) NOOP
|
||||
#define HAL_timer_isr_epilogue(T) NOOP
|
||||
|
||||
/* 18 cycles maximum latency */
|
||||
#ifndef HAL_STEP_TIMER_ISR
|
||||
|
||||
/* 18 cycles maximum latency */
|
||||
#define HAL_STEP_TIMER_ISR() \
|
||||
extern "C" void TIMER1_COMPA_vect() __attribute__ ((signal, naked, used, externally_visible)); \
|
||||
extern "C" void TIMER1_COMPA_vect_bottom() asm ("TIMER1_COMPA_vect_bottom") __attribute__ ((used, externally_visible, noinline)); \
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
// Public Variables
|
||||
// ------------------------
|
||||
|
||||
uint16_t HAL_adc_result;
|
||||
uint16_t MarlinHAL::adc_result;
|
||||
|
||||
// ------------------------
|
||||
// Public functions
|
||||
@@ -42,8 +42,7 @@ uint16_t HAL_adc_result;
|
||||
|
||||
TERN_(POSTMORTEM_DEBUGGING, extern void install_min_serial());
|
||||
|
||||
// HAL initialization task
|
||||
void HAL_init() {
|
||||
void MarlinHAL::init() {
|
||||
// Initialize the USB stack
|
||||
#if ENABLED(SDSUPPORT)
|
||||
OUT_WRITE(SDSS, HIGH); // Try to set SDSS inactive before any other SPI users start up
|
||||
@@ -52,21 +51,15 @@ void HAL_init() {
|
||||
TERN_(POSTMORTEM_DEBUGGING, install_min_serial()); // Install the min serial handler
|
||||
}
|
||||
|
||||
// HAL idle task
|
||||
void HAL_idletask() {
|
||||
// Perform USB stack housekeeping
|
||||
usb_task_idle();
|
||||
void MarlinHAL::init_board() {
|
||||
#ifdef BOARD_INIT
|
||||
BOARD_INIT();
|
||||
#endif
|
||||
}
|
||||
|
||||
// Disable interrupts
|
||||
void cli() { noInterrupts(); }
|
||||
void MarlinHAL::idletask() { usb_task_idle(); } // Perform USB stack housekeeping
|
||||
|
||||
// Enable interrupts
|
||||
void sei() { interrupts(); }
|
||||
|
||||
void HAL_clear_reset_source() { }
|
||||
|
||||
uint8_t HAL_get_reset_source() {
|
||||
uint8_t MarlinHAL::get_reset_source() {
|
||||
switch ((RSTC->RSTC_SR >> 8) & 0x07) {
|
||||
case 0: return RST_POWER_ON;
|
||||
case 1: return RST_BACKUP;
|
||||
@@ -77,12 +70,7 @@ uint8_t HAL_get_reset_source() {
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_reboot() { rstc_start_software_reset(RSTC); }
|
||||
|
||||
void _delay_ms(const int delay_ms) {
|
||||
// Todo: port for Due?
|
||||
delay(delay_ms);
|
||||
}
|
||||
void MarlinHAL::reboot() { rstc_start_software_reset(RSTC); }
|
||||
|
||||
extern "C" {
|
||||
extern unsigned int _ebss; // end of bss section
|
||||
@@ -94,19 +82,6 @@ int freeMemory() {
|
||||
return (int)&free_memory - (heap_end ?: (int)&_ebss);
|
||||
}
|
||||
|
||||
// ------------------------
|
||||
// ADC
|
||||
// ------------------------
|
||||
|
||||
void HAL_adc_start_conversion(const uint8_t ch) {
|
||||
HAL_adc_result = analogRead(ch);
|
||||
}
|
||||
|
||||
uint16_t HAL_adc_get_result() {
|
||||
// nop
|
||||
return HAL_adc_result;
|
||||
}
|
||||
|
||||
// Forward the default serial ports
|
||||
#if USING_HW_SERIAL0
|
||||
DefaultSerial1 MSerial0(false, Serial);
|
||||
|
||||
+87
-48
@@ -38,6 +38,10 @@
|
||||
|
||||
#include "../../core/serial_hook.h"
|
||||
|
||||
// ------------------------
|
||||
// Serial ports
|
||||
// ------------------------
|
||||
|
||||
typedef ForwardSerial1Class< decltype(Serial) > DefaultSerial1;
|
||||
typedef ForwardSerial1Class< decltype(Serial1) > DefaultSerial2;
|
||||
typedef ForwardSerial1Class< decltype(Serial2) > DefaultSerial3;
|
||||
@@ -97,60 +101,38 @@ extern DefaultSerial4 MSerial3;
|
||||
#include "MarlinSerial.h"
|
||||
#include "MarlinSerialUSB.h"
|
||||
|
||||
// On AVR this is in math.h?
|
||||
#define square(x) ((x)*(x))
|
||||
// ------------------------
|
||||
// Types
|
||||
// ------------------------
|
||||
|
||||
typedef int8_t pin_t;
|
||||
|
||||
#define SHARED_SERVOS HAS_SERVOS
|
||||
#define HAL_SERVO_LIB Servo
|
||||
#define SHARED_SERVOS HAS_SERVOS // Use shared/servos.cpp
|
||||
|
||||
class Servo;
|
||||
typedef Servo hal_servo_t;
|
||||
|
||||
//
|
||||
// Interrupts
|
||||
//
|
||||
#define CRITICAL_SECTION_START() uint32_t primask = __get_PRIMASK(); __disable_irq()
|
||||
#define CRITICAL_SECTION_END() if (!primask) __enable_irq()
|
||||
#define ISRS_ENABLED() (!__get_PRIMASK())
|
||||
#define ENABLE_ISRS() __enable_irq()
|
||||
#define DISABLE_ISRS() __disable_irq()
|
||||
#define sei() noInterrupts()
|
||||
#define cli() interrupts()
|
||||
|
||||
void cli(); // Disable interrupts
|
||||
void sei(); // Enable interrupts
|
||||
|
||||
void HAL_clear_reset_source(); // clear reset reason
|
||||
uint8_t HAL_get_reset_source(); // get reset reason
|
||||
|
||||
void HAL_reboot();
|
||||
#define CRITICAL_SECTION_START() const bool _irqon = hal.isr_state(); hal.isr_off()
|
||||
#define CRITICAL_SECTION_END() if (_irqon) hal.isr_on()
|
||||
|
||||
//
|
||||
// ADC
|
||||
//
|
||||
extern uint16_t HAL_adc_result; // result of last ADC conversion
|
||||
#define HAL_ADC_VREF 3.3
|
||||
#define HAL_ADC_RESOLUTION 10
|
||||
|
||||
#ifndef analogInputToDigitalPin
|
||||
#define analogInputToDigitalPin(p) ((p < 12U) ? (p) + 54U : -1)
|
||||
#endif
|
||||
|
||||
#define HAL_ANALOG_SELECT(ch)
|
||||
|
||||
inline void HAL_adc_init() {}//todo
|
||||
|
||||
#define HAL_ADC_VREF 3.3
|
||||
#define HAL_ADC_RESOLUTION 10
|
||||
#define HAL_START_ADC(ch) HAL_adc_start_conversion(ch)
|
||||
#define HAL_READ_ADC() HAL_adc_result
|
||||
#define HAL_ADC_READY() true
|
||||
|
||||
void HAL_adc_start_conversion(const uint8_t ch);
|
||||
uint16_t HAL_adc_get_result();
|
||||
|
||||
//
|
||||
// PWM
|
||||
//
|
||||
inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); }
|
||||
|
||||
//
|
||||
// Pin Map
|
||||
// Pin Mapping for M42, M43, M226
|
||||
//
|
||||
#define GET_PIN_MAP_PIN(index) index
|
||||
#define GET_PIN_MAP_INDEX(pin) pin
|
||||
@@ -159,27 +141,18 @@ inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255,
|
||||
//
|
||||
// Tone
|
||||
//
|
||||
void toneInit();
|
||||
void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration=0);
|
||||
void noTone(const pin_t _pin);
|
||||
|
||||
// Enable hooks into idle and setup for HAL
|
||||
#define HAL_IDLETASK 1
|
||||
void HAL_idletask();
|
||||
void HAL_init();
|
||||
|
||||
//
|
||||
// Utility functions
|
||||
//
|
||||
void _delay_ms(const int delay);
|
||||
// ------------------------
|
||||
// Class Utilities
|
||||
// ------------------------
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#if GCC_VERSION <= 50000
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#endif
|
||||
|
||||
int freeMemory();
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -189,3 +162,69 @@ char *dtostrf(double __val, signed char __width, unsigned char __prec, char *__s
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
// Return free RAM between end of heap (or end bss) and whatever is current
|
||||
int freeMemory();
|
||||
|
||||
// ------------------------
|
||||
// MarlinHAL Class
|
||||
// ------------------------
|
||||
|
||||
class MarlinHAL {
|
||||
public:
|
||||
|
||||
// Earliest possible init, before setup()
|
||||
MarlinHAL() {}
|
||||
|
||||
static void init(); // Called early in setup()
|
||||
static void init_board(); // Called less early in setup()
|
||||
static void reboot(); // Software reset
|
||||
|
||||
// Interrupts
|
||||
static bool isr_state() { return !__get_PRIMASK(); }
|
||||
static void isr_on() { __enable_irq(); }
|
||||
static void isr_off() { __disable_irq(); }
|
||||
|
||||
static void delay_ms(const int ms) { delay(ms); }
|
||||
|
||||
// Tasks, called from idle()
|
||||
static void idletask();
|
||||
|
||||
// Reset
|
||||
static uint8_t get_reset_source();
|
||||
static void clear_reset_source() {}
|
||||
|
||||
// Free SRAM
|
||||
static int freeMemory() { return ::freeMemory(); }
|
||||
|
||||
//
|
||||
// ADC Methods
|
||||
//
|
||||
|
||||
static uint16_t adc_result;
|
||||
|
||||
// Called by Temperature::init once at startup
|
||||
static void adc_init() {}
|
||||
|
||||
// Called by Temperature::init for each sensor at startup
|
||||
static void adc_enable(const uint8_t ch) {}
|
||||
|
||||
// Begin ADC sampling on the given channel
|
||||
static void adc_start(const uint8_t ch) { adc_result = analogRead(ch); }
|
||||
|
||||
// Is the ADC ready for reading?
|
||||
static bool adc_ready() { return true; }
|
||||
|
||||
// The current value of the ADC register
|
||||
static uint16_t adc_value() { return adc_result; }
|
||||
|
||||
/**
|
||||
* Set the PWM duty cycle for the pin to the given value.
|
||||
* No inverting the duty cycle in this HAL.
|
||||
* No changing the maximum size of the provided value to enable finer PWM duty control in this HAL.
|
||||
*/
|
||||
static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) {
|
||||
analogWrite(pin, v);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -406,7 +406,7 @@ size_t MarlinSerial<Cfg>::write(const uint8_t c) {
|
||||
const uint8_t i = (tx_buffer.head + 1) & (Cfg::TX_SIZE - 1);
|
||||
|
||||
// If global interrupts are disabled (as the result of being called from an ISR)...
|
||||
if (!ISRS_ENABLED()) {
|
||||
if (!hal.isr_state()) {
|
||||
|
||||
// Make room by polling if it is possible to transmit, and do so!
|
||||
while (i == tx_buffer.tail) {
|
||||
@@ -454,7 +454,7 @@ void MarlinSerial<Cfg>::flushTX() {
|
||||
if (!_written) return;
|
||||
|
||||
// If global interrupts are disabled (as the result of being called from an ISR)...
|
||||
if (!ISRS_ENABLED()) {
|
||||
if (!hal.isr_state()) {
|
||||
|
||||
// Wait until everything was transmitted - We must do polling, as interrupts are disabled
|
||||
while (tx_buffer.head != tx_buffer.tail || !(HWUART->UART_SR & UART_SR_TXEMPTY)) {
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
static pin_t tone_pin;
|
||||
volatile static int32_t toggles;
|
||||
|
||||
void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration) {
|
||||
void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration/*=0*/) {
|
||||
tone_pin = _pin;
|
||||
toggles = 2 * frequency * duration / 1000;
|
||||
HAL_timer_start(MF_TIMER_TONE, 2 * frequency);
|
||||
|
||||
@@ -70,4 +70,10 @@ void setup_endstop_interrupts() {
|
||||
TERN_(HAS_J_MIN, _ATTACH(J_MIN_PIN));
|
||||
TERN_(HAS_K_MAX, _ATTACH(K_MAX_PIN));
|
||||
TERN_(HAS_K_MIN, _ATTACH(K_MIN_PIN));
|
||||
TERN_(HAS_U_MAX, _ATTACH(U_MAX_PIN));
|
||||
TERN_(HAS_U_MIN, _ATTACH(U_MIN_PIN));
|
||||
TERN_(HAS_V_MAX, _ATTACH(V_MAX_PIN));
|
||||
TERN_(HAS_V_MIN, _ATTACH(V_MIN_PIN));
|
||||
TERN_(HAS_W_MAX, _ATTACH(W_MAX_PIN));
|
||||
TERN_(HAS_W_MIN, _ATTACH(W_MIN_PIN));
|
||||
}
|
||||
|
||||
@@ -59,3 +59,7 @@
|
||||
#if HAS_TMC_SW_SERIAL
|
||||
#error "TMC220x Software Serial is not supported on the DUE platform."
|
||||
#endif
|
||||
|
||||
#if USING_PULLDOWNS
|
||||
#error "PULLDOWN pin mode is not available on DUE boards."
|
||||
#endif
|
||||
|
||||
@@ -125,4 +125,4 @@ FORCE_INLINE static void HAL_timer_isr_prologue(const uint8_t timer_num) {
|
||||
pConfig->pTimerRegs->TC_CHANNEL[pConfig->channel].TC_SR;
|
||||
}
|
||||
|
||||
#define HAL_timer_isr_epilogue(T)
|
||||
#define HAL_timer_isr_epilogue(T) NOOP
|
||||
|
||||
+116
-48
@@ -52,7 +52,7 @@
|
||||
// Externs
|
||||
// ------------------------
|
||||
|
||||
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
|
||||
portMUX_TYPE MarlinHAL::spinlock = portMUX_INITIALIZER_UNLOCKED;
|
||||
|
||||
// ------------------------
|
||||
// Local defines
|
||||
@@ -64,7 +64,7 @@ portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
|
||||
// Public Variables
|
||||
// ------------------------
|
||||
|
||||
uint16_t HAL_adc_result;
|
||||
uint16_t MarlinHAL::adc_result;
|
||||
|
||||
// ------------------------
|
||||
// Private Variables
|
||||
@@ -73,9 +73,16 @@ uint16_t HAL_adc_result;
|
||||
esp_adc_cal_characteristics_t characteristics[ADC_ATTEN_MAX];
|
||||
adc_atten_t attenuations[ADC1_CHANNEL_MAX] = {};
|
||||
uint32_t thresholds[ADC_ATTEN_MAX];
|
||||
volatile int numPWMUsed = 0,
|
||||
pwmPins[MAX_PWM_PINS],
|
||||
pwmValues[MAX_PWM_PINS];
|
||||
|
||||
volatile int numPWMUsed = 0;
|
||||
volatile struct { pin_t pin; int value; } pwmState[MAX_PWM_PINS];
|
||||
|
||||
pin_t chan_pin[CHANNEL_MAX_NUM + 1] = { 0 }; // PWM capable IOpins - not 0 or >33 on ESP32
|
||||
|
||||
struct {
|
||||
uint32_t freq; // ledcReadFreq doesn't work if a duty hasn't been set yet!
|
||||
uint16_t res;
|
||||
} pwmInfo[(CHANNEL_MAX_NUM + 1) / 2];
|
||||
|
||||
// ------------------------
|
||||
// Public functions
|
||||
@@ -95,20 +102,22 @@ volatile int numPWMUsed = 0,
|
||||
#endif
|
||||
|
||||
#if ENABLED(USE_ESP32_EXIO)
|
||||
|
||||
HardwareSerial YSerial2(2);
|
||||
|
||||
void Write_EXIO(uint8_t IO, uint8_t v) {
|
||||
if (ISRS_ENABLED()) {
|
||||
DISABLE_ISRS();
|
||||
if (hal.isr_state()) {
|
||||
hal.isr_off();
|
||||
YSerial2.write(0x80 | (((char)v) << 5) | (IO - 100));
|
||||
ENABLE_ISRS();
|
||||
hal.isr_on();
|
||||
}
|
||||
else
|
||||
YSerial2.write(0x80 | (((char)v) << 5) | (IO - 100));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void HAL_init_board() {
|
||||
void MarlinHAL::init_board() {
|
||||
#if ENABLED(USE_ESP32_TASK_WDT)
|
||||
esp_task_wdt_init(10, true);
|
||||
#endif
|
||||
@@ -154,27 +163,26 @@ void HAL_init_board() {
|
||||
#endif
|
||||
}
|
||||
|
||||
void HAL_idletask() {
|
||||
void MarlinHAL::idletask() {
|
||||
#if BOTH(WIFISUPPORT, OTASUPPORT)
|
||||
OTA_handle();
|
||||
#endif
|
||||
TERN_(ESP3D_WIFISUPPORT, esp3dlib.idletask());
|
||||
}
|
||||
|
||||
void HAL_clear_reset_source() { }
|
||||
uint8_t MarlinHAL::get_reset_source() { return rtc_get_reset_reason(1); }
|
||||
|
||||
uint8_t HAL_get_reset_source() { return rtc_get_reset_reason(1); }
|
||||
|
||||
void HAL_reboot() { ESP.restart(); }
|
||||
void MarlinHAL::reboot() { ESP.restart(); }
|
||||
|
||||
void _delay_ms(int delay_ms) { delay(delay_ms); }
|
||||
|
||||
// return free memory between end of heap (or end bss) and whatever is current
|
||||
int freeMemory() { return ESP.getFreeHeap(); }
|
||||
int MarlinHAL::freeMemory() { return ESP.getFreeHeap(); }
|
||||
|
||||
// ------------------------
|
||||
// ADC
|
||||
// ------------------------
|
||||
|
||||
#define ADC1_CHANNEL(pin) ADC1_GPIO ## pin ## _CHANNEL
|
||||
|
||||
adc1_channel_t get_channel(int pin) {
|
||||
@@ -196,24 +204,24 @@ void adc1_set_attenuation(adc1_channel_t chan, adc_atten_t atten) {
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_adc_init() {
|
||||
void MarlinHAL::adc_init() {
|
||||
// Configure ADC
|
||||
adc1_config_width(ADC_WIDTH_12Bit);
|
||||
|
||||
// Configure channels only if used as (re-)configuring a pin for ADC that is used elsewhere might have adverse effects
|
||||
TERN_(HAS_TEMP_ADC_0, adc1_set_attenuation(get_channel(TEMP_0_PIN), ADC_ATTEN_11db));
|
||||
TERN_(HAS_TEMP_ADC_1, adc1_set_attenuation(get_channel(TEMP_1_PIN), ADC_ATTEN_11db));
|
||||
TERN_(HAS_TEMP_ADC_2, adc1_set_attenuation(get_channel(TEMP_2_PIN), ADC_ATTEN_11db));
|
||||
TERN_(HAS_TEMP_ADC_3, adc1_set_attenuation(get_channel(TEMP_3_PIN), ADC_ATTEN_11db));
|
||||
TERN_(HAS_TEMP_ADC_4, adc1_set_attenuation(get_channel(TEMP_4_PIN), ADC_ATTEN_11db));
|
||||
TERN_(HAS_TEMP_ADC_5, adc1_set_attenuation(get_channel(TEMP_5_PIN), ADC_ATTEN_11db));
|
||||
TERN_(HAS_TEMP_ADC_6, adc2_set_attenuation(get_channel(TEMP_6_PIN), ADC_ATTEN_11db));
|
||||
TERN_(HAS_TEMP_ADC_7, adc3_set_attenuation(get_channel(TEMP_7_PIN), ADC_ATTEN_11db));
|
||||
TERN_(HAS_HEATED_BED, adc1_set_attenuation(get_channel(TEMP_BED_PIN), ADC_ATTEN_11db));
|
||||
TERN_(HAS_TEMP_CHAMBER, adc1_set_attenuation(get_channel(TEMP_CHAMBER_PIN), ADC_ATTEN_11db));
|
||||
TERN_(HAS_TEMP_PROBE, adc1_set_attenuation(get_channel(TEMP_PROBE_PIN), ADC_ATTEN_11db));
|
||||
TERN_(HAS_TEMP_COOLER, adc1_set_attenuation(get_channel(TEMP_COOLER_PIN), ADC_ATTEN_11db));
|
||||
TERN_(HAS_TEMP_BOARD, adc1_set_attenuation(get_channel(TEMP_BOARD_PIN), ADC_ATTEN_11db));
|
||||
TERN_(HAS_TEMP_ADC_0, adc1_set_attenuation(get_channel(TEMP_0_PIN), ADC_ATTEN_11db));
|
||||
TERN_(HAS_TEMP_ADC_1, adc1_set_attenuation(get_channel(TEMP_1_PIN), ADC_ATTEN_11db));
|
||||
TERN_(HAS_TEMP_ADC_2, adc1_set_attenuation(get_channel(TEMP_2_PIN), ADC_ATTEN_11db));
|
||||
TERN_(HAS_TEMP_ADC_3, adc1_set_attenuation(get_channel(TEMP_3_PIN), ADC_ATTEN_11db));
|
||||
TERN_(HAS_TEMP_ADC_4, adc1_set_attenuation(get_channel(TEMP_4_PIN), ADC_ATTEN_11db));
|
||||
TERN_(HAS_TEMP_ADC_5, adc1_set_attenuation(get_channel(TEMP_5_PIN), ADC_ATTEN_11db));
|
||||
TERN_(HAS_TEMP_ADC_6, adc2_set_attenuation(get_channel(TEMP_6_PIN), ADC_ATTEN_11db));
|
||||
TERN_(HAS_TEMP_ADC_7, adc3_set_attenuation(get_channel(TEMP_7_PIN), ADC_ATTEN_11db));
|
||||
TERN_(HAS_HEATED_BED, adc1_set_attenuation(get_channel(TEMP_BED_PIN), ADC_ATTEN_11db));
|
||||
TERN_(HAS_TEMP_CHAMBER, adc1_set_attenuation(get_channel(TEMP_CHAMBER_PIN), ADC_ATTEN_11db));
|
||||
TERN_(HAS_TEMP_PROBE, adc1_set_attenuation(get_channel(TEMP_PROBE_PIN), ADC_ATTEN_11db));
|
||||
TERN_(HAS_TEMP_COOLER, adc1_set_attenuation(get_channel(TEMP_COOLER_PIN), ADC_ATTEN_11db));
|
||||
TERN_(HAS_TEMP_BOARD, adc1_set_attenuation(get_channel(TEMP_BOARD_PIN), ADC_ATTEN_11db));
|
||||
TERN_(FILAMENT_WIDTH_SENSOR, adc1_set_attenuation(get_channel(FILWIDTH_PIN), ADC_ATTEN_11db));
|
||||
|
||||
// Note that adc2 is shared with the WiFi module, which has higher priority, so the conversion may fail.
|
||||
@@ -228,11 +236,15 @@ void HAL_adc_init() {
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_adc_start_conversion(const uint8_t adc_pin) {
|
||||
const adc1_channel_t chan = get_channel(adc_pin);
|
||||
#ifndef ADC_REFERENCE_VOLTAGE
|
||||
#define ADC_REFERENCE_VOLTAGE 3.3
|
||||
#endif
|
||||
|
||||
void MarlinHAL::adc_start(const pin_t pin) {
|
||||
const adc1_channel_t chan = get_channel(pin);
|
||||
uint32_t mv;
|
||||
esp_adc_cal_get_voltage((adc_channel_t)chan, &characteristics[attenuations[chan]], &mv);
|
||||
HAL_adc_result = mv * 1023.0 / 3300.0;
|
||||
adc_result = mv * 1023.0f / float(ADC_REFERENCE_VOLTAGE) / 1000.0f;
|
||||
|
||||
// Change the attenuation level based on the new reading
|
||||
adc_atten_t atten;
|
||||
@@ -249,25 +261,81 @@ void HAL_adc_start_conversion(const uint8_t adc_pin) {
|
||||
adc1_set_attenuation(chan, atten);
|
||||
}
|
||||
|
||||
void analogWrite(pin_t pin, int value) {
|
||||
// Use ledc hardware for internal pins
|
||||
if (pin < 34) {
|
||||
static int cnt_channel = 1, pin_to_channel[40] = { 0 };
|
||||
if (pin_to_channel[pin] == 0) {
|
||||
ledcAttachPin(pin, cnt_channel);
|
||||
ledcSetup(cnt_channel, 490, 8);
|
||||
ledcWrite(cnt_channel, value);
|
||||
pin_to_channel[pin] = cnt_channel++;
|
||||
// ------------------------
|
||||
// PWM
|
||||
// ------------------------
|
||||
|
||||
int8_t channel_for_pin(const uint8_t pin) {
|
||||
for (int i = 0; i <= CHANNEL_MAX_NUM; i++)
|
||||
if (chan_pin[i] == pin) return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// get PWM channel for pin - if none then attach a new one
|
||||
// return -1 if fail or invalid pin#, channel # (0-15) if success
|
||||
int8_t get_pwm_channel(const pin_t pin, const uint32_t freq, const uint16_t res) {
|
||||
if (!WITHIN(pin, 1, MAX_PWM_IOPIN)) return -1; // Not a hardware PWM pin!
|
||||
int8_t cid = channel_for_pin(pin);
|
||||
if (cid >= 0) return cid;
|
||||
|
||||
// Find an empty adjacent channel (same timer & freq/res)
|
||||
for (int i = 0; i <= CHANNEL_MAX_NUM; i++) {
|
||||
if (chan_pin[i] == 0) {
|
||||
if (chan_pin[i ^ 0x1] != 0) {
|
||||
if (pwmInfo[i / 2].freq == freq && pwmInfo[i / 2].res == res) {
|
||||
chan_pin[i] = pin; // Allocate PWM to this channel
|
||||
ledcAttachPin(pin, i);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
else if (cid == -1) // Pair of empty channels?
|
||||
cid = i & 0xFE; // Save lower channel number
|
||||
}
|
||||
ledcWrite(pin_to_channel[pin], value);
|
||||
}
|
||||
// not attached, is an empty timer slot avail?
|
||||
if (cid >= 0) {
|
||||
chan_pin[cid] = pin;
|
||||
pwmInfo[cid / 2].freq = freq;
|
||||
pwmInfo[cid / 2].res = res;
|
||||
ledcSetup(cid, freq, res);
|
||||
ledcAttachPin(pin, cid);
|
||||
}
|
||||
return cid; // -1 if no channel avail
|
||||
}
|
||||
|
||||
void MarlinHAL::set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=_BV(PWM_RESOLUTION)-1*/, const bool invert/*=false*/) {
|
||||
const int8_t cid = get_pwm_channel(pin, PWM_FREQUENCY, PWM_RESOLUTION);
|
||||
if (cid >= 0) {
|
||||
uint32_t duty = map(invert ? v_size - v : v, 0, v_size, 0, _BV(PWM_RESOLUTION)-1);
|
||||
ledcWrite(cid, duty);
|
||||
}
|
||||
}
|
||||
|
||||
int8_t MarlinHAL::set_pwm_frequency(const pin_t pin, const uint32_t f_desired) {
|
||||
const int8_t cid = channel_for_pin(pin);
|
||||
if (cid >= 0) {
|
||||
if (f_desired == ledcReadFreq(cid)) return cid; // no freq change
|
||||
ledcDetachPin(chan_pin[cid]);
|
||||
chan_pin[cid] = 0; // remove old freq channel
|
||||
}
|
||||
return get_pwm_channel(pin, f_desired, PWM_RESOLUTION); // try for new one
|
||||
}
|
||||
|
||||
// use hardware PWM if avail, if not then ISR
|
||||
void analogWrite(const pin_t pin, const uint16_t value, const uint32_t freq/*=PWM_FREQUENCY*/, const uint16_t res/*=8*/) { // always 8 bit resolution!
|
||||
// Use ledc hardware for internal pins
|
||||
const int8_t cid = get_pwm_channel(pin, freq, res);
|
||||
if (cid >= 0) {
|
||||
ledcWrite(cid, value); // set duty value
|
||||
return;
|
||||
}
|
||||
|
||||
// not a hardware PWM pin OR no PWM channels available
|
||||
int idx = -1;
|
||||
|
||||
// Search Pin
|
||||
for (int i = 0; i < numPWMUsed; ++i)
|
||||
if (pwmPins[i] == pin) { idx = i; break; }
|
||||
if (pwmState[i].pin == pin) { idx = i; break; }
|
||||
|
||||
// not found ?
|
||||
if (idx < 0) {
|
||||
@@ -276,7 +344,7 @@ void analogWrite(pin_t pin, int value) {
|
||||
|
||||
// Take new slot for pin
|
||||
idx = numPWMUsed;
|
||||
pwmPins[idx] = pin;
|
||||
pwmState[idx].pin = pin;
|
||||
// Start timer on first use
|
||||
if (idx == 0) HAL_timer_start(MF_TIMER_PWM, PWM_TIMER_FREQUENCY);
|
||||
|
||||
@@ -284,7 +352,7 @@ void analogWrite(pin_t pin, int value) {
|
||||
}
|
||||
|
||||
// Use 7bit internal value - add 1 to have 100% high at 255
|
||||
pwmValues[idx] = (value + 1) / 2;
|
||||
pwmState[idx].value = (value + 1) / 2;
|
||||
}
|
||||
|
||||
// Handle PWM timer interrupt
|
||||
@@ -295,9 +363,9 @@ HAL_PWM_TIMER_ISR() {
|
||||
|
||||
for (int i = 0; i < numPWMUsed; ++i) {
|
||||
if (count == 0) // Start of interval
|
||||
WRITE(pwmPins[i], pwmValues[i] ? HIGH : LOW);
|
||||
else if (pwmValues[i] == count) // End of duration
|
||||
WRITE(pwmPins[i], LOW);
|
||||
digitalWrite(pwmState[i].pin, pwmState[i].value ? HIGH : LOW);
|
||||
else if (pwmState[i].value == count) // End of duration
|
||||
digitalWrite(pwmState[i].pin, LOW);
|
||||
}
|
||||
|
||||
// 128 for 7 Bit resolution
|
||||
|
||||
+99
-58
@@ -49,8 +49,6 @@
|
||||
// Defines
|
||||
// ------------------------
|
||||
|
||||
extern portMUX_TYPE spinlock;
|
||||
|
||||
#define MYSERIAL1 flushableSerial
|
||||
|
||||
#if EITHER(WIFISUPPORT, ESP3D_WIFISUPPORT)
|
||||
@@ -65,9 +63,12 @@ extern portMUX_TYPE spinlock;
|
||||
|
||||
#define CRITICAL_SECTION_START() portENTER_CRITICAL(&spinlock)
|
||||
#define CRITICAL_SECTION_END() portEXIT_CRITICAL(&spinlock)
|
||||
#define ISRS_ENABLED() (spinlock.owner == portMUX_FREE_VAL)
|
||||
#define ENABLE_ISRS() if (spinlock.owner != portMUX_FREE_VAL) portEXIT_CRITICAL(&spinlock)
|
||||
#define DISABLE_ISRS() portENTER_CRITICAL(&spinlock)
|
||||
|
||||
#define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment
|
||||
#define PWM_FREQUENCY 1000u // Default PWM frequency when set_pwm_duty() is called without set_pwm_frequency()
|
||||
#define PWM_RESOLUTION 10u // Default PWM bit resolution
|
||||
#define CHANNEL_MAX_NUM 15u // max PWM channel # to allocate (7 to only use low speed, 15 to use low & high)
|
||||
#define MAX_PWM_IOPIN 33u // hardware pwm pins < 34
|
||||
|
||||
// ------------------------
|
||||
// Types
|
||||
@@ -75,14 +76,8 @@ extern portMUX_TYPE spinlock;
|
||||
|
||||
typedef int16_t pin_t;
|
||||
|
||||
#define HAL_SERVO_LIB Servo
|
||||
|
||||
// ------------------------
|
||||
// Public Variables
|
||||
// ------------------------
|
||||
|
||||
/** result of last ADC conversion */
|
||||
extern uint16_t HAL_adc_result;
|
||||
class Servo;
|
||||
typedef Servo hal_servo_t;
|
||||
|
||||
// ------------------------
|
||||
// Public functions
|
||||
@@ -91,59 +86,18 @@ extern uint16_t HAL_adc_result;
|
||||
//
|
||||
// Tone
|
||||
//
|
||||
void toneInit();
|
||||
void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration=0);
|
||||
void noTone(const pin_t _pin);
|
||||
|
||||
// clear reset reason
|
||||
void HAL_clear_reset_source();
|
||||
void analogWrite(const pin_t pin, const uint16_t value, const uint32_t freq=PWM_FREQUENCY, const uint16_t res=8);
|
||||
|
||||
// reset reason
|
||||
uint8_t HAL_get_reset_source();
|
||||
|
||||
void HAL_reboot();
|
||||
|
||||
void _delay_ms(int delay);
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#if GCC_VERSION <= 50000
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#endif
|
||||
|
||||
int freeMemory();
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
void analogWrite(pin_t pin, int value);
|
||||
|
||||
// ADC
|
||||
#define HAL_ANALOG_SELECT(pin)
|
||||
|
||||
void HAL_adc_init();
|
||||
|
||||
#define HAL_ADC_VREF 3.3
|
||||
#define HAL_ADC_RESOLUTION 10
|
||||
#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
|
||||
#define HAL_READ_ADC() HAL_adc_result
|
||||
#define HAL_ADC_READY() true
|
||||
|
||||
void HAL_adc_start_conversion(const uint8_t adc_pin);
|
||||
|
||||
// PWM
|
||||
inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); }
|
||||
|
||||
// Pin Map
|
||||
//
|
||||
// Pin Mapping for M42, M43, M226
|
||||
//
|
||||
#define GET_PIN_MAP_PIN(index) index
|
||||
#define GET_PIN_MAP_INDEX(pin) pin
|
||||
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
|
||||
|
||||
// Enable hooks into idle and setup for HAL
|
||||
#define HAL_IDLETASK 1
|
||||
#define BOARD_INIT() HAL_init_board()
|
||||
void HAL_idletask();
|
||||
inline void HAL_init() {}
|
||||
void HAL_init_board();
|
||||
|
||||
#if ENABLED(USE_ESP32_EXIO)
|
||||
void Write_EXIO(uint8_t IO, uint8_t v);
|
||||
#endif
|
||||
@@ -188,3 +142,90 @@ FORCE_INLINE static void DELAY_CYCLES(uint32_t x) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ------------------------
|
||||
// Class Utilities
|
||||
// ------------------------
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#if GCC_VERSION <= 50000
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#endif
|
||||
|
||||
int freeMemory();
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
void _delay_ms(const int ms);
|
||||
|
||||
// ------------------------
|
||||
// MarlinHAL Class
|
||||
// ------------------------
|
||||
|
||||
#define HAL_ADC_VREF 3.3
|
||||
#define HAL_ADC_RESOLUTION 10
|
||||
|
||||
class MarlinHAL {
|
||||
public:
|
||||
|
||||
// Earliest possible init, before setup()
|
||||
MarlinHAL() {}
|
||||
|
||||
static void init() {} // Called early in setup()
|
||||
static void init_board(); // Called less early in setup()
|
||||
static void reboot(); // Restart the firmware
|
||||
|
||||
// Interrupts
|
||||
static portMUX_TYPE spinlock;
|
||||
static bool isr_state() { return spinlock.owner == portMUX_FREE_VAL; }
|
||||
static void isr_on() { if (spinlock.owner != portMUX_FREE_VAL) portEXIT_CRITICAL(&spinlock); }
|
||||
static void isr_off() { portENTER_CRITICAL(&spinlock); }
|
||||
|
||||
static void delay_ms(const int ms) { _delay_ms(ms); }
|
||||
|
||||
// Tasks, called from idle()
|
||||
static void idletask();
|
||||
|
||||
// Reset
|
||||
static uint8_t get_reset_source();
|
||||
static void clear_reset_source() {}
|
||||
|
||||
// Free SRAM
|
||||
static int freeMemory();
|
||||
|
||||
//
|
||||
// ADC Methods
|
||||
//
|
||||
|
||||
static uint16_t adc_result;
|
||||
|
||||
// Called by Temperature::init once at startup
|
||||
static void adc_init();
|
||||
|
||||
// Called by Temperature::init for each sensor at startup
|
||||
static void adc_enable(const pin_t pin) {}
|
||||
|
||||
// Begin ADC sampling on the given channel
|
||||
static void adc_start(const pin_t pin);
|
||||
|
||||
// Is the ADC ready for reading?
|
||||
static bool adc_ready() { return true; }
|
||||
|
||||
// The current value of the ADC register
|
||||
static uint16_t adc_value() { return adc_result; }
|
||||
|
||||
/**
|
||||
* If not already allocated, allocate a hardware PWM channel
|
||||
* to the pin and set the duty cycle..
|
||||
* Optionally invert the duty cycle [default = false]
|
||||
* Optionally change the scale of the provided value to enable finer PWM duty control [default = 255]
|
||||
*/
|
||||
static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false);
|
||||
|
||||
/**
|
||||
* Allocate and set the frequency of a hardware PWM pin
|
||||
* Returns -1 if no pin available.
|
||||
*/
|
||||
static int8_t set_pwm_frequency(const pin_t pin, const uint32_t f_desired);
|
||||
|
||||
};
|
||||
|
||||
@@ -31,20 +31,18 @@
|
||||
// so we only allocate servo channels up high to avoid side effects with regards to analogWrite (fans, leds, laser pwm etc.)
|
||||
int Servo::channel_next_free = 12;
|
||||
|
||||
Servo::Servo() {
|
||||
channel = channel_next_free++;
|
||||
}
|
||||
Servo::Servo() {}
|
||||
|
||||
int8_t Servo::attach(const int inPin) {
|
||||
if (channel >= CHANNEL_MAX_NUM) return -1;
|
||||
if (inPin > 0) pin = inPin;
|
||||
|
||||
ledcSetup(channel, 50, 16); // channel X, 50 Hz, 16-bit depth
|
||||
ledcAttachPin(pin, channel);
|
||||
return true;
|
||||
channel = get_pwm_channel(pin, 50u, 16u);
|
||||
return channel; // -1 if no PWM avail.
|
||||
}
|
||||
|
||||
void Servo::detach() { ledcDetachPin(pin); }
|
||||
// leave channel connected to servo - set duty to zero
|
||||
void Servo::detach() {
|
||||
if (channel >= 0) ledcWrite(channel, 0);
|
||||
}
|
||||
|
||||
int Servo::read() { return degrees; }
|
||||
|
||||
@@ -52,7 +50,7 @@ void Servo::write(int inDegrees) {
|
||||
degrees = constrain(inDegrees, MIN_ANGLE, MAX_ANGLE);
|
||||
int us = map(degrees, MIN_ANGLE, MAX_ANGLE, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH);
|
||||
int duty = map(us, 0, TAU_USEC, 0, MAX_COMPARE);
|
||||
ledcWrite(channel, duty);
|
||||
if (channel >= 0) ledcWrite(channel, duty); // don't save duty for servos!
|
||||
}
|
||||
|
||||
void Servo::move(const int value) {
|
||||
|
||||
@@ -30,8 +30,7 @@ class Servo {
|
||||
MAX_PULSE_WIDTH = 2400, // Longest pulse sent to a servo
|
||||
TAU_MSEC = 20,
|
||||
TAU_USEC = (TAU_MSEC * 1000),
|
||||
MAX_COMPARE = _BV(16) - 1, // 65535
|
||||
CHANNEL_MAX_NUM = 16;
|
||||
MAX_COMPARE = _BV(16) - 1; // 65535
|
||||
|
||||
public:
|
||||
Servo();
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
static pin_t tone_pin;
|
||||
volatile static int32_t toggles;
|
||||
|
||||
void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration) {
|
||||
void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration/*=0*/) {
|
||||
tone_pin = _pin;
|
||||
toggles = 2 * frequency * duration / 1000;
|
||||
HAL_timer_start(MF_TIMER_TONE, 2 * frequency);
|
||||
|
||||
@@ -65,4 +65,10 @@ void setup_endstop_interrupts() {
|
||||
TERN_(HAS_J_MIN, _ATTACH(J_MIN_PIN));
|
||||
TERN_(HAS_K_MAX, _ATTACH(K_MAX_PIN));
|
||||
TERN_(HAS_K_MIN, _ATTACH(K_MIN_PIN));
|
||||
TERN_(HAS_U_MAX, _ATTACH(U_MAX_PIN));
|
||||
TERN_(HAS_U_MIN, _ATTACH(U_MIN_PIN));
|
||||
TERN_(HAS_V_MAX, _ATTACH(V_MAX_PIN));
|
||||
TERN_(HAS_V_MIN, _ATTACH(V_MIN_PIN));
|
||||
TERN_(HAS_W_MAX, _ATTACH(W_MAX_PIN));
|
||||
TERN_(HAS_W_MIN, _ATTACH(W_MIN_PIN));
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
#error "EMERGENCY_PARSER is not yet implemented for ESP32. Disable EMERGENCY_PARSER to continue."
|
||||
#endif
|
||||
|
||||
#if ENABLED(FAST_PWM_FAN) || SPINDLE_LASER_FREQUENCY
|
||||
#error "Features requiring Hardware PWM (FAST_PWM_FAN, SPINDLE_LASER_FREQUENCY) are not yet supported on ESP32."
|
||||
#if (ENABLED(SPINDLE_LASER_USE_PWM) && SPINDLE_LASER_FREQUENCY > 78125) || (ENABLED(FAST_PWM_FAN_FREQUENCY) && FAST_PWM_FAN_FREQUENCY > 78125)
|
||||
#error "SPINDLE_LASER_FREQUENCY and FAST_PWM_FREQUENCY maximum value is 78125Hz for ESP32."
|
||||
#endif
|
||||
|
||||
#if HAS_TMC_SW_SERIAL
|
||||
@@ -40,3 +40,11 @@
|
||||
#if ENABLED(POSTMORTEM_DEBUGGING)
|
||||
#error "POSTMORTEM_DEBUGGING is not yet supported on ESP32."
|
||||
#endif
|
||||
|
||||
#if MB(MKS_TINYBEE) && ENABLED(FAST_PWM_FAN)
|
||||
#error "FAST_PWM_FAN is not available on TinyBee."
|
||||
#endif
|
||||
|
||||
#if USING_PULLDOWNS
|
||||
#error "PULLDOWN pin mode is not available on ESP32 boards."
|
||||
#endif
|
||||
|
||||
@@ -81,7 +81,7 @@ void IRAM_ATTR timer_isr(void *para) {
|
||||
* @param timer_num timer number to initialize
|
||||
* @param frequency frequency of the timer
|
||||
*/
|
||||
void HAL_timer_start(const uint8_t timer_num, uint32_t frequency) {
|
||||
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
||||
const tTimerConfig timer = timer_config[timer_num];
|
||||
|
||||
timer_config_t config;
|
||||
|
||||
@@ -127,7 +127,7 @@ extern const tTimerConfig timer_config[];
|
||||
// Public functions
|
||||
// ------------------------
|
||||
|
||||
void HAL_timer_start (const uint8_t timer_num, uint32_t frequency);
|
||||
void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency);
|
||||
void HAL_timer_set_compare(const uint8_t timer_num, const hal_timer_t count);
|
||||
hal_timer_t HAL_timer_get_compare(const uint8_t timer_num);
|
||||
hal_timer_t HAL_timer_get_count(const uint8_t timer_num);
|
||||
@@ -136,5 +136,5 @@ void HAL_timer_enable_interrupt(const uint8_t timer_num);
|
||||
void HAL_timer_disable_interrupt(const uint8_t timer_num);
|
||||
bool HAL_timer_interrupt_enabled(const uint8_t timer_num);
|
||||
|
||||
#define HAL_timer_isr_prologue(T)
|
||||
#define HAL_timer_isr_epilogue(T)
|
||||
#define HAL_timer_isr_prologue(T) NOOP
|
||||
#define HAL_timer_isr_epilogue(T) NOOP
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* Copypaste of SAMD51 HAL developed by Giuliano Zaro (AKA GMagician)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if ENABLED(FYSETC_MINI_12864_2_1)
|
||||
|
||||
#include <U8glib-HAL.h>
|
||||
#include "Arduino.h"
|
||||
#include "../shared/HAL_SPI.h"
|
||||
#include "HAL.h"
|
||||
#include "SPI.h"
|
||||
|
||||
static SPISettings spiConfig;
|
||||
|
||||
#define MDOGLCD_MOSI 23
|
||||
#define MDOGLCD_SCK 18
|
||||
#define MLCD_RESET_PIN 0
|
||||
#define MLCD_PINS_DC 4
|
||||
#define MDOGLCD_CS 21
|
||||
#define MDOGLCD_A0 4
|
||||
|
||||
#ifndef LCD_SPI_SPEED
|
||||
#ifdef SD_SPI_SPEED
|
||||
#define LCD_SPI_SPEED SD_SPI_SPEED // Assume SPI speed shared with SD
|
||||
#else
|
||||
#define LCD_SPI_SPEED SPI_FULL_SPEED // Use full speed if SD speed is not supplied
|
||||
#endif
|
||||
#endif
|
||||
|
||||
uint8_t u8g_eps_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {
|
||||
static uint8_t msgInitCount = 2; // Ignore all messages until 2nd U8G_COM_MSG_INIT
|
||||
if (msgInitCount) {
|
||||
if (msg == U8G_COM_MSG_INIT) msgInitCount--;
|
||||
if (msgInitCount) return -1;
|
||||
}
|
||||
|
||||
switch (msg) {
|
||||
case U8G_COM_MSG_STOP: break;
|
||||
|
||||
case U8G_COM_MSG_INIT:
|
||||
OUT_WRITE(MDOGLCD_CS, HIGH);
|
||||
OUT_WRITE(MDOGLCD_A0, HIGH);
|
||||
OUT_WRITE(MLCD_RESET_PIN, HIGH);
|
||||
u8g_Delay(5);
|
||||
spiBegin();
|
||||
spiInit(LCD_SPI_SPEED);
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
|
||||
WRITE(MDOGLCD_A0, arg_val ? HIGH : LOW);
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_CHIP_SELECT: /* arg_val == 0 means HIGH level of U8G_PI_CS */
|
||||
WRITE(MDOGLCD_CS, arg_val ? LOW : HIGH);
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_RESET:
|
||||
WRITE(MLCD_RESET_PIN, arg_val);
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_BYTE:
|
||||
spiSend((uint8_t)arg_val);
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_SEQ:
|
||||
uint8_t *ptr = (uint8_t*) arg_ptr;
|
||||
while (arg_val > 0) {
|
||||
spiSend(*ptr++);
|
||||
arg_val--;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif // FYSETC_MINI_12864_2_1
|
||||
#endif // ARDUINO_ARCH_ESP32
|
||||
@@ -24,6 +24,10 @@
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
#include "../shared/Delay.h"
|
||||
|
||||
// ------------------------
|
||||
// Serial ports
|
||||
// ------------------------
|
||||
|
||||
MSerialT usb_serial(TERN0(EMERGENCY_PARSER, true));
|
||||
|
||||
// U8glib required functions
|
||||
@@ -37,42 +41,21 @@ extern "C" {
|
||||
//************************//
|
||||
|
||||
// return free heap space
|
||||
int freeMemory() {
|
||||
return 0;
|
||||
}
|
||||
int freeMemory() { return 0; }
|
||||
|
||||
// ------------------------
|
||||
// ADC
|
||||
// ------------------------
|
||||
|
||||
void HAL_adc_init() {
|
||||
uint8_t MarlinHAL::active_ch = 0;
|
||||
|
||||
}
|
||||
|
||||
void HAL_adc_enable_channel(const uint8_t ch) {
|
||||
|
||||
}
|
||||
|
||||
uint8_t active_ch = 0;
|
||||
void HAL_adc_start_conversion(const uint8_t ch) {
|
||||
active_ch = ch;
|
||||
}
|
||||
|
||||
bool HAL_adc_finished() {
|
||||
return true;
|
||||
}
|
||||
|
||||
uint16_t HAL_adc_get_result() {
|
||||
pin_t pin = analogInputToDigitalPin(active_ch);
|
||||
uint16_t MarlinHAL::adc_value() {
|
||||
const pin_t pin = analogInputToDigitalPin(active_ch);
|
||||
if (!VALID_PIN(pin)) return 0;
|
||||
uint16_t data = ((Gpio::get(pin) >> 2) & 0x3FF);
|
||||
const uint16_t data = ((Gpio::get(pin) >> 2) & 0x3FF);
|
||||
return data; // return 10bit value as Marlin expects
|
||||
}
|
||||
|
||||
void HAL_pwm_init() {
|
||||
|
||||
}
|
||||
|
||||
void HAL_reboot() { /* Reset the application state and GPIO */ }
|
||||
void MarlinHAL::reboot() { /* Reset the application state and GPIO */ }
|
||||
|
||||
#endif // __PLAT_LINUX__
|
||||
|
||||
+95
-50
@@ -21,34 +21,13 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#define CPU_32_BIT
|
||||
|
||||
#define F_CPU 100000000UL
|
||||
#define SystemCoreClock F_CPU
|
||||
#include <iostream>
|
||||
#include <stdint.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#undef min
|
||||
#undef max
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
void _printf (const char *format, ...);
|
||||
void _putc(uint8_t c);
|
||||
uint8_t _getc();
|
||||
|
||||
//extern "C" volatile uint32_t _millis;
|
||||
|
||||
//arduino: Print.h
|
||||
#define DEC 10
|
||||
#define HEX 16
|
||||
#define OCT 8
|
||||
#define BIN 2
|
||||
//arduino: binary.h (weird defines)
|
||||
#define B01 1
|
||||
#define B10 2
|
||||
|
||||
#include "hardware/Clock.h"
|
||||
|
||||
#include "../shared/Marduino.h"
|
||||
@@ -58,27 +37,56 @@ uint8_t _getc();
|
||||
#include "watchdog.h"
|
||||
#include "serial.h"
|
||||
|
||||
#define SHARED_SERVOS HAS_SERVOS
|
||||
// ------------------------
|
||||
// Defines
|
||||
// ------------------------
|
||||
|
||||
extern MSerialT usb_serial;
|
||||
#define MYSERIAL1 usb_serial
|
||||
#define CPU_32_BIT
|
||||
#define SHARED_SERVOS HAS_SERVOS // Use shared/servos.cpp
|
||||
|
||||
#define F_CPU 100000000UL
|
||||
#define SystemCoreClock F_CPU
|
||||
|
||||
#define DELAY_CYCLES(x) Clock::delayCycles(x)
|
||||
|
||||
#define CPU_ST7920_DELAY_1 600
|
||||
#define CPU_ST7920_DELAY_2 750
|
||||
#define CPU_ST7920_DELAY_3 750
|
||||
|
||||
void _printf(const char *format, ...);
|
||||
void _putc(uint8_t c);
|
||||
uint8_t _getc();
|
||||
|
||||
//arduino: Print.h
|
||||
#define DEC 10
|
||||
#define HEX 16
|
||||
#define OCT 8
|
||||
#define BIN 2
|
||||
//arduino: binary.h (weird defines)
|
||||
#define B01 1
|
||||
#define B10 2
|
||||
|
||||
// ------------------------
|
||||
// Serial ports
|
||||
// ------------------------
|
||||
|
||||
extern MSerialT usb_serial;
|
||||
#define MYSERIAL1 usb_serial
|
||||
|
||||
//
|
||||
// Interrupts
|
||||
//
|
||||
#define CRITICAL_SECTION_START()
|
||||
#define CRITICAL_SECTION_END()
|
||||
#define ISRS_ENABLED()
|
||||
#define ENABLE_ISRS()
|
||||
#define DISABLE_ISRS()
|
||||
|
||||
inline void HAL_init() {}
|
||||
// ADC
|
||||
#define HAL_ADC_VREF 5.0
|
||||
#define HAL_ADC_RESOLUTION 10
|
||||
|
||||
// ------------------------
|
||||
// Class Utilities
|
||||
// ------------------------
|
||||
|
||||
// Utility functions
|
||||
#pragma GCC diagnostic push
|
||||
#if GCC_VERSION <= 50000
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
@@ -88,29 +96,66 @@ int freeMemory();
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
// ADC
|
||||
#define HAL_ADC_VREF 5.0
|
||||
#define HAL_ADC_RESOLUTION 10
|
||||
#define HAL_ANALOG_SELECT(ch) HAL_adc_enable_channel(ch)
|
||||
#define HAL_START_ADC(ch) HAL_adc_start_conversion(ch)
|
||||
#define HAL_READ_ADC() HAL_adc_get_result()
|
||||
#define HAL_ADC_READY() true
|
||||
// ------------------------
|
||||
// MarlinHAL Class
|
||||
// ------------------------
|
||||
|
||||
void HAL_adc_init();
|
||||
void HAL_adc_enable_channel(const uint8_t ch);
|
||||
void HAL_adc_start_conversion(const uint8_t ch);
|
||||
uint16_t HAL_adc_get_result();
|
||||
class MarlinHAL {
|
||||
public:
|
||||
|
||||
// PWM
|
||||
inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); }
|
||||
// Earliest possible init, before setup()
|
||||
MarlinHAL() {}
|
||||
|
||||
// Reset source
|
||||
inline void HAL_clear_reset_source(void) {}
|
||||
inline uint8_t HAL_get_reset_source(void) { return RST_POWER_ON; }
|
||||
static void init() {} // Called early in setup()
|
||||
static void init_board() {} // Called less early in setup()
|
||||
static void reboot(); // Reset the application state and GPIO
|
||||
|
||||
void HAL_reboot(); // Reset the application state and GPIO
|
||||
// Interrupts
|
||||
static bool isr_state() { return true; }
|
||||
static void isr_on() {}
|
||||
static void isr_off() {}
|
||||
|
||||
/* ---------------- Delay in cycles */
|
||||
FORCE_INLINE static void DELAY_CYCLES(uint64_t x) {
|
||||
Clock::delayCycles(x);
|
||||
}
|
||||
static void delay_ms(const int ms) { _delay_ms(ms); }
|
||||
|
||||
// Tasks, called from idle()
|
||||
static void idletask() {}
|
||||
|
||||
// Reset
|
||||
static constexpr uint8_t reset_reason = RST_POWER_ON;
|
||||
static uint8_t get_reset_source() { return reset_reason; }
|
||||
static void clear_reset_source() {}
|
||||
|
||||
// Free SRAM
|
||||
static int freeMemory() { return ::freeMemory(); }
|
||||
|
||||
//
|
||||
// ADC Methods
|
||||
//
|
||||
|
||||
static uint8_t active_ch;
|
||||
|
||||
// Called by Temperature::init once at startup
|
||||
static void adc_init() {}
|
||||
|
||||
// Called by Temperature::init for each sensor at startup
|
||||
static void adc_enable(const uint8_t) {}
|
||||
|
||||
// Begin ADC sampling on the given channel
|
||||
static void adc_start(const uint8_t ch) { active_ch = ch; }
|
||||
|
||||
// Is the ADC ready for reading?
|
||||
static bool adc_ready() { return true; }
|
||||
|
||||
// The current value of the ADC register
|
||||
static uint16_t adc_value();
|
||||
|
||||
/**
|
||||
* Set the PWM duty cycle for the pin to the given value.
|
||||
* No option to change the resolution or invert the duty cycle.
|
||||
*/
|
||||
static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) {
|
||||
analogWrite(pin, v);
|
||||
}
|
||||
|
||||
static void set_pwm_frequency(const pin_t, int) {}
|
||||
};
|
||||
|
||||
@@ -31,9 +31,7 @@ void cli() { } // Disable
|
||||
void sei() { } // Enable
|
||||
|
||||
// Time functions
|
||||
void _delay_ms(const int delay_ms) {
|
||||
delay(delay_ms);
|
||||
}
|
||||
void _delay_ms(const int ms) { delay(ms); }
|
||||
|
||||
uint32_t millis() {
|
||||
return (uint32_t)Clock::millis();
|
||||
|
||||
@@ -59,10 +59,9 @@ typedef uint8_t byte;
|
||||
#endif
|
||||
|
||||
#define sq(v) ((v) * (v))
|
||||
#define square(v) sq(v)
|
||||
#define constrain(value, arg_min, arg_max) ((value) < (arg_min) ? (arg_min) :((value) > (arg_max) ? (arg_max) : (value)))
|
||||
|
||||
//Interrupts
|
||||
// Interrupts
|
||||
void cli(); // Disable
|
||||
void sei(); // Enable
|
||||
void attachInterrupt(uint32_t pin, void (*callback)(), uint32_t mode);
|
||||
@@ -74,8 +73,8 @@ extern "C" {
|
||||
}
|
||||
|
||||
// Time functions
|
||||
extern "C" void delay(const int milis);
|
||||
void _delay_ms(const int delay);
|
||||
extern "C" void delay(const int ms);
|
||||
void _delay_ms(const int ms);
|
||||
void delayMicroseconds(unsigned long);
|
||||
uint32_t millis();
|
||||
|
||||
|
||||
@@ -92,5 +92,5 @@ void HAL_timer_enable_interrupt(const uint8_t timer_num);
|
||||
void HAL_timer_disable_interrupt(const uint8_t timer_num);
|
||||
bool HAL_timer_interrupt_enabled(const uint8_t timer_num);
|
||||
|
||||
#define HAL_timer_isr_prologue(T)
|
||||
#define HAL_timer_isr_epilogue(T)
|
||||
#define HAL_timer_isr_prologue(T) NOOP
|
||||
#define HAL_timer_isr_epilogue(T) NOOP
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
DefaultSerial1 USBSerial(false, UsbSerial);
|
||||
|
||||
uint32_t HAL_adc_reading = 0;
|
||||
uint32_t MarlinHAL::adc_result = 0;
|
||||
|
||||
// U8glib required functions
|
||||
extern "C" {
|
||||
@@ -41,8 +41,6 @@ extern "C" {
|
||||
void u8g_Delay(uint16_t val) { delay(val); }
|
||||
}
|
||||
|
||||
//************************//
|
||||
|
||||
// return free heap space
|
||||
int freeMemory() {
|
||||
char stack_end;
|
||||
@@ -54,7 +52,27 @@ int freeMemory() {
|
||||
return result;
|
||||
}
|
||||
|
||||
// scan command line for code
|
||||
void MarlinHAL::reboot() { NVIC_SystemReset(); }
|
||||
|
||||
uint8_t MarlinHAL::get_reset_source() {
|
||||
#if ENABLED(USE_WATCHDOG)
|
||||
if (watchdog_timed_out()) return RST_WATCHDOG;
|
||||
#endif
|
||||
return RST_POWER_ON;
|
||||
}
|
||||
|
||||
void MarlinHAL::clear_reset_source() {
|
||||
TERN_(USE_WATCHDOG, watchdog_clear_timeout_flag());
|
||||
}
|
||||
|
||||
void flashFirmware(const int16_t) {
|
||||
delay(500); // Give OS time to disconnect
|
||||
USB_Connect(false); // USB clear connection
|
||||
delay(1000); // Give OS time to notice
|
||||
hal.reboot();
|
||||
}
|
||||
|
||||
// For M42/M43, scan command line for pin code
|
||||
// return index into pin map array if found and the pin is valid.
|
||||
// return dval if not found or not a valid pin.
|
||||
int16_t PARSED_PIN_INDEX(const char code, const int16_t dval) {
|
||||
@@ -63,24 +81,4 @@ int16_t PARSED_PIN_INDEX(const char code, const int16_t dval) {
|
||||
return ind > -1 ? ind : dval;
|
||||
}
|
||||
|
||||
void flashFirmware(const int16_t) {
|
||||
delay(500); // Give OS time to disconnect
|
||||
USB_Connect(false); // USB clear connection
|
||||
delay(1000); // Give OS time to notice
|
||||
HAL_reboot();
|
||||
}
|
||||
|
||||
void HAL_clear_reset_source(void) {
|
||||
TERN_(USE_WATCHDOG, watchdog_clear_timeout_flag());
|
||||
}
|
||||
|
||||
uint8_t HAL_get_reset_source(void) {
|
||||
#if ENABLED(USE_WATCHDOG)
|
||||
if (watchdog_timed_out()) return RST_WATCHDOG;
|
||||
#endif
|
||||
return RST_POWER_ON;
|
||||
}
|
||||
|
||||
void HAL_reboot() { NVIC_SystemReset(); }
|
||||
|
||||
#endif // TARGET_LPC1768
|
||||
|
||||
@@ -28,8 +28,6 @@
|
||||
|
||||
#define CPU_32_BIT
|
||||
|
||||
void HAL_init();
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdarg.h>
|
||||
#include <algorithm>
|
||||
@@ -47,12 +45,9 @@ extern "C" volatile uint32_t _millis;
|
||||
#include <pinmapping.h>
|
||||
#include <CDCSerial.h>
|
||||
|
||||
//
|
||||
// Default graphical display delays
|
||||
//
|
||||
#define CPU_ST7920_DELAY_1 600
|
||||
#define CPU_ST7920_DELAY_2 750
|
||||
#define CPU_ST7920_DELAY_3 750
|
||||
// ------------------------
|
||||
// Serial ports
|
||||
// ------------------------
|
||||
|
||||
typedef ForwardSerial1Class< decltype(UsbSerial) > DefaultSerial1;
|
||||
extern DefaultSerial1 USBSerial;
|
||||
@@ -114,26 +109,12 @@ extern DefaultSerial1 USBSerial;
|
||||
//
|
||||
// Interrupts
|
||||
//
|
||||
#define CRITICAL_SECTION_START() uint32_t primask = __get_PRIMASK(); __disable_irq()
|
||||
#define CRITICAL_SECTION_END() if (!primask) __enable_irq()
|
||||
#define ISRS_ENABLED() (!__get_PRIMASK())
|
||||
#define ENABLE_ISRS() __enable_irq()
|
||||
#define DISABLE_ISRS() __disable_irq()
|
||||
|
||||
#define CRITICAL_SECTION_START() const bool irqon = !__get_PRIMASK(); __disable_irq()
|
||||
#define CRITICAL_SECTION_END() if (irqon) __enable_irq()
|
||||
|
||||
//
|
||||
// Utility functions
|
||||
//
|
||||
#pragma GCC diagnostic push
|
||||
#if GCC_VERSION <= 50000
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#endif
|
||||
|
||||
int freeMemory();
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
//
|
||||
// ADC API
|
||||
// ADC
|
||||
//
|
||||
|
||||
#define ADC_MEDIAN_FILTER_SIZE (23) // Higher values increase step delay (phase shift),
|
||||
@@ -152,20 +133,9 @@ int freeMemory();
|
||||
#define HAL_ADC_RESOLUTION 12 // 15 bit maximum, raw temperature is stored as int16_t
|
||||
#define HAL_ADC_FILTERED // Disable oversampling done in Marlin as ADC values already filtered in HAL
|
||||
|
||||
using FilteredADC = LPC176x::ADC<ADC_LOWPASS_K_VALUE, ADC_MEDIAN_FILTER_SIZE>;
|
||||
extern uint32_t HAL_adc_reading;
|
||||
[[gnu::always_inline]] inline void HAL_adc_start_conversion(const pin_t pin) {
|
||||
HAL_adc_reading = FilteredADC::read(pin) >> (16 - HAL_ADC_RESOLUTION); // returns 16bit value, reduce to required bits
|
||||
}
|
||||
[[gnu::always_inline]] inline uint16_t HAL_adc_get_result() {
|
||||
return HAL_adc_reading;
|
||||
}
|
||||
|
||||
#define HAL_adc_init()
|
||||
#define HAL_ANALOG_SELECT(pin) FilteredADC::enable_channel(pin)
|
||||
#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
|
||||
#define HAL_READ_ADC() HAL_adc_get_result()
|
||||
#define HAL_ADC_READY() (true)
|
||||
//
|
||||
// Pin Mapping for M42, M43, M226
|
||||
//
|
||||
|
||||
// Test whether the pin is valid
|
||||
constexpr bool VALID_PIN(const pin_t pin) {
|
||||
@@ -192,32 +162,101 @@ int16_t PARSED_PIN_INDEX(const char code, const int16_t dval);
|
||||
// P0.6 thru P0.9 are for the onboard SD card
|
||||
#define HAL_SENSITIVE_PINS P0_06, P0_07, P0_08, P0_09,
|
||||
|
||||
#define HAL_IDLETASK 1
|
||||
void HAL_idletask();
|
||||
// ------------------------
|
||||
// Defines
|
||||
// ------------------------
|
||||
|
||||
#define PLATFORM_M997_SUPPORT
|
||||
void flashFirmware(const int16_t);
|
||||
|
||||
#define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment
|
||||
|
||||
/**
|
||||
* set_pwm_frequency
|
||||
* Set the frequency of the timer corresponding to the provided pin
|
||||
* All Hardware PWM pins run at the same frequency and all
|
||||
* Software PWM pins run at the same frequency
|
||||
*/
|
||||
void set_pwm_frequency(const pin_t pin, const uint16_t f_desired);
|
||||
// Default graphical display delays
|
||||
#define CPU_ST7920_DELAY_1 600
|
||||
#define CPU_ST7920_DELAY_2 750
|
||||
#define CPU_ST7920_DELAY_3 750
|
||||
|
||||
/**
|
||||
* set_pwm_duty
|
||||
* Set the PWM duty cycle of the provided pin to the provided value
|
||||
* Optionally allows inverting the duty cycle [default = false]
|
||||
* Optionally allows changing the maximum size of the provided value to enable finer PWM duty control [default = 255]
|
||||
*/
|
||||
void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false);
|
||||
// ------------------------
|
||||
// Class Utilities
|
||||
// ------------------------
|
||||
|
||||
// Reset source
|
||||
void HAL_clear_reset_source(void);
|
||||
uint8_t HAL_get_reset_source(void);
|
||||
#pragma GCC diagnostic push
|
||||
#if GCC_VERSION <= 50000
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#endif
|
||||
|
||||
void HAL_reboot();
|
||||
int freeMemory();
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
// ------------------------
|
||||
// MarlinHAL Class
|
||||
// ------------------------
|
||||
|
||||
class MarlinHAL {
|
||||
public:
|
||||
|
||||
// Earliest possible init, before setup()
|
||||
MarlinHAL() {}
|
||||
|
||||
static void init(); // Called early in setup()
|
||||
static void init_board() {} // Called less early in setup()
|
||||
static void reboot(); // Restart the firmware from 0x0
|
||||
|
||||
// Interrupts
|
||||
static bool isr_state() { return !__get_PRIMASK(); }
|
||||
static void isr_on() { __enable_irq(); }
|
||||
static void isr_off() { __disable_irq(); }
|
||||
|
||||
static void delay_ms(const int ms) { _delay_ms(ms); }
|
||||
|
||||
// Tasks, called from idle()
|
||||
static void idletask();
|
||||
|
||||
// Reset
|
||||
static uint8_t get_reset_source();
|
||||
static void clear_reset_source();
|
||||
|
||||
// Free SRAM
|
||||
static int freeMemory() { return ::freeMemory(); }
|
||||
|
||||
//
|
||||
// ADC Methods
|
||||
//
|
||||
|
||||
using FilteredADC = LPC176x::ADC<ADC_LOWPASS_K_VALUE, ADC_MEDIAN_FILTER_SIZE>;
|
||||
|
||||
// Called by Temperature::init once at startup
|
||||
static void adc_init() {}
|
||||
|
||||
// Called by Temperature::init for each sensor at startup
|
||||
static void adc_enable(const pin_t pin) {
|
||||
FilteredADC::enable_channel(pin);
|
||||
}
|
||||
|
||||
// Begin ADC sampling on the given pin
|
||||
static uint32_t adc_result;
|
||||
static void adc_start(const pin_t pin) {
|
||||
adc_result = FilteredADC::read(pin) >> (16 - HAL_ADC_RESOLUTION); // returns 16bit value, reduce to required bits
|
||||
}
|
||||
|
||||
// Is the ADC ready for reading?
|
||||
static bool adc_ready() { return true; }
|
||||
|
||||
// The current value of the ADC register
|
||||
static uint16_t adc_value() { return uint16_t(adc_result); }
|
||||
|
||||
/**
|
||||
* Set the PWM duty cycle for the pin to the given value.
|
||||
* Optionally invert the duty cycle [default = false]
|
||||
* Optionally change the scale of the provided value to enable finer PWM duty control [default = 255]
|
||||
*/
|
||||
static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false);
|
||||
|
||||
/**
|
||||
* Set the frequency of the timer corresponding to the provided pin
|
||||
* All Hardware PWM pins will run at the same frequency and
|
||||
* All Software PWM pins will run at the same frequency
|
||||
*/
|
||||
static void set_pwm_frequency(const pin_t pin, const uint16_t f_desired);
|
||||
};
|
||||
|
||||
@@ -65,4 +65,5 @@ class libServo: public Servo {
|
||||
}
|
||||
};
|
||||
|
||||
#define HAL_SERVO_LIB libServo
|
||||
class libServo;
|
||||
typedef libServo hal_servo_t;
|
||||
|
||||
@@ -155,4 +155,37 @@ void setup_endstop_interrupts() {
|
||||
#endif
|
||||
_ATTACH(K_MIN_PIN);
|
||||
#endif
|
||||
#if HAS_U_MAX
|
||||
#if !LPC1768_PIN_INTERRUPT_M(U_MAX_PIN)
|
||||
#error "U_MAX_PIN is not INTERRUPT-capable."
|
||||
#endif
|
||||
_ATTACH(U_MAX_PIN);
|
||||
#elif HAS_U_MIN
|
||||
#if !LPC1768_PIN_INTERRUPT_M(U_MIN_PIN)
|
||||
#error "U_MIN_PIN is not INTERRUPT-capable."
|
||||
#endif
|
||||
_ATTACH(U_MIN_PIN);
|
||||
#endif
|
||||
#if HAS_V_MAX
|
||||
#if !LPC1768_PIN_INTERRUPT_M(V_MAX_PIN)
|
||||
#error "V_MAX_PIN is not INTERRUPT-capable."
|
||||
#endif
|
||||
_ATTACH(V_MAX_PIN);
|
||||
#elif HAS_V_MIN
|
||||
#if !LPC1768_PIN_INTERRUPT_M(V_MIN_PIN)
|
||||
#error "V_MIN_PIN is not INTERRUPT-capable."
|
||||
#endif
|
||||
_ATTACH(V_MIN_PIN);
|
||||
#endif
|
||||
#if HAS_W_MAX
|
||||
#if !LPC1768_PIN_INTERRUPT_M(W_MAX_PIN)
|
||||
#error "W_MAX_PIN is not INTERRUPT-capable."
|
||||
#endif
|
||||
_ATTACH(W_MAX_PIN);
|
||||
#elif HAS_W_MIN
|
||||
#if !LPC1768_PIN_INTERRUPT_M(W_MIN_PIN)
|
||||
#error "W_MIN_PIN is not INTERRUPT-capable."
|
||||
#endif
|
||||
_ATTACH(W_MIN_PIN);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -21,16 +21,16 @@
|
||||
*/
|
||||
#ifdef TARGET_LPC1768
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
#include <pwm.h>
|
||||
|
||||
void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) {
|
||||
void MarlinHAL::set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) {
|
||||
if (!LPC176x::pin_is_valid(pin)) return;
|
||||
if (LPC176x::pwm_attach_pin(pin))
|
||||
LPC176x::pwm_write_ratio(pin, invert ? 1.0f - (float)v / v_size : (float)v / v_size); // map 1-254 onto PWM range
|
||||
}
|
||||
|
||||
void set_pwm_frequency(const pin_t pin, const uint16_t f_desired) {
|
||||
void MarlinHAL::set_pwm_frequency(const pin_t pin, const uint16_t f_desired) {
|
||||
LPC176x::pwm_set_frequency(pin, f_desired);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if MB(MKS_SBASE)
|
||||
#if ENABLED(DIGIPOT_MCP4451) && MB(MKS_SBASE)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -37,35 +37,6 @@
|
||||
|
||||
#include "digipot_mcp4451_I2C_routines.h"
|
||||
|
||||
// These two routines are exact copies of the lpc17xx_i2c.c routines. Couldn't link to
|
||||
// to the lpc17xx_i2c.c routines so had to copy them into this file & rename them.
|
||||
|
||||
static uint32_t _I2C_Start(LPC_I2C_TypeDef *I2Cx) {
|
||||
// Reset STA, STO, SI
|
||||
I2Cx->I2CONCLR = I2C_I2CONCLR_SIC|I2C_I2CONCLR_STOC|I2C_I2CONCLR_STAC;
|
||||
|
||||
// Enter to Master Transmitter mode
|
||||
I2Cx->I2CONSET = I2C_I2CONSET_STA;
|
||||
|
||||
// Wait for complete
|
||||
while (!(I2Cx->I2CONSET & I2C_I2CONSET_SI));
|
||||
I2Cx->I2CONCLR = I2C_I2CONCLR_STAC;
|
||||
return (I2Cx->I2STAT & I2C_STAT_CODE_BITMASK);
|
||||
}
|
||||
|
||||
static void _I2C_Stop(LPC_I2C_TypeDef *I2Cx) {
|
||||
// Make sure start bit is not active
|
||||
if (I2Cx->I2CONSET & I2C_I2CONSET_STA)
|
||||
I2Cx->I2CONCLR = I2C_I2CONCLR_STAC;
|
||||
|
||||
I2Cx->I2CONSET = I2C_I2CONSET_STO|I2C_I2CONSET_AA;
|
||||
I2Cx->I2CONCLR = I2C_I2CONCLR_SIC;
|
||||
}
|
||||
|
||||
I2C_M_SETUP_Type transferMCfg;
|
||||
|
||||
#define I2C_status (LPC_I2C1->I2STAT & I2C_STAT_CODE_BITMASK)
|
||||
|
||||
uint8_t digipot_mcp4451_start(uint8_t sla) { // send slave address and write bit
|
||||
// Sometimes TX data ACK or NAK status is returned. That mean the start state didn't
|
||||
// happen which means only the value of the slave address was send. Keep looping until
|
||||
@@ -102,5 +73,5 @@ uint8_t digipot_mcp4451_send_byte(uint8_t data) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // MB(MKS_SBASE)
|
||||
#endif // DIGIPOT_MCP4451 && MKS_SBASE
|
||||
#endif // TARGET_LPC1768
|
||||
|
||||
@@ -63,6 +63,32 @@ void configure_i2c(const uint8_t clock_option) {
|
||||
I2C_Cmd(I2CDEV_M, I2C_MASTER_MODE, ENABLE);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// These two routines are exact copies of the lpc17xx_i2c.c routines. Couldn't link to
|
||||
// to the lpc17xx_i2c.c routines so had to copy them into this file & rename them.
|
||||
|
||||
uint32_t _I2C_Start(LPC_I2C_TypeDef *I2Cx) {
|
||||
// Reset STA, STO, SI
|
||||
I2Cx->I2CONCLR = I2C_I2CONCLR_SIC|I2C_I2CONCLR_STOC|I2C_I2CONCLR_STAC;
|
||||
|
||||
// Enter to Master Transmitter mode
|
||||
I2Cx->I2CONSET = I2C_I2CONSET_STA;
|
||||
|
||||
// Wait for complete
|
||||
while (!(I2Cx->I2CONSET & I2C_I2CONSET_SI));
|
||||
I2Cx->I2CONCLR = I2C_I2CONCLR_STAC;
|
||||
return (I2Cx->I2STAT & I2C_STAT_CODE_BITMASK);
|
||||
}
|
||||
|
||||
void _I2C_Stop(LPC_I2C_TypeDef *I2Cx) {
|
||||
/* Make sure start bit is not active */
|
||||
if (I2Cx->I2CONSET & I2C_I2CONSET_STA)
|
||||
I2Cx->I2CONCLR = I2C_I2CONCLR_STAC;
|
||||
|
||||
I2Cx->I2CONSET = I2C_I2CONSET_STO|I2C_I2CONSET_AA;
|
||||
I2Cx->I2CONCLR = I2C_I2CONCLR_SIC;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -51,6 +51,11 @@
|
||||
|
||||
void configure_i2c(const uint8_t clock_option);
|
||||
|
||||
uint32_t _I2C_Start(LPC_I2C_TypeDef *I2Cx);
|
||||
void _I2C_Stop(LPC_I2C_TypeDef *I2Cx);
|
||||
|
||||
#define I2C_status (LPC_I2C1->I2STAT & I2C_STAT_CODE_BITMASK)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -48,7 +48,7 @@ void SysTick_Callback() { disk_timerproc(); }
|
||||
|
||||
TERN_(POSTMORTEM_DEBUGGING, extern void install_min_serial());
|
||||
|
||||
void HAL_init() {
|
||||
void MarlinHAL::init() {
|
||||
|
||||
// Init LEDs
|
||||
#if PIN_EXISTS(LED)
|
||||
@@ -130,7 +130,7 @@ void HAL_init() {
|
||||
const millis_t usb_timeout = millis() + 2000;
|
||||
while (!USB_Configuration && PENDING(millis(), usb_timeout)) {
|
||||
delay(50);
|
||||
HAL_idletask();
|
||||
idletask();
|
||||
#if PIN_EXISTS(LED)
|
||||
TOGGLE(LED_PIN); // Flash quickly during USB initialization
|
||||
#endif
|
||||
@@ -142,7 +142,7 @@ void HAL_init() {
|
||||
}
|
||||
|
||||
// HAL idle task
|
||||
void HAL_idletask() {
|
||||
void MarlinHAL::idletask() {
|
||||
#if HAS_SHARED_MEDIA
|
||||
// If Marlin is using the SD card we need to lock it to prevent access from
|
||||
// a PC via USB.
|
||||
|
||||
@@ -170,4 +170,4 @@ FORCE_INLINE static void HAL_timer_isr_prologue(const uint8_t timer_num) {
|
||||
}
|
||||
}
|
||||
|
||||
#define HAL_timer_isr_epilogue(T)
|
||||
#define HAL_timer_isr_epilogue(T) NOOP
|
||||
|
||||
@@ -36,40 +36,7 @@ extern int millis();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// These two routines are exact copies of the lpc17xx_i2c.c routines. Couldn't link to
|
||||
// to the lpc17xx_i2c.c routines so had to copy them into this file & rename them.
|
||||
|
||||
static uint32_t _I2C_Start(LPC_I2C_TypeDef *I2Cx) {
|
||||
// Reset STA, STO, SI
|
||||
I2Cx->I2CONCLR = I2C_I2CONCLR_SIC|I2C_I2CONCLR_STOC|I2C_I2CONCLR_STAC;
|
||||
|
||||
// Enter to Master Transmitter mode
|
||||
I2Cx->I2CONSET = I2C_I2CONSET_STA;
|
||||
|
||||
// Wait for complete
|
||||
while (!(I2Cx->I2CONSET & I2C_I2CONSET_SI));
|
||||
I2Cx->I2CONCLR = I2C_I2CONCLR_STAC;
|
||||
return (I2Cx->I2STAT & I2C_STAT_CODE_BITMASK);
|
||||
}
|
||||
|
||||
static void _I2C_Stop (LPC_I2C_TypeDef *I2Cx) {
|
||||
/* Make sure start bit is not active */
|
||||
if (I2Cx->I2CONSET & I2C_I2CONSET_STA)
|
||||
I2Cx->I2CONCLR = I2C_I2CONCLR_STAC;
|
||||
|
||||
I2Cx->I2CONSET = I2C_I2CONSET_STO|I2C_I2CONSET_AA;
|
||||
I2Cx->I2CONCLR = I2C_I2CONCLR_SIC;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define I2CDEV_S_ADDR 0x78 // from SSD1306 //actual address is 0x3C - shift left 1 with LSB set to 0 to indicate write
|
||||
|
||||
#define BUFFER_SIZE 0x1 // only do single byte transfers with LCDs
|
||||
|
||||
I2C_M_SETUP_Type transferMCfg;
|
||||
|
||||
#define I2C_status (LPC_I2C1->I2STAT & I2C_STAT_CODE_BITMASK)
|
||||
#define I2CDEV_S_ADDR 0x78 // From SSD1306 (actual address is 0x3C - shift left 1 with LSB set to 0 to indicate write)
|
||||
|
||||
// Send slave address and write bit
|
||||
uint8_t u8g_i2c_start(const uint8_t sla) {
|
||||
@@ -115,7 +82,6 @@ uint8_t u8g_i2c_send_byte(uint8_t data) {
|
||||
void u8g_i2c_stop() {
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
+107
-66
@@ -21,18 +21,10 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#define CPU_32_BIT
|
||||
#define HAL_IDLETASK
|
||||
void HAL_idletask();
|
||||
|
||||
#define F_CPU 100000000
|
||||
#define SystemCoreClock F_CPU
|
||||
#include <stdint.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#undef min
|
||||
#undef max
|
||||
|
||||
#include <algorithm>
|
||||
#include "pinmapping.h"
|
||||
|
||||
@@ -40,8 +32,6 @@ void _printf (const char *format, ...);
|
||||
void _putc(uint8_t c);
|
||||
uint8_t _getc();
|
||||
|
||||
//extern "C" volatile uint32_t _millis;
|
||||
|
||||
//arduino: Print.h
|
||||
#define DEC 10
|
||||
#define HEX 16
|
||||
@@ -58,7 +48,23 @@ uint8_t _getc();
|
||||
#include "watchdog.h"
|
||||
#include "serial.h"
|
||||
|
||||
#define SHARED_SERVOS HAS_SERVOS
|
||||
// ------------------------
|
||||
// Defines
|
||||
// ------------------------
|
||||
|
||||
#define CPU_32_BIT
|
||||
#define SHARED_SERVOS HAS_SERVOS // Use shared/servos.cpp
|
||||
|
||||
#define F_CPU 100000000
|
||||
#define SystemCoreClock F_CPU
|
||||
|
||||
#define CPU_ST7920_DELAY_1 600
|
||||
#define CPU_ST7920_DELAY_2 750
|
||||
#define CPU_ST7920_DELAY_3 750
|
||||
|
||||
// ------------------------
|
||||
// Serial ports
|
||||
// ------------------------
|
||||
|
||||
extern MSerialT serial_stream_0;
|
||||
extern MSerialT serial_stream_1;
|
||||
@@ -98,49 +104,19 @@ extern MSerialT serial_stream_3;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#define CPU_ST7920_DELAY_1 600
|
||||
#define CPU_ST7920_DELAY_2 750
|
||||
#define CPU_ST7920_DELAY_3 750
|
||||
|
||||
//
|
||||
// ------------------------
|
||||
// Interrupts
|
||||
//
|
||||
// ------------------------
|
||||
|
||||
#define CRITICAL_SECTION_START()
|
||||
#define CRITICAL_SECTION_END()
|
||||
#define ISRS_ENABLED()
|
||||
#define ENABLE_ISRS()
|
||||
#define DISABLE_ISRS()
|
||||
|
||||
inline void HAL_init() {}
|
||||
|
||||
// Utility functions
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
int freeMemory();
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
// ------------------------
|
||||
// ADC
|
||||
// ------------------------
|
||||
|
||||
#define HAL_ADC_VREF 5.0
|
||||
#define HAL_ADC_RESOLUTION 10
|
||||
#define HAL_ANALOG_SELECT(ch) HAL_adc_enable_channel(ch)
|
||||
#define HAL_START_ADC(ch) HAL_adc_start_conversion(ch)
|
||||
#define HAL_READ_ADC() HAL_adc_get_result()
|
||||
#define HAL_ADC_READY() true
|
||||
|
||||
void HAL_adc_init();
|
||||
void HAL_adc_enable_channel(const uint8_t ch);
|
||||
void HAL_adc_start_conversion(const uint8_t ch);
|
||||
uint16_t HAL_adc_get_result();
|
||||
|
||||
// PWM
|
||||
inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); }
|
||||
|
||||
// Reset source
|
||||
inline void HAL_clear_reset_source(void) {}
|
||||
inline uint8_t HAL_get_reset_source(void) { return RST_POWER_ON; }
|
||||
|
||||
void HAL_reboot();
|
||||
|
||||
/* ---------------- Delay in cycles */
|
||||
|
||||
@@ -159,29 +135,22 @@ constexpr inline std::size_t strlen_constexpr(const char* str) {
|
||||
// https://github.com/gcc-mirror/gcc/blob/5c7634a0e5f202935aa6c11b6ea953b8bf80a00a/libstdc%2B%2B-v3/include/bits/char_traits.h#L329
|
||||
if (str != nullptr) {
|
||||
std::size_t i = 0;
|
||||
while (str[i] != '\0') {
|
||||
++i;
|
||||
}
|
||||
|
||||
while (str[i] != '\0') ++i;
|
||||
return i;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
constexpr inline int strncmp_constexpr(const char* lhs, const char* rhs, std::size_t count) {
|
||||
// https://github.com/gcc-mirror/gcc/blob/13b9cbfc32fe3ac4c81c4dd9c42d141c8fb95db4/libstdc%2B%2B-v3/include/bits/char_traits.h#L655
|
||||
if (lhs == nullptr || rhs == nullptr) {
|
||||
if (lhs == nullptr || rhs == nullptr)
|
||||
return rhs != nullptr ? -1 : 1;
|
||||
}
|
||||
|
||||
for (std::size_t i = 0; i < count; ++i) {
|
||||
if (lhs[i] != rhs[i]) {
|
||||
for (std::size_t i = 0; i < count; ++i)
|
||||
if (lhs[i] != rhs[i])
|
||||
return lhs[i] < rhs[i] ? -1 : 1;
|
||||
} else if (lhs[i] == '\0') {
|
||||
else if (lhs[i] == '\0')
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -193,14 +162,11 @@ constexpr inline const char* strstr_constexpr(const char* str, const char* targe
|
||||
do {
|
||||
char sc = {};
|
||||
do {
|
||||
if ((sc = *str++) == '\0') {
|
||||
return nullptr;
|
||||
}
|
||||
if ((sc = *str++) == '\0') return nullptr;
|
||||
} while (sc != c);
|
||||
} while (strncmp_constexpr(str, target, len) != 0);
|
||||
--str;
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
@@ -211,12 +177,87 @@ constexpr inline char* strstr_constexpr(char* str, const char* target) {
|
||||
do {
|
||||
char sc = {};
|
||||
do {
|
||||
if ((sc = *str++) == '\0') {
|
||||
return nullptr;
|
||||
}
|
||||
if ((sc = *str++) == '\0') return nullptr;
|
||||
} while (sc != c);
|
||||
} while (strncmp_constexpr(str, target, len) != 0);
|
||||
--str;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
// ------------------------
|
||||
// Class Utilities
|
||||
// ------------------------
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#if GCC_VERSION <= 50000
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#endif
|
||||
|
||||
int freeMemory();
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
// ------------------------
|
||||
// MarlinHAL Class
|
||||
// ------------------------
|
||||
|
||||
class MarlinHAL {
|
||||
public:
|
||||
|
||||
// Earliest possible init, before setup()
|
||||
MarlinHAL() {}
|
||||
|
||||
static void init() {} // Called early in setup()
|
||||
static void init_board() {} // Called less early in setup()
|
||||
static void reboot(); // Restart the firmware from 0x0
|
||||
|
||||
// Interrupts
|
||||
static bool isr_state() { return true; }
|
||||
static void isr_on() {}
|
||||
static void isr_off() {}
|
||||
|
||||
static void delay_ms(const int ms) { _delay_ms(ms); }
|
||||
|
||||
// Tasks, called from idle()
|
||||
static void idletask();
|
||||
|
||||
// Reset
|
||||
static constexpr uint8_t reset_reason = RST_POWER_ON;
|
||||
static uint8_t get_reset_source() { return reset_reason; }
|
||||
static void clear_reset_source() {}
|
||||
|
||||
// Free SRAM
|
||||
static int freeMemory() { return ::freeMemory(); }
|
||||
|
||||
//
|
||||
// ADC Methods
|
||||
//
|
||||
|
||||
static uint8_t active_ch;
|
||||
|
||||
// Called by Temperature::init once at startup
|
||||
static void adc_init();
|
||||
|
||||
// Called by Temperature::init for each sensor at startup
|
||||
static void adc_enable(const uint8_t ch);
|
||||
|
||||
// Begin ADC sampling on the given channel
|
||||
static void adc_start(const uint8_t ch);
|
||||
|
||||
// Is the ADC ready for reading?
|
||||
static bool adc_ready();
|
||||
|
||||
// The current value of the ADC register
|
||||
static uint16_t adc_value();
|
||||
|
||||
/**
|
||||
* Set the PWM duty cycle for the pin to the given value.
|
||||
* No option to invert the duty cycle [default = false]
|
||||
* No option to change the scale of the provided value to enable finer PWM duty control [default = 255]
|
||||
*/
|
||||
static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) {
|
||||
analogWrite(pin, v);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -87,5 +87,5 @@ void HAL_timer_enable_interrupt(const uint8_t timer_num);
|
||||
void HAL_timer_disable_interrupt(const uint8_t timer_num);
|
||||
bool HAL_timer_interrupt_enabled(const uint8_t timer_num);
|
||||
|
||||
#define HAL_timer_isr_prologue(T)
|
||||
#define HAL_timer_isr_epilogue(T)
|
||||
#define HAL_timer_isr_prologue(T) NOOP
|
||||
#define HAL_timer_isr_epilogue(T) NOOP
|
||||
|
||||
+182
-47
@@ -42,10 +42,6 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// ------------------------
|
||||
// Local defines
|
||||
// ------------------------
|
||||
|
||||
#define GET_TEMP_0_ADC() TERN(HAS_TEMP_ADC_0, PIN_TO_ADC(TEMP_0_PIN), -1)
|
||||
#define GET_TEMP_1_ADC() TERN(HAS_TEMP_ADC_1, PIN_TO_ADC(TEMP_1_PIN), -1)
|
||||
#define GET_TEMP_2_ADC() TERN(HAS_TEMP_ADC_2, PIN_TO_ADC(TEMP_2_PIN), -1)
|
||||
@@ -61,17 +57,21 @@
|
||||
#define GET_BOARD_ADC() TERN(HAS_TEMP_ADC_BOARD, PIN_TO_ADC(TEMP_BOARD_PIN), -1)
|
||||
#define GET_FILAMENT_WIDTH_ADC() TERN(FILAMENT_WIDTH_SENSOR, PIN_TO_ADC(FILWIDTH_PIN), -1)
|
||||
#define GET_BUTTONS_ADC() TERN(HAS_ADC_BUTTONS, PIN_TO_ADC(ADC_KEYPAD_PIN), -1)
|
||||
#define GET_JOY_ADC_X() TERN(HAS_JOY_ADC_X, PIN_TO_ADC(JOY_X_PIN), -1)
|
||||
#define GET_JOY_ADC_Y() TERN(HAS_JOY_ADC_Y, PIN_TO_ADC(JOY_Y_PIN), -1)
|
||||
#define GET_JOY_ADC_Z() TERN(HAS_JOY_ADC_Z, PIN_TO_ADC(JOY_Z_PIN), -1)
|
||||
|
||||
#define IS_ADC_REQUIRED(n) ( \
|
||||
GET_TEMP_0_ADC() == n || GET_TEMP_1_ADC() == n || GET_TEMP_2_ADC() == n || GET_TEMP_3_ADC() == n \
|
||||
|| GET_TEMP_4_ADC() == n || GET_TEMP_5_ADC() == n || GET_TEMP_6_ADC() == n || GET_TEMP_7_ADC() == n \
|
||||
|| GET_BED_ADC() == n \
|
||||
|| GET_CHAMBER_ADC() == n \
|
||||
|| GET_PROBE_ADC() == n \
|
||||
|| GET_COOLER_ADC() == n \
|
||||
|| GET_BOARD_ADC() == n \
|
||||
|| GET_BED_ADC() == n \
|
||||
|| GET_CHAMBER_ADC() == n \
|
||||
|| GET_PROBE_ADC() == n \
|
||||
|| GET_COOLER_ADC() == n \
|
||||
|| GET_BOARD_ADC() == n \
|
||||
|| GET_FILAMENT_WIDTH_ADC() == n \
|
||||
|| GET_BUTTONS_ADC() == n \
|
||||
|| GET_BUTTONS_ADC() == n \
|
||||
|| GET_JOY_ADC_X() == n || GET_JOY_ADC_Y() == n || GET_JOY_ADC_Z() == n \
|
||||
)
|
||||
|
||||
#if IS_ADC_REQUIRED(0)
|
||||
@@ -91,6 +91,118 @@
|
||||
#define DMA_IS_REQUIRED 1
|
||||
#endif
|
||||
|
||||
enum ADCIndex {
|
||||
#if GET_TEMP_0_ADC() == 0
|
||||
TEMP_0,
|
||||
#endif
|
||||
#if GET_TEMP_1_ADC() == 0
|
||||
TEMP_1,
|
||||
#endif
|
||||
#if GET_TEMP_2_ADC() == 0
|
||||
TEMP_2,
|
||||
#endif
|
||||
#if GET_TEMP_3_ADC() == 0
|
||||
TEMP_3,
|
||||
#endif
|
||||
#if GET_TEMP_4_ADC() == 0
|
||||
TEMP_4,
|
||||
#endif
|
||||
#if GET_TEMP_5_ADC() == 0
|
||||
TEMP_5,
|
||||
#endif
|
||||
#if GET_TEMP_6_ADC() == 0
|
||||
TEMP_6,
|
||||
#endif
|
||||
#if GET_TEMP_7_ADC() == 0
|
||||
TEMP_7,
|
||||
#endif
|
||||
#if GET_BED_ADC() == 0
|
||||
TEMP_BED,
|
||||
#endif
|
||||
#if GET_CHAMBER_ADC() == 0
|
||||
TEMP_CHAMBER,
|
||||
#endif
|
||||
#if GET_PROBE_ADC() == 0
|
||||
TEMP_PROBE,
|
||||
#endif
|
||||
#if GET_COOLER_ADC() == 0
|
||||
TEMP_COOLER,
|
||||
#endif
|
||||
#if GET_BOARD_ADC() == 0
|
||||
TEMP_BOARD,
|
||||
#endif
|
||||
#if GET_FILAMENT_WIDTH_ADC() == 0
|
||||
FILWIDTH,
|
||||
#endif
|
||||
#if GET_BUTTONS_ADC() == 0
|
||||
ADC_KEY,
|
||||
#endif
|
||||
#if GET_JOY_ADC_X() == 0
|
||||
JOY_X,
|
||||
#endif
|
||||
#if GET_JOY_ADC_Y() == 0
|
||||
JOY_Y,
|
||||
#endif
|
||||
#if GET_JOY_ADC_Z() == 0
|
||||
JOY_Z,
|
||||
#endif
|
||||
#if GET_TEMP_0_ADC() == 1
|
||||
TEMP_0,
|
||||
#endif
|
||||
#if GET_TEMP_1_ADC() == 1
|
||||
TEMP_1,
|
||||
#endif
|
||||
#if GET_TEMP_2_ADC() == 1
|
||||
TEMP_2,
|
||||
#endif
|
||||
#if GET_TEMP_3_ADC() == 1
|
||||
TEMP_3,
|
||||
#endif
|
||||
#if GET_TEMP_4_ADC() == 1
|
||||
TEMP_4,
|
||||
#endif
|
||||
#if GET_TEMP_5_ADC() == 1
|
||||
TEMP_5,
|
||||
#endif
|
||||
#if GET_TEMP_6_ADC() == 1
|
||||
TEMP_6,
|
||||
#endif
|
||||
#if GET_TEMP_7_ADC() == 1
|
||||
TEMP_7,
|
||||
#endif
|
||||
#if GET_BED_ADC() == 1
|
||||
TEMP_BED,
|
||||
#endif
|
||||
#if GET_CHAMBER_ADC() == 1
|
||||
TEMP_CHAMBER,
|
||||
#endif
|
||||
#if GET_PROBE_ADC() == 1
|
||||
TEMP_PROBE,
|
||||
#endif
|
||||
#if GET_COOLER_ADC() == 1
|
||||
TEMP_COOLER,
|
||||
#endif
|
||||
#if GET_BOARD_ADC() == 1
|
||||
TEMP_BOARD,
|
||||
#endif
|
||||
#if GET_FILAMENT_WIDTH_ADC() == 1
|
||||
FILWIDTH,
|
||||
#endif
|
||||
#if GET_BUTTONS_ADC() == 1
|
||||
ADC_KEY,
|
||||
#endif
|
||||
#if GET_JOY_ADC_X() == 1
|
||||
JOY_X,
|
||||
#endif
|
||||
#if GET_JOY_ADC_Y() == 1
|
||||
JOY_Y,
|
||||
#endif
|
||||
#if GET_JOY_ADC_Z() == 1
|
||||
JOY_Z,
|
||||
#endif
|
||||
ADC_COUNT
|
||||
};
|
||||
|
||||
// ------------------------
|
||||
// Types
|
||||
// ------------------------
|
||||
@@ -108,12 +220,10 @@
|
||||
// Private Variables
|
||||
// ------------------------
|
||||
|
||||
uint16_t HAL_adc_result;
|
||||
|
||||
#if ADC_IS_REQUIRED
|
||||
|
||||
// Pins used by ADC inputs. Order must be ADC0 inputs first then ADC1
|
||||
const uint8_t adc_pins[] = {
|
||||
static constexpr uint8_t adc_pins[ADC_COUNT] = {
|
||||
// ADC0 pins
|
||||
#if GET_TEMP_0_ADC() == 0
|
||||
TEMP_0_PIN,
|
||||
@@ -160,6 +270,15 @@ uint16_t HAL_adc_result;
|
||||
#if GET_BUTTONS_ADC() == 0
|
||||
ADC_KEYPAD_PIN,
|
||||
#endif
|
||||
#if GET_JOY_ADC_X() == 0
|
||||
JOY_X_PIN,
|
||||
#endif
|
||||
#if GET_JOY_ADC_Y() == 0
|
||||
JOY_Y_PIN,
|
||||
#endif
|
||||
#if GET_JOY_ADC_Z() == 0
|
||||
JOY_Z_PIN,
|
||||
#endif
|
||||
// ADC1 pins
|
||||
#if GET_TEMP_0_ADC() == 1
|
||||
TEMP_0_PIN,
|
||||
@@ -206,15 +325,23 @@ uint16_t HAL_adc_result;
|
||||
#if GET_BUTTONS_ADC() == 1
|
||||
ADC_KEYPAD_PIN,
|
||||
#endif
|
||||
#if GET_JOY_ADC_X() == 1
|
||||
JOY_X_PIN,
|
||||
#endif
|
||||
#if GET_JOY_ADC_Y() == 1
|
||||
JOY_Y_PIN,
|
||||
#endif
|
||||
#if GET_JOY_ADC_Z() == 1
|
||||
JOY_Z_PIN,
|
||||
#endif
|
||||
};
|
||||
|
||||
uint16_t HAL_adc_results[COUNT(adc_pins)];
|
||||
static uint16_t adc_results[ADC_COUNT];
|
||||
|
||||
#if ADC0_IS_REQUIRED
|
||||
Adafruit_ZeroDMA adc0DMAProgram,
|
||||
adc0DMARead;
|
||||
Adafruit_ZeroDMA adc0DMAProgram, adc0DMARead;
|
||||
|
||||
const HAL_DMA_DAC_Registers adc0_dma_regs_list[] = {
|
||||
static constexpr HAL_DMA_DAC_Registers adc0_dma_regs_list[ADC_COUNT] = {
|
||||
#if GET_TEMP_0_ADC() == 0
|
||||
{ PIN_TO_INPUTCTRL(TEMP_0_PIN) },
|
||||
#endif
|
||||
@@ -260,16 +387,24 @@ uint16_t HAL_adc_result;
|
||||
#if GET_BUTTONS_ADC() == 0
|
||||
{ PIN_TO_INPUTCTRL(ADC_KEYPAD_PIN) },
|
||||
#endif
|
||||
#if GET_JOY_ADC_X() == 0
|
||||
{ PIN_TO_INPUTCTRL(JOY_X_PIN) },
|
||||
#endif
|
||||
#if GET_JOY_ADC_Y() == 0
|
||||
{ PIN_TO_INPUTCTRL(JOY_Y_PIN) },
|
||||
#endif
|
||||
#if GET_JOY_ADC_Z() == 0
|
||||
{ PIN_TO_INPUTCTRL(JOY_Z_PIN) },
|
||||
#endif
|
||||
};
|
||||
|
||||
#define ADC0_AINCOUNT COUNT(adc0_dma_regs_list)
|
||||
#endif // ADC0_IS_REQUIRED
|
||||
|
||||
#if ADC1_IS_REQUIRED
|
||||
Adafruit_ZeroDMA adc1DMAProgram,
|
||||
adc1DMARead;
|
||||
Adafruit_ZeroDMA adc1DMAProgram, adc1DMARead;
|
||||
|
||||
const HAL_DMA_DAC_Registers adc1_dma_regs_list[] = {
|
||||
static constexpr HAL_DMA_DAC_Registers adc1_dma_regs_list[ADC_COUNT] = {
|
||||
#if GET_TEMP_0_ADC() == 1
|
||||
{ PIN_TO_INPUTCTRL(TEMP_0_PIN) },
|
||||
#endif
|
||||
@@ -315,6 +450,15 @@ uint16_t HAL_adc_result;
|
||||
#if GET_BUTTONS_ADC() == 1
|
||||
{ PIN_TO_INPUTCTRL(ADC_KEYPAD_PIN) },
|
||||
#endif
|
||||
#if GET_JOY_ADC_X() == 1
|
||||
{ PIN_TO_INPUTCTRL(JOY_X_PIN) },
|
||||
#endif
|
||||
#if GET_JOY_ADC_Y() == 1
|
||||
{ PIN_TO_INPUTCTRL(JOY_Y_PIN) },
|
||||
#endif
|
||||
#if GET_JOY_ADC_Z() == 1
|
||||
{ PIN_TO_INPUTCTRL(JOY_Z_PIN) },
|
||||
#endif
|
||||
};
|
||||
|
||||
#define ADC1_AINCOUNT COUNT(adc1_dma_regs_list)
|
||||
@@ -326,9 +470,10 @@ uint16_t HAL_adc_result;
|
||||
// Private functions
|
||||
// ------------------------
|
||||
|
||||
#if DMA_IS_REQUIRED
|
||||
void MarlinHAL::dma_init() {
|
||||
|
||||
#if DMA_IS_REQUIRED
|
||||
|
||||
void dma_init() {
|
||||
DmacDescriptor *descriptor;
|
||||
|
||||
#if ADC0_IS_REQUIRED
|
||||
@@ -357,7 +502,7 @@ uint16_t HAL_adc_result;
|
||||
if (adc0DMARead.allocate() == DMA_STATUS_OK) {
|
||||
adc0DMARead.addDescriptor(
|
||||
(void *)&ADC0->RESULT.reg, // SRC
|
||||
&HAL_adc_results, // DEST
|
||||
&adc_results, // DEST
|
||||
ADC0_AINCOUNT, // CNT
|
||||
DMA_BEAT_SIZE_HWORD,
|
||||
false, // SRCINC
|
||||
@@ -394,7 +539,7 @@ uint16_t HAL_adc_result;
|
||||
if (adc1DMARead.allocate() == DMA_STATUS_OK) {
|
||||
adc1DMARead.addDescriptor(
|
||||
(void *)&ADC1->RESULT.reg, // SRC
|
||||
&HAL_adc_results[ADC0_AINCOUNT], // DEST
|
||||
&adc_results[ADC0_AINCOUNT], // DEST
|
||||
ADC1_AINCOUNT, // CNT
|
||||
DMA_BEAT_SIZE_HWORD,
|
||||
false, // SRCINC
|
||||
@@ -407,16 +552,16 @@ uint16_t HAL_adc_result;
|
||||
#endif
|
||||
|
||||
DMAC->PRICTRL0.bit.RRLVLEN0 = true; // Activate round robin for DMA channels required by ADCs
|
||||
}
|
||||
|
||||
#endif // DMA_IS_REQUIRED
|
||||
#endif // DMA_IS_REQUIRED
|
||||
}
|
||||
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// ------------------------
|
||||
|
||||
// HAL initialization task
|
||||
void HAL_init() {
|
||||
void MarlinHAL::init() {
|
||||
TERN_(DMA_IS_REQUIRED, dma_init());
|
||||
#if ENABLED(SDSUPPORT)
|
||||
#if SD_CONNECTION_IS(ONBOARD) && PIN_EXISTS(SD_DETECT)
|
||||
@@ -426,17 +571,9 @@ void HAL_init() {
|
||||
#endif
|
||||
}
|
||||
|
||||
// HAL idle task
|
||||
/*
|
||||
void HAL_idletask() {
|
||||
}
|
||||
*/
|
||||
|
||||
void HAL_clear_reset_source() { }
|
||||
|
||||
#pragma push_macro("WDT")
|
||||
#undef WDT // Required to be able to use '.bit.WDT'. Compiler wrongly replace struct field with WDT define
|
||||
uint8_t HAL_get_reset_source() {
|
||||
uint8_t MarlinHAL::get_reset_source() {
|
||||
RSTC_RCAUSE_Type resetCause;
|
||||
|
||||
resetCause.reg = REG_RSTC_RCAUSE;
|
||||
@@ -450,7 +587,7 @@ uint8_t HAL_get_reset_source() {
|
||||
}
|
||||
#pragma pop_macro("WDT")
|
||||
|
||||
void HAL_reboot() { NVIC_SystemReset(); }
|
||||
void MarlinHAL::reboot() { NVIC_SystemReset(); }
|
||||
|
||||
extern "C" {
|
||||
void * _sbrk(int incr);
|
||||
@@ -468,9 +605,11 @@ int freeMemory() {
|
||||
// ADC
|
||||
// ------------------------
|
||||
|
||||
void HAL_adc_init() {
|
||||
uint16_t MarlinHAL::adc_result;
|
||||
|
||||
void MarlinHAL::adc_init() {
|
||||
#if ADC_IS_REQUIRED
|
||||
memset(HAL_adc_results, 0xFF, sizeof(HAL_adc_results)); // Fill result with invalid values
|
||||
memset(adc_results, 0xFF, sizeof(adc_results)); // Fill result with invalid values
|
||||
|
||||
LOOP_L_N(pi, COUNT(adc_pins))
|
||||
pinPeripheral(adc_pins[pi], PIO_ANALOG);
|
||||
@@ -505,17 +644,13 @@ void HAL_adc_init() {
|
||||
#endif // ADC_IS_REQUIRED
|
||||
}
|
||||
|
||||
void HAL_adc_start_conversion(const uint8_t adc_pin) {
|
||||
void MarlinHAL::adc_start(const pin_t pin) {
|
||||
#if ADC_IS_REQUIRED
|
||||
LOOP_L_N(pi, COUNT(adc_pins)) {
|
||||
if (adc_pin == adc_pins[pi]) {
|
||||
HAL_adc_result = HAL_adc_results[pi];
|
||||
return;
|
||||
}
|
||||
}
|
||||
LOOP_L_N(pi, COUNT(adc_pins))
|
||||
if (pin == adc_pins[pi]) { adc_result = adc_results[pi]; return; }
|
||||
#endif
|
||||
|
||||
HAL_adc_result = 0xFFFF;
|
||||
adc_result = 0xFFFF;
|
||||
}
|
||||
|
||||
#endif // __SAMD51__
|
||||
|
||||
+83
-46
@@ -89,51 +89,30 @@
|
||||
|
||||
typedef int8_t pin_t;
|
||||
|
||||
#define SHARED_SERVOS HAS_SERVOS
|
||||
#define HAL_SERVO_LIB Servo
|
||||
#define SHARED_SERVOS HAS_SERVOS // Use shared/servos.cpp
|
||||
|
||||
class Servo;
|
||||
typedef Servo hal_servo_t;
|
||||
|
||||
//
|
||||
// Interrupts
|
||||
//
|
||||
#define CRITICAL_SECTION_START() uint32_t primask = __get_PRIMASK(); __disable_irq()
|
||||
#define CRITICAL_SECTION_END() if (!primask) __enable_irq()
|
||||
#define ISRS_ENABLED() (!__get_PRIMASK())
|
||||
#define ENABLE_ISRS() __enable_irq()
|
||||
#define DISABLE_ISRS() __disable_irq()
|
||||
#define CRITICAL_SECTION_START() const bool irqon = !__get_PRIMASK(); __disable_irq()
|
||||
#define CRITICAL_SECTION_END() if (irqon) __enable_irq()
|
||||
|
||||
#define cli() __disable_irq() // Disable interrupts
|
||||
#define sei() __enable_irq() // Enable interrupts
|
||||
|
||||
void HAL_clear_reset_source(); // clear reset reason
|
||||
uint8_t HAL_get_reset_source(); // get reset reason
|
||||
|
||||
void HAL_reboot();
|
||||
#define cli() __disable_irq() // Disable interrupts
|
||||
#define sei() __enable_irq() // Enable interrupts
|
||||
|
||||
//
|
||||
// ADC
|
||||
//
|
||||
extern uint16_t HAL_adc_result; // Most recent ADC conversion
|
||||
|
||||
#define HAL_ANALOG_SELECT(pin)
|
||||
|
||||
void HAL_adc_init();
|
||||
|
||||
//#define HAL_ADC_FILTERED // Disable Marlin's oversampling. The HAL filters ADC values.
|
||||
#define HAL_ADC_VREF 3.3
|
||||
#define HAL_ADC_RESOLUTION 10 // ... 12
|
||||
#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
|
||||
#define HAL_READ_ADC() HAL_adc_result
|
||||
#define HAL_ADC_READY() true
|
||||
|
||||
void HAL_adc_start_conversion(const uint8_t adc_pin);
|
||||
|
||||
//
|
||||
// PWM
|
||||
//
|
||||
inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); }
|
||||
|
||||
//
|
||||
// Pin Map
|
||||
// Pin Mapping for M42, M43, M226
|
||||
//
|
||||
#define GET_PIN_MAP_PIN(index) index
|
||||
#define GET_PIN_MAP_INDEX(pin) pin
|
||||
@@ -142,35 +121,93 @@ inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255,
|
||||
//
|
||||
// Tone
|
||||
//
|
||||
void toneInit();
|
||||
void tone(const pin_t _pin, const unsigned int frequency, const unsigned long duration=0);
|
||||
void noTone(const pin_t _pin);
|
||||
|
||||
// Enable hooks into idle and setup for HAL
|
||||
void HAL_init();
|
||||
/*
|
||||
#define HAL_IDLETASK 1
|
||||
void HAL_idletask();
|
||||
*/
|
||||
|
||||
//
|
||||
// Utility functions
|
||||
//
|
||||
FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); }
|
||||
// ------------------------
|
||||
// Class Utilities
|
||||
// ------------------------
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#if GCC_VERSION <= 50000
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#endif
|
||||
|
||||
int freeMemory();
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
char *dtostrf(double __val, signed char __width, unsigned char __prec, char *__s);
|
||||
|
||||
extern "C" int freeMemory();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
// ------------------------
|
||||
// MarlinHAL Class
|
||||
// ------------------------
|
||||
|
||||
class MarlinHAL {
|
||||
public:
|
||||
|
||||
// Earliest possible init, before setup()
|
||||
MarlinHAL() {}
|
||||
|
||||
static void init(); // Called early in setup()
|
||||
static void init_board() {} // Called less early in setup()
|
||||
static void reboot(); // Restart the firmware from 0x0
|
||||
|
||||
// Interrupts
|
||||
static bool isr_state() { return !__get_PRIMASK(); }
|
||||
static void isr_on() { sei(); }
|
||||
static void isr_off() { cli(); }
|
||||
|
||||
static void delay_ms(const int ms) { delay(ms); }
|
||||
|
||||
// Tasks, called from idle()
|
||||
static void idletask() {}
|
||||
|
||||
// Reset
|
||||
static uint8_t get_reset_source();
|
||||
static void clear_reset_source() {}
|
||||
|
||||
// Free SRAM
|
||||
static int freeMemory() { return ::freeMemory(); }
|
||||
|
||||
//
|
||||
// ADC Methods
|
||||
//
|
||||
|
||||
static uint16_t adc_result;
|
||||
|
||||
// Called by Temperature::init once at startup
|
||||
static void adc_init();
|
||||
|
||||
// Called by Temperature::init for each sensor at startup
|
||||
static void adc_enable(const uint8_t ch) {}
|
||||
|
||||
// Begin ADC sampling on the given channel
|
||||
static void adc_start(const pin_t pin);
|
||||
|
||||
// Is the ADC ready for reading?
|
||||
static bool adc_ready() { return true; }
|
||||
|
||||
// The current value of the ADC register
|
||||
static uint16_t adc_value() { return adc_result; }
|
||||
|
||||
/**
|
||||
* Set the PWM duty cycle for the pin to the given value.
|
||||
* No option to invert the duty cycle [default = false]
|
||||
* No option to change the scale of the provided value to enable finer PWM duty control [default = 255]
|
||||
*/
|
||||
static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) {
|
||||
analogWrite(pin, v);
|
||||
}
|
||||
|
||||
private:
|
||||
static void dma_init();
|
||||
};
|
||||
|
||||
@@ -60,6 +60,12 @@
|
||||
#define MATCH_J_MIN_EILINE(P) TERN0(HAS_J_MIN, DEFER4(MATCH_EILINE)(P, J_MIN_PIN))
|
||||
#define MATCH_K_MAX_EILINE(P) TERN0(HAS_K_MAX, DEFER4(MATCH_EILINE)(P, K_MAX_PIN))
|
||||
#define MATCH_K_MIN_EILINE(P) TERN0(HAS_K_MIN, DEFER4(MATCH_EILINE)(P, K_MIN_PIN))
|
||||
#define MATCH_U_MAX_EILINE(P) TERN0(HAS_U_MAX, DEFER4(MATCH_EILINE)(P, U_MAX_PIN))
|
||||
#define MATCH_U_MIN_EILINE(P) TERN0(HAS_U_MIN, DEFER4(MATCH_EILINE)(P, U_MIN_PIN))
|
||||
#define MATCH_V_MAX_EILINE(P) TERN0(HAS_V_MAX, DEFER4(MATCH_EILINE)(P, V_MAX_PIN))
|
||||
#define MATCH_V_MIN_EILINE(P) TERN0(HAS_V_MIN, DEFER4(MATCH_EILINE)(P, V_MIN_PIN))
|
||||
#define MATCH_W_MAX_EILINE(P) TERN0(HAS_W_MAX, DEFER4(MATCH_EILINE)(P, W_MAX_PIN))
|
||||
#define MATCH_W_MIN_EILINE(P) TERN0(HAS_W_MIN, DEFER4(MATCH_EILINE)(P, W_MIN_PIN))
|
||||
#define MATCH_Z2_MAX_EILINE(P) TERN0(HAS_Z2_MAX, DEFER4(MATCH_EILINE)(P, Z2_MAX_PIN))
|
||||
#define MATCH_Z2_MIN_EILINE(P) TERN0(HAS_Z2_MIN, DEFER4(MATCH_EILINE)(P, Z2_MIN_PIN))
|
||||
#define MATCH_Z3_MAX_EILINE(P) TERN0(HAS_Z3_MAX, DEFER4(MATCH_EILINE)(P, Z3_MAX_PIN))
|
||||
@@ -75,6 +81,9 @@
|
||||
&& !MATCH_I_MAX_EILINE(P) && !MATCH_I_MIN_EILINE(P) \
|
||||
&& !MATCH_J_MAX_EILINE(P) && !MATCH_J_MIN_EILINE(P) \
|
||||
&& !MATCH_K_MAX_EILINE(P) && !MATCH_K_MIN_EILINE(P) \
|
||||
&& !MATCH_U_MAX_EILINE(P) && !MATCH_U_MIN_EILINE(P) \
|
||||
&& !MATCH_V_MAX_EILINE(P) && !MATCH_V_MIN_EILINE(P) \
|
||||
&& !MATCH_W_MAX_EILINE(P) && !MATCH_W_MIN_EILINE(P) \
|
||||
&& !MATCH_Z2_MAX_EILINE(P) && !MATCH_Z2_MIN_EILINE(P) \
|
||||
&& !MATCH_Z3_MAX_EILINE(P) && !MATCH_Z3_MIN_EILINE(P) \
|
||||
&& !MATCH_Z4_MAX_EILINE(P) && !MATCH_Z4_MIN_EILINE(P) \
|
||||
@@ -199,4 +208,40 @@ void setup_endstop_interrupts() {
|
||||
#endif
|
||||
attachInterrupt(K_MIN_PIN, endstop_ISR, CHANGE);
|
||||
#endif
|
||||
#if HAS_U_MAX
|
||||
#if !AVAILABLE_EILINE(U_MAX_PIN)
|
||||
#error "U_MAX_PIN has no EXTINT line available."
|
||||
#endif
|
||||
attachInterrupt(U_MAX_PIN, endstop_ISR, CHANGE);
|
||||
#endif
|
||||
#if HAS_U_MIN
|
||||
#if !AVAILABLE_EILINE(U_MIN_PIN)
|
||||
#error "U_MIN_PIN has no EXTINT line available."
|
||||
#endif
|
||||
attachInterrupt(U_MIN_PIN, endstop_ISR, CHANGE);
|
||||
#endif
|
||||
#if HAS_V_MAX
|
||||
#if !AVAILABLE_EILINE(V_MAX_PIN)
|
||||
#error "V_MAX_PIN has no EXTINT line available."
|
||||
#endif
|
||||
attachInterrupt(V_MAX_PIN, endstop_ISR, CHANGE);
|
||||
#endif
|
||||
#if HAS_V_MIN
|
||||
#if !AVAILABLE_EILINE(V_MIN_PIN)
|
||||
#error "V_MIN_PIN has no EXTINT line available."
|
||||
#endif
|
||||
attachInterrupt(V_MIN_PIN, endstop_ISR, CHANGE);
|
||||
#endif
|
||||
#if HAS_W_MAX
|
||||
#if !AVAILABLE_EILINE(W_MAX_PIN)
|
||||
#error "W_MAX_PIN has no EXTINT line available."
|
||||
#endif
|
||||
attachInterrupt(W_MAX_PIN, endstop_ISR, CHANGE);
|
||||
#endif
|
||||
#if HAS_W_MIN
|
||||
#if !AVAILABLE_EILINE(W_MIN_PIN)
|
||||
#error "W_MIN_PIN has no EXTINT line available."
|
||||
#endif
|
||||
attachInterrupt(W_MIN_PIN, endstop_ISR, CHANGE);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -53,16 +53,18 @@
|
||||
// Public Variables
|
||||
// ------------------------
|
||||
|
||||
uint16_t HAL_adc_result;
|
||||
uint16_t MarlinHAL::adc_result;
|
||||
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// ------------------------
|
||||
|
||||
TERN_(POSTMORTEM_DEBUGGING, extern void install_min_serial());
|
||||
#if ENABLED(POSTMORTEM_DEBUGGING)
|
||||
extern void install_min_serial();
|
||||
#endif
|
||||
|
||||
// HAL initialization task
|
||||
void HAL_init() {
|
||||
void MarlinHAL::init() {
|
||||
// Ensure F_CPU is a constant expression.
|
||||
// If the compiler breaks here, it means that delay code that should compute at compile time will not work.
|
||||
// So better safe than sorry here.
|
||||
@@ -87,7 +89,7 @@ void HAL_init() {
|
||||
|
||||
SetTimerInterruptPriorities();
|
||||
|
||||
#if ENABLED(EMERGENCY_PARSER) && USBD_USE_CDC
|
||||
#if ENABLED(EMERGENCY_PARSER) && (USBD_USE_CDC || USBD_USE_CDC_MSC)
|
||||
USB_Hook_init();
|
||||
#endif
|
||||
|
||||
@@ -103,7 +105,7 @@ void HAL_init() {
|
||||
}
|
||||
|
||||
// HAL idle task
|
||||
void HAL_idletask() {
|
||||
void MarlinHAL::idletask() {
|
||||
#if HAS_SHARED_MEDIA
|
||||
// Stm32duino currently doesn't have a "loop/idle" method
|
||||
CDC_resume_receive();
|
||||
@@ -111,9 +113,9 @@ void HAL_idletask() {
|
||||
#endif
|
||||
}
|
||||
|
||||
void HAL_clear_reset_source() { __HAL_RCC_CLEAR_RESET_FLAGS(); }
|
||||
void MarlinHAL::reboot() { NVIC_SystemReset(); }
|
||||
|
||||
uint8_t HAL_get_reset_source() {
|
||||
uint8_t MarlinHAL::get_reset_source() {
|
||||
return
|
||||
#ifdef RCC_FLAG_IWDGRST // Some sources may not exist...
|
||||
RESET != __HAL_RCC_GET_FLAG(RCC_FLAG_IWDGRST) ? RST_WATCHDOG :
|
||||
@@ -137,24 +139,14 @@ uint8_t HAL_get_reset_source() {
|
||||
;
|
||||
}
|
||||
|
||||
void HAL_reboot() { NVIC_SystemReset(); }
|
||||
|
||||
void _delay_ms(const int delay_ms) { delay(delay_ms); }
|
||||
void MarlinHAL::clear_reset_source() { __HAL_RCC_CLEAR_RESET_FLAGS(); }
|
||||
|
||||
extern "C" {
|
||||
extern unsigned int _ebss; // end of bss section
|
||||
}
|
||||
|
||||
// ------------------------
|
||||
// ADC
|
||||
// ------------------------
|
||||
|
||||
// TODO: Make sure this doesn't cause any delay
|
||||
void HAL_adc_start_conversion(const uint8_t adc_pin) { HAL_adc_result = analogRead(adc_pin); }
|
||||
uint16_t HAL_adc_get_result() { return HAL_adc_result; }
|
||||
|
||||
// Reset the system to initiate a firmware flash
|
||||
WEAK void flashFirmware(const int16_t) { HAL_reboot(); }
|
||||
WEAK void flashFirmware(const int16_t) { hal.reboot(); }
|
||||
|
||||
// Maple Compatibility
|
||||
volatile uint32_t systick_uptime_millis = 0;
|
||||
|
||||
+102
-78
@@ -44,9 +44,9 @@
|
||||
#define CPU_ST7920_DELAY_2 40
|
||||
#define CPU_ST7920_DELAY_3 340
|
||||
|
||||
//
|
||||
// Serial Ports
|
||||
//
|
||||
// ------------------------
|
||||
// Serial ports
|
||||
// ------------------------
|
||||
#ifdef USBCON
|
||||
#include <USBSerial.h>
|
||||
#include "../../core/serial_hook.h"
|
||||
@@ -115,17 +115,14 @@
|
||||
#define analogInputToDigitalPin(p) (p)
|
||||
#endif
|
||||
|
||||
#define CRITICAL_SECTION_START() uint32_t primask = __get_PRIMASK(); __disable_irq()
|
||||
#define CRITICAL_SECTION_END() if (!primask) __enable_irq()
|
||||
#define ISRS_ENABLED() (!__get_PRIMASK())
|
||||
#define ENABLE_ISRS() __enable_irq()
|
||||
#define DISABLE_ISRS() __disable_irq()
|
||||
//
|
||||
// Interrupts
|
||||
//
|
||||
#define CRITICAL_SECTION_START() const bool irqon = !__get_PRIMASK(); __disable_irq()
|
||||
#define CRITICAL_SECTION_END() if (irqon) __enable_irq()
|
||||
#define cli() __disable_irq()
|
||||
#define sei() __enable_irq()
|
||||
|
||||
// On AVR this is in math.h?
|
||||
#define square(x) ((x)*(x))
|
||||
|
||||
// ------------------------
|
||||
// Types
|
||||
// ------------------------
|
||||
@@ -136,56 +133,14 @@
|
||||
typedef int16_t pin_t;
|
||||
#endif
|
||||
|
||||
#define HAL_SERVO_LIB libServo
|
||||
class libServo;
|
||||
typedef libServo hal_servo_t;
|
||||
#define PAUSE_SERVO_OUTPUT() libServo::pause_all_servos()
|
||||
#define RESUME_SERVO_OUTPUT() libServo::resume_all_servos()
|
||||
|
||||
// ------------------------
|
||||
// Public Variables
|
||||
// ------------------------
|
||||
|
||||
// result of last ADC conversion
|
||||
extern uint16_t HAL_adc_result;
|
||||
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// ------------------------
|
||||
|
||||
// Memory related
|
||||
#define __bss_end __bss_end__
|
||||
|
||||
// Enable hooks into setup for HAL
|
||||
void HAL_init();
|
||||
#define HAL_IDLETASK 1
|
||||
void HAL_idletask();
|
||||
|
||||
// Clear reset reason
|
||||
void HAL_clear_reset_source();
|
||||
|
||||
// Reset reason
|
||||
uint8_t HAL_get_reset_source();
|
||||
|
||||
void HAL_reboot();
|
||||
|
||||
void _delay_ms(const int delay);
|
||||
|
||||
extern "C" char* _sbrk(int incr);
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
|
||||
static inline int freeMemory() {
|
||||
volatile char top;
|
||||
return &top - reinterpret_cast<char*>(_sbrk(0));
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
//
|
||||
// ADC
|
||||
//
|
||||
|
||||
#define HAL_ANALOG_SELECT(pin) pinMode(pin, INPUT)
|
||||
// ------------------------
|
||||
|
||||
#ifdef ADC_RESOLUTION
|
||||
#define HAL_ADC_RESOLUTION ADC_RESOLUTION
|
||||
@@ -194,16 +149,10 @@ static inline int freeMemory() {
|
||||
#endif
|
||||
|
||||
#define HAL_ADC_VREF 3.3
|
||||
#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
|
||||
#define HAL_READ_ADC() HAL_adc_result
|
||||
#define HAL_ADC_READY() true
|
||||
|
||||
inline void HAL_adc_init() { analogReadResolution(HAL_ADC_RESOLUTION); }
|
||||
|
||||
void HAL_adc_start_conversion(const uint8_t adc_pin);
|
||||
|
||||
uint16_t HAL_adc_get_result();
|
||||
|
||||
//
|
||||
// Pin Mapping for M42, M43, M226
|
||||
//
|
||||
#define GET_PIN_MAP_PIN(index) index
|
||||
#define GET_PIN_MAP_INDEX(pin) pin
|
||||
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
|
||||
@@ -226,17 +175,92 @@ extern volatile uint32_t systick_uptime_millis;
|
||||
|
||||
#define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment
|
||||
|
||||
/**
|
||||
* set_pwm_frequency
|
||||
* Set the frequency of the timer corresponding to the provided pin
|
||||
* All Timer PWM pins run at the same frequency
|
||||
*/
|
||||
void set_pwm_frequency(const pin_t pin, const uint16_t f_desired);
|
||||
// ------------------------
|
||||
// Class Utilities
|
||||
// ------------------------
|
||||
|
||||
/**
|
||||
* set_pwm_duty
|
||||
* Set the PWM duty cycle of the provided pin to the provided value
|
||||
* Optionally allows inverting the duty cycle [default = false]
|
||||
* Optionally allows changing the maximum size of the provided value to enable finer PWM duty control [default = 255]
|
||||
*/
|
||||
void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false);
|
||||
// Memory related
|
||||
#define __bss_end __bss_end__
|
||||
|
||||
extern "C" char* _sbrk(int incr);
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#if GCC_VERSION <= 50000
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#endif
|
||||
|
||||
static inline int freeMemory() {
|
||||
volatile char top;
|
||||
return &top - reinterpret_cast<char*>(_sbrk(0));
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
// ------------------------
|
||||
// MarlinHAL Class
|
||||
// ------------------------
|
||||
|
||||
class MarlinHAL {
|
||||
public:
|
||||
|
||||
// Earliest possible init, before setup()
|
||||
MarlinHAL() {}
|
||||
|
||||
static void init(); // Called early in setup()
|
||||
static void init_board() {} // Called less early in setup()
|
||||
static void reboot(); // Restart the firmware from 0x0
|
||||
|
||||
// Interrupts
|
||||
static bool isr_state() { return !__get_PRIMASK(); }
|
||||
static void isr_on() { sei(); }
|
||||
static void isr_off() { cli(); }
|
||||
|
||||
static void delay_ms(const int ms) { delay(ms); }
|
||||
|
||||
// Tasks, called from idle()
|
||||
static void idletask();
|
||||
|
||||
// Reset
|
||||
static uint8_t get_reset_source();
|
||||
static void clear_reset_source();
|
||||
|
||||
// Free SRAM
|
||||
static int freeMemory() { return ::freeMemory(); }
|
||||
|
||||
//
|
||||
// ADC Methods
|
||||
//
|
||||
|
||||
static uint16_t adc_result;
|
||||
|
||||
// Called by Temperature::init once at startup
|
||||
static void adc_init() {
|
||||
analogReadResolution(HAL_ADC_RESOLUTION);
|
||||
}
|
||||
|
||||
// Called by Temperature::init for each sensor at startup
|
||||
static void adc_enable(const pin_t pin) { pinMode(pin, INPUT); }
|
||||
|
||||
// Begin ADC sampling on the given channel
|
||||
static void adc_start(const pin_t pin) { adc_result = analogRead(pin); }
|
||||
|
||||
// Is the ADC ready for reading?
|
||||
static bool adc_ready() { return true; }
|
||||
|
||||
// The current value of the ADC register
|
||||
static uint16_t adc_value() { return adc_result; }
|
||||
|
||||
/**
|
||||
* Set the PWM duty cycle for the pin to the given value.
|
||||
* Optionally invert the duty cycle [default = false]
|
||||
* Optionally change the maximum size of the provided value to enable finer PWM duty control [default = 255]
|
||||
*/
|
||||
static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false);
|
||||
|
||||
/**
|
||||
* Set the frequency of the timer for the given pin.
|
||||
* All Timer PWM pins run at the same frequency.
|
||||
*/
|
||||
static void set_pwm_frequency(const pin_t pin, const uint16_t f_desired);
|
||||
|
||||
};
|
||||
|
||||
@@ -102,9 +102,9 @@ static SPISettings spiConfig;
|
||||
|
||||
// Soft SPI receive byte
|
||||
uint8_t spiRec() {
|
||||
DISABLE_ISRS(); // No interrupts during byte receive
|
||||
hal.isr_off(); // No interrupts during byte receive
|
||||
const uint8_t data = HAL_SPI_STM32_SpiTransfer_Mode_3(0xFF);
|
||||
ENABLE_ISRS(); // Enable interrupts
|
||||
hal.isr_on(); // Enable interrupts
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -116,9 +116,9 @@ static SPISettings spiConfig;
|
||||
|
||||
// Soft SPI send byte
|
||||
void spiSend(uint8_t data) {
|
||||
DISABLE_ISRS(); // No interrupts during byte send
|
||||
hal.isr_off(); // No interrupts during byte send
|
||||
HAL_SPI_STM32_SpiTransfer_Mode_3(data); // Don't care what is received
|
||||
ENABLE_ISRS(); // Enable interrupts
|
||||
hal.isr_on(); // Enable interrupts
|
||||
}
|
||||
|
||||
// Soft SPI send block
|
||||
|
||||
@@ -174,9 +174,9 @@ bool PersistentStore::access_finish() {
|
||||
UNLOCK_FLASH();
|
||||
|
||||
TERN_(HAS_PAUSE_SERVO_OUTPUT, PAUSE_SERVO_OUTPUT());
|
||||
DISABLE_ISRS();
|
||||
hal.isr_off();
|
||||
status = HAL_FLASHEx_Erase(&EraseInitStruct, &SectorError);
|
||||
ENABLE_ISRS();
|
||||
hal.isr_on();
|
||||
TERN_(HAS_PAUSE_SERVO_OUTPUT, RESUME_SERVO_OUTPUT());
|
||||
if (status != HAL_OK) {
|
||||
DEBUG_ECHOLNPGM("HAL_FLASHEx_Erase=", status);
|
||||
@@ -229,9 +229,9 @@ bool PersistentStore::access_finish() {
|
||||
// output. Servo output still glitches with interrupts disabled, but recovers after the
|
||||
// erase.
|
||||
TERN_(HAS_PAUSE_SERVO_OUTPUT, PAUSE_SERVO_OUTPUT());
|
||||
DISABLE_ISRS();
|
||||
hal.isr_off();
|
||||
eeprom_buffer_flush();
|
||||
ENABLE_ISRS();
|
||||
hal.isr_on();
|
||||
TERN_(HAS_PAUSE_SERVO_OUTPUT, RESUME_SERVO_OUTPUT());
|
||||
|
||||
eeprom_data_written = false;
|
||||
|
||||
@@ -52,4 +52,10 @@ void setup_endstop_interrupts() {
|
||||
TERN_(HAS_J_MIN, _ATTACH(J_MIN_PIN));
|
||||
TERN_(HAS_K_MAX, _ATTACH(K_MAX_PIN));
|
||||
TERN_(HAS_K_MIN, _ATTACH(K_MIN_PIN));
|
||||
TERN_(HAS_U_MAX, _ATTACH(U_MAX_PIN));
|
||||
TERN_(HAS_U_MIN, _ATTACH(U_MIN_PIN));
|
||||
TERN_(HAS_V_MAX, _ATTACH(V_MAX_PIN));
|
||||
TERN_(HAS_V_MIN, _ATTACH(V_MIN_PIN));
|
||||
TERN_(HAS_W_MAX, _ATTACH(W_MAX_PIN));
|
||||
TERN_(HAS_W_MIN, _ATTACH(W_MIN_PIN));
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
// Array to support sticky frequency sets per timer
|
||||
static uint16_t timer_freq[TIMER_NUM];
|
||||
|
||||
void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) {
|
||||
void MarlinHAL::set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) {
|
||||
const uint16_t duty = invert ? v_size - v : v;
|
||||
if (PWM_PIN(pin)) {
|
||||
const PinName pin_name = digitalPinToPinName(pin);
|
||||
@@ -61,7 +61,7 @@ void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255
|
||||
}
|
||||
}
|
||||
|
||||
void set_pwm_frequency(const pin_t pin, const uint16_t f_desired) {
|
||||
void MarlinHAL::set_pwm_frequency(const pin_t pin, const uint16_t f_desired) {
|
||||
if (!PWM_PIN(pin)) return; // Don't proceed if no hardware timer
|
||||
const PinName pin_name = digitalPinToPinName(pin);
|
||||
TIM_TypeDef * const Instance = (TIM_TypeDef *)pinmap_peripheral(pin_name, PinMap_PWM); // Get HAL timer instance
|
||||
|
||||
@@ -115,7 +115,6 @@ const XrefInfo pin_xref[] PROGMEM = {
|
||||
#define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0)
|
||||
#define PRINT_PORT(ANUM) port_print(ANUM)
|
||||
#define DIGITAL_PIN_TO_ANALOG_PIN(ANUM) -1 // will report analog pin number in the print port routine
|
||||
#define GET_PIN_MAP_PIN_M43(Index) pin_xref[Index].Ard_num
|
||||
|
||||
// x is a variable used to search pin_array
|
||||
#define GET_ARRAY_IS_DIGITAL(x) ((bool) pin_array[x].is_digital)
|
||||
@@ -123,6 +122,11 @@ const XrefInfo pin_xref[] PROGMEM = {
|
||||
#define PRINT_ARRAY_NAME(x) do{ sprintf_P(buffer, PSTR("%-" STRINGIFY(MAX_NAME_LENGTH) "s"), pin_array[x].name); SERIAL_ECHO(buffer); }while(0)
|
||||
#define MULTI_NAME_PAD 33 // space needed to be pretty if not first name assigned to a pin
|
||||
|
||||
//
|
||||
// Pin Mapping for M43
|
||||
//
|
||||
#define GET_PIN_MAP_PIN_M43(Index) pin_xref[Index].Ard_num
|
||||
|
||||
#ifndef M43_NEVER_TOUCH
|
||||
#define _M43_NEVER_TOUCH(Index) (Index >= 9 && Index <= 12) // SERIAL/USB pins: PA9(TX) PA10(RX) PA11(USB_DM) PA12(USB_DP)
|
||||
#ifdef KILL_PIN
|
||||
|
||||
@@ -116,5 +116,5 @@ FORCE_INLINE static void HAL_timer_set_compare(const uint8_t timer_num, const ha
|
||||
}
|
||||
}
|
||||
|
||||
#define HAL_timer_isr_prologue(T)
|
||||
#define HAL_timer_isr_epilogue(T)
|
||||
#define HAL_timer_isr_prologue(T) NOOP
|
||||
#define HAL_timer_isr_epilogue(T) NOOP
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if ENABLED(EMERGENCY_PARSER) && USBD_USE_CDC
|
||||
#if ENABLED(EMERGENCY_PARSER) && (USBD_USE_CDC || USBD_USE_CDC_MSC)
|
||||
|
||||
#include "usb_serial.h"
|
||||
#include "../../feature/e_parser.h"
|
||||
|
||||
@@ -79,7 +79,7 @@
|
||||
#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */
|
||||
|
||||
// ------------------------
|
||||
// Public Variables
|
||||
// Serial ports
|
||||
// ------------------------
|
||||
|
||||
#if defined(SERIAL_USB) && !HAS_SD_HOST_DRIVE
|
||||
@@ -112,74 +112,37 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
uint16_t HAL_adc_result;
|
||||
|
||||
// ------------------------
|
||||
// Private Variables
|
||||
// ADC
|
||||
// ------------------------
|
||||
STM32ADC adc(ADC1);
|
||||
|
||||
const uint8_t adc_pins[] = {
|
||||
OPTITEM(HAS_TEMP_ADC_0, TEMP_0_PIN)
|
||||
OPTITEM(HAS_TEMP_ADC_1, TEMP_1_PIN)
|
||||
OPTITEM(HAS_TEMP_ADC_2, TEMP_2_PIN)
|
||||
OPTITEM(HAS_TEMP_ADC_3, TEMP_3_PIN)
|
||||
OPTITEM(HAS_TEMP_ADC_4, TEMP_4_PIN)
|
||||
OPTITEM(HAS_TEMP_ADC_5, TEMP_5_PIN)
|
||||
OPTITEM(HAS_TEMP_ADC_6, TEMP_6_PIN)
|
||||
OPTITEM(HAS_TEMP_ADC_7, TEMP_7_PIN)
|
||||
OPTITEM(HAS_HEATED_BED, TEMP_BED_PIN)
|
||||
OPTITEM(HAS_TEMP_CHAMBER, TEMP_CHAMBER_PIN)
|
||||
OPTITEM(HAS_TEMP_ADC_PROBE, TEMP_PROBE_PIN)
|
||||
OPTITEM(HAS_TEMP_COOLER, TEMP_COOLER_PIN)
|
||||
OPTITEM(HAS_TEMP_BOARD, TEMP_BOARD_PIN)
|
||||
OPTITEM(FILAMENT_WIDTH_SENSOR, FILWIDTH_PIN)
|
||||
OPTITEM(HAS_ADC_BUTTONS, ADC_KEYPAD_PIN)
|
||||
OPTITEM(HAS_JOY_ADC_X, JOY_X_PIN)
|
||||
OPTITEM(HAS_JOY_ADC_Y, JOY_Y_PIN)
|
||||
OPTITEM(HAS_JOY_ADC_Z, JOY_Z_PIN)
|
||||
OPTITEM(POWER_MONITOR_CURRENT, POWER_MONITOR_CURRENT_PIN)
|
||||
OPTITEM(POWER_MONITOR_VOLTAGE, POWER_MONITOR_VOLTAGE_PIN)
|
||||
};
|
||||
// Watch out for recursion here! Our pin_t is signed, so pass through to Arduino -> analogRead(uint8_t)
|
||||
|
||||
enum TempPinIndex : char {
|
||||
OPTITEM(HAS_TEMP_ADC_0, TEMP_0)
|
||||
OPTITEM(HAS_TEMP_ADC_1, TEMP_1)
|
||||
OPTITEM(HAS_TEMP_ADC_2, TEMP_2)
|
||||
OPTITEM(HAS_TEMP_ADC_3, TEMP_3)
|
||||
OPTITEM(HAS_TEMP_ADC_4, TEMP_4)
|
||||
OPTITEM(HAS_TEMP_ADC_5, TEMP_5)
|
||||
OPTITEM(HAS_TEMP_ADC_6, TEMP_6)
|
||||
OPTITEM(HAS_TEMP_ADC_7, TEMP_7)
|
||||
OPTITEM(HAS_HEATED_BED, TEMP_BED)
|
||||
OPTITEM(HAS_TEMP_CHAMBER, TEMP_CHAMBER)
|
||||
OPTITEM(HAS_TEMP_ADC_PROBE, TEMP_PROBE)
|
||||
OPTITEM(HAS_TEMP_COOLER, TEMP_COOLER)
|
||||
OPTITEM(HAS_TEMP_BOARD, TEMP_BOARD)
|
||||
OPTITEM(FILAMENT_WIDTH_SENSOR, FILWIDTH)
|
||||
OPTITEM(HAS_ADC_BUTTONS, ADC_KEY)
|
||||
OPTITEM(HAS_JOY_ADC_X, JOY_X)
|
||||
OPTITEM(HAS_JOY_ADC_Y, JOY_Y)
|
||||
OPTITEM(HAS_JOY_ADC_Z, JOY_Z)
|
||||
OPTITEM(POWER_MONITOR_CURRENT, POWERMON_CURRENT)
|
||||
OPTITEM(POWER_MONITOR_VOLTAGE, POWERMON_VOLTS)
|
||||
ADC_PIN_COUNT
|
||||
};
|
||||
uint16_t analogRead(const pin_t pin) {
|
||||
const bool is_analog = _GET_MODE(pin) == GPIO_INPUT_ANALOG;
|
||||
return is_analog ? analogRead(uint8_t(pin)) : 0;
|
||||
}
|
||||
|
||||
uint16_t HAL_adc_results[ADC_PIN_COUNT];
|
||||
// Wrapper to maple unprotected analogWrite
|
||||
void analogWrite(const pin_t pin, int pwm_val8) {
|
||||
if (PWM_PIN(pin)) analogWrite(uint8_t(pin), pwm_val8);
|
||||
}
|
||||
|
||||
uint16_t MarlinHAL::adc_result;
|
||||
|
||||
// ------------------------
|
||||
// Private functions
|
||||
// ------------------------
|
||||
|
||||
static void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) {
|
||||
uint32_t reg_value;
|
||||
uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07); /* only values 0..7 are used */
|
||||
uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07); // only values 0..7 are used
|
||||
|
||||
reg_value = SCB->AIRCR; /* read old register configuration */
|
||||
reg_value &= ~(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk); /* clear bits to change */
|
||||
reg_value = SCB->AIRCR; // read old register configuration
|
||||
reg_value &= ~(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk); // clear bits to change
|
||||
reg_value = (reg_value |
|
||||
((uint32_t)0x5FA << SCB_AIRCR_VECTKEY_Pos) |
|
||||
(PriorityGroupTmp << 8)); /* Insert write key & priority group */
|
||||
(PriorityGroupTmp << 8)); // Insert write key & priority group
|
||||
SCB->AIRCR = reg_value;
|
||||
}
|
||||
|
||||
@@ -187,6 +150,8 @@ static void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) {
|
||||
// Public functions
|
||||
// ------------------------
|
||||
|
||||
void flashFirmware(const int16_t) { hal.reboot(); }
|
||||
|
||||
//
|
||||
// Leave PA11/PA12 intact if USBSerial is not used
|
||||
//
|
||||
@@ -206,7 +171,11 @@ static void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) {
|
||||
|
||||
TERN_(POSTMORTEM_DEBUGGING, extern void install_min_serial());
|
||||
|
||||
void HAL_init() {
|
||||
// ------------------------
|
||||
// MarlinHAL class
|
||||
// ------------------------
|
||||
|
||||
void MarlinHAL::init() {
|
||||
NVIC_SetPriorityGrouping(0x3);
|
||||
#if PIN_EXISTS(LED)
|
||||
OUT_WRITE(LED_PIN, LOW);
|
||||
@@ -225,7 +194,7 @@ void HAL_init() {
|
||||
}
|
||||
|
||||
// HAL idle task
|
||||
void HAL_idletask() {
|
||||
void MarlinHAL::idletask() {
|
||||
#if HAS_SHARED_MEDIA
|
||||
// If Marlin is using the SD card we need to lock it to prevent access from
|
||||
// a PC via USB.
|
||||
@@ -240,14 +209,7 @@ void HAL_idletask() {
|
||||
#endif
|
||||
}
|
||||
|
||||
void HAL_clear_reset_source() { }
|
||||
|
||||
/**
|
||||
* TODO: Check this and change or remove.
|
||||
*/
|
||||
uint8_t HAL_get_reset_source() { return RST_POWER_ON; }
|
||||
|
||||
void _delay_ms(const int delay_ms) { delay(delay_ms); }
|
||||
void MarlinHAL::reboot() { nvic_sys_reset(); }
|
||||
|
||||
extern "C" {
|
||||
extern unsigned int _ebss; // end of bss section
|
||||
@@ -281,31 +243,76 @@ extern "C" {
|
||||
}
|
||||
*/
|
||||
|
||||
// ------------------------
|
||||
//
|
||||
// ADC
|
||||
// ------------------------
|
||||
//
|
||||
|
||||
enum ADCIndex : uint8_t {
|
||||
OPTITEM(HAS_TEMP_ADC_0, TEMP_0)
|
||||
OPTITEM(HAS_TEMP_ADC_1, TEMP_1)
|
||||
OPTITEM(HAS_TEMP_ADC_2, TEMP_2)
|
||||
OPTITEM(HAS_TEMP_ADC_3, TEMP_3)
|
||||
OPTITEM(HAS_TEMP_ADC_4, TEMP_4)
|
||||
OPTITEM(HAS_TEMP_ADC_5, TEMP_5)
|
||||
OPTITEM(HAS_TEMP_ADC_6, TEMP_6)
|
||||
OPTITEM(HAS_TEMP_ADC_7, TEMP_7)
|
||||
OPTITEM(HAS_HEATED_BED, TEMP_BED)
|
||||
OPTITEM(HAS_TEMP_CHAMBER, TEMP_CHAMBER)
|
||||
OPTITEM(HAS_TEMP_ADC_PROBE, TEMP_PROBE)
|
||||
OPTITEM(HAS_TEMP_COOLER, TEMP_COOLER)
|
||||
OPTITEM(HAS_TEMP_BOARD, TEMP_BOARD)
|
||||
OPTITEM(FILAMENT_WIDTH_SENSOR, FILWIDTH)
|
||||
OPTITEM(HAS_ADC_BUTTONS, ADC_KEY)
|
||||
OPTITEM(HAS_JOY_ADC_X, JOY_X)
|
||||
OPTITEM(HAS_JOY_ADC_Y, JOY_Y)
|
||||
OPTITEM(HAS_JOY_ADC_Z, JOY_Z)
|
||||
OPTITEM(POWER_MONITOR_CURRENT, POWERMON_CURRENT)
|
||||
OPTITEM(POWER_MONITOR_VOLTAGE, POWERMON_VOLTS)
|
||||
ADC_COUNT
|
||||
};
|
||||
|
||||
static uint16_t adc_results[ADC_COUNT];
|
||||
|
||||
// Init the AD in continuous capture mode
|
||||
void HAL_adc_init() {
|
||||
void MarlinHAL::adc_init() {
|
||||
static const uint8_t adc_pins[] = {
|
||||
OPTITEM(HAS_TEMP_ADC_0, TEMP_0_PIN)
|
||||
OPTITEM(HAS_TEMP_ADC_1, TEMP_1_PIN)
|
||||
OPTITEM(HAS_TEMP_ADC_2, TEMP_2_PIN)
|
||||
OPTITEM(HAS_TEMP_ADC_3, TEMP_3_PIN)
|
||||
OPTITEM(HAS_TEMP_ADC_4, TEMP_4_PIN)
|
||||
OPTITEM(HAS_TEMP_ADC_5, TEMP_5_PIN)
|
||||
OPTITEM(HAS_TEMP_ADC_6, TEMP_6_PIN)
|
||||
OPTITEM(HAS_TEMP_ADC_7, TEMP_7_PIN)
|
||||
OPTITEM(HAS_HEATED_BED, TEMP_BED_PIN)
|
||||
OPTITEM(HAS_TEMP_CHAMBER, TEMP_CHAMBER_PIN)
|
||||
OPTITEM(HAS_TEMP_ADC_PROBE, TEMP_PROBE_PIN)
|
||||
OPTITEM(HAS_TEMP_COOLER, TEMP_COOLER_PIN)
|
||||
OPTITEM(HAS_TEMP_BOARD, TEMP_BOARD_PIN)
|
||||
OPTITEM(FILAMENT_WIDTH_SENSOR, FILWIDTH_PIN)
|
||||
OPTITEM(HAS_ADC_BUTTONS, ADC_KEYPAD_PIN)
|
||||
OPTITEM(HAS_JOY_ADC_X, JOY_X_PIN)
|
||||
OPTITEM(HAS_JOY_ADC_Y, JOY_Y_PIN)
|
||||
OPTITEM(HAS_JOY_ADC_Z, JOY_Z_PIN)
|
||||
OPTITEM(POWER_MONITOR_CURRENT, POWER_MONITOR_CURRENT_PIN)
|
||||
OPTITEM(POWER_MONITOR_VOLTAGE, POWER_MONITOR_VOLTAGE_PIN)
|
||||
};
|
||||
static STM32ADC adc(ADC1);
|
||||
// configure the ADC
|
||||
adc.calibrate();
|
||||
#if F_CPU > 72000000
|
||||
adc.setSampleRate(ADC_SMPR_71_5); // 71.5 ADC cycles
|
||||
#else
|
||||
adc.setSampleRate(ADC_SMPR_41_5); // 41.5 ADC cycles
|
||||
#endif
|
||||
adc.setPins((uint8_t *)adc_pins, ADC_PIN_COUNT);
|
||||
adc.setDMA(HAL_adc_results, (uint16_t)ADC_PIN_COUNT, (uint32_t)(DMA_MINC_MODE | DMA_CIRC_MODE), nullptr);
|
||||
adc.setSampleRate((F_CPU > 72000000) ? ADC_SMPR_71_5 : ADC_SMPR_41_5); // 71.5 or 41.5 ADC cycles
|
||||
adc.setPins((uint8_t *)adc_pins, ADC_COUNT);
|
||||
adc.setDMA(adc_results, uint16_t(ADC_COUNT), uint32_t(DMA_MINC_MODE | DMA_CIRC_MODE), nullptr);
|
||||
adc.setScanMode();
|
||||
adc.setContinuous();
|
||||
adc.startConversion();
|
||||
}
|
||||
|
||||
void HAL_adc_start_conversion(const uint8_t adc_pin) {
|
||||
void MarlinHAL::adc_start(const pin_t pin) {
|
||||
#define __TCASE(N,I) case N: pin_index = I; break;
|
||||
#define _TCASE(C,N,I) TERN_(C, __TCASE(N, I))
|
||||
//TEMP_PINS pin_index;
|
||||
TempPinIndex pin_index;
|
||||
switch (adc_pin) {
|
||||
ADCIndex pin_index;
|
||||
switch (pin) {
|
||||
default: return;
|
||||
_TCASE(HAS_TEMP_ADC_0, TEMP_0_PIN, TEMP_0)
|
||||
_TCASE(HAS_TEMP_ADC_1, TEMP_1_PIN, TEMP_1)
|
||||
@@ -328,23 +335,7 @@ void HAL_adc_start_conversion(const uint8_t adc_pin) {
|
||||
_TCASE(POWER_MONITOR_CURRENT, POWER_MONITOR_CURRENT_PIN, POWERMON_CURRENT)
|
||||
_TCASE(POWER_MONITOR_VOLTAGE, POWER_MONITOR_VOLTAGE_PIN, POWERMON_VOLTS)
|
||||
}
|
||||
HAL_adc_result = HAL_adc_results[(int)pin_index] >> (12 - HAL_ADC_RESOLUTION); // shift out unused bits
|
||||
adc_result = (adc_results[(int)pin_index] & 0xFFF) >> (12 - HAL_ADC_RESOLUTION); // shift out unused bits
|
||||
}
|
||||
|
||||
uint16_t HAL_adc_get_result() { return HAL_adc_result; }
|
||||
|
||||
uint16_t analogRead(pin_t pin) {
|
||||
const bool is_analog = _GET_MODE(pin) == GPIO_INPUT_ANALOG;
|
||||
return is_analog ? analogRead(uint8_t(pin)) : 0;
|
||||
}
|
||||
|
||||
// Wrapper to maple unprotected analogWrite
|
||||
void analogWrite(pin_t pin, int pwm_val8) {
|
||||
if (PWM_PIN(pin)) analogWrite(uint8_t(pin), pwm_val8);
|
||||
}
|
||||
|
||||
void HAL_reboot() { nvic_sys_reset(); }
|
||||
|
||||
void flashFirmware(const int16_t) { HAL_reboot(); }
|
||||
|
||||
#endif // __STM32F1__
|
||||
|
||||
+106
-86
@@ -66,6 +66,10 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// ------------------------
|
||||
// Serial ports
|
||||
// ------------------------
|
||||
|
||||
#ifdef SERIAL_USB
|
||||
typedef ForwardSerial1Class< USBSerial > DefaultSerial1;
|
||||
extern DefaultSerial1 MSerial0;
|
||||
@@ -141,11 +145,6 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Set interrupt grouping for this MCU
|
||||
void HAL_init();
|
||||
#define HAL_IDLETASK 1
|
||||
void HAL_idletask();
|
||||
|
||||
/**
|
||||
* TODO: review this to return 1 for pins that are not analog input
|
||||
*/
|
||||
@@ -158,15 +157,7 @@ void HAL_idletask();
|
||||
#define NO_COMPILE_TIME_PWM
|
||||
#endif
|
||||
|
||||
#define CRITICAL_SECTION_START() uint32_t primask = __get_primask(); (void)__iCliRetVal()
|
||||
#define CRITICAL_SECTION_END() if (!primask) (void)__iSeiRetVal()
|
||||
#define ISRS_ENABLED() (!__get_primask())
|
||||
#define ENABLE_ISRS() ((void)__iSeiRetVal())
|
||||
#define DISABLE_ISRS() ((void)__iCliRetVal())
|
||||
|
||||
// On AVR this is in math.h?
|
||||
#define square(x) ((x)*(x))
|
||||
|
||||
// Reset Reason
|
||||
#define RST_POWER_ON 1
|
||||
#define RST_EXTERNAL 2
|
||||
#define RST_BROWN_OUT 4
|
||||
@@ -182,60 +173,17 @@ void HAL_idletask();
|
||||
typedef int8_t pin_t;
|
||||
|
||||
// ------------------------
|
||||
// Public Variables
|
||||
// Interrupts
|
||||
// ------------------------
|
||||
|
||||
// Result of last ADC conversion
|
||||
extern uint16_t HAL_adc_result;
|
||||
|
||||
// ------------------------
|
||||
// Public functions
|
||||
// ------------------------
|
||||
|
||||
// Disable interrupts
|
||||
#define CRITICAL_SECTION_START() const bool irqon = !__get_primask(); (void)__iCliRetVal()
|
||||
#define CRITICAL_SECTION_END() if (!irqon) (void)__iSeiRetVal()
|
||||
#define cli() noInterrupts()
|
||||
|
||||
// Enable interrupts
|
||||
#define sei() interrupts()
|
||||
|
||||
// Memory related
|
||||
#define __bss_end __bss_end__
|
||||
|
||||
// Clear reset reason
|
||||
void HAL_clear_reset_source();
|
||||
|
||||
// Reset reason
|
||||
uint8_t HAL_get_reset_source();
|
||||
|
||||
void HAL_reboot();
|
||||
|
||||
void _delay_ms(const int delay);
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
|
||||
/*
|
||||
extern "C" {
|
||||
int freeMemory();
|
||||
}
|
||||
*/
|
||||
|
||||
extern "C" char* _sbrk(int incr);
|
||||
|
||||
static inline int freeMemory() {
|
||||
volatile char top;
|
||||
return &top - _sbrk(0);
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
//
|
||||
// ------------------------
|
||||
// ADC
|
||||
//
|
||||
|
||||
#define HAL_ANALOG_SELECT(pin) pinMode(pin, INPUT_ANALOG);
|
||||
|
||||
void HAL_adc_init();
|
||||
// ------------------------
|
||||
|
||||
#ifdef ADC_RESOLUTION
|
||||
#define HAL_ADC_RESOLUTION ADC_RESOLUTION
|
||||
@@ -244,43 +192,115 @@ void HAL_adc_init();
|
||||
#endif
|
||||
|
||||
#define HAL_ADC_VREF 3.3
|
||||
#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
|
||||
#define HAL_READ_ADC() HAL_adc_result
|
||||
#define HAL_ADC_READY() true
|
||||
|
||||
void HAL_adc_start_conversion(const uint8_t adc_pin);
|
||||
uint16_t HAL_adc_get_result();
|
||||
|
||||
uint16_t analogRead(pin_t pin); // need HAL_ANALOG_SELECT() first
|
||||
void analogWrite(pin_t pin, int pwm_val8); // PWM only! mul by 257 in maple!?
|
||||
uint16_t analogRead(const pin_t pin); // need hal.adc_enable() first
|
||||
void analogWrite(const pin_t pin, int pwm_val8); // PWM only! mul by 257 in maple!?
|
||||
|
||||
//
|
||||
// Pin Mapping for M42, M43, M226
|
||||
//
|
||||
#define GET_PIN_MAP_PIN(index) index
|
||||
#define GET_PIN_MAP_INDEX(pin) pin
|
||||
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
|
||||
|
||||
#define JTAG_DISABLE() afio_cfg_debug_ports(AFIO_DEBUG_SW_ONLY)
|
||||
#define JTAG_DISABLE() afio_cfg_debug_ports(AFIO_DEBUG_SW_ONLY)
|
||||
#define JTAGSWD_DISABLE() afio_cfg_debug_ports(AFIO_DEBUG_NONE)
|
||||
|
||||
#define PLATFORM_M997_SUPPORT
|
||||
void flashFirmware(const int16_t);
|
||||
|
||||
#define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment
|
||||
#ifndef PWM_FREQUENCY
|
||||
#define PWM_FREQUENCY 1000 // Default PWM Frequency
|
||||
#endif
|
||||
#define HAL_CAN_SET_PWM_FREQ // This HAL supports PWM Frequency adjustment
|
||||
|
||||
/**
|
||||
* set_pwm_frequency
|
||||
* Set the frequency of the timer corresponding to the provided pin
|
||||
* All Timer PWM pins run at the same frequency
|
||||
*/
|
||||
void set_pwm_frequency(const pin_t pin, const uint16_t f_desired);
|
||||
// ------------------------
|
||||
// Class Utilities
|
||||
// ------------------------
|
||||
|
||||
/**
|
||||
* set_pwm_duty
|
||||
* Set the PWM duty cycle of the provided pin to the provided value
|
||||
* Optionally allows inverting the duty cycle [default = false]
|
||||
* Optionally allows changing the maximum size of the provided value to enable finer PWM duty control [default = 255]
|
||||
* The timer must be pre-configured with set_pwm_frequency() if the default frequency is not desired.
|
||||
*/
|
||||
void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size=255, const bool invert=false);
|
||||
// Memory related
|
||||
#define __bss_end __bss_end__
|
||||
|
||||
void _delay_ms(const int ms);
|
||||
|
||||
extern "C" char* _sbrk(int incr);
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#if GCC_VERSION <= 50000
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#endif
|
||||
|
||||
static inline int freeMemory() {
|
||||
volatile char top;
|
||||
return &top - _sbrk(0);
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
// ------------------------
|
||||
// MarlinHAL Class
|
||||
// ------------------------
|
||||
|
||||
class MarlinHAL {
|
||||
public:
|
||||
|
||||
// Earliest possible init, before setup()
|
||||
MarlinHAL() {}
|
||||
|
||||
static void init(); // Called early in setup()
|
||||
static void init_board() {} // Called less early in setup()
|
||||
static void reboot(); // Restart the firmware from 0x0
|
||||
|
||||
// Interrupts
|
||||
static bool isr_state() { return !__get_primask(); }
|
||||
static void isr_on() { ((void)__iSeiRetVal()); }
|
||||
static void isr_off() { ((void)__iCliRetVal()); }
|
||||
|
||||
static void delay_ms(const int ms) { delay(ms); }
|
||||
|
||||
// Tasks, called from idle()
|
||||
static void idletask();
|
||||
|
||||
// Reset
|
||||
static uint8_t get_reset_source() { return RST_POWER_ON; }
|
||||
static void clear_reset_source() {}
|
||||
|
||||
// Free SRAM
|
||||
static int freeMemory() { return ::freeMemory(); }
|
||||
|
||||
//
|
||||
// ADC Methods
|
||||
//
|
||||
|
||||
static uint16_t adc_result;
|
||||
|
||||
// Called by Temperature::init once at startup
|
||||
static void adc_init();
|
||||
|
||||
// Called by Temperature::init for each sensor at startup
|
||||
static void adc_enable(const pin_t pin) { pinMode(pin, INPUT_ANALOG); }
|
||||
|
||||
// Begin ADC sampling on the given channel
|
||||
static void adc_start(const pin_t pin);
|
||||
|
||||
// Is the ADC ready for reading?
|
||||
static bool adc_ready() { return true; }
|
||||
|
||||
// The current value of the ADC register
|
||||
static uint16_t adc_value() { return adc_result; }
|
||||
|
||||
/**
|
||||
* Set the PWM duty cycle for the pin to the given value.
|
||||
* Optionally invert the duty cycle [default = false]
|
||||
* Optionally change the maximum size of the provided value to enable finer PWM duty control [default = 255]
|
||||
* The timer must be pre-configured with set_pwm_frequency() if the default frequency is not desired.
|
||||
*/
|
||||
static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false);
|
||||
|
||||
/**
|
||||
* Set the frequency of the timer for the given pin.
|
||||
* All Timer PWM pins run at the same frequency.
|
||||
*/
|
||||
static void set_pwm_frequency(const pin_t pin, const uint16_t f_desired);
|
||||
|
||||
};
|
||||
|
||||
@@ -91,6 +91,14 @@ static const spi_pins board_spi_pins[] __FLASH__ = {
|
||||
static void *_spi3_this;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Wait until TXE (tx empty) flag is set and BSY (busy) flag unset.
|
||||
*/
|
||||
static inline void waitSpiTxEnd(spi_dev *spi_d) {
|
||||
while (spi_is_tx_empty(spi_d) == 0) { /* nada */ } // wait until TXE=1
|
||||
while (spi_is_busy(spi_d) != 0) { /* nada */ } // wait until BSY=0
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
|
||||
@@ -414,12 +414,4 @@ private:
|
||||
*/
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Wait until TXE (tx empty) flag is set and BSY (busy) flag unset.
|
||||
*/
|
||||
static void waitSpiTxEnd(spi_dev *spi_d) {
|
||||
while (spi_is_tx_empty(spi_d) == 0) { /* nada */ } // wait until TXE=1
|
||||
while (spi_is_busy(spi_d) != 0) { /* nada */ } // wait until BSY=0
|
||||
}
|
||||
|
||||
extern SPIClass SPI;
|
||||
|
||||
@@ -35,7 +35,8 @@
|
||||
#define SERVO_DEFAULT_MIN_ANGLE 0
|
||||
#define SERVO_DEFAULT_MAX_ANGLE 180
|
||||
|
||||
#define HAL_SERVO_LIB libServo
|
||||
class libServo;
|
||||
typedef libServo hal_servo_t;
|
||||
|
||||
class libServo {
|
||||
public:
|
||||
|
||||
@@ -77,4 +77,10 @@ void setup_endstop_interrupts() {
|
||||
TERN_(HAS_J_MIN, _ATTACH(J_MIN_PIN));
|
||||
TERN_(HAS_K_MAX, _ATTACH(K_MAX_PIN));
|
||||
TERN_(HAS_K_MIN, _ATTACH(K_MIN_PIN));
|
||||
TERN_(HAS_U_MAX, _ATTACH(U_MAX_PIN));
|
||||
TERN_(HAS_U_MIN, _ATTACH(U_MIN_PIN));
|
||||
TERN_(HAS_V_MAX, _ATTACH(V_MAX_PIN));
|
||||
TERN_(HAS_V_MIN, _ATTACH(V_MIN_PIN));
|
||||
TERN_(HAS_W_MAX, _ATTACH(W_MAX_PIN));
|
||||
TERN_(HAS_W_MIN, _ATTACH(W_MIN_PIN));
|
||||
}
|
||||
|
||||
@@ -21,11 +21,9 @@
|
||||
*/
|
||||
#ifdef __STM32F1__
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#include <pwm.h>
|
||||
#include "HAL.h"
|
||||
#include "timers.h"
|
||||
|
||||
#define NR_TIMERS TERN(STM32_XL_DENSITY, 14, 8) // Maple timers, 14 for STM32_XL_DENSITY (F/G chips), 8 for HIGH density (C D E)
|
||||
|
||||
@@ -38,7 +36,7 @@ inline uint8_t timer_and_index_for_pin(const pin_t pin, timer_dev **timer_ptr) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) {
|
||||
void MarlinHAL::set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255*/, const bool invert/*=false*/) {
|
||||
const uint16_t duty = invert ? v_size - v : v;
|
||||
if (PWM_PIN(pin)) {
|
||||
timer_dev *timer; UNUSED(timer);
|
||||
@@ -54,7 +52,7 @@ void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255
|
||||
}
|
||||
}
|
||||
|
||||
void set_pwm_frequency(const pin_t pin, const uint16_t f_desired) {
|
||||
void MarlinHAL::set_pwm_frequency(const pin_t pin, const uint16_t f_desired) {
|
||||
if (!PWM_PIN(pin)) return; // Don't proceed if no hardware timer
|
||||
|
||||
timer_dev *timer; UNUSED(timer);
|
||||
|
||||
@@ -41,7 +41,6 @@
|
||||
#if PIN_EXISTS(ONBOARD_SD_CS) && ONBOARD_SD_CS_PIN != SD_SS_PIN
|
||||
#define CS_LOW() WRITE(ONBOARD_SD_CS_PIN, LOW) // Set OnboardSPI cs low
|
||||
#define CS_HIGH() WRITE(ONBOARD_SD_CS_PIN, HIGH) // Set OnboardSPI cs high
|
||||
|
||||
#else
|
||||
#define CS_LOW()
|
||||
#define CS_HIGH()
|
||||
|
||||
@@ -188,7 +188,7 @@ FORCE_INLINE static void HAL_timer_isr_prologue(const uint8_t timer_num) {
|
||||
}
|
||||
}
|
||||
|
||||
#define HAL_timer_isr_epilogue(T)
|
||||
#define HAL_timer_isr_epilogue(T) NOOP
|
||||
|
||||
// No command is available in framework to turn off ARPE bit, which is turned on by default in libmaple.
|
||||
// Needed here to reset ARPE=0 for stepper timer
|
||||
|
||||
@@ -31,6 +31,10 @@
|
||||
|
||||
#include <Wire.h>
|
||||
|
||||
// ------------------------
|
||||
// Serial ports
|
||||
// ------------------------
|
||||
|
||||
#define _IMPLEMENT_SERIAL(X) DefaultSerial##X MSerial##X(false, Serial##X)
|
||||
#define IMPLEMENT_SERIAL(X) _IMPLEMENT_SERIAL(X)
|
||||
#if WITHIN(SERIAL_PORT, 0, 3)
|
||||
@@ -40,45 +44,9 @@
|
||||
#endif
|
||||
USBSerialType USBSerial(false, SerialUSB);
|
||||
|
||||
uint16_t HAL_adc_result;
|
||||
|
||||
static const uint8_t pin2sc1a[] = {
|
||||
5, 14, 8, 9, 13, 12, 6, 7, 15, 4, 0, 19, 3, 31, // 0-13, we treat them as A0-A13
|
||||
5, 14, 8, 9, 13, 12, 6, 7, 15, 4, // 14-23 (A0-A9)
|
||||
31, 31, 31, 31, 31, 31, 31, 31, 31, 31, // 24-33
|
||||
0+64, 19+64, 3+64, 31+64, // 34-37 (A10-A13)
|
||||
26, 22, 23, 27, 29, 30 // 38-43: temp. sensor, VREF_OUT, A14, bandgap, VREFH, VREFL. A14 isn't connected to anything in Teensy 3.0.
|
||||
};
|
||||
|
||||
/*
|
||||
// disable interrupts
|
||||
void cli() { noInterrupts(); }
|
||||
|
||||
// enable interrupts
|
||||
void sei() { interrupts(); }
|
||||
*/
|
||||
|
||||
void HAL_adc_init() {
|
||||
analog_init();
|
||||
while (ADC0_SC3 & ADC_SC3_CAL) {}; // Wait for calibration to finish
|
||||
NVIC_ENABLE_IRQ(IRQ_FTM1);
|
||||
}
|
||||
|
||||
void HAL_clear_reset_source() { }
|
||||
|
||||
uint8_t HAL_get_reset_source() {
|
||||
switch (RCM_SRS0) {
|
||||
case 128: return RST_POWER_ON; break;
|
||||
case 64: return RST_EXTERNAL; break;
|
||||
case 32: return RST_WATCHDOG; break;
|
||||
// case 8: return RST_LOSS_OF_LOCK; break;
|
||||
// case 4: return RST_LOSS_OF_CLOCK; break;
|
||||
// case 2: return RST_LOW_VOLTAGE; break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void HAL_reboot() { _reboot_Teensyduino_(); }
|
||||
// ------------------------
|
||||
// Class Utilities
|
||||
// ------------------------
|
||||
|
||||
extern "C" {
|
||||
extern char __bss_end;
|
||||
@@ -95,8 +63,43 @@ extern "C" {
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_adc_start_conversion(const uint8_t adc_pin) { ADC0_SC1A = pin2sc1a[adc_pin]; }
|
||||
// ------------------------
|
||||
// MarlinHAL Class
|
||||
// ------------------------
|
||||
|
||||
uint16_t HAL_adc_get_result() { return ADC0_RA; }
|
||||
void MarlinHAL::reboot() { _reboot_Teensyduino_(); }
|
||||
|
||||
uint8_t MarlinHAL::get_reset_source() {
|
||||
switch (RCM_SRS0) {
|
||||
case 128: return RST_POWER_ON; break;
|
||||
case 64: return RST_EXTERNAL; break;
|
||||
case 32: return RST_WATCHDOG; break;
|
||||
// case 8: return RST_LOSS_OF_LOCK; break;
|
||||
// case 4: return RST_LOSS_OF_CLOCK; break;
|
||||
// case 2: return RST_LOW_VOLTAGE; break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ADC
|
||||
|
||||
void MarlinHAL::adc_init() {
|
||||
analog_init();
|
||||
while (ADC0_SC3 & ADC_SC3_CAL) {}; // Wait for calibration to finish
|
||||
NVIC_ENABLE_IRQ(IRQ_FTM1);
|
||||
}
|
||||
|
||||
void MarlinHAL::adc_start(const pin_t pin) {
|
||||
static const uint8_t pin2sc1a[] = {
|
||||
5, 14, 8, 9, 13, 12, 6, 7, 15, 4, 0, 19, 3, 31, // 0-13, we treat them as A0-A13
|
||||
5, 14, 8, 9, 13, 12, 6, 7, 15, 4, // 14-23 (A0-A9)
|
||||
31, 31, 31, 31, 31, 31, 31, 31, 31, 31, // 24-33
|
||||
0+64, 19+64, 3+64, 31+64, // 34-37 (A10-A13)
|
||||
26, 22, 23, 27, 29, 30 // 38-43: temp. sensor, VREF_OUT, A14, bandgap, VREFH, VREFL. A14 isn't connected to anything in Teensy 3.0.
|
||||
};
|
||||
ADC0_SC1A = pin2sc1a[pin];
|
||||
}
|
||||
|
||||
uint16_t MarlinHAL::adc_value() { return ADC0_RA; }
|
||||
|
||||
#endif // __MK20DX256__
|
||||
|
||||
@@ -36,12 +36,9 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define CPU_ST7920_DELAY_1 600
|
||||
#define CPU_ST7920_DELAY_2 750
|
||||
#define CPU_ST7920_DELAY_3 750
|
||||
|
||||
//#undef MOTHERBOARD
|
||||
//#define MOTHERBOARD BOARD_TEENSY31_32
|
||||
// ------------------------
|
||||
// Defines
|
||||
// ------------------------
|
||||
|
||||
#define IS_32BIT_TEENSY 1
|
||||
#define IS_TEENSY_31_32 1
|
||||
@@ -49,6 +46,14 @@
|
||||
#define IS_TEENSY32 1
|
||||
#endif
|
||||
|
||||
#define CPU_ST7920_DELAY_1 600
|
||||
#define CPU_ST7920_DELAY_2 750
|
||||
#define CPU_ST7920_DELAY_3 750
|
||||
|
||||
// ------------------------
|
||||
// Serial ports
|
||||
// ------------------------
|
||||
|
||||
#include "../../core/serial_hook.h"
|
||||
|
||||
#define Serial0 Serial
|
||||
@@ -72,31 +77,44 @@ extern USBSerialType USBSerial;
|
||||
#error "The required SERIAL_PORT must be from 0 to 3, or -1 for Native USB."
|
||||
#endif
|
||||
|
||||
#define HAL_SERVO_LIB libServo
|
||||
// ------------------------
|
||||
// Types
|
||||
// ------------------------
|
||||
|
||||
class libServo;
|
||||
typedef libServo hal_servo_t;
|
||||
|
||||
typedef int8_t pin_t;
|
||||
|
||||
// ------------------------
|
||||
// Interrupts
|
||||
// ------------------------
|
||||
|
||||
uint32_t __get_PRIMASK(void); // CMSIS
|
||||
#define CRITICAL_SECTION_START() const bool irqon = !__get_PRIMASK(); __disable_irq()
|
||||
#define CRITICAL_SECTION_END() if (irqon) __enable_irq()
|
||||
|
||||
// ------------------------
|
||||
// ADC
|
||||
// ------------------------
|
||||
|
||||
#ifndef analogInputToDigitalPin
|
||||
#define analogInputToDigitalPin(p) ((p < 12U) ? (p) + 54U : -1)
|
||||
#endif
|
||||
|
||||
#define CRITICAL_SECTION_START() uint32_t primask = __get_PRIMASK(); __disable_irq()
|
||||
#define CRITICAL_SECTION_END() if (!primask) __enable_irq()
|
||||
#define ISRS_ENABLED() (!__get_PRIMASK())
|
||||
#define ENABLE_ISRS() __enable_irq()
|
||||
#define DISABLE_ISRS() __disable_irq()
|
||||
#define HAL_ADC_VREF 3.3
|
||||
#define HAL_ADC_RESOLUTION 10
|
||||
|
||||
inline void HAL_init() {}
|
||||
//
|
||||
// Pin Mapping for M42, M43, M226
|
||||
//
|
||||
#define GET_PIN_MAP_PIN(index) index
|
||||
#define GET_PIN_MAP_INDEX(pin) pin
|
||||
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
|
||||
|
||||
// Clear the reset reason
|
||||
void HAL_clear_reset_source();
|
||||
|
||||
// Get the reason for the reset
|
||||
uint8_t HAL_get_reset_source();
|
||||
|
||||
void HAL_reboot();
|
||||
|
||||
FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); }
|
||||
// ------------------------
|
||||
// Class Utilities
|
||||
// ------------------------
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#if GCC_VERSION <= 50000
|
||||
@@ -107,27 +125,63 @@ extern "C" int freeMemory();
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
// ADC
|
||||
// ------------------------
|
||||
// MarlinHAL Class
|
||||
// ------------------------
|
||||
|
||||
void HAL_adc_init();
|
||||
class MarlinHAL {
|
||||
public:
|
||||
|
||||
#define HAL_ADC_VREF 3.3
|
||||
#define HAL_ADC_RESOLUTION 10
|
||||
#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
|
||||
#define HAL_READ_ADC() HAL_adc_get_result()
|
||||
#define HAL_ADC_READY() true
|
||||
// Earliest possible init, before setup()
|
||||
MarlinHAL() {}
|
||||
|
||||
#define HAL_ANALOG_SELECT(pin)
|
||||
static void init() {} // Called early in setup()
|
||||
static void init_board() {} // Called less early in setup()
|
||||
static void reboot(); // Restart the firmware from 0x0
|
||||
|
||||
void HAL_adc_start_conversion(const uint8_t adc_pin);
|
||||
uint16_t HAL_adc_get_result();
|
||||
// Interrupts
|
||||
static bool isr_state() { return !__get_PRIMASK(); }
|
||||
static void isr_on() { __enable_irq(); }
|
||||
static void isr_off() { __disable_irq(); }
|
||||
|
||||
// PWM
|
||||
static void delay_ms(const int ms) { delay(ms); }
|
||||
|
||||
inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); }
|
||||
// Tasks, called from idle()
|
||||
static void idletask() {}
|
||||
|
||||
// Pin Map
|
||||
// Reset
|
||||
static uint8_t get_reset_source();
|
||||
static void clear_reset_source() {}
|
||||
|
||||
#define GET_PIN_MAP_PIN(index) index
|
||||
#define GET_PIN_MAP_INDEX(pin) pin
|
||||
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
|
||||
// Free SRAM
|
||||
static int freeMemory() { return ::freeMemory(); }
|
||||
|
||||
//
|
||||
// ADC Methods
|
||||
//
|
||||
|
||||
// Called by Temperature::init once at startup
|
||||
static void adc_init();
|
||||
|
||||
// Called by Temperature::init for each sensor at startup
|
||||
static void adc_enable(const pin_t ch) {}
|
||||
|
||||
// Begin ADC sampling on the given channel
|
||||
static void adc_start(const pin_t ch);
|
||||
|
||||
// Is the ADC ready for reading?
|
||||
static bool adc_ready() { return true; }
|
||||
|
||||
// The current value of the ADC register
|
||||
static uint16_t adc_value();
|
||||
|
||||
/**
|
||||
* Set the PWM duty cycle for the pin to the given value.
|
||||
* No option to invert the duty cycle [default = false]
|
||||
* No option to change the scale of the provided value to enable finer PWM duty control [default = 255]
|
||||
*/
|
||||
static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) {
|
||||
analogWrite(pin, v);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -70,4 +70,10 @@ void setup_endstop_interrupts() {
|
||||
TERN_(HAS_J_MIN, _ATTACH(J_MIN_PIN));
|
||||
TERN_(HAS_K_MAX, _ATTACH(K_MAX_PIN));
|
||||
TERN_(HAS_K_MIN, _ATTACH(K_MIN_PIN));
|
||||
TERN_(HAS_U_MAX, _ATTACH(U_MAX_PIN));
|
||||
TERN_(HAS_U_MIN, _ATTACH(U_MIN_PIN));
|
||||
TERN_(HAS_V_MAX, _ATTACH(V_MAX_PIN));
|
||||
TERN_(HAS_V_MIN, _ATTACH(V_MIN_PIN));
|
||||
TERN_(HAS_W_MAX, _ATTACH(W_MAX_PIN));
|
||||
TERN_(HAS_W_MIN, _ATTACH(W_MIN_PIN));
|
||||
}
|
||||
|
||||
@@ -40,3 +40,7 @@
|
||||
#if ENABLED(POSTMORTEM_DEBUGGING)
|
||||
#error "POSTMORTEM_DEBUGGING is not yet supported on Teensy 3.1/3.2."
|
||||
#endif
|
||||
|
||||
#if USING_PULLDOWNS
|
||||
#error "PULLDOWN pin mode is not available on Teensy 3.1/3.2 boards."
|
||||
#endif
|
||||
|
||||
@@ -110,4 +110,4 @@ void HAL_timer_disable_interrupt(const uint8_t timer_num);
|
||||
bool HAL_timer_interrupt_enabled(const uint8_t timer_num);
|
||||
|
||||
void HAL_timer_isr_prologue(const uint8_t timer_num);
|
||||
#define HAL_timer_isr_epilogue(T)
|
||||
#define HAL_timer_isr_epilogue(T) NOOP
|
||||
|
||||
@@ -31,6 +31,10 @@
|
||||
|
||||
#include <Wire.h>
|
||||
|
||||
// ------------------------
|
||||
// Serial ports
|
||||
// ------------------------
|
||||
|
||||
#define _IMPLEMENT_SERIAL(X) DefaultSerial##X MSerial##X(false, Serial##X)
|
||||
#define IMPLEMENT_SERIAL(X) _IMPLEMENT_SERIAL(X)
|
||||
#if WITHIN(SERIAL_PORT, 0, 3)
|
||||
@@ -39,54 +43,9 @@
|
||||
|
||||
USBSerialType USBSerial(false, SerialUSB);
|
||||
|
||||
uint16_t HAL_adc_result, HAL_adc_select;
|
||||
|
||||
static const uint8_t pin2sc1a[] = {
|
||||
5, 14, 8, 9, 13, 12, 6, 7, 15, 4, 3, 19+128, 14+128, 15+128, // 0-13 -> A0-A13
|
||||
5, 14, 8, 9, 13, 12, 6, 7, 15, 4, // 14-23 are A0-A9
|
||||
255, 255, 255, 255, 255, 255, 255, // 24-30 are digital only
|
||||
14+128, 15+128, 17, 18, 4+128, 5+128, 6+128, 7+128, 17+128, // 31-39 are A12-A20
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, // 40-48 are digital only
|
||||
10+128, 11+128, // 49-50 are A23-A24
|
||||
255, 255, 255, 255, 255, 255, 255, // 51-57 are digital only
|
||||
255, 255, 255, 255, 255, 255, // 58-63 (sd card pins) are digital only
|
||||
3, 19+128, // 64-65 are A10-A11
|
||||
23, 23+128,// 66-67 are A21-A22 (DAC pins)
|
||||
1, 1+128, // 68-69 are A25-A26 (unused USB host port on Teensy 3.5)
|
||||
26, // 70 is Temperature Sensor
|
||||
18+128 // 71 is Vref
|
||||
};
|
||||
|
||||
/*
|
||||
// disable interrupts
|
||||
void cli() { noInterrupts(); }
|
||||
|
||||
// enable interrupts
|
||||
void sei() { interrupts(); }
|
||||
*/
|
||||
|
||||
void HAL_adc_init() {
|
||||
analog_init();
|
||||
while (ADC0_SC3 & ADC_SC3_CAL) {}; // Wait for calibration to finish
|
||||
while (ADC1_SC3 & ADC_SC3_CAL) {}; // Wait for calibration to finish
|
||||
NVIC_ENABLE_IRQ(IRQ_FTM1);
|
||||
}
|
||||
|
||||
void HAL_clear_reset_source() { }
|
||||
|
||||
uint8_t HAL_get_reset_source() {
|
||||
switch (RCM_SRS0) {
|
||||
case 128: return RST_POWER_ON; break;
|
||||
case 64: return RST_EXTERNAL; break;
|
||||
case 32: return RST_WATCHDOG; break;
|
||||
// case 8: return RST_LOSS_OF_LOCK; break;
|
||||
// case 4: return RST_LOSS_OF_CLOCK; break;
|
||||
// case 2: return RST_LOW_VOLTAGE; break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void HAL_reboot() { _reboot_Teensyduino_(); }
|
||||
// ------------------------
|
||||
// Class Utilities
|
||||
// ------------------------
|
||||
|
||||
extern "C" {
|
||||
extern char __bss_end;
|
||||
@@ -103,24 +62,69 @@ extern "C" {
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_adc_start_conversion(const uint8_t adc_pin) {
|
||||
// ------------------------
|
||||
// MarlinHAL Class
|
||||
// ------------------------
|
||||
|
||||
void MarlinHAL::reboot() { _reboot_Teensyduino_(); }
|
||||
|
||||
// Reset
|
||||
|
||||
uint8_t MarlinHAL::get_reset_source() {
|
||||
switch (RCM_SRS0) {
|
||||
case 128: return RST_POWER_ON; break;
|
||||
case 64: return RST_EXTERNAL; break;
|
||||
case 32: return RST_WATCHDOG; break;
|
||||
// case 8: return RST_LOSS_OF_LOCK; break;
|
||||
// case 4: return RST_LOSS_OF_CLOCK; break;
|
||||
// case 2: return RST_LOW_VOLTAGE; break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ADC
|
||||
|
||||
int8_t MarlinHAL::adc_select;
|
||||
|
||||
void MarlinHAL::adc_init() {
|
||||
analog_init();
|
||||
while (ADC0_SC3 & ADC_SC3_CAL) { /* Wait for calibration to finish */ }
|
||||
while (ADC1_SC3 & ADC_SC3_CAL) { /* Wait for calibration to finish */ }
|
||||
NVIC_ENABLE_IRQ(IRQ_FTM1);
|
||||
}
|
||||
|
||||
void MarlinHAL::adc_start(const pin_t adc_pin) {
|
||||
static const uint8_t pin2sc1a[] = {
|
||||
5, 14, 8, 9, 13, 12, 6, 7, 15, 4, 3, 19+128, 14+128, 15+128, // 0-13 -> A0-A13
|
||||
5, 14, 8, 9, 13, 12, 6, 7, 15, 4, // 14-23 are A0-A9
|
||||
255, 255, 255, 255, 255, 255, 255, // 24-30 are digital only
|
||||
14+128, 15+128, 17, 18, 4+128, 5+128, 6+128, 7+128, 17+128, // 31-39 are A12-A20
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, // 40-48 are digital only
|
||||
10+128, 11+128, // 49-50 are A23-A24
|
||||
255, 255, 255, 255, 255, 255, 255, // 51-57 are digital only
|
||||
255, 255, 255, 255, 255, 255, // 58-63 (sd card pins) are digital only
|
||||
3, 19+128, // 64-65 are A10-A11
|
||||
23, 23+128,// 66-67 are A21-A22 (DAC pins)
|
||||
1, 1+128, // 68-69 are A25-A26 (unused USB host port on Teensy 3.5)
|
||||
26, // 70 is Temperature Sensor
|
||||
18+128 // 71 is Vref
|
||||
};
|
||||
const uint16_t pin = pin2sc1a[adc_pin];
|
||||
if (pin == 0xFF) {
|
||||
// Digital only
|
||||
HAL_adc_select = -1;
|
||||
adc_select = -1; // Digital only
|
||||
}
|
||||
else if (pin & 0x80) {
|
||||
HAL_adc_select = 1;
|
||||
adc_select = 1;
|
||||
ADC1_SC1A = pin & 0x7F;
|
||||
}
|
||||
else {
|
||||
HAL_adc_select = 0;
|
||||
adc_select = 0;
|
||||
ADC0_SC1A = pin;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t HAL_adc_get_result() {
|
||||
switch (HAL_adc_select) {
|
||||
uint16_t MarlinHAL::adc_value() {
|
||||
switch (adc_select) {
|
||||
case 0: return ADC0_RA;
|
||||
case 1: return ADC1_RA;
|
||||
}
|
||||
|
||||
@@ -37,10 +37,6 @@
|
||||
#include <stdint.h>
|
||||
#include <util/atomic.h>
|
||||
|
||||
#define CPU_ST7920_DELAY_1 600
|
||||
#define CPU_ST7920_DELAY_2 750
|
||||
#define CPU_ST7920_DELAY_3 750
|
||||
|
||||
// ------------------------
|
||||
// Defines
|
||||
// ------------------------
|
||||
@@ -53,6 +49,17 @@
|
||||
#define IS_TEENSY35 1
|
||||
#endif
|
||||
|
||||
#define CPU_ST7920_DELAY_1 600
|
||||
#define CPU_ST7920_DELAY_2 750
|
||||
#define CPU_ST7920_DELAY_3 750
|
||||
|
||||
#undef sq
|
||||
#define sq(x) ((x)*(x))
|
||||
|
||||
// ------------------------
|
||||
// Serial ports
|
||||
// ------------------------
|
||||
|
||||
#include "../../core/serial_hook.h"
|
||||
|
||||
#define Serial0 Serial
|
||||
@@ -76,34 +83,43 @@ extern USBSerialType USBSerial;
|
||||
#error "SERIAL_PORT must be from 0 to 3, or -1 for Native USB."
|
||||
#endif
|
||||
|
||||
#define HAL_SERVO_LIB libServo
|
||||
// ------------------------
|
||||
// Types
|
||||
// ------------------------
|
||||
|
||||
class libServo;
|
||||
typedef libServo hal_servo_t;
|
||||
|
||||
typedef int8_t pin_t;
|
||||
|
||||
// ------------------------
|
||||
// Interrupts
|
||||
// ------------------------
|
||||
|
||||
#define CRITICAL_SECTION_START() const bool irqon = !__get_primask(); __disable_irq()
|
||||
#define CRITICAL_SECTION_END() if (irqon) __enable_irq()
|
||||
|
||||
// ------------------------
|
||||
// ADC
|
||||
// ------------------------
|
||||
|
||||
#ifndef analogInputToDigitalPin
|
||||
#define analogInputToDigitalPin(p) ((p < 12U) ? (p) + 54U : -1)
|
||||
#endif
|
||||
|
||||
#define CRITICAL_SECTION_START() uint32_t primask = __get_primask(); __disable_irq()
|
||||
#define CRITICAL_SECTION_END() if (!primask) __enable_irq()
|
||||
#define ISRS_ENABLED() (!__get_primask())
|
||||
#define ENABLE_ISRS() __enable_irq()
|
||||
#define DISABLE_ISRS() __disable_irq()
|
||||
#define HAL_ADC_VREF 3.3
|
||||
#define HAL_ADC_RESOLUTION 10
|
||||
|
||||
#undef sq
|
||||
#define sq(x) ((x)*(x))
|
||||
//
|
||||
// Pin Mapping for M42, M43, M226
|
||||
//
|
||||
#define GET_PIN_MAP_PIN(index) index
|
||||
#define GET_PIN_MAP_INDEX(pin) pin
|
||||
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
|
||||
|
||||
inline void HAL_init() {}
|
||||
|
||||
// Clear reset reason
|
||||
void HAL_clear_reset_source();
|
||||
|
||||
// Reset reason
|
||||
uint8_t HAL_get_reset_source();
|
||||
|
||||
void HAL_reboot();
|
||||
|
||||
FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); }
|
||||
// ------------------------
|
||||
// Class Utilities
|
||||
// ------------------------
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#if GCC_VERSION <= 50000
|
||||
@@ -114,27 +130,65 @@ extern "C" int freeMemory();
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
// ADC
|
||||
// ------------------------
|
||||
// MarlinHAL Class
|
||||
// ------------------------
|
||||
|
||||
void HAL_adc_init();
|
||||
class MarlinHAL {
|
||||
public:
|
||||
|
||||
#define HAL_ADC_VREF 3.3
|
||||
#define HAL_ADC_RESOLUTION 10
|
||||
#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
|
||||
#define HAL_READ_ADC() HAL_adc_get_result()
|
||||
#define HAL_ADC_READY() true
|
||||
// Earliest possible init, before setup()
|
||||
MarlinHAL() {}
|
||||
|
||||
#define HAL_ANALOG_SELECT(pin)
|
||||
static void init() {} // Called early in setup()
|
||||
static void init_board() {} // Called less early in setup()
|
||||
static void reboot(); // Restart the firmware from 0x0
|
||||
|
||||
void HAL_adc_start_conversion(const uint8_t adc_pin);
|
||||
uint16_t HAL_adc_get_result();
|
||||
// Interrupts
|
||||
static bool isr_state() { return true; }
|
||||
static void isr_on() { __enable_irq(); }
|
||||
static void isr_off() { __disable_irq(); }
|
||||
|
||||
// PWM
|
||||
static void delay_ms(const int ms) { delay(ms); }
|
||||
|
||||
inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); }
|
||||
// Tasks, called from idle()
|
||||
static void idletask() {}
|
||||
|
||||
// Pin Map
|
||||
// Reset
|
||||
static uint8_t get_reset_source();
|
||||
static void clear_reset_source() {}
|
||||
|
||||
#define GET_PIN_MAP_PIN(index) index
|
||||
#define GET_PIN_MAP_INDEX(pin) pin
|
||||
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
|
||||
// Free SRAM
|
||||
static int freeMemory() { return ::freeMemory(); }
|
||||
|
||||
//
|
||||
// ADC Methods
|
||||
//
|
||||
|
||||
static int8_t adc_select;
|
||||
|
||||
// Called by Temperature::init once at startup
|
||||
static void adc_init();
|
||||
|
||||
// Called by Temperature::init for each sensor at startup
|
||||
static void adc_enable(const pin_t) {}
|
||||
|
||||
// Begin ADC sampling on the given channel
|
||||
static void adc_start(const pin_t pin);
|
||||
|
||||
// Is the ADC ready for reading?
|
||||
static bool adc_ready() { return true; }
|
||||
|
||||
// The current value of the ADC register
|
||||
static uint16_t adc_value();
|
||||
|
||||
/**
|
||||
* Set the PWM duty cycle for the pin to the given value.
|
||||
* No option to invert the duty cycle [default = false]
|
||||
* No option to change the scale of the provided value to enable finer PWM duty control [default = 255]
|
||||
*/
|
||||
static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) {
|
||||
analogWrite(pin, v);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -69,4 +69,10 @@ void setup_endstop_interrupts() {
|
||||
TERN_(HAS_J_MIN, _ATTACH(J_MIN_PIN));
|
||||
TERN_(HAS_K_MAX, _ATTACH(K_MAX_PIN));
|
||||
TERN_(HAS_K_MIN, _ATTACH(K_MIN_PIN));
|
||||
TERN_(HAS_U_MAX, _ATTACH(U_MAX_PIN));
|
||||
TERN_(HAS_U_MIN, _ATTACH(U_MIN_PIN));
|
||||
TERN_(HAS_V_MAX, _ATTACH(V_MAX_PIN));
|
||||
TERN_(HAS_V_MIN, _ATTACH(V_MIN_PIN));
|
||||
TERN_(HAS_W_MAX, _ATTACH(W_MAX_PIN));
|
||||
TERN_(HAS_W_MIN, _ATTACH(W_MIN_PIN));
|
||||
}
|
||||
|
||||
@@ -40,3 +40,7 @@
|
||||
#if ENABLED(POSTMORTEM_DEBUGGING)
|
||||
#error "POSTMORTEM_DEBUGGING is not yet supported on Teensy 3.5/3.6."
|
||||
#endif
|
||||
|
||||
#if USING_PULLDOWNS
|
||||
#error "PULLDOWN pin mode is not available on Teensy 3.5/3.6 boards."
|
||||
#endif
|
||||
|
||||
@@ -109,4 +109,4 @@ void HAL_timer_disable_interrupt(const uint8_t timer_num);
|
||||
bool HAL_timer_interrupt_enabled(const uint8_t timer_num);
|
||||
|
||||
void HAL_timer_isr_prologue(const uint8_t timer_num);
|
||||
#define HAL_timer_isr_epilogue(T)
|
||||
#define HAL_timer_isr_epilogue(T) NOOP
|
||||
|
||||
@@ -33,6 +33,10 @@
|
||||
#include "timers.h"
|
||||
#include <Wire.h>
|
||||
|
||||
// ------------------------
|
||||
// Serial ports
|
||||
// ------------------------
|
||||
|
||||
#define _IMPLEMENT_SERIAL(X) DefaultSerial##X MSerial##X(false, Serial##X)
|
||||
#define IMPLEMENT_SERIAL(X) _IMPLEMENT_SERIAL(X)
|
||||
#if WITHIN(SERIAL_PORT, 0, 3)
|
||||
@@ -40,75 +44,42 @@
|
||||
#endif
|
||||
USBSerialType USBSerial(false, SerialUSB);
|
||||
|
||||
uint16_t HAL_adc_result, HAL_adc_select;
|
||||
// ------------------------
|
||||
// Class Utilities
|
||||
// ------------------------
|
||||
|
||||
static const uint8_t pin2sc1a[] = {
|
||||
0x07, // 0/A0 AD_B1_02
|
||||
0x08, // 1/A1 AD_B1_03
|
||||
0x0C, // 2/A2 AD_B1_07
|
||||
0x0B, // 3/A3 AD_B1_06
|
||||
0x06, // 4/A4 AD_B1_01
|
||||
0x05, // 5/A5 AD_B1_00
|
||||
0x0F, // 6/A6 AD_B1_10
|
||||
0x00, // 7/A7 AD_B1_11
|
||||
0x0D, // 8/A8 AD_B1_08
|
||||
0x0E, // 9/A9 AD_B1_09
|
||||
0x01, // 24/A10 AD_B0_12
|
||||
0x02, // 25/A11 AD_B0_13
|
||||
0x83, // 26/A12 AD_B1_14 - only on ADC2, 3
|
||||
0x84, // 27/A13 AD_B1_15 - only on ADC2, 4
|
||||
0x07, // 14/A0 AD_B1_02
|
||||
0x08, // 15/A1 AD_B1_03
|
||||
0x0C, // 16/A2 AD_B1_07
|
||||
0x0B, // 17/A3 AD_B1_06
|
||||
0x06, // 18/A4 AD_B1_01
|
||||
0x05, // 19/A5 AD_B1_00
|
||||
0x0F, // 20/A6 AD_B1_10
|
||||
0x00, // 21/A7 AD_B1_11
|
||||
0x0D, // 22/A8 AD_B1_08
|
||||
0x0E, // 23/A9 AD_B1_09
|
||||
0x01, // 24/A10 AD_B0_12
|
||||
0x02, // 25/A11 AD_B0_13
|
||||
0x83, // 26/A12 AD_B1_14 - only on ADC2, 3
|
||||
0x84, // 27/A13 AD_B1_15 - only on ADC2, 4
|
||||
#ifdef ARDUINO_TEENSY41
|
||||
0xFF, // 28
|
||||
0xFF, // 29
|
||||
0xFF, // 30
|
||||
0xFF, // 31
|
||||
0xFF, // 32
|
||||
0xFF, // 33
|
||||
0xFF, // 34
|
||||
0xFF, // 35
|
||||
0xFF, // 36
|
||||
0xFF, // 37
|
||||
0x81, // 38/A14 AD_B1_12 - only on ADC2, 1
|
||||
0x82, // 39/A15 AD_B1_13 - only on ADC2, 2
|
||||
0x09, // 40/A16 AD_B1_04
|
||||
0x0A, // 41/A17 AD_B1_05
|
||||
#endif
|
||||
};
|
||||
#define __bss_end _ebss
|
||||
|
||||
/*
|
||||
// disable interrupts
|
||||
void cli() { noInterrupts(); }
|
||||
extern "C" {
|
||||
extern char __bss_end;
|
||||
extern char __heap_start;
|
||||
extern void* __brkval;
|
||||
|
||||
// enable interrupts
|
||||
void sei() { interrupts(); }
|
||||
*/
|
||||
|
||||
void HAL_adc_init() {
|
||||
analog_init();
|
||||
while (ADC1_GC & ADC_GC_CAL) ;
|
||||
while (ADC2_GC & ADC_GC_CAL) ;
|
||||
// Doesn't work on Teensy 4.x
|
||||
uint32_t freeMemory() {
|
||||
uint32_t free_memory;
|
||||
free_memory = ((uint32_t)&free_memory) - (((uint32_t)__brkval) ?: ((uint32_t)&__bss_end));
|
||||
return free_memory;
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_clear_reset_source() {
|
||||
uint32_t reset_source = SRC_SRSR;
|
||||
SRC_SRSR = reset_source;
|
||||
// ------------------------
|
||||
// FastIO
|
||||
// ------------------------
|
||||
|
||||
bool is_output(pin_t pin) {
|
||||
const struct digital_pin_bitband_and_config_table_struct *p;
|
||||
p = digital_pin_to_info_PGM + pin;
|
||||
return (*(p->reg + 1) & p->mask);
|
||||
}
|
||||
|
||||
uint8_t HAL_get_reset_source() {
|
||||
// ------------------------
|
||||
// MarlinHAL Class
|
||||
// ------------------------
|
||||
|
||||
void MarlinHAL::reboot() { _reboot_Teensyduino_(); }
|
||||
|
||||
uint8_t MarlinHAL::get_reset_source() {
|
||||
switch (SRC_SRSR & 0xFF) {
|
||||
case 1: return RST_POWER_ON; break;
|
||||
case 2: return RST_SOFTWARE; break;
|
||||
@@ -121,57 +92,92 @@ uint8_t HAL_get_reset_source() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void HAL_reboot() { _reboot_Teensyduino_(); }
|
||||
|
||||
#define __bss_end _ebss
|
||||
|
||||
extern "C" {
|
||||
extern char __bss_end;
|
||||
extern char __heap_start;
|
||||
extern void* __brkval;
|
||||
|
||||
// Doesn't work on Teensy 4.x
|
||||
uint32_t freeMemory() {
|
||||
uint32_t free_memory;
|
||||
if ((uint32_t)__brkval == 0)
|
||||
free_memory = ((uint32_t)&free_memory) - ((uint32_t)&__bss_end);
|
||||
else
|
||||
free_memory = ((uint32_t)&free_memory) - ((uint32_t)__brkval);
|
||||
return free_memory;
|
||||
}
|
||||
void MarlinHAL::clear_reset_source() {
|
||||
uint32_t reset_source = SRC_SRSR;
|
||||
SRC_SRSR = reset_source;
|
||||
}
|
||||
|
||||
void HAL_adc_start_conversion(const uint8_t adc_pin) {
|
||||
// ADC
|
||||
|
||||
int8_t MarlinHAL::adc_select;
|
||||
|
||||
void MarlinHAL::adc_init() {
|
||||
analog_init();
|
||||
while (ADC1_GC & ADC_GC_CAL) { /* wait */ }
|
||||
while (ADC2_GC & ADC_GC_CAL) { /* wait */ }
|
||||
}
|
||||
|
||||
void MarlinHAL::adc_start(const pin_t adc_pin) {
|
||||
static const uint8_t pin2sc1a[] = {
|
||||
0x07, // 0/A0 AD_B1_02
|
||||
0x08, // 1/A1 AD_B1_03
|
||||
0x0C, // 2/A2 AD_B1_07
|
||||
0x0B, // 3/A3 AD_B1_06
|
||||
0x06, // 4/A4 AD_B1_01
|
||||
0x05, // 5/A5 AD_B1_00
|
||||
0x0F, // 6/A6 AD_B1_10
|
||||
0x00, // 7/A7 AD_B1_11
|
||||
0x0D, // 8/A8 AD_B1_08
|
||||
0x0E, // 9/A9 AD_B1_09
|
||||
0x01, // 24/A10 AD_B0_12
|
||||
0x02, // 25/A11 AD_B0_13
|
||||
0x83, // 26/A12 AD_B1_14 - only on ADC2, 3
|
||||
0x84, // 27/A13 AD_B1_15 - only on ADC2, 4
|
||||
0x07, // 14/A0 AD_B1_02
|
||||
0x08, // 15/A1 AD_B1_03
|
||||
0x0C, // 16/A2 AD_B1_07
|
||||
0x0B, // 17/A3 AD_B1_06
|
||||
0x06, // 18/A4 AD_B1_01
|
||||
0x05, // 19/A5 AD_B1_00
|
||||
0x0F, // 20/A6 AD_B1_10
|
||||
0x00, // 21/A7 AD_B1_11
|
||||
0x0D, // 22/A8 AD_B1_08
|
||||
0x0E, // 23/A9 AD_B1_09
|
||||
0x01, // 24/A10 AD_B0_12
|
||||
0x02, // 25/A11 AD_B0_13
|
||||
0x83, // 26/A12 AD_B1_14 - only on ADC2, 3
|
||||
0x84, // 27/A13 AD_B1_15 - only on ADC2, 4
|
||||
#ifdef ARDUINO_TEENSY41
|
||||
0xFF, // 28
|
||||
0xFF, // 29
|
||||
0xFF, // 30
|
||||
0xFF, // 31
|
||||
0xFF, // 32
|
||||
0xFF, // 33
|
||||
0xFF, // 34
|
||||
0xFF, // 35
|
||||
0xFF, // 36
|
||||
0xFF, // 37
|
||||
0x81, // 38/A14 AD_B1_12 - only on ADC2, 1
|
||||
0x82, // 39/A15 AD_B1_13 - only on ADC2, 2
|
||||
0x09, // 40/A16 AD_B1_04
|
||||
0x0A, // 41/A17 AD_B1_05
|
||||
#endif
|
||||
};
|
||||
const uint16_t pin = pin2sc1a[adc_pin];
|
||||
if (pin == 0xFF) {
|
||||
HAL_adc_select = -1; // Digital only
|
||||
adc_select = -1; // Digital only
|
||||
}
|
||||
else if (pin & 0x80) {
|
||||
HAL_adc_select = 1;
|
||||
adc_select = 1;
|
||||
ADC2_HC0 = pin & 0x7F;
|
||||
}
|
||||
else {
|
||||
HAL_adc_select = 0;
|
||||
adc_select = 0;
|
||||
ADC1_HC0 = pin;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t HAL_adc_get_result() {
|
||||
switch (HAL_adc_select) {
|
||||
uint16_t MarlinHAL::adc_value() {
|
||||
switch (adc_select) {
|
||||
case 0:
|
||||
while (!(ADC1_HS & ADC_HS_COCO0)) ; // wait
|
||||
while (!(ADC1_HS & ADC_HS_COCO0)) { /* wait */ }
|
||||
return ADC1_R0;
|
||||
case 1:
|
||||
while (!(ADC2_HS & ADC_HS_COCO0)) ; // wait
|
||||
while (!(ADC2_HS & ADC_HS_COCO0)) { /* wait */ }
|
||||
return ADC2_R0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool is_output(pin_t pin) {
|
||||
const struct digital_pin_bitband_and_config_table_struct *p;
|
||||
p = digital_pin_to_info_PGM + pin;
|
||||
return (*(p->reg + 1) & p->mask);
|
||||
}
|
||||
|
||||
#endif // __IMXRT1062__
|
||||
|
||||
@@ -41,10 +41,6 @@
|
||||
#include "../../feature/ethernet.h"
|
||||
#endif
|
||||
|
||||
#define CPU_ST7920_DELAY_1 600
|
||||
#define CPU_ST7920_DELAY_2 750
|
||||
#define CPU_ST7920_DELAY_3 750
|
||||
|
||||
// ------------------------
|
||||
// Defines
|
||||
// ------------------------
|
||||
@@ -55,7 +51,23 @@
|
||||
#define IS_TEENSY41 1
|
||||
#endif
|
||||
|
||||
#define CPU_ST7920_DELAY_1 600
|
||||
#define CPU_ST7920_DELAY_2 750
|
||||
#define CPU_ST7920_DELAY_3 750
|
||||
|
||||
#undef sq
|
||||
#define sq(x) ((x)*(x))
|
||||
|
||||
// Don't place string constants in PROGMEM
|
||||
#undef PSTR
|
||||
#define PSTR(str) ({static const char *data = (str); &data[0];})
|
||||
|
||||
// ------------------------
|
||||
// Serial ports
|
||||
// ------------------------
|
||||
|
||||
#include "../../core/serial_hook.h"
|
||||
|
||||
#define Serial0 Serial
|
||||
#define _DECLARE_SERIAL(X) \
|
||||
typedef ForwardSerial1Class<decltype(Serial##X)> DefaultSerial##X; \
|
||||
@@ -89,41 +101,47 @@ extern USBSerialType USBSerial;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define HAL_SERVO_LIB libServo
|
||||
// ------------------------
|
||||
// Types
|
||||
// ------------------------
|
||||
|
||||
class libServo;
|
||||
typedef libServo hal_servo_t;
|
||||
|
||||
typedef int8_t pin_t;
|
||||
|
||||
// ------------------------
|
||||
// Interrupts
|
||||
// ------------------------
|
||||
|
||||
#define CRITICAL_SECTION_START() const bool irqon = !__get_primask(); __disable_irq()
|
||||
#define CRITICAL_SECTION_END() if (irqon) __enable_irq()
|
||||
|
||||
// ------------------------
|
||||
// ADC
|
||||
// ------------------------
|
||||
|
||||
#ifndef analogInputToDigitalPin
|
||||
#define analogInputToDigitalPin(p) ((p < 12U) ? (p) + 54U : -1)
|
||||
#endif
|
||||
|
||||
#define CRITICAL_SECTION_START() uint32_t primask = __get_primask(); __disable_irq()
|
||||
#define CRITICAL_SECTION_END() if (!primask) __enable_irq()
|
||||
#define ISRS_ENABLED() (!__get_primask())
|
||||
#define ENABLE_ISRS() __enable_irq()
|
||||
#define DISABLE_ISRS() __disable_irq()
|
||||
#define HAL_ADC_VREF 3.3
|
||||
#define HAL_ADC_RESOLUTION 10
|
||||
#define HAL_ADC_FILTERED // turn off ADC oversampling
|
||||
|
||||
#undef sq
|
||||
#define sq(x) ((x)*(x))
|
||||
//
|
||||
// Pin Mapping for M42, M43, M226
|
||||
//
|
||||
#define GET_PIN_MAP_PIN(index) index
|
||||
#define GET_PIN_MAP_INDEX(pin) pin
|
||||
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
|
||||
|
||||
// Don't place string constants in PROGMEM
|
||||
#undef PSTR
|
||||
#define PSTR(str) ({static const char *data = (str); &data[0];})
|
||||
// FastIO
|
||||
bool is_output(pin_t pin);
|
||||
|
||||
// Enable hooks into idle and setup for HAL
|
||||
#define HAL_IDLETASK 1
|
||||
FORCE_INLINE void HAL_idletask() {}
|
||||
FORCE_INLINE void HAL_init() {}
|
||||
|
||||
// Clear reset reason
|
||||
void HAL_clear_reset_source();
|
||||
|
||||
// Reset reason
|
||||
uint8_t HAL_get_reset_source();
|
||||
|
||||
void HAL_reboot();
|
||||
|
||||
FORCE_INLINE void _delay_ms(const int delay_ms) { delay(delay_ms); }
|
||||
// ------------------------
|
||||
// Class Utilities
|
||||
// ------------------------
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#if GCC_VERSION <= 50000
|
||||
@@ -134,30 +152,65 @@ extern "C" uint32_t freeMemory();
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
// ADC
|
||||
// ------------------------
|
||||
// MarlinHAL Class
|
||||
// ------------------------
|
||||
|
||||
void HAL_adc_init();
|
||||
class MarlinHAL {
|
||||
public:
|
||||
|
||||
#define HAL_ADC_VREF 3.3
|
||||
#define HAL_ADC_RESOLUTION 10
|
||||
#define HAL_ADC_FILTERED // turn off ADC oversampling
|
||||
#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
|
||||
#define HAL_READ_ADC() HAL_adc_get_result()
|
||||
#define HAL_ADC_READY() true
|
||||
// Earliest possible init, before setup()
|
||||
MarlinHAL() {}
|
||||
|
||||
#define HAL_ANALOG_SELECT(pin)
|
||||
static void init() {} // Called early in setup()
|
||||
static void init_board() {} // Called less early in setup()
|
||||
static void reboot(); // Restart the firmware from 0x0
|
||||
|
||||
void HAL_adc_start_conversion(const uint8_t adc_pin);
|
||||
uint16_t HAL_adc_get_result();
|
||||
// Interrupts
|
||||
static bool isr_state() { return !__get_primask(); }
|
||||
static void isr_on() { __enable_irq(); }
|
||||
static void isr_off() { __disable_irq(); }
|
||||
|
||||
// PWM
|
||||
static void delay_ms(const int ms) { delay(ms); }
|
||||
|
||||
inline void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) { analogWrite(pin, v); }
|
||||
// Tasks, called from idle()
|
||||
static void idletask() {}
|
||||
|
||||
// Pin Map
|
||||
// Reset
|
||||
static uint8_t get_reset_source();
|
||||
static void clear_reset_source();
|
||||
|
||||
#define GET_PIN_MAP_PIN(index) index
|
||||
#define GET_PIN_MAP_INDEX(pin) pin
|
||||
#define PARSED_PIN_INDEX(code, dval) parser.intval(code, dval)
|
||||
// Free SRAM
|
||||
static int freeMemory() { return ::freeMemory(); }
|
||||
|
||||
bool is_output(pin_t pin);
|
||||
//
|
||||
// ADC Methods
|
||||
//
|
||||
|
||||
static int8_t adc_select;
|
||||
|
||||
// Called by Temperature::init once at startup
|
||||
static void adc_init();
|
||||
|
||||
// Called by Temperature::init for each sensor at startup
|
||||
static void adc_enable(const pin_t pin) {}
|
||||
|
||||
// Begin ADC sampling on the given channel
|
||||
static void adc_start(const pin_t pin);
|
||||
|
||||
// Is the ADC ready for reading?
|
||||
static bool adc_ready() { return true; }
|
||||
|
||||
// The current value of the ADC register
|
||||
static uint16_t adc_value();
|
||||
|
||||
/**
|
||||
* Set the PWM duty cycle for the pin to the given value.
|
||||
* No option to invert the duty cycle [default = false]
|
||||
* No option to change the scale of the provided value to enable finer PWM duty control [default = 255]
|
||||
*/
|
||||
static void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t=255, const bool=false) {
|
||||
analogWrite(pin, v);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -114,4 +114,4 @@ bool HAL_timer_interrupt_enabled(const uint8_t timer_num);
|
||||
|
||||
void HAL_timer_isr_prologue(const uint8_t timer_num);
|
||||
//void HAL_timer_isr_epilogue(const uint8_t timer_num) {}
|
||||
#define HAL_timer_isr_epilogue(T)
|
||||
#define HAL_timer_isr_epilogue(T) NOOP
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
* Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
@@ -19,18 +19,18 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* DWIN Mesh Viewer
|
||||
* Author: Miguel A. Risco-Castillo
|
||||
* Version: 3.8.1
|
||||
* Date: 2021/11/06
|
||||
* HAL/shared/HAL.cpp
|
||||
*/
|
||||
|
||||
class MeshViewerClass {
|
||||
public:
|
||||
void Draw();
|
||||
};
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
extern MeshViewerClass MeshViewer;
|
||||
MarlinHAL hal;
|
||||
|
||||
#if ENABLED(SOFT_RESET_VIA_SERIAL)
|
||||
|
||||
// Global for use by e_parser.h
|
||||
void HAL_reboot() { hal.reboot(); }
|
||||
|
||||
#endif
|
||||
@@ -92,9 +92,9 @@ uint8_t L64XX_Marlin::transfer_single(uint8_t data, int16_t ss_pin) {
|
||||
// First device in chain has data sent last
|
||||
extDigitalWrite(ss_pin, LOW);
|
||||
|
||||
DISABLE_ISRS(); // Disable interrupts during SPI transfer (can't allow partial command to chips)
|
||||
hal.isr_off(); // Disable interrupts during SPI transfer (can't allow partial command to chips)
|
||||
const uint8_t data_out = L6470_SpiTransfer_Mode_3(data);
|
||||
ENABLE_ISRS(); // Enable interrupts
|
||||
hal.isr_on(); // Enable interrupts
|
||||
|
||||
extDigitalWrite(ss_pin, HIGH);
|
||||
return data_out;
|
||||
@@ -107,9 +107,9 @@ uint8_t L64XX_Marlin::transfer_chain(uint8_t data, int16_t ss_pin, uint8_t chain
|
||||
extDigitalWrite(ss_pin, LOW);
|
||||
|
||||
for (uint8_t i = L64XX::chain[0]; !L64xxManager.spi_abort && i >= 1; i--) { // Send data unless aborted
|
||||
DISABLE_ISRS(); // Disable interrupts during SPI transfer (can't allow partial command to chips)
|
||||
hal.isr_off(); // Disable interrupts during SPI transfer (can't allow partial command to chips)
|
||||
const uint8_t temp = L6470_SpiTransfer_Mode_3(uint8_t(i == chain_position ? data : dSPIN_NOP));
|
||||
ENABLE_ISRS(); // Enable interrupts
|
||||
hal.isr_on(); // Enable interrupts
|
||||
if (i == chain_position) data_out = temp;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,6 @@
|
||||
/**
|
||||
* Math helper functions for 32 bit CPUs
|
||||
*/
|
||||
static FORCE_INLINE uint32_t MultiU32X24toH32(uint32_t longIn1, uint32_t longIn2) {
|
||||
FORCE_INLINE static uint32_t MultiU32X24toH32(uint32_t longIn1, uint32_t longIn2) {
|
||||
return ((uint64_t)longIn1 * longIn2 + 0x00800000) >> 24;
|
||||
}
|
||||
|
||||
+50
-40
@@ -74,8 +74,8 @@
|
||||
#include "lcd/e3v2/common/encoder.h"
|
||||
#if ENABLED(DWIN_CREALITY_LCD)
|
||||
#include "lcd/e3v2/creality/dwin.h"
|
||||
#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
|
||||
#include "lcd/e3v2/enhanced/dwin.h"
|
||||
#elif ENABLED(DWIN_LCD_PROUI)
|
||||
#include "lcd/e3v2/proui/dwin.h"
|
||||
#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI)
|
||||
#include "lcd/e3v2/jyersui/dwin.h"
|
||||
#endif
|
||||
@@ -145,7 +145,7 @@
|
||||
#include "feature/encoder_i2c.h"
|
||||
#endif
|
||||
|
||||
#if HAS_TRINAMIC_CONFIG && DISABLED(PSU_DEFAULT_OFF)
|
||||
#if (HAS_TRINAMIC_CONFIG || HAS_TMC_SPI) && DISABLED(PSU_DEFAULT_OFF)
|
||||
#include "feature/tmc_util.h"
|
||||
#endif
|
||||
|
||||
@@ -436,6 +436,9 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
|
||||
TERN_(DISABLE_INACTIVE_I, stepper.disable_axis(I_AXIS));
|
||||
TERN_(DISABLE_INACTIVE_J, stepper.disable_axis(J_AXIS));
|
||||
TERN_(DISABLE_INACTIVE_K, stepper.disable_axis(K_AXIS));
|
||||
TERN_(DISABLE_INACTIVE_U, stepper.disable_axis(U_AXIS));
|
||||
TERN_(DISABLE_INACTIVE_V, stepper.disable_axis(V_AXIS));
|
||||
TERN_(DISABLE_INACTIVE_W, stepper.disable_axis(W_AXIS));
|
||||
TERN_(DISABLE_INACTIVE_E, stepper.disable_e_steppers());
|
||||
|
||||
TERN_(AUTO_BED_LEVELING_UBL, ubl.steppers_were_disabled());
|
||||
@@ -476,7 +479,7 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
|
||||
#endif
|
||||
|
||||
#if HAS_FREEZE_PIN
|
||||
Stepper::frozen = !READ(FREEZE_PIN);
|
||||
stepper.frozen = READ(FREEZE_PIN) == FREEZE_STATE;
|
||||
#endif
|
||||
|
||||
#if HAS_HOME
|
||||
@@ -790,7 +793,7 @@ void idle(bool no_stepper_sleep/*=false*/) {
|
||||
#endif
|
||||
|
||||
// Run HAL idle tasks
|
||||
TERN_(HAL_IDLETASK, HAL_idletask());
|
||||
hal.idletask();
|
||||
|
||||
// Check network connection
|
||||
TERN_(HAS_ETHERNET, ethernet.check());
|
||||
@@ -822,7 +825,7 @@ void idle(bool no_stepper_sleep/*=false*/) {
|
||||
TERN_(USE_BEEPER, buzzer.tick());
|
||||
|
||||
// Handle UI input / draw events
|
||||
TERN(HAS_DWIN_E3V2_BASIC, DWIN_Update(), ui.update());
|
||||
TERN(DWIN_CREALITY_LCD, DWIN_Update(), ui.update());
|
||||
|
||||
// Run i2c Position Encoders
|
||||
#if ENABLED(I2C_POSITION_ENCODERS)
|
||||
@@ -878,7 +881,7 @@ void kill(FSTR_P const lcd_error/*=nullptr*/, FSTR_P const lcd_component/*=nullp
|
||||
// Echo the LCD message to serial for extra context
|
||||
if (lcd_error) { SERIAL_ECHO_START(); SERIAL_ECHOLNF(lcd_error); }
|
||||
|
||||
#if EITHER(HAS_DISPLAY, DWIN_CREALITY_LCD_ENHANCED)
|
||||
#if EITHER(HAS_DISPLAY, DWIN_LCD_PROUI)
|
||||
ui.kill_screen(lcd_error ?: GET_TEXT_F(MSG_KILLED), lcd_component ?: FPSTR(NUL_STR));
|
||||
#else
|
||||
UNUSED(lcd_error); UNUSED(lcd_component);
|
||||
@@ -929,7 +932,7 @@ void minkill(const bool steppers_off/*=false*/) {
|
||||
watchdog_refresh();
|
||||
|
||||
// Reboot the board
|
||||
HAL_reboot();
|
||||
hal.reboot();
|
||||
|
||||
#else
|
||||
|
||||
@@ -993,6 +996,15 @@ inline void tmc_standby_setup() {
|
||||
#if PIN_EXISTS(K_STDBY)
|
||||
SET_INPUT_PULLDOWN(K_STDBY_PIN);
|
||||
#endif
|
||||
#if PIN_EXISTS(U_STDBY)
|
||||
SET_INPUT_PULLDOWN(U_STDBY_PIN);
|
||||
#endif
|
||||
#if PIN_EXISTS(V_STDBY)
|
||||
SET_INPUT_PULLDOWN(V_STDBY_PIN);
|
||||
#endif
|
||||
#if PIN_EXISTS(W_STDBY)
|
||||
SET_INPUT_PULLDOWN(W_STDBY_PIN);
|
||||
#endif
|
||||
#if PIN_EXISTS(E0_STDBY)
|
||||
SET_INPUT_PULLDOWN(E0_STDBY_PIN);
|
||||
#endif
|
||||
@@ -1041,7 +1053,7 @@ inline void tmc_standby_setup() {
|
||||
* • L64XX Stepper Drivers (SPI)
|
||||
* • Stepper Driver Reset: DISABLE
|
||||
* • TMC Stepper Drivers (SPI)
|
||||
* • Run BOARD_INIT if defined
|
||||
* • Run hal.init_board() for additional pins setup
|
||||
* • ESP WiFi
|
||||
* - Get the Reset Reason and report it
|
||||
* - Print startup messages and diagnostics
|
||||
@@ -1119,8 +1131,8 @@ void setup() {
|
||||
tmc_standby_setup(); // TMC Low Power Standby pins must be set early or they're not usable
|
||||
|
||||
// Check startup - does nothing if bootloader sets MCUSR to 0
|
||||
const byte mcu = HAL_get_reset_source();
|
||||
HAL_clear_reset_source();
|
||||
const byte mcu = hal.get_reset_source();
|
||||
hal.clear_reset_source();
|
||||
|
||||
#if ENABLED(MARLIN_DEV_MODE)
|
||||
auto log_current_ms = [&](PGM_P const msg) {
|
||||
@@ -1166,9 +1178,13 @@ void setup() {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if HAS_FREEZE_PIN
|
||||
#if ENABLED(FREEZE_FEATURE)
|
||||
SETUP_LOG("FREEZE_PIN");
|
||||
SET_INPUT_PULLUP(FREEZE_PIN);
|
||||
#if FREEZE_STATE
|
||||
SET_INPUT_PULLDOWN(FREEZE_PIN);
|
||||
#else
|
||||
SET_INPUT_PULLUP(FREEZE_PIN);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if HAS_SUICIDE
|
||||
@@ -1181,23 +1197,20 @@ void setup() {
|
||||
JTAGSWD_RESET();
|
||||
#endif
|
||||
|
||||
#if EITHER(DISABLE_DEBUG, DISABLE_JTAG)
|
||||
// Disable any hardware debug to free up pins for IO
|
||||
#if ENABLED(DISABLE_DEBUG) && defined(JTAGSWD_DISABLE)
|
||||
delay(10);
|
||||
// Disable any hardware debug to free up pins for IO
|
||||
#if ENABLED(DISABLE_DEBUG) && defined(JTAGSWD_DISABLE)
|
||||
SETUP_LOG("JTAGSWD_DISABLE");
|
||||
JTAGSWD_DISABLE();
|
||||
#elif defined(JTAG_DISABLE)
|
||||
SETUP_LOG("JTAG_DISABLE");
|
||||
JTAG_DISABLE();
|
||||
#else
|
||||
#error "DISABLE_(DEBUG|JTAG) is not supported for the selected MCU/Board."
|
||||
#endif
|
||||
SETUP_LOG("JTAGSWD_DISABLE");
|
||||
JTAGSWD_DISABLE();
|
||||
#elif ENABLED(DISABLE_JTAG) && defined(JTAG_DISABLE)
|
||||
delay(10);
|
||||
SETUP_LOG("JTAG_DISABLE");
|
||||
JTAG_DISABLE();
|
||||
#endif
|
||||
|
||||
TERN_(DYNAMIC_VECTORTABLE, hook_cpu_exceptions()); // If supported, install Marlin exception handlers at runtime
|
||||
|
||||
SETUP_RUN(HAL_init());
|
||||
SETUP_RUN(hal.init());
|
||||
|
||||
// Init and disable SPI thermocouples; this is still needed
|
||||
#if TEMP_SENSOR_0_IS_MAX_TC || (TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E0))
|
||||
@@ -1243,19 +1256,16 @@ void setup() {
|
||||
SETUP_RUN(tmc_init_cs_pins());
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_INIT
|
||||
SETUP_LOG("BOARD_INIT");
|
||||
BOARD_INIT();
|
||||
#endif
|
||||
SETUP_RUN(hal.init_board());
|
||||
|
||||
SETUP_RUN(esp_wifi_init());
|
||||
|
||||
// Report Reset Reason
|
||||
if (mcu & RST_POWER_ON) SERIAL_ECHOLNPGM(STR_POWERUP);
|
||||
if (mcu & RST_EXTERNAL) SERIAL_ECHOLNPGM(STR_EXTERNAL_RESET);
|
||||
if (mcu & RST_POWER_ON) SERIAL_ECHOLNPGM(STR_POWERUP);
|
||||
if (mcu & RST_EXTERNAL) SERIAL_ECHOLNPGM(STR_EXTERNAL_RESET);
|
||||
if (mcu & RST_BROWN_OUT) SERIAL_ECHOLNPGM(STR_BROWNOUT_RESET);
|
||||
if (mcu & RST_WATCHDOG) SERIAL_ECHOLNPGM(STR_WATCHDOG_RESET);
|
||||
if (mcu & RST_SOFTWARE) SERIAL_ECHOLNPGM(STR_SOFTWARE_RESET);
|
||||
if (mcu & RST_WATCHDOG) SERIAL_ECHOLNPGM(STR_WATCHDOG_RESET);
|
||||
if (mcu & RST_SOFTWARE) SERIAL_ECHOLNPGM(STR_SOFTWARE_RESET);
|
||||
|
||||
// Identify myself as Marlin x.x.x
|
||||
SERIAL_ECHOLNPGM("Marlin " SHORT_BUILD_VERSION);
|
||||
@@ -1266,7 +1276,7 @@ void setup() {
|
||||
);
|
||||
#endif
|
||||
SERIAL_ECHO_MSG(" Compiled: " __DATE__);
|
||||
SERIAL_ECHO_MSG(STR_FREE_MEMORY, freeMemory(), STR_PLANNER_BUFFER_BYTES, sizeof(block_t) * (BLOCK_BUFFER_SIZE));
|
||||
SERIAL_ECHO_MSG(STR_FREE_MEMORY, hal.freeMemory(), STR_PLANNER_BUFFER_BYTES, sizeof(block_t) * (BLOCK_BUFFER_SIZE));
|
||||
|
||||
// Some HAL need precise delay adjustment
|
||||
calibrate_delay_loop();
|
||||
@@ -1339,6 +1349,10 @@ void setup() {
|
||||
|
||||
SETUP_RUN(endstops.init()); // Init endstops and pullups
|
||||
|
||||
#if ENABLED(DELTA) && !HAS_SOFTWARE_ENDSTOPS
|
||||
SETUP_RUN(refresh_delta_clip_start_height()); // Init safe delta height without soft endstops
|
||||
#endif
|
||||
|
||||
SETUP_RUN(stepper.init()); // Init stepper. This enables interrupts!
|
||||
|
||||
#if HAS_SERVOS
|
||||
@@ -1538,7 +1552,7 @@ void setup() {
|
||||
#endif
|
||||
|
||||
#if ENABLED(USE_WATCHDOG)
|
||||
SETUP_RUN(watchdog_init()); // Reinit watchdog after HAL_get_reset_source call
|
||||
SETUP_RUN(watchdog_init()); // Reinit watchdog after hal.get_reset_source call
|
||||
#endif
|
||||
|
||||
#if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER)
|
||||
@@ -1573,11 +1587,7 @@ void setup() {
|
||||
#endif
|
||||
|
||||
#if HAS_DWIN_E3V2_BASIC
|
||||
SETUP_LOG("E3V2 Init");
|
||||
Encoder_Configuration();
|
||||
HMI_Init();
|
||||
HMI_SetLanguageCache();
|
||||
HMI_StartFrame(true);
|
||||
SETUP_RUN(DWIN_InitScreen());
|
||||
#endif
|
||||
|
||||
#if HAS_SERVICE_INTERVALS && !HAS_DWIN_E3V2_BASIC
|
||||
|
||||
+14
-10
@@ -116,6 +116,7 @@
|
||||
#define BOARD_LONGER3D_LK1_PRO 1160 // Longer LK1 PRO / Alfawise U20 Pro (PRO version)
|
||||
#define BOARD_LONGER3D_LKx_PRO 1161 // Longer LKx PRO / Alfawise Uxx Pro (PRO version)
|
||||
#define BOARD_ZRIB_V53 1162 // Zonestar zrib V5.3 (Chinese RAMPS replica)
|
||||
#define BOARD_PXMALION_CORE_I3 1163 // Pxmalion Core I3
|
||||
|
||||
//
|
||||
// RAMBo and derivatives
|
||||
@@ -163,6 +164,7 @@
|
||||
#define BOARD_MALYAN_M180 1327 // Malyan M180 Mainboard Version 2 (no display function, direct gcode only)
|
||||
#define BOARD_GT2560_V4_A20 1328 // Geeetech GT2560 Rev B for A20(M/T/D)
|
||||
#define BOARD_PROTONEER_CNC_SHIELD_V3 1329 // Mega controller & Protoneer CNC Shield V3.00
|
||||
#define BOARD_WEEDO_62A 1330 // WEEDO 62A board (TINA2, Monoprice Cadet, etc.)
|
||||
|
||||
//
|
||||
// ATmega1281, ATmega2561
|
||||
@@ -362,6 +364,7 @@
|
||||
#define BOARD_ZONESTAR_ZM3E4 4061 // Zonestar ZM3E4 V1 (STM32F103VC)
|
||||
#define BOARD_ZONESTAR_ZM3E4V2 4062 // Zonestar ZM3E4 V2 (STM32F103VC)
|
||||
#define BOARD_ERYONE_ERY32_MINI 4063 // Eryone Ery32 mini (STM32F103VE)
|
||||
#define BOARD_PANDA_PI_V29 4064 // Panda Pi V2.9 - Standalone (STM32F103RC)
|
||||
|
||||
//
|
||||
// ARM Cortex-M4F
|
||||
@@ -403,16 +406,17 @@
|
||||
#define BOARD_MKS_ROBIN2 4226 // MKS_ROBIN2 (STM32F407ZE)
|
||||
#define BOARD_MKS_ROBIN_PRO_V2 4227 // MKS Robin Pro V2 (STM32F407VE)
|
||||
#define BOARD_MKS_ROBIN_NANO_V3 4228 // MKS Robin Nano V3 (STM32F407VG)
|
||||
#define BOARD_MKS_MONSTER8 4229 // MKS Monster8 (STM32F407VG)
|
||||
#define BOARD_ANET_ET4 4230 // ANET ET4 V1.x (STM32F407VG)
|
||||
#define BOARD_ANET_ET4P 4231 // ANET ET4P V1.x (STM32F407VG)
|
||||
#define BOARD_FYSETC_CHEETAH_V20 4232 // FYSETC Cheetah V2.0
|
||||
#define BOARD_TH3D_EZBOARD_V2 4233 // TH3D EZBoard v2.0
|
||||
#define BOARD_INDEX_REV03 4234 // Index PnP Controller REV03 (STM32F407VE/VG)
|
||||
#define BOARD_MKS_ROBIN_NANO_V1_3_F4 4235 // MKS Robin Nano V1.3 and MKS Robin Nano-S V1.3 (STM32F407VE)
|
||||
#define BOARD_MKS_EAGLE 4236 // MKS Eagle (STM32F407VE)
|
||||
#define BOARD_ARTILLERY_RUBY 4237 // Artillery Ruby (STM32F401RC)
|
||||
#define BOARD_FYSETC_SPIDER_V2_2 4238 // FYSETC Spider V2.2 (STM32F446VE)
|
||||
#define BOARD_MKS_ROBIN_NANO_V3_1 4229 // MKS Robin Nano V3.1 (STM32F407VE)
|
||||
#define BOARD_MKS_MONSTER8 4230 // MKS Monster8 (STM32F407VG)
|
||||
#define BOARD_ANET_ET4 4231 // ANET ET4 V1.x (STM32F407VG)
|
||||
#define BOARD_ANET_ET4P 4232 // ANET ET4P V1.x (STM32F407VG)
|
||||
#define BOARD_FYSETC_CHEETAH_V20 4233 // FYSETC Cheetah V2.0
|
||||
#define BOARD_TH3D_EZBOARD_V2 4234 // TH3D EZBoard v2.0
|
||||
#define BOARD_INDEX_REV03 4235 // Index PnP Controller REV03 (STM32F407VE/VG)
|
||||
#define BOARD_MKS_ROBIN_NANO_V1_3_F4 4236 // MKS Robin Nano V1.3 and MKS Robin Nano-S V1.3 (STM32F407VE)
|
||||
#define BOARD_MKS_EAGLE 4237 // MKS Eagle (STM32F407VE)
|
||||
#define BOARD_ARTILLERY_RUBY 4238 // Artillery Ruby (STM32F401RC)
|
||||
#define BOARD_FYSETC_SPIDER_V2_2 4239 // FYSETC Spider V2.2 (STM32F446VE)
|
||||
|
||||
//
|
||||
// ARM Cortex M7
|
||||
|
||||
@@ -63,6 +63,9 @@
|
||||
#define AXIS_DRIVER_TYPE_I(T) _AXIS_DRIVER_TYPE(I,T)
|
||||
#define AXIS_DRIVER_TYPE_J(T) _AXIS_DRIVER_TYPE(J,T)
|
||||
#define AXIS_DRIVER_TYPE_K(T) _AXIS_DRIVER_TYPE(K,T)
|
||||
#define AXIS_DRIVER_TYPE_U(T) _AXIS_DRIVER_TYPE(U,T)
|
||||
#define AXIS_DRIVER_TYPE_V(T) _AXIS_DRIVER_TYPE(V,T)
|
||||
#define AXIS_DRIVER_TYPE_W(T) _AXIS_DRIVER_TYPE(W,T)
|
||||
|
||||
#define AXIS_DRIVER_TYPE_X2(T) (EITHER(X_DUAL_STEPPER_DRIVERS, DUAL_X_CARRIAGE) && _AXIS_DRIVER_TYPE(X2,T))
|
||||
#define AXIS_DRIVER_TYPE_Y2(T) (ENABLED(Y_DUAL_STEPPER_DRIVERS) && _AXIS_DRIVER_TYPE(Y2,T))
|
||||
@@ -87,6 +90,7 @@
|
||||
|
||||
#define HAS_DRIVER(T) ( AXIS_DRIVER_TYPE_X(T) || AXIS_DRIVER_TYPE_Y(T) || AXIS_DRIVER_TYPE_Z(T) \
|
||||
|| AXIS_DRIVER_TYPE_I(T) || AXIS_DRIVER_TYPE_J(T) || AXIS_DRIVER_TYPE_K(T) \
|
||||
|| AXIS_DRIVER_TYPE_U(T) || AXIS_DRIVER_TYPE_V(T) || AXIS_DRIVER_TYPE_W(T) \
|
||||
|| AXIS_DRIVER_TYPE_X2(T) || AXIS_DRIVER_TYPE_Y2(T) || AXIS_DRIVER_TYPE_Z2(T) \
|
||||
|| AXIS_DRIVER_TYPE_Z3(T) || AXIS_DRIVER_TYPE_Z4(T) || HAS_E_DRIVER(T) )
|
||||
|
||||
@@ -128,7 +132,7 @@
|
||||
// Test for a driver that uses SPI - this allows checking whether a _CS_ pin
|
||||
// is considered sensitive
|
||||
#define AXIS_HAS_SPI(A) ( AXIS_DRIVER_TYPE(A,TMC2130) || AXIS_DRIVER_TYPE(A,TMC2160) \
|
||||
|| AXIS_DRIVER_TYPE(A,TMC2660) \
|
||||
|| AXIS_DRIVER_TYPE(A,TMC26X) || AXIS_DRIVER_TYPE(A,TMC2660) \
|
||||
|| AXIS_DRIVER_TYPE(A,TMC5130) || AXIS_DRIVER_TYPE(A,TMC5160) )
|
||||
|
||||
#define AXIS_HAS_UART(A) ( AXIS_DRIVER_TYPE(A,TMC2208) || AXIS_DRIVER_TYPE(A,TMC2209) )
|
||||
@@ -161,6 +165,7 @@
|
||||
|| AXIS_HAS_##T(Y) || AXIS_HAS_##T(Y2) \
|
||||
|| AXIS_HAS_##T(Z) || AXIS_HAS_##T(Z2) || AXIS_HAS_##T(Z3) || AXIS_HAS_##T(Z4) \
|
||||
|| AXIS_HAS_##T(I) || AXIS_HAS_##T(J) || AXIS_HAS_##T(K) \
|
||||
|| AXIS_HAS_##T(U) || AXIS_HAS_##T(V) || AXIS_HAS_##T(W) \
|
||||
|| E_AXIS_HAS(T) )
|
||||
|
||||
#if ANY_AXIS_HAS(STEALTHCHOP)
|
||||
@@ -200,4 +205,4 @@
|
||||
#define HAS_L64XX_NOT_L6474 1
|
||||
#endif
|
||||
|
||||
#define AXIS_IS_L64XX(A) (AXIS_DRIVER_TYPE_##A(L6470) || AXIS_DRIVER_TYPE_##A(L6474) || AXIS_DRIVER_TYPE_##A(L6480) || AXIS_DRIVER_TYPE_##A(POWERSTEP01))
|
||||
#define AXIS_IS_L64XX(A) (AXIS_DRIVER_TYPE_##A(L6470) || AXIS_DRIVER_TYPE_##A(L6474) || AXIS_DRIVER_TYPE_##A(L6480) || AXIS_DRIVER_TYPE_##A(POWERSTEP01))
|
||||
|
||||
@@ -444,6 +444,54 @@
|
||||
#define STR_K ""
|
||||
#endif
|
||||
|
||||
#if HAS_U_AXIS
|
||||
#if AXIS7_NAME == 'U'
|
||||
#define STR_U "U"
|
||||
#define STR_U_MIN "u_min"
|
||||
#define STR_U_MAX "u_max"
|
||||
#elif AXIS7_NAME == 'V'
|
||||
#define STR_U "V"
|
||||
#define STR_U_MIN "v_min"
|
||||
#define STR_U_MAX "v_max"
|
||||
#elif AXIS7_NAME == 'W'
|
||||
#define STR_U "W"
|
||||
#define STR_U_MIN "w_min"
|
||||
#define STR_U_MAX "w_max"
|
||||
#else
|
||||
#error "AXIS7_NAME can only be one of 'U', 'V', or 'W'."
|
||||
#endif
|
||||
#else
|
||||
#define STR_U ""
|
||||
#endif
|
||||
|
||||
#if HAS_V_AXIS
|
||||
#if AXIS8_NAME == 'V'
|
||||
#define STR_V "V"
|
||||
#define STR_V_MIN "v_min"
|
||||
#define STR_V_MAX "v_max"
|
||||
#elif AXIS8_NAME == 'W'
|
||||
#define STR_V "W"
|
||||
#define STR_V_MIN "w_min"
|
||||
#define STR_V_MAX "w_max"
|
||||
#else
|
||||
#error "AXIS8_NAME can only be one of 'V', or 'W'."
|
||||
#endif
|
||||
#else
|
||||
#define STR_V ""
|
||||
#endif
|
||||
|
||||
#if HAS_W_AXIS
|
||||
#if AXIS9_NAME == 'W'
|
||||
#define STR_W "W"
|
||||
#define STR_W_MIN "w_min"
|
||||
#define STR_W_MAX "w_max"
|
||||
#else
|
||||
#error "AXIS9_NAME can only be 'W'."
|
||||
#endif
|
||||
#else
|
||||
#define STR_W ""
|
||||
#endif
|
||||
|
||||
#if EITHER(HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL)
|
||||
|
||||
// Custom characters defined in the first 8 characters of the LCD
|
||||
|
||||
@@ -39,24 +39,36 @@
|
||||
#define _ISTOP_ 0x04
|
||||
#define _JSTOP_ 0x05
|
||||
#define _KSTOP_ 0x06
|
||||
#define _USTOP_ 0x07
|
||||
#define _VSTOP_ 0x08
|
||||
#define _WSTOP_ 0x09
|
||||
#define _XMIN_ 0x11
|
||||
#define _YMIN_ 0x12
|
||||
#define _ZMIN_ 0x13
|
||||
#define _IMIN_ 0x14
|
||||
#define _JMIN_ 0x15
|
||||
#define _KMIN_ 0x16
|
||||
#define _UMIN_ 0x17
|
||||
#define _VMIN_ 0x18
|
||||
#define _WMIN_ 0x19
|
||||
#define _XMAX_ 0x21
|
||||
#define _YMAX_ 0x22
|
||||
#define _ZMAX_ 0x23
|
||||
#define _IMAX_ 0x24
|
||||
#define _JMAX_ 0x25
|
||||
#define _KMAX_ 0x26
|
||||
#define _UMAX_ 0x27
|
||||
#define _VMAX_ 0x28
|
||||
#define _WMAX_ 0x29
|
||||
#define _XDIAG_ 0x31
|
||||
#define _YDIAG_ 0x32
|
||||
#define _ZDIAG_ 0x33
|
||||
#define _IDIAG_ 0x34
|
||||
#define _JDIAG_ 0x35
|
||||
#define _KDIAG_ 0x36
|
||||
#define _UDIAG_ 0x37
|
||||
#define _VDIAG_ 0x38
|
||||
#define _WDIAG_ 0x39
|
||||
#define _E0DIAG_ 0xE0
|
||||
#define _E1DIAG_ 0xE1
|
||||
#define _E2DIAG_ 0xE2
|
||||
@@ -350,7 +362,7 @@
|
||||
|
||||
#define _LIST_N(N,V...) LIST_##N(V)
|
||||
#define LIST_N(N,V...) _LIST_N(N,V)
|
||||
#define LIST_N_1(N,K) _LIST_N(N,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K)
|
||||
#define LIST_N_1(N,K) _LIST_N(N,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K)
|
||||
#define ARRAY_N(N,V...) { _LIST_N(N,V) }
|
||||
#define ARRAY_N_1(N,K) { LIST_N_1(N,K) }
|
||||
|
||||
|
||||
@@ -80,6 +80,9 @@ typedef const char Language_Str[];
|
||||
#endif
|
||||
#define GET_TEXT_F(MSG) FPSTR(GET_TEXT(MSG))
|
||||
|
||||
#define GET_EN_TEXT(MSG) GET_LANG(en)::MSG
|
||||
#define GET_EN_TEXT_F(MSG) FPSTR(GET_EN_TEXT(MSG))
|
||||
|
||||
#define GET_LANGUAGE_NAME(INDEX) GET_LANG(LCD_LANGUAGE_##INDEX)::LANGUAGE
|
||||
#define LANG_CHARSIZE GET_TEXT(CHARSIZE)
|
||||
#define USE_WIDE_GLYPH (LANG_CHARSIZE > 2)
|
||||
|
||||
@@ -32,14 +32,18 @@ uint8_t marlin_debug_flags = MARLIN_DEBUG_NONE;
|
||||
// Commonly-used strings in serial output
|
||||
PGMSTR(NUL_STR, ""); PGMSTR(SP_P_STR, " P"); PGMSTR(SP_T_STR, " T");
|
||||
PGMSTR(X_STR, "X"); PGMSTR(Y_STR, "Y"); PGMSTR(Z_STR, "Z"); PGMSTR(E_STR, "E");
|
||||
PGMSTR(U_STR, STR_U); PGMSTR(V_STR, STR_V); PGMSTR(W_STR, STR_W);
|
||||
PGMSTR(X_LBL, "X:"); PGMSTR(Y_LBL, "Y:"); PGMSTR(Z_LBL, "Z:"); PGMSTR(E_LBL, "E:");
|
||||
PGMSTR(U_LBL, STR_U ":"); PGMSTR(V_LBL, STR_V ":"); PGMSTR(W_LBL, STR_W ":");
|
||||
PGMSTR(SP_A_STR, " A"); PGMSTR(SP_B_STR, " B"); PGMSTR(SP_C_STR, " C");
|
||||
PGMSTR(SP_X_STR, " X"); PGMSTR(SP_Y_STR, " Y"); PGMSTR(SP_Z_STR, " Z"); PGMSTR(SP_E_STR, " E");
|
||||
PGMSTR(SP_X_LBL, " X:"); PGMSTR(SP_Y_LBL, " Y:"); PGMSTR(SP_Z_LBL, " Z:"); PGMSTR(SP_E_LBL, " E:");
|
||||
PGMSTR(I_STR, STR_I); PGMSTR(J_STR, STR_J); PGMSTR(K_STR, STR_K);
|
||||
PGMSTR(I_LBL, STR_I ":"); PGMSTR(J_LBL, STR_J ":"); PGMSTR(K_LBL, STR_K ":");
|
||||
PGMSTR(SP_I_STR, " " STR_I); PGMSTR(SP_J_STR, " " STR_J); PGMSTR(SP_K_STR, " " STR_K);
|
||||
PGMSTR(SP_U_STR, " " STR_U); PGMSTR(SP_V_STR, " " STR_V); PGMSTR(SP_W_STR, " " STR_W);
|
||||
PGMSTR(SP_I_LBL, " " STR_I ":"); PGMSTR(SP_J_LBL, " " STR_J ":"); PGMSTR(SP_K_LBL, " " STR_K ":");
|
||||
PGMSTR(SP_U_LBL, " " STR_U ":"); PGMSTR(SP_V_LBL, " " STR_V ":"); PGMSTR(SP_W_LBL, " " STR_W ":");
|
||||
|
||||
// Hook Meatpack if it's enabled on the first leaf
|
||||
#if ENABLED(MEATPACK_ON_SERIAL_PORT_1)
|
||||
@@ -78,6 +82,14 @@ void serial_error_start() { static PGMSTR(errormagic, "Error:"); serial_print_P(
|
||||
|
||||
void serial_spaces(uint8_t count) { count *= (PROPORTIONAL_FONT_RATIO); while (count--) SERIAL_CHAR(' '); }
|
||||
|
||||
void serial_offset(const_float_t v, const uint8_t sp/*=0*/) {
|
||||
if (v == 0 && sp == 1)
|
||||
SERIAL_CHAR(' ');
|
||||
else if (v > 0 || (v == 0 && sp == 2))
|
||||
SERIAL_CHAR('+');
|
||||
SERIAL_DECIMAL(v);
|
||||
}
|
||||
|
||||
void serial_ternary(const bool onoff, FSTR_P const pre, FSTR_P const on, FSTR_P const off, FSTR_P const post/*=nullptr*/) {
|
||||
if (pre) serial_print(pre);
|
||||
serial_print(onoff ? on : off);
|
||||
@@ -94,10 +106,10 @@ void print_bin(uint16_t val) {
|
||||
}
|
||||
}
|
||||
|
||||
void print_pos(LINEAR_AXIS_ARGS(const_float_t), FSTR_P const prefix/*=nullptr*/, FSTR_P const suffix/*=nullptr*/) {
|
||||
void print_pos(NUM_AXIS_ARGS(const_float_t), FSTR_P const prefix/*=nullptr*/, FSTR_P const suffix/*=nullptr*/) {
|
||||
if (prefix) serial_print(prefix);
|
||||
SERIAL_ECHOPGM_P(
|
||||
LIST_N(DOUBLE(LINEAR_AXES), SP_X_STR, x, SP_Y_STR, y, SP_Z_STR, z, SP_I_STR, i, SP_J_STR, j, SP_K_STR, k)
|
||||
LIST_N(DOUBLE(NUM_AXES), SP_X_STR, x, SP_Y_STR, y, SP_Z_STR, z, SP_I_STR, i, SP_J_STR, j, SP_K_STR, k, SP_U_STR, u, SP_V_STR, v, SP_W_STR, w)
|
||||
);
|
||||
if (suffix) serial_print(suffix); else SERIAL_EOL();
|
||||
}
|
||||
|
||||
@@ -29,17 +29,12 @@
|
||||
#endif
|
||||
|
||||
// Commonly-used strings in serial output
|
||||
extern const char NUL_STR[],
|
||||
SP_X_STR[], SP_Y_STR[], SP_Z_STR[],
|
||||
SP_A_STR[], SP_B_STR[], SP_C_STR[], SP_E_STR[],
|
||||
SP_X_LBL[], SP_Y_LBL[], SP_Z_LBL[], SP_E_LBL[],
|
||||
SP_I_STR[], SP_J_STR[], SP_K_STR[],
|
||||
SP_I_LBL[], SP_J_LBL[], SP_K_LBL[],
|
||||
SP_P_STR[], SP_T_STR[],
|
||||
X_STR[], Y_STR[], Z_STR[], E_STR[],
|
||||
I_STR[], J_STR[], K_STR[],
|
||||
X_LBL[], Y_LBL[], Z_LBL[], E_LBL[],
|
||||
I_LBL[], J_LBL[], K_LBL[];
|
||||
extern const char NUL_STR[], SP_P_STR[], SP_T_STR[],
|
||||
SP_A_STR[], SP_B_STR[], SP_C_STR[],
|
||||
SP_X_STR[], SP_Y_STR[], SP_Z_STR[], SP_I_STR[], SP_J_STR[], SP_K_STR[], SP_U_STR[], SP_V_STR[], SP_W_STR[], SP_E_STR[],
|
||||
SP_X_LBL[], SP_Y_LBL[], SP_Z_LBL[], SP_I_LBL[], SP_J_LBL[], SP_K_LBL[], SP_U_LBL[], SP_V_LBL[], SP_W_LBL[], SP_E_LBL[],
|
||||
X_STR[], Y_STR[], Z_STR[], I_STR[], J_STR[], K_STR[], U_STR[], V_STR[], W_STR[], E_STR[],
|
||||
X_LBL[], Y_LBL[], Z_LBL[], I_LBL[], J_LBL[], K_LBL[], U_LBL[], V_LBL[], W_LBL[], E_LBL[];
|
||||
|
||||
//
|
||||
// Debugging flags for use by M111
|
||||
@@ -345,12 +340,13 @@ void serialprint_onoff(const bool onoff);
|
||||
void serialprintln_onoff(const bool onoff);
|
||||
void serialprint_truefalse(const bool tf);
|
||||
void serial_spaces(uint8_t count);
|
||||
void serial_offset(const_float_t v, const uint8_t sp=0); // For v==0 draw space (sp==1) or plus (sp==2)
|
||||
|
||||
void print_bin(const uint16_t val);
|
||||
void print_pos(LINEAR_AXIS_ARGS(const_float_t), FSTR_P const prefix=nullptr, FSTR_P const suffix=nullptr);
|
||||
void print_pos(NUM_AXIS_ARGS(const_float_t), FSTR_P const prefix=nullptr, FSTR_P const suffix=nullptr);
|
||||
|
||||
inline void print_pos(const xyz_pos_t &xyz, FSTR_P const prefix=nullptr, FSTR_P const suffix=nullptr) {
|
||||
print_pos(LINEAR_AXIS_ELEM(xyz), prefix, suffix);
|
||||
print_pos(NUM_AXIS_ELEM(xyz), prefix, suffix);
|
||||
}
|
||||
|
||||
#define SERIAL_POS(SUFFIX,VAR) do { print_pos(VAR, F(" " STRINGIFY(VAR) "="), F(" : " SUFFIX "\n")); }while(0)
|
||||
|
||||
+214
-180
@@ -36,23 +36,33 @@ struct IF { typedef R type; };
|
||||
template <class L, class R>
|
||||
struct IF<true, L, R> { typedef L type; };
|
||||
|
||||
#define LINEAR_AXIS_GANG(V...) GANG_N(LINEAR_AXES, V)
|
||||
#define LINEAR_AXIS_CODE(V...) CODE_N(LINEAR_AXES, V)
|
||||
#define LINEAR_AXIS_LIST(V...) LIST_N(LINEAR_AXES, V)
|
||||
#define LINEAR_AXIS_ARRAY(V...) { LINEAR_AXIS_LIST(V) }
|
||||
#define LINEAR_AXIS_ARGS(T...) LINEAR_AXIS_LIST(T x, T y, T z, T i, T j, T k)
|
||||
#define LINEAR_AXIS_ELEM(O) LINEAR_AXIS_LIST(O.x, O.y, O.z, O.i, O.j, O.k)
|
||||
#define LINEAR_AXIS_DEFS(T,V) LINEAR_AXIS_LIST(T x=V, T y=V, T z=V, T i=V, T j=V, T k=V)
|
||||
#define NUM_AXIS_GANG(V...) GANG_N(NUM_AXES, V)
|
||||
#define NUM_AXIS_CODE(V...) CODE_N(NUM_AXES, V)
|
||||
#define NUM_AXIS_LIST(V...) LIST_N(NUM_AXES, V)
|
||||
#define NUM_AXIS_ARRAY(V...) { NUM_AXIS_LIST(V) }
|
||||
#define NUM_AXIS_ARGS(T...) NUM_AXIS_LIST(T x, T y, T z, T i, T j, T k, T u, T v, T w)
|
||||
#define NUM_AXIS_ELEM(O) NUM_AXIS_LIST(O.x, O.y, O.z, O.i, O.j, O.k, O.u, O.v, O.w)
|
||||
#define NUM_AXIS_DEFS(T,V) NUM_AXIS_LIST(T x=V, T y=V, T z=V, T i=V, T j=V, T k=V, T u=V, T v=V, T w=V)
|
||||
|
||||
#define LOGICAL_AXIS_GANG(E,V...) LINEAR_AXIS_GANG(V) GANG_ITEM_E(E)
|
||||
#define LOGICAL_AXIS_CODE(E,V...) LINEAR_AXIS_CODE(V) CODE_ITEM_E(E)
|
||||
#define LOGICAL_AXIS_LIST(E,V...) LINEAR_AXIS_LIST(V) LIST_ITEM_E(E)
|
||||
#define LOGICAL_AXIS_GANG(E,V...) NUM_AXIS_GANG(V) GANG_ITEM_E(E)
|
||||
#define LOGICAL_AXIS_CODE(E,V...) NUM_AXIS_CODE(V) CODE_ITEM_E(E)
|
||||
#define LOGICAL_AXIS_LIST(E,V...) NUM_AXIS_LIST(V) LIST_ITEM_E(E)
|
||||
#define LOGICAL_AXIS_ARRAY(E,V...) { LOGICAL_AXIS_LIST(E,V) }
|
||||
#define LOGICAL_AXIS_ARGS(T...) LOGICAL_AXIS_LIST(T e, T x, T y, T z, T i, T j, T k)
|
||||
#define LOGICAL_AXIS_ELEM(O) LOGICAL_AXIS_LIST(O.e, O.x, O.y, O.z, O.i, O.j, O.k)
|
||||
#define LOGICAL_AXIS_DECL(T,V) LOGICAL_AXIS_LIST(T e=V, T x=V, T y=V, T z=V, T i=V, T j=V, T k=V)
|
||||
#define LOGICAL_AXIS_ARGS(T...) LOGICAL_AXIS_LIST(T e, T x, T y, T z, T i, T j, T k, T u, T v, T w)
|
||||
#define LOGICAL_AXIS_ELEM(O) LOGICAL_AXIS_LIST(O.e, O.x, O.y, O.z, O.i, O.j, O.k, O.u, O.v, O.w)
|
||||
#define LOGICAL_AXIS_DECL(T,V) LOGICAL_AXIS_LIST(T e=V, T x=V, T y=V, T z=V, T i=V, T j=V, T k=V, T u=V, T v=V, T w=V)
|
||||
|
||||
#define LOGICAL_AXES_STRING LOGICAL_AXIS_GANG("E", "X", "Y", "Z", STR_I, STR_J, STR_K)
|
||||
#define LOGICAL_AXES_STRING LOGICAL_AXIS_GANG("E", "X", "Y", "Z", STR_I, STR_J, STR_K, STR_U, STR_V, STR_W)
|
||||
|
||||
#define XYZ_GANG(V...) GANG_N(PRIMARY_LINEAR_AXES, V)
|
||||
#define XYZ_CODE(V...) CODE_N(PRIMARY_LINEAR_AXES, V)
|
||||
|
||||
#define SECONDARY_AXIS_GANG(V...) GANG_N(SECONDARY_AXES, V)
|
||||
#define SECONDARY_AXIS_CODE(V...) CODE_N(SECONDARY_AXES, V)
|
||||
|
||||
#if HAS_ROTATIONAL_AXES
|
||||
#define ROTATIONAL_AXIS_GANG(V...) GANG_N(ROTATIONAL_AXES, V)
|
||||
#endif
|
||||
|
||||
#if HAS_EXTRUDERS
|
||||
#define LIST_ITEM_E(N) , N
|
||||
@@ -64,7 +74,7 @@ struct IF<true, L, R> { typedef L type; };
|
||||
#define GANG_ITEM_E(N)
|
||||
#endif
|
||||
|
||||
#define AXIS_COLLISION(L) (AXIS4_NAME == L || AXIS5_NAME == L || AXIS6_NAME == L)
|
||||
#define AXIS_COLLISION(L) (AXIS4_NAME == L || AXIS5_NAME == L || AXIS6_NAME == L || AXIS7_NAME == L || AXIS8_NAME == L || AXIS9_NAME == L)
|
||||
|
||||
//
|
||||
// Enumerated axis indices
|
||||
@@ -76,7 +86,7 @@ struct IF<true, L, R> { typedef L type; };
|
||||
enum AxisEnum : uint8_t {
|
||||
|
||||
// Linear axes may be controlled directly or indirectly
|
||||
LINEAR_AXIS_LIST(X_AXIS, Y_AXIS, Z_AXIS, I_AXIS, J_AXIS, K_AXIS)
|
||||
NUM_AXIS_LIST(X_AXIS, Y_AXIS, Z_AXIS, I_AXIS, J_AXIS, K_AXIS, U_AXIS, V_AXIS, W_AXIS)
|
||||
|
||||
// Extruder axes may be considered distinctly
|
||||
#define _EN_ITEM(N) , E##N##_AXIS
|
||||
@@ -110,14 +120,16 @@ enum AxisEnum : uint8_t {
|
||||
};
|
||||
|
||||
typedef IF<(NUM_AXIS_ENUMS > 8), uint16_t, uint8_t>::type axis_bits_t;
|
||||
typedef IF<(NUM_AXES > 8), uint16_t, uint8_t>::type linear_axis_bits_t;
|
||||
|
||||
//
|
||||
// Loop over axes
|
||||
//
|
||||
#define LOOP_ABC(VAR) LOOP_S_LE_N(VAR, A_AXIS, C_AXIS)
|
||||
#define LOOP_LINEAR_AXES(VAR) LOOP_S_L_N(VAR, X_AXIS, LINEAR_AXES)
|
||||
#define LOOP_NUM_AXES(VAR) LOOP_S_L_N(VAR, X_AXIS, NUM_AXES)
|
||||
#define LOOP_LOGICAL_AXES(VAR) LOOP_S_L_N(VAR, X_AXIS, LOGICAL_AXES)
|
||||
#define LOOP_DISTINCT_AXES(VAR) LOOP_S_L_N(VAR, X_AXIS, DISTINCT_AXES)
|
||||
#define LOOP_DISTINCT_E(VAR) LOOP_L_N(VAR, DISTINCT_E)
|
||||
|
||||
//
|
||||
// feedRate_t is just a humble float
|
||||
@@ -128,6 +140,7 @@ typedef float feedRate_t;
|
||||
// celsius_t is the native unit of temperature. Signed to handle a disconnected thermistor value (-14).
|
||||
// For more resolition (e.g., for a chocolate printer) this may later be changed to Celsius x 100
|
||||
//
|
||||
typedef uint16_t raw_adc_t;
|
||||
typedef int16_t celsius_t;
|
||||
typedef float celsius_float_t;
|
||||
|
||||
@@ -258,10 +271,10 @@ struct XYval {
|
||||
FI void set(const T px, const T py) { x = px; y = py; }
|
||||
FI void set(const T (&arr)[XY]) { x = arr[0]; y = arr[1]; }
|
||||
#endif
|
||||
#if LINEAR_AXES > XY
|
||||
FI void set(const T (&arr)[LINEAR_AXES]) { x = arr[0]; y = arr[1]; }
|
||||
#if NUM_AXES > XY
|
||||
FI void set(const T (&arr)[NUM_AXES]) { x = arr[0]; y = arr[1]; }
|
||||
#endif
|
||||
#if LOGICAL_AXES > LINEAR_AXES
|
||||
#if LOGICAL_AXES > NUM_AXES
|
||||
FI void set(const T (&arr)[LOGICAL_AXES]) { x = arr[0]; y = arr[1]; }
|
||||
#if DISTINCT_AXES > LOGICAL_AXES
|
||||
FI void set(const T (&arr)[DISTINCT_AXES]) { x = arr[0]; y = arr[1]; }
|
||||
@@ -383,60 +396,69 @@ struct XYval {
|
||||
template<typename T>
|
||||
struct XYZval {
|
||||
union {
|
||||
struct { T LINEAR_AXIS_ARGS(); };
|
||||
struct { T LINEAR_AXIS_LIST(a, b, c, u, v, w); };
|
||||
T pos[LINEAR_AXES];
|
||||
struct { T NUM_AXIS_ARGS(); };
|
||||
struct { T NUM_AXIS_LIST(a, b, c, _i, _j, _k, _u, _v, _w); };
|
||||
T pos[NUM_AXES];
|
||||
};
|
||||
|
||||
// Set all to 0
|
||||
FI void reset() { LINEAR_AXIS_GANG(x =, y =, z =, i =, j =, k =) 0; }
|
||||
FI void reset() { NUM_AXIS_GANG(x =, y =, z =, i =, j =, k =, u =, v =, w =) 0; }
|
||||
|
||||
// Setters taking struct types and arrays
|
||||
FI void set(const T px) { x = px; }
|
||||
FI void set(const T px, const T py) { x = px; y = py; }
|
||||
FI void set(const XYval<T> pxy) { x = pxy.x; y = pxy.y; }
|
||||
FI void set(const XYval<T> pxy, const T pz) { LINEAR_AXIS_CODE(x = pxy.x, y = pxy.y, z = pz, NOOP, NOOP, NOOP); }
|
||||
FI void set(const XYval<T> pxy, const T pz) { NUM_AXIS_CODE(x = pxy.x, y = pxy.y, z = pz, NOOP, NOOP, NOOP, NOOP, NOOP, NOOP); }
|
||||
FI void set(const T (&arr)[XY]) { x = arr[0]; y = arr[1]; }
|
||||
#if HAS_Z_AXIS
|
||||
FI void set(const T (&arr)[LINEAR_AXES]) { LINEAR_AXIS_CODE(x = arr[0], y = arr[1], z = arr[2], i = arr[3], j = arr[4], k = arr[5]); }
|
||||
FI void set(LINEAR_AXIS_ARGS(const T)) { LINEAR_AXIS_CODE(a = x, b = y, c = z, u = i, v = j, w = k ); }
|
||||
FI void set(const T (&arr)[NUM_AXES]) { NUM_AXIS_CODE(x = arr[0], y = arr[1], z = arr[2], i = arr[3], j = arr[4], k = arr[5], u = arr[6], v = arr[7], w = arr[8]); }
|
||||
FI void set(NUM_AXIS_ARGS(const T)) { NUM_AXIS_CODE(a = x, b = y, c = z, _i = i, _j = j, _k = k, _u = u, _v = v, _w = w ); }
|
||||
#endif
|
||||
#if LOGICAL_AXES > LINEAR_AXES
|
||||
FI void set(const T (&arr)[LOGICAL_AXES]) { LINEAR_AXIS_CODE(x = arr[0], y = arr[1], z = arr[2], i = arr[3], j = arr[4], k = arr[5]); }
|
||||
FI void set(LOGICAL_AXIS_ARGS(const T)) { LINEAR_AXIS_CODE(a = x, b = y, c = z, u = i, v = j, w = k ); }
|
||||
#if LOGICAL_AXES > NUM_AXES
|
||||
FI void set(const T (&arr)[LOGICAL_AXES]) { NUM_AXIS_CODE(x = arr[0], y = arr[1], z = arr[2], i = arr[3], j = arr[4], k = arr[5], u = arr[6], v = arr[7], w = arr[8]); }
|
||||
FI void set(LOGICAL_AXIS_ARGS(const T)) { NUM_AXIS_CODE(a = x, b = y, c = z, _i = i, _j = j, _k = k, _u = u, _v = v, _w = w ); }
|
||||
#if DISTINCT_AXES > LOGICAL_AXES
|
||||
FI void set(const T (&arr)[DISTINCT_AXES]) { LINEAR_AXIS_CODE(x = arr[0], y = arr[1], z = arr[2], i = arr[3], j = arr[4], k = arr[5]); }
|
||||
FI void set(const T (&arr)[DISTINCT_AXES]) { NUM_AXIS_CODE(x = arr[0], y = arr[1], z = arr[2], i = arr[3], j = arr[4], k = arr[5], u = arr[6], v = arr[7], w = arr[8]); }
|
||||
#endif
|
||||
#endif
|
||||
#if HAS_I_AXIS
|
||||
FI void set(const T px, const T py, const T pz) { x = px; y = py; z = pz; }
|
||||
FI void set(const T px, const T py, const T pz) { x = px; y = py; z = pz; }
|
||||
#endif
|
||||
#if HAS_J_AXIS
|
||||
FI void set(const T px, const T py, const T pz, const T pi) { x = px; y = py; z = pz; i = pi; }
|
||||
FI void set(const T px, const T py, const T pz, const T pi) { x = px; y = py; z = pz; i = pi; }
|
||||
#endif
|
||||
#if HAS_K_AXIS
|
||||
FI void set(const T px, const T py, const T pz, const T pi, const T pj) { x = px; y = py; z = pz; i = pi; j = pj; }
|
||||
#endif
|
||||
#if HAS_U_AXIS
|
||||
FI void set(const T px, const T py, const T pz, const T pi, const T pj, const T pk) { x = px; y = py; z = pz; i = pi; j = pj; k = pk; }
|
||||
#endif
|
||||
#if HAS_V_AXIS
|
||||
FI void set(const T px, const T py, const T pz, const T pi, const T pj, const T pk, const T pm) { x = px; y = py; z = pz; i = pi; j = pj; k = pk; u = pu; }
|
||||
#endif
|
||||
#if HAS_W_AXIS
|
||||
FI void set(const T px, const T py, const T pz, const T pi, const T pj, const T pk, const T pm, const T po) { x = px; y = py; z = pz; i = pi; j = pj; k = pk; u = pu; v = pv; }
|
||||
#endif
|
||||
|
||||
// Length reduced to one dimension
|
||||
FI T magnitude() const { return (T)sqrtf(LINEAR_AXIS_GANG(x*x, + y*y, + z*z, + i*i, + j*j, + k*k)); }
|
||||
FI T magnitude() const { return (T)sqrtf(NUM_AXIS_GANG(x*x, + y*y, + z*z, + i*i, + j*j, + k*k, + u*u, + v*v, + w*w)); }
|
||||
// Pointer to the data as a simple array
|
||||
FI operator T* () { return pos; }
|
||||
// If any element is true then it's true
|
||||
FI operator bool() { return LINEAR_AXIS_GANG(x, || y, || z, || i, || j, || k); }
|
||||
FI operator bool() { return NUM_AXIS_GANG(x, || y, || z, || i, || j, || k, || u, || v, || w); }
|
||||
|
||||
// Explicit copy and copies with conversion
|
||||
FI XYZval<T> copy() const { XYZval<T> o = *this; return o; }
|
||||
FI XYZval<T> ABS() const { return LINEAR_AXIS_ARRAY(T(_ABS(x)), T(_ABS(y)), T(_ABS(z)), T(_ABS(i)), T(_ABS(j)), T(_ABS(k))); }
|
||||
FI XYZval<int16_t> asInt() { return LINEAR_AXIS_ARRAY(int16_t(x), int16_t(y), int16_t(z), int16_t(i), int16_t(j), int16_t(k)); }
|
||||
FI XYZval<int16_t> asInt() const { return LINEAR_AXIS_ARRAY(int16_t(x), int16_t(y), int16_t(z), int16_t(i), int16_t(j), int16_t(k)); }
|
||||
FI XYZval<int32_t> asLong() { return LINEAR_AXIS_ARRAY(int32_t(x), int32_t(y), int32_t(z), int32_t(i), int32_t(j), int32_t(k)); }
|
||||
FI XYZval<int32_t> asLong() const { return LINEAR_AXIS_ARRAY(int32_t(x), int32_t(y), int32_t(z), int32_t(i), int32_t(j), int32_t(k)); }
|
||||
FI XYZval<int32_t> ROUNDL() { return LINEAR_AXIS_ARRAY(int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)), int32_t(LROUND(i)), int32_t(LROUND(j)), int32_t(LROUND(k))); }
|
||||
FI XYZval<int32_t> ROUNDL() const { return LINEAR_AXIS_ARRAY(int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)), int32_t(LROUND(i)), int32_t(LROUND(j)), int32_t(LROUND(k))); }
|
||||
FI XYZval<float> asFloat() { return LINEAR_AXIS_ARRAY(static_cast<float>(x), static_cast<float>(y), static_cast<float>(z), static_cast<float>(i), static_cast<float>(j), static_cast<float>(k)); }
|
||||
FI XYZval<float> asFloat() const { return LINEAR_AXIS_ARRAY(static_cast<float>(x), static_cast<float>(y), static_cast<float>(z), static_cast<float>(i), static_cast<float>(j), static_cast<float>(k)); }
|
||||
FI XYZval<float> reciprocal() const { return LINEAR_AXIS_ARRAY(_RECIP(x), _RECIP(y), _RECIP(z), _RECIP(i), _RECIP(j), _RECIP(k)); }
|
||||
FI XYZval<T> ABS() const { return NUM_AXIS_ARRAY(T(_ABS(x)), T(_ABS(y)), T(_ABS(z)), T(_ABS(i)), T(_ABS(j)), T(_ABS(k)), T(_ABS(u)), T(_ABS(v)), T(_ABS(w))); }
|
||||
FI XYZval<int16_t> asInt() { return NUM_AXIS_ARRAY(int16_t(x), int16_t(y), int16_t(z), int16_t(i), int16_t(j), int16_t(k), int16_t(u), int16_t(v), int16_t(w)); }
|
||||
FI XYZval<int16_t> asInt() const { return NUM_AXIS_ARRAY(int16_t(x), int16_t(y), int16_t(z), int16_t(i), int16_t(j), int16_t(k), int16_t(u), int16_t(v), int16_t(w)); }
|
||||
FI XYZval<int32_t> asLong() { return NUM_AXIS_ARRAY(int32_t(x), int32_t(y), int32_t(z), int32_t(i), int32_t(j), int32_t(k), int32_t(u), int32_t(v), int32_t(w)); }
|
||||
FI XYZval<int32_t> asLong() const { return NUM_AXIS_ARRAY(int32_t(x), int32_t(y), int32_t(z), int32_t(i), int32_t(j), int32_t(k), int32_t(u), int32_t(v), int32_t(w)); }
|
||||
FI XYZval<int32_t> ROUNDL() { return NUM_AXIS_ARRAY(int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)), int32_t(LROUND(i)), int32_t(LROUND(j)), int32_t(LROUND(k)), int32_t(LROUND(u)), int32_t(LROUND(v)), int32_t(LROUND(w))); }
|
||||
FI XYZval<int32_t> ROUNDL() const { return NUM_AXIS_ARRAY(int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)), int32_t(LROUND(i)), int32_t(LROUND(j)), int32_t(LROUND(k)), int32_t(LROUND(u)), int32_t(LROUND(v)), int32_t(LROUND(w))); }
|
||||
FI XYZval<float> asFloat() { return NUM_AXIS_ARRAY(static_cast<float>(x), static_cast<float>(y), static_cast<float>(z), static_cast<float>(i), static_cast<float>(j), static_cast<float>(k), static_cast<float>(u), static_cast<float>(v), static_cast<float>(w)); }
|
||||
FI XYZval<float> asFloat() const { return NUM_AXIS_ARRAY(static_cast<float>(x), static_cast<float>(y), static_cast<float>(z), static_cast<float>(i), static_cast<float>(j), static_cast<float>(k), static_cast<float>(u), static_cast<float>(v), static_cast<float>(w)); }
|
||||
FI XYZval<float> reciprocal() const { return NUM_AXIS_ARRAY(_RECIP(x), _RECIP(y), _RECIP(z), _RECIP(i), _RECIP(j), _RECIP(k), _RECIP(u), _RECIP(v), _RECIP(w)); }
|
||||
|
||||
// Marlin workspace shifting is done with G92 and M206
|
||||
FI XYZval<float> asLogical() const { XYZval<float> o = asFloat(); toLogical(o); return o; }
|
||||
@@ -447,78 +469,78 @@ struct XYZval {
|
||||
FI operator const XYval<T>&() const { return *(const XYval<T>*)this; }
|
||||
|
||||
// Cast to a type with more fields by making a new object
|
||||
FI operator XYZEval<T>() const { return LINEAR_AXIS_ARRAY(x, y, z, i, j, k); }
|
||||
FI operator XYZEval<T>() const { return NUM_AXIS_ARRAY(x, y, z, i, j, k, u, v, w); }
|
||||
|
||||
// Accessor via an AxisEnum (or any integer) [index]
|
||||
FI T& operator[](const int n) { return pos[n]; }
|
||||
FI const T& operator[](const int n) const { return pos[n]; }
|
||||
|
||||
// Assignment operator overrides do the expected thing
|
||||
FI XYZval<T>& operator= (const T v) { set(ARRAY_N_1(LINEAR_AXES, v)); return *this; }
|
||||
FI XYZval<T>& operator= (const T v) { set(ARRAY_N_1(NUM_AXES, v)); return *this; }
|
||||
FI XYZval<T>& operator= (const XYval<T> &rs) { set(rs.x, rs.y ); return *this; }
|
||||
FI XYZval<T>& operator= (const XYZEval<T> &rs) { set(LINEAR_AXIS_ELEM(rs)); return *this; }
|
||||
FI XYZval<T>& operator= (const XYZEval<T> &rs) { set(NUM_AXIS_ELEM(rs)); return *this; }
|
||||
|
||||
// Override other operators to get intuitive behaviors
|
||||
FI XYZval<T> operator+ (const XYval<T> &rs) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, NOOP , NOOP , NOOP , NOOP ); return ls; }
|
||||
FI XYZval<T> operator+ (const XYval<T> &rs) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, NOOP , NOOP , NOOP , NOOP ); return ls; }
|
||||
FI XYZval<T> operator- (const XYval<T> &rs) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, NOOP , NOOP , NOOP , NOOP ); return ls; }
|
||||
FI XYZval<T> operator- (const XYval<T> &rs) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, NOOP , NOOP , NOOP , NOOP ); return ls; }
|
||||
FI XYZval<T> operator* (const XYval<T> &rs) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, NOOP , NOOP , NOOP , NOOP ); return ls; }
|
||||
FI XYZval<T> operator* (const XYval<T> &rs) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, NOOP , NOOP , NOOP , NOOP ); return ls; }
|
||||
FI XYZval<T> operator/ (const XYval<T> &rs) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, NOOP , NOOP , NOOP , NOOP ); return ls; }
|
||||
FI XYZval<T> operator/ (const XYval<T> &rs) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, NOOP , NOOP , NOOP , NOOP ); return ls; }
|
||||
FI XYZval<T> operator+ (const XYZval<T> &rs) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k); return ls; }
|
||||
FI XYZval<T> operator+ (const XYZval<T> &rs) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k); return ls; }
|
||||
FI XYZval<T> operator- (const XYZval<T> &rs) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k); return ls; }
|
||||
FI XYZval<T> operator- (const XYZval<T> &rs) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k); return ls; }
|
||||
FI XYZval<T> operator* (const XYZval<T> &rs) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k); return ls; }
|
||||
FI XYZval<T> operator* (const XYZval<T> &rs) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k); return ls; }
|
||||
FI XYZval<T> operator/ (const XYZval<T> &rs) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k); return ls; }
|
||||
FI XYZval<T> operator/ (const XYZval<T> &rs) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k); return ls; }
|
||||
FI XYZval<T> operator+ (const XYZEval<T> &rs) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k); return ls; }
|
||||
FI XYZval<T> operator+ (const XYZEval<T> &rs) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k); return ls; }
|
||||
FI XYZval<T> operator- (const XYZEval<T> &rs) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k); return ls; }
|
||||
FI XYZval<T> operator- (const XYZEval<T> &rs) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k); return ls; }
|
||||
FI XYZval<T> operator* (const XYZEval<T> &rs) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k); return ls; }
|
||||
FI XYZval<T> operator* (const XYZEval<T> &rs) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k); return ls; }
|
||||
FI XYZval<T> operator/ (const XYZEval<T> &rs) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k); return ls; }
|
||||
FI XYZval<T> operator/ (const XYZEval<T> &rs) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k); return ls; }
|
||||
FI XYZval<T> operator* (const float &v) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v ); return ls; }
|
||||
FI XYZval<T> operator* (const float &v) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v ); return ls; }
|
||||
FI XYZval<T> operator* (const int &v) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v ); return ls; }
|
||||
FI XYZval<T> operator* (const int &v) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v ); return ls; }
|
||||
FI XYZval<T> operator/ (const float &v) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v ); return ls; }
|
||||
FI XYZval<T> operator/ (const float &v) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v ); return ls; }
|
||||
FI XYZval<T> operator/ (const int &v) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v ); return ls; }
|
||||
FI XYZval<T> operator/ (const int &v) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v ); return ls; }
|
||||
FI XYZval<T> operator>>(const int &v) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(_RS(ls.x), _RS(ls.y), _RS(ls.z), _RS(ls.i), _RS(ls.j), _RS(ls.k) ); return ls; }
|
||||
FI XYZval<T> operator>>(const int &v) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(_RS(ls.x), _RS(ls.y), _RS(ls.z), _RS(ls.i), _RS(ls.j), _RS(ls.k) ); return ls; }
|
||||
FI XYZval<T> operator<<(const int &v) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(_LS(ls.x), _LS(ls.y), _LS(ls.z), _LS(ls.i), _LS(ls.j), _LS(ls.k) ); return ls; }
|
||||
FI XYZval<T> operator<<(const int &v) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(_LS(ls.x), _LS(ls.y), _LS(ls.z), _LS(ls.i), _LS(ls.j), _LS(ls.k) ); return ls; }
|
||||
FI const XYZval<T> operator-() const { XYZval<T> o = *this; LINEAR_AXIS_CODE(o.x = -x, o.y = -y, o.z = -z, o.i = -i, o.j = -j, o.k = -k); return o; }
|
||||
FI XYZval<T> operator-() { XYZval<T> o = *this; LINEAR_AXIS_CODE(o.x = -x, o.y = -y, o.z = -z, o.i = -i, o.j = -j, o.k = -k); return o; }
|
||||
FI XYZval<T> operator+ (const XYval<T> &rs) const { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, NOOP , NOOP , NOOP , NOOP , NOOP , NOOP , NOOP ); return ls; }
|
||||
FI XYZval<T> operator+ (const XYval<T> &rs) { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, NOOP , NOOP , NOOP , NOOP , NOOP , NOOP , NOOP ); return ls; }
|
||||
FI XYZval<T> operator- (const XYval<T> &rs) const { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, NOOP , NOOP , NOOP , NOOP , NOOP , NOOP , NOOP ); return ls; }
|
||||
FI XYZval<T> operator- (const XYval<T> &rs) { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, NOOP , NOOP , NOOP , NOOP , NOOP , NOOP , NOOP ); return ls; }
|
||||
FI XYZval<T> operator* (const XYval<T> &rs) const { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, NOOP , NOOP , NOOP , NOOP , NOOP , NOOP , NOOP ); return ls; }
|
||||
FI XYZval<T> operator* (const XYval<T> &rs) { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, NOOP , NOOP , NOOP , NOOP , NOOP , NOOP , NOOP ); return ls; }
|
||||
FI XYZval<T> operator/ (const XYval<T> &rs) const { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, NOOP , NOOP , NOOP , NOOP , NOOP , NOOP , NOOP ); return ls; }
|
||||
FI XYZval<T> operator/ (const XYval<T> &rs) { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, NOOP , NOOP , NOOP , NOOP , NOOP , NOOP , NOOP ); return ls; }
|
||||
FI XYZval<T> operator+ (const XYZval<T> &rs) const { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k, ls.u += rs.u, ls.v += rs.v, ls.w += rs.w); return ls; }
|
||||
FI XYZval<T> operator+ (const XYZval<T> &rs) { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k, ls.u += rs.u, ls.v += rs.v, ls.w += rs.w); return ls; }
|
||||
FI XYZval<T> operator- (const XYZval<T> &rs) const { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k, ls.u -= rs.u, ls.v -= rs.v, ls.w -= rs.w); return ls; }
|
||||
FI XYZval<T> operator- (const XYZval<T> &rs) { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k, ls.u -= rs.u, ls.v -= rs.v, ls.w -= rs.w); return ls; }
|
||||
FI XYZval<T> operator* (const XYZval<T> &rs) const { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k, ls.u *= rs.u, ls.v *= rs.v, ls.w *= rs.w); return ls; }
|
||||
FI XYZval<T> operator* (const XYZval<T> &rs) { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k, ls.u *= rs.u, ls.v *= rs.v, ls.w *= rs.w); return ls; }
|
||||
FI XYZval<T> operator/ (const XYZval<T> &rs) const { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k, ls.u /= rs.u, ls.v /= rs.v, ls.w /= rs.w); return ls; }
|
||||
FI XYZval<T> operator/ (const XYZval<T> &rs) { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k, ls.u /= rs.u, ls.v /= rs.v, ls.w /= rs.w); return ls; }
|
||||
FI XYZval<T> operator+ (const XYZEval<T> &rs) const { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k, ls.u += rs.u, ls.v += rs.v, ls.w += rs.w); return ls; }
|
||||
FI XYZval<T> operator+ (const XYZEval<T> &rs) { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k, ls.u += rs.u, ls.v += rs.v, ls.w += rs.w); return ls; }
|
||||
FI XYZval<T> operator- (const XYZEval<T> &rs) const { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k, ls.u -= rs.u, ls.v -= rs.v, ls.w -= rs.w); return ls; }
|
||||
FI XYZval<T> operator- (const XYZEval<T> &rs) { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k, ls.u -= rs.u, ls.v -= rs.v, ls.w -= rs.w); return ls; }
|
||||
FI XYZval<T> operator* (const XYZEval<T> &rs) const { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k, ls.u *= rs.u, ls.v *= rs.v, ls.w *= rs.w); return ls; }
|
||||
FI XYZval<T> operator* (const XYZEval<T> &rs) { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k, ls.u *= rs.u, ls.v *= rs.v, ls.w *= rs.w); return ls; }
|
||||
FI XYZval<T> operator/ (const XYZEval<T> &rs) const { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k, ls.u /= rs.u, ls.v /= rs.v, ls.w /= rs.w); return ls; }
|
||||
FI XYZval<T> operator/ (const XYZEval<T> &rs) { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k, ls.u /= rs.u, ls.v /= rs.v, ls.w /= rs.w); return ls; }
|
||||
FI XYZval<T> operator* (const float &v) const { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v, ls.u *= v, ls.v *= v, ls.w *= v ); return ls; }
|
||||
FI XYZval<T> operator* (const float &v) { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v, ls.u *= v, ls.v *= v, ls.w *= v ); return ls; }
|
||||
FI XYZval<T> operator* (const int &v) const { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v, ls.u *= v, ls.v *= v, ls.w *= v ); return ls; }
|
||||
FI XYZval<T> operator* (const int &v) { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v, ls.u *= v, ls.v *= v, ls.w *= v ); return ls; }
|
||||
FI XYZval<T> operator/ (const float &v) const { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v, ls.u /= v, ls.v /= v, ls.w /= v ); return ls; }
|
||||
FI XYZval<T> operator/ (const float &v) { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v, ls.u /= v, ls.v /= v, ls.w /= v ); return ls; }
|
||||
FI XYZval<T> operator/ (const int &v) const { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v, ls.u /= v, ls.v /= v, ls.w /= v ); return ls; }
|
||||
FI XYZval<T> operator/ (const int &v) { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v, ls.u /= v, ls.v /= v, ls.w /= v ); return ls; }
|
||||
FI XYZval<T> operator>>(const int &v) const { XYZval<T> ls = *this; NUM_AXIS_CODE(_RS(ls.x), _RS(ls.y), _RS(ls.z), _RS(ls.i), _RS(ls.j), _RS(ls.k), _RS(ls.u), _RS(ls.v), _RS(ls.w) ); return ls; }
|
||||
FI XYZval<T> operator>>(const int &v) { XYZval<T> ls = *this; NUM_AXIS_CODE(_RS(ls.x), _RS(ls.y), _RS(ls.z), _RS(ls.i), _RS(ls.j), _RS(ls.k), _RS(ls.u), _RS(ls.v), _RS(ls.w) ); return ls; }
|
||||
FI XYZval<T> operator<<(const int &v) const { XYZval<T> ls = *this; NUM_AXIS_CODE(_LS(ls.x), _LS(ls.y), _LS(ls.z), _LS(ls.i), _LS(ls.j), _LS(ls.k), _LS(ls.u), _LS(ls.v), _LS(ls.w) ); return ls; }
|
||||
FI XYZval<T> operator<<(const int &v) { XYZval<T> ls = *this; NUM_AXIS_CODE(_LS(ls.x), _LS(ls.y), _LS(ls.z), _LS(ls.i), _LS(ls.j), _LS(ls.k), _LS(ls.u), _LS(ls.v), _LS(ls.w) ); return ls; }
|
||||
FI const XYZval<T> operator-() const { XYZval<T> o = *this; NUM_AXIS_CODE(o.x = -x, o.y = -y, o.z = -z, o.i = -i, o.j = -j, o.k = -k, o.u = -u, o.v = -v, o.w = -w); return o; }
|
||||
FI XYZval<T> operator-() { XYZval<T> o = *this; NUM_AXIS_CODE(o.x = -x, o.y = -y, o.z = -z, o.i = -i, o.j = -j, o.k = -k, o.u = -u, o.v = -v, o.w = -w); return o; }
|
||||
|
||||
// Modifier operators
|
||||
FI XYZval<T>& operator+=(const XYval<T> &rs) { LINEAR_AXIS_CODE(x += rs.x, y += rs.y, NOOP, NOOP, NOOP, NOOP ); return *this; }
|
||||
FI XYZval<T>& operator-=(const XYval<T> &rs) { LINEAR_AXIS_CODE(x -= rs.x, y -= rs.y, NOOP, NOOP, NOOP, NOOP ); return *this; }
|
||||
FI XYZval<T>& operator*=(const XYval<T> &rs) { LINEAR_AXIS_CODE(x *= rs.x, y *= rs.y, NOOP, NOOP, NOOP, NOOP ); return *this; }
|
||||
FI XYZval<T>& operator/=(const XYval<T> &rs) { LINEAR_AXIS_CODE(x /= rs.x, y /= rs.y, NOOP, NOOP, NOOP, NOOP ); return *this; }
|
||||
FI XYZval<T>& operator+=(const XYZval<T> &rs) { LINEAR_AXIS_CODE(x += rs.x, y += rs.y, z += rs.z, i += rs.i, j += rs.j, k += rs.k); return *this; }
|
||||
FI XYZval<T>& operator-=(const XYZval<T> &rs) { LINEAR_AXIS_CODE(x -= rs.x, y -= rs.y, z -= rs.z, i -= rs.i, j -= rs.j, k -= rs.k); return *this; }
|
||||
FI XYZval<T>& operator*=(const XYZval<T> &rs) { LINEAR_AXIS_CODE(x *= rs.x, y *= rs.y, z *= rs.z, i *= rs.i, j *= rs.j, k *= rs.k); return *this; }
|
||||
FI XYZval<T>& operator/=(const XYZval<T> &rs) { LINEAR_AXIS_CODE(x /= rs.x, y /= rs.y, z /= rs.z, i /= rs.i, j /= rs.j, k /= rs.k); return *this; }
|
||||
FI XYZval<T>& operator+=(const XYZEval<T> &rs) { LINEAR_AXIS_CODE(x += rs.x, y += rs.y, z += rs.z, i += rs.i, j += rs.j, k += rs.k); return *this; }
|
||||
FI XYZval<T>& operator-=(const XYZEval<T> &rs) { LINEAR_AXIS_CODE(x -= rs.x, y -= rs.y, z -= rs.z, i -= rs.i, j -= rs.j, k -= rs.k); return *this; }
|
||||
FI XYZval<T>& operator*=(const XYZEval<T> &rs) { LINEAR_AXIS_CODE(x *= rs.x, y *= rs.y, z *= rs.z, i *= rs.i, j *= rs.j, k *= rs.k); return *this; }
|
||||
FI XYZval<T>& operator/=(const XYZEval<T> &rs) { LINEAR_AXIS_CODE(x /= rs.x, y /= rs.y, z /= rs.z, i /= rs.i, j /= rs.j, k /= rs.k); return *this; }
|
||||
FI XYZval<T>& operator*=(const float &v) { LINEAR_AXIS_CODE(x *= v, y *= v, z *= v, i *= v, j *= v, k *= v); return *this; }
|
||||
FI XYZval<T>& operator*=(const int &v) { LINEAR_AXIS_CODE(x *= v, y *= v, z *= v, i *= v, j *= v, k *= v); return *this; }
|
||||
FI XYZval<T>& operator>>=(const int &v) { LINEAR_AXIS_CODE(_RS(x), _RS(y), _RS(z), _RS(i), _RS(j), _RS(k)); return *this; }
|
||||
FI XYZval<T>& operator<<=(const int &v) { LINEAR_AXIS_CODE(_LS(x), _LS(y), _LS(z), _LS(i), _LS(j), _LS(k)); return *this; }
|
||||
FI XYZval<T>& operator+=(const XYval<T> &rs) { NUM_AXIS_CODE(x += rs.x, y += rs.y, NOOP, NOOP, NOOP, NOOP, NOOP, NOOP, NOOP ); return *this; }
|
||||
FI XYZval<T>& operator-=(const XYval<T> &rs) { NUM_AXIS_CODE(x -= rs.x, y -= rs.y, NOOP, NOOP, NOOP, NOOP, NOOP, NOOP, NOOP ); return *this; }
|
||||
FI XYZval<T>& operator*=(const XYval<T> &rs) { NUM_AXIS_CODE(x *= rs.x, y *= rs.y, NOOP, NOOP, NOOP, NOOP, NOOP, NOOP, NOOP ); return *this; }
|
||||
FI XYZval<T>& operator/=(const XYval<T> &rs) { NUM_AXIS_CODE(x /= rs.x, y /= rs.y, NOOP, NOOP, NOOP, NOOP, NOOP, NOOP, NOOP ); return *this; }
|
||||
FI XYZval<T>& operator+=(const XYZval<T> &rs) { NUM_AXIS_CODE(x += rs.x, y += rs.y, z += rs.z, i += rs.i, j += rs.j, k += rs.k, u += rs.u, v += rs.v, w += rs.w); return *this; }
|
||||
FI XYZval<T>& operator-=(const XYZval<T> &rs) { NUM_AXIS_CODE(x -= rs.x, y -= rs.y, z -= rs.z, i -= rs.i, j -= rs.j, k -= rs.k, u -= rs.u, v -= rs.v, w -= rs.w); return *this; }
|
||||
FI XYZval<T>& operator*=(const XYZval<T> &rs) { NUM_AXIS_CODE(x *= rs.x, y *= rs.y, z *= rs.z, i *= rs.i, j *= rs.j, k *= rs.k, u *= rs.u, v *= rs.v, w *= rs.w); return *this; }
|
||||
FI XYZval<T>& operator/=(const XYZval<T> &rs) { NUM_AXIS_CODE(x /= rs.x, y /= rs.y, z /= rs.z, i /= rs.i, j /= rs.j, k /= rs.k, u /= rs.u, v /= rs.v, w /= rs.w); return *this; }
|
||||
FI XYZval<T>& operator+=(const XYZEval<T> &rs) { NUM_AXIS_CODE(x += rs.x, y += rs.y, z += rs.z, i += rs.i, j += rs.j, k += rs.k, u += rs.u, v += rs.v, w += rs.w); return *this; }
|
||||
FI XYZval<T>& operator-=(const XYZEval<T> &rs) { NUM_AXIS_CODE(x -= rs.x, y -= rs.y, z -= rs.z, i -= rs.i, j -= rs.j, k -= rs.k, u -= rs.u, v -= rs.v, w -= rs.w); return *this; }
|
||||
FI XYZval<T>& operator*=(const XYZEval<T> &rs) { NUM_AXIS_CODE(x *= rs.x, y *= rs.y, z *= rs.z, i *= rs.i, j *= rs.j, k *= rs.k, u *= rs.u, v *= rs.v, w *= rs.w); return *this; }
|
||||
FI XYZval<T>& operator/=(const XYZEval<T> &rs) { NUM_AXIS_CODE(x /= rs.x, y /= rs.y, z /= rs.z, i /= rs.i, j /= rs.j, k /= rs.k, u /= rs.u, v /= rs.v, w /= rs.w); return *this; }
|
||||
FI XYZval<T>& operator*=(const float &v) { NUM_AXIS_CODE(x *= v, y *= v, z *= v, i *= v, j *= v, k *= v, u *= v, v *= v, w *= v); return *this; }
|
||||
FI XYZval<T>& operator*=(const int &v) { NUM_AXIS_CODE(x *= v, y *= v, z *= v, i *= v, j *= v, k *= v, u *= v, v *= v, w *= v); return *this; }
|
||||
FI XYZval<T>& operator>>=(const int &v) { NUM_AXIS_CODE(_RS(x), _RS(y), _RS(z), _RS(i), _RS(j), _RS(k), _RS(u), _RS(v), _RS(w)); return *this; }
|
||||
FI XYZval<T>& operator<<=(const int &v) { NUM_AXIS_CODE(_LS(x), _LS(y), _LS(z), _LS(i), _LS(j), _LS(k), _LS(u), _LS(v), _LS(w)); return *this; }
|
||||
|
||||
// Exact comparisons. For floats a "NEAR" operation may be better.
|
||||
FI bool operator==(const XYZEval<T> &rs) { return true LINEAR_AXIS_GANG(&& x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k); }
|
||||
FI bool operator==(const XYZEval<T> &rs) const { return true LINEAR_AXIS_GANG(&& x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k); }
|
||||
FI bool operator==(const XYZEval<T> &rs) { return true NUM_AXIS_GANG(&& x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k, && u == rs.u, && v == rs.v, && w == rs.w); }
|
||||
FI bool operator==(const XYZEval<T> &rs) const { return true NUM_AXIS_GANG(&& x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k, && u == rs.u, && v == rs.v, && w == rs.w); }
|
||||
FI bool operator!=(const XYZEval<T> &rs) { return !operator==(rs); }
|
||||
FI bool operator!=(const XYZEval<T> &rs) const { return !operator==(rs); }
|
||||
};
|
||||
@@ -530,54 +552,66 @@ template<typename T>
|
||||
struct XYZEval {
|
||||
union {
|
||||
struct { T LOGICAL_AXIS_ARGS(); };
|
||||
struct { T LOGICAL_AXIS_LIST(_e, a, b, c, u, v, w); };
|
||||
struct { T LOGICAL_AXIS_LIST(_e, a, b, c, _i, _j, _k, _u, _v, _w); };
|
||||
T pos[LOGICAL_AXES];
|
||||
};
|
||||
// Reset all to 0
|
||||
FI void reset() { LOGICAL_AXIS_GANG(e =, x =, y =, z =, i =, j =, k =) 0; }
|
||||
FI void reset() { LOGICAL_AXIS_GANG(e =, x =, y =, z =, i =, j =, k =, u =, v =, w =) 0; }
|
||||
|
||||
// Setters taking struct types and arrays
|
||||
FI void set(const T px) { x = px; }
|
||||
FI void set(const T px, const T py) { x = px; y = py; }
|
||||
FI void set(const XYval<T> pxy) { x = pxy.x; y = pxy.y; }
|
||||
FI void set(const XYZval<T> pxyz) { set(LINEAR_AXIS_ELEM(pxyz)); }
|
||||
#if HAS_Z_AXIS
|
||||
FI void set(LINEAR_AXIS_ARGS(const T)) { LINEAR_AXIS_CODE(a = x, b = y, c = z, u = i, v = j, w = k); }
|
||||
#endif
|
||||
#if LOGICAL_AXES > LINEAR_AXES
|
||||
FI void set(const XYval<T> pxy, const T pe) { set(pxy); e = pe; }
|
||||
FI void set(const XYZval<T> pxyz, const T pe) { set(pxyz); e = pe; }
|
||||
FI void set(LOGICAL_AXIS_ARGS(const T)) { LOGICAL_AXIS_CODE(_e = e, a = x, b = y, c = z, u = i, v = j, w = k); }
|
||||
#endif
|
||||
// Setters for some number of linear axes, not all
|
||||
FI void set(const T px) { x = px; }
|
||||
FI void set(const T px, const T py) { x = px; y = py; }
|
||||
#if HAS_I_AXIS
|
||||
FI void set(const T px, const T py, const T pz) { x = px; y = py; z = pz; }
|
||||
FI void set(const T px, const T py, const T pz) { x = px; y = py; z = pz; }
|
||||
#endif
|
||||
#if HAS_J_AXIS
|
||||
FI void set(const T px, const T py, const T pz, const T pi) { x = px; y = py; z = pz; i = pi; }
|
||||
FI void set(const T px, const T py, const T pz, const T pi) { x = px; y = py; z = pz; i = pi; }
|
||||
#endif
|
||||
#if HAS_K_AXIS
|
||||
FI void set(const T px, const T py, const T pz, const T pi, const T pj) { x = px; y = py; z = pz; i = pi; j = pj; }
|
||||
FI void set(const T px, const T py, const T pz, const T pi, const T pj) { x = px; y = py; z = pz; i = pi; j = pj; }
|
||||
#endif
|
||||
#if HAS_U_AXIS
|
||||
FI void set(const T px, const T py, const T pz, const T pi, const T pj, const T pk) { x = px; y = py; z = pz; i = pi; j = pj; k = pk; }
|
||||
#endif
|
||||
#if HAS_V_AXIS
|
||||
FI void set(const T px, const T py, const T pz, const T pi, const T pj, const T pk, const T pm) { x = px; y = py; z = pz; i = pi; j = pj; k = pk; u = pu; }
|
||||
#endif
|
||||
#if HAS_W_AXIS
|
||||
FI void set(const T px, const T py, const T pz, const T pi, const T pj, const T pk, const T pm, const T po) { x = px; y = py; z = pz; i = pi; j = pj; k = pk; u = pm; v = pv; }
|
||||
#endif
|
||||
|
||||
// Setters taking struct types and arrays
|
||||
FI void set(const XYval<T> pxy) { x = pxy.x; y = pxy.y; }
|
||||
FI void set(const XYZval<T> pxyz) { set(NUM_AXIS_ELEM(pxyz)); }
|
||||
#if HAS_Z_AXIS
|
||||
FI void set(NUM_AXIS_ARGS(const T)) { NUM_AXIS_CODE(a = x, b = y, c = z, _i = i, _j = j, _k = k, _u = u, _v = v, _w = w); }
|
||||
#endif
|
||||
FI void set(const XYval<T> pxy, const T pz) { set(pxy); TERN_(HAS_Z_AXIS, z = pz); }
|
||||
#if LOGICAL_AXES > NUM_AXES
|
||||
FI void set(const XYval<T> pxy, const T pz, const T pe) { set(pxy, pz); e = pe; }
|
||||
FI void set(const XYZval<T> pxyz, const T pe) { set(pxyz); e = pe; }
|
||||
FI void set(LOGICAL_AXIS_ARGS(const T)) { LOGICAL_AXIS_CODE(_e = e, a = x, b = y, c = z, _i = i, _j = j, _k = k, _u = u, _v = v, _w = w); }
|
||||
#endif
|
||||
|
||||
// Length reduced to one dimension
|
||||
FI T magnitude() const { return (T)sqrtf(LOGICAL_AXIS_GANG(+ e*e, + x*x, + y*y, + z*z, + i*i, + j*j, + k*k)); }
|
||||
FI T magnitude() const { return (T)sqrtf(LOGICAL_AXIS_GANG(+ e*e, + x*x, + y*y, + z*z, + i*i, + j*j, + k*k, + u*u, + v*v, + w*w)); }
|
||||
// Pointer to the data as a simple array
|
||||
FI operator T* () { return pos; }
|
||||
// If any element is true then it's true
|
||||
FI operator bool() { return 0 LOGICAL_AXIS_GANG(|| e, || x, || y, || z, || i, || j, || k); }
|
||||
FI operator bool() { return 0 LOGICAL_AXIS_GANG(|| e, || x, || y, || z, || i, || j, || k, || u, || v, || w); }
|
||||
|
||||
// Explicit copy and copies with conversion
|
||||
FI XYZEval<T> copy() const { XYZEval<T> o = *this; return o; }
|
||||
FI XYZEval<T> ABS() const { return LOGICAL_AXIS_ARRAY(T(_ABS(e)), T(_ABS(x)), T(_ABS(y)), T(_ABS(z)), T(_ABS(i)), T(_ABS(j)), T(_ABS(k))); }
|
||||
FI XYZEval<int16_t> asInt() { return LOGICAL_AXIS_ARRAY(int16_t(e), int16_t(x), int16_t(y), int16_t(z), int16_t(i), int16_t(j), int16_t(k)); }
|
||||
FI XYZEval<int16_t> asInt() const { return LOGICAL_AXIS_ARRAY(int16_t(e), int16_t(x), int16_t(y), int16_t(z), int16_t(i), int16_t(j), int16_t(k)); }
|
||||
FI XYZEval<int32_t> asLong() { return LOGICAL_AXIS_ARRAY(int32_t(e), int32_t(x), int32_t(y), int32_t(z), int32_t(i), int32_t(j), int32_t(k)); }
|
||||
FI XYZEval<int32_t> asLong() const { return LOGICAL_AXIS_ARRAY(int32_t(e), int32_t(x), int32_t(y), int32_t(z), int32_t(i), int32_t(j), int32_t(k)); }
|
||||
FI XYZEval<int32_t> ROUNDL() { return LOGICAL_AXIS_ARRAY(int32_t(LROUND(e)), int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)), int32_t(LROUND(i)), int32_t(LROUND(j)), int32_t(LROUND(k))); }
|
||||
FI XYZEval<int32_t> ROUNDL() const { return LOGICAL_AXIS_ARRAY(int32_t(LROUND(e)), int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)), int32_t(LROUND(i)), int32_t(LROUND(j)), int32_t(LROUND(k))); }
|
||||
FI XYZEval<float> asFloat() { return LOGICAL_AXIS_ARRAY(static_cast<float>(e), static_cast<float>(x), static_cast<float>(y), static_cast<float>(z), static_cast<float>(i), static_cast<float>(j), static_cast<float>(k)); }
|
||||
FI XYZEval<float> asFloat() const { return LOGICAL_AXIS_ARRAY(static_cast<float>(e), static_cast<float>(x), static_cast<float>(y), static_cast<float>(z), static_cast<float>(i), static_cast<float>(j), static_cast<float>(k)); }
|
||||
FI XYZEval<float> reciprocal() const { return LOGICAL_AXIS_ARRAY(_RECIP(e), _RECIP(x), _RECIP(y), _RECIP(z), _RECIP(i), _RECIP(j), _RECIP(k)); }
|
||||
FI XYZEval<T> copy() const { XYZEval<T> v = *this; return v; }
|
||||
FI XYZEval<T> ABS() const { return LOGICAL_AXIS_ARRAY(T(_ABS(e)), T(_ABS(x)), T(_ABS(y)), T(_ABS(z)), T(_ABS(i)), T(_ABS(j)), T(_ABS(k)), T(_ABS(u)), T(_ABS(v)), T(_ABS(w))); }
|
||||
FI XYZEval<int16_t> asInt() { return LOGICAL_AXIS_ARRAY(int16_t(e), int16_t(x), int16_t(y), int16_t(z), int16_t(i), int16_t(j), int16_t(k), int16_t(u), int16_t(v), int16_t(w)); }
|
||||
FI XYZEval<int16_t> asInt() const { return LOGICAL_AXIS_ARRAY(int16_t(e), int16_t(x), int16_t(y), int16_t(z), int16_t(i), int16_t(j), int16_t(k), int16_t(u), int16_t(v), int16_t(w)); }
|
||||
FI XYZEval<int32_t> asLong() { return LOGICAL_AXIS_ARRAY(int32_t(e), int32_t(x), int32_t(y), int32_t(z), int32_t(i), int32_t(j), int32_t(k), int32_t(u), int32_t(v), int32_t(w)); }
|
||||
FI XYZEval<int32_t> asLong() const { return LOGICAL_AXIS_ARRAY(int32_t(e), int32_t(x), int32_t(y), int32_t(z), int32_t(i), int32_t(j), int32_t(k), int32_t(u), int32_t(v), int32_t(w)); }
|
||||
FI XYZEval<int32_t> ROUNDL() { return LOGICAL_AXIS_ARRAY(int32_t(LROUND(e)), int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)), int32_t(LROUND(i)), int32_t(LROUND(j)), int32_t(LROUND(k)), int32_t(LROUND(u)), int32_t(LROUND(v)), int32_t(LROUND(w))); }
|
||||
FI XYZEval<int32_t> ROUNDL() const { return LOGICAL_AXIS_ARRAY(int32_t(LROUND(e)), int32_t(LROUND(x)), int32_t(LROUND(y)), int32_t(LROUND(z)), int32_t(LROUND(i)), int32_t(LROUND(j)), int32_t(LROUND(k)), int32_t(LROUND(u)), int32_t(LROUND(v)), int32_t(LROUND(w))); }
|
||||
FI XYZEval<float> asFloat() { return LOGICAL_AXIS_ARRAY(static_cast<float>(e), static_cast<float>(x), static_cast<float>(y), static_cast<float>(z), static_cast<float>(i), static_cast<float>(j), static_cast<float>(k), static_cast<float>(u), static_cast<float>(v), static_cast<float>(w)); }
|
||||
FI XYZEval<float> asFloat() const { return LOGICAL_AXIS_ARRAY(static_cast<float>(e), static_cast<float>(x), static_cast<float>(y), static_cast<float>(z), static_cast<float>(i), static_cast<float>(j), static_cast<float>(k), static_cast<float>(u), static_cast<float>(v), static_cast<float>(w)); }
|
||||
FI XYZEval<float> reciprocal() const { return LOGICAL_AXIS_ARRAY(_RECIP(e), _RECIP(x), _RECIP(y), _RECIP(z), _RECIP(i), _RECIP(j), _RECIP(k), _RECIP(u), _RECIP(v), _RECIP(w)); }
|
||||
|
||||
// Marlin workspace shifting is done with G92 and M206
|
||||
FI XYZEval<float> asLogical() const { XYZEval<float> o = asFloat(); toLogical(o); return o; }
|
||||
@@ -594,9 +628,9 @@ struct XYZEval {
|
||||
FI const T& operator[](const int n) const { return pos[n]; }
|
||||
|
||||
// Assignment operator overrides do the expected thing
|
||||
FI XYZEval<T>& operator= (const T v) { set(LIST_N_1(LINEAR_AXES, v)); return *this; }
|
||||
FI XYZEval<T>& operator= (const T v) { set(LIST_N_1(NUM_AXES, v)); return *this; }
|
||||
FI XYZEval<T>& operator= (const XYval<T> &rs) { set(rs.x, rs.y); return *this; }
|
||||
FI XYZEval<T>& operator= (const XYZval<T> &rs) { set(LINEAR_AXIS_ELEM(rs)); return *this; }
|
||||
FI XYZEval<T>& operator= (const XYZval<T> &rs) { set(NUM_AXIS_ELEM(rs)); return *this; }
|
||||
|
||||
// Override other operators to get intuitive behaviors
|
||||
FI XYZEval<T> operator+ (const XYval<T> &rs) const { XYZEval<T> ls = *this; ls.x += rs.x; ls.y += rs.y; return ls; }
|
||||
@@ -607,57 +641,57 @@ struct XYZEval {
|
||||
FI XYZEval<T> operator* (const XYval<T> &rs) { XYZEval<T> ls = *this; ls.x *= rs.x; ls.y *= rs.y; return ls; }
|
||||
FI XYZEval<T> operator/ (const XYval<T> &rs) const { XYZEval<T> ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; }
|
||||
FI XYZEval<T> operator/ (const XYval<T> &rs) { XYZEval<T> ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; }
|
||||
FI XYZEval<T> operator+ (const XYZval<T> &rs) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k); return ls; }
|
||||
FI XYZEval<T> operator+ (const XYZval<T> &rs) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k); return ls; }
|
||||
FI XYZEval<T> operator- (const XYZval<T> &rs) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k); return ls; }
|
||||
FI XYZEval<T> operator- (const XYZval<T> &rs) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k); return ls; }
|
||||
FI XYZEval<T> operator* (const XYZval<T> &rs) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k); return ls; }
|
||||
FI XYZEval<T> operator* (const XYZval<T> &rs) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k); return ls; }
|
||||
FI XYZEval<T> operator/ (const XYZval<T> &rs) const { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k); return ls; }
|
||||
FI XYZEval<T> operator/ (const XYZval<T> &rs) { XYZval<T> ls = *this; LINEAR_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k); return ls; }
|
||||
FI XYZEval<T> operator+ (const XYZEval<T> &rs) const { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e += rs.e, ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k); return ls; }
|
||||
FI XYZEval<T> operator+ (const XYZEval<T> &rs) { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e += rs.e, ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k); return ls; }
|
||||
FI XYZEval<T> operator- (const XYZEval<T> &rs) const { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e -= rs.e, ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k); return ls; }
|
||||
FI XYZEval<T> operator- (const XYZEval<T> &rs) { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e -= rs.e, ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k); return ls; }
|
||||
FI XYZEval<T> operator* (const XYZEval<T> &rs) const { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e *= rs.e, ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k); return ls; }
|
||||
FI XYZEval<T> operator* (const XYZEval<T> &rs) { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e *= rs.e, ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k); return ls; }
|
||||
FI XYZEval<T> operator/ (const XYZEval<T> &rs) const { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e /= rs.e, ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k); return ls; }
|
||||
FI XYZEval<T> operator/ (const XYZEval<T> &rs) { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e /= rs.e, ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k); return ls; }
|
||||
FI XYZEval<T> operator* (const float &v) const { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e *= v, ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v ); return ls; }
|
||||
FI XYZEval<T> operator* (const float &v) { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e *= v, ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v ); return ls; }
|
||||
FI XYZEval<T> operator* (const int &v) const { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e *= v, ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v ); return ls; }
|
||||
FI XYZEval<T> operator* (const int &v) { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e *= v, ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v ); return ls; }
|
||||
FI XYZEval<T> operator/ (const float &v) const { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e /= v, ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v ); return ls; }
|
||||
FI XYZEval<T> operator/ (const float &v) { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e /= v, ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v ); return ls; }
|
||||
FI XYZEval<T> operator/ (const int &v) const { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e /= v, ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v ); return ls; }
|
||||
FI XYZEval<T> operator/ (const int &v) { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e /= v, ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v ); return ls; }
|
||||
FI XYZEval<T> operator>>(const int &v) const { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(_RS(ls.e), _RS(ls.x), _RS(ls.y), _RS(ls.z), _RS(ls.i), _RS(ls.j), _RS(ls.k) ); return ls; }
|
||||
FI XYZEval<T> operator>>(const int &v) { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(_RS(ls.e), _RS(ls.x), _RS(ls.y), _RS(ls.z), _RS(ls.i), _RS(ls.j), _RS(ls.k) ); return ls; }
|
||||
FI XYZEval<T> operator<<(const int &v) const { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(_LS(ls.e), _LS(ls.x), _LS(ls.y), _LS(ls.z), _LS(ls.i), _LS(ls.j), _LS(ls.k) ); return ls; }
|
||||
FI XYZEval<T> operator<<(const int &v) { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(_LS(ls.e), _LS(ls.x), _LS(ls.y), _LS(ls.z), _LS(ls.i), _LS(ls.j), _LS(ls.k) ); return ls; }
|
||||
FI const XYZEval<T> operator-() const { return LOGICAL_AXIS_ARRAY(-e, -x, -y, -z, -i, -j, -k); }
|
||||
FI XYZEval<T> operator-() { return LOGICAL_AXIS_ARRAY(-e, -x, -y, -z, -i, -j, -k); }
|
||||
FI XYZEval<T> operator+ (const XYZval<T> &rs) const { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k, ls.u += rs.u, ls.v += rs.v, ls.w += rs.w); return ls; }
|
||||
FI XYZEval<T> operator+ (const XYZval<T> &rs) { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k, ls.u += rs.u, ls.v += rs.v, ls.w += rs.w); return ls; }
|
||||
FI XYZEval<T> operator- (const XYZval<T> &rs) const { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k, ls.u -= rs.u, ls.v -= rs.v, ls.w -= rs.w); return ls; }
|
||||
FI XYZEval<T> operator- (const XYZval<T> &rs) { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k, ls.u -= rs.u, ls.v -= rs.v, ls.w -= rs.w); return ls; }
|
||||
FI XYZEval<T> operator* (const XYZval<T> &rs) const { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k, ls.u *= rs.u, ls.v *= rs.v, ls.w *= rs.w); return ls; }
|
||||
FI XYZEval<T> operator* (const XYZval<T> &rs) { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k, ls.u *= rs.u, ls.v *= rs.v, ls.w *= rs.w); return ls; }
|
||||
FI XYZEval<T> operator/ (const XYZval<T> &rs) const { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k, ls.u /= rs.u, ls.v /= rs.v, ls.w /= rs.w); return ls; }
|
||||
FI XYZEval<T> operator/ (const XYZval<T> &rs) { XYZval<T> ls = *this; NUM_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k, ls.u /= rs.u, ls.v /= rs.v, ls.w /= rs.w); return ls; }
|
||||
FI XYZEval<T> operator+ (const XYZEval<T> &rs) const { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e += rs.e, ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k, ls.u += rs.u, ls.v += rs.v, ls.w += rs.w); return ls; }
|
||||
FI XYZEval<T> operator+ (const XYZEval<T> &rs) { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e += rs.e, ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k, ls.u += rs.u, ls.v += rs.v, ls.w += rs.w); return ls; }
|
||||
FI XYZEval<T> operator- (const XYZEval<T> &rs) const { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e -= rs.e, ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k, ls.u -= rs.u, ls.v -= rs.v, ls.w -= rs.w); return ls; }
|
||||
FI XYZEval<T> operator- (const XYZEval<T> &rs) { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e -= rs.e, ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k, ls.u -= rs.u, ls.v -= rs.v, ls.w -= rs.w); return ls; }
|
||||
FI XYZEval<T> operator* (const XYZEval<T> &rs) const { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e *= rs.e, ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k, ls.u *= rs.u, ls.v *= rs.v, ls.w *= rs.w); return ls; }
|
||||
FI XYZEval<T> operator* (const XYZEval<T> &rs) { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e *= rs.e, ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k, ls.u *= rs.u, ls.v *= rs.v, ls.w *= rs.w); return ls; }
|
||||
FI XYZEval<T> operator/ (const XYZEval<T> &rs) const { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e /= rs.e, ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k, ls.u /= rs.u, ls.v /= rs.v, ls.w /= rs.w); return ls; }
|
||||
FI XYZEval<T> operator/ (const XYZEval<T> &rs) { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e /= rs.e, ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k, ls.u /= rs.u, ls.v /= rs.v, ls.w /= rs.w); return ls; }
|
||||
FI XYZEval<T> operator* (const float &v) const { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e *= v, ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v, ls.u *= v, ls.v *= v, ls.w *= v ); return ls; }
|
||||
FI XYZEval<T> operator* (const float &v) { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e *= v, ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v, ls.u *= v, ls.v *= v, ls.w *= v ); return ls; }
|
||||
FI XYZEval<T> operator* (const int &v) const { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e *= v, ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v, ls.u *= v, ls.v *= v, ls.w *= v ); return ls; }
|
||||
FI XYZEval<T> operator* (const int &v) { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e *= v, ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v, ls.u *= v, ls.v *= v, ls.w *= v ); return ls; }
|
||||
FI XYZEval<T> operator/ (const float &v) const { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e /= v, ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v, ls.u /= v, ls.v /= v, ls.w /= v ); return ls; }
|
||||
FI XYZEval<T> operator/ (const float &v) { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e /= v, ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v, ls.u /= v, ls.v /= v, ls.w /= v ); return ls; }
|
||||
FI XYZEval<T> operator/ (const int &v) const { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e /= v, ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v, ls.u /= v, ls.v /= v, ls.w /= v ); return ls; }
|
||||
FI XYZEval<T> operator/ (const int &v) { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(ls.e /= v, ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v, ls.u /= v, ls.v /= v, ls.w /= v ); return ls; }
|
||||
FI XYZEval<T> operator>>(const int &v) const { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(_RS(ls.e), _RS(ls.x), _RS(ls.y), _RS(ls.z), _RS(ls.i), _RS(ls.j), _RS(ls.k), _RS(ls.u), _RS(ls.v), _RS(ls.w) ); return ls; }
|
||||
FI XYZEval<T> operator>>(const int &v) { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(_RS(ls.e), _RS(ls.x), _RS(ls.y), _RS(ls.z), _RS(ls.i), _RS(ls.j), _RS(ls.k), _RS(ls.u), _RS(ls.v), _RS(ls.w) ); return ls; }
|
||||
FI XYZEval<T> operator<<(const int &v) const { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(_LS(ls.e), _LS(ls.x), _LS(ls.y), _LS(ls.z), _LS(ls.i), _LS(ls.j), _LS(ls.k), _LS(ls.u), _LS(ls.v), _LS(ls.w) ); return ls; }
|
||||
FI XYZEval<T> operator<<(const int &v) { XYZEval<T> ls = *this; LOGICAL_AXIS_CODE(_LS(ls.e), _LS(ls.x), _LS(ls.y), _LS(ls.z), _LS(ls.i), _LS(ls.j), _LS(ls.k), _LS(ls.u), _LS(ls.v), _LS(ls.w) ); return ls; }
|
||||
FI const XYZEval<T> operator-() const { return LOGICAL_AXIS_ARRAY(-e, -x, -y, -z, -i, -j, -k, -u, -v, -w); }
|
||||
FI XYZEval<T> operator-() { return LOGICAL_AXIS_ARRAY(-e, -x, -y, -z, -i, -j, -k, -u, -v, -w); }
|
||||
|
||||
// Modifier operators
|
||||
FI XYZEval<T>& operator+=(const XYval<T> &rs) { x += rs.x; y += rs.y; return *this; }
|
||||
FI XYZEval<T>& operator-=(const XYval<T> &rs) { x -= rs.x; y -= rs.y; return *this; }
|
||||
FI XYZEval<T>& operator*=(const XYval<T> &rs) { x *= rs.x; y *= rs.y; return *this; }
|
||||
FI XYZEval<T>& operator/=(const XYval<T> &rs) { x /= rs.x; y /= rs.y; return *this; }
|
||||
FI XYZEval<T>& operator+=(const XYZval<T> &rs) { LINEAR_AXIS_CODE(x += rs.x, y += rs.y, z += rs.z, i += rs.i, j += rs.j, k += rs.k); return *this; }
|
||||
FI XYZEval<T>& operator-=(const XYZval<T> &rs) { LINEAR_AXIS_CODE(x -= rs.x, y -= rs.y, z -= rs.z, i -= rs.i, j -= rs.j, k -= rs.k); return *this; }
|
||||
FI XYZEval<T>& operator*=(const XYZval<T> &rs) { LINEAR_AXIS_CODE(x *= rs.x, y *= rs.y, z *= rs.z, i *= rs.i, j *= rs.j, k *= rs.k); return *this; }
|
||||
FI XYZEval<T>& operator/=(const XYZval<T> &rs) { LINEAR_AXIS_CODE(x /= rs.x, y /= rs.y, z /= rs.z, i /= rs.i, j /= rs.j, k /= rs.k); return *this; }
|
||||
FI XYZEval<T>& operator+=(const XYZEval<T> &rs) { LOGICAL_AXIS_CODE(e += rs.e, x += rs.x, y += rs.y, z += rs.z, i += rs.i, j += rs.j, k += rs.k); return *this; }
|
||||
FI XYZEval<T>& operator-=(const XYZEval<T> &rs) { LOGICAL_AXIS_CODE(e -= rs.e, x -= rs.x, y -= rs.y, z -= rs.z, i -= rs.i, j -= rs.j, k -= rs.k); return *this; }
|
||||
FI XYZEval<T>& operator*=(const XYZEval<T> &rs) { LOGICAL_AXIS_CODE(e *= rs.e, x *= rs.x, y *= rs.y, z *= rs.z, i *= rs.i, j *= rs.j, k *= rs.k); return *this; }
|
||||
FI XYZEval<T>& operator/=(const XYZEval<T> &rs) { LOGICAL_AXIS_CODE(e /= rs.e, x /= rs.x, y /= rs.y, z /= rs.z, i /= rs.i, j /= rs.j, k /= rs.k); return *this; }
|
||||
FI XYZEval<T>& operator*=(const T &v) { LOGICAL_AXIS_CODE(e *= v, x *= v, y *= v, z *= v, i *= v, j *= v, k *= v); return *this; }
|
||||
FI XYZEval<T>& operator>>=(const int &v) { LOGICAL_AXIS_CODE(_RS(e), _RS(x), _RS(y), _RS(z), _RS(i), _RS(j), _RS(k)); return *this; }
|
||||
FI XYZEval<T>& operator<<=(const int &v) { LOGICAL_AXIS_CODE(_LS(e), _LS(x), _LS(y), _LS(z), _LS(i), _LS(j), _LS(k)); return *this; }
|
||||
FI XYZEval<T>& operator+=(const XYZval<T> &rs) { NUM_AXIS_CODE(x += rs.x, y += rs.y, z += rs.z, i += rs.i, j += rs.j, k += rs.k, u += rs.u, v += rs.v, w += rs.w); return *this; }
|
||||
FI XYZEval<T>& operator-=(const XYZval<T> &rs) { NUM_AXIS_CODE(x -= rs.x, y -= rs.y, z -= rs.z, i -= rs.i, j -= rs.j, k -= rs.k, u -= rs.u, v -= rs.v, w -= rs.w); return *this; }
|
||||
FI XYZEval<T>& operator*=(const XYZval<T> &rs) { NUM_AXIS_CODE(x *= rs.x, y *= rs.y, z *= rs.z, i *= rs.i, j *= rs.j, k *= rs.k, u *= rs.u, v *= rs.v, w *= rs.w); return *this; }
|
||||
FI XYZEval<T>& operator/=(const XYZval<T> &rs) { NUM_AXIS_CODE(x /= rs.x, y /= rs.y, z /= rs.z, i /= rs.i, j /= rs.j, k /= rs.k, u /= rs.u, v /= rs.v, w /= rs.w); return *this; }
|
||||
FI XYZEval<T>& operator+=(const XYZEval<T> &rs) { LOGICAL_AXIS_CODE(e += rs.e, x += rs.x, y += rs.y, z += rs.z, i += rs.i, j += rs.j, k += rs.k, u += rs.u, v += rs.v, w += rs.w); return *this; }
|
||||
FI XYZEval<T>& operator-=(const XYZEval<T> &rs) { LOGICAL_AXIS_CODE(e -= rs.e, x -= rs.x, y -= rs.y, z -= rs.z, i -= rs.i, j -= rs.j, k -= rs.k, u -= rs.u, v -= rs.v, w -= rs.w); return *this; }
|
||||
FI XYZEval<T>& operator*=(const XYZEval<T> &rs) { LOGICAL_AXIS_CODE(e *= rs.e, x *= rs.x, y *= rs.y, z *= rs.z, i *= rs.i, j *= rs.j, k *= rs.k, u *= rs.u, v *= rs.v, w *= rs.w); return *this; }
|
||||
FI XYZEval<T>& operator/=(const XYZEval<T> &rs) { LOGICAL_AXIS_CODE(e /= rs.e, x /= rs.x, y /= rs.y, z /= rs.z, i /= rs.i, j /= rs.j, k /= rs.k, u /= rs.u, v /= rs.v, w /= rs.w); return *this; }
|
||||
FI XYZEval<T>& operator*=(const T &v) { LOGICAL_AXIS_CODE(e *= v, x *= v, y *= v, z *= v, i *= v, j *= v, k *= v, u *= v, v *= v, w *= v); return *this; }
|
||||
FI XYZEval<T>& operator>>=(const int &v) { LOGICAL_AXIS_CODE(_RS(e), _RS(x), _RS(y), _RS(z), _RS(i), _RS(j), _RS(k), _RS(u), _RS(v), _RS(w)); return *this; }
|
||||
FI XYZEval<T>& operator<<=(const int &v) { LOGICAL_AXIS_CODE(_LS(e), _LS(x), _LS(y), _LS(z), _LS(i), _LS(j), _LS(k), _LS(u), _LS(v), _LS(w)); return *this; }
|
||||
|
||||
// Exact comparisons. For floats a "NEAR" operation may be better.
|
||||
FI bool operator==(const XYZval<T> &rs) { return true LINEAR_AXIS_GANG(&& x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k); }
|
||||
FI bool operator==(const XYZval<T> &rs) const { return true LINEAR_AXIS_GANG(&& x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k); }
|
||||
FI bool operator==(const XYZval<T> &rs) { return true NUM_AXIS_GANG(&& x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k, && u == rs.u, && v == rs.v, && w == rs.w); }
|
||||
FI bool operator==(const XYZval<T> &rs) const { return true NUM_AXIS_GANG(&& x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k, && u == rs.u, && v == rs.v, && w == rs.w); }
|
||||
FI bool operator!=(const XYZval<T> &rs) { return !operator==(rs); }
|
||||
FI bool operator!=(const XYZval<T> &rs) const { return !operator==(rs); }
|
||||
};
|
||||
|
||||
@@ -94,9 +94,9 @@ void safe_delay(millis_t ms) {
|
||||
SERIAL_ECHOPGM(" (Aligned With");
|
||||
|
||||
if (probe.offset_xy.y > 0)
|
||||
SERIAL_ECHOF(F(TERN(IS_SCARA, "-Distal", "-Back")));
|
||||
SERIAL_ECHOPGM(TERN(IS_SCARA, "-Distal", "-Back"));
|
||||
else if (probe.offset_xy.y < 0)
|
||||
SERIAL_ECHOF(F(TERN(IS_SCARA, "-Proximal", "-Front")));
|
||||
SERIAL_ECHOPGM(TERN(IS_SCARA, "-Proximal", "-Front"));
|
||||
else if (probe.offset_xy.x != 0)
|
||||
SERIAL_ECHOPGM("-Center");
|
||||
|
||||
@@ -125,11 +125,9 @@ void safe_delay(millis_t ms) {
|
||||
#endif
|
||||
#if ABL_PLANAR
|
||||
SERIAL_ECHOPGM("ABL Adjustment");
|
||||
LOOP_LINEAR_AXES(a) {
|
||||
const float v = planner.get_axis_position_mm(AxisEnum(a)) - current_position[a];
|
||||
LOOP_NUM_AXES(a) {
|
||||
SERIAL_CHAR(' ', AXIS_CHAR(a));
|
||||
if (v > 0) SERIAL_CHAR('+');
|
||||
SERIAL_DECIMAL(v);
|
||||
serial_offset(planner.get_axis_position_mm(AxisEnum(a)) - current_position[a]);
|
||||
}
|
||||
#else
|
||||
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
||||
@@ -137,7 +135,7 @@ void safe_delay(millis_t ms) {
|
||||
const float rz = ubl.get_z_correction(current_position);
|
||||
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||
SERIAL_ECHOPGM("ABL Adjustment Z");
|
||||
const float rz = bilinear_z_offset(current_position);
|
||||
const float rz = bbl.get_z_correction(current_position);
|
||||
#endif
|
||||
SERIAL_ECHO(ftostr43sign(rz, '+'));
|
||||
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
||||
|
||||
@@ -77,10 +77,13 @@ public:
|
||||
// in the range 0-100 while avoiding rounding artifacts
|
||||
constexpr uint8_t ui8_to_percent(const uint8_t i) { return (int(i) * 100 + 127) / 255; }
|
||||
|
||||
const xyze_char_t axis_codes LOGICAL_AXIS_ARRAY('E', 'X', 'Y', 'Z', AXIS4_NAME, AXIS5_NAME, AXIS6_NAME);
|
||||
|
||||
#if LINEAR_AXES <= XYZ
|
||||
// Axis names for G-code parsing, reports, etc.
|
||||
const xyze_char_t axis_codes LOGICAL_AXIS_ARRAY('E', 'X', 'Y', 'Z', AXIS4_NAME, AXIS5_NAME, AXIS6_NAME, AXIS7_NAME, AXIS8_NAME, AXIS9_NAME);
|
||||
#if NUM_AXES <= XYZ
|
||||
#define AXIS_CHAR(A) ((char)('X' + A))
|
||||
#define IAXIS_CHAR AXIS_CHAR
|
||||
#else
|
||||
const xyze_char_t iaxis_codes LOGICAL_AXIS_ARRAY('E', 'X', 'Y', 'Z', 'I', 'J', 'K', 'U', 'V', 'W');
|
||||
#define AXIS_CHAR(A) axis_codes[A]
|
||||
#define IAXIS_CHAR(A) iaxis_codes[A]
|
||||
#endif
|
||||
|
||||
@@ -29,6 +29,9 @@
|
||||
#include "../module/motion.h"
|
||||
#include "../module/planner.h"
|
||||
|
||||
axis_bits_t Backlash::last_direction_bits;
|
||||
xyz_long_t Backlash::residual_error{0};
|
||||
|
||||
#ifdef BACKLASH_DISTANCE_MM
|
||||
#if ENABLED(BACKLASH_GCODE)
|
||||
xyz_float_t Backlash::distance_mm = BACKLASH_DISTANCE_MM;
|
||||
@@ -38,7 +41,7 @@
|
||||
#endif
|
||||
|
||||
#if ENABLED(BACKLASH_GCODE)
|
||||
uint8_t Backlash::correction = (BACKLASH_CORRECTION) * 0xFF;
|
||||
uint8_t Backlash::correction = (BACKLASH_CORRECTION) * all_on;
|
||||
#ifdef BACKLASH_SMOOTHING_MM
|
||||
float Backlash::smoothing_mm = BACKLASH_SMOOTHING_MM;
|
||||
#endif
|
||||
@@ -61,7 +64,6 @@ Backlash backlash;
|
||||
*/
|
||||
|
||||
void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const int32_t &dc, const axis_bits_t dm, block_t * const block) {
|
||||
static axis_bits_t last_direction_bits;
|
||||
axis_bits_t changed_dir = last_direction_bits ^ dm;
|
||||
// Ignore direction change unless steps are taken in that direction
|
||||
#if DISABLED(CORE_BACKLASH) || EITHER(MARKFORGED_XY, MARKFORGED_YX)
|
||||
@@ -83,7 +85,7 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const
|
||||
#endif
|
||||
last_direction_bits ^= changed_dir;
|
||||
|
||||
if (correction == 0) return;
|
||||
if (!correction && !residual_error) return;
|
||||
|
||||
#ifdef BACKLASH_SMOOTHING_MM
|
||||
// The segment proportion is a value greater than 0.0 indicating how much residual_error
|
||||
@@ -91,39 +93,28 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const
|
||||
// smoothing distance. Since the computation of this proportion involves a floating point
|
||||
// division, defer computation until needed.
|
||||
float segment_proportion = 0;
|
||||
|
||||
// Residual error carried forward across multiple segments, so correction can be applied
|
||||
// to segments where there is no direction change.
|
||||
static xyz_long_t residual_error{0};
|
||||
#else
|
||||
// No direction change, no correction.
|
||||
if (!changed_dir) return;
|
||||
// No leftover residual error from segment to segment
|
||||
xyz_long_t residual_error{0};
|
||||
#endif
|
||||
|
||||
const float f_corr = float(correction) / 255.0f;
|
||||
const float f_corr = float(correction) / all_on;
|
||||
|
||||
LOOP_LINEAR_AXES(axis) {
|
||||
LOOP_NUM_AXES(axis) {
|
||||
if (distance_mm[axis]) {
|
||||
const bool reversing = TEST(dm,axis);
|
||||
const bool reverse = TEST(dm, axis);
|
||||
|
||||
// When an axis changes direction, add axis backlash to the residual error
|
||||
if (TEST(changed_dir, axis))
|
||||
residual_error[axis] += (reversing ? -f_corr : f_corr) * distance_mm[axis] * planner.settings.axis_steps_per_mm[axis];
|
||||
residual_error[axis] += (reverse ? -f_corr : f_corr) * distance_mm[axis] * planner.settings.axis_steps_per_mm[axis];
|
||||
|
||||
// Decide how much of the residual error to correct in this segment
|
||||
int32_t error_correction = residual_error[axis];
|
||||
if (reverse != (error_correction < 0))
|
||||
error_correction = 0; // Don't take up any backlash in this segment, as it would subtract steps
|
||||
|
||||
#ifdef BACKLASH_SMOOTHING_MM
|
||||
if (error_correction && smoothing_mm != 0) {
|
||||
// Take up a portion of the residual_error in this segment, but only when
|
||||
// the current segment travels in the same direction as the correction
|
||||
if (reversing == (error_correction < 0)) {
|
||||
if (segment_proportion == 0) segment_proportion = _MIN(1.0f, block->millimeters / smoothing_mm);
|
||||
error_correction = CEIL(segment_proportion * error_correction);
|
||||
}
|
||||
else
|
||||
error_correction = 0; // Don't take up any backlash in this segment, as it would subtract steps
|
||||
// Take up a portion of the residual_error in this segment
|
||||
if (segment_proportion == 0) segment_proportion = _MIN(1.0f, block->millimeters / smoothing_mm);
|
||||
error_correction = CEIL(segment_proportion * error_correction);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -153,6 +144,52 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const
|
||||
}
|
||||
}
|
||||
|
||||
int32_t Backlash::get_applied_steps(const AxisEnum axis) {
|
||||
if (axis >= NUM_AXES) return 0;
|
||||
|
||||
const bool reverse = TEST(last_direction_bits, axis);
|
||||
|
||||
const int32_t residual_error_axis = residual_error[axis];
|
||||
|
||||
// At startup it is assumed the last move was forwards. So the applied
|
||||
// steps will always be a non-positive number.
|
||||
|
||||
if (!reverse) return -residual_error_axis;
|
||||
|
||||
const float f_corr = float(correction) / all_on;
|
||||
const int32_t full_error_axis = -f_corr * distance_mm[axis] * planner.settings.axis_steps_per_mm[axis];
|
||||
return full_error_axis - residual_error_axis;
|
||||
}
|
||||
|
||||
class Backlash::StepAdjuster {
|
||||
xyz_long_t applied_steps;
|
||||
public:
|
||||
StepAdjuster() {
|
||||
LOOP_NUM_AXES(axis) applied_steps[axis] = backlash.get_applied_steps((AxisEnum)axis);
|
||||
}
|
||||
~StepAdjuster() {
|
||||
// after backlash compensation parameter changes, ensure applied step count does not change
|
||||
LOOP_NUM_AXES(axis) residual_error[axis] += backlash.get_applied_steps((AxisEnum)axis) - applied_steps[axis];
|
||||
}
|
||||
};
|
||||
|
||||
void Backlash::set_correction_uint8(const uint8_t v) {
|
||||
StepAdjuster adjuster;
|
||||
correction = v;
|
||||
}
|
||||
|
||||
void Backlash::set_distance_mm(const AxisEnum axis, const float v) {
|
||||
StepAdjuster adjuster;
|
||||
distance_mm[axis] = v;
|
||||
}
|
||||
|
||||
#ifdef BACKLASH_SMOOTHING_MM
|
||||
void Backlash::set_smoothing_mm(const float v) {
|
||||
StepAdjuster adjuster;
|
||||
smoothing_mm = v;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ENABLED(MEASURE_BACKLASH_WHEN_PROBING)
|
||||
|
||||
#include "../module/probe.h"
|
||||
|
||||
@@ -24,21 +24,22 @@
|
||||
#include "../inc/MarlinConfigPre.h"
|
||||
#include "../module/planner.h"
|
||||
|
||||
constexpr uint8_t all_on = 0xFF, all_off = 0x00;
|
||||
|
||||
class Backlash {
|
||||
public:
|
||||
static constexpr uint8_t all_on = 0xFF, all_off = 0x00;
|
||||
|
||||
private:
|
||||
static axis_bits_t last_direction_bits;
|
||||
static xyz_long_t residual_error;
|
||||
|
||||
#if ENABLED(BACKLASH_GCODE)
|
||||
static xyz_float_t distance_mm;
|
||||
static uint8_t correction;
|
||||
static xyz_float_t distance_mm;
|
||||
#ifdef BACKLASH_SMOOTHING_MM
|
||||
static float smoothing_mm;
|
||||
#endif
|
||||
|
||||
static void set_correction(const_float_t v) { correction = _MAX(0, _MIN(1.0, v)) * all_on; }
|
||||
static float get_correction() { return float(ui8_to_percent(correction)) / 100.0f; }
|
||||
#else
|
||||
static constexpr uint8_t correction = (BACKLASH_CORRECTION) * 0xFF;
|
||||
static constexpr uint8_t correction = (BACKLASH_CORRECTION) * all_on;
|
||||
static const xyz_float_t distance_mm;
|
||||
#ifdef BACKLASH_SMOOTHING_MM
|
||||
static constexpr float smoothing_mm = BACKLASH_SMOOTHING_MM;
|
||||
@@ -46,13 +47,13 @@ public:
|
||||
#endif
|
||||
|
||||
#if ENABLED(MEASURE_BACKLASH_WHEN_PROBING)
|
||||
private:
|
||||
static xyz_float_t measured_mm;
|
||||
static xyz_uint8_t measured_count;
|
||||
public:
|
||||
static void measure_with_probe();
|
||||
static xyz_float_t measured_mm;
|
||||
static xyz_uint8_t measured_count;
|
||||
#endif
|
||||
|
||||
class StepAdjuster;
|
||||
|
||||
public:
|
||||
static float get_measurement(const AxisEnum a) {
|
||||
UNUSED(a);
|
||||
// Return the measurement averaged over all readings
|
||||
@@ -71,7 +72,25 @@ public:
|
||||
return has_measurement(X_AXIS) || has_measurement(Y_AXIS) || has_measurement(Z_AXIS);
|
||||
}
|
||||
|
||||
void add_correction_steps(const int32_t &da, const int32_t &db, const int32_t &dc, const axis_bits_t dm, block_t * const block);
|
||||
static void add_correction_steps(const int32_t &da, const int32_t &db, const int32_t &dc, const axis_bits_t dm, block_t * const block);
|
||||
static int32_t get_applied_steps(const AxisEnum axis);
|
||||
|
||||
#if ENABLED(BACKLASH_GCODE)
|
||||
static void set_correction_uint8(const uint8_t v);
|
||||
static uint8_t get_correction_uint8() { return correction; }
|
||||
static void set_correction(const float v) { set_correction_uint8(_MAX(0, _MIN(1.0, v)) * all_on + 0.5f); }
|
||||
static float get_correction() { return float(get_correction_uint8()) / all_on; }
|
||||
static void set_distance_mm(const AxisEnum axis, const float v);
|
||||
static float get_distance_mm(const AxisEnum axis) {return distance_mm[axis];}
|
||||
#ifdef BACKLASH_SMOOTHING_MM
|
||||
static void set_smoothing_mm(const float v);
|
||||
static float get_smoothing_mm() {return smoothing_mm;}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ENABLED(MEASURE_BACKLASH_WHEN_PROBING)
|
||||
static void measure_with_probe();
|
||||
#endif
|
||||
};
|
||||
|
||||
extern Backlash backlash;
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
|
||||
extern xy_pos_t bilinear_grid_spacing, bilinear_start;
|
||||
extern xy_float_t bilinear_grid_factor;
|
||||
extern bed_mesh_t z_values;
|
||||
float bilinear_z_offset(const xy_pos_t &raw);
|
||||
|
||||
void extrapolate_unprobed_bed_level();
|
||||
void print_bilinear_leveling_grid();
|
||||
void refresh_bed_level();
|
||||
#if ENABLED(ABL_BILINEAR_SUBDIVISION)
|
||||
void print_bilinear_leveling_grid_virt();
|
||||
void bed_level_virt_interpolate();
|
||||
#endif
|
||||
|
||||
#if IS_CARTESIAN && DISABLED(SEGMENT_LEVELED_MOVES)
|
||||
void bilinear_line_to_destination(const_feedRate_t scaled_fr_mm_s, uint16_t x_splits=0xFFFF, uint16_t y_splits=0xFFFF);
|
||||
#endif
|
||||
|
||||
#define _GET_MESH_X(I) float(bilinear_start.x + (I) * bilinear_grid_spacing.x)
|
||||
#define _GET_MESH_Y(J) float(bilinear_start.y + (J) * bilinear_grid_spacing.y)
|
||||
#define Z_VALUES_ARR z_values
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user