Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
split up dda and its queue, moved clock tick functions from main loop…
… so I can call them from M101 while waiting for heater to reach target temperature, added thermal hysteresis setting
- Loading branch information
Showing
12 changed files
with
270 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#include "dda_queue.h" | ||
|
||
#include "timer.h" | ||
#include "serial.h" | ||
#include "sermsg.h" | ||
|
||
uint8_t mb_head = 0; | ||
uint8_t mb_tail = 0; | ||
DDA movebuffer[MOVEBUFFER_SIZE]; | ||
|
||
|
||
uint8_t queue_full() { | ||
if (mb_tail == 0) | ||
return mb_head == (MOVEBUFFER_SIZE - 1); | ||
else | ||
return mb_head == (mb_tail - 1); | ||
} | ||
|
||
uint8_t queue_empty() { | ||
return ((mb_tail == mb_head) && (movebuffer[mb_tail].live == 0))?255:0; | ||
} | ||
|
||
void enqueue(TARGET *t) { | ||
while (queue_full()) | ||
delay(WAITING_DELAY); | ||
|
||
uint8_t h = mb_head; | ||
h++; | ||
if (h == MOVEBUFFER_SIZE) | ||
h = 0; | ||
|
||
dda_create(&movebuffer[h], t); | ||
|
||
// if queue only has one space left, stop transmition | ||
if (((h + 2) & (MOVEBUFFER_SIZE - 1)) == mb_tail) | ||
xoff(); | ||
|
||
mb_head = h; | ||
|
||
// fire up in case we're not running yet | ||
enableTimerInterrupt(); | ||
} | ||
|
||
void next_move() { | ||
if (queue_empty()) { | ||
// queue is empty | ||
// disable_steppers(); | ||
// setTimer(DEFAULT_TICK); | ||
disableTimerInterrupt(); | ||
} | ||
else { | ||
uint8_t t = mb_tail; | ||
t++; | ||
if (t == MOVEBUFFER_SIZE) | ||
t = 0; | ||
dda_start(&movebuffer[t]); | ||
mb_tail = t; | ||
} | ||
// restart transmission | ||
xon(); | ||
} | ||
|
||
void print_queue() { | ||
serial_writechar('Q'); | ||
serwrite_uint8(mb_tail); | ||
serial_writechar('/'); | ||
serwrite_uint8(mb_head); | ||
if (queue_full()) | ||
serial_writechar('F'); | ||
if (queue_empty()) | ||
serial_writechar('E'); | ||
serial_writechar('\n'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#ifndef _DDA_QUEUE | ||
#define _DDA_QUEUE | ||
|
||
#include "dda.h" | ||
|
||
/* | ||
variables | ||
*/ | ||
|
||
extern uint8_t mb_head; | ||
extern uint8_t mb_tail; | ||
extern DDA movebuffer[MOVEBUFFER_SIZE]; | ||
|
||
/* | ||
methods | ||
*/ | ||
|
||
uint8_t queue_full(void); | ||
uint8_t queue_empty(void); | ||
void enqueue(TARGET *t); | ||
void next_move(void); | ||
void print_queue(void); | ||
|
||
#endif /* _DDA_QUEUE */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.