grbl-LPC-CoreXY/coolant_control.c
Sonny Jeon 3b468f602b Bug fix for certain motions. Re-org of includes.
- Critical bug fix for diagonal motions that continue on the same
direction or return in the exact opposite direction. This issue could
cause Grbl to crash intermittently due to a numerical round-off error.
Grbl versions prior to v0.9g shouldn’t have this issue.

- Reorganized all of the includes used by Grbl. Centralized it into a
single “grbl.h” include. This will help simplify the compiling and
uploading process through the Arduino IDE.

- Added an example .INO file for users to simply open and run when
compiling and uploading through the IDE. More to come later.
2015-02-10 08:25:09 -07:00

65 lines
1.5 KiB
C

/*
coolant_control.c - coolant control methods
Part of Grbl v0.9
Copyright (c) 2012-2015 Sungeun K. Jeon
Grbl is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Grbl is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
*/
#include "grbl.h"
void coolant_init()
{
COOLANT_FLOOD_DDR |= (1 << COOLANT_FLOOD_BIT);
#ifdef ENABLE_M7
COOLANT_MIST_DDR |= (1 << COOLANT_MIST_BIT);
#endif
coolant_stop();
}
void coolant_stop()
{
COOLANT_FLOOD_PORT &= ~(1 << COOLANT_FLOOD_BIT);
#ifdef ENABLE_M7
COOLANT_MIST_PORT &= ~(1 << COOLANT_MIST_BIT);
#endif
}
void coolant_set_state(uint8_t mode)
{
if (mode == COOLANT_FLOOD_ENABLE) {
COOLANT_FLOOD_PORT |= (1 << COOLANT_FLOOD_BIT);
#ifdef ENABLE_M7
} else if (mode == COOLANT_MIST_ENABLE) {
COOLANT_MIST_PORT |= (1 << COOLANT_MIST_BIT);
#endif
} else {
coolant_stop();
}
}
void coolant_run(uint8_t mode)
{
if (sys.state == STATE_CHECK_MODE) { return; }
protocol_buffer_synchronize(); // Ensure coolant turns on when specified in program.
coolant_set_state(mode);
}