Commit 43fb9aac authored by MagoKimbra's avatar MagoKimbra

Update and fix

parent c1a72f44
......@@ -226,7 +226,7 @@
// Comment the following line to disable PID and enable bang-bang.
#define PIDTEMP
#if defined(PIDTEMP)
#ifdef PIDTEMP
//#define PID_DEBUG // Sends debug data to the serial port.
//#define PID_OPENLOOP 1 // Puts PID in open loop. M104/M140 sets the output power from 0 to PID_MAX
//#define SLOW_PWM_HEATERS // PWM with very low frequency (roughly 0.125Hz=8s) and minimum state time of approximately 1s useful for heaters driven by a relay
......@@ -265,7 +265,7 @@
//#define PID_BED_DEBUG // Sends debug data to the serial port.
#if defined(PIDTEMPBED)
#ifdef PIDTEMPBED
#define PID_BED_INTEGRAL_DRIVE_MAX MAX_BED_POWER // limit for the integral term
//120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
//from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10)
......@@ -469,15 +469,17 @@
//========================== EXTRA SETTINGS ON SD ===========================
// Uncomment SD SETTINGS to enable the firmware to write some configuration, that require frequent update, on the SD card.
//#define SD_SETTINGS
#ifdef SD_SETTINGS
#define SD_CFG_SECONDS 300 //seconds between update
#define CFG_SD_FILE "INFO.CFG" //name of the configuration file
#define CFG_SD_MAX_KEY_LEN 3+1 //icrease this if you add key name longer than the actual value.
#define CFG_SD_MAX_VALUE_LEN 12+1 //this should be enought for int, long and float if you need to retrive strings increase this carefully
#endif
//===========================================================================
//==================== Bowden Filament management ===========================
//#define EASY_LOAD
#if defined(EASY_LOAD)
#ifdef EASY_LOAD
#define BOWDEN_LENGTH 250 // mm
#define LCD_PURGE_LENGTH 3 // mm
#define LCD_RETRACT_LENGTH 3 // mm
......@@ -536,7 +538,6 @@
#define FILAMENT_SENSOR_EXTRUDER_NUM 0 //The number of the extruder that has the filament sensor (0,1,2,3)
#define MEASUREMENT_DELAY_CM 14 //measurement delay in cm. This is the distance from filament sensor to middle of barrel
#define DEFAULT_NOMINAL_FILAMENT_DIA 1.75 //Enter the diameter (in mm) of the filament generally used (3.0 mm or 1.75 mm) - this is then used in the slicer software. Used for sensor reading validation
#define MEASURED_UPPER_LIMIT 2.00 //upper limit factor used for sensor reading validation in mm
#define MEASURED_LOWER_LIMIT 1.35 //lower limit factor for sensor reading validation in mm
......@@ -564,7 +565,7 @@
**********************************************************************/
// Uncomment below to enable
//#define POWER_CONSUMPTION
#ifdef POWER_CONSUMPTION
#define POWER_VOLTAGE 12.00 //(V) The power supply OUT voltage
#define POWER_ZERO 2.54459 //(V) The /\V coming out from the sensor when no current flow.
#define POWER_SENSITIVITY 0.066 //(V/A) How much increase V for 1A of increase
......@@ -574,6 +575,7 @@
//When using an LCD, uncomment the line below to display the Power consumption sensor data on the last line instead of status. Status will appear for 5 sec.
//#define POWER_CONSUMPTION_LCD_DISPLAY
#endif
//===========================================================================
......
......@@ -1266,9 +1266,6 @@ static void clean_up_after_endstop_move() {
current_position[Y_AXIS] = corrected_position.y;
current_position[Z_AXIS] = corrected_position.z;
// put the bed at 0 so we don't go below it.
//current_position[Z_AXIS] = zprobe_zoffset; // in the lsq we reach here after raising the extruder due to the loop structure
sync_plan_position();
}
#else // not AUTO_BED_LEVELING_GRID
......@@ -1294,8 +1291,6 @@ static void clean_up_after_endstop_move() {
current_position[Y_AXIS] = corrected_position.y;
current_position[Z_AXIS] = corrected_position.z;
// put the bed at 0 so we don't go below it.
//current_position[Z_AXIS] += zprobe_zoffset;
sync_plan_position();
}
......@@ -3424,7 +3419,6 @@ inline void gcode_G28() {
xInc = -1;
}
// If topo_flag is set then don't zig-zag. Just scan in one direction.
// This gets the probe points in more readable order.
if (!do_topography_map) zig = !zig;
......@@ -3534,7 +3528,7 @@ inline void gcode_G28() {
real_z = (float)st_get_position(Z_AXIS) / axis_steps_per_unit[Z_AXIS]; //get the real Z (since the auto bed leveling is already correcting the plane)
apply_rotation_xyz(plan_bed_level_matrix, x_tmp, y_tmp, z_tmp); //Apply the correction sending the probe offset
current_position[Z_AXIS] += z_tmp - real_z; //The difference is added to current position and sent to planner.
current_position[Z_AXIS] = z_tmp - real_z - zprobe_zoffset;
sync_plan_position();
}
......@@ -5930,7 +5924,7 @@ inline void gcode_M999() {
}
}
else {
ECHO_LMV(DB, MSG_ZPROBE_ZOFFSET " : ", -zprobe_zoffset);
ECHO_LMV(DB, MSG_ZPROBE_ZOFFSET " : ", zprobe_zoffset);
}
}
......@@ -6652,14 +6646,14 @@ void ok_to_send() {
ECHO_E;
}
FORCE_INLINE void clamp_to_software_endstops(float target[3]) {
void clamp_to_software_endstops(float target[3]) {
if (min_software_endstops) {
NOLESS(target[X_AXIS], min_pos[X_AXIS]);
NOLESS(target[Y_AXIS], min_pos[Y_AXIS]);
float negative_z_offset = 0;
#ifdef ENABLE_AUTO_BED_LEVELING
if (Z_PROBE_OFFSET_FROM_EXTRUDER < 0) negative_z_offset += Z_PROBE_OFFSET_FROM_EXTRUDER;
if (zprobe_zoffset < 0) negative_z_offset += zprobe_zoffset;
if (home_offset[Z_AXIS] < 0) negative_z_offset += home_offset[Z_AXIS];
#endif
NOLESS(target[Z_AXIS], min_pos[Z_AXIS] + negative_z_offset);
......@@ -6812,6 +6806,9 @@ FORCE_INLINE void clamp_to_software_endstops(float target[3]) {
/**
* Prepare a single move and get ready for the next one
*
* (This may call plan_buffer_line several times to put
* smaller moves into the planner for DELTA or SCARA.)
*/
void prepare_move() {
clamp_to_software_endstops(destination);
......@@ -7338,6 +7335,6 @@ float calculate_volumetric_multiplier(float diameter) {
}
void calculate_volumetric_multipliers() {
for (int i=0; i<EXTRUDERS; i++)
for (int i = 0; i < EXTRUDERS; i++)
volumetric_multiplier[i] = calculate_volumetric_multiplier(filament_size[i]);
}
/*
buzzer.cpp - Library for controlling a buzzer
Created by Mago Kimbra, 10/05/2015
*/
#include "Marlin.h"
#include "buzzer.h"
#include "ultralcd.h"
......
/* buzzer.h
* MarlinKimbra
*
*/
#ifndef BUZZER_H
#define BUZZER_H
......@@ -10,4 +5,4 @@
void buzz(long duration, uint16_t freq);
#endif
#endif BUZZER_H
#endif //BUZZER_H
......@@ -413,7 +413,7 @@ static void lcd_implementation_status_screen() {
lcd_printPGM(PSTR("dia:"));
lcd_print(ftostr12ns(filament_width_meas));
lcd_printPGM(PSTR(" factor:"));
lcd_print(itostr3(volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]));
lcd_print(itostr3(100.0 * volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]));
lcd_print('%');
}
#endif
......
......@@ -101,29 +101,29 @@ static inline void handle_interrupts(timer16_Sequence_t timer, volatile uint16_t
#ifndef WIRING // Wiring pre-defines signal handlers so don't define any if compiling for the Wiring platform
// Interrupt handlers for Arduino
#if defined(_useTimer1)
#ifdef _useTimer1
SIGNAL (TIMER1_COMPA_vect) { handle_interrupts(_timer1, &TCNT1, &OCR1A); }
#endif
#if defined(_useTimer3)
#ifdef _useTimer3
SIGNAL (TIMER3_COMPA_vect) { handle_interrupts(_timer3, &TCNT3, &OCR3A); }
#endif
#if defined(_useTimer4)
#ifdef _useTimer4
SIGNAL (TIMER4_COMPA_vect) { handle_interrupts(_timer4, &TCNT4, &OCR4A); }
#endif
#if defined(_useTimer5)
#ifdef _useTimer5
SIGNAL (TIMER5_COMPA_vect) { handle_interrupts(_timer5, &TCNT5, &OCR5A); }
#endif
#else //!WIRING
// Interrupt handlers for Wiring
#if defined(_useTimer1)
#ifdef _useTimer1
void Timer1Service() { handle_interrupts(_timer1, &TCNT1, &OCR1A); }
#endif
#if defined(_useTimer3)
#ifdef _useTimer3
void Timer3Service() { handle_interrupts(_timer3, &TCNT3, &OCR3A); }
#endif
......@@ -131,7 +131,7 @@ static inline void handle_interrupts(timer16_Sequence_t timer, volatile uint16_t
static void initISR(timer16_Sequence_t timer) {
#if defined(_useTimer1)
#ifdef _useTimer1
if (timer == _timer1) {
TCCR1A = 0; // normal counting mode
TCCR1B = _BV(CS11); // set prescaler of 8
......@@ -150,25 +150,25 @@ static void initISR(timer16_Sequence_t timer) {
}
#endif
#if defined(_useTimer3)
#ifdef _useTimer3
if (timer == _timer3) {
TCCR3A = 0; // normal counting mode
TCCR3B = _BV(CS31); // set prescaler of 8
TCNT3 = 0; // clear the timer count
#if defined(__AVR_ATmega128__)
#ifdef __AVR_ATmega128__
TIFR |= _BV(OCF3A); // clear any pending interrupts;
ETIMSK |= _BV(OCIE3A); // enable the output compare interrupt
#else
TIFR3 = _BV(OCF3A); // clear any pending interrupts;
TIMSK3 = _BV(OCIE3A) ; // enable the output compare interrupt
#endif
#if defined(WIRING)
#ifdef WIRING
timerAttach(TIMER3OUTCOMPAREA_INT, Timer3Service); // for Wiring platform only
#endif
}
#endif
#if defined(_useTimer4)
#ifdef _useTimer4
if (timer == _timer4) {
TCCR4A = 0; // normal counting mode
TCCR4B = _BV(CS41); // set prescaler of 8
......@@ -178,7 +178,7 @@ static void initISR(timer16_Sequence_t timer) {
}
#endif
#if defined(_useTimer5)
#ifdef _useTimer5
if (timer == _timer5) {
TCCR5A = 0; // normal counting mode
TCCR5B = _BV(CS51); // set prescaler of 8
......@@ -191,7 +191,7 @@ static void initISR(timer16_Sequence_t timer) {
static void finISR(timer16_Sequence_t timer) {
// Disable use of the given timer
#if defined(WIRING)
#ifdef WIRING
if (timer == _timer1) {
#if defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__)
TIMSK1
......
......@@ -420,42 +420,6 @@ FORCE_INLINE void trapezoid_generator_reset() {
OCR1A = acceleration_time;
}
#define _ENDSTOP_PIN(AXIS, MINMAX) AXIS ##_## MINMAX ##_PIN
#define _ENDSTOP_INVERTING(AXIS, MINMAX) AXIS ##_## MINMAX ##_ENDSTOP_INVERTING
#define _AXIS(AXIS) AXIS ##_AXIS
#define _ENDSTOP_HIT(AXIS) endstop_hit_bits |= BIT(_ENDSTOP(AXIS, MIN))
#define _ENDSTOP(AXIS, MINMAX) AXIS ##_## MINMAX
// SET_ENDSTOP_BIT: set the current endstop bits for an endstop to its status
#define SET_ENDSTOP_BIT(AXIS, MINMAX) SET_BIT(current_endstop_bits, _ENDSTOP(AXIS, MINMAX), (READ(_ENDSTOP_PIN(AXIS, MINMAX)) != _ENDSTOP_INVERTING(AXIS, MINMAX)))
// COPY_BIT: copy the value of COPY_BIT to BIT in bits
#define COPY_BIT(bits, COPY_BIT, BIT) SET_BIT(bits, BIT, TEST(bits, COPY_BIT))
// TEST_ENDSTOP: test the old and the current status of an endstop
#define TEST_ENDSTOP(ENDSTOP) (TEST(current_endstop_bits, ENDSTOP) && TEST(old_endstop_bits, ENDSTOP))
#define UPDATE_ENDSTOP(AXIS,MINMAX) \
SET_ENDSTOP_BIT(AXIS, MINMAX); \
if (TEST_ENDSTOP(_ENDSTOP(AXIS, MINMAX)) && (current_block->steps[_AXIS(AXIS)] > 0)) { \
endstops_trigsteps[_AXIS(AXIS)] = count_position[_AXIS(AXIS)]; \
_ENDSTOP_HIT(AXIS); \
step_events_completed = current_block->step_event_count; \
}
#define _COUNTER(axis) counter_## axis
#define _APPLY_STEP(AXIS) AXIS ##_APPLY_STEP
#define _INVERT_STEP_PIN(AXIS) INVERT_## AXIS ##_STEP_PIN
#define STEP_START(axis, AXIS) \
_COUNTER(axis) += current_block->steps[_AXIS(AXIS)]; \
if (_COUNTER(axis) > 0) { _APPLY_STEP(AXIS)(!_INVERT_STEP_PIN(AXIS),0); }
#define STEP_END(axis, AXIS) \
if (_COUNTER(axis) > 0) { \
_COUNTER(axis) -= current_block->step_event_count; \
count_position[_AXIS(AXIS)] += count_direction[_AXIS(AXIS)]; \
_APPLY_STEP(AXIS)(_INVERT_STEP_PIN(AXIS),0); \
}
// "The Stepper Driver Interrupt" - This timer interrupt is the workhorse.
// It pops blocks from the block_buffer and executes them by pulsing the stepper pins appropriately.
ISR(TIMER1_COMPA_vect) {
......@@ -509,8 +473,29 @@ ISR(TIMER1_COMPA_vect) {
#else
byte
#endif
current_endstop_bits = 0;
current_endstop_bits = 0;
#define _ENDSTOP_PIN(AXIS, MINMAX) AXIS ##_## MINMAX ##_PIN
#define _ENDSTOP_INVERTING(AXIS, MINMAX) AXIS ##_## MINMAX ##_ENDSTOP_INVERTING
#define _AXIS(AXIS) AXIS ##_AXIS
#define _ENDSTOP_HIT(AXIS) endstop_hit_bits |= BIT(_ENDSTOP(AXIS, MIN))
#define _ENDSTOP(AXIS, MINMAX) AXIS ##_## MINMAX
// SET_ENDSTOP_BIT: set the current endstop bits for an endstop to its status
#define SET_ENDSTOP_BIT(AXIS, MINMAX) SET_BIT(current_endstop_bits, _ENDSTOP(AXIS, MINMAX), (READ(_ENDSTOP_PIN(AXIS, MINMAX)) != _ENDSTOP_INVERTING(AXIS, MINMAX)))
// COPY_BIT: copy the value of COPY_BIT to BIT in bits
#define COPY_BIT(bits, COPY_BIT, BIT) SET_BIT(bits, BIT, TEST(bits, COPY_BIT))
// TEST_ENDSTOP: test the old and the current status of an endstop
#define TEST_ENDSTOP(ENDSTOP) (TEST(current_endstop_bits, ENDSTOP) && TEST(old_endstop_bits, ENDSTOP))
#define UPDATE_ENDSTOP(AXIS,MINMAX) \
SET_ENDSTOP_BIT(AXIS, MINMAX); \
if (TEST_ENDSTOP(_ENDSTOP(AXIS, MINMAX)) && (current_block->steps[_AXIS(AXIS)] > 0)) { \
endstops_trigsteps[_AXIS(AXIS)] = count_position[_AXIS(AXIS)]; \
_ENDSTOP_HIT(AXIS); \
step_events_completed = current_block->step_event_count; \
}
#ifdef COREXY
// Head direction in -X axis for CoreXY bots.
// If DeltaX == -DeltaY, the movement is only in Y axis
......@@ -663,6 +648,14 @@ ISR(TIMER1_COMPA_vect) {
}
#endif //ADVANCE
#define _COUNTER(axis) counter_## axis
#define _APPLY_STEP(AXIS) AXIS ##_APPLY_STEP
#define _INVERT_STEP_PIN(AXIS) INVERT_## AXIS ##_STEP_PIN
#define STEP_START(axis, AXIS) \
_COUNTER(axis) += current_block->steps[_AXIS(AXIS)]; \
if (_COUNTER(axis) > 0) { _APPLY_STEP(AXIS)(!_INVERT_STEP_PIN(AXIS),0); }
STEP_START(x,X);
STEP_START(y,Y);
STEP_START(z,Z);
......@@ -674,6 +667,13 @@ ISR(TIMER1_COMPA_vect) {
delayMicroseconds(STEPPER_HIGH_LOW_DELAY);
#endif
#define STEP_END(axis, AXIS) \
if (_COUNTER(axis) > 0) { \
_COUNTER(axis) -= current_block->step_event_count; \
count_position[_AXIS(AXIS)] += count_direction[_AXIS(AXIS)]; \
_APPLY_STEP(AXIS)(_INVERT_STEP_PIN(AXIS),0); \
}
STEP_END(x, X);
STEP_END(y, Y);
STEP_END(z, Z);
......
......@@ -1463,6 +1463,13 @@ menu_edit_type(unsigned long, long5, ftostr5, 0.01)
* Audio feedback for controller clicks
*
*/
#ifdef LCD_USE_I2C_BUZZER
void lcd_buzz(long duration, uint16_t freq) { // called from buzz() in Marlin_main.cpp where lcd is unknown
lcd.buzz(duration, freq);
}
#endif
void lcd_quick_feedback() {
lcdDrawUpdate = 2;
next_button_update_ms = millis() + 500;
......@@ -1474,7 +1481,7 @@ void lcd_quick_feedback() {
#ifndef LCD_FEEDBACK_FREQUENCY_DURATION_MS
#define LCD_FEEDBACK_FREQUENCY_DURATION_MS (1000/6)
#endif
buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ);
lcd.buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ);
#elif defined(BEEPER) && BEEPER >= 0
#ifndef LCD_FEEDBACK_FREQUENCY_HZ
#define LCD_FEEDBACK_FREQUENCY_HZ 5000
......
......@@ -16,6 +16,10 @@
void lcd_reset_alert_level();
bool lcd_detected(void);
#ifdef LCD_USE_I2C_BUZZER
void lcd_buzz(long duration, uint16_t freq);
#endif
#if defined(LCD_PROGRESS_BAR) && PROGRESS_MSG_EXPIRE > 0
void dontExpireStatus();
#endif
......@@ -123,10 +127,6 @@
#endif //ULTRA_LCD
#if HAS_BUZZER
void buzz(long duration,uint16_t freq);
#endif
char *itostr2(const uint8_t &x);
char *itostr31(const int &xx);
char *itostr3(const int &xx);
......
......@@ -488,12 +488,11 @@ static void lcd_implementation_status_screen() {
//
#if HOTENDS > 1 || TEMP_SENSOR_BED != 0
// If we have an 2nd extruder or heated bed, show that in the top right corner
lcd.setCursor(8, 0);
#if HOTENDS > 1
lcd.print(LCD_STR_THERMOMETER[0]);
LCD_TEMP_ONLY(degHotend(1), degTargetHotend(1));
#else // Heated bed
#else
lcd.print(LCD_STR_BEDTEMP[0]);
LCD_TEMP_ONLY(degBed(), degTargetBed());
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment