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