feat: add version as apart of build info

pull/1276/head
Noah Gaeta 2024-12-06 12:04:56 -05:00
rodzic 6e01b7ac97
commit c2e42f2475
5 zmienionych plików z 54 dodań i 18 usunięć

Wyświetl plik

@ -3,6 +3,7 @@ SRC_DIR = $(PROJECT_NAME)
INO_FILE = $(PROJECT_NAME)/grbl.ino
BUILD_DIR = build
BOARD = arduino:avr:uno
VERSION = 1.2h
PORT = $(shell ls /dev/cu.usbmodem* 2>/dev/null | head -n 1)
@ -14,17 +15,23 @@ all: build_rcmini build_bamboo
.PHONY: build_rcmini
build_rcmini:
@mkdir -p $(BUILD_DIR)
@arduino-cli compile --fqbn $(BOARD) --build-path $(BUILD_DIR)/rcmini --build-property compiler.cpp.extra_flags="-DMACHINE_TYPE=RCMINI" $(INO_FILE)
@mv $(BUILD_DIR)/rcmini/$(PROJECT_NAME).ino.hex $(BUILD_DIR)/rcmini.hex
@echo "Built RC Mini firmware: $(BUILD_DIR)/rcmini.hex"
@arduino-cli compile --fqbn $(BOARD) \
--build-path $(BUILD_DIR)/rcmini \
--build-property "build.extra_flags=-DMACHINE_TYPE=RCMINI -DGRBL_VERSION=\"$(VERSION)\"" \
$(INO_FILE)
@cp $(BUILD_DIR)/rcmini/$(PROJECT_NAME).ino.hex $(BUILD_DIR)/rcmini$(VERSION).hex
@echo "Built RC Mini firmware: $(BUILD_DIR)/rcmini$(VERSION).hex"
# Build target for Bamboo
.PHONY: build_bamboo
build_bamboo:
@mkdir -p $(BUILD_DIR)
@arduino-cli compile --fqbn $(BOARD) --build-path $(BUILD_DIR)/bamboo --build-property compiler.cpp.extra_flags="-DMACHINE_TYPE=BAMBOO" $(INO_FILE)
@mv $(BUILD_DIR)/bamboo/$(PROJECT_NAME).ino.hex $(BUILD_DIR)/bamboo.hex
@echo "Built Bamboo firmware: $(BUILD_DIR)/bamboo.hex"
@arduino-cli compile --fqbn $(BOARD) \
--build-path $(BUILD_DIR)/bamboo \
--build-property "build.extra_flags=-DMACHINE_TYPE=BAMBOO -DGRBL_VERSION=\"$(VERSION)\"" \
$(INO_FILE)
@cp $(BUILD_DIR)/bamboo/$(PROJECT_NAME).ino.hex $(BUILD_DIR)/bamboo$(VERSION).hex
@echo "Built Bamboo firmware: $(BUILD_DIR)/bamboo$(VERSION).hex"
# Flash RC Mini firmware
.PHONY: flash_rcmini

Wyświetl plik

@ -36,7 +36,7 @@ typedef enum {
// ? Default machine type to RCMINI if not provided by compiler
#ifndef MACHINE_TYPE
#define MACHINE_TYPE RCMINI
#error "Must define MACHINE_TYPE in compiler options"
#endif
// Define CPU pin map and default settings.

Wyświetl plik

@ -22,7 +22,10 @@
#define grbl_h
// Grbl versioning system
#define GRBL_VERSION "1.2h"
#ifndef GRBL_VERSION
#error "Must define GRBL_VERSION in compiler options"
#endif
#define GRBL_VERSION_BUILD "20190830"
// Define standard libraries used by Grbl.

Wyświetl plik

@ -366,11 +366,35 @@ void report_execute_startup_message(char *line, uint8_t status_code)
report_status_message(status_code);
}
const char* machine_type_to_string(int type) {
switch (type) {
case RCMINI:
return "RCMINI";
case BAMBOO:
return "BAMBOO";
default:
return "UNKNOWN";
}
}
void print_version() {
// Create a buffer for the resulting string
char versionStr[100]; // Make sure the buffer is large enough
// Get the machine name using the switch function
const char* MACHINE_NAME = machine_type_to_string(MACHINE_TYPE);
// Concatenate the parts into the buffer
snprintf(versionStr, sizeof(versionStr), "[VER:%s.%s:%s", GRBL_VERSION, GRBL_VERSION_BUILD, MACHINE_NAME);
printString(versionStr);
}
// Prints build info line
void report_build_info(char *line)
{
printPgmString(PSTR("[VER:" GRBL_VERSION "." GRBL_VERSION_BUILD ":"));
printString(line);
print_version();
report_util_feedback_line_feed();
printPgmString(PSTR("[OPT:")); // Generate compile-time build option list
#ifdef VARIABLE_SPINDLE

Wyświetl plik

@ -43,14 +43,16 @@ void spi_write(uint8_t cs_port, uint8_t cs_pin, uint8_t address, uint8_t data) {
* 111b = Smart tune Ripple Control
*/
void motor_spi_init() {
// Configure Chip Select pins as outputs
DDRC |= (1 << CS1_PIN) | (1 << CS2_PIN);
CS1_PORT |= (1 << CS1_PIN); // Set CS high (deselect)
CS2_PORT |= (1 << CS2_PIN); // Set CS high (deselect)
if (MACHINE_TYPE == BAMBOO) {
// Configure Chip Select pins as outputs
DDRC |= (1 << CS1_PIN) | (1 << CS2_PIN);
CS1_PORT |= (1 << CS1_PIN); // Set CS high (deselect)
CS2_PORT |= (1 << CS2_PIN); // Set CS high (deselect)
// Send configuration to Driver 1
spi_write(CS1_PORT, CS1_PIN, 0x04, 0x07);
// Send configuration to Driver 1
spi_write(CS1_PORT, CS1_PIN, 0x04, 0x07);
// Send configuration to Driver 2
spi_write(CS2_PORT, CS2_PIN, 0x04, 0x07);
// Send configuration to Driver 2
spi_write(CS2_PORT, CS2_PIN, 0x04, 0x07);
}
}