Skip to content

Commit

Permalink
Added auto update to channels.
Browse files Browse the repository at this point in the history
I just copied the code from the commit mitch did to the uart extender branch.
  • Loading branch information
bdring committed Nov 11, 2023
1 parent f5508af commit 2250d6c
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion FluidNC/src/OLED.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void OLED::init() {
_oled->display();

allChannels.registration(this);
setReportInterval(500);
setReportInterval(_report_interval_ms);
}

Channel* OLED::pollLine(char* line) {
Expand Down
2 changes: 2 additions & 0 deletions FluidNC/src/OLED.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class OLED : public Channel, public Configuration::Configurable {
std::string _ticker;

int _radio_delay = 0;
int _report_interval_ms = 500;

uint8_t _i2c_num = 0;

Expand Down Expand Up @@ -116,6 +117,7 @@ class OLED : public Channel, public Configuration::Configurable {
void afterParse() override;

void group(Configuration::HandlerBase& handler) override {
handler.item("report_interval_ms", _report_interval_ms, 100, 5000);
handler.item("i2c_num", _i2c_num);
handler.item("i2c_address", _address);
handler.item("width", _width);
Expand Down
6 changes: 3 additions & 3 deletions FluidNC/src/Status_outputs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ void Status_Outputs::init() {
}

log_info("Status outputs"
<< " Interval:" << _interval_ms << " Idle:" << _Idle_pin.name() << " Cycle:" << _Run_pin.name() << " Hold:" << _Hold_pin.name()
<< " Alarm:" << _Alarm_pin.name());
<< " Interval:" << _report_interval_ms << " Idle:" << _Idle_pin.name() << " Cycle:" << _Run_pin.name()
<< " Hold:" << _Hold_pin.name() << " Alarm:" << _Alarm_pin.name());

allChannels.registration(this);
setReportInterval(_interval_ms);
setReportInterval(_report_interval_ms);
}

void Status_Outputs::parse_report() {
Expand Down
10 changes: 5 additions & 5 deletions FluidNC/src/Status_outputs.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ class Status_Outputs : public Channel, public Configuration::Configurable {
std::string _report;
std::string _state;

int _interval_ms = 500;
int _report_interval_ms = 500;

void parse_report();
void parse_status_report();

public:
Status_Outputs() : Channel("status_outputs") {}

Status_Outputs(const Status_Outputs&) = delete;
Status_Outputs(Status_Outputs&&) = delete;
Status_Outputs(const Status_Outputs&) = delete;
Status_Outputs(Status_Outputs&&) = delete;
Status_Outputs& operator=(const Status_Outputs&) = delete;
Status_Outputs& operator=(Status_Outputs&&) = delete;
Status_Outputs& operator=(Status_Outputs&&) = delete;

virtual ~Status_Outputs() = default;

Expand All @@ -47,7 +47,7 @@ class Status_Outputs : public Channel, public Configuration::Configurable {
void afterParse() override {};

void group(Configuration::HandlerBase& handler) override {
handler.item("report_interval_ms", _interval_ms, 100, 5000);
handler.item("report_interval_ms", _report_interval_ms, 100, 5000);
handler.item("idle_pin", _Idle_pin);
handler.item("run_pin", _Run_pin);
handler.item("hold_pin", _Hold_pin);
Expand Down
1 change: 1 addition & 0 deletions FluidNC/src/UartChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ void UartChannel::init() {
} else {
log_error("UartChannel: missing uart" << _uart_num);
}
setReportInterval(_report_interval_ms);
}
void UartChannel::init(Uart* uart) {
_uart = uart;
Expand Down
8 changes: 6 additions & 2 deletions FluidNC/src/UartChannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ class UartChannel : public Channel, public Configuration::Configurable {
Lineedit* _lineedit;
Uart* _uart;

int _uart_num = 0;
int _uart_num = 0;
int _report_interval_ms = 0;

public:
UartChannel(bool addCR = false);
Expand All @@ -39,7 +40,10 @@ class UartChannel : public Channel, public Configuration::Configurable {
Channel* pollLine(char* line) override;

// Configuration methods
void group(Configuration::HandlerBase& handler) override { handler.item("uart_num", _uart_num); }
void group(Configuration::HandlerBase& handler) override {
handler.item("uart_num", _uart_num);
handler.item("report_interval_ms", _report_interval_ms);
}
};

extern UartChannel Uart0;
Expand Down

0 comments on commit 2250d6c

Please sign in to comment.