Skip to content

Commit

Permalink
Fixed WebUI3 validation issue:
Browse files Browse the repository at this point in the history
- /i2so/min_pulse_us is now enumerated
- unsigned config items report MAXINT not -1 as the max value
  • Loading branch information
MitchBradley committed Feb 2, 2025
1 parent 8a037f7 commit a28f59a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion FluidNC/src/Configuration/JsonGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ namespace Configuration {
void JsonGenerator::item(const char* name, uint32_t& value, const uint32_t minValue, const uint32_t maxValue) {
enter(name);
char buf[32];
itoa(value, buf, 10);
utoa(value, buf, 10);
_encoder.begin_webui(_currentPath, _currentPath, "I", buf, minValue, maxValue);
_encoder.end_object();
leave();
Expand Down
4 changes: 3 additions & 1 deletion FluidNC/src/Machine/I2SOBus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include "Driver/i2s_out.h" // i2s_out_init()

namespace Machine {
const EnumItem pulseUsValues[] = { { 1, "1" }, { 2, "2" }, { 4, "4" }, EnumItem(2) };

void I2SOBus::validate() {
Assert(_min_pulse_us == 1 || _min_pulse_us == 2 || _min_pulse_us == 4, "min_pulse_us must be 1, 2 or 4");
if (_bck.defined() || _data.defined() || _ws.defined()) {
Expand All @@ -19,7 +21,7 @@ namespace Machine {
handler.item("bck_pin", _bck);
handler.item("data_pin", _data);
handler.item("ws_pin", _ws);
handler.item("min_pulse_us", _min_pulse_us);
handler.item("min_pulse_us", _min_pulse_us, pulseUsValues);
}

void I2SOBus::init() {
Expand Down
2 changes: 1 addition & 1 deletion FluidNC/src/Machine/I2SOBus.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Machine {
Pin _data;
Pin _ws;

uint32_t _min_pulse_us = 2;
int _min_pulse_us = 2;

void validate() override;
void group(Configuration::HandlerBase& handler) override;
Expand Down

0 comments on commit a28f59a

Please sign in to comment.