Merge remote-tracking branch 'upstream/MK3' into 4point_xyz_cal

This commit is contained in:
PavelSindler 2017-10-30 11:48:45 +01:00
commit 1ee6016fa0
5 changed files with 14512 additions and 6 deletions

View File

@ -9,7 +9,7 @@
// Firmware version
#define FW_version "3.0.12-RC2"
#define FW_build 104
#define FW_build 105
#define FW_version_build FW_version " b" STR(FW_build)

File diff suppressed because it is too large Load Diff

View File

@ -334,6 +334,7 @@ extern int fanSpeedBckp;
extern float pause_lastpos[4];
extern unsigned long pause_time;
extern unsigned long start_pause_print;
extern unsigned long t_fan_rising_edge;
extern bool mesh_bed_leveling_flag;
extern bool mesh_bed_run_from_menu;
@ -371,6 +372,7 @@ void serialecho_temperatures();
void uvlo_();
void recover_print(uint8_t automatic);
void setup_uvlo_interrupt();
void setup_fan_interrupt();
extern void recover_machine_state_after_power_panic();
extern void restore_print_from_eeprom();

View File

@ -107,6 +107,8 @@
#define TEST(n,b) (((n)&BIT(b))!=0)
#define SET_BIT(n,b,value) (n) ^= ((-value)^(n)) & (BIT(b))
//Macro for print fan speed
#define FAN_PULSE_WIDTH_LIMIT ((fanSpeed > 100) ? 3 : 4) //time in ms
// look here for descriptions of G-codes: http://linuxcnc.org/handbook/gcode/g-code.html
// http://objects.reprap.org/wiki/Mendel_User_Manual:_RepRapGCodes
@ -288,6 +290,7 @@ int fanSpeedBckp = 0;
float pause_lastpos[4];
unsigned long pause_time = 0;
unsigned long start_pause_print = millis();
unsigned long t_fan_rising_edge = millis();
unsigned long load_filament_time;
@ -987,9 +990,10 @@ void setup()
check_babystep(); //checking if Z babystep is in allowed range
setup_uvlo_interrupt();
setup_fan_interrupt();
fsensor_setup_interrupt();
#ifndef DEBUG_DISABLE_STARTMSGS
if (calibration_status() == CALIBRATION_STATUS_ASSEMBLED ||
@ -6991,6 +6995,34 @@ void uvlo_()
while(1);
}
void setup_fan_interrupt() {
//INT7
DDRE &= ~(1 << 7); //input pin
PORTE &= ~(1 << 7); //no internal pull-up
//start with sensing rising edge
EICRB &= ~(1 << 6);
EICRB |= (1 << 7);
//enable INT7 interrupt
EIMSK |= (1 << 7);
}
ISR(INT7_vect) {
//measuring speed now works for fanSpeed > 18 (approximately), which is sufficient because MIN_PRINT_FAN_SPEED is higher
if (fanSpeed < MIN_PRINT_FAN_SPEED) return;
if ((1 << 6) & EICRB) { //interrupt was triggered by rising edge
t_fan_rising_edge = millis();
}
else { //interrupt was triggered by falling edge
if ((millis() - t_fan_rising_edge) >= FAN_PULSE_WIDTH_LIMIT) {//this pulse was from sensor and not from pwm
fan_edge_counter[1] += 2; //we are currently counting all edges so lets count two edges for one pulse
}
}
EICRB ^= (1 << 6); //change edge
}
void setup_uvlo_interrupt() {
DDRE &= ~(1 << 4); //input pin
PORTE &= ~(1 << 4); //no internal pull-up

View File

@ -2178,10 +2178,10 @@ void check_fans() {
fan_edge_counter[0] ++;
fan_state[0] = !fan_state[0];
}
if (READ(TACH_1) != fan_state[1]) {
fan_edge_counter[1] ++;
fan_state[1] = !fan_state[1];
}
//if (READ(TACH_1) != fan_state[1]) {
// fan_edge_counter[1] ++;
// fan_state[1] = !fan_state[1];
//}
}
#ifdef PIDTEMP