Remove two functions EEPROM_read_B() and EEPROM_save_B()

This resolves #3218
This commit is contained in:
Guðni Már Gilbert 2021-07-02 20:02:13 +00:00 committed by Guðni Már Gilbert
parent 47b8462c38
commit 13477c65c6
3 changed files with 45 additions and 44 deletions

View File

@ -1502,7 +1502,9 @@ void setup()
#ifdef SNMM #ifdef SNMM
if (eeprom_read_dword((uint32_t*)EEPROM_BOWDEN_LENGTH) == 0x0ffffffff) { //bowden length used for SNMM if (eeprom_read_dword((uint32_t*)EEPROM_BOWDEN_LENGTH) == 0x0ffffffff) { //bowden length used for SNMM
int _z = BOWDEN_LENGTH; int _z = BOWDEN_LENGTH;
for(int i = 0; i<4; i++) EEPROM_save_B(EEPROM_BOWDEN_LENGTH + i * 2, &_z); for(uint8_t i = 0; i < 4; i++) {
eeprom_update_word((uint16_t*)EEPROM_BOWDEN_LENGTH + i, _z);
}
} }
#endif #endif
@ -1547,7 +1549,9 @@ void setup()
//eeprom_write_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 0); //eeprom_write_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 0);
eeprom_write_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 1); eeprom_write_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 1);
int16_t z_shift = 0; int16_t z_shift = 0;
for (uint8_t i = 0; i < 5; i++) EEPROM_save_B(EEPROM_PROBE_TEMP_SHIFT + i * 2, &z_shift); for (uint8_t i = 0; i < 5; i++) {
eeprom_update_word((uint16_t*)EEPROM_PROBE_TEMP_SHIFT + i, z_shift);
}
eeprom_write_byte((uint8_t*)EEPROM_TEMP_CAL_ACTIVE, 0); eeprom_write_byte((uint8_t*)EEPROM_TEMP_CAL_ACTIVE, 0);
} }
if (eeprom_read_byte((uint8_t*)EEPROM_UVLO) == 255) { if (eeprom_read_byte((uint8_t*)EEPROM_UVLO) == 255) {
@ -1571,7 +1575,9 @@ void setup()
#ifdef PAT9125 #ifdef PAT9125
fsensor_setup_interrupt(); fsensor_setup_interrupt();
#endif //PAT9125 #endif //PAT9125
for (int i = 0; i<4; i++) EEPROM_read_B(EEPROM_BOWDEN_LENGTH + i * 2, &bowden_length[i]); for (uint8_t i = 0; i < 4; i++) {
bowden_length[i] = eeprom_read_word((uint16_t*) EEPROM_BOWDEN_LENGTH + i);
}
#ifndef DEBUG_DISABLE_STARTMSGS #ifndef DEBUG_DISABLE_STARTMSGS
KEEPALIVE_STATE(PAUSED_FOR_USER); KEEPALIVE_STATE(PAUSED_FOR_USER);
@ -5434,7 +5440,9 @@ if(eSoundMode!=e_SOUND_MODE_SILENT)
{ {
float temp = (40 + i * 5); float temp = (40 + i * 5);
printf_P(_N("\nStep: %d/6 (skipped)\nPINDA temperature: %d Z shift (mm):0\n"), i + 2, (40 + i*5)); printf_P(_N("\nStep: %d/6 (skipped)\nPINDA temperature: %d Z shift (mm):0\n"), i + 2, (40 + i*5));
if (i >= 0) EEPROM_save_B(EEPROM_PROBE_TEMP_SHIFT + i * 2, &z_shift); if (i >= 0) {
eeprom_update_word((uint16_t*)EEPROM_PROBE_TEMP_SHIFT + i, z_shift);
}
if (start_temp <= temp) break; if (start_temp <= temp) break;
} }
@ -5473,7 +5481,7 @@ if(eSoundMode!=e_SOUND_MODE_SILENT)
printf_P(_N("\nPINDA temperature: %.1f Z shift (mm): %.3f"), current_temperature_pinda, current_position[Z_AXIS] - zero_z); printf_P(_N("\nPINDA temperature: %.1f Z shift (mm): %.3f"), current_temperature_pinda, current_position[Z_AXIS] - zero_z);
EEPROM_save_B(EEPROM_PROBE_TEMP_SHIFT + i * 2, &z_shift); eeprom_update_word((uint16_t*)EEPROM_PROBE_TEMP_SHIFT + i, z_shift);
} }
lcd_temp_cal_show_result(true); lcd_temp_cal_show_result(true);
homing_flag = false; homing_flag = false;
@ -5558,7 +5566,7 @@ if(eSoundMode!=e_SOUND_MODE_SILENT)
printf_P(_N("\nTemperature: %d Z shift (mm): %.3f\n"), t_c, current_position[Z_AXIS] - zero_z); printf_P(_N("\nTemperature: %d Z shift (mm): %.3f\n"), t_c, current_position[Z_AXIS] - zero_z);
EEPROM_save_B(EEPROM_PROBE_TEMP_SHIFT + i*2, &z_shift); eeprom_update_word((uint16_t*)EEPROM_PROBE_TEMP_SHIFT + i, z_shift);
} }
@ -5680,7 +5688,7 @@ if(eSoundMode!=e_SOUND_MODE_SILENT)
}else{ }else{
// Save it to the eeprom // Save it to the eeprom
babystepLoadZ = babystepz; babystepLoadZ = babystepz;
EEPROM_save_B(EEPROM_BABYSTEP_Z0+(BabyPosition*2),&babystepLoadZ); eeprom_update_word((uint16_t*)EEPROM_BABYSTEP_Z0 + BabyPosition, babystepLoadZ);
// adjust the Z // adjust the Z
babystepsTodoZadd(babystepLoadZ); babystepsTodoZadd(babystepLoadZ);
} }
@ -8363,7 +8371,9 @@ Sigma_Exit:
SERIAL_PROTOCOLLN("index, temp, ustep, um"); SERIAL_PROTOCOLLN("index, temp, ustep, um");
for (uint8_t i = 0; i < 6; i++) for (uint8_t i = 0; i < 6; i++)
{ {
if(i>0) EEPROM_read_B(EEPROM_PROBE_TEMP_SHIFT + (i-1) * 2, &usteps); if(i > 0) {
usteps = eeprom_read_word((uint16_t*) EEPROM_PROBE_TEMP_SHIFT + (i - 1));
}
float mm = ((float)usteps) / cs.axis_steps_per_unit[Z_AXIS]; float mm = ((float)usteps) / cs.axis_steps_per_unit[Z_AXIS];
i == 0 ? SERIAL_PROTOCOLPGM("n/a") : SERIAL_PROTOCOL(i - 1); i == 0 ? SERIAL_PROTOCOLPGM("n/a") : SERIAL_PROTOCOL(i - 1);
SERIAL_PROTOCOLPGM(", "); SERIAL_PROTOCOLPGM(", ");
@ -8378,21 +8388,23 @@ Sigma_Exit:
else if (code_seen('!')) { // ! - Set factory default values else if (code_seen('!')) { // ! - Set factory default values
eeprom_write_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 1); eeprom_write_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 1);
int16_t z_shift = 8; //40C - 20um - 8usteps int16_t z_shift = 8; //40C - 20um - 8usteps
EEPROM_save_B(EEPROM_PROBE_TEMP_SHIFT, &z_shift); eeprom_update_word((uint16_t*)EEPROM_PROBE_TEMP_SHIFT, z_shift);
z_shift = 24; //45C - 60um - 24usteps z_shift = 24; //45C - 60um - 24usteps
EEPROM_save_B(EEPROM_PROBE_TEMP_SHIFT + 2, &z_shift); eeprom_update_word((uint16_t*)EEPROM_PROBE_TEMP_SHIFT + 1, z_shift);
z_shift = 48; //50C - 120um - 48usteps z_shift = 48; //50C - 120um - 48usteps
EEPROM_save_B(EEPROM_PROBE_TEMP_SHIFT + 4, &z_shift); eeprom_update_word((uint16_t*)EEPROM_PROBE_TEMP_SHIFT + 2, z_shift);
z_shift = 80; //55C - 200um - 80usteps z_shift = 80; //55C - 200um - 80usteps
EEPROM_save_B(EEPROM_PROBE_TEMP_SHIFT + 6, &z_shift); eeprom_update_word((uint16_t*)EEPROM_PROBE_TEMP_SHIFT + 3, z_shift);
z_shift = 120; //60C - 300um - 120usteps z_shift = 120; //60C - 300um - 120usteps
EEPROM_save_B(EEPROM_PROBE_TEMP_SHIFT + 8, &z_shift); eeprom_update_word((uint16_t*)EEPROM_PROBE_TEMP_SHIFT + 4, z_shift);
SERIAL_PROTOCOLLN("factory restored"); SERIAL_PROTOCOLLN("factory restored");
} }
else if (code_seen('Z')) { // Z - Set all values to 0 (effectively disabling PINDA temperature compensation) else if (code_seen('Z')) { // Z - Set all values to 0 (effectively disabling PINDA temperature compensation)
eeprom_write_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 1); eeprom_write_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 1);
int16_t z_shift = 0; int16_t z_shift = 0;
for (uint8_t i = 0; i < 5; i++) EEPROM_save_B(EEPROM_PROBE_TEMP_SHIFT + i * 2, &z_shift); for (uint8_t i = 0; i < 5; i++) {
eeprom_update_word((uint16_t*)EEPROM_PROBE_TEMP_SHIFT + i, z_shift);
}
SERIAL_PROTOCOLLN("zerorized"); SERIAL_PROTOCOLLN("zerorized");
} }
else if (code_seen('S')) { // Sxxx Iyyy - Set compensation ustep value S for compensation table index I else if (code_seen('S')) { // Sxxx Iyyy - Set compensation ustep value S for compensation table index I
@ -8400,13 +8412,15 @@ Sigma_Exit:
if (code_seen('I')) { if (code_seen('I')) {
uint8_t index = code_value(); uint8_t index = code_value();
if (index < 5) { if (index < 5) {
EEPROM_save_B(EEPROM_PROBE_TEMP_SHIFT + index * 2, &usteps); eeprom_update_word((uint16_t*)EEPROM_PROBE_TEMP_SHIFT + index, usteps);
SERIAL_PROTOCOLLN("OK"); SERIAL_PROTOCOLLN("OK");
SERIAL_PROTOCOLLN("index, temp, ustep, um"); SERIAL_PROTOCOLLN("index, temp, ustep, um");
for (uint8_t i = 0; i < 6; i++) for (uint8_t i = 0; i < 6; i++)
{ {
usteps = 0; usteps = 0;
if (i>0) EEPROM_read_B(EEPROM_PROBE_TEMP_SHIFT + (i - 1) * 2, &usteps); if (i > 0) {
usteps = eeprom_read_word((uint16_t*)EEPROM_PROBE_TEMP_SHIFT + (i - 1));
}
float mm = ((float)usteps) / cs.axis_steps_per_unit[Z_AXIS]; float mm = ((float)usteps) / cs.axis_steps_per_unit[Z_AXIS];
i == 0 ? SERIAL_PROTOCOLPGM("n/a") : SERIAL_PROTOCOL(i - 1); i == 0 ? SERIAL_PROTOCOLPGM("n/a") : SERIAL_PROTOCOL(i - 1);
SERIAL_PROTOCOLPGM(", "); SERIAL_PROTOCOLPGM(", ");
@ -10898,7 +10912,7 @@ static void temp_compensation_apply() {
if (calibration_status() == CALIBRATION_STATUS_CALIBRATED) { if (calibration_status() == CALIBRATION_STATUS_CALIBRATED) {
if (target_temperature_bed % 10 == 0 && target_temperature_bed >= 60 && target_temperature_bed <= 100) { if (target_temperature_bed % 10 == 0 && target_temperature_bed >= 60 && target_temperature_bed <= 100) {
i_add = (target_temperature_bed - 60) / 10; i_add = (target_temperature_bed - 60) / 10;
EEPROM_read_B(EEPROM_PROBE_TEMP_SHIFT + i_add * 2, &z_shift); z_shift = eeprom_read_word((uint16_t*)EEPROM_PROBE_TEMP_SHIFT + i_add);
z_shift_mm = z_shift / cs.axis_steps_per_unit[Z_AXIS]; z_shift_mm = z_shift / cs.axis_steps_per_unit[Z_AXIS];
}else { }else {
//interpolation //interpolation
@ -10928,7 +10942,10 @@ float temp_comp_interpolation(float inp_temperature) {
shift[0] = 0; shift[0] = 0;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
if (i>0) EEPROM_read_B(EEPROM_PROBE_TEMP_SHIFT + (i-1) * 2, &shift[i]); //read shift in steps from EEPROM if (i > 0) {
//read shift in steps from EEPROM
shift[i] = eeprom_read_word((uint16_t*)EEPROM_PROBE_TEMP_SHIFT + (i - 1));
}
temp_C[i] = 50 + i * 10; //temperature in C temp_C[i] = 50 + i * 10; //temperature in C
#ifdef PINDA_THERMISTOR #ifdef PINDA_THERMISTOR
constexpr int start_compensating_temp = 35; constexpr int start_compensating_temp = 35;

View File

@ -2928,20 +2928,6 @@ static void lcd_menu_xyz_offset()
menu_back_if_clicked(); menu_back_if_clicked();
} }
// Save a single axis babystep value.
void EEPROM_save_B(int pos, int* value)
{
eeprom_update_byte((unsigned char*)pos, (unsigned char)((*value) & 0xff));
eeprom_update_byte((unsigned char*)pos + 1, (unsigned char)((*value) >> 8));
}
// Read a single axis babystep value.
void EEPROM_read_B(int pos, int* value)
{
*value = (int)eeprom_read_byte((unsigned char*)pos) | (int)(eeprom_read_byte((unsigned char*)pos + 1) << 8);
}
// Note: the colon behind the text (X, Y, Z) is necessary to greatly shorten // Note: the colon behind the text (X, Y, Z) is necessary to greatly shorten
// the implementation of menu_draw_float31 // the implementation of menu_draw_float31
static void lcd_move_x() { static void lcd_move_x() {
@ -3211,15 +3197,15 @@ void lcd_adjust_z() {
fsm = cursor_pos; fsm = cursor_pos;
if (fsm == 1) { if (fsm == 1) {
int babystepLoadZ = 0; int babystepLoadZ = 0;
EEPROM_read_B(EEPROM_BABYSTEP_Z, &babystepLoadZ); babystepLoadZ = eeprom_read_word((uint16_t*)EEPROM_BABYSTEP_Z);
CRITICAL_SECTION_START CRITICAL_SECTION_START
babystepsTodo[Z_AXIS] = babystepLoadZ; babystepsTodo[Z_AXIS] = babystepLoadZ;
CRITICAL_SECTION_END CRITICAL_SECTION_END
} else { } else {
int zero = 0; int zero = 0;
EEPROM_save_B(EEPROM_BABYSTEP_X, &zero); eeprom_update_word((uint16_t*)EEPROM_BABYSTEP_X, zero);
EEPROM_save_B(EEPROM_BABYSTEP_Y, &zero); eeprom_update_word((uint16_t*)EEPROM_BABYSTEP_Y, zero);
EEPROM_save_B(EEPROM_BABYSTEP_Z, &zero); eeprom_update_word((uint16_t*)EEPROM_BABYSTEP_Z, zero);
} }
_delay(500); _delay(500);
} }
@ -4213,8 +4199,8 @@ void lcd_pick_babystep(){
if (lcd_clicked()) { if (lcd_clicked()) {
fsm = cursor_pos; fsm = cursor_pos;
int babyStepZ; int babyStepZ;
EEPROM_read_B(EEPROM_BABYSTEP_Z0+((fsm-1)*2),&babyStepZ); babyStepZ = eeprom_read_word((uint16_t*)EEPROM_BABYSTEP_Z0+(fsm-1));
EEPROM_save_B(EEPROM_BABYSTEP_Z,&babyStepZ); eeprom_update_word((uint16_t*)EEPROM_BABYSTEP_Z, babyStepZ);
calibration_status_store(CALIBRATION_STATUS_CALIBRATED); calibration_status_store(CALIBRATION_STATUS_CALIBRATED);
_delay(500); _delay(500);
@ -5804,7 +5790,7 @@ void bowden_menu() {
lcd_puts_at_P(1, i, PSTR("Extruder ")); lcd_puts_at_P(1, i, PSTR("Extruder "));
lcd_print(i); lcd_print(i);
lcd_print(": "); lcd_print(": ");
EEPROM_read_B(EEPROM_BOWDEN_LENGTH + i * 2, &bowden_length[i]); bowden_length[i] = eeprom_read_word((uint16_t*)EEPROM_BOWDEN_LENGTH + i);
lcd_print(bowden_length[i] - 48); lcd_print(bowden_length[i] - 48);
} }
@ -5874,7 +5860,7 @@ void bowden_menu() {
_delay(100); _delay(100);
if (lcd_clicked()) { if (lcd_clicked()) {
Sound_MakeSound(e_SOUND_TYPE_ButtonEcho); Sound_MakeSound(e_SOUND_TYPE_ButtonEcho);
EEPROM_save_B(EEPROM_BOWDEN_LENGTH + cursor_pos * 2, &bowden_length[cursor_pos]); eeprom_update_word((uint16_t*)EEPROM_BOWDEN_LENGTH + cursor_pos, bowden_length[cursor_pos]);
if (lcd_show_fullscreen_message_yes_no_and_wait_P(PSTR("Continue with another bowden?"))) { if (lcd_show_fullscreen_message_yes_no_and_wait_P(PSTR("Continue with another bowden?"))) {
lcd_update_enable(true); lcd_update_enable(true);
lcd_clear(); lcd_clear();
@ -5884,7 +5870,7 @@ void bowden_menu() {
lcd_puts_at_P(1, i, PSTR("Extruder ")); lcd_puts_at_P(1, i, PSTR("Extruder "));
lcd_print(i); lcd_print(i);
lcd_print(": "); lcd_print(": ");
EEPROM_read_B(EEPROM_BOWDEN_LENGTH + i * 2, &bowden_length[i]); bowden_length[i] = eeprom_read_word((uint16_t*)EEPROM_BOWDEN_LENGTH + i);
lcd_print(bowden_length[i] - 48); lcd_print(bowden_length[i] - 48);
} }

View File

@ -30,8 +30,6 @@ void lcd_adjust_z();
void lcd_pick_babystep(); void lcd_pick_babystep();
void lcd_alright(); void lcd_alright();
void show_preheat_nozzle_warning(); void show_preheat_nozzle_warning();
void EEPROM_save_B(int pos, int* value);
void EEPROM_read_B(int pos, int* value);
void lcd_wait_interact(); void lcd_wait_interact();
void lcd_loading_filament(); void lcd_loading_filament();
void lcd_change_success(); void lcd_change_success();