From 4f8ed7f1234274f563b8fa613b27f2060a311779 Mon Sep 17 00:00:00 2001 From: DRracer Date: Wed, 12 Jun 2019 10:31:09 +0200 Subject: [PATCH] for cycles' variables: int -> uint8_t where appropriate, part1 --- Firmware/temperature.cpp | 2 +- Firmware/tmc2130.cpp | 10 +++++----- Firmware/ultralcd.cpp | 32 ++++++++++++++++---------------- 3 files changed, 22 insertions(+), 22 deletions(-) mode change 100644 => 100755 Firmware/tmc2130.cpp diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index 9c49cf79..03845b12 100755 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -434,7 +434,7 @@ static void temp_runaway_stop(bool isPreheat, bool isBed); void updatePID() { #ifdef PIDTEMP - for(int e = 0; e < EXTRUDERS; e++) { + for(uint8_t e = 0; e < EXTRUDERS; e++) { iState_sum_max[e] = PID_INTEGRAL_DRIVE_MAX / cs.Ki; } #endif diff --git a/Firmware/tmc2130.cpp b/Firmware/tmc2130.cpp old mode 100644 new mode 100755 index 05ea2ab6..fe04e8da --- a/Firmware/tmc2130.cpp +++ b/Firmware/tmc2130.cpp @@ -158,7 +158,7 @@ void tmc2130_init() SET_INPUT(Y_TMC2130_DIAG); SET_INPUT(Z_TMC2130_DIAG); SET_INPUT(E0_TMC2130_DIAG); - for (int axis = 0; axis < 2; axis++) // X Y axes + for (uint8_t axis = 0; axis < 2; axis++) // X Y axes { tmc2130_setup_chopper(axis, tmc2130_mres[axis], tmc2130_current_h[axis], tmc2130_current_r[axis]); tmc2130_wr(axis, TMC2130_REG_TPOWERDOWN, 0x00000000); @@ -169,7 +169,7 @@ void tmc2130_init() tmc2130_wr_TPWMTHRS(axis, TMC2130_TPWMTHRS); //tmc2130_wr_THIGH(axis, TMC2130_THIGH); } - for (int axis = 2; axis < 3; axis++) // Z axis + for (uint8_t axis = 2; axis < 3; axis++) // Z axis { tmc2130_setup_chopper(axis, tmc2130_mres[axis], tmc2130_current_h[axis], tmc2130_current_r[axis]); tmc2130_wr(axis, TMC2130_REG_TPOWERDOWN, 0x00000000); @@ -183,7 +183,7 @@ void tmc2130_init() tmc2130_wr_TPWMTHRS(axis, TMC2130_TPWMTHRS); #endif //TMC2130_STEALTH_Z } - for (int axis = 3; axis < 4; axis++) // E axis + for (uint8_t axis = 3; axis < 4; axis++) // E axis { tmc2130_setup_chopper(axis, tmc2130_mres[axis], tmc2130_current_h[axis], tmc2130_current_r[axis]); tmc2130_wr(axis, TMC2130_REG_TPOWERDOWN, 0x00000000); @@ -383,7 +383,7 @@ void tmc2130_check_overtemp() static uint32_t checktime = 0; if (_millis() - checktime > 1000 ) { - for (int i = 0; i < 4; i++) + for (uint8_t i = 0; i < 4; i++) { uint32_t drv_status = 0; skip_debug_msg = true; @@ -392,7 +392,7 @@ void tmc2130_check_overtemp() { // BIT 26 - over temp prewarning ~120C (+-20C) SERIAL_ERRORRPGM(MSG_TMC_OVERTEMP); SERIAL_ECHOLN(i); - for (int j = 0; j < 4; j++) + for (uint8_t j = 0; j < 4; j++) tmc2130_wr(j, TMC2130_REG_CHOPCONF, 0x00010000); kill(MSG_TMC_OVERTEMP); } diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 19601df3..5efa9bf2 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -317,7 +317,7 @@ static void lcd_implementation_drawmenu_sdfile_selected(uint8_t row, char* longF char c; int enc_dif = lcd_encoder_diff; uint8_t n = LCD_WIDTH - 1; - for(int g = 0; g<4;g++){ + for(uint8_t g = 0; g<4;g++){ lcd_set_cursor(0, g); lcd_print(' '); } @@ -2708,11 +2708,11 @@ void lcd_change_success() { static void lcd_loading_progress_bar(uint16_t loading_time_ms) { - for (int i = 0; i < 20; i++) { + for (uint8_t i = 0; i < 20; i++) { lcd_set_cursor(i, 3); lcd_print("."); //loading_time_ms/20 delay - for (int j = 0; j < 5; j++) { + for (uint8_t j = 0; j < 5; j++) { delay_keep_alive(loading_time_ms / 100); } } @@ -3154,7 +3154,7 @@ static void lcd_menu_xyz_offset() float cntr[2]; world2machine_read_valid(vec_x, vec_y, cntr); - for (int i = 0; i < 2; i++) + for (uint8_t i = 0; i < 2; i++) { lcd_puts_at_P(11, i + 2, PSTR("")); lcd_print(cntr[i]); @@ -4822,7 +4822,7 @@ void lcd_v2_calibration() else { lcd_display_message_fullscreen_P(_i("Please load PLA filament first."));////MSG_PLEASE_LOAD_PLA c=20 r=4 lcd_consume_click(); - for (int i = 0; i < 20; i++) { //wait max. 2s + for (uint8_t i = 0; i < 20; i++) { //wait max. 2s delay_keep_alive(100); if (lcd_clicked()) { break; @@ -5549,7 +5549,7 @@ void bowden_menu() { lcd_clear(); lcd_set_cursor(0, 0); lcd_print(">"); - for (int i = 0; i < 4; i++) { + for (uint8_t i = 0; i < 4; i++) { lcd_set_cursor(1, i); lcd_print("Extruder "); lcd_print(i); @@ -5637,7 +5637,7 @@ void bowden_menu() { enc_dif = lcd_encoder_diff; lcd_set_cursor(0, cursor_pos); lcd_print(">"); - for (int i = 0; i < 4; i++) { + for (uint8_t i = 0; i < 4; i++) { lcd_set_cursor(1, i); lcd_print("Extruder "); lcd_print(i); @@ -5764,14 +5764,14 @@ uint8_t choose_menu_P(const char *header, const char *item, const char *last_ite if (header) lcd_puts_at_P(0,0,header); const bool last_visible = (first == items_no - 3); - const int8_t ordinary_items = (last_item&&last_visible)?2:3; + const uint8_t ordinary_items = (last_item&&last_visible)?2:3; - for (int i = 0; i < ordinary_items; i++) + for (uint8_t i = 0; i < ordinary_items; i++) { if (item) lcd_puts_at_P(1, i + 1, item); } - for (int i = 0; i < ordinary_items; i++) + for (uint8_t i = 0; i < ordinary_items; i++) { lcd_set_cursor(2 + item_len, i+1); lcd_print(first + i + 1); @@ -5825,7 +5825,7 @@ char reset_menu() { lcd_consume_click(); while (1) { - for (int i = 0; i < 4; i++) { + for (uint8_t i = 0; i < 4; i++) { lcd_set_cursor(1, i); lcd_print(item[first + i]); } @@ -6151,7 +6151,7 @@ unsigned char lcd_choose_color() { item[0] = "Orange"; item[1] = "Black"; //----------------------------------------------------- - unsigned char active_rows; + uint8_t active_rows; static int first = 0; int enc_dif = 0; unsigned char cursor_pos = 1; @@ -6164,7 +6164,7 @@ unsigned char lcd_choose_color() { lcd_consume_click(); while (1) { lcd_puts_at_P(0, 0, PSTR("Choose color:")); - for (int i = 0; i < active_rows; i++) { + for (uint8_t i = 0; i < active_rows; i++) { lcd_set_cursor(1, i+1); lcd_print(item[first + i]); } @@ -7201,7 +7201,7 @@ static bool lcd_selfcheck_axis_sg(unsigned char axis) { //end of second measurement, now check for possible errors: - for(int i = 0; i < 2; i++){ //check if measured axis length corresponds to expected length + for(uint8_t i = 0; i < 2; i++){ //check if measured axis length corresponds to expected length printf_P(_N("Measured axis length:%.3f\n"), measured_axis_length[i]); if (abs(measured_axis_length[i] - axis_length) > max_error_mm) { enable_endstops(false); @@ -8065,7 +8065,7 @@ static void menu_action_sdfile(const char* filename) const char end[5] = ".gco"; //we are storing just first 8 characters of 8.3 filename assuming that extension is always ".gco" - for (int i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { if (strcmp((cmd + i + 4), end) == 0) { //filename is shorter then 8.3, store '\0' character on position where ".gco" string was found to terminate stored string properly eeprom_write_byte((uint8_t*)EEPROM_FILENAME + i, '\0'); @@ -8080,7 +8080,7 @@ static void menu_action_sdfile(const char* filename) eeprom_write_byte((uint8_t*)EEPROM_DIR_DEPTH, depth); for (uint8_t i = 0; i < depth; i++) { - for (int j = 0; j < 8; j++) { + for (uint8_t j = 0; j < 8; j++) { eeprom_write_byte((uint8_t*)EEPROM_DIRS + j + 8 * i, dir_names[i][j]); } }