Backlash cleanup (#13659)

…And save backlash, fil. sensor, ExtUI userdata to EEPROM.
This commit is contained in:
Marcio Teixeira
2019-05-03 22:53:15 -06:00
committed by Scott Lahteine
parent 0181e57417
commit 15357af67c
22 changed files with 645 additions and 293 deletions

View File

@@ -1,6 +1,6 @@
/*************
* dummy.cpp *
*************/
/***************
* example.cpp *
***************/
/****************************************************************************
* Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
@@ -21,7 +21,7 @@
#include "../../../inc/MarlinConfigPre.h"
#if ENABLED(EXTENSIBLE_UI)
#if BOTH(EXTUI_EXAMPLE, EXTENSIBLE_UI)
#include "../ui_api.h"
@@ -58,8 +58,36 @@ namespace ExtUI {
void onUserConfirmRequired(const char * const msg) {}
void onStatusChanged(const char * const msg) {}
void onFactoryReset() {}
void onLoadSettings() {}
void onStoreSettings() {}
void onStoreSettings(char *buff) {
// This is called when saving to EEPROM (i.e. M500). If the ExtUI needs
// permanent data to be stored, it can write up to eeprom_data_size bytes
// into buff.
// Example:
// static_assert(sizeof(myDataStruct) <= ExtUI::eeprom_data_size);
// memcpy(buff, &myDataStruct, sizeof(myDataStruct));
}
void onLoadSettings(const char *buff) {
// This is called while loading settings from EEPROM. If the ExtUI
// needs to retrieve data, it should copy up to eeprom_data_size bytes
// from buff
// Example:
// static_assert(sizeof(myDataStruct) <= ExtUI::eeprom_data_size);
// memcpy(&myDataStruct, buff, sizeof(myDataStruct));
}
void onConfigurationStoreWritten(bool success) {
// This is called after the entire EEPROM has been written,
// whether successful or not.
}
void onConfigurationStoreRead(bool success) {
// This is called after the entire EEPROM has been read,
// whether successful or not.
}
}
#endif // EXTENSIBLE_UI
#endif // EXTUI_EXAMPLE && EXTENSIBLE_UI

View File

@@ -82,11 +82,7 @@
#include "ui_api.h"
#if ENABLED(BACKLASH_GCODE)
extern float backlash_distance_mm[XYZ];
extern uint8_t backlash_correction;
#ifdef BACKLASH_SMOOTHING_MM
extern float backlash_smoothing_mm;
#endif
#include "../../feature/backlash.h"
#endif
#if HAS_LEVELING
@@ -111,7 +107,6 @@ static struct {
} flags;
namespace ExtUI {
#ifdef __SAM3X8E__
/**
* Implement a special millis() to allow time measurement
@@ -517,13 +512,13 @@ namespace ExtUI {
bool getFilamentRunoutEnabled() { return runout.enabled; }
void setFilamentRunoutEnabled(const bool value) { runout.enabled = value; }
#if FILAMENT_RUNOUT_DISTANCE_MM > 0
#ifdef FILAMENT_RUNOUT_DISTANCE_MM
float getFilamentRunoutDistance_mm() {
return RunoutResponseDelayed::runout_distance_mm;
return runout.runout_distance();
}
void setFilamentRunoutDistance_mm(const float value) {
RunoutResponseDelayed::runout_distance_mm = clamp(value, 0, 999);
runout.set_runout_distance(clamp(value, 0, 999));
}
#endif
#endif
@@ -687,16 +682,16 @@ namespace ExtUI {
#endif // HAS_HOTEND_OFFSET
#if ENABLED(BACKLASH_GCODE)
float getAxisBacklash_mm(const axis_t axis) { return backlash_distance_mm[axis]; }
float getAxisBacklash_mm(const axis_t axis) { return backlash.distance_mm[axis]; }
void setAxisBacklash_mm(const float value, const axis_t axis)
{ backlash_distance_mm[axis] = clamp(value,0,5); }
{ backlash.distance_mm[axis] = clamp(value,0,5); }
float getBacklashCorrection_percent() { return ui8_to_percent(backlash_correction); }
void setBacklashCorrection_percent(const float value) { backlash_correction = map(clamp(value, 0, 100), 0, 100, 0, 255); }
float getBacklashCorrection_percent() { return ui8_to_percent(backlash.correction); }
void setBacklashCorrection_percent(const float value) { backlash.correction = map(clamp(value, 0, 100), 0, 100, 0, 255); }
#ifdef BACKLASH_SMOOTHING_MM
float getBacklashSmoothing_mm() { return backlash_smoothing_mm; }
void setBacklashSmoothing_mm(const float value) { backlash_smoothing_mm = clamp(value, 0, 999); }
float getBacklashSmoothing_mm() { return backlash.smoothing_mm; }
void setBacklashSmoothing_mm(const float value) { backlash.smoothing_mm = clamp(value, 0, 999); }
#endif
#endif
@@ -750,7 +745,7 @@ namespace ExtUI {
}
bool commandsInQueue() { return (planner.movesplanned() || commands_in_queue); }
bool isAxisPositionKnown(const axis_t axis) {
return TEST(axis_known_position, axis);
}

View File

@@ -46,6 +46,11 @@
#include "../../inc/MarlinConfig.h"
namespace ExtUI {
// The ExtUI implementation can store up to this many bytes
// in the EEPROM when the methods onStoreSettings and
// onLoadSettings are called.
static constexpr size_t eeprom_data_size = 48;
enum axis_t : uint8_t { X, Y, Z };
enum extruder_t : uint8_t { E0, E1, E2, E3, E4, E5 };
@@ -207,7 +212,7 @@ namespace ExtUI {
bool getFilamentRunoutEnabled();
void setFilamentRunoutEnabled(const bool);
#if FILAMENT_RUNOUT_DISTANCE_MM > 0
#ifdef FILAMENT_RUNOUT_DISTANCE_MM
float getFilamentRunoutDistance_mm();
void setFilamentRunoutDistance_mm(const float);
#endif
@@ -283,8 +288,10 @@ namespace ExtUI {
void onUserConfirmRequired(const char * const msg);
void onStatusChanged(const char * const msg);
void onFactoryReset();
void onStoreSettings();
void onLoadSettings();
void onStoreSettings(char *);
void onLoadSettings(const char *);
void onConfigurationStoreWritten(bool success);
void onConfigurationStoreRead(bool success);
};
/**