Compare commits
131 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fa2e1be0ca | |||
| 7699f250e3 | |||
| 11518a987f | |||
| 13e185d330 | |||
| b58eae7657 | |||
| 3e7fcb813e | |||
| 2a77c84c8f | |||
| d47a3e5950 | |||
| f87c80889f | |||
| 154de69c02 | |||
| 6ef8459494 | |||
| 598eb1d4f1 | |||
| 9173a5713b | |||
| da040fd393 | |||
| bdb70c0509 | |||
| 5113513cb2 | |||
| d8a0c6450f | |||
| f9c5333f97 | |||
| 292ddd2edb | |||
| abb7e63906 | |||
| 9f139d6e0e | |||
| e45e5c68bb | |||
| 7c6141ebc4 | |||
| 9c918a497b | |||
| ab01658fd2 | |||
| 42bedb3f60 | |||
| a991bde523 | |||
| 3e575533c5 | |||
| 2ae2ead97b | |||
| 71dc82e0b4 | |||
| 5aadc2f5ca | |||
| 8d0916af13 | |||
| 6cc6029d7a | |||
| 157aa7f2fd | |||
| 7aeb45303d | |||
| cee5f9020a | |||
| 3814bbb529 | |||
| 729cde4475 | |||
| 396270a0de | |||
| 11f2dafc4e | |||
| 8463e39a4a | |||
| 2bc160a978 | |||
| 57f9359a41 | |||
| 3c1a4aac2b | |||
| 212515148e | |||
| 6735025428 | |||
| 415aadf704 | |||
| 4bababf5b0 | |||
| f312216e97 | |||
| 651cde8b98 | |||
| 554cc1718d | |||
| 617968ab76 | |||
| 84d9cf7339 | |||
| e017228569 | |||
| 3320a5b37d | |||
| 06411d5c9e | |||
| 82c99625fa | |||
| 01001b89d2 | |||
| 88ee053af0 | |||
| b1d84d879b | |||
| f6fe7143e4 | |||
| dde4b40fa9 | |||
| 2bc5e7ec9e | |||
| aa4f9a6474 | |||
| 87fd249c43 | |||
| 1ec0c3b68a | |||
| 5b4625f79c | |||
| cc4a9cdb69 | |||
| 61c943b4bf | |||
| bae1e422f6 | |||
| 754d2d69b2 | |||
| 986f0ba76c | |||
| 460b788d78 | |||
| 3664ed6aad | |||
| 43f5c3e82b | |||
| 4fd75dc813 | |||
| 12e8edcac3 | |||
| cf50ba140f | |||
| 89e832c295 | |||
| b99c49ec3b | |||
| 95a0b28acb | |||
| af22e9cd38 | |||
| 7714b98da7 | |||
| dfd240b260 | |||
| 4f909963e4 | |||
| 6b86f15686 | |||
| 0bc9daa4f7 | |||
| b0c3871750 | |||
| 9c57453168 | |||
| 59205ac5fc | |||
| 7a4be21b4f | |||
| 716e89b87c | |||
| d00b7e5587 | |||
| e4ab0e5982 | |||
| 8cb29921a0 | |||
| 044886b4a0 | |||
| b19c8b74b9 | |||
| 6d95644c0d | |||
| 311627141b | |||
| 7216a12856 | |||
| 98805c9228 | |||
| 85da81e673 | |||
| b9ad0bb2ce | |||
| dd5ca68c87 | |||
| dd5296ad4d | |||
| f75f426dfa | |||
| 2d9a715655 | |||
| d2f034ba84 | |||
| 6aecf80278 | |||
| b128d25f27 | |||
| 26a1de1e44 | |||
| f8e170a44b | |||
| aad4b75b94 | |||
| a0dc66f7bf | |||
| 6d6f323535 | |||
| 4d6a5c29df | |||
| 74d0032e25 | |||
| 191f36b493 | |||
| c54a807824 | |||
| a6823a84e1 | |||
| 57e163e989 | |||
| b58787a367 | |||
| 71ca78982b | |||
| 235051253a | |||
| 27654bfe69 | |||
| cdf0bd4e63 | |||
| 6ac9b2e761 | |||
| ac8adabb2b | |||
| 0e0e4945d8 | |||
| c0f8c9fd72 | |||
| 0db97b9c7f |
+73
-208
@@ -1,28 +1,19 @@
|
||||
#ifndef __CONFIGURATION_H
|
||||
#define __CONFIGURATION_H
|
||||
|
||||
// This configurtion file contains the basic settings.
|
||||
// Advanced settings can be found in Configuration_adv.h
|
||||
// BASIC SETTINGS: select your board type, temperature sensor type, axis scaling, and endstop configuration
|
||||
|
||||
//User specified version info of THIS file 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 file by the user have been successfully uploaded into firmware.
|
||||
#define STRING_VERSION_CONFIG_H "2012-02-08j" //Personal revision number for changes to THIS file.
|
||||
#define STRING_CONFIG_H_AUTHOR "username" //Who made the changes.
|
||||
|
||||
// This determines the communication speed of the printer
|
||||
#define BAUDRATE 250000
|
||||
//#define BAUDRATE 115200
|
||||
//#define BAUDRATE 230400
|
||||
|
||||
|
||||
// Frequency limit
|
||||
// See nophead's blog for more info
|
||||
// Not working O
|
||||
//#define XY_FREQUENCY_LIMIT 15
|
||||
|
||||
// Minimum planner junction speed. Sets the default minimum speed the planner plans for at the end
|
||||
// of the buffer and all stops. This should not be much greater than zero and should only be changed
|
||||
// if unwanted behavior is observed on a user's machine when running at very slow speeds.
|
||||
#define MINIMUM_PLANNER_SPEED 2.0 // (mm/sec)
|
||||
|
||||
// If defined the movements slow down when the look ahead buffer is only half full
|
||||
#define SLOWDOWN
|
||||
|
||||
// BASIC SETTINGS: select your board type, thermistor type, axis scaling, and endstop configuration
|
||||
|
||||
//// The following define selects which electronics board you have. Please choose the one that matches your setup
|
||||
// MEGA/RAMPS up to 1.2 = 3,
|
||||
@@ -30,201 +21,145 @@
|
||||
// Gen6 = 5,
|
||||
// Sanguinololu 1.2 and above = 62
|
||||
// Ultimaker = 7,
|
||||
// Teensylu = 8
|
||||
// Teensylu = 8,
|
||||
// Gen3+ =9
|
||||
#define MOTHERBOARD 7
|
||||
|
||||
//===========================================================================
|
||||
//=============================Thermal Settings ============================
|
||||
//===========================================================================
|
||||
|
||||
//// Thermistor settings:
|
||||
//// Temperature sensor settings:
|
||||
// -2 is thermocouple with MAX6675 (only for sensor 0)
|
||||
// -1 is thermocouple with AD595
|
||||
// 0 is not used
|
||||
// 1 is 100k thermistor
|
||||
// 2 is 200k thermistor
|
||||
// 3 is mendel-parts thermistor
|
||||
// 4 is 10k thermistor
|
||||
// 4 is 10k thermistor !! do not use it for a hotend. It gives bad resolution at high temp. !!
|
||||
// 5 is ParCan supplied 104GT-2 100K
|
||||
// 6 is EPCOS 100k
|
||||
// 7 is 100k Honeywell thermistor 135-104LAG-J01
|
||||
//#define THERMISTORHEATER_0 3
|
||||
//#define THERMISTORHEATER_1 3
|
||||
//#define THERMISTORBED 3
|
||||
|
||||
//#define HEATER_0_USES_THERMISTOR
|
||||
//#define HEATER_1_USES_THERMISTOR
|
||||
#define HEATER_0_USES_AD595
|
||||
//#define HEATER_1_USES_AD595
|
||||
|
||||
// Select one of these only to define how the bed temp is read.
|
||||
//#define BED_USES_THERMISTOR
|
||||
//#define BED_USES_AD595
|
||||
|
||||
#define BED_CHECK_INTERVAL 5000 //ms
|
||||
|
||||
//// Experimental watchdog and minimal temp
|
||||
// The watchdog waits for the watchperiod in milliseconds whenever an M104 or M109 increases the target temperature
|
||||
// If the temperature has not increased at the end of that period, the target temperature is set to zero. It can be reset with another M104/M109
|
||||
/// CURRENTLY NOT IMPLEMENTED AND UNUSEABLE
|
||||
//#define WATCHPERIOD 5000 //5 seconds
|
||||
#define TEMP_SENSOR_0 -1
|
||||
#define TEMP_SENSOR_1 0
|
||||
#define TEMP_SENSOR_2 0
|
||||
#define TEMP_SENSOR_BED 0
|
||||
|
||||
// Actual temperature must be close to target for this long before M109 returns success
|
||||
//#define TEMP_RESIDENCY_TIME 20 // (seconds)
|
||||
//#define TEMP_HYSTERESIS 5 // (C°) range of +/- temperatures considered "close" to the target one
|
||||
#define TEMP_RESIDENCY_TIME 30 // (seconds)
|
||||
#define TEMP_HYSTERESIS 3 // (C°) range of +/- temperatures considered "close" to the target one
|
||||
|
||||
//// The minimal temperature defines the temperature below which the heater will not be enabled
|
||||
// The minimal temperature defines the temperature below which the heater will not be enabled It is used
|
||||
// to check that the wiring to the thermistor is not broken.
|
||||
// Otherwise this would lead to the heater being powered on all the time.
|
||||
#define HEATER_0_MINTEMP 5
|
||||
//#define HEATER_1_MINTEMP 5
|
||||
//#define BED_MINTEMP 5
|
||||
|
||||
#define HEATER_1_MINTEMP 5
|
||||
#define HEATER_2_MINTEMP 5
|
||||
#define BED_MINTEMP 5
|
||||
|
||||
// When temperature exceeds max temp, your heater will be switched off.
|
||||
// This feature exists to protect your hotend from overheating accidentally, but *NOT* from thermistor short/failure!
|
||||
// You should use MINTEMP for thermistor short/failure protection.
|
||||
#define HEATER_0_MAXTEMP 275
|
||||
//#define HEATER_1_MAXTEMP 275
|
||||
//#define BED_MAXTEMP 150
|
||||
|
||||
|
||||
#define HEATER_1_MAXTEMP 275
|
||||
#define HEATER_2_MAXTEMP 275
|
||||
#define BED_MAXTEMP 150
|
||||
|
||||
// PID settings:
|
||||
// Uncomment the following line to enable PID support.
|
||||
|
||||
// Comment the following line to disable PID and enable bang-bang.
|
||||
#define PIDTEMP
|
||||
#define PID_MAX 255 // limits current to nozzle; 255=full current
|
||||
#ifdef PIDTEMP
|
||||
#if MOTHERBOARD == 62
|
||||
#error Sanguinololu does not support PID, sorry. Please disable it.
|
||||
#endif
|
||||
//#define PID_DEBUG // Sends debug data to the serial port.
|
||||
//#define PID_OPENLOOP 1 // Puts PID in open loop. M104 sets the output power in %
|
||||
|
||||
#define PID_MAX 255 // limits current to nozzle; 255=full current
|
||||
#define PID_INTEGRAL_DRIVE_MAX 255 //limit for the integral term
|
||||
#define K1 0.95 //smoothing factor withing the PID
|
||||
#define PID_dT 0.1 //sampling period of the PID
|
||||
#define PID_dT 0.128 //sampling period of the PID
|
||||
|
||||
//To develop some PID settings for your machine, you can initiall follow
|
||||
// the Ziegler-Nichols method.
|
||||
// set Ki and Kd to zero.
|
||||
// heat with a defined Kp and see if the temperature stabilizes
|
||||
// ideally you do this graphically with repg.
|
||||
// the PID_CRITIAL_GAIN should be the Kp at which temperature oscillatins are not dampned out/decreas in amplitutde
|
||||
// PID_SWING_AT_CRITIAL is the time for a full period of the oscillations at the critical Gain
|
||||
// usually further manual tunine is necessary.
|
||||
|
||||
#define PID_CRITIAL_GAIN 50
|
||||
#define PID_SWING_AT_CRITIAL 47 //seconds
|
||||
|
||||
//#define PID_PI //no differentail term
|
||||
#define PID_PID //normal PID
|
||||
|
||||
#ifdef PID_PID
|
||||
//PID according to Ziegler-Nichols method
|
||||
// #define DEFAULT_Kp (0.6*PID_CRITIAL_GAIN)
|
||||
// #define DEFAULT_Ki (2*Kp/PID_SWING_AT_CRITIAL*PID_dT)
|
||||
// #define DEFAULT_Kd (PID_SWING_AT_CRITIAL/8./PID_dT)
|
||||
|
||||
// Ultitmaker
|
||||
// If you are using a preconfigured hotend then you can use one of the value sets by uncommenting it
|
||||
// Ultimaker
|
||||
#define DEFAULT_Kp 22.2
|
||||
#define DEFAULT_Ki (1.25*PID_dT)
|
||||
#define DEFAULT_Kd (99/PID_dT)
|
||||
|
||||
// Makergear
|
||||
// #define DEFAULT_Kp 7.0
|
||||
// #define DEFAULT_Ki 0.1
|
||||
// #define DEFAULT_Kd 12
|
||||
|
||||
// Mendel Parts V9 on 12V
|
||||
// #define DEFAULT_Kp 63.0
|
||||
// #define DEFAULT_Ki (2.25*PID_dT)
|
||||
// #define DEFAULT_Kd (440/PID_dT)
|
||||
#endif
|
||||
|
||||
#ifdef PID_PI
|
||||
//PI according to Ziegler-Nichols method
|
||||
#define DEFAULT_Kp (PID_CRITIAL_GAIN/2.2)
|
||||
#define DEFAULT_Ki (1.2*Kp/PID_SWING_AT_CRITIAL*PID_dT)
|
||||
#define DEFAULT_Kd (0)
|
||||
#endif
|
||||
|
||||
// this adds an experimental additional term to the heatingpower, proportional to the extrusion speed.
|
||||
// if Kc is choosen well, the additional required power due to increased melting should be compensated.
|
||||
#define PID_ADD_EXTRUSION_RATE
|
||||
#ifdef PID_ADD_EXTRUSION_RATE
|
||||
#define DEFAULT_Kc (3) //heatingpower=Kc*(e_speed)
|
||||
#endif
|
||||
// #define DEFAULT_Kd (440/PID_dT)
|
||||
#endif // PIDTEMP
|
||||
|
||||
//this prevents dangerous Extruder moves, i.e. if the temperature is under the limit
|
||||
//can be software-disabled for whatever purposes by
|
||||
#define PREVENT_DANGEROUS_EXTRUDE
|
||||
#define EXTRUDE_MINTEMP 170
|
||||
#define EXTRUDE_MAXLENGTH (X_MAX_LENGTH+Y_MAX_LENGTH) //prevent extrusion of very large distances.
|
||||
|
||||
//===========================================================================
|
||||
//=============================Mechanical Settings===========================
|
||||
//===========================================================================
|
||||
|
||||
|
||||
// Endstop Settings
|
||||
#define ENDSTOPPULLUPS // Comment this out (using // at the start of the line) to disable the endstop pullup resistors
|
||||
// The pullups are needed if you directly connect a mechanical endswitch between the signal and ground pins.
|
||||
const bool ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops.
|
||||
// For optos H21LOB set to true, for Mendel-Parts newer optos TCST2103 set to false
|
||||
|
||||
// The pullups are needed if you directly connect a mechanical endswitch between the signal and ground pins.
|
||||
const bool X_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops.
|
||||
const bool Y_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops.
|
||||
const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops.
|
||||
|
||||
// For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1
|
||||
#define X_ENABLE_ON 0
|
||||
#define Y_ENABLE_ON 0
|
||||
#define Z_ENABLE_ON 0
|
||||
#define E_ENABLE_ON 0
|
||||
#define E_ENABLE_ON 0 // For all extruders
|
||||
|
||||
// Disables axis when it's not being used.
|
||||
#define DISABLE_X false
|
||||
#define DISABLE_Y false
|
||||
#define DISABLE_Z false
|
||||
#define DISABLE_E false
|
||||
#define DISABLE_E false // For all extruders
|
||||
|
||||
// Inverting axis direction
|
||||
//#define INVERT_X_DIR false // for Mendel set to false, for Orca set to true
|
||||
//#define INVERT_Y_DIR true // for Mendel set to true, for Orca set to false
|
||||
//#define INVERT_Z_DIR false // for Mendel set to false, for Orca set to true
|
||||
//#define INVERT_E_DIR true // for direct drive extruder v9 set to true, for geared extruder set to false
|
||||
|
||||
#define INVERT_X_DIR true // for Mendel set to false, for Orca set to true
|
||||
#define INVERT_X_DIR true // for Mendel set to false, for Orca set to true
|
||||
#define INVERT_Y_DIR false // for Mendel set to true, for Orca set to false
|
||||
#define INVERT_Z_DIR true // for Mendel set to false, for Orca set to true
|
||||
#define INVERT_E_DIR false // for direct drive extruder v9 set to true, for geared extruder set to false
|
||||
#define INVERT_E0_DIR false // for direct drive extruder v9 set to true, for geared extruder set to false
|
||||
#define INVERT_E1_DIR false // for direct drive extruder v9 set to true, for geared extruder set to false
|
||||
#define INVERT_E2_DIR false // for direct drive extruder v9 set to true, for geared extruder set to false
|
||||
|
||||
//// ENDSTOP SETTINGS:
|
||||
// ENDSTOP SETTINGS:
|
||||
// Sets direction of endstops when homing; 1=MAX, -1=MIN
|
||||
#define X_HOME_DIR -1
|
||||
#define Y_HOME_DIR -1
|
||||
#define Z_HOME_DIR -1
|
||||
|
||||
#define min_software_endstops false //If true, axis won't move to coordinates less than zero.
|
||||
#define max_software_endstops false //If true, axis won't move to coordinates greater than the defined lengths below.
|
||||
#define X_MAX_LENGTH 210
|
||||
#define Y_MAX_LENGTH 210
|
||||
#define Z_MAX_LENGTH 210
|
||||
#define min_software_endstops true //If true, axis won't move to coordinates less than zero.
|
||||
#define max_software_endstops true //If true, axis won't move to coordinates greater than the defined lengths below.
|
||||
#define X_MAX_LENGTH 205
|
||||
#define Y_MAX_LENGTH 205
|
||||
#define Z_MAX_LENGTH 200
|
||||
|
||||
//// MOVEMENT SETTINGS
|
||||
#define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E
|
||||
#define HOMING_FEEDRATE {50*60, 50*60, 4*60, 0} // set the homing speeds (mm/min)
|
||||
|
||||
#define AXIS_RELATIVE_MODES {false, false, false, false}
|
||||
|
||||
#define MAX_STEP_FREQUENCY 40000 // Max step frequency for Ultimaker (5000 pps / half step)
|
||||
|
||||
// default settings
|
||||
|
||||
#define DEFAULT_AXIS_STEPS_PER_UNIT {78.7402,78.7402,200*8/3,760*1.1} // default steps per unit for ultimaker
|
||||
//#define DEFAULT_AXIS_STEPS_PER_UNIT {40, 40, 3333.92, 67} //sells mendel with v9 extruder
|
||||
#define DEFAULT_MAX_FEEDRATE {500, 500, 5, 200000} // (mm/sec)
|
||||
#define DEFAULT_MAX_FEEDRATE {500, 500, 5, 45} // (mm/sec)
|
||||
#define DEFAULT_MAX_ACCELERATION {9000,9000,100,10000} // X, Y, Z, E maximum start speed for accelerated moves. E default values are good for skeinforge 40+, for older versions raise them a lot.
|
||||
|
||||
#define DEFAULT_ACCELERATION 3000 // X, Y, Z and E max acceleration in mm/s^2 for printing moves
|
||||
#define DEFAULT_RETRACT_ACCELERATION 7000 // X, Y, Z and E max acceleration in mm/s^2 for r retracts
|
||||
#define DEFAULT_RETRACT_ACCELERATION 3000 // X, Y, Z and E max acceleration in mm/s^2 for r retracts
|
||||
|
||||
#define DEFAULT_MINIMUMFEEDRATE 0.0 // minimum feedrate
|
||||
#define DEFAULT_MINTRAVELFEEDRATE 0.0
|
||||
|
||||
// minimum time in microseconds that a movement needs to take if the buffer is emptied. Increase this number if you see blobs while printing high speed & high detail. It will slowdown on the detailed stuff.
|
||||
#define DEFAULT_MINSEGMENTTIME 20000 // Obsolete delete this
|
||||
#define DEFAULT_XYJERK 30.0 // (mm/sec)
|
||||
//
|
||||
#define DEFAULT_XYJERK 20.0 // (mm/sec)
|
||||
#define DEFAULT_ZJERK 0.4 // (mm/sec)
|
||||
|
||||
|
||||
|
||||
|
||||
//===========================================================================
|
||||
//=============================Additional Features===========================
|
||||
//===========================================================================
|
||||
@@ -235,45 +170,14 @@ const bool ENDSTOPS_INVERTING = true; // set to true to invert the logic of the
|
||||
// M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).
|
||||
// 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 EEPROM_SETTINGS
|
||||
//#define EEPROM_SETTINGS
|
||||
//to disable EEPROM Serial responses and decrease program space by ~1700 byte: comment this out:
|
||||
// please keep turned on if you can.
|
||||
#define EEPROM_CHITCHAT
|
||||
|
||||
|
||||
// The hardware watchdog should halt the Microcontroller, in case the firmware gets stuck somewhere. However:
|
||||
// the Watchdog is not working well, so please only enable this for testing
|
||||
// this enables the watchdog interrupt.
|
||||
//#define USE_WATCHDOG
|
||||
//#ifdef USE_WATCHDOG
|
||||
// you cannot reboot on a mega2560 due to a bug in he bootloader. Hence, you have to reset manually, and this is done hereby:
|
||||
//#define RESET_MANUAL
|
||||
//#define WATCHDOG_TIMEOUT 4 //seconds
|
||||
//#endif
|
||||
|
||||
// extruder advance constant (s2/mm3)
|
||||
//
|
||||
// advance (steps) = STEPS_PER_CUBIC_MM_E * EXTUDER_ADVANCE_K * cubic mm per second ^ 2
|
||||
//
|
||||
// hooke's law says: force = k * distance
|
||||
// bernoulli's priniciple says: v ^ 2 / 2 + g . h + pressure / density = constant
|
||||
// so: v ^ 2 is proportional to number of steps we advance the extruder
|
||||
//#define ADVANCE
|
||||
|
||||
#ifdef ADVANCE
|
||||
#define EXTRUDER_ADVANCE_K .3
|
||||
|
||||
#define D_FILAMENT 1.7
|
||||
#define STEPS_MM_E 65
|
||||
#define EXTRUTION_AREA (0.25 * D_FILAMENT * D_FILAMENT * 3.14159)
|
||||
#define STEPS_PER_CUBIC_MM_E (axis_steps_per_unit[E_AXIS]/ EXTRUTION_AREA)
|
||||
|
||||
#endif // ADVANCE
|
||||
|
||||
//#define EEPROM_CHITCHAT
|
||||
|
||||
//LCD and SD support
|
||||
//#define ULTRA_LCD //general lcd support, also 16x2
|
||||
//#define SDSUPPORT // Enable SD Card Support in Hardware Console
|
||||
#define SDSUPPORT // Enable SD Card Support in Hardware Console
|
||||
|
||||
//#define ULTIPANEL
|
||||
#ifdef ULTIPANEL
|
||||
@@ -289,50 +193,11 @@ const bool ENDSTOPS_INVERTING = true; // set to true to invert the logic of the
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// A debugging feature to compare calculated vs performed steps, to see if steps are lost by the software.
|
||||
//#define DEBUG_STEPS
|
||||
|
||||
|
||||
// Arc interpretation settings:
|
||||
#define MM_PER_ARC_SEGMENT 1
|
||||
#define N_ARC_CORRECTION 25
|
||||
|
||||
|
||||
//automatic temperature: The hot end target temperature is calculated by all the buffered lines of gcode.
|
||||
//The maximum buffered steps/sec of the extruder motor are called "se".
|
||||
//You enter the autotemp mode by a M109 S<mintemp> T<maxtemp> F<factor>
|
||||
// the target temperature is set to mintemp+factor*se[steps/sec] and limited by mintemp and maxtemp
|
||||
// you exit the value by any M109 without F*
|
||||
// Also, if the temperature is set to a value <mintemp, it is not changed by autotemp.
|
||||
// on an ultimaker, some initial testing worked with M109 S215 T260 F0.1 in the start.gcode
|
||||
//#define AUTOTEMP
|
||||
#ifdef AUTOTEMP
|
||||
#define AUTOTEMP_OLDWEIGHT 0.98
|
||||
#endif
|
||||
|
||||
|
||||
const int dropsegments=5; //everything with less than this number of steps will be ignored as move and joined with the next movement
|
||||
|
||||
//===========================================================================
|
||||
//=============================Buffers ============================
|
||||
//===========================================================================
|
||||
|
||||
|
||||
|
||||
// The number of linear motions that can be in the plan at any give time.
|
||||
// THE BLOCK_BUFFER_SIZE NEEDS TO BE A POWER OF 2, i.g. 8,16,32 because shifts and ors are used to do the ringbuffering.
|
||||
#if defined SDSUPPORT
|
||||
#define BLOCK_BUFFER_SIZE 16 // SD,LCD,Buttons take more memory, block buffer needs to be smaller
|
||||
#else
|
||||
#define BLOCK_BUFFER_SIZE 16 // maximize block buffer
|
||||
#endif
|
||||
|
||||
|
||||
//The ASCII buffer for recieving from the serial:
|
||||
#define MAX_CMD_SIZE 96
|
||||
#define BUFSIZE 4
|
||||
|
||||
// M240 Triggers a camera by emulating a Canon RC-1 Remote
|
||||
// Data from: http://www.doc-diy.net/photo/rc-1_hacked/
|
||||
// #define PHOTOGRAPH_PIN 23
|
||||
|
||||
#include "Configuration_adv.h"
|
||||
#include "thermistortables.h"
|
||||
|
||||
#endif //__CONFIGURATION_H
|
||||
|
||||
@@ -0,0 +1,221 @@
|
||||
#ifndef __CONFIGURATION_ADV_H
|
||||
#define __CONFIGURATION_ADV_H
|
||||
|
||||
//===========================================================================
|
||||
//=============================Thermal Settings ============================
|
||||
//===========================================================================
|
||||
|
||||
// Select one of these only to define how the bed temp is read.
|
||||
//
|
||||
//#define BED_LIMIT_SWITCHING
|
||||
#ifdef BED_LIMIT_SWITCHING
|
||||
#define BED_HYSTERESIS 2 //only disable heating if T>target+BED_HYSTERESIS and enable heating if T>target-BED_HYSTERESIS
|
||||
#endif
|
||||
#define BED_CHECK_INTERVAL 5000 //ms
|
||||
|
||||
//// Heating sanity check:
|
||||
// This waits for the watchperiod in milliseconds whenever an M104 or M109 increases the target temperature
|
||||
// If the temperature has not increased at the end of that period, the target temperature is set to zero.
|
||||
// It can be reset with another M104/M109
|
||||
//#define WATCHPERIOD 20000 //20 seconds
|
||||
|
||||
// Wait for Cooldown
|
||||
// This defines if the M109 call should not block if it is cooling down.
|
||||
// example: From a current temp of 220, you set M109 S200.
|
||||
// if CooldownNoWait is defined M109 will not wait for the cooldown to finish
|
||||
#define CooldownNoWait true
|
||||
|
||||
//Do not wait for M109 to finish when printing from SD card
|
||||
//#define STOP_HEATING_WAIT_WHEN_SD_PRINTING
|
||||
|
||||
#ifdef PIDTEMP
|
||||
// this adds an experimental additional term to the heatingpower, proportional to the extrusion speed.
|
||||
// if Kc is choosen well, the additional required power due to increased melting should be compensated.
|
||||
#define PID_ADD_EXTRUSION_RATE
|
||||
#ifdef PID_ADD_EXTRUSION_RATE
|
||||
#define DEFAULT_Kc (1) //heatingpower=Kc*(e_speed)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
//automatic temperature: The hot end target temperature is calculated by all the buffered lines of gcode.
|
||||
//The maximum buffered steps/sec of the extruder motor are called "se".
|
||||
//You enter the autotemp mode by a M109 S<mintemp> T<maxtemp> F<factor>
|
||||
// the target temperature is set to mintemp+factor*se[steps/sec] and limited by mintemp and maxtemp
|
||||
// you exit the value by any M109 without F*
|
||||
// Also, if the temperature is set to a value <mintemp, it is not changed by autotemp.
|
||||
// on an ultimaker, some initial testing worked with M109 S215 T260 F0.1 in the start.gcode
|
||||
//#define AUTOTEMP
|
||||
#ifdef AUTOTEMP
|
||||
#define AUTOTEMP_OLDWEIGHT 0.98
|
||||
#endif
|
||||
|
||||
// extruder run-out prevention.
|
||||
//if the machine is idle, and the temperature over MINTEMP, every couple of SECONDS some filament is extruded
|
||||
//#define EXTRUDER_RUNOUT_PREVENT
|
||||
#define EXTRUDER_RUNOUT_MINTEMP 190
|
||||
#define EXTRUDER_RUNOUT_SECONDS 30.
|
||||
#define EXTRUDER_RUNOUT_ESTEPS 14. //mm filament
|
||||
#define EXTRUDER_RUNOUT_SPEED 1500. //extrusion speed
|
||||
#define EXTRUDER_RUNOUT_EXTRUDE 100
|
||||
|
||||
//===========================================================================
|
||||
//=============================Mechanical Settings===========================
|
||||
//===========================================================================
|
||||
|
||||
// This defines the number of extruders
|
||||
#define EXTRUDERS 1
|
||||
|
||||
#define ENDSTOPS_ONLY_FOR_HOMING // If defined the endstops will only be used for homing
|
||||
|
||||
//#define Z_LATE_ENABLE // Enable Z the last moment. Needed if your Z driver overheats.
|
||||
|
||||
//homing hits the endstop, then retracts by this distance, before it tries to slowly bump again:
|
||||
#define X_HOME_RETRACT_MM 5
|
||||
#define Y_HOME_RETRACT_MM 5
|
||||
#define Z_HOME_RETRACT_MM 1
|
||||
#define QUICK_HOME //if this is defined, if both x and y are to be homed, a diagonal move will be performed initially.
|
||||
|
||||
#define AXIS_RELATIVE_MODES {false, false, false, false}
|
||||
|
||||
#define MAX_STEP_FREQUENCY 40000 // Max step frequency for Ultimaker (5000 pps / half step)
|
||||
|
||||
//default stepper release if idle
|
||||
#define DEFAULT_STEPPER_DEACTIVE_TIME 60
|
||||
|
||||
#define DEFAULT_MINIMUMFEEDRATE 0.0 // minimum feedrate
|
||||
#define DEFAULT_MINTRAVELFEEDRATE 0.0
|
||||
|
||||
// minimum time in microseconds that a movement needs to take if the buffer is emptied. Increase this number if you see blobs while printing high speed & high detail. It will slowdown on the detailed stuff.
|
||||
#define DEFAULT_MINSEGMENTTIME 20000 // Obsolete delete this
|
||||
|
||||
// If defined the movements slow down when the look ahead buffer is only half full
|
||||
#define SLOWDOWN
|
||||
|
||||
// Frequency limit
|
||||
// See nophead's blog for more info
|
||||
// Not working O
|
||||
//#define XY_FREQUENCY_LIMIT 15
|
||||
|
||||
// Minimum planner junction speed. Sets the default minimum speed the planner plans for at the end
|
||||
// of the buffer and all stops. This should not be much greater than zero and should only be changed
|
||||
// if unwanted behavior is observed on a user's machine when running at very slow speeds.
|
||||
#define MINIMUM_PLANNER_SPEED 2.0 // (mm/sec)
|
||||
|
||||
//===========================================================================
|
||||
//=============================Additional Features===========================
|
||||
//===========================================================================
|
||||
|
||||
|
||||
#define SD_FINISHED_STEPPERRELEASE true //if sd support and the file is finished: disable steppers?
|
||||
#define SD_FINISHED_RELEASECOMMAND "M84 X Y Z E" // no z because of layer shift.
|
||||
|
||||
// The hardware watchdog should halt the Microcontroller, in case the firmware gets stuck somewhere. However:
|
||||
// the Watchdog is not working well, so please only enable this for testing
|
||||
// this enables the watchdog interrupt.
|
||||
//#define USE_WATCHDOG
|
||||
//#ifdef USE_WATCHDOG
|
||||
// you cannot reboot on a mega2560 due to a bug in he bootloader. Hence, you have to reset manually, and this is done hereby:
|
||||
//#define RESET_MANUAL
|
||||
//#define WATCHDOG_TIMEOUT 4 //seconds
|
||||
//#endif
|
||||
|
||||
// extruder advance constant (s2/mm3)
|
||||
//
|
||||
// advance (steps) = STEPS_PER_CUBIC_MM_E * EXTUDER_ADVANCE_K * cubic mm per second ^ 2
|
||||
//
|
||||
// hooke's law says: force = k * distance
|
||||
// bernoulli's priniciple says: v ^ 2 / 2 + g . h + pressure / density = constant
|
||||
// so: v ^ 2 is proportional to number of steps we advance the extruder
|
||||
//#define ADVANCE
|
||||
|
||||
#ifdef ADVANCE
|
||||
#define EXTRUDER_ADVANCE_K .0
|
||||
|
||||
#define D_FILAMENT 2.85
|
||||
#define STEPS_MM_E 836
|
||||
#define EXTRUTION_AREA (0.25 * D_FILAMENT * D_FILAMENT * 3.14159)
|
||||
#define STEPS_PER_CUBIC_MM_E (axis_steps_per_unit[E_AXIS]/ EXTRUTION_AREA)
|
||||
|
||||
#endif // ADVANCE
|
||||
|
||||
// A debugging feature to compare calculated vs performed steps, to see if steps are lost by the software.
|
||||
//#define DEBUG_STEPS
|
||||
|
||||
// Arc interpretation settings:
|
||||
#define MM_PER_ARC_SEGMENT 1
|
||||
#define N_ARC_CORRECTION 25
|
||||
|
||||
const int dropsegments=5; //everything with less than this number of steps will be ignored as move and joined with the next movement
|
||||
|
||||
//===========================================================================
|
||||
//=============================Buffers ============================
|
||||
//===========================================================================
|
||||
|
||||
// The number of linear motions that can be in the plan at any give time.
|
||||
// THE BLOCK_BUFFER_SIZE NEEDS TO BE A POWER OF 2, i.g. 8,16,32 because shifts and ors are used to do the ringbuffering.
|
||||
#if defined SDSUPPORT
|
||||
#define BLOCK_BUFFER_SIZE 16 // SD,LCD,Buttons take more memory, block buffer needs to be smaller
|
||||
#else
|
||||
#define BLOCK_BUFFER_SIZE 16 // maximize block buffer
|
||||
#endif
|
||||
|
||||
|
||||
//The ASCII buffer for recieving from the serial:
|
||||
#define MAX_CMD_SIZE 96
|
||||
#define BUFSIZE 4
|
||||
|
||||
//===========================================================================
|
||||
//============================= Define Defines ============================
|
||||
//===========================================================================
|
||||
|
||||
#if TEMP_SENSOR_0 > 0
|
||||
#define THERMISTORHEATER_0 TEMP_SENSOR_0
|
||||
#define HEATER_0_USES_THERMISTOR
|
||||
#endif
|
||||
#if TEMP_SENSOR_1 > 0
|
||||
#define THERMISTORHEATER_1 TEMP_SENSOR_1
|
||||
#define HEATER_1_USES_THERMISTOR
|
||||
#endif
|
||||
#if TEMP_SENSOR_2 > 0
|
||||
#define THERMISTORHEATER_2 TEMP_SENSOR_2
|
||||
#define HEATER_2_USES_THERMISTOR
|
||||
#endif
|
||||
#if TEMP_SENSOR_BED > 0
|
||||
#define THERMISTORBED TEMP_SENSOR_BED
|
||||
#define BED_USES_THERMISTOR
|
||||
#endif
|
||||
#if TEMP_SENSOR_0 == -1
|
||||
#define HEATER_0_USES_AD595
|
||||
#endif
|
||||
#if TEMP_SENSOR_1 == -1
|
||||
#define HEATER_1_USES_AD595
|
||||
#endif
|
||||
#if TEMP_SENSOR_2 == -1
|
||||
#define HEATER_2_USES_AD595
|
||||
#endif
|
||||
#if TEMP_SENSOR_BED == -1
|
||||
#define BED_USES_AD595
|
||||
#endif
|
||||
#if TEMP_SENSOR_0 == -2
|
||||
#define HEATER_0_USES_MAX6675
|
||||
#endif
|
||||
#if TEMP_SENSOR_0 == 0
|
||||
#undef HEATER_0_MINTEMP
|
||||
#undef HEATER_0_MAXTEMP
|
||||
#endif
|
||||
#if TEMP_SENSOR_1 == 0
|
||||
#undef HEATER_1_MINTEMP
|
||||
#undef HEATER_1_MAXTEMP
|
||||
#endif
|
||||
#if TEMP_SENSOR_2 == 0
|
||||
#undef HEATER_2_MINTEMP
|
||||
#undef HEATER_2_MAXTEMP
|
||||
#endif
|
||||
#if TEMP_SENSOR_BED == 0
|
||||
#undef BED_MINTEMP
|
||||
#undef BED_MAXTEMP
|
||||
#endif
|
||||
|
||||
|
||||
#endif //__CONFIGURATION_ADV_H
|
||||
+66
-56
@@ -4,14 +4,16 @@
|
||||
#include "Marlin.h"
|
||||
#include "planner.h"
|
||||
#include "temperature.h"
|
||||
#include <EEPROM.h>
|
||||
//#include <EEPROM.h>
|
||||
|
||||
|
||||
|
||||
template <class T> int EEPROM_writeAnything(int &ee, const T& value)
|
||||
{
|
||||
const byte* p = (const byte*)(const void*)&value;
|
||||
int i;
|
||||
for (i = 0; i < (int)sizeof(value); i++)
|
||||
EEPROM.write(ee++, *p++);
|
||||
eeprom_write_byte((unsigned char *)ee++, *p++);
|
||||
return i;
|
||||
}
|
||||
|
||||
@@ -20,7 +22,7 @@ template <class T> int EEPROM_readAnything(int &ee, T& value)
|
||||
byte* p = (byte*)(void*)&value;
|
||||
int i;
|
||||
for (i = 0; i < (int)sizeof(value); i++)
|
||||
*p++ = EEPROM.read(ee++);
|
||||
*p++ = eeprom_read_byte((unsigned char *)ee++);
|
||||
return i;
|
||||
}
|
||||
//======================================================================================
|
||||
@@ -38,7 +40,7 @@ template <class T> int EEPROM_readAnything(int &ee, T& value)
|
||||
// ALSO: always make sure the variables in the Store and retrieve sections are in the same order.
|
||||
#define EEPROM_VERSION "V04"
|
||||
|
||||
inline void StoreSettings()
|
||||
inline void EEPROM_StoreSettings()
|
||||
{
|
||||
#ifdef EEPROM_SETTINGS
|
||||
char ver[4]= "000";
|
||||
@@ -71,7 +73,64 @@ inline void StoreSettings()
|
||||
#endif //EEPROM_SETTINGS
|
||||
}
|
||||
|
||||
inline void RetrieveSettings(bool def=false)
|
||||
|
||||
inline void EEPROM_printSettings()
|
||||
{ // if def=true, the default values will be used
|
||||
#ifdef EEPROM_SETTINGS
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOLNPGM("Steps per unit:");
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOPAIR(" M92 X",axis_steps_per_unit[0]);
|
||||
SERIAL_ECHOPAIR(" Y",axis_steps_per_unit[1]);
|
||||
SERIAL_ECHOPAIR(" Z",axis_steps_per_unit[2]);
|
||||
SERIAL_ECHOPAIR(" E",axis_steps_per_unit[3]);
|
||||
SERIAL_ECHOLN("");
|
||||
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOLNPGM("Maximum feedrates (mm/s):");
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOPAIR(" M203 X",max_feedrate[0]);
|
||||
SERIAL_ECHOPAIR(" Y",max_feedrate[1] );
|
||||
SERIAL_ECHOPAIR(" Z", max_feedrate[2] );
|
||||
SERIAL_ECHOPAIR(" E", max_feedrate[3]);
|
||||
SERIAL_ECHOLN("");
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOLNPGM("Maximum Acceleration (mm/s2):");
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOPAIR(" M201 X" ,max_acceleration_units_per_sq_second[0] );
|
||||
SERIAL_ECHOPAIR(" Y" , max_acceleration_units_per_sq_second[1] );
|
||||
SERIAL_ECHOPAIR(" Z" ,max_acceleration_units_per_sq_second[2] );
|
||||
SERIAL_ECHOPAIR(" E" ,max_acceleration_units_per_sq_second[3]);
|
||||
SERIAL_ECHOLN("");
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOLNPGM("Acceleration: S=acceleration, T=retract acceleration");
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOPAIR(" M204 S",acceleration );
|
||||
SERIAL_ECHOPAIR(" T" ,retract_acceleration);
|
||||
SERIAL_ECHOLN("");
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOLNPGM("Advanced variables: S=Min feedrate (mm/s), T=Min travel feedrate (mm/s), B=minimum segment time (ms), X=maximum xY jerk (mm/s), Z=maximum Z jerk (mm/s)");
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOPAIR(" M205 S",minimumfeedrate );
|
||||
SERIAL_ECHOPAIR(" T" ,mintravelfeedrate );
|
||||
SERIAL_ECHOPAIR(" B" ,minsegmenttime );
|
||||
SERIAL_ECHOPAIR(" X" ,max_xy_jerk );
|
||||
SERIAL_ECHOPAIR(" Z" ,max_z_jerk);
|
||||
SERIAL_ECHOLN("");
|
||||
#ifdef PIDTEMP
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOLNPGM("PID settings:");
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOPAIR(" M301 P",Kp);
|
||||
SERIAL_ECHOPAIR(" I" ,Ki/PID_dT);
|
||||
SERIAL_ECHOPAIR(" D" ,Kd*PID_dT);
|
||||
SERIAL_ECHOLN("");
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
inline void EEPROM_RetrieveSettings(bool def=false)
|
||||
{ // if def=true, the default values will be used
|
||||
#ifdef EEPROM_SETTINGS
|
||||
int i=EEPROM_OFFSET;
|
||||
@@ -102,6 +161,7 @@ inline void RetrieveSettings(bool def=false)
|
||||
SERIAL_ECHOLNPGM("Stored settings retreived:");
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
float tmp1[]=DEFAULT_AXIS_STEPS_PER_UNIT;
|
||||
float tmp2[]=DEFAULT_MAX_FEEDRATE;
|
||||
@@ -123,58 +183,8 @@ inline void RetrieveSettings(bool def=false)
|
||||
SERIAL_ECHOLN("Using Default settings:");
|
||||
}
|
||||
#ifdef EEPROM_CHITCHAT
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOLNPGM("Steps per unit:");
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOPAIR(" M92 X",axis_steps_per_unit[0]);
|
||||
SERIAL_ECHOPAIR(" Y",axis_steps_per_unit[1]);
|
||||
SERIAL_ECHOPAIR(" Z",axis_steps_per_unit[2]);
|
||||
SERIAL_ECHOPAIR(" E",axis_steps_per_unit[3]);
|
||||
SERIAL_ECHOLN("");
|
||||
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOLNPGM("Maximum feedrates (mm/s):");
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOPAIR(" M203 X",max_feedrate[0]/60);
|
||||
SERIAL_ECHOPAIR(" Y",max_feedrate[1]/60 );
|
||||
SERIAL_ECHOPAIR(" Z", max_feedrate[2]/60 );
|
||||
SERIAL_ECHOPAIR(" E", max_feedrate[3]/60);
|
||||
SERIAL_ECHOLN("");
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOLNPGM("Maximum Acceleration (mm/s2):");
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOPAIR(" M201 X" ,max_acceleration_units_per_sq_second[0] );
|
||||
SERIAL_ECHOPAIR(" Y" , max_acceleration_units_per_sq_second[1] );
|
||||
SERIAL_ECHOPAIR(" Z" ,max_acceleration_units_per_sq_second[2] );
|
||||
SERIAL_ECHOPAIR(" E" ,max_acceleration_units_per_sq_second[3]);
|
||||
SERIAL_ECHOLN("");
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOLNPGM("Acceleration: S=acceleration, T=retract acceleration");
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOPAIR(" M204 S",acceleration );
|
||||
SERIAL_ECHOPAIR(" T" ,retract_acceleration);
|
||||
SERIAL_ECHOLN("");
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOLNPGM("Advanced variables: S=Min feedrate (mm/s), T=Min travel feedrate (mm/s), B=minimum segment time (ms), X=maximum xY jerk (mm/s), Z=maximum Z jerk (mm/s)");
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOPAIR(" M205 S",minimumfeedrate/60 );
|
||||
SERIAL_ECHOPAIR(" T" ,mintravelfeedrate/60 );
|
||||
SERIAL_ECHOPAIR(" B" ,minsegmenttime );
|
||||
SERIAL_ECHOPAIR(" X" ,max_xy_jerk/60 );
|
||||
SERIAL_ECHOPAIR(" Z" ,max_z_jerk/60);
|
||||
SERIAL_ECHOLN("");
|
||||
#ifdef PIDTEMP
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOLNPGM("PID settings:");
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOPAIR(" M301 P",Kp );
|
||||
SERIAL_ECHOPAIR(" I" ,Ki );
|
||||
SERIAL_ECHOPAIR(" D" ,Kd);
|
||||
SERIAL_ECHOLN("");
|
||||
#endif
|
||||
EEPROM_printSettings();
|
||||
#endif
|
||||
|
||||
#endif //EEPROM_SETTINGS
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+154
-227
@@ -1,51 +1,70 @@
|
||||
# Sprinter Arduino Project Makefile
|
||||
#
|
||||
# Makefile Based on:
|
||||
# Arduino 0011 Makefile
|
||||
# Arduino adaptation by mellis, eighthave, oli.keller
|
||||
#
|
||||
# This has been tested with Arduino 0022.
|
||||
#
|
||||
# This makefile allows you to build sketches from the command line
|
||||
# without the Arduino environment (or Java).
|
||||
#
|
||||
# Detailed instructions for using the makefile:
|
||||
#
|
||||
# 1. Modify the line containg "INSTALL_DIR" to point to the directory that
|
||||
# contains the Arduino installation (for example, under Mac OS X, this
|
||||
# might be /Applications/arduino-0012).
|
||||
#
|
||||
# 2. Modify the line containing "PORT" to refer to the filename
|
||||
# representing the USB or serial connection to your Arduino board
|
||||
# (e.g. PORT = /dev/tty.USB0). If the exact name of this file
|
||||
# changes, you can use * as a wildcard (e.g. PORT = /dev/tty.usb*).
|
||||
#
|
||||
# 3. Set the line containing "MCU" to match your board's processor.
|
||||
# Older one's are atmega8 based, newer ones like Arduino Mini, Bluetooth
|
||||
# or Diecimila have the atmega168. If you're using a LilyPad Arduino,
|
||||
# change F_CPU to 8000000.
|
||||
#
|
||||
# 4. Type "make" and press enter to compile/verify your program.
|
||||
#
|
||||
# 5. Type "make upload", reset your Arduino board, and press enter to
|
||||
# upload your program to the Arduino board.
|
||||
#
|
||||
# $Id$
|
||||
|
||||
#For "old" Arduino Mega
|
||||
MCU = atmega1280
|
||||
#For Arduino Mega2560
|
||||
#MCU = atmega2560
|
||||
#For Sanguinololu
|
||||
#MCU = atmega644p
|
||||
|
||||
#Arduino install directory
|
||||
INSTALL_DIR = ../../arduino-0022/
|
||||
|
||||
F_CPU = 16000000
|
||||
|
||||
UPLOAD_RATE = 115200
|
||||
AVRDUDE_PROGRAMMER = arduino
|
||||
PORT = /dev/arduino
|
||||
|
||||
TARGET = $(notdir $(CURDIR))
|
||||
# CHANGE BELOW:
|
||||
#~ INSTALL_DIR = /Applications/Arduino.app/Contents/Resources/Java
|
||||
INSTALL_DIR = /home/bkubicek/software/arduino-0022
|
||||
#~ PORT = /dev/cu.usbserial*
|
||||
PORT = /dev/ttyACM0
|
||||
|
||||
# Get these values from:
|
||||
# $(INSTALL_DIR)/hardware/boards.txt
|
||||
# (arduino-0022/hardware/arduino/boards.txt)
|
||||
# The values below are for the "Arduino Duemilanove or Nano w/ ATmega328"
|
||||
# now for "Arduino Mega 2560"
|
||||
UPLOAD_SPEED = 115200
|
||||
UPLOAD_PROTOCOL = stk500v2
|
||||
BUILD_MCU = atmega2560
|
||||
BUILD_F_CPU = 16000000L
|
||||
TERM=bash
|
||||
|
||||
# getting undefined reference to `__cxa_pure_virtual'
|
||||
#~ [http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1254180518 Arduino Forum - Makefile]
|
||||
#~ http://www.arduino.cc/playground/OpenBSD/CLI
|
||||
#~ [http://arduino.cc/forum/index.php?topic=52041.0 A "simple" makefile for Arduino]
|
||||
#~ [http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1275488191 Arduino Forum - Configuring avr-gcc options in arduino IDE]
|
||||
# found in /usr/lib/gcc/avr/4.3.5/cc1plus; fixed with -Wl,--gc-section
|
||||
|
||||
############################################################################
|
||||
# Below here nothing should be changed...
|
||||
|
||||
ARDUINO = $(INSTALL_DIR)/hardware/arduino/cores/arduino
|
||||
#
|
||||
#~ AVR_TOOLS_PATH = $(INSTALL_DIR)/hardware/tools/avr/bin
|
||||
# in Ubuntu, avr-gcc is installed separate;
|
||||
# only avrdude comes with the IDE
|
||||
AVR_TOOLS_PATH = /usr/bin
|
||||
AVR_DUDE_PATH = $(INSTALL_DIR)/hardware/tools
|
||||
#
|
||||
SRC = $(ARDUINO)/pins_arduino.c $(ARDUINO)/wiring.c \
|
||||
$(ARDUINO)/wiring_analog.c $(ARDUINO)/wiring_digital.c \
|
||||
$(ARDUINO)/wiring_pulse.c \
|
||||
$(ARDUINO)/wiring_shift.c $(ARDUINO)/WInterrupts.c
|
||||
# added applet/$(TARGET).cpp as in IDE 0022
|
||||
CXXSRC = $(ARDUINO)/HardwareSerial.cpp $(ARDUINO)/WMath.cpp \
|
||||
$(ARDUINO)/Print.cpp \
|
||||
$(ARDUINO)/main.cpp
|
||||
# applet/$(TARGET).cpp # no need, having a rule now for applet/$(TARGET).cpp.o
|
||||
# added main.cpp, as in 0022
|
||||
AVR_TOOLS_PATH =
|
||||
SRC = $(ARDUINO)/pins_arduino.c $(ARDUINO)/wiring.c \
|
||||
$(ARDUINO)/wiring_analog.c $(ARDUINO)/wiring_digital.c \
|
||||
$(ARDUINO)/wiring_pulse.c \
|
||||
$(ARDUINO)/wiring_shift.c $(ARDUINO)/WInterrupts.c
|
||||
CXXSRC = $(ARDUINO)/WMath.cpp $(ARDUINO)/WString.cpp\
|
||||
$(ARDUINO)/Print.cpp Marlin.cpp MarlinSerial.cpp Sd2Card.cpp SdBaseFile.cpp SdFatUtil.cpp SdFile.cpp SdVolume.cpp motion_control.cpp planner.cpp stepper.cpp temperature.cpp cardreader.cpp
|
||||
FORMAT = ihex
|
||||
|
||||
|
||||
# Name of this Makefile (used for "make depend").
|
||||
MAKEFILE = Makefile
|
||||
|
||||
@@ -54,189 +73,133 @@ MAKEFILE = Makefile
|
||||
# AVR (extended) COFF requires stabs, plus an avr-objcopy run.
|
||||
DEBUG = stabs
|
||||
|
||||
OPT = 2
|
||||
OPT = s
|
||||
|
||||
# Place -D or -U options here
|
||||
#~ CDEFS = -DBUILD_F_CPU=$(BUILD_F_CPU)
|
||||
#~ CXXDEFS = -DBUILD_F_CPU=$(BUILD_F_CPU)
|
||||
# now called DF_CPU
|
||||
CDEFS = -DF_CPU=$(BUILD_F_CPU) -DARDUINO=22
|
||||
CXXDEFS = -DF_CPU=$(BUILD_F_CPU) -DARDUINO=22
|
||||
CDEFS = -DF_CPU=$(F_CPU)
|
||||
CXXDEFS = -DF_CPU=$(F_CPU)
|
||||
|
||||
# Place -I options here
|
||||
CINCS = -I$(ARDUINO) -I$(INSTALL_DIR)/libraries/LiquidCrystal/ -I$(INSTALL_DIR)/libraries/EEPROM/
|
||||
CINCS = -I$(ARDUINO)
|
||||
CXXINCS = -I$(ARDUINO)
|
||||
|
||||
# Compiler flag to set the C Standard level.
|
||||
# c89 - "ANSI" C
|
||||
# c89 - "ANSI" C
|
||||
# gnu89 - c89 plus GCC extensions
|
||||
# c99 - ISO C99 standard (not yet fully implemented)
|
||||
# c99 - ISO C99 standard (not yet fully implemented)
|
||||
# gnu99 - c99 plus GCC extensions
|
||||
CSTANDARD = -std=gnu99
|
||||
#CSTANDARD = -std=gnu99
|
||||
CDEBUG = -g$(DEBUG)
|
||||
# note that typically, IDE 0022 uses -w to suppress warnings (both in cpp and c)!
|
||||
CWARN = -Wall
|
||||
#~ CWARN = -w
|
||||
# "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++:
|
||||
CCWARN = -Wstrict-prototypes
|
||||
CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
|
||||
CWARN = -Wall -Wstrict-prototypes
|
||||
CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -w -ffunction-sections -fdata-sections -DARDUINO=22
|
||||
#CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
|
||||
|
||||
# to eliminate pins_ardiuno warnings:
|
||||
# http://arduino.cc/pipermail/developers_arduino.cc/2010-December/004005.html
|
||||
|
||||
# [http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1254180518 Arduino Forum - Makefile]
|
||||
#~ For building the objects files "-ffunction-sections -fdata-sections" was missing
|
||||
#~ and the final avr-gcc call needs "-Wl,--gc-section".
|
||||
CXSECTF = -fno-exceptions -ffunction-sections -fdata-sections
|
||||
CFINALF = -Wl,--gc-section
|
||||
|
||||
CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CCWARN) $(CSTANDARD) $(CEXTRA)
|
||||
# added CWARN also to .cpp
|
||||
CXXFLAGS = $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CXSECTF)
|
||||
#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
|
||||
CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CEXTRA) $(CTUNING)
|
||||
CXXFLAGS = $(CDEFS) $(CINCS) -O$(OPT) -Wall $(CEXTRA) $(CTUNING)
|
||||
#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
|
||||
LDFLAGS = -lm
|
||||
|
||||
|
||||
# Programming support using avrdude. Settings and variables.
|
||||
AVRDUDE_PORT = $(PORT)
|
||||
AVRDUDE_WRITE_FLASH = -U flash:w:applet/$(TARGET).hex
|
||||
AVRDUDE_FLAGS = -V -F \
|
||||
-p $(BUILD_MCU) -P $(AVRDUDE_PORT) -c $(UPLOAD_PROTOCOL) \
|
||||
-b $(UPLOAD_SPEED) -C $(INSTALL_DIR)/hardware/tools/avrdude.conf
|
||||
# -b $(UPLOAD_SPEED) -C $(INSTALL_DIR)/hardware/tools/avr/etc/avrdude.conf
|
||||
AVRDUDE_WRITE_FLASH = -U flash:w:applet/$(TARGET).hex:i
|
||||
AVRDUDE_FLAGS = -D -C $(INSTALL_DIR)/hardware/tools/avrdude.conf \
|
||||
-p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) \
|
||||
-b $(UPLOAD_RATE)
|
||||
|
||||
# Program settings
|
||||
CC = $(AVR_TOOLS_PATH)/avr-gcc
|
||||
CXX = $(AVR_TOOLS_PATH)/avr-g++
|
||||
OBJCOPY = $(AVR_TOOLS_PATH)/avr-objcopy
|
||||
OBJDUMP = $(AVR_TOOLS_PATH)/avr-objdump
|
||||
AR = $(AVR_TOOLS_PATH)/avr-ar
|
||||
SIZE = $(AVR_TOOLS_PATH)/avr-size
|
||||
NM = $(AVR_TOOLS_PATH)/avr-nm
|
||||
#~ AVRDUDE = $(AVR_TOOLS_PATH)/avrdude
|
||||
AVRDUDE = $(AVR_DUDE_PATH)/avrdude
|
||||
CC = $(AVR_TOOLS_PATH)avr-gcc
|
||||
CXX = $(AVR_TOOLS_PATH)avr-g++
|
||||
OBJCOPY = $(AVR_TOOLS_PATH)avr-objcopy
|
||||
OBJDUMP = $(AVR_TOOLS_PATH)avr-objdump
|
||||
AR = $(AVR_TOOLS_PATH)avr-ar
|
||||
SIZE = $(AVR_TOOLS_PATH)avr-size
|
||||
NM = $(AVR_TOOLS_PATH)avr-nm
|
||||
AVRDUDE = avrdude
|
||||
REMOVE = rm -f
|
||||
MV = mv -f
|
||||
|
||||
# Define all object files.
|
||||
# NOTE: obj files will be created in respective src directories (libraries or $(INSTALL_DIR));
|
||||
# make clean deletes them fine
|
||||
# note that srcs are in libraries or other directories;
|
||||
# $(CXXSRC:.cpp=.o) will cause obj files to be in same loc as src files
|
||||
#~ OBJ = $(SRC:.c=.o) $(CXXSRC:.cpp=.o) $(ASRC:.S=.o)
|
||||
# to change the output directory for object files;
|
||||
# must change the obj list here!
|
||||
# and then, match to corresponding rule somehow?
|
||||
# or leave this - and parse in rule (auth automatic variable $(@F))?
|
||||
# "Suffix Replacement"
|
||||
OBJ = $(SRC:.c=.o) $(CXXSRC:.cpp=.o) $(ASRC:.S=.o)
|
||||
|
||||
# added - OBJ list, transformed into applet/
|
||||
OBJT = $(addprefix applet/,$(notdir $(OBJ)))
|
||||
ALLSRC = $(SRC) $(CXXSRC) $(ASRC)
|
||||
OBJ = $(SRC:.c=.o) $(CXXSRC:.cpp=.o) $(ASRC:.S=.o)
|
||||
|
||||
# Define all listing files.
|
||||
LST = $(ASRC:.S=.lst) $(CXXSRC:.cpp=.lst) $(SRC:.c=.lst)
|
||||
|
||||
# Combine all necessary flags and optional flags.
|
||||
# Add target processor to flags.
|
||||
ALL_CFLAGS = -mmcu=$(BUILD_MCU) -I. $(CFLAGS)
|
||||
ALL_CXXFLAGS = -mmcu=$(BUILD_MCU) -I. $(CXXFLAGS)
|
||||
ALL_ASFLAGS = -mmcu=$(BUILD_MCU) -I. -x assembler-with-cpp $(ASFLAGS)
|
||||
ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
|
||||
ALL_CXXFLAGS = -mmcu=$(MCU) -I. $(CXXFLAGS)
|
||||
ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
|
||||
|
||||
# depended libraries of .pde need to be added from
|
||||
# $(INSTALL_DIR)/libraries (TODO: and/or ~/sketchbook/libraries)
|
||||
# grep for 'include', test if exists, add...
|
||||
# note: prefix "a real tab character" http://www.delorie.com/djgpp/doc/ug/larger/makefiles.html
|
||||
# $$ to escape $ for shell;
|
||||
# note: must NOT put comments # inside bash execution;
|
||||
# those would get removed by make; making shell see "EOF in backquote substitution"
|
||||
# echo $$ix ; \
|
||||
# 'shell' twice - for each subprocess! Backtick doesn't get expanded?
|
||||
GREPRES:=$(shell for ix in $(shell grep include $(TARGET).pde | sed 's/.*[<"]\(.*\).h[>"].*/\1/'); do \
|
||||
if [ -d $(INSTALL_DIR)/libraries/$$ix ] ; then \
|
||||
LINCS="$$LINCS -I$(INSTALL_DIR)/libraries/$$ix" ;\
|
||||
fi; \
|
||||
done; \
|
||||
echo $$LINCS)
|
||||
# append includes:
|
||||
CINCS += $(GREPRES)
|
||||
CXXINCS += $(GREPRES)
|
||||
# append library source .cpp files too (CXXSRC)
|
||||
GREPRESB:=$(shell for ix in $(shell grep include $(TARGET).pde | sed 's/.*[<"]\(.*\).h[>"].*/\1/'); do \
|
||||
if [ -d $(INSTALL_DIR)/libraries/$$ix ] ; then \
|
||||
CPPSRCS="$$CPPSRCS $(INSTALL_DIR)/libraries/$$ix/*.cpp" ;\
|
||||
fi; \
|
||||
done; \
|
||||
echo $$CPPSRCS)
|
||||
CXXSRC += $(GREPRESB)
|
||||
# added - only CXX obj from libraries:
|
||||
CXXLIBOBJ = $(GREPRESB:.cpp=.o)
|
||||
|
||||
# Default target.
|
||||
all: applet_files build sizeafter
|
||||
all: build sizeafter
|
||||
|
||||
build: elf hex
|
||||
|
||||
applet_files: $(TARGET).pde
|
||||
# Here is the "preprocessing".
|
||||
# It creates a .cpp file based with the same name as the .pde file.
|
||||
# On top of the new .cpp file comes the WProgram.h header.
|
||||
# At the end there is a generic main() function attached.
|
||||
# Then the .cpp file will be compiled. Errors during compile will
|
||||
# refer to this new, automatically generated, file.
|
||||
# Not the original .pde file you actually edit...
|
||||
test -d applet || mkdir applet
|
||||
# @ supresses printout of the cmdline itself; so only the out of echo is printed
|
||||
@echo ALL OBJT: $(OBJT)
|
||||
@echo ALL CXXLIBOBJ: $(CXXLIBOBJ)
|
||||
# echo '#include "WProgram.h"' > applet/$(TARGET).cpp
|
||||
@echo "#include \"WProgram.h\"\nvoid setup();\nvoid loop();\n" > applet/$(TARGET).cpp
|
||||
cat $(TARGET).pde >> applet/$(TARGET).cpp
|
||||
# no more need to cat main.cpp (v0022) - now it is compiled in
|
||||
# cat $(ARDUINO)/main.cpp >> applet/$(TARGET).cpp
|
||||
build: elf hex
|
||||
|
||||
applet/$(TARGET).cpp: $(TARGET).pde $(MAKEFILE)
|
||||
# Here is the "preprocessing".
|
||||
# It creates a .cpp file based with the same name as the .pde file.
|
||||
# On top of the new .cpp file comes the WProgram.h header.
|
||||
# At the end there is a generic main() function attached.
|
||||
# Then the .cpp file will be compiled. Errors during compile will
|
||||
# refer to this new, automatically generated, file.
|
||||
# Not the original .pde file you actually edit...
|
||||
@echo " WR applet/$(TARGET).cpp"
|
||||
@test -d applet || mkdir applet
|
||||
@echo '#include "WProgram.h"' > applet/$(TARGET).cpp
|
||||
@cat $(TARGET).pde >> applet/$(TARGET).cpp
|
||||
@cat $(ARDUINO)/main.cpp >> applet/$(TARGET).cpp
|
||||
|
||||
elf: applet/$(TARGET).elf
|
||||
hex: applet/$(TARGET).hex
|
||||
eep: applet/$(TARGET).eep
|
||||
lss: applet/$(TARGET).lss
|
||||
lss: applet/$(TARGET).lss
|
||||
sym: applet/$(TARGET).sym
|
||||
|
||||
# Program the device.
|
||||
# Program the device.
|
||||
upload: applet/$(TARGET).hex
|
||||
stty hup < $(PORT); true
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
|
||||
stty -hup < $(PORT); true
|
||||
|
||||
# Display size of file.
|
||||
|
||||
# Display size of file.
|
||||
HEXSIZE = $(SIZE) --target=$(FORMAT) applet/$(TARGET).hex
|
||||
ELFSIZE = $(SIZE) applet/$(TARGET).elf
|
||||
ELFSIZE = $(SIZE) applet/$(TARGET).elf
|
||||
sizebefore:
|
||||
@if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi
|
||||
|
||||
sizeafter:
|
||||
@if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(HEXSIZE); echo; fi
|
||||
@if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
|
||||
|
||||
|
||||
# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
|
||||
COFFCONVERT=$(OBJCOPY) --debugging \
|
||||
--change-section-address .data-0x800000 \
|
||||
--change-section-address .bss-0x800000 \
|
||||
--change-section-address .noinit-0x800000 \
|
||||
--change-section-address .eeprom-0x810000
|
||||
--change-section-address .data-0x800000 \
|
||||
--change-section-address .bss-0x800000 \
|
||||
--change-section-address .noinit-0x800000 \
|
||||
--change-section-address .eeprom-0x810000
|
||||
|
||||
|
||||
coff: applet/$(TARGET).elf
|
||||
$(COFFCONVERT) -O coff-avr applet/$(TARGET).elf $(TARGET).cof
|
||||
|
||||
|
||||
extcoff: $(TARGET).elf
|
||||
$(COFFCONVERT) -O coff-ext-avr applet/$(TARGET).elf $(TARGET).cof
|
||||
|
||||
|
||||
.SUFFIXES: .elf .hex .eep .lss .sym
|
||||
.PRECIOUS: .o
|
||||
|
||||
.elf.hex:
|
||||
$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
|
||||
@echo " COPY $@"
|
||||
@$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
|
||||
|
||||
.elf.eep:
|
||||
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
|
||||
--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
|
||||
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
|
||||
--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
|
||||
|
||||
# Create extended listing file from ELF output file.
|
||||
.elf.lss:
|
||||
@@ -246,76 +209,40 @@ extcoff: $(TARGET).elf
|
||||
.elf.sym:
|
||||
$(NM) -n $< > $@
|
||||
|
||||
# Link: create ELF output file from library.
|
||||
# NOTE: applet/$(TARGET).cpp.o MUST BE BEFORE applet/core.a
|
||||
# in the dependency list, so its rule runs first!
|
||||
applet/$(TARGET).elf: $(TARGET).pde applet/$(TARGET).cpp.o applet/core.a
|
||||
# $(CC) $(ALL_CFLAGS) -o $@ applet/$(TARGET).cpp -L. applet/core.a $(LDFLAGS)
|
||||
# changed as in IDE v0022: link cpp obj files
|
||||
@echo $$(tput bold)$$(tput setaf 2) $(CC) $$(tput sgr0) $(ALL_CFLAGS) $(CFINALF) -o $@ applet/$(TARGET).cpp.o $(CXXOBJ) -L. applet/core.a $(LDFLAGS)
|
||||
@$(CC) $(ALL_CFLAGS) $(CFINALF) -o $@ applet/$(TARGET).cpp.o $(CXXOBJ) -L. applet/core.a $(LDFLAGS)
|
||||
# Link: create ELF output file from library.
|
||||
applet/$(TARGET).elf: applet/$(TARGET).cpp applet/core.a Configuration.h
|
||||
@echo " CXX $@"
|
||||
@$(CC) $(ALL_CXXFLAGS) -Wl,--gc-sections -o $@ applet/$(TARGET).cpp -L. applet/core.a $(LDFLAGS)
|
||||
|
||||
# added: cpp.o depends on cpp (and .pde which generates it)
|
||||
# $< "first item in the dependencies list"; $@ "left side of the :"; $^ "right side of the :"
|
||||
# http://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/
|
||||
applet/$(TARGET).cpp.o: applet/$(TARGET).cpp
|
||||
@echo $$(tput bold) $(CXX) $$(tput sgr0) -c $(ALL_CXXFLAGS) $< -o $@
|
||||
applet/core.a: $(OBJ) Configuration.h
|
||||
@for i in $(OBJ); do echo " AR $$i"; $(AR) rcs applet/core.a $$i; done
|
||||
|
||||
%.o: %.c Configuration.h $(MAKEFILE)
|
||||
@echo " CC $@"
|
||||
@$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
|
||||
%.o: %.cpp Configuration.h $(MAKEFILE)
|
||||
@echo " CXX $@"
|
||||
@$(CXX) -c $(ALL_CXXFLAGS) $< -o $@
|
||||
|
||||
#~ applet/core.a: $(OBJ)
|
||||
#~ @for i in $(OBJ); do echo $(AR) rcs applet/core.a $$i; $(AR) rcs applet/core.a $$i; done
|
||||
|
||||
applet/core.a: $(OBJT)
|
||||
@for i in $(OBJT); do echo $(AR) rcs applet/core.a $$i; $(AR) rcs applet/core.a $$i; done
|
||||
|
||||
# iterate through OBJ to find the original location; then build depending on source extension
|
||||
# TODO: add handling of assembler files
|
||||
applet/%.o:
|
||||
@for iob in $(OBJ); do \
|
||||
if [ "`basename $$iob`" = "`basename $@`" ]; then \
|
||||
for ios in $(ALLSRC); do \
|
||||
if [ "$${iob%%.*}" = "$${ios%%.*}" ]; then \
|
||||
case $${ios##*.} in \
|
||||
"cpp") \
|
||||
echo "$$(tput bold)$$(tput setaf 1) $(CXX) $$(tput sgr0) -c $(ALL_CXXFLAGS) $$ios -o $@"; \
|
||||
$(CXX) -c $(ALL_CXXFLAGS) $$ios -o $@;; \
|
||||
"c") \
|
||||
echo "$$(tput bold)$$(tput setaf 1) $(CC) $$(tput sgr0) -c $(ALL_CFLAGS) $$ios -o $@"; \
|
||||
$(CC) -c $(ALL_CFLAGS) $$ios -o $@;; \
|
||||
esac; \
|
||||
fi; \
|
||||
done; \
|
||||
fi; \
|
||||
done;
|
||||
|
||||
#~ # Compile: create object files from C++ source files.
|
||||
#~ .cpp.o:
|
||||
#~ $(CXX) -c $(ALL_CXXFLAGS) $< -o $@
|
||||
|
||||
#~ # Compile: create object files from C source files.
|
||||
#~ .c.o:
|
||||
#~ $(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
|
||||
#~ # Compile: create assembler files from C source files.
|
||||
#~ .c.s:
|
||||
#~ $(CC) -S $(ALL_CFLAGS) $< -o $@
|
||||
|
||||
#~ # Assemble: create object files from assembler source files.
|
||||
#~ .S.o:
|
||||
#~ $(CC) -c $(ALL_ASFLAGS) $< -o $@
|
||||
|
||||
#~ # Automatic dependencies
|
||||
#~ %.d: %.c
|
||||
#~ $(CC) -M $(ALL_CFLAGS) $< | sed "s;$(notdir $*).o:;$*.o $*.d:;" > $@
|
||||
|
||||
#~ %.d: %.cpp
|
||||
#~ $(CXX) -M $(ALL_CXXFLAGS) $< | sed "s;$(notdir $*).o:;$*.o $*.d:;" > $@
|
||||
|
||||
# Target: clean project.
|
||||
clean:
|
||||
$(REMOVE) applet/$(TARGET).hex applet/$(TARGET).eep applet/$(TARGET).cof applet/$(TARGET).elf \
|
||||
applet/$(TARGET).map applet/$(TARGET).sym applet/$(TARGET).lss applet/core.a \
|
||||
$(OBJT) applet/$(TARGET).cpp.o \
|
||||
$(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d)
|
||||
@echo " RM applet/*"
|
||||
@$(REMOVE) applet/$(TARGET).hex applet/$(TARGET).eep applet/$(TARGET).cof applet/$(TARGET).elf \
|
||||
applet/$(TARGET).map applet/$(TARGET).sym applet/$(TARGET).lss applet/$(TARGET).cpp applet/core.a \
|
||||
$(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d)
|
||||
@echo " RMDIR applet/"
|
||||
@rmdir applet
|
||||
|
||||
.PHONY: all build elf hex eep lss sym program coff extcoff clean applet_files sizebefore sizeafter
|
||||
depend:
|
||||
if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \
|
||||
then \
|
||||
sed -e '/^# DO NOT DELETE/,$$d' $(MAKEFILE) > \
|
||||
$(MAKEFILE).$$$$ && \
|
||||
$(MV) $(MAKEFILE).$$$$ $(MAKEFILE); \
|
||||
fi
|
||||
echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' \
|
||||
>> $(MAKEFILE); \
|
||||
$(CC) -M -mmcu=$(MCU) $(CDEFS) $(CINCS) $(SRC) $(ASRC) >> $(MAKEFILE)
|
||||
|
||||
.PHONY: all build elf hex eep lss sym program coff extcoff clean depend applet_files sizebefore sizeafter
|
||||
|
||||
+91
-22
@@ -1,26 +1,73 @@
|
||||
// Tonokip RepRap firmware rewrite based off of Hydra-mmm firmware.
|
||||
// Licence: GPL
|
||||
|
||||
#ifndef __MARLINH
|
||||
#define __MARLINH
|
||||
|
||||
// Tonokip RepRap firmware rewrite based off of Hydra-mmm firmware.
|
||||
// Licence: GPL
|
||||
#include <WProgram.h>
|
||||
#include "fastio.h"
|
||||
#define HardwareSerial_h // trick to disable the standard HWserial
|
||||
|
||||
#define FORCE_INLINE __attribute__((always_inline)) inline
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <util/delay.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include <avr/eeprom.h>
|
||||
#include <avr/wdt.h>
|
||||
#include <avr/interrupt.h>
|
||||
|
||||
|
||||
#include "fastio.h"
|
||||
#include "Configuration.h"
|
||||
#include "pins.h"
|
||||
|
||||
//#define SERIAL_ECHO(x) Serial << "echo: " << x;
|
||||
//#define SERIAL_ECHOLN(x) Serial << "echo: "<<x<<endl;
|
||||
//#define SERIAL_ERROR(x) Serial << "Error: " << x;
|
||||
//#define SERIAL_ERRORLN(x) Serial << "Error: " << x<<endl;
|
||||
//#define SERIAL_PROTOCOL(x) Serial << x;
|
||||
//#define SERIAL_PROTOCOLLN(x) Serial << x<<endl;
|
||||
#if ARDUINO >= 100
|
||||
#if defined(__AVR_ATmega644P__)
|
||||
#include "WProgram.h"
|
||||
#else
|
||||
#include "Arduino.h"
|
||||
#endif
|
||||
#else
|
||||
#include "WProgram.h"
|
||||
#endif
|
||||
|
||||
#include "MarlinSerial.h"
|
||||
|
||||
#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"
|
||||
|
||||
#if MOTHERBOARD == 8 // Teensylu
|
||||
#define MYSERIAL Serial
|
||||
#else
|
||||
#define MYSERIAL MSerial
|
||||
#endif
|
||||
|
||||
//this is a unfinsihed attemp to removes a lot of warning messages, see:
|
||||
// http://www.avrfreaks.net/index.php?name=PNphpBB2&file=printview&t=57011
|
||||
//typedef char prog_char PROGMEM;
|
||||
// //#define PSTR (s ) ((const PROGMEM char *)(s))
|
||||
// //# define MYPGM(s) (__extension__({static prog_char __c[] = (s); &__c[0];}))
|
||||
// //#define MYPGM(s) ((const prog_char *g PROGMEM=s))
|
||||
#define MYPGM(s) PSTR(s)
|
||||
//#define MYPGM(s) (__extension__({static char __c[] __attribute__((__progmem__)) = (s); &__c[0];})) //This is the normal behaviour
|
||||
//#define MYPGM(s) (__extension__({static prog_char __c[] = (s); &__c[0];})) //this does not work but hides the warnings
|
||||
|
||||
|
||||
#define SERIAL_PROTOCOL(x) MYSERIAL.print(x);
|
||||
#define SERIAL_PROTOCOLPGM(x) serialprintPGM(MYPGM(x));
|
||||
#define SERIAL_PROTOCOLLN(x) {MYSERIAL.print(x);MYSERIAL.write('\n');}
|
||||
#define SERIAL_PROTOCOLLNPGM(x) {serialprintPGM(MYPGM(x));MYSERIAL.write('\n');}
|
||||
|
||||
#define SERIAL_PROTOCOL(x) Serial.print(x);
|
||||
#define SERIAL_PROTOCOLPGM(x) serialprintPGM(PSTR(x));
|
||||
#define SERIAL_PROTOCOLLN(x) {Serial.print(x);Serial.write('\n');}
|
||||
#define SERIAL_PROTOCOLLNPGM(x) {serialprintPGM(PSTR(x));Serial.write('\n');}
|
||||
|
||||
const char errormagic[] PROGMEM ="Error:";
|
||||
const char echomagic[] PROGMEM ="echo:";
|
||||
@@ -40,13 +87,13 @@ const char echomagic[] PROGMEM ="echo:";
|
||||
|
||||
|
||||
//things to write to serial from Programmemory. saves 400 to 2k of RAM.
|
||||
#define SerialprintPGM(x) serialprintPGM(PSTR(x))
|
||||
inline void serialprintPGM(const char *str)
|
||||
#define SerialprintPGM(x) serialprintPGM(MYPGM(x))
|
||||
FORCE_INLINE void serialprintPGM(const char *str)
|
||||
{
|
||||
char ch=pgm_read_byte(str);
|
||||
while(ch)
|
||||
{
|
||||
Serial.write(ch);
|
||||
MYSERIAL.write(ch);
|
||||
ch=pgm_read_byte(++str);
|
||||
}
|
||||
}
|
||||
@@ -81,14 +128,31 @@ void manage_inactivity(byte debug);
|
||||
#define disable_z() ;
|
||||
#endif
|
||||
|
||||
#if E_ENABLE_PIN > -1
|
||||
#define enable_e() WRITE(E_ENABLE_PIN, E_ENABLE_ON)
|
||||
#define disable_e() WRITE(E_ENABLE_PIN,!E_ENABLE_ON)
|
||||
#if defined(E0_ENABLE_PIN) && (E0_ENABLE_PIN > -1)
|
||||
#define enable_e0() WRITE(E0_ENABLE_PIN, E_ENABLE_ON)
|
||||
#define disable_e0() WRITE(E0_ENABLE_PIN,!E_ENABLE_ON)
|
||||
#else
|
||||
#define enable_e() ;
|
||||
#define disable_e() ;
|
||||
#define enable_e0() /* nothing */
|
||||
#define disable_e0() /* nothing */
|
||||
#endif
|
||||
|
||||
#if (EXTRUDERS > 1) && defined(E1_ENABLE_PIN) && (E1_ENABLE_PIN > -1)
|
||||
#define enable_e1() WRITE(E1_ENABLE_PIN, E_ENABLE_ON)
|
||||
#define disable_e1() WRITE(E1_ENABLE_PIN,!E_ENABLE_ON)
|
||||
#else
|
||||
#define enable_e1() /* nothing */
|
||||
#define disable_e1() /* nothing */
|
||||
#endif
|
||||
|
||||
#if (EXTRUDERS > 2) && defined(E2_ENABLE_PIN) && (E2_ENABLE_PIN > -1)
|
||||
#define enable_e2() WRITE(E2_ENABLE_PIN, E_ENABLE_ON)
|
||||
#define disable_e2() WRITE(E2_ENABLE_PIN,!E_ENABLE_ON)
|
||||
#else
|
||||
#define enable_e2() /* nothing */
|
||||
#define disable_e2() /* nothing */
|
||||
#endif
|
||||
|
||||
|
||||
enum AxisEnum {X_AXIS=0, Y_AXIS=1, Z_AXIS=2, E_AXIS=3};
|
||||
|
||||
|
||||
@@ -110,5 +174,10 @@ void prepare_arc_move(char isclockwise);
|
||||
extern float homing_feedrate[];
|
||||
extern bool axis_relative_modes[];
|
||||
extern float current_position[NUM_AXIS] ;
|
||||
extern float add_homeing[3];
|
||||
extern bool stop_heating_wait;
|
||||
|
||||
// Handling multiple extruders pins
|
||||
extern uint8_t active_extruder;
|
||||
|
||||
#endif
|
||||
|
||||
+416
-170
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,329 @@
|
||||
/*
|
||||
HardwareSerial.cpp - Hardware serial library for Wiring
|
||||
Copyright (c) 2006 Nicholas Zambetti. 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
|
||||
|
||||
Modified 23 November 2006 by David A. Mellis
|
||||
Modified 28 September 2010 by Mark Sproul
|
||||
*/
|
||||
|
||||
#include "Marlin.h"
|
||||
#include "MarlinSerial.h"
|
||||
|
||||
#if MOTHERBOARD != 8 // !teensylu
|
||||
// this next line disables the entire HardwareSerial.cpp,
|
||||
// this is so I can support Attiny series and any other chip without a uart
|
||||
#if defined(UBRRH) || defined(UBRR0H) || defined(UBRR1H) || defined(UBRR2H) || defined(UBRR3H)
|
||||
|
||||
#if defined(UBRRH) || defined(UBRR0H)
|
||||
ring_buffer rx_buffer = { { 0 }, 0, 0 };
|
||||
#endif
|
||||
|
||||
FORCE_INLINE void store_char(unsigned char c)
|
||||
{
|
||||
int i = (unsigned int)(rx_buffer.head + 1) % RX_BUFFER_SIZE;
|
||||
|
||||
// if we should be storing the received character into the location
|
||||
// just before the tail (meaning that the head would advance to the
|
||||
// current location of the tail), we're about to overflow the buffer
|
||||
// and so we don't write the character or advance the head.
|
||||
if (i != rx_buffer.tail) {
|
||||
rx_buffer.buffer[rx_buffer.head] = c;
|
||||
rx_buffer.head = i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//#elif defined(SIG_USART_RECV)
|
||||
#if defined(USART0_RX_vect)
|
||||
// fixed by Mark Sproul this is on the 644/644p
|
||||
//SIGNAL(SIG_USART_RECV)
|
||||
SIGNAL(USART0_RX_vect)
|
||||
{
|
||||
#if defined(UDR0)
|
||||
unsigned char c = UDR0;
|
||||
#elif defined(UDR)
|
||||
unsigned char c = UDR; // atmega8, atmega32
|
||||
#else
|
||||
#error UDR not defined
|
||||
#endif
|
||||
store_char(c);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Constructors ////////////////////////////////////////////////////////////////
|
||||
|
||||
MarlinSerial::MarlinSerial()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Public Methods //////////////////////////////////////////////////////////////
|
||||
|
||||
void MarlinSerial::begin(long baud)
|
||||
{
|
||||
uint16_t baud_setting;
|
||||
bool useU2X0 = true;
|
||||
|
||||
#if F_CPU == 16000000UL
|
||||
// hardcoded exception for compatibility with the bootloader shipped
|
||||
// with the Duemilanove and previous boards and the firmware on the 8U2
|
||||
// on the Uno and Mega 2560.
|
||||
if (baud == 57600) {
|
||||
useU2X0 = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (useU2X0) {
|
||||
UCSR0A = 1 << U2X0;
|
||||
baud_setting = (F_CPU / 4 / baud - 1) / 2;
|
||||
} else {
|
||||
UCSR0A = 0;
|
||||
baud_setting = (F_CPU / 8 / baud - 1) / 2;
|
||||
}
|
||||
|
||||
// assign the baud_setting, a.k.a. ubbr (USART Baud Rate Register)
|
||||
UBRR0H = baud_setting >> 8;
|
||||
UBRR0L = baud_setting;
|
||||
|
||||
sbi(UCSR0B, RXEN0);
|
||||
sbi(UCSR0B, TXEN0);
|
||||
sbi(UCSR0B, RXCIE0);
|
||||
}
|
||||
|
||||
void MarlinSerial::end()
|
||||
{
|
||||
cbi(UCSR0B, RXEN0);
|
||||
cbi(UCSR0B, TXEN0);
|
||||
cbi(UCSR0B, RXCIE0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int MarlinSerial::peek(void)
|
||||
{
|
||||
if (rx_buffer.head == rx_buffer.tail) {
|
||||
return -1;
|
||||
} else {
|
||||
return rx_buffer.buffer[rx_buffer.tail];
|
||||
}
|
||||
}
|
||||
|
||||
int MarlinSerial::read(void)
|
||||
{
|
||||
// if the head isn't ahead of the tail, we don't have any characters
|
||||
if (rx_buffer.head == rx_buffer.tail) {
|
||||
return -1;
|
||||
} else {
|
||||
unsigned char c = rx_buffer.buffer[rx_buffer.tail];
|
||||
rx_buffer.tail = (unsigned int)(rx_buffer.tail + 1) % RX_BUFFER_SIZE;
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
void MarlinSerial::flush()
|
||||
{
|
||||
// don't reverse this or there may be problems if the RX interrupt
|
||||
// occurs after reading the value of rx_buffer_head but before writing
|
||||
// the value to rx_buffer_tail; the previous value of rx_buffer_head
|
||||
// may be written to rx_buffer_tail, making it appear as if the buffer
|
||||
// don't reverse this or there may be problems if the RX interrupt
|
||||
// occurs after reading the value of rx_buffer_head but before writing
|
||||
// the value to rx_buffer_tail; the previous value of rx_buffer_head
|
||||
// may be written to rx_buffer_tail, making it appear as if the buffer
|
||||
// were full, not empty.
|
||||
rx_buffer.head = rx_buffer.tail;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// imports from print.h
|
||||
|
||||
|
||||
|
||||
|
||||
void MarlinSerial::print(char c, int base)
|
||||
{
|
||||
print((long) c, base);
|
||||
}
|
||||
|
||||
void MarlinSerial::print(unsigned char b, int base)
|
||||
{
|
||||
print((unsigned long) b, base);
|
||||
}
|
||||
|
||||
void MarlinSerial::print(int n, int base)
|
||||
{
|
||||
print((long) n, base);
|
||||
}
|
||||
|
||||
void MarlinSerial::print(unsigned int n, int base)
|
||||
{
|
||||
print((unsigned long) n, base);
|
||||
}
|
||||
|
||||
void MarlinSerial::print(long n, int base)
|
||||
{
|
||||
if (base == 0) {
|
||||
write(n);
|
||||
} else if (base == 10) {
|
||||
if (n < 0) {
|
||||
print('-');
|
||||
n = -n;
|
||||
}
|
||||
printNumber(n, 10);
|
||||
} else {
|
||||
printNumber(n, base);
|
||||
}
|
||||
}
|
||||
|
||||
void MarlinSerial::print(unsigned long n, int base)
|
||||
{
|
||||
if (base == 0) write(n);
|
||||
else printNumber(n, base);
|
||||
}
|
||||
|
||||
void MarlinSerial::print(double n, int digits)
|
||||
{
|
||||
printFloat(n, digits);
|
||||
}
|
||||
|
||||
void MarlinSerial::println(void)
|
||||
{
|
||||
print('\r');
|
||||
print('\n');
|
||||
}
|
||||
|
||||
void MarlinSerial::println(const String &s)
|
||||
{
|
||||
print(s);
|
||||
println();
|
||||
}
|
||||
|
||||
void MarlinSerial::println(const char c[])
|
||||
{
|
||||
print(c);
|
||||
println();
|
||||
}
|
||||
|
||||
void MarlinSerial::println(char c, int base)
|
||||
{
|
||||
print(c, base);
|
||||
println();
|
||||
}
|
||||
|
||||
void MarlinSerial::println(unsigned char b, int base)
|
||||
{
|
||||
print(b, base);
|
||||
println();
|
||||
}
|
||||
|
||||
void MarlinSerial::println(int n, int base)
|
||||
{
|
||||
print(n, base);
|
||||
println();
|
||||
}
|
||||
|
||||
void MarlinSerial::println(unsigned int n, int base)
|
||||
{
|
||||
print(n, base);
|
||||
println();
|
||||
}
|
||||
|
||||
void MarlinSerial::println(long n, int base)
|
||||
{
|
||||
print(n, base);
|
||||
println();
|
||||
}
|
||||
|
||||
void MarlinSerial::println(unsigned long n, int base)
|
||||
{
|
||||
print(n, base);
|
||||
println();
|
||||
}
|
||||
|
||||
void MarlinSerial::println(double n, int digits)
|
||||
{
|
||||
print(n, digits);
|
||||
println();
|
||||
}
|
||||
|
||||
// Private Methods /////////////////////////////////////////////////////////////
|
||||
|
||||
void MarlinSerial::printNumber(unsigned long n, uint8_t base)
|
||||
{
|
||||
unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars.
|
||||
unsigned long i = 0;
|
||||
|
||||
if (n == 0) {
|
||||
print('0');
|
||||
return;
|
||||
}
|
||||
|
||||
while (n > 0) {
|
||||
buf[i++] = n % base;
|
||||
n /= base;
|
||||
}
|
||||
|
||||
for (; i > 0; i--)
|
||||
print((char) (buf[i - 1] < 10 ?
|
||||
'0' + buf[i - 1] :
|
||||
'A' + buf[i - 1] - 10));
|
||||
}
|
||||
|
||||
void MarlinSerial::printFloat(double number, uint8_t digits)
|
||||
{
|
||||
// Handle negative numbers
|
||||
if (number < 0.0)
|
||||
{
|
||||
print('-');
|
||||
number = -number;
|
||||
}
|
||||
|
||||
// Round correctly so that print(1.999, 2) prints as "2.00"
|
||||
double rounding = 0.5;
|
||||
for (uint8_t i=0; i<digits; ++i)
|
||||
rounding /= 10.0;
|
||||
|
||||
number += rounding;
|
||||
|
||||
// Extract the integer part of the number and print it
|
||||
unsigned long int_part = (unsigned long)number;
|
||||
double remainder = number - (double)int_part;
|
||||
print(int_part);
|
||||
|
||||
// Print the decimal point, but only if there are digits beyond
|
||||
if (digits > 0)
|
||||
print(".");
|
||||
|
||||
// Extract digits from the remainder one at a time
|
||||
while (digits-- > 0)
|
||||
{
|
||||
remainder *= 10.0;
|
||||
int toPrint = int(remainder);
|
||||
print(toPrint);
|
||||
remainder -= toPrint;
|
||||
}
|
||||
}
|
||||
// Preinstantiate Objects //////////////////////////////////////////////////////
|
||||
|
||||
|
||||
MarlinSerial MSerial;
|
||||
|
||||
#endif // whole file
|
||||
#endif //teensylu
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
HardwareSerial.h - Hardware serial library for Wiring
|
||||
Copyright (c) 2006 Nicholas Zambetti. 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
|
||||
|
||||
Modified 28 September 2010 by Mark Sproul
|
||||
*/
|
||||
|
||||
#ifndef MarlinSerial_h
|
||||
#define MarlinSerial_h
|
||||
#include "Marlin.h"
|
||||
|
||||
|
||||
#define DEC 10
|
||||
#define HEX 16
|
||||
#define OCT 8
|
||||
#define BIN 2
|
||||
#define BYTE 0
|
||||
|
||||
|
||||
#if MOTHERBOARD != 8 // ! teensylu
|
||||
// Define constants and variables for buffering incoming serial data. We're
|
||||
// using a ring buffer (I think), in which rx_buffer_head is the index of the
|
||||
// location to which to write the next incoming character and rx_buffer_tail
|
||||
// is the index of the location from which to read.
|
||||
#define RX_BUFFER_SIZE 128
|
||||
|
||||
|
||||
struct ring_buffer
|
||||
{
|
||||
unsigned char buffer[RX_BUFFER_SIZE];
|
||||
int head;
|
||||
int tail;
|
||||
};
|
||||
|
||||
#if defined(UBRRH) || defined(UBRR0H)
|
||||
extern ring_buffer rx_buffer;
|
||||
#endif
|
||||
|
||||
class MarlinSerial //: public Stream
|
||||
{
|
||||
|
||||
public:
|
||||
MarlinSerial();
|
||||
void begin(long);
|
||||
void end();
|
||||
int peek(void);
|
||||
int read(void);
|
||||
void flush(void);
|
||||
|
||||
FORCE_INLINE int available(void)
|
||||
{
|
||||
return (unsigned int)(RX_BUFFER_SIZE + rx_buffer.head - rx_buffer.tail) % RX_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
FORCE_INLINE void write(uint8_t c)
|
||||
{
|
||||
while (!((UCSR0A) & (1 << UDRE0)))
|
||||
;
|
||||
|
||||
UDR0 = c;
|
||||
}
|
||||
|
||||
|
||||
FORCE_INLINE void checkRx(void)
|
||||
{
|
||||
if((UCSR0A & (1<<RXC0)) != 0) {
|
||||
unsigned char c = UDR0;
|
||||
int i = (unsigned int)(rx_buffer.head + 1) % RX_BUFFER_SIZE;
|
||||
|
||||
// if we should be storing the received character into the location
|
||||
// just before the tail (meaning that the head would advance to the
|
||||
// current location of the tail), we're about to overflow the buffer
|
||||
// and so we don't write the character or advance the head.
|
||||
if (i != rx_buffer.tail) {
|
||||
rx_buffer.buffer[rx_buffer.head] = c;
|
||||
rx_buffer.head = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
void printNumber(unsigned long, uint8_t);
|
||||
void printFloat(double, uint8_t);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
FORCE_INLINE void write(const char *str)
|
||||
{
|
||||
while (*str)
|
||||
write(*str++);
|
||||
}
|
||||
|
||||
|
||||
FORCE_INLINE void write(const uint8_t *buffer, size_t size)
|
||||
{
|
||||
while (size--)
|
||||
write(*buffer++);
|
||||
}
|
||||
|
||||
FORCE_INLINE void print(const String &s)
|
||||
{
|
||||
for (int i = 0; i < (int)s.length(); i++) {
|
||||
write(s[i]);
|
||||
}
|
||||
}
|
||||
|
||||
FORCE_INLINE void print(const char *str)
|
||||
{
|
||||
write(str);
|
||||
}
|
||||
void print(char, int = BYTE);
|
||||
void print(unsigned char, int = BYTE);
|
||||
void print(int, int = DEC);
|
||||
void print(unsigned int, int = DEC);
|
||||
void print(long, int = DEC);
|
||||
void print(unsigned long, int = DEC);
|
||||
void print(double, int = 2);
|
||||
|
||||
void println(const String &s);
|
||||
void println(const char[]);
|
||||
void println(char, int = BYTE);
|
||||
void println(unsigned char, int = BYTE);
|
||||
void println(int, int = DEC);
|
||||
void println(unsigned int, int = DEC);
|
||||
void println(long, int = DEC);
|
||||
void println(unsigned long, int = DEC);
|
||||
void println(double, int = 2);
|
||||
void println(void);
|
||||
};
|
||||
|
||||
extern MarlinSerial MSerial;
|
||||
#endif // ! teensylu
|
||||
|
||||
#endif
|
||||
@@ -25,6 +25,7 @@
|
||||
#ifndef Wiring_h
|
||||
#define Wiring_h
|
||||
|
||||
#include <math.h>
|
||||
#include <avr/io.h>
|
||||
#include <stdlib.h>
|
||||
#include "binary.h"
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#ifndef WiringPrivate_h
|
||||
#define WiringPrivate_h
|
||||
|
||||
#include <math.h>
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/delay.h>
|
||||
|
||||
+6
-5
@@ -17,11 +17,9 @@
|
||||
* along with the Arduino Sd2Card Library. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#if ARDUINO < 100
|
||||
#include <WProgram.h>
|
||||
#else // ARDUINO
|
||||
#include <Arduino.h>
|
||||
#endif // ARDUINO
|
||||
#include "Marlin.h"
|
||||
|
||||
#ifdef SDSUPPORT
|
||||
#include "Sd2Card.h"
|
||||
//------------------------------------------------------------------------------
|
||||
#ifndef SOFTWARE_SPI
|
||||
@@ -640,3 +638,6 @@ bool Sd2Card::writeStop() {
|
||||
chipSelectHigh();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -17,6 +17,10 @@
|
||||
* along with the Arduino Sd2Card Library. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "Marlin.h"
|
||||
#ifdef SDSUPPORT
|
||||
|
||||
#ifndef Sd2Card_h
|
||||
#define Sd2Card_h
|
||||
/**
|
||||
@@ -232,3 +236,6 @@ class Sd2Card {
|
||||
bool writeData(uint8_t token, const uint8_t* src);
|
||||
};
|
||||
#endif // Sd2Card_h
|
||||
|
||||
|
||||
#endif
|
||||
@@ -18,6 +18,9 @@
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// Warning this file was generated by a program.
|
||||
#include "Marlin.h"
|
||||
#ifdef SDSUPPORT
|
||||
|
||||
#ifndef Sd2PinMap_h
|
||||
#define Sd2PinMap_h
|
||||
#include <avr/io.h>
|
||||
@@ -38,6 +41,8 @@ struct pin_map_t {
|
||||
uint8_t const SDA_PIN = 20; // D1
|
||||
uint8_t const SCL_PIN = 21; // D0
|
||||
|
||||
#undef MOSI_PIN
|
||||
#undef MISO_PIN
|
||||
// SPI port
|
||||
uint8_t const SS_PIN = 53; // B0
|
||||
uint8_t const MOSI_PIN = 51; // B2
|
||||
@@ -358,3 +363,6 @@ static inline __attribute__((always_inline))
|
||||
}
|
||||
}
|
||||
#endif // Sd2PinMap_h
|
||||
|
||||
|
||||
#endif
|
||||
+48
-75
@@ -17,6 +17,10 @@
|
||||
* along with the Arduino SdFat Library. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "Marlin.h"
|
||||
#ifdef SDSUPPORT
|
||||
|
||||
#include "SdBaseFile.h"
|
||||
//------------------------------------------------------------------------------
|
||||
// pointer to cwd directory
|
||||
@@ -294,20 +298,7 @@ void SdBaseFile::getpos(fpos_t* pos) {
|
||||
pos->position = curPosition_;
|
||||
pos->cluster = curCluster_;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/** List directory contents to Serial.
|
||||
*
|
||||
* \param[in] flags The inclusive OR of
|
||||
*
|
||||
* LS_DATE - %Print file modification date
|
||||
*
|
||||
* LS_SIZE - %Print file size.
|
||||
*
|
||||
* LS_R - Recursive list of subdirectories.
|
||||
*/
|
||||
void SdBaseFile::ls(uint8_t flags) {
|
||||
ls(&Serial, flags, 0);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/** List directory contents.
|
||||
*
|
||||
@@ -324,14 +315,14 @@ void SdBaseFile::ls(uint8_t flags) {
|
||||
* \param[in] indent Amount of space before file name. Used for recursive
|
||||
* list to indicate subdirectory level.
|
||||
*/
|
||||
void SdBaseFile::ls(Print* pr, uint8_t flags, uint8_t indent) {
|
||||
void SdBaseFile::ls(uint8_t flags, uint8_t indent) {
|
||||
rewind();
|
||||
int8_t status;
|
||||
while ((status = lsPrintNext(pr, flags, indent))) {
|
||||
while ((status = lsPrintNext( flags, indent))) {
|
||||
if (status > 1 && (flags & LS_R)) {
|
||||
uint16_t index = curPosition()/32 - 1;
|
||||
SdBaseFile s;
|
||||
if (s.open(this, index, O_READ)) s.ls(pr, flags, indent + 2);
|
||||
if (s.open(this, index, O_READ)) s.ls( flags, indent + 2);
|
||||
seekSet(32 * (index + 1));
|
||||
}
|
||||
}
|
||||
@@ -339,7 +330,7 @@ void SdBaseFile::ls(Print* pr, uint8_t flags, uint8_t indent) {
|
||||
//------------------------------------------------------------------------------
|
||||
// saves 32 bytes on stack for ls recursion
|
||||
// return 0 - EOF, 1 - normal file, or 2 - directory
|
||||
int8_t SdBaseFile::lsPrintNext(Print *pr, uint8_t flags, uint8_t indent) {
|
||||
int8_t SdBaseFile::lsPrintNext( uint8_t flags, uint8_t indent) {
|
||||
dir_t dir;
|
||||
uint8_t w = 0;
|
||||
|
||||
@@ -352,38 +343,38 @@ int8_t SdBaseFile::lsPrintNext(Print *pr, uint8_t flags, uint8_t indent) {
|
||||
&& DIR_IS_FILE_OR_SUBDIR(&dir)) break;
|
||||
}
|
||||
// indent for dir level
|
||||
for (uint8_t i = 0; i < indent; i++) pr->write(' ');
|
||||
for (uint8_t i = 0; i < indent; i++) MYSERIAL.write(' ');
|
||||
|
||||
// print name
|
||||
for (uint8_t i = 0; i < 11; i++) {
|
||||
if (dir.name[i] == ' ')continue;
|
||||
if (i == 8) {
|
||||
pr->write('.');
|
||||
MYSERIAL.write('.');
|
||||
w++;
|
||||
}
|
||||
pr->write(dir.name[i]);
|
||||
MYSERIAL.write(dir.name[i]);
|
||||
w++;
|
||||
}
|
||||
if (DIR_IS_SUBDIR(&dir)) {
|
||||
pr->write('/');
|
||||
MYSERIAL.write('/');
|
||||
w++;
|
||||
}
|
||||
if (flags & (LS_DATE | LS_SIZE)) {
|
||||
while (w++ < 14) pr->write(' ');
|
||||
while (w++ < 14) MYSERIAL.write(' ');
|
||||
}
|
||||
// print modify date/time if requested
|
||||
if (flags & LS_DATE) {
|
||||
pr->write(' ');
|
||||
printFatDate(pr, dir.lastWriteDate);
|
||||
pr->write(' ');
|
||||
printFatTime(pr, dir.lastWriteTime);
|
||||
MYSERIAL.write(' ');
|
||||
printFatDate( dir.lastWriteDate);
|
||||
MYSERIAL.write(' ');
|
||||
printFatTime( dir.lastWriteTime);
|
||||
}
|
||||
// print size if requested
|
||||
if (!DIR_IS_SUBDIR(&dir) && (flags & LS_SIZE)) {
|
||||
pr->write(' ');
|
||||
pr->print(dir.fileSize);
|
||||
MYSERIAL.write(' ');
|
||||
MYSERIAL.print(dir.fileSize);
|
||||
}
|
||||
pr->println();
|
||||
MYSERIAL.println();
|
||||
return DIR_IS_FILE(&dir) ? 1 : 2;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -940,17 +931,7 @@ int SdBaseFile::peek() {
|
||||
if (c >= 0) setpos(&pos);
|
||||
return c;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/** %Print the name field of a directory entry in 8.3 format to Serial.
|
||||
*
|
||||
* \param[in] dir The directory structure containing the name.
|
||||
* \param[in] width Blank fill name if length is less than \a width.
|
||||
* \param[in] printSlash Print '/' after directory names if true.
|
||||
*/
|
||||
void SdBaseFile::printDirName(const dir_t& dir,
|
||||
uint8_t width, bool printSlash) {
|
||||
printDirName(&Serial, dir, width, printSlash);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/** %Print the name field of a directory entry in 8.3 format.
|
||||
* \param[in] pr Print stream for output.
|
||||
@@ -958,32 +939,32 @@ void SdBaseFile::printDirName(const dir_t& dir,
|
||||
* \param[in] width Blank fill name if length is less than \a width.
|
||||
* \param[in] printSlash Print '/' after directory names if true.
|
||||
*/
|
||||
void SdBaseFile::printDirName(Print* pr, const dir_t& dir,
|
||||
void SdBaseFile::printDirName(const dir_t& dir,
|
||||
uint8_t width, bool printSlash) {
|
||||
uint8_t w = 0;
|
||||
for (uint8_t i = 0; i < 11; i++) {
|
||||
if (dir.name[i] == ' ')continue;
|
||||
if (i == 8) {
|
||||
pr->write('.');
|
||||
MYSERIAL.write('.');
|
||||
w++;
|
||||
}
|
||||
pr->write(dir.name[i]);
|
||||
MYSERIAL.write(dir.name[i]);
|
||||
w++;
|
||||
}
|
||||
if (DIR_IS_SUBDIR(&dir) && printSlash) {
|
||||
pr->write('/');
|
||||
MYSERIAL.write('/');
|
||||
w++;
|
||||
}
|
||||
while (w < width) {
|
||||
pr->write(' ');
|
||||
MYSERIAL.write(' ');
|
||||
w++;
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
// print uint8_t with width 2
|
||||
static void print2u(Print* pr, uint8_t v) {
|
||||
if (v < 10) pr->write('0');
|
||||
pr->print(v, DEC);
|
||||
static void print2u( uint8_t v) {
|
||||
if (v < 10) MYSERIAL.write('0');
|
||||
MYSERIAL.print(v, DEC);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/** %Print a directory date field to Serial.
|
||||
@@ -992,9 +973,7 @@ static void print2u(Print* pr, uint8_t v) {
|
||||
*
|
||||
* \param[in] fatDate The date field from a directory entry.
|
||||
*/
|
||||
void SdBaseFile::printFatDate(uint16_t fatDate) {
|
||||
printFatDate(&Serial, fatDate);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/** %Print a directory date field.
|
||||
*
|
||||
@@ -1003,23 +982,14 @@ void SdBaseFile::printFatDate(uint16_t fatDate) {
|
||||
* \param[in] pr Print stream for output.
|
||||
* \param[in] fatDate The date field from a directory entry.
|
||||
*/
|
||||
void SdBaseFile::printFatDate(Print* pr, uint16_t fatDate) {
|
||||
pr->print(FAT_YEAR(fatDate));
|
||||
pr->write('-');
|
||||
print2u(pr, FAT_MONTH(fatDate));
|
||||
pr->write('-');
|
||||
print2u(pr, FAT_DAY(fatDate));
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/** %Print a directory time field to Serial.
|
||||
*
|
||||
* Format is hh:mm:ss.
|
||||
*
|
||||
* \param[in] fatTime The time field from a directory entry.
|
||||
*/
|
||||
void SdBaseFile::printFatTime(uint16_t fatTime) {
|
||||
printFatTime(&Serial, fatTime);
|
||||
void SdBaseFile::printFatDate(uint16_t fatDate) {
|
||||
MYSERIAL.print(FAT_YEAR(fatDate));
|
||||
MYSERIAL.write('-');
|
||||
print2u( FAT_MONTH(fatDate));
|
||||
MYSERIAL.write('-');
|
||||
print2u( FAT_DAY(fatDate));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/** %Print a directory time field.
|
||||
*
|
||||
@@ -1028,12 +998,12 @@ void SdBaseFile::printFatTime(uint16_t fatTime) {
|
||||
* \param[in] pr Print stream for output.
|
||||
* \param[in] fatTime The time field from a directory entry.
|
||||
*/
|
||||
void SdBaseFile::printFatTime(Print* pr, uint16_t fatTime) {
|
||||
print2u(pr, FAT_HOUR(fatTime));
|
||||
pr->write(':');
|
||||
print2u(pr, FAT_MINUTE(fatTime));
|
||||
pr->write(':');
|
||||
print2u(pr, FAT_SECOND(fatTime));
|
||||
void SdBaseFile::printFatTime( uint16_t fatTime) {
|
||||
print2u( FAT_HOUR(fatTime));
|
||||
MYSERIAL.write(':');
|
||||
print2u( FAT_MINUTE(fatTime));
|
||||
MYSERIAL.write(':');
|
||||
print2u( FAT_SECOND(fatTime));
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/** Print a file's name to Serial
|
||||
@@ -1044,7 +1014,7 @@ void SdBaseFile::printFatTime(Print* pr, uint16_t fatTime) {
|
||||
bool SdBaseFile::printName() {
|
||||
char name[13];
|
||||
if (!getFilename(name)) return false;
|
||||
Serial.print(name);
|
||||
MYSERIAL.print(name);
|
||||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -1816,3 +1786,6 @@ int16_t SdBaseFile::write(const void* buf, uint16_t nbyte) {
|
||||
#if ALLOW_DEPRECATED_FUNCTIONS && !defined(DOXYGEN)
|
||||
void (*SdBaseFile::oldDateTime_)(uint16_t& date, uint16_t& time) = 0; // NOLINT
|
||||
#endif // ALLOW_DEPRECATED_FUNCTIONS
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
+9
-15
@@ -17,18 +17,16 @@
|
||||
* along with the Arduino SdFat Library. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "Marlin.h"
|
||||
#ifdef SDSUPPORT
|
||||
|
||||
#ifndef SdBaseFile_h
|
||||
#define SdBaseFile_h
|
||||
/**
|
||||
* \file
|
||||
* \brief SdBaseFile class
|
||||
*/
|
||||
#include <avr/pgmspace.h>
|
||||
#if ARDUINO < 100
|
||||
#include <WProgram.h>
|
||||
#else // ARDUINO
|
||||
#include <Arduino.h>
|
||||
#endif // ARDUINO
|
||||
#include "Marlin.h"
|
||||
#include "SdFatConfig.h"
|
||||
#include "SdVolume.h"
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -268,8 +266,7 @@ class SdBaseFile {
|
||||
bool isRoot() const {
|
||||
return type_ == FAT_FILE_TYPE_ROOT_FIXED || type_ == FAT_FILE_TYPE_ROOT32;
|
||||
}
|
||||
void ls(Print* pr, uint8_t flags = 0, uint8_t indent = 0);
|
||||
void ls(uint8_t flags = 0);
|
||||
void ls( uint8_t flags = 0, uint8_t indent = 0);
|
||||
bool mkdir(SdBaseFile* dir, const char* path, bool pFlag = true);
|
||||
// alias for backward compactability
|
||||
bool makeDir(SdBaseFile* dir, const char* path) {
|
||||
@@ -282,9 +279,7 @@ class SdBaseFile {
|
||||
bool openRoot(SdVolume* vol);
|
||||
int peek();
|
||||
static void printFatDate(uint16_t fatDate);
|
||||
static void printFatDate(Print* pr, uint16_t fatDate);
|
||||
static void printFatTime(uint16_t fatTime);
|
||||
static void printFatTime(Print* pr, uint16_t fatTime);
|
||||
static void printFatTime( uint16_t fatTime);
|
||||
bool printName();
|
||||
int16_t read();
|
||||
int16_t read(void* buf, uint16_t nbyte);
|
||||
@@ -357,7 +352,7 @@ class SdBaseFile {
|
||||
bool addCluster();
|
||||
bool addDirCluster();
|
||||
dir_t* cacheDirEntry(uint8_t action);
|
||||
int8_t lsPrintNext(Print *pr, uint8_t flags, uint8_t indent);
|
||||
int8_t lsPrintNext( uint8_t flags, uint8_t indent);
|
||||
static bool make83Name(const char* str, uint8_t* name, const char** ptr);
|
||||
bool mkdir(SdBaseFile* parent, const uint8_t dname[11]);
|
||||
bool open(SdBaseFile* dirFile, const uint8_t dname[11], uint8_t oflag);
|
||||
@@ -365,9 +360,7 @@ class SdBaseFile {
|
||||
dir_t* readDirCache();
|
||||
//------------------------------------------------------------------------------
|
||||
// to be deleted
|
||||
static void printDirName(const dir_t& dir,
|
||||
uint8_t width, bool printSlash);
|
||||
static void printDirName(Print* pr, const dir_t& dir,
|
||||
static void printDirName( const dir_t& dir,
|
||||
uint8_t width, bool printSlash);
|
||||
//------------------------------------------------------------------------------
|
||||
// Deprecated functions - suppress cpplint warnings with NOLINT comment
|
||||
@@ -487,3 +480,4 @@ class SdBaseFile {
|
||||
};
|
||||
|
||||
#endif // SdBaseFile_h
|
||||
#endif
|
||||
@@ -21,6 +21,9 @@
|
||||
* \file
|
||||
* \brief configuration definitions
|
||||
*/
|
||||
#include "Marlin.h"
|
||||
#ifdef SDSUPPORT
|
||||
|
||||
#ifndef SdFatConfig_h
|
||||
#define SdFatConfig_h
|
||||
#include <stdint.h>
|
||||
@@ -106,3 +109,6 @@ uint8_t const SOFT_SPI_SCK_PIN = 13;
|
||||
*/
|
||||
#define USE_CXA_PURE_VIRTUAL 1
|
||||
#endif // SdFatConfig_h
|
||||
|
||||
|
||||
#endif
|
||||
@@ -17,6 +17,9 @@
|
||||
* along with the Arduino SdFat Library. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "Marlin.h"
|
||||
#ifdef SDSUPPORT
|
||||
|
||||
#ifndef SdFatStructs_h
|
||||
#define SdFatStructs_h
|
||||
/**
|
||||
@@ -602,3 +605,6 @@ static inline uint8_t DIR_IS_FILE_OR_SUBDIR(const dir_t* dir) {
|
||||
return (dir->attributes & DIR_ATT_VOLUME_ID) == 0;
|
||||
}
|
||||
#endif // SdFatStructs_h
|
||||
|
||||
|
||||
#endif
|
||||
+12
-7
@@ -17,7 +17,11 @@
|
||||
* along with the Arduino SdFat Library. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "Marlin.h"
|
||||
|
||||
#ifdef SDSUPPORT
|
||||
#include "SdFatUtil.h"
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/** Amount of free RAM
|
||||
* \return The number of free bytes.
|
||||
@@ -43,8 +47,8 @@ int SdFatUtil::FreeRam() {
|
||||
* \param[in] pr Print object for output.
|
||||
* \param[in] str Pointer to string stored in flash memory.
|
||||
*/
|
||||
void SdFatUtil::print_P(Print* pr, PGM_P str) {
|
||||
for (uint8_t c; (c = pgm_read_byte(str)); str++) pr->write(c);
|
||||
void SdFatUtil::print_P( PGM_P str) {
|
||||
for (uint8_t c; (c = pgm_read_byte(str)); str++) MYSERIAL.write(c);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/** %Print a string in flash memory followed by a CR/LF.
|
||||
@@ -52,9 +56,9 @@ void SdFatUtil::print_P(Print* pr, PGM_P str) {
|
||||
* \param[in] pr Print object for output.
|
||||
* \param[in] str Pointer to string stored in flash memory.
|
||||
*/
|
||||
void SdFatUtil::println_P(Print* pr, PGM_P str) {
|
||||
print_P(pr, str);
|
||||
pr->println();
|
||||
void SdFatUtil::println_P( PGM_P str) {
|
||||
print_P( str);
|
||||
MYSERIAL.println();
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/** %Print a string in flash memory to Serial.
|
||||
@@ -62,7 +66,7 @@ void SdFatUtil::println_P(Print* pr, PGM_P str) {
|
||||
* \param[in] str Pointer to string stored in flash memory.
|
||||
*/
|
||||
void SdFatUtil::SerialPrint_P(PGM_P str) {
|
||||
print_P(&Serial, str);
|
||||
print_P(str);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
/** %Print a string in flash memory to Serial followed by a CR/LF.
|
||||
@@ -70,5 +74,6 @@ void SdFatUtil::SerialPrint_P(PGM_P str) {
|
||||
* \param[in] str Pointer to string stored in flash memory.
|
||||
*/
|
||||
void SdFatUtil::SerialPrintln_P(PGM_P str) {
|
||||
println_P(&Serial, str);
|
||||
println_P( str);
|
||||
}
|
||||
#endif
|
||||
|
||||
+10
-8
@@ -17,18 +17,17 @@
|
||||
* along with the Arduino SdFat Library. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "Marlin.h"
|
||||
#ifdef SDSUPPORT
|
||||
|
||||
#ifndef SdFatUtil_h
|
||||
#define SdFatUtil_h
|
||||
/**
|
||||
* \file
|
||||
* \brief Useful utility functions.
|
||||
*/
|
||||
#include <avr/pgmspace.h>
|
||||
#if ARDUINO < 100
|
||||
#include <WProgram.h>
|
||||
#else // ARDUINO
|
||||
#include <Arduino.h>
|
||||
#endif // ARDUINO
|
||||
#include "Marlin.h"
|
||||
#include "MarlinSerial.h"
|
||||
/** Store and print a string in flash memory.*/
|
||||
#define PgmPrint(x) SerialPrint_P(PSTR(x))
|
||||
/** Store and print a string in flash memory followed by a CR/LF.*/
|
||||
@@ -36,11 +35,14 @@
|
||||
|
||||
namespace SdFatUtil {
|
||||
int FreeRam();
|
||||
void print_P(Print* pr, PGM_P str);
|
||||
void println_P(Print* pr, PGM_P str);
|
||||
void print_P( PGM_P str);
|
||||
void println_P( PGM_P str);
|
||||
void SerialPrint_P(PGM_P str);
|
||||
void SerialPrintln_P(PGM_P str);
|
||||
}
|
||||
|
||||
using namespace SdFatUtil; // NOLINT
|
||||
#endif // #define SdFatUtil_h
|
||||
|
||||
|
||||
#endif
|
||||
+12
-1
@@ -17,6 +17,9 @@
|
||||
* along with the Arduino SdFat Library. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "Marlin.h"
|
||||
|
||||
#ifdef SDSUPPORT
|
||||
#include "SdFile.h"
|
||||
/** Create a file object and open it in the current working directory.
|
||||
*
|
||||
@@ -51,7 +54,12 @@ int16_t SdFile::write(const void* buf, uint16_t nbyte) {
|
||||
* \param[in] b the byte to be written.
|
||||
* Use writeError to check for errors.
|
||||
*/
|
||||
void SdFile::write(uint8_t b) {
|
||||
#if ARDUINO >= 100
|
||||
size_t SdFile::write(uint8_t b)
|
||||
#else
|
||||
void SdFile::write(uint8_t b)
|
||||
#endif
|
||||
{
|
||||
SdBaseFile::write(&b, 1);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -79,3 +87,6 @@ void SdFile::writeln_P(PGM_P str) {
|
||||
write_P(str);
|
||||
write_P(PSTR("\r\n"));
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
+13
-1
@@ -21,7 +21,11 @@
|
||||
* \file
|
||||
* \brief SdFile class
|
||||
*/
|
||||
#include "Marlin.h"
|
||||
|
||||
#ifdef SDSUPPORT
|
||||
#include "SdBaseFile.h"
|
||||
#include <Print.h>
|
||||
#ifndef SdFile_h
|
||||
#define SdFile_h
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -33,10 +37,18 @@ class SdFile : public SdBaseFile, public Print {
|
||||
public:
|
||||
SdFile() {}
|
||||
SdFile(const char* name, uint8_t oflag);
|
||||
void write(uint8_t b);
|
||||
#if ARDUINO >= 100
|
||||
size_t write(uint8_t b);
|
||||
#else
|
||||
void write(uint8_t b);
|
||||
#endif
|
||||
|
||||
int16_t write(const void* buf, uint16_t nbyte);
|
||||
void write(const char* str);
|
||||
void write_P(PGM_P str);
|
||||
void writeln_P(PGM_P str);
|
||||
};
|
||||
#endif // SdFile_h
|
||||
|
||||
|
||||
#endif
|
||||
@@ -17,6 +17,9 @@
|
||||
* along with the Arduino Sd2Card Library. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "Marlin.h"
|
||||
#ifdef SDSUPPORT
|
||||
|
||||
#ifndef SdInfo_h
|
||||
#define SdInfo_h
|
||||
#include <stdint.h>
|
||||
@@ -273,3 +276,5 @@ union csd_t {
|
||||
csd2_t v2;
|
||||
};
|
||||
#endif // SdInfo_h
|
||||
|
||||
#endif
|
||||
@@ -17,6 +17,9 @@
|
||||
* along with the Arduino SdFat Library. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "Marlin.h"
|
||||
#ifdef SDSUPPORT
|
||||
|
||||
#include "SdVolume.h"
|
||||
//------------------------------------------------------------------------------
|
||||
#if !USE_MULTIPLE_CARDS
|
||||
@@ -399,3 +402,4 @@ bool SdVolume::init(Sd2Card* dev, uint8_t part) {
|
||||
fail:
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
@@ -17,6 +17,8 @@
|
||||
* along with the Arduino SdFat Library. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "Marlin.h"
|
||||
#ifdef SDSUPPORT
|
||||
#ifndef SdVolume_h
|
||||
#define SdVolume_h
|
||||
/**
|
||||
@@ -209,3 +211,4 @@ class SdVolume {
|
||||
#endif // ALLOW_DEPRECATED_FUNCTIONS
|
||||
};
|
||||
#endif // SdVolume
|
||||
#endif
|
||||
@@ -1,7 +1,12 @@
|
||||
#include "Marlin.h"
|
||||
#include "cardreader.h"
|
||||
//#include <unistd.h>
|
||||
#include "ultralcd.h"
|
||||
#include "stepper.h"
|
||||
#include "temperature.h"
|
||||
#ifdef SDSUPPORT
|
||||
|
||||
|
||||
|
||||
CardReader::CardReader()
|
||||
{
|
||||
filesize = 0;
|
||||
@@ -12,6 +17,7 @@ CardReader::CardReader()
|
||||
autostart_atmillis=0;
|
||||
|
||||
autostart_stilltocheck=true; //the sd start is delayed, because otherwise the serial cannot answer fast enought to make contact with the hostsoftware.
|
||||
lastnr=0;
|
||||
//power to SD reader
|
||||
#if SDPOWER > -1
|
||||
SET_OUTPUT(SDPOWER);
|
||||
@@ -38,7 +44,7 @@ char *createFilename(char *buffer,const dir_t &p) //buffer>12characters
|
||||
}
|
||||
|
||||
|
||||
void CardReader::lsDive(char *prepend,SdFile parent)
|
||||
void CardReader::lsDive(const char *prepend,SdFile parent)
|
||||
{
|
||||
dir_t p;
|
||||
uint8_t cnt=0;
|
||||
@@ -161,6 +167,15 @@ void CardReader::initsd()
|
||||
SERIAL_ECHOLNPGM("workDir open failed");
|
||||
}
|
||||
}
|
||||
|
||||
void CardReader::setroot()
|
||||
{
|
||||
curDir=&root;
|
||||
if(!workDir.openRoot(&volume))
|
||||
{
|
||||
SERIAL_ECHOLNPGM("workDir open failed");
|
||||
}
|
||||
}
|
||||
void CardReader::release()
|
||||
{
|
||||
sdprinting = false;
|
||||
@@ -332,7 +347,7 @@ void CardReader::checkautostart(bool force)
|
||||
if(!cardOK) //fail
|
||||
return;
|
||||
}
|
||||
static int lastnr=0;
|
||||
|
||||
char autoname[30];
|
||||
sprintf(autoname,"auto%i.g",lastnr);
|
||||
for(int8_t i=0;i<(int)strlen(autoname);i++)
|
||||
@@ -426,4 +441,20 @@ void CardReader::updir()
|
||||
}
|
||||
}
|
||||
|
||||
#endif //SDSUPPORT
|
||||
|
||||
void CardReader::printingHasFinished()
|
||||
{
|
||||
st_synchronize();
|
||||
quickStop();
|
||||
sdprinting = false;
|
||||
#ifdef STOP_HEATING_WAIT_FOR_SD_PRINTING
|
||||
stop_heating_wait=true;
|
||||
#endif
|
||||
if(SD_FINISHED_STEPPERRELEASE)
|
||||
{
|
||||
//finishAndDisableSteppers();
|
||||
enquecommand(SD_FINISHED_RELEASECOMMAND);
|
||||
}
|
||||
autotempShutdown();
|
||||
}
|
||||
#endif //SDSUPPORT
|
||||
+30
-25
@@ -2,7 +2,7 @@
|
||||
#define __CARDREADERH
|
||||
|
||||
#ifdef SDSUPPORT
|
||||
|
||||
|
||||
#include "SdFile.h"
|
||||
enum LsAction {LS_SerialPrint,LS_Count,LS_GetFilename};
|
||||
class CardReader
|
||||
@@ -22,6 +22,7 @@ public:
|
||||
void startFileprint();
|
||||
void pauseSDPrint();
|
||||
void getStatus();
|
||||
void printingHasFinished();
|
||||
|
||||
void getfilename(const uint8_t nr);
|
||||
uint16_t getnrfilenames();
|
||||
@@ -30,11 +31,14 @@ public:
|
||||
void ls();
|
||||
void chdir(const char * relpath);
|
||||
void updir();
|
||||
void setroot();
|
||||
|
||||
inline bool eof() { return sdpos>=filesize ;};
|
||||
inline int16_t get() { sdpos = file.curPosition();return (int16_t)file.read();};
|
||||
inline void setIndex(long index) {sdpos = index;file.seekSet(index);};
|
||||
inline uint8_t percentDone(){if(!sdprinting) return 0; if(filesize) return sdpos*100/filesize; else return 0;};
|
||||
|
||||
FORCE_INLINE bool eof() { return sdpos>=filesize ;};
|
||||
FORCE_INLINE int16_t get() { sdpos = file.curPosition();return (int16_t)file.read();};
|
||||
FORCE_INLINE void setIndex(long index) {sdpos = index;file.seekSet(index);};
|
||||
FORCE_INLINE uint8_t percentDone(){if(!sdprinting) return 0; if(filesize) return sdpos*100/filesize; else return 0;};
|
||||
FORCE_INLINE char* getWorkDirName(){workDir.getFilename(filename);return filename;};
|
||||
|
||||
public:
|
||||
bool saving;
|
||||
@@ -42,6 +46,7 @@ public:
|
||||
bool cardOK ;
|
||||
char filename[11];
|
||||
bool filenameIsDir;
|
||||
int lastnr; //last number of the autostart;
|
||||
private:
|
||||
SdFile root,*curDir,workDir,workDirParent,workDirParentParent;
|
||||
Sd2Card card;
|
||||
@@ -57,7 +62,7 @@ private:
|
||||
LsAction lsAction; //stored for recursion.
|
||||
int16_t nrFiles; //counter for the files in the current directory and recycled as position counter for getting the nrFiles'th name in the directory.
|
||||
char* diveDirName;
|
||||
void lsDive(char *prepend,SdFile parent);
|
||||
void lsDive(const char *prepend,SdFile parent);
|
||||
};
|
||||
|
||||
|
||||
@@ -67,31 +72,31 @@ private:
|
||||
class CardReader
|
||||
{
|
||||
public:
|
||||
inline CardReader(){};
|
||||
FORCE_INLINE CardReader(){};
|
||||
|
||||
inline static void initsd(){};
|
||||
inline static void write_command(char *buf){};
|
||||
FORCE_INLINE static void initsd(){};
|
||||
FORCE_INLINE static void write_command(char *buf){};
|
||||
|
||||
inline static void checkautostart(bool x) {};
|
||||
FORCE_INLINE static void checkautostart(bool x) {};
|
||||
|
||||
inline static void openFile(char* name,bool read){};
|
||||
inline static void closefile() {};
|
||||
inline static void release(){};
|
||||
inline static void startFileprint(){};
|
||||
inline static void startFilewrite(char *name){};
|
||||
inline static void pauseSDPrint(){};
|
||||
inline static void getStatus(){};
|
||||
FORCE_INLINE static void openFile(char* name,bool read){};
|
||||
FORCE_INLINE static void closefile() {};
|
||||
FORCE_INLINE static void release(){};
|
||||
FORCE_INLINE static void startFileprint(){};
|
||||
FORCE_INLINE static void startFilewrite(char *name){};
|
||||
FORCE_INLINE static void pauseSDPrint(){};
|
||||
FORCE_INLINE static void getStatus(){};
|
||||
|
||||
inline static void selectFile(char* name){};
|
||||
inline static void getfilename(const uint8_t nr){};
|
||||
inline static uint8_t getnrfilenames(){return 0;};
|
||||
FORCE_INLINE static void selectFile(char* name){};
|
||||
FORCE_INLINE static void getfilename(const uint8_t nr){};
|
||||
FORCE_INLINE static uint8_t getnrfilenames(){return 0;};
|
||||
|
||||
|
||||
inline static void ls() {};
|
||||
inline static bool eof() {return true;};
|
||||
inline static char get() {return 0;};
|
||||
inline static void setIndex(){};
|
||||
inline uint8_t percentDone(){return 0;};
|
||||
FORCE_INLINE static void ls() {};
|
||||
FORCE_INLINE static bool eof() {return true;};
|
||||
FORCE_INLINE static char get() {return 0;};
|
||||
FORCE_INLINE static void setIndex(){};
|
||||
FORCE_INLINE uint8_t percentDone(){return 0;};
|
||||
};
|
||||
#endif //SDSUPPORT
|
||||
#endif
|
||||
+2581
-2558
File diff suppressed because it is too large
Load Diff
@@ -19,7 +19,6 @@
|
||||
along with Grbl. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "Configuration.h"
|
||||
#include "Marlin.h"
|
||||
#include "stepper.h"
|
||||
#include "planner.h"
|
||||
@@ -27,7 +26,7 @@
|
||||
// The arc is approximated by generating a huge number of tiny, linear segments. The length of each
|
||||
// segment is configured in settings.mm_per_arc_segment.
|
||||
void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8_t axis_1,
|
||||
uint8_t axis_linear, float feed_rate, float radius, uint8_t isclockwise)
|
||||
uint8_t axis_linear, float feed_rate, float radius, uint8_t isclockwise, uint8_t extruder)
|
||||
{
|
||||
// int acceleration_manager_was_enabled = plan_is_acceleration_manager_enabled();
|
||||
// plan_set_acceleration_manager_enabled(false); // disable acceleration management for the duration of the arc
|
||||
@@ -46,7 +45,7 @@ void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8
|
||||
if (isclockwise) { angular_travel -= 2*M_PI; }
|
||||
|
||||
float millimeters_of_travel = hypot(angular_travel*radius, fabs(linear_travel));
|
||||
if (millimeters_of_travel == 0.0) { return; }
|
||||
if (millimeters_of_travel < 0.001) { return; }
|
||||
uint16_t segments = floor(millimeters_of_travel/MM_PER_ARC_SEGMENT);
|
||||
/*
|
||||
// Multiply inverse feed_rate to compensate for the fact that this movement is approximated
|
||||
@@ -123,11 +122,11 @@ void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8
|
||||
arc_target[axis_1] = center_axis1 + r_axis1;
|
||||
arc_target[axis_linear] += linear_per_segment;
|
||||
arc_target[E_AXIS] += extruder_per_segment;
|
||||
plan_buffer_line(arc_target[X_AXIS], arc_target[Y_AXIS], arc_target[Z_AXIS], arc_target[E_AXIS], feed_rate);
|
||||
plan_buffer_line(arc_target[X_AXIS], arc_target[Y_AXIS], arc_target[Z_AXIS], arc_target[E_AXIS], feed_rate, extruder);
|
||||
|
||||
}
|
||||
// Ensure last segment arrives at target location.
|
||||
plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feed_rate);
|
||||
plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feed_rate, extruder);
|
||||
|
||||
// plan_set_acceleration_manager_enabled(acceleration_manager_was_enabled);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,6 @@
|
||||
// the direction of helical travel, radius == circle radius, isclockwise boolean. Used
|
||||
// for vector transformation direction.
|
||||
void mc_arc(float *position, float *target, float *offset, unsigned char axis_0, unsigned char axis_1,
|
||||
unsigned char axis_linear, float feed_rate, float radius, unsigned char isclockwise);
|
||||
unsigned char axis_linear, float feed_rate, float radius, unsigned char isclockwise, uint8_t extruder);
|
||||
|
||||
#endif
|
||||
|
||||
+903
-694
File diff suppressed because it is too large
Load Diff
+88
-56
@@ -52,14 +52,9 @@
|
||||
*/
|
||||
|
||||
|
||||
//#include <inttypes.h>
|
||||
//#include <math.h>
|
||||
//#include <stdlib.h>
|
||||
|
||||
|
||||
#include "Marlin.h"
|
||||
#include "Configuration.h"
|
||||
#include "pins.h"
|
||||
#include "fastio.h"
|
||||
#include "planner.h"
|
||||
#include "stepper.h"
|
||||
#include "temperature.h"
|
||||
@@ -89,22 +84,29 @@ static float previous_nominal_speed; // Nominal speed of previous path line segm
|
||||
#ifdef AUTOTEMP
|
||||
float autotemp_max=250;
|
||||
float autotemp_min=210;
|
||||
float autotemp_factor=1;
|
||||
float autotemp_factor=0.1;
|
||||
bool autotemp_enabled=false;
|
||||
#endif
|
||||
|
||||
//===========================================================================
|
||||
//=================semi-private variables, used in inline functions =====
|
||||
//===========================================================================
|
||||
block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instfructions
|
||||
volatile unsigned char block_buffer_head; // Index of the next block to be pushed
|
||||
volatile unsigned char block_buffer_tail; // Index of the block to process now
|
||||
|
||||
//===========================================================================
|
||||
//=============================private variables ============================
|
||||
//===========================================================================
|
||||
static block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instfructions
|
||||
static volatile unsigned char block_buffer_head; // Index of the next block to be pushed
|
||||
static volatile unsigned char block_buffer_tail; // Index of the block to process now
|
||||
|
||||
// Used for the frequency limit
|
||||
static unsigned char old_direction_bits = 0; // Old direction bits. Used for speed calculations
|
||||
static long x_segment_time[3]={0,0,0}; // Segment times (in us). Used for speed calculations
|
||||
static long y_segment_time[3]={0,0,0};
|
||||
#ifdef PREVENT_DANGEROUS_EXTRUDE
|
||||
bool allow_cold_extrude=false;
|
||||
#endif
|
||||
#ifdef XY_FREQUENCY_LIMIT
|
||||
// Used for the frequency limit
|
||||
static unsigned char old_direction_bits = 0; // Old direction bits. Used for speed calculations
|
||||
static long x_segment_time[3]={0,0,0}; // Segment times (in us). Used for speed calculations
|
||||
static long y_segment_time[3]={0,0,0};
|
||||
#endif
|
||||
|
||||
// Returns the index of the next block in the ring buffer
|
||||
// NOTE: Removed modulo (%) operator, which uses an expensive divide and multiplication.
|
||||
@@ -128,7 +130,8 @@ static int8_t prev_block_index(int8_t block_index) {
|
||||
|
||||
// Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the
|
||||
// given acceleration:
|
||||
inline float estimate_acceleration_distance(float initial_rate, float target_rate, float acceleration) {
|
||||
FORCE_INLINE float estimate_acceleration_distance(float initial_rate, float target_rate, float acceleration)
|
||||
{
|
||||
if (acceleration!=0) {
|
||||
return((target_rate*target_rate-initial_rate*initial_rate)/
|
||||
(2.0*acceleration));
|
||||
@@ -143,7 +146,8 @@ inline float estimate_acceleration_distance(float initial_rate, float target_rat
|
||||
// a total travel of distance. This can be used to compute the intersection point between acceleration and
|
||||
// deceleration in the cases where the trapezoid has no plateau (i.e. never reaches maximum speed)
|
||||
|
||||
inline float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance) {
|
||||
FORCE_INLINE float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance)
|
||||
{
|
||||
if (acceleration!=0) {
|
||||
return((2.0*acceleration*distance-initial_rate*initial_rate+final_rate*final_rate)/
|
||||
(4.0*acceleration) );
|
||||
@@ -184,13 +188,12 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi
|
||||
}
|
||||
|
||||
#ifdef ADVANCE
|
||||
long initial_advance = block->advance*entry_factor*entry_factor;
|
||||
long final_advance = block->advance*exit_factor*exit_factor;
|
||||
volatile long initial_advance = block->advance*entry_factor*entry_factor;
|
||||
volatile long final_advance = block->advance*exit_factor*exit_factor;
|
||||
#endif // ADVANCE
|
||||
|
||||
// block->accelerate_until = accelerate_steps;
|
||||
// block->decelerate_after = accelerate_steps+plateau_steps;
|
||||
|
||||
CRITICAL_SECTION_START; // Fill variables used by the stepper in a critical section
|
||||
if(block->busy == false) { // Don't update variables if block is busy.
|
||||
block->accelerate_until = accelerate_steps;
|
||||
@@ -207,7 +210,7 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi
|
||||
|
||||
// Calculates the maximum allowable speed at this point when you must be able to reach target_velocity using the
|
||||
// acceleration within the allotted distance.
|
||||
inline float max_allowable_speed(float acceleration, float target_velocity, float distance) {
|
||||
FORCE_INLINE float max_allowable_speed(float acceleration, float target_velocity, float distance) {
|
||||
return sqrt(target_velocity*target_velocity-2*acceleration*distance);
|
||||
}
|
||||
|
||||
@@ -247,7 +250,7 @@ void planner_reverse_pass_kernel(block_t *previous, block_t *current, block_t *n
|
||||
// planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This
|
||||
// implements the reverse pass.
|
||||
void planner_reverse_pass() {
|
||||
char block_index = block_buffer_head;
|
||||
uint8_t block_index = block_buffer_head;
|
||||
if(((block_buffer_head-block_buffer_tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1)) > 3) {
|
||||
block_index = (block_buffer_head - 3) & (BLOCK_BUFFER_SIZE - 1);
|
||||
block_t *block[3] = { NULL, NULL, NULL };
|
||||
@@ -286,7 +289,7 @@ void planner_forward_pass_kernel(block_t *previous, block_t *current, block_t *n
|
||||
// planner_recalculate() needs to go over the current plan twice. Once in reverse and once forward. This
|
||||
// implements the forward pass.
|
||||
void planner_forward_pass() {
|
||||
char block_index = block_buffer_tail;
|
||||
uint8_t block_index = block_buffer_tail;
|
||||
block_t *block[3] = { NULL, NULL, NULL };
|
||||
|
||||
while(block_index != block_buffer_head) {
|
||||
@@ -364,20 +367,7 @@ void plan_init() {
|
||||
}
|
||||
|
||||
|
||||
void plan_discard_current_block() {
|
||||
if (block_buffer_head != block_buffer_tail) {
|
||||
block_buffer_tail = (block_buffer_tail + 1) & (BLOCK_BUFFER_SIZE - 1);
|
||||
}
|
||||
}
|
||||
|
||||
block_t *plan_get_current_block() {
|
||||
if (block_buffer_head == block_buffer_tail) {
|
||||
return(NULL);
|
||||
}
|
||||
block_t *block = &block_buffer[block_buffer_tail];
|
||||
block->busy = true;
|
||||
return(block);
|
||||
}
|
||||
|
||||
#ifdef AUTOTEMP
|
||||
void getHighESpeed()
|
||||
@@ -389,7 +379,7 @@ void getHighESpeed()
|
||||
return; //do nothing
|
||||
|
||||
float high=0;
|
||||
char block_index = block_buffer_tail;
|
||||
uint8_t block_index = block_buffer_tail;
|
||||
|
||||
while(block_index != block_buffer_head) {
|
||||
float se=block_buffer[block_index].steps_e/float(block_buffer[block_index].step_event_count)*block_buffer[block_index].nominal_rate;
|
||||
@@ -428,7 +418,7 @@ void check_axes_activity() {
|
||||
block_t *block;
|
||||
|
||||
if(block_buffer_tail != block_buffer_head) {
|
||||
char block_index = block_buffer_tail;
|
||||
uint8_t block_index = block_buffer_tail;
|
||||
while(block_index != block_buffer_head) {
|
||||
block = &block_buffer[block_index];
|
||||
if(block->steps_x != 0) x_active++;
|
||||
@@ -441,7 +431,7 @@ void check_axes_activity() {
|
||||
if((DISABLE_X) && (x_active == 0)) disable_x();
|
||||
if((DISABLE_Y) && (y_active == 0)) disable_y();
|
||||
if((DISABLE_Z) && (z_active == 0)) disable_z();
|
||||
if((DISABLE_E) && (e_active == 0)) disable_e();
|
||||
if((DISABLE_E) && (e_active == 0)) { disable_e0();disable_e1();disable_e2(); }
|
||||
}
|
||||
|
||||
|
||||
@@ -449,7 +439,7 @@ float junction_deviation = 0.1;
|
||||
// Add a new linear movement to the buffer. steps_x, _y and _z is the absolute position in
|
||||
// mm. Microseconds specify how many microseconds the move should take to perform. To aid acceleration
|
||||
// calculation the caller must also provide the physical length of the line in millimeters.
|
||||
void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate)
|
||||
void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate, const uint8_t &extruder)
|
||||
{
|
||||
// Calculate the buffer head after we push this byte
|
||||
int next_buffer_head = next_block_index(block_buffer_head);
|
||||
@@ -469,7 +459,23 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
||||
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]);
|
||||
target[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]);
|
||||
|
||||
#ifdef PREVENT_DANGEROUS_EXTRUDE
|
||||
if(target[E_AXIS]!=position[E_AXIS])
|
||||
if(degHotend(active_extruder)<EXTRUDE_MINTEMP && !allow_cold_extrude)
|
||||
{
|
||||
position[E_AXIS]=target[E_AXIS]; //behave as if the move really took place, but ignore E part
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOLNPGM(" cold extrusion prevented");
|
||||
}
|
||||
if(labs(target[E_AXIS]-position[E_AXIS])>axis_steps_per_unit[E_AXIS]*EXTRUDE_MAXLENGTH)
|
||||
{
|
||||
position[E_AXIS]=target[E_AXIS]; //behave as if the move really took place, but ignore E part
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOLNPGM(" too long extrusion prevented");
|
||||
}
|
||||
#endif
|
||||
|
||||
// Prepare to set up new block
|
||||
block_t *block = &block_buffer[block_buffer_head];
|
||||
@@ -487,26 +493,35 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
||||
// Bail if this is a zero-length block
|
||||
if (block->step_event_count <=dropsegments) { return; };
|
||||
|
||||
// Compute direction bits for this block
|
||||
// Compute direction bits for this block
|
||||
block->direction_bits = 0;
|
||||
if (target[X_AXIS] < position[X_AXIS]) { block->direction_bits |= (1<<X_AXIS); }
|
||||
if (target[Y_AXIS] < position[Y_AXIS]) { block->direction_bits |= (1<<Y_AXIS); }
|
||||
if (target[Z_AXIS] < position[Z_AXIS]) { block->direction_bits |= (1<<Z_AXIS); }
|
||||
if (target[E_AXIS] < position[E_AXIS]) { block->direction_bits |= (1<<E_AXIS); }
|
||||
|
||||
block->active_extruder = extruder;
|
||||
|
||||
//enable active axes
|
||||
if(block->steps_x != 0) enable_x();
|
||||
if(block->steps_y != 0) enable_y();
|
||||
if(block->steps_z != 0) enable_z();
|
||||
if(block->steps_e != 0) enable_e();
|
||||
#ifndef Z_LATE_ENABLE
|
||||
if(block->steps_z != 0) enable_z();
|
||||
#endif
|
||||
|
||||
// Enable all
|
||||
if(block->steps_e != 0) { enable_e0();enable_e1();enable_e2(); }
|
||||
|
||||
float delta_mm[4];
|
||||
delta_mm[X_AXIS] = (target[X_AXIS]-position[X_AXIS])/axis_steps_per_unit[X_AXIS];
|
||||
delta_mm[Y_AXIS] = (target[Y_AXIS]-position[Y_AXIS])/axis_steps_per_unit[Y_AXIS];
|
||||
delta_mm[Z_AXIS] = (target[Z_AXIS]-position[Z_AXIS])/axis_steps_per_unit[Z_AXIS];
|
||||
delta_mm[E_AXIS] = (target[E_AXIS]-position[E_AXIS])/axis_steps_per_unit[E_AXIS];
|
||||
block->millimeters = sqrt(square(delta_mm[X_AXIS]) + square(delta_mm[Y_AXIS]) +
|
||||
square(delta_mm[Z_AXIS]) + square(delta_mm[E_AXIS]));
|
||||
if ( block->steps_x == 0 && block->steps_y == 0 && block->steps_z == 0 ) {
|
||||
block->millimeters = abs(delta_mm[E_AXIS]);
|
||||
} else {
|
||||
block->millimeters = sqrt(square(delta_mm[X_AXIS]) + square(delta_mm[Y_AXIS]) + square(delta_mm[Z_AXIS]));
|
||||
}
|
||||
float inverse_millimeters = 1.0/block->millimeters; // Inverse millimeters to remove multiple divides
|
||||
|
||||
// Calculate speed in mm/second for each axis. No divide by zero due to previous checks.
|
||||
@@ -515,25 +530,22 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
||||
block->nominal_speed = block->millimeters * inverse_second; // (mm/sec) Always > 0
|
||||
block->nominal_rate = ceil(block->step_event_count * inverse_second); // (step/sec) Always > 0
|
||||
|
||||
// segment time im micro seconds
|
||||
long segment_time = lround(1000000.0/inverse_second);
|
||||
|
||||
|
||||
if (block->steps_e == 0) {
|
||||
if(feed_rate<mintravelfeedrate) feed_rate=mintravelfeedrate;
|
||||
}
|
||||
else {
|
||||
if(feed_rate<minimumfeedrate) feed_rate=minimumfeedrate;
|
||||
}
|
||||
|
||||
#ifdef SLOWDOWN
|
||||
|
||||
// slow down when de buffer starts to empty, rather than wait at the corner for a buffer refill
|
||||
int moves_queued=(block_buffer_head-block_buffer_tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1);
|
||||
|
||||
if(moves_queued < (BLOCK_BUFFER_SIZE * 0.5)) feed_rate = feed_rate / ((BLOCK_BUFFER_SIZE * 0.5)/moves_queued);
|
||||
#ifdef SLOWDOWN
|
||||
if(moves_queued < (BLOCK_BUFFER_SIZE * 0.5) && moves_queued > 1) feed_rate = feed_rate*moves_queued / (BLOCK_BUFFER_SIZE * 0.5);
|
||||
#endif
|
||||
|
||||
/*
|
||||
// segment time im micro seconds
|
||||
long segment_time = lround(1000000.0/inverse_second);
|
||||
if ((blockcount>0) && (blockcount < (BLOCK_BUFFER_SIZE - 4))) {
|
||||
if (segment_time<minsegmenttime) { // buffer is draining, add extra time. The amount of time added increases if the buffer is still emptied more.
|
||||
segment_time=segment_time+lround(2*(minsegmenttime-segment_time)/blockcount);
|
||||
@@ -675,7 +687,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
||||
vmax_junction = max_z_jerk/2;
|
||||
vmax_junction = min(vmax_junction, block->nominal_speed);
|
||||
|
||||
if ((block_buffer_head != block_buffer_tail) && (previous_nominal_speed > 0.0)) {
|
||||
if ((moves_queued > 1) && (previous_nominal_speed > 0.0)) {
|
||||
float jerk = sqrt(pow((current_speed[X_AXIS]-previous_speed[X_AXIS]), 2)+pow((current_speed[Y_AXIS]-previous_speed[Y_AXIS]), 2));
|
||||
if((previous_speed[X_AXIS] != 0.0) || (previous_speed[Y_AXIS] != 0.0)) {
|
||||
vmax_junction = block->nominal_speed;
|
||||
@@ -718,7 +730,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
||||
else {
|
||||
long acc_dist = estimate_acceleration_distance(0, block->nominal_rate, block->acceleration_st);
|
||||
float advance = (STEPS_PER_CUBIC_MM_E * EXTRUDER_ADVANCE_K) *
|
||||
(block->speed_e * block->speed_e * EXTRUTION_AREA * EXTRUTION_AREA / 3600.0)*65536;
|
||||
(current_speed[E_AXIS] * current_speed[E_AXIS] * EXTRUTION_AREA * EXTRUTION_AREA)*256;
|
||||
block->advance = advance;
|
||||
if(acc_dist == 0) {
|
||||
block->advance_rate = 0;
|
||||
@@ -727,6 +739,13 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
||||
block->advance_rate = advance / (float)acc_dist;
|
||||
}
|
||||
}
|
||||
/*
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOPGM("advance :");
|
||||
SERIAL_ECHO(block->advance/256.0);
|
||||
SERIAL_ECHOPGM("advance rate :");
|
||||
SERIAL_ECHOLN(block->advance_rate/256.0);
|
||||
*/
|
||||
#endif // ADVANCE
|
||||
|
||||
|
||||
@@ -762,7 +781,20 @@ void plan_set_position(const float &x, const float &y, const float &z, const flo
|
||||
previous_speed[3] = 0.0;
|
||||
}
|
||||
|
||||
void plan_set_e_position(const float &e)
|
||||
{
|
||||
position[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]);
|
||||
st_set_e_position(position[E_AXIS]);
|
||||
}
|
||||
|
||||
uint8_t movesplanned()
|
||||
{
|
||||
return (block_buffer_head-block_buffer_tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1);
|
||||
}
|
||||
|
||||
void allow_cold_extrudes(bool allow)
|
||||
{
|
||||
#ifdef PREVENT_DANGEROUS_EXTRUDE
|
||||
allow_cold_extrude=allow;
|
||||
#endif
|
||||
}
|
||||
|
||||
+45
-13
@@ -24,7 +24,7 @@
|
||||
#ifndef planner_h
|
||||
#define planner_h
|
||||
|
||||
#include "Configuration.h"
|
||||
#include "Marlin.h"
|
||||
|
||||
// This struct is used when buffering the setup for each linear movement "nominal" values are as specified in
|
||||
// the source g-code and may never actually be reached if acceleration management is active.
|
||||
@@ -36,11 +36,12 @@ typedef struct {
|
||||
long decelerate_after; // The index of the step event on which to start decelerating
|
||||
long acceleration_rate; // The acceleration rate used for acceleration calculation
|
||||
unsigned char direction_bits; // The direction bit set for this block (refers to *_DIRECTION_BIT in config.h)
|
||||
unsigned char active_extruder; // Selects the active extruder
|
||||
#ifdef ADVANCE
|
||||
// long advance_rate;
|
||||
// volatile long initial_advance;
|
||||
// volatile long final_advance;
|
||||
// float advance;
|
||||
long advance_rate;
|
||||
volatile long initial_advance;
|
||||
volatile long final_advance;
|
||||
float advance;
|
||||
#endif
|
||||
|
||||
// Fields used by the motion planner to manage acceleration
|
||||
@@ -66,18 +67,13 @@ void plan_init();
|
||||
|
||||
// Add a new linear movement to the buffer. x, y and z is the signed, absolute target position in
|
||||
// millimaters. Feed rate specifies the speed of the motion.
|
||||
void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate);
|
||||
void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate, const uint8_t &extruder);
|
||||
|
||||
// Set position. Used for G92 instructions.
|
||||
void plan_set_position(const float &x, const float &y, const float &z, const float &e);
|
||||
void plan_set_e_position(const float &e);
|
||||
|
||||
|
||||
// Called when the current block is no longer needed. Discards the block and makes the memory
|
||||
// availible for new blocks.
|
||||
void plan_discard_current_block();
|
||||
|
||||
// Gets the current block. Returns NULL if buffer empty
|
||||
block_t *plan_get_current_block();
|
||||
|
||||
void check_axes_activity();
|
||||
uint8_t movesplanned(); //return the nr of buffered moves
|
||||
@@ -94,7 +90,6 @@ extern float max_z_jerk;
|
||||
extern float mintravelfeedrate;
|
||||
extern unsigned long axis_steps_per_sqr_second[NUM_AXIS];
|
||||
|
||||
|
||||
#ifdef AUTOTEMP
|
||||
extern bool autotemp_enabled;
|
||||
extern float autotemp_max;
|
||||
@@ -102,4 +97,41 @@ extern unsigned long axis_steps_per_sqr_second[NUM_AXIS];
|
||||
extern float autotemp_factor;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
extern block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instfructions
|
||||
extern volatile unsigned char block_buffer_head; // Index of the next block to be pushed
|
||||
extern volatile unsigned char block_buffer_tail;
|
||||
// Called when the current block is no longer needed. Discards the block and makes the memory
|
||||
// availible for new blocks.
|
||||
FORCE_INLINE void plan_discard_current_block()
|
||||
{
|
||||
if (block_buffer_head != block_buffer_tail) {
|
||||
block_buffer_tail = (block_buffer_tail + 1) & (BLOCK_BUFFER_SIZE - 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Gets the current block. Returns NULL if buffer empty
|
||||
FORCE_INLINE block_t *plan_get_current_block()
|
||||
{
|
||||
if (block_buffer_head == block_buffer_tail) {
|
||||
return(NULL);
|
||||
}
|
||||
block_t *block = &block_buffer[block_buffer_tail];
|
||||
block->busy = true;
|
||||
return(block);
|
||||
}
|
||||
|
||||
// Gets the current block. Returns NULL if buffer empty
|
||||
FORCE_INLINE bool blocks_queued()
|
||||
{
|
||||
if (block_buffer_head == block_buffer_tail) {
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
void allow_cold_extrudes(bool allow);
|
||||
#endif
|
||||
|
||||
+76
-76
@@ -1,76 +1,76 @@
|
||||
#ifndef SPEED_LOOKUPTABLE_H
|
||||
#define SPEED_LOOKUPTABLE_H
|
||||
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
uint16_t speed_lookuptable_fast[256][2] PROGMEM = {\
|
||||
{ 62500, 55556}, { 6944, 3268}, { 3676, 1176}, { 2500, 607}, { 1893, 369}, { 1524, 249}, { 1275, 179}, { 1096, 135},
|
||||
{ 961, 105}, { 856, 85}, { 771, 69}, { 702, 58}, { 644, 49}, { 595, 42}, { 553, 37}, { 516, 32},
|
||||
{ 484, 28}, { 456, 25}, { 431, 23}, { 408, 20}, { 388, 19}, { 369, 16}, { 353, 16}, { 337, 14},
|
||||
{ 323, 13}, { 310, 11}, { 299, 11}, { 288, 11}, { 277, 9}, { 268, 9}, { 259, 8}, { 251, 8},
|
||||
{ 243, 8}, { 235, 7}, { 228, 6}, { 222, 6}, { 216, 6}, { 210, 6}, { 204, 5}, { 199, 5},
|
||||
{ 194, 5}, { 189, 4}, { 185, 4}, { 181, 4}, { 177, 4}, { 173, 4}, { 169, 4}, { 165, 3},
|
||||
{ 162, 3}, { 159, 4}, { 155, 3}, { 152, 3}, { 149, 2}, { 147, 3}, { 144, 3}, { 141, 2},
|
||||
{ 139, 3}, { 136, 2}, { 134, 2}, { 132, 3}, { 129, 2}, { 127, 2}, { 125, 2}, { 123, 2},
|
||||
{ 121, 2}, { 119, 1}, { 118, 2}, { 116, 2}, { 114, 1}, { 113, 2}, { 111, 2}, { 109, 1},
|
||||
{ 108, 2}, { 106, 1}, { 105, 2}, { 103, 1}, { 102, 1}, { 101, 1}, { 100, 2}, { 98, 1},
|
||||
{ 97, 1}, { 96, 1}, { 95, 2}, { 93, 1}, { 92, 1}, { 91, 1}, { 90, 1}, { 89, 1},
|
||||
{ 88, 1}, { 87, 1}, { 86, 1}, { 85, 1}, { 84, 1}, { 83, 0}, { 83, 1}, { 82, 1},
|
||||
{ 81, 1}, { 80, 1}, { 79, 1}, { 78, 0}, { 78, 1}, { 77, 1}, { 76, 1}, { 75, 0},
|
||||
{ 75, 1}, { 74, 1}, { 73, 1}, { 72, 0}, { 72, 1}, { 71, 1}, { 70, 0}, { 70, 1},
|
||||
{ 69, 0}, { 69, 1}, { 68, 1}, { 67, 0}, { 67, 1}, { 66, 0}, { 66, 1}, { 65, 0},
|
||||
{ 65, 1}, { 64, 1}, { 63, 0}, { 63, 1}, { 62, 0}, { 62, 1}, { 61, 0}, { 61, 1},
|
||||
{ 60, 0}, { 60, 0}, { 60, 1}, { 59, 0}, { 59, 1}, { 58, 0}, { 58, 1}, { 57, 0},
|
||||
{ 57, 1}, { 56, 0}, { 56, 0}, { 56, 1}, { 55, 0}, { 55, 1}, { 54, 0}, { 54, 0},
|
||||
{ 54, 1}, { 53, 0}, { 53, 0}, { 53, 1}, { 52, 0}, { 52, 0}, { 52, 1}, { 51, 0},
|
||||
{ 51, 0}, { 51, 1}, { 50, 0}, { 50, 0}, { 50, 1}, { 49, 0}, { 49, 0}, { 49, 1},
|
||||
{ 48, 0}, { 48, 0}, { 48, 1}, { 47, 0}, { 47, 0}, { 47, 0}, { 47, 1}, { 46, 0},
|
||||
{ 46, 0}, { 46, 1}, { 45, 0}, { 45, 0}, { 45, 0}, { 45, 1}, { 44, 0}, { 44, 0},
|
||||
{ 44, 0}, { 44, 1}, { 43, 0}, { 43, 0}, { 43, 0}, { 43, 1}, { 42, 0}, { 42, 0},
|
||||
{ 42, 0}, { 42, 1}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 1}, { 40, 0},
|
||||
{ 40, 0}, { 40, 0}, { 40, 0}, { 40, 1}, { 39, 0}, { 39, 0}, { 39, 0}, { 39, 0},
|
||||
{ 39, 1}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 1}, { 37, 0}, { 37, 0},
|
||||
{ 37, 0}, { 37, 0}, { 37, 0}, { 37, 1}, { 36, 0}, { 36, 0}, { 36, 0}, { 36, 0},
|
||||
{ 36, 1}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 1},
|
||||
{ 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 1}, { 33, 0}, { 33, 0},
|
||||
{ 33, 0}, { 33, 0}, { 33, 0}, { 33, 0}, { 33, 1}, { 32, 0}, { 32, 0}, { 32, 0},
|
||||
{ 32, 0}, { 32, 0}, { 32, 0}, { 32, 0}, { 32, 1}, { 31, 0}, { 31, 0}, { 31, 0},
|
||||
{ 31, 0}, { 31, 0}, { 31, 0}, { 31, 1}, { 30, 0}, { 30, 0}, { 30, 0}, { 30, 0}
|
||||
};
|
||||
|
||||
uint16_t speed_lookuptable_slow[256][2] PROGMEM = {\
|
||||
{ 62500, 12500}, { 50000, 8334}, { 41666, 5952}, { 35714, 4464}, { 31250, 3473}, { 27777, 2777}, { 25000, 2273}, { 22727, 1894},
|
||||
{ 20833, 1603}, { 19230, 1373}, { 17857, 1191}, { 16666, 1041}, { 15625, 920}, { 14705, 817}, { 13888, 731}, { 13157, 657},
|
||||
{ 12500, 596}, { 11904, 541}, { 11363, 494}, { 10869, 453}, { 10416, 416}, { 10000, 385}, { 9615, 356}, { 9259, 331},
|
||||
{ 8928, 308}, { 8620, 287}, { 8333, 269}, { 8064, 252}, { 7812, 237}, { 7575, 223}, { 7352, 210}, { 7142, 198},
|
||||
{ 6944, 188}, { 6756, 178}, { 6578, 168}, { 6410, 160}, { 6250, 153}, { 6097, 145}, { 5952, 139}, { 5813, 132},
|
||||
{ 5681, 126}, { 5555, 121}, { 5434, 115}, { 5319, 111}, { 5208, 106}, { 5102, 102}, { 5000, 99}, { 4901, 94},
|
||||
{ 4807, 91}, { 4716, 87}, { 4629, 84}, { 4545, 81}, { 4464, 79}, { 4385, 75}, { 4310, 73}, { 4237, 71},
|
||||
{ 4166, 68}, { 4098, 66}, { 4032, 64}, { 3968, 62}, { 3906, 60}, { 3846, 59}, { 3787, 56}, { 3731, 55},
|
||||
{ 3676, 53}, { 3623, 52}, { 3571, 50}, { 3521, 49}, { 3472, 48}, { 3424, 46}, { 3378, 45}, { 3333, 44},
|
||||
{ 3289, 43}, { 3246, 41}, { 3205, 41}, { 3164, 39}, { 3125, 39}, { 3086, 38}, { 3048, 36}, { 3012, 36},
|
||||
{ 2976, 35}, { 2941, 35}, { 2906, 33}, { 2873, 33}, { 2840, 32}, { 2808, 31}, { 2777, 30}, { 2747, 30},
|
||||
{ 2717, 29}, { 2688, 29}, { 2659, 28}, { 2631, 27}, { 2604, 27}, { 2577, 26}, { 2551, 26}, { 2525, 25},
|
||||
{ 2500, 25}, { 2475, 25}, { 2450, 23}, { 2427, 24}, { 2403, 23}, { 2380, 22}, { 2358, 22}, { 2336, 22},
|
||||
{ 2314, 21}, { 2293, 21}, { 2272, 20}, { 2252, 20}, { 2232, 20}, { 2212, 20}, { 2192, 19}, { 2173, 18},
|
||||
{ 2155, 19}, { 2136, 18}, { 2118, 18}, { 2100, 17}, { 2083, 17}, { 2066, 17}, { 2049, 17}, { 2032, 16},
|
||||
{ 2016, 16}, { 2000, 16}, { 1984, 16}, { 1968, 15}, { 1953, 16}, { 1937, 14}, { 1923, 15}, { 1908, 15},
|
||||
{ 1893, 14}, { 1879, 14}, { 1865, 14}, { 1851, 13}, { 1838, 14}, { 1824, 13}, { 1811, 13}, { 1798, 13},
|
||||
{ 1785, 12}, { 1773, 13}, { 1760, 12}, { 1748, 12}, { 1736, 12}, { 1724, 12}, { 1712, 12}, { 1700, 11},
|
||||
{ 1689, 12}, { 1677, 11}, { 1666, 11}, { 1655, 11}, { 1644, 11}, { 1633, 10}, { 1623, 11}, { 1612, 10},
|
||||
{ 1602, 10}, { 1592, 10}, { 1582, 10}, { 1572, 10}, { 1562, 10}, { 1552, 9}, { 1543, 10}, { 1533, 9},
|
||||
{ 1524, 9}, { 1515, 9}, { 1506, 9}, { 1497, 9}, { 1488, 9}, { 1479, 9}, { 1470, 9}, { 1461, 8},
|
||||
{ 1453, 8}, { 1445, 9}, { 1436, 8}, { 1428, 8}, { 1420, 8}, { 1412, 8}, { 1404, 8}, { 1396, 8},
|
||||
{ 1388, 7}, { 1381, 8}, { 1373, 7}, { 1366, 8}, { 1358, 7}, { 1351, 7}, { 1344, 8}, { 1336, 7},
|
||||
{ 1329, 7}, { 1322, 7}, { 1315, 7}, { 1308, 6}, { 1302, 7}, { 1295, 7}, { 1288, 6}, { 1282, 7},
|
||||
{ 1275, 6}, { 1269, 7}, { 1262, 6}, { 1256, 6}, { 1250, 7}, { 1243, 6}, { 1237, 6}, { 1231, 6},
|
||||
{ 1225, 6}, { 1219, 6}, { 1213, 6}, { 1207, 6}, { 1201, 5}, { 1196, 6}, { 1190, 6}, { 1184, 5},
|
||||
{ 1179, 6}, { 1173, 5}, { 1168, 6}, { 1162, 5}, { 1157, 5}, { 1152, 6}, { 1146, 5}, { 1141, 5},
|
||||
{ 1136, 5}, { 1131, 5}, { 1126, 5}, { 1121, 5}, { 1116, 5}, { 1111, 5}, { 1106, 5}, { 1101, 5},
|
||||
{ 1096, 5}, { 1091, 5}, { 1086, 4}, { 1082, 5}, { 1077, 5}, { 1072, 4}, { 1068, 5}, { 1063, 4},
|
||||
{ 1059, 5}, { 1054, 4}, { 1050, 4}, { 1046, 5}, { 1041, 4}, { 1037, 4}, { 1033, 5}, { 1028, 4},
|
||||
{ 1024, 4}, { 1020, 4}, { 1016, 4}, { 1012, 4}, { 1008, 4}, { 1004, 4}, { 1000, 4}, { 996, 4},
|
||||
{ 992, 4}, { 988, 4}, { 984, 4}, { 980, 4}, { 976, 4}, { 972, 4}, { 968, 3}, { 965, 3}
|
||||
};
|
||||
|
||||
#endif
|
||||
#ifndef SPEED_LOOKUPTABLE_H
|
||||
#define SPEED_LOOKUPTABLE_H
|
||||
|
||||
#include "Marlin.h"
|
||||
|
||||
const uint16_t speed_lookuptable_fast[256][2] PROGMEM = {\
|
||||
{ 62500, 55556}, { 6944, 3268}, { 3676, 1176}, { 2500, 607}, { 1893, 369}, { 1524, 249}, { 1275, 179}, { 1096, 135},
|
||||
{ 961, 105}, { 856, 85}, { 771, 69}, { 702, 58}, { 644, 49}, { 595, 42}, { 553, 37}, { 516, 32},
|
||||
{ 484, 28}, { 456, 25}, { 431, 23}, { 408, 20}, { 388, 19}, { 369, 16}, { 353, 16}, { 337, 14},
|
||||
{ 323, 13}, { 310, 11}, { 299, 11}, { 288, 11}, { 277, 9}, { 268, 9}, { 259, 8}, { 251, 8},
|
||||
{ 243, 8}, { 235, 7}, { 228, 6}, { 222, 6}, { 216, 6}, { 210, 6}, { 204, 5}, { 199, 5},
|
||||
{ 194, 5}, { 189, 4}, { 185, 4}, { 181, 4}, { 177, 4}, { 173, 4}, { 169, 4}, { 165, 3},
|
||||
{ 162, 3}, { 159, 4}, { 155, 3}, { 152, 3}, { 149, 2}, { 147, 3}, { 144, 3}, { 141, 2},
|
||||
{ 139, 3}, { 136, 2}, { 134, 2}, { 132, 3}, { 129, 2}, { 127, 2}, { 125, 2}, { 123, 2},
|
||||
{ 121, 2}, { 119, 1}, { 118, 2}, { 116, 2}, { 114, 1}, { 113, 2}, { 111, 2}, { 109, 1},
|
||||
{ 108, 2}, { 106, 1}, { 105, 2}, { 103, 1}, { 102, 1}, { 101, 1}, { 100, 2}, { 98, 1},
|
||||
{ 97, 1}, { 96, 1}, { 95, 2}, { 93, 1}, { 92, 1}, { 91, 1}, { 90, 1}, { 89, 1},
|
||||
{ 88, 1}, { 87, 1}, { 86, 1}, { 85, 1}, { 84, 1}, { 83, 0}, { 83, 1}, { 82, 1},
|
||||
{ 81, 1}, { 80, 1}, { 79, 1}, { 78, 0}, { 78, 1}, { 77, 1}, { 76, 1}, { 75, 0},
|
||||
{ 75, 1}, { 74, 1}, { 73, 1}, { 72, 0}, { 72, 1}, { 71, 1}, { 70, 0}, { 70, 1},
|
||||
{ 69, 0}, { 69, 1}, { 68, 1}, { 67, 0}, { 67, 1}, { 66, 0}, { 66, 1}, { 65, 0},
|
||||
{ 65, 1}, { 64, 1}, { 63, 0}, { 63, 1}, { 62, 0}, { 62, 1}, { 61, 0}, { 61, 1},
|
||||
{ 60, 0}, { 60, 0}, { 60, 1}, { 59, 0}, { 59, 1}, { 58, 0}, { 58, 1}, { 57, 0},
|
||||
{ 57, 1}, { 56, 0}, { 56, 0}, { 56, 1}, { 55, 0}, { 55, 1}, { 54, 0}, { 54, 0},
|
||||
{ 54, 1}, { 53, 0}, { 53, 0}, { 53, 1}, { 52, 0}, { 52, 0}, { 52, 1}, { 51, 0},
|
||||
{ 51, 0}, { 51, 1}, { 50, 0}, { 50, 0}, { 50, 1}, { 49, 0}, { 49, 0}, { 49, 1},
|
||||
{ 48, 0}, { 48, 0}, { 48, 1}, { 47, 0}, { 47, 0}, { 47, 0}, { 47, 1}, { 46, 0},
|
||||
{ 46, 0}, { 46, 1}, { 45, 0}, { 45, 0}, { 45, 0}, { 45, 1}, { 44, 0}, { 44, 0},
|
||||
{ 44, 0}, { 44, 1}, { 43, 0}, { 43, 0}, { 43, 0}, { 43, 1}, { 42, 0}, { 42, 0},
|
||||
{ 42, 0}, { 42, 1}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 0}, { 41, 1}, { 40, 0},
|
||||
{ 40, 0}, { 40, 0}, { 40, 0}, { 40, 1}, { 39, 0}, { 39, 0}, { 39, 0}, { 39, 0},
|
||||
{ 39, 1}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 0}, { 38, 1}, { 37, 0}, { 37, 0},
|
||||
{ 37, 0}, { 37, 0}, { 37, 0}, { 37, 1}, { 36, 0}, { 36, 0}, { 36, 0}, { 36, 0},
|
||||
{ 36, 1}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 0}, { 35, 1},
|
||||
{ 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 0}, { 34, 1}, { 33, 0}, { 33, 0},
|
||||
{ 33, 0}, { 33, 0}, { 33, 0}, { 33, 0}, { 33, 1}, { 32, 0}, { 32, 0}, { 32, 0},
|
||||
{ 32, 0}, { 32, 0}, { 32, 0}, { 32, 0}, { 32, 1}, { 31, 0}, { 31, 0}, { 31, 0},
|
||||
{ 31, 0}, { 31, 0}, { 31, 0}, { 31, 1}, { 30, 0}, { 30, 0}, { 30, 0}, { 30, 0}
|
||||
};
|
||||
|
||||
const uint16_t speed_lookuptable_slow[256][2] PROGMEM = {\
|
||||
{ 62500, 12500}, { 50000, 8334}, { 41666, 5952}, { 35714, 4464}, { 31250, 3473}, { 27777, 2777}, { 25000, 2273}, { 22727, 1894},
|
||||
{ 20833, 1603}, { 19230, 1373}, { 17857, 1191}, { 16666, 1041}, { 15625, 920}, { 14705, 817}, { 13888, 731}, { 13157, 657},
|
||||
{ 12500, 596}, { 11904, 541}, { 11363, 494}, { 10869, 453}, { 10416, 416}, { 10000, 385}, { 9615, 356}, { 9259, 331},
|
||||
{ 8928, 308}, { 8620, 287}, { 8333, 269}, { 8064, 252}, { 7812, 237}, { 7575, 223}, { 7352, 210}, { 7142, 198},
|
||||
{ 6944, 188}, { 6756, 178}, { 6578, 168}, { 6410, 160}, { 6250, 153}, { 6097, 145}, { 5952, 139}, { 5813, 132},
|
||||
{ 5681, 126}, { 5555, 121}, { 5434, 115}, { 5319, 111}, { 5208, 106}, { 5102, 102}, { 5000, 99}, { 4901, 94},
|
||||
{ 4807, 91}, { 4716, 87}, { 4629, 84}, { 4545, 81}, { 4464, 79}, { 4385, 75}, { 4310, 73}, { 4237, 71},
|
||||
{ 4166, 68}, { 4098, 66}, { 4032, 64}, { 3968, 62}, { 3906, 60}, { 3846, 59}, { 3787, 56}, { 3731, 55},
|
||||
{ 3676, 53}, { 3623, 52}, { 3571, 50}, { 3521, 49}, { 3472, 48}, { 3424, 46}, { 3378, 45}, { 3333, 44},
|
||||
{ 3289, 43}, { 3246, 41}, { 3205, 41}, { 3164, 39}, { 3125, 39}, { 3086, 38}, { 3048, 36}, { 3012, 36},
|
||||
{ 2976, 35}, { 2941, 35}, { 2906, 33}, { 2873, 33}, { 2840, 32}, { 2808, 31}, { 2777, 30}, { 2747, 30},
|
||||
{ 2717, 29}, { 2688, 29}, { 2659, 28}, { 2631, 27}, { 2604, 27}, { 2577, 26}, { 2551, 26}, { 2525, 25},
|
||||
{ 2500, 25}, { 2475, 25}, { 2450, 23}, { 2427, 24}, { 2403, 23}, { 2380, 22}, { 2358, 22}, { 2336, 22},
|
||||
{ 2314, 21}, { 2293, 21}, { 2272, 20}, { 2252, 20}, { 2232, 20}, { 2212, 20}, { 2192, 19}, { 2173, 18},
|
||||
{ 2155, 19}, { 2136, 18}, { 2118, 18}, { 2100, 17}, { 2083, 17}, { 2066, 17}, { 2049, 17}, { 2032, 16},
|
||||
{ 2016, 16}, { 2000, 16}, { 1984, 16}, { 1968, 15}, { 1953, 16}, { 1937, 14}, { 1923, 15}, { 1908, 15},
|
||||
{ 1893, 14}, { 1879, 14}, { 1865, 14}, { 1851, 13}, { 1838, 14}, { 1824, 13}, { 1811, 13}, { 1798, 13},
|
||||
{ 1785, 12}, { 1773, 13}, { 1760, 12}, { 1748, 12}, { 1736, 12}, { 1724, 12}, { 1712, 12}, { 1700, 11},
|
||||
{ 1689, 12}, { 1677, 11}, { 1666, 11}, { 1655, 11}, { 1644, 11}, { 1633, 10}, { 1623, 11}, { 1612, 10},
|
||||
{ 1602, 10}, { 1592, 10}, { 1582, 10}, { 1572, 10}, { 1562, 10}, { 1552, 9}, { 1543, 10}, { 1533, 9},
|
||||
{ 1524, 9}, { 1515, 9}, { 1506, 9}, { 1497, 9}, { 1488, 9}, { 1479, 9}, { 1470, 9}, { 1461, 8},
|
||||
{ 1453, 8}, { 1445, 9}, { 1436, 8}, { 1428, 8}, { 1420, 8}, { 1412, 8}, { 1404, 8}, { 1396, 8},
|
||||
{ 1388, 7}, { 1381, 8}, { 1373, 7}, { 1366, 8}, { 1358, 7}, { 1351, 7}, { 1344, 8}, { 1336, 7},
|
||||
{ 1329, 7}, { 1322, 7}, { 1315, 7}, { 1308, 6}, { 1302, 7}, { 1295, 7}, { 1288, 6}, { 1282, 7},
|
||||
{ 1275, 6}, { 1269, 7}, { 1262, 6}, { 1256, 6}, { 1250, 7}, { 1243, 6}, { 1237, 6}, { 1231, 6},
|
||||
{ 1225, 6}, { 1219, 6}, { 1213, 6}, { 1207, 6}, { 1201, 5}, { 1196, 6}, { 1190, 6}, { 1184, 5},
|
||||
{ 1179, 6}, { 1173, 5}, { 1168, 6}, { 1162, 5}, { 1157, 5}, { 1152, 6}, { 1146, 5}, { 1141, 5},
|
||||
{ 1136, 5}, { 1131, 5}, { 1126, 5}, { 1121, 5}, { 1116, 5}, { 1111, 5}, { 1106, 5}, { 1101, 5},
|
||||
{ 1096, 5}, { 1091, 5}, { 1086, 4}, { 1082, 5}, { 1077, 5}, { 1072, 4}, { 1068, 5}, { 1063, 4},
|
||||
{ 1059, 5}, { 1054, 4}, { 1050, 4}, { 1046, 5}, { 1041, 4}, { 1037, 4}, { 1033, 5}, { 1028, 4},
|
||||
{ 1024, 4}, { 1020, 4}, { 1016, 4}, { 1012, 4}, { 1008, 4}, { 1004, 4}, { 1000, 4}, { 996, 4},
|
||||
{ 992, 4}, { 988, 4}, { 984, 4}, { 980, 4}, { 976, 4}, { 972, 4}, { 968, 3}, { 965, 3}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
+296
-133
@@ -21,12 +21,12 @@
|
||||
/* The timer calculations of this module informed by the 'RepRap cartesian firmware' by Zack Smith
|
||||
and Philipp Tiefenbacher. */
|
||||
|
||||
#include "stepper.h"
|
||||
#include "Configuration.h"
|
||||
|
||||
|
||||
|
||||
#include "Marlin.h"
|
||||
#include "stepper.h"
|
||||
#include "planner.h"
|
||||
#include "pins.h"
|
||||
#include "fastio.h"
|
||||
#include "temperature.h"
|
||||
#include "ultralcd.h"
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
block_t *current_block; // A pointer to the block currently being traced
|
||||
|
||||
|
||||
|
||||
//===========================================================================
|
||||
//=============================private variables ============================
|
||||
//===========================================================================
|
||||
@@ -52,17 +51,18 @@ static long counter_x, // Counter variables for the bresenham line tracer
|
||||
counter_y,
|
||||
counter_z,
|
||||
counter_e;
|
||||
static unsigned long step_events_completed; // The number of step events executed in the current block
|
||||
volatile static unsigned long step_events_completed; // The number of step events executed in the current block
|
||||
#ifdef ADVANCE
|
||||
static long advance_rate, advance, final_advance = 0;
|
||||
static short old_advance = 0;
|
||||
static long old_advance = 0;
|
||||
#endif
|
||||
static short e_steps;
|
||||
static long e_steps[3];
|
||||
static unsigned char busy = false; // TRUE when SIG_OUTPUT_COMPARE1A is being serviced. Used to avoid retriggering that handler.
|
||||
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 char step_loops;
|
||||
static unsigned short OCR1A_nominal;
|
||||
|
||||
volatile long endstops_trigsteps[3]={0,0,0};
|
||||
volatile long endstops_stepsTotal,endstops_stepsDone;
|
||||
@@ -70,13 +70,27 @@ static volatile bool endstop_x_hit=false;
|
||||
static volatile bool endstop_y_hit=false;
|
||||
static volatile bool endstop_z_hit=false;
|
||||
|
||||
static bool old_x_min_endstop=false;
|
||||
static bool old_x_max_endstop=false;
|
||||
static bool old_y_min_endstop=false;
|
||||
static bool old_y_max_endstop=false;
|
||||
static bool old_z_min_endstop=false;
|
||||
static bool old_z_max_endstop=false;
|
||||
|
||||
static bool check_endstops = true;
|
||||
|
||||
volatile long count_position[NUM_AXIS] = { 0, 0, 0, 0};
|
||||
volatile char count_direction[NUM_AXIS] = { 1, 1, 1, 1};
|
||||
|
||||
//===========================================================================
|
||||
//=============================functions ============================
|
||||
//===========================================================================
|
||||
|
||||
|
||||
#ifdef ENDSTOPS_ONLY_FOR_HOMING
|
||||
#define CHECK_ENDSTOPS if(check_endstops)
|
||||
#else
|
||||
#define CHECK_ENDSTOPS
|
||||
#endif
|
||||
|
||||
// intRes = intIn1 * intIn2 >> 16
|
||||
// uses:
|
||||
@@ -153,6 +167,7 @@ asm volatile ( \
|
||||
#define ENABLE_STEPPER_DRIVER_INTERRUPT() TIMSK1 |= (1<<OCIE1A)
|
||||
#define DISABLE_STEPPER_DRIVER_INTERRUPT() TIMSK1 &= ~(1<<OCIE1A)
|
||||
|
||||
|
||||
void checkHitEndstops()
|
||||
{
|
||||
if( endstop_x_hit || endstop_y_hit || endstop_z_hit) {
|
||||
@@ -181,6 +196,11 @@ void endstops_hit_on_purpose()
|
||||
endstop_z_hit=false;
|
||||
}
|
||||
|
||||
void enable_endstops(bool check)
|
||||
{
|
||||
check_endstops = check;
|
||||
}
|
||||
|
||||
// __________________________
|
||||
// /| |\ _________________ ^
|
||||
// / | | \ /| |\ |
|
||||
@@ -203,7 +223,7 @@ void st_wake_up() {
|
||||
ENABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
}
|
||||
|
||||
inline unsigned short calc_timer(unsigned short step_rate) {
|
||||
FORCE_INLINE unsigned short calc_timer(unsigned short step_rate) {
|
||||
unsigned short timer;
|
||||
if(step_rate > MAX_STEP_FREQUENCY) step_rate = MAX_STEP_FREQUENCY;
|
||||
|
||||
@@ -234,38 +254,45 @@ inline unsigned short calc_timer(unsigned short step_rate) {
|
||||
timer = (unsigned short)pgm_read_word_near(table_address);
|
||||
timer -= (((unsigned short)pgm_read_word_near(table_address+2) * (unsigned char)(step_rate & 0x0007))>>3);
|
||||
}
|
||||
if(timer < 100) { timer = 100; Serial.print("Steprate to high : "); Serial.println(step_rate); }//(20kHz this should never happen)
|
||||
if(timer < 100) { timer = 100; MYSERIAL.print("Steprate to high : "); MYSERIAL.println(step_rate); }//(20kHz this should never happen)
|
||||
return timer;
|
||||
}
|
||||
|
||||
// Initializes the trapezoid generator from the current block. Called whenever a new
|
||||
// block begins.
|
||||
inline void trapezoid_generator_reset() {
|
||||
FORCE_INLINE void trapezoid_generator_reset() {
|
||||
#ifdef ADVANCE
|
||||
advance = current_block->initial_advance;
|
||||
final_advance = current_block->final_advance;
|
||||
// Do E steps + advance steps
|
||||
e_steps[current_block->active_extruder] += ((advance >>8) - old_advance);
|
||||
old_advance = advance >>8;
|
||||
#endif
|
||||
deceleration_time = 0;
|
||||
// step_rate to timer interval
|
||||
acc_step_rate = current_block->initial_rate;
|
||||
acceleration_time = calc_timer(acc_step_rate);
|
||||
OCR1A = acceleration_time;
|
||||
OCR1A_nominal = calc_timer(current_block->nominal_rate);
|
||||
|
||||
|
||||
|
||||
// SERIAL_ECHO_START;
|
||||
// SERIAL_ECHOPGM("advance :");
|
||||
// SERIAL_ECHO(current_block->advance/256.0);
|
||||
// SERIAL_ECHOPGM("advance rate :");
|
||||
// SERIAL_ECHO(current_block->advance_rate/256.0);
|
||||
// SERIAL_ECHOPGM("initial advance :");
|
||||
// SERIAL_ECHO(current_block->initial_advance/256.0);
|
||||
// SERIAL_ECHOPGM("final advance :");
|
||||
// SERIAL_ECHOLN(current_block->final_advance/256.0);
|
||||
|
||||
}
|
||||
|
||||
// "The Stepper Driver Interrupt" - This timer interrupt is the workhorse.
|
||||
// It pops blocks from the block_buffer and executes them by pulsing the stepper pins appropriately.
|
||||
ISR(TIMER1_COMPA_vect)
|
||||
{
|
||||
if(busy){
|
||||
SERIAL_ERROR_START
|
||||
SERIAL_ERROR(*(unsigned short *)OCR1A);
|
||||
SERIAL_ERRORLNPGM(" ISR overtaking itself.");
|
||||
return;
|
||||
} // The busy-flag is used to avoid reentering this interrupt
|
||||
|
||||
busy = true;
|
||||
sei(); // Re enable interrupts (normally disabled while inside an interrupt handler)
|
||||
|
||||
{
|
||||
// If there is no current block, attempt to pop one from the buffer
|
||||
if (current_block == NULL) {
|
||||
// Anything in the buffer?
|
||||
@@ -277,12 +304,20 @@ ISR(TIMER1_COMPA_vect)
|
||||
counter_z = counter_x;
|
||||
counter_e = counter_x;
|
||||
step_events_completed = 0;
|
||||
// #ifdef ADVANCE
|
||||
e_steps = 0;
|
||||
#ifdef Z_LATE_ENABLE
|
||||
if(current_block->steps_z > 0) {
|
||||
enable_z();
|
||||
OCR1A = 2000; //1ms wait
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
// #ifdef ADVANCE
|
||||
// e_steps[current_block->active_extruder] = 0;
|
||||
// #endif
|
||||
}
|
||||
else {
|
||||
// DISABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
OCR1A=2000; // 1kHz.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,108 +329,133 @@ ISR(TIMER1_COMPA_vect)
|
||||
if ((out_bits & (1<<X_AXIS)) != 0) { // -direction
|
||||
WRITE(X_DIR_PIN, INVERT_X_DIR);
|
||||
count_direction[X_AXIS]=-1;
|
||||
#if X_MIN_PIN > -1
|
||||
if((READ(X_MIN_PIN) != ENDSTOPS_INVERTING) && (current_block->steps_x > 0)) {
|
||||
endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
|
||||
endstop_x_hit=true;
|
||||
step_events_completed = current_block->step_event_count;
|
||||
}
|
||||
#endif
|
||||
CHECK_ENDSTOPS
|
||||
{
|
||||
#if X_MIN_PIN > -1
|
||||
bool x_min_endstop=(READ(X_MIN_PIN) != X_ENDSTOPS_INVERTING);
|
||||
if(x_min_endstop && old_x_min_endstop && (current_block->steps_x > 0)) {
|
||||
endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
|
||||
endstop_x_hit=true;
|
||||
step_events_completed = current_block->step_event_count;
|
||||
}
|
||||
old_x_min_endstop = x_min_endstop;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else { // +direction
|
||||
WRITE(X_DIR_PIN,!INVERT_X_DIR);
|
||||
count_direction[X_AXIS]=1;
|
||||
#if X_MAX_PIN > -1
|
||||
if((READ(X_MAX_PIN) != ENDSTOPS_INVERTING) && (current_block->steps_x > 0)){
|
||||
endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
|
||||
endstop_x_hit=true;
|
||||
step_events_completed = current_block->step_event_count;
|
||||
}
|
||||
#endif
|
||||
CHECK_ENDSTOPS
|
||||
{
|
||||
#if X_MAX_PIN > -1
|
||||
bool x_max_endstop=(READ(X_MAX_PIN) != X_ENDSTOPS_INVERTING);
|
||||
if(x_max_endstop && old_x_max_endstop && (current_block->steps_x > 0)){
|
||||
endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
|
||||
endstop_x_hit=true;
|
||||
step_events_completed = current_block->step_event_count;
|
||||
}
|
||||
old_x_max_endstop = x_max_endstop;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if ((out_bits & (1<<Y_AXIS)) != 0) { // -direction
|
||||
WRITE(Y_DIR_PIN,INVERT_Y_DIR);
|
||||
count_direction[Y_AXIS]=-1;
|
||||
#if Y_MIN_PIN > -1
|
||||
if((READ(Y_MIN_PIN) != ENDSTOPS_INVERTING) && (current_block->steps_y > 0)) {
|
||||
endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
|
||||
endstop_y_hit=true;
|
||||
step_events_completed = current_block->step_event_count;
|
||||
}
|
||||
#endif
|
||||
CHECK_ENDSTOPS
|
||||
{
|
||||
#if Y_MIN_PIN > -1
|
||||
bool y_min_endstop=(READ(Y_MIN_PIN) != Y_ENDSTOPS_INVERTING);
|
||||
if(y_min_endstop && old_y_min_endstop && (current_block->steps_y > 0)) {
|
||||
endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
|
||||
endstop_y_hit=true;
|
||||
step_events_completed = current_block->step_event_count;
|
||||
}
|
||||
old_y_min_endstop = y_min_endstop;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else { // +direction
|
||||
WRITE(Y_DIR_PIN,!INVERT_Y_DIR);
|
||||
count_direction[Y_AXIS]=1;
|
||||
#if Y_MAX_PIN > -1
|
||||
if((READ(Y_MAX_PIN) != ENDSTOPS_INVERTING) && (current_block->steps_y > 0)){
|
||||
endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
|
||||
endstop_y_hit=true;
|
||||
step_events_completed = current_block->step_event_count;
|
||||
}
|
||||
#endif
|
||||
CHECK_ENDSTOPS
|
||||
{
|
||||
#if Y_MAX_PIN > -1
|
||||
bool y_max_endstop=(READ(Y_MAX_PIN) != Y_ENDSTOPS_INVERTING);
|
||||
if(y_max_endstop && old_y_max_endstop && (current_block->steps_y > 0)){
|
||||
endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
|
||||
endstop_y_hit=true;
|
||||
step_events_completed = current_block->step_event_count;
|
||||
}
|
||||
old_y_max_endstop = y_max_endstop;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if ((out_bits & (1<<Z_AXIS)) != 0) { // -direction
|
||||
WRITE(Z_DIR_PIN,INVERT_Z_DIR);
|
||||
count_direction[Z_AXIS]=-1;
|
||||
#if Z_MIN_PIN > -1
|
||||
if((READ(Z_MIN_PIN) != ENDSTOPS_INVERTING) && (current_block->steps_z > 0)) {
|
||||
endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
|
||||
endstop_z_hit=true;
|
||||
step_events_completed = current_block->step_event_count;
|
||||
}
|
||||
#endif
|
||||
CHECK_ENDSTOPS
|
||||
{
|
||||
#if Z_MIN_PIN > -1
|
||||
bool z_min_endstop=(READ(Z_MIN_PIN) != Z_ENDSTOPS_INVERTING);
|
||||
if(z_min_endstop && old_z_min_endstop && (current_block->steps_z > 0)) {
|
||||
endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
|
||||
endstop_z_hit=true;
|
||||
step_events_completed = current_block->step_event_count;
|
||||
}
|
||||
old_z_min_endstop = z_min_endstop;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else { // +direction
|
||||
WRITE(Z_DIR_PIN,!INVERT_Z_DIR);
|
||||
count_direction[Z_AXIS]=1;
|
||||
#if Z_MAX_PIN > -1
|
||||
if((READ(Z_MAX_PIN) != ENDSTOPS_INVERTING) && (current_block->steps_z > 0)){
|
||||
endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
|
||||
endstop_z_hit=true;
|
||||
step_events_completed = current_block->step_event_count;
|
||||
}
|
||||
#endif
|
||||
count_direction[Z_AXIS]=1;
|
||||
CHECK_ENDSTOPS
|
||||
{
|
||||
#if Z_MAX_PIN > -1
|
||||
bool z_max_endstop=(READ(Z_MAX_PIN) != Z_ENDSTOPS_INVERTING);
|
||||
if(z_max_endstop && old_z_max_endstop && (current_block->steps_z > 0)) {
|
||||
endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
|
||||
endstop_z_hit=true;
|
||||
step_events_completed = current_block->step_event_count;
|
||||
}
|
||||
old_z_max_endstop = z_max_endstop;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef ADVANCE
|
||||
if ((out_bits & (1<<E_AXIS)) != 0) { // -direction
|
||||
WRITE(E_DIR_PIN,INVERT_E_DIR);
|
||||
REV_E_DIR();
|
||||
count_direction[E_AXIS]=-1;
|
||||
}
|
||||
else { // +direction
|
||||
WRITE(E_DIR_PIN,!INVERT_E_DIR);
|
||||
NORM_E_DIR();
|
||||
count_direction[E_AXIS]=-1;
|
||||
}
|
||||
#endif //!ADVANCE
|
||||
|
||||
|
||||
|
||||
for(int8_t i=0; i < step_loops; i++) { // Take multiple steps per interrupt (For high speed moves)
|
||||
/*
|
||||
#if MOTHERBOARD != 8 // !teensylu
|
||||
MSerial.checkRx(); // Check for serial chars.
|
||||
#endif
|
||||
|
||||
#ifdef ADVANCE
|
||||
counter_e += current_block->steps_e;
|
||||
if (counter_e > 0) {
|
||||
counter_e -= current_block->step_event_count;
|
||||
if ((out_bits & (1<<E_AXIS)) != 0) { // - direction
|
||||
CRITICAL_SECTION_START;
|
||||
e_steps--;
|
||||
CRITICAL_SECTION_END;
|
||||
e_steps[current_block->active_extruder]--;
|
||||
}
|
||||
else {
|
||||
CRITICAL_SECTION_START;
|
||||
e_steps++;
|
||||
CRITICAL_SECTION_END;
|
||||
e_steps[current_block->active_extruder]++;
|
||||
}
|
||||
}
|
||||
*/
|
||||
/*
|
||||
// Do E steps + advance steps
|
||||
CRITICAL_SECTION_START;
|
||||
e_steps += ((advance >> 16) - old_advance);
|
||||
CRITICAL_SECTION_END;
|
||||
old_advance = advance >> 16;
|
||||
*/
|
||||
|
||||
#endif //ADVANCE
|
||||
|
||||
counter_x += current_block->steps_x;
|
||||
if (counter_x > 0) {
|
||||
WRITE(X_STEP_PIN, HIGH);
|
||||
@@ -423,9 +483,9 @@ ISR(TIMER1_COMPA_vect)
|
||||
#ifndef ADVANCE
|
||||
counter_e += current_block->steps_e;
|
||||
if (counter_e > 0) {
|
||||
WRITE(E_STEP_PIN, HIGH);
|
||||
WRITE_E_STEP(HIGH);
|
||||
counter_e -= current_block->step_event_count;
|
||||
WRITE(E_STEP_PIN, LOW);
|
||||
WRITE_E_STEP(LOW);
|
||||
count_position[E_AXIS]+=count_direction[E_AXIS];
|
||||
}
|
||||
#endif //!ADVANCE
|
||||
@@ -435,7 +495,8 @@ ISR(TIMER1_COMPA_vect)
|
||||
// Calculare new timer value
|
||||
unsigned short timer;
|
||||
unsigned short step_rate;
|
||||
if (step_events_completed <= current_block->accelerate_until) {
|
||||
if (step_events_completed <= (unsigned long int)current_block->accelerate_until) {
|
||||
|
||||
MultiU24X24toH16(acc_step_rate, acceleration_time, current_block->acceleration_rate);
|
||||
acc_step_rate += current_block->initial_rate;
|
||||
|
||||
@@ -445,13 +506,20 @@ ISR(TIMER1_COMPA_vect)
|
||||
|
||||
// step_rate to timer interval
|
||||
timer = calc_timer(acc_step_rate);
|
||||
#ifdef ADVANCE
|
||||
advance += advance_rate;
|
||||
#endif
|
||||
acceleration_time += timer;
|
||||
OCR1A = timer;
|
||||
acceleration_time += timer;
|
||||
#ifdef ADVANCE
|
||||
for(int8_t i=0; i < step_loops; i++) {
|
||||
advance += advance_rate;
|
||||
}
|
||||
//if(advance > current_block->advance) advance = current_block->advance;
|
||||
// Do E steps + advance steps
|
||||
e_steps[current_block->active_extruder] += ((advance >>8) - old_advance);
|
||||
old_advance = advance >>8;
|
||||
|
||||
#endif
|
||||
}
|
||||
else if (step_events_completed > current_block->decelerate_after) {
|
||||
else if (step_events_completed > (unsigned long int)current_block->decelerate_after) {
|
||||
MultiU24X24toH16(step_rate, deceleration_time, current_block->acceleration_rate);
|
||||
|
||||
if(step_rate > acc_step_rate) { // Check step_rate stays positive
|
||||
@@ -467,27 +535,28 @@ ISR(TIMER1_COMPA_vect)
|
||||
|
||||
// step_rate to timer interval
|
||||
timer = calc_timer(step_rate);
|
||||
#ifdef ADVANCE
|
||||
advance -= advance_rate;
|
||||
if(advance < final_advance)
|
||||
advance = final_advance;
|
||||
#endif //ADVANCE
|
||||
deceleration_time += timer;
|
||||
OCR1A = timer;
|
||||
deceleration_time += timer;
|
||||
#ifdef ADVANCE
|
||||
for(int8_t i=0; i < step_loops; i++) {
|
||||
advance -= advance_rate;
|
||||
}
|
||||
if(advance < final_advance) advance = final_advance;
|
||||
// Do E steps + advance steps
|
||||
e_steps[current_block->active_extruder] += ((advance >>8) - old_advance);
|
||||
old_advance = advance >>8;
|
||||
#endif //ADVANCE
|
||||
}
|
||||
else {
|
||||
timer = calc_timer(current_block->nominal_rate);
|
||||
OCR1A = timer;
|
||||
OCR1A = OCR1A_nominal;
|
||||
}
|
||||
|
||||
|
||||
// If current block is finished, reset pointer
|
||||
if (step_events_completed >= current_block->step_event_count) {
|
||||
current_block = NULL;
|
||||
plan_discard_current_block();
|
||||
}
|
||||
}
|
||||
cli(); // disable interrupts
|
||||
busy=false;
|
||||
}
|
||||
|
||||
#ifdef ADVANCE
|
||||
@@ -496,28 +565,60 @@ ISR(TIMER1_COMPA_vect)
|
||||
// Timer 0 is shared with millies
|
||||
ISR(TIMER0_COMPA_vect)
|
||||
{
|
||||
// Critical section needed because Timer 1 interrupt has higher priority.
|
||||
// The pin set functions are placed on trategic position to comply with the stepper driver timing.
|
||||
WRITE(E_STEP_PIN, LOW);
|
||||
// Set E direction (Depends on E direction + advance)
|
||||
if (e_steps < 0) {
|
||||
WRITE(E_DIR_PIN,INVERT_E_DIR);
|
||||
e_steps++;
|
||||
WRITE(E_STEP_PIN, HIGH);
|
||||
}
|
||||
if (e_steps > 0) {
|
||||
WRITE(E_DIR_PIN,!INVERT_E_DIR);
|
||||
e_steps--;
|
||||
WRITE(E_STEP_PIN, HIGH);
|
||||
}
|
||||
old_OCR0A += 25; // 10kHz interrupt
|
||||
old_OCR0A += 52; // ~10kHz interrupt (250000 / 26 = 9615kHz)
|
||||
OCR0A = old_OCR0A;
|
||||
// Set E direction (Depends on E direction + advance)
|
||||
for(unsigned char i=0; i<4;i++) {
|
||||
if (e_steps[0] != 0) {
|
||||
WRITE(E0_STEP_PIN, LOW);
|
||||
if (e_steps[0] < 0) {
|
||||
WRITE(E0_DIR_PIN, INVERT_E0_DIR);
|
||||
e_steps[0]++;
|
||||
WRITE(E0_STEP_PIN, HIGH);
|
||||
}
|
||||
else if (e_steps[0] > 0) {
|
||||
WRITE(E0_DIR_PIN, !INVERT_E0_DIR);
|
||||
e_steps[0]--;
|
||||
WRITE(E0_STEP_PIN, HIGH);
|
||||
}
|
||||
}
|
||||
#if EXTRUDERS > 1
|
||||
if (e_steps[1] != 0) {
|
||||
WRITE(E1_STEP_PIN, LOW);
|
||||
if (e_steps[1] < 0) {
|
||||
WRITE(E1_DIR_PIN, INVERT_E1_DIR);
|
||||
e_steps[1]++;
|
||||
WRITE(E1_STEP_PIN, HIGH);
|
||||
}
|
||||
else if (e_steps[1] > 0) {
|
||||
WRITE(E1_DIR_PIN, !INVERT_E1_DIR);
|
||||
e_steps[1]--;
|
||||
WRITE(E1_STEP_PIN, HIGH);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if EXTRUDERS > 2
|
||||
if (e_steps[2] != 0) {
|
||||
WRITE(E2_STEP_PIN, LOW);
|
||||
if (e_steps[2] < 0) {
|
||||
WRITE(E2_DIR_PIN, INVERT_E2_DIR);
|
||||
e_steps[2]++;
|
||||
WRITE(E2_STEP_PIN, HIGH);
|
||||
}
|
||||
else if (e_steps[2] > 0) {
|
||||
WRITE(E2_DIR_PIN, !INVERT_E2_DIR);
|
||||
e_steps[2]--;
|
||||
WRITE(E2_STEP_PIN, HIGH);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif // ADVANCE
|
||||
|
||||
void st_init()
|
||||
{
|
||||
//Initialize Dir Pins
|
||||
//Initialize Dir Pins
|
||||
#if X_DIR_PIN > -1
|
||||
SET_OUTPUT(X_DIR_PIN);
|
||||
#endif
|
||||
@@ -527,8 +628,14 @@ void st_init()
|
||||
#if Z_DIR_PIN > -1
|
||||
SET_OUTPUT(Z_DIR_PIN);
|
||||
#endif
|
||||
#if E_DIR_PIN > -1
|
||||
SET_OUTPUT(E_DIR_PIN);
|
||||
#if E0_DIR_PIN > -1
|
||||
SET_OUTPUT(E0_DIR_PIN);
|
||||
#endif
|
||||
#if defined(E1_DIR_PIN) && (E1_DIR_PIN > -1)
|
||||
SET_OUTPUT(E1_DIR_PIN);
|
||||
#endif
|
||||
#if defined(E2_DIR_PIN) && (E2_DIR_PIN > -1)
|
||||
SET_OUTPUT(E2_DIR_PIN);
|
||||
#endif
|
||||
|
||||
//Initialize Enable Pins - steppers default to disabled.
|
||||
@@ -545,9 +652,17 @@ void st_init()
|
||||
SET_OUTPUT(Z_ENABLE_PIN);
|
||||
if(!Z_ENABLE_ON) WRITE(Z_ENABLE_PIN,HIGH);
|
||||
#endif
|
||||
#if (E_ENABLE_PIN > -1)
|
||||
SET_OUTPUT(E_ENABLE_PIN);
|
||||
if(!E_ENABLE_ON) WRITE(E_ENABLE_PIN,HIGH);
|
||||
#if (E0_ENABLE_PIN > -1)
|
||||
SET_OUTPUT(E0_ENABLE_PIN);
|
||||
if(!E_ENABLE_ON) WRITE(E0_ENABLE_PIN,HIGH);
|
||||
#endif
|
||||
#if defined(E1_ENABLE_PIN) && (E1_ENABLE_PIN > -1)
|
||||
SET_OUTPUT(E1_ENABLE_PIN);
|
||||
if(!E_ENABLE_ON) WRITE(E1_ENABLE_PIN,HIGH);
|
||||
#endif
|
||||
#if defined(E2_ENABLE_PIN) && (E2_ENABLE_PIN > -1)
|
||||
SET_OUTPUT(E2_ENABLE_PIN);
|
||||
if(!E_ENABLE_ON) WRITE(E2_ENABLE_PIN,HIGH);
|
||||
#endif
|
||||
|
||||
//endstops and pullups
|
||||
@@ -608,8 +723,14 @@ void st_init()
|
||||
#if (Z_STEP_PIN > -1)
|
||||
SET_OUTPUT(Z_STEP_PIN);
|
||||
#endif
|
||||
#if (E_STEP_PIN > -1)
|
||||
SET_OUTPUT(E_STEP_PIN);
|
||||
#if (E0_STEP_PIN > -1)
|
||||
SET_OUTPUT(E0_STEP_PIN);
|
||||
#endif
|
||||
#if defined(E1_STEP_PIN) && (E1_STEP_PIN > -1)
|
||||
SET_OUTPUT(E1_STEP_PIN);
|
||||
#endif
|
||||
#if defined(E2_STEP_PIN) && (E2_STEP_PIN > -1)
|
||||
SET_OUTPUT(E2_STEP_PIN);
|
||||
#endif
|
||||
|
||||
// waveform generation = 0100 = CTC
|
||||
@@ -628,20 +749,34 @@ void st_init()
|
||||
ENABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
|
||||
#ifdef ADVANCE
|
||||
e_steps = 0;
|
||||
#if defined(TCCR0A) && defined(WGM01)
|
||||
TCCR0A &= ~(1<<WGM01);
|
||||
TCCR0A &= ~(1<<WGM00);
|
||||
#endif
|
||||
e_steps[0] = 0;
|
||||
e_steps[1] = 0;
|
||||
e_steps[2] = 0;
|
||||
TIMSK0 |= (1<<OCIE0A);
|
||||
#endif //ADVANCE
|
||||
|
||||
#ifdef ENDSTOPS_ONLY_FOR_HOMING
|
||||
enable_endstops(false);
|
||||
#else
|
||||
enable_endstops(true);
|
||||
#endif
|
||||
|
||||
sei();
|
||||
}
|
||||
|
||||
|
||||
// Block until all buffered steps are executed
|
||||
void st_synchronize()
|
||||
{
|
||||
while(plan_get_current_block()) {
|
||||
while( blocks_queued()) {
|
||||
manage_heater();
|
||||
manage_inactivity(1);
|
||||
LCD_STATUS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void st_set_position(const long &x, const long &y, const long &z, const long &e)
|
||||
@@ -654,7 +789,14 @@ void st_set_position(const long &x, const long &y, const long &z, const long &e)
|
||||
CRITICAL_SECTION_END;
|
||||
}
|
||||
|
||||
long st_get_position(char axis)
|
||||
void st_set_e_position(const long &e)
|
||||
{
|
||||
CRITICAL_SECTION_START;
|
||||
count_position[E_AXIS] = e;
|
||||
CRITICAL_SECTION_END;
|
||||
}
|
||||
|
||||
long st_get_position(uint8_t axis)
|
||||
{
|
||||
long count_pos;
|
||||
CRITICAL_SECTION_START;
|
||||
@@ -662,3 +804,24 @@ long st_get_position(char axis)
|
||||
CRITICAL_SECTION_END;
|
||||
return count_pos;
|
||||
}
|
||||
|
||||
void finishAndDisableSteppers()
|
||||
{
|
||||
st_synchronize();
|
||||
LCD_MESSAGEPGM("Released.");
|
||||
disable_x();
|
||||
disable_y();
|
||||
disable_z();
|
||||
disable_e0();
|
||||
disable_e1();
|
||||
disable_e2();
|
||||
}
|
||||
|
||||
void quickStop()
|
||||
{
|
||||
DISABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
while(blocks_queued())
|
||||
plan_discard_current_block();
|
||||
ENABLE_STEPPER_DRIVER_INTERRUPT();
|
||||
}
|
||||
|
||||
|
||||
+23
-3
@@ -23,6 +23,21 @@
|
||||
|
||||
#include "planner.h"
|
||||
|
||||
#if EXTRUDERS > 2
|
||||
#define WRITE_E_STEP(v) { if(current_block->active_extruder == 2) { WRITE(E2_STEP_PIN, v); } else { if(current_block->active_extruder == 1) { WRITE(E1_STEP_PIN, v); } else { WRITE(E0_STEP_PIN, v); }}}
|
||||
#define NORM_E_DIR() { if(current_block->active_extruder == 2) { WRITE(!E2_DIR_PIN, INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { WRITE(!E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); }}}
|
||||
#define REV_E_DIR() { if(current_block->active_extruder == 2) { WRITE(E2_DIR_PIN, INVERT_E2_DIR); } else { if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, INVERT_E0_DIR); }}}
|
||||
#elif EXTRUDERS > 1
|
||||
#define WRITE_E_STEP(v) { if(current_block->active_extruder == 1) { WRITE(E1_STEP_PIN, v); } else { WRITE(E0_STEP_PIN, v); }}
|
||||
#define NORM_E_DIR() { if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); }}
|
||||
#define REV_E_DIR() { if(current_block->active_extruder == 1) { WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, INVERT_E0_DIR); }}
|
||||
#else
|
||||
#define WRITE_E_STEP(v) WRITE(E0_STEP_PIN, v)
|
||||
#define NORM_E_DIR() WRITE(E0_DIR_PIN, !INVERT_E0_DIR)
|
||||
#define REV_E_DIR() WRITE(E0_DIR_PIN, INVERT_E0_DIR)
|
||||
#endif
|
||||
|
||||
|
||||
// Initialize and start the stepper motor subsystem
|
||||
void st_init();
|
||||
|
||||
@@ -31,9 +46,10 @@ void st_synchronize();
|
||||
|
||||
// Set current position in steps
|
||||
void st_set_position(const long &x, const long &y, const long &z, const long &e);
|
||||
void st_set_e_position(const long &e);
|
||||
|
||||
// Get current position in steps
|
||||
long st_get_position(char axis);
|
||||
long st_get_position(uint8_t axis);
|
||||
|
||||
// The stepper subsystem goes to sleep when it runs out of things to execute. Call this
|
||||
// to notify the subsystem that it is time to go to work.
|
||||
@@ -43,9 +59,13 @@ void st_wake_up();
|
||||
void checkHitEndstops(); //call from somwhere to create an serial error message with the locations the endstops where hit, in case they were triggered
|
||||
void endstops_hit_on_purpose(); //avoid creation of the message, i.e. after homeing and before a routine call of checkHitEndstops();
|
||||
|
||||
void enable_endstops(bool check); // Enable/disable endstop checking
|
||||
|
||||
void checkStepperErrors(); //Print errors detected by the stepper
|
||||
|
||||
void finishAndDisableSteppers();
|
||||
|
||||
extern block_t *current_block; // A pointer to the block currently being traced
|
||||
|
||||
|
||||
#endif
|
||||
void quickStop();
|
||||
#endif
|
||||
|
||||
+485
-237
File diff suppressed because it is too large
Load Diff
+105
-36
@@ -22,7 +22,7 @@
|
||||
#define temperature_h
|
||||
|
||||
#include "Marlin.h"
|
||||
#include "fastio.h"
|
||||
#include "planner.h"
|
||||
#ifdef PID_ADD_EXTRUSION_RATE
|
||||
#include "stepper.h"
|
||||
#endif
|
||||
@@ -31,63 +31,132 @@
|
||||
void tp_init(); //initialise the heating
|
||||
void manage_heater(); //it is critical that this is called periodically.
|
||||
|
||||
|
||||
enum TempSensor {TEMPSENSOR_HOTEND_0=0,TEMPSENSOR_BED=1, TEMPSENSOR_HOTEND_1=2};
|
||||
|
||||
//low leven conversion routines
|
||||
// do not use this routines and variables outsie of temperature.cpp
|
||||
int temp2analog(int celsius);
|
||||
int temp2analog(int celsius, uint8_t e);
|
||||
int temp2analogBed(int celsius);
|
||||
float analog2temp(int raw);
|
||||
float analog2temp(int raw, uint8_t e);
|
||||
float analog2tempBed(int raw);
|
||||
extern int target_raw[3];
|
||||
extern int current_raw[3];
|
||||
extern int target_raw[EXTRUDERS];
|
||||
extern int heatingtarget_raw[EXTRUDERS];
|
||||
extern int current_raw[EXTRUDERS];
|
||||
extern int target_raw_bed;
|
||||
extern int current_raw_bed;
|
||||
#ifdef BED_LIMIT_SWITCHING
|
||||
extern int target_bed_low_temp ;
|
||||
extern int target_bed_high_temp ;
|
||||
#endif
|
||||
extern float Kp,Ki,Kd,Kc;
|
||||
|
||||
#ifdef PIDTEMP
|
||||
extern float pid_setpoint ;
|
||||
extern float pid_setpoint[EXTRUDERS];
|
||||
#endif
|
||||
|
||||
#ifdef WATCHPERIOD
|
||||
extern int watch_raw[3] ;
|
||||
extern unsigned long watchmillis;
|
||||
#endif
|
||||
|
||||
// #ifdef WATCHPERIOD
|
||||
extern int watch_raw[EXTRUDERS] ;
|
||||
// extern unsigned long watchmillis;
|
||||
// #endif
|
||||
|
||||
|
||||
//high level conversion routines, for use outside of temperature.cpp
|
||||
//inline so that there is no performance decrease.
|
||||
//deg=degreeCelsius
|
||||
|
||||
inline float degHotend0(){ return analog2temp(current_raw[TEMPSENSOR_HOTEND_0]);};
|
||||
inline float degHotend1(){ return analog2temp(current_raw[TEMPSENSOR_HOTEND_1]);};
|
||||
inline float degBed() { return analog2tempBed(current_raw[TEMPSENSOR_BED]);};
|
||||
|
||||
inline float degTargetHotend0() { return analog2temp(target_raw[TEMPSENSOR_HOTEND_0]);};
|
||||
inline float degTargetHotend1() { return analog2temp(target_raw[TEMPSENSOR_HOTEND_1]);};
|
||||
inline float degTargetBed() { return analog2tempBed(target_raw[TEMPSENSOR_BED]);};
|
||||
|
||||
inline void setTargetHotend0(const float &celsius)
|
||||
{
|
||||
target_raw[TEMPSENSOR_HOTEND_0]=temp2analog(celsius);
|
||||
#ifdef PIDTEMP
|
||||
pid_setpoint = celsius;
|
||||
#endif //PIDTEMP
|
||||
FORCE_INLINE float degHotend(uint8_t extruder) {
|
||||
return analog2temp(current_raw[extruder], extruder);
|
||||
};
|
||||
inline void setTargetHotend1(const float &celsius) { target_raw[TEMPSENSOR_HOTEND_1]=temp2analog(celsius);};
|
||||
inline void setTargetBed(const float &celsius) { target_raw[TEMPSENSOR_BED ]=temp2analogBed(celsius);};
|
||||
|
||||
inline bool isHeatingHotend0() {return target_raw[TEMPSENSOR_HOTEND_0] > current_raw[TEMPSENSOR_HOTEND_0];};
|
||||
inline bool isHeatingHotend1() {return target_raw[TEMPSENSOR_HOTEND_1] > current_raw[TEMPSENSOR_HOTEND_1];};
|
||||
inline bool isHeatingBed() {return target_raw[TEMPSENSOR_BED] > current_raw[TEMPSENSOR_BED];};
|
||||
FORCE_INLINE float degBed() {
|
||||
return analog2tempBed(current_raw_bed);
|
||||
};
|
||||
|
||||
inline bool isCoolingHotend0() {return target_raw[TEMPSENSOR_HOTEND_0] < current_raw[TEMPSENSOR_HOTEND_0];};
|
||||
inline bool isCoolingHotend1() {return target_raw[TEMPSENSOR_HOTEND_1] < current_raw[TEMPSENSOR_HOTEND_1];};
|
||||
inline bool isCoolingBed() {return target_raw[TEMPSENSOR_BED] < current_raw[TEMPSENSOR_BED];};
|
||||
FORCE_INLINE float degTargetHotend(uint8_t extruder) {
|
||||
return analog2temp(target_raw[extruder], extruder);
|
||||
};
|
||||
|
||||
FORCE_INLINE float degTargetBed() {
|
||||
return analog2tempBed(target_raw_bed);
|
||||
};
|
||||
|
||||
FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t extruder) {
|
||||
target_raw[extruder] = temp2analog(celsius, extruder);
|
||||
#ifdef PIDTEMP
|
||||
pid_setpoint[extruder] = celsius;
|
||||
#endif //PIDTEMP
|
||||
};
|
||||
|
||||
FORCE_INLINE void setTargetBed(const float &celsius) {
|
||||
|
||||
target_raw_bed = temp2analogBed(celsius);
|
||||
#ifdef BED_LIMIT_SWITCHING
|
||||
if(celsius>BED_HYSTERESIS)
|
||||
{
|
||||
target_bed_low_temp= temp2analogBed(celsius-BED_HYSTERESIS);
|
||||
target_bed_high_temp= temp2analogBed(celsius+BED_HYSTERESIS);
|
||||
}
|
||||
else
|
||||
{
|
||||
target_bed_low_temp=0;
|
||||
target_bed_high_temp=0;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
FORCE_INLINE bool isHeatingHotend(uint8_t extruder){
|
||||
return target_raw[extruder] > current_raw[extruder];
|
||||
};
|
||||
|
||||
FORCE_INLINE bool isHeatingBed() {
|
||||
return target_raw_bed > current_raw_bed;
|
||||
};
|
||||
|
||||
FORCE_INLINE bool isCoolingHotend(uint8_t extruder) {
|
||||
return target_raw[extruder] < current_raw[extruder];
|
||||
};
|
||||
|
||||
FORCE_INLINE bool isCoolingBed() {
|
||||
return target_raw_bed < current_raw_bed;
|
||||
};
|
||||
|
||||
#define degHotend0() degHotend(0)
|
||||
#define degTargetHotend0() degTargetHotend(0)
|
||||
#define setTargetHotend0(_celsius) setTargetHotend((_celsius), 0)
|
||||
#define isHeatingHotend0() isHeatingHotend(0)
|
||||
#define isCoolingHotend0() isCoolingHotend(0)
|
||||
#if EXTRUDERS > 1
|
||||
#define degHotend1() degHotend(1)
|
||||
#define degTargetHotend1() degTargetHotend(1)
|
||||
#define setTargetHotend1(_celsius) setTargetHotend((_celsius), 1)
|
||||
#define isHeatingHotend1() isHeatingHotend(1)
|
||||
#define isCoolingHotend1() isCoolingHotend(1)
|
||||
#endif
|
||||
#if EXTRUDERS > 2
|
||||
#define degHotend2() degHotend(2)
|
||||
#define degTargetHotend2() degTargetHotend(2)
|
||||
#define setTargetHotend2(_celsius) setTargetHotend((_celsius), 2)
|
||||
#define isHeatingHotend2() isHeatingHotend(2)
|
||||
#define isCoolingHotend2() isCoolingHotend(2)
|
||||
#endif
|
||||
#if EXTRUDERS > 3
|
||||
#error Invalid number of extruders
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
int getHeaterPower(int heater);
|
||||
void disable_heater();
|
||||
void setWatch();
|
||||
void updatePID();
|
||||
|
||||
FORCE_INLINE void autotempShutdown(){
|
||||
#ifdef AUTOTEMP
|
||||
if(autotemp_enabled)
|
||||
{
|
||||
autotemp_enabled=false;
|
||||
if(degTargetHotend(ACTIVE_EXTRUDER)>autotemp_min)
|
||||
setTargetHotend(0,ACTIVE_EXTRUDER);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
+55
-94
@@ -1,14 +1,13 @@
|
||||
#ifndef THERMISTORTABLES_H_
|
||||
#define THERMISTORTABLES_H_
|
||||
|
||||
#include <avr/pgmspace.h>
|
||||
#include "Marlin.h"
|
||||
|
||||
#define OVERSAMPLENR 16
|
||||
|
||||
#if (THERMISTORHEATER_0 == 1) || (THERMISTORHEATER_1 == 1) || (THERMISTORBED == 1) //100k bed thermistor
|
||||
#if (THERMISTORHEATER_0 == 1) || (THERMISTORHEATER_1 == 1) || (THERMISTORHEATER_2 == 1) || (THERMISTORBED == 1) //100k bed thermistor
|
||||
|
||||
#define NUMTEMPS_1 61
|
||||
const short temptable_1[NUMTEMPS_1][2] PROGMEM = {
|
||||
const short temptable_1[][2] PROGMEM = {
|
||||
{ 23*OVERSAMPLENR , 300 },
|
||||
{ 25*OVERSAMPLENR , 295 },
|
||||
{ 27*OVERSAMPLENR , 290 },
|
||||
@@ -72,9 +71,8 @@ const short temptable_1[NUMTEMPS_1][2] PROGMEM = {
|
||||
{ 1008*OVERSAMPLENR , 0 } //safety
|
||||
};
|
||||
#endif
|
||||
#if (THERMISTORHEATER_0 == 2) || (THERMISTORHEATER_1 == 2) || (THERMISTORBED == 2) //200k bed thermistor
|
||||
#define NUMTEMPS_2 21
|
||||
const short temptable_2[NUMTEMPS_2][2] PROGMEM = {
|
||||
#if (THERMISTORHEATER_0 == 2) || (THERMISTORHEATER_1 == 2) || (THERMISTORHEATER_2 == 2) || (THERMISTORBED == 2) //200k bed thermistor
|
||||
const short temptable_2[][2] PROGMEM = {
|
||||
{1*OVERSAMPLENR, 848},
|
||||
{54*OVERSAMPLENR, 275},
|
||||
{107*OVERSAMPLENR, 228},
|
||||
@@ -99,9 +97,8 @@ const short temptable_2[NUMTEMPS_2][2] PROGMEM = {
|
||||
};
|
||||
|
||||
#endif
|
||||
#if (THERMISTORHEATER_0 == 3) || (THERMISTORHEATER_1 == 3) || (THERMISTORBED == 3) //mendel-parts
|
||||
#define NUMTEMPS_3 28
|
||||
const short temptable_3[NUMTEMPS_3][2] PROGMEM = {
|
||||
#if (THERMISTORHEATER_0 == 3) || (THERMISTORHEATER_1 == 3) || (THERMISTORHEATER_2 == 3) || (THERMISTORBED == 3) //mendel-parts
|
||||
const short temptable_3[][2] PROGMEM = {
|
||||
{1*OVERSAMPLENR,864},
|
||||
{21*OVERSAMPLENR,300},
|
||||
{25*OVERSAMPLENR,290},
|
||||
@@ -133,10 +130,8 @@ const short temptable_3[NUMTEMPS_3][2] PROGMEM = {
|
||||
};
|
||||
|
||||
#endif
|
||||
#if (THERMISTORHEATER_0 == 4) || (THERMISTORHEATER_1 == 4) || (THERMISTORBED == 4) //10k thermistor
|
||||
|
||||
#define NUMTEMPS_4 20
|
||||
const short temptable_4[NUMTEMPS_4][2] PROGMEM = {
|
||||
#if (THERMISTORHEATER_0 == 4) || (THERMISTORHEATER_1 == 4) || (THERMISTORHEATER_2 == 4) || (THERMISTORBED == 4) //10k thermistor
|
||||
const short temptable_4[][2] PROGMEM = {
|
||||
{1*OVERSAMPLENR, 430},
|
||||
{54*OVERSAMPLENR, 137},
|
||||
{107*OVERSAMPLENR, 107},
|
||||
@@ -160,10 +155,8 @@ const short temptable_4[NUMTEMPS_4][2] PROGMEM = {
|
||||
};
|
||||
#endif
|
||||
|
||||
#if (THERMISTORHEATER_0 == 5) || (THERMISTORHEATER_1 == 5) || (THERMISTORBED == 5) //100k ParCan thermistor (104GT-2)
|
||||
|
||||
#define NUMTEMPS_5 61
|
||||
const short temptable_5[NUMTEMPS_5][2] PROGMEM = {
|
||||
#if (THERMISTORHEATER_0 == 5) || (THERMISTORHEATER_1 == 5) || (THERMISTORHEATER_2 == 5) || (THERMISTORBED == 5) //100k ParCan thermistor (104GT-2)
|
||||
const short temptable_5[][2] PROGMEM = {
|
||||
{1*OVERSAMPLENR, 713},
|
||||
{18*OVERSAMPLENR, 316},
|
||||
{35*OVERSAMPLENR, 266},
|
||||
@@ -228,9 +221,8 @@ const short temptable_5[NUMTEMPS_5][2] PROGMEM = {
|
||||
};
|
||||
#endif
|
||||
|
||||
#if (THERMISTORHEATER_0 == 6) || (THERMISTORHEATER_1 == 6) || (THERMISTORBED == 6) // 100k Epcos thermistor
|
||||
#define NUMTEMPS_6 36
|
||||
const short temptable_6[NUMTEMPS_6][2] PROGMEM = {
|
||||
#if (THERMISTORHEATER_0 == 6) || (THERMISTORHEATER_1 == 6) || (THERMISTORHEATER_2 == 6) || (THERMISTORBED == 6) // 100k Epcos thermistor
|
||||
const short temptable_6[][2] PROGMEM = {
|
||||
{28*OVERSAMPLENR, 250},
|
||||
{31*OVERSAMPLENR, 245},
|
||||
{35*OVERSAMPLENR, 240},
|
||||
@@ -270,9 +262,8 @@ const short temptable_6[NUMTEMPS_6][2] PROGMEM = {
|
||||
};
|
||||
#endif
|
||||
|
||||
#if (THERMISTORHEATER_0 == 7) || (THERMISTORHEATER_1 == 7) || (THERMISTORBED == 7) // 100k Honeywell 135-104LAG-J01
|
||||
#define NUMTEMPS_7 54
|
||||
const short temptable_7[NUMTEMPS_7][2] PROGMEM = {
|
||||
#if (THERMISTORHEATER_0 == 7) || (THERMISTORHEATER_1 == 7) || (THERMISTORHEATER_2 == 7) || (THERMISTORBED == 7) // 100k Honeywell 135-104LAG-J01
|
||||
const short temptable_7[][2] PROGMEM = {
|
||||
{46*OVERSAMPLENR, 270},
|
||||
{50*OVERSAMPLENR, 265},
|
||||
{54*OVERSAMPLENR, 260},
|
||||
@@ -330,82 +321,52 @@ const short temptable_7[NUMTEMPS_7][2] PROGMEM = {
|
||||
};
|
||||
#endif
|
||||
|
||||
#define _TT_NAME(_N) temptable_ ## _N
|
||||
#define TT_NAME(_N) _TT_NAME(_N)
|
||||
|
||||
|
||||
#if THERMISTORHEATER_0 == 1
|
||||
#define NUMTEMPS_HEATER_0 NUMTEMPS_1
|
||||
#define heater_0_temptable temptable_1
|
||||
#elif THERMISTORHEATER_0 == 2
|
||||
#define NUMTEMPS_HEATER_0 NUMTEMPS_2
|
||||
#define heater_0_temptable temptable_2
|
||||
#elif THERMISTORHEATER_0 == 3
|
||||
#define NUMTEMPS_HEATER_0 NUMTEMPS_3
|
||||
#define heater_0_temptable temptable_3
|
||||
#elif THERMISTORHEATER_0 == 4
|
||||
#define NUMTEMPS_HEATER_0 NUMTEMPS_4
|
||||
#define heater_0_temptable temptable_4
|
||||
#elif THERMISTORHEATER_0 == 5
|
||||
#define NUMTEMPS_HEATER_0 NUMTEMPS_5
|
||||
#define heater_0_temptable temptable_5
|
||||
#elif THERMISTORHEATER_0 == 6
|
||||
#define NUMTEMPS_HEATER_0 NUMTEMPS_6
|
||||
#define heater_0_temptable temptable_6
|
||||
#elif THERMISTORHEATER_0 == 7
|
||||
#define NUMTEMPS_HEATER_0 NUMTEMPS_7
|
||||
#define heater_0_temptable temptable_7
|
||||
#elif defined HEATER_0_USES_THERMISTOR
|
||||
#error No heater 0 thermistor table specified
|
||||
#ifdef THERMISTORHEATER_0
|
||||
#define heater_0_temptable TT_NAME(THERMISTORHEATER_0)
|
||||
#define heater_0_temptable_len (sizeof(heater_0_temptable)/sizeof(*heater_0_temptable))
|
||||
#else
|
||||
#ifdef HEATER_0_USES_THERMISTOR
|
||||
#error No heater 0 thermistor table specified
|
||||
#else // HEATER_0_USES_THERMISTOR
|
||||
#define heater_0_temptable 0
|
||||
#define heater_0_temptable_len 0
|
||||
#endif // HEATER_0_USES_THERMISTOR
|
||||
#endif
|
||||
|
||||
#if THERMISTORHEATER_1 == 1
|
||||
#define NUMTEMPS_HEATER_1 NUMTEMPS_1
|
||||
#define heater_1_temptable temptable_1
|
||||
#elif THERMISTORHEATER_1 == 2
|
||||
#define NUMTEMPS_HEATER_1 NUMTEMPS_2
|
||||
#define heater_1_temptable temptable_2
|
||||
#elif THERMISTORHEATER_1 == 3
|
||||
#define NUMTEMPS_HEATER_1 NUMTEMPS_3
|
||||
#define heater_1_temptable temptable_3
|
||||
#elif THERMISTORHEATER_1 == 4
|
||||
#define NUMTEMPS_HEATER_1 NUMTEMPS_4
|
||||
#define heater_1_temptable temptable_4
|
||||
#elif THERMISTORHEATER_1 == 5
|
||||
#define NUMTEMPS_HEATER_1 NUMTEMPS_5
|
||||
#define heater_1_temptable temptable_5
|
||||
#elif THERMISTORHEATER_1 == 6
|
||||
#define NUMTEMPS_HEATER_1 NUMTEMPS_6
|
||||
#define heater_1_temptable temptable_6
|
||||
#elif THERMISTORHEATER_1 == 7
|
||||
#define NUMTEMPS_HEATER_1 NUMTEMPS_7
|
||||
#define heater_1_temptable temptable_7
|
||||
#elif defined HEATER_1_USES_THERMISTOR
|
||||
#error No heater 1 thermistor table specified
|
||||
#ifdef THERMISTORHEATER_1
|
||||
#define heater_1_temptable TT_NAME(THERMISTORHEATER_1)
|
||||
#define heater_1_temptable_len (sizeof(heater_1_temptable)/sizeof(*heater_1_temptable))
|
||||
#else
|
||||
#ifdef HEATER_1_USES_THERMISTOR
|
||||
#error No heater 1 thermistor table specified
|
||||
#else // HEATER_1_USES_THERMISTOR
|
||||
#define heater_1_temptable 0
|
||||
#define heater_1_temptable_len 0
|
||||
#endif // HEATER_1_USES_THERMISTOR
|
||||
#endif
|
||||
|
||||
#ifdef THERMISTORHEATER_2
|
||||
#define heater_2_temptable TT_NAME(THERMISTORHEATER_2)
|
||||
#define heater_2_temptable_len (sizeof(heater_2_temptable)/sizeof(*heater_2_temptable))
|
||||
#else
|
||||
#ifdef HEATER_2_USES_THERMISTOR
|
||||
#error No heater 2 thermistor table specified
|
||||
#else // HEATER_2_USES_THERMISTOR
|
||||
#define heater_2_temptable 0
|
||||
#define heater_2_temptable_len 0
|
||||
#endif // HEATER_2_USES_THERMISTOR
|
||||
#endif
|
||||
|
||||
#if THERMISTORBED == 1
|
||||
#define BNUMTEMPS NUMTEMPS_1
|
||||
#define bedtemptable temptable_1
|
||||
#elif THERMISTORBED == 2
|
||||
#define BNUMTEMPS NUMTEMPS_2
|
||||
#define bedtemptable temptable_2
|
||||
#elif THERMISTORBED == 3
|
||||
#define BNUMTEMPS NUMTEMPS_3
|
||||
#define bedtemptable temptable_3
|
||||
#elif THERMISTORBED == 4
|
||||
#define BNUMTEMPS NUMTEMPS_4
|
||||
#define bedtemptable temptable_4
|
||||
#elif THERMISTORBED == 5
|
||||
#define BNUMTEMPS NUMTEMPS_5
|
||||
#define bedtemptable temptable_5
|
||||
#elif THERMISTORBED == 6
|
||||
#define BNUMTEMPS NUMTEMPS_6
|
||||
#define bedtemptable temptable_6
|
||||
#elif THERMISTORBED == 7
|
||||
#define BNUMTEMPS NUMTEMPS_7
|
||||
#define bedtemptable temptable_7
|
||||
#elif defined BED_USES_THERMISTOR
|
||||
#error No bed thermistor table specified
|
||||
#ifdef THERMISTORBED
|
||||
#define bedtemptable TT_NAME(THERMISTORBED)
|
||||
#define bedtemptable_len (sizeof(bedtemptable)/sizeof(*bedtemptable))
|
||||
#else
|
||||
#ifdef BED_USES_THERMISTOR
|
||||
#error No bed thermistor table specified
|
||||
#endif // BED_USES_THERMISTOR
|
||||
#endif
|
||||
|
||||
#endif //THERMISTORTABLES_H_
|
||||
|
||||
+15
-9
@@ -1,9 +1,8 @@
|
||||
#ifndef __ULTRALCDH
|
||||
#define __ULTRALCDH
|
||||
#include "Configuration.h"
|
||||
|
||||
#include "Marlin.h"
|
||||
#ifdef ULTRA_LCD
|
||||
|
||||
#include <LiquidCrystal.h>
|
||||
void lcd_status();
|
||||
void lcd_init();
|
||||
void lcd_status(const char* message);
|
||||
@@ -15,7 +14,7 @@
|
||||
#define STATUSTIMEOUT 15000
|
||||
|
||||
|
||||
#include <LiquidCrystal.h>
|
||||
|
||||
extern LiquidCrystal lcd;
|
||||
|
||||
|
||||
@@ -79,7 +78,7 @@
|
||||
bool tune;
|
||||
|
||||
private:
|
||||
inline void updateActiveLines(const uint8_t &maxlines,volatile int &encoderpos)
|
||||
FORCE_INLINE void updateActiveLines(const uint8_t &maxlines,volatile int &encoderpos)
|
||||
{
|
||||
if(linechanging) return; // an item is changint its value, do not switch lines hence
|
||||
lastlineoffset=lineoffset;
|
||||
@@ -104,7 +103,6 @@
|
||||
curencoderpos=maxlines*lcdslow;
|
||||
}
|
||||
lastencoderpos=encoderpos=curencoderpos;
|
||||
int lastactiveline=activeline;
|
||||
activeline=curencoderpos/lcdslow;
|
||||
if(activeline<0) activeline=0;
|
||||
if(activeline>LCD_HEIGHT-1) activeline=LCD_HEIGHT-1;
|
||||
@@ -119,7 +117,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
inline void clearIfNecessary()
|
||||
FORCE_INLINE void clearIfNecessary()
|
||||
{
|
||||
if(lastlineoffset!=lineoffset ||force_lcd_update)
|
||||
{
|
||||
@@ -137,13 +135,13 @@
|
||||
|
||||
|
||||
#define LCD_MESSAGE(x) lcd_status(x);
|
||||
#define LCD_MESSAGEPGM(x) lcd_statuspgm(PSTR(x));
|
||||
#define LCD_MESSAGEPGM(x) lcd_statuspgm(MYPGM(x));
|
||||
#define LCD_STATUS lcd_status()
|
||||
#else //no lcd
|
||||
#define LCD_STATUS
|
||||
#define LCD_MESSAGE(x)
|
||||
#define LCD_MESSAGEPGM(x)
|
||||
inline void lcd_status() {};
|
||||
FORCE_INLINE void lcd_status() {};
|
||||
#endif
|
||||
|
||||
#ifndef ULTIPANEL
|
||||
@@ -153,5 +151,13 @@
|
||||
|
||||
void lcd_statuspgm(const char* message);
|
||||
|
||||
char *ftostr3(const float &x);
|
||||
char *itostr2(const uint8_t &x);
|
||||
char *ftostr31(const float &x);
|
||||
char *ftostr32(const float &x);
|
||||
char *itostr31(const int &xx);
|
||||
char *itostr3(const int &xx);
|
||||
char *itostr4(const int &xx);
|
||||
char *ftostr51(const float &x);
|
||||
#endif //ULTRALCD
|
||||
|
||||
|
||||
+1933
-1673
File diff suppressed because it is too large
Load Diff
+3
-3
@@ -1,6 +1,6 @@
|
||||
#ifndef __WATCHDOGH
|
||||
#define __WATCHDOGH
|
||||
#include "Configuration.h"
|
||||
#include "Marlin.h"
|
||||
#ifdef USE_WATCHDOG
|
||||
|
||||
// intialise watch dog with a 1 sec interrupt time
|
||||
@@ -9,8 +9,8 @@
|
||||
void wd_reset();
|
||||
|
||||
#else
|
||||
inline void wd_init() {};
|
||||
inline void wd_reset() {};
|
||||
FORCE_INLINE void wd_init() {};
|
||||
FORCE_INLINE void wd_reset() {};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
+1
-2
@@ -1,7 +1,6 @@
|
||||
#ifdef USE_WATCHDOG
|
||||
#include "Marlin.h"
|
||||
#include "watchdog.h"
|
||||
#include <avr/wdt.h>
|
||||
#include <avr/interrupt.h>
|
||||
|
||||
//===========================================================================
|
||||
//=============================private variables ============================
|
||||
|
||||
+141
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* fixed by this patch:
|
||||
* http://code.google.com/p/arduino/issues/detail?id=604
|
||||
* */
|
||||
/*
|
||||
wiring.h - Partial implementation of the Wiring API for the ATmega8.
|
||||
Part of Arduino - http://www.arduino.cc/
|
||||
|
||||
Copyright (c) 2005-2006 David A. Mellis
|
||||
|
||||
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., 59 Temple Place, Suite 330,
|
||||
Boston, MA 02111-1307 USA
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#ifndef Wiring_h
|
||||
#define Wiring_h
|
||||
|
||||
#include <avr/io.h>
|
||||
#include <stdlib.h>
|
||||
#include "binary.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
#define HIGH 0x1
|
||||
#define LOW 0x0
|
||||
|
||||
#define INPUT 0x0
|
||||
#define OUTPUT 0x1
|
||||
|
||||
#define true 0x1
|
||||
#define false 0x0
|
||||
|
||||
#define PI 3.1415926535897932384626433832795
|
||||
#define HALF_PI 1.5707963267948966192313216916398
|
||||
#define TWO_PI 6.283185307179586476925286766559
|
||||
#define DEG_TO_RAD 0.017453292519943295769236907684886
|
||||
#define RAD_TO_DEG 57.295779513082320876798154814105
|
||||
|
||||
#define SERIAL 0x0
|
||||
#define DISPLAY 0x1
|
||||
|
||||
#define LSBFIRST 0
|
||||
#define MSBFIRST 1
|
||||
|
||||
#define CHANGE 1
|
||||
#define FALLING 2
|
||||
#define RISING 3
|
||||
|
||||
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||
#define INTERNAL1V1 2
|
||||
#define INTERNAL2V56 3
|
||||
#else
|
||||
#define INTERNAL 3
|
||||
#endif
|
||||
#define DEFAULT 1
|
||||
#define EXTERNAL 0
|
||||
|
||||
// undefine stdlib's abs if encountered
|
||||
#ifdef abs
|
||||
#undef abs
|
||||
#endif
|
||||
|
||||
#define min(a,b) ((a)<(b)?(a):(b))
|
||||
#define max(a,b) ((a)>(b)?(a):(b))
|
||||
#define abs(x) ((x)>0?(x):-(x))
|
||||
#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
|
||||
#if __AVR_LIBC_VERSION__ < 10701UL
|
||||
#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
|
||||
#endif
|
||||
#define radians(deg) ((deg)*DEG_TO_RAD)
|
||||
#define degrees(rad) ((rad)*RAD_TO_DEG)
|
||||
#define sq(x) ((x)*(x))
|
||||
|
||||
#define interrupts() sei()
|
||||
#define noInterrupts() cli()
|
||||
|
||||
#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )
|
||||
#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (F_CPU / 1000L) )
|
||||
#define microsecondsToClockCycles(a) ( ((a) * (F_CPU / 1000L)) / 1000L )
|
||||
|
||||
#define lowByte(w) ((uint8_t) ((w) & 0xff))
|
||||
#define highByte(w) ((uint8_t) ((w) >> 8))
|
||||
|
||||
#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
|
||||
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
|
||||
#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
|
||||
#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
|
||||
|
||||
|
||||
typedef unsigned int word;
|
||||
|
||||
#define bit(b) (1UL << (b))
|
||||
|
||||
typedef uint8_t boolean;
|
||||
typedef uint8_t byte;
|
||||
|
||||
void init(void);
|
||||
|
||||
void pinMode(uint8_t, uint8_t);
|
||||
void digitalWrite(uint8_t, uint8_t);
|
||||
int digitalRead(uint8_t);
|
||||
int analogRead(uint8_t);
|
||||
void analogReference(uint8_t mode);
|
||||
void analogWrite(uint8_t, int);
|
||||
|
||||
unsigned long millis(void);
|
||||
unsigned long micros(void);
|
||||
void delay(unsigned long);
|
||||
void delayMicroseconds(unsigned int us);
|
||||
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout);
|
||||
|
||||
void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val);
|
||||
uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder);
|
||||
|
||||
void attachInterrupt(uint8_t, void (*)(void), int mode);
|
||||
void detachInterrupt(uint8_t);
|
||||
|
||||
void setup(void);
|
||||
void loop(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,7 +1,10 @@
|
||||
|
||||
WARNING:
|
||||
--------
|
||||
THIS IS THE BETA 1 FOR MARLIN 1.0.0
|
||||
THIS IS RELEASE CANDIDATE 1 FOR MARLIN 1.0.0
|
||||
|
||||
The configuration is now split in two files
|
||||
Configuration.h for the normal settings
|
||||
Configuration_adv.h for the advanced settings
|
||||
|
||||
Quick Information
|
||||
===================
|
||||
@@ -54,7 +57,7 @@ It leads to less over-deposition at corners, especially at flat angles.
|
||||
|
||||
*Arc support:*
|
||||
|
||||
Splic3r can find curves that, although broken into segments, were ment to describe an arc.
|
||||
Slic3r can find curves that, although broken into segments, were ment to describe an arc.
|
||||
Marlin is able to print those arcs. The advantage is the firmware can choose the resolution,
|
||||
and can perform the arc with nearly constant velocity, resulting in a nice finish.
|
||||
Also, less serial communication is needed.
|
||||
|
||||
Reference in New Issue
Block a user