This triggers inclusion of:
- triggering digipot_i2c_set_current in Marlin/Marlin_main.cpp (lines 4849 - 4854)
- Inclusion of all the code from Marlin/digipot_mcp4451.cpp - this file is actually included by default in the Marlin/Makefile? why is this not set in a standard include elsewhere?
- Inclusion of Wire.h in Marlin/Marlin.pde
- Inclusion of Wire.h in Marlin/Marlin.ino
- Definition of
extern void digipot_i2c_*
in Marlin/Marlin.h
This defines the number of I2C channels available on the I2C device. This is then used in Marlin/Marlin_main.cpp
This defines the current output for each of the channels defined in I2C_NUM_CHANNELS. must be defined as the example version already shown.
Of the 3 options above, the DIGIPOT_I2C_NUM_CHANNELS
and
DIGIPOT_I2C_MOTOR_CURRENTS
definitions will probably be re-usable. the
NUM_CHANNELS option may do better in the board definition header instead of in
Configuration_adv, as that is a pretty fixed value for the board?
This will set the specific I2C chip in use. so for this project, it would be MCP4018, and could possibly be used for MCP4451 (in the future maybe).
// In the board definition header #define DIGIPOT_I2C_IC MCP3018
// In something like digipot.h #define MCP3018 1 #ifdef DIGIPOT_I2C_IC // Required definitions for the modules void digipot_i2c_init(); void digipot_i2c_set_current(); #if DIGIPOT_I2C_IC == MCP3018 #include <digipot_mcp3018.cpp> #endif #endif
This will set the pin which defines the SCL - infact could always be set to be an array if a board uses multiple SCL lines (though that would be a future improvement).
// In the board definition header #define DIGIPOT_I2C_SCL 68
This will set the pin(s) for the various I2C pot data lines - in standard X,Y,Z,A,B,C,D,E etc. order.
// In the board definition header #define DIGIPOT_I2C_SDA {94, 90, 86, 73, 69}
Setting the trimpots through M907 will need to be looked at, as well as how that actually gets saved to the EEPROM, if at all - if its not, then may not integrate that currently, as otherwise on re-starting the printer, the MCP3018's will lose their values - they have volatile memory.