Skip to content

Commit

Permalink
🏗️ Allow headless Flow Meter (MarlinFirmware#22234)
Browse files Browse the repository at this point in the history
  • Loading branch information
descipher authored Jul 12, 2021
1 parent 2c6a053 commit c0ecc66
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
23 changes: 12 additions & 11 deletions Marlin/src/feature/cooler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,27 @@

#include "../inc/MarlinConfig.h"

#if HAS_COOLER
#if EITHER(HAS_COOLER, LASER_COOLANT_FLOW_METER)

#include "cooler.h"
Cooler cooler;

uint8_t Cooler::mode = 0;
uint16_t Cooler::capacity;
uint16_t Cooler::load;
bool Cooler::enabled = false;
#if HAS_COOLER
uint8_t Cooler::mode = 0;
uint16_t Cooler::capacity;
uint16_t Cooler::load;
bool Cooler::enabled = false;
#endif

#if ENABLED(LASER_COOLANT_FLOW_METER)
bool Cooler::flowmeter = false;
millis_t Cooler::flowmeter_next_ms; // = 0
volatile uint16_t Cooler::flowpulses;
float Cooler::flowrate;
#if ENABLED(FLOWMETER_SAFETY)
bool Cooler::flowsafety_enabled = true;
bool Cooler::flowfault = false;
#endif
#endif

#if ENABLED(FLOWMETER_SAFETY)
bool Cooler::flowsafety_enabled = true;
bool Cooler::fault = false;
#endif

#endif // HAS_COOLER
#endif // HAS_COOLER || LASER_COOLANT_FLOW_METER
6 changes: 3 additions & 3 deletions Marlin/src/feature/cooler.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ class Cooler {
}

#if ENABLED(FLOWMETER_SAFETY)
static bool fault; // Flag that the cooler is in a fault state
static bool flowsafety_enabled; // Flag to disable the cutter if flow rate is too low
static bool flowfault; // Flag that the cooler is in a fault state
static bool flowsafety_enabled; // Flag to disable the cutter if flow rate is too low
static void flowsafety_toggle() { flowsafety_enabled = !flowsafety_enabled; }
static bool check_flow_too_low() {
const bool too_low = flowsafety_enabled && flowrate < (FLOWMETER_MIN_LITERS_PER_MINUTE);
if (too_low) fault = true;
flowfault = too_low;
return too_low;
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/gcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
#endif

#if ENABLED(FLOWMETER_SAFETY)
if (cooler.fault) {
if (cooler.flowfault) {
SERIAL_ECHO_MSG(STR_FLOWMETER_FAULT);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/module/temperature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1608,7 +1608,7 @@ void Temperature::manage_heater() {
#if ENABLED(FLOWMETER_SAFETY)
if (cutter.enabled() && cooler.check_flow_too_low()) {
cutter.disable();
ui.flow_fault();
TERN_(HAS_DISPLAY, ui.flow_fault());
}
#endif
#endif
Expand Down
3 changes: 2 additions & 1 deletion ini/features.ini
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ SDSUPPORT = src_filter=+<src/sd/cardreader.cpp> +<s
HAS_MEDIA_SUBCALLS = src_filter=+<src/gcode/sd/M32.cpp>
GCODE_REPEAT_MARKERS = src_filter=+<src/feature/repeat.cpp> +<src/gcode/sd/M808.cpp>
HAS_EXTRUDERS = src_filter=+<src/gcode/units/M82_M83.cpp> +<src/gcode/temp/M104_M109.cpp> +<src/gcode/config/M221.cpp>
HAS_COOLER = src_filter=+<src/feature/cooler.cpp> +<src/gcode/temp/M143_M193.cpp>
HAS_COOLER = src_filter=+<src/gcode/temp/M143_M193.cpp>
HAS_COOLER|LASER_COOLANT_FLOW_METER = src_filter=+<src/feature/cooler.cpp>
AUTO_REPORT_TEMPERATURES = src_filter=+<src/gcode/temp/M155.cpp>
INCH_MODE_SUPPORT = src_filter=+<src/gcode/units/G20_G21.cpp>
TEMPERATURE_UNITS_SUPPORT = src_filter=+<src/gcode/units/M149.cpp>
Expand Down

0 comments on commit c0ecc66

Please sign in to comment.