Canned G-code: setup right in config.h.

This works with Arduino IDE as well and should be easier to figure
for inexperienced users.
This commit is contained in:
Markus Hitter 2014-08-30 13:03:34 +02:00
parent 7f990a298c
commit 5cc84a069a
6 changed files with 39 additions and 21 deletions

View File

@ -49,7 +49,7 @@ OBJDUMP = $(TOOLCHAIN)objdump
OBJCOPY = $(TOOLCHAIN)objcopy
OBJ = $(patsubst %.c,$(BUILDDIR)/%.o,$(SOURCES)) $(BUILDDIR)/canned_gcode.o
OBJ = $(patsubst %.c,$(BUILDDIR)/%.o,$(SOURCES))
.PHONY: all clean doc functionsbysize
.PRECIOUS: %.o %.elf
@ -57,7 +57,7 @@ OBJ = $(patsubst %.c,$(BUILDDIR)/%.o,$(SOURCES)) $(BUILDDIR)/canned_gcode.o
all: $(BUILDDIR) $(TARGET)
clean:
rm -rf $(BUILDDIR) $(TARGET) *~ canned_gcode.c
rm -rf $(BUILDDIR) $(TARGET) *~
doc: Doxyfile *.c *.h
doxygen $<
@ -107,11 +107,3 @@ $(BUILDDIR)/%.bin: $(BUILDDIR)/%.elf
$(BUILDDIR)/%.sym: $(BUILDDIR)/%.elf
@echo " SYM $@"
@$(OBJDUMP) -t $< | perl -ne 'BEGIN { printf " ADDR NAME SIZE\n"; } /([0-9a-f]+)\s+(\w+)\s+O\s+\.(bss|data)\s+([0-9a-f]+)\s+(\w+)/ && printf "0x%04x %-20s +%d\n", eval("0x$$1") & 0xFFFF, $$5, eval("0x$$4")' | sort -k1 > $@
canned_gcode.c: canned_gcode.g
@echo " GEN $@"
@echo "#include \"canned_gcode.h\"" > $@
@echo "" >> $@
@echo -n "const char canned_gcode_P[] PROGMEM = \"" >> $@
@perl -pe 's/\n/\\n/gs' $< >> $@
@echo "\";" >> $@

View File

@ -1,3 +0,0 @@
G28
G1 X100
G1 X0

View File

@ -1,3 +0,0 @@
#include <avr/pgmspace.h>
extern const char canned_gcode_P[] PROGMEM;

View File

@ -571,6 +571,22 @@ PWM value for 'off'
*/
#define ENDSTOP_STEPS 4
/** \def CANNED_CYCLE
G-code commands in this string will be executed over and over again, without
user interaction or even a serial connection. It's purpose is e.g. for
exhibitions or when using Teacup for other purposes than printing. You can
add any G-code supported by Teacup.
Note: don't miss these newlines (\n) and backslashes (\).
*/
/*
#define CANNED_CYCLE "G1 X100 F3000\n" \
"G4 P500\n" \
"G1 X0\n" \
"G4 P500\n"
*/
/***************************************************************************\

View File

@ -58,6 +58,10 @@
SIMINFO_SERIAL_OUT("D1", "-", BAUD);
#endif
#ifdef CANNED_CYCLE
const char PROGMEM canned_gcode_P[] = CANNED_CYCLE;
#endif
/// initialise all I/O - set pins as input or output, turn off unused subsystems, etc
void io_init(void) {
// disable modules we don't use
@ -254,11 +258,6 @@ int main (void)
#endif
init();
#ifdef CANNED_CYCLE
#include "canned_gcode.h"
uint32_t canned_gcode_pos = 0;
#endif /* CANNED_CYCLE */
// main loop
for (;;)
{
@ -287,6 +286,8 @@ int main (void)
If ever print-from-SD card is implemented, these changes may become
necessary.
*/
static uint32_t canned_gcode_pos = 0;
gcode_parse_char(pgm_read_byte(&(canned_gcode_P[canned_gcode_pos])));
canned_gcode_pos++;

View File

@ -570,6 +570,21 @@ PWM value for 'off'
*/
#define ENDSTOP_STEPS 4
/** \def CANNED_CYCLE
G-code commands in this string will be executed over and over again, without
user interaction or even a serial connection. It's purpose is e.g. for
exhibitions or when using Teacup for other purposes than printing. You can
add any G-code supported by Teacup.
Note: don't miss these newlines (\n) and backslashes (\).
*/
/*
#define CANNED_CYCLE "G1 X100 F3000\n" \
"G4 P500\n" \
"G1 X0\n" \
"G4 P500\n"
*/
/***************************************************************************\