diff --git a/Makefile b/Makefile index 839ec06..578f5ec 100644 --- a/Makefile +++ b/Makefile @@ -42,8 +42,14 @@ FUSES = -U hfuse:w:0xd2:m -U lfuse:w:0xff:m # Tune the lines below only if you know what you are doing: AVRDUDE = avrdude $(PROGRAMMER) -p $(DEVICE) -B 10 -F + +# Compile flags for avr-gcc v4.8.1. Does not produce -flto warnings. COMPILE = avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE) -I. -ffunction-sections +# Compile flags for avr-gcc v4.9.2 compatible with the IDE. Or if you don't care about the warnings. +# COMPILE = avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE) -I. -ffunction-sections -flto + + OBJECTS = $(addprefix $(BUILDDIR)/,$(notdir $(SOURCE:.c=.o))) # symbolic targets: diff --git a/doc/log/commit_log_v1.1.txt b/doc/log/commit_log_v1.1.txt index 1efad5f..a846e03 100644 --- a/doc/log/commit_log_v1.1.txt +++ b/doc/log/commit_log_v1.1.txt @@ -1,3 +1,21 @@ +---------------- +Date: 2016-09-24 +Author: Sonny Jeon +Subject: Serial RX count bug fix. Settings codes CSV. More documentation. + +- Reverted back the serial RX count function to how it was. The +variable type was unsigned and cause an integer underflow whenever the +calculation produced a negative number. The old way was the correct way. + +- Lots of minor edits to the code CSVs and markdown documents. + +- Expanded on explaining feedback messages and startup line execution +feedback. + +- Created a new settings codes CSV to help GUIs import the values and +meanings. + + ---------------- Date: 2016-09-22 Author: Sonny Jeon diff --git a/grbl/grbl.h b/grbl/grbl.h index 113a692..8fa00f3 100644 --- a/grbl/grbl.h +++ b/grbl/grbl.h @@ -23,7 +23,7 @@ // Grbl versioning system #define GRBL_VERSION "1.1a" -#define GRBL_VERSION_BUILD "20160922" +#define GRBL_VERSION_BUILD "20160925" // Define standard libraries used by Grbl. #include diff --git a/grbl/print.c b/grbl/print.c index 1a39ae0..7b753d1 100644 --- a/grbl/print.c +++ b/grbl/print.c @@ -173,7 +173,6 @@ void printFloat(float n, uint8_t decimal_places) // in the config.h. // - CoordValue: Handles all position or coordinate values in inches or mm reporting. // - RateValue: Handles feed rate and current velocity in inches or mm reporting. -// - SettingValue: Handles all floating point settings values (always in mm.) void printFloat_CoordValue(float n) { if (bit_istrue(settings.flags,BITFLAG_REPORT_INCHES)) { printFloat(n*INCH_PER_MM,N_DECIMAL_COORDVALUE_INCH); @@ -190,10 +189,6 @@ void printFloat_RateValue(float n) { } } -// void printFloat_SettingValue(float n) { printFloat(n,N_DECIMAL_SETTINGVALUE); } - -void printFloat_RPMValue(float n) { printFloat(n,N_DECIMAL_RPMVALUE); } - // Debug tool to print free memory in bytes at the called point. // NOTE: Keep commented unless using. Part of this function always gets compiled in. // void printFreeMemory() diff --git a/grbl/print.h b/grbl/print.h index ad1e2aa..31e0a57 100644 --- a/grbl/print.h +++ b/grbl/print.h @@ -42,12 +42,8 @@ void printFloat(float n, uint8_t decimal_places); // Floating value printing handlers for special variables types used in Grbl. // - CoordValue: Handles all position or coordinate values in inches or mm reporting. // - RateValue: Handles feed rate and current velocity in inches or mm reporting. -// - SettingValue: Handles all floating point settings values (always in mm.) -// - RPMValue: Handles spindle RPM values in settings and reports. void printFloat_CoordValue(float n); void printFloat_RateValue(float n); -// void printFloat_SettingValue(float n); -void printFloat_RPMValue(float n); // Debug tool to print free memory in bytes at the called point. Not used otherwise. void printFreeMemory(); diff --git a/grbl/report.c b/grbl/report.c index befb091..c13bc75 100644 --- a/grbl/report.c +++ b/grbl/report.c @@ -29,6 +29,22 @@ #include "grbl.h" +// Internal report utilities to reduce flash with repetitive tasks turned into functions. +static void report_util_line_feed() { printPgmString(PSTR("\r\n")); } +static void report_util_feedback_line_feed() { serial_write(']'); report_util_line_feed(); } +void report_util_setting_prefix(uint8_t n) { serial_write('$'); print_uint8_base10(n); serial_write('='); } +static void report_util_uint8_setting(uint8_t n, int val) { report_util_setting_prefix(n); print_uint8_base10(val); report_util_line_feed(); } +static void report_util_float_setting(uint8_t n, float val) { report_util_setting_prefix(n); printFloat(val,N_DECIMAL_SETTINGVALUE); report_util_line_feed(); } +static void report_util_rpm_setting(uint8_t n, float val) { report_util_setting_prefix(n); printFloat(val,N_DECIMAL_RPMVALUE); report_util_line_feed(); } +static void report_util_axis_values(float *axis_value) { + uint8_t idx; + for (idx=0; idx'); - printString(line); // Echo startup line to indicate execution. + printString(line); serial_write(':'); report_status_message(status_code); } @@ -506,7 +495,7 @@ void report_build_info(char *line) { printPgmString(PSTR("[VER:" GRBL_VERSION "." GRBL_VERSION_BUILD ":")); printString(line); - printPgmString(PSTR("]\r\n")); + report_util_feedback_line_feed(); } @@ -515,7 +504,7 @@ void report_build_info(char *line) void report_echo_line_received(char *line) { printPgmString(PSTR("[echo: ")); printString(line); - printPgmString(PSTR("]\r\n")); + report_util_feedback_line_feed(); } @@ -700,22 +689,39 @@ void report_realtime_status() // break; } - // Report machine position + float wco[N_AXIS]; + if (bit_isfalse(settings.status_report_mask,BITFLAG_RT_STATUS_POSITION_TYPE) || + (sys.report_wco_counter >= REPORT_WCO_REFRESH_BUSY_COUNT) ) { + for (idx=0; idx< N_AXIS; idx++) { + // Apply work coordinate offsets and tool length offset to current position. + wco[idx] = gc_state.coord_system[idx]+gc_state.coord_offset[idx]; + if (idx == TOOL_LENGTH_OFFSET_AXIS) { wco[idx] += gc_state.tool_length_offset; } + if (bit_isfalse(settings.status_report_mask,BITFLAG_RT_STATUS_POSITION_TYPE)) { + print_position[idx] -= wco[idx]; + } + } + } + if (bit_istrue(settings.status_report_mask,BITFLAG_RT_STATUS_POSITION_TYPE)) { printPgmString(PSTR("|MPos:")); } else { - // Report work position printPgmString(PSTR("|WPos:")); - for (idx=0; idx< N_AXIS; idx++) { - // Apply work coordinate offsets and tool length offset to current position. - print_position[idx] -= gc_state.coord_system[idx]+gc_state.coord_offset[idx]; - if (idx == TOOL_LENGTH_OFFSET_AXIS) { print_position[idx] -= gc_state.tool_length_offset; } - } - } - for (idx=0; idx< N_AXIS; idx++) { - printFloat_CoordValue(print_position[idx]); - if (idx < (N_AXIS-1)) { serial_write(','); } } + report_util_axis_values(print_position); + + // Report machine position + // if (bit_istrue(settings.status_report_mask,BITFLAG_RT_STATUS_POSITION_TYPE)) { + // printPgmString(PSTR("|MPos:")); + // } else { + // // Report work position + // printPgmString(PSTR("|WPos:")); + // for (idx=0; idx< N_AXIS; idx++) { + // // Apply work coordinate offsets and tool length offset to current position. + // print_position[idx] -= gc_state.coord_system[idx]+gc_state.coord_offset[idx]; + // if (idx == TOOL_LENGTH_OFFSET_AXIS) { print_position[idx] -= gc_state.tool_length_offset; } + // } + // } + // report_util_axis_values(print_position); // Returns planner and serial read buffer states. #ifdef REPORT_FIELD_BUFFER_STATE @@ -777,15 +783,25 @@ void report_realtime_status() sys.report_ovr_counter = (REPORT_OVR_REFRESH_BUSY_COUNT-1); // Set override on next report. } printPgmString(PSTR("|WCO:")); - float axis_offset; - uint8_t idx; - for (idx=0; idx= REPORT_WCO_REFRESH_BUSY_COUNT) { + // if (sys.state & (STATE_HOMING | STATE_CYCLE | STATE_HOLD | STATE_JOG | STATE_SAFETY_DOOR)) { + // sys.report_wco_counter = 1; // Reset counter for slow refresh + // } else { sys.report_wco_counter = (REPORT_WCO_REFRESH_BUSY_COUNT-REPORT_WCO_REFRESH_IDLE_COUNT+1); } + // if (sys.report_ovr_counter >= REPORT_OVR_REFRESH_BUSY_COUNT) { + // sys.report_ovr_counter = (REPORT_OVR_REFRESH_BUSY_COUNT-1); // Set override on next report. + // } + // printPgmString(PSTR("|WCO:")); + // float axis_offset; + // uint8_t idx; + // for (idx=0; idx\r\n")); + serial_write('>'); + report_util_line_feed(); #endif }