From 5113513cb2efd62c01a4fab4cb28e0a8d9905005 Mon Sep 17 00:00:00 2001
From: Erik van der Zalm <erik@vdzalm.eu>
Date: Wed, 8 Feb 2012 18:28:54 +0100
Subject: [PATCH] RC 1

---
 Marlin/Configuration_adv.h | 17 +++++++++++++++
 Marlin/Marlin.pde          | 42 ++++++++++++--------------------------
 README.md                  |  6 +++++-
 3 files changed, 35 insertions(+), 30 deletions(-)

diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h
index a94dba79d6..1bdbd1ac2c 100644
--- a/Marlin/Configuration_adv.h
+++ b/Marlin/Configuration_adv.h
@@ -204,5 +204,22 @@ const int dropsegments=5; //everything with less than this number of steps will
 #if TEMP_SENSOR_0 == -2
   #define HEATER_0_USES_MAX6675
 #endif
+#if TEMP_SENSOR_0 == 0
+  #undef HEATER_0_MINTEMP
+  #undef HEATER_0_MAXTEMP
+#endif
+#if TEMP_SENSOR_1 == 0
+  #undef HEATER_1_MINTEMP
+  #undef HEATER_1_MAXTEMP
+#endif
+#if TEMP_SENSOR_2 == 0
+  #undef HEATER_2_MINTEMP
+  #undef HEATER_2_MAXTEMP
+#endif
+#if TEMP_SENSOR_BED == 0
+  #undef BED_MINTEMP
+  #undef BED_MAXTEMP
+#endif
+
 
 #endif //__CONFIGURATION_ADV_H
diff --git a/Marlin/Marlin.pde b/Marlin/Marlin.pde
index e1decfd3f0..57ededa2ef 100644
--- a/Marlin/Marlin.pde
+++ b/Marlin/Marlin.pde
@@ -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);
diff --git a/README.md b/README.md
index 0beb13fe58..6f04764c94 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,10 @@
 WARNING: 
 --------
-THIS IS THE BETA 1 FOR MARLIN 1.0.0
+THIS IS RELEASE CANDIDATE 1 FOR MARLIN 1.0.0
+
+The configuration is now split in two files
+Configuration.h for the normal settings
+Configuration_adv.h for the advanced settings
 
 Quick Information
 ===================