Edit digipot currents via LCD, save to EEPROM

This commit is contained in:
dot-bob
2017-06-02 23:38:07 -06:00
committed by Scott Lahteine
parent 3c7bfe798d
commit b3c36c98fd
6 changed files with 164 additions and 51 deletions

View File

@ -36,13 +36,13 @@
*
*/
#define EEPROM_VERSION "V38"
#define EEPROM_VERSION "V39"
// Change EEPROM version if these are changed:
#define EEPROM_OFFSET 100
/**
* V38 EEPROM Layout:
* V39 EEPROM Layout:
*
* 100 Version (char x4)
* 104 EEPROM CRC16 (uint16_t)
@ -140,24 +140,29 @@
* 534 M200 T D filament_size (float x5) (T0..3)
*
* HAVE_TMC2130: 20 bytes
* 554 M906 X stepperX current (uint16_t)
* 556 M906 Y stepperY current (uint16_t)
* 558 M906 Z stepperZ current (uint16_t)
* 560 M906 X2 stepperX2 current (uint16_t)
* 562 M906 Y2 stepperY2 current (uint16_t)
* 564 M906 Z2 stepperZ2 current (uint16_t)
* 566 M906 E0 stepperE0 current (uint16_t)
* 568 M906 E1 stepperE1 current (uint16_t)
* 570 M906 E2 stepperE2 current (uint16_t)
* 572 M906 E3 stepperE3 current (uint16_t)
* 576 M906 E4 stepperE4 current (uint16_t)
* 554 M906 X Stepper X current (uint16_t)
* 556 M906 Y Stepper Y current (uint16_t)
* 558 M906 Z Stepper Z current (uint16_t)
* 560 M906 X2 Stepper X2 current (uint16_t)
* 562 M906 Y2 Stepper Y2 current (uint16_t)
* 564 M906 Z2 Stepper Z2 current (uint16_t)
* 566 M906 E0 Stepper E0 current (uint16_t)
* 568 M906 E1 Stepper E1 current (uint16_t)
* 570 M906 E2 Stepper E2 current (uint16_t)
* 572 M906 E3 Stepper E3 current (uint16_t)
* 576 M906 E4 Stepper E4 current (uint16_t)
*
* LIN_ADVANCE: 8 bytes
* 580 M900 K extruder_advance_k (float)
* 584 M900 WHD advance_ed_ratio (float)
*
* 588 Minimum end-point
* 1909 (588 + 36 + 9 + 288 + 988) Maximum end-point
* HAS_MOTOR_CURRENT_PWM:
* 588 M907 X Stepper XY current (uint32_t)
* 592 M907 Z Stepper Z current (uint32_t)
* 596 M907 E Stepper E current (uint32_t)
*
* 600 Minimum end-point
* 1921 (600 + 36 + 9 + 288 + 988) Maximum end-point
*
* ========================================================================
* meshes_begin (between max and min end-point, directly above)
@ -177,6 +182,7 @@ MarlinSettings settings;
#include "planner.h"
#include "temperature.h"
#include "ultralcd.h"
#include "stepper.h"
#if ENABLED(INCH_MODE_SUPPORT) || (ENABLED(ULTIPANEL) && ENABLED(TEMPERATURE_UNITS_SUPPORT))
#include "gcode.h"
@ -238,6 +244,10 @@ void MarlinSettings::postprocess() {
refresh_bed_level();
//set_bed_leveling_enabled(leveling_is_on);
#endif
#if HAS_MOTOR_CURRENT_PWM
stepper.refresh_motor_power();
#endif
}
#if ENABLED(EEPROM_SETTINGS)
@ -626,6 +636,13 @@ void MarlinSettings::postprocess() {
EEPROM_WRITE(dummy);
#endif
#if HAS_MOTOR_CURRENT_PWM
for (uint8_t q = 3; q--;) EEPROM_WRITE(stepper.motor_current_setting[q]);
#else
const uint32_t dummyui32 = 0;
for (uint8_t q = 3; q--;) EEPROM_WRITE(dummyui32);
#endif
if (!eeprom_error) {
const int eeprom_size = eeprom_index;
@ -979,6 +996,13 @@ void MarlinSettings::postprocess() {
EEPROM_READ(dummy);
#endif
#if HAS_MOTOR_CURRENT_PWM
for (uint8_t q = 3; q--;) EEPROM_READ(stepper.motor_current_setting[q]);
#else
uint32_t dummyui32;
for (uint8_t q = 3; q--;) EEPROM_READ(dummyui32);
#endif
if (working_crc == stored_crc) {
postprocess();
SERIAL_ECHO_START();
@ -1309,6 +1333,12 @@ void MarlinSettings::reset() {
planner.advance_ed_ratio = LIN_ADVANCE_E_D_RATIO;
#endif
#if HAS_MOTOR_CURRENT_PWM
uint32_t tmp_motor_current_setting[3] = PWM_MOTOR_CURRENT;
for (uint8_t q = 3; q--;)
stepper.digipot_current(q, (stepper.motor_current_setting[q] = tmp_motor_current_setting[q]));
#endif
#if ENABLED(AUTO_BED_LEVELING_UBL)
ubl.reset();
#endif
@ -1788,6 +1818,18 @@ void MarlinSettings::reset() {
SERIAL_ECHOPAIR(" M900 K", planner.extruder_advance_k);
SERIAL_ECHOLNPAIR(" R", planner.advance_ed_ratio);
#endif
#if HAS_MOTOR_CURRENT_PWM
CONFIG_ECHO_START;
if (!forReplay) {
SERIAL_ECHOLNPGM("Stepper motor currents:");
CONFIG_ECHO_START;
}
SERIAL_ECHOPAIR(" M907 X", stepper.motor_current_setting[0]);
SERIAL_ECHOPAIR(" Z", stepper.motor_current_setting[1]);
SERIAL_ECHOPAIR(" E", stepper.motor_current_setting[2]);
SERIAL_EOL();
#endif
}
#endif // !DISABLE_M503