Commit 4756724e authored by MagoKimbra's avatar MagoKimbra

Merge branch 'pr/39' into Development

parents b0d0aa70 eb511f3b
......@@ -20,7 +20,7 @@
// User-specified version info of this build to display in [Pronterface, etc] terminal window during
// startup. Implementation of an idea by Prof Braino to inform user that any changes made to this
// build by the user have been successfully uploaded into firmware.
#define STRING_VERSION " 4.0.9"
#define STRING_VERSION " 4.1.1"
#define STRING_URL "reprap.org"
#define STRING_VERSION_CONFIG_H __DATE__ " " __TIME__ // build date and time
#define STRING_CONFIG_H_AUTHOR "(none, default config)" // Who made the changes.
......@@ -147,7 +147,7 @@
// 10 is 100k RS thermistor 198-961 (4.7k pullup)
// 11 is 100k beta 3950 1% thermistor (4.7k pullup)
// 12 is 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) (calibrated for Makibox hot bed)
// 13 is 100k Hisens 3950 1% up to 300C for hotend "Simple ONE " & "Hotend "All In ONE"
// 13 is 100k Hisens 3950 1% up to 300°C for hotend "Simple ONE " & "Hotend "All In ONE"
// 20 is the PT100 circuit found in the Ultimainboard V2.x
// 60 is 100k Maker's Tool Works Kapton Bed Thermistor beta=3950
//
......@@ -161,7 +161,7 @@
// 1010 is Pt1000 with 1k pullup (non standard)
// 147 is Pt100 with 4k7 pullup
// 110 is Pt100 with 1k pullup (non standard)
// 998 and 999 are Dummy Tables. They will ALWAYS read 25C or the temperature defined below.
// 998 and 999 are Dummy Tables. They will ALWAYS read 25°C or the temperature defined below.
// Use it for Testing or Development purposes. NEVER for production machine.
// #define DUMMY_THERMISTOR_998_VALUE 25
// #define DUMMY_THERMISTOR_999_VALUE 100
......@@ -228,9 +228,9 @@
#define K1 0.95 // Smoothing factor within the PID
// HotEnd{HE0,HE1,HE2,HE3}
#define DEFAULT_Kp {41,41,41,41} // Kp for E0, E1, E2, E3
#define DEFAULT_Kp {40,40,40,40} // Kp for E0, E1, E2, E3
#define DEFAULT_Ki {07,07,07,07} // Ki for E0, E1, E2, E3
#define DEFAULT_Kd {59,59,59,59} // Kd for E0, E1, E2, E3
#define DEFAULT_Kd {60,60,60,60} // Kd for E0, E1, E2, E3
#endif // PIDTEMP
......@@ -460,6 +460,14 @@ your extruder heater takes 2 minutes to hit the target on heating.
// please keep turned on if you can.
//#define DISABLE_M503
//=================================== 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
#define SD_CFG_SECONDS 10 //seconds between update
#define CFG_SD_FILE "config.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
//========================= Bowden Filament management ======================
//#define EASY_LOAD
#ifdef EASY_LOAD
......
......@@ -14,10 +14,10 @@
*
*/
#define EEPROM_VERSION "V20"
#define EEPROM_VERSION "V21"
/**
* V19 EEPROM Layout:
* V21 EEPROM Layout:
*
* ver
* axis_steps_per_unit (x7)
......@@ -92,7 +92,6 @@
*
* idleoozing_enabled
*
* power_consumption_hour
*
*
*/
......@@ -101,6 +100,7 @@
#include "planner.h"
#include "temperature.h"
#include "ultralcd.h"
#include "cardreader.h"
#include "ConfigurationStore.h"
void _EEPROM_writeData(int &pos, uint8_t* value, uint8_t size) {
......@@ -260,10 +260,6 @@ void Config_StoreSettings() {
EEPROM_WRITE_VAR(i, idleoozing_enabled);
#endif
#if defined(POWER_CONSUMPTION) && defined(STORE_CONSUMPTION)
EEPROM_WRITE_VAR(i, power_consumption_hour);
#endif
char ver2[4] = EEPROM_VERSION;
int j = EEPROM_OFFSET;
EEPROM_WRITE_VAR(j, ver2); // validate data
......@@ -419,10 +415,6 @@ void Config_RetrieveSettings() {
EEPROM_READ_VAR(i, idleoozing_enabled);
#endif
#if defined(POWER_CONSUMPTION) && defined(STORE_CONSUMPTION)
EEPROM_READ_VAR(i, power_consumption_hour);
#endif
// Call updatePID (similar to when we have processed M301)
updatePID();
......@@ -567,14 +559,19 @@ void Config_ResetDefault() {
idleoozing_enabled = true;
#endif
#if defined(POWER_CONSUMPTION) && defined(STORE_CONSUMPTION)
power_consumption_hour = 0;
#endif
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Hardcoded Default Settings Loaded");
}
void ConfigSD_ResetDefault() {
#ifdef POWER_CONSUMPTION
power_consumption_hour = 0;
#endif
printer_usage_seconds = 0;
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Hardcoded SD Default Settings Loaded");
}
#ifndef DISABLE_M503
void Config_PrintSettings(bool forReplay) {
......@@ -868,16 +865,86 @@ void Config_PrintSettings(bool forReplay) {
SERIAL_ECHOLNPGM("Filament settings: Disabled");
}
}
}
#if defined(POWER_CONSUMPTION) && defined(STORE_CONSUMPTION)
SERIAL_ECHO_START;
void ConfigSD_PrintSettings(bool forReplay) {
// Always have this function, even with SD_SETTINGS disabled, the current values will be shown
#ifdef POWER_CONSUMPTION
if (!forReplay) {
SERIAL_ECHOLNPGM("Power consumation:");
SERIAL_ECHOLNPGM("Watt/h consumed:");
SERIAL_ECHO_START;
}
SERIAL_ECHOPAIR(" W/h:", power_consumption_hour);
SERIAL_ECHOPAIR(" W/h", power_consumption_hour);
SERIAL_EOL;
#endif
if (!forReplay) {
SERIAL_ECHOLNPGM("Power on time:");
SERIAL_ECHO_START;
}
SERIAL_ECHOPAIR(" s", printer_usage_seconds);
SERIAL_EOL;
}
#endif //!DISABLE_M503
#if defined(SDSUPPORT) && defined(SD_SETTINGS)
void ConfigSD_StoreSettings() {
if(!IS_SD_INSERTED || card.isFileOpen() || card.sdprinting) return;
card.openFile(CFG_SD_FILE, false, true, false);
char buff[CFG_SD_MAX_VALUE_LEN];
#ifdef POWER_CONSUMPTION
ltoa(power_consumption_hour,buff,10);
card.unparseKeyLine(cfgSD_KEY[SD_CFG_PWR], buff);
#endif
ltoa(printer_usage_seconds,buff,10);
card.unparseKeyLine(cfgSD_KEY[SD_CFG_TME], buff);
card.closeFile(false);
config_last_update = millis();
}
void ConfigSD_RetrieveSettings(bool addValue) {
if(!IS_SD_INSERTED || card.isFileOpen() || card.sdprinting) return;
char key[CFG_SD_MAX_KEY_LEN], value[CFG_SD_MAX_VALUE_LEN];
int k_idx;
int k_len, v_len;
card.openFile(CFG_SD_FILE, true, true, false);
while(true) {
k_len = CFG_SD_MAX_KEY_LEN;
v_len = CFG_SD_MAX_VALUE_LEN;
card.parseKeyLine(key, value, k_len, v_len);
if(k_len == 0 || v_len == 0) break; //no valid key or value founded
k_idx = ConfigSD_KeyIndex(key);
if(k_idx == -1) continue; //unknow key ignore it
switch(k_idx) {
#ifdef POWER_CONSUMPTION
case SD_CFG_PWR: {
if(addValue) power_consumption_hour += (unsigned long)atol(value);
else power_consumption_hour = (unsigned long)atol(value);
}
break;
#endif
case SD_CFG_TME: {
if(addValue) printer_usage_seconds += (unsigned long)atol(value);
else printer_usage_seconds = (unsigned long)atol(value);
}
break;
}
}
card.closeFile(false);
config_readed = true;
config_last_update = millis();
}
int ConfigSD_KeyIndex(char *key) { //At the moment a binary search algorithm is used for simplicity, if it will be necessary (Eg. tons of key), an hash search algorithm will be implemented.
int begin = 0, end = SD_CFG_END - 1, middle, cond;
while(begin <= end) {
middle = (begin + end) / 2;
cond = strcmp(cfgSD_KEY[middle], key);
if(!cond) return middle;
else if(cond < 0) begin = middle + 1;
else end = middle - 1;
}
return -1;
}
#endif
......@@ -4,11 +4,14 @@
#include "Configuration.h"
void Config_ResetDefault();
void ConfigSD_ResetDefault();
#ifndef DISABLE_M503
void Config_PrintSettings(bool forReplay=false);
void ConfigSD_PrintSettings(bool forReplay=false);
#else
FORCE_INLINE void Config_PrintSettings(bool forReplay=false) {}
FORCE_INLINE void ConfigSD_PrintSettings(bool forReplay=false) {}
#endif
#ifdef EEPROM_SETTINGS
......@@ -19,4 +22,27 @@ void Config_ResetDefault();
FORCE_INLINE void Config_RetrieveSettings() { Config_ResetDefault(); Config_PrintSettings(); }
#endif
#if defined(SDSUPPORT) && defined(SD_SETTINGS)
static const char *cfgSD_KEY[] = { //Keep this in lexicographical order for better search performance(O(Nlog2(N)) insted of O(N*N)) (if you don't keep this sorted, the algorithm for find the key index won't work, keep attention.)
#ifdef POWER_CONSUMPTION
"PWR",
#endif
"TME",
};
enum cfgSD_ENUM { //This need to be in the same order as cfgSD_KEY
#ifdef POWER_CONSUMPTION
SD_CFG_PWR,
#endif
SD_CFG_TME,
SD_CFG_END //Leave this always as the last
};
void ConfigSD_StoreSettings();
void ConfigSD_RetrieveSettings(bool addValue = false);
int ConfigSD_KeyIndex(char *key);
#else
FORCE_INLINE void ConfigSD_RetrieveSettings() { ConfigSD_ResetDefault(); ConfigSD_PrintSettings(); }
#endif
#endif //CONFIGURATIONSTORE_H
......@@ -198,9 +198,9 @@
//Manual homing switch locations:
// For SCARA: Offset between HomingPosition and Bed X=0 / Y=0
#ifdef MANUAL_HOME_POSITIONS
#define MANUAL_X_HOME_POS -22
#define MANUAL_Y_HOME_POS -52
#define MANUAL_Z_HOME_POS 0.1 // Distance between nozzle and print surface after homing.
#define MANUAL_X_HOME_POS -22
#define MANUAL_Y_HOME_POS -52
#define MANUAL_Z_HOME_POS 0.1 // Distance between nozzle and print surface after homing.
#endif
// MOVEMENT SETTINGS
......
......@@ -48,13 +48,12 @@
// extruder idle oozing prevention
//if the extruder motor is idle for more than SECONDS, and the temperature over MINTEMP, some filament is retracted. The filament retracted is re-added before the next extrusion
//or when the target temperature is less than EXTRUDE_MINTEMP and the actual temperature is greater than IDLE_OOZING_MINTEMP and less than IDLE_OOZING_FEEDRATE
//or when the target temperature is less than EXTRUDE_MINTEMP.
//#define IDLE_OOZING_PREVENT
#define IDLE_OOZING_MINTEMP EXTRUDE_MINTEMP + 5
#define IDLE_OOZING_MAXTEMP IDLE_OOZING_MINTEMP + 5
#define IDLE_OOZING_MINTEMP EXTRUDE_MINTEMP + 25
#define IDLE_OOZING_FEEDRATE 45 //default feedrate for retracting (mm/s)
#define IDLE_OOZING_SECONDS 10
#define IDLE_OOZING_LENGTH 15 //default retract length (positive mm)
#define IDLE_OOZING_LENGTH 10 //default retract length (positive mm)
#define IDLE_OOZING_RECOVER_LENGTH 0 //default additional recover length (mm, added to retract length when recovering)
#define IDLE_OOZING_RECOVER_FEEDRATE 50 //default feedrate for recovering from retraction (mm/s)
......
......@@ -35,6 +35,10 @@
#define TEST(n,b) (((n)&BIT(b))!=0)
#define RADIANS(d) ((d)*M_PI/180.0)
#define DEGREES(r) ((d)*180.0/M_PI)
#define NOLESS(v,n) do{ if (v < n) v = n; }while(0)
#define NOMORE(v,n) do{ if (v > n) v = n; }while(0)
typedef unsigned long millis_t;
// Arduino < 1.0.0 does not define this, so we need to do it ourselves
#ifndef analogInputToDigitalPin
......@@ -244,14 +248,14 @@ extern bool Running;
inline bool IsRunning() { return Running; }
inline bool IsStopped() { return !Running; }
bool enquecommand(const char *cmd); //put a single ASCII command at the end of the current buffer or return false when it is full
void enquecommands_P(const char *cmd); //put one or many ASCII commands at the end of the current buffer, read from flash
bool enqueuecommand(const char *cmd); //put a single ASCII command at the end of the current buffer or return false when it is full
void enqueuecommands_P(const char *cmd); //put one or many ASCII commands at the end of the current buffer, read from flash
void prepare_arc_move(char isclockwise);
void clamp_to_software_endstops(float target[3]);
extern unsigned long previous_millis_cmd;
inline void refresh_cmd_timeout() { previous_millis_cmd = millis(); }
extern millis_t previous_cmd_ms;
inline void refresh_cmd_timeout() { previous_cmd_ms = millis(); }
#ifdef FAST_PWM_FAN
void setPwmFrequency(uint8_t pin, int val);
......@@ -264,7 +268,7 @@ inline void refresh_cmd_timeout() { previous_millis_cmd = millis(); }
extern float homing_feedrate[];
extern bool axis_relative_modes[];
extern int feedmultiply;
extern int feedrate_multiplier;
extern bool volumetric_enabled;
extern int extruder_multiply[EXTRUDERS]; // sets extrude multiply factor (in percent) for each extruder individually
extern float filament_size[EXTRUDERS]; // cross-sectional area of filament (in millimeters), typically around 1.75 or 2.85, 0 disables the volumetric calculations for the extruder.
......@@ -307,6 +311,8 @@ extern bool axis_known_position[3];
extern float lastpos[4];
extern float zprobe_zoffset;
extern unsigned long printer_usage_seconds; //this can old about 136 year before go overflow. If you belive that you can live more than this please contact me.
#ifdef PREVENT_DANGEROUS_EXTRUDE
extern float extrude_min_temp;
#endif
......@@ -358,8 +364,13 @@ extern int fanSpeed;
extern int laser_ttl_modulation;
#endif
extern unsigned long starttime;
extern unsigned long stoptime;
#if defined(SDSUPPORT) && defined(SD_SETTINGS)
extern unsigned long config_last_update;
extern bool config_readed;
#endif
extern millis_t print_job_start_ms;
extern millis_t print_job_stop_ms;
// Handling multiple extruders pins
extern uint8_t active_extruder;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -25,7 +25,7 @@ CardReader::CardReader() {
OUT_WRITE(SDPOWER, HIGH);
#endif //SDPOWER
autostart_atmillis = millis() + 5000;
next_autostart_ms = millis() + 5000;
}
char *createFilename(char *buffer, const dir_t &p) { //buffer > 12characters
......@@ -189,36 +189,35 @@ void CardReader::getAbsFilename(char *t) {
t[0] = 0;
}
void CardReader::openFile(char* name, bool read, bool replace_current/*=true*/) {
void CardReader::openFile(char* name, bool read, bool replace_current/*=true*/, bool lcd_status/*=true*/) {
if (!cardOK) return;
if (file.isOpen()) { //replacing current file by new file, or subfile call
if (!replace_current) {
if (file_subcall_ctr > SD_PROCEDURE_DEPTH - 1) {
SERIAL_ERROR_START;
SERIAL_ERRORPGM("trying to call sub-gcode files with too many levels. MAX level is:");
SERIAL_ERRORLN(SD_PROCEDURE_DEPTH);
kill();
return;
}
SERIAL_ECHO_START;
SERIAL_ECHOPGM("SUBROUTINE CALL target:\"");
SERIAL_ECHO(name);
SERIAL_ECHOPGM("\" parent:\"");
//store current filename and position
getAbsFilename(filenames[file_subcall_ctr]);
SERIAL_ECHO(filenames[file_subcall_ctr]);
SERIAL_ECHOPGM("\" pos");
SERIAL_ECHOLN(sdpos);
filespos[file_subcall_ctr] = sdpos;
file_subcall_ctr++;
if (file_subcall_ctr > SD_PROCEDURE_DEPTH - 1) {
SERIAL_ERROR_START;
SERIAL_ERRORPGM("trying to call sub-gcode files with too many levels. MAX level is:");
SERIAL_ERRORLN(SD_PROCEDURE_DEPTH);
kill();
return;
}
SERIAL_ECHO_START;
SERIAL_ECHOPGM("SUBROUTINE CALL target:\"");
SERIAL_ECHO(name);
SERIAL_ECHOPGM("\" parent:\"");
//store current filename and position
getAbsFilename(filenames[file_subcall_ctr]);
SERIAL_ECHO(filenames[file_subcall_ctr]);
SERIAL_ECHOPGM("\" pos");
SERIAL_ECHOLN(sdpos);
filespos[file_subcall_ctr] = sdpos;
file_subcall_ctr++;
}
else {
SERIAL_ECHO_START;
SERIAL_ECHOPGM("Now doing file: ");
SERIAL_ECHOLN(name);
SERIAL_ECHO_START;
SERIAL_ECHOPGM("Now doing file: ");
SERIAL_ECHOLN(name);
}
file.close();
}
......@@ -282,7 +281,7 @@ void CardReader::openFile(char* name, bool read, bool replace_current/*=true*/)
SERIAL_PROTOCOLLNPGM(MSG_SD_FILE_SELECTED);
getfilename(0, fname);
lcd_setstatus(longFilename[0] ? longFilename : fname);
if(lcd_status) lcd_setstatus(longFilename[0] ? longFilename : fname);
}
else {
SERIAL_PROTOCOLPGM(MSG_SD_OPEN_FILE_FAIL);
......@@ -291,16 +290,16 @@ void CardReader::openFile(char* name, bool read, bool replace_current/*=true*/)
}
}
else { //write
if (!file.open(curDir, fname, O_CREAT | O_APPEND | O_WRITE | O_TRUNC)) {
SERIAL_PROTOCOLPGM(MSG_SD_OPEN_FILE_FAIL);
SERIAL_PROTOCOL(fname);
SERIAL_PROTOCOLCHAR('.');
}
else {
if (file.open(curDir, fname, O_CREAT | O_APPEND | O_WRITE | O_TRUNC)) {
saving = true;
SERIAL_PROTOCOLPGM(MSG_SD_WRITE_TO_FILE);
SERIAL_PROTOCOLLN(name);
lcd_setstatus(fname);
if(lcd_status) lcd_setstatus(fname);
}
else {
SERIAL_PROTOCOLPGM(MSG_SD_OPEN_FILE_FAIL);
SERIAL_PROTOCOL(fname);
SERIAL_PROTOCOLCHAR('.');
}
}
}
......@@ -397,7 +396,7 @@ void CardReader::write_command(char *buf) {
}
void CardReader::checkautostart(bool force) {
if (!force && (!autostart_stilltocheck || autostart_atmillis < millis()))
if (!force && (!autostart_stilltocheck || next_autostart_ms < millis()))
return;
autostart_stilltocheck = false;
......@@ -421,8 +420,8 @@ void CardReader::checkautostart(bool force) {
if (p.name[9] != '~' && strncmp((char*)p.name, autoname, 5) == 0) {
char cmd[30];
sprintf_P(cmd, PSTR("M23 %s"), autoname);
enquecommand(cmd);
enquecommands_P(PSTR("M24"));
enqueuecommand(cmd);
enqueuecommands_P(PSTR("M24"));
found = true;
}
}
......@@ -432,7 +431,7 @@ void CardReader::checkautostart(bool force) {
autostart_index++;
}
void CardReader::closefile(bool store_location) {
void CardReader::closeFile(bool store_location) {
file.sync();
file.close();
saving = logging = false;
......@@ -443,6 +442,94 @@ void CardReader::closefile(bool store_location) {
}
}
void CardReader::parseKeyLine(char *key, char *value, int &len_k, int &len_v) {
if (!cardOK || !isFileOpen()) return;
int ln_buf = 0;
char ln_char;
bool ln_space = false, ln_ignore = false, key_found = false;
while(!eof()) { //READ KEY
ln_char = (char)get();
if(ln_char == '\n') {
ln_buf = 0;
ln_ignore = false; //We've reached a new line try to find a key again
continue;
}
if(ln_ignore) continue;
if(ln_char == ' ') {
ln_space = true;
continue;
}
if(ln_char == '=') {
key[ln_buf] = '\0';
len_k = ln_buf;
key_found = true;
break; //key finded and buffered
}
if(ln_char == ';' || ln_buf+1 >= len_k || ln_space && ln_buf > 0) { //comments on key is not allowd. Also key len can't be longer than len_k or contain spaces. Stop buffering and try the next line
ln_ignore = true;
continue;
}
ln_space = false;
key[ln_buf] = ln_char;
ln_buf++;
}
if(!key_found) { //definitly there isn't no more key that can be readed in the file
key[0] = '\0';
value[0] = '\0';
len_k = 0;
len_v = 0;
return;
}
ln_buf = 0;
ln_ignore = false;
while(!eof()) { //READ VALUE
ln_char = (char)get();
if(ln_char == '\n') {
value[ln_buf] = '\0';
len_v = ln_buf;
break; //new line reached, we can stop
}
if(ln_ignore|| ln_char == ' ' && ln_buf == 0) continue; //ignore also initial spaces of the value
if(ln_char == ';' || ln_buf+1 >= len_v) { //comments reached or value len longer than len_v. Stop buffering and go to the next line.
ln_ignore = true;
continue;
}
value[ln_buf] = ln_char;
ln_buf++;
}
}
void CardReader::unparseKeyLine(const char *key, char *value) {
if (!cardOK || !isFileOpen()) return;
file.writeError = false;
file.write(key);
if (file.writeError) {
SERIAL_ERROR_START;
SERIAL_ERRORLNPGM(MSG_SD_ERR_WRITE_TO_FILE);
return;
}
file.writeError = false;
file.write("=");
if (file.writeError) {
SERIAL_ERROR_START;
SERIAL_ERRORLNPGM(MSG_SD_ERR_WRITE_TO_FILE);
return;
}
file.writeError = false;
file.write(value);
if (file.writeError) {
SERIAL_ERROR_START;
SERIAL_ERRORLNPGM(MSG_SD_ERR_WRITE_TO_FILE);
return;
}
file.writeError = false;
file.write("\n");
if (file.writeError) {
SERIAL_ERROR_START;
SERIAL_ERRORLNPGM(MSG_SD_ERR_WRITE_TO_FILE);
}
}
/**
* Get the name of a file in the current directory by index
*/
......@@ -508,7 +595,7 @@ void CardReader::printingHasFinished() {
sdprinting = false;
if (SD_FINISHED_STEPPERRELEASE) {
//finishAndDisableSteppers();
enquecommands_P(PSTR(SD_FINISHED_RELEASECOMMAND));
enqueuecommands_P(PSTR(SD_FINISHED_RELEASECOMMAND));
}
autotempShutdown();
}
......
......@@ -18,10 +18,12 @@ public:
//this is to delay autostart and hence the initialisaiton of the sd card to some seconds after the normal init, so the device is available quick after a reset
void checkautostart(bool x);
void openFile(char* name,bool read,bool replace_current=true);
void openFile(char* name,bool read,bool replace_current=true, bool lcd_status=true);
void openLogFile(char* name);
void removeFile(char* name);
void closefile(bool store_location=false);
void closeFile(bool store_location=false);
void parseKeyLine(char *key, char *value, int &len_k, int &len_v);
void unparseKeyLine(const char *key, char *value);
void release();
void startFileprint();
void pauseSDPrint();
......@@ -62,7 +64,7 @@ private:
uint32_t filespos[SD_PROCEDURE_DEPTH];
char filenames[SD_PROCEDURE_DEPTH][MAXPATHNAMELENGTH];
uint32_t filesize;
unsigned long autostart_atmillis;
millis_t next_autostart_ms;
uint32_t sdpos;
bool autostart_stilltocheck; //the sd start is delayed, because otherwise the serial cannot answer fast enought to make contact with the hostsoftware.
......
......@@ -186,11 +186,11 @@ static void lcd_implementation_init() {
// digitalWrite(17, HIGH);
#ifdef LCD_SCREEN_ROT_90
u8g.setRot90(); // Rotate screen by 90
u8g.setRot90(); // Rotate screen by 90°
#elif defined(LCD_SCREEN_ROT_180)
u8g.setRot180(); // Rotate screen by 180
u8g.setRot180(); // Rotate screen by 180°
#elif defined(LCD_SCREEN_ROT_270)
u8g.setRot270(); // Rotate screen by 270
u8g.setRot270(); // Rotate screen by 270°
#endif
// Show splashscreen
......@@ -269,23 +269,23 @@ static void lcd_implementation_status_screen() {
}
u8g.setPrintPos(80,48);
if (starttime != 0) {
if (print_job_start_ms != 0) {
#if HAS_LCD_POWER_SENSOR
if (millis() < print_millis + 1000) {
uint16_t time = (millis() - starttime) / 60000;
lcd_print(itostr2(time/60));
uint16_t time = (millis() - print_job_start_ms) / 60000;
lcd_print(itostr2(time / 60));
lcd_print(':');
lcd_print(itostr2(time%60));
lcd_print(itostr2(time % 60));
}
else {
lcd_print(itostr4(power_consumption_hour-startpower));
lcd_print('Wh');
}
#else
uint16_t time = (millis() - starttime) / 60000;
lcd_print(itostr2(time/60));
uint16_t time = (millis() - print_job_start_ms) / 60000;
lcd_print(itostr2(time / 60));
lcd_print(':');
lcd_print(itostr2(time%60));
lcd_print(itostr2(time % 60));
#endif
}
else {
......@@ -350,7 +350,7 @@ static void lcd_implementation_status_screen() {
lcd_print(LCD_STR_FEEDRATE[0]);
lcd_setFont(FONT_STATUSMENU);
u8g.setPrintPos(12,49);
lcd_print(itostr3(feedmultiply));
lcd_print(itostr3(feedrate_multiplier));
lcd_print('%');
// Status line
......@@ -362,12 +362,12 @@ static void lcd_implementation_status_screen() {
#endif
#if HAS_LCD_FILAMENT_SENSOR || HAS_LCD_POWER_SENSOR
if (millis() < message_millis + 5000) { //Display both Status message line and Filament display on the last line
if (millis() < previous_lcd_status_ms + 5000) { //Display both Status message line and Filament display on the last line
lcd_print(lcd_status_message);
}
#if HAS_LCD_POWER_SENSOR
#if HAS_LCD_FILAMENT_SENSOR
else if (millis() < message_millis + 10000)
else if (millis() < previous_lcd_status_ms + 10000)
#else
else
#endif
......
......@@ -59,6 +59,10 @@
#define MACHINE_NAME CUSTOM_MENDEL_NAME
#endif
#ifndef BUILD_VERSION
#define BUILD_VERSION "V4;"
#endif
#ifndef MACHINE_UUID
#define MACHINE_UUID "00000000-0000-0000-0000-000000000000"
#endif
......@@ -77,7 +81,7 @@
// Serial Console Messages (do not translate those!)
#define MSG_Enqueing "enqueing \""
#define MSG_Enqueueing "enqueueing \""
#define MSG_POWERUP "PowerUp"
#define MSG_EXTERNAL_RESET " External Reset"
#define MSG_BROWNOUT_RESET " Brown out Reset"
......@@ -86,8 +90,9 @@
#define MSG_AUTHOR " | Author: "
#define MSG_CONFIGURATION_VER " Last Updated: "
#define MSG_FREE_MEMORY " Free Memory: "
#define MSG_PLANNER_BUFFER_BYTES " PlannerBufferBytes: "
#define MSG_PLANNER_BUFFER_BYTES " PlannerBufferBytes: "
#define MSG_OK "ok"
#define MSG_WAIT "wait"
#define MSG_FILE_SAVED "Done saving file."
#define MSG_ERR_LINE_NO "Line Number is not Last Line Number+1, Last Line: "
#define MSG_ERR_CHECKSUM_MISMATCH "checksum mismatch, Last Line: "
......@@ -107,7 +112,7 @@
#define MSG_HEATING_COMPLETE "Heating done."
#define MSG_BED_HEATING "Bed Heating."
#define MSG_BED_DONE "Bed done."
#define MSG_M115_REPORT "FIRMWARE_NAME:MarlinKimbra V4; FIRMWARE_URL:" FIRMWARE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:" MACHINE_NAME " EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " UUID:" MACHINE_UUID "\n"
#define MSG_M115_REPORT "FIRMWARE_NAME:MarlinKimbra " BUILD_VERSION " FIRMWARE_URL:" FIRMWARE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:" MACHINE_NAME " EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " UUID:" MACHINE_UUID "\n"
#define MSG_COUNT_X " Count X: "
#define MSG_ERR_KILLED "Printer halted. kill() called!"
#define MSG_ERR_STOPPED "Printer stopped due to errors. Fix the error and use M999 to restart. (Temperature is reset. Set it after restarting)"
......
......@@ -62,7 +62,7 @@
//============================= public variables ============================
//===========================================================================
unsigned long minsegmenttime;
millis_t minsegmenttime;
float max_feedrate[3 + EXTRUDERS]; // Max speeds in mm per minute
float max_retraction_feedrate[EXTRUDERS]; // set the max speeds for retraction
float axis_steps_per_unit[3 + EXTRUDERS];
......@@ -156,8 +156,8 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi
unsigned long final_rate = ceil(block->nominal_rate * exit_factor); // (step/min)
// Limit minimal step rate (Otherwise the timer will overflow.)
if (initial_rate < 120) initial_rate = 120;
if (final_rate < 120) final_rate = 120;
NOLESS(initial_rate, 120);
NOLESS(final_rate, 120);
long acceleration = block->acceleration_st;
int32_t accelerate_steps = ceil(estimate_acceleration_distance(initial_rate, block->nominal_rate, acceleration));
......@@ -378,16 +378,18 @@ void plan_init() {
}
float t = autotemp_min + high * autotemp_factor;
if (t < autotemp_min) t = autotemp_min;
if (t > autotemp_max) t = autotemp_max;
if (oldt > t) t = AUTOTEMP_OLDWEIGHT * oldt + (1 - AUTOTEMP_OLDWEIGHT) * t;
t = constrain(t, autotemp_min, autotemp_max);
if (oldt > t) {
t *= (1 - AUTOTEMP_OLDWEIGHT);
t += AUTOTEMP_OLDWEIGHT * oldt;
}
oldt = t;
setTargetHotend0(t);
}
#endif
void check_axes_activity() {
unsigned char axis_active[NUM_AXIS],
unsigned char axis_active[NUM_AXIS] = { 0 },
tail_fan_speed = fanSpeed;
#ifdef BARICUDA
unsigned char tail_valve_pressure = ValvePressure,
......@@ -428,7 +430,7 @@ void check_axes_activity() {
#if HAS_FAN
#ifdef FAN_KICKSTART_TIME
static unsigned long fan_kick_end;
static millis_t fan_kick_end;
if (tail_fan_speed) {
if (fan_kick_end == 0) {
// Just starting up fan - run at full power.
......@@ -500,7 +502,7 @@ float junction_deviation = 0.1;
target[X_AXIS] = lround(x * axis_steps_per_unit[X_AXIS]);
target[Y_AXIS] = lround(y * axis_steps_per_unit[Y_AXIS]);
target[Z_AXIS] = lround(z * axis_steps_per_unit[Z_AXIS]);
target[E_AXIS] = lround(e * axis_steps_per_unit[E_AXIS + extruder]);
target[E_AXIS] = lround(e * axis_steps_per_unit[E_AXIS + active_extruder]);
float dx = target[X_AXIS] - position[X_AXIS],
dy = target[Y_AXIS] - position[Y_AXIS],
......@@ -693,7 +695,11 @@ float junction_deviation = 0.1;
#endif //!MKR4 && !NPR2
if (feed_rate < minimumfeedrate) feed_rate = minimumfeedrate;
}
else if (feed_rate < mintravelfeedrate) feed_rate = mintravelfeedrate;
if (block->steps[E_AXIS])
NOLESS(feed_rate, minimumfeedrate);
else
NOLESS(feed_rate, mintravelfeedrate);
/**
* This part of the code calculates the total length of the movement.
......
......@@ -114,7 +114,7 @@ FORCE_INLINE uint8_t movesplanned() { return BLOCK_MOD(block_buffer_head - block
void plan_set_e_position(const float &e);
extern unsigned long minsegmenttime;
extern millis_t minsegmenttime;
extern float max_feedrate[3 + EXTRUDERS]; // set the max speeds
extern float max_retraction_feedrate[EXTRUDERS]; // set the max speeds for retraction
extern float axis_steps_per_unit[3 + EXTRUDERS];
......
......@@ -54,7 +54,7 @@ static unsigned int cleaning_buffer_counter;
locked_z2_motor = false;
#endif
// Counter variables for the bresenham line tracer
// Counter variables for the Bresenham line tracer
static long counter_x, counter_y, counter_z, counter_e;
volatile static unsigned long step_events_completed; // The number of step events executed in the current block
......@@ -66,7 +66,7 @@ volatile static unsigned long step_events_completed; // The number of step event
static long acceleration_time, deceleration_time;
//static unsigned long accelerate_until, decelerate_after, acceleration_rate, initial_rate, final_rate, nominal_rate;
static unsigned short acc_step_rate; // needed for deccelaration start point
static unsigned short acc_step_rate; // needed for deceleration start point
static char step_loops;
static unsigned short OCR1A_nominal;
static unsigned short step_loops_nominal;
......@@ -210,8 +210,14 @@ volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1 };
// intRes = longIn1 * longIn2 >> 24
// uses:
// r26 to store 0
// r27 to store the byte 1 of the 48bit result
#define MultiU24X24toH16(intRes, longIn1, longIn2) \
// r27 to store bits 16-23 of the 48bit result. The top bit is used to round the two byte result.
// note that the lower two bytes and the upper byte of the 48bit result are not calculated.
// this can cause the result to be out by one as the lower bytes may cause carries into the upper ones.
// B0 A0 are bits 24-39 and are the returned value
// C1 B1 A1 is longIn1
// D2 C2 B2 A2 is longIn2
//
#define MultiU24X32toH16(intRes, longIn1, longIn2) \
asm volatile ( \
"clr r26 \n\t" \
"mul %A1, %B2 \n\t" \
......@@ -242,6 +248,11 @@ volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1 };
"lsr r27 \n\t" \
"adc %A0, r26 \n\t" \
"adc %B0, r26 \n\t" \
"mul %D2, %A1 \n\t" \
"add %A0, r0 \n\t" \
"adc %B0, r1 \n\t" \
"mul %D2, %B1 \n\t" \
"add %B0, r0 \n\t" \
"clr r1 \n\t" \
: \
"=&r" (intRes) \
......@@ -297,7 +308,7 @@ void checkHitEndstops() {
#if defined(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) && defined(SDSUPPORT)
if (abort_on_endstop_hit) {
card.sdprinting = false;
card.closefile();
card.closeFile();
quickStop();
setTargetHotend0(0);
setTargetHotend1(0);
......@@ -343,7 +354,7 @@ void checkHitEndstops() {
#if defined(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) && defined(SDSUPPORT)
if (abort_on_endstop_hit) {
card.sdprinting = false;
card.closefile();
card.closeFile();
quickStop();
setTargetHotend0(0);
setTargetHotend1(0);
......@@ -372,7 +383,7 @@ void enable_endstops(bool check) { check_endstops = check; }
// The trapezoid is the shape the speed curve over time. It starts at block->initial_rate, accelerates
// first block->accelerate_until step_events_completed, then keeps going at constant speed until
// step_events_completed reaches block->decelerate_after after which it decelerates until the trapezoid generator is reset.
// The slope of acceleration is calculated with the lib ramp algorithm.
// The slope of acceleration is calculated using v = u + at where t is the accumulated timer values of the steps so far.
void st_wake_up() {
// TCNT1 = 0;
......@@ -453,7 +464,7 @@ ISR(TIMER1_COMPA_vect) {
current_block = NULL;
plan_discard_current_block();
#ifdef SD_FINISHED_RELEASECOMMAND
if ((cleaning_buffer_counter == 1) && (SD_FINISHED_STEPPERRELEASE)) enquecommands_P(PSTR(SD_FINISHED_RELEASECOMMAND));
if ((cleaning_buffer_counter == 1) && (SD_FINISHED_STEPPERRELEASE)) enqueuecommands_P(PSTR(SD_FINISHED_RELEASECOMMAND));
#endif
cleaning_buffer_counter--;
OCR1A = 200;
......@@ -528,7 +539,7 @@ ISR(TIMER1_COMPA_vect) {
if ((current_block->steps[A_AXIS] != current_block->steps[B_AXIS]) || (TEST(out_bits, A_AXIS) == TEST(out_bits, B_AXIS))) {
if (TEST(out_bits, X_HEAD))
#else
if (TEST(out_bits, X_AXIS)) // stepping along -X axis (regular cartesians bot)
if (TEST(out_bits, X_AXIS)) // stepping along -X axis (regular Cartesian bot)
#endif
{ // -direction
#ifdef DUAL_X_CARRIAGE
......@@ -772,9 +783,9 @@ ISR(TIMER1_COMPA_vect) {
// Calculate new timer value
unsigned short timer;
unsigned short step_rate;
if (step_events_completed <= (unsigned long int)current_block->accelerate_until) {
if (step_events_completed <= (unsigned long)current_block->accelerate_until) {
MultiU24X24toH16(acc_step_rate, acceleration_time, current_block->acceleration_rate);
MultiU24X32toH16(acc_step_rate, acceleration_time, current_block->acceleration_rate);
acc_step_rate += current_block->initial_rate;
// upper limit
......@@ -796,8 +807,8 @@ ISR(TIMER1_COMPA_vect) {
#endif
}
else if (step_events_completed > (unsigned long int)current_block->decelerate_after) {
MultiU24X24toH16(step_rate, deceleration_time, current_block->acceleration_rate);
else if (step_events_completed > (unsigned long)current_block->decelerate_after) {
MultiU24X32toH16(step_rate, deceleration_time, current_block->acceleration_rate);
if (step_rate > acc_step_rate) { // Check step_rate stays positive
step_rate = current_block->final_rate;
......@@ -1236,7 +1247,7 @@ void quickStop() {
uint8_t old_pin = AXIS ##_DIR_READ; \
AXIS ##_APPLY_DIR(INVERT_## AXIS ##_DIR^direction^INVERT, true); \
AXIS ##_APPLY_STEP(!INVERT_## AXIS ##_STEP_PIN, true); \
_delay_us(1U); \
delayMicroseconds(2); \
AXIS ##_APPLY_STEP(INVERT_## AXIS ##_STEP_PIN, true); \
AXIS ##_APPLY_DIR(old_pin, true); \
}
......@@ -1275,7 +1286,7 @@ void quickStop() {
X_STEP_WRITE(!INVERT_X_STEP_PIN);
Y_STEP_WRITE(!INVERT_Y_STEP_PIN);
Z_STEP_WRITE(!INVERT_Z_STEP_PIN);
_delay_us(1U);
delayMicroseconds(2);
X_STEP_WRITE(INVERT_X_STEP_PIN);
Y_STEP_WRITE(INVERT_Y_STEP_PIN);
Z_STEP_WRITE(INVERT_Z_STEP_PIN);
......
......@@ -109,7 +109,7 @@ void microstep_readings();
#ifdef BABYSTEPPING
void babystep(const uint8_t axis,const bool direction); // perform a short step with a single stepper motor, outside of any convention
#endif //BABYSTEPPING
#endif
#ifdef NPR2 //Multiextruder
void colorstep(long csteps,const bool direction);
......
This diff is collapsed.
......@@ -23,6 +23,7 @@
#include "Marlin.h"
#include "planner.h"
#include "stepper.h"
// public functions
void tp_init(); //initialize the heating
......@@ -133,7 +134,7 @@ HOTEND_ROUTINES(0);
#endif
int getHeaterPower(int heater);
void disable_heater();
void disable_all_heaters();
void setWatch();
void updatePID();
......
This diff is collapsed.
......@@ -57,10 +57,11 @@
extern bool cancel_heatup;
#if (HAS_FILAMENT_SENSOR && defined(FILAMENT_LCD_DISPLAY)) || (HAS_POWER_CONSUMPTION_SENSOR && defined(POWER_CONSUMPTION_LCD_DISPLAY))
extern unsigned long message_millis;
extern millis_t previous_lcd_status_ms;
#endif
void lcd_buzz(long duration,uint16_t freq);
void lcd_quick_feedback(); // Audible feedback for a button click - could also be visual
bool lcd_clicked();
void lcd_ignore_click(bool b=true);
......
......@@ -582,7 +582,7 @@ static void lcd_implementation_status_screen() {
lcd.setCursor(0, 2);
lcd.print(LCD_STR_FEEDRATE[0]);
lcd.print(itostr3(feedmultiply));
lcd.print(itostr3(feedrate_multiplier));
lcd.print('%');
#if LCD_WIDTH > 19 && defined(SDSUPPORT)
......@@ -598,11 +598,11 @@ static void lcd_implementation_status_screen() {
#endif // LCD_WIDTH > 19 && SDSUPPORT
lcd.setCursor(LCD_WIDTH - 6, 2);
if(starttime != 0) {
if(print_job_start_ms != 0) {
#if HAS_LCD_POWER_SENSOR
if (millis() < print_millis + 1000) {
lcd.print(LCD_STR_CLOCK[0]);
uint16_t time = millis()/60000 - starttime/60000;
uint16_t time = millis()/60000 - print_job_start_ms/60000;
lcd.print(itostr2(time/60));
lcd.print(':');
lcd.print(itostr2(time%60));
......@@ -613,7 +613,7 @@ static void lcd_implementation_status_screen() {
}
#else
lcd.print(LCD_STR_CLOCK[0]);
uint16_t time = millis()/60000 - starttime/60000;
uint16_t time = millis()/60000 - print_job_start_ms/60000;
lcd.print(itostr2(time/60));
lcd.print(':');
lcd.print(itostr2(time%60));
......@@ -656,12 +656,12 @@ static void lcd_implementation_status_screen() {
//Display both Status message line and Filament display on the last line
#if HAS_LCD_FILAMENT_SENSOR || HAS_LCD_POWER_SENSOR
if (millis() < message_millis + 5000) { //Display both Status message line and Filament display on the last line
if (millis() >= previous_lcd_status_ms + 5000) {
lcd_print(lcd_status_message);
}
#if HAS_LCD_POWER_SENSOR
#if HAS_LCD_FILAMENT_SENSOR
else if (millis() < message_millis + 10000)
else if (millis() < previous_lcd_status_ms + 10000)
#else
else
#endif
......@@ -788,46 +788,45 @@ static void lcd_implementation_drawmenu_sddirectory(bool sel, uint8_t row, const
#define lcd_implementation_drawmenu_function(sel, row, pstr, data) lcd_implementation_drawmenu_generic(sel, row, pstr, '>', ' ')
#ifdef LCD_HAS_STATUS_INDICATORS
static void lcd_implementation_update_indicators()
{
#if defined(LCD_I2C_PANELOLU2) || defined(LCD_I2C_VIKI)
//set the LEDS - referred to as backlights by the LiquidTWI2 library
static uint8_t ledsprev = 0;
uint8_t leds = 0;
if (target_temperature_bed > 0) leds |= LED_A;
if (target_temperature[0] > 0) leds |= LED_B;
if (fanSpeed) leds |= LED_C;
#if HOTENDS > 1
if (target_temperature[1] > 0) leds |= LED_C;
static void lcd_implementation_update_indicators() {
#if defined(LCD_I2C_PANELOLU2) || defined(LCD_I2C_VIKI)
//set the LEDS - referred to as backlights by the LiquidTWI2 library
static uint8_t ledsprev = 0;
uint8_t leds = 0;
if (target_temperature_bed > 0) leds |= LED_A;
if (target_temperature[0] > 0) leds |= LED_B;
if (fanSpeed) leds |= LED_C;
#if HOTENDS > 1
if (target_temperature[1] > 0) leds |= LED_C;
#endif
if (leds != ledsprev) {
lcd.setBacklight(leds);
ledsprev = leds;
}
#endif
if (leds != ledsprev) {
lcd.setBacklight(leds);
ledsprev = leds;
}
#endif
}
#endif
}
#endif // LCD_HAS_STATUS_INDICATORS
#ifdef LCD_HAS_SLOW_BUTTONS
extern uint32_t blocking_enc;
static uint8_t lcd_implementation_read_slow_buttons()
{
#ifdef LCD_I2C_TYPE_MCP23017
uint8_t slow_buttons;
// Reading these buttons this is likely to be too slow to call inside interrupt context
// so they are called during normal lcd_update
slow_buttons = lcd.readButtons() << B_I2C_BTN_OFFSET;
#if defined(LCD_I2C_VIKI)
if(slow_buttons & (B_MI|B_RI)) { //LCD clicked
if(blocking_enc > millis()) {
slow_buttons &= ~(B_MI|B_RI); // Disable LCD clicked buttons if screen is updated
}
}
extern millis_t next_button_update_ms;
static uint8_t lcd_implementation_read_slow_buttons() {
#ifdef LCD_I2C_TYPE_MCP23017
uint8_t slow_buttons;
// Reading these buttons this is likely to be too slow to call inside interrupt context
// so they are called during normal lcd_update
slow_buttons = lcd.readButtons() << B_I2C_BTN_OFFSET;
#ifdef LCD_I2C_VIKI
if ((slow_buttons & (B_MI|B_RI)) && millis() < next_button_update_ms) // LCD clicked
slow_buttons &= ~(B_MI|B_RI); // Disable LCD clicked buttons if screen is updated
#endif
return slow_buttons;
#endif
return slow_buttons;
#endif
}
#endif
}
#endif // LCD_HAS_SLOW_BUTTONS
#endif //__ULTRALCD_IMPLEMENTATION_HITACHI_HD44780_H
......@@ -39,9 +39,10 @@ The current MarlinKimbra dev team consists of:
More features have been added by:
-
- simone97 (https://github.com/simone97)
-
## License
Marlin is published under the [GPL license](/Documentation/COPYING.md) because I believe in open development.
Please do not use this code in products (3D printers, CNC etc) that are closed source or are crippled by a patent.
\ No newline at end of file
Please do not use this code in products (3D printers, CNC etc) that are closed source or are crippled by a patent.
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