Skip to content

Commit

Permalink
New build info feature. (per @Analogreality request)
Browse files Browse the repository at this point in the history
- New build info feature. Hidden command ‘$I’ will print the build info
for your Grbl firmware. Users may also write an identifying message
within it via ‘$I=‘ with up to 32 characters. (no more, or else it will
break).

- Adjusted the max number of startup lines to 3. Majority of people
will only need one.

- Fixed a compile error with spindle_control.c. A rogue #endif was
causing problems.
  • Loading branch information
chamnit committed Jan 5, 2014
1 parent 1baff78 commit 3c3382f
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 5 deletions.
4 changes: 2 additions & 2 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@
#define N_HOMING_LOCATE_CYCLE 2 // Integer (1-128)

// Number of blocks Grbl executes upon startup. These blocks are stored in EEPROM, where the size
// and addresses are defined in settings.h. With the current settings, up to 5 startup blocks may
// and addresses are defined in settings.h. With the current settings, up to 3 startup blocks may
// be stored and executed in order. These startup blocks would typically be used to set the g-code
// parser state depending on user preferences.
#define N_STARTUP_LINE 2 // Integer (1-5)
#define N_STARTUP_LINE 2 // Integer (1-3)

// ---------------------------------------------------------------------------------------
// ADVANCED CONFIGURATION OPTIONS:
Expand Down
16 changes: 16 additions & 0 deletions protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,22 @@ uint8_t protocol_execute_line(char *line)
if (!sys.abort) { protocol_execute_startup(); } // Execute startup scripts after successful homing.
} else { return(STATUS_SETTING_DISABLED); }
break;
case 'I' : // Print or store build info.
if ( line[++char_counter] == 0 ) {
if (!(settings_read_build_info(line))) {
report_status_message(STATUS_SETTING_READ_FAIL);
} else {
report_build_info(line);
}
} else { // Store startup line
if(line[char_counter++] != '=') { return(STATUS_UNSUPPORTED_STATEMENT); }
helper_var = char_counter; // Set helper variable as counter to start of user info line.
do {
line[char_counter-helper_var] = line[char_counter];
} while (line[char_counter++] != 0);
settings_store_build_info(line);
}
break;
case 'N' : // Startup lines.
if ( line[++char_counter] == 0 ) { // Print startup lines
for (helper_var=0; helper_var < N_STARTUP_LINE; helper_var++) {
Expand Down
12 changes: 11 additions & 1 deletion report.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void report_feedback_message(uint8_t message_code)
// Welcome message
void report_init_message()
{
printPgmString(PSTR("\r\nGrbl " GRBL_VERSION " ("GRBL_VERSION_BUILD ") ['$' for help]\r\n"));
printPgmString(PSTR("\r\nGrbl " GRBL_VERSION " ['$' for help]\r\n"));
}

// Grbl help message
Expand Down Expand Up @@ -292,6 +292,16 @@ void report_startup_line(uint8_t n, char *line)
printPgmString(PSTR("\r\n"));
}


// Prints build info line
void report_build_info(char *line)
{
printPgmString(PSTR("[" GRBL_VERSION "." GRBL_VERSION_BUILD ":"));
printString(line);
printPgmString(PSTR("]\r\n"));
}


// Prints real-time data. This function grabs a real-time snapshot of the stepper subprogram
// and the actual location of the CNC machine. Users may change the following function to their
// specific needs, but the desired real-time data report must be as short as possible. This is
Expand Down
3 changes: 3 additions & 0 deletions report.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,7 @@ void report_gcode_modes();
// Prints startup line
void report_startup_line(uint8_t n, char *line);

// Prints build info and user info
void report_build_info(char *line);

#endif
19 changes: 19 additions & 0 deletions settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ void settings_store_startup_line(uint8_t n, char *line)
memcpy_to_eeprom_with_checksum(addr,(char*)line, LINE_BUFFER_SIZE);
}

// Method to store build info into EEPROM
void settings_store_build_info(char *line)
{
memcpy_to_eeprom_with_checksum(EEPROM_ADDR_BUILD_INFO,(char*)line, LINE_BUFFER_SIZE);
}

// Method to store coord data parameters into EEPROM
void settings_write_coord_data(uint8_t coord_select, float *coord_data)
{
Expand Down Expand Up @@ -120,6 +126,19 @@ uint8_t settings_read_startup_line(uint8_t n, char *line)
}
}

// Reads startup line from EEPROM. Updated pointed line string data.
uint8_t settings_read_build_info(char *line)
{
if (!(memcpy_from_eeprom_with_checksum((char*)line, EEPROM_ADDR_BUILD_INFO, LINE_BUFFER_SIZE))) {
// Reset line with default value
line[0] = 0;
settings_store_build_info(line);
return(false);
} else {
return(true);
}
}

// Read selected coordinate data from EEPROM. Updates pointed coord_data value.
uint8_t settings_read_coord_data(uint8_t coord_select, float *coord_data)
{
Expand Down
5 changes: 5 additions & 0 deletions settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#define EEPROM_ADDR_GLOBAL 1
#define EEPROM_ADDR_PARAMETERS 512
#define EEPROM_ADDR_STARTUP_BLOCK 768
#define EEPROM_ADDR_BUILD_INFO 992

// Define EEPROM address indexing for coordinate parameters
#define N_COORDINATE_SYSTEM 6 // Number of supported work coordinate systems (from index 1)
Expand Down Expand Up @@ -93,6 +94,10 @@ void settings_store_startup_line(uint8_t n, char *line);
// Reads an EEPROM startup line to the protocol line variable
uint8_t settings_read_startup_line(uint8_t n, char *line);

void settings_store_build_info(char *line);

uint8_t settings_read_build_info(char *line);

// Writes selected coordinate data to EEPROM
void settings_write_coord_data(uint8_t coord_select, float *coord_data);

Expand Down
2 changes: 0 additions & 2 deletions spindle_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,3 @@ void spindle_run(int8_t direction, uint16_t rpm)
current_rpm = rpm;
}
}

#endif

0 comments on commit 3c3382f

Please sign in to comment.