Position reporting, refactored system variables, serial print fixes, updated streaming scripts.
- Added machine position reporting to status queries. This will be further developed with part positioning/offsets and maintaining location upon reset. - System variables refactored into a global struct for better readability. - Removed old obsolete Ruby streaming scripts. These were no longer compatible. Updated Python streaming scripts. - Fixed printFloat() and other printing functions. - Decreased planner buffer back to 18 blocks and increased TX serial buffer to 64 bytes. Need the memory space for future developments. - Begun adding run-time modes to grbl, where block delete toggle, mm/in reporting modes, jog modes, etc can be set during runtime. Will be fleshed out and placed into EEPROM when everything is added.
This commit is contained in:
52
main.c
52
main.c
@ -4,8 +4,7 @@
|
||||
|
||||
Copyright (c) 2009-2011 Simen Svale Skogsrud
|
||||
Copyright (c) 2011 Sungeun K. Jeon
|
||||
Copyright (c) 2011 Jens Geisler
|
||||
|
||||
|
||||
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
|
||||
@ -20,11 +19,8 @@
|
||||
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <avr/io.h>
|
||||
#include <avr/sleep.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include <util/delay.h>
|
||||
#include "config.h"
|
||||
#include "planner.h"
|
||||
#include "nuts_bolts.h"
|
||||
@ -34,15 +30,11 @@
|
||||
#include "gcode.h"
|
||||
#include "protocol.h"
|
||||
#include "limits.h"
|
||||
|
||||
#include "settings.h"
|
||||
#include "serial.h"
|
||||
|
||||
#include "print.h"
|
||||
|
||||
// Declare system global variables
|
||||
uint8_t sys_abort; // Global system abort flag
|
||||
volatile uint8_t sys_state; // Global system state variable
|
||||
// Declare system global variable structure
|
||||
system_t sys;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
@ -50,17 +42,18 @@ int main(void)
|
||||
sei(); // Enable interrupts
|
||||
serial_init(BAUD_RATE); // Setup serial baud rate and interrupts
|
||||
st_init(); // Setup stepper pins and interrupt timers
|
||||
sys_abort = true; // Set abort to complete initialization
|
||||
|
||||
sys.abort = true; // Set abort to complete initialization
|
||||
|
||||
while(1) {
|
||||
|
||||
// Upon a system abort, the main program will return to this loop. Once here, it is safe to
|
||||
// re-initialize the system. Upon startup, the system will automatically reset to finish the
|
||||
// initialization process.
|
||||
if (sys_abort) {
|
||||
// Execute system reset
|
||||
sys_state = 0; // Reset system state
|
||||
sys_abort = false; // Release system abort
|
||||
// Execute system reset upon a system abort, where the main program will return to this loop.
|
||||
// Once here, it is safe to re-initialize the system. At startup, the system will automatically
|
||||
// reset to finish the initialization process.
|
||||
if (sys.abort) {
|
||||
|
||||
// Clear all system variables
|
||||
memset(&sys, 0, sizeof(sys));
|
||||
|
||||
// Reset system.
|
||||
serial_reset_read_buffer(); // Clear serial read buffer
|
||||
@ -70,19 +63,14 @@ int main(void)
|
||||
gc_init(); // Set g-code parser to default state
|
||||
spindle_init();
|
||||
limits_init();
|
||||
|
||||
// TODO: For now, the stepper subsystem tracks the absolute stepper position from the point
|
||||
// of power up or hard reset. This reset is a soft reset, where the information of the current
|
||||
// position is not lost after a system abort. This is not guaranteed to be correct, since
|
||||
// during an abort, the steppers can lose steps in the immediate stop. However, if a feed
|
||||
// hold is performed before a system abort, this position should be correct. In the next few
|
||||
// updates, this soft reset feature will be fleshed out along with the status reporting and
|
||||
// jogging features.
|
||||
st_reset(); // Clear stepper subsystem variables. Machine position variable is not reset.
|
||||
|
||||
// Print grbl initialization message
|
||||
printPgmString(PSTR("\r\nGrbl " GRBL_VERSION));
|
||||
printPgmString(PSTR("\r\n'$' to dump current settings\r\n"));
|
||||
st_reset(); // Clear stepper subsystem variables.
|
||||
|
||||
// Set system runtime defaults
|
||||
// TODO: Eventual move to EEPROM from config.h when all of the new settings are worked out.
|
||||
// Mainly to avoid having to maintain several different versions.
|
||||
#ifdef CYCLE_AUTO_START
|
||||
sys.auto_start = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
protocol_execute_runtime();
|
||||
|
Reference in New Issue
Block a user