some code cleanup, added M114, wrapped M25[0..5] in ifdef DEBUG wrapper

This commit is contained in:
Michael Moon 2010-09-12 12:54:58 +10:00
parent c46db07f26
commit 48cf0e05d7
4 changed files with 20 additions and 31 deletions

View File

@ -91,9 +91,6 @@ void enqueue_temp_wait() {
delay(WAITING_DELAY); delay(WAITING_DELAY);
uint8_t h = mb_head + 1; uint8_t h = mb_head + 1;
// h++;
// if (h == MOVEBUFFER_SIZE)
// h = 0;
h &= (MOVEBUFFER_SIZE - 1); h &= (MOVEBUFFER_SIZE - 1);
// wait for temp flag // wait for temp flag
@ -122,9 +119,6 @@ void next_move() {
if (queue_empty() == 0) { if (queue_empty() == 0) {
// next item // next item
uint8_t t = mb_tail + 1; uint8_t t = mb_tail + 1;
// t++;
// if (t == MOVEBUFFER_SIZE)
// t = 0;
t &= (MOVEBUFFER_SIZE - 1); t &= (MOVEBUFFER_SIZE - 1);
dda_start(&movebuffer[t]); dda_start(&movebuffer[t]);
mb_tail = t; mb_tail = t;

16
gcode.c
View File

@ -627,7 +627,19 @@ void process_gcode_command(GCODE_COMMAND *gcmd) {
break; break;
// M113- extruder PWM // M113- extruder PWM
// M114- report XYZEF to host // M114- report XYZEF to host
case 114:
serial_writestr_P(PSTR("X:"));
serwrite_int32(current_position.X);
serial_writestr_P(PSTR(",Y:"));
serwrite_int32(current_position.Y);
serial_writestr_P(PSTR(",Z:"));
serwrite_int32(current_position.Z);
serial_writestr_P(PSTR(",E:"));
serwrite_int32(current_position.E);
serial_writestr_P(PSTR(",F:"));
serwrite_int32(current_position.F);
serial_writechar('\n');
break;
// M130- heater P factor // M130- heater P factor
case 130: case 130:
if (gcmd->seen_S) if (gcmd->seen_S)
@ -664,7 +676,6 @@ void process_gcode_command(GCODE_COMMAND *gcmd) {
debug_flags |= DEBUG_ECHO; debug_flags |= DEBUG_ECHO;
serial_writestr_P(PSTR("Echo on\n")); serial_writestr_P(PSTR("Echo on\n"));
break; break;
#endif
// DEBUG: return current position // DEBUG: return current position
case 250: case 250:
@ -724,6 +735,7 @@ void process_gcode_command(GCODE_COMMAND *gcmd) {
serial_writechar('\n'); serial_writechar('\n');
(*(volatile uint8_t *)(gcmd->S)) = gcmd->P; (*(volatile uint8_t *)(gcmd->S)) = gcmd->P;
break; break;
#endif /* DEBUG */
// unknown mcode: spit an error // unknown mcode: spit an error
default: default:
serial_writestr_P(PSTR("E: Bad M-code ")); serial_writestr_P(PSTR("E: Bad M-code "));

View File

@ -58,12 +58,9 @@ void serial_init()
{ {
#if BAUD > 38401 #if BAUD > 38401
UCSR0A = MASK(U2X0); UCSR0A = MASK(U2X0);
#else
UCSR0A = 0;
#endif
#if BAUD > 38401
UBRR0 = (((F_CPU / 8) / BAUD) - 0.5); UBRR0 = (((F_CPU / 8) / BAUD) - 0.5);
#else #else
UCSR0A = 0;
UBRR0 = (((F_CPU / 16) / BAUD) - 0.5); UBRR0 = (((F_CPU / 16) / BAUD) - 0.5);
#endif #endif
@ -124,11 +121,6 @@ uint8_t serial_popchar()
Write Write
*/ */
// uint8_t serial_txchars()
// {
// return buf_canwrite(tx);
// }
void serial_writechar(uint8_t data) void serial_writechar(uint8_t data)
{ {
// check if interrupts are enabled // check if interrupts are enabled
@ -159,7 +151,6 @@ void serial_writestr(uint8_t *data)
{ {
uint8_t i = 0, r; uint8_t i = 0, r;
// yes, this is *supposed* to be assignment rather than comparison, so we break when r is assigned zero // yes, this is *supposed* to be assignment rather than comparison, so we break when r is assigned zero
// for (uint8_t r; (r = data[i]); i++)
while ((r = data[i++])) while ((r = data[i++]))
serial_writechar(r); serial_writechar(r);
} }
@ -187,7 +178,7 @@ void serial_writestr_P(PGM_P data)
{ {
uint8_t r, i = 0; uint8_t r, i = 0;
// yes, this is *supposed* to be assignment rather than comparison, so we break when r is assigned zero // yes, this is *supposed* to be assignment rather than comparison, so we break when r is assigned zero
for ( ; (r = pgm_read_byte(&data[i])); i++) while ((r = pgm_read_byte(&data[i++])))
serial_writechar(r); serial_writechar(r);
} }

10
timer.c
View File

@ -30,7 +30,7 @@ void setupTimerInterrupt()
setTimer(F_CPU / 100); setTimer(F_CPU / 100);
} }
// the following are all from reprap project 5D firmware // the following are all from reprap project 5D firmware with some modification to reduce redundancy
uint8_t getTimerResolution(const uint32_t delay) uint8_t getTimerResolution(const uint32_t delay)
{ {
@ -54,10 +54,7 @@ uint8_t getTimerResolution(const uint32_t delay)
return 4; return 4;
// our slowest speed at our lowest resolution ((2^16-1) * 64 usecs = 4194240 usecs (4.19 seconds max)) // our slowest speed at our lowest resolution ((2^16-1) * 64 usecs = 4194240 usecs (4.19 seconds max))
// range: 7.812Khz max - 0.119hz min // range: 7.812Khz max - 0.119hz min
// else if (delay <= 67107840L)
// return 5;
//its really slow... hopefully we can just get by with super slow. //its really slow... hopefully we can just get by with super slow.
// else
return 5; return 5;
} }
@ -106,11 +103,6 @@ void setTimer(uint32_t delay)
// we also then calculate the timer ceiling required. (ie what the counter counts to) // we also then calculate the timer ceiling required. (ie what the counter counts to)
// the result is the timer counts up to the appropriate time and then fires an interrupt. // the result is the timer counts up to the appropriate time and then fires an interrupt.
// Actual ticks are 0.0625 us, so multiply delay by 16
// convert to ticks
// delay = delay US;
setTimerCeiling(getTimerCeiling(delay)); setTimerCeiling(getTimerCeiling(delay));
setTimerResolution(getTimerResolution(delay)); setTimerResolution(getTimerResolution(delay));
} }