Merge branch 'vanilla_fb_2.1.x' into FB4S_WIFI
Signed-off-by: Sergey Terentiev <sergey@terentiev.me>
This commit is contained in:
@@ -37,8 +37,8 @@ L64XX_Marlin L64xxManager;
|
||||
#include "../../module/planner.h"
|
||||
#include "../../HAL/shared/Delay.h"
|
||||
|
||||
static const char LINEAR_AXIS_LIST(
|
||||
str_X[] PROGMEM = "X ", str_Y[] PROGMEM = "Y ", str_Z[] PROGMEM = "Z ",
|
||||
static const char NUM_AXIS_LIST(
|
||||
str_X[] PROGMEM = "X ", str_Y[] PROGMEM = "Y ", str_Z[] PROGMEM = "Z ",
|
||||
str_I[] PROGMEM = STR_I " ", str_J[] PROGMEM = STR_J " ", str_K[] PROGMEM = STR_K " "
|
||||
),
|
||||
str_X2[] PROGMEM = "X2", str_Y2[] PROGMEM = "Y2",
|
||||
@@ -53,7 +53,7 @@ static const char LINEAR_AXIS_LIST(
|
||||
|
||||
#define _EN_ITEM(N) , str_E##N
|
||||
PGM_P const L64XX_Marlin::index_to_axis[] PROGMEM = {
|
||||
LINEAR_AXIS_LIST(str_X, str_Y, str_Z, str_I, str_J, str_K),
|
||||
NUM_AXIS_LIST(str_X, str_Y, str_Z, str_I, str_J, str_K),
|
||||
str_X2, str_Y2, str_Z2, str_Z3, str_Z4
|
||||
REPEAT(E_STEPPERS, _EN_ITEM)
|
||||
};
|
||||
@@ -66,14 +66,14 @@ void echo_yes_no(const bool yes) { DEBUG_ECHOPGM_P(yes ? PSTR(" YES") : PSTR(" N
|
||||
|
||||
uint8_t L64XX_Marlin::dir_commands[MAX_L64XX]; // array to hold direction command for each driver
|
||||
|
||||
#define _EN_ITEM(N) , INVERT_E##N##_DIR
|
||||
#define _EN_ITEM(N) , ENABLED(INVERT_E##N##_DIR)
|
||||
const uint8_t L64XX_Marlin::index_to_dir[MAX_L64XX] = {
|
||||
LINEAR_AXIS_LIST(INVERT_X_DIR, INVERT_Y_DIR, INVERT_Z_DIR, INVERT_I_DIR, INVERT_J_DIR, INVERT_K_DIR)
|
||||
, (INVERT_X_DIR) ^ BOTH(X_DUAL_STEPPER_DRIVERS, INVERT_X2_VS_X_DIR) // X2
|
||||
, (INVERT_Y_DIR) ^ BOTH(Y_DUAL_STEPPER_DRIVERS, INVERT_Y2_VS_Y_DIR) // Y2
|
||||
, (INVERT_Z_DIR) ^ ENABLED(INVERT_Z2_VS_Z_DIR) // Z2
|
||||
, (INVERT_Z_DIR) ^ ENABLED(INVERT_Z3_VS_Z_DIR) // Z3
|
||||
, (INVERT_Z_DIR) ^ ENABLED(INVERT_Z4_VS_Z_DIR) // Z4
|
||||
NUM_AXIS_LIST(ENABLED(INVERT_X_DIR), ENABLED(INVERT_Y_DIR), ENABLED(INVERT_Z_DIR), ENABLED(INVERT_I_DIR), ENABLED(INVERT_J_DIR), ENABLED(INVERT_K_DIR), ENABLED(INVERT_U_DIR), ENABLED(INVERT_V_DIR), ENABLED(INVERT_W_DIR))
|
||||
, ENABLED(INVERT_X_DIR) ^ BOTH(HAS_DUAL_X_STEPPERS, INVERT_X2_VS_X_DIR) // X2
|
||||
, ENABLED(INVERT_Y_DIR) ^ BOTH(HAS_DUAL_Y_STEPPERS, INVERT_Y2_VS_Y_DIR) // Y2
|
||||
, ENABLED(INVERT_Z_DIR) ^ ENABLED(INVERT_Z2_VS_Z_DIR) // Z2
|
||||
, ENABLED(INVERT_Z_DIR) ^ ENABLED(INVERT_Z3_VS_Z_DIR) // Z3
|
||||
, ENABLED(INVERT_Z_DIR) ^ ENABLED(INVERT_Z4_VS_Z_DIR) // Z4
|
||||
REPEAT(E_STEPPERS, _EN_ITEM)
|
||||
};
|
||||
#undef _EN_ITEM
|
||||
@@ -412,11 +412,11 @@ uint8_t L64XX_Marlin::get_user_input(uint8_t &driver_count, L64XX_axis_t axis_in
|
||||
}
|
||||
|
||||
uint8_t found_displacement = false;
|
||||
LOOP_LOGICAL_AXES(i) if (uint16_t _displacement = parser.intval(axis_codes[i])) {
|
||||
LOOP_LOGICAL_AXES(i) if (uint16_t _displacement = parser.intval(AXIS_CHAR(i))) {
|
||||
found_displacement = true;
|
||||
displacement = _displacement;
|
||||
uint8_t axis_offset = parser.byteval('J');
|
||||
axis_mon[0][0] = axis_codes[i]; // Axis first character, one of XYZE
|
||||
const uint8_t axis_offset = parser.byteval('J');
|
||||
axis_mon[0][0] = AXIS_CHAR(i); // Axis first character, one of XYZ...E
|
||||
const bool single_or_e = axis_offset >= 2 || axis_mon[0][0] == 'E',
|
||||
one_or_more = !single_or_e && axis_offset == 0;
|
||||
uint8_t driver_count_local = 0; // Can't use "driver_count" directly as a subscript because it's passed by reference
|
||||
@@ -667,7 +667,7 @@ uint8_t L64XX_Marlin::get_user_input(uint8_t &driver_count, L64XX_axis_t axis_in
|
||||
static constexpr float default_max_feedrate[] = DEFAULT_MAX_FEEDRATE;
|
||||
const uint8_t num_feedrates = COUNT(default_max_feedrate);
|
||||
for (j = 0; j < num_feedrates; j++) {
|
||||
if (axis_codes[j] == axis_mon[0][0]) {
|
||||
if (AXIS_CHAR(j) == axis_mon[0][0]) {
|
||||
final_feedrate = default_max_feedrate[j];
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#define HAS_L64XX_EXTRUDER (AXIS_IS_L64XX(E0) || AXIS_IS_L64XX(E1) || AXIS_IS_L64XX(E2) || AXIS_IS_L64XX(E3) || AXIS_IS_L64XX(E4) || AXIS_IS_L64XX(E5) || AXIS_IS_L64XX(E6) || AXIS_IS_L64XX(E7))
|
||||
|
||||
#define _EN_ITEM(N) , E##N
|
||||
enum L64XX_axis_t : uint8_t { LINEAR_AXIS_LIST(X, Y, Z, I, J, K), X2, Y2, Z2, Z3, Z4 REPEAT(E_STEPPERS, _EN_ITEM), MAX_L64XX };
|
||||
enum L64XX_axis_t : uint8_t { MAIN_AXIS_NAMES, X2, Y2, Z2, Z3, Z4 REPEAT(E_STEPPERS, _EN_ITEM), MAX_L64XX };
|
||||
#undef _EN_ITEM
|
||||
|
||||
class L64XX_Marlin : public L64XXHelper {
|
||||
|
||||
@@ -133,13 +133,13 @@ SPISettings MAX31865::spiConfig = SPISettings(
|
||||
/**
|
||||
* Initialize the SPI interface and set the number of RTD wires used
|
||||
*
|
||||
* @param wires The number of wires in enum format. Can be MAX31865_2WIRE, MAX31865_3WIRE, or MAX31865_4WIRE.
|
||||
* @param zero The resistance of the RTD at 0 degC, in ohms.
|
||||
* @param ref The resistance of the reference resistor, in ohms.
|
||||
* @param wire The resistance of the wire connecting the sensor to the RTD, in ohms.
|
||||
* @param wires The number of wires as an enum: MAX31865_2WIRE, MAX31865_3WIRE, or MAX31865_4WIRE.
|
||||
* @param zero_res The resistance of the RTD at 0°C, in ohms.
|
||||
* @param ref_res The resistance of the reference resistor, in ohms.
|
||||
* @param wire_res The resistance of the wire connecting the sensor to the RTD, in ohms.
|
||||
*/
|
||||
void MAX31865::begin(max31865_numwires_t wires, float zero_res, float ref_res, float wire_res) {
|
||||
zeroRes = zero_res;
|
||||
void MAX31865::begin(max31865_numwires_t wires, const_float_t zero_res, const_float_t ref_res, const_float_t wire_res) {
|
||||
resNormalizer = 100.0f / zero_res; // reciprocal of resistance, scaled by 100
|
||||
refRes = ref_res;
|
||||
wireRes = wire_res;
|
||||
|
||||
@@ -437,42 +437,61 @@ float MAX31865::temperature() {
|
||||
*
|
||||
* @return Temperature in C
|
||||
*/
|
||||
float MAX31865::temperature(uint16_t adc_val) {
|
||||
float MAX31865::temperature(const uint16_t adc_val) {
|
||||
return temperature(((adc_val) * RECIPROCAL(32768.0f)) * refRes - wireRes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the temperature in C from the RTD resistance.
|
||||
* Uses the technique outlined in this PDF:
|
||||
* http://www.analog.com/media/en/technical-documentation/application-notes/AN709_0.pdf
|
||||
*
|
||||
* @param rtd_res the resistance value in ohms
|
||||
* @return the temperature in degC
|
||||
* @return the temperature in °C
|
||||
*/
|
||||
float MAX31865::temperature(float rtd_res) {
|
||||
|
||||
rtd_res *= resNormalizer; // normalize to 100 ohm
|
||||
|
||||
// Constants for calculating temperature from the measured RTD resistance.
|
||||
// http://www.analog.com/media/en/technical-documentation/application-notes/AN709_0.pdf
|
||||
constexpr float RTD_Z1 = -0.0039083,
|
||||
RTD_Z2 = +1.758480889e-5,
|
||||
RTD_Z3 = -2.31e-8,
|
||||
RTD_Z4 = -1.155e-6;
|
||||
|
||||
// Callender-Van Dusen equation
|
||||
float temp = (RTD_Z1 + sqrt(RTD_Z2 + (RTD_Z3 * rtd_res))) * RECIPROCAL(RTD_Z4);
|
||||
|
||||
// From the PDF...
|
||||
//
|
||||
// The previous equation is valid only for temperatures of 0°C and above.
|
||||
// The equation for RRTD(t) that defines negative temperature behavior is a
|
||||
// fourth-order polynomial (after expanding the third term) and is quite
|
||||
// impractical to solve for a single expression of temperature as a function
|
||||
// of resistance.
|
||||
// of resistance. So here we use a Linear Approximation instead.
|
||||
//
|
||||
if (temp < 0) {
|
||||
rtd_res = (rtd_res / zeroRes) * 100; // normalize to 100 ohm
|
||||
float rpoly = rtd_res;
|
||||
#ifndef MAX31865_APPROX
|
||||
#define MAX31865_APPROX 5
|
||||
#endif
|
||||
|
||||
temp = -242.02 + (2.2228 * rpoly);
|
||||
rpoly *= rtd_res; // square
|
||||
temp += 2.5859e-3 * rpoly;
|
||||
rpoly *= rtd_res; // ^3
|
||||
temp -= 4.8260e-6 * rpoly;
|
||||
rpoly *= rtd_res; // ^4
|
||||
temp -= 2.8183e-8 * rpoly;
|
||||
rpoly *= rtd_res; // ^5
|
||||
temp += 1.5243e-10 * rpoly;
|
||||
constexpr float RTD_C[] = {
|
||||
#if MAX31865_APPROX == 5
|
||||
-242.02, +2.2228, +2.5859e-3, -4.8260e-6, -2.8183e-8, +1.5243e-10
|
||||
#elif MAX31865_APPROX == 4
|
||||
-241.96, +2.2163, +2.8541e-3, -9.9121e-6, -1.7152e-8
|
||||
#elif MAX31865_APPROX == 3
|
||||
-242.09, +2.2276, +2.5178e-3, -5.8620e-6
|
||||
#else
|
||||
-242.97, +2.2838, +1.4727e-3
|
||||
#endif
|
||||
};
|
||||
|
||||
float rpoly = rtd_res;
|
||||
temp = RTD_C[0];
|
||||
temp += rpoly * RTD_C[1];
|
||||
rpoly *= rtd_res; temp += rpoly * RTD_C[2];
|
||||
if (MAX31865_APPROX >= 3) rpoly *= rtd_res; temp += rpoly * RTD_C[3];
|
||||
if (MAX31865_APPROX >= 4) rpoly *= rtd_res; temp += rpoly * RTD_C[4];
|
||||
if (MAX31865_APPROX >= 5) rpoly *= rtd_res; temp += rpoly * RTD_C[5];
|
||||
}
|
||||
|
||||
return temp;
|
||||
|
||||
@@ -73,13 +73,6 @@
|
||||
#define MAX31865_FAULT_RTDINLOW 0x08 // D3
|
||||
#define MAX31865_FAULT_OVUV 0x04 // D2
|
||||
|
||||
// http://www.analog.com/media/en/technical-documentation/application-notes/AN709_0.pdf
|
||||
// constants for calculating temperature from the measured RTD resistance.
|
||||
#define RTD_Z1 -0.0039083
|
||||
#define RTD_Z2 0.00001758480889
|
||||
#define RTD_Z3 -0.0000000231
|
||||
#define RTD_Z4 -0.000001155
|
||||
|
||||
typedef enum max31865_numwires {
|
||||
MAX31865_2WIRE = 0,
|
||||
MAX31865_3WIRE = 1,
|
||||
@@ -103,7 +96,7 @@ private:
|
||||
|
||||
uint16_t spiDelay;
|
||||
|
||||
float zeroRes, refRes, wireRes;
|
||||
float resNormalizer, refRes, wireRes;
|
||||
|
||||
#if ENABLED(MAX31865_USE_READ_ERROR_DETECTION)
|
||||
millis_t lastReadStamp = 0;
|
||||
@@ -160,7 +153,7 @@ public:
|
||||
int8_t spi_clk);
|
||||
#endif
|
||||
|
||||
void begin(max31865_numwires_t wires, float zero_res, float ref_res, float wire_res);
|
||||
void begin(max31865_numwires_t wires, const_float_t zero_res, const_float_t ref_res, const_float_t wire_res);
|
||||
|
||||
uint8_t readFault();
|
||||
void clearFault();
|
||||
@@ -168,6 +161,6 @@ public:
|
||||
uint16_t readRaw();
|
||||
float readResistance();
|
||||
float temperature();
|
||||
float temperature(uint16_t adc_val);
|
||||
float temperature(const uint16_t adc_val);
|
||||
float temperature(float rtd_res);
|
||||
};
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#include "../inc/MarlinConfig.h"
|
||||
|
||||
#if USE_BEEPER
|
||||
#if HAS_BEEPER
|
||||
|
||||
#include "buzzer.h"
|
||||
#include "../module/temperature.h"
|
||||
@@ -45,7 +45,7 @@ Buzzer buzzer;
|
||||
* @param frequency Frequency of the tone in hertz
|
||||
*/
|
||||
void Buzzer::tone(const uint16_t duration, const uint16_t frequency/*=0*/) {
|
||||
if (!ui.buzzer_enabled) return;
|
||||
if (!ui.sound_on) return;
|
||||
while (buffer.isFull()) {
|
||||
tick();
|
||||
thermalManager.manage_heater();
|
||||
@@ -55,7 +55,7 @@ void Buzzer::tone(const uint16_t duration, const uint16_t frequency/*=0*/) {
|
||||
}
|
||||
|
||||
void Buzzer::tick() {
|
||||
if (!ui.buzzer_enabled) return;
|
||||
if (!ui.sound_on) return;
|
||||
const millis_t now = millis();
|
||||
|
||||
if (!state.endtime) {
|
||||
@@ -81,4 +81,4 @@ void Buzzer::tick() {
|
||||
else if (ELAPSED(now, state.endtime)) reset();
|
||||
}
|
||||
|
||||
#endif // USE_BEEPER
|
||||
#endif // HAS_BEEPER
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
#include "../inc/MarlinConfig.h"
|
||||
|
||||
#if USE_BEEPER
|
||||
#if HAS_BEEPER
|
||||
|
||||
#include "circularqueue.h"
|
||||
|
||||
@@ -61,18 +61,6 @@
|
||||
*/
|
||||
FORCE_INLINE static void invert() { TOGGLE(BEEPER_PIN); }
|
||||
|
||||
/**
|
||||
* @brief Turn off a digital PIN
|
||||
* @details Alias of digitalWrite(PIN, LOW) using FastIO
|
||||
*/
|
||||
FORCE_INLINE static void off() { WRITE(BEEPER_PIN, LOW); }
|
||||
|
||||
/**
|
||||
* @brief Turn on a digital PIN
|
||||
* @details Alias of digitalWrite(PIN, HIGH) using FastIO
|
||||
*/
|
||||
FORCE_INLINE static void on() { WRITE(BEEPER_PIN, HIGH); }
|
||||
|
||||
/**
|
||||
* @brief Resets the state of the class
|
||||
* @details Brings the class state to a known one.
|
||||
@@ -91,6 +79,20 @@
|
||||
reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Turn on a digital PIN
|
||||
* @details Alias of digitalWrite(PIN, HIGH) using FastIO
|
||||
*/
|
||||
FORCE_INLINE static void on() { WRITE(BEEPER_PIN, HIGH); }
|
||||
|
||||
/**
|
||||
* @brief Turn off a digital PIN
|
||||
* @details Alias of digitalWrite(PIN, LOW) using FastIO
|
||||
*/
|
||||
FORCE_INLINE static void off() { WRITE(BEEPER_PIN, LOW); }
|
||||
|
||||
static void click(const uint16_t duration) { on(); delay(duration); off(); }
|
||||
|
||||
/**
|
||||
* @brief Add a tone to the queue
|
||||
* @details Adds a tone_t structure to the ring buffer, will block IO if the
|
||||
@@ -118,8 +120,8 @@
|
||||
#elif HAS_BUZZER
|
||||
|
||||
// Buzz indirectly via the MarlinUI instance
|
||||
#include "../lcd/marlinui.h"
|
||||
#define BUZZ(d,f) ui.buzz(d,f)
|
||||
#include "../lcd/marlinui.h"
|
||||
|
||||
#else
|
||||
|
||||
|
||||
Reference in New Issue
Block a user