Commit 449d646b authored by MagoKimbra's avatar MagoKimbra

New Update

parent 5d4c2d2b
/**
* Comunication.h - serial messages functions
* Part of Marlin
*
* Author: Simone Primarosa
*/
#ifndef COMUNICATION_H
#define COMUNICATION_H
#ifdef AT90USB
#include "HardwareSerial.h"
#endif
#ifndef __SAM3X8E__
#include "MarlinSerial.h"
#endif
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif
#include "WString.h"
#ifdef AT90USB
#ifdef BTENABLED
#define MYSERIAL bt
#else
#define MYSERIAL Serial
#endif // BTENABLED
#else
#ifdef __SAM3X8E__
#define MYSERIAL Serial
#else
#define MYSERIAL MSerial
#endif
#endif
#define START "start" //start for host
#define OK "ok " //ok answer for host
#define ER "Error:" //error for host
#define DB "echo: " //message for user
#define RS "Resend:" //resend for host
#define PAUSE "//action:pause" //command for host that support action
#define RESUME "//action:resume" //command for host that support action
#define DISCONNECT "//action:disconnect" //command for host that support action
#define SERIAL_INIT(baud) MYSERIAL.begin(baud), delay(1)
#define SERIAL_WRITE(x) MYSERIAL.write(x)
#define SERIAL_PRINT(msg, args...) MYSERIAL.print(msg, ##args)
#define SERIAL_ENDL MYSERIAL.println()
FORCE_INLINE void PS_PGM(const char *str) {
char ch;
while ((ch = pgm_read_byte(str++))) { SERIAL_WRITE(ch); }
}
#define ECHO_ENDL SERIAL_ENDL
#define ECHO_PGM(message) PS_PGM(PSTR(message))
#define ECHO_MV(msg, val, args...) ECHO_PGM(msg),ECHO_V(val, ##args)
#define ECHO_VM(val, msg, args...) ECHO_V(val, ##args),ECHO_PGM(msg)
#define ECHO_M(msg) ECHO_PGM(msg)
#define ECHO_V SERIAL_PRINT
#define ECHO_C SERIAL_WRITE
#define ECHO_S(srt) ECHO_PGM(srt)
#define ECHO_E ECHO_ENDL
#define ECHO_SM(srt, msg) ECHO_S(srt),ECHO_M(msg)
#define ECHO_SV(srt, val, args...) ECHO_S(srt),ECHO_V(val, ##args)
#define ECHO_SMV(srt, msg, val, args...) ECHO_S(srt),ECHO_MV(msg, val, ##args)
#define ECHO_SVM(srt, val, msg, args...) ECHO_S(srt),ECHO_VM(val, msg, ##args)
#define ECHO_EM(msg) ECHO_M(msg),ECHO_E
#define ECHO_EV(val, args...) ECHO_V(val, ##args),ECHO_E
#define ECHO_EMV(msg, val, args...) ECHO_MV(msg, val, ##args),ECHO_E
#define ECHO_EVM(val, msg, args...) ECHO_VM(val, msg, ##args),ECHO_E
#define ECHO_LM(srt, msg) ECHO_S(srt),ECHO_M(msg),ECHO_E
#define ECHO_LV(srt, val) ECHO_S(srt),ECHO_V(val),ECHO_E
#define ECHO_LMV(srt, msg, val, args...) ECHO_S(srt),ECHO_MV(msg, val, ##args),ECHO_E
#define ECHO_LVM(srt, val, msg, args...) ECHO_S(srt),ECHO_VM(val, msg, ##args),ECHO_E
#endif
This diff is collapsed.
...@@ -20,11 +20,7 @@ ...@@ -20,11 +20,7 @@
// User-specified version info of this build to display in [Pronterface, etc] terminal window during // 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 // 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. // build by the user have been successfully uploaded into firmware.
<<<<<<< HEAD
#define STRING_VERSION " 4.1.1"
=======
#define STRING_VERSION "4.1.2" #define STRING_VERSION "4.1.2"
>>>>>>> origin/master
#define STRING_URL "reprap.org" #define STRING_URL "reprap.org"
#define STRING_VERSION_CONFIG_H __DATE__ " " __TIME__ // build date and time #define STRING_VERSION_CONFIG_H __DATE__ " " __TIME__ // build date and time
#define STRING_CONFIG_H_AUTHOR "(none, default config)" // Who made the changes. #define STRING_CONFIG_H_AUTHOR "(none, default config)" // Who made the changes.
...@@ -228,16 +224,10 @@ ...@@ -228,16 +224,10 @@
#define K1 0.95 // Smoothing factor within the PID #define K1 0.95 // Smoothing factor within the PID
// HotEnd{HE0,HE1,HE2,HE3} // HotEnd{HE0,HE1,HE2,HE3}
<<<<<<< HEAD
#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 {60,60,60,60} // Kd for E0, E1, E2, E3
=======
#define DEFAULT_Kp {40, 40, 40, 40} // 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_Ki {07, 07, 07, 07} // Ki for E0, E1, E2, E3
#define DEFAULT_Kd {60, 60, 60, 60} // Kd for E0, E1, E2, E3 #define DEFAULT_Kd {60, 60, 60, 60} // Kd for E0, E1, E2, E3
//=========================================================================== //===========================================================================
>>>>>>> origin/master
//=========================================================================== //===========================================================================
...@@ -455,38 +445,14 @@ your extruder heater takes 2 minutes to hit the target on heating. ...@@ -455,38 +445,14 @@ your extruder heater takes 2 minutes to hit the target on heating.
// M502 - reverts to the default "factory settings". You still need to store them in EEPROM afterwards if you want to. // M502 - reverts to the default "factory settings". You still need to store them in EEPROM afterwards if you want to.
//define this to enable EEPROM support //define this to enable EEPROM support
//#define EEPROM_SETTINGS //#define EEPROM_SETTINGS
#define EEPROM_CHITCHAT //#define EEPROM_CHITCHAT
// to disable EEPROM Serial responses and decrease program space by ~1700 byte: comment this out: // to disable EEPROM Serial responses and decrease program space by ~1700 byte: comment this out:
// please keep turned on if you can. // please keep turned on if you can.
//#define DISABLE_M503 //#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 60 //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
//===========================================================================
<<<<<<< HEAD
//=================================== 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 ======================
=======
//==================== Bowden Filament management =========================== //==================== Bowden Filament management ===========================
>>>>>>> origin/master
//#define EASY_LOAD //#define EASY_LOAD
#define BOWDEN_LENGTH 250 // mm #define BOWDEN_LENGTH 250 // mm
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#ifndef CONFIGURATION_ADV_H #ifndef CONFIGURATION_ADV_H
#define CONFIGURATION_ADV_H #define CONFIGURATION_ADV_H
#include "Conditionals.h" #include "conditionals.h"
//=========================================================================== //===========================================================================
//=============================Thermal Settings ============================ //=============================Thermal Settings ============================
...@@ -46,22 +46,17 @@ ...@@ -46,22 +46,17 @@
//The M105 command return, besides traditional information, the ADC value read from temperature sensors. //The M105 command return, besides traditional information, the ADC value read from temperature sensors.
//#define SHOW_TEMP_ADC_VALUES //#define SHOW_TEMP_ADC_VALUES
<<<<<<< HEAD
// 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.
=======
//extruder idle oozing prevention //extruder idle oozing prevention
//if the extruder motor is idle for more than SECONDS, and the temperature over MINTEMP, //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 //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 //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 //is greater than IDLE_OOZING_MINTEMP and less than IDLE_OOZING_FEEDRATE
>>>>>>> origin/master
//#define IDLE_OOZING_PREVENT //#define IDLE_OOZING_PREVENT
#define IDLE_OOZING_MINTEMP EXTRUDE_MINTEMP + 25 #define IDLE_OOZING_MINTEMP EXTRUDE_MINTEMP + 5
#define IDLE_OOZING_MAXTEMP IDLE_OOZING_MINTEMP + 5
#define IDLE_OOZING_FEEDRATE 45 //default feedrate for retracting (mm/s) #define IDLE_OOZING_FEEDRATE 45 //default feedrate for retracting (mm/s)
#define IDLE_OOZING_SECONDS 10 #define IDLE_OOZING_SECONDS 10
#define IDLE_OOZING_LENGTH 10 //default retract length (positive mm) #define IDLE_OOZING_LENGTH 15 //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_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) #define IDLE_OOZING_RECOVER_FEEDRATE 50 //default feedrate for recovering from retraction (mm/s)
...@@ -526,7 +521,7 @@ const unsigned int dropsegments=5; //everything with less than this number of st ...@@ -526,7 +521,7 @@ const unsigned int dropsegments=5; //everything with less than this number of st
#endif #endif
#include "Conditionals.h" #include "conditionals.h"
#include "SanityCheck.h" #include "sanitycheck.h"
#endif //CONFIGURATION_ADV_H #endif //CONFIGURATION_ADV_H
...@@ -267,8 +267,8 @@ endif ...@@ -267,8 +267,8 @@ endif
CXXSRC = WMath.cpp WString.cpp Print.cpp Marlin_main.cpp \ CXXSRC = WMath.cpp WString.cpp Print.cpp Marlin_main.cpp \
MarlinSerial.cpp Sd2Card.cpp SdBaseFile.cpp SdFatUtil.cpp \ MarlinSerial.cpp Sd2Card.cpp SdBaseFile.cpp SdFatUtil.cpp \
SdFile.cpp SdVolume.cpp motion_control.cpp planner.cpp \ SdFile.cpp SdVolume.cpp motion_control.cpp planner.cpp \
stepper.cpp temperature.cpp cardreader.cpp ConfigurationStore.cpp \ stepper.cpp temperature.cpp cardreader.cpp configuration_store.cpp \
watchdog.cpp SPI.cpp Servo.cpp Tone.cpp ultralcd.cpp digipot_mcp4451.cpp \ watchdog.cpp SPI.cpp servo.cpp Tone.cpp ultralcd.cpp digipot_mcp4451.cpp \
vector_3.cpp qr_solve.cpp vector_3.cpp qr_solve.cpp
ifeq ($(LIQUID_TWI2), 0) ifeq ($(LIQUID_TWI2), 0)
CXXSRC += LiquidCrystal.cpp CXXSRC += LiquidCrystal.cpp
......
...@@ -240,7 +240,9 @@ extern bool axis_known_position[3]; ...@@ -240,7 +240,9 @@ extern bool axis_known_position[3];
extern float lastpos[4]; extern float lastpos[4];
extern float zprobe_zoffset; extern float zprobe_zoffset;
// Lifetime stats
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. 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.
extern millis_t config_last_update;
#ifdef PREVENT_DANGEROUS_EXTRUDE #ifdef PREVENT_DANGEROUS_EXTRUDE
extern float extrude_min_temp; extern float extrude_min_temp;
...@@ -293,15 +295,6 @@ extern int fanSpeed; ...@@ -293,15 +295,6 @@ extern int fanSpeed;
extern int laser_ttl_modulation; extern int laser_ttl_modulation;
#endif #endif
#if defined(SDSUPPORT) && defined(SD_SETTINGS)
<<<<<<< HEAD
extern unsigned long config_last_update;
=======
extern millis_t config_last_update;
>>>>>>> origin/master
extern bool config_readed;
#endif
extern millis_t print_job_start_ms; extern millis_t print_job_start_ms;
extern millis_t print_job_stop_ms; extern millis_t print_job_stop_ms;
...@@ -314,7 +307,16 @@ extern uint8_t active_driver; ...@@ -314,7 +307,16 @@ extern uint8_t active_driver;
extern void digipot_i2c_init(); extern void digipot_i2c_init();
#endif #endif
// Debug with repetier /**
* Debug with repetier
*/
enum DebugFlags {
DEBUG_ECHO = BIT(0),
DEBUG_INFO = BIT(1),
DEBUG_ERRORS = BIT(2),
DEBUG_DRYRUN = BIT(3),
DEBUG_COMMUNICATION = BIT(4)
};
extern uint8_t debugLevel; extern uint8_t debugLevel;
extern inline bool debugDryrun() { extern inline bool debugDryrun() {
return ((debugLevel & 8) != 0); return ((debugLevel & 8) != 0);
......
/* -*- c++ -*- */
/*
Reprap firmware based on Sprinter and grbl.
Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
This firmware is a mashup between Sprinter and grbl.
(https://github.com/kliment/Sprinter)
(https://github.com/simen/grbl/tree)
It has preliminary support for Matthew Roberts advance algorithm
http://reprap.org/pipermail/reprap-dev/2011-May/003323.html
*/
/* All the implementation is done in *.cpp files to get better compatibility with avr-gcc without the Arduino IDE */
/* Use this file to help the Arduino IDE find which Arduino libraries are needed and to keep documentation on GCode */
#include "Configuration.h"
#include "pins.h"
#ifdef ULTRA_LCD
#if defined(LCD_I2C_TYPE_PCF8575)
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#elif defined(LCD_I2C_TYPE_MCP23017) || defined(LCD_I2C_TYPE_MCP23008)
#include <Wire.h>
#include <LiquidTWI2.h>
#elif defined(DOGLCD)
#include <U8glib.h> // library for graphics LCD by Oli Kraus (https://code.google.com/p/u8glib/)
#else
#include <LiquidCrystal.h> // library for character LCD
#endif
#endif
#if defined(DIGIPOTSS_PIN) && DIGIPOTSS_PIN > -1
#include <SPI.h>
#endif
#if defined(DIGIPOT_I2C)
#include <Wire.h>
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
Servo.h - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2
Copyright (c) 2009 Michael Margolis. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
A servo is activated by creating an instance of the Servo class passing the desired pin to the attach() method.
The servos are pulsed in the background using the value most recently written using the write() method
Note that analogWrite of PWM on pins associated with the timer are disabled when the first servo is attached.
Timers are seized as needed in groups of 12 servos - 24 servos use two timers, 48 servos will use four.
The sequence used to seize timers is defined in timers.h
The methods are:
Servo - Class for manipulating servo motors connected to Arduino pins.
attach(pin ) - Attaches a servo motor to an i/o pin.
attach(pin, min, max ) - Attaches to a pin setting min and max values in microseconds
default min is 544, max is 2400
write() - Sets the servo angle in degrees. (invalid angle that is valid as pulse in microseconds is treated as microseconds)
writeMicroseconds() - Sets the servo pulse width in microseconds
read() - Gets the last written servo pulse width as an angle between 0 and 180.
readMicroseconds() - Gets the last written servo pulse width in microseconds. (was read_us() in first release)
attached() - Returns true if there is a servo attached.
detach() - Stops an attached servos from pulsing its i/o pin.
*/
#ifndef Servo_h
#define Servo_h
#include <inttypes.h>
/*
* Defines for 16 bit timers used with Servo library
*
* If _useTimerX is defined then TimerX is a 16 bit timer on the current board
* timer16_Sequence_t enumerates the sequence that the timers should be allocated
* _Nbr_16timers indicates how many 16 bit timers are available.
*
*/
// Say which 16 bit timers can be used and in what order
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
#define _useTimer5
//#define _useTimer1
#define _useTimer3
#define _useTimer4
//typedef enum { _timer5, _timer1, _timer3, _timer4, _Nbr_16timers } timer16_Sequence_t ;
typedef enum { _timer5, _timer3, _timer4, _Nbr_16timers } timer16_Sequence_t ;
#elif defined(__AVR_ATmega32U4__)
//#define _useTimer1
#define _useTimer3
//typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t ;
typedef enum { _timer3, _Nbr_16timers } timer16_Sequence_t ;
#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
#define _useTimer3
//#define _useTimer1
//typedef enum { _timer3, _timer1, _Nbr_16timers } timer16_Sequence_t ;
typedef enum { _timer3, _Nbr_16timers } timer16_Sequence_t ;
#elif defined(__AVR_ATmega128__) ||defined(__AVR_ATmega1281__) || defined(__AVR_ATmega1284P__) ||defined(__AVR_ATmega2561__)
#define _useTimer3
//#define _useTimer1
//typedef enum { _timer3, _timer1, _Nbr_16timers } timer16_Sequence_t ;
typedef enum { _timer3, _Nbr_16timers } timer16_Sequence_t ;
#else // everything else
//#define _useTimer1
//typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t ;
typedef enum { _Nbr_16timers } timer16_Sequence_t ;
#endif
#define Servo_VERSION 2 // software version of this library
#define MIN_PULSE_WIDTH 544 // the shortest pulse sent to a servo
#define MAX_PULSE_WIDTH 2400 // the longest pulse sent to a servo
#define DEFAULT_PULSE_WIDTH 1500 // default pulse width when servo is attached
#define REFRESH_INTERVAL 20000 // minimum time to refresh servos in microseconds
#define SERVOS_PER_TIMER 12 // the maximum number of servos controlled by one timer
#define MAX_SERVOS (_Nbr_16timers * SERVOS_PER_TIMER)
#define INVALID_SERVO 255 // flag indicating an invalid servo index
typedef struct {
uint8_t nbr :6 ; // a pin number from 0 to 63
uint8_t isActive :1 ; // true if this channel is enabled, pin not pulsed if false
} ServoPin_t;
typedef struct {
ServoPin_t Pin;
unsigned int ticks;
} servo_t;
class Servo {
public:
Servo();
uint8_t attach(int pin); // attach the given pin to the next free channel, sets pinMode, returns channel number or 0 if failure
uint8_t attach(int pin, int min, int max); // as above but also sets min and max values for writes.
void detach();
void write(int value); // if value is < 200 it is treated as an angle, otherwise as pulse width in microseconds
void writeMicroseconds(int value); // Write pulse width in microseconds
int read(); // returns current pulse width as an angle between 0 and 180 degrees
int readMicroseconds(); // returns current pulse width in microseconds for this servo (was read_us() in first release)
bool attached(); // return true if this servo is attached, otherwise false
#if defined(ENABLE_AUTO_BED_LEVELING) && PROBE_SERVO_DEACTIVATION_DELAY > 0
int pin; // store the hardware pin of the servo
#endif
private:
uint8_t servoIndex; // index into the channel data for this servo
int8_t min; // minimum is this value times 4 added to MIN_PULSE_WIDTH
int8_t max; // maximum is this value times 4 added to MAX_PULSE_WIDTH
};
#endif
/* /*
BlinkM.cpp - Library for controlling a BlinkM over i2c blinkm.cpp - Library for controlling a BlinkM over i2c
Created by Tim Koster, August 21 2013. Created by Tim Koster, August 21 2013.
*/ */
#include "Marlin.h" #include "Marlin.h"
#ifdef BLINKM #ifdef BLINKM
#include "BlinkM.h" #include "blinkm.h"
void SendColors(byte red, byte grn, byte blu) { void SendColors(byte red, byte grn, byte blu) {
Wire.begin(); Wire.begin();
......
/* /*
BlinkM.h blinkm.h
Library header file for BlinkM library Library header file for BlinkM library
*/ */
#if ARDUINO >= 100 #if ARDUINO >= 100
......
...@@ -21,9 +21,14 @@ ...@@ -21,9 +21,14 @@
#define BOARD_RAMBO 301 // Rambo #define BOARD_RAMBO 301 // Rambo
#define BOARD_DUEMILANOVE_328P 4 // Duemilanove w/ ATMega328P pin assignments #define BOARD_DUEMILANOVE_328P 4 // Duemilanove w/ ATMega328P pin assignments
#define BOARD_RADDS 402 // RADDS
#define BOARD_RAMPS_FDV1 403 // RAMPS-FD V1
#define BOARD_RAMPS_FDV2 404 // RAMPS-FD V2
#define BOARD_RAMPS4DUE 433 // RAMPS4DUE with AndrewBCN's RAMPS mods (http://forums.reprap.org/read.php?219,479626,page=1)
#define BOARD_GEN6 5 // Gen6 #define BOARD_GEN6 5 // Gen6
#define BOARD_GEN6_DELUXE 51 // Gen6 deluxe #define BOARD_GEN6_DELUXE 51 // Gen6 deluxe
#define BOARD_ALLIGATOR 502 // ALLIGATOR R2 ARM 32
#define BOARD_SANGUINOLOLU_11 6 // Sanguinololu < 1.2 #define BOARD_SANGUINOLOLU_11 6 // Sanguinololu < 1.2
#define BOARD_SANGUINOLOLU_12 62 // Sanguinololu 1.2 and above #define BOARD_SANGUINOLOLU_12 62 // Sanguinololu 1.2 and above
......
...@@ -186,32 +186,6 @@ void CardReader::openFile(char* name, bool read, bool replace_current/*=true*/, ...@@ -186,32 +186,6 @@ void CardReader::openFile(char* name, bool read, bool replace_current/*=true*/,
if (file.isOpen()) { //replacing current file by new file, or subfile call if (file.isOpen()) { //replacing current file by new file, or subfile call
if (!replace_current) { if (!replace_current) {
if (file_subcall_ctr > SD_PROCEDURE_DEPTH - 1) { if (file_subcall_ctr > SD_PROCEDURE_DEPTH - 1) {
<<<<<<< HEAD
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);
=======
ECHO_LMV(ER, MSG_SD_MAX_DEPTH, SD_PROCEDURE_DEPTH); ECHO_LMV(ER, MSG_SD_MAX_DEPTH, SD_PROCEDURE_DEPTH);
kill(); kill();
return; return;
...@@ -221,7 +195,6 @@ void CardReader::openFile(char* name, bool read, bool replace_current/*=true*/, ...@@ -221,7 +195,6 @@ void CardReader::openFile(char* name, bool read, bool replace_current/*=true*/,
filespos[file_subcall_ctr] = sdpos; filespos[file_subcall_ctr] = sdpos;
file_subcall_ctr++; file_subcall_ctr++;
>>>>>>> origin/master
} }
file.close(); file.close();
} }
...@@ -277,22 +250,11 @@ void CardReader::openFile(char* name, bool read, bool replace_current/*=true*/, ...@@ -277,22 +250,11 @@ void CardReader::openFile(char* name, bool read, bool replace_current/*=true*/,
else { //write else { //write
if (file.open(curDir, fname, O_CREAT | O_APPEND | O_WRITE | O_TRUNC)) { if (file.open(curDir, fname, O_CREAT | O_APPEND | O_WRITE | O_TRUNC)) {
saving = true; saving = true;
<<<<<<< HEAD
SERIAL_PROTOCOLPGM(MSG_SD_WRITE_TO_FILE);
SERIAL_PROTOCOLLN(name);
if(lcd_status) lcd_setstatus(fname);
}
else {
SERIAL_PROTOCOLPGM(MSG_SD_OPEN_FILE_FAIL);
SERIAL_PROTOCOL(fname);
SERIAL_PROTOCOLCHAR('.');
=======
ECHO_LMV(OK, MSG_SD_WRITE_TO_FILE, name); ECHO_LMV(OK, MSG_SD_WRITE_TO_FILE, name);
if(lcd_status) lcd_setstatus(fname); if(lcd_status) lcd_setstatus(fname);
} }
else { else {
ECHO_LMV(ER, MSG_SD_OPEN_FILE_FAIL,fname); ECHO_LMV(ER, MSG_SD_OPEN_FILE_FAIL,fname);
>>>>>>> origin/master
} }
} }
} }
...@@ -419,94 +381,6 @@ void CardReader::closeFile(bool store_location) { ...@@ -419,94 +381,6 @@ 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);
}
}
/** /**
* File parser for KEY->VALUE format from files * File parser for KEY->VALUE format from files
* *
......
...@@ -18,17 +18,10 @@ public: ...@@ -18,17 +18,10 @@ 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 //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 checkautostart(bool x);
<<<<<<< HEAD
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 openFile(char* name, bool read, bool replace_current = true, bool lcd_status = true); void openFile(char* name, bool read, bool replace_current = true, bool lcd_status = true);
void openLogFile(char* name); void openLogFile(char* name);
void removeFile(char* name); void removeFile(char* name);
void closeFile(bool store_location = false); void closeFile(bool store_location = false);
>>>>>>> origin/master
void parseKeyLine(char *key, char *value, int &len_k, int &len_v); void parseKeyLine(char *key, char *value, int &len_k, int &len_v);
void unparseKeyLine(const char *key, char *value); void unparseKeyLine(const char *key, char *value);
void release(); void release();
......
/** /**
* ConfigurationStore.cpp * configuration_store.cpp
* *
* Configuration and EEPROM storage * Configuration and EEPROM storage
* *
...@@ -95,13 +95,13 @@ ...@@ -95,13 +95,13 @@
* *
* *
*/ */
#include "Marlin.h" #include "Marlin.h"
#include "language.h" #include "language.h"
#include "planner.h" #include "planner.h"
#include "temperature.h" #include "temperature.h"
#include "ultralcd.h" #include "ultralcd.h"
#include "cardreader.h" #include "configuration_store.h"
#include "ConfigurationStore.h"
void _EEPROM_writeData(int &pos, uint8_t* value, uint8_t size) { void _EEPROM_writeData(int &pos, uint8_t* value, uint8_t size) {
uint8_t c; uint8_t c;
...@@ -115,6 +115,7 @@ void _EEPROM_writeData(int &pos, uint8_t* value, uint8_t size) { ...@@ -115,6 +115,7 @@ void _EEPROM_writeData(int &pos, uint8_t* value, uint8_t size) {
value++; value++;
}; };
} }
void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) { void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) {
do { do {
*value = eeprom_read_byte((unsigned char*)pos); *value = eeprom_read_byte((unsigned char*)pos);
...@@ -122,6 +123,7 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) { ...@@ -122,6 +123,7 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) {
value++; value++;
} while (--size); } while (--size);
} }
#define EEPROM_WRITE_VAR(pos, value) _EEPROM_writeData(pos, (uint8_t*)&value, sizeof(value)) #define EEPROM_WRITE_VAR(pos, value) _EEPROM_writeData(pos, (uint8_t*)&value, sizeof(value))
#define EEPROM_READ_VAR(pos, value) _EEPROM_readData(pos, (uint8_t*)&value, sizeof(value)) #define EEPROM_READ_VAR(pos, value) _EEPROM_readData(pos, (uint8_t*)&value, sizeof(value))
...@@ -130,6 +132,8 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) { ...@@ -130,6 +132,8 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) {
#define DUMMY_PID_VALUE 3000.0f #define DUMMY_PID_VALUE 3000.0f
#define EEPROM_OFFSET 100 #define EEPROM_OFFSET 100
#define LIFETIME_EEPROM_OFFSET 600
#define LIFETIME_MAGIC "L99"
#ifdef EEPROM_SETTINGS #ifdef EEPROM_SETTINGS
...@@ -555,31 +559,9 @@ void Config_ResetDefault() { ...@@ -555,31 +559,9 @@ void Config_ResetDefault() {
idleoozing_enabled = true; idleoozing_enabled = true;
#endif #endif
<<<<<<< HEAD
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Hardcoded Default Settings Loaded");
=======
ECHO_LM(DB, "Hardcoded Default Settings Loaded"); ECHO_LM(DB, "Hardcoded Default Settings Loaded");
} }
void ConfigSD_ResetDefault() {
#ifdef POWER_CONSUMPTION
power_consumption_hour = 0;
#endif
printer_usage_seconds = 0;
ECHO_LM(DB, "Hardcoded SD Default Settings Loaded");
>>>>>>> origin/master
}
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 #ifndef DISABLE_M503
void Config_PrintSettings(bool forReplay) { void Config_PrintSettings(bool forReplay) {
...@@ -811,30 +793,10 @@ void Config_PrintSettings(bool forReplay) { ...@@ -811,30 +793,10 @@ void Config_PrintSettings(bool forReplay) {
ECHO_LM(DB, "Filament settings: Disabled"); ECHO_LM(DB, "Filament settings: Disabled");
} }
} }
<<<<<<< HEAD
=======
if (printer_usage_seconds > 0) ConfigSD_PrintSettings(forReplay);
>>>>>>> origin/master
}
void ConfigSD_PrintSettings(bool forReplay) { // Print Lifetime stats
// Always have this function, even with SD_SETTINGS disabled, the current values will be shown
#ifdef POWER_CONSUMPTION #ifdef POWER_CONSUMPTION
if (!forReplay) { if (!forReplay) {
<<<<<<< HEAD
SERIAL_ECHOLNPGM("Watt/h consumed:");
SERIAL_ECHO_START;
}
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;
=======
ECHO_LM(DB, "Watt/h consumed:"); ECHO_LM(DB, "Watt/h consumed:");
} }
ECHO_LVM(DB, power_consumption_hour," W/h"); ECHO_LVM(DB, power_consumption_hour," W/h");
...@@ -846,87 +808,50 @@ void ConfigSD_PrintSettings(bool forReplay) { ...@@ -846,87 +808,50 @@ void ConfigSD_PrintSettings(bool forReplay) {
int hours = printer_usage_seconds / 60 / 60, minutes = (printer_usage_seconds / 60) % 60; int hours = printer_usage_seconds / 60 / 60, minutes = (printer_usage_seconds / 60) % 60;
sprintf_P(time, PSTR("%i " MSG_END_HOUR " %i " MSG_END_MINUTE), hours, minutes); sprintf_P(time, PSTR("%i " MSG_END_HOUR " %i " MSG_END_MINUTE), hours, minutes);
ECHO_LV(DB, time); ECHO_LV(DB, time);
>>>>>>> origin/master
} }
#endif //!DISABLE_M503 #endif //!DISABLE_M503
<<<<<<< HEAD
=======
/** /**
* Configuration on SD card * Lifetime on EEPROM
*
* Author: Simone Primarosa
* *
*/ */
void load_lifetime_stats() {
int i = LIFETIME_EEPROM_OFFSET;
char stored_magic[4];
char magic[4] = LIFETIME_MAGIC;
EEPROM_READ_VAR(i, stored_magic); // read magic
>>>>>>> origin/master if (strncmp(magic, stored_magic, 3) != 0) {
#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 #ifdef POWER_CONSUMPTION
ltoa(power_consumption_hour,buff,10); power_consumption_hour = 0;
card.unparseKeyLine(cfgSD_KEY[SD_CFG_PWR], buff);
#endif #endif
ltoa(printer_usage_seconds,buff,10); printer_usage_seconds = 0;
card.unparseKeyLine(cfgSD_KEY[SD_CFG_TME], buff);
card.closeFile(false);
config_last_update = millis();
} }
void ConfigSD_RetrieveSettings(bool addValue) { else {
<<<<<<< HEAD EEPROM_READ_VAR(i, printer_usage_seconds);
if(!IS_SD_INSERTED || card.isFileOpen() || card.sdprinting) return;
=======
if(!IS_SD_INSERTED || card.isFileOpen() || card.sdprinting || !card.cardOK) return;
>>>>>>> origin/master
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 #ifdef POWER_CONSUMPTION
case SD_CFG_PWR: { EEPROM_READ_VAR(i, power_consumption_hour);
if(addValue) power_consumption_hour += (unsigned long)atol(value);
else power_consumption_hour = (unsigned long)atol(value);
}
break;
#endif #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;
<<<<<<< HEAD
config_last_update = millis();
=======
ConfigSD_PrintSettings(true);
>>>>>>> origin/master
} }
}
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. void save_lifetime_stats() {
int begin = 0, end = SD_CFG_END - 1, middle, cond; int i = LIFETIME_EEPROM_OFFSET;
while(begin <= end) { char magic[4] = "000";
middle = (begin + end) / 2; EEPROM_WRITE_VAR(i, magic); // invalidate data first
cond = strcmp(cfgSD_KEY[middle], key);
if(!cond) return middle; EEPROM_WRITE_VAR(i, printer_usage_seconds);
else if(cond < 0) begin = middle + 1;
else end = middle - 1; #ifdef POWER_CONSUMPTION
} EEPROM_WRITE_VAR(i, power_consumption_hour);
return -1; #endif
}
#endif char magic2[4] = LIFETIME_MAGIC;
int j = LIFETIME_EEPROM_OFFSET;
EEPROM_WRITE_VAR(j, magic2); // validate data
config_last_update = millis();
}
#ifndef CONFIGURATIONSTORE_H #ifndef CONFIGURATION_STORE_H
#define CONFIGURATIONSTORE_H #define CONFIGURATION_STORE_H
#include "Configuration.h" #include "Configuration.h"
void Config_ResetDefault(); void Config_ResetDefault();
void ConfigSD_ResetDefault(); void load_lifetime_stats();
void save_lifetime_stats();
#ifndef DISABLE_M503 #ifndef DISABLE_M503
void Config_PrintSettings(bool forReplay=false); void Config_PrintSettings(bool forReplay=false);
...@@ -22,35 +23,4 @@ void ConfigSD_ResetDefault(); ...@@ -22,35 +23,4 @@ void ConfigSD_ResetDefault();
FORCE_INLINE void Config_RetrieveSettings() { Config_ResetDefault(); Config_PrintSettings(); } FORCE_INLINE void Config_RetrieveSettings() { Config_ResetDefault(); Config_PrintSettings(); }
#endif #endif
#if defined(SDSUPPORT) && defined(SD_SETTINGS) #endif //CONFIGURATION_STORE_H
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",
};
<<<<<<< HEAD
=======
>>>>>>> origin/master
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
};
<<<<<<< HEAD
=======
>>>>>>> origin/master
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
...@@ -273,9 +273,9 @@ static void lcd_implementation_status_screen() { ...@@ -273,9 +273,9 @@ static void lcd_implementation_status_screen() {
#if HAS_LCD_POWER_SENSOR #if HAS_LCD_POWER_SENSOR
if (millis() < print_millis + 1000) { if (millis() < print_millis + 1000) {
uint16_t time = (millis() - print_job_start_ms) / 60000; uint16_t time = (millis() - print_job_start_ms) / 60000;
lcd_print(itostr2(time / 60)); lcd_print(itostr2(time/60));
lcd_print(':'); lcd_print(':');
lcd_print(itostr2(time % 60)); lcd_print(itostr2(time%60));
} }
else { else {
lcd_print(itostr4(power_consumption_hour-startpower)); lcd_print(itostr4(power_consumption_hour-startpower));
...@@ -283,9 +283,9 @@ static void lcd_implementation_status_screen() { ...@@ -283,9 +283,9 @@ static void lcd_implementation_status_screen() {
} }
#else #else
uint16_t time = (millis() - print_job_start_ms) / 60000; uint16_t time = (millis() - print_job_start_ms) / 60000;
lcd_print(itostr2(time / 60)); lcd_print(itostr2(time/60));
lcd_print(':'); lcd_print(':');
lcd_print(itostr2(time % 60)); lcd_print(itostr2(time%60));
#endif #endif
} }
else { else {
......
...@@ -3,5 +3,6 @@ ...@@ -3,5 +3,6 @@
.\bdf2u8g.exe -b 32 -e 255 HD44780_C.bdf HD44780_C_5x7 dogm_font_data_HD44780_C.h .\bdf2u8g.exe -b 32 -e 255 HD44780_C.bdf HD44780_C_5x7 dogm_font_data_HD44780_C.h
.\bdf2u8g.exe -b 32 -e 255 HD44780_J.bdf HD44780_J_5x7 dogm_font_data_HD44780_J.h .\bdf2u8g.exe -b 32 -e 255 HD44780_J.bdf HD44780_J_5x7 dogm_font_data_HD44780_J.h
.\bdf2u8g.exe -b 32 -e 255 ISO10646-1.bdf ISO10646_1_5x7 dogm_font_data_ISO10646_1.h .\bdf2u8g.exe -b 32 -e 255 ISO10646-1.bdf ISO10646_1_5x7 dogm_font_data_ISO10646_1.h
.\bdf2u8g.exe -b 32 -e 255 ISO10646-1-Marlin.bdf ISO10646_1_Marlin_5x7 dogm_font_data_ISO10646_1_Marlin.h
.\bdf2u8g.exe -b 32 -e 255 ISO10646_5_Cyrillic.bdf ISO10646_5_Cyrillic_5x7 dogm_font_data_ISO10646_5_Cyrillic.h .\bdf2u8g.exe -b 32 -e 255 ISO10646_5_Cyrillic.bdf ISO10646_5_Cyrillic_5x7 dogm_font_data_ISO10646_5_Cyrillic.h
.\bdf2u8g.exe -b 32 -e 255 ISO10646_Kana.bdf ISO10646_Kana_5x7 dogm_font_data_ISO10646_Kana.h .\bdf2u8g.exe -b 32 -e 255 ISO10646_Kana.bdf ISO10646_Kana_5x7 dogm_font_data_ISO10646_Kana.h
...@@ -94,7 +94,8 @@ ...@@ -94,7 +94,8 @@
#define MSG_OK "ok" #define MSG_OK "ok"
#define MSG_WAIT "wait" #define MSG_WAIT "wait"
#define MSG_FILE_SAVED "Done saving file." #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_LINE_NO1 "Line Number out of sequence. Expected: "
#define MSG_ERR_LINE_NO2 " Got: "
#define MSG_ERR_CHECKSUM_MISMATCH "checksum mismatch, Last Line: " #define MSG_ERR_CHECKSUM_MISMATCH "checksum mismatch, Last Line: "
#define MSG_ERR_NO_CHECKSUM "No Checksum with line number, Last Line: " #define MSG_ERR_NO_CHECKSUM "No Checksum with line number, Last Line: "
#define MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM "No Line Number with checksum, Last Line: " #define MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM "No Line Number with checksum, Last Line: "
......
This diff is collapsed.
...@@ -3,39 +3,47 @@ ...@@ -3,39 +3,47 @@
//============================================================================ //============================================================================
//X axis pins //X axis pins
#define ORIG_X_STEP_PIN X_STEP_PIN #define X_STEP_PIN ORIG_X_STEP_PIN
#define ORIG_X_DIR_PIN X_DIR_PIN #define X_DIR_PIN ORIG_X_DIR_PIN
#define ORIG_X_ENABLE_PIN X_ENABLE_PIN #define X_ENABLE_PIN ORIG_X_ENABLE_PIN
//Y axis pins //Y axis pins
#define ORIG_Y_STEP_PIN Y_STEP_PIN #define Y_STEP_PIN ORIG_Y_STEP_PIN
#define ORIG_Y_DIR_PIN Y_DIR_PIN #define Y_DIR_PIN ORIG_Y_DIR_PIN
#define ORIG_Y_ENABLE_PIN Y_ENABLE_PIN #define Y_ENABLE_PIN ORIG_Y_ENABLE_PIN
//Z axis pins //Z axis pins
#define ORIG_Z_STEP_PIN Z_STEP_PIN #define Z_STEP_PIN ORIG_Z_STEP_PIN
#define ORIG_Z_DIR_PIN Z_DIR_PIN #define Z_DIR_PIN ORIG_Z_DIR_PIN
#define ORIG_Z_ENABLE_PIN Z_ENABLE_PIN #define Z_ENABLE_PIN ORIG_Z_ENABLE_PIN
//E axis pins //E axis pins
#define ORIG_E0_STEP_PIN E0_STEP_PIN #if DRIVER_EXTRUDERS > 0
#define ORIG_E0_DIR_PIN E0_DIR_PIN #define E0_STEP_PIN ORIG_E0_STEP_PIN
#define ORIG_E0_ENABLE_PIN E0_ENABLE_PIN #define E0_DIR_PIN ORIG_E0_DIR_PIN
#define E0_ENABLE_PIN ORIG_E0_ENABLE_PIN
#define ORIG_E1_STEP_PIN E1_STEP_PIN #endif
#define ORIG_E1_DIR_PIN E1_DIR_PIN
#define ORIG_E1_ENABLE_PIN E1_ENABLE_PIN #if DRIVER_EXTRUDERS > 1
#define E1_STEP_PIN ORIG_E1_STEP_PIN
#define ORIG_E2_STEP_PIN E2_STEP_PIN #define E1_DIR_PIN ORIG_E1_DIR_PIN
#define ORIG_E2_DIR_PIN E2_DIR_PIN #define E1_ENABLE_PIN ORIG_E1_ENABLE_PIN
#define ORIG_E2_ENABLE_PIN E2_ENABLE_PIN #endif
#define ORIG_E3_STEP_PIN E3_STEP_PIN #if DRIVER_EXTRUDERS > 2
#define ORIG_E3_DIR_PIN E3_DIR_PIN #define E2_STEP_PIN ORIG_E2_STEP_PIN
#define ORIG_E3_ENABLE_PIN E3_ENABLE_PIN #define E2_DIR_PIN ORIG_E2_DIR_PIN
#define E2_ENABLE_PIN ORIG_E2_ENABLE_PIN
#endif
#if DRIVER_EXTRUDERS > 3
#define E3_STEP_PIN ORIG_E3_STEP_PIN
#define E3_DIR_PIN ORIG_E3_DIR_PIN
#define E3_ENABLE_PIN ORIG_E3_ENABLE_PIN
#endif
//FAN pin //FAN pin
#define ORIG_FAN_PIN FAN_PIN #define FAN_PIN ORIG_FAN_PIN
//============================================================================ //============================================================================
......
...@@ -1040,7 +1040,7 @@ float junction_deviation = 0.1; ...@@ -1040,7 +1040,7 @@ float junction_deviation = 0.1;
float nx = position[X_AXIS] = lround(x * axis_steps_per_unit[X_AXIS]); float nx = position[X_AXIS] = lround(x * axis_steps_per_unit[X_AXIS]);
float ny = position[Y_AXIS] = lround(y * axis_steps_per_unit[Y_AXIS]); float ny = position[Y_AXIS] = lround(y * axis_steps_per_unit[Y_AXIS]);
float nz = position[Z_AXIS] = lround(z * axis_steps_per_unit[Z_AXIS]); float nz = position[Z_AXIS] = lround(z * axis_steps_per_unit[Z_AXIS]);
float ne = position[E_AXIS] = lround(e * axis_steps_per_unit[E_AXIS + extruder]); float ne = position[E_AXIS] = lround(e * axis_steps_per_unit[E_AXIS + active_extruder]);
st_set_position(nx, ny, nz, ne); st_set_position(nx, ny, nz, ne);
previous_nominal_speed = 0.0; // Resets planner junction speeds. Assumes start from rest. previous_nominal_speed = 0.0; // Resets planner junction speeds. Assumes start from rest.
...@@ -1048,7 +1048,7 @@ float junction_deviation = 0.1; ...@@ -1048,7 +1048,7 @@ float junction_deviation = 0.1;
} }
void plan_set_e_position(const float &e) { void plan_set_e_position(const float &e) {
position[E_AXIS] = lround(e * axis_steps_per_unit[E_AXIS + extruder]); position[E_AXIS] = lround(e * axis_steps_per_unit[E_AXIS + active_extruder]);
st_set_e_position(position[E_AXIS]); st_set_e_position(position[E_AXIS]);
} }
......
...@@ -509,14 +509,22 @@ ISR(TIMER1_COMPA_vect) { ...@@ -509,14 +509,22 @@ ISR(TIMER1_COMPA_vect) {
count_direction[Y_AXIS] = 1; count_direction[Y_AXIS] = 1;
} }
#define _ENDSTOP(axis, minmax) axis ##_## minmax ##_endstop
#define _ENDSTOP_PIN(AXIS, MINMAX) AXIS ##_## MINMAX ##_PIN
#define _ENDSTOP_INVERTING(AXIS, MINMAX) AXIS ##_## MINMAX ##_ENDSTOP_INVERTING
#define _OLD_ENDSTOP(axis, minmax) old_## axis ##_## minmax ##_endstop
#define _AXIS(AXIS) AXIS ##_AXIS
#define _ENDSTOP_HIT(axis) endstop_## axis ##_hit
#define UPDATE_ENDSTOP(axis,AXIS,minmax,MINMAX) \ #define UPDATE_ENDSTOP(axis,AXIS,minmax,MINMAX) \
bool axis ##_## minmax ##_endstop = (READ(AXIS ##_## MINMAX ##_PIN) != AXIS ##_## MINMAX ##_ENDSTOP_INVERTING); \ bool _ENDSTOP(axis, minmax) = (READ(_ENDSTOP_PIN(AXIS, MINMAX)) != _ENDSTOP_INVERTING(AXIS, MINMAX)); \
if (axis ##_## minmax ##_endstop && old_## axis ##_## minmax ##_endstop && (current_block->steps[AXIS ##_AXIS] > 0)) { \ if (_ENDSTOP(axis, minmax) && _OLD_ENDSTOP(axis, minmax) && (current_block->steps[_AXIS(AXIS)] > 0)) { \
endstops_trigsteps[AXIS ##_AXIS] = count_position[AXIS ##_AXIS]; \ endstops_trigsteps[_AXIS(AXIS)] = count_position[_AXIS(AXIS)]; \
endstop_## axis ##_hit = true; \ _ENDSTOP_HIT(axis) = true; \
step_events_completed = current_block->step_event_count; \ step_events_completed = current_block->step_event_count; \
} \ } \
old_## axis ##_## minmax ##_endstop = axis ##_## minmax ##_endstop; _OLD_ENDSTOP(axis, minmax) = _ENDSTOP(axis, minmax);
// Check X and Y endstops // Check X and Y endstops
if (check_endstops) { if (check_endstops) {
...@@ -714,6 +722,11 @@ ISR(TIMER1_COMPA_vect) { ...@@ -714,6 +722,11 @@ ISR(TIMER1_COMPA_vect) {
} }
#endif //ADVANCE #endif //ADVANCE
#define _COUNTER(axis) counter_## axis
#define _WRITE_STEP(AXIS, HIGHLOW) AXIS ##_STEP_WRITE(HIGHLOW)
#define _APPLY_STEP(AXIS) AXIS ##_APPLY_STEP
#define _INVERT_STEP_PIN(AXIS) INVERT_## AXIS ##_STEP_PIN
#ifdef CONFIG_STEPPERS_TOSHIBA #ifdef CONFIG_STEPPERS_TOSHIBA
/** /**
* The Toshiba stepper controller require much longer pulses. * The Toshiba stepper controller require much longer pulses.
...@@ -722,8 +735,8 @@ ISR(TIMER1_COMPA_vect) { ...@@ -722,8 +735,8 @@ ISR(TIMER1_COMPA_vect) {
* lag to allow it work with without needing NOPs * lag to allow it work with without needing NOPs
*/ */
#define STEP_ADD(axis, AXIS) \ #define STEP_ADD(axis, AXIS) \
counter_## axis += current_block->steps[AXIS ##_AXIS]; \ _COUNTER(axis) += current_block->steps[_AXIS(AXIS)]; \
if (counter_## axis > 0) { AXIS ##_STEP_WRITE(HIGH); } if (_COUNTER(axis) > 0) { _WRITE_STEP(AXIS, HIGH); }
STEP_ADD(x,X); STEP_ADD(x,X);
STEP_ADD(y,Y); STEP_ADD(y,Y);
STEP_ADD(z,Z); STEP_ADD(z,Z);
...@@ -732,10 +745,10 @@ ISR(TIMER1_COMPA_vect) { ...@@ -732,10 +745,10 @@ ISR(TIMER1_COMPA_vect) {
#endif #endif
#define STEP_IF_COUNTER(axis, AXIS) \ #define STEP_IF_COUNTER(axis, AXIS) \
if (counter_## axis > 0) { \ if (_COUNTER(axis) > 0) { \
counter_## axis -= current_block->step_event_count; \ _COUNTER(axis) -= current_block->step_event_count; \
count_position[AXIS ##_AXIS] += count_direction[AXIS ##_AXIS]; \ count_position[_AXIS(AXIS)] += count_direction[_AXIS(AXIS)]; \
AXIS ##_STEP_WRITE(LOW); \ _WRITE_STEP(AXIS, LOW); \
} }
STEP_IF_COUNTER(x, X); STEP_IF_COUNTER(x, X);
...@@ -748,12 +761,12 @@ ISR(TIMER1_COMPA_vect) { ...@@ -748,12 +761,12 @@ ISR(TIMER1_COMPA_vect) {
#else // !CONFIG_STEPPERS_TOSHIBA #else // !CONFIG_STEPPERS_TOSHIBA
#define APPLY_MOVEMENT(axis, AXIS) \ #define APPLY_MOVEMENT(axis, AXIS) \
counter_## axis += current_block->steps[AXIS ##_AXIS]; \ _COUNTER(axis) += current_block->steps[_AXIS(AXIS)]; \
if (counter_## axis > 0) { \ if (_COUNTER(axis) > 0) { \
AXIS ##_APPLY_STEP(!INVERT_## AXIS ##_STEP_PIN,0); \ _APPLY_STEP(AXIS)(!_INVERT_STEP_PIN(AXIS),0); \
counter_## axis -= current_block->step_event_count; \ _COUNTER(axis) -= current_block->step_event_count; \
count_position[AXIS ##_AXIS] += count_direction[AXIS ##_AXIS]; \ count_position[_AXIS(AXIS)] += count_direction[_AXIS(AXIS)]; \
AXIS ##_APPLY_STEP(INVERT_## AXIS ##_STEP_PIN,0); \ _APPLY_STEP(AXIS)(_INVERT_STEP_PIN(AXIS),0); \
} }
APPLY_MOVEMENT(x, X); APPLY_MOVEMENT(x, X);
...@@ -1079,10 +1092,13 @@ void st_init() { ...@@ -1079,10 +1092,13 @@ void st_init() {
#endif #endif
#endif #endif
#define _STEP_INIT(AXIS) AXIS ##_STEP_INIT
#define _DISABLE(axis) disable_## axis()
#define AXIS_INIT(axis, AXIS, PIN) \ #define AXIS_INIT(axis, AXIS, PIN) \
AXIS ##_STEP_INIT; \ _STEP_INIT(AXIS); \
AXIS ##_STEP_WRITE(INVERT_## PIN ##_STEP_PIN); \ _WRITE_STEP(AXIS, _INVERT_STEP_PIN(PIN)); \
disable_## axis() _DISABLE(axis)
#define E_AXIS_INIT(NUM) AXIS_INIT(e## NUM, E## NUM, E) #define E_AXIS_INIT(NUM) AXIS_INIT(e## NUM, E## NUM, E)
...@@ -1230,14 +1246,19 @@ void quickStop() { ...@@ -1230,14 +1246,19 @@ void quickStop() {
// No other ISR should ever interrupt this! // No other ISR should ever interrupt this!
void babystep(const uint8_t axis, const bool direction) { void babystep(const uint8_t axis, const bool direction) {
#define _ENABLE(axis) enable_## axis()
#define _READ_DIR(AXIS) AXIS ##_DIR_READ
#define _INVERT_DIR(AXIS) INVERT_## AXIS ##_DIR
#define _APPLY_DIR(AXIS, INVERT) AXIS ##_APPLY_DIR(INVERT, true)
#define BABYSTEP_AXIS(axis, AXIS, INVERT) { \ #define BABYSTEP_AXIS(axis, AXIS, INVERT) { \
enable_## axis(); \ _ENABLE(axis); \
uint8_t old_pin = AXIS ##_DIR_READ; \ uint8_t old_pin = _READ_DIR(AXIS); \
AXIS ##_APPLY_DIR(INVERT_## AXIS ##_DIR^direction^INVERT, true); \ _APPLY_DIR(AXIS, _INVERT_DIR(AXIS)^direction^INVERT); \
AXIS ##_APPLY_STEP(!INVERT_## AXIS ##_STEP_PIN, true); \ _APPLY_STEP(AXIS)(!_INVERT_STEP_PIN(AXIS), true); \
delayMicroseconds(2); \ delayMicroseconds(2); \
AXIS ##_APPLY_STEP(INVERT_## AXIS ##_STEP_PIN, true); \ _APPLY_STEP(AXIS)(_INVERT_STEP_PIN(AXIS), true); \
AXIS ##_APPLY_DIR(old_pin, true); \ _APPLY_DIR(AXIS, old_pin); \
} }
switch(axis) { switch(axis) {
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include "stepper_indirection.h" #include "stepper_indirection.h"
#if MB(ALLIGATOR) #if MB(ALLIGATOR)
#include "ExternalDac.h" #include "external_dac.h"
#endif #endif
#if DRIVER_EXTRUDERS > 3 #if DRIVER_EXTRUDERS > 3
......
...@@ -795,21 +795,12 @@ static void updateTemperaturesFromRawValues() { ...@@ -795,21 +795,12 @@ static void updateTemperaturesFromRawValues() {
watt_overflow--; watt_overflow--;
} }
#endif #endif
<<<<<<< HEAD
static unsigned int second_overflow = 0; static unsigned int second_overflow = 0;
second_overflow += from_last_update; second_overflow += from_last_update;
if(second_overflow >= 1000) { if(second_overflow >= 1000) {
printer_usage_seconds++; printer_usage_seconds++;
second_overflow -= 1000; second_overflow -= 1000;
=======
static unsigned int second_overflow = 0;
second_overflow += from_last_update;
if(second_overflow >= 1000) {
printer_usage_seconds++;
second_overflow -= 1000;
>>>>>>> origin/master
} }
last_update = temp_last_update; last_update = temp_last_update;
//Reset the watchdog after we know we have a temperature measurement. //Reset the watchdog after we know we have a temperature measurement.
......
...@@ -25,6 +25,9 @@ ...@@ -25,6 +25,9 @@
#include "planner.h" #include "planner.h"
#include "stepper.h" #include "stepper.h"
// for smoother temperature
#define MEDIAN_COUNT 10
// public functions // public functions
void tp_init(); //initialize the heating void tp_init(); //initialize the heating
void manage_heater(); //it is critical that this is called periodically. void manage_heater(); //it is critical that this is called periodically.
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "cardreader.h" #include "cardreader.h"
#include "temperature.h" #include "temperature.h"
#include "stepper.h" #include "stepper.h"
#include "ConfigurationStore.h" #include "configuration_store.h"
int8_t encoderDiff; /* encoderDiff is updated from interrupt context and added to encoderPosition every LCD update */ int8_t encoderDiff; /* encoderDiff is updated from interrupt context and added to encoderPosition every LCD update */
......
...@@ -662,7 +662,7 @@ static void lcd_implementation_status_screen() { ...@@ -662,7 +662,7 @@ static void lcd_implementation_status_screen() {
} }
#if HAS_LCD_POWER_SENSOR #if HAS_LCD_POWER_SENSOR
#if HAS_LCD_FILAMENT_SENSOR #if HAS_LCD_FILAMENT_SENSOR
else if (millis() < previous_lcd_status_ms + 10000) else if (millis() < message_millis + 10000)
#else #else
else else
#endif #endif
......
...@@ -43,10 +43,10 @@ void watchdog_reset() ...@@ -43,10 +43,10 @@ void watchdog_reset()
#ifdef WATCHDOG_RESET_MANUAL #ifdef WATCHDOG_RESET_MANUAL
ISR(WDT_vect) ISR(WDT_vect)
{ {
ECHO_LM(MSG_WATCHDOG_RESET);
//TODO: This message gets overwritten by the kill() call //TODO: This message gets overwritten by the kill() call
LCD_ALERTMESSAGEPGM("ERR:Please Reset");//16 characters so it fits on a 16x2 display LCD_ALERTMESSAGEPGM("ERR:Please Reset");//16 characters so it fits on a 16x2 display
lcd_update(); lcd_update();
ECHO_LM(MSG_WATCHDOG_RESET);
kill(); //kill blocks kill(); //kill blocks
while(1); //wait for user or serial reset while(1); //wait for user or serial reset
} }
......
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