Canned G-code: implement continuous replay of G-code stored on flash.
This commit is contained in:
parent
0723b53c44
commit
aed4bfdb5b
|
|
@ -49,7 +49,7 @@ OBJDUMP = $(TOOLCHAIN)objdump
|
|||
OBJCOPY = $(TOOLCHAIN)objcopy
|
||||
|
||||
|
||||
OBJ = $(patsubst %.c,$(BUILDDIR)/%.o,$(SOURCES))
|
||||
OBJ = $(patsubst %.c,$(BUILDDIR)/%.o,$(SOURCES)) $(BUILDDIR)/canned_gcode.o
|
||||
|
||||
.PHONY: all clean doc functionsbysize
|
||||
.PRECIOUS: %.o %.elf
|
||||
|
|
@ -57,7 +57,7 @@ OBJ = $(patsubst %.c,$(BUILDDIR)/%.o,$(SOURCES))
|
|||
all: $(BUILDDIR) $(TARGET)
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILDDIR) $(TARGET) *~
|
||||
rm -rf $(BUILDDIR) $(TARGET) *~ canned_gcode.c
|
||||
|
||||
doc: Doxyfile *.c *.h
|
||||
doxygen $<
|
||||
|
|
@ -107,3 +107,11 @@ $(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 "\";" >> $@
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
G28
|
||||
G1 X100
|
||||
G1 X0
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
#include <avr/pgmspace.h>
|
||||
|
||||
extern const char canned_gcode_P[] PROGMEM;
|
||||
38
mendel.c
38
mendel.c
|
|
@ -254,13 +254,45 @@ int main (void)
|
|||
#endif
|
||||
init();
|
||||
|
||||
#ifdef CANNED_CYCLE
|
||||
#include "canned_gcode.h"
|
||||
uint32_t canned_gcode_pos = 0;
|
||||
#endif /* CANNED_CYCLE */
|
||||
|
||||
// main loop
|
||||
for (;;)
|
||||
{
|
||||
// if queue is full, no point in reading chars- host will just have to wait
|
||||
if ((serial_rxchars() != 0) && (queue_full() == 0)) {
|
||||
uint8_t c = serial_popchar();
|
||||
gcode_parse_char(c);
|
||||
if (queue_full() == 0) {
|
||||
if (serial_rxchars() != 0) {
|
||||
uint8_t c = serial_popchar();
|
||||
gcode_parse_char(c);
|
||||
}
|
||||
|
||||
#ifdef CANNED_CYCLE
|
||||
/**
|
||||
WARNING!
|
||||
|
||||
This code works on a per-character basis.
|
||||
|
||||
Any data received over serial WILL be randomly distributed through
|
||||
the canned gcode, and you'll have a big mess!
|
||||
|
||||
The solution is to either store gcode parser state with each source,
|
||||
or only parse a line at a time.
|
||||
|
||||
This will take extra ram, and may be out of scope for the Teacup
|
||||
project.
|
||||
|
||||
If ever print-from-SD card is implemented, these changes may become
|
||||
necessary.
|
||||
*/
|
||||
if (pgm_read_byte(canned_gcode_P[++canned_gcode_pos]) == 0)
|
||||
canned_gcode_pos = 0;
|
||||
else
|
||||
gcode_parse_char(pgm_read_byte(canned_gcode_P[canned_gcode_pos]));
|
||||
|
||||
#endif /* CANNED_CYCLE */
|
||||
}
|
||||
|
||||
clock();
|
||||
|
|
|
|||
Loading…
Reference in New Issue