diff --git a/Makefile b/Makefile index 802f17b..362b134 100644 --- a/Makefile +++ b/Makefile @@ -96,7 +96,7 @@ PROGBAUD = 57600 PROGRAM = mendel -SOURCES = $(PROGRAM).c serial.c dda.c gcode_parse.c gcode_process.c timer.c temp.c sermsg.c dda_queue.c watchdog.c debug.c sersendf.c heater.c analog.c delay.c intercom.c pinio.c +SOURCES = $(PROGRAM).c serial.c dda.c gcode_parse.c gcode_process.c timer.c temp.c sermsg.c dda_queue.c watchdog.c debug.c sersendf.c heater.c analog.c delay.c intercom.c pinio.c clock.c ARCH = avr- CC = $(ARCH)gcc diff --git a/clock.c b/clock.c new file mode 100644 index 0000000..01bcbf1 --- /dev/null +++ b/clock.c @@ -0,0 +1,45 @@ +#include "clock.h" + +#include "pinio.h" +#include "sersendf.h" +#include "dda_queue.h" +#include "watchdog.h" +#include "temp.h" +#include "timer.h" +#include "debug.h" + +void clock_250ms() { + if (steptimeout > (30 * 4)) { + power_off(); + } + else + steptimeout++; + + ifclock(CLOCK_FLAG_1S) { + if (debug_flags & DEBUG_POSITION) { + // current position + sersendf_P(PSTR("Pos: %ld,%ld,%ld,%ld,%lu\n"), current_position.X, current_position.Y, current_position.Z, current_position.E, current_position.F); + + // target position + sersendf_P(PSTR("Dst: %ld,%ld,%ld,%ld,%lu\n"), movebuffer[mb_tail].endpoint.X, movebuffer[mb_tail].endpoint.Y, movebuffer[mb_tail].endpoint.Z, movebuffer[mb_tail].endpoint.E, movebuffer[mb_tail].endpoint.F); + + // Queue + print_queue(); + } + // temperature + /* if (temp_get_target()) + temp_print();*/ + } +} + +void clock_10ms() { + // reset watchdog + wd_reset(); + + temp_tick(); + + ifclock(CLOCK_FLAG_250MS) { + clock_250ms(); + } +} + diff --git a/clock.h b/clock.h new file mode 100644 index 0000000..daf4023 --- /dev/null +++ b/clock.h @@ -0,0 +1,7 @@ +#ifndef _CLOCK_H +#define _CLOCK_H + +void clock_250ms(void); +void clock_10ms(void); + +#endif /* _CLOCK_H */ diff --git a/mendel.c b/mendel.c index 0e5d0cc..919822b 100644 --- a/mendel.c +++ b/mendel.c @@ -18,6 +18,7 @@ #include "analog.h" #include "pinio.h" #include "arduino.h" +#include "clock.h" void io_init(void) { // disable modules we don't use @@ -150,41 +151,6 @@ void init(void) { } -void clock_250ms(void) { - if (steptimeout > (30 * 4)) { - power_off(); - } - else - steptimeout++; - - ifclock(CLOCK_FLAG_1S) { - if (debug_flags & DEBUG_POSITION) { - // current position - sersendf_P(PSTR("Pos: %ld,%ld,%ld,%ld,%lu\n"), current_position.X, current_position.Y, current_position.Z, current_position.E, current_position.F); - - // target position - sersendf_P(PSTR("Dst: %ld,%ld,%ld,%ld,%lu\n"), movebuffer[mb_tail].endpoint.X, movebuffer[mb_tail].endpoint.Y, movebuffer[mb_tail].endpoint.Z, movebuffer[mb_tail].endpoint.E, movebuffer[mb_tail].endpoint.F); - - // Queue - print_queue(); - } - // temperature -/* if (temp_get_target()) - temp_print();*/ - } -} - -void clock_10ms(void) { - // reset watchdog - wd_reset(); - - temp_tick(); - - ifclock(CLOCK_FLAG_250MS) { - clock_250ms(); - } -} - int main (void) { init();