diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index c2c5ca933..e6c5685d0 100755 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -294,9 +294,9 @@ extern int8_t lcd_change_fil_state; extern float default_retraction; #ifdef TMC2130 -void homeaxis(int axis, uint8_t cnt = 1, uint8_t* pstep = 0); +void homeaxis(uint8_t axis, uint8_t cnt = 1, uint8_t* pstep = 0); #else -void homeaxis(int axis, uint8_t cnt = 1); +void homeaxis(uint8_t axis, uint8_t cnt = 1); #endif //TMC2130 diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index bf0c51ad6..284262d6a 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -1760,7 +1760,6 @@ void trace(); #define CHUNK_SIZE 64 // bytes #define SAFETY_MARGIN 1 char chunk[CHUNK_SIZE+SAFETY_MARGIN]; -int chunkHead = 0; void serial_read_stream() { @@ -2038,9 +2037,9 @@ DEFINE_PGM_READ_ANY(signed char, byte); #define XYZ_CONSTS_FROM_CONFIG(type, array, CONFIG) \ static const PROGMEM type array##_P[3] = \ { X_##CONFIG, Y_##CONFIG, Z_##CONFIG }; \ -static inline type array(int axis) \ +static inline type array(uint8_t axis) \ { return pgm_read_any(&array##_P[axis]); } \ -type array##_ext(int axis) \ +type array##_ext(uint8_t axis) \ { return pgm_read_any(&array##_P[axis]); } XYZ_CONSTS_FROM_CONFIG(float, base_min_pos, MIN_POS); @@ -2050,7 +2049,7 @@ XYZ_CONSTS_FROM_CONFIG(float, max_length, MAX_LENGTH); XYZ_CONSTS_FROM_CONFIG(float, home_retract_mm, HOME_RETRACT_MM); XYZ_CONSTS_FROM_CONFIG(signed char, home_dir, HOME_DIR); -static void axis_is_at_home(int axis) { +static void axis_is_at_home(uint8_t axis) { current_position[axis] = base_home_pos(axis) + cs.add_homing[axis]; min_pos[axis] = base_min_pos(axis) + cs.add_homing[axis]; max_pos[axis] = base_max_pos(axis) + cs.add_homing[axis]; @@ -2366,9 +2365,9 @@ static void check_Z_crash(void) #endif //TMC2130 #ifdef TMC2130 -void homeaxis(int axis, uint8_t cnt, uint8_t* pstep) +void homeaxis(uint8_t axis, uint8_t cnt, uint8_t* pstep) #else -void homeaxis(int axis, uint8_t cnt) +void homeaxis(uint8_t axis, uint8_t cnt) #endif //TMC2130 { bool endstops_enabled = enable_endstops(true); //RP: endstops should be allways enabled durring homing @@ -2842,7 +2841,7 @@ static void gcode_G28(bool home_x_axis, long home_x_value, bool home_y_axis, lon { current_position[X_AXIS] = 0;current_position[Y_AXIS] = 0; - int x_axis_home_dir = home_dir(X_AXIS); + uint8_t x_axis_home_dir = home_dir(X_AXIS); plan_set_position_curposXYZE(); destination[X_AXIS] = 1.5 * max_length(X_AXIS) * x_axis_home_dir;destination[Y_AXIS] = 1.5 * max_length(Y_AXIS) * home_dir(Y_AXIS); @@ -5305,7 +5304,7 @@ if(eSoundMode!=e_SOUND_MODE_SILENT) */ case 75: { - for (int i = 40; i <= 110; i++) + for (uint8_t i = 40; i <= 110; i++) printf_P(_N("%d %.2f"), i, temp_comp_interpolation(i)); } break; @@ -7803,8 +7802,8 @@ Sigma_Exit: */ case 300: // M300 { - int beepS = code_seen('S') ? code_value() : 110; - int beepP = code_seen('P') ? code_value() : 1000; + uint16_t beepS = code_seen('S') ? code_value() : 110; + uint16_t beepP = code_seen('P') ? code_value() : 1000; if (beepS > 0) { #if BEEPER > 0 @@ -11499,8 +11498,8 @@ void restore_print_from_eeprom(bool mbl_was_active) { depth = eeprom_read_byte((uint8_t*)EEPROM_DIR_DEPTH); MYSERIAL.println(int(depth)); - for (int i = 0; i < depth; i++) { - for (int j = 0; j < 8; j++) { + for (uint8_t i = 0; i < depth; i++) { + for (uint8_t j = 0; j < 8; j++) { dir_name[j] = eeprom_read_byte((uint8_t*)EEPROM_DIRS + j + 8 * i); } dir_name[8] = '\0'; @@ -11509,7 +11508,7 @@ void restore_print_from_eeprom(bool mbl_was_active) { card.chdir(dir_name, false); } - for (int i = 0; i < 8; i++) { + for (uint8_t i = 0; i < 8; i++) { filename[i] = eeprom_read_byte((uint8_t*)EEPROM_FILENAME + i); } filename[8] = '\0'; diff --git a/Firmware/cardreader.h b/Firmware/cardreader.h index f7e3acc94..32a024529 100644 --- a/Firmware/cardreader.h +++ b/Firmware/cardreader.h @@ -136,7 +136,6 @@ private: bool autostart_stilltocheck; //the sd start is delayed, because otherwise the serial cannot answer fast enought to make contact with the hostsoftware. int16_t nrFiles; //counter for the files in the current directory and recycled as position counter for getting the nrFiles'th name in the directory. - char* diveDirName; bool diveSubfolder (const char *&fileName); void lsDive(const char *prepend, SdFile parent, const char * const match=NULL, LsAction lsAction = LS_GetFilename, ls_param lsParams = ls_param()); diff --git a/Firmware/lcd.cpp b/Firmware/lcd.cpp index 37b70f1a1..024f973f9 100644 --- a/Firmware/lcd.cpp +++ b/Firmware/lcd.cpp @@ -344,7 +344,7 @@ void lcd_createChar_P(uint8_t location, const uint8_t* charmap) { location &= 0x7; // we only have 8 locations 0-7 lcd_command(LCD_SETCGRAMADDR | (location << 3)); - for (int i=0; i<8; i++) + for (uint8_t i = 0; i < 8; i++) lcd_send(pgm_read_byte(&charmap[i]), HIGH); } diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp index ef83e5735..f97851059 100644 --- a/Firmware/mesh_bed_calibration.cpp +++ b/Firmware/mesh_bed_calibration.cpp @@ -2240,7 +2240,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level /// Retry point scanning if a point with bad data appears. /// Bad data could be cause by "cold" sensor. /// This behavior vanishes after few point scans so retry will help. - for (int retries = 0; retries <= 1; ++retries) { + for (uint8_t retries = 0; retries <= 1; ++retries) { bool retry = false; for (int k = 0; k < 4; ++k) { // Don't let the manage_inactivity() function remove power from the motors. diff --git a/Firmware/mesh_bed_leveling.cpp b/Firmware/mesh_bed_leveling.cpp index 344d41e3f..aa969340c 100644 --- a/Firmware/mesh_bed_leveling.cpp +++ b/Firmware/mesh_bed_leveling.cpp @@ -10,9 +10,7 @@ mesh_bed_leveling::mesh_bed_leveling() { reset(); } void mesh_bed_leveling::reset() { active = 0; - for (int y = 0; y < MESH_NUM_Y_POINTS; y++) - for (int x = 0; x < MESH_NUM_X_POINTS; x++) - z_values[y][x] = 0; + memset(z_values, 0, sizeof(float) * MESH_NUM_X_POINTS * MESH_NUM_Y_POINTS); } static inline bool vec_undef(const float v[2]) diff --git a/Firmware/planner.cpp b/Firmware/planner.cpp index 5750ce6e8..3361e1a17 100644 --- a/Firmware/planner.cpp +++ b/Firmware/planner.cpp @@ -1023,7 +1023,7 @@ Having the real displacement of the head, we can calculate the total movement le // Calculate speed in mm/second for each axis. No divide by zero due to previous checks. float inverse_second = feed_rate * inverse_millimeters; - int moves_queued = moves_planned(); + uint8_t moves_queued = moves_planned(); // slow down when de buffer starts to empty, rather than wait at the corner for a buffer refill #ifdef SLOWDOWN diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index c7fa599c2..7730be05d 100755 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -204,7 +204,7 @@ static float analog2tempAmbient(int raw); #endif static void updateTemperaturesFromRawValues(); -enum TempRunawayStates +enum TempRunawayStates : uint8_t { TempRunaway_INACTIVE = 0, TempRunaway_PREHEAT = 1, @@ -225,7 +225,7 @@ static float temp_runaway_target[1 + EXTRUDERS]; static float temp_runaway_timer[1 + EXTRUDERS]; static int temp_runaway_error_counter[1 + EXTRUDERS]; -static void temp_runaway_check(int _heater_id, float _target_temperature, float _current_temperature, float _output, bool _isbed); +static void temp_runaway_check(uint8_t _heater_id, float _target_temperature, float _current_temperature, float _output, bool _isbed); static void temp_runaway_stop(bool isPreheat, bool isBed); #endif @@ -683,7 +683,7 @@ void manage_heater() temp_runaway_check(0, target_temperature_bed, current_temperature_bed, (int)soft_pwm_bed, true); #endif - for(int e = 0; e < EXTRUDERS; e++) + for(uint8_t e = 0; e < EXTRUDERS; e++) { #ifdef TEMP_RUNAWAY_EXTRUDER_HYSTERESIS @@ -1240,15 +1240,15 @@ void tp_init() } #if (defined (TEMP_RUNAWAY_BED_HYSTERESIS) && TEMP_RUNAWAY_BED_TIMEOUT > 0) || (defined (TEMP_RUNAWAY_EXTRUDER_HYSTERESIS) && TEMP_RUNAWAY_EXTRUDER_TIMEOUT > 0) -void temp_runaway_check(int _heater_id, float _target_temperature, float _current_temperature, float _output, bool _isbed) +void temp_runaway_check(uint8_t _heater_id, float _target_temperature, float _current_temperature, float _output, bool _isbed) { float __delta; float __hysteresis = 0; - int __timeout = 0; + uint16_t __timeout = 0; bool temp_runaway_check_active = false; static float __preheat_start[2] = { 0,0}; //currently just bed and one extruder - static int __preheat_counter[2] = { 0,0}; - static int __preheat_errors[2] = { 0,0}; + static uint8_t __preheat_counter[2] = { 0,0}; + static uint8_t __preheat_errors[2] = { 0,0}; if (_millis() - temp_runaway_timer[_heater_id] > 2000) diff --git a/Firmware/tmc2130.cpp b/Firmware/tmc2130.cpp index 66ac59632..8f29cd480 100755 --- a/Firmware/tmc2130.cpp +++ b/Firmware/tmc2130.cpp @@ -910,7 +910,7 @@ void tmc2130_set_wave(uint8_t axis, uint8_t amp, uint8_t fac1000) uint8_t s = 0; //current segment int8_t b; //encoded bit value int8_t dA; //delta value - int i; //microstep index + uint8_t i; //microstep index uint32_t reg = 0; //tmc2130 register tmc2130_wr_MSLUTSTART(axis, 0, amp); for (i = 0; i < 256; i++) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 704274d9b..669cdd71c 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -161,8 +161,8 @@ static void lcd_belttest_v(); static void lcd_selftest_v(); #ifdef TMC2130 -static void reset_crash_det(unsigned char axis); -static bool lcd_selfcheck_axis_sg(unsigned char axis); +static void reset_crash_det(uint8_t axis); +static bool lcd_selfcheck_axis_sg(uint8_t axis); #else static bool lcd_selfcheck_axis(int _axis, int _travel); static bool lcd_selfcheck_pulleys(int axis); @@ -207,7 +207,7 @@ enum class TestError : uint_least8_t }; static int lcd_selftest_screen(TestScreen screen, int _progress, int _progress_scale, bool _clear, int _delay); -static void lcd_selftest_screen_step(int _row, int _col, int _state, const char *_name, const char *_indicator); +static void lcd_selftest_screen_step(uint8_t _row, uint8_t _col, uint8_t _state, const char *_name, const char *_indicator); static bool lcd_selftest_manual_fan_check(int _fan, bool check_opposite, bool _default=false); @@ -610,15 +610,14 @@ void lcdui_print_status_line(void) else if ((IS_SD_PRINTING) && (custom_message_type == CustomMsg::Status)) { // If printing from SD, show what we are printing const char* longFilenameOLD = (card.longFilename[0] ? card.longFilename : card.filename); if(strlen(longFilenameOLD) > LCD_WIDTH) { - int inters = 0; - int gh = scrollstuff; - while (((gh - scrollstuff) < LCD_WIDTH) && (inters == 0)) { + uint8_t gh = scrollstuff; + while (((gh - scrollstuff) < LCD_WIDTH)) { if (longFilenameOLD[gh] == '\0') { lcd_set_cursor(gh - scrollstuff, 3); lcd_print(longFilenameOLD[gh - 1]); scrollstuff = 0; gh = scrollstuff; - inters = 1; + break; } else { lcd_set_cursor(gh - scrollstuff, 3); lcd_print(longFilenameOLD[gh - 1]); @@ -694,7 +693,7 @@ void lcdui_print_status_line(void) } // Fill the rest of line to have nice and clean output - for(int fillspace = 0; fillspace < LCD_WIDTH; fillspace++) + for(uint8_t fillspace = 0; fillspace < LCD_WIDTH; fillspace++) if ((lcd_status_message[fillspace] <= 31 )) lcd_print(' '); } @@ -2738,7 +2737,7 @@ void lcd_menu_statistics() } -static void _lcd_move(const char *name, int axis, int min, int max) +static void _lcd_move(const char *name, uint8_t axis, int min, int max) { if (homing_flag || mesh_bed_leveling_flag) { @@ -3921,7 +3920,7 @@ static void prusa_statistics_case0(uint8_t statnr){ prusa_stat_printinfo(); } -void prusa_statistics(int _message, uint8_t _fil_nr) { +void prusa_statistics(uint8_t _message, uint8_t _fil_nr) { #ifdef DEBUG_DISABLE_PRUSA_STATISTICS return; #endif //DEBUG_DISABLE_PRUSA_STATISTICS @@ -7706,14 +7705,14 @@ bool lcd_selftest() #ifdef TMC2130 -static void reset_crash_det(unsigned char axis) { +static void reset_crash_det(uint8_t axis) { current_position[axis] += 10; plan_buffer_line_curposXYZE(manual_feedrate[0] / 60); st_synchronize(); if (eeprom_read_byte((uint8_t*)EEPROM_CRASH_DET)) tmc2130_sg_stop_on_crash = true; } -static bool lcd_selfcheck_axis_sg(unsigned char axis) { +static bool lcd_selfcheck_axis_sg(uint8_t axis) { // each axis length is measured twice float axis_length, current_position_init, current_position_final; float measured_axis_length[2]; @@ -8547,7 +8546,7 @@ static int lcd_selftest_screen(TestScreen screen, int _progress, int _progress_s return (_progress >= _progress_scale * 2) ? 0 : _progress; } -static void lcd_selftest_screen_step(int _row, int _col, int _state, const char *_name_PROGMEM, const char *_indicator) +static void lcd_selftest_screen_step(uint8_t _row, uint8_t _col, uint8_t _state, const char *_name_PROGMEM, const char *_indicator) { lcd_set_cursor(_col, _row); uint8_t strlenNameP = strlen_P(_name_PROGMEM); diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index 68b933d02..06763556b 100755 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -41,7 +41,7 @@ void lcd_pause_print(); void lcd_pause_usb_print(); void lcd_resume_print(); void lcd_print_stop(); -void prusa_statistics(int _message, uint8_t _col_nr = 0); +void prusa_statistics(uint8_t _message, uint8_t _col_nr = 0); unsigned char lcd_choose_color(); void lcd_load_filament_color_check(); //void lcd_mylang();