Additional ExtUI features (#13449)

This commit is contained in:
Marcio Teixeira 2019-03-23 22:09:18 -06:00 committed by Scott Lahteine
parent a8fa275dc6
commit a0ca98f699
3 changed files with 134 additions and 6 deletions

View file

@ -674,7 +674,7 @@ ASFLAGS := $(CDEFS)
ifeq ($(HARDWARE_VARIANT), archim)
LD_PREFIX = -Wl,--gc-sections,-Map,Marlin.ino.map,--cref,--check-sections,--entry=Reset_Handler,--unresolved-symbols=report-all,--warn-common,--warn-section-align
LD_SUFFIX = $(LDLIBS)
LDFLAGS = -lm -gcc -T$(LDSCRIPT) -u _sbrk -u link -u _close -u _fstat -u _isatty -u _lseek -u _read -u _write -u _exit -u kill -u _getpid
LDFLAGS = -lm -T$(LDSCRIPT) -u _sbrk -u link -u _close -u _fstat -u _isatty -u _lseek -u _read -u _write -u _exit -u kill -u _getpid
else
LD_PREFIX = -Wl,--gc-sections,--relax
LDFLAGS = -lm

View file

@ -74,8 +74,9 @@
#define IFSD(A,B) (B)
#endif
#if HAS_TRINAMIC && HAS_LCD_MENU
#if HAS_TRINAMIC
#include "../../feature/tmc_util.h"
#include "../../module/stepper_indirection.h"
#endif
#include "ui_api.h"
@ -339,6 +340,122 @@ namespace ExtUI {
return !thermalManager.tooColdToExtrude(extruder - E0);
}
#if HAS_SOFTWARE_ENDSTOPS
bool getSoftEndstopState() {
return soft_endstops_enabled;
}
void setSoftEndstopState(const bool value) {
soft_endstops_enabled = value;
}
#endif
#if HAS_TRINAMIC
float getAxisCurrent_mA(const axis_t axis) {
switch (axis) {
#if AXIS_IS_TMC(X)
case X: return stepperX.getMilliamps();
#endif
#if AXIS_IS_TMC(Y)
case Y: return stepperY.getMilliamps();
#endif
#if AXIS_IS_TMC(Z)
case Z: return stepperZ.getMilliamps();
#endif
default: return NAN;
};
}
float getAxisCurrent_mA(const extruder_t extruder) {
switch (extruder) {
#if AXIS_IS_TMC(E0)
case E0: return stepperE0.getMilliamps();
#endif
#if AXIS_IS_TMC(E1)
case E1: return stepperE1.getMilliamps();
#endif
#if AXIS_IS_TMC(E2)
case E2: return stepperE2.getMilliamps();
#endif
#if AXIS_IS_TMC(E3)
case E3: return stepperE3.getMilliamps();
#endif
#if AXIS_IS_TMC(E4)
case E4: return stepperE4.getMilliamps();
#endif
#if AXIS_IS_TMC(E5)
case E5: return stepperE5.getMilliamps();
#endif
default: return NAN;
};
}
void setAxisCurrent_mA(const float mA, const axis_t axis) {
switch (axis) {
#if AXIS_IS_TMC(X)
case X: stepperX.rms_current(clamp(mA, 500, 1500)); break;
#endif
#if AXIS_IS_TMC(Y)
case Y: stepperY.rms_current(clamp(mA, 500, 1500)); break;
#endif
#if AXIS_IS_TMC(Z)
case Z: stepperZ.rms_current(clamp(mA, 500, 1500)); break;
#endif
};
}
void setAxisCurrent_mA(const float mA, const extruder_t extruder) {
switch (extruder) {
#if AXIS_IS_TMC(E0)
case E0: stepperE0.rms_current(clamp(mA, 500, 1500)); break;
#endif
#if AXIS_IS_TMC(E1)
case E1: stepperE1.rms_current(clamp(mA, 500, 1500)); break;
#endif
#if AXIS_IS_TMC(E2)
case E2: stepperE2.rms_current(clamp(mA, 500, 1500)); break;
#endif
#if AXIS_IS_TMC(E3)
case E3: stepperE3.rms_current(clamp(mA, 500, 1500)); break;
#endif
#if AXIS_IS_TMC(E4)
case E4: stepperE4.rms_current(clamp(mA, 500, 1500)); break;
#endif
#if AXIS_IS_TMC(E5)
case E5: stepperE5.rms_current(clamp(mA, 500, 1500)); break;
#endif
};
}
int getTMCBumpSensitivity(const axis_t axis) {
switch (axis) {
#if X_SENSORLESS && AXIS_HAS_STALLGUARD(X)
case X: return stepperX.sgt();
#endif
#if Y_SENSORLESS && AXIS_HAS_STALLGUARD(Y)
case Y: return stepperY.sgt();
#endif
#if Z_SENSORLESS && AXIS_HAS_STALLGUARD(Z)
case Z: return stepperZ.sgt();
#endif
}
}
void setTMCBumpSensitivity(const float value, const axis_t axis) {
switch (axis) {
#if X_SENSORLESS && AXIS_HAS_STALLGUARD(X)
case X: stepperX.sgt(clamp(value, -64, 63)); break;
#endif
#if Y_SENSORLESS && AXIS_HAS_STALLGUARD(Y)
case Y: stepperY.sgt(clamp(value, -64, 63)); break;
#endif
#if Z_SENSORLESS && AXIS_HAS_STALLGUARD(Z)
case Z: stepperZ.sgt(clamp(value, -64, 63)); break;
#endif
}
}
#endif
float getAxisSteps_per_mm(const axis_t axis) {
return planner.settings.axis_steps_per_mm[axis];
}
@ -787,10 +904,6 @@ void MarlinUI::init() {
SET_INPUT_PULLUP(SD_DETECT_PIN);
#endif
#if HAS_TRINAMIC && HAS_LCD_MENU
init_tmc_section();
#endif
ExtUI::onStartup();
}

View file

@ -68,6 +68,21 @@ namespace ExtUI {
*/
PGM_P getFirmwareName_str();
#if HAS_SOFTWARE_ENDSTOPS
bool getSoftEndstopState();
void setSoftEndstopState(const bool);
#endif
#if HAS_TRINAMIC
float getAxisCurrent_mA(const axis_t);
float getAxisCurrent_mA(const extruder_t);
void setAxisCurrent_mA(const float, const axis_t);
void setAxisCurrent_mA(const float, const extruder_t);
int getTMCBumpSensitivity(const axis_t);
void setTMCBumpSensitivity(const float, const axis_t);
#endif
float getActualTemp_celsius(const heater_t);
float getActualTemp_celsius(const extruder_t);
float getTargetTemp_celsius(const heater_t);