From 907daa49af3a3ca41895007052d8732408e81b95 Mon Sep 17 00:00:00 2001 From: Bernhard Kubicek Date: Sun, 6 Nov 2011 23:21:12 +0100 Subject: [PATCH] made loop counters uint8_t most were int(16_t) before --- Marlin/Marlin.pde | 24 ++++++++++++------------ Marlin/cardreader.pde | 6 +++--- Marlin/stepper.cpp | 2 +- Marlin/ultralcd.pde | 14 +++++++------- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Marlin/Marlin.pde b/Marlin/Marlin.pde index 5f138f4be..104fc6576 100644 --- a/Marlin/Marlin.pde +++ b/Marlin/Marlin.pde @@ -192,14 +192,14 @@ void setup() Serial.begin(BAUDRATE); SERIAL_ECHOLN("Marlin "<= 0 && pin_status <= 255) { int pin_number = code_value(); - for(int i = 0; i < (int)sizeof(sensitive_pins); i++) + for(int8_t i = 0; i < (int8_t)sizeof(sensitive_pins); i++) { if (sensitive_pins[i] == pin_number) { @@ -759,7 +759,7 @@ inline void process_commands() max_inactive_time = code_value() * 1000; break; case 92: // M92 - for(int i=0; i < NUM_AXIS; i++) + for(int8_t i=0; i < NUM_AXIS; i++) { if(code_seen(axis_codes[i])) axis_steps_per_unit[i] = code_value(); @@ -816,20 +816,20 @@ inline void process_commands() break; //TODO: update for all axis, use for loop case 201: // M201 - for(int i=0; i < NUM_AXIS; i++) + for(int8_t i=0; i < NUM_AXIS; i++) { if(code_seen(axis_codes[i])) axis_steps_per_sqr_second[i] = code_value() * axis_steps_per_unit[i]; } break; #if 0 // Not used for Sprinter/grbl gen6 case 202: // M202 - for(int i=0; i < NUM_AXIS; i++) { + for(int8_t i=0; i < NUM_AXIS; i++) { if(code_seen(axis_codes[i])) axis_travel_steps_per_sqr_second[i] = code_value() * axis_steps_per_unit[i]; } break; #endif case 203: // M203 max feedrate mm/sec - for(int i=0; i < NUM_AXIS; i++) { + for(int8_t i=0; i < NUM_AXIS; i++) { if(code_seen(axis_codes[i])) max_feedrate[i] = code_value()*60 ; } break; @@ -914,7 +914,7 @@ void ClearToSend() inline void get_coordinates() { - for(int i=0; i < NUM_AXIS; i++) { + for(int8_t i=0; i < NUM_AXIS; i++) { if(code_seen(axis_codes[i])) destination[i] = (float)code_value() + (axis_relative_modes[i] || relative_mode)*current_position[i]; else destination[i] = current_position[i]; //Are these else lines really needed? } @@ -934,7 +934,7 @@ inline void get_arc_coordinates() void prepare_move() { plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60.0/100.0); - for(int i=0; i < NUM_AXIS; i++) { + for(int8_t i=0; i < NUM_AXIS; i++) { current_position[i] = destination[i]; } } @@ -948,7 +948,7 @@ void prepare_arc_move(char isclockwise) { // As far as the parser is concerned, the position is now == target. In reality the // motion control system might still be processing the action and the real tool position // in any intermediate location. - for(int i=0; i < NUM_AXIS; i++) { + for(int8_t i=0; i < NUM_AXIS; i++) { current_position[i] = destination[i]; } } diff --git a/Marlin/cardreader.pde b/Marlin/cardreader.pde index 9f94de0bc..a49b9999f 100644 --- a/Marlin/cardreader.pde +++ b/Marlin/cardreader.pde @@ -167,7 +167,7 @@ void CardReader::checkautostart(bool force) static int lastnr=0; char autoname[30]; sprintf(autoname,"auto%i.g",lastnr); - for(int i=0;i<(int)strlen(autoname);i++) + for(int8_t i=0;i<(int)strlen(autoname);i++) autoname[i]=tolower(autoname[i]); dir_t p; @@ -176,7 +176,7 @@ void CardReader::checkautostart(bool force) bool found=false; while (root.readDir(p) > 0) { - for(int i=0;i<(int)strlen((char*)p.name);i++) + for(int8_t i=0;i<(int)strlen((char*)p.name);i++) p.name[i]=tolower(p.name[i]); //Serial.print((char*)p.name); //Serial.print(" "); @@ -222,7 +222,7 @@ void CardReader::getfilename(const uint8_t nr) if(cnt++!=nr) continue; //Serial.println((char*)p.name); uint8_t writepos=0; - for (uint8_t i = 0; i < 11; i++) + for (int8_t i = 0; i < 11; i++) { if (p.name[i] == ' ') continue; if (i == 8) { diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index 924521119..2607eef60 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -345,7 +345,7 @@ ISR(TIMER1_COMPA_vect) WRITE(E_DIR_PIN,!INVERT_E_DIR); #endif //!ADVANCE - for(char i=0; i < step_loops; i++) { // Take multiple steps per interrupt (For high speed moves) + for(int8_t i=0; i < step_loops; i++) { // Take multiple steps per interrupt (For high speed moves) counter_x += current_block->steps_x; if (counter_x > 0) { WRITE(X_STEP_PIN, HIGH); diff --git a/Marlin/ultralcd.pde b/Marlin/ultralcd.pde index 77d7151d9..d437cf3a6 100644 --- a/Marlin/ultralcd.pde +++ b/Marlin/ultralcd.pde @@ -80,7 +80,7 @@ void beep() //return; #ifdef ULTIPANEL pinMode(BEEPER,OUTPUT); - for(int i=0;i<20;i++){ + for(int8_t i=0;i<20;i++){ WRITE(BEEPER,HIGH); delay(5); WRITE(BEEPER,LOW); @@ -94,7 +94,7 @@ void beepshort() //return; #ifdef ULTIPANEL pinMode(BEEPER,OUTPUT); - for(int i=0;i<10;i++){ + for(int8_t i=0;i<10;i++){ WRITE(BEEPER,HIGH); delay(3); WRITE(BEEPER,LOW); @@ -165,7 +165,7 @@ void buttons_check() WRITE(SHIFT_LD,LOW); WRITE(SHIFT_LD,HIGH); unsigned char tmp_buttons=0; - for(unsigned char i=0;i<8;i++) + for(int8_t i=0;i<8;i++) { newbutton = newbutton>>1; if(READ(SHIFT_OUT)) @@ -375,7 +375,7 @@ void MainMenu::showPrepare() force_lcd_update=true; clear(); } - for(uint8_t i=lineoffset;i