Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix 2.0.x #7

Merged
merged 16 commits into from
May 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -479,16 +479,12 @@
#define BANG_MAX 255 // Limits current to nozzle while in bang-bang mode; 255=full current
#define PID_MAX BANG_MAX // Limits current to nozzle while PID is active (see PID_FUNCTIONAL_RANGE below); 255=full current
#define PID_K1 0.95 // Smoothing factor within any PID loop

#if ENABLED(PIDTEMP)
//#define PID_EDIT_MENU // Add PID editing to the "Advanced Settings" menu. (~700 bytes of PROGMEM)
//#define PID_AUTOTUNE_MENU // Add PID auto-tuning to the "Advanced Settings" menu. (~250 bytes of PROGMEM)
//#define PID_DEBUG // Sends debug data to the serial port. Use 'M303 D' to toggle activation.
//#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
//#define PID_PARAMS_PER_HOTEND // Uses separate PID parameters for each extruder (useful for mismatched extruders)
// Set/get with gcode: M301 E[extruder number, 0-2]
#define PID_FUNCTIONAL_RANGE 10 // If the temperature difference between the target temperature and the actual temperature
// is more than PID_FUNCTIONAL_RANGE then the PID will be shut off and the heater will be set to min/max.

// If you are using a pre-configured hotend then you can use one of the value sets by uncommenting it

Expand Down Expand Up @@ -557,6 +553,14 @@
// FIND YOUR OWN: "M303 E-1 C8 S90" to run autotune on the bed at 90 degreesC for 8 cycles.
#endif // PIDTEMPBED

#if EITHER(PIDTEMP, PIDTEMPBED)
//#define PID_DEBUG // Sends debug data to the serial port. Use 'M303 D' to toggle activation.
//#define PID_OPENLOOP // 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
#define PID_FUNCTIONAL_RANGE 10 // If the temperature difference between the target temperature and the actual temperature
// is more than PID_FUNCTIONAL_RANGE then the PID will be shut off and the heater will be set to min/max.
#endif

// @section extruder

/**
Expand Down
27 changes: 26 additions & 1 deletion Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@
//=============================Thermal Settings ============================
//===========================================================================

/**
* Thermocouple sensors are quite sensitive to noise. Any noise induced in
* the sensor wires, such as by stepper motor wires run in parallel to them,
* may result in the thermocouple sensor reporting spurious errors. This
* value is the number of errors which can occur in a row before the error
* is reported. This allows us to ignore intermittent error conditions while
* still detecting an actual failure, which should result in a continuous
* stream of errors from the sensor.
*
* Set this value to 0 to fail on the first error to occur.
*/
#define THERMOCOUPLE_MAX_ERRORS 15

//
// Custom Thermistor 1000 parameters
//
Expand Down Expand Up @@ -330,6 +343,18 @@
#define EXTRUDER_RUNOUT_EXTRUDE 5 // (mm)
#endif

/**
* Hotend Idle Timeout
* Prevent filament in the nozzle from charring and causing a critical jam.
*/
//#define HOTEND_IDLE_TIMEOUT
#if ENABLED(HOTEND_IDLE_TIMEOUT)
#define HOTEND_IDLE_TIMEOUT_SEC (5*60) // (seconds) Time without extruder movement to trigger protection
#define HOTEND_IDLE_MIN_TRIGGER 180 // (°C) Minimum temperature to enable hotend protection
#define HOTEND_IDLE_NOZZLE_TARGET 0 // (°C) Safe temperature for the nozzle after timeout
#define HOTEND_IDLE_BED_TARGET 0 // (°C) Safe temperature for the bed after timeout
#endif

// @section temperature

// Calibration for AD595 / AD8495 sensor to adjust temperature measurements.
Expand Down Expand Up @@ -3308,7 +3333,7 @@
*/

//#define MMU_EXTRUDER_SENSOR
#if ENABLED(MMU_EXTRUDER_SENSOR)
#if ENABLED(MMU_EXTRUDER_SENSOR)
#define MMU_LOADING_ATTEMPTS_NR 5 //max. number of attempts to load filament if first load fail
#endif

Expand Down
5 changes: 4 additions & 1 deletion Marlin/src/HAL/AVR/eeprom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@

#include "../shared/eeprom_api.h"

size_t PersistentStore::capacity() { return E2END + 1; }
#ifndef MARLIN_EEPROM_SIZE
#define MARLIN_EEPROM_SIZE size_t(E2END + 1)
#endif
size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; }
bool PersistentStore::access_start() { return true; }
bool PersistentStore::access_finish() { return true; }

Expand Down
9 changes: 4 additions & 5 deletions Marlin/src/HAL/DUE/eeprom_flash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@

#if ENABLED(FLASH_EEPROM_EMULATION)

#ifndef E2END
#define E2END 0xFFF // Default to Flash emulated EEPROM size (eeprom_emul.cpp)
#endif

/* EEPROM emulation over flash with reduced wear
*
* We will use 2 contiguous groups of pages as main and alternate.
Expand Down Expand Up @@ -973,7 +969,10 @@ static void ee_Init() {

#include "../shared/eeprom_api.h"

size_t PersistentStore::capacity() { return E2END + 1; }
#ifndef MARLIN_EEPROM_SIZE
#define MARLIN_EEPROM_SIZE 0x1000 // 4KB
#endif
size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; }
bool PersistentStore::access_start() { ee_Init(); return true; }
bool PersistentStore::access_finish() { ee_Flush(); return true; }

Expand Down
5 changes: 4 additions & 1 deletion Marlin/src/HAL/DUE/eeprom_wired.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@
#include "../shared/eeprom_if.h"
#include "../shared/eeprom_api.h"

size_t PersistentStore::capacity() { return E2END + 1; }
#ifndef MARLIN_EEPROM_SIZE
#error "MARLIN_EEPROM_SIZE is required for I2C / SPI EEPROM."
#endif
size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; }
bool PersistentStore::access_start() { return true; }
bool PersistentStore::access_finish() { return true; }

Expand Down
17 changes: 6 additions & 11 deletions Marlin/src/HAL/ESP32/eeprom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,13 @@
#include "../shared/eeprom_api.h"
#include <EEPROM.h>

#define EEPROM_SIZE 4096
#ifndef MARLIN_EEPROM_SIZE
#define MARLIN_EEPROM_SIZE 0x1000 // 4KB
#endif
size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; }

bool PersistentStore::access_start() {
return EEPROM.begin(EEPROM_SIZE);
}

bool PersistentStore::access_finish() {
EEPROM.end();
return true;
}
bool PersistentStore::access_start() { return EEPROM.begin(MARLIN_EEPROM_SIZE); }
bool PersistentStore::access_finish() { EEPROM.end(); return true; }

bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
for (size_t i = 0; i < size; i++) {
Expand All @@ -56,7 +53,5 @@ bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t
return false;
}

size_t PersistentStore::capacity() { return EEPROM_SIZE; }

#endif // EEPROM_SETTINGS
#endif // ARDUINO_ARCH_ESP32
15 changes: 9 additions & 6 deletions Marlin/src/HAL/LINUX/eeprom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,15 @@
#include "../shared/eeprom_api.h"
#include <stdio.h>

#define LINUX_EEPROM_SIZE (E2END + 1)
uint8_t buffer[LINUX_EEPROM_SIZE];
#ifndef MARLIN_EEPROM_SIZE
#define MARLIN_EEPROM_SIZE 0x1000 // 4KB of Emulated EEPROM
#endif

uint8_t buffer[MARLIN_EEPROM_SIZE];
char filename[] = "eeprom.dat";

size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; }

bool PersistentStore::access_start() {
const char eeprom_erase_value = 0xFF;
FILE * eeprom_file = fopen(filename, "rb");
Expand All @@ -40,8 +45,8 @@ bool PersistentStore::access_start() {
fseek(eeprom_file, 0L, SEEK_END);
std::size_t file_size = ftell(eeprom_file);

if (file_size < LINUX_EEPROM_SIZE) {
memset(buffer + file_size, eeprom_erase_value, LINUX_EEPROM_SIZE - file_size);
if (file_size < MARLIN_EEPROM_SIZE) {
memset(buffer + file_size, eeprom_erase_value, MARLIN_EEPROM_SIZE - file_size);
}
else {
fseek(eeprom_file, 0L, SEEK_SET);
Expand Down Expand Up @@ -95,7 +100,5 @@ bool PersistentStore::read_data(int &pos, uint8_t* value, const size_t size, uin
return bytes_read != size; // return true for any error
}

size_t PersistentStore::capacity() { return 4096; } // 4KiB of Emulated EEPROM

#endif // EEPROM_SETTINGS
#endif // __PLAT_LINUX__
2 changes: 1 addition & 1 deletion Marlin/src/HAL/LPC1768/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ extern "C" volatile uint32_t _millis;
#include <CDCSerial.h>

// i2c uses 8-bit shifted address
#define I2C_ADDRESS(A) ((A) << 1)
#define I2C_ADDRESS(A) uint8_t((A) << 1)

//
// Default graphical display delays
Expand Down
25 changes: 14 additions & 11 deletions Marlin/src/HAL/LPC1768/eeprom_flash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,22 @@ extern "C" {
#include <lpc17xx_iap.h>
}

#define SECTOR_START(sector) ((sector < 16) ? (sector * 0x1000) : ((sector - 14) * 0x8000))
#ifndef MARLIN_EEPROM_SIZE
#define MARLIN_EEPROM_SIZE 0x1000 // 4KB
#endif

#define SECTOR_START(sector) ((sector < 16) ? (sector << 12) : ((sector - 14) << 15))
#define EEPROM_SECTOR 29
#define EEPROM_SIZE (4096)
#define SECTOR_SIZE (32768)
#define EEPROM_SLOTS (SECTOR_SIZE/EEPROM_SIZE)
#define EEPROM_ERASE (0xFF)
#define SLOT_ADDRESS(sector, slot) (((uint8_t *)SECTOR_START(sector)) + slot * EEPROM_SIZE)
#define SECTOR_SIZE 32768
#define EEPROM_SLOTS ((SECTOR_SIZE)/(MARLIN_EEPROM_SIZE))
#define EEPROM_ERASE 0xFF
#define SLOT_ADDRESS(sector, slot) (((uint8_t *)SECTOR_START(sector)) + slot * (MARLIN_EEPROM_SIZE))

static uint8_t ram_eeprom[EEPROM_SIZE] __attribute__((aligned(4))) = {0};
static uint8_t ram_eeprom[MARLIN_EEPROM_SIZE] __attribute__((aligned(4))) = {0};
static bool eeprom_dirty = false;
static int current_slot = 0;

size_t PersistentStore::capacity() { return EEPROM_SIZE; }
size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; }

bool PersistentStore::access_start() {
uint32_t first_nblank_loc, first_nblank_val;
Expand All @@ -71,15 +74,15 @@ bool PersistentStore::access_start() {

if (status == CMD_SUCCESS) {
// sector is blank so nothing stored yet
for (int i = 0; i < EEPROM_SIZE; i++) ram_eeprom[i] = EEPROM_ERASE;
for (int i = 0; i < MARLIN_EEPROM_SIZE; i++) ram_eeprom[i] = EEPROM_ERASE;
current_slot = EEPROM_SLOTS;
}
else {
// current slot is the first non blank one
current_slot = first_nblank_loc / EEPROM_SIZE;
current_slot = first_nblank_loc / (MARLIN_EEPROM_SIZE);
uint8_t *eeprom_data = SLOT_ADDRESS(EEPROM_SECTOR, current_slot);
// load current settings
for (int i = 0; i < EEPROM_SIZE; i++) ram_eeprom[i] = eeprom_data[i];
for (int i = 0; i < MARLIN_EEPROM_SIZE; i++) ram_eeprom[i] = eeprom_data[i];
}
eeprom_dirty = false;

Expand Down
5 changes: 4 additions & 1 deletion Marlin/src/HAL/LPC1768/eeprom_sdcard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ FATFS fat_fs;
FIL eeprom_file;
bool eeprom_file_open = false;

size_t PersistentStore::capacity() { return 4096; } // 4KiB of Emulated EEPROM
#ifndef MARLIN_EEPROM_SIZE
#define MARLIN_EEPROM_SIZE size_t(0x1000) // 4KiB of Emulated EEPROM
#endif
size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; }

bool PersistentStore::access_start() {
const char eeprom_erase_value = 0xFF;
Expand Down
12 changes: 4 additions & 8 deletions Marlin/src/HAL/LPC1768/eeprom_wired.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,14 @@
#include "../shared/eeprom_if.h"
#include "../shared/eeprom_api.h"

#ifndef EEPROM_SIZE
#define EEPROM_SIZE 0x8000 // 32kB
#ifndef MARLIN_EEPROM_SIZE
#define MARLIN_EEPROM_SIZE 0x8000 // 32KB
#endif
size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; }

size_t PersistentStore::capacity() { return EEPROM_SIZE; }
bool PersistentStore::access_start() { eeprom_init(); return true; }
bool PersistentStore::access_finish() { return true; }

bool PersistentStore::access_start() {
eeprom_init();
return true;
}

bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
while (size--) {
uint8_t v = *value;
Expand Down
12 changes: 6 additions & 6 deletions Marlin/src/HAL/SAMD51/eeprom_wired.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
#include "../shared/eeprom_if.h"
#include "../shared/eeprom_api.h"

size_t PersistentStore::capacity() { return E2END + 1; }
bool PersistentStore::access_finish() { return true; }
#ifndef MARLIN_EEPROM_SIZE
#error "MARLIN_EEPROM_SIZE is required for I2C / SPI EEPROM."
#endif
size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; }

bool PersistentStore::access_start() {
eeprom_init();
return true;
}
bool PersistentStore::access_start() { eeprom_init(); return true; }
bool PersistentStore::access_finish() { return true; }

bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
while (size--) {
Expand Down
Loading