configuration changes

This commit is contained in:
jeanmarc
2012-06-25 08:30:48 +01:00
parent c8e953bdf9
commit d5eb0622ee
19 changed files with 844 additions and 358 deletions
+8 -7
View File
@@ -1,5 +1,5 @@
#ifndef __CONFIGURATION_H
#define __CONFIGURATION_H
#ifndef CONFIGURATION_H
#define CONFIGURATION_H
// Uncomment ONE of the next three lines - the one for your RepRap machine
//#define REPRAPPRO_HUXLEY
@@ -55,7 +55,7 @@
// Set this if you want to define the constants in the thermistor circuit
// and work out temperatures algebraically - added by AB.
#define COMPUTE_THERMISTORS
//#define COMPUTE_THERMISTORS
#ifdef COMPUTE_THERMISTORS
@@ -100,9 +100,9 @@
// -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
// 1 is 100k thermistor - best choice for EPCOS 100k (4.7k pullup)
// 2 is 200k thermistor - ATC Semitec 204GT-2 (4.7k pullup)
// 3 is mendel-parts thermistor (4.7k pullup)
// 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
@@ -113,7 +113,7 @@
// 103 is 100k EPCOS G57540 Bed with r2=4k7
// 104 is 10k G57540 Bed with r2=4k7
// 105 is 10k G57540 Bed with r2=10k
// 110 is reprappro xmas huxley hot end with 10K resistor (RS thermistor 198-961)
// 110 is 100k RS thermistor 198-961 hot end with 10K resistor
#define TEMP_SENSOR_0 110
#define TEMP_SENSOR_1 0
@@ -123,6 +123,7 @@
// Actual temperature must be close to target for this long before M109 returns success
#define TEMP_RESIDENCY_TIME 10 // (seconds)
#define TEMP_HYSTERESIS 5 // (C°) range of +/- temperatures considered "close" to the target one
#define TEMP_WINDOW 2 // (degC) Window around target to start the recidency timer x degC early.
// 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.
+2 -5
View File
@@ -1,5 +1,5 @@
#ifndef __CONFIGURATION_ADV_H
#define __CONFIGURATION_ADV_H
#ifndef CONFIGURATION_ADV_H
#define CONFIGURATION_ADV_H
//===========================================================================
//=============================Thermal Settings ============================
@@ -150,9 +150,6 @@
#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
+2 -2
View File
@@ -1,5 +1,5 @@
#ifndef __EEPROMH
#define __EEPROMH
#ifndef EEPROM_H
#define EEPROM_H
#include "Marlin.h"
#include "planner.h"
+6 -2
View File
@@ -1,8 +1,8 @@
// Tonokip RepRap firmware rewrite based off of Hydra-mmm firmware.
// Licence: GPL
#ifndef __MARLINH
#define __MARLINH
#ifndef MARLIN_H
#define MARLIN_H
#define HardwareSerial_h // trick to disable the standard HWserial
@@ -64,6 +64,7 @@
#define SERIAL_PROTOCOL(x) MYSERIAL.print(x);
#define SERIAL_PROTOCOL_F(x,y) MYSERIAL.print(x,y);
#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');}
@@ -169,6 +170,9 @@ void ClearToSend();
void get_coordinates();
void prepare_move();
void kill();
void Stop();
bool IsStopped();
void enquecommand(const char *cmd); //put an ascii command at the end of the current buffer.
void prepare_arc_move(char isclockwise);
+166 -36
View File
@@ -39,6 +39,7 @@
#include "watchdog.h"
#include "EEPROMwrite.h"
#include "language.h"
#include "pins_arduino.h"
#define VERSION_STRING "1.0.0 RC2"
@@ -113,15 +114,16 @@
// M240 - Trigger a camera to take a photograph
// M301 - Set PID parameters P I and D
// M302 - Allow cold extrudes
// M303 - PID relay autotune S<temperature> sets the target temperature. (default target temperature = 150C)
// M400 - Finish all moves
// M500 - stores paramters in EEPROM
// 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.
// M503 - print the current settings (from memory not from eeprom)
// M303 - PID relay autotune S<temperature> sets the target temperature. (default target temperature = 150C)
// M510 - FPU Enable
// M511 - FPU Reset
// M512 - FPU Disable
// M999 - Restart after being stopped by error
//Stepper Movement Variables
@@ -160,7 +162,7 @@ float modified_destination[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0};
//===========================================================================
const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'};
static bool home_all_axis = true;
static long gcode_N, gcode_LastN;
static long gcode_N, gcode_LastN, Stopped_gcode_LastN = 0;
static bool relative_mode = false; //Determines Absolute or Relative Coordinates
static bool relative_mode_e = false; //Determines Absolute or Relative E Codes while in Absolute Coordinates mode. E is always relative in Relative Coordinates mode.
@@ -192,6 +194,8 @@ static unsigned long stoptime=0;
static uint8_t tmp_extruder;
bool Stopped=false;
//===========================================================================
//=============================ROUTINES=============================
//===========================================================================
@@ -366,7 +370,10 @@ void get_command()
{
while( MYSERIAL.available() > 0 && buflen < BUFSIZE) {
serial_char = MYSERIAL.read();
if(serial_char == '\n' || serial_char == '\r' || serial_char == ':' || serial_count >= (MAX_CMD_SIZE - 1) )
if(serial_char == '\n' ||
serial_char == '\r' ||
(serial_char == ':' && comment_mode == false) ||
serial_count >= (MAX_CMD_SIZE - 1) )
{
if(!serial_count) { //if empty line
comment_mode = false; //for new command
@@ -438,11 +445,17 @@ void get_command()
case 1:
case 2:
case 3:
#ifdef SDSUPPORT
if(card.saving)
break;
#endif //SDSUPPORT
SERIAL_PROTOCOLLNPGM(MSG_OK);
if(Stopped == false) { // If printer is stopped by an error the G[0-3] codes are ignored.
#ifdef SDSUPPORT
if(card.saving)
break;
#endif //SDSUPPORT
SERIAL_PROTOCOLLNPGM(MSG_OK);
}
else {
SERIAL_ERRORLNPGM(MSG_ERR_STOPPED);
LCD_MESSAGEPGM(MSG_STOPPED);
}
break;
default:
break;
@@ -467,7 +480,10 @@ void get_command()
while( !card.eof() && buflen < BUFSIZE) {
int16_t n=card.get();
serial_char = (char)n;
if(serial_char == '\n' || serial_char == '\r' || serial_char == ':' || serial_count >= (MAX_CMD_SIZE - 1)||n==-1)
if(serial_char == '\n' ||
serial_char == '\r' ||
(serial_char == ':' && comment_mode == false) ||
serial_count >= (MAX_CMD_SIZE - 1)||n==-1)
{
if(card.eof()){
SERIAL_PROTOCOLLNPGM(MSG_FILE_PRINTED);
@@ -570,19 +586,25 @@ void process_commands()
{
case 0: // G0 -> G1
case 1: // G1
get_coordinates(); // For X Y Z E F
prepare_move();
//ClearToSend();
return;
if(Stopped == false) {
get_coordinates(); // For X Y Z E F
prepare_move();
//ClearToSend();
return;
}
//break;
case 2: // G2 - CW ARC
get_arc_coordinates();
prepare_arc_move(true);
return;
if(Stopped == false) {
get_arc_coordinates();
prepare_arc_move(true);
return;
}
case 3: // G3 - CCW ARC
get_arc_coordinates();
prepare_arc_move(false);
return;
if(Stopped == false) {
get_arc_coordinates();
prepare_arc_move(false);
return;
}
case 4: // G4 dwell
LCD_MESSAGEPGM(MSG_DWELL);
codenum = 0;
@@ -873,10 +895,14 @@ void process_commands()
}
#if (TEMP_0_PIN > -1)
SERIAL_PROTOCOLPGM("ok T:");
SERIAL_PROTOCOL(degHotend(tmp_extruder));
SERIAL_PROTOCOL_F(degHotend(tmp_extruder),1);
SERIAL_PROTOCOLPGM(" /");
SERIAL_PROTOCOL_F(degTargetHotend(tmp_extruder),1);
#if TEMP_BED_PIN > -1
SERIAL_PROTOCOLPGM(" B:");
SERIAL_PROTOCOL(degBed());
SERIAL_PROTOCOL_F(degBed(),1);
SERIAL_PROTOCOLPGM(" /");
SERIAL_PROTOCOL_F(degTargetBed(),1);
#endif //TEMP_BED_PIN
#else
SERIAL_ERROR_START;
@@ -908,7 +934,7 @@ void process_commands()
if (code_seen('S')) setTargetHotend(code_value(), tmp_extruder);
#ifdef AUTOTEMP
if (code_seen('S')) autotemp_min=code_value();
if (code_seen('G')) autotemp_max=code_value();
if (code_seen('B')) autotemp_max=code_value();
if (code_seen('F'))
{
autotemp_factor=code_value();
@@ -935,9 +961,9 @@ void process_commands()
if( (millis() - codenum) > 1000UL )
{ //Print Temp Reading and remaining time every 1 second while heating up/cooling down
SERIAL_PROTOCOLPGM("T:");
SERIAL_PROTOCOL( degHotend(tmp_extruder) );
SERIAL_PROTOCOL_F(degHotend(tmp_extruder),1);
SERIAL_PROTOCOLPGM(" E:");
SERIAL_PROTOCOL( (int)tmp_extruder );
SERIAL_PROTOCOL((int)tmp_extruder);
#ifdef TEMP_RESIDENCY_TIME
SERIAL_PROTOCOLPGM(" W:");
if(residencyStart > -1)
@@ -961,8 +987,8 @@ void process_commands()
#ifdef TEMP_RESIDENCY_TIME
/* start/restart the TEMP_RESIDENCY_TIME timer whenever we reach target temp for the first time
or when current temp falls outside the hysteresis after target temp was reached */
if ((residencyStart == -1 && target_direction && !isHeatingHotend(tmp_extruder)) ||
(residencyStart == -1 && !target_direction && !isCoolingHotend(tmp_extruder)) ||
if ((residencyStart == -1 && target_direction && (degHotend(tmp_extruder) >= (degTargetHotend(tmp_extruder)-TEMP_WINDOW))) ||
(residencyStart == -1 && !target_direction && (degHotend(tmp_extruder) <= (degTargetHotend(tmp_extruder)+TEMP_WINDOW))) ||
(residencyStart > -1 && labs(degHotend(tmp_extruder) - degTargetHotend(tmp_extruder)) > TEMP_HYSTERESIS) )
{
residencyStart = millis();
@@ -987,9 +1013,10 @@ void process_commands()
SERIAL_PROTOCOLPGM("T:");
SERIAL_PROTOCOL(tt);
SERIAL_PROTOCOLPGM(" E:");
SERIAL_PROTOCOL( (int)active_extruder );
SERIAL_PROTOCOL((int)active_extruder);
SERIAL_PROTOCOLPGM(" B:");
SERIAL_PROTOCOLLN(degBed());
SERIAL_PROTOCOL_F(degBed(),1);
SERIAL_PROTOCOLLN("");
codenum = millis();
}
manage_heater();
@@ -1018,6 +1045,7 @@ void process_commands()
#if (PS_ON_PIN > -1)
case 80: // M80 - ATX Power On
SET_OUTPUT(PS_ON_PIN); //GND
WRITE(PS_ON_PIN, LOW);
break;
#endif
@@ -1106,6 +1134,12 @@ void process_commands()
SERIAL_PROTOCOLLN("");
break;
case 120: // M120
enable_endstops(false) ;
break;
case 121: // M121
enable_endstops(true) ;
break;
case 119: // M119
#if (X_MIN_PIN > -1)
SERIAL_PROTOCOLPGM(MSG_X_MIN);
@@ -1248,7 +1282,7 @@ void process_commands()
}
break;
case 302: // finish all moves
case 302: // allow cold extrudes
{
allow_cold_extrudes(true);
}
@@ -1260,7 +1294,7 @@ void process_commands()
PID_autotune(temp);
}
break;
case 400: // finish all moves
case 400: // M400 finish all moves
{
st_synchronize();
}
@@ -1292,6 +1326,11 @@ void process_commands()
SERIAL_ECHO(freeMemory());
}
break;
case 999: // Restart after being stopped
Stopped = false;
gcode_LastN = Stopped_gcode_LastN;
FlushSerialRequestResend();
break;
case 510: // FPU Enable
{
FPUEnable();
@@ -1373,8 +1412,18 @@ void get_coordinates()
void get_arc_coordinates()
{
get_coordinates();
if(code_seen('I')) offset[0] = code_value();
if(code_seen('J')) offset[1] = code_value();
if(code_seen('I')) {
offset[0] = code_value();
}
else {
offset[0] = 0.0;
}
if(code_seen('J')) {
offset[1] = code_value();
}
else {
offset[1] = 0.0;
}
}
void prepare_move()
@@ -1429,7 +1478,7 @@ void controllerFan()
if ((millis() - lastMotorCheck) >= 2500) //Not a time critical function, so we only check every 2500ms
{
lastMotorCheck = millis();
#if (X_ENABLE_PIN > -1 && Y_ENABLE_PIN > -1 && Z_ENABLE_PIN > -1 && E0_ENABLE_PIN > -1)
if(!READ(X_ENABLE_PIN) || !READ(Y_ENABLE_PIN) || !READ(Z_ENABLE_PIN)
#if EXTRUDERS > 2
|| !READ(E2_ENABLE_PIN)
@@ -1441,9 +1490,6 @@ void controllerFan()
{
lastMotor = millis(); //... set time to NOW so the fan will turn on
}
#else
lastMotor = millis();
#endif
if ((millis() - lastMotor) >= (CONTROLLERFAN_SEC*1000UL) || lastMotor == 0) //If the last time any driver was enabled, is longer since than CONTROLLERSEC...
{
@@ -1520,4 +1566,88 @@ void kill()
while(1); // Wait for reset
}
void Stop()
{
disable_heater();
if(Stopped == false) {
Stopped = true;
Stopped_gcode_LastN = gcode_LastN; // Save last g_code for restart
SERIAL_ERROR_START;
SERIAL_ERRORLNPGM(MSG_ERR_STOPPED);
LCD_MESSAGEPGM(MSG_STOPPED);
}
}
bool IsStopped() { return Stopped; };
#ifdef FAST_PWM_FAN
void setPwmFrequency(uint8_t pin, int val)
{
val &= 0x07;
switch(digitalPinToTimer(pin))
{
#if defined(TCCR0A)
case TIMER0A:
case TIMER0B:
// TCCR0B &= ~(CS00 | CS01 | CS02);
// TCCR0B |= val;
break;
#endif
#if defined(TCCR1A)
case TIMER1A:
case TIMER1B:
// TCCR1B &= ~(CS10 | CS11 | CS12);
// TCCR1B |= val;
break;
#endif
#if defined(TCCR2)
case TIMER2:
case TIMER2:
TCCR2 &= ~(CS10 | CS11 | CS12);
TCCR2 |= val;
break;
#endif
#if defined(TCCR2A)
case TIMER2A:
case TIMER2B:
TCCR2B &= ~(CS20 | CS21 | CS22);
TCCR2B |= val;
break;
#endif
#if defined(TCCR3A)
case TIMER3A:
case TIMER3B:
case TIMER3C:
TCCR3B &= ~(CS30 | CS31 | CS32);
TCCR3B |= val;
break;
#endif
#if defined(TCCR4A)
case TIMER4A:
case TIMER4B:
case TIMER4C:
TCCR4B &= ~(CS40 | CS41 | CS42);
TCCR4B |= val;
break;
#endif
#if defined(TCCR5A)
case TIMER5A:
case TIMER5B:
case TIMER5C:
TCCR5B &= ~(CS50 | CS51 | CS52);
TCCR5B |= val;
break;
#endif
}
}
#endif
+12 -4
View File
@@ -53,7 +53,7 @@ void CardReader::lsDive(const char *prepend,SdFile parent)
while (parent.readDir(p) > 0)
{
if( DIR_IS_SUBDIR(&p) && lsAction!=LS_Count && lsAction!=LS_GetFilename)
if( DIR_IS_SUBDIR(&p) && lsAction!=LS_Count && lsAction!=LS_GetFilename) // hence LS_SerialPrint
{
char path[13*2];
@@ -95,9 +95,11 @@ void CardReader::lsDive(const char *prepend,SdFile parent)
if ( p.name[1] != '.')
continue;
}
if (!DIR_IS_FILE_OR_SUBDIR(&p)) continue;
filenameIsDir=DIR_IS_SUBDIR(&p);
if(!filenameIsDir)
{
if(p.name[8]!='G') continue;
@@ -163,20 +165,26 @@ void CardReader::initsd()
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM(MSG_SD_CARD_OK);
}
workDir=root;
curDir=&root;
/*
if(!workDir.openRoot(&volume))
{
SERIAL_ECHOLNPGM(MSG_SD_WORKDIR_FAIL);
}
*/
}
void CardReader::setroot()
{
curDir=&root;
if(!workDir.openRoot(&volume))
/*if(!workDir.openRoot(&volume))
{
SERIAL_ECHOLNPGM(MSG_SD_WORKDIR_FAIL);
}
}*/
workDir=root;
curDir=&workDir;
}
void CardReader::release()
{
+3 -3
View File
@@ -1,5 +1,5 @@
#ifndef __CARDREADERH
#define __CARDREADERH
#ifndef CARDREADER_H
#define CARDREADER_H
#ifdef SDSUPPORT
@@ -47,7 +47,7 @@ public:
bool saving;
bool sdprinting ;
bool cardOK ;
char filename[11];
char filename[12];
bool filenameIsDir;
int lastnr; //last number of the autostart;
char fastxferbuffer[SD_FAST_XFER_CHUNK_SIZE + 1];
+9 -5
View File
@@ -61,8 +61,8 @@
#define MSG_MAIN_WIDE " Main \003"
#define MSG_TEMPERATURE_WIDE " Temperature \x7E"
#define MSG_MOTION_WIDE " Motion \x7E"
#define MSG_STORE_EPROM " Store EPROM"
#define MSG_LOAD_EPROM " Load EPROM"
#define MSG_STORE_EPROM " Store memory"
#define MSG_LOAD_EPROM " Load memory"
#define MSG_RESTORE_FAILSAFE " Restore Failsafe"
#define MSG_REFRESH "\004Refresh"
#define MSG_WATCH " Watch \003"
@@ -74,10 +74,12 @@
#define MSG_CARD_MENU " Card Menu \x7E"
#define MSG_NO_CARD " No Card"
#define MSG_SERIAL_ERROR_MENU_STRUCTURE "Something is wrong in the MenuStructure."
#define MSG_DWELL "DWELL..."
#define MSG_DWELL "Sleep..."
#define MSG_USERWAIT "Wait for user..."
#define MSG_NO_MOVE "No move."
#define MSG_PART_RELEASE "Partial Release"
#define MSG_KILLED "KILLED. "
#define MSG_STOPPED "STOPPED. "
#define MSG_PREHEAT_PLA " Preheat PLA"
#define MSG_PREHEAT_ABS " Preheat ABS"
#define MSG_STEPPER_RELEASED "Released."
@@ -91,7 +93,7 @@
#define MSG_BROWNOUT_RESET " Brown out Reset"
#define MSG_WATCHDOG_RESET " Watchdog Reset"
#define MSG_SOFTWARE_RESET " Software Reset"
#define MSG_MARLIN "Marlin: "
#define MSG_MARLIN "Marlin "
#define MSG_AUTHOR " | Author: "
#define MSG_CONFIGURATION_VER " Last Updated: "
#define MSG_FREE_MEMORY " Free Memory: "
@@ -116,6 +118,7 @@
#define MSG_M115_REPORT "FIRMWARE_NAME:Marlin V1; Sprinter/grbl mashup for gen6 FIRMWARE_URL:http://www.mendel-parts.com PROTOCOL_VERSION:1.0 MACHINE_TYPE:Mendel EXTRUDER_COUNT:1\n"
#define MSG_COUNT_X " Count X:"
#define MSG_ERR_KILLED "Printer halted. kill() called !!"
#define MSG_ERR_STOPPED "Printer stopped due to errors. Fix the error and use M999 to restart!. (Temperature is reset. Set it before restarting)"
#define MSG_RESEND "Resend:"
#define MSG_UNKNOWN_COMMAND "Unknown command:\""
#define MSG_ACTIVE_EXTRUDER "Active Extruder: "
@@ -153,7 +156,7 @@
// LCD Menu Messages
#define WELCOME_MSG "UltiMARLIN Ready."
#define WELCOME_MSG "MARLIN Ready."
#define MSG_SD_INSERTED "Card inserted"
#define MSG_SD_REMOVED "Card removed"
@@ -259,6 +262,7 @@
#define MSG_M115_REPORT "FIRMWARE_NAME:Marlin V1; Sprinter/grbl mashup for gen6 FIRMWARE_URL:http://www.mendel-parts.com PROTOCOL_VERSION:1.0 MACHINE_TYPE:Mendel EXTRUDER_COUNT:1\n"
#define MSG_COUNT_X " Count X:"
#define MSG_ERR_KILLED "Printer halted. kill() called !!"
#define MSG_ERR_STOPPED "Printer stopped due to errors. Fix the error and use M999 to restart!"
#define MSG_RESEND "Resend:"
#define MSG_UNKNOWN_COMMAND "Unknown command:\""
#define MSG_ACTIVE_EXTRUDER "Active Extruder: "
+2
View File
@@ -47,6 +47,8 @@ void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8
float millimeters_of_travel = hypot(angular_travel*radius, fabs(linear_travel));
if (millimeters_of_travel < 0.001) { return; }
uint16_t segments = floor(millimeters_of_travel/MM_PER_ARC_SEGMENT);
if(segments == 0) segments = 1;
/*
// Multiply inverse feed_rate to compensate for the fact that this movement is approximated
// by a number of discrete segments. The inverse feed_rate should be correct for the sum of
+7 -5
View File
@@ -579,16 +579,16 @@
#define Z_STEP_PIN 3
#define Z_DIR_PIN 2
#define Z_MIN_PIN 20 //for Melzi Z bed probe, 20 for standard Z endstop
#define Z_MIN_PIN 20
#define Z_MAX_PIN -1
#define E0_STEP_PIN 1
#define E0_DIR_PIN 0
#define PROBE_PIN -1 //29 on Melzi1284p A2, 11 on SL1.3a
#define PROBE_PIN -1
#define LED_PIN 27//27 //27 on Melzi1284p
#define FAN_PIN 4 //4 on Melzi1284p
#define LED_PIN -1
#define FAN_PIN -1
#define PS_ON_PIN -1
#define KILL_PIN -1
@@ -654,6 +654,8 @@
#define E0_STEP_PIN 1
#define E0_DIR_PIN 0
#define PROBE_PIN -1 //29 on Melzi1284p A2
#define LED_PIN 27
#define FAN_PIN 4
@@ -730,7 +732,7 @@
#define E1_STEP_PIN 49
#define E1_DIR_PIN 47
#define E1_ENABLE_PIN 51
#define E1_ENABLE_PIN 48
#define SDPOWER -1
#define SDSS 53
+55 -79
View File
@@ -51,9 +51,6 @@
IntersectionDistance[s1_, s2_, a_, d_] := (2 a d - s1^2 + s2^2)/(4 a)
*/
#include "Marlin.h"
#include "planner.h"
#include "stepper.h"
@@ -378,20 +375,26 @@ void plan_init() {
void getHighESpeed()
{
static float oldt=0;
if(!autotemp_enabled)
if(!autotemp_enabled){
return;
if(degTargetHotend0()+2<autotemp_min) //probably temperature set to zero.
}
if(degTargetHotend0()+2<autotemp_min) { //probably temperature set to zero.
return; //do nothing
}
float high=0;
float high=0.0;
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;
//se; units steps/sec;
if(se>high)
{
high=se;
if((block_buffer[block_index].steps_x != 0) ||
(block_buffer[block_index].steps_y != 0) ||
(block_buffer[block_index].steps_z != 0)) {
float se=(float(block_buffer[block_index].steps_e)/float(block_buffer[block_index].step_event_count))*block_buffer[block_index].nominal_speed;
//se; mm/sec;
if(se>high)
{
high=se;
}
}
block_index = (block_index+1) & (BLOCK_BUFFER_SIZE - 1);
}
@@ -408,10 +411,6 @@ void getHighESpeed()
}
oldt=t;
setTargetHotend0(t);
// SERIAL_ECHO_START;
// SERIAL_ECHOPAIR("highe",high);
// SERIAL_ECHOPAIR(" t",t);
// SERIAL_ECHOLN("");
}
#endif
@@ -514,7 +513,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
block->step_event_count = max(block->steps_x, max(block->steps_y, max(block->steps_z, block->steps_e)));
// Bail if this is a zero-length block
if (block->step_event_count <=dropsegments) { return; };
if (block->step_event_count <= dropsegments) { return; };
block->fan_speed = FanSpeed;
@@ -537,7 +536,6 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
// Enable all
if(block->steps_e != 0) { enable_e0();enable_e1();enable_e2(); }
if (block->steps_e == 0) {
if(feed_rate<mintravelfeedrate) feed_rate=mintravelfeedrate;
}
@@ -545,61 +543,54 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
if(feed_rate<minimumfeedrate) feed_rate=minimumfeedrate;
}
// 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);
#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
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])*extrudemultiply/100.0;
// 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]));
// }
if ( block->steps_x <=dropsegments && block->steps_y <=dropsegments && block->steps_z <=dropsegments ) {
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]));
}
// TODO - JMG - SORT OUT RETRACTS WHEN e IS NOT ALONE
block->millimeters = sqrt(square(delta_mm[X_AXIS]) + square(delta_mm[Y_AXIS]) +
square(delta_mm[Z_AXIS]) + square(delta_mm[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]));
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.
float inverse_second = feed_rate * inverse_millimeters;
int moves_queued=(block_buffer_head-block_buffer_tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1);
// slow down when de buffer starts to empty, rather than wait at the corner for a buffer refill
#ifdef OLD_SLOWDOWN
if(moves_queued < (BLOCK_BUFFER_SIZE * 0.5) && moves_queued > 1) feed_rate = feed_rate*moves_queued / (BLOCK_BUFFER_SIZE * 0.5);
#endif
#ifdef SLOWDOWN
// segment time im micro seconds
unsigned long segment_time = lround(1000000.0/inverse_second);
if ((moves_queued > 1) && (moves_queued < (BLOCK_BUFFER_SIZE * 0.5))) {
if (segment_time < minsegmenttime) { // buffer is draining, add extra time. The amount of time added increases if the buffer is still emptied more.
inverse_second=1000000.0/(segment_time+lround(2*(minsegmenttime-segment_time)/moves_queued));
}
}
#endif
// END OF SLOW DOWN SECTION
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 ((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);
}
}
else {
if (segment_time<minsegmenttime) segment_time=minsegmenttime;
}
// END OF SLOW DOWN SECTION
*/
// Calculate speed in mm/sec for each axis
// Calculate and limit speed in mm/sec for each axis
float current_speed[4];
for(int i=0; i < 4; i++) {
current_speed[i] = delta_mm[i] * inverse_second;
}
// Limit speed per axis
float speed_factor = 1.0; //factor <=1 do decrease speed
for(int i=0; i < 4; i++) {
if(abs(current_speed[i]) > max_feedrate[i])
speed_factor = min(speed_factor, max_feedrate[i] / abs(current_speed[i]));
current_speed[i] = delta_mm[i] * inverse_second;
if(fabs(current_speed[i]) > max_feedrate[i])
speed_factor = min(speed_factor, max_feedrate[i] / fabs(current_speed[i]));
}
// Max segement time in us.
@@ -634,17 +625,6 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
// Correct the speed
if( speed_factor < 1.0) {
// Serial.print("speed factor : "); Serial.println(speed_factor);
for(int i=0; i < 4; i++) {
if(abs(current_speed[i]) > max_feedrate[i])
speed_factor = min(speed_factor, max_feedrate[i] / abs(current_speed[i]));
/*
if(speed_factor < 0.1) {
Serial.print("speed factor : "); Serial.println(speed_factor);
Serial.print("current_speed"); Serial.print(i); Serial.print(" : "); Serial.println(current_speed[i]);
}
*/
}
for(unsigned char i=0; i < 4; i++) {
current_speed[i] *= speed_factor;
}
@@ -714,25 +694,25 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
#endif
// Start with a safe speed
float vmax_junction = max_xy_jerk/2;
if(abs(current_speed[Z_AXIS]) > max_z_jerk/2)
if(fabs(current_speed[Z_AXIS]) > max_z_jerk/2)
vmax_junction = max_z_jerk/2;
vmax_junction = min(vmax_junction, block->nominal_speed);
if(abs(current_speed[E_AXIS]) > max_e_jerk/2)
if(fabs(current_speed[E_AXIS]) > max_e_jerk/2)
vmax_junction = min(vmax_junction, max_e_jerk/2);
if ((moves_queued > 1) && (previous_nominal_speed > 0.0)) {
if ((moves_queued > 1) && (previous_nominal_speed > 0.0001)) {
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)) {
if((fabs(previous_speed[X_AXIS]) > 0.0001) || (fabs(previous_speed[Y_AXIS]) > 0.0001)) {
vmax_junction = block->nominal_speed;
}
if (jerk > max_xy_jerk) {
vmax_junction *= (max_xy_jerk/jerk);
}
if(abs(current_speed[Z_AXIS] - previous_speed[Z_AXIS]) > max_z_jerk) {
vmax_junction *= (max_z_jerk/abs(current_speed[Z_AXIS] - previous_speed[Z_AXIS]));
if(fabs(current_speed[Z_AXIS] - previous_speed[Z_AXIS]) > max_z_jerk) {
vmax_junction *= (max_z_jerk/fabs(current_speed[Z_AXIS] - previous_speed[Z_AXIS]));
}
if(abs(current_speed[E_AXIS] - previous_speed[E_AXIS]) > max_e_jerk) {
vmax_junction *= (max_e_jerk/abs(current_speed[E_AXIS] - previous_speed[E_AXIS]));
if(fabs(current_speed[E_AXIS] - previous_speed[E_AXIS]) > max_e_jerk) {
vmax_junction *= (max_e_jerk/fabs(current_speed[E_AXIS] - previous_speed[E_AXIS]));
}
}
block->max_entry_speed = vmax_junction;
@@ -756,6 +736,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
// Update previous path unit_vector and nominal speed
memcpy(previous_speed, current_speed, sizeof(previous_speed)); // previous_speed[] = current_speed[]
previous_nominal_speed = block->nominal_speed;
#ifdef ADVANCE
// Calculate advance rate
@@ -784,9 +765,6 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
*/
#endif // ADVANCE
calculate_trapezoid_for_block(block, block->entry_speed/block->nominal_speed,
MINIMUM_PLANNER_SPEED/block->nominal_speed);
@@ -797,9 +775,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
memcpy(position, target, sizeof(target)); // position[] = target[]
planner_recalculate();
#ifdef AUTOTEMP
getHighESpeed();
#endif
st_wake_up();
}
+4 -4
View File
@@ -45,10 +45,10 @@ typedef struct {
#endif
// Fields used by the motion planner to manage acceleration
// float speed_x, speed_y, speed_z, speed_e; // Nominal mm/minute for each axis
float nominal_speed; // The nominal speed for this block in mm/min
float entry_speed; // Entry speed at previous-current junction in mm/min
float max_entry_speed; // Maximum allowable junction entry speed in mm/min
// float speed_x, speed_y, speed_z, speed_e; // Nominal mm/sec for each axis
float nominal_speed; // The nominal speed for this block in mm/sec
float entry_speed; // Entry speed at previous-current junction in mm/sec
float max_entry_speed; // Maximum allowable junction entry speed in mm/sec
float millimeters; // The total travel of this block in mm
float acceleration; // acceleration mm/sec^2
unsigned char recalculate_flag; // Planner flag to recalculate trapezoids on entry junction
+2 -7
View File
@@ -57,7 +57,6 @@ volatile static unsigned long step_events_completed; // The number of step event
static long old_advance = 0;
#endif
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
@@ -84,11 +83,7 @@ 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
#define CHECK_ENDSTOPS if(check_endstops)
// intRes = intIn1 * intIn2 >> 16
// uses:
@@ -217,7 +212,6 @@ void enable_endstops(bool check)
void st_wake_up() {
// TCNT1 = 0;
if(busy == false)
ENABLE_STEPPER_DRIVER_INTERRUPT();
}
@@ -296,6 +290,7 @@ ISR(TIMER1_COMPA_vect)
// Anything in the buffer?
current_block = plan_get_current_block();
if (current_block != NULL) {
current_block->busy = true;
trapezoid_generator_reset();
counter_x = -(current_block->step_event_count >> 1);
counter_y = counter_x;
+48 -40
View File
@@ -96,17 +96,6 @@ static unsigned long previous_millis_bed_heater;
static int maxttemp[EXTRUDERS] = { 16383 }; // the first value used for all
static int bed_minttemp = 0;
static int bed_maxttemp = 16383;
static int heater_pin_map[EXTRUDERS] = { HEATER_0_PIN
#if EXTRUDERS > 1
, HEATER_1_PIN
#endif
#if EXTRUDERS > 2
, HEATER_2_PIN
#endif
#if EXTRUDERS > 3
#error Unsupported number of extruders
#endif
};
static void *heater_ttbl_map[EXTRUDERS] = { (void *)heater_0_temptable
#if EXTRUDERS > 1
, (void *)heater_1_temptable
@@ -139,7 +128,6 @@ void PID_autotune(float temp)
float input;
int cycles=0;
bool heating = true;
soft_pwm[0] = 255>>1;
unsigned long temp_millis = millis();
unsigned long t1=temp_millis;
@@ -147,14 +135,18 @@ void PID_autotune(float temp)
long t_high;
long t_low;
long bias=127;
long d = 127;
long bias=PID_MAX/2;
long d = PID_MAX/2;
float Ku, Tu;
float Kp, Ki, Kd;
float max, min;
SERIAL_ECHOLN("PID Autotune start");
disable_heater(); // switch off all heaters.
soft_pwm[0] = PID_MAX/2;
for(;;) {
if(temp_meas_ready == true) { // temp sample ready
@@ -181,8 +173,8 @@ void PID_autotune(float temp)
t_low=t2 - t1;
if(cycles > 0) {
bias += (d*(t_high - t_low))/(t_low + t_high);
bias = constrain(bias, 20 ,235);
if(bias > 127) d = 254 - bias;
bias = constrain(bias, 20 ,PID_MAX-FULL_PID_BAND);
if(bias > PID_MAX/2) d = PID_MAX - 1 - bias;
else d = bias;
SERIAL_PROTOCOLPGM(" bias: "); SERIAL_PROTOCOL(bias);
@@ -201,6 +193,7 @@ void PID_autotune(float temp)
SERIAL_PROTOCOLPGM(" Kp: "); SERIAL_PROTOCOLLN(Kp);
SERIAL_PROTOCOLPGM(" Ki: "); SERIAL_PROTOCOLLN(Ki);
SERIAL_PROTOCOLPGM(" Kd: "); SERIAL_PROTOCOLLN(Kd);
/*
Kp = 0.33*Ku;
Ki = Kp/Tu;
Kd = Kp*Tu/3;
@@ -215,6 +208,7 @@ void PID_autotune(float temp)
SERIAL_PROTOCOLPGM(" Kp: "); SERIAL_PROTOCOLLN(Kp);
SERIAL_PROTOCOLPGM(" Ki: "); SERIAL_PROTOCOLLN(Ki);
SERIAL_PROTOCOLPGM(" Kd: "); SERIAL_PROTOCOLLN(Kd);
*/
}
}
soft_pwm[0] = (bias + d) >> 1;
@@ -224,7 +218,7 @@ void PID_autotune(float temp)
}
}
if(input > (temp + 20)) {
SERIAL_PROTOCOLLNPGM("PID Autotune failed !, Temperature to high");
SERIAL_PROTOCOLLNPGM("PID Autotune failed! Temperature to high");
return;
}
if(millis() - temp_millis > 2000) {
@@ -234,6 +228,14 @@ void PID_autotune(float temp)
SERIAL_PROTOCOLPGM(" @:");
SERIAL_PROTOCOLLN(getHeaterPower(0));
}
if(((millis() - t1) + (millis() - t2)) > (10L*60L*1000L*2L)) {
SERIAL_PROTOCOLLNPGM("PID Autotune failed! timeout");
return;
}
if(cycles > 5) {
SERIAL_PROTOCOLLNPGM("PID Autotune finished ! Place the Kp, Ki and Kd constants in the configuration.h");
return;
}
LCD_STATUS;
}
}
@@ -312,11 +314,9 @@ void manage_heater()
// Check if temperature is within the correct range
if((current_raw[e] > minttemp[e]) && (current_raw[e] < maxttemp[e]))
{
//analogWrite(heater_pin_map[e], pid_output);
soft_pwm[e] = (int)pid_output >> 1;
}
else {
//analogWrite(heater_pin_map[e], 0);
soft_pwm[e] = 0;
}
} // End extruder for loop
@@ -705,7 +705,7 @@ void disable_heater()
target_raw[0]=0;
soft_pwm[0]=0;
#if HEATER_0_PIN > -1
digitalWrite(HEATER_0_PIN,LOW);
WRITE(HEATER_0_PIN,LOW);
#endif
#endif
@@ -713,7 +713,7 @@ void disable_heater()
target_raw[1]=0;
soft_pwm[1]=0;
#if HEATER_1_PIN > -1
digitalWrite(HEATER_1_PIN,LOW);
WRITE(HEATER_1_PIN,LOW);
#endif
#endif
@@ -721,36 +721,44 @@ void disable_heater()
target_raw[2]=0;
soft_pwm[2]=0;
#if HEATER_2_PIN > -1
digitalWrite(HEATER_2_PIN,LOW);
WRITE(HEATER_2_PIN,LOW);
#endif
#endif
#if TEMP_BED_PIN > -1
target_raw_bed=0;
#if HEATER_BED_PIN > -1
digitalWrite(HEATER_BED_PIN,LOW);
WRITE(HEATER_BED_PIN,LOW);
#endif
#endif
}
void max_temp_error(uint8_t e) {
digitalWrite(heater_pin_map[e], 0);
SERIAL_ERROR_START;
SERIAL_ERRORLN(e);
SERIAL_ERRORLNPGM(": Extruder switched off. MAXTEMP triggered !");
disable_heater();
if(IsStopped() == false) {
SERIAL_ERROR_START;
SERIAL_ERRORLN((int)e);
SERIAL_ERRORLNPGM(": Extruder switched off. MAXTEMP triggered !");
}
}
void min_temp_error(uint8_t e) {
digitalWrite(heater_pin_map[e], 0);
SERIAL_ERROR_START;
SERIAL_ERRORLN(e);
SERIAL_ERRORLNPGM(": Extruder switched off. MINTEMP triggered !");
disable_heater();
if(IsStopped() == false) {
SERIAL_ERROR_START;
SERIAL_ERRORLN((int)e);
SERIAL_ERRORLNPGM(": Extruder switched off. MINTEMP triggered !");
}
}
void bed_max_temp_error(void) {
digitalWrite(HEATER_BED_PIN, 0);
SERIAL_ERROR_START;
SERIAL_ERRORLNPGM("Temperature heated bed switched off. MAXTEMP triggered !!");
#if HEATER_BED_PIN > -1
WRITE(HEATER_BED_PIN, 0);
#endif
if(IsStopped() == false) {
SERIAL_ERROR_START;
SERIAL_ERRORLNPGM("Temperature heated bed switched off. MAXTEMP triggered !!");
}
}
#define HEAT_INTERVAL 250
@@ -942,14 +950,14 @@ ISR(TIMER0_COMPB_vect)
if(temp_count >= 16) // 8 ms * 16 = 128ms.
{
#ifdef HEATER_0_USES_AD595
#if defined(HEATER_0_USES_AD595) || defined(HEATER_0_USES_MAX6675)
current_raw[0] = raw_temp_0_value;
#else
current_raw[0] = 16383 - raw_temp_0_value;
#endif
#if EXTRUDERS > 1
#ifdef HEATER_1_USES_AD595 || defined HEATER_0_USES_MAX6675
#ifdef HEATER_1_USES_AD595
current_raw[1] = raw_temp_1_value;
#else
current_raw[1] = 16383 - raw_temp_1_value;
@@ -983,7 +991,7 @@ ISR(TIMER0_COMPB_vect)
max_temp_error(e);
#ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
{
kill();;
Stop();;
}
#endif
}
@@ -992,7 +1000,7 @@ ISR(TIMER0_COMPB_vect)
min_temp_error(e);
#ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
{
kill();
Stop();
}
#endif
}
@@ -1002,7 +1010,7 @@ ISR(TIMER0_COMPB_vect)
if(current_raw_bed >= bed_maxttemp) {
target_raw_bed = 0;
bed_max_temp_error();
kill();
Stop();
}
#endif
}
+4
View File
@@ -130,6 +130,8 @@ FORCE_INLINE bool isCoolingBed() {
#define setTargetHotend1(_celsius) setTargetHotend((_celsius), 1)
#define isHeatingHotend1() isHeatingHotend(1)
#define isCoolingHotend1() isCoolingHotend(1)
#else
#define setTargetHotend1(_celsius) do{}while(0)
#endif
#if EXTRUDERS > 2
#define degHotend2() degHotend(2)
@@ -137,6 +139,8 @@ FORCE_INLINE bool isCoolingBed() {
#define setTargetHotend2(_celsius) setTargetHotend((_celsius), 2)
#define isHeatingHotend2() isHeatingHotend(2)
#define isCoolingHotend2() isCoolingHotend(2)
#else
#define setTargetHotend2(_celsius) do{}while(0)
#endif
#if EXTRUDERS > 3
#error Invalid number of extruders
+75 -85
View File
@@ -73,27 +73,41 @@ const short temptable_1[][2] PROGMEM = {
#endif
#if (THERMISTORHEATER_0 == 2) || (THERMISTORHEATER_1 == 2) || (THERMISTORHEATER_2 == 2) || (THERMISTORBED == 2) //200k bed thermistor
const short temptable_2[][2] PROGMEM = {
//200k ATC Semitec 204GT-2
//Verified by linagee. Source: http://shop.arcol.hu/static/datasheets/thermistors.pdf
// Calculated using 4.7kohm pullup, voltage divider math, and manufacturer provided temp/resistance
{1*OVERSAMPLENR, 848},
{54*OVERSAMPLENR, 275},
{107*OVERSAMPLENR, 228},
{160*OVERSAMPLENR, 202},
{213*OVERSAMPLENR, 185},
{266*OVERSAMPLENR, 171},
{319*OVERSAMPLENR, 160},
{372*OVERSAMPLENR, 150},
{425*OVERSAMPLENR, 141},
{478*OVERSAMPLENR, 133},
{531*OVERSAMPLENR, 125},
{584*OVERSAMPLENR, 118},
{637*OVERSAMPLENR, 110},
{690*OVERSAMPLENR, 103},
{743*OVERSAMPLENR, 95},
{796*OVERSAMPLENR, 86},
{849*OVERSAMPLENR, 77},
{902*OVERSAMPLENR, 65},
{955*OVERSAMPLENR, 49},
{1008*OVERSAMPLENR, 17},
{1020*OVERSAMPLENR, 0} //safety
{30*OVERSAMPLENR, 300}, //top rating 300C
{34*OVERSAMPLENR, 290},
{39*OVERSAMPLENR, 280},
{46*OVERSAMPLENR, 270},
{53*OVERSAMPLENR, 260},
{63*OVERSAMPLENR, 250},
{74*OVERSAMPLENR, 240},
{87*OVERSAMPLENR, 230},
{104*OVERSAMPLENR, 220},
{124*OVERSAMPLENR, 210},
{148*OVERSAMPLENR, 200},
{176*OVERSAMPLENR, 190},
{211*OVERSAMPLENR, 180},
{252*OVERSAMPLENR, 170},
{301*OVERSAMPLENR, 160},
{357*OVERSAMPLENR, 150},
{420*OVERSAMPLENR, 140},
{489*OVERSAMPLENR, 130},
{562*OVERSAMPLENR, 120},
{636*OVERSAMPLENR, 110},
{708*OVERSAMPLENR, 100},
{775*OVERSAMPLENR, 90},
{835*OVERSAMPLENR, 80},
{884*OVERSAMPLENR, 70},
{924*OVERSAMPLENR, 60},
{955*OVERSAMPLENR, 50},
{977*OVERSAMPLENR, 40},
{993*OVERSAMPLENR, 30},
{1004*OVERSAMPLENR, 20},
{1012*OVERSAMPLENR, 10},
{1016*OVERSAMPLENR, 0},
};
#endif
@@ -157,73 +171,48 @@ const short temptable_4[][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},
{52*OVERSAMPLENR, 239},
{69*OVERSAMPLENR, 221},
{86*OVERSAMPLENR, 208},
{103*OVERSAMPLENR, 197},
{120*OVERSAMPLENR, 188},
{137*OVERSAMPLENR, 181},
{154*OVERSAMPLENR, 174},
{171*OVERSAMPLENR, 169},
{188*OVERSAMPLENR, 163},
{205*OVERSAMPLENR, 159},
{222*OVERSAMPLENR, 154},
{239*OVERSAMPLENR, 150},
{256*OVERSAMPLENR, 147},
{273*OVERSAMPLENR, 143},
{290*OVERSAMPLENR, 140},
{307*OVERSAMPLENR, 136},
{324*OVERSAMPLENR, 133},
{341*OVERSAMPLENR, 130},
{358*OVERSAMPLENR, 128},
{375*OVERSAMPLENR, 125},
{392*OVERSAMPLENR, 122},
{409*OVERSAMPLENR, 120},
{426*OVERSAMPLENR, 117},
{443*OVERSAMPLENR, 115},
{460*OVERSAMPLENR, 112},
{477*OVERSAMPLENR, 110},
{494*OVERSAMPLENR, 108},
{511*OVERSAMPLENR, 106},
{528*OVERSAMPLENR, 103},
{545*OVERSAMPLENR, 101},
{562*OVERSAMPLENR, 99},
{579*OVERSAMPLENR, 97},
{596*OVERSAMPLENR, 95},
{613*OVERSAMPLENR, 92},
{630*OVERSAMPLENR, 90},
{647*OVERSAMPLENR, 88},
{664*OVERSAMPLENR, 86},
{681*OVERSAMPLENR, 84},
{698*OVERSAMPLENR, 81},
{715*OVERSAMPLENR, 79},
{732*OVERSAMPLENR, 77},
{749*OVERSAMPLENR, 75},
{766*OVERSAMPLENR, 72},
{783*OVERSAMPLENR, 70},
{800*OVERSAMPLENR, 67},
{817*OVERSAMPLENR, 64},
{834*OVERSAMPLENR, 61},
{851*OVERSAMPLENR, 58},
{868*OVERSAMPLENR, 55},
{885*OVERSAMPLENR, 52},
{902*OVERSAMPLENR, 48},
{919*OVERSAMPLENR, 44},
{936*OVERSAMPLENR, 40},
{953*OVERSAMPLENR, 34},
{970*OVERSAMPLENR, 28},
{987*OVERSAMPLENR, 20},
{1004*OVERSAMPLENR, 8},
{1021*OVERSAMPLENR, 0}
// ATC Semitec 104GT-2 (Used in ParCan)
// Verified by linagee. Source: http://shop.arcol.hu/static/datasheets/thermistors.pdf
// Calculated using 4.7kohm pullup, voltage divider math, and manufacturer provided temp/resistance
{1*OVERSAMPLENR, 713},
{17*OVERSAMPLENR, 300}, //top rating 300C
{20*OVERSAMPLENR, 290},
{23*OVERSAMPLENR, 280},
{27*OVERSAMPLENR, 270},
{31*OVERSAMPLENR, 260},
{37*OVERSAMPLENR, 250},
{43*OVERSAMPLENR, 240},
{51*OVERSAMPLENR, 230},
{61*OVERSAMPLENR, 220},
{73*OVERSAMPLENR, 210},
{87*OVERSAMPLENR, 200},
{106*OVERSAMPLENR, 190},
{128*OVERSAMPLENR, 180},
{155*OVERSAMPLENR, 170},
{189*OVERSAMPLENR, 160},
{230*OVERSAMPLENR, 150},
{278*OVERSAMPLENR, 140},
{336*OVERSAMPLENR, 130},
{402*OVERSAMPLENR, 120},
{476*OVERSAMPLENR, 110},
{554*OVERSAMPLENR, 100},
{635*OVERSAMPLENR, 90},
{713*OVERSAMPLENR, 80},
{784*OVERSAMPLENR, 70},
{846*OVERSAMPLENR, 60},
{897*OVERSAMPLENR, 50},
{937*OVERSAMPLENR, 40},
{966*OVERSAMPLENR, 30},
{986*OVERSAMPLENR, 20},
{1000*OVERSAMPLENR, 10},
{1010*OVERSAMPLENR, 0}
};
#endif
#if (THERMISTORHEATER_0 == 6) || (THERMISTORHEATER_1 == 6) || (THERMISTORHEATER_2 == 6) || (THERMISTORBED == 6) // 100k Epcos thermistor
const short temptable_6[][2] PROGMEM = {
{28*OVERSAMPLENR, 250},
{1*OVERSAMPLENR, 350},
{28*OVERSAMPLENR, 250}, //top rating 250C
{31*OVERSAMPLENR, 245},
{35*OVERSAMPLENR, 240},
{39*OVERSAMPLENR, 235},
@@ -232,8 +221,8 @@ const short temptable_6[][2] PROGMEM = {
{49*OVERSAMPLENR, 220},
{53*OVERSAMPLENR, 215},
{62*OVERSAMPLENR, 210},
{73*OVERSAMPLENR, 205},
{72*OVERSAMPLENR, 200},
{71*OVERSAMPLENR, 205}, //fitted graphically
{78*OVERSAMPLENR, 200}, //fitted graphically
{94*OVERSAMPLENR, 190},
{102*OVERSAMPLENR, 185},
{116*OVERSAMPLENR, 170},
@@ -264,7 +253,8 @@ const short temptable_6[][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},
{1*OVERSAMPLENR, 500},
{46*OVERSAMPLENR, 270}, //top rating 300C
{50*OVERSAMPLENR, 265},
{54*OVERSAMPLENR, 260},
{58*OVERSAMPLENR, 255},
+11 -7
View File
@@ -1,5 +1,5 @@
#ifndef __ULTRALCDH
#define __ULTRALCDH
#ifndef ULTRALCD_H
#define ULTRALCD_H
#include "Marlin.h"
#ifdef ULTRA_LCD
#include <LiquidCrystal.h>
@@ -7,11 +7,13 @@
void lcd_init();
void lcd_status(const char* message);
void beep();
void buttons_init();
void buttons_check();
#define LCD_UPDATE_INTERVAL 100
#define STATUSTIMEOUT 15000
extern LiquidCrystal lcd;
extern volatile char buttons; //the last checked buttons in a bit array.
#ifdef NEWPANEL
#define EN_C (1<<BLEN_C)
@@ -49,7 +51,7 @@
#define blocktime 500
#define lcdslow 5
enum MainStatus{Main_Status, Main_Menu, Main_Prepare,Sub_PrepareMove, Main_Control, Main_SD,Sub_TempControl,Sub_MotionControl};
enum MainStatus{Main_Status, Main_Menu, Main_Prepare,Sub_PrepareMove, Main_Control, Main_SD,Sub_TempControl,Sub_MotionControl,Sub_RetractControl};
class MainMenu{
public:
@@ -66,10 +68,11 @@
void showControl();
void showControlMotion();
void showControlTemp();
void showControlRetract();
void showAxisMove();
void showSD();
bool force_lcd_update;
int lastencoderpos;
long lastencoderpos;
int8_t lineoffset;
int8_t lastlineoffset;
@@ -78,11 +81,11 @@
bool tune;
private:
FORCE_INLINE void updateActiveLines(const uint8_t &maxlines,volatile int &encoderpos)
FORCE_INLINE void updateActiveLines(const uint8_t &maxlines,volatile long &encoderpos)
{
if(linechanging) return; // an item is changint its value, do not switch lines hence
lastlineoffset=lineoffset;
int curencoderpos=encoderpos;
long curencoderpos=encoderpos;
force_lcd_update=false;
if( (abs(curencoderpos-lastencoderpos)<lcdslow) )
{
@@ -134,11 +137,12 @@
char *ftostr3(const float &x);
#define LCD_INIT lcd_init();
#define LCD_MESSAGE(x) lcd_status(x);
#define LCD_MESSAGEPGM(x) lcd_statuspgm(MYPGM(x));
#define LCD_STATUS lcd_status()
#else //no lcd
#define LCD_INIT
#define LCD_STATUS
#define LCD_MESSAGE(x)
#define LCD_MESSAGEPGM(x)
+426 -65
View File
@@ -1,6 +1,11 @@
#include "language.h"
#include "temperature.h"
#include "ultralcd.h"
#ifdef ULTRA_LCD
#include "Marlin.h"
#include "language.h"
#include "temperature.h"
#include "EEPROMwrite.h"
#include <LiquidCrystal.h>
//===========================================================================
//=============================imported variables============================
@@ -13,6 +18,7 @@ extern volatile int extrudemultiply;
extern long position[4];
#ifdef SDSUPPORT
#include "cardreader.h"
extern CardReader card;
#endif
@@ -20,7 +26,7 @@ extern CardReader card;
//=============================public variables============================
//===========================================================================
volatile char buttons=0; //the last checked buttons in a bit array.
int encoderpos=0;
long encoderpos=0;
short lastenc=0;
@@ -95,6 +101,10 @@ FORCE_INLINE void clear()
void lcd_init()
{
//beep();
#ifdef ULTIPANEL
buttons_init();
#endif
byte Degree[8] =
{
B01100,
@@ -301,10 +311,6 @@ MainMenu::MainMenu()
displayStartingRow=0;
activeline=0;
force_lcd_update=true;
#ifdef ULTIPANEL
buttons_init();
#endif
lcd_init();
linechanging=false;
tune=false;
}
@@ -322,6 +328,8 @@ void MainMenu::showStatus()
lcd.setCursor(0,0);lcdprintPGM("\002---/---\001 ");
#if defined BED_USES_THERMISTOR || defined BED_USES_AD595
lcd.setCursor(10,0);lcdprintPGM("B---/---\001 ");
#elif EXTRUDERS > 1
lcd.setCursor(10,0);lcdprintPGM("\002---/---\001 ");
#endif
}
@@ -356,6 +364,23 @@ void MainMenu::showStatus()
lcd.print(ftostr3(targetBed));
oldtargetBed=targetBed;
}
#elif EXTRUDERS > 1
static int olddegHotEnd1=-1;
static int oldtargetHotEnd1=-1;
int tHotEnd1=intround(degHotend1());
if((tHotEnd1!=olddegHotEnd1)||force_lcd_update)
{
lcd.setCursor(11,0);
lcd.print(ftostr3(tHotEnd1));
olddegHotEnd1=tHotEnd1;
}
int ttHotEnd1=intround(degTargetHotend1());
if((ttHotEnd1!=oldtargetHotEnd1)||force_lcd_update)
{
lcd.setCursor(15,0);
lcd.print(ftostr3(ttHotEnd1));
oldtargetHotEnd1=ttHotEnd1;
}
#endif
//starttime=2;
static uint16_t oldtime=0;
@@ -430,10 +455,7 @@ void MainMenu::showStatus()
if(force_lcd_update) //initial display of content
{
encoderpos=feedmultiply;
lcd.setCursor(0,0);lcdprintPGM("\002123/567\001 ");
#if defined BED_USES_THERMISTOR || defined BED_USES_AD595
lcd.setCursor(10,0);lcdprintPGM("B123/567\001 ");
#endif
lcd.setCursor(0,0);lcdprintPGM("\002---/---\001 ");
}
int tHotEnd0=intround(degHotend0());
@@ -520,7 +542,7 @@ void MainMenu::showPrepare()
beepshort(); );
break;
case ItemP_cooldown:
MENUITEM( lcdprintPGM(MSG_COOLDOWN) , BLOCK;setTargetHotend0(0);setTargetBed(0);beepshort(); ) ;
MENUITEM( lcdprintPGM(MSG_COOLDOWN) , BLOCK;setTargetHotend0(0);setTargetHotend1(0);setTargetHotend2(0);setTargetBed(0);beepshort(); ) ;
break;
// case ItemP_extrude:
// MENUITEM( lcdprintPGM(" Extrude") , BLOCK;enquecommand("G92 E0");enquecommand("G1 F700 E50");beepshort(); ) ;
@@ -691,6 +713,7 @@ void MainMenu::showAxisMove()
}
break;
case ItemAM_E:
// ErikDB: TODO: this length should be changed for volumetric.
MENUITEM( lcdprintPGM(MSG_EXTRUDE) , BLOCK;enquecommand("G92 E0");enquecommand("G1 F700 E5");beepshort(); ) ;
break;
default:
@@ -864,7 +887,7 @@ void MainMenu::showTune()
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_FLOW);
lcd.setCursor(13,line);lcd.print(itostr4(axis_steps_per_unit[3]));
lcd.setCursor(13,line);lcd.print(ftostr52(axis_steps_per_unit[E_AXIS]));
}
if((activeline!=line) )
@@ -875,14 +898,14 @@ void MainMenu::showTune()
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)axis_steps_per_unit[3];
encoderpos=(long)(axis_steps_per_unit[E_AXIS]*100.0);
}
else
{
float factor=float(encoderpos)/float(axis_steps_per_unit[3]);
float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[E_AXIS]);
position[E_AXIS]=lround(position[E_AXIS]*factor);
//current_position[3]*=factor;
axis_steps_per_unit[E_AXIS]= encoderpos;
//current_position[E_AXIS]*=factor;
axis_steps_per_unit[E_AXIS]= encoderpos/100.0;
encoderpos=activeline*lcdslow;
}
@@ -892,8 +915,8 @@ void MainMenu::showTune()
if(linechanging)
{
if(encoderpos<5) encoderpos=5;
if(encoderpos>9999) encoderpos=9999;
lcd.setCursor(13,line);lcd.print(itostr4(encoderpos));
if(encoderpos>999999) encoderpos=999999;
lcd.setCursor(13,line);lcd.print(ftostr52(encoderpos/100.0));
}
}break;
@@ -923,12 +946,18 @@ void MainMenu::showTune()
//
enum {
ItemCT_exit,ItemCT_nozzle,
ItemCT_exit,ItemCT_nozzle0,
#ifdef AUTOTEMP
ItemCT_autotempactive,
ItemCT_autotempmin,ItemCT_autotempmax,ItemCT_autotempfact,
#endif
#if (HEATER_BED_PIN > -1)
#if EXTRUDERS > 1
ItemCT_nozzle1,
#endif
#if EXTRUDERS > 2
ItemCT_nozzle2,
#endif
#if defined BED_USES_THERMISTOR || BED_USES_AD595
ItemCT_bed,
#endif
ItemCT_fan,
@@ -946,7 +975,7 @@ void MainMenu::showControlTemp()
case ItemCT_exit:
MENUITEM( lcdprintPGM(MSG_CONTROL) , BLOCK;status=Main_Control;beepshort(); ) ;
break;
case ItemCT_nozzle:
case ItemCT_nozzle0:
{
if(force_lcd_update)
{
@@ -980,8 +1009,80 @@ void MainMenu::showControlTemp()
}
}break;
#ifdef AUTOTEMP
case ItemCT_autotempmin:
#if EXTRUDERS > 1
case ItemCT_nozzle1:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_NOZZLE1);
lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetHotend1())));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=intround(degTargetHotend1());
}
else
{
setTargetHotend1(encoderpos);
encoderpos=activeline*lcdslow;
beepshort();
}
BLOCK;
}
if(linechanging)
{
if(encoderpos<0) encoderpos=0;
if(encoderpos>260) encoderpos=260;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
}
}break;
#endif
#if EXTRUDERS > 2
case ItemCT_nozzle2:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_NOZZLE2);
lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetHotend2())));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=intround(degTargetHotend2());
}
else
{
setTargetHotend1(encoderpos);
encoderpos=activeline*lcdslow;
beepshort();
}
BLOCK;
}
if(linechanging)
{
if(encoderpos<0) encoderpos=0;
if(encoderpos>260) encoderpos=260;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
}
}break;
#endif
#ifdef AUTOTEMP
case ItemCT_autotempmin:
{
if(force_lcd_update)
{
@@ -1015,7 +1116,7 @@ void MainMenu::showControlTemp()
}
}break;
case ItemCT_autotempmax:
case ItemCT_autotempmax:
{
if(force_lcd_update)
{
@@ -1049,7 +1150,7 @@ void MainMenu::showControlTemp()
}
}break;
case ItemCT_autotempfact:
case ItemCT_autotempfact:
{
if(force_lcd_update)
{
@@ -1083,7 +1184,7 @@ void MainMenu::showControlTemp()
}
}break;
case ItemCT_autotempactive:
case ItemCT_autotempactive:
{
if(force_lcd_update)
{
@@ -1110,9 +1211,9 @@ void MainMenu::showControlTemp()
}
}break;
#endif //autotemp
#if (HEATER_BED_PIN > -1)
case ItemCT_bed:
#endif //autotemp
#if defined BED_USES_THERMISTOR || BED_USES_AD595
case ItemCT_bed:
{
if(force_lcd_update)
{
@@ -1145,8 +1246,8 @@ void MainMenu::showControlTemp()
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
}
}break;
#endif
case ItemCT_fan:
#endif
case ItemCT_fan:
{
if(force_lcd_update)
{
@@ -1181,7 +1282,8 @@ void MainMenu::showControlTemp()
}
}break;
case ItemCT_PID_P:
#ifdef PIDTEMP
case ItemCT_PID_P:
{
if(force_lcd_update)
{
@@ -1197,7 +1299,7 @@ void MainMenu::showControlTemp()
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)Kp;
encoderpos=(long)Kp;
}
else
{
@@ -1232,7 +1334,7 @@ void MainMenu::showControlTemp()
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)(Ki*10/PID_dT);
encoderpos=(long)(Ki*10/PID_dT);
}
else
{
@@ -1251,7 +1353,7 @@ void MainMenu::showControlTemp()
}
}break;
case ItemCT_PID_D:
case ItemCT_PID_D:
{
if(force_lcd_update)
{
@@ -1268,7 +1370,7 @@ void MainMenu::showControlTemp()
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)(Kd/5./PID_dT);
encoderpos=(long)(Kd/5./PID_dT);
}
else
{
@@ -1304,7 +1406,7 @@ void MainMenu::showControlTemp()
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)Kc;
encoderpos=(long)Kc;
}
else
{
@@ -1324,6 +1426,7 @@ void MainMenu::showControlTemp()
}
#endif
#endif
break;
default:
break;
@@ -1376,7 +1479,7 @@ void MainMenu::showControlMotion()
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)acceleration/100;
encoderpos=(long)acceleration/100;
}
else
{
@@ -1410,7 +1513,7 @@ void MainMenu::showControlMotion()
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)max_xy_jerk;
encoderpos=(long)max_xy_jerk;
}
else
{
@@ -1453,7 +1556,7 @@ void MainMenu::showControlMotion()
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)max_feedrate[i-ItemCM_vmaxx];
encoderpos=(long)max_feedrate[i-ItemCM_vmaxx];
}
else
{
@@ -1489,7 +1592,7 @@ void MainMenu::showControlMotion()
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)(minimumfeedrate);
encoderpos=(long)(minimumfeedrate);
}
else
{
@@ -1524,7 +1627,7 @@ void MainMenu::showControlMotion()
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)mintravelfeedrate;
encoderpos=(long)mintravelfeedrate;
}
else
{
@@ -1567,7 +1670,7 @@ void MainMenu::showControlMotion()
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)max_acceleration_units_per_sq_second[i-ItemCM_amaxx]/100;
encoderpos=(long)max_acceleration_units_per_sq_second[i-ItemCM_amaxx]/100;
}
else
{
@@ -1585,6 +1688,8 @@ void MainMenu::showControlMotion()
}
}break;
case ItemCM_aret://float retract_acceleration = 7000;
{
if(force_lcd_update)
@@ -1601,7 +1706,7 @@ void MainMenu::showControlMotion()
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)retract_acceleration/100;
encoderpos=(long)retract_acceleration/100;
}
else
{
@@ -1625,7 +1730,7 @@ void MainMenu::showControlMotion()
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_XSTEPS);
lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[0]));
lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[X_AXIS]));
}
if((activeline!=line) )
@@ -1636,13 +1741,13 @@ void MainMenu::showControlMotion()
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)(axis_steps_per_unit[0]*100.0);
encoderpos=(long)(axis_steps_per_unit[X_AXIS]*100.0);
}
else
{
float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[0]);
float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[X_AXIS]);
position[X_AXIS]=lround(position[X_AXIS]*factor);
//current_position[3]*=factor;
//current_position[X_AXIS]*=factor;
axis_steps_per_unit[X_AXIS]= encoderpos/100.0;
encoderpos=activeline*lcdslow;
}
@@ -1652,7 +1757,7 @@ void MainMenu::showControlMotion()
if(linechanging)
{
if(encoderpos<5) encoderpos=5;
if(encoderpos>32000) encoderpos=32000;//TODO: This is a problem, encoderpos is 16bit, but steps_per_unit for e can be wel over 800
if(encoderpos>999999) encoderpos=999999;
lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
}
@@ -1662,7 +1767,7 @@ void MainMenu::showControlMotion()
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_YSTEPS);
lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[1]));
lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[Y_AXIS]));
}
if((activeline!=line) )
@@ -1673,13 +1778,13 @@ void MainMenu::showControlMotion()
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)(axis_steps_per_unit[1]*100.0);
encoderpos=(long)(axis_steps_per_unit[Y_AXIS]*100.0);
}
else
{
float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[1]);
float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[Y_AXIS]);
position[Y_AXIS]=lround(position[Y_AXIS]*factor);
//current_position[3]*=factor;
//current_position[Y_AXIS]*=factor;
axis_steps_per_unit[Y_AXIS]= encoderpos/100.0;
encoderpos=activeline*lcdslow;
@@ -1690,7 +1795,7 @@ void MainMenu::showControlMotion()
if(linechanging)
{
if(encoderpos<5) encoderpos=5;
if(encoderpos>9999) encoderpos=9999;
if(encoderpos>999999) encoderpos=999999;
lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
}
@@ -1700,7 +1805,7 @@ void MainMenu::showControlMotion()
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_ZSTEPS);
lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[2]));
lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[Z_AXIS]));
}
if((activeline!=line) )
@@ -1711,13 +1816,13 @@ void MainMenu::showControlMotion()
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)(axis_steps_per_unit[2]*100.0);
encoderpos=(long)(axis_steps_per_unit[Z_AXIS]*100.0);
}
else
{
float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[2]);
float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[Z_AXIS]);
position[Z_AXIS]=lround(position[Z_AXIS]*factor);
//current_position[3]*=factor;
//current_position[Z_AXIS]*=factor;
axis_steps_per_unit[Z_AXIS]= encoderpos/100.0;
encoderpos=activeline*lcdslow;
@@ -1728,7 +1833,7 @@ void MainMenu::showControlMotion()
if(linechanging)
{
if(encoderpos<5) encoderpos=5;
if(encoderpos>9999) encoderpos=9999;
if(encoderpos>999999) encoderpos=999999;
lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
}
@@ -1739,7 +1844,7 @@ void MainMenu::showControlMotion()
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_ESTEPS);
lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[3]));
lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[E_AXIS]));
}
if((activeline!=line) )
@@ -1750,13 +1855,13 @@ void MainMenu::showControlMotion()
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(int)(axis_steps_per_unit[3]*100.0);
encoderpos=(long)(axis_steps_per_unit[E_AXIS]*100.0);
}
else
{
float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[3]);
float factor=float(encoderpos)/100.0/float(axis_steps_per_unit[E_AXIS]);
position[E_AXIS]=lround(position[E_AXIS]*factor);
//current_position[3]*=factor;
//current_position[E_AXIS]*=factor;
axis_steps_per_unit[E_AXIS]= encoderpos/100.0;
encoderpos=activeline*lcdslow;
@@ -1767,7 +1872,7 @@ void MainMenu::showControlMotion()
if(linechanging)
{
if(encoderpos<5) encoderpos=5;
if(encoderpos>9999) encoderpos=9999;
if(encoderpos>999999) encoderpos=999999;
lcd.setCursor(11,line);lcd.print(ftostr52(encoderpos/100.0));
}
@@ -1781,8 +1886,252 @@ void MainMenu::showControlMotion()
}
enum {
ItemR_exit,
ItemR_autoretract,
ItemR_retract_length,ItemR_retract_feedrate,ItemR_retract_zlift,
ItemR_unretract_length,ItemR_unretract_feedrate,
};
void MainMenu::showControlRetract()
{
#ifdef FWRETRACT
uint8_t line=0;
clearIfNecessary();
for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
{
switch(i)
{
case ItemR_exit:
MENUITEM( lcdprintPGM(MSG_CONTROL) , BLOCK;status=Main_Control;beepshort(); ) ;
break;
//float retract_length=2, retract_feedrate=1200, retract_zlift=0.4;
//float retract_recover_length=0, retract_recover_feedrate=500;
case ItemR_autoretract:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_AUTORETRACT);
lcd.setCursor(13,line);
if(autoretract_enabled)
lcdprintPGM(MSG_ON);
else
lcdprintPGM(MSG_OFF);
}
if((activeline!=line) )
break;
if(CLICKED)
{
autoretract_enabled=!autoretract_enabled;
lcd.setCursor(13,line);
if(autoretract_enabled)
lcdprintPGM(MSG_ON);
else
lcdprintPGM(MSG_OFF);
BLOCK;
}
}break;
case ItemR_retract_length:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_CONTROL_RETRACT);
lcd.setCursor(13,line);lcd.print(ftostr52(retract_length));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(long)(retract_length*100);
}
else
{
retract_length= encoderpos/100.;
encoderpos=activeline*lcdslow;
}
BLOCK;
beepshort();
}
if(linechanging)
{
if(encoderpos<1) encoderpos=1;
if(encoderpos>990) encoderpos=990;
lcd.setCursor(13,line);lcd.print(ftostr52(encoderpos/100.));
}
}break;
case ItemR_retract_feedrate:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_CONTROL_RETRACTF);
lcd.setCursor(13,line);lcd.print(itostr4(retract_feedrate));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(long)(retract_feedrate/5);
}
else
{
retract_feedrate= encoderpos*5.;
encoderpos=activeline*lcdslow;
}
BLOCK;
beepshort();
}
if(linechanging)
{
if(encoderpos<1) encoderpos=1;
if(encoderpos>990) encoderpos=990;
lcd.setCursor(13,line);lcd.print(itostr4(encoderpos*5));
}
}break;
case ItemR_retract_zlift://float retract_acceleration = 7000;
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_CONTROL_RETRACT_ZLIFT);
lcd.setCursor(13,line);lcd.print(ftostr52(retract_zlift));;
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(long)(retract_zlift*10);
}
else
{
retract_zlift= encoderpos/10.;
encoderpos=activeline*lcdslow;
}
BLOCK;
beepshort();
}
if(linechanging)
{
if(encoderpos<0) encoderpos=0;
if(encoderpos>990) encoderpos=990;
lcd.setCursor(13,line);lcd.print(ftostr52(encoderpos/10.));
}
}break;
case ItemR_unretract_length:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_CONTROL_RETRACT_RECOVER);
lcd.setCursor(13,line);lcd.print(ftostr52(retract_recover_length));;
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(long)(retract_recover_length*100);
}
else
{
retract_recover_length= encoderpos/100.;
encoderpos=activeline*lcdslow;
}
BLOCK;
beepshort();
}
if(linechanging)
{
if(encoderpos<0) encoderpos=0;
if(encoderpos>990) encoderpos=990;
lcd.setCursor(13,line);lcd.print(ftostr52(encoderpos/100.));
}
}break;
case ItemR_unretract_feedrate:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_CONTROL_RETRACT_RECOVERF);
lcd.setCursor(13,line);lcd.print(itostr4(retract_recover_feedrate));
}
if((activeline!=line) )
break;
if(CLICKED)
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=(long)retract_recover_feedrate/5;
}
else
{
retract_recover_feedrate= encoderpos*5.;
encoderpos=activeline*lcdslow;
}
BLOCK;
beepshort();
}
if(linechanging)
{
if(encoderpos<1) encoderpos=1;
if(encoderpos>990) encoderpos=990;
lcd.setCursor(13,line);lcd.print(itostr4(encoderpos*5));
}
}break;
default:
break;
}
line++;
}
updateActiveLines(ItemR_unretract_feedrate,encoderpos);
#endif
}
enum {
ItemC_exit,ItemC_temp,ItemC_move,
#ifdef FWRETRACT
ItemC_rectract,
#endif
ItemC_store, ItemC_load,ItemC_failsafe
};
@@ -1803,6 +2152,11 @@ void MainMenu::showControl()
case ItemC_move:
MENUITEM( lcdprintPGM(MSG_MOTION_WIDE) , BLOCK;status=Sub_MotionControl;beepshort(); ) ;
break;
#ifdef FWRETRACT
case ItemC_rectract:
MENUITEM( lcdprintPGM(MSG_RECTRACT_WIDE) , BLOCK;status=Sub_RetractControl;beepshort(); ) ;
break;
#endif
case ItemC_store:
{
if(force_lcd_update)
@@ -2008,9 +2362,10 @@ void MainMenu::showMainMenu()
}
}
clearIfNecessary();
for(int8_t line=0;line<LCD_HEIGHT;line++)
uint8_t line=0;
for(int8_t i=lineoffset;i<lineoffset+LCD_HEIGHT;i++)
{
switch(line)
switch(i)
{
case ItemM_watch:
MENUITEM( lcdprintPGM(MSG_WATCH) , BLOCK;status=Main_Status;beepshort(); ) ;
@@ -2064,6 +2419,7 @@ void MainMenu::showMainMenu()
SERIAL_ERRORLNPGM(MSG_SERIAL_ERROR_MENU_STRUCTURE);
break;
}
line++;
}
updateActiveLines(3,encoderpos);
}
@@ -2078,6 +2434,7 @@ void MainMenu::update()
{
force_lcd_update=true;
oldcardstatus=CARDINSERTED;
lcd_init(); // to maybe revive the lcd if static electricty killed it.
//Serial.println("echo: SD CHANGE");
if(CARDINSERTED)
{
@@ -2144,6 +2501,10 @@ void MainMenu::update()
{
showControlMotion();
}break;
case Sub_RetractControl:
{
showControlRetract();
}break;
case Sub_TempControl:
{
showControlTemp();
+2 -2
View File
@@ -1,5 +1,5 @@
#ifndef __WATCHDOGH
#define __WATCHDOGH
#ifndef WATCHDOG_H
#define WATCHDOG_H
#include "Marlin.h"
#ifdef USE_WATCHDOG