for cycles' variables: int -> uint8_t where appropriate, part1

This commit is contained in:
DRracer 2019-06-12 10:31:09 +02:00
parent baa36ce740
commit 4f8ed7f123
3 changed files with 22 additions and 22 deletions

View File

@ -434,7 +434,7 @@ static void temp_runaway_stop(bool isPreheat, bool isBed);
void updatePID() void updatePID()
{ {
#ifdef PIDTEMP #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; iState_sum_max[e] = PID_INTEGRAL_DRIVE_MAX / cs.Ki;
} }
#endif #endif

10
Firmware/tmc2130.cpp Normal file → Executable file
View File

@ -158,7 +158,7 @@ void tmc2130_init()
SET_INPUT(Y_TMC2130_DIAG); SET_INPUT(Y_TMC2130_DIAG);
SET_INPUT(Z_TMC2130_DIAG); SET_INPUT(Z_TMC2130_DIAG);
SET_INPUT(E0_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_setup_chopper(axis, tmc2130_mres[axis], tmc2130_current_h[axis], tmc2130_current_r[axis]);
tmc2130_wr(axis, TMC2130_REG_TPOWERDOWN, 0x00000000); tmc2130_wr(axis, TMC2130_REG_TPOWERDOWN, 0x00000000);
@ -169,7 +169,7 @@ void tmc2130_init()
tmc2130_wr_TPWMTHRS(axis, TMC2130_TPWMTHRS); tmc2130_wr_TPWMTHRS(axis, TMC2130_TPWMTHRS);
//tmc2130_wr_THIGH(axis, TMC2130_THIGH); //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_setup_chopper(axis, tmc2130_mres[axis], tmc2130_current_h[axis], tmc2130_current_r[axis]);
tmc2130_wr(axis, TMC2130_REG_TPOWERDOWN, 0x00000000); tmc2130_wr(axis, TMC2130_REG_TPOWERDOWN, 0x00000000);
@ -183,7 +183,7 @@ void tmc2130_init()
tmc2130_wr_TPWMTHRS(axis, TMC2130_TPWMTHRS); tmc2130_wr_TPWMTHRS(axis, TMC2130_TPWMTHRS);
#endif //TMC2130_STEALTH_Z #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_setup_chopper(axis, tmc2130_mres[axis], tmc2130_current_h[axis], tmc2130_current_r[axis]);
tmc2130_wr(axis, TMC2130_REG_TPOWERDOWN, 0x00000000); tmc2130_wr(axis, TMC2130_REG_TPOWERDOWN, 0x00000000);
@ -383,7 +383,7 @@ void tmc2130_check_overtemp()
static uint32_t checktime = 0; static uint32_t checktime = 0;
if (_millis() - checktime > 1000 ) if (_millis() - checktime > 1000 )
{ {
for (int i = 0; i < 4; i++) for (uint8_t i = 0; i < 4; i++)
{ {
uint32_t drv_status = 0; uint32_t drv_status = 0;
skip_debug_msg = true; skip_debug_msg = true;
@ -392,7 +392,7 @@ void tmc2130_check_overtemp()
{ // BIT 26 - over temp prewarning ~120C (+-20C) { // BIT 26 - over temp prewarning ~120C (+-20C)
SERIAL_ERRORRPGM(MSG_TMC_OVERTEMP); SERIAL_ERRORRPGM(MSG_TMC_OVERTEMP);
SERIAL_ECHOLN(i); 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); tmc2130_wr(j, TMC2130_REG_CHOPCONF, 0x00010000);
kill(MSG_TMC_OVERTEMP); kill(MSG_TMC_OVERTEMP);
} }

View File

@ -317,7 +317,7 @@ static void lcd_implementation_drawmenu_sdfile_selected(uint8_t row, char* longF
char c; char c;
int enc_dif = lcd_encoder_diff; int enc_dif = lcd_encoder_diff;
uint8_t n = LCD_WIDTH - 1; 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_set_cursor(0, g);
lcd_print(' '); lcd_print(' ');
} }
@ -2708,11 +2708,11 @@ void lcd_change_success() {
static void lcd_loading_progress_bar(uint16_t loading_time_ms) { 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_set_cursor(i, 3);
lcd_print("."); lcd_print(".");
//loading_time_ms/20 delay //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); delay_keep_alive(loading_time_ms / 100);
} }
} }
@ -3154,7 +3154,7 @@ static void lcd_menu_xyz_offset()
float cntr[2]; float cntr[2];
world2machine_read_valid(vec_x, vec_y, cntr); 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_puts_at_P(11, i + 2, PSTR(""));
lcd_print(cntr[i]); lcd_print(cntr[i]);
@ -4822,7 +4822,7 @@ void lcd_v2_calibration()
else { else {
lcd_display_message_fullscreen_P(_i("Please load PLA filament first."));////MSG_PLEASE_LOAD_PLA c=20 r=4 lcd_display_message_fullscreen_P(_i("Please load PLA filament first."));////MSG_PLEASE_LOAD_PLA c=20 r=4
lcd_consume_click(); 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); delay_keep_alive(100);
if (lcd_clicked()) { if (lcd_clicked()) {
break; break;
@ -5549,7 +5549,7 @@ void bowden_menu() {
lcd_clear(); lcd_clear();
lcd_set_cursor(0, 0); lcd_set_cursor(0, 0);
lcd_print(">"); lcd_print(">");
for (int i = 0; i < 4; i++) { for (uint8_t i = 0; i < 4; i++) {
lcd_set_cursor(1, i); lcd_set_cursor(1, i);
lcd_print("Extruder "); lcd_print("Extruder ");
lcd_print(i); lcd_print(i);
@ -5637,7 +5637,7 @@ void bowden_menu() {
enc_dif = lcd_encoder_diff; enc_dif = lcd_encoder_diff;
lcd_set_cursor(0, cursor_pos); lcd_set_cursor(0, cursor_pos);
lcd_print(">"); lcd_print(">");
for (int i = 0; i < 4; i++) { for (uint8_t i = 0; i < 4; i++) {
lcd_set_cursor(1, i); lcd_set_cursor(1, i);
lcd_print("Extruder "); lcd_print("Extruder ");
lcd_print(i); 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); if (header) lcd_puts_at_P(0,0,header);
const bool last_visible = (first == items_no - 3); 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); 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_set_cursor(2 + item_len, i+1);
lcd_print(first + i + 1); lcd_print(first + i + 1);
@ -5825,7 +5825,7 @@ char reset_menu() {
lcd_consume_click(); lcd_consume_click();
while (1) { while (1) {
for (int i = 0; i < 4; i++) { for (uint8_t i = 0; i < 4; i++) {
lcd_set_cursor(1, i); lcd_set_cursor(1, i);
lcd_print(item[first + i]); lcd_print(item[first + i]);
} }
@ -6151,7 +6151,7 @@ unsigned char lcd_choose_color() {
item[0] = "Orange"; item[0] = "Orange";
item[1] = "Black"; item[1] = "Black";
//----------------------------------------------------- //-----------------------------------------------------
unsigned char active_rows; uint8_t active_rows;
static int first = 0; static int first = 0;
int enc_dif = 0; int enc_dif = 0;
unsigned char cursor_pos = 1; unsigned char cursor_pos = 1;
@ -6164,7 +6164,7 @@ unsigned char lcd_choose_color() {
lcd_consume_click(); lcd_consume_click();
while (1) { while (1) {
lcd_puts_at_P(0, 0, PSTR("Choose color:")); 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_set_cursor(1, i+1);
lcd_print(item[first + i]); 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: //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]); printf_P(_N("Measured axis length:%.3f\n"), measured_axis_length[i]);
if (abs(measured_axis_length[i] - axis_length) > max_error_mm) { if (abs(measured_axis_length[i] - axis_length) > max_error_mm) {
enable_endstops(false); enable_endstops(false);
@ -8065,7 +8065,7 @@ static void menu_action_sdfile(const char* filename)
const char end[5] = ".gco"; const char end[5] = ".gco";
//we are storing just first 8 characters of 8.3 filename assuming that extension is always ".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) { 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 //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'); 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); eeprom_write_byte((uint8_t*)EEPROM_DIR_DEPTH, depth);
for (uint8_t i = 0; i < depth; i++) { 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]); eeprom_write_byte((uint8_t*)EEPROM_DIRS + j + 8 * i, dir_names[i][j]);
} }
} }