Various optimisation to change int to uint8_t

This commit saves 174 bytes of flash memory
This commit is contained in:
Guðni Már Gilbert 2021-08-03 22:42:01 +00:00
parent 8d7d1698ee
commit b716c208d7
7 changed files with 14 additions and 14 deletions

View file

@ -5293,7 +5293,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;
@ -7791,8 +7791,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
@ -11487,8 +11487,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';
@ -11497,7 +11497,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';

View file

@ -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);
}

View file

@ -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.

View file

@ -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

View file

@ -911,7 +911,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++)

View file

@ -693,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(' ');
}
@ -2737,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)
{
@ -3920,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

View file

@ -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();