mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2026-01-18 05:45:33 -07:00
should work
This commit is contained in:
parent
07ea825525
commit
f47b7a7fc3
4 changed files with 81 additions and 4 deletions
|
|
@ -244,8 +244,11 @@ uint32_t Stepper::advance_divisor = 0,
|
|||
* Standard Motion Linear Advance state
|
||||
*/
|
||||
#if ENABLED(LIN_ADVANCE)
|
||||
hal_timer_t Stepper::nextAdvanceISR = LA_ADV_NEVER,
|
||||
Stepper::la_interval = LA_ADV_NEVER;
|
||||
hal_timer_t Stepper::nextAdvanceISR = LA_ADV_NEVER,
|
||||
Stepper::la_interval = LA_ADV_NEVER;
|
||||
#if ENABLED(SPEED_DIAL_FEATURE)
|
||||
Stepper::la_interval_nom = LA_ADV_NEVER;
|
||||
#endif
|
||||
#if ENABLED(SMOOTH_LIN_ADVANCE)
|
||||
uint32_t Stepper::curr_step_rate,
|
||||
Stepper::curr_timer_tick = 0;
|
||||
|
|
@ -2480,6 +2483,9 @@ void Stepper::isr() {
|
|||
if (la_active) {
|
||||
const uint32_t la_step_rate = la_advance_steps < current_block->max_adv_steps ? current_block->la_advance_rate : 0;
|
||||
la_interval = calc_timer_interval((acc_step_rate + la_step_rate) >> current_block->la_scaling);
|
||||
#if ENABLED(SPEED_DIAL_FEATURE)
|
||||
speed_dial_adjust_interval(la_interval);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -2538,6 +2544,10 @@ void Stepper::isr() {
|
|||
interval = calc_multistep_timer_interval(step_rate << oversampling_factor);
|
||||
deceleration_time += interval;
|
||||
|
||||
#if ENABLED(SPEED_DIAL_FEATURE)
|
||||
speed_dial_adjust_interval(interval);
|
||||
#endif
|
||||
|
||||
// Apply Nonlinear Extrusion, if enabled
|
||||
calc_nonlinear_e(step_rate << oversampling_factor);
|
||||
|
||||
|
|
@ -2547,6 +2557,9 @@ void Stepper::isr() {
|
|||
if (la_step_rate != step_rate) {
|
||||
const bool forward_e = la_step_rate < step_rate;
|
||||
la_interval = calc_timer_interval((forward_e ? step_rate - la_step_rate : la_step_rate - step_rate) >> current_block->la_scaling);
|
||||
#if ENABLED(SPEED_DIAL_FEATURE)
|
||||
speed_dial_adjust_interval(la_interval);
|
||||
#endif
|
||||
|
||||
if (forward_e != motor_direction(E_AXIS)) {
|
||||
last_direction_bits.toggle(E_AXIS);
|
||||
|
|
@ -2597,8 +2610,13 @@ void Stepper::isr() {
|
|||
calc_nonlinear_e(current_block->nominal_rate << oversampling_factor);
|
||||
|
||||
#if HAS_ROUGH_LIN_ADVANCE
|
||||
if (la_active)
|
||||
la_interval = calc_timer_interval(current_block->nominal_rate >> current_block->la_scaling);
|
||||
if (la_active) {
|
||||
#if ENABLED(SPEED_DIAL_FEATURE)
|
||||
la_interval_nom = calc_timer_interval(current_block->nominal_rate >> current_block->la_scaling);
|
||||
#else
|
||||
la_interval = calc_timer_interval(current_block->nominal_rate >> current_block->la_scaling);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
// Adjust Laser Power - Cruise
|
||||
|
|
@ -2618,6 +2636,15 @@ void Stepper::isr() {
|
|||
|
||||
// The timer interval is just the nominal value for the nominal speed
|
||||
interval = ticks_nominal;
|
||||
|
||||
#if ENABLED(SPEED_DIAL_FEATURE)
|
||||
speed_dial_adjust_interval(interval);
|
||||
|
||||
#if HAS_ROUGH_LIN_ADVANCE
|
||||
la_interval = la_interval_nom;
|
||||
speed_dial_adjust_interval(la_interval);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2929,6 +2956,10 @@ void Stepper::isr() {
|
|||
// Initialize ac/deceleration time as if half the time passed.
|
||||
acceleration_time = deceleration_time = interval / 2;
|
||||
|
||||
#if ENABLED(SPEED_DIAL_FEATURE)
|
||||
speed_dial_adjust_interval(interval);
|
||||
#endif
|
||||
|
||||
// Apply Nonlinear Extrusion, if enabled
|
||||
calc_nonlinear_e(current_block->initial_rate << oversampling_factor);
|
||||
|
||||
|
|
@ -2939,6 +2970,9 @@ void Stepper::isr() {
|
|||
if (la_active) {
|
||||
const uint32_t la_step_rate = la_advance_steps < current_block->max_adv_steps ? current_block->la_advance_rate : 0;
|
||||
la_interval = calc_timer_interval((current_block->initial_rate + la_step_rate) >> current_block->la_scaling);
|
||||
#if ENABLED(SPEED_DIAL_FEATURE)
|
||||
speed_dial_adjust_interval(la_interval);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -3872,3 +3906,13 @@ void Stepper::report_positions() {
|
|||
}
|
||||
|
||||
#endif // BABYSTEPPING
|
||||
|
||||
#if ENABLED(SPEED_DIAL_FEATURE)
|
||||
|
||||
void Stepper::speed_dial_adjust_interval(uint32_t& interval) {
|
||||
interval *= 100;
|
||||
interval /= speed_dial_value;
|
||||
if (interval == 0) interval = 1;
|
||||
}
|
||||
|
||||
#endif // SPEED_DIAL_FEATURE
|
||||
|
|
|
|||
|
|
@ -371,6 +371,11 @@ class Stepper {
|
|||
static bool frozen; // Set this flag to instantly freeze motion
|
||||
#endif
|
||||
|
||||
#if ENABLED(SPEED_DIAL_FEATURE)
|
||||
static inline void set_speed_dial(uint8_t speed) { speed_dial_value = speed > 0 ? speed : 1; }
|
||||
static inline uint8_t current_speed_dial() { return speed_dial_value; }
|
||||
#endif
|
||||
|
||||
#if ENABLED(NONLINEAR_EXTRUSION)
|
||||
static nonlinear_t ne;
|
||||
#endif
|
||||
|
|
@ -487,6 +492,9 @@ class Stepper {
|
|||
static constexpr hal_timer_t LA_ADV_NEVER = HAL_TIMER_TYPE_MAX;
|
||||
static hal_timer_t nextAdvanceISR,
|
||||
la_interval; // Interval between ISR calls for LA
|
||||
#if ENABLED(SPEED_DIAL_FEATURE)
|
||||
static hal_timer_t la_interval_nom;
|
||||
#endif
|
||||
#if ENABLED(SMOOTH_LIN_ADVANCE)
|
||||
static uint32_t curr_timer_tick, // Current tick relative to block start
|
||||
curr_step_rate; // Current motion step rate
|
||||
|
|
@ -800,6 +808,11 @@ class Stepper {
|
|||
static void ftMotion_stepper();
|
||||
#endif
|
||||
|
||||
#if ENABLED(SPEED_DIAL_FEATURE)
|
||||
static void speed_dial_adjust_interval(uint32_t& step_rate);
|
||||
static uint8_t speed_dial_value;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
extern Stepper stepper;
|
||||
|
|
|
|||
|
|
@ -37,6 +37,10 @@
|
|||
#include "planner.h"
|
||||
#include "printcounter.h"
|
||||
|
||||
#if ENABLED(SPEED_DIAL_FEATURE)
|
||||
#include "../feature/speed_dial.h"
|
||||
#endif
|
||||
|
||||
#if ANY(HAS_COOLER, LASER_COOLANT_FLOW_METER)
|
||||
#include "../feature/cooler.h"
|
||||
#include "../feature/spindle_laser.h"
|
||||
|
|
@ -3145,6 +3149,8 @@ void Temperature::init() {
|
|||
|
||||
TERF(HAS_JOY_ADC_EN, SET_INPUT_PULLUP)(JOY_EN_PIN);
|
||||
|
||||
TERN_(SPEED_DIAL_FEATURE, hal.adc_enable(SPEED_DIAL_PIN));
|
||||
|
||||
HAL_timer_start(MF_TIMER_TEMP, TEMP_TIMER_FREQUENCY);
|
||||
ENABLE_TEMPERATURE_INTERRUPT();
|
||||
|
||||
|
|
@ -4399,6 +4405,14 @@ void Temperature::isr() {
|
|||
break;
|
||||
#endif // HAS_ADC_BUTTONS
|
||||
|
||||
#if ENABLED(SPEED_DIAL_FEATURE)
|
||||
case Prepare_Speed_Dial: hal.adc_start(SPEED_DIAL_PIN); break;
|
||||
case Measure_Speed_Dial:
|
||||
if (!hal.adc_ready()) next_sensor_state = adc_sensor_state;
|
||||
else speedDial.set(hal.adc_value());
|
||||
break;
|
||||
#endif
|
||||
|
||||
case StartupDelay: break;
|
||||
|
||||
} // switch(adc_sensor_state)
|
||||
|
|
@ -4530,6 +4544,9 @@ void Temperature::isr() {
|
|||
#if HAS_MULTI_HOTEND
|
||||
HOTEND_LOOP() s.append(F(" @"), e, ':', getHeaterPower((heater_id_t)e));
|
||||
#endif
|
||||
#if ENABLED(SPEED_DIAL_FEATURE)
|
||||
s.append(F(" S@:"), speedDial.current());
|
||||
# endif
|
||||
s.echo();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -135,6 +135,9 @@ enum ADCSensorState : char {
|
|||
#if HAS_ADC_BUTTONS
|
||||
Prepare_ADC_KEY, Measure_ADC_KEY,
|
||||
#endif
|
||||
#if ENABLED(SPEED_DIAL_FEATURE)
|
||||
Prepare_Speed_Dial, Measure_Speed_Dial,
|
||||
#endif
|
||||
SensorsReady, // Temperatures ready. Delay the next round of readings to let ADC pins settle.
|
||||
StartupDelay // Startup, delay initial temp reading a tiny bit so the hardware can settle
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue