Apply loop shorthand macros (#17159)
This commit is contained in:
parent
a96be32fae
commit
118bd2f8b2
|
@ -197,7 +197,7 @@ void spiBegin() {
|
||||||
// output pin high - like sending 0xFF
|
// output pin high - like sending 0xFF
|
||||||
WRITE(MOSI_PIN, HIGH);
|
WRITE(MOSI_PIN, HIGH);
|
||||||
|
|
||||||
for (uint8_t i = 0; i < 8; i++) {
|
LOOP_L_N(i, 8) {
|
||||||
WRITE(SCK_PIN, HIGH);
|
WRITE(SCK_PIN, HIGH);
|
||||||
|
|
||||||
nop; // adjust so SCK is nice
|
nop; // adjust so SCK is nice
|
||||||
|
@ -224,7 +224,7 @@ void spiBegin() {
|
||||||
void spiSend(uint8_t data) {
|
void spiSend(uint8_t data) {
|
||||||
// no interrupts during byte send - about 8µs
|
// no interrupts during byte send - about 8µs
|
||||||
cli();
|
cli();
|
||||||
for (uint8_t i = 0; i < 8; i++) {
|
LOOP_L_N(i, 8) {
|
||||||
WRITE(SCK_PIN, LOW);
|
WRITE(SCK_PIN, LOW);
|
||||||
WRITE(MOSI_PIN, data & 0x80);
|
WRITE(MOSI_PIN, data & 0x80);
|
||||||
data <<= 1;
|
data <<= 1;
|
||||||
|
|
|
@ -682,7 +682,7 @@
|
||||||
|
|
||||||
// Round correctly so that print(1.999, 2) prints as "2.00"
|
// Round correctly so that print(1.999, 2) prints as "2.00"
|
||||||
double rounding = 0.5;
|
double rounding = 0.5;
|
||||||
for (uint8_t i = 0; i < digits; ++i) rounding *= 0.1;
|
LOOP_L_N(i, digits) rounding *= 0.1;
|
||||||
number += rounding;
|
number += rounding;
|
||||||
|
|
||||||
// Extract the integer part of the number and print it
|
// Extract the integer part of the number and print it
|
||||||
|
|
|
@ -167,7 +167,7 @@ void set_pwm_frequency(const pin_t pin, int f_desired) {
|
||||||
uint16_t prescaler[] = { 0, 1, 8, /*TIMER2 ONLY*/32, 64, /*TIMER2 ONLY*/128, 256, 1024 };
|
uint16_t prescaler[] = { 0, 1, 8, /*TIMER2 ONLY*/32, 64, /*TIMER2 ONLY*/128, 256, 1024 };
|
||||||
|
|
||||||
// loop over prescaler values
|
// loop over prescaler values
|
||||||
for (uint8_t i = 1; i < 8; i++) {
|
LOOP_S_L_N(i, 1, 8) {
|
||||||
uint16_t res_temp_fast = 255, res_temp_phase_correct = 255;
|
uint16_t res_temp_fast = 255, res_temp_phase_correct = 255;
|
||||||
if (timer.n == 2) {
|
if (timer.n == 2) {
|
||||||
// No resolution calculation for TIMER2 unless enabled USE_OCR2A_AS_TOP
|
// No resolution calculation for TIMER2 unless enabled USE_OCR2A_AS_TOP
|
||||||
|
|
|
@ -70,12 +70,12 @@
|
||||||
|
|
||||||
void PRINT_ARRAY_NAME(uint8_t x) {
|
void PRINT_ARRAY_NAME(uint8_t x) {
|
||||||
char *name_mem_pointer = (char*)pgm_read_ptr(&pin_array[x].name);
|
char *name_mem_pointer = (char*)pgm_read_ptr(&pin_array[x].name);
|
||||||
for (uint8_t y = 0; y < MAX_NAME_LENGTH; y++) {
|
LOOP_L_N(y, MAX_NAME_LENGTH) {
|
||||||
char temp_char = pgm_read_byte(name_mem_pointer + y);
|
char temp_char = pgm_read_byte(name_mem_pointer + y);
|
||||||
if (temp_char != 0)
|
if (temp_char != 0)
|
||||||
SERIAL_CHAR(temp_char);
|
SERIAL_CHAR(temp_char);
|
||||||
else {
|
else {
|
||||||
for (uint8_t i = 0; i < MAX_NAME_LENGTH - y; i++) SERIAL_CHAR(' ');
|
LOOP_L_N(i, MAX_NAME_LENGTH - y) SERIAL_CHAR(' ');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ void u8g_spiSend_sw_AVR_mode_0(uint8_t val) {
|
||||||
volatile uint8_t *outData = u8g_outData,
|
volatile uint8_t *outData = u8g_outData,
|
||||||
*outClock = u8g_outClock;
|
*outClock = u8g_outClock;
|
||||||
U8G_ATOMIC_START();
|
U8G_ATOMIC_START();
|
||||||
for (uint8_t i = 0; i < 8; i++) {
|
LOOP_L_N(i, 8) {
|
||||||
if (val & 0x80)
|
if (val & 0x80)
|
||||||
*outData |= bitData;
|
*outData |= bitData;
|
||||||
else
|
else
|
||||||
|
@ -108,7 +108,7 @@ void u8g_spiSend_sw_AVR_mode_3(uint8_t val) {
|
||||||
volatile uint8_t *outData = u8g_outData,
|
volatile uint8_t *outData = u8g_outData,
|
||||||
*outClock = u8g_outClock;
|
*outClock = u8g_outClock;
|
||||||
U8G_ATOMIC_START();
|
U8G_ATOMIC_START();
|
||||||
for (uint8_t i = 0; i < 8; i++) {
|
LOOP_L_N(i, 8) {
|
||||||
*outClock &= bitNotClock;
|
*outClock &= bitNotClock;
|
||||||
if (val & 0x80)
|
if (val & 0x80)
|
||||||
*outData |= bitData;
|
*outData |= bitData;
|
||||||
|
|
|
@ -606,7 +606,7 @@ void MarlinSerial<Cfg>::printFloat(double number, uint8_t digits) {
|
||||||
|
|
||||||
// Round correctly so that print(1.999, 2) prints as "2.00"
|
// Round correctly so that print(1.999, 2) prints as "2.00"
|
||||||
double rounding = 0.5;
|
double rounding = 0.5;
|
||||||
for (uint8_t i = 0; i < digits; ++i) rounding *= 0.1;
|
LOOP_L_N(i, digits) rounding *= 0.1;
|
||||||
number += rounding;
|
number += rounding;
|
||||||
|
|
||||||
// Extract the integer part of the number and print it
|
// Extract the integer part of the number and print it
|
||||||
|
|
|
@ -259,7 +259,7 @@ void MarlinSerialUSB::printFloat(double number, uint8_t digits) {
|
||||||
|
|
||||||
// Round correctly so that print(1.999, 2) prints as "2.00"
|
// Round correctly so that print(1.999, 2) prints as "2.00"
|
||||||
double rounding = 0.5;
|
double rounding = 0.5;
|
||||||
for (uint8_t i = 0; i < digits; ++i)
|
LOOP_L_N(i, digits)
|
||||||
rounding *= 0.1;
|
rounding *= 0.1;
|
||||||
|
|
||||||
number += rounding;
|
number += rounding;
|
||||||
|
|
|
@ -80,7 +80,7 @@ Pio *SCK_pPio, *MOSI_pPio;
|
||||||
uint32_t SCK_dwMask, MOSI_dwMask;
|
uint32_t SCK_dwMask, MOSI_dwMask;
|
||||||
|
|
||||||
void u8g_spiSend_sw_DUE_mode_0(uint8_t val) { // 3MHz
|
void u8g_spiSend_sw_DUE_mode_0(uint8_t val) { // 3MHz
|
||||||
for (uint8_t i = 0; i < 8; i++) {
|
LOOP_L_N(i, 8) {
|
||||||
if (val & 0x80)
|
if (val & 0x80)
|
||||||
MOSI_pPio->PIO_SODR = MOSI_dwMask;
|
MOSI_pPio->PIO_SODR = MOSI_dwMask;
|
||||||
else
|
else
|
||||||
|
@ -94,7 +94,7 @@ void u8g_spiSend_sw_DUE_mode_0(uint8_t val) { // 3MHz
|
||||||
}
|
}
|
||||||
|
|
||||||
void u8g_spiSend_sw_DUE_mode_3(uint8_t val) { // 3.5MHz
|
void u8g_spiSend_sw_DUE_mode_3(uint8_t val) { // 3.5MHz
|
||||||
for (uint8_t i = 0; i < 8; i++) {
|
LOOP_L_N(i, 8) {
|
||||||
SCK_pPio->PIO_CODR = SCK_dwMask;
|
SCK_pPio->PIO_CODR = SCK_dwMask;
|
||||||
DELAY_NS(50);
|
DELAY_NS(50);
|
||||||
if (val & 0x80)
|
if (val & 0x80)
|
||||||
|
|
|
@ -63,7 +63,7 @@ extern PWM_map ISR_table[NUM_PWMS];
|
||||||
extern uint32_t motor_current_setting[3];
|
extern uint32_t motor_current_setting[3];
|
||||||
|
|
||||||
#define IR_BIT(p) (WITHIN(p, 0, 3) ? (p) : (p) + 4)
|
#define IR_BIT(p) (WITHIN(p, 0, 3) ? (p) : (p) + 4)
|
||||||
#define COPY_ACTIVE_TABLE() do{ for (uint8_t i = 0; i < 6 ; i++) work_table[i] = active_table[i]; }while(0)
|
#define COPY_ACTIVE_TABLE() do{ LOOP_L_N(i, 6) work_table[i] = active_table[i]; }while(0)
|
||||||
|
|
||||||
#define PWM_MR0 19999 // base repetition rate minus one count - 20mS
|
#define PWM_MR0 19999 // base repetition rate minus one count - 20mS
|
||||||
#define PWM_PR 24 // prescaler value - prescaler divide by 24 + 1 - 1 MHz output
|
#define PWM_PR 24 // prescaler value - prescaler divide by 24 + 1 - 1 MHz output
|
||||||
|
|
|
@ -67,7 +67,7 @@ void HAL_init() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Flash status LED 3 times to indicate Marlin has started booting
|
// Flash status LED 3 times to indicate Marlin has started booting
|
||||||
for (uint8_t i = 0; i < 6; ++i) {
|
LOOP_L_N(i, 6) {
|
||||||
TOGGLE(LED_PIN);
|
TOGGLE(LED_PIN);
|
||||||
delay(100);
|
delay(100);
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@
|
||||||
|
|
||||||
uint8_t swSpiTransfer_mode_0(uint8_t b, const uint8_t spi_speed, const pin_t sck_pin, const pin_t miso_pin, const pin_t mosi_pin ) {
|
uint8_t swSpiTransfer_mode_0(uint8_t b, const uint8_t spi_speed, const pin_t sck_pin, const pin_t miso_pin, const pin_t mosi_pin ) {
|
||||||
|
|
||||||
for (uint8_t i = 0; i < 8; i++) {
|
LOOP_L_N(i, 8) {
|
||||||
if (spi_speed == 0) {
|
if (spi_speed == 0) {
|
||||||
LPC176x::gpio_set(mosi_pin, !!(b & 0x80));
|
LPC176x::gpio_set(mosi_pin, !!(b & 0x80));
|
||||||
LPC176x::gpio_set(sck_pin, HIGH);
|
LPC176x::gpio_set(sck_pin, HIGH);
|
||||||
|
@ -83,16 +83,16 @@ uint8_t swSpiTransfer_mode_0(uint8_t b, const uint8_t spi_speed, const pin_t sck
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const uint8_t state = (b & 0x80) ? HIGH : LOW;
|
const uint8_t state = (b & 0x80) ? HIGH : LOW;
|
||||||
for (uint8_t j = 0; j < spi_speed; j++)
|
LOOP_L_N(j, spi_speed)
|
||||||
LPC176x::gpio_set(mosi_pin, state);
|
LPC176x::gpio_set(mosi_pin, state);
|
||||||
|
|
||||||
for (uint8_t j = 0; j < spi_speed + (miso_pin >= 0 ? 0 : 1); j++)
|
LOOP_L_N(j, spi_speed + (miso_pin >= 0 ? 0 : 1))
|
||||||
LPC176x::gpio_set(sck_pin, HIGH);
|
LPC176x::gpio_set(sck_pin, HIGH);
|
||||||
|
|
||||||
b <<= 1;
|
b <<= 1;
|
||||||
if (miso_pin >= 0 && LPC176x::gpio_get(miso_pin)) b |= 1;
|
if (miso_pin >= 0 && LPC176x::gpio_get(miso_pin)) b |= 1;
|
||||||
|
|
||||||
for (uint8_t j = 0; j < spi_speed; j++)
|
LOOP_L_N(j, spi_speed)
|
||||||
LPC176x::gpio_set(sck_pin, LOW);
|
LPC176x::gpio_set(sck_pin, LOW);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ uint8_t swSpiTransfer_mode_0(uint8_t b, const uint8_t spi_speed, const pin_t sck
|
||||||
|
|
||||||
uint8_t swSpiTransfer_mode_3(uint8_t b, const uint8_t spi_speed, const pin_t sck_pin, const pin_t miso_pin, const pin_t mosi_pin ) {
|
uint8_t swSpiTransfer_mode_3(uint8_t b, const uint8_t spi_speed, const pin_t sck_pin, const pin_t miso_pin, const pin_t mosi_pin ) {
|
||||||
|
|
||||||
for (uint8_t i = 0; i < 8; i++) {
|
LOOP_L_N(i, 8) {
|
||||||
const uint8_t state = (b & 0x80) ? HIGH : LOW;
|
const uint8_t state = (b & 0x80) ? HIGH : LOW;
|
||||||
if (spi_speed == 0) {
|
if (spi_speed == 0) {
|
||||||
LPC176x::gpio_set(sck_pin, LOW);
|
LPC176x::gpio_set(sck_pin, LOW);
|
||||||
|
@ -111,13 +111,13 @@ uint8_t swSpiTransfer_mode_3(uint8_t b, const uint8_t spi_speed, const pin_t sck
|
||||||
LPC176x::gpio_set(sck_pin, HIGH);
|
LPC176x::gpio_set(sck_pin, HIGH);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (uint8_t j = 0; j < spi_speed + (miso_pin >= 0 ? 0 : 1); j++)
|
LOOP_L_N(j, spi_speed + (miso_pin >= 0 ? 0 : 1))
|
||||||
LPC176x::gpio_set(sck_pin, LOW);
|
LPC176x::gpio_set(sck_pin, LOW);
|
||||||
|
|
||||||
for (uint8_t j = 0; j < spi_speed; j++)
|
LOOP_L_N(j, spi_speed)
|
||||||
LPC176x::gpio_set(mosi_pin, state);
|
LPC176x::gpio_set(mosi_pin, state);
|
||||||
|
|
||||||
for (uint8_t j = 0; j < spi_speed; j++)
|
LOOP_L_N(j, spi_speed)
|
||||||
LPC176x::gpio_set(sck_pin, HIGH);
|
LPC176x::gpio_set(sck_pin, HIGH);
|
||||||
}
|
}
|
||||||
b <<= 1;
|
b <<= 1;
|
||||||
|
|
|
@ -478,10 +478,10 @@ void HAL_adc_init() {
|
||||||
#if ADC_IS_REQUIRED
|
#if ADC_IS_REQUIRED
|
||||||
memset(HAL_adc_results, 0xFF, sizeof(HAL_adc_results)); // Fill result with invalid values
|
memset(HAL_adc_results, 0xFF, sizeof(HAL_adc_results)); // Fill result with invalid values
|
||||||
|
|
||||||
for (uint8_t pi = 0; pi < COUNT(adc_pins); ++pi)
|
LOOP_L_N(pi, COUNT(adc_pins))
|
||||||
pinPeripheral(adc_pins[pi], PIO_ANALOG);
|
pinPeripheral(adc_pins[pi], PIO_ANALOG);
|
||||||
|
|
||||||
for (uint8_t ai = FIRST_ADC; ai <= LAST_ADC; ++ai) {
|
LOOP_S_LE_N(ai, FIRST_ADC, LAST_ADC) {
|
||||||
Adc* adc = ((Adc*[])ADC_INSTS)[ai];
|
Adc* adc = ((Adc*[])ADC_INSTS)[ai];
|
||||||
|
|
||||||
// ADC clock setup
|
// ADC clock setup
|
||||||
|
@ -513,7 +513,7 @@ void HAL_adc_init() {
|
||||||
|
|
||||||
void HAL_adc_start_conversion(const uint8_t adc_pin) {
|
void HAL_adc_start_conversion(const uint8_t adc_pin) {
|
||||||
#if ADC_IS_REQUIRED
|
#if ADC_IS_REQUIRED
|
||||||
for (uint8_t pi = 0; pi < COUNT(adc_pins); ++pi) {
|
LOOP_L_N(pi, COUNT(adc_pins)) {
|
||||||
if (adc_pin == adc_pins[pi]) {
|
if (adc_pin == adc_pins[pi]) {
|
||||||
HAL_adc_result = HAL_adc_results[pi];
|
HAL_adc_result = HAL_adc_results[pi];
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
GPIO_TypeDef* FastIOPortMap[LastPort + 1];
|
GPIO_TypeDef* FastIOPortMap[LastPort + 1];
|
||||||
|
|
||||||
void FastIO_init() {
|
void FastIO_init() {
|
||||||
for (uint8_t i = 0; i < NUM_DIGITAL_PINS; i++)
|
LOOP_L_N(i, NUM_DIGITAL_PINS)
|
||||||
FastIOPortMap[STM_PORT(digitalPin[i])] = get_GPIO_Port(STM_PORT(digitalPin[i]));
|
FastIOPortMap[STM_PORT(digitalPin[i])] = get_GPIO_Port(STM_PORT(digitalPin[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
static uint8_t SPI_speed = SPI_SPEED;
|
static uint8_t SPI_speed = SPI_SPEED;
|
||||||
|
|
||||||
static inline uint8_t swSpiTransfer_mode_0(uint8_t b, const uint8_t spi_speed, const pin_t miso_pin=-1) {
|
static inline uint8_t swSpiTransfer_mode_0(uint8_t b, const uint8_t spi_speed, const pin_t miso_pin=-1) {
|
||||||
for (uint8_t i = 0; i < 8; i++) {
|
LOOP_L_N(i, 8) {
|
||||||
if (spi_speed == 0) {
|
if (spi_speed == 0) {
|
||||||
WRITE(DOGLCD_MOSI, !!(b & 0x80));
|
WRITE(DOGLCD_MOSI, !!(b & 0x80));
|
||||||
WRITE(DOGLCD_SCK, HIGH);
|
WRITE(DOGLCD_SCK, HIGH);
|
||||||
|
@ -42,16 +42,16 @@ static inline uint8_t swSpiTransfer_mode_0(uint8_t b, const uint8_t spi_speed, c
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const uint8_t state = (b & 0x80) ? HIGH : LOW;
|
const uint8_t state = (b & 0x80) ? HIGH : LOW;
|
||||||
for (uint8_t j = 0; j < spi_speed; j++)
|
LOOP_L_N(j, spi_speed)
|
||||||
WRITE(DOGLCD_MOSI, state);
|
WRITE(DOGLCD_MOSI, state);
|
||||||
|
|
||||||
for (uint8_t j = 0; j < spi_speed + (miso_pin >= 0 ? 0 : 1); j++)
|
LOOP_L_N(j, spi_speed + (miso_pin >= 0 ? 0 : 1))
|
||||||
WRITE(DOGLCD_SCK, HIGH);
|
WRITE(DOGLCD_SCK, HIGH);
|
||||||
|
|
||||||
b <<= 1;
|
b <<= 1;
|
||||||
if (miso_pin >= 0 && READ(miso_pin)) b |= 1;
|
if (miso_pin >= 0 && READ(miso_pin)) b |= 1;
|
||||||
|
|
||||||
for (uint8_t j = 0; j < spi_speed; j++)
|
LOOP_L_N(j, spi_speed)
|
||||||
WRITE(DOGLCD_SCK, LOW);
|
WRITE(DOGLCD_SCK, LOW);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ static inline uint8_t swSpiTransfer_mode_0(uint8_t b, const uint8_t spi_speed, c
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint8_t swSpiTransfer_mode_3(uint8_t b, const uint8_t spi_speed, const pin_t miso_pin=-1) {
|
static inline uint8_t swSpiTransfer_mode_3(uint8_t b, const uint8_t spi_speed, const pin_t miso_pin=-1) {
|
||||||
for (uint8_t i = 0; i < 8; i++) {
|
LOOP_L_N(i, 8) {
|
||||||
const uint8_t state = (b & 0x80) ? HIGH : LOW;
|
const uint8_t state = (b & 0x80) ? HIGH : LOW;
|
||||||
if (spi_speed == 0) {
|
if (spi_speed == 0) {
|
||||||
WRITE(DOGLCD_SCK, LOW);
|
WRITE(DOGLCD_SCK, LOW);
|
||||||
|
@ -68,13 +68,13 @@ static inline uint8_t swSpiTransfer_mode_3(uint8_t b, const uint8_t spi_speed, c
|
||||||
WRITE(DOGLCD_SCK, HIGH);
|
WRITE(DOGLCD_SCK, HIGH);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (uint8_t j = 0; j < spi_speed + (miso_pin >= 0 ? 0 : 1); j++)
|
LOOP_L_N(j, spi_speed + (miso_pin >= 0 ? 0 : 1))
|
||||||
WRITE(DOGLCD_SCK, LOW);
|
WRITE(DOGLCD_SCK, LOW);
|
||||||
|
|
||||||
for (uint8_t j = 0; j < spi_speed; j++)
|
LOOP_L_N(j, spi_speed)
|
||||||
WRITE(DOGLCD_MOSI, state);
|
WRITE(DOGLCD_MOSI, state);
|
||||||
|
|
||||||
for (uint8_t j = 0; j < spi_speed; j++)
|
LOOP_L_N(j, spi_speed)
|
||||||
WRITE(DOGLCD_SCK, HIGH);
|
WRITE(DOGLCD_SCK, HIGH);
|
||||||
}
|
}
|
||||||
b <<= 1;
|
b <<= 1;
|
||||||
|
|
|
@ -102,7 +102,7 @@ void eeprom_read_block(void *__dst, const void *__src, size_t __n) {
|
||||||
|
|
||||||
uint16_t data = 0xFF;
|
uint16_t data = 0xFF;
|
||||||
uint16_t eeprom_address = unsigned(__src);
|
uint16_t eeprom_address = unsigned(__src);
|
||||||
for (uint8_t c = 0; c < __n; c++) {
|
LOOP_L_N(c, __n) {
|
||||||
EE_ReadVariable(eeprom_address+c, &data);
|
EE_ReadVariable(eeprom_address+c, &data);
|
||||||
*((uint8_t*)__dst + c) = data;
|
*((uint8_t*)__dst + c) = data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ uint8_t ServoCount = 0; // the total number of attached
|
||||||
|
|
||||||
static boolean isTimerActive(timer16_Sequence_t timer) {
|
static boolean isTimerActive(timer16_Sequence_t timer) {
|
||||||
// returns true if any servo is active on this timer
|
// returns true if any servo is active on this timer
|
||||||
for (uint8_t channel = 0; channel < SERVOS_PER_TIMER; channel++) {
|
LOOP_L_N(channel, SERVOS_PER_TIMER) {
|
||||||
if (SERVO(timer, channel).Pin.isActive)
|
if (SERVO(timer, channel).Pin.isActive)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -274,7 +274,7 @@ void setup_powerhold() {
|
||||||
|
|
||||||
bool pin_is_protected(const pin_t pin) {
|
bool pin_is_protected(const pin_t pin) {
|
||||||
static const pin_t sensitive_pins[] PROGMEM = SENSITIVE_PINS;
|
static const pin_t sensitive_pins[] PROGMEM = SENSITIVE_PINS;
|
||||||
for (uint8_t i = 0; i < COUNT(sensitive_pins); i++) {
|
LOOP_L_N(i, COUNT(sensitive_pins)) {
|
||||||
pin_t sensitive_pin;
|
pin_t sensitive_pin;
|
||||||
memcpy_P(&sensitive_pin, &sensitive_pins[i], sizeof(pin_t));
|
memcpy_P(&sensitive_pin, &sensitive_pins[i], sizeof(pin_t));
|
||||||
if (pin == sensitive_pin) return true;
|
if (pin == sensitive_pin) return true;
|
||||||
|
|
|
@ -248,6 +248,11 @@
|
||||||
#define _JOIN_1(O) (O)
|
#define _JOIN_1(O) (O)
|
||||||
#define JOIN_N(N,C,V...) (DO(JOIN,C,LIST_N(N,V)))
|
#define JOIN_N(N,C,V...) (DO(JOIN,C,LIST_N(N,V)))
|
||||||
|
|
||||||
|
#define LOOP_S_LE_N(VAR, S, N) for (uint8_t VAR=(S); VAR<=(N); VAR++)
|
||||||
|
#define LOOP_S_L_N(VAR, S, N) for (uint8_t VAR=(S); VAR<(N); VAR++)
|
||||||
|
#define LOOP_LE_N(VAR, N) LOOP_S_LE_N(VAR, 0, N)
|
||||||
|
#define LOOP_L_N(VAR, N) LOOP_S_L_N(VAR, 0, N)
|
||||||
|
|
||||||
#define NOOP (void(0))
|
#define NOOP (void(0))
|
||||||
|
|
||||||
#define CEILING(x,y) (((x) + (y) - 1) / (y))
|
#define CEILING(x,y) (((x) + (y) - 1) / (y))
|
||||||
|
|
|
@ -50,12 +50,6 @@ enum AxisEnum : uint8_t {
|
||||||
//
|
//
|
||||||
// Loop over XYZE axes
|
// Loop over XYZE axes
|
||||||
//
|
//
|
||||||
|
|
||||||
#define LOOP_S_LE_N(VAR, S, N) for (uint8_t VAR=(S); VAR<=(N); VAR++)
|
|
||||||
#define LOOP_S_L_N(VAR, S, N) for (uint8_t VAR=(S); VAR<(N); VAR++)
|
|
||||||
#define LOOP_LE_N(VAR, N) LOOP_S_LE_N(VAR, 0, N)
|
|
||||||
#define LOOP_L_N(VAR, N) LOOP_S_L_N(VAR, 0, N)
|
|
||||||
|
|
||||||
#define LOOP_XYZ(VAR) LOOP_S_LE_N(VAR, X_AXIS, Z_AXIS)
|
#define LOOP_XYZ(VAR) LOOP_S_LE_N(VAR, X_AXIS, Z_AXIS)
|
||||||
#define LOOP_XYZE(VAR) LOOP_S_LE_N(VAR, X_AXIS, E_AXIS)
|
#define LOOP_XYZE(VAR) LOOP_S_LE_N(VAR, X_AXIS, E_AXIS)
|
||||||
#define LOOP_XYZE_N(VAR) LOOP_S_L_N(VAR, X_AXIS, XYZE_N)
|
#define LOOP_XYZE_N(VAR) LOOP_S_L_N(VAR, X_AXIS, XYZE_N)
|
||||||
|
|
|
@ -115,8 +115,8 @@ void extrapolate_unprobed_bed_level() {
|
||||||
ylen = ctry1;
|
ylen = ctry1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (uint8_t xo = 0; xo <= xlen; xo++)
|
LOOP_LE_N(xo, xlen)
|
||||||
for (uint8_t yo = 0; yo <= ylen; yo++) {
|
LOOP_LE_N(yo, ylen) {
|
||||||
uint8_t x2 = ctrx2 + xo, y2 = ctry2 + yo;
|
uint8_t x2 = ctrx2 + xo, y2 = ctry2 + yo;
|
||||||
#ifndef HALF_IN_X
|
#ifndef HALF_IN_X
|
||||||
const uint8_t x1 = ctrx1 - xo;
|
const uint8_t x1 = ctrx1 - xo;
|
||||||
|
@ -209,8 +209,8 @@ void print_bilinear_leveling_grid() {
|
||||||
|
|
||||||
static float bed_level_virt_2cmr(const uint8_t x, const uint8_t y, const float &tx, const float &ty) {
|
static float bed_level_virt_2cmr(const uint8_t x, const uint8_t y, const float &tx, const float &ty) {
|
||||||
float row[4], column[4];
|
float row[4], column[4];
|
||||||
for (uint8_t i = 0; i < 4; i++) {
|
LOOP_L_N(i, 4) {
|
||||||
for (uint8_t j = 0; j < 4; j++) {
|
LOOP_L_N(j, 4) {
|
||||||
column[j] = bed_level_virt_coord(i + x - 1, j + y - 1);
|
column[j] = bed_level_virt_coord(i + x - 1, j + y - 1);
|
||||||
}
|
}
|
||||||
row[i] = bed_level_virt_cmr(column, 1, ty);
|
row[i] = bed_level_virt_cmr(column, 1, ty);
|
||||||
|
@ -221,11 +221,11 @@ void print_bilinear_leveling_grid() {
|
||||||
void bed_level_virt_interpolate() {
|
void bed_level_virt_interpolate() {
|
||||||
bilinear_grid_spacing_virt = bilinear_grid_spacing / (BILINEAR_SUBDIVISIONS);
|
bilinear_grid_spacing_virt = bilinear_grid_spacing / (BILINEAR_SUBDIVISIONS);
|
||||||
bilinear_grid_factor_virt = bilinear_grid_spacing_virt.reciprocal();
|
bilinear_grid_factor_virt = bilinear_grid_spacing_virt.reciprocal();
|
||||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
LOOP_L_N(y, GRID_MAX_POINTS_Y)
|
||||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
LOOP_L_N(x, GRID_MAX_POINTS_X)
|
||||||
for (uint8_t ty = 0; ty < BILINEAR_SUBDIVISIONS; ty++)
|
LOOP_L_N(ty, BILINEAR_SUBDIVISIONS)
|
||||||
for (uint8_t tx = 0; tx < BILINEAR_SUBDIVISIONS; tx++) {
|
LOOP_L_N(tx, BILINEAR_SUBDIVISIONS) {
|
||||||
if ((ty && y == GRID_MAX_POINTS_Y - 1) || (tx && x == GRID_MAX_POINTS_X - 1))
|
if ((ty && y == (GRID_MAX_POINTS_Y) - 1) || (tx && x == (GRID_MAX_POINTS_X) - 1))
|
||||||
continue;
|
continue;
|
||||||
z_values_virt[x * (BILINEAR_SUBDIVISIONS) + tx][y * (BILINEAR_SUBDIVISIONS) + ty] =
|
z_values_virt[x * (BILINEAR_SUBDIVISIONS) + tx][y * (BILINEAR_SUBDIVISIONS) + ty] =
|
||||||
bed_level_virt_2cmr(
|
bed_level_virt_2cmr(
|
||||||
|
|
|
@ -143,13 +143,12 @@ void reset_bed_level() {
|
||||||
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||||
bilinear_start.reset();
|
bilinear_start.reset();
|
||||||
bilinear_grid_spacing.reset();
|
bilinear_grid_spacing.reset();
|
||||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
GRID_LOOP(x, y) {
|
||||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++) {
|
z_values[x][y] = NAN;
|
||||||
z_values[x][y] = NAN;
|
#if ENABLED(EXTENSIBLE_UI)
|
||||||
#if ENABLED(EXTENSIBLE_UI)
|
ExtUI::onMeshUpdate(x, y, 0);
|
||||||
ExtUI::onMeshUpdate(x, y, 0);
|
#endif
|
||||||
#endif
|
}
|
||||||
}
|
|
||||||
#elif ABL_PLANAR
|
#elif ABL_PLANAR
|
||||||
planner.bed_level_matrix.set_to_identity();
|
planner.bed_level_matrix.set_to_identity();
|
||||||
#endif
|
#endif
|
||||||
|
@ -173,7 +172,7 @@ void reset_bed_level() {
|
||||||
*/
|
*/
|
||||||
void print_2d_array(const uint8_t sx, const uint8_t sy, const uint8_t precision, element_2d_fn fn) {
|
void print_2d_array(const uint8_t sx, const uint8_t sy, const uint8_t precision, element_2d_fn fn) {
|
||||||
#ifndef SCAD_MESH_OUTPUT
|
#ifndef SCAD_MESH_OUTPUT
|
||||||
for (uint8_t x = 0; x < sx; x++) {
|
LOOP_L_N(x, sx) {
|
||||||
serial_spaces(precision + (x < 10 ? 3 : 2));
|
serial_spaces(precision + (x < 10 ? 3 : 2));
|
||||||
SERIAL_ECHO(int(x));
|
SERIAL_ECHO(int(x));
|
||||||
}
|
}
|
||||||
|
@ -182,14 +181,14 @@ void reset_bed_level() {
|
||||||
#ifdef SCAD_MESH_OUTPUT
|
#ifdef SCAD_MESH_OUTPUT
|
||||||
SERIAL_ECHOLNPGM("measured_z = ["); // open 2D array
|
SERIAL_ECHOLNPGM("measured_z = ["); // open 2D array
|
||||||
#endif
|
#endif
|
||||||
for (uint8_t y = 0; y < sy; y++) {
|
LOOP_L_N(y, sy) {
|
||||||
#ifdef SCAD_MESH_OUTPUT
|
#ifdef SCAD_MESH_OUTPUT
|
||||||
SERIAL_ECHOPGM(" ["); // open sub-array
|
SERIAL_ECHOPGM(" ["); // open sub-array
|
||||||
#else
|
#else
|
||||||
if (y < 10) SERIAL_CHAR(' ');
|
if (y < 10) SERIAL_CHAR(' ');
|
||||||
SERIAL_ECHO(int(y));
|
SERIAL_ECHO(int(y));
|
||||||
#endif
|
#endif
|
||||||
for (uint8_t x = 0; x < sx; x++) {
|
LOOP_L_N(x, sx) {
|
||||||
SERIAL_CHAR(' ');
|
SERIAL_CHAR(' ');
|
||||||
const float offset = fn(x, y);
|
const float offset = fn(x, y);
|
||||||
if (!isnan(offset)) {
|
if (!isnan(offset)) {
|
||||||
|
@ -202,7 +201,7 @@ void reset_bed_level() {
|
||||||
SERIAL_CHAR(' ');
|
SERIAL_CHAR(' ');
|
||||||
SERIAL_ECHOPGM("NAN");
|
SERIAL_ECHOPGM("NAN");
|
||||||
#else
|
#else
|
||||||
for (uint8_t i = 0; i < precision + 3; i++)
|
LOOP_L_N(i, precision + 3)
|
||||||
SERIAL_CHAR(i ? '=' : ' ');
|
SERIAL_CHAR(i ? '=' : ' ');
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,9 +40,9 @@
|
||||||
mesh_bed_leveling::index_to_ypos[GRID_MAX_POINTS_Y];
|
mesh_bed_leveling::index_to_ypos[GRID_MAX_POINTS_Y];
|
||||||
|
|
||||||
mesh_bed_leveling::mesh_bed_leveling() {
|
mesh_bed_leveling::mesh_bed_leveling() {
|
||||||
for (uint8_t i = 0; i < GRID_MAX_POINTS_X; ++i)
|
LOOP_L_N(i, GRID_MAX_POINTS_X)
|
||||||
index_to_xpos[i] = MESH_MIN_X + i * (MESH_X_DIST);
|
index_to_xpos[i] = MESH_MIN_X + i * (MESH_X_DIST);
|
||||||
for (uint8_t i = 0; i < GRID_MAX_POINTS_Y; ++i)
|
LOOP_L_N(i, GRID_MAX_POINTS_Y)
|
||||||
index_to_ypos[i] = MESH_MIN_Y + i * (MESH_Y_DIST);
|
index_to_ypos[i] = MESH_MIN_Y + i * (MESH_Y_DIST);
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
@ -51,9 +51,7 @@
|
||||||
z_offset = 0;
|
z_offset = 0;
|
||||||
ZERO(z_values);
|
ZERO(z_values);
|
||||||
#if ENABLED(EXTENSIBLE_UI)
|
#if ENABLED(EXTENSIBLE_UI)
|
||||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
GRID_LOOP(x, y) ExtUI::onMeshUpdate(x, y, 0);
|
||||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
|
||||||
ExtUI::onMeshUpdate(x, y, 0);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,9 +52,7 @@ public:
|
||||||
static void reset();
|
static void reset();
|
||||||
|
|
||||||
FORCE_INLINE static bool has_mesh() {
|
FORCE_INLINE static bool has_mesh() {
|
||||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
GRID_LOOP(x, y) if (z_values[x][y]) return true;
|
||||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
|
||||||
if (z_values[x][y]) return true;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
void unified_bed_leveling::report_current_mesh() {
|
void unified_bed_leveling::report_current_mesh() {
|
||||||
if (!leveling_is_valid()) return;
|
if (!leveling_is_valid()) return;
|
||||||
SERIAL_ECHO_MSG(" G29 I99");
|
SERIAL_ECHO_MSG(" G29 I99");
|
||||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
LOOP_L_N(x, GRID_MAX_POINTS_X)
|
||||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
||||||
if (!isnan(z_values[x][y])) {
|
if (!isnan(z_values[x][y])) {
|
||||||
SERIAL_ECHO_START();
|
SERIAL_ECHO_START();
|
||||||
|
@ -101,9 +101,7 @@
|
||||||
storage_slot = -1;
|
storage_slot = -1;
|
||||||
ZERO(z_values);
|
ZERO(z_values);
|
||||||
#if ENABLED(EXTENSIBLE_UI)
|
#if ENABLED(EXTENSIBLE_UI)
|
||||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
GRID_LOOP(x, y) ExtUI::onMeshUpdate(x, y, 0);
|
||||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
|
||||||
ExtUI::onMeshUpdate(x, y, 0);
|
|
||||||
#endif
|
#endif
|
||||||
if (was_enabled) report_current_position();
|
if (was_enabled) report_current_position();
|
||||||
}
|
}
|
||||||
|
@ -114,13 +112,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
void unified_bed_leveling::set_all_mesh_points_to_value(const float value) {
|
void unified_bed_leveling::set_all_mesh_points_to_value(const float value) {
|
||||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++) {
|
GRID_LOOP(x, y) {
|
||||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++) {
|
z_values[x][y] = value;
|
||||||
z_values[x][y] = value;
|
#if ENABLED(EXTENSIBLE_UI)
|
||||||
#if ENABLED(EXTENSIBLE_UI)
|
ExtUI::onMeshUpdate(x, y, value);
|
||||||
ExtUI::onMeshUpdate(x, y, value);
|
#endif
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +186,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Row Values (I indexes)
|
// Row Values (I indexes)
|
||||||
for (uint8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
|
LOOP_L_N(i, GRID_MAX_POINTS_X) {
|
||||||
|
|
||||||
// Opening Brace or Space
|
// Opening Brace or Space
|
||||||
const bool is_current = i == curr.x && j == curr.y;
|
const bool is_current = i == curr.x && j == curr.y;
|
||||||
|
|
|
@ -298,9 +298,7 @@ class unified_bed_leveling {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline bool mesh_is_valid() {
|
static inline bool mesh_is_valid() {
|
||||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
GRID_LOOP(x, y) if (isnan(z_values[x][y])) return false;
|
||||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
|
||||||
if (isnan(z_values[x][y])) return false;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -365,25 +365,23 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++) { // Create a bowl shape - similar to
|
GRID_LOOP(x, y) { // Create a bowl shape similar to a poorly-calibrated Delta
|
||||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++) { // a poorly calibrated Delta.
|
const float p1 = 0.5f * (GRID_MAX_POINTS_X) - x,
|
||||||
const float p1 = 0.5f * (GRID_MAX_POINTS_X) - x,
|
p2 = 0.5f * (GRID_MAX_POINTS_Y) - y;
|
||||||
p2 = 0.5f * (GRID_MAX_POINTS_Y) - y;
|
z_values[x][y] += 2.0f * HYPOT(p1, p2);
|
||||||
z_values[x][y] += 2.0f * HYPOT(p1, p2);
|
#if ENABLED(EXTENSIBLE_UI)
|
||||||
#if ENABLED(EXTENSIBLE_UI)
|
ExtUI::onMeshUpdate(x, y, z_values[x][y]);
|
||||||
ExtUI::onMeshUpdate(x, y, z_values[x][y]);
|
#endif
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++) { // Create a diagonal line several Mesh cells thick that is raised
|
LOOP_L_N(x, GRID_MAX_POINTS_X) { // Create a diagonal line several Mesh cells thick that is raised
|
||||||
z_values[x][x] += 9.999f;
|
z_values[x][x] += 9.999f;
|
||||||
z_values[x][x + (x < GRID_MAX_POINTS_Y - 1) ? 1 : -1] += 9.999f; // We want the altered line several mesh points thick
|
z_values[x][x + (x < (GRID_MAX_POINTS_Y) - 1) ? 1 : -1] += 9.999f; // We want the altered line several mesh points thick
|
||||||
#if ENABLED(EXTENSIBLE_UI)
|
#if ENABLED(EXTENSIBLE_UI)
|
||||||
ExtUI::onMeshUpdate(x, x, z_values[x][x]);
|
ExtUI::onMeshUpdate(x, x, z_values[x][x]);
|
||||||
ExtUI::onMeshUpdate(x, (x + (x < GRID_MAX_POINTS_Y - 1) ? 1 : -1), z_values[x][x + (x < GRID_MAX_POINTS_Y - 1) ? 1 : -1]);
|
ExtUI::onMeshUpdate(x, (x + (x < (GRID_MAX_POINTS_Y) - 1) ? 1 : -1), z_values[x][x + (x < (GRID_MAX_POINTS_Y) - 1) ? 1 : -1]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -467,7 +465,7 @@
|
||||||
//
|
//
|
||||||
// Manually Probe Mesh in areas that can't be reached by the probe
|
// Manually Probe Mesh in areas that can't be reached by the probe
|
||||||
//
|
//
|
||||||
SERIAL_ECHOLNPGM("Manually probing unreachable mesh locations.");
|
SERIAL_ECHOLNPGM("Manually probing unreachable points.");
|
||||||
do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
|
do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
|
||||||
|
|
||||||
if (parser.seen('C') && !xy_seen) {
|
if (parser.seen('C') && !xy_seen) {
|
||||||
|
@ -537,9 +535,7 @@
|
||||||
if (cpos.x < 0) {
|
if (cpos.x < 0) {
|
||||||
// No more REAL INVALID mesh points to populate, so we ASSUME
|
// No more REAL INVALID mesh points to populate, so we ASSUME
|
||||||
// user meant to populate ALL INVALID mesh points to value
|
// user meant to populate ALL INVALID mesh points to value
|
||||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
GRID_LOOP(x, y) if (isnan(z_values[x][y])) z_values[x][y] = g29_constant;
|
||||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
|
||||||
if (isnan(z_values[x][y])) z_values[x][y] = g29_constant;
|
|
||||||
break; // No more invalid Mesh Points to populate
|
break; // No more invalid Mesh Points to populate
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -696,12 +692,11 @@
|
||||||
void unified_bed_leveling::adjust_mesh_to_mean(const bool cflag, const float value) {
|
void unified_bed_leveling::adjust_mesh_to_mean(const bool cflag, const float value) {
|
||||||
float sum = 0;
|
float sum = 0;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
GRID_LOOP(x, y)
|
||||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
if (!isnan(z_values[x][y])) {
|
||||||
if (!isnan(z_values[x][y])) {
|
sum += z_values[x][y];
|
||||||
sum += z_values[x][y];
|
n++;
|
||||||
n++;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const float mean = sum / n;
|
const float mean = sum / n;
|
||||||
|
|
||||||
|
@ -709,10 +704,9 @@
|
||||||
// Sum the squares of difference from mean
|
// Sum the squares of difference from mean
|
||||||
//
|
//
|
||||||
float sum_of_diff_squared = 0;
|
float sum_of_diff_squared = 0;
|
||||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
GRID_LOOP(x, y)
|
||||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
if (!isnan(z_values[x][y]))
|
||||||
if (!isnan(z_values[x][y]))
|
sum_of_diff_squared += sq(z_values[x][y] - mean);
|
||||||
sum_of_diff_squared += sq(z_values[x][y] - mean);
|
|
||||||
|
|
||||||
SERIAL_ECHOLNPAIR("# of samples: ", n);
|
SERIAL_ECHOLNPAIR("# of samples: ", n);
|
||||||
SERIAL_ECHOLNPAIR_F("Mean Mesh Height: ", mean, 6);
|
SERIAL_ECHOLNPAIR_F("Mean Mesh Height: ", mean, 6);
|
||||||
|
@ -721,27 +715,25 @@
|
||||||
SERIAL_ECHOLNPAIR_F("Standard Deviation: ", sigma, 6);
|
SERIAL_ECHOLNPAIR_F("Standard Deviation: ", sigma, 6);
|
||||||
|
|
||||||
if (cflag)
|
if (cflag)
|
||||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
GRID_LOOP(x, y)
|
||||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
|
||||||
if (!isnan(z_values[x][y])) {
|
|
||||||
z_values[x][y] -= mean + value;
|
|
||||||
#if ENABLED(EXTENSIBLE_UI)
|
|
||||||
ExtUI::onMeshUpdate(x, y, z_values[x][y]);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void unified_bed_leveling::shift_mesh_height() {
|
|
||||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
|
||||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
|
||||||
if (!isnan(z_values[x][y])) {
|
if (!isnan(z_values[x][y])) {
|
||||||
z_values[x][y] += g29_constant;
|
z_values[x][y] -= mean + value;
|
||||||
#if ENABLED(EXTENSIBLE_UI)
|
#if ENABLED(EXTENSIBLE_UI)
|
||||||
ExtUI::onMeshUpdate(x, y, z_values[x][y]);
|
ExtUI::onMeshUpdate(x, y, z_values[x][y]);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void unified_bed_leveling::shift_mesh_height() {
|
||||||
|
GRID_LOOP(x, y)
|
||||||
|
if (!isnan(z_values[x][y])) {
|
||||||
|
z_values[x][y] += g29_constant;
|
||||||
|
#if ENABLED(EXTENSIBLE_UI)
|
||||||
|
ExtUI::onMeshUpdate(x, y, z_values[x][y]);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if HAS_BED_PROBE
|
#if HAS_BED_PROBE
|
||||||
/**
|
/**
|
||||||
* Probe all invalidated locations of the mesh that can be reached by the probe.
|
* Probe all invalidated locations of the mesh that can be reached by the probe.
|
||||||
|
@ -1243,52 +1235,46 @@
|
||||||
|
|
||||||
mesh_index_pair farthest { -1, -1, -99999.99 };
|
mesh_index_pair farthest { -1, -1, -99999.99 };
|
||||||
|
|
||||||
for (int8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
|
GRID_LOOP(i, j) {
|
||||||
for (int8_t j = 0; j < GRID_MAX_POINTS_Y; j++) {
|
if (!isnan(z_values[i][j])) continue; // Skip valid mesh points
|
||||||
|
|
||||||
if (isnan(z_values[i][j])) { // Invalid mesh point?
|
// Skip unreachable points
|
||||||
|
if (!probe.can_reach(mesh_index_to_xpos(i), mesh_index_to_ypos(j)))
|
||||||
|
continue;
|
||||||
|
|
||||||
// Skip points the probe can't reach
|
found_a_NAN = true;
|
||||||
if (!probe.can_reach(mesh_index_to_xpos(i), mesh_index_to_ypos(j)))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
found_a_NAN = true;
|
xy_int8_t near { -1, -1 };
|
||||||
|
float d1, d2 = 99999.9f;
|
||||||
|
GRID_LOOP(k, l) {
|
||||||
|
if (isnan(z_values[k][l])) continue;
|
||||||
|
|
||||||
xy_int8_t near { -1, -1 };
|
found_a_real = true;
|
||||||
float d1, d2 = 99999.9f;
|
|
||||||
for (int8_t k = 0; k < GRID_MAX_POINTS_X; k++) {
|
|
||||||
for (int8_t l = 0; l < GRID_MAX_POINTS_Y; l++) {
|
|
||||||
if (!isnan(z_values[k][l])) {
|
|
||||||
found_a_real = true;
|
|
||||||
|
|
||||||
// Add in a random weighting factor that scrambles the probing of the
|
// Add in a random weighting factor that scrambles the probing of the
|
||||||
// last half of the mesh (when every unprobed mesh point is one index
|
// last half of the mesh (when every unprobed mesh point is one index
|
||||||
// from a probed location).
|
// from a probed location).
|
||||||
|
|
||||||
d1 = HYPOT(i - k, j - l) + (1.0f / ((millis() % 47) + 13));
|
d1 = HYPOT(i - k, j - l) + (1.0f / ((millis() % 47) + 13));
|
||||||
|
|
||||||
if (d1 < d2) { // Invalid mesh point (i,j) is closer to the defined point (k,l)
|
if (d1 < d2) { // Invalid mesh point (i,j) is closer to the defined point (k,l)
|
||||||
d2 = d1;
|
d2 = d1;
|
||||||
near.set(i, j);
|
near.set(i, j);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// At this point d2 should have the near defined mesh point to invalid mesh point (i,j)
|
|
||||||
//
|
|
||||||
|
|
||||||
if (found_a_real && near.x >= 0 && d2 > farthest.distance) {
|
|
||||||
farthest.pos = near; // Found an invalid location farther from the defined mesh point
|
|
||||||
farthest.distance = d2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} // for j
|
}
|
||||||
} // for i
|
|
||||||
|
//
|
||||||
|
// At this point d2 should have the near defined mesh point to invalid mesh point (i,j)
|
||||||
|
//
|
||||||
|
|
||||||
|
if (found_a_real && near.x >= 0 && d2 > farthest.distance) {
|
||||||
|
farthest.pos = near; // Found an invalid location farther from the defined mesh point
|
||||||
|
farthest.distance = d2;
|
||||||
|
}
|
||||||
|
} // GRID_LOOP
|
||||||
|
|
||||||
if (!found_a_real && found_a_NAN) { // if the mesh is totally unpopulated, start the probing
|
if (!found_a_real && found_a_NAN) { // if the mesh is totally unpopulated, start the probing
|
||||||
farthest.pos.set(GRID_MAX_POINTS_X / 2, GRID_MAX_POINTS_Y / 2);
|
farthest.pos.set((GRID_MAX_POINTS_X) / 2, (GRID_MAX_POINTS_Y) / 2);
|
||||||
farthest.distance = 1;
|
farthest.distance = 1;
|
||||||
}
|
}
|
||||||
return farthest;
|
return farthest;
|
||||||
|
@ -1304,36 +1290,34 @@
|
||||||
|
|
||||||
float best_so_far = 99999.99f;
|
float best_so_far = 99999.99f;
|
||||||
|
|
||||||
for (int8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
|
GRID_LOOP(i, j) {
|
||||||
for (int8_t j = 0; j < GRID_MAX_POINTS_Y; j++) {
|
if ( (type == (isnan(z_values[i][j]) ? INVALID : REAL))
|
||||||
if ( (type == (isnan(z_values[i][j]) ? INVALID : REAL))
|
|| (type == SET_IN_BITMAP && !done_flags->marked(i, j))
|
||||||
|| (type == SET_IN_BITMAP && !done_flags->marked(i, j))
|
) {
|
||||||
) {
|
// Found a Mesh Point of the specified type!
|
||||||
// Found a Mesh Point of the specified type!
|
const xy_pos_t mpos = { mesh_index_to_xpos(i), mesh_index_to_ypos(j) };
|
||||||
const xy_pos_t mpos = { mesh_index_to_xpos(i), mesh_index_to_ypos(j) };
|
|
||||||
|
|
||||||
// If using the probe as the reference there are some unreachable locations.
|
// If using the probe as the reference there are some unreachable locations.
|
||||||
// Also for round beds, there are grid points outside the bed the nozzle can't reach.
|
// Also for round beds, there are grid points outside the bed the nozzle can't reach.
|
||||||
// Prune them from the list and ignore them till the next Phase (manual nozzle probing).
|
// Prune them from the list and ignore them till the next Phase (manual nozzle probing).
|
||||||
|
|
||||||
if (!(probe_relative ? probe.can_reach(mpos) : position_is_reachable(mpos)))
|
if (!(probe_relative ? probe.can_reach(mpos) : position_is_reachable(mpos)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Reachable. Check if it's the best_so_far location to the nozzle.
|
// Reachable. Check if it's the best_so_far location to the nozzle.
|
||||||
|
|
||||||
const xy_pos_t diff = current_position - mpos;
|
const xy_pos_t diff = current_position - mpos;
|
||||||
const float distance = (ref - mpos).magnitude() + diff.magnitude() * 0.1f;
|
const float distance = (ref - mpos).magnitude() + diff.magnitude() * 0.1f;
|
||||||
|
|
||||||
// factor in the distance from the current location for the normal case
|
// factor in the distance from the current location for the normal case
|
||||||
// so the nozzle isn't running all over the bed.
|
// so the nozzle isn't running all over the bed.
|
||||||
if (distance < best_so_far) {
|
if (distance < best_so_far) {
|
||||||
best_so_far = distance; // Found a closer location with the desired value type.
|
best_so_far = distance; // Found a closer location with the desired value type.
|
||||||
closest.pos.set(i, j);
|
closest.pos.set(i, j);
|
||||||
closest.distance = best_so_far;
|
closest.distance = best_so_far;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} // for j
|
}
|
||||||
} // for i
|
} // GRID_LOOP
|
||||||
|
|
||||||
return closest;
|
return closest;
|
||||||
}
|
}
|
||||||
|
@ -1373,7 +1357,7 @@
|
||||||
info3 PROGMEM = { GRID_MAX_POINTS_X - 1, 0, 0, GRID_MAX_POINTS_Y, true }; // Right side of the mesh looking left
|
info3 PROGMEM = { GRID_MAX_POINTS_X - 1, 0, 0, GRID_MAX_POINTS_Y, true }; // Right side of the mesh looking left
|
||||||
static const smart_fill_info * const info[] PROGMEM = { &info0, &info1, &info2, &info3 };
|
static const smart_fill_info * const info[] PROGMEM = { &info0, &info1, &info2, &info3 };
|
||||||
|
|
||||||
for (uint8_t i = 0; i < COUNT(info); ++i) {
|
LOOP_L_N(i, COUNT(info)) {
|
||||||
const smart_fill_info *f = (smart_fill_info*)pgm_read_ptr(&info[i]);
|
const smart_fill_info *f = (smart_fill_info*)pgm_read_ptr(&info[i]);
|
||||||
const int8_t sx = pgm_read_byte(&f->sx), sy = pgm_read_byte(&f->sy),
|
const int8_t sx = pgm_read_byte(&f->sx), sy = pgm_read_byte(&f->sy),
|
||||||
ex = pgm_read_byte(&f->ex), ey = pgm_read_byte(&f->ey);
|
ex = pgm_read_byte(&f->ex), ey = pgm_read_byte(&f->ey);
|
||||||
|
@ -1496,12 +1480,13 @@
|
||||||
|
|
||||||
bool zig_zag = false;
|
bool zig_zag = false;
|
||||||
|
|
||||||
uint16_t total_points = g29_grid_size * g29_grid_size, point_num = 1;
|
const uint16_t total_points = sq(g29_grid_size);
|
||||||
|
uint16_t point_num = 1;
|
||||||
|
|
||||||
xy_pos_t rpos;
|
xy_pos_t rpos;
|
||||||
for (uint8_t ix = 0; ix < g29_grid_size; ix++) {
|
LOOP_L_N(ix, g29_grid_size) {
|
||||||
rpos.x = x_min + ix * dx;
|
rpos.x = x_min + ix * dx;
|
||||||
for (int8_t iy = 0; iy < g29_grid_size; iy++) {
|
LOOP_L_N(iy, g29_grid_size) {
|
||||||
rpos.y = y_min + dy * (zig_zag ? g29_grid_size - 1 - iy : iy);
|
rpos.y = y_min + dy * (zig_zag ? g29_grid_size - 1 - iy : iy);
|
||||||
|
|
||||||
if (!abort_flag) {
|
if (!abort_flag) {
|
||||||
|
@ -1569,39 +1554,37 @@
|
||||||
|
|
||||||
matrix_3x3 rotation = matrix_3x3::create_look_at(vector_3(lsf_results.A, lsf_results.B, 1));
|
matrix_3x3 rotation = matrix_3x3::create_look_at(vector_3(lsf_results.A, lsf_results.B, 1));
|
||||||
|
|
||||||
for (uint8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
|
GRID_LOOP(i, j) {
|
||||||
for (uint8_t j = 0; j < GRID_MAX_POINTS_Y; j++) {
|
float mx = mesh_index_to_xpos(i),
|
||||||
float mx = mesh_index_to_xpos(i),
|
my = mesh_index_to_ypos(j),
|
||||||
my = mesh_index_to_ypos(j),
|
mz = z_values[i][j];
|
||||||
mz = z_values[i][j];
|
|
||||||
|
|
||||||
if (DEBUGGING(LEVELING)) {
|
if (DEBUGGING(LEVELING)) {
|
||||||
DEBUG_ECHOPAIR_F("before rotation = [", mx, 7);
|
DEBUG_ECHOPAIR_F("before rotation = [", mx, 7);
|
||||||
DEBUG_CHAR(',');
|
DEBUG_CHAR(',');
|
||||||
DEBUG_ECHO_F(my, 7);
|
DEBUG_ECHO_F(my, 7);
|
||||||
DEBUG_CHAR(',');
|
DEBUG_CHAR(',');
|
||||||
DEBUG_ECHO_F(mz, 7);
|
DEBUG_ECHO_F(mz, 7);
|
||||||
DEBUG_ECHOPGM("] ---> ");
|
DEBUG_ECHOPGM("] ---> ");
|
||||||
DEBUG_DELAY(20);
|
DEBUG_DELAY(20);
|
||||||
}
|
|
||||||
|
|
||||||
apply_rotation_xyz(rotation, mx, my, mz);
|
|
||||||
|
|
||||||
if (DEBUGGING(LEVELING)) {
|
|
||||||
DEBUG_ECHOPAIR_F("after rotation = [", mx, 7);
|
|
||||||
DEBUG_CHAR(',');
|
|
||||||
DEBUG_ECHO_F(my, 7);
|
|
||||||
DEBUG_CHAR(',');
|
|
||||||
DEBUG_ECHO_F(mz, 7);
|
|
||||||
DEBUG_ECHOLNPGM("]");
|
|
||||||
DEBUG_DELAY(20);
|
|
||||||
}
|
|
||||||
|
|
||||||
z_values[i][j] = mz - lsf_results.D;
|
|
||||||
#if ENABLED(EXTENSIBLE_UI)
|
|
||||||
ExtUI::onMeshUpdate(i, j, z_values[i][j]);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apply_rotation_xyz(rotation, mx, my, mz);
|
||||||
|
|
||||||
|
if (DEBUGGING(LEVELING)) {
|
||||||
|
DEBUG_ECHOPAIR_F("after rotation = [", mx, 7);
|
||||||
|
DEBUG_CHAR(',');
|
||||||
|
DEBUG_ECHO_F(my, 7);
|
||||||
|
DEBUG_CHAR(',');
|
||||||
|
DEBUG_ECHO_F(mz, 7);
|
||||||
|
DEBUG_ECHOLNPGM("]");
|
||||||
|
DEBUG_DELAY(20);
|
||||||
|
}
|
||||||
|
|
||||||
|
z_values[i][j] = mz - lsf_results.D;
|
||||||
|
#if ENABLED(EXTENSIBLE_UI)
|
||||||
|
ExtUI::onMeshUpdate(i, j, z_values[i][j]);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DEBUGGING(LEVELING)) {
|
if (DEBUGGING(LEVELING)) {
|
||||||
|
@ -1661,7 +1644,7 @@
|
||||||
// being extrapolated so that nearby points will have greater influence on
|
// being extrapolated so that nearby points will have greater influence on
|
||||||
// the point being extrapolated. Then extrapolate the mesh point from WLSF.
|
// the point being extrapolated. Then extrapolate the mesh point from WLSF.
|
||||||
|
|
||||||
static_assert(GRID_MAX_POINTS_Y <= 16, "GRID_MAX_POINTS_Y too big");
|
static_assert((GRID_MAX_POINTS_Y) <= 16, "GRID_MAX_POINTS_Y too big");
|
||||||
uint16_t bitmap[GRID_MAX_POINTS_X] = { 0 };
|
uint16_t bitmap[GRID_MAX_POINTS_X] = { 0 };
|
||||||
struct linear_fit_data lsf_results;
|
struct linear_fit_data lsf_results;
|
||||||
|
|
||||||
|
@ -1669,23 +1652,20 @@
|
||||||
|
|
||||||
const float weight_scaled = weight_factor * _MAX(MESH_X_DIST, MESH_Y_DIST);
|
const float weight_scaled = weight_factor * _MAX(MESH_X_DIST, MESH_Y_DIST);
|
||||||
|
|
||||||
for (uint8_t jx = 0; jx < GRID_MAX_POINTS_X; jx++)
|
GRID_LOOP(jx, jy) if (!isnan(z_values[jx][jy])) SBI(bitmap[jx], jy);
|
||||||
for (uint8_t jy = 0; jy < GRID_MAX_POINTS_Y; jy++)
|
|
||||||
if (!isnan(z_values[jx][jy]))
|
|
||||||
SBI(bitmap[jx], jy);
|
|
||||||
|
|
||||||
xy_pos_t ppos;
|
xy_pos_t ppos;
|
||||||
for (uint8_t ix = 0; ix < GRID_MAX_POINTS_X; ix++) {
|
LOOP_L_N(ix, GRID_MAX_POINTS_X) {
|
||||||
ppos.x = mesh_index_to_xpos(ix);
|
ppos.x = mesh_index_to_xpos(ix);
|
||||||
for (uint8_t iy = 0; iy < GRID_MAX_POINTS_Y; iy++) {
|
LOOP_L_N(iy, GRID_MAX_POINTS_Y) {
|
||||||
ppos.y = mesh_index_to_ypos(iy);
|
ppos.y = mesh_index_to_ypos(iy);
|
||||||
if (isnan(z_values[ix][iy])) {
|
if (isnan(z_values[ix][iy])) {
|
||||||
// undefined mesh point at (ppos.x,ppos.y), compute weighted LSF from original valid mesh points.
|
// undefined mesh point at (ppos.x,ppos.y), compute weighted LSF from original valid mesh points.
|
||||||
incremental_LSF_reset(&lsf_results);
|
incremental_LSF_reset(&lsf_results);
|
||||||
xy_pos_t rpos;
|
xy_pos_t rpos;
|
||||||
for (uint8_t jx = 0; jx < GRID_MAX_POINTS_X; jx++) {
|
LOOP_L_N(jx, GRID_MAX_POINTS_X) {
|
||||||
rpos.x = mesh_index_to_xpos(jx);
|
rpos.x = mesh_index_to_xpos(jx);
|
||||||
for (uint8_t jy = 0; jy < GRID_MAX_POINTS_Y; jy++) {
|
LOOP_L_N(jy, GRID_MAX_POINTS_Y) {
|
||||||
if (TEST(bitmap[jx], jy)) {
|
if (TEST(bitmap[jx], jy)) {
|
||||||
rpos.y = mesh_index_to_ypos(jy);
|
rpos.y = mesh_index_to_ypos(jy);
|
||||||
const float rz = z_values[jx][jy],
|
const float rz = z_values[jx][jy],
|
||||||
|
@ -1747,7 +1727,7 @@
|
||||||
SERIAL_ECHOLNPAIR("MESH_Y_DIST ", MESH_Y_DIST); serial_delay(50);
|
SERIAL_ECHOLNPAIR("MESH_Y_DIST ", MESH_Y_DIST); serial_delay(50);
|
||||||
|
|
||||||
SERIAL_ECHOPGM("X-Axis Mesh Points at: ");
|
SERIAL_ECHOPGM("X-Axis Mesh Points at: ");
|
||||||
for (uint8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
|
LOOP_L_N(i, GRID_MAX_POINTS_X) {
|
||||||
SERIAL_ECHO_F(LOGICAL_X_POSITION(mesh_index_to_xpos(i)), 3);
|
SERIAL_ECHO_F(LOGICAL_X_POSITION(mesh_index_to_xpos(i)), 3);
|
||||||
SERIAL_ECHOPGM(" ");
|
SERIAL_ECHOPGM(" ");
|
||||||
serial_delay(25);
|
serial_delay(25);
|
||||||
|
@ -1755,7 +1735,7 @@
|
||||||
SERIAL_EOL();
|
SERIAL_EOL();
|
||||||
|
|
||||||
SERIAL_ECHOPGM("Y-Axis Mesh Points at: ");
|
SERIAL_ECHOPGM("Y-Axis Mesh Points at: ");
|
||||||
for (uint8_t i = 0; i < GRID_MAX_POINTS_Y; i++) {
|
LOOP_L_N(i, GRID_MAX_POINTS_Y) {
|
||||||
SERIAL_ECHO_F(LOGICAL_Y_POSITION(mesh_index_to_ypos(i)), 3);
|
SERIAL_ECHO_F(LOGICAL_Y_POSITION(mesh_index_to_ypos(i)), 3);
|
||||||
SERIAL_ECHOPGM(" ");
|
SERIAL_ECHOPGM(" ");
|
||||||
serial_delay(25);
|
serial_delay(25);
|
||||||
|
@ -1840,13 +1820,12 @@
|
||||||
|
|
||||||
SERIAL_ECHOLNPAIR("Subtracting mesh in slot ", g29_storage_slot, " from current mesh.");
|
SERIAL_ECHOLNPAIR("Subtracting mesh in slot ", g29_storage_slot, " from current mesh.");
|
||||||
|
|
||||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
GRID_LOOP(x, y) {
|
||||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++) {
|
z_values[x][y] -= tmp_z_values[x][y];
|
||||||
z_values[x][y] -= tmp_z_values[x][y];
|
#if ENABLED(EXTENSIBLE_UI)
|
||||||
#if ENABLED(EXTENSIBLE_UI)
|
ExtUI::onMeshUpdate(x, y, z_values[x][y]);
|
||||||
ExtUI::onMeshUpdate(x, y, z_values[x][y]);
|
#endif
|
||||||
#endif
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // UBL_DEVEL_DEBUGGING
|
#endif // UBL_DEVEL_DEBUGGING
|
||||||
|
|
|
@ -92,11 +92,11 @@ void digipot_i2c_set_current(const uint8_t channel, const float current) {
|
||||||
void digipot_i2c_init() {
|
void digipot_i2c_init() {
|
||||||
static const float digipot_motor_current[] PROGMEM = DIGIPOT_I2C_MOTOR_CURRENTS;
|
static const float digipot_motor_current[] PROGMEM = DIGIPOT_I2C_MOTOR_CURRENTS;
|
||||||
|
|
||||||
for (uint8_t i = 0; i < DIGIPOT_I2C_NUM_CHANNELS; i++)
|
LOOP_L_N(i, DIGIPOT_I2C_NUM_CHANNELS)
|
||||||
pots[i].i2c_init();
|
pots[i].i2c_init();
|
||||||
|
|
||||||
// setup initial currents as defined in Configuration_adv.h
|
// setup initial currents as defined in Configuration_adv.h
|
||||||
for (uint8_t i = 0; i < COUNT(digipot_motor_current); i++)
|
LOOP_L_N(i, COUNT(digipot_motor_current))
|
||||||
digipot_i2c_set_current(i, pgm_read_float(&digipot_motor_current[i]));
|
digipot_i2c_set_current(i, pgm_read_float(&digipot_motor_current[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ void digipot_i2c_init() {
|
||||||
#endif
|
#endif
|
||||||
// setup initial currents as defined in Configuration_adv.h
|
// setup initial currents as defined in Configuration_adv.h
|
||||||
static const float digipot_motor_current[] PROGMEM = DIGIPOT_I2C_MOTOR_CURRENTS;
|
static const float digipot_motor_current[] PROGMEM = DIGIPOT_I2C_MOTOR_CURRENTS;
|
||||||
for (uint8_t i = 0; i < COUNT(digipot_motor_current); i++)
|
LOOP_L_N(i, COUNT(digipot_motor_current))
|
||||||
digipot_i2c_set_current(i, pgm_read_float(&digipot_motor_current[i]));
|
digipot_i2c_set_current(i, pgm_read_float(&digipot_motor_current[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ int8_t FilamentWidthSensor::ratios[MAX_MEASUREMENT_DELAY + 1], // Ring
|
||||||
|
|
||||||
void FilamentWidthSensor::init() {
|
void FilamentWidthSensor::init() {
|
||||||
const int8_t ratio = sample_to_size_ratio();
|
const int8_t ratio = sample_to_size_ratio();
|
||||||
for (uint8_t i = 0; i < COUNT(ratios); ++i) ratios[i] = ratio;
|
LOOP_L_N(i, COUNT(ratios)) ratios[i] = ratio;
|
||||||
index_r = index_w = 0;
|
index_r = index_w = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ void FWRetract::reset() {
|
||||||
settings.swap_retract_recover_feedrate_mm_s = RETRACT_RECOVER_FEEDRATE_SWAP;
|
settings.swap_retract_recover_feedrate_mm_s = RETRACT_RECOVER_FEEDRATE_SWAP;
|
||||||
current_hop = 0.0;
|
current_hop = 0.0;
|
||||||
|
|
||||||
for (uint8_t i = 0; i < EXTRUDERS; ++i) {
|
LOOP_L_N(i, EXTRUDERS) {
|
||||||
retracted[i] = false;
|
retracted[i] = false;
|
||||||
#if EXTRUDERS > 1
|
#if EXTRUDERS > 1
|
||||||
retracted_swap[i] = false;
|
retracted_swap[i] = false;
|
||||||
|
@ -117,7 +117,7 @@ void FWRetract::retract(const bool retracting
|
||||||
" swapping ", swapping,
|
" swapping ", swapping,
|
||||||
" active extruder ", active_extruder
|
" active extruder ", active_extruder
|
||||||
);
|
);
|
||||||
for (uint8_t i = 0; i < EXTRUDERS; ++i) {
|
LOOP_L_N(i, EXTRUDERS) {
|
||||||
SERIAL_ECHOLNPAIR("retracted[", i, "] ", retracted[i]);
|
SERIAL_ECHOLNPAIR("retracted[", i, "] ", retracted[i]);
|
||||||
#if EXTRUDERS > 1
|
#if EXTRUDERS > 1
|
||||||
SERIAL_ECHOLNPAIR("retracted_swap[", i, "] ", retracted_swap[i]);
|
SERIAL_ECHOLNPAIR("retracted_swap[", i, "] ", retracted_swap[i]);
|
||||||
|
@ -201,7 +201,7 @@ void FWRetract::retract(const bool retracting
|
||||||
SERIAL_ECHOLNPAIR("retracting ", retracting);
|
SERIAL_ECHOLNPAIR("retracting ", retracting);
|
||||||
SERIAL_ECHOLNPAIR("swapping ", swapping);
|
SERIAL_ECHOLNPAIR("swapping ", swapping);
|
||||||
SERIAL_ECHOLNPAIR("active_extruder ", active_extruder);
|
SERIAL_ECHOLNPAIR("active_extruder ", active_extruder);
|
||||||
for (uint8_t i = 0; i < EXTRUDERS; ++i) {
|
LOOP_L_N(i, EXTRUDERS) {
|
||||||
SERIAL_ECHOLNPAIR("retracted[", i, "] ", retracted[i]);
|
SERIAL_ECHOLNPAIR("retracted[", i, "] ", retracted[i]);
|
||||||
#if EXTRUDERS > 1
|
#if EXTRUDERS > 1
|
||||||
SERIAL_ECHOLNPAIR("retracted_swap[", i, "] ", retracted_swap[i]);
|
SERIAL_ECHOLNPAIR("retracted_swap[", i, "] ", retracted_swap[i]);
|
||||||
|
|
|
@ -147,7 +147,7 @@ void Max7219::error(const char * const func, const int32_t v1, const int32_t v2/
|
||||||
*/
|
*/
|
||||||
inline uint32_t flipped(const uint32_t bits, const uint8_t n_bytes) {
|
inline uint32_t flipped(const uint32_t bits, const uint8_t n_bytes) {
|
||||||
uint32_t mask = 1, outbits = 0;
|
uint32_t mask = 1, outbits = 0;
|
||||||
for (uint8_t b = 0; b < n_bytes * 8; b++) {
|
LOOP_L_N(b, n_bytes * 8) {
|
||||||
outbits <<= 1;
|
outbits <<= 1;
|
||||||
if (bits & mask) outbits |= 1;
|
if (bits & mask) outbits |= 1;
|
||||||
mask <<= 1;
|
mask <<= 1;
|
||||||
|
@ -329,13 +329,13 @@ void Max7219::fill() {
|
||||||
|
|
||||||
void Max7219::clear_row(const uint8_t row) {
|
void Max7219::clear_row(const uint8_t row) {
|
||||||
if (row >= MAX7219_Y_LEDS) return error(PSTR("clear_row"), row);
|
if (row >= MAX7219_Y_LEDS) return error(PSTR("clear_row"), row);
|
||||||
for (uint8_t x = 0; x < MAX7219_X_LEDS; x++) CLR_7219(x, row);
|
LOOP_L_N(x, MAX7219_X_LEDS) CLR_7219(x, row);
|
||||||
send_row(row);
|
send_row(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Max7219::clear_column(const uint8_t col) {
|
void Max7219::clear_column(const uint8_t col) {
|
||||||
if (col >= MAX7219_X_LEDS) return error(PSTR("set_column"), col);
|
if (col >= MAX7219_X_LEDS) return error(PSTR("set_column"), col);
|
||||||
for (uint8_t y = 0; y < MAX7219_Y_LEDS; y++) CLR_7219(col, y);
|
LOOP_L_N(y, MAX7219_Y_LEDS) CLR_7219(col, y);
|
||||||
send_column(col);
|
send_column(col);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,7 +347,7 @@ void Max7219::clear_column(const uint8_t col) {
|
||||||
void Max7219::set_row(const uint8_t row, const uint32_t val) {
|
void Max7219::set_row(const uint8_t row, const uint32_t val) {
|
||||||
if (row >= MAX7219_Y_LEDS) return error(PSTR("set_row"), row);
|
if (row >= MAX7219_Y_LEDS) return error(PSTR("set_row"), row);
|
||||||
uint32_t mask = _BV32(MAX7219_X_LEDS - 1);
|
uint32_t mask = _BV32(MAX7219_X_LEDS - 1);
|
||||||
for (uint8_t x = 0; x < MAX7219_X_LEDS; x++) {
|
LOOP_L_N(x, MAX7219_X_LEDS) {
|
||||||
if (val & mask) SET_7219(x, row); else CLR_7219(x, row);
|
if (val & mask) SET_7219(x, row); else CLR_7219(x, row);
|
||||||
mask >>= 1;
|
mask >>= 1;
|
||||||
}
|
}
|
||||||
|
@ -362,7 +362,7 @@ void Max7219::set_row(const uint8_t row, const uint32_t val) {
|
||||||
void Max7219::set_column(const uint8_t col, const uint32_t val) {
|
void Max7219::set_column(const uint8_t col, const uint32_t val) {
|
||||||
if (col >= MAX7219_X_LEDS) return error(PSTR("set_column"), col);
|
if (col >= MAX7219_X_LEDS) return error(PSTR("set_column"), col);
|
||||||
uint32_t mask = _BV32(MAX7219_Y_LEDS - 1);
|
uint32_t mask = _BV32(MAX7219_Y_LEDS - 1);
|
||||||
for (uint8_t y = 0; y < MAX7219_Y_LEDS; y++) {
|
LOOP_L_N(y, MAX7219_Y_LEDS) {
|
||||||
if (val & mask) SET_7219(col, y); else CLR_7219(col, y);
|
if (val & mask) SET_7219(col, y); else CLR_7219(col, y);
|
||||||
mask >>= 1;
|
mask >>= 1;
|
||||||
}
|
}
|
||||||
|
@ -427,23 +427,23 @@ void Max7219::set_columns_32bits(const uint8_t x, uint32_t val) {
|
||||||
|
|
||||||
// Initialize the Max7219
|
// Initialize the Max7219
|
||||||
void Max7219::register_setup() {
|
void Max7219::register_setup() {
|
||||||
for (uint8_t i = 0; i < MAX7219_NUMBER_UNITS; i++)
|
LOOP_L_N(i, MAX7219_NUMBER_UNITS)
|
||||||
send(max7219_reg_scanLimit, 0x07);
|
send(max7219_reg_scanLimit, 0x07);
|
||||||
pulse_load(); // Tell the chips to load the clocked out data
|
pulse_load(); // Tell the chips to load the clocked out data
|
||||||
|
|
||||||
for (uint8_t i = 0; i < MAX7219_NUMBER_UNITS; i++)
|
LOOP_L_N(i, MAX7219_NUMBER_UNITS)
|
||||||
send(max7219_reg_decodeMode, 0x00); // Using an led matrix (not digits)
|
send(max7219_reg_decodeMode, 0x00); // Using an led matrix (not digits)
|
||||||
pulse_load(); // Tell the chips to load the clocked out data
|
pulse_load(); // Tell the chips to load the clocked out data
|
||||||
|
|
||||||
for (uint8_t i = 0; i < MAX7219_NUMBER_UNITS; i++)
|
LOOP_L_N(i, MAX7219_NUMBER_UNITS)
|
||||||
send(max7219_reg_shutdown, 0x01); // Not in shutdown mode
|
send(max7219_reg_shutdown, 0x01); // Not in shutdown mode
|
||||||
pulse_load(); // Tell the chips to load the clocked out data
|
pulse_load(); // Tell the chips to load the clocked out data
|
||||||
|
|
||||||
for (uint8_t i = 0; i < MAX7219_NUMBER_UNITS; i++)
|
LOOP_L_N(i, MAX7219_NUMBER_UNITS)
|
||||||
send(max7219_reg_displayTest, 0x00); // No display test
|
send(max7219_reg_displayTest, 0x00); // No display test
|
||||||
pulse_load(); // Tell the chips to load the clocked out data
|
pulse_load(); // Tell the chips to load the clocked out data
|
||||||
|
|
||||||
for (uint8_t i = 0; i < MAX7219_NUMBER_UNITS; i++)
|
LOOP_L_N(i, MAX7219_NUMBER_UNITS)
|
||||||
send(max7219_reg_intensity, 0x01 & 0x0F); // The first 0x0F is the value you can set
|
send(max7219_reg_intensity, 0x01 & 0x0F); // The first 0x0F is the value you can set
|
||||||
// Range: 0x00 to 0x0F
|
// Range: 0x00 to 0x0F
|
||||||
pulse_load(); // Tell the chips to load the clocked out data
|
pulse_load(); // Tell the chips to load the clocked out data
|
||||||
|
@ -537,7 +537,7 @@ void Max7219::init() {
|
||||||
|
|
||||||
register_setup();
|
register_setup();
|
||||||
|
|
||||||
for (uint8_t i = 0; i <= 7; i++) { // Empty registers to turn all LEDs off
|
LOOP_LE_N(i, 7) { // Empty registers to turn all LEDs off
|
||||||
led_line[i] = 0x00;
|
led_line[i] = 0x00;
|
||||||
send(max7219_reg_digit0 + i, 0);
|
send(max7219_reg_digit0 + i, 0);
|
||||||
pulse_load(); // Tell the chips to load the clocked out data
|
pulse_load(); // Tell the chips to load the clocked out data
|
||||||
|
|
|
@ -98,13 +98,13 @@ void Mixer::normalize(const uint8_t tool_index) {
|
||||||
void Mixer::reset_vtools() {
|
void Mixer::reset_vtools() {
|
||||||
// Virtual Tools 0, 1, 2, 3 = Filament 1, 2, 3, 4, etc.
|
// Virtual Tools 0, 1, 2, 3 = Filament 1, 2, 3, 4, etc.
|
||||||
// Every virtual tool gets a pure filament
|
// Every virtual tool gets a pure filament
|
||||||
for (uint8_t t = 0; t < MIXING_VIRTUAL_TOOLS && t < MIXING_STEPPERS; t++)
|
LOOP_L_N(t, MIXING_VIRTUAL_TOOLS && t < MIXING_STEPPERS)
|
||||||
MIXER_STEPPER_LOOP(i)
|
MIXER_STEPPER_LOOP(i)
|
||||||
color[t][i] = (t == i) ? COLOR_A_MASK : 0;
|
color[t][i] = (t == i) ? COLOR_A_MASK : 0;
|
||||||
|
|
||||||
// Remaining virtual tools are 100% filament 1
|
// Remaining virtual tools are 100% filament 1
|
||||||
#if MIXING_VIRTUAL_TOOLS > MIXING_STEPPERS
|
#if MIXING_VIRTUAL_TOOLS > MIXING_STEPPERS
|
||||||
for (uint8_t t = MIXING_STEPPERS; t < MIXING_VIRTUAL_TOOLS; t++)
|
LOOP_S_L_N(t, MIXING_STEPPERS, MIXING_VIRTUAL_TOOLS)
|
||||||
MIXER_STEPPER_LOOP(i)
|
MIXER_STEPPER_LOOP(i)
|
||||||
color[t][i] = (i == 0) ? COLOR_A_MASK : 0;
|
color[t][i] = (i == 0) ? COLOR_A_MASK : 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -381,7 +381,7 @@ bool MMU2::rx_str_P(const char* str) {
|
||||||
void MMU2::tx_str_P(const char* str) {
|
void MMU2::tx_str_P(const char* str) {
|
||||||
clear_rx_buffer();
|
clear_rx_buffer();
|
||||||
uint8_t len = strlen_P(str);
|
uint8_t len = strlen_P(str);
|
||||||
for (uint8_t i = 0; i < len; i++) mmuSerial.write(pgm_read_byte(str++));
|
LOOP_L_N(i, len) mmuSerial.write(pgm_read_byte(str++));
|
||||||
rx_buffer[0] = '\0';
|
rx_buffer[0] = '\0';
|
||||||
last_request = millis();
|
last_request = millis();
|
||||||
}
|
}
|
||||||
|
@ -392,7 +392,7 @@ void MMU2::tx_str_P(const char* str) {
|
||||||
void MMU2::tx_printf_P(const char* format, int argument = -1) {
|
void MMU2::tx_printf_P(const char* format, int argument = -1) {
|
||||||
clear_rx_buffer();
|
clear_rx_buffer();
|
||||||
uint8_t len = sprintf_P(tx_buffer, format, argument);
|
uint8_t len = sprintf_P(tx_buffer, format, argument);
|
||||||
for (uint8_t i = 0; i < len; i++) mmuSerial.write(tx_buffer[i]);
|
LOOP_L_N(i, len) mmuSerial.write(tx_buffer[i]);
|
||||||
rx_buffer[0] = '\0';
|
rx_buffer[0] = '\0';
|
||||||
last_request = millis();
|
last_request = millis();
|
||||||
}
|
}
|
||||||
|
@ -403,7 +403,7 @@ void MMU2::tx_printf_P(const char* format, int argument = -1) {
|
||||||
void MMU2::tx_printf_P(const char* format, int argument1, int argument2) {
|
void MMU2::tx_printf_P(const char* format, int argument1, int argument2) {
|
||||||
clear_rx_buffer();
|
clear_rx_buffer();
|
||||||
uint8_t len = sprintf_P(tx_buffer, format, argument1, argument2);
|
uint8_t len = sprintf_P(tx_buffer, format, argument1, argument2);
|
||||||
for (uint8_t i = 0; i < len; i++) mmuSerial.write(tx_buffer[i]);
|
LOOP_L_N(i, len) mmuSerial.write(tx_buffer[i]);
|
||||||
rx_buffer[0] = '\0';
|
rx_buffer[0] = '\0';
|
||||||
last_request = millis();
|
last_request = millis();
|
||||||
}
|
}
|
||||||
|
@ -780,7 +780,7 @@ void MMU2::filament_runout() {
|
||||||
|
|
||||||
const E_Step* step = sequence;
|
const E_Step* step = sequence;
|
||||||
|
|
||||||
for (uint8_t i = 0; i < steps; i++) {
|
LOOP_L_N(i, steps) {
|
||||||
const float es = pgm_read_float(&(step->extrude));
|
const float es = pgm_read_float(&(step->extrude));
|
||||||
const feedRate_t fr_mm_m = pgm_read_float(&(step->feedRate));
|
const feedRate_t fr_mm_m = pgm_read_float(&(step->feedRate));
|
||||||
|
|
||||||
|
|
|
@ -391,7 +391,7 @@ void PrintJobRecovery::resume() {
|
||||||
|
|
||||||
// Restore retract and hop state
|
// Restore retract and hop state
|
||||||
#if ENABLED(FWRETRACT)
|
#if ENABLED(FWRETRACT)
|
||||||
for (uint8_t e = 0; e < EXTRUDERS; e++) {
|
LOOP_L_N(e, EXTRUDERS) {
|
||||||
if (info.retract[e] != 0.0) {
|
if (info.retract[e] != 0.0) {
|
||||||
fwretract.current_retract[e] = info.retract[e];
|
fwretract.current_retract[e] = info.retract[e];
|
||||||
fwretract.retracted[e] = true;
|
fwretract.retracted[e] = true;
|
||||||
|
|
|
@ -54,7 +54,7 @@ uint8_t ProbeTempComp::calib_idx; // = 0
|
||||||
float ProbeTempComp::init_measurement; // = 0.0
|
float ProbeTempComp::init_measurement; // = 0.0
|
||||||
|
|
||||||
void ProbeTempComp::clear_offsets(const TempSensorID tsi) {
|
void ProbeTempComp::clear_offsets(const TempSensorID tsi) {
|
||||||
for (uint8_t i = 0; i < cali_info[tsi].measurements; ++i)
|
LOOP_L_N(i, cali_info[tsi].measurements)
|
||||||
sensor_z_offsets[tsi][i] = 0;
|
sensor_z_offsets[tsi][i] = 0;
|
||||||
calib_idx = 0;
|
calib_idx = 0;
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ bool ProbeTempComp::set_offset(const TempSensorID tsi, const uint8_t idx, const
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProbeTempComp::print_offsets() {
|
void ProbeTempComp::print_offsets() {
|
||||||
for (uint8_t s = 0; s < TSI_COUNT; s++) {
|
LOOP_L_N(s, TSI_COUNT) {
|
||||||
float temp = cali_info[s].start_temp;
|
float temp = cali_info[s].start_temp;
|
||||||
for (int16_t i = -1; i < cali_info[s].measurements; ++i) {
|
for (int16_t i = -1; i < cali_info[s].measurements; ++i) {
|
||||||
serialprintPGM(s == TSI_BED ? PSTR("Bed") :
|
serialprintPGM(s == TSI_BED ? PSTR("Bed") :
|
||||||
|
@ -198,7 +198,7 @@ bool ProbeTempComp::linear_regression(const TempSensorID tsi, float &k, float &d
|
||||||
sum_x2 = sq(start_temp),
|
sum_x2 = sq(start_temp),
|
||||||
sum_xy = 0, sum_y = 0;
|
sum_xy = 0, sum_y = 0;
|
||||||
|
|
||||||
for (uint8_t i = 0; i < calib_idx; ++i) {
|
LOOP_L_N(i, calib_idx) {
|
||||||
const float xi = start_temp + (i + 1) * res_temp,
|
const float xi = start_temp + (i + 1) * res_temp,
|
||||||
yi = static_cast<float>(data[i]);
|
yi = static_cast<float>(data[i]);
|
||||||
sum_x += xi;
|
sum_x += xi;
|
||||||
|
|
|
@ -184,7 +184,7 @@ class FilamentSensorBase {
|
||||||
#ifdef FILAMENT_RUNOUT_SENSOR_DEBUG
|
#ifdef FILAMENT_RUNOUT_SENSOR_DEBUG
|
||||||
if (change) {
|
if (change) {
|
||||||
SERIAL_ECHOPGM("Motion detected:");
|
SERIAL_ECHOPGM("Motion detected:");
|
||||||
for (uint8_t e = 0; e < NUM_RUNOUT_SENSORS; e++)
|
LOOP_L_N(e, NUM_RUNOUT_SENSORS)
|
||||||
if (TEST(change, e)) SERIAL_CHAR(' ', '0' + e);
|
if (TEST(change, e)) SERIAL_CHAR(' ', '0' + e);
|
||||||
SERIAL_EOL();
|
SERIAL_EOL();
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ void TWIBus::echodata(uint8_t bytes, const char prefix[], uint8_t adr) {
|
||||||
|
|
||||||
void TWIBus::echobuffer(const char prefix[], uint8_t adr) {
|
void TWIBus::echobuffer(const char prefix[], uint8_t adr) {
|
||||||
echoprefix(buffer_s, prefix, adr);
|
echoprefix(buffer_s, prefix, adr);
|
||||||
for (uint8_t i = 0; i < buffer_s; i++) SERIAL_CHAR(buffer[i]);
|
LOOP_L_N(i, buffer_s) SERIAL_CHAR(buffer[i]);
|
||||||
SERIAL_EOL();
|
SERIAL_EOL();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -157,7 +157,7 @@ float g26_extrusion_multiplier,
|
||||||
g26_layer_height,
|
g26_layer_height,
|
||||||
g26_prime_length;
|
g26_prime_length;
|
||||||
|
|
||||||
xy_pos_t g26_pos; // = { 0, 0 }
|
xy_pos_t g26_xy_pos; // = { 0, 0 }
|
||||||
|
|
||||||
int16_t g26_bed_temp,
|
int16_t g26_bed_temp,
|
||||||
g26_hotend_temp;
|
g26_hotend_temp;
|
||||||
|
@ -187,29 +187,27 @@ mesh_index_pair find_closest_circle_to_print(const xy_pos_t &pos) {
|
||||||
|
|
||||||
out_point.pos = -1;
|
out_point.pos = -1;
|
||||||
|
|
||||||
for (uint8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
|
GRID_LOOP(i, j) {
|
||||||
for (uint8_t j = 0; j < GRID_MAX_POINTS_Y; j++) {
|
if (!circle_flags.marked(i, j)) {
|
||||||
if (!circle_flags.marked(i, j)) {
|
// We found a circle that needs to be printed
|
||||||
// We found a circle that needs to be printed
|
const xy_pos_t m = { _GET_MESH_X(i), _GET_MESH_Y(j) };
|
||||||
const xy_pos_t m = { _GET_MESH_X(i), _GET_MESH_Y(j) };
|
|
||||||
|
|
||||||
// Get the distance to this intersection
|
// Get the distance to this intersection
|
||||||
float f = (pos - m).magnitude();
|
float f = (pos - m).magnitude();
|
||||||
|
|
||||||
// It is possible that we are being called with the values
|
// It is possible that we are being called with the values
|
||||||
// to let us find the closest circle to the start position.
|
// to let us find the closest circle to the start position.
|
||||||
// But if this is not the case, add a small weighting to the
|
// But if this is not the case, add a small weighting to the
|
||||||
// distance calculation to help it choose a better place to continue.
|
// distance calculation to help it choose a better place to continue.
|
||||||
f += (g26_pos - m).magnitude() / 15.0f;
|
f += (g26_xy_pos - m).magnitude() / 15.0f;
|
||||||
|
|
||||||
// Add the specified amount of Random Noise to our search
|
// Add the specified amount of Random Noise to our search
|
||||||
if (random_deviation > 1.0) f += random(0.0, random_deviation);
|
if (random_deviation > 1.0) f += random(0.0, random_deviation);
|
||||||
|
|
||||||
if (f < closest) {
|
if (f < closest) {
|
||||||
closest = f; // Found a closer un-printed location
|
closest = f; // Found a closer un-printed location
|
||||||
out_point.pos.set(i, j); // Save its data
|
out_point.pos.set(i, j); // Save its data
|
||||||
out_point.distance = closest;
|
out_point.distance = closest;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -308,51 +306,49 @@ inline bool look_for_lines_to_connect() {
|
||||||
xyz_pos_t s, e;
|
xyz_pos_t s, e;
|
||||||
s.z = e.z = g26_layer_height;
|
s.z = e.z = g26_layer_height;
|
||||||
|
|
||||||
for (uint8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
|
GRID_LOOP(i, j) {
|
||||||
for (uint8_t j = 0; j < GRID_MAX_POINTS_Y; j++) {
|
|
||||||
|
|
||||||
#if HAS_LCD_MENU
|
#if HAS_LCD_MENU
|
||||||
if (user_canceled()) return true;
|
if (user_canceled()) return true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (i < GRID_MAX_POINTS_X) { // Can't connect to anything farther to the right than GRID_MAX_POINTS_X.
|
if (i < (GRID_MAX_POINTS_X)) { // Can't connect to anything farther to the right than GRID_MAX_POINTS_X.
|
||||||
// Already a half circle at the edge of the bed.
|
// Already a half circle at the edge of the bed.
|
||||||
|
|
||||||
if (circle_flags.marked(i, j) && circle_flags.marked(i + 1, j)) { // Test whether a leftward line can be done
|
if (circle_flags.marked(i, j) && circle_flags.marked(i + 1, j)) { // Test whether a leftward line can be done
|
||||||
if (!horizontal_mesh_line_flags.marked(i, j)) {
|
if (!horizontal_mesh_line_flags.marked(i, j)) {
|
||||||
// Two circles need a horizontal line to connect them
|
// Two circles need a horizontal line to connect them
|
||||||
s.x = _GET_MESH_X( i ) + (INTERSECTION_CIRCLE_RADIUS - (CROSSHAIRS_SIZE)); // right edge
|
s.x = _GET_MESH_X( i ) + (INTERSECTION_CIRCLE_RADIUS - (CROSSHAIRS_SIZE)); // right edge
|
||||||
e.x = _GET_MESH_X(i + 1) - (INTERSECTION_CIRCLE_RADIUS - (CROSSHAIRS_SIZE)); // left edge
|
e.x = _GET_MESH_X(i + 1) - (INTERSECTION_CIRCLE_RADIUS - (CROSSHAIRS_SIZE)); // left edge
|
||||||
|
|
||||||
LIMIT(s.x, X_MIN_POS + 1, X_MAX_POS - 1);
|
LIMIT(s.x, X_MIN_POS + 1, X_MAX_POS - 1);
|
||||||
s.y = e.y = constrain(_GET_MESH_Y(j), Y_MIN_POS + 1, Y_MAX_POS - 1);
|
s.y = e.y = constrain(_GET_MESH_Y(j), Y_MIN_POS + 1, Y_MAX_POS - 1);
|
||||||
LIMIT(e.x, X_MIN_POS + 1, X_MAX_POS - 1);
|
LIMIT(e.x, X_MIN_POS + 1, X_MAX_POS - 1);
|
||||||
|
|
||||||
|
if (position_is_reachable(s.x, s.y) && position_is_reachable(e.x, e.y))
|
||||||
|
print_line_from_here_to_there(s, e);
|
||||||
|
|
||||||
|
horizontal_mesh_line_flags.mark(i, j); // Mark done, even if skipped
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (j < (GRID_MAX_POINTS_Y)) { // Can't connect to anything further back than GRID_MAX_POINTS_Y.
|
||||||
|
// Already a half circle at the edge of the bed.
|
||||||
|
|
||||||
|
if (circle_flags.marked(i, j) && circle_flags.marked(i, j + 1)) { // Test whether a downward line can be done
|
||||||
|
if (!vertical_mesh_line_flags.marked(i, j)) {
|
||||||
|
// Two circles that need a vertical line to connect them
|
||||||
|
s.y = _GET_MESH_Y( j ) + (INTERSECTION_CIRCLE_RADIUS - (CROSSHAIRS_SIZE)); // top edge
|
||||||
|
e.y = _GET_MESH_Y(j + 1) - (INTERSECTION_CIRCLE_RADIUS - (CROSSHAIRS_SIZE)); // bottom edge
|
||||||
|
|
||||||
|
s.x = e.x = constrain(_GET_MESH_X(i), X_MIN_POS + 1, X_MAX_POS - 1);
|
||||||
|
LIMIT(s.y, Y_MIN_POS + 1, Y_MAX_POS - 1);
|
||||||
|
LIMIT(e.y, Y_MIN_POS + 1, Y_MAX_POS - 1);
|
||||||
|
|
||||||
if (position_is_reachable(s.x, s.y) && position_is_reachable(e.x, e.y))
|
if (position_is_reachable(s.x, s.y) && position_is_reachable(e.x, e.y))
|
||||||
print_line_from_here_to_there(s, e);
|
print_line_from_here_to_there(s, e);
|
||||||
|
|
||||||
horizontal_mesh_line_flags.mark(i, j); // Mark done, even if skipped
|
vertical_mesh_line_flags.mark(i, j); // Mark done, even if skipped
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (j < GRID_MAX_POINTS_Y) { // Can't connect to anything further back than GRID_MAX_POINTS_Y.
|
|
||||||
// Already a half circle at the edge of the bed.
|
|
||||||
|
|
||||||
if (circle_flags.marked(i, j) && circle_flags.marked(i, j + 1)) { // Test whether a downward line can be done
|
|
||||||
if (!vertical_mesh_line_flags.marked(i, j)) {
|
|
||||||
// Two circles that need a vertical line to connect them
|
|
||||||
s.y = _GET_MESH_Y( j ) + (INTERSECTION_CIRCLE_RADIUS - (CROSSHAIRS_SIZE)); // top edge
|
|
||||||
e.y = _GET_MESH_Y(j + 1) - (INTERSECTION_CIRCLE_RADIUS - (CROSSHAIRS_SIZE)); // bottom edge
|
|
||||||
|
|
||||||
s.x = e.x = constrain(_GET_MESH_X(i), X_MIN_POS + 1, X_MAX_POS - 1);
|
|
||||||
LIMIT(s.y, Y_MIN_POS + 1, Y_MAX_POS - 1);
|
|
||||||
LIMIT(e.y, Y_MIN_POS + 1, Y_MAX_POS - 1);
|
|
||||||
|
|
||||||
if (position_is_reachable(s.x, s.y) && position_is_reachable(e.x, e.y))
|
|
||||||
print_line_from_here_to_there(s, e);
|
|
||||||
|
|
||||||
vertical_mesh_line_flags.mark(i, j); // Mark done, even if skipped
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -628,9 +624,9 @@ void GcodeSuite::G26() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
g26_pos.set(parser.seenval('X') ? RAW_X_POSITION(parser.value_linear_units()) : current_position.x,
|
g26_xy_pos.set(parser.seenval('X') ? RAW_X_POSITION(parser.value_linear_units()) : current_position.x,
|
||||||
parser.seenval('Y') ? RAW_Y_POSITION(parser.value_linear_units()) : current_position.y);
|
parser.seenval('Y') ? RAW_Y_POSITION(parser.value_linear_units()) : current_position.y);
|
||||||
if (!position_is_reachable(g26_pos.x, g26_pos.y)) {
|
if (!position_is_reachable(g26_xy_pos)) {
|
||||||
SERIAL_ECHOLNPGM("?Specified X,Y coordinate out of bounds.");
|
SERIAL_ECHOLNPGM("?Specified X,Y coordinate out of bounds.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -695,7 +691,7 @@ void GcodeSuite::G26() {
|
||||||
#error "A_CNT must be a positive value. Please change A_INT."
|
#error "A_CNT must be a positive value. Please change A_INT."
|
||||||
#endif
|
#endif
|
||||||
float trig_table[A_CNT];
|
float trig_table[A_CNT];
|
||||||
for (uint8_t i = 0; i < A_CNT; i++)
|
LOOP_L_N(i, A_CNT)
|
||||||
trig_table[i] = INTERSECTION_CIRCLE_RADIUS * cos(RADIANS(i * A_INT));
|
trig_table[i] = INTERSECTION_CIRCLE_RADIUS * cos(RADIANS(i * A_INT));
|
||||||
|
|
||||||
#endif // !ARC_SUPPORT
|
#endif // !ARC_SUPPORT
|
||||||
|
@ -703,7 +699,7 @@ void GcodeSuite::G26() {
|
||||||
mesh_index_pair location;
|
mesh_index_pair location;
|
||||||
do {
|
do {
|
||||||
// Find the nearest confluence
|
// Find the nearest confluence
|
||||||
location = find_closest_circle_to_print(g26_continue_with_closest ? xy_pos_t(current_position) : g26_pos);
|
location = find_closest_circle_to_print(g26_continue_with_closest ? xy_pos_t(current_position) : g26_xy_pos);
|
||||||
|
|
||||||
if (location.valid()) {
|
if (location.valid()) {
|
||||||
const xy_pos_t circle = _GET_MESH_POS(location.pos);
|
const xy_pos_t circle = _GET_MESH_POS(location.pos);
|
||||||
|
@ -834,12 +830,9 @@ void GcodeSuite::G26() {
|
||||||
|
|
||||||
retract_filament(destination);
|
retract_filament(destination);
|
||||||
destination.z = Z_CLEARANCE_BETWEEN_PROBES;
|
destination.z = Z_CLEARANCE_BETWEEN_PROBES;
|
||||||
|
move_to(destination, 0); // Raise the nozzle
|
||||||
|
|
||||||
move_to(destination, 0); // Raise the nozzle
|
destination = g26_xy_pos; // Move back to the starting XY position
|
||||||
|
|
||||||
destination.set(g26_pos.x, g26_pos.y); // Move back to the starting position
|
|
||||||
//destination.z = Z_CLEARANCE_BETWEEN_PROBES; // Keep the nozzle where it is
|
|
||||||
|
|
||||||
move_to(destination, 0); // Move back to the starting position
|
move_to(destination, 0); // Move back to the starting position
|
||||||
|
|
||||||
#if DISABLED(NO_VOLUMETRICS)
|
#if DISABLED(NO_VOLUMETRICS)
|
||||||
|
|
|
@ -71,13 +71,12 @@ void GcodeSuite::M420() {
|
||||||
bilinear_grid_spacing.set((x_max - x_min) / (GRID_MAX_POINTS_X - 1),
|
bilinear_grid_spacing.set((x_max - x_min) / (GRID_MAX_POINTS_X - 1),
|
||||||
(y_max - y_min) / (GRID_MAX_POINTS_Y - 1));
|
(y_max - y_min) / (GRID_MAX_POINTS_Y - 1));
|
||||||
#endif
|
#endif
|
||||||
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
GRID_LOOP(x, y) {
|
||||||
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++) {
|
Z_VALUES(x, y) = 0.001 * random(-200, 200);
|
||||||
Z_VALUES(x, y) = 0.001 * random(-200, 200);
|
#if ENABLED(EXTENSIBLE_UI)
|
||||||
#if ENABLED(EXTENSIBLE_UI)
|
ExtUI::onMeshUpdate(x, y, Z_VALUES(x, y));
|
||||||
ExtUI::onMeshUpdate(x, y, Z_VALUES(x, y));
|
#endif
|
||||||
#endif
|
}
|
||||||
}
|
|
||||||
SERIAL_ECHOPGM("Simulated " STRINGIFY(GRID_MAX_POINTS_X) "x" STRINGIFY(GRID_MAX_POINTS_Y) " mesh ");
|
SERIAL_ECHOPGM("Simulated " STRINGIFY(GRID_MAX_POINTS_X) "x" STRINGIFY(GRID_MAX_POINTS_Y) " mesh ");
|
||||||
SERIAL_ECHOPAIR(" (", x_min);
|
SERIAL_ECHOPAIR(" (", x_min);
|
||||||
SERIAL_CHAR(','); SERIAL_ECHO(y_min);
|
SERIAL_CHAR(','); SERIAL_ECHO(y_min);
|
||||||
|
|
|
@ -746,7 +746,7 @@ G29_TYPE GcodeSuite::G29() {
|
||||||
|
|
||||||
// Probe at 3 arbitrary points
|
// Probe at 3 arbitrary points
|
||||||
|
|
||||||
for (uint8_t i = 0; i < 3; ++i) {
|
LOOP_L_N(i, 3) {
|
||||||
if (verbose_level) SERIAL_ECHOLNPAIR("Probing point ", int(i), "/3.");
|
if (verbose_level) SERIAL_ECHOLNPAIR("Probing point ", int(i), "/3.");
|
||||||
#if HAS_DISPLAY
|
#if HAS_DISPLAY
|
||||||
ui.status_printf_P(0, PSTR(S_FMT " %i/3"), GET_TEXT(MSG_PROBING_MESH), int(i));
|
ui.status_printf_P(0, PSTR(S_FMT " %i/3"), GET_TEXT(MSG_PROBING_MESH), int(i));
|
||||||
|
@ -861,7 +861,7 @@ G29_TYPE GcodeSuite::G29() {
|
||||||
auto print_topo_map = [&](PGM_P const title, const bool get_min) {
|
auto print_topo_map = [&](PGM_P const title, const bool get_min) {
|
||||||
serialprintPGM(title);
|
serialprintPGM(title);
|
||||||
for (int8_t yy = abl_grid_points.y - 1; yy >= 0; yy--) {
|
for (int8_t yy = abl_grid_points.y - 1; yy >= 0; yy--) {
|
||||||
for (uint8_t xx = 0; xx < abl_grid_points.x; xx++) {
|
LOOP_L_N(xx, abl_grid_points.x) {
|
||||||
const int ind = indexIntoAB[xx][yy];
|
const int ind = indexIntoAB[xx][yy];
|
||||||
xyz_float_t tmp = { eqnAMatrix[ind + 0 * abl_points],
|
xyz_float_t tmp = { eqnAMatrix[ind + 0 * abl_points],
|
||||||
eqnAMatrix[ind + 1 * abl_points], 0 };
|
eqnAMatrix[ind + 1 * abl_points], 0 };
|
||||||
|
|
|
@ -124,7 +124,7 @@ inline void park_above_object(measurements_t &m, const float uncertainty) {
|
||||||
#if HAS_HOTEND_OFFSET
|
#if HAS_HOTEND_OFFSET
|
||||||
|
|
||||||
inline void normalize_hotend_offsets() {
|
inline void normalize_hotend_offsets() {
|
||||||
for (uint8_t e = 1; e < HOTENDS; e++)
|
LOOP_S_L_N(e, 1, HOTENDS)
|
||||||
hotend_offset[e] -= hotend_offset[0];
|
hotend_offset[e] -= hotend_offset[0];
|
||||||
hotend_offset[0].reset();
|
hotend_offset[0].reset();
|
||||||
}
|
}
|
||||||
|
@ -393,7 +393,7 @@ inline void probe_sides(measurements_t &m, const float uncertainty) {
|
||||||
// This function requires normalize_hotend_offsets() to be called
|
// This function requires normalize_hotend_offsets() to be called
|
||||||
//
|
//
|
||||||
inline void report_hotend_offsets() {
|
inline void report_hotend_offsets() {
|
||||||
for (uint8_t e = 1; e < HOTENDS; e++)
|
LOOP_S_L_N(e, 1, HOTENDS)
|
||||||
SERIAL_ECHOLNPAIR_P(PSTR("T"), int(e), PSTR(" Hotend Offset X"), hotend_offset[e].x, SP_Y_STR, hotend_offset[e].y, SP_Z_STR, hotend_offset[e].z);
|
SERIAL_ECHOLNPAIR_P(PSTR("T"), int(e), PSTR(" Hotend Offset X"), hotend_offset[e].x, SP_Y_STR, hotend_offset[e].y, SP_Z_STR, hotend_offset[e].z);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -158,14 +158,14 @@ inline int32_t count_test_bytes(const char * const start_free_memory) {
|
||||||
while (start_free_memory < end_free_memory) {
|
while (start_free_memory < end_free_memory) {
|
||||||
print_hex_address(start_free_memory); // Print the address
|
print_hex_address(start_free_memory); // Print the address
|
||||||
SERIAL_CHAR(':');
|
SERIAL_CHAR(':');
|
||||||
for (uint8_t i = 0; i < 16; i++) { // and 16 data bytes
|
LOOP_L_N(i, 16) { // and 16 data bytes
|
||||||
if (i == 8) SERIAL_CHAR('-');
|
if (i == 8) SERIAL_CHAR('-');
|
||||||
print_hex_byte(start_free_memory[i]);
|
print_hex_byte(start_free_memory[i]);
|
||||||
SERIAL_CHAR(' ');
|
SERIAL_CHAR(' ');
|
||||||
}
|
}
|
||||||
serial_delay(25);
|
serial_delay(25);
|
||||||
SERIAL_CHAR('|'); // Point out non test bytes
|
SERIAL_CHAR('|'); // Point out non test bytes
|
||||||
for (uint8_t i = 0; i < 16; i++) {
|
LOOP_L_N(i, 16) {
|
||||||
char ccc = (char)start_free_memory[i]; // cast to char before automatically casting to char on assignment, in case the compiler is broken
|
char ccc = (char)start_free_memory[i]; // cast to char before automatically casting to char on assignment, in case the compiler is broken
|
||||||
ccc = (ccc == TEST_BYTE) ? ' ' : '?';
|
ccc = (ccc == TEST_BYTE) ? ' ' : '?';
|
||||||
SERIAL_CHAR(ccc);
|
SERIAL_CHAR(ccc);
|
||||||
|
|
|
@ -126,7 +126,7 @@ void GcodeSuite::M48() {
|
||||||
if (probing_good) {
|
if (probing_good) {
|
||||||
randomSeed(millis());
|
randomSeed(millis());
|
||||||
|
|
||||||
for (uint8_t n = 0; n < n_samples; n++) {
|
LOOP_L_N(n, n_samples) {
|
||||||
#if HAS_SPI_LCD
|
#if HAS_SPI_LCD
|
||||||
// Display M48 progress in the status bar
|
// Display M48 progress in the status bar
|
||||||
ui.status_printf_P(0, PSTR(S_FMT ": %d/%d"), GET_TEXT(MSG_M48_POINT), int(n + 1), int(n_samples));
|
ui.status_printf_P(0, PSTR(S_FMT ": %d/%d"), GET_TEXT(MSG_M48_POINT), int(n + 1), int(n_samples));
|
||||||
|
@ -149,7 +149,7 @@ void GcodeSuite::M48() {
|
||||||
SERIAL_ECHOLNPGM("CW");
|
SERIAL_ECHOLNPGM("CW");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint8_t l = 0; l < n_legs - 1; l++) {
|
LOOP_L_N(l, n_legs - 1) {
|
||||||
float delta_angle;
|
float delta_angle;
|
||||||
|
|
||||||
if (schizoid_flag) {
|
if (schizoid_flag) {
|
||||||
|
@ -204,7 +204,7 @@ void GcodeSuite::M48() {
|
||||||
* Get the current mean for the data points we have so far
|
* Get the current mean for the data points we have so far
|
||||||
*/
|
*/
|
||||||
float sum = 0.0;
|
float sum = 0.0;
|
||||||
for (uint8_t j = 0; j <= n; j++) sum += sample_set[j];
|
LOOP_LE_N(j, n) sum += sample_set[j];
|
||||||
mean = sum / (n + 1);
|
mean = sum / (n + 1);
|
||||||
|
|
||||||
NOMORE(min, sample_set[n]);
|
NOMORE(min, sample_set[n]);
|
||||||
|
@ -215,7 +215,7 @@ void GcodeSuite::M48() {
|
||||||
* data points we have so far
|
* data points we have so far
|
||||||
*/
|
*/
|
||||||
sum = 0.0;
|
sum = 0.0;
|
||||||
for (uint8_t j = 0; j <= n; j++)
|
LOOP_LE_N(j, n)
|
||||||
sum += sq(sample_set[j] - mean);
|
sum += sq(sample_set[j] - mean);
|
||||||
|
|
||||||
sigma = SQRT(sum / (n + 1));
|
sigma = SQRT(sum / (n + 1));
|
||||||
|
|
|
@ -71,7 +71,7 @@ void GcodeSuite::M305() {
|
||||||
SERIAL_ECHO_MSG("!Invalid Steinhart-Hart C coeff. (-0.01 < C < +0.01)");
|
SERIAL_ECHO_MSG("!Invalid Steinhart-Hart C coeff. (-0.01 < C < +0.01)");
|
||||||
} // If not setting then report parameters
|
} // If not setting then report parameters
|
||||||
else if (t_index < 0) { // ...all user thermistors
|
else if (t_index < 0) { // ...all user thermistors
|
||||||
for (uint8_t i = 0; i < USER_THERMISTORS; i++)
|
LOOP_L_N(i, USER_THERMISTORS)
|
||||||
thermalManager.log_user_thermistor(i);
|
thermalManager.log_user_thermistor(i);
|
||||||
}
|
}
|
||||||
else // ...one user thermistor
|
else // ...one user thermistor
|
||||||
|
|
|
@ -57,7 +57,7 @@ inline void toggle_pins() {
|
||||||
end = PARSED_PIN_INDEX('L', NUM_DIGITAL_PINS - 1),
|
end = PARSED_PIN_INDEX('L', NUM_DIGITAL_PINS - 1),
|
||||||
wait = parser.intval('W', 500);
|
wait = parser.intval('W', 500);
|
||||||
|
|
||||||
for (uint8_t i = start; i <= end; i++) {
|
LOOP_S_LE_N(i, start, end) {
|
||||||
pin_t pin = GET_PIN_MAP_PIN_M43(i);
|
pin_t pin = GET_PIN_MAP_PIN_M43(i);
|
||||||
if (!VALID_PIN(pin)) continue;
|
if (!VALID_PIN(pin)) continue;
|
||||||
if (M43_NEVER_TOUCH(i) || (!ignore_protection && pin_is_protected(pin))) {
|
if (M43_NEVER_TOUCH(i) || (!ignore_protection && pin_is_protected(pin))) {
|
||||||
|
@ -313,7 +313,7 @@ void GcodeSuite::M43() {
|
||||||
NOLESS(first_pin, 2); // Don't hijack the UART pins
|
NOLESS(first_pin, 2); // Don't hijack the UART pins
|
||||||
#endif
|
#endif
|
||||||
uint8_t pin_state[last_pin - first_pin + 1];
|
uint8_t pin_state[last_pin - first_pin + 1];
|
||||||
for (uint8_t i = first_pin; i <= last_pin; i++) {
|
LOOP_S_LE_N(i, first_pin, last_pin) {
|
||||||
pin_t pin = GET_PIN_MAP_PIN_M43(i);
|
pin_t pin = GET_PIN_MAP_PIN_M43(i);
|
||||||
if (!VALID_PIN(pin)) continue;
|
if (!VALID_PIN(pin)) continue;
|
||||||
if (M43_NEVER_TOUCH(i) || (!ignore_protection && pin_is_protected(pin))) continue;
|
if (M43_NEVER_TOUCH(i) || (!ignore_protection && pin_is_protected(pin))) continue;
|
||||||
|
@ -339,7 +339,7 @@ void GcodeSuite::M43() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
for (uint8_t i = first_pin; i <= last_pin; i++) {
|
LOOP_S_LE_N(i, first_pin, last_pin) {
|
||||||
pin_t pin = GET_PIN_MAP_PIN_M43(i);
|
pin_t pin = GET_PIN_MAP_PIN_M43(i);
|
||||||
if (!VALID_PIN(pin)) continue;
|
if (!VALID_PIN(pin)) continue;
|
||||||
if (M43_NEVER_TOUCH(i) || (!ignore_protection && pin_is_protected(pin))) continue;
|
if (M43_NEVER_TOUCH(i) || (!ignore_protection && pin_is_protected(pin))) continue;
|
||||||
|
@ -365,7 +365,7 @@ void GcodeSuite::M43() {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Report current state of selected pin(s)
|
// Report current state of selected pin(s)
|
||||||
for (uint8_t i = first_pin; i <= last_pin; i++) {
|
LOOP_S_LE_N(i, first_pin, last_pin) {
|
||||||
pin_t pin = GET_PIN_MAP_PIN_M43(i);
|
pin_t pin = GET_PIN_MAP_PIN_M43(i);
|
||||||
if (VALID_PIN(pin)) report_pin_state_extended(pin, ignore_protection, true);
|
if (VALID_PIN(pin)) report_pin_state_extended(pin, ignore_protection, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@
|
||||||
// b3 b2 b1 b0 ~b0 ... lo bits, NOT last bit
|
// b3 b2 b1 b0 ~b0 ... lo bits, NOT last bit
|
||||||
//
|
//
|
||||||
void M672_send(uint8_t b) { // bit rate requirement: 1KHz +/- 30%
|
void M672_send(uint8_t b) { // bit rate requirement: 1KHz +/- 30%
|
||||||
for (uint8_t bits = 0; bits < 14; bits++) {
|
LOOP_L_N(bits, 14) {
|
||||||
switch (bits) {
|
switch (bits) {
|
||||||
default: { OUT_WRITE(SMART_EFFECTOR_MOD_PIN, !!(b & 0x80)); b <<= 1; break; } // send bit, shift next into place
|
default: { OUT_WRITE(SMART_EFFECTOR_MOD_PIN, !!(b & 0x80)); b <<= 1; break; } // send bit, shift next into place
|
||||||
case 7:
|
case 7:
|
||||||
|
|
|
@ -34,7 +34,7 @@ void report_M92(const bool echo=true, const int8_t e=-1) {
|
||||||
SERIAL_EOL();
|
SERIAL_EOL();
|
||||||
|
|
||||||
#if ENABLED(DISTINCT_E_FACTORS)
|
#if ENABLED(DISTINCT_E_FACTORS)
|
||||||
for (uint8_t i = 0; i < E_STEPPERS; i++) {
|
LOOP_L_N(i, E_STEPPERS) {
|
||||||
if (e >= 0 && i != e) continue;
|
if (e >= 0 && i != e) continue;
|
||||||
if (echo) SERIAL_ECHO_START(); else SERIAL_CHAR(' ');
|
if (echo) SERIAL_ECHO_START(); else SERIAL_CHAR(' ');
|
||||||
SERIAL_ECHOLNPAIR_P(PSTR(" M92 T"), (int)i,
|
SERIAL_ECHOLNPAIR_P(PSTR(" M92 T"), (int)i,
|
||||||
|
|
|
@ -49,7 +49,7 @@ void GcodeSuite::M111() {
|
||||||
SERIAL_ECHOPGM(STR_DEBUG_PREFIX);
|
SERIAL_ECHOPGM(STR_DEBUG_PREFIX);
|
||||||
if (marlin_debug_flags) {
|
if (marlin_debug_flags) {
|
||||||
uint8_t comma = 0;
|
uint8_t comma = 0;
|
||||||
for (uint8_t i = 0; i < COUNT(debug_strings); i++) {
|
LOOP_L_N(i, COUNT(debug_strings)) {
|
||||||
if (TEST(marlin_debug_flags, i)) {
|
if (TEST(marlin_debug_flags, i)) {
|
||||||
if (comma++) SERIAL_CHAR(',');
|
if (comma++) SERIAL_CHAR(',');
|
||||||
serialprintPGM((char*)pgm_read_ptr(&debug_strings[i]));
|
serialprintPGM((char*)pgm_read_ptr(&debug_strings[i]));
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
* Warning: Steps-per-unit remains unchanged.
|
* Warning: Steps-per-unit remains unchanged.
|
||||||
*/
|
*/
|
||||||
void GcodeSuite::M350() {
|
void GcodeSuite::M350() {
|
||||||
if (parser.seen('S')) for (uint8_t i = 0; i <= 4; i++) stepper.microstep_mode(i, parser.value_byte());
|
if (parser.seen('S')) LOOP_LE_N(i, 4) stepper.microstep_mode(i, parser.value_byte());
|
||||||
LOOP_XYZE(i) if (parser.seen(axis_codes[i])) stepper.microstep_mode(i, parser.value_byte());
|
LOOP_XYZE(i) if (parser.seen(axis_codes[i])) stepper.microstep_mode(i, parser.value_byte());
|
||||||
if (parser.seen('B')) stepper.microstep_mode(4, parser.value_byte());
|
if (parser.seen('B')) stepper.microstep_mode(4, parser.value_byte());
|
||||||
stepper.microstep_readings();
|
stepper.microstep_readings();
|
||||||
|
|
|
@ -90,7 +90,7 @@
|
||||||
|
|
||||||
inline void spin_photo_pin() {
|
inline void spin_photo_pin() {
|
||||||
static constexpr uint32_t sequence[] = PHOTO_PULSES_US;
|
static constexpr uint32_t sequence[] = PHOTO_PULSES_US;
|
||||||
for (uint8_t i = 0; i < COUNT(sequence); i++)
|
LOOP_L_N(i, COUNT(sequence))
|
||||||
pulse_photo_pin(sequence[i], !(i & 1));
|
pulse_photo_pin(sequence[i], !(i & 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ void GcodeSuite::M907() {
|
||||||
|
|
||||||
LOOP_XYZE(i) if (parser.seenval(axis_codes[i])) stepper.digipot_current(i, parser.value_int());
|
LOOP_XYZE(i) if (parser.seenval(axis_codes[i])) stepper.digipot_current(i, parser.value_int());
|
||||||
if (parser.seenval('B')) stepper.digipot_current(4, parser.value_int());
|
if (parser.seenval('B')) stepper.digipot_current(4, parser.value_int());
|
||||||
if (parser.seenval('S')) for (uint8_t i = 0; i <= 4; i++) stepper.digipot_current(i, parser.value_int());
|
if (parser.seenval('S')) LOOP_LE_N(i, 4) stepper.digipot_current(i, parser.value_int());
|
||||||
|
|
||||||
#elif HAS_MOTOR_CURRENT_PWM
|
#elif HAS_MOTOR_CURRENT_PWM
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ void GcodeSuite::M907() {
|
||||||
#if ENABLED(DAC_STEPPER_CURRENT)
|
#if ENABLED(DAC_STEPPER_CURRENT)
|
||||||
if (parser.seenval('S')) {
|
if (parser.seenval('S')) {
|
||||||
const float dac_percent = parser.value_float();
|
const float dac_percent = parser.value_float();
|
||||||
for (uint8_t i = 0; i <= 4; i++) dac_current_percent(i, dac_percent);
|
LOOP_LE_N(i, 4) dac_current_percent(i, dac_percent);
|
||||||
}
|
}
|
||||||
LOOP_XYZE(i) if (parser.seenval(axis_codes[i])) dac_current_percent(i, parser.value_float());
|
LOOP_XYZE(i) if (parser.seenval(axis_codes[i])) dac_current_percent(i, parser.value_float());
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -79,7 +79,7 @@ void GcodeSuite::M7219() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parser.seen('P')) {
|
if (parser.seen('P')) {
|
||||||
for (uint8_t r = 0; r < MAX7219_LINES; r++) {
|
LOOP_L_N(r, MAX7219_LINES) {
|
||||||
SERIAL_ECHOPGM("led_line[");
|
SERIAL_ECHOPGM("led_line[");
|
||||||
if (r < 10) SERIAL_CHAR(' ');
|
if (r < 10) SERIAL_CHAR(' ');
|
||||||
SERIAL_ECHO(int(r));
|
SERIAL_ECHO(int(r));
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
void report_xyze(const xyze_pos_t &pos, const uint8_t n=XYZE, const uint8_t precision=3) {
|
void report_xyze(const xyze_pos_t &pos, const uint8_t n=XYZE, const uint8_t precision=3) {
|
||||||
char str[12];
|
char str[12];
|
||||||
for (uint8_t a = 0; a < n; a++) {
|
LOOP_L_N(a, n) {
|
||||||
SERIAL_CHAR(' ', axis_codes[a], ':');
|
SERIAL_CHAR(' ', axis_codes[a], ':');
|
||||||
SERIAL_ECHO(dtostrf(pos[a], 1, precision, str));
|
SERIAL_ECHO(dtostrf(pos[a], 1, precision, str));
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,7 +94,7 @@ static PGM_P injected_commands_P = nullptr;
|
||||||
|
|
||||||
GCodeQueue::GCodeQueue() {
|
GCodeQueue::GCodeQueue() {
|
||||||
// Send "ok" after commands by default
|
// Send "ok" after commands by default
|
||||||
for (uint8_t i = 0; i < COUNT(send_ok); i++) send_ok[i] = true;
|
LOOP_L_N(i, COUNT(send_ok)) send_ok[i] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -427,7 +427,7 @@ void GCodeQueue::get_serial_commands() {
|
||||||
* Loop while serial characters are incoming and the queue is not full
|
* Loop while serial characters are incoming and the queue is not full
|
||||||
*/
|
*/
|
||||||
while (length < BUFSIZE && serial_data_available()) {
|
while (length < BUFSIZE && serial_data_available()) {
|
||||||
for (uint8_t i = 0; i < NUM_SERIAL; ++i) {
|
LOOP_L_N(i, NUM_SERIAL) {
|
||||||
|
|
||||||
const int c = read_serial(i);
|
const int c = read_serial(i);
|
||||||
if (c < 0) continue;
|
if (c < 0) continue;
|
||||||
|
|
|
@ -604,8 +604,52 @@
|
||||||
#undef Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN
|
#undef Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set granular options based on the specific type of leveling
|
||||||
|
*/
|
||||||
|
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
||||||
|
#undef LCD_BED_LEVELING
|
||||||
|
#if ENABLED(DELTA)
|
||||||
|
#define UBL_SEGMENTED 1
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#if EITHER(AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_3POINT)
|
||||||
|
#define ABL_PLANAR 1
|
||||||
|
#endif
|
||||||
|
#if EITHER(AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_BILINEAR)
|
||||||
|
#define ABL_GRID 1
|
||||||
|
#endif
|
||||||
|
#if ANY(AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_3POINT)
|
||||||
|
#define HAS_ABL_NOT_UBL 1
|
||||||
|
#endif
|
||||||
|
#if ANY(AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_UBL, MESH_BED_LEVELING)
|
||||||
|
#define HAS_MESH 1
|
||||||
|
#endif
|
||||||
|
#if EITHER(AUTO_BED_LEVELING_UBL, AUTO_BED_LEVELING_3POINT)
|
||||||
|
#define NEEDS_THREE_PROBE_POINTS 1
|
||||||
|
#endif
|
||||||
|
#if EITHER(HAS_ABL_NOT_UBL, AUTO_BED_LEVELING_UBL)
|
||||||
|
#define HAS_ABL_OR_UBL 1
|
||||||
|
#if DISABLED(PROBE_MANUALLY)
|
||||||
|
#define HAS_AUTOLEVEL 1
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#if EITHER(HAS_ABL_OR_UBL, MESH_BED_LEVELING)
|
||||||
|
#define HAS_LEVELING 1
|
||||||
|
#if DISABLED(AUTO_BED_LEVELING_UBL)
|
||||||
|
#define PLANNER_LEVELING 1
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#if EITHER(HAS_ABL_OR_UBL, Z_MIN_PROBE_REPEATABILITY_TEST)
|
||||||
|
#define HAS_PROBING_PROCEDURE 1
|
||||||
|
#endif
|
||||||
|
#if !HAS_LEVELING
|
||||||
|
#undef RESTORE_LEVELING_AFTER_G28
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef GRID_MAX_POINTS_X
|
#ifdef GRID_MAX_POINTS_X
|
||||||
#define GRID_MAX_POINTS ((GRID_MAX_POINTS_X) * (GRID_MAX_POINTS_Y))
|
#define GRID_MAX_POINTS ((GRID_MAX_POINTS_X) * (GRID_MAX_POINTS_Y))
|
||||||
|
#define GRID_LOOP(A,B) LOOP_L_N(A, GRID_MAX_POINTS_X) LOOP_L_N(B, GRID_MAX_POINTS_Y)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef INVERT_X_DIR
|
#ifndef INVERT_X_DIR
|
||||||
|
|
|
@ -83,6 +83,10 @@
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ANY(FWRETRACT, HAS_LEVELING, SKEW_CORRECTION)
|
||||||
|
#define HAS_POSITION_MODIFIERS 1
|
||||||
|
#endif
|
||||||
|
|
||||||
#if ANY(X_DUAL_ENDSTOPS, Y_DUAL_ENDSTOPS, Z_MULTI_ENDSTOPS)
|
#if ANY(X_DUAL_ENDSTOPS, Y_DUAL_ENDSTOPS, Z_MULTI_ENDSTOPS)
|
||||||
#define HAS_EXTRA_ENDSTOPS 1
|
#define HAS_EXTRA_ENDSTOPS 1
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1854,53 +1854,6 @@
|
||||||
#endif
|
#endif
|
||||||
#endif // SKEW_CORRECTION
|
#endif // SKEW_CORRECTION
|
||||||
|
|
||||||
/**
|
|
||||||
* Set granular options based on the specific type of leveling
|
|
||||||
*/
|
|
||||||
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
|
||||||
#undef LCD_BED_LEVELING
|
|
||||||
#if ENABLED(DELTA)
|
|
||||||
#define UBL_SEGMENTED 1
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#if EITHER(AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_3POINT)
|
|
||||||
#define ABL_PLANAR 1
|
|
||||||
#endif
|
|
||||||
#if EITHER(AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_BILINEAR)
|
|
||||||
#define ABL_GRID 1
|
|
||||||
#endif
|
|
||||||
#if ANY(AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_3POINT)
|
|
||||||
#define HAS_ABL_NOT_UBL 1
|
|
||||||
#endif
|
|
||||||
#if ANY(AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_UBL, MESH_BED_LEVELING)
|
|
||||||
#define HAS_MESH 1
|
|
||||||
#endif
|
|
||||||
#if EITHER(AUTO_BED_LEVELING_UBL, AUTO_BED_LEVELING_3POINT)
|
|
||||||
#define NEEDS_THREE_PROBE_POINTS 1
|
|
||||||
#endif
|
|
||||||
#if EITHER(HAS_ABL_NOT_UBL, AUTO_BED_LEVELING_UBL)
|
|
||||||
#define HAS_ABL_OR_UBL 1
|
|
||||||
#if DISABLED(PROBE_MANUALLY)
|
|
||||||
#define HAS_AUTOLEVEL 1
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#if EITHER(HAS_ABL_OR_UBL, MESH_BED_LEVELING)
|
|
||||||
#define HAS_LEVELING 1
|
|
||||||
#if DISABLED(AUTO_BED_LEVELING_UBL)
|
|
||||||
#define PLANNER_LEVELING 1
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#if EITHER(HAS_ABL_OR_UBL, Z_MIN_PROBE_REPEATABILITY_TEST)
|
|
||||||
#define HAS_PROBING_PROCEDURE 1
|
|
||||||
#endif
|
|
||||||
#if ANY(FWRETRACT, HAS_LEVELING, SKEW_CORRECTION)
|
|
||||||
#define HAS_POSITION_MODIFIERS 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !HAS_LEVELING
|
|
||||||
#undef RESTORE_LEVELING_AFTER_G28
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Heater, Fan, and Probe interactions
|
* Heater, Fan, and Probe interactions
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -102,7 +102,7 @@
|
||||||
|
|
||||||
static void createChar_P(const char c, const byte * const ptr) {
|
static void createChar_P(const char c, const byte * const ptr) {
|
||||||
byte temp[8];
|
byte temp[8];
|
||||||
for (uint8_t i = 0; i < 8; i++)
|
LOOP_L_N(i, 8)
|
||||||
temp[i] = pgm_read_byte(&ptr[i]);
|
temp[i] = pgm_read_byte(&ptr[i]);
|
||||||
lcd.createChar(c, temp);
|
lcd.createChar(c, temp);
|
||||||
}
|
}
|
||||||
|
@ -414,7 +414,7 @@ void MarlinUI::clear_lcd() { lcd.clear(); }
|
||||||
else {
|
else {
|
||||||
PGM_P p = text;
|
PGM_P p = text;
|
||||||
int dly = time / _MAX(slen, 1);
|
int dly = time / _MAX(slen, 1);
|
||||||
for (uint8_t i = 0; i <= slen; i++) {
|
LOOP_LE_N(i, slen) {
|
||||||
|
|
||||||
// Print the text at the correct place
|
// Print the text at the correct place
|
||||||
lcd_put_u8str_max_P(col, line, p, len);
|
lcd_put_u8str_max_P(col, line, p, len);
|
||||||
|
|
|
@ -564,7 +564,7 @@ void MarlinUI::draw_status_screen() {
|
||||||
if (PAGE_UNDER(6 + 1 + 12 + 1 + 6 + 1)) {
|
if (PAGE_UNDER(6 + 1 + 12 + 1 + 6 + 1)) {
|
||||||
// Extruders
|
// Extruders
|
||||||
#if DO_DRAW_HOTENDS
|
#if DO_DRAW_HOTENDS
|
||||||
for (uint8_t e = 0; e < MAX_HOTEND_DRAW; ++e)
|
LOOP_L_N(e, MAX_HOTEND_DRAW)
|
||||||
_draw_hotend_status((heater_ind_t)e, blink);
|
_draw_hotend_status((heater_ind_t)e, blink);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -209,7 +209,7 @@ void ST7920_Lite_Status_Screen::clear_ddram() {
|
||||||
|
|
||||||
/* This fills the entire graphics buffer with zeros */
|
/* This fills the entire graphics buffer with zeros */
|
||||||
void ST7920_Lite_Status_Screen::clear_gdram() {
|
void ST7920_Lite_Status_Screen::clear_gdram() {
|
||||||
for (uint8_t y = 0; y < BUFFER_HEIGHT; y++) {
|
LOOP_L_N(y, BUFFER_HEIGHT) {
|
||||||
set_gdram_address(0, y);
|
set_gdram_address(0, y);
|
||||||
begin_data();
|
begin_data();
|
||||||
for (uint8_t i = (BUFFER_WIDTH) / 16; i--;) write_word(0);
|
for (uint8_t i = (BUFFER_WIDTH) / 16; i--;) write_word(0);
|
||||||
|
@ -407,7 +407,7 @@ void ST7920_Lite_Status_Screen::draw_degree_symbol(uint8_t x, uint8_t y, const b
|
||||||
const uint8_t x_word = x >> 1,
|
const uint8_t x_word = x >> 1,
|
||||||
y_top = degree_symbol_y_top,
|
y_top = degree_symbol_y_top,
|
||||||
y_bot = y_top + COUNT(degree_symbol);
|
y_bot = y_top + COUNT(degree_symbol);
|
||||||
for (uint8_t i = y_top; i < y_bot; i++) {
|
LOOP_S_L_N(i, y_top, y_bot) {
|
||||||
uint8_t byte = pgm_read_byte(p_bytes++);
|
uint8_t byte = pgm_read_byte(p_bytes++);
|
||||||
set_gdram_address(x_word, i + y * 16);
|
set_gdram_address(x_word, i + y * 16);
|
||||||
begin_data();
|
begin_data();
|
||||||
|
@ -467,10 +467,10 @@ void ST7920_Lite_Status_Screen::draw_progress_bar(const uint8_t value) {
|
||||||
const uint8_t char_pcnt = 100 / width; // How many percent does each 16-bit word represent?
|
const uint8_t char_pcnt = 100 / width; // How many percent does each 16-bit word represent?
|
||||||
|
|
||||||
// Draw the progress bar as a bitmap in CGRAM
|
// Draw the progress bar as a bitmap in CGRAM
|
||||||
for (uint8_t y = top; y <= bottom; y++) {
|
LOOP_S_LE_N(y, top, bottom) {
|
||||||
set_gdram_address(left, y);
|
set_gdram_address(left, y);
|
||||||
begin_data();
|
begin_data();
|
||||||
for (uint8_t x = 0; x < width; x++) {
|
LOOP_L_N(x, width) {
|
||||||
uint16_t gfx_word = 0x0000;
|
uint16_t gfx_word = 0x0000;
|
||||||
if ((x + 1) * char_pcnt <= value)
|
if ((x + 1) * char_pcnt <= value)
|
||||||
gfx_word = 0xFFFF; // Draw completely filled bytes
|
gfx_word = 0xFFFF; // Draw completely filled bytes
|
||||||
|
|
|
@ -87,11 +87,11 @@ void clear_graphics_DRAM(u8g_t *u8g, u8g_dev_t *dev) {
|
||||||
u8g_SetAddress(u8g, dev, 0); // cmd mode
|
u8g_SetAddress(u8g, dev, 0); // cmd mode
|
||||||
u8g_WriteByte(u8g, dev, 0x08); //display off, cursor+blink off
|
u8g_WriteByte(u8g, dev, 0x08); //display off, cursor+blink off
|
||||||
u8g_WriteByte(u8g, dev, 0x3E); //extended mode + GDRAM active
|
u8g_WriteByte(u8g, dev, 0x3E); //extended mode + GDRAM active
|
||||||
for (uint8_t y = 0; y < (LCD_PIXEL_HEIGHT) / 2; y++) { //clear GDRAM
|
LOOP_L_N(y, (LCD_PIXEL_HEIGHT) / 2) { //clear GDRAM
|
||||||
u8g_WriteByte(u8g, dev, 0x80 | y); //set y
|
u8g_WriteByte(u8g, dev, 0x80 | y); //set y
|
||||||
u8g_WriteByte(u8g, dev, 0x80); //set x = 0
|
u8g_WriteByte(u8g, dev, 0x80); //set x = 0
|
||||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||||
for (uint8_t i = 0; i < 2 * (LCD_PIXEL_WIDTH) / 8; i++) //2x width clears both segments
|
LOOP_L_N(i, 2 * (LCD_PIXEL_WIDTH) / 8) //2x width clears both segments
|
||||||
u8g_WriteByte(u8g, dev, 0);
|
u8g_WriteByte(u8g, dev, 0);
|
||||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||||
}
|
}
|
||||||
|
|
|
@ -670,7 +670,7 @@ uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, u
|
||||||
case U8G_DEV_MSG_PAGE_NEXT:
|
case U8G_DEV_MSG_PAGE_NEXT:
|
||||||
if (++page > (HEIGHT / PAGE_HEIGHT)) return 1;
|
if (++page > (HEIGHT / PAGE_HEIGHT)) return 1;
|
||||||
|
|
||||||
for (uint8_t y = 0; y < PAGE_HEIGHT; y++) {
|
LOOP_L_N(y, PAGE_HEIGHT) {
|
||||||
uint32_t k = 0;
|
uint32_t k = 0;
|
||||||
#ifdef LCD_USE_DMA_FSMC
|
#ifdef LCD_USE_DMA_FSMC
|
||||||
buffer = (y & 1) ? bufferB : bufferA;
|
buffer = (y & 1) ? bufferB : bufferA;
|
||||||
|
|
|
@ -237,7 +237,7 @@ public:
|
||||||
if (!var.memadr) return;
|
if (!var.memadr) return;
|
||||||
union { unsigned char tmp[sizeof(T)]; T t; } x;
|
union { unsigned char tmp[sizeof(T)]; T t; } x;
|
||||||
unsigned char *ptr = (unsigned char*)val_ptr;
|
unsigned char *ptr = (unsigned char*)val_ptr;
|
||||||
for (uint8_t i = 0; i < sizeof(T); i++) x.tmp[i] = ptr[sizeof(T) - i - 1];
|
LOOP_L_N(i, sizeof(T)) x.tmp[i] = ptr[sizeof(T) - i - 1];
|
||||||
*(T*)var.memadr = x.t;
|
*(T*)var.memadr = x.t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -339,11 +339,11 @@
|
||||||
alt_fm.stride = 19;
|
alt_fm.stride = 19;
|
||||||
alt_fm.width = 38;
|
alt_fm.width = 38;
|
||||||
alt_fm.height = 49;
|
alt_fm.height = 49;
|
||||||
for (uint8_t i = 0; i < 127; i++)
|
LOOP_L_N(i, 127)
|
||||||
alt_fm.char_widths[i] = 0;
|
alt_fm.char_widths[i] = 0;
|
||||||
|
|
||||||
// For special characters, copy the character widths from the char tables
|
// For special characters, copy the character widths from the char tables
|
||||||
for (uint8_t i = 0; i < NUM_ELEMENTS(char_recipe); i++) {
|
LOOP_L_N(i, NUM_ELEMENTS(char_recipe)) {
|
||||||
uint8_t std_char, alt_char, alt_data;
|
uint8_t std_char, alt_char, alt_data;
|
||||||
get_char_data(i, std_char, alt_char, alt_data);
|
get_char_data(i, std_char, alt_char, alt_data);
|
||||||
if (std_char == 0)
|
if (std_char == 0)
|
||||||
|
|
|
@ -36,7 +36,7 @@ void MoveAxisScreen::onEntry() {
|
||||||
// ourselves. The relative distances are reset to zero whenever this
|
// ourselves. The relative distances are reset to zero whenever this
|
||||||
// screen is entered.
|
// screen is entered.
|
||||||
|
|
||||||
for (uint8_t i = 0; i < ExtUI::extruderCount; i++) {
|
LOOP_L_N(i, ExtUI::extruderCount) {
|
||||||
screen_data.MoveAxisScreen.e_rel[i] = 0;
|
screen_data.MoveAxisScreen.e_rel[i] = 0;
|
||||||
}
|
}
|
||||||
BaseNumericAdjustmentScreen::onEntry();
|
BaseNumericAdjustmentScreen::onEntry();
|
||||||
|
|
|
@ -81,7 +81,7 @@ void write_to_lcd_P(PGM_P const message) {
|
||||||
char encoded_message[MAX_CURLY_COMMAND];
|
char encoded_message[MAX_CURLY_COMMAND];
|
||||||
uint8_t message_length = _MIN(strlen_P(message), sizeof(encoded_message));
|
uint8_t message_length = _MIN(strlen_P(message), sizeof(encoded_message));
|
||||||
|
|
||||||
for (uint8_t i = 0; i < message_length; i++)
|
LOOP_L_N(i, message_length)
|
||||||
encoded_message[i] = pgm_read_byte(&message[i]) | 0x80;
|
encoded_message[i] = pgm_read_byte(&message[i]) | 0x80;
|
||||||
|
|
||||||
LCD_SERIAL.Print::write(encoded_message, message_length);
|
LCD_SERIAL.Print::write(encoded_message, message_length);
|
||||||
|
@ -91,7 +91,7 @@ void write_to_lcd(const char * const message) {
|
||||||
char encoded_message[MAX_CURLY_COMMAND];
|
char encoded_message[MAX_CURLY_COMMAND];
|
||||||
const uint8_t message_length = _MIN(strlen(message), sizeof(encoded_message));
|
const uint8_t message_length = _MIN(strlen(message), sizeof(encoded_message));
|
||||||
|
|
||||||
for (uint8_t i = 0; i < message_length; i++)
|
LOOP_L_N(i, message_length)
|
||||||
encoded_message[i] = message[i] | 0x80;
|
encoded_message[i] = message[i] | 0x80;
|
||||||
|
|
||||||
LCD_SERIAL.Print::write(encoded_message, message_length);
|
LCD_SERIAL.Print::write(encoded_message, message_length);
|
||||||
|
|
|
@ -140,13 +140,13 @@ void BrickoutGame::game_screen() {
|
||||||
|
|
||||||
// Draw bricks
|
// Draw bricks
|
||||||
if (PAGE_CONTAINS(BRICK_TOP, BRICK_BOT)) {
|
if (PAGE_CONTAINS(BRICK_TOP, BRICK_BOT)) {
|
||||||
for (uint8_t y = 0; y < BRICK_ROWS; ++y) {
|
LOOP_L_N(y, BRICK_ROWS) {
|
||||||
const uint8_t yy = y * BRICK_H + BRICK_TOP;
|
const uint8_t yy = y * BRICK_H + BRICK_TOP;
|
||||||
if (PAGE_CONTAINS(yy, yy + BRICK_H - 1)) {
|
if (PAGE_CONTAINS(yy, yy + BRICK_H - 1)) {
|
||||||
for (uint8_t x = 0; x < BRICK_COLS; ++x) {
|
LOOP_L_N(x, BRICK_COLS) {
|
||||||
if (TEST(bdat.bricks[y], x)) {
|
if (TEST(bdat.bricks[y], x)) {
|
||||||
const uint8_t xx = x * BRICK_W;
|
const uint8_t xx = x * BRICK_W;
|
||||||
for (uint8_t v = 0; v < BRICK_H - 1; ++v)
|
LOOP_L_N(v, BRICK_H - 1)
|
||||||
if (PAGE_CONTAINS(yy + v, yy + v))
|
if (PAGE_CONTAINS(yy + v, yy + v))
|
||||||
u8g.drawHLine(xx, yy + v, BRICK_W - 1);
|
u8g.drawHLine(xx, yy + v, BRICK_W - 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,7 +170,7 @@ inline void update_invader_data() {
|
||||||
uint8_t m = idat.bugs[y];
|
uint8_t m = idat.bugs[y];
|
||||||
if (m) idat.botmost = y + 1;
|
if (m) idat.botmost = y + 1;
|
||||||
inv_mask |= m;
|
inv_mask |= m;
|
||||||
for (uint8_t x = 0; x < INVADER_COLS; ++x)
|
LOOP_L_N(x, INVADER_COLS)
|
||||||
if (TEST(m, x)) idat.shooters[sc++] = (y << 4) | x;
|
if (TEST(m, x)) idat.shooters[sc++] = (y << 4) | x;
|
||||||
}
|
}
|
||||||
idat.leftmost = 0;
|
idat.leftmost = 0;
|
||||||
|
@ -371,11 +371,11 @@ void InvadersGame::game_screen() {
|
||||||
// Draw invaders
|
// Draw invaders
|
||||||
if (PAGE_CONTAINS(idat.pos.y, idat.pos.y + idat.botmost * (INVADER_ROW_H) - 2 - 1)) {
|
if (PAGE_CONTAINS(idat.pos.y, idat.pos.y + idat.botmost * (INVADER_ROW_H) - 2 - 1)) {
|
||||||
int8_t yy = idat.pos.y;
|
int8_t yy = idat.pos.y;
|
||||||
for (uint8_t y = 0; y < INVADER_ROWS; ++y) {
|
LOOP_L_N(y, INVADER_ROWS) {
|
||||||
const uint8_t type = inv_type[y];
|
const uint8_t type = inv_type[y];
|
||||||
if (PAGE_CONTAINS(yy, yy + INVADER_H - 1)) {
|
if (PAGE_CONTAINS(yy, yy + INVADER_H - 1)) {
|
||||||
int8_t xx = idat.pos.x;
|
int8_t xx = idat.pos.x;
|
||||||
for (uint8_t x = 0; x < INVADER_COLS; ++x) {
|
LOOP_L_N(x, INVADER_COLS) {
|
||||||
if (TEST(idat.bugs[y], x))
|
if (TEST(idat.bugs[y], x))
|
||||||
u8g.drawBitmapP(xx, yy, 2, INVADER_H, invader[type][idat.game_blink]);
|
u8g.drawBitmapP(xx, yy, 2, INVADER_H, invader[type][idat.game_blink]);
|
||||||
xx += INVADER_COL_W;
|
xx += INVADER_COL_W;
|
||||||
|
|
|
@ -83,7 +83,7 @@ void MazeGame::game_screen() {
|
||||||
if (PAGE_UNDER(HEADER_H)) lcd_put_int(0, HEADER_H - 1, score);
|
if (PAGE_UNDER(HEADER_H)) lcd_put_int(0, HEADER_H - 1, score);
|
||||||
|
|
||||||
// Draw the maze
|
// Draw the maze
|
||||||
// for (uint8_t n = 0; n < head_ind; ++n) {
|
// LOOP_L_N(n, head_ind) {
|
||||||
// const pos_t &p = maze_walls[n], &q = maze_walls[n + 1];
|
// const pos_t &p = maze_walls[n], &q = maze_walls[n + 1];
|
||||||
// if (p.x == q.x) {
|
// if (p.x == q.x) {
|
||||||
// const int8_t y1 = GAMEY(_MIN(p.y, q.y)), y2 = GAMEY(_MAX(p.y, q.y));
|
// const int8_t y1 = GAMEY(_MIN(p.y, q.y)), y2 = GAMEY(_MAX(p.y, q.y));
|
||||||
|
|
|
@ -84,14 +84,14 @@ void shorten_tail() {
|
||||||
}
|
}
|
||||||
if (shift) {
|
if (shift) {
|
||||||
sdat.head_ind--;
|
sdat.head_ind--;
|
||||||
for (uint8_t i = 0; i <= sdat.head_ind; ++i)
|
LOOP_LE_N(i, sdat.head_ind)
|
||||||
sdat.snake_tail[i] = sdat.snake_tail[i + 1];
|
sdat.snake_tail[i] = sdat.snake_tail[i + 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The food is on a line
|
// The food is on a line
|
||||||
inline bool food_on_line() {
|
inline bool food_on_line() {
|
||||||
for (uint8_t n = 0; n < sdat.head_ind; ++n) {
|
LOOP_L_N(n, sdat.head_ind) {
|
||||||
pos_t &p = sdat.snake_tail[n], &q = sdat.snake_tail[n + 1];
|
pos_t &p = sdat.snake_tail[n], &q = sdat.snake_tail[n + 1];
|
||||||
if (p.x == q.x) {
|
if (p.x == q.x) {
|
||||||
if ((sdat.foodx == p.x - 1 || sdat.foodx == p.x) && WITHIN(sdat.foody, _MIN(p.y, q.y), _MAX(p.y, q.y)))
|
if ((sdat.foodx == p.x - 1 || sdat.foodx == p.x) && WITHIN(sdat.foody, _MIN(p.y, q.y), _MAX(p.y, q.y)))
|
||||||
|
@ -151,7 +151,7 @@ bool snake_overlap() {
|
||||||
// VERTICAL head segment?
|
// VERTICAL head segment?
|
||||||
if (h1.x == h2.x) {
|
if (h1.x == h2.x) {
|
||||||
// Loop from oldest to segment two away from head
|
// Loop from oldest to segment two away from head
|
||||||
for (uint8_t n = 0; n < sdat.head_ind - 2; ++n) {
|
LOOP_L_N(n, sdat.head_ind - 2) {
|
||||||
// Segment p to q
|
// Segment p to q
|
||||||
const pos_t &p = sdat.snake_tail[n], &q = sdat.snake_tail[n + 1];
|
const pos_t &p = sdat.snake_tail[n], &q = sdat.snake_tail[n + 1];
|
||||||
if (p.x != q.x) {
|
if (p.x != q.x) {
|
||||||
|
@ -163,7 +163,7 @@ bool snake_overlap() {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Loop from oldest to segment two away from head
|
// Loop from oldest to segment two away from head
|
||||||
for (uint8_t n = 0; n < sdat.head_ind - 2; ++n) {
|
LOOP_L_N(n, sdat.head_ind - 2) {
|
||||||
// Segment p to q
|
// Segment p to q
|
||||||
const pos_t &p = sdat.snake_tail[n], &q = sdat.snake_tail[n + 1];
|
const pos_t &p = sdat.snake_tail[n], &q = sdat.snake_tail[n + 1];
|
||||||
if (p.y != q.y) {
|
if (p.y != q.y) {
|
||||||
|
@ -240,7 +240,7 @@ void SnakeGame::game_screen() {
|
||||||
#if SNAKE_WH < 2
|
#if SNAKE_WH < 2
|
||||||
|
|
||||||
// At this scale just draw a line
|
// At this scale just draw a line
|
||||||
for (uint8_t n = 0; n < sdat.head_ind; ++n) {
|
LOOP_L_N(n, sdat.head_ind) {
|
||||||
const pos_t &p = sdat.snake_tail[n], &q = sdat.snake_tail[n + 1];
|
const pos_t &p = sdat.snake_tail[n], &q = sdat.snake_tail[n + 1];
|
||||||
if (p.x == q.x) {
|
if (p.x == q.x) {
|
||||||
const int8_t y1 = GAMEY(_MIN(p.y, q.y)), y2 = GAMEY(_MAX(p.y, q.y));
|
const int8_t y1 = GAMEY(_MIN(p.y, q.y)), y2 = GAMEY(_MAX(p.y, q.y));
|
||||||
|
@ -256,7 +256,7 @@ void SnakeGame::game_screen() {
|
||||||
#elif SNAKE_WH == 2
|
#elif SNAKE_WH == 2
|
||||||
|
|
||||||
// At this scale draw two lines
|
// At this scale draw two lines
|
||||||
for (uint8_t n = 0; n < sdat.head_ind; ++n) {
|
LOOP_L_N(n, sdat.head_ind) {
|
||||||
const pos_t &p = sdat.snake_tail[n], &q = sdat.snake_tail[n + 1];
|
const pos_t &p = sdat.snake_tail[n], &q = sdat.snake_tail[n + 1];
|
||||||
if (p.x == q.x) {
|
if (p.x == q.x) {
|
||||||
const int8_t y1 = GAMEY(_MIN(p.y, q.y)), y2 = GAMEY(_MAX(p.y, q.y));
|
const int8_t y1 = GAMEY(_MIN(p.y, q.y)), y2 = GAMEY(_MAX(p.y, q.y));
|
||||||
|
@ -275,7 +275,7 @@ void SnakeGame::game_screen() {
|
||||||
#else
|
#else
|
||||||
|
|
||||||
// Draw a series of boxes
|
// Draw a series of boxes
|
||||||
for (uint8_t n = 0; n < sdat.head_ind; ++n) {
|
LOOP_L_N(n, sdat.head_ind) {
|
||||||
const pos_t &p = sdat.snake_tail[n], &q = sdat.snake_tail[n + 1];
|
const pos_t &p = sdat.snake_tail[n], &q = sdat.snake_tail[n + 1];
|
||||||
if (p.x == q.x) {
|
if (p.x == q.x) {
|
||||||
const int8_t y1 = _MIN(p.y, q.y), y2 = _MAX(p.y, q.y);
|
const int8_t y1 = _MIN(p.y, q.y), y2 = _MAX(p.y, q.y);
|
||||||
|
|
|
@ -114,7 +114,7 @@ void menu_cancelobject();
|
||||||
#if EXTRUDERS == 1
|
#if EXTRUDERS == 1
|
||||||
EDIT_ITEM(float52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 999);
|
EDIT_ITEM(float52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 999);
|
||||||
#elif EXTRUDERS > 1
|
#elif EXTRUDERS > 1
|
||||||
for (uint8_t n = 0; n < EXTRUDERS; n++)
|
LOOP_L_N(n, EXTRUDERS)
|
||||||
EDIT_ITEM_N(float52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 999);
|
EDIT_ITEM_N(float52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 999);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -125,7 +125,7 @@ void menu_cancelobject();
|
||||||
if (parser.volumetric_enabled) {
|
if (parser.volumetric_enabled) {
|
||||||
EDIT_ITEM_FAST(float43, MSG_FILAMENT_DIAM, &planner.filament_size[active_extruder], 1.5f, 3.25f, planner.calculate_volumetric_multipliers);
|
EDIT_ITEM_FAST(float43, MSG_FILAMENT_DIAM, &planner.filament_size[active_extruder], 1.5f, 3.25f, planner.calculate_volumetric_multipliers);
|
||||||
#if EXTRUDERS > 1
|
#if EXTRUDERS > 1
|
||||||
for (uint8_t n = 0; n < EXTRUDERS; n++)
|
LOOP_L_N(n, EXTRUDERS)
|
||||||
EDIT_ITEM_FAST_N(float43, n, MSG_FILAMENT_DIAM_E, &planner.filament_size[n], 1.5f, 3.25f, planner.calculate_volumetric_multipliers);
|
EDIT_ITEM_FAST_N(float43, n, MSG_FILAMENT_DIAM_E, &planner.filament_size[n], 1.5f, 3.25f, planner.calculate_volumetric_multipliers);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -142,13 +142,13 @@ void menu_cancelobject();
|
||||||
|
|
||||||
EDIT_ITEM_FAST(float3, MSG_FILAMENT_UNLOAD, &fc_settings[active_extruder].unload_length, 0, extrude_maxlength);
|
EDIT_ITEM_FAST(float3, MSG_FILAMENT_UNLOAD, &fc_settings[active_extruder].unload_length, 0, extrude_maxlength);
|
||||||
#if EXTRUDERS > 1
|
#if EXTRUDERS > 1
|
||||||
for (uint8_t n = 0; n < EXTRUDERS; n++)
|
LOOP_L_N(n, EXTRUDERS)
|
||||||
EDIT_ITEM_FAST_N(float3, n, MSG_FILAMENTUNLOAD_E, &fc_settings[n].unload_length, 0, extrude_maxlength);
|
EDIT_ITEM_FAST_N(float3, n, MSG_FILAMENTUNLOAD_E, &fc_settings[n].unload_length, 0, extrude_maxlength);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
EDIT_ITEM_FAST(float3, MSG_FILAMENT_LOAD, &fc_settings[active_extruder].load_length, 0, extrude_maxlength);
|
EDIT_ITEM_FAST(float3, MSG_FILAMENT_LOAD, &fc_settings[active_extruder].load_length, 0, extrude_maxlength);
|
||||||
#if EXTRUDERS > 1
|
#if EXTRUDERS > 1
|
||||||
for (uint8_t n = 0; n < EXTRUDERS; n++)
|
LOOP_L_N(n, EXTRUDERS)
|
||||||
EDIT_ITEM_FAST_N(float3, n, MSG_FILAMENTLOAD_E, &fc_settings[n].load_length, 0, extrude_maxlength);
|
EDIT_ITEM_FAST_N(float3, n, MSG_FILAMENTLOAD_E, &fc_settings[n].load_length, 0, extrude_maxlength);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -358,7 +358,7 @@ void menu_cancelobject();
|
||||||
EDIT_ITEM_FAST(float3, MSG_VMAX_E, &planner.settings.max_feedrate_mm_s[E_AXIS_N(active_extruder)], 1, max_fr_edit_scaled.e);
|
EDIT_ITEM_FAST(float3, MSG_VMAX_E, &planner.settings.max_feedrate_mm_s[E_AXIS_N(active_extruder)], 1, max_fr_edit_scaled.e);
|
||||||
#endif
|
#endif
|
||||||
#if ENABLED(DISTINCT_E_FACTORS)
|
#if ENABLED(DISTINCT_E_FACTORS)
|
||||||
for (uint8_t n = 0; n < E_STEPPERS; n++)
|
LOOP_L_N(n, E_STEPPERS)
|
||||||
EDIT_ITEM_FAST_N(float3, n, MSG_VMAX_EN, &planner.settings.max_feedrate_mm_s[E_AXIS_N(n)], 1, max_fr_edit_scaled.e);
|
EDIT_ITEM_FAST_N(float3, n, MSG_VMAX_EN, &planner.settings.max_feedrate_mm_s[E_AXIS_N(n)], 1, max_fr_edit_scaled.e);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -409,7 +409,7 @@ void menu_cancelobject();
|
||||||
|
|
||||||
#if ENABLED(DISTINCT_E_FACTORS)
|
#if ENABLED(DISTINCT_E_FACTORS)
|
||||||
EDIT_ITEM_FAST(long5_25, MSG_AMAX_E, &planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(active_extruder)], 100, max_accel_edit_scaled.e, []{ planner.reset_acceleration_rates(); });
|
EDIT_ITEM_FAST(long5_25, MSG_AMAX_E, &planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(active_extruder)], 100, max_accel_edit_scaled.e, []{ planner.reset_acceleration_rates(); });
|
||||||
for (uint8_t n = 0; n < E_STEPPERS; n++)
|
LOOP_L_N(n, E_STEPPERS)
|
||||||
EDIT_ITEM_FAST_N(long5_25, n, MSG_AMAX_EN, &planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(n)], 100, max_accel_edit_scaled.e, []{ _reset_e_acceleration_rate(MenuItemBase::itemIndex); });
|
EDIT_ITEM_FAST_N(long5_25, n, MSG_AMAX_EN, &planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(n)], 100, max_accel_edit_scaled.e, []{ _reset_e_acceleration_rate(MenuItemBase::itemIndex); });
|
||||||
#elif E_STEPPERS
|
#elif E_STEPPERS
|
||||||
EDIT_ITEM_FAST(long5_25, MSG_AMAX_E, &planner.settings.max_acceleration_mm_per_s2[E_AXIS], 100, max_accel_edit_scaled.e, []{ planner.reset_acceleration_rates(); });
|
EDIT_ITEM_FAST(long5_25, MSG_AMAX_E, &planner.settings.max_acceleration_mm_per_s2[E_AXIS], 100, max_accel_edit_scaled.e, []{ planner.reset_acceleration_rates(); });
|
||||||
|
@ -484,7 +484,7 @@ void menu_advanced_steps_per_mm() {
|
||||||
|
|
||||||
#if ENABLED(DISTINCT_E_FACTORS)
|
#if ENABLED(DISTINCT_E_FACTORS)
|
||||||
EDIT_ITEM_FAST(float51, MSG_E_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS_N(active_extruder)], 5, 9999, []{ planner.refresh_positioning(); });
|
EDIT_ITEM_FAST(float51, MSG_E_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS_N(active_extruder)], 5, 9999, []{ planner.refresh_positioning(); });
|
||||||
for (uint8_t n = 0; n < E_STEPPERS; n++)
|
LOOP_L_N(n, E_STEPPERS)
|
||||||
EDIT_ITEM_FAST_N(float51, n, MSG_EN_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS_N(n)], 5, 9999, []{ _planner_refresh_e_positioning(MenuItemBase::itemIndex); });
|
EDIT_ITEM_FAST_N(float51, n, MSG_EN_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS_N(n)], 5, 9999, []{ _planner_refresh_e_positioning(MenuItemBase::itemIndex); });
|
||||||
#elif E_STEPPERS
|
#elif E_STEPPERS
|
||||||
EDIT_ITEM_FAST(float51, MSG_E_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS], 5, 9999, []{ planner.refresh_positioning(); });
|
EDIT_ITEM_FAST(float51, MSG_E_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS], 5, 9999, []{ planner.refresh_positioning(); });
|
||||||
|
@ -558,7 +558,7 @@ void menu_advanced_settings() {
|
||||||
#if EXTRUDERS == 1
|
#if EXTRUDERS == 1
|
||||||
EDIT_ITEM(float52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 999);
|
EDIT_ITEM(float52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 999);
|
||||||
#elif EXTRUDERS > 1
|
#elif EXTRUDERS > 1
|
||||||
for (uint8_t n = 0; n < E_STEPPERS; n++)
|
LOOP_L_N(n, E_STEPPERS)
|
||||||
EDIT_ITEM_N(float52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 999);
|
EDIT_ITEM_N(float52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 999);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -114,7 +114,7 @@ void _menu_temp_filament_op(const PauseMode mode, const int8_t extruder) {
|
||||||
GCODES_ITEM_P(msg, PSTR("M600 B0"));
|
GCODES_ITEM_P(msg, PSTR("M600 B0"));
|
||||||
#else
|
#else
|
||||||
PGM_P const msg = GET_TEXT(MSG_FILAMENTCHANGE_E);
|
PGM_P const msg = GET_TEXT(MSG_FILAMENTCHANGE_E);
|
||||||
for (uint8_t s = 0; s < E_STEPPERS; s++) {
|
LOOP_L_N(s, E_STEPPERS) {
|
||||||
if (thermalManager.targetTooColdToExtrude(s))
|
if (thermalManager.targetTooColdToExtrude(s))
|
||||||
SUBMENU_N_P(s, msg, []{ _menu_temp_filament_op(PAUSE_MODE_CHANGE_FILAMENT, MenuItemBase::itemIndex); });
|
SUBMENU_N_P(s, msg, []{ _menu_temp_filament_op(PAUSE_MODE_CHANGE_FILAMENT, MenuItemBase::itemIndex); });
|
||||||
else {
|
else {
|
||||||
|
@ -138,7 +138,7 @@ void _menu_temp_filament_op(const PauseMode mode, const int8_t extruder) {
|
||||||
GCODES_ITEM_P(msg_load, PSTR("M701"));
|
GCODES_ITEM_P(msg_load, PSTR("M701"));
|
||||||
#else
|
#else
|
||||||
PGM_P const msg_load = GET_TEXT(MSG_FILAMENTLOAD_E);
|
PGM_P const msg_load = GET_TEXT(MSG_FILAMENTLOAD_E);
|
||||||
for (uint8_t s = 0; s < E_STEPPERS; s++) {
|
LOOP_L_N(s, E_STEPPERS) {
|
||||||
if (thermalManager.targetTooColdToExtrude(s))
|
if (thermalManager.targetTooColdToExtrude(s))
|
||||||
SUBMENU_N_P(s, msg_load, []{ _menu_temp_filament_op(PAUSE_MODE_LOAD_FILAMENT, MenuItemBase::itemIndex); });
|
SUBMENU_N_P(s, msg_load, []{ _menu_temp_filament_op(PAUSE_MODE_LOAD_FILAMENT, MenuItemBase::itemIndex); });
|
||||||
else {
|
else {
|
||||||
|
@ -162,7 +162,7 @@ void _menu_temp_filament_op(const PauseMode mode, const int8_t extruder) {
|
||||||
#if ENABLED(FILAMENT_UNLOAD_ALL_EXTRUDERS)
|
#if ENABLED(FILAMENT_UNLOAD_ALL_EXTRUDERS)
|
||||||
{
|
{
|
||||||
bool too_cold = false;
|
bool too_cold = false;
|
||||||
for (uint8_t s = 0; s < E_STEPPERS; s++) {
|
LOOP_L_N(s, E_STEPPERS) {
|
||||||
if (thermalManager.targetTooColdToExtrude(s)) {
|
if (thermalManager.targetTooColdToExtrude(s)) {
|
||||||
too_cold = true; break;
|
too_cold = true; break;
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,7 @@ void _menu_temp_filament_op(const PauseMode mode, const int8_t extruder) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
PGM_P const msg_unload = GET_TEXT(MSG_FILAMENTUNLOAD_E);
|
PGM_P const msg_unload = GET_TEXT(MSG_FILAMENTUNLOAD_E);
|
||||||
for (uint8_t s = 0; s < E_STEPPERS; s++) {
|
LOOP_L_N(s, E_STEPPERS) {
|
||||||
if (thermalManager.targetTooColdToExtrude(s))
|
if (thermalManager.targetTooColdToExtrude(s))
|
||||||
SUBMENU_N_P(s, msg_unload, []{ _menu_temp_filament_op(PAUSE_MODE_UNLOAD_FILAMENT, MenuItemBase::itemIndex); });
|
SUBMENU_N_P(s, msg_unload, []{ _menu_temp_filament_op(PAUSE_MODE_UNLOAD_FILAMENT, MenuItemBase::itemIndex); });
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -181,7 +181,7 @@ void lcd_mixer_mix_edit() {
|
||||||
|
|
||||||
#if CHANNEL_MIX_EDITING
|
#if CHANNEL_MIX_EDITING
|
||||||
|
|
||||||
for (uint8_t n = 1; n <= MIXING_STEPPERS; n++)
|
LOOP_S_LE_N(n, 1, MIXING_STEPPERS)
|
||||||
EDIT_ITEM_FAST_N(float52, n, MSG_MIX_COMPONENT_N, &mixer.collector[n-1], 0, 10);
|
EDIT_ITEM_FAST_N(float52, n, MSG_MIX_COMPONENT_N, &mixer.collector[n-1], 0, 10);
|
||||||
|
|
||||||
ACTION_ITEM(MSG_CYCLE_MIX, _lcd_mixer_cycle_mix);
|
ACTION_ITEM(MSG_CYCLE_MIX, _lcd_mixer_cycle_mix);
|
||||||
|
|
|
@ -54,7 +54,7 @@ void _mmu2_load_filament(uint8_t index) {
|
||||||
ui.reset_status();
|
ui.reset_status();
|
||||||
}
|
}
|
||||||
void action_mmu2_load_all() {
|
void action_mmu2_load_all() {
|
||||||
for (uint8_t i = 0; i < EXTRUDERS; i++)
|
LOOP_L_N(i, EXTRUDERS)
|
||||||
_mmu2_load_filament(i);
|
_mmu2_load_filament(i);
|
||||||
ui.return_to_status();
|
ui.return_to_status();
|
||||||
}
|
}
|
||||||
|
|
|
@ -357,7 +357,7 @@ void menu_move() {
|
||||||
#elif E_MANUAL > 1
|
#elif E_MANUAL > 1
|
||||||
|
|
||||||
// Independent extruders with one E-stepper per hotend
|
// Independent extruders with one E-stepper per hotend
|
||||||
for (uint8_t n = 0; n < E_MANUAL; n++) SUBMENU_MOVE_E(n);
|
LOOP_L_N(n, E_MANUAL) SUBMENU_MOVE_E(n);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ void _lcd_preheat(const int16_t endnum, const int16_t temph, const int16_t tempb
|
||||||
#if HAS_HEATED_BED
|
#if HAS_HEATED_BED
|
||||||
_PREHEAT_ITEMS(1,0);
|
_PREHEAT_ITEMS(1,0);
|
||||||
#endif
|
#endif
|
||||||
for (uint8_t n = 1; n < HOTENDS; n++) PREHEAT_ITEMS(1,n);
|
LOOP_S_L_N(n, 1, HOTENDS) PREHEAT_ITEMS(1,n);
|
||||||
ACTION_ITEM(MSG_PREHEAT_1_ALL, []() {
|
ACTION_ITEM(MSG_PREHEAT_1_ALL, []() {
|
||||||
#if HAS_HEATED_BED
|
#if HAS_HEATED_BED
|
||||||
_preheat_bed(0);
|
_preheat_bed(0);
|
||||||
|
@ -139,7 +139,7 @@ void _lcd_preheat(const int16_t endnum, const int16_t temph, const int16_t tempb
|
||||||
#if HAS_HEATED_BED
|
#if HAS_HEATED_BED
|
||||||
_PREHEAT_ITEMS(2,0);
|
_PREHEAT_ITEMS(2,0);
|
||||||
#endif
|
#endif
|
||||||
for (uint8_t n = 1; n < HOTENDS; n++) PREHEAT_ITEMS(2,n);
|
LOOP_S_L_N(n, 1, HOTENDS) PREHEAT_ITEMS(2,n);
|
||||||
ACTION_ITEM(MSG_PREHEAT_2_ALL, []() {
|
ACTION_ITEM(MSG_PREHEAT_2_ALL, []() {
|
||||||
#if HAS_HEATED_BED
|
#if HAS_HEATED_BED
|
||||||
_preheat_bed(1);
|
_preheat_bed(1);
|
||||||
|
|
|
@ -222,7 +222,7 @@ void menu_tune() {
|
||||||
EDIT_ITEM(int3, MSG_FLOW, &planner.flow_percentage[active_extruder], 10, 999, []{ planner.refresh_e_factor(active_extruder); });
|
EDIT_ITEM(int3, MSG_FLOW, &planner.flow_percentage[active_extruder], 10, 999, []{ planner.refresh_e_factor(active_extruder); });
|
||||||
// Flow En:
|
// Flow En:
|
||||||
#if EXTRUDERS > 1
|
#if EXTRUDERS > 1
|
||||||
for (uint8_t n = 0; n < EXTRUDERS; n++)
|
LOOP_L_N(n, EXTRUDERS)
|
||||||
EDIT_ITEM_N(int3, n, MSG_FLOW_N, &planner.flow_percentage[n], 10, 999, []{ planner.refresh_e_factor(MenuItemBase::itemIndex); });
|
EDIT_ITEM_N(int3, n, MSG_FLOW_N, &planner.flow_percentage[n], 10, 999, []{ planner.refresh_e_factor(MenuItemBase::itemIndex); });
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -234,7 +234,7 @@ void menu_tune() {
|
||||||
#if EXTRUDERS == 1
|
#if EXTRUDERS == 1
|
||||||
EDIT_ITEM(float52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 999);
|
EDIT_ITEM(float52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 999);
|
||||||
#elif EXTRUDERS > 1
|
#elif EXTRUDERS > 1
|
||||||
for (uint8_t n = 0; n < EXTRUDERS; n++)
|
LOOP_L_N(n, EXTRUDERS)
|
||||||
EDIT_ITEM_N(float52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 999);
|
EDIT_ITEM_N(float52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 999);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1136,7 +1136,7 @@ void MarlinUI::update() {
|
||||||
thermalManager.current_ADCKey_raw = HAL_ADC_RANGE;
|
thermalManager.current_ADCKey_raw = HAL_ADC_RANGE;
|
||||||
thermalManager.ADCKey_count = 0;
|
thermalManager.ADCKey_count = 0;
|
||||||
if (currentkpADCValue < adc_other_button)
|
if (currentkpADCValue < adc_other_button)
|
||||||
for (uint8_t i = 0; i < ADC_KEY_NUM; i++) {
|
LOOP_L_N(i, ADC_KEY_NUM) {
|
||||||
const uint16_t lo = pgm_read_word(&stADCKeyTable[i].ADCKeyValueMin),
|
const uint16_t lo = pgm_read_word(&stADCKeyTable[i].ADCKeyValueMin),
|
||||||
hi = pgm_read_word(&stADCKeyTable[i].ADCKeyValueMax);
|
hi = pgm_read_word(&stADCKeyTable[i].ADCKeyValueMax);
|
||||||
if (WITHIN(currentkpADCValue, lo, hi)) return pgm_read_byte(&stADCKeyTable[i].ADCKeyNo);
|
if (WITHIN(currentkpADCValue, lo, hi)) return pgm_read_byte(&stADCKeyTable[i].ADCKeyNo);
|
||||||
|
|
|
@ -508,7 +508,7 @@ uint8_t L64XX_Marlin::get_user_input(uint8_t &driver_count, L64XX_axis_t axis_in
|
||||||
// Work on the drivers
|
// Work on the drivers
|
||||||
//
|
//
|
||||||
|
|
||||||
for (uint8_t k = 0; k < driver_count; k++) {
|
LOOP_L_N(k, driver_count) {
|
||||||
uint8_t not_found = true;
|
uint8_t not_found = true;
|
||||||
for (j = 1; j <= L64XX::chain[0]; j++) {
|
for (j = 1; j <= L64XX::chain[0]; j++) {
|
||||||
PGM_P const str = (PGM_P)pgm_read_ptr(&index_to_axis[L64XX::chain[j]]);
|
PGM_P const str = (PGM_P)pgm_read_ptr(&index_to_axis[L64XX::chain[j]]);
|
||||||
|
|
|
@ -54,7 +54,7 @@ Nozzle nozzle;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Start the stroke pattern
|
// Start the stroke pattern
|
||||||
for (uint8_t i = 0; i < (strokes >> 1); i++) {
|
LOOP_L_N(i, strokes >> 1) {
|
||||||
do_blocking_move_to_xy(end);
|
do_blocking_move_to_xy(end);
|
||||||
do_blocking_move_to_xy(start);
|
do_blocking_move_to_xy(start);
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ Nozzle nozzle;
|
||||||
const bool horiz = ABS(diff.x) >= ABS(diff.y); // Do a horizontal wipe?
|
const bool horiz = ABS(diff.x) >= ABS(diff.y); // Do a horizontal wipe?
|
||||||
const float P = (horiz ? diff.x : diff.y) / zigs; // Period of each zig / zag
|
const float P = (horiz ? diff.x : diff.y) / zigs; // Period of each zig / zag
|
||||||
const xyz_pos_t *side;
|
const xyz_pos_t *side;
|
||||||
for (uint8_t j = 0; j < strokes; j++) {
|
LOOP_L_N(j, strokes) {
|
||||||
for (int8_t i = 0; i < zigs; i++) {
|
for (int8_t i = 0; i < zigs; i++) {
|
||||||
side = (i & 1) ? &end : &start;
|
side = (i & 1) ? &end : &start;
|
||||||
if (horiz)
|
if (horiz)
|
||||||
|
@ -134,8 +134,8 @@ Nozzle nozzle;
|
||||||
do_blocking_move_to(start);
|
do_blocking_move_to(start);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (uint8_t s = 0; s < strokes; s++)
|
LOOP_L_N(s, strokes)
|
||||||
for (uint8_t i = 0; i < NOZZLE_CLEAN_CIRCLE_FN; i++)
|
LOOP_L_N(i, NOZZLE_CLEAN_CIRCLE_FN)
|
||||||
do_blocking_move_to_xy(
|
do_blocking_move_to_xy(
|
||||||
middle.x + sin((RADIANS(360) / NOZZLE_CLEAN_CIRCLE_FN) * i) * radius,
|
middle.x + sin((RADIANS(360) / NOZZLE_CLEAN_CIRCLE_FN) * i) * radius,
|
||||||
middle.y + cos((RADIANS(360) / NOZZLE_CLEAN_CIRCLE_FN) * i) * radius
|
middle.y + cos((RADIANS(360) / NOZZLE_CLEAN_CIRCLE_FN) * i) * radius
|
||||||
|
|
|
@ -96,8 +96,8 @@ void apply_rotation_xyz(const matrix_3x3 &matrix, float &_x, float &_y, float &_
|
||||||
|
|
||||||
// Reset to identity. No rotate or translate.
|
// Reset to identity. No rotate or translate.
|
||||||
void matrix_3x3::set_to_identity() {
|
void matrix_3x3::set_to_identity() {
|
||||||
for (uint8_t i = 0; i < 3; i++)
|
LOOP_L_N(i, 3)
|
||||||
for (uint8_t j = 0; j < 3; j++)
|
LOOP_L_N(j, 3)
|
||||||
vectors[i][j] = float(i == j);
|
vectors[i][j] = float(i == j);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,8 +134,8 @@ matrix_3x3 matrix_3x3::create_look_at(const vector_3 &target) {
|
||||||
// Get a transposed copy of the matrix
|
// Get a transposed copy of the matrix
|
||||||
matrix_3x3 matrix_3x3::transpose(const matrix_3x3 &original) {
|
matrix_3x3 matrix_3x3::transpose(const matrix_3x3 &original) {
|
||||||
matrix_3x3 new_matrix;
|
matrix_3x3 new_matrix;
|
||||||
for (uint8_t i = 0; i < 3; i++)
|
LOOP_L_N(i, 3)
|
||||||
for (uint8_t j = 0; j < 3; j++)
|
LOOP_L_N(j, 3)
|
||||||
new_matrix.vectors[i][j] = original.vectors[j][i];
|
new_matrix.vectors[i][j] = original.vectors[j][i];
|
||||||
return new_matrix;
|
return new_matrix;
|
||||||
}
|
}
|
||||||
|
@ -145,8 +145,8 @@ void matrix_3x3::debug(PGM_P const title) {
|
||||||
serialprintPGM(title);
|
serialprintPGM(title);
|
||||||
SERIAL_EOL();
|
SERIAL_EOL();
|
||||||
}
|
}
|
||||||
for (uint8_t i = 0; i < 3; i++) {
|
LOOP_L_N(i, 3) {
|
||||||
for (uint8_t j = 0; j < 3; j++) {
|
LOOP_L_N(j, 3) {
|
||||||
if (vectors[i][j] >= 0.0) SERIAL_CHAR('+');
|
if (vectors[i][j] >= 0.0) SERIAL_CHAR('+');
|
||||||
SERIAL_ECHO_F(vectors[i][j], 6);
|
SERIAL_ECHO_F(vectors[i][j], 6);
|
||||||
SERIAL_CHAR(' ');
|
SERIAL_CHAR(' ');
|
||||||
|
|
|
@ -583,7 +583,7 @@ void MarlinSettings::postprocess() {
|
||||||
|
|
||||||
#if HAS_HOTEND_OFFSET
|
#if HAS_HOTEND_OFFSET
|
||||||
// Skip hotend 0 which must be 0
|
// Skip hotend 0 which must be 0
|
||||||
for (uint8_t e = 1; e < HOTENDS; e++)
|
LOOP_S_L_N(e, 1, HOTENDS)
|
||||||
EEPROM_WRITE(hotend_offset[e]);
|
EEPROM_WRITE(hotend_offset[e]);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1420,7 +1420,7 @@ void MarlinSettings::postprocess() {
|
||||||
{
|
{
|
||||||
#if HAS_HOTEND_OFFSET
|
#if HAS_HOTEND_OFFSET
|
||||||
// Skip hotend 0 which must be 0
|
// Skip hotend 0 which must be 0
|
||||||
for (uint8_t e = 1; e < HOTENDS; e++)
|
LOOP_S_L_N(e, 1, HOTENDS)
|
||||||
EEPROM_READ(hotend_offset[e]);
|
EEPROM_READ(hotend_offset[e]);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -2915,7 +2915,7 @@ void MarlinSettings::reset() {
|
||||||
#if HAS_HOTEND_OFFSET
|
#if HAS_HOTEND_OFFSET
|
||||||
CONFIG_ECHO_HEADING("Hotend offsets:");
|
CONFIG_ECHO_HEADING("Hotend offsets:");
|
||||||
CONFIG_ECHO_START();
|
CONFIG_ECHO_START();
|
||||||
for (uint8_t e = 1; e < HOTENDS; e++) {
|
LOOP_S_L_N(e, 1, HOTENDS) {
|
||||||
SERIAL_ECHOPAIR_P(
|
SERIAL_ECHOPAIR_P(
|
||||||
PSTR(" M218 T"), (int)e,
|
PSTR(" M218 T"), (int)e,
|
||||||
SP_X_STR, LINEAR_UNIT(hotend_offset[e].x),
|
SP_X_STR, LINEAR_UNIT(hotend_offset[e].x),
|
||||||
|
|
|
@ -481,7 +481,7 @@ void _O2 Endstops::report_states() {
|
||||||
print_es_state(READ(FIL_RUNOUT_PIN) != FIL_RUNOUT_INVERTING, PSTR(STR_FILAMENT_RUNOUT_SENSOR));
|
print_es_state(READ(FIL_RUNOUT_PIN) != FIL_RUNOUT_INVERTING, PSTR(STR_FILAMENT_RUNOUT_SENSOR));
|
||||||
#else
|
#else
|
||||||
#define _CASE_RUNOUT(N) case N: pin = FIL_RUNOUT##N##_PIN; break;
|
#define _CASE_RUNOUT(N) case N: pin = FIL_RUNOUT##N##_PIN; break;
|
||||||
for (uint8_t i = 1; i <= NUM_RUNOUT_SENSORS; i++) {
|
LOOP_S_LE_N(i, 1, NUM_RUNOUT_SENSORS) {
|
||||||
pin_t pin;
|
pin_t pin;
|
||||||
switch (i) {
|
switch (i) {
|
||||||
default: continue;
|
default: continue;
|
||||||
|
|
|
@ -1408,7 +1408,7 @@ void Planner::check_axes_activity() {
|
||||||
* The multiplier converts a given E value into a length.
|
* The multiplier converts a given E value into a length.
|
||||||
*/
|
*/
|
||||||
void Planner::calculate_volumetric_multipliers() {
|
void Planner::calculate_volumetric_multipliers() {
|
||||||
for (uint8_t i = 0; i < COUNT(filament_size); i++) {
|
LOOP_L_N(i, COUNT(filament_size)) {
|
||||||
volumetric_multiplier[i] = calculate_volumetric_multiplier(filament_size[i]);
|
volumetric_multiplier[i] = calculate_volumetric_multiplier(filament_size[i]);
|
||||||
refresh_e_factor(i);
|
refresh_e_factor(i);
|
||||||
}
|
}
|
||||||
|
@ -1991,7 +1991,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
|
||||||
|
|
||||||
#if ENABLED(DISABLE_INACTIVE_EXTRUDER) // Enable only the selected extruder
|
#if ENABLED(DISABLE_INACTIVE_EXTRUDER) // Enable only the selected extruder
|
||||||
|
|
||||||
for (uint8_t i = 0; i < EXTRUDERS; i++)
|
LOOP_L_N(i, EXTRUDERS)
|
||||||
if (g_uc_extruder_last_move[i] > 0) g_uc_extruder_last_move[i]--;
|
if (g_uc_extruder_last_move[i] > 0) g_uc_extruder_last_move[i]--;
|
||||||
|
|
||||||
#if HAS_DUPLICATION_MODE
|
#if HAS_DUPLICATION_MODE
|
||||||
|
|
|
@ -403,7 +403,7 @@ class Planner {
|
||||||
FORCE_INLINE static void set_filament_size(const uint8_t e, const float &v) {
|
FORCE_INLINE static void set_filament_size(const uint8_t e, const float &v) {
|
||||||
filament_size[e] = v;
|
filament_size[e] = v;
|
||||||
// make sure all extruders have some sane value for the filament size
|
// make sure all extruders have some sane value for the filament size
|
||||||
for (uint8_t i = 0; i < COUNT(filament_size); i++)
|
LOOP_L_N(i, COUNT(filament_size))
|
||||||
if (!filament_size[i]) filament_size[i] = DEFAULT_NOMINAL_FILAMENT_DIA;
|
if (!filament_size[i]) filament_size[i] = DEFAULT_NOMINAL_FILAMENT_DIA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -807,7 +807,7 @@ class Planner {
|
||||||
FORCE_INLINE static void recalculate_max_e_jerk() {
|
FORCE_INLINE static void recalculate_max_e_jerk() {
|
||||||
#define GET_MAX_E_JERK(N) SQRT(SQRT(0.5) * junction_deviation_mm * (N) * RECIPROCAL(1.0 - SQRT(0.5)))
|
#define GET_MAX_E_JERK(N) SQRT(SQRT(0.5) * junction_deviation_mm * (N) * RECIPROCAL(1.0 - SQRT(0.5)))
|
||||||
#if ENABLED(DISTINCT_E_FACTORS)
|
#if ENABLED(DISTINCT_E_FACTORS)
|
||||||
for (uint8_t i = 0; i < EXTRUDERS; i++)
|
LOOP_L_N(i, EXTRUDERS)
|
||||||
max_e_jerk[i] = GET_MAX_E_JERK(settings.max_acceleration_mm_per_s2[E_AXIS_N(i)]);
|
max_e_jerk[i] = GET_MAX_E_JERK(settings.max_acceleration_mm_per_s2[E_AXIS_N(i)]);
|
||||||
#else
|
#else
|
||||||
max_e_jerk = GET_MAX_E_JERK(settings.max_acceleration_mm_per_s2[E_AXIS]);
|
max_e_jerk = GET_MAX_E_JERK(settings.max_acceleration_mm_per_s2[E_AXIS]);
|
||||||
|
|
|
@ -624,7 +624,7 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
|
||||||
|
|
||||||
#if EXTRA_PROBING
|
#if EXTRA_PROBING
|
||||||
// Insert Z measurement into probes[]. Keep it sorted ascending.
|
// Insert Z measurement into probes[]. Keep it sorted ascending.
|
||||||
for (uint8_t i = 0; i <= p; i++) { // Iterate the saved Zs to insert the new Z
|
LOOP_LE_N(i, p) { // Iterate the saved Zs to insert the new Z
|
||||||
if (i == p || probes[i] > z) { // Last index or new Z is smaller than this Z
|
if (i == p || probes[i] > z) { // Last index or new Z is smaller than this Z
|
||||||
for (int8_t m = p; --m >= i;) probes[m + 1] = probes[m]; // Shift items down after the insertion point
|
for (int8_t m = p; --m >= i;) probes[m + 1] = probes[m]; // Shift items down after the insertion point
|
||||||
probes[i] = z; // Insert the new Z measurement
|
probes[i] = z; // Insert the new Z measurement
|
||||||
|
@ -662,7 +662,7 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
|
||||||
max_avg_idx--; else min_avg_idx++;
|
max_avg_idx--; else min_avg_idx++;
|
||||||
|
|
||||||
// Return the average value of all remaining probes.
|
// Return the average value of all remaining probes.
|
||||||
for (uint8_t i = min_avg_idx; i <= max_avg_idx; i++)
|
LOOP_S_LE_N(i, min_avg_idx, max_avg_idx)
|
||||||
probes_z_sum += probes[i];
|
probes_z_sum += probes[i];
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -2116,7 +2116,7 @@ void Stepper::init() {
|
||||||
#if MB(ALLIGATOR)
|
#if MB(ALLIGATOR)
|
||||||
const float motor_current[] = MOTOR_CURRENT;
|
const float motor_current[] = MOTOR_CURRENT;
|
||||||
unsigned int digipot_motor = 0;
|
unsigned int digipot_motor = 0;
|
||||||
for (uint8_t i = 0; i < 3 + EXTRUDERS; i++) {
|
LOOP_L_N(i, 3 + EXTRUDERS) {
|
||||||
digipot_motor = 255 * (motor_current[i] / 2.5);
|
digipot_motor = 255 * (motor_current[i] / 2.5);
|
||||||
dac084s085::setValue(i, digipot_motor);
|
dac084s085::setValue(i, digipot_motor);
|
||||||
}
|
}
|
||||||
|
@ -2756,7 +2756,7 @@ void Stepper::report_positions() {
|
||||||
SPI.begin();
|
SPI.begin();
|
||||||
SET_OUTPUT(DIGIPOTSS_PIN);
|
SET_OUTPUT(DIGIPOTSS_PIN);
|
||||||
|
|
||||||
for (uint8_t i = 0; i < COUNT(digipot_motor_current); i++) {
|
LOOP_L_N(i, COUNT(digipot_motor_current)) {
|
||||||
//digitalPotWrite(digipot_ch[i], digipot_motor_current[i]);
|
//digitalPotWrite(digipot_ch[i], digipot_motor_current[i]);
|
||||||
digipot_current(i, digipot_motor_current[i]);
|
digipot_current(i, digipot_motor_current[i]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -708,7 +708,7 @@ int16_t Temperature::getHeaterPower(const heater_ind_t heater_id) {
|
||||||
}while(0)
|
}while(0)
|
||||||
|
|
||||||
uint8_t fanDone = 0;
|
uint8_t fanDone = 0;
|
||||||
for (uint8_t f = 0; f < COUNT(fanBit); f++) {
|
LOOP_L_N(f, COUNT(fanBit)) {
|
||||||
const uint8_t realFan = pgm_read_byte(&fanBit[f]);
|
const uint8_t realFan = pgm_read_byte(&fanBit[f]);
|
||||||
if (TEST(fanDone, realFan)) continue;
|
if (TEST(fanDone, realFan)) continue;
|
||||||
const bool fan_on = TEST(fanState, realFan);
|
const bool fan_on = TEST(fanState, realFan);
|
||||||
|
@ -2422,7 +2422,7 @@ void Temperature::readings_ready() {
|
||||||
#endif // HOTENDS > 1
|
#endif // HOTENDS > 1
|
||||||
};
|
};
|
||||||
|
|
||||||
for (uint8_t e = 0; e < COUNT(temp_dir); e++) {
|
LOOP_L_N(e, COUNT(temp_dir)) {
|
||||||
const int8_t tdir = temp_dir[e];
|
const int8_t tdir = temp_dir[e];
|
||||||
if (tdir) {
|
if (tdir) {
|
||||||
const int16_t rawtemp = temp_hotend[e].raw * tdir; // normal direction, +rawtemp, else -rawtemp
|
const int16_t rawtemp = temp_hotend[e].raw * tdir; // normal direction, +rawtemp, else -rawtemp
|
||||||
|
|
|
@ -251,7 +251,7 @@ inline void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_a
|
||||||
#elif ENABLED(PARKING_EXTRUDER)
|
#elif ENABLED(PARKING_EXTRUDER)
|
||||||
|
|
||||||
void pe_solenoid_init() {
|
void pe_solenoid_init() {
|
||||||
for (uint8_t n = 0; n <= 1; ++n)
|
LOOP_LE_N(n, 1)
|
||||||
#if ENABLED(PARKING_EXTRUDER_SOLENOIDS_INVERT)
|
#if ENABLED(PARKING_EXTRUDER_SOLENOIDS_INVERT)
|
||||||
pe_activate_solenoid(n);
|
pe_activate_solenoid(n);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -228,7 +228,7 @@ inline void report_pin_state_extended(pin_t pin, const bool ignore, const bool e
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
for (uint8_t x = 0; x < COUNT(pin_array); x++) { // scan entire array and report all instances of this pin
|
LOOP_L_N(x, COUNT(pin_array)) { // scan entire array and report all instances of this pin
|
||||||
if (GET_ARRAY_PIN(x) == pin) {
|
if (GET_ARRAY_PIN(x) == pin) {
|
||||||
if (!found) { // report digital and analog pin number only on the first time through
|
if (!found) { // report digital and analog pin number only on the first time through
|
||||||
if (start_string) serialprintPGM(start_string);
|
if (start_string) serialprintPGM(start_string);
|
||||||
|
|
|
@ -74,7 +74,7 @@
|
||||||
#else
|
#else
|
||||||
static uint8_t CRC7(const uint8_t* data, uint8_t n) {
|
static uint8_t CRC7(const uint8_t* data, uint8_t n) {
|
||||||
uint8_t crc = 0;
|
uint8_t crc = 0;
|
||||||
for (uint8_t i = 0; i < n; i++) {
|
LOOP_L_N(i, n) {
|
||||||
uint8_t d = data[i];
|
uint8_t d = data[i];
|
||||||
d ^= crc << 1;
|
d ^= crc << 1;
|
||||||
if (d & 0x80) d ^= 9;
|
if (d & 0x80) d ^= 9;
|
||||||
|
@ -106,7 +106,7 @@ uint8_t Sd2Card::cardCommand(const uint8_t cmd, const uint32_t arg) {
|
||||||
d[5] = CRC7(d, 5);
|
d[5] = CRC7(d, 5);
|
||||||
|
|
||||||
// Send message
|
// Send message
|
||||||
for (uint8_t k = 0; k < 6; k++) spiSend(d[k]);
|
LOOP_L_N(k, 6) spiSend(d[k]);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
// Send command
|
// Send command
|
||||||
|
@ -246,7 +246,7 @@ bool Sd2Card::init(const uint8_t sckRateID, const pin_t chipSelectPin) {
|
||||||
spiInit(spiRate_);
|
spiInit(spiRate_);
|
||||||
|
|
||||||
// Must supply min of 74 clock cycles with CS high.
|
// Must supply min of 74 clock cycles with CS high.
|
||||||
for (uint8_t i = 0; i < 10; i++) spiSend(0xFF);
|
LOOP_L_N(i, 10) spiSend(0xFF);
|
||||||
|
|
||||||
watchdog_refresh(); // In case init takes too long
|
watchdog_refresh(); // In case init takes too long
|
||||||
|
|
||||||
|
@ -272,7 +272,7 @@ bool Sd2Card::init(const uint8_t sckRateID, const pin_t chipSelectPin) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the last byte of r7 response
|
// Get the last byte of r7 response
|
||||||
for (uint8_t i = 0; i < 4; i++) status_ = spiRec();
|
LOOP_L_N(i, 4) status_ = spiRec();
|
||||||
if (status_ == 0xAA) {
|
if (status_ == 0xAA) {
|
||||||
type(SD_CARD_TYPE_SD2);
|
type(SD_CARD_TYPE_SD2);
|
||||||
break;
|
break;
|
||||||
|
@ -303,7 +303,7 @@ bool Sd2Card::init(const uint8_t sckRateID, const pin_t chipSelectPin) {
|
||||||
}
|
}
|
||||||
if ((spiRec() & 0xC0) == 0xC0) type(SD_CARD_TYPE_SDHC);
|
if ((spiRec() & 0xC0) == 0xC0) type(SD_CARD_TYPE_SDHC);
|
||||||
// Discard rest of ocr - contains allowed voltage range
|
// Discard rest of ocr - contains allowed voltage range
|
||||||
for (uint8_t i = 0; i < 3; i++) spiRec();
|
LOOP_L_N(i, 3) spiRec();
|
||||||
}
|
}
|
||||||
chipDeselect();
|
chipDeselect();
|
||||||
|
|
||||||
|
|
|
@ -204,7 +204,7 @@ bool SdBaseFile::dirEntry(dir_t* dir) {
|
||||||
*/
|
*/
|
||||||
void SdBaseFile::dirName(const dir_t& dir, char* name) {
|
void SdBaseFile::dirName(const dir_t& dir, char* name) {
|
||||||
uint8_t j = 0;
|
uint8_t j = 0;
|
||||||
for (uint8_t i = 0; i < 11; i++) {
|
LOOP_L_N(i, 11) {
|
||||||
if (dir.name[i] == ' ')continue;
|
if (dir.name[i] == ' ')continue;
|
||||||
if (i == 8) name[j++] = '.';
|
if (i == 8) name[j++] = '.';
|
||||||
name[j++] = dir.name[i];
|
name[j++] = dir.name[i];
|
||||||
|
@ -345,10 +345,10 @@ int8_t SdBaseFile::lsPrintNext(uint8_t flags, uint8_t indent) {
|
||||||
&& DIR_IS_FILE_OR_SUBDIR(&dir)) break;
|
&& DIR_IS_FILE_OR_SUBDIR(&dir)) break;
|
||||||
}
|
}
|
||||||
// indent for dir level
|
// indent for dir level
|
||||||
for (uint8_t i = 0; i < indent; i++) SERIAL_CHAR(' ');
|
LOOP_L_N(i, indent) SERIAL_CHAR(' ');
|
||||||
|
|
||||||
// print name
|
// print name
|
||||||
for (uint8_t i = 0; i < 11; i++) {
|
LOOP_L_N(i, 11) {
|
||||||
if (dir.name[i] == ' ')continue;
|
if (dir.name[i] == ' ')continue;
|
||||||
if (i == 8) {
|
if (i == 8) {
|
||||||
SERIAL_CHAR('.');
|
SERIAL_CHAR('.');
|
||||||
|
@ -478,7 +478,7 @@ bool SdBaseFile::mkdir(SdBaseFile* parent, const uint8_t dname[11]) {
|
||||||
// make entry for '.'
|
// make entry for '.'
|
||||||
memcpy(&d, p, sizeof(d));
|
memcpy(&d, p, sizeof(d));
|
||||||
d.name[0] = '.';
|
d.name[0] = '.';
|
||||||
for (uint8_t i = 1; i < 11; i++) d.name[i] = ' ';
|
LOOP_S_L_N(i, 1, 11) d.name[i] = ' ';
|
||||||
|
|
||||||
// cache block for '.' and '..'
|
// cache block for '.' and '..'
|
||||||
block = vol_->clusterStartBlock(firstCluster_);
|
block = vol_->clusterStartBlock(firstCluster_);
|
||||||
|
@ -1088,7 +1088,7 @@ int8_t SdBaseFile::readDir(dir_t* dir, char* longFilename) {
|
||||||
if (WITHIN(seq, 1, MAX_VFAT_ENTRIES)) {
|
if (WITHIN(seq, 1, MAX_VFAT_ENTRIES)) {
|
||||||
// TODO: Store the filename checksum to verify if a long-filename-unaware system modified the file table.
|
// TODO: Store the filename checksum to verify if a long-filename-unaware system modified the file table.
|
||||||
n = (seq - 1) * (FILENAME_LENGTH);
|
n = (seq - 1) * (FILENAME_LENGTH);
|
||||||
for (uint8_t i = 0; i < FILENAME_LENGTH; i++)
|
LOOP_L_N(i, FILENAME_LENGTH)
|
||||||
longFilename[n + i] = (i < 5) ? VFAT->name1[i] : (i < 11) ? VFAT->name2[i - 5] : VFAT->name3[i - 11];
|
longFilename[n + i] = (i < 5) ? VFAT->name1[i] : (i < 11) ? VFAT->name2[i - 5] : VFAT->name3[i - 11];
|
||||||
// If this VFAT entry is the last one, add a NUL terminator at the end of the string
|
// If this VFAT entry is the last one, add a NUL terminator at the end of the string
|
||||||
if (VFAT->sequenceNumber & 0x40) longFilename[n + FILENAME_LENGTH] = '\0';
|
if (VFAT->sequenceNumber & 0x40) longFilename[n + FILENAME_LENGTH] = '\0';
|
||||||
|
|
|
@ -143,7 +143,7 @@ CardReader::CardReader() {
|
||||||
//
|
//
|
||||||
char *createFilename(char * const buffer, const dir_t &p) {
|
char *createFilename(char * const buffer, const dir_t &p) {
|
||||||
char *pos = buffer;
|
char *pos = buffer;
|
||||||
for (uint8_t i = 0; i < 11; i++) {
|
LOOP_L_N(i, 11) {
|
||||||
if (p.name[i] == ' ') continue;
|
if (p.name[i] == ' ') continue;
|
||||||
if (i == 8) *pos++ = '.';
|
if (i == 8) *pos++ = '.';
|
||||||
*pos++ = p.name[i];
|
*pos++ = p.name[i];
|
||||||
|
@ -435,7 +435,7 @@ void CardReader::getAbsFilename(char *dst) {
|
||||||
if (cnt < MAXPATHNAMELENGTH) { *dst = '/'; dst++; cnt++; }
|
if (cnt < MAXPATHNAMELENGTH) { *dst = '/'; dst++; cnt++; }
|
||||||
};
|
};
|
||||||
|
|
||||||
for (uint8_t i = 0; i < workDirDepth; i++) // Loop down to current work dir
|
LOOP_L_N(i, workDirDepth) // Loop down to current work dir
|
||||||
appendAtom(workDirParents[i]);
|
appendAtom(workDirParents[i]);
|
||||||
|
|
||||||
if (cnt < MAXPATHNAMELENGTH - (FILENAME_LENGTH) - 1) { // Leave room for filename and nul
|
if (cnt < MAXPATHNAMELENGTH - (FILENAME_LENGTH) - 1) { // Leave room for filename and nul
|
||||||
|
@ -1046,7 +1046,7 @@ void CardReader::cdroot() {
|
||||||
#if ENABLED(SDSORT_DYNAMIC_RAM)
|
#if ENABLED(SDSORT_DYNAMIC_RAM)
|
||||||
delete sort_order;
|
delete sort_order;
|
||||||
#if ENABLED(SDSORT_CACHE_NAMES)
|
#if ENABLED(SDSORT_CACHE_NAMES)
|
||||||
for (uint8_t i = 0; i < sort_count; ++i) {
|
LOOP_L_N(i, sort_count) {
|
||||||
free(sortshort[i]); // strdup
|
free(sortshort[i]); // strdup
|
||||||
free(sortnames[i]); // strdup
|
free(sortnames[i]); // strdup
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue