From a71a1ee2ab0fb29b8ea38eca3efd117533f1d808 Mon Sep 17 00:00:00 2001 From: kliment Date: Tue, 5 Apr 2011 13:45:46 +0200 Subject: Fixed SD card removal and reinsertion. Added support for bed temp reading in newer repsnapper. --- Tonokip_Firmware/Tonokip_Firmware.pde | 63 +++++++++++++---------------------- 1 file changed, 23 insertions(+), 40 deletions(-) diff --git a/Tonokip_Firmware/Tonokip_Firmware.pde b/Tonokip_Firmware/Tonokip_Firmware.pde index c233fc4..a8bcab1 100644 --- a/Tonokip_Firmware/Tonokip_Firmware.pde +++ b/Tonokip_Firmware/Tonokip_Firmware.pde @@ -81,7 +81,8 @@ int target_raw = 0; int current_raw; int target_bed_raw = 0; int current_bed_raw; - +float tt=0,bt=0; + //Inactivity shutdown variables unsigned long previous_millis_cmd=0; unsigned long max_inactive_time = 0; @@ -99,7 +100,8 @@ int16_t n; void initsd(){ sdactive=false; - +if(root.isOpen()) + root.close(); if (!card.init(SPI_FULL_SPEED)){ if (!card.init(SPI_HALF_SPEED)) Serial.println("SD init fail"); @@ -120,11 +122,6 @@ void setup() Serial.begin(BAUDRATE); Serial.println("start"); - -//cmdbuffer[0]="\0"; -//cmdbuffer[1]="\0"; -//cmdbuffer[2]=char[4]; -//cmdbuffer[3]=char[4]; for(int i=0;i 0) { - // for (uint8_t i = 0; i < n; i++) Serial.print(buf[i]); - //} Serial.println("File selected"); - //file.close(); } else{ Serial.println("file.open failed"); @@ -537,11 +509,16 @@ inline void process_commands() if (code_seen('S')) target_bed_raw = temp2analogBed(code_value()); break; case 105: // M105 + tt=analog2temp(analogRead(TEMP_0_PIN)); + bt=analog2tempBed(analogRead(TEMP_1_PIN)); Serial.print("T:"); - Serial.println( analog2temp(analogRead(TEMP_0_PIN)) ); - Serial.print("Bed:"); - Serial.println( analog2tempBed(analogRead(TEMP_1_PIN)) ); - break; + Serial.println(tt); + Serial.print("ok T:"); + Serial.print(tt); + Serial.print(" B:"); + Serial.println(bt); + return; + //break; case 109: // M109 - Wait for heater to reach target. if (code_seen('S')) target_raw = temp2analog(code_value()); previous_millis_heater = millis(); @@ -686,6 +663,9 @@ void linear_move(unsigned long x_steps_remaining, unsigned long y_steps_remainin if(X_MIN_PIN > -1) if(!direction_x) if(digitalRead(X_MIN_PIN) != ENDSTOPS_INVERTING) x_steps_remaining=0; if(Y_MIN_PIN > -1) if(!direction_y) if(digitalRead(Y_MIN_PIN) != ENDSTOPS_INVERTING) y_steps_remaining=0; if(Z_MIN_PIN > -1) if(!direction_z) if(digitalRead(Z_MIN_PIN) != ENDSTOPS_INVERTING) z_steps_remaining=0; + if(X_MAX_PIN > -1) if(direction_x) if(digitalRead(X_MAX_PIN) != ENDSTOPS_INVERTING) x_steps_remaining=0; + if(Y_MAX_PIN > -1) if(direction_y) if(digitalRead(Y_MAX_PIN) != ENDSTOPS_INVERTING) y_steps_remaining=0; + if(Z_MAX_PIN > -1) if(direction_z) if(digitalRead(Z_MAX_PIN) != ENDSTOPS_INVERTING) z_steps_remaining=0; previous_millis_heater = millis(); @@ -807,6 +787,8 @@ void linear_move(unsigned long x_steps_remaining, unsigned long y_steps_remainin if(x_steps_remaining || y_steps_remaining) { if(X_MIN_PIN > -1) if(!direction_x) if(digitalRead(X_MIN_PIN) != ENDSTOPS_INVERTING) x_steps_remaining=0; if(Y_MIN_PIN > -1) if(!direction_y) if(digitalRead(Y_MIN_PIN) != ENDSTOPS_INVERTING) y_steps_remaining=0; + if(X_MAX_PIN > -1) if(direction_x) if(digitalRead(X_MAX_PIN) != ENDSTOPS_INVERTING) x_steps_remaining=0; + if(Y_MAX_PIN > -1) if(direction_y) if(digitalRead(Y_MAX_PIN) != ENDSTOPS_INVERTING) y_steps_remaining=0; if(steep_y) { timediff = micros() - previous_micros_y; while(timediff >= interval) { @@ -866,6 +848,7 @@ void linear_move(unsigned long x_steps_remaining, unsigned long y_steps_remainin if(z_steps_remaining) { if(Z_MIN_PIN > -1) if(!direction_z) if(digitalRead(Z_MIN_PIN) != ENDSTOPS_INVERTING) z_steps_remaining=0; + if(Z_MAX_PIN > -1) if(direction_z) if(digitalRead(Z_MAX_PIN) != ENDSTOPS_INVERTING) z_steps_remaining=0; timediff=micros()-previous_micros_z; while(timediff >= z_interval && z_steps_remaining) { do_z_step(); z_steps_remaining--; timediff-=z_interval;} } -- cgit v1.2.1