mirror of
https://github.com/bdring/Grbl_Esp32.git
synced 2025-09-02 10:53:01 +02:00
Removed obsolete AxisMaskSetting and FloatSetting
This commit is contained in:
@@ -176,198 +176,6 @@ void IntSetting::addWebui(WebUI::JSONencoder* j) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AxisMaskSetting::AxisMaskSetting(const char* description,
|
|
||||||
type_t type,
|
|
||||||
permissions_t permissions,
|
|
||||||
const char* grblName,
|
|
||||||
const char* name,
|
|
||||||
int32_t defVal,
|
|
||||||
bool (*checker)(char*) = NULL) :
|
|
||||||
Setting(description, type, permissions, grblName, name, checker),
|
|
||||||
_defaultValue(defVal), _currentValue(defVal) {}
|
|
||||||
|
|
||||||
void AxisMaskSetting::load() {
|
|
||||||
esp_err_t err = nvs_get_i32(_handle, _keyName, &_storedValue);
|
|
||||||
if (err) {
|
|
||||||
_storedValue = -1;
|
|
||||||
_currentValue = _defaultValue;
|
|
||||||
} else {
|
|
||||||
_currentValue = _storedValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AxisMaskSetting::setDefault() {
|
|
||||||
_currentValue = _defaultValue;
|
|
||||||
if (_storedValue != _currentValue) {
|
|
||||||
nvs_erase_key(_handle, _keyName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Error AxisMaskSetting::setStringValue(char* s) {
|
|
||||||
s = trim(s);
|
|
||||||
Error err = check(s);
|
|
||||||
if (err != Error::Ok) {
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
int32_t convertedValue;
|
|
||||||
char* endptr;
|
|
||||||
if (*s == '\0') {
|
|
||||||
convertedValue = 0;
|
|
||||||
} else {
|
|
||||||
convertedValue = strtol(s, &endptr, 10);
|
|
||||||
if (endptr == s || *endptr != '\0') {
|
|
||||||
// Try to convert as an axis list
|
|
||||||
convertedValue = 0;
|
|
||||||
auto axisNames = String("XYZABC");
|
|
||||||
while (*s) {
|
|
||||||
int index = axisNames.indexOf(toupper(*s++));
|
|
||||||
if (index < 0) {
|
|
||||||
return Error::BadNumberFormat;
|
|
||||||
}
|
|
||||||
convertedValue |= bit(index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_currentValue = convertedValue;
|
|
||||||
if (_storedValue != _currentValue) {
|
|
||||||
if (_currentValue == _defaultValue) {
|
|
||||||
nvs_erase_key(_handle, _keyName);
|
|
||||||
} else {
|
|
||||||
if (nvs_set_i32(_handle, _keyName, _currentValue)) {
|
|
||||||
return Error::NvsSetFailed;
|
|
||||||
}
|
|
||||||
_storedValue = _currentValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
check(NULL);
|
|
||||||
return Error::Ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* AxisMaskSetting::getCompatibleValue() {
|
|
||||||
static char strval[32];
|
|
||||||
sprintf(strval, "%d", get());
|
|
||||||
return strval;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char* maskToString(uint32_t mask, char* strval) {
|
|
||||||
char* s = strval;
|
|
||||||
for (int i = 0; i < MAX_N_AXIS; i++) {
|
|
||||||
if (mask & bit(i)) {
|
|
||||||
*s++ = "XYZABC"[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*s = '\0';
|
|
||||||
return strval;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* AxisMaskSetting::getDefaultString() {
|
|
||||||
static char strval[32];
|
|
||||||
return maskToString(_defaultValue, strval);
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* AxisMaskSetting::getStringValue() {
|
|
||||||
static char strval[32];
|
|
||||||
return maskToString(get(), strval);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AxisMaskSetting::addWebui(WebUI::JSONencoder* j) {
|
|
||||||
if (getDescription()) {
|
|
||||||
j->begin_webui(getName(), getDescription(), "I", getStringValue(), 0, (1 << MAX_N_AXIS) - 1);
|
|
||||||
j->end_object();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FloatSetting::FloatSetting(const char* description,
|
|
||||||
type_t type,
|
|
||||||
permissions_t permissions,
|
|
||||||
const char* grblName,
|
|
||||||
const char* name,
|
|
||||||
float defVal,
|
|
||||||
float minVal,
|
|
||||||
float maxVal,
|
|
||||||
bool (*checker)(char*) = NULL) :
|
|
||||||
Setting(description, type, permissions, grblName, name, checker),
|
|
||||||
_defaultValue(defVal), _currentValue(defVal), _minValue(minVal), _maxValue(maxVal) {}
|
|
||||||
|
|
||||||
void FloatSetting::load() {
|
|
||||||
union {
|
|
||||||
int32_t ival;
|
|
||||||
float fval;
|
|
||||||
} v;
|
|
||||||
if (nvs_get_i32(_handle, _keyName, &v.ival)) {
|
|
||||||
_currentValue = _defaultValue;
|
|
||||||
} else {
|
|
||||||
_currentValue = v.fval;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FloatSetting::setDefault() {
|
|
||||||
_currentValue = _defaultValue;
|
|
||||||
if (_storedValue != _currentValue) {
|
|
||||||
nvs_erase_key(_handle, _keyName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Error FloatSetting::setStringValue(char* s) {
|
|
||||||
s = trim(s);
|
|
||||||
Error err = check(s);
|
|
||||||
if (err != Error::Ok) {
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
float convertedValue;
|
|
||||||
uint8_t len = strlen(s);
|
|
||||||
uint8_t retlen = 0;
|
|
||||||
if (!read_float(s, &retlen, &convertedValue) || retlen != len) {
|
|
||||||
return Error::BadNumberFormat;
|
|
||||||
}
|
|
||||||
if (convertedValue < _minValue || convertedValue > _maxValue) {
|
|
||||||
return Error::NumberRange;
|
|
||||||
}
|
|
||||||
_currentValue = convertedValue;
|
|
||||||
if (_storedValue != _currentValue) {
|
|
||||||
if (_currentValue == _defaultValue) {
|
|
||||||
nvs_erase_key(_handle, _keyName);
|
|
||||||
} else {
|
|
||||||
union {
|
|
||||||
int32_t ival;
|
|
||||||
float fval;
|
|
||||||
} v;
|
|
||||||
v.fval = _currentValue;
|
|
||||||
if (nvs_set_i32(_handle, _keyName, v.ival)) {
|
|
||||||
return Error::NvsSetFailed;
|
|
||||||
}
|
|
||||||
_storedValue = _currentValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
check(NULL);
|
|
||||||
return Error::Ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* FloatSetting::getDefaultString() {
|
|
||||||
static char strval[32];
|
|
||||||
(void)sprintf(strval, "%.3f", _defaultValue);
|
|
||||||
return strval;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* FloatSetting::getStringValue() {
|
|
||||||
static char strval[32];
|
|
||||||
(void)sprintf(strval, "%.3f", get());
|
|
||||||
#if 0
|
|
||||||
// With the goal of representing both large and small floating point
|
|
||||||
// numbers compactly while showing clearly that the are floating point,
|
|
||||||
// remove trailing zeros leaving at least one post-decimal digit.
|
|
||||||
// The loop is guaranteed to terminate because the string contains
|
|
||||||
// a decimal point which is not a '0'.
|
|
||||||
for (char *p = strval + strlen(strval) - 1; *p == '0'; --p) {
|
|
||||||
if (*(p-1) != '.' && *(p-1) != ',') {
|
|
||||||
*p = '\0';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return strval;
|
|
||||||
}
|
|
||||||
|
|
||||||
StringSetting::StringSetting(const char* description,
|
StringSetting::StringSetting(const char* description,
|
||||||
type_t type,
|
type_t type,
|
||||||
permissions_t permissions,
|
permissions_t permissions,
|
||||||
@@ -716,8 +524,6 @@ void IPaddrSetting::addWebui(WebUI::JSONencoder* j) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AxisSettings::AxisSettings(const char* axisName) : name(axisName) {}
|
|
||||||
|
|
||||||
Error GrblCommand::action(char* value, WebUI::AuthenticationLevel auth_level, WebUI::ESPResponseStream* out) {
|
Error GrblCommand::action(char* value, WebUI::AuthenticationLevel auth_level, WebUI::ESPResponseStream* out) {
|
||||||
if (_cmdChecker && _cmdChecker()) {
|
if (_cmdChecker && _cmdChecker()) {
|
||||||
return Error::IdleError;
|
return Error::IdleError;
|
||||||
|
@@ -200,36 +200,6 @@ public:
|
|||||||
int32_t get() { return _currentValue; }
|
int32_t get() { return _currentValue; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class AxisMaskSetting : public Setting {
|
|
||||||
private:
|
|
||||||
int32_t _defaultValue;
|
|
||||||
int32_t _currentValue;
|
|
||||||
int32_t _storedValue;
|
|
||||||
|
|
||||||
public:
|
|
||||||
AxisMaskSetting(const char* description,
|
|
||||||
type_t type,
|
|
||||||
permissions_t permissions,
|
|
||||||
const char* grblName,
|
|
||||||
const char* name,
|
|
||||||
int32_t defVal,
|
|
||||||
bool (*checker)(char*));
|
|
||||||
|
|
||||||
AxisMaskSetting(
|
|
||||||
type_t type, permissions_t permissions, const char* grblName, const char* name, int32_t defVal, bool (*checker)(char*) = NULL) :
|
|
||||||
AxisMaskSetting(NULL, type, permissions, grblName, name, defVal, checker) {}
|
|
||||||
|
|
||||||
void load();
|
|
||||||
void setDefault();
|
|
||||||
void addWebui(WebUI::JSONencoder*);
|
|
||||||
Error setStringValue(char* value);
|
|
||||||
const char* getCompatibleValue();
|
|
||||||
const char* getStringValue();
|
|
||||||
const char* getDefaultString();
|
|
||||||
|
|
||||||
int32_t get() { return _currentValue; }
|
|
||||||
};
|
|
||||||
|
|
||||||
class Coordinates {
|
class Coordinates {
|
||||||
private:
|
private:
|
||||||
float _currentValue[MAX_N_AXIS];
|
float _currentValue[MAX_N_AXIS];
|
||||||
@@ -255,46 +225,6 @@ public:
|
|||||||
|
|
||||||
extern Coordinates* coords[CoordIndex::End];
|
extern Coordinates* coords[CoordIndex::End];
|
||||||
|
|
||||||
class FloatSetting : public Setting {
|
|
||||||
private:
|
|
||||||
float _defaultValue;
|
|
||||||
float _currentValue;
|
|
||||||
float _storedValue;
|
|
||||||
float _minValue;
|
|
||||||
float _maxValue;
|
|
||||||
|
|
||||||
public:
|
|
||||||
FloatSetting(const char* description,
|
|
||||||
type_t type,
|
|
||||||
permissions_t permissions,
|
|
||||||
const char* grblName,
|
|
||||||
const char* name,
|
|
||||||
float defVal,
|
|
||||||
float minVal,
|
|
||||||
float maxVal,
|
|
||||||
bool (*checker)(char*));
|
|
||||||
|
|
||||||
FloatSetting(type_t type,
|
|
||||||
permissions_t permissions,
|
|
||||||
const char* grblName,
|
|
||||||
const char* name,
|
|
||||||
float defVal,
|
|
||||||
float minVal,
|
|
||||||
float maxVal,
|
|
||||||
bool (*checker)(char*) = NULL) :
|
|
||||||
FloatSetting(NULL, type, permissions, grblName, name, defVal, minVal, maxVal, checker) {}
|
|
||||||
|
|
||||||
void load();
|
|
||||||
void setDefault();
|
|
||||||
// There are no Float settings in WebUI
|
|
||||||
void addWebui(WebUI::JSONencoder*) {}
|
|
||||||
Error setStringValue(char* value);
|
|
||||||
const char* getStringValue();
|
|
||||||
const char* getDefaultString();
|
|
||||||
|
|
||||||
float get() { return _currentValue; }
|
|
||||||
};
|
|
||||||
|
|
||||||
class StringSetting : public Setting {
|
class StringSetting : public Setting {
|
||||||
private:
|
private:
|
||||||
String _defaultValue;
|
String _defaultValue;
|
||||||
@@ -432,22 +362,6 @@ public:
|
|||||||
uint32_t get() { return _currentValue; }
|
uint32_t get() { return _currentValue; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class AxisSettings {
|
|
||||||
public:
|
|
||||||
const char* name;
|
|
||||||
FloatSetting* steps_per_mm;
|
|
||||||
FloatSetting* max_rate;
|
|
||||||
FloatSetting* acceleration;
|
|
||||||
FloatSetting* max_travel;
|
|
||||||
FloatSetting* run_current;
|
|
||||||
FloatSetting* hold_current;
|
|
||||||
FloatSetting* home_mpos;
|
|
||||||
IntSetting* microsteps;
|
|
||||||
IntSetting* stallguard;
|
|
||||||
|
|
||||||
AxisSettings(const char* axisName);
|
|
||||||
};
|
|
||||||
|
|
||||||
extern bool idleOrJog();
|
extern bool idleOrJog();
|
||||||
extern bool idleOrAlarm();
|
extern bool idleOrAlarm();
|
||||||
extern bool anyState();
|
extern bool anyState();
|
||||||
|
Reference in New Issue
Block a user