ClosedLoop as singleton
This commit is contained in:
parent
30ee0d3800
commit
48151d1778
6 changed files with 29 additions and 13 deletions
|
@ -1136,7 +1136,7 @@ void setup() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER)
|
#if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER)
|
||||||
SETUP_RUN(init_closedloop());
|
SETUP_RUN(closedloop.init());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef STARTUP_COMMANDS
|
#ifdef STARTUP_COMMANDS
|
||||||
|
|
|
@ -29,12 +29,14 @@
|
||||||
|
|
||||||
#include "closedloop.h"
|
#include "closedloop.h"
|
||||||
|
|
||||||
void init_closedloop() {
|
ClosedLoop closedloop;
|
||||||
|
|
||||||
|
void ClosedLoop::init() {
|
||||||
OUT_WRITE(CLOSED_LOOP_ENABLE_PIN, LOW);
|
OUT_WRITE(CLOSED_LOOP_ENABLE_PIN, LOW);
|
||||||
SET_INPUT_PULLUP(CLOSED_LOOP_MOVE_COMPLETE_PIN);
|
SET_INPUT_PULLUP(CLOSED_LOOP_MOVE_COMPLETE_PIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_closedloop(const byte val) {
|
void ClosedLoop::set(const byte val) {
|
||||||
OUT_WRITE(CLOSED_LOOP_ENABLE_PIN, val);
|
OUT_WRITE(CLOSED_LOOP_ENABLE_PIN, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,5 +21,12 @@
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
void init_closedloop();
|
class ClosedLoop {
|
||||||
void set_closedloop(const byte val);
|
public:
|
||||||
|
static void init();
|
||||||
|
static void set(const byte val);
|
||||||
|
};
|
||||||
|
|
||||||
|
extern ClosedLoop closedloop;
|
||||||
|
|
||||||
|
#define CLOSED_LOOP_WAITING() (READ(CLOSED_LOOP_ENABLE_PIN) && !READ(CLOSED_LOOP_MOVE_COMPLETE_PIN))
|
||||||
|
|
|
@ -28,9 +28,12 @@
|
||||||
#include "../../feature/closedloop.h"
|
#include "../../feature/closedloop.h"
|
||||||
|
|
||||||
void GcodeSuite::M12() {
|
void GcodeSuite::M12() {
|
||||||
|
|
||||||
planner.synchronize();
|
planner.synchronize();
|
||||||
|
|
||||||
if (parser.seenval('S'))
|
if (parser.seenval('S'))
|
||||||
set_closedloop(parser.value_int()); // Force a CLC set
|
closedloop.set(parser.value_int()); // Force a CLC set
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -91,6 +91,10 @@
|
||||||
#include "../feature/power.h"
|
#include "../feature/power.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER)
|
||||||
|
#include "../feature/closedloop.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if ENABLED(BACKLASH_COMPENSATION)
|
#if ENABLED(BACKLASH_COMPENSATION)
|
||||||
#include "../feature/backlash.h"
|
#include "../feature/backlash.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -1634,11 +1638,8 @@ float Planner::get_axis_position_mm(const AxisEnum axis) {
|
||||||
* Block until all buffered steps are executed / cleaned
|
* Block until all buffered steps are executed / cleaned
|
||||||
*/
|
*/
|
||||||
void Planner::synchronize() {
|
void Planner::synchronize() {
|
||||||
while (
|
while (has_blocks_queued() || cleaning_buffer_counter
|
||||||
has_blocks_queued() || cleaning_buffer_counter
|
|| TERN0(EXTERNAL_CLOSED_LOOP_CONTROLLER, CLOSED_LOOP_WAITING())
|
||||||
#if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER)
|
|
||||||
|| (READ(CLOSED_LOOP_ENABLE_PIN) && !READ(CLOSED_LOOP_MOVE_COMPLETE_PIN))
|
|
||||||
#endif
|
|
||||||
) idle();
|
) idle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,11 @@ opt_set LCD_LANGUAGE an
|
||||||
opt_enable SPINDLE_FEATURE ULTIMAKERCONTROLLER LCD_BED_LEVELING \
|
opt_enable SPINDLE_FEATURE ULTIMAKERCONTROLLER LCD_BED_LEVELING \
|
||||||
SENSORLESS_BACKOFF_MM HOMING_BACKOFF_POST_MM HOME_Y_BEFORE_X CODEPENDENT_XY_HOMING \
|
SENSORLESS_BACKOFF_MM HOMING_BACKOFF_POST_MM HOME_Y_BEFORE_X CODEPENDENT_XY_HOMING \
|
||||||
MESH_BED_LEVELING ENABLE_LEVELING_FADE_HEIGHT MESH_G28_REST_ORIGIN \
|
MESH_BED_LEVELING ENABLE_LEVELING_FADE_HEIGHT MESH_G28_REST_ORIGIN \
|
||||||
G26_MESH_VALIDATION MESH_EDIT_MENU GCODE_QUOTED_STRINGS
|
G26_MESH_VALIDATION MESH_EDIT_MENU GCODE_QUOTED_STRINGS \
|
||||||
exec_test $1 $2 "Spindle, MESH_BED_LEVELING, and LCD"
|
EXTERNAL_CLOSED_LOOP_CONTROLLER
|
||||||
|
opt_set CLOSED_LOOP_ENABLE_PIN 44
|
||||||
|
opt_set CLOSED_LOOP_MOVE_COMPLETE_PIN 45
|
||||||
|
exec_test $1 $2 "Spindle, MESH_BED_LEVELING, closed loop, and LCD"
|
||||||
|
|
||||||
#
|
#
|
||||||
# Test DUAL_X_CARRIAGE
|
# Test DUAL_X_CARRIAGE
|
||||||
|
|
Reference in a new issue