This commit is contained in:
Erik van der Zalm
2012-02-08 18:28:54 +01:00
parent d8a0c6450f
commit 5113513cb2
3 changed files with 35 additions and 30 deletions

View File

@@ -27,8 +27,6 @@
#include "Marlin.h"
#include "ultralcd.h"
#include "planner.h"
#include "stepper.h"
@@ -38,12 +36,7 @@
#include "watchdog.h"
#include "EEPROMwrite.h"
#define VERSION_STRING "1.0.0 Beta 1"
#define VERSION_STRING "1.0.0 RC1"
// look here for descriptions of gcodes: http://linuxcnc.org/handbook/gcode/g-code.html
// http://objects.reprap.org/wiki/Mendel_User_Manual:_RepRapGCodes
@@ -147,15 +140,11 @@ static bool home_all_axis = true;
static float feedrate = 1500.0, next_feedrate, saved_feedrate;
static long gcode_N, gcode_LastN;
static bool relative_mode = false; //Determines Absolute or Relative Coordinates
static bool relative_mode_e = false; //Determines Absolute or Relative E Codes while in Absolute Coordinates mode. E is always relative in Relative Coordinates mode.
static uint8_t fanpwm=0;
static char cmdbuffer[BUFSIZE][MAX_CMD_SIZE];
static bool fromsd[BUFSIZE];
static int bufindr = 0;
@@ -224,6 +213,7 @@ void enquecommand(const char *cmd)
buflen += 1;
}
}
void setup_photpin()
{
#ifdef PHOTOGRAPH_PIN
@@ -254,12 +244,6 @@ void suicide()
#endif
}
long millis_diff(unsigned long starttime) {
unsigned long difftime = millis() - starttime;
if (difftime > 0x8000) difftime += 0x8000;
return difftime;
}
void setup()
{
setup_powerhold();
@@ -332,7 +316,6 @@ void loop()
LCD_STATUS;
}
void get_command()
{
while( MSerial.available() > 0 && buflen < BUFSIZE) {
@@ -556,9 +539,9 @@ void process_commands()
if(code_seen('S')) codenum = code_value() * 1000; // seconds to wait
st_synchronize();
// codenum += millis(); // keep track of when we started waiting
codenum += millis(); // keep track of when we started waiting
previous_millis_cmd = millis();
while(millis_diff(previous_millis_cmd) < codenum ){
while(millis() < codenum ){
manage_heater();
}
break;
@@ -795,7 +778,7 @@ void process_commands()
#if (TEMP_0_PIN > -1)
SERIAL_PROTOCOLPGM("ok T:");
SERIAL_PROTOCOL(degHotend(tmp_extruder));
#if TEMP_BED_PIN > -1
#if TEMP_BED_PIN > -1
SERIAL_PROTOCOLPGM(" B:");
SERIAL_PROTOCOL(degBed());
#endif //TEMP_BED_PIN
@@ -849,11 +832,11 @@ void process_commands()
/* continue to loop until we have reached the target temp
_and_ until TEMP_RESIDENCY_TIME hasn't passed since we reached it */
while((residencyStart == -1) ||
(residencyStart > -1 && (millis_diff(residencyStart) < TEMP_RESIDENCY_TIME*1000) )) {
(residencyStart > -1 && (millis() - residencyStart) < TEMP_RESIDENCY_TIME*1000) ) {
#else
while ( target_direction ? (isHeatingHotend(tmp_extruder)) : (isCoolingHotend(tmp_extruder)&&(CooldownNoWait==false)) ) {
#endif //TEMP_RESIDENCY_TIME
if(millis_diff(codenum) > 1000 )
if((millis() - codenum) > 1000 )
{ //Print Temp Reading and remaining time every 1 second while heating up/cooling down
SERIAL_PROTOCOLPGM("T:");
SERIAL_PROTOCOL( degHotend(tmp_extruder) );
@@ -863,7 +846,7 @@ void process_commands()
SERIAL_PROTOCOLPGM(" W:");
if(residencyStart > -1)
{
codenum = TEMP_RESIDENCY_TIME - (millis_diff(residencyStart) / 1000);
codenum = TEMP_RESIDENCY_TIME - ((millis() - residencyStart) / 1000);
SERIAL_PROTOCOLLN( codenum );
}
else
@@ -901,7 +884,7 @@ void process_commands()
codenum = millis();
while(isHeatingBed())
{
if( millis_diff(codenum) > 1000 ) //Print Temp Reading every 1 second while heating up.
if(( millis() - codenum) > 1000 ) //Print Temp Reading every 1 second while heating up.
{
float tt=degHotend(active_extruder);
SERIAL_PROTOCOLPGM("T:");
@@ -971,6 +954,7 @@ void process_commands()
bool all_axis = !((code_seen(axis_codes[0])) || (code_seen(axis_codes[1])) || (code_seen(axis_codes[2]))|| (code_seen(axis_codes[3])));
if(all_axis)
{
st_synchronize();
disable_e0();
disable_e1();
disable_e2();
@@ -1299,11 +1283,11 @@ void prepare_arc_move(char isclockwise) {
void manage_inactivity(byte debug)
{
if( millis_diff(previous_millis_cmd) > max_inactive_time )
if( (millis() - previous_millis_cmd) > max_inactive_time )
if(max_inactive_time)
kill();
if(stepper_inactive_time)
if( millis_diff(last_stepperdisabled_time) > stepper_inactive_time )
if( (millis() - last_stepperdisabled_time) > stepper_inactive_time )
{
if(previous_millis_cmd>last_stepperdisabled_time)
last_stepperdisabled_time=previous_millis_cmd;
@@ -1315,7 +1299,7 @@ void manage_inactivity(byte debug)
}
}
#ifdef EXTRUDER_RUNOUT_PREVENT
if( millis_diff(previous_millis_cmd) > EXTRUDER_RUNOUT_SECONDS*1000 )
if( (millis() - previous_millis_cmd) > EXTRUDER_RUNOUT_SECONDS*1000 )
if(degHotend(active_extruder)>EXTRUDER_RUNOUT_MINTEMP)
{
bool oldstatus=READ(E0_ENABLE_PIN);