Merge pull request #4893 from thinkyhead/rc_stat_led_check

Define status LED pins without condition
This commit is contained in:
Scott Lahteine 2016-09-25 18:50:47 -05:00 committed by GitHub
commit 9cebbabd05
21 changed files with 1011 additions and 980 deletions

View File

@ -462,10 +462,13 @@
#define HAS_SOLENOID_1 (PIN_EXISTS(SOL1))
#define HAS_SOLENOID_2 (PIN_EXISTS(SOL2))
#define HAS_SOLENOID_3 (PIN_EXISTS(SOL3))
#define HAS_MICROSTEPS (PIN_EXISTS(X_MS1))
#define HAS_MICROSTEPS_X (PIN_EXISTS(X_MS1))
#define HAS_MICROSTEPS_Y (PIN_EXISTS(Y_MS1))
#define HAS_MICROSTEPS_Z (PIN_EXISTS(Z_MS1))
#define HAS_MICROSTEPS_E0 (PIN_EXISTS(E0_MS1))
#define HAS_MICROSTEPS_E1 (PIN_EXISTS(E1_MS1))
#define HAS_MICROSTEPS_E2 (PIN_EXISTS(E2_MS1))
#define HAS_MICROSTEPS (HAS_MICROSTEPS_X || HAS_MICROSTEPS_Y || HAS_MICROSTEPS_Z || HAS_MICROSTEPS_E0 || HAS_MICROSTEPS_E1 || HAS_MICROSTEPS_E2)
#define HAS_STEPPER_RESET (PIN_EXISTS(STEPPER_RESET))
#define HAS_X_ENABLE (PIN_EXISTS(X_ENABLE))
#define HAS_X2_ENABLE (PIN_EXISTS(X2_ENABLE))

View File

@ -781,7 +781,7 @@ void setup_killpin() {
#if ENABLED(FILAMENT_RUNOUT_SENSOR)
void setup_filrunoutpin() {
pinMode(FIL_RUNOUT_PIN, INPUT);
SET_INPUT(FIL_RUNOUT_PIN);
#if ENABLED(ENDSTOPPULLUP_FIL_RUNOUT)
WRITE(FIL_RUNOUT_PIN, HIGH);
#endif
@ -859,10 +859,9 @@ void servo_init() {
*/
#if HAS_STEPPER_RESET
void disableStepperDrivers() {
pinMode(STEPPER_RESET_PIN, OUTPUT);
digitalWrite(STEPPER_RESET_PIN, LOW); // drive it down to hold in reset motor driver chips
OUT_WRITE(STEPPER_RESET_PIN, LOW); // drive it down to hold in reset motor driver chips
}
void enableStepperDrivers() { pinMode(STEPPER_RESET_PIN, INPUT); } // set to input, which allows it to be pulled high by pullups
void enableStepperDrivers() { SET_INPUT(STEPPER_RESET_PIN); } // set to input, which allows it to be pulled high by pullups
#endif
#if ENABLED(EXPERIMENTAL_I2CBUS) && I2C_SLAVE_ADDRESS > 0
@ -6514,18 +6513,19 @@ inline void gcode_M503() {
inline void gcode_M907() {
#if HAS_DIGIPOTSS
LOOP_XYZE(i)
if (code_seen(axis_codes[i])) stepper.digipot_current(i, code_value_int());
if (code_seen(axis_codes[i])) stepper.digipot_current(i, code_value_int());
if (code_seen('B')) stepper.digipot_current(4, code_value_int());
if (code_seen('S')) for (int i = 0; i <= 4; i++) stepper.digipot_current(i, code_value_int());
#endif
#if PIN_EXISTS(MOTOR_CURRENT_PWM_XY)
if (code_seen('X')) stepper.digipot_current(0, code_value_int());
#endif
#if PIN_EXISTS(MOTOR_CURRENT_PWM_Z)
if (code_seen('Z')) stepper.digipot_current(1, code_value_int());
#endif
#if PIN_EXISTS(MOTOR_CURRENT_PWM_E)
if (code_seen('E')) stepper.digipot_current(2, code_value_int());
#elif HAS_MOTOR_CURRENT_PWM
#if PIN_EXISTS(MOTOR_CURRENT_PWM_XY)
if (code_seen('X')) stepper.digipot_current(0, code_value_int());
#endif
#if PIN_EXISTS(MOTOR_CURRENT_PWM_Z)
if (code_seen('Z')) stepper.digipot_current(1, code_value_int());
#endif
#if PIN_EXISTS(MOTOR_CURRENT_PWM_E)
if (code_seen('E')) stepper.digipot_current(2, code_value_int());
#endif
#endif
#if ENABLED(DIGIPOT_I2C)
// this one uses actual amps in floating point
@ -8718,8 +8718,8 @@ void prepare_move_to_destination() {
bool new_led = (max_temp > 55.0) ? true : (max_temp < 54.0) ? false : red_led;
if (new_led != red_led) {
red_led = new_led;
digitalWrite(STAT_LED_RED, new_led ? HIGH : LOW);
digitalWrite(STAT_LED_BLUE, new_led ? LOW : HIGH);
WRITE(STAT_LED_RED_PIN, new_led ? HIGH : LOW);
WRITE(STAT_LED_BLUE_PIN, new_led ? LOW : HIGH);
}
}
}
@ -9193,20 +9193,17 @@ void setup() {
#endif
#if ENABLED(Z_PROBE_SLED) && PIN_EXISTS(SLED)
pinMode(SLED_PIN, OUTPUT);
digitalWrite(SLED_PIN, LOW); // turn it off
OUT_WRITE(SLED_PIN, LOW); // turn it off
#endif // Z_PROBE_SLED
setup_homepin();
#ifdef STAT_LED_RED
pinMode(STAT_LED_RED, OUTPUT);
digitalWrite(STAT_LED_RED, LOW); // turn it off
#if PIN_EXISTS(STAT_LED_RED)
OUT_WRITE(STAT_LED_RED_PIN, LOW); // turn it off
#endif
#ifdef STAT_LED_BLUE
pinMode(STAT_LED_BLUE, OUTPUT);
digitalWrite(STAT_LED_BLUE, LOW); // turn it off
#if PIN_EXISTS(STAT_LED_BLUE)
OUT_WRITE(STAT_LED_BLUE_PIN, LOW); // turn it off
#endif
lcd_init();

View File

@ -61,10 +61,6 @@
#error "Z_LATE_ENABLE can't be used with COREXZ."
#elif defined(X_HOME_RETRACT_MM)
#error "[XYZ]_HOME_RETRACT_MM settings have been renamed [XYZ]_HOME_BUMP_MM."
#elif defined(BEEPER)
#error "BEEPER is now BEEPER_PIN. Please update your pins definitions."
#elif defined(SDCARDDETECT)
#error "SDCARDDETECT is now SD_DETECT_PIN. Please update your pins definitions."
#elif defined(SDCARDDETECTINVERTED)
#error "SDCARDDETECTINVERTED is now SD_DETECT_INVERTED. Please update your configuration."
#elif defined(BTENABLED)
@ -143,6 +139,16 @@
#error "SCARA is now MORGAN_SCARA. Please update your configuration."
#elif defined(AUTO_BED_LEVELING_GRID_POINTS)
#error "AUTO_BED_LEVELING_GRID_POINTS is now ABL_GRID_POINTS_X and ABL_GRID_POINTS_Y. Please update your configuration."
#elif defined(BEEPER)
#error "BEEPER is now BEEPER_PIN. Please update your pins definitions."
#elif defined(SDCARDDETECT)
#error "SDCARDDETECT is now SD_DETECT_PIN. Please update your pins definitions."
#elif defined(STAT_LED_RED) || defined(STAT_LED_BLUE)
#error "STAT_LED_RED/STAT_LED_BLUE are now STAT_LED_RED_PIN/STAT_LED_BLUE_PIN. Please update your pins definitions."
#elif defined(LCD_PIN_BL)
#error "LCD_PIN_BL is now LCD_BACKLIGHT_PIN. Please update your pins definitions."
#elif defined(LCD_PIN_RESET)
#error "LCD_PIN_RESET is now LCD_RESET_PIN. Please update your pins definitions."
#endif
/**
@ -722,6 +728,13 @@
#error "TEMP_SENSOR_1 is required with TEMP_SENSOR_1_AS_REDUNDANT."
#endif
/**
* Temperature status LEDs
*/
#if ENABLED(TEMP_STAT_LEDS) && !(PIN_EXISTS(STAT_LED_RED) && PIN_EXISTS(STAT_LED_BLUE))
#error "TEMP_STAT_LEDS requires STAT_LED_RED_PIN and STAT_LED_BLUE_PIN."
#endif
/**
* Basic 2-nozzle duplication mode
*/

View File

@ -302,16 +302,16 @@ bool Sd2Card::init(uint8_t sckRateID, uint8_t chipSelectPin) {
// set pin modes
pinMode(chipSelectPin_, OUTPUT);
chipSelectHigh();
pinMode(SPI_MISO_PIN, INPUT);
pinMode(SPI_MOSI_PIN, OUTPUT);
pinMode(SPI_SCK_PIN, OUTPUT);
SET_INPUT(SPI_MISO_PIN);
SET_OUTPUT(SPI_MOSI_PIN);
SET_OUTPUT(SPI_SCK_PIN);
#if DISABLED(SOFTWARE_SPI)
// SS must be in output mode even it is not chip select
pinMode(SS_PIN, OUTPUT);
SET_OUTPUT(SS_PIN);
// set SS high - may be chip select for another SPI device
#if SET_SPI_SS_HIGH
digitalWrite(SS_PIN, HIGH);
WRITE(SS_PIN, HIGH);
#endif // SET_SPI_SS_HIGH
// set SCK rate for initialization commands
spiRate_ = SPI_SD_INIT_RATE;

File diff suppressed because it is too large Load Diff

View File

@ -104,53 +104,51 @@
//
// Heaters / Fans
//
#define HEATER_0_PIN 9
#define HEATER_1_PIN 7
#define HEATER_BED_PIN 3
#define HEATER_0_PIN 9
#define HEATER_1_PIN 7
#define HEATER_BED_PIN 3
#define FAN_PIN 8
#define FAN0_PIN 6
#define FAN1_PIN 2
#define FAN_PIN 8
#define FAN0_PIN 6
#define FAN1_PIN 2
#define TEMP_0_PIN 0
#define TEMP_BED_PIN 7
#define TEMP_0_PIN 0
#define TEMP_BED_PIN 7
#define SDSS 53
#define LED_PIN 13
#define PS_ON_PIN 4
#define SDSS 53
#define LED_PIN 13
#define PS_ON_PIN 4
//
// LCD / Controller
//
#define LCD_PINS_RS 70 //ext2_5
#define LCD_PINS_ENABLE 71 //ext2_7
#define LCD_PINS_D4 72 ///////Ext2 9 ?
#define LCD_PINS_D5 73 ///////Ext2 11 ?
#define LCD_PINS_D6 74 //ext2_13
#define LCD_PINS_D7 75 ///////Ext2 15 ?
#define BEEPER_PIN -1
#define LCD_PINS_RS 70 //ext2_5
#define LCD_PINS_ENABLE 71 //ext2_7
#define LCD_PINS_D4 72 ///////Ext2 9 ?
#define LCD_PINS_D5 73 ///////Ext2 11 ?
#define LCD_PINS_D6 74 //ext2_13
#define LCD_PINS_D7 75 ///////Ext2 15 ?
#define BEEPER_PIN -1
#define BTN_HOME 80 //ext_16
#define BTN_CENTER 81 //ext_14
#define BTN_ENC BTN_CENTER
#define BTN_RIGHT 82 //ext_12
#define BTN_LEFT 83 //ext_10
#define BTN_UP 84 //ext2_8
#define BTN_DOWN 85 //ext2_6
#define BTN_HOME 80 //ext_16
#define BTN_CENTER 81 //ext_14
#define BTN_ENC BTN_CENTER
#define BTN_RIGHT 82 //ext_12
#define BTN_LEFT 83 //ext_10
#define BTN_UP 84 //ext2_8
#define BTN_DOWN 85 //ext2_6
#define HOME_PIN BTN_HOME
#define HOME_PIN BTN_HOME
#if ENABLED(VIKI2) || ENABLED(miniVIKI)
#define BEEPER_PIN 44
#define BEEPER_PIN 44
// Pins for DOGM SPI LCD Support
#define DOGLCD_A0 70
#define DOGLCD_CS 71
#define DOGLCD_A0 70
#define DOGLCD_CS 71
#define LCD_SCREEN_ROT_180
#define SD_DETECT_PIN -1 // Pin 72 if using easy adapter board
#define SD_DETECT_PIN -1 // Pin 72 if using easy adapter board
#if ENABLED(TEMP_STAT_LEDS)
#define STAT_LED_RED 22
#define STAT_LED_BLUE 32
#endif
#define STAT_LED_RED_PIN 22
#define STAT_LED_BLUE_PIN 32
#endif // VIKI2/miniVIKI

View File

@ -41,16 +41,14 @@
#define DOGLCD_CS 32
#define BTN_ENC 12
#if ENABLED(TEMP_STAT_LEDS)
#undef STAT_LED_RED
#undef STAT_LED_BLUE
#define STAT_LED_RED 64
#define STAT_LED_BLUE 63
#endif
#undef STAT_LED_RED_PIN
#undef STAT_LED_BLUE_PIN
#define STAT_LED_RED_PIN 64
#define STAT_LED_BLUE_PIN 63
#elif ENABLED(TEMP_STAT_LEDS)
#else
#define STAT_LED_RED 6
#define STAT_LED_BLUE 11
#define STAT_LED_RED_PIN 6
#define STAT_LED_BLUE_PIN 11
#endif

View File

@ -117,6 +117,6 @@
#undef SD_DETECT_PIN
#define SD_DETECT_PIN 49 // For easy adapter board
#else
#define STAT_LED_RED 32
#define STAT_LED_BLUE 35
#define STAT_LED_RED_PIN 32
#define STAT_LED_BLUE_PIN 35
#endif

View File

@ -115,5 +115,5 @@
//
// Misc. Functions
//
#define STAT_LED_BLUE -1
#define STAT_LED_RED 31
#define STAT_LED_BLUE_PIN -1
#define STAT_LED_RED_PIN 31

View File

@ -111,8 +111,8 @@
//#define UI1 43
//#define UI2 37
#define STAT_LED_BLUE -1
#define STAT_LED_RED 10 // TOOL_0_PWM_PIN
#define STAT_LED_BLUE_PIN -1
#define STAT_LED_RED_PIN 10 // TOOL_0_PWM_PIN
//
// SD Card

View File

@ -134,7 +134,7 @@
// Pins for DOGM SPI LCD Support
#define DOGLCD_A0 47
#define DOGLCD_CS 45
#define LCD_PIN_BL 44 // backlight LED on PA3
#define LCD_BACKLIGHT_PIN 44 // backlight LED on PA3
#define KILL_PIN 12
// GLCD features

View File

@ -120,9 +120,9 @@
#define BEEPER_PIN 25
// yellow RED-LED
#define STAT_LED_RED 16
#define STAT_LED_RED_PIN 16
// white BLUE-LED
#define STAT_LED_BLUE 17
#define STAT_LED_BLUE_PIN 17
#endif

View File

@ -131,8 +131,8 @@
#define SDSS 45
#define SD_DETECT_PIN -1 // FastIO (Manual says 72 I'm not certain cause I can't test)
#if ENABLED(TEMP_STAT_LEDS)
#define STAT_LED_RED 12 //Non-FastIO
#define STAT_LED_BLUE 10 //Non-FastIO
#endif
#define STAT_LED_RED_PIN 12 //Non-FastIO
#define STAT_LED_BLUE_PIN 10 //Non-FastIO
#endif

View File

@ -117,21 +117,18 @@
#if ENABLED(VIKI2) || ENABLED(miniVIKI)
#define BEEPER_PIN 32 //FastIO
// Pins for DOGM SPI LCD Support
#define DOGLCD_A0 42 //Non-FastIO
#define DOGLCD_CS 43 //Non-FastIO
#define LCD_SCREEN_ROT_180
//The encoder and click button (FastIO Pins)
// (FastIO Pins)
#define BTN_EN1 26
#define BTN_EN2 27
#define BTN_ENC 47
#define SDSS 45
#define SD_DETECT_PIN -1 // FastIO (Manual says 72 I'm not certain cause I can't test)
#define SD_DETECT_PIN -1 // FastIO (Manual says 72)
#if ENABLED(TEMP_STAT_LEDS)
#define STAT_LED_RED 12 //Non-FastIO
#define STAT_LED_BLUE 10 //Non-FastIO
#endif
#define STAT_LED_RED_PIN 12 //Non-FastIO
#define STAT_LED_BLUE_PIN 10 //Non-FastIO
#endif

View File

@ -169,10 +169,8 @@
#define SD_DETECT_PIN -1 // Pin 72 if using easy adapter board
#if ENABLED(TEMP_STAT_LEDS)
#define STAT_LED_RED 22
#define STAT_LED_BLUE 32
#endif
#define STAT_LED_RED_PIN 22
#define STAT_LED_BLUE_PIN 32
#else

View File

@ -240,7 +240,7 @@
#define KILL_PIN 41
#if ENABLED(BQ_LCD_SMART_CONTROLLER)
#define LCD_PIN_BL 39
#define LCD_BACKLIGHT_PIN 39
#endif
#elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD)
@ -280,10 +280,9 @@
#define KILL_PIN 31
#if ENABLED(TEMP_STAT_LEDS)
#define STAT_LED_RED 32
#define STAT_LED_BLUE 35
#endif
#define STAT_LED_RED_PIN 32
#define STAT_LED_BLUE_PIN 35
#elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER)
#define BTN_EN1 35 // reverse if the encoder turns the wrong way.
#define BTN_EN2 37
@ -294,13 +293,13 @@
#define BEEPER_PIN 23
#define DOGLCD_CS 29
#define DOGLCD_A0 27
#define LCD_PIN_BL 33
#define LCD_BACKLIGHT_PIN 33
#elif ENABLED(MINIPANEL)
#define BEEPER_PIN 42
// Pins for DOGM SPI LCD Support
#define DOGLCD_A0 44
#define DOGLCD_CS 66
#define LCD_PIN_BL 65 // backlight LED on A11/D65
#define LCD_BACKLIGHT_PIN 65 // backlight LED on A11/D65
#define SDSS 53
#define KILL_PIN 64

View File

@ -56,7 +56,7 @@
#if IS_MELZI
#define LED_PIN 27 // On some broken versions of the Sanguino libraries the pin definitions are wrong, so LED_PIN needs to be 28. But you should upgrade your Sanguino libraries! See #368.
#elif MB(STB_11)
#define LCD_PIN_BL 17 // LCD backlight LED
#define LCD_BACKLIGHT_PIN 17 // LCD backlight LED
#endif
#if ENABLED(Z_PROBE_SLED)
@ -173,7 +173,7 @@
// Pins for DOGM SPI LCD Support
#define DOGLCD_A0 30
#define DOGLCD_CS 17
#define LCD_PIN_BL 28 // backlight LED on PA3
#define LCD_BACKLIGHT_PIN 28 // backlight LED on PA3
// GLCD features
#define LCD_CONTRAST 1
// Uncomment screen orientation

View File

@ -733,19 +733,27 @@ void Stepper::isr() {
void Stepper::init() {
digipot_init(); //Initialize Digipot Motor Current
microstep_init(); //Initialize Microstepping Pins
// Init Digipot Motor Current
#if HAS_DIGIPOTSS || HAS_MOTOR_CURRENT_PWM
digipot_init();
#endif
// initialise TMC Steppers
// Init Microstepping Pins
#if HAS_MICROSTEPS
microstep_init();
#endif
// Init TMC Steppers
#if ENABLED(HAVE_TMCDRIVER)
tmc_init();
#endif
// initialise L6470 Steppers
// Init L6470 Steppers
#if ENABLED(HAVE_L6470DRIVER)
L6470_init();
#endif
// Initialize Dir Pins
// Init Dir Pins
#if HAS_X_DIR
X_DIR_INIT;
#endif
@ -777,8 +785,7 @@ void Stepper::init() {
E3_DIR_INIT;
#endif
//Initialize Enable Pins - steppers default to disabled.
// Init Enable Pins - steppers default to disabled.
#if HAS_X_ENABLE
X_ENABLE_INIT;
if (!X_ENABLE_ON) X_ENABLE_WRITE(HIGH);
@ -787,7 +794,6 @@ void Stepper::init() {
if (!X_ENABLE_ON) X2_ENABLE_WRITE(HIGH);
#endif
#endif
#if HAS_Y_ENABLE
Y_ENABLE_INIT;
if (!Y_ENABLE_ON) Y_ENABLE_WRITE(HIGH);
@ -796,7 +802,6 @@ void Stepper::init() {
if (!Y_ENABLE_ON) Y2_ENABLE_WRITE(HIGH);
#endif
#endif
#if HAS_Z_ENABLE
Z_ENABLE_INIT;
if (!Z_ENABLE_ON) Z_ENABLE_WRITE(HIGH);
@ -805,7 +810,6 @@ void Stepper::init() {
if (!Z_ENABLE_ON) Z2_ENABLE_WRITE(HIGH);
#endif
#endif
#if HAS_E0_ENABLE
E0_ENABLE_INIT;
if (!E_ENABLE_ON) E0_ENABLE_WRITE(HIGH);
@ -823,9 +827,7 @@ void Stepper::init() {
if (!E_ENABLE_ON) E3_ENABLE_WRITE(HIGH);
#endif
//
// Init endstops and pullups here
//
// Init endstops and pullups
endstops.init();
#define _STEP_INIT(AXIS) AXIS ##_STEP_INIT
@ -839,7 +841,7 @@ void Stepper::init() {
#define E_AXIS_INIT(NUM) AXIS_INIT(e## NUM, E## NUM, E)
// Initialize Step Pins
// Init Step Pins
#if HAS_X_STEP
#if ENABLED(X_DUAL_STEPPER_DRIVERS) || ENABLED(DUAL_X_CARRIAGE)
X2_STEP_INIT;
@ -1155,143 +1157,167 @@ void Stepper::report_positions() {
// From Arduino DigitalPotControl example
void Stepper::digitalPotWrite(int address, int value) {
digitalWrite(DIGIPOTSS_PIN, LOW); // take the SS pin low to select the chip
WRITE(DIGIPOTSS_PIN, LOW); // take the SS pin low to select the chip
SPI.transfer(address); // send in the address and value via SPI:
SPI.transfer(value);
digitalWrite(DIGIPOTSS_PIN, HIGH); // take the SS pin high to de-select the chip:
WRITE(DIGIPOTSS_PIN, HIGH); // take the SS pin high to de-select the chip:
//delay(10);
}
#endif //HAS_DIGIPOTSS
void Stepper::digipot_init() {
#if HAS_DIGIPOTSS
const uint8_t digipot_motor_current[] = DIGIPOT_MOTOR_CURRENT;
#if HAS_DIGIPOTSS || HAS_MOTOR_CURRENT_PWM
SPI.begin();
pinMode(DIGIPOTSS_PIN, OUTPUT);
for (uint8_t i = 0; i < COUNT(digipot_motor_current); i++) {
//digitalPotWrite(digipot_ch[i], digipot_motor_current[i]);
digipot_current(i, digipot_motor_current[i]);
}
#endif
#if HAS_MOTOR_CURRENT_PWM
#if PIN_EXISTS(MOTOR_CURRENT_PWM_XY)
pinMode(MOTOR_CURRENT_PWM_XY_PIN, OUTPUT);
digipot_current(0, motor_current_setting[0]);
#endif
#if PIN_EXISTS(MOTOR_CURRENT_PWM_Z)
pinMode(MOTOR_CURRENT_PWM_Z_PIN, OUTPUT);
digipot_current(1, motor_current_setting[1]);
#endif
#if PIN_EXISTS(MOTOR_CURRENT_PWM_E)
pinMode(MOTOR_CURRENT_PWM_E_PIN, OUTPUT);
digipot_current(2, motor_current_setting[2]);
#endif
//Set timer5 to 31khz so the PWM of the motor power is as constant as possible. (removes a buzzing noise)
TCCR5B = (TCCR5B & ~(_BV(CS50) | _BV(CS51) | _BV(CS52))) | _BV(CS50);
#endif
}
void Stepper::digipot_current(uint8_t driver, int current) {
#if HAS_DIGIPOTSS
const uint8_t digipot_ch[] = DIGIPOT_CHANNELS;
digitalPotWrite(digipot_ch[driver], current);
#elif HAS_MOTOR_CURRENT_PWM
#define _WRITE_CURRENT_PWM(P) analogWrite(P, 255L * current / (MOTOR_CURRENT_PWM_RANGE))
switch (driver) {
void Stepper::digipot_init() {
#if HAS_DIGIPOTSS
static const uint8_t digipot_motor_current[] = DIGIPOT_MOTOR_CURRENT;
SPI.begin();
SET_OUTPUT(DIGIPOTSS_PIN);
for (uint8_t i = 0; i < COUNT(digipot_motor_current); i++) {
//digitalPotWrite(digipot_ch[i], digipot_motor_current[i]);
digipot_current(i, digipot_motor_current[i]);
}
#elif HAS_MOTOR_CURRENT_PWM
#if PIN_EXISTS(MOTOR_CURRENT_PWM_XY)
case 0: _WRITE_CURRENT_PWM(MOTOR_CURRENT_PWM_XY_PIN); break;
SET_OUTPUT(MOTOR_CURRENT_PWM_XY_PIN);
digipot_current(0, motor_current_setting[0]);
#endif
#if PIN_EXISTS(MOTOR_CURRENT_PWM_Z)
case 1: _WRITE_CURRENT_PWM(MOTOR_CURRENT_PWM_Z_PIN); break;
SET_OUTPUT(MOTOR_CURRENT_PWM_Z_PIN);
digipot_current(1, motor_current_setting[1]);
#endif
#if PIN_EXISTS(MOTOR_CURRENT_PWM_E)
case 2: _WRITE_CURRENT_PWM(MOTOR_CURRENT_PWM_E_PIN); break;
SET_OUTPUT(MOTOR_CURRENT_PWM_E_PIN);
digipot_current(2, motor_current_setting[2]);
#endif
}
#else
UNUSED(driver);
UNUSED(current);
#endif
}
//Set timer5 to 31khz so the PWM of the motor power is as constant as possible. (removes a buzzing noise)
TCCR5B = (TCCR5B & ~(_BV(CS50) | _BV(CS51) | _BV(CS52))) | _BV(CS50);
#endif
}
void Stepper::microstep_init() {
#if HAS_MICROSTEPS_E1
pinMode(E1_MS1_PIN, OUTPUT);
pinMode(E1_MS2_PIN, OUTPUT);
#endif
void Stepper::digipot_current(uint8_t driver, int current) {
#if HAS_DIGIPOTSS
const uint8_t digipot_ch[] = DIGIPOT_CHANNELS;
digitalPotWrite(digipot_ch[driver], current);
#elif HAS_MOTOR_CURRENT_PWM
#define _WRITE_CURRENT_PWM(P) analogWrite(P, 255L * current / (MOTOR_CURRENT_PWM_RANGE))
switch (driver) {
#if PIN_EXISTS(MOTOR_CURRENT_PWM_XY)
case 0: _WRITE_CURRENT_PWM(MOTOR_CURRENT_PWM_XY_PIN); break;
#endif
#if PIN_EXISTS(MOTOR_CURRENT_PWM_Z)
case 1: _WRITE_CURRENT_PWM(MOTOR_CURRENT_PWM_Z_PIN); break;
#endif
#if PIN_EXISTS(MOTOR_CURRENT_PWM_E)
case 2: _WRITE_CURRENT_PWM(MOTOR_CURRENT_PWM_E_PIN); break;
#endif
}
#endif
}
#if HAS_MICROSTEPS
pinMode(X_MS1_PIN, OUTPUT);
pinMode(X_MS2_PIN, OUTPUT);
pinMode(Y_MS1_PIN, OUTPUT);
pinMode(Y_MS2_PIN, OUTPUT);
pinMode(Z_MS1_PIN, OUTPUT);
pinMode(Z_MS2_PIN, OUTPUT);
pinMode(E0_MS1_PIN, OUTPUT);
pinMode(E0_MS2_PIN, OUTPUT);
const uint8_t microstep_modes[] = MICROSTEP_MODES;
#endif
#if HAS_MICROSTEPS
/**
* Software-controlled Microstepping
*/
void Stepper::microstep_init() {
SET_OUTPUT(X_MS1_PIN);
SET_OUTPUT(X_MS2_PIN);
#if HAS_MICROSTEPS_Y
SET_OUTPUT(Y_MS1_PIN);
SET_OUTPUT(Y_MS2_PIN);
#endif
#if HAS_MICROSTEPS_Z
SET_OUTPUT(Z_MS1_PIN);
SET_OUTPUT(Z_MS2_PIN);
#endif
#if HAS_MICROSTEPS_E0
SET_OUTPUT(E0_MS1_PIN);
SET_OUTPUT(E0_MS2_PIN);
#endif
#if HAS_MICROSTEPS_E1
SET_OUTPUT(E1_MS1_PIN);
SET_OUTPUT(E1_MS2_PIN);
#endif
static const uint8_t microstep_modes[] = MICROSTEP_MODES;
for (uint16_t i = 0; i < COUNT(microstep_modes); i++)
microstep_mode(i, microstep_modes[i]);
#endif
}
}
/**
* Software-controlled Microstepping
*/
void Stepper::microstep_ms(uint8_t driver, int8_t ms1, int8_t ms2) {
if (ms1 >= 0) switch (driver) {
case 0: digitalWrite(X_MS1_PIN, ms1); break;
#if HAS_MICROSTEPS_Y
case 1: digitalWrite(Y_MS1_PIN, ms1); break;
#endif
#if HAS_MICROSTEPS_Z
case 2: digitalWrite(Z_MS1_PIN, ms1); break;
#endif
#if HAS_MICROSTEPS_E0
case 3: digitalWrite(E0_MS1_PIN, ms1); break;
#endif
#if HAS_MICROSTEPS_E1
case 4: digitalWrite(E1_MS1_PIN, ms1); break;
#endif
}
if (ms2 >= 0) switch (driver) {
case 0: digitalWrite(X_MS2_PIN, ms2); break;
#if HAS_MICROSTEPS_Y
case 1: digitalWrite(Y_MS2_PIN, ms2); break;
#endif
#if HAS_MICROSTEPS_Z
case 2: digitalWrite(Z_MS2_PIN, ms2); break;
#endif
#if HAS_MICROSTEPS_E0
case 3: digitalWrite(E0_MS2_PIN, ms2); break;
#endif
#if HAS_MICROSTEPS_E1
case 4: digitalWrite(E1_MS2_PIN, ms2); break;
#endif
}
}
void Stepper::microstep_ms(uint8_t driver, int8_t ms1, int8_t ms2) {
if (ms1 >= 0) switch (driver) {
case 0: digitalWrite(X_MS1_PIN, ms1); break;
case 1: digitalWrite(Y_MS1_PIN, ms1); break;
case 2: digitalWrite(Z_MS1_PIN, ms1); break;
case 3: digitalWrite(E0_MS1_PIN, ms1); break;
void Stepper::microstep_mode(uint8_t driver, uint8_t stepping_mode) {
switch (stepping_mode) {
case 1: microstep_ms(driver, MICROSTEP1); break;
case 2: microstep_ms(driver, MICROSTEP2); break;
case 4: microstep_ms(driver, MICROSTEP4); break;
case 8: microstep_ms(driver, MICROSTEP8); break;
case 16: microstep_ms(driver, MICROSTEP16); break;
}
}
void Stepper::microstep_readings() {
SERIAL_PROTOCOLLNPGM("MS1,MS2 Pins");
SERIAL_PROTOCOLPGM("X: ");
SERIAL_PROTOCOL(READ(X_MS1_PIN));
SERIAL_PROTOCOLLN(READ(X_MS2_PIN));
#if HAS_MICROSTEPS_Y
SERIAL_PROTOCOLPGM("Y: ");
SERIAL_PROTOCOL(READ(Y_MS1_PIN));
SERIAL_PROTOCOLLN(READ(Y_MS2_PIN));
#endif
#if HAS_MICROSTEPS_Z
SERIAL_PROTOCOLPGM("Z: ");
SERIAL_PROTOCOL(READ(Z_MS1_PIN));
SERIAL_PROTOCOLLN(READ(Z_MS2_PIN));
#endif
#if HAS_MICROSTEPS_E0
SERIAL_PROTOCOLPGM("E0: ");
SERIAL_PROTOCOL(READ(E0_MS1_PIN));
SERIAL_PROTOCOLLN(READ(E0_MS2_PIN));
#endif
#if HAS_MICROSTEPS_E1
case 4: digitalWrite(E1_MS1_PIN, ms1); break;
SERIAL_PROTOCOLPGM("E1: ");
SERIAL_PROTOCOL(READ(E1_MS1_PIN));
SERIAL_PROTOCOLLN(READ(E1_MS2_PIN));
#endif
}
if (ms2 >= 0) switch (driver) {
case 0: digitalWrite(X_MS2_PIN, ms2); break;
case 1: digitalWrite(Y_MS2_PIN, ms2); break;
case 2: digitalWrite(Z_MS2_PIN, ms2); break;
case 3: digitalWrite(E0_MS2_PIN, ms2); break;
#if PIN_EXISTS(E1_MS2)
case 4: digitalWrite(E1_MS2_PIN, ms2); break;
#endif
}
}
void Stepper::microstep_mode(uint8_t driver, uint8_t stepping_mode) {
switch (stepping_mode) {
case 1: microstep_ms(driver, MICROSTEP1); break;
case 2: microstep_ms(driver, MICROSTEP2); break;
case 4: microstep_ms(driver, MICROSTEP4); break;
case 8: microstep_ms(driver, MICROSTEP8); break;
case 16: microstep_ms(driver, MICROSTEP16); break;
}
}
void Stepper::microstep_readings() {
SERIAL_PROTOCOLLNPGM("MS1,MS2 Pins");
SERIAL_PROTOCOLPGM("X: ");
SERIAL_PROTOCOL(digitalRead(X_MS1_PIN));
SERIAL_PROTOCOLLN(digitalRead(X_MS2_PIN));
SERIAL_PROTOCOLPGM("Y: ");
SERIAL_PROTOCOL(digitalRead(Y_MS1_PIN));
SERIAL_PROTOCOLLN(digitalRead(Y_MS2_PIN));
SERIAL_PROTOCOLPGM("Z: ");
SERIAL_PROTOCOL(digitalRead(Z_MS1_PIN));
SERIAL_PROTOCOLLN(digitalRead(Z_MS2_PIN));
SERIAL_PROTOCOLPGM("E0: ");
SERIAL_PROTOCOL(digitalRead(E0_MS1_PIN));
SERIAL_PROTOCOLLN(digitalRead(E0_MS2_PIN));
#if HAS_MICROSTEPS_E1
SERIAL_PROTOCOLPGM("E1: ");
SERIAL_PROTOCOL(digitalRead(E1_MS1_PIN));
SERIAL_PROTOCOLLN(digitalRead(E1_MS2_PIN));
#endif
}
#endif // HAS_MICROSTEPS
#if ENABLED(LIN_ADVANCE)

View File

@ -239,13 +239,16 @@ class Stepper {
//
static FORCE_INLINE bool motor_direction(AxisEnum axis) { return TEST(last_direction_bits, axis); }
#if HAS_DIGIPOTSS
#if HAS_DIGIPOTSS || HAS_MOTOR_CURRENT_PWM
static void digitalPotWrite(int address, int value);
static void digipot_current(uint8_t driver, int current);
#endif
#if HAS_MICROSTEPS
static void microstep_ms(uint8_t driver, int8_t ms1, int8_t ms2);
static void microstep_mode(uint8_t driver, uint8_t stepping);
static void microstep_readings();
#endif
static void microstep_ms(uint8_t driver, int8_t ms1, int8_t ms2);
static void digipot_current(uint8_t driver, int current);
static void microstep_mode(uint8_t driver, uint8_t stepping);
static void microstep_readings();
#if ENABLED(Z_DUAL_ENDSTOPS)
static FORCE_INLINE void set_homing_flag(bool state) { performing_homing = state; }
@ -380,7 +383,10 @@ class Stepper {
}
static void digipot_init();
static void microstep_init();
#if HAS_MICROSTEPS
static void microstep_init();
#endif
};

View File

@ -52,8 +52,7 @@
int dac_init() {
#if PIN_EXISTS(DAC_DISABLE)
pinMode(DAC_DISABLE_PIN, OUTPUT);
digitalWrite(DAC_DISABLE_PIN, LOW); // set pin low to enable DAC
OUT_WRITE(DAC_DISABLE_PIN, LOW); // set pin low to enable DAC
#endif
mcp4728_init();

View File

@ -220,14 +220,12 @@ void lcd_printPGM(const char* str) {
// Initialize or re-initializw the LCD
static void lcd_implementation_init() {
#if defined(LCD_PIN_BL) && LCD_PIN_BL > -1 // Enable LCD backlight
pinMode(LCD_PIN_BL, OUTPUT);
digitalWrite(LCD_PIN_BL, HIGH);
#if PIN_EXISTS(LCD_BACKLIGHT) // Enable LCD backlight
OUT_WRITE(LCD_BACKLIGHT_PIN, HIGH);
#endif
#if defined(LCD_PIN_RESET) && LCD_PIN_RESET > -1
pinMode(LCD_PIN_RESET, OUTPUT);
digitalWrite(LCD_PIN_RESET, HIGH);
#if PIN_EXISTS(LCD_RESET)
OUT_WRITE(LCD_RESET_PIN, HIGH);
#endif
#if DISABLED(MINIPANEL) // setContrast not working for Mini Panel