Skip to content

Commit

Permalink
fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Apr 20, 2021
1 parent 0ede80d commit 7d98ca4
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 39 deletions.
9 changes: 6 additions & 3 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -3159,9 +3159,12 @@
#define SPINDLE_LASER_PWM_INVERT false // Set to "true" if the speed/power goes up when you want it to go slower

#define SPINDLE_LASER_FREQUENCY 2500 // (Hz) Spindle/laser frequency (only on supported HALs: AVR and LPC)
#define AIR_EVACUATION // Cutter Vacuum or Laser Blower motor control gcode support (M10,M11)
#define AIR_EVACUATION_ACTIVE LOW // Set to "HIGH" if the on/off function is active HIGH
#define AIR_EVACUATION_PIN 42 // Pin to control the Cutter Vacuum or Laser Blower motor

//#define AIR_EVACUATION // Cutter Vacuum / Laser Blower motor control with G-codes M10-M11
#if ENABLED(AIR_EVACUATION)
#define AIR_EVACUATION_ACTIVE LOW // Set to "HIGH" if the on/off function is active HIGH
#define AIR_EVACUATION_PIN 42 // Override the default Cutter Vacuum or Laser Blower pin
#endif

//#define SPINDLE_SERVO // A servo converting an angle to spindle power
#ifdef SPINDLE_SERVO
Expand Down
20 changes: 9 additions & 11 deletions Marlin/src/feature/spindle_laser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ void SpindleLaser::init() {
set_pwm_frequency(pin_t(SPINDLE_LASER_PWM_PIN), SPINDLE_LASER_FREQUENCY);
TERN_(MARLIN_DEV_MODE, frequency = SPINDLE_LASER_FREQUENCY);
#endif
#if ENABLED(AIR_EVACUATION)
OUT_WRITE(AIR_EVACUATION_PIN, !AIR_EVACUATION_ACTIVE); // Init Vacuum/Blower to off
#endif
TERN_(AIR_EVACUATION, air_evac_disable()); // Init Vacuum/Blower OFF
}

#if ENABLED(SPINDLE_LASER_PWM)
Expand Down Expand Up @@ -139,14 +137,14 @@ void SpindleLaser::apply_power(const uint8_t opwr) {
#endif

#if ENABLED(AIR_EVACUATION)
// Enable or disable Vacuum or Blower Motor
void SpindleLaser::air_evac_enable() { // Turn On
WRITE(AIR_EVACUATION_PIN, AIR_EVACUATION_ACTIVE);
}

void SpindleLaser::air_evac_disable() { // Turn Off
WRITE(AIR_EVACUATION_PIN, !AIR_EVACUATION_ACTIVE);
}
#endif // AIR_EVACUATION
// Enable / disable Cutter Vacuum or Laser Blower motor
void SpindleLaser::air_evac_enable() { WRITE(AIR_EVACUATION_PIN, AIR_EVACUATION_ACTIVE); } // Turn ON

void SpindleLaser::air_evac_disable() { WRITE(AIR_EVACUATION_PIN, !AIR_EVACUATION_ACTIVE); } // Turn OFF

void SpindleLaser::air_evac_toggle() { TOGGLE(AIR_EVACUATION_PIN); } // Toggle state

#endif

#endif // HAS_CUTTER
9 changes: 6 additions & 3 deletions Marlin/src/feature/spindle_laser.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,12 @@ class SpindleLaser {
#endif

#if ENABLED(AIR_EVACUATION)
static void air_evac_enable(void); // Turn On Vacuum or Blower motor
static void air_evac_disable(void); // Turn Off Vacuum or Blower motor
static bool air_evac_state() { return (READ(AIR_EVACUATION_PIN) == AIR_EVACUATION_ACTIVE); } // Get current state
static void air_evac_enable(); // Turn On Cutter Vacuum or Laser Blower motor
static void air_evac_disable(); // Turn Off Cutter Vacuum or Laser Blower motor
static void air_evac_toggle(); // Toggle Cutter Vacuum or Laser Blower motor
static inline bool air_evac_state() { // Get current state
return (READ(AIR_EVACUATION_PIN) == AIR_EVACUATION_ACTIVE);
}
#endif

static inline void disable() { isReady = false; set_enabled(false); }
Expand Down
9 changes: 0 additions & 9 deletions Marlin/src/feature/spindle_laser_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,6 @@
#endif
#define MSG_CUTTER(M) _MSG_CUTTER(M)

#if ENABLED(AIR_EVACUATION)
#if ENABLED(SPINDLE_FEATURE)
#define _MSG_CUTTER_EVAC(M) MSG_SPINDLE_EVAC_##M
#else
#define _MSG_CUTTER_EVAC(M) MSG_LASER_EVAC_##M
#endif
#define MSG_CUTTER_EVAC(M) _MSG_CUTTER_EVAC(M)
#endif

typedef IF<(SPEED_POWER_MAX > 255), uint16_t, uint8_t>::type cutter_cpower_t;

#if CUTTER_UNIT_IS(RPM) && SPEED_POWER_MAX > 255
Expand Down
11 changes: 6 additions & 5 deletions Marlin/src/gcode/control/M10-M11.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
Expand All @@ -26,21 +26,22 @@

#include "../gcode.h"
#include "../../module/planner.h"
#include "../../feature/spindle_laser.h"

/**
* M10: Vacuum or Blower On
*/
void GcodeSuite::M10() {
planner.synchronize(); // Wait for move to arrive
WRITE(AIR_EVACUATION_PIN, AIR_EVACUATION_ACTIVE); // Turn on Vacuum or Blower motor
planner.synchronize(); // Wait for move to arrive (TODO: asynchronous)
cutter.air_evac_enable(); // Turn on Vacuum or Blower motor
}

/**
* M11: Vacuum or Blower OFF
*/
void GcodeSuite::M11() {
planner.synchronize(); // Wait for move to arrive
WRITE(AIR_EVACUATION_PIN, !AIR_EVACUATION_ACTIVE); // Turn off Vacuum or Blower motor
planner.synchronize(); // Wait for move to arrive (TODO: asynchronous)
cutter.air_evac_disable(); // Turn off Vacuum or Blower motor
}

#endif // AIR_EVACUATION
4 changes: 2 additions & 2 deletions Marlin/src/gcode/gcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,8 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
case 4: M3_M4(true ); break; // M4: Turn ON Laser | Spindle (counter-clockwise), set Power | Speed
case 5: M5(); break; // M5: Turn OFF Laser | Spindle
#if ENABLED(AIR_EVACUATION)
case 10: M10(); break; // M10: Vacuum or Blower motor ON
case 11: M11(); break; // M11: Vacuum or Blower motor OFF
case 10: M10(); break; // M10: Vacuum or Blower motor ON
case 11: M11(); break; // M11: Vacuum or Blower motor OFF
#endif
#endif

Expand Down
8 changes: 4 additions & 4 deletions Marlin/src/gcode/gcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@
* M7 - Turn mist coolant ON. (Requires COOLANT_CONTROL)
* M8 - Turn flood coolant ON. (Requires COOLANT_CONTROL)
* M9 - Turn coolant OFF. (Requires COOLANT_CONTROL)
* M10 - Turn Vacuum or Blower motor ON (Requires SPINDLE_FEATURE or LASER_FEATURE and AIR_EVACUATION)
* M11 - Turn Vacuum or Blower motor OFF (Requires SPINDLE_FEATURE or LASER_FEATURE and AIR_EVACUATION)
* M10 - Turn Vacuum or Blower motor ON (Requires AIR_EVACUATION)
* M11 - Turn Vacuum or Blower motor OFF (Requires AIR_EVACUATION)
* M12 - Set up closed loop control system. (Requires EXTERNAL_CLOSED_LOOP_CONTROLLER)
* M16 - Expected printer check. (Requires EXPECTED_PRINTER_CHECK)
* M17 - Enable/Power all stepper motors
Expand Down Expand Up @@ -551,8 +551,8 @@ class GcodeSuite {
static void M3_M4(const bool is_M4);
static void M5();
#if ENABLED(AIR_EVACUATION)
static void M10();
static void M11();
static void M10();
static void M11();
#endif
#endif

Expand Down
3 changes: 1 addition & 2 deletions Marlin/src/lcd/menu/menu_spindle_laser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@

#if ENABLED(AIR_EVACUATION)
bool evac_state = cutter.air_evac_state();
editable.state = evac_state;
EDIT_ITEM(bool, MSG_CUTTER_EVAC(TOGGLE), &evac_state, []{ if (editable.state) cutter.air_evac_disable(); else cutter.air_evac_enable(); });
EDIT_ITEM(bool, MSG_CUTTER(EVAC_TOGGLE), &evac_state, cutter.air_evac_toggle);
#endif

#if ENABLED(SPINDLE_CHANGE_DIR)
Expand Down
1 change: 1 addition & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ default_src_filter = +<src/*> -<src/config> -<src/HAL> +<src/HAL/shared>
-<src/gcode/calibrate/M425.cpp>
-<src/gcode/calibrate/M666.cpp>
-<src/gcode/calibrate/M852.cpp>
-<src/gcode/control/M10-M11.cpp>
-<src/gcode/control/M42.cpp> -<src/gcode/control/M226.cpp>
-<src/gcode/config/M43.cpp>
-<src/gcode/config/M217.cpp>
Expand Down

0 comments on commit 7d98ca4

Please sign in to comment.