Compare commits

...

15 Commits

Author SHA1 Message Date
daid303 12a4d60e18 Fix the EEPROM storage, no longer inline it at multiple locations, and remove the template. 2012-11-07 10:02:45 +01:00
daid303 5a998558a9 Update suggested by Robert F-C. #289 2012-11-06 21:04:29 +01:00
daid303 f6ff0ab767 signed/unsigned fixes. 2012-11-06 15:33:49 +01:00
daid303 5d471e0f34 Also reset the PID values to defaults. Fixes #281 2012-11-06 15:21:00 +01:00
daid303 d3ebc34958 Hopefully also support chips with a single UART in MarlinSerial now. 2012-11-06 14:43:36 +01:00
daid303 b6ff45254e Better explain the watchdog "problem" and rename the config define so it explains that the feature belongs to the watchdog. 2012-11-06 13:33:00 +01:00
daid303 7e348fcb5f By mistake enabled the watchdog by default. This should be off by default. 2012-11-06 13:20:08 +01:00
daid303 06b58a9c4f First cleanup. Moved all code to cpp files, so there are no dependencies on pde files. And no more odd requirement to cat files together. (Still need to fix the Makefile). Also cleaned up some defines and made defines upper case as by C coding conventions. 2012-11-06 12:06:41 +01:00
daid 539f3b3fe4 Merge pull request #284 from brackendawson/Marlin_v1
Use the right pins for Gen7 1.4
2012-11-06 01:06:24 -08:00
daid 2f20df3f55 Merge pull request #289 from buildrob/Marlin_v1
Marlin v1 configurable serial port
2012-11-06 01:00:50 -08:00
Robert F-C 65c9a0728f Set default serial port back to 0. 2012-11-05 22:15:07 +11:00
Bracken Dawson f5631a89e8 Add dummy Emergancy Pin to Gen7 1.4
Change required after pulling from ErikZalm.
2012-10-26 22:28:37 +01:00
Bracken Dawson a4f9e1ebf2 Merge git://github.com/ErikZalm/Marlin into Marlin_v1 2012-10-26 22:20:35 +01:00
Bracken Dawson 2873d67b17 Put bogus temp override back in Gen7 up to 1.3
Took out the ifdef when I split 1.4 out and forgot to permanently
define it for <=1.3.
2012-10-26 22:17:26 +01:00
Bracken Dawson 47d4f55bc0 Fix Gen7 1.4 pinout
Gen7 1.4 uses very different pin assignments, might as well make a new
section and remove some of the conditionals from each. It's easier to change
your pin assingment this way if like me you don't wire it exactly to plan.
2012-08-22 23:15:46 +01:00
18 changed files with 2285 additions and 2387 deletions
+5 -7
View File
@@ -11,6 +11,11 @@
#define STRING_VERSION_CONFIG_H "2012-05-02" //Personal revision number for changes to THIS file.
#define STRING_CONFIG_H_AUTHOR "erik" //Who made the changes.
// SERIAL_PORT selects which serial port should be used for communication with the host.
// This allows the connection of wireless adapters (for instance) to non-default port pins.
// Serial port 0 is still used by the Arduino bootloader regardless of this setting.
#define SERIAL_PORT 0
// This determines the communication speed of the printer
#define BAUDRATE 250000
//#define BAUDRATE 115200
@@ -331,13 +336,6 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
// SF send wrong arc g-codes when using Arc Point as fillet procedure
//#define SF_ARC_FIX
// SERIAL_PORT selects which serial port should be used for communication with the host.
// This allows the use of wireless adapters (for instance) which are connected to
// non-default serial port pins.
#define SERIAL_PORT 2
#include "Configuration_adv.h"
#include "thermistortables.h"
+24
View File
@@ -0,0 +1,24 @@
#ifndef CONFIG_STORE_H
#define CONFIG_STORE_H
#include "Configuration.h"
#ifdef EEPROM_SETTINGS
void Config_StoreSettings();
void Config_RetrieveSettings();
#else
FORCE_INLINE void Config_StoreSettings() {}
FORCE_INLINE void Config_RetrieveSettings() {}
#endif
#ifdef EEPROM_CHITCHAT
void Config_PrintSettings();
#else
FORCE_INLINE void Config_PrintSettings() {}
#endif
void Config_ResetDefault();
#endif
+10 -10
View File
@@ -179,17 +179,17 @@
#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.
#define SD_FINISHED_RELEASECOMMAND "M84 X Y Z E" // You might want to keep the z enabled so your bed stays in place.
// 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.
// The hardware watchdog should reset the Microcontroller disabling all outputs, in case the firmware gets stuck and doesn't do temperature regulation.
//#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
#ifdef USE_WATCHDOG
// If you have a watchdog reboot in an ArduinoMega2560 then the device will hang forever, as a watchdog reset will leave the watchdog on.
// The "WATCHDOG_RESET_MANUAL" goes around this by not using the hardware reset.
// However, THIS FEATURE IS UNSAFE!, as it will only work if interrupts are disabled. And the code could hang in an interrupt routine with interrupts disabled.
//#define WATCHDOG_RESET_MANUAL
#endif
// extruder advance constant (s2/mm3)
//
@@ -214,7 +214,7 @@
#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
const unsigned int dropsegments=5; //everything with less than this number of steps will be ignored as move and joined with the next movement
// If you are using a RAMPS board or cheap E-bay purchased boards that do not detect when an SD card is inserted
// You can get round this by connecting a push button or single throw switch to the pin defined as SDCARDCARDDETECT
-232
View File
@@ -1,232 +0,0 @@
#ifndef EEPROM_H
#define EEPROM_H
#include "Marlin.h"
#include "planner.h"
#include "temperature.h"
//#include <EEPROM.h>
int plaPreheatHotendTemp;
int plaPreheatHPBTemp;
int plaPreheatFanSpeed;
int absPreheatHotendTemp;
int absPreheatHPBTemp;
int absPreheatFanSpeed;
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_byte((unsigned char *)ee++, *p++);
return i;
}
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_byte((unsigned char *)ee++);
return i;
}
//======================================================================================
#define EEPROM_OFFSET 100
// IMPORTANT: Whenever there are changes made to the variables stored in EEPROM
// in the functions below, also increment the version number. This makes sure that
// the default values are used whenever there is a change to the data, to prevent
// wrong data being written to the variables.
// ALSO: always make sure the variables in the Store and retrieve sections are in the same order.
#define EEPROM_VERSION "V07"
inline void EEPROM_StoreSettings()
{
#ifdef EEPROM_SETTINGS
char ver[4]= "000";
int i=EEPROM_OFFSET;
EEPROM_writeAnything(i,ver); // invalidate data first
EEPROM_writeAnything(i,axis_steps_per_unit);
EEPROM_writeAnything(i,max_feedrate);
EEPROM_writeAnything(i,max_acceleration_units_per_sq_second);
EEPROM_writeAnything(i,acceleration);
EEPROM_writeAnything(i,retract_acceleration);
EEPROM_writeAnything(i,minimumfeedrate);
EEPROM_writeAnything(i,mintravelfeedrate);
EEPROM_writeAnything(i,minsegmenttime);
EEPROM_writeAnything(i,max_xy_jerk);
EEPROM_writeAnything(i,max_z_jerk);
EEPROM_writeAnything(i,max_e_jerk);
EEPROM_writeAnything(i,add_homeing);
EEPROM_writeAnything(i,plaPreheatHotendTemp);
EEPROM_writeAnything(i,plaPreheatHPBTemp);
EEPROM_writeAnything(i,plaPreheatFanSpeed);
EEPROM_writeAnything(i,absPreheatHotendTemp);
EEPROM_writeAnything(i,absPreheatHPBTemp);
EEPROM_writeAnything(i,absPreheatFanSpeed);
#ifdef PIDTEMP
EEPROM_writeAnything(i,Kp);
EEPROM_writeAnything(i,Ki);
EEPROM_writeAnything(i,Kd);
#else
EEPROM_writeAnything(i,3000);
EEPROM_writeAnything(i,0);
EEPROM_writeAnything(i,0);
#endif
char ver2[4]=EEPROM_VERSION;
i=EEPROM_OFFSET;
EEPROM_writeAnything(i,ver2); // validate data
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Settings Stored");
#endif //EEPROM_SETTINGS
}
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_ECHOPAIR(" E" ,max_e_jerk);
SERIAL_ECHOLN("");
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Home offset (mm):");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M206 X",add_homeing[0] );
SERIAL_ECHOPAIR(" Y" ,add_homeing[1] );
SERIAL_ECHOPAIR(" Z" ,add_homeing[2] );
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;
char stored_ver[4];
char ver[4]=EEPROM_VERSION;
EEPROM_readAnything(i,stored_ver); //read stored version
// SERIAL_ECHOLN("Version: [" << ver << "] Stored version: [" << stored_ver << "]");
if ((!def)&&(strncmp(ver,stored_ver,3)==0))
{ // version number match
EEPROM_readAnything(i,axis_steps_per_unit);
EEPROM_readAnything(i,max_feedrate);
EEPROM_readAnything(i,max_acceleration_units_per_sq_second);
EEPROM_readAnything(i,acceleration);
EEPROM_readAnything(i,retract_acceleration);
EEPROM_readAnything(i,minimumfeedrate);
EEPROM_readAnything(i,mintravelfeedrate);
EEPROM_readAnything(i,minsegmenttime);
EEPROM_readAnything(i,max_xy_jerk);
EEPROM_readAnything(i,max_z_jerk);
EEPROM_readAnything(i,max_e_jerk);
EEPROM_readAnything(i,add_homeing);
EEPROM_readAnything(i,plaPreheatHotendTemp);
EEPROM_readAnything(i,plaPreheatHPBTemp);
EEPROM_readAnything(i,plaPreheatFanSpeed);
EEPROM_readAnything(i,absPreheatHotendTemp);
EEPROM_readAnything(i,absPreheatHPBTemp);
EEPROM_readAnything(i,absPreheatFanSpeed);
#ifndef PIDTEMP
float Kp,Ki,Kd;
#endif
EEPROM_readAnything(i,Kp);
EEPROM_readAnything(i,Ki);
EEPROM_readAnything(i,Kd);
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Stored settings retreived:");
}
else
#endif
{
float tmp1[]=DEFAULT_AXIS_STEPS_PER_UNIT;
float tmp2[]=DEFAULT_MAX_FEEDRATE;
long tmp3[]=DEFAULT_MAX_ACCELERATION;
for (short i=0;i<4;i++)
{
axis_steps_per_unit[i]=tmp1[i];
max_feedrate[i]=tmp2[i];
max_acceleration_units_per_sq_second[i]=tmp3[i];
}
acceleration=DEFAULT_ACCELERATION;
retract_acceleration=DEFAULT_RETRACT_ACCELERATION;
minimumfeedrate=DEFAULT_MINIMUMFEEDRATE;
minsegmenttime=DEFAULT_MINSEGMENTTIME;
mintravelfeedrate=DEFAULT_MINTRAVELFEEDRATE;
max_xy_jerk=DEFAULT_XYJERK;
max_z_jerk=DEFAULT_ZJERK;
max_e_jerk=DEFAULT_EJERK;
add_homeing[0] = add_homeing[1] = add_homeing[2] = 0;
SERIAL_ECHO_START;
SERIAL_ECHOLN("Using Default settings:");
#ifdef ULTIPANEL
plaPreheatHotendTemp = PLA_PREHEAT_HOTEND_TEMP;
plaPreheatHPBTemp = PLA_PREHEAT_HPB_TEMP;
plaPreheatFanSpeed = PLA_PREHEAT_FAN_SPEED;
absPreheatHotendTemp = ABS_PREHEAT_HOTEND_TEMP;
absPreheatHPBTemp = ABS_PREHEAT_HPB_TEMP;
absPreheatFanSpeed = ABS_PREHEAT_FAN_SPEED;
#endif
}
#ifdef EEPROM_CHITCHAT
EEPROM_printSettings();
#endif
}
#endif
+1 -2
View File
@@ -1,4 +1,3 @@
#define __PROG_TYPES_COMPAT__
#include "LiquidCrystalRus.h"
#include <stdio.h>
@@ -14,7 +13,7 @@
// it is a russian alphabet translation
// except 0401 --> 0xa2 = ╗, 0451 --> 0xb5
const PROGMEM prog_uchar utf_recode[] =
const PROGMEM uint8_t utf_recode[] =
{ 0x41,0xa0,0x42,0xa1,0xe0,0x45,0xa3,0xa4,0xa5,0xa6,0x4b,0xa7,0x4d,0x48,0x4f,
0xa8,0x50,0x43,0x54,0xa9,0xaa,0x58,0xe1,0xab,0xac,0xe2,0xad,0xae,0x62,0xaf,0xb0,0xb1,
0x61,0xb2,0xb3,0xb4,0xe3,0x65,0xb6,0xb7,0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0x6f,
+6 -16
View File
@@ -17,8 +17,7 @@
#include <util/delay.h>
#include <avr/pgmspace.h>
#include <avr/eeprom.h>
#include <avr/wdt.h>
#include <avr/interrupt.h>
#include <avr/interrupt.h>
#include "fastio.h"
@@ -52,22 +51,11 @@
#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_PROTOCOL_F(x,y) MYSERIAL.print(x,y);
#define SERIAL_PROTOCOLPGM(x) serialprintPGM(MYPGM(x));
#define SERIAL_PROTOCOLPGM(x) serialprintPGM(PSTR(x));
#define SERIAL_PROTOCOLLN(x) {MYSERIAL.print(x);MYSERIAL.write('\n');}
#define SERIAL_PROTOCOLLNPGM(x) {serialprintPGM(MYPGM(x));MYSERIAL.write('\n');}
#define SERIAL_PROTOCOLLNPGM(x) {serialprintPGM(PSTR(x));MYSERIAL.write('\n');}
const char errormagic[] PROGMEM ="Error:";
@@ -92,7 +80,6 @@ void serial_echopair_P(const char *s_P, unsigned long v);
//things to write to serial from Programmemory. saves 400 to 2k of RAM.
#define SerialprintPGM(x) serialprintPGM(MYPGM(x))
FORCE_INLINE void serialprintPGM(const char *str)
{
char ch=pgm_read_byte(str);
@@ -197,6 +184,9 @@ extern float min_pos[3];
extern float max_pos[3];
extern unsigned char FanSpeed;
extern unsigned long starttime;
extern unsigned long stoptime;
// Handling multiple extruders pins
extern uint8_t active_extruder;
+5 -1834
View File
File diff suppressed because it is too large Load Diff
+4
View File
@@ -35,7 +35,11 @@
// These are macros to build serial port register names for the selected SERIAL_PORT (C preprocessor
// requires two levels of indirection to expand macro values properly)
#define SERIAL_REGNAME(registerbase,number,suffix) SERIAL_REGNAME_INTERNAL(registerbase,number,suffix)
#if SERIAL_PORT == 0 && !defined(UBRR0H)
#define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##suffix
#else
#define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##number##suffix
#endif
// Registers used by MarlinSerial class (these are expanded
// depending on selected serial port
File diff suppressed because it is too large Load Diff
+9 -6
View File
@@ -55,13 +55,16 @@ int16_t SdFile::write(const void* buf, uint16_t nbyte) {
* Use writeError to check for errors.
*/
#if ARDUINO >= 100
size_t SdFile::write(uint8_t b)
#else
void SdFile::write(uint8_t b)
#endif
size_t SdFile::write(uint8_t b)
{
SdBaseFile::write(&b, 1);
return SdBaseFile::write(&b, 1);
}
#else
void SdFile::write(uint8_t b)
{
SdBaseFile::write(&b, 1);
}
#endif
//------------------------------------------------------------------------------
/** Write a string to a file. Used by the Arduino Print class.
* \param[in] str Pointer to the string.
@@ -89,4 +92,4 @@ void SdFile::writeln_P(PGM_P str) {
}
#endif
#endif
+78 -9
View File
@@ -45,16 +45,11 @@
#endif /* 99 */
/****************************************************************************************
* Gen7 v1.1, v1.2, v1.3, v1.4 pin assignment
* Gen7 v1.1, v1.2, v1.3 pin assignment
*
****************************************************************************************/
#if MOTHERBOARD == 13
#define MOTHERBOARD 11
#define GEN7_VERSION 14 // v1.4
#endif
#if MOTHERBOARD == 12
#define MOTHERBOARD 11
#define GEN7_VERSION 13 // v1.3
@@ -122,12 +117,86 @@
#endif
#define PS_ON_PIN 15
#if (GEN7_VERSION < 14)
// Gen 1.3 and earlier supplied thermistor power via PS_ON
// Need to ignore the bad thermistor readings on those units
//All these generations of Gen7 supply thermistor power
//via PS_ON, so ignore bad thermistor readings
#define BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
//our pin for debugging.
#define DEBUG_PIN 0
//our RS485 pins
#define TX_ENABLE_PIN 12
#define RX_ENABLE_PIN 13
#endif
/****************************************************************************************
* Gen7 v1.4 pin assignment
*
****************************************************************************************/
#if MOTHERBOARD == 13
#define GEN7_VERSION 14 // v1.4
#endif
#if MOTHERBOARD == 13
#define KNOWN_BOARD
#if !defined(__AVR_ATmega644P__) && !defined(__AVR_ATmega644__) && !defined(__AVR_ATmega1284P__)
#error Oops! Make sure you have 'Gen7' selected from the 'Tools -> Boards' menu.
#endif
#ifndef GEN7_VERSION
#define GEN7_VERSION 14 // v1.x
#endif
//x axis pins
#define X_STEP_PIN 29
#define X_DIR_PIN 28
#define X_ENABLE_PIN 25
#define X_MIN_PIN 0
#define X_MAX_PIN -1
//y axis pins
#define Y_STEP_PIN 27
#define Y_DIR_PIN 26
#define Y_ENABLE_PIN 25
#define Y_MIN_PIN 1
#define Y_MAX_PIN -1
//z axis pins
#define Z_STEP_PIN 23
#define Z_DIR_PIN 22
#define Z_ENABLE_PIN 25
#define Z_MIN_PIN 2
#define Z_MAX_PIN -1
//extruder pins
#define E0_STEP_PIN 19
#define E0_DIR_PIN 18
#define E0_ENABLE_PIN 25
#define TEMP_0_PIN 0
#define TEMP_1_PIN -1
#define TEMP_2_PIN -1
#define TEMP_BED_PIN 1
#define HEATER_0_PIN 4
#define HEATER_1_PIN -1
#define HEATER_2_PIN -1
#define HEATER_BED_PIN 3
#define KILL_PIN -1
#define SDPOWER -1
#define SDSS -1 // SCL pin of I2C header
#define LED_PIN -1
#define FAN_PIN -1
#define PS_ON_PIN 15
//our pin for debugging.
#define DEBUG_PIN 0
+1 -2
View File
@@ -191,8 +191,7 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi
// have to use intersection_distance() to calculate when to abort acceleration and start braking
// in order to reach the final_rate exactly at the end of this block.
if (plateau_steps < 0) {
accelerate_steps = ceil(
intersection_distance(block->initial_rate, block->final_rate, acceleration, block->step_event_count));
accelerate_steps = ceil(intersection_distance(block->initial_rate, block->final_rate, acceleration, block->step_event_count));
accelerate_steps = max(accelerate_steps,0); // Check limits due to numerical round-off
accelerate_steps = min(accelerate_steps,block->step_event_count);
plateau_steps = 0;
+7 -11
View File
@@ -145,20 +145,20 @@ static volatile bool temp_meas_ready = false;
void PID_autotune(float temp, int extruder, int ncycles)
{
float input;
float input = 0.0;
int cycles=0;
bool heating = true;
unsigned long temp_millis = millis();
unsigned long t1=temp_millis;
unsigned long t2=temp_millis;
long t_high;
long t_low;
long t_high = 0;
long t_low = 0;
long bias, d;
float Ku, Tu;
float Kp, Ki, Kd;
float max, min;
float max = 0, min = 10000;
if ((extruder > EXTRUDERS)
#if (TEMP_BED_PIN <= -1)
@@ -315,17 +315,15 @@ int getHeaterPower(int heater) {
void manage_heater()
{
#ifdef USE_WATCHDOG
wd_reset();
#endif
float pid_input;
float pid_output;
if(temp_meas_ready != true) //better readability
return;
//Reset the watchdog after we know we have a temperature measurement.
watchdog_reset();
CRITICAL_SECTION_START;
temp_meas_ready = false;
CRITICAL_SECTION_END;
@@ -548,7 +546,6 @@ int temp2analogBed(int celsius) {
#elif defined BED_USES_AD595
return lround(((celsius-TEMP_SENSOR_AD595_OFFSET)/TEMP_SENSOR_AD595_GAIN) * (1024.0 * OVERSAMPLENR/ (5.0 * 100.0) ) );
#else
#warning No heater-type defined for the bed.
return 0;
#endif
}
@@ -625,7 +622,6 @@ float analog2tempBed(int raw) {
#elif defined BED_USES_AD595
return ((raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR) * TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET;
#else
#warning No heater-type defined for the bed.
return 0;
#endif
}
+162 -158
View File
@@ -5,12 +5,8 @@
#include "Marlin.h"
#include "language.h"
#include "temperature.h"
#include "EEPROMwrite.h"
#if LANGUAGE_CHOICE == 6
#include "LiquidCrystalRus.h"
#else
#include <LiquidCrystal.h>
#endif
#include "ConfigurationStore.h"
//===========================================================================
//=============================imported variables============================
//===========================================================================
@@ -33,6 +29,14 @@ volatile char buttons=0; //the last checked buttons in a bit array.
long encoderpos=0;
short lastenc=0;
//TODO: This should be in a preferences file.
int plaPreheatHotendTemp;
int plaPreheatHPBTemp;
int plaPreheatFanSpeed;
int absPreheatHotendTemp;
int absPreheatHPBTemp;
int absPreheatFanSpeed;
//===========================================================================
//=============================private variables============================
@@ -42,20 +46,16 @@ static char messagetext[LCD_WIDTH]="";
//return for string conversion routines
static char conv[8];
#if LANGUAGE_CHOICE == 6
LiquidCrystalRus lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7); //RS,Enable,D4,D5,D6,D7
#else
LiquidCrystal lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7); //RS,Enable,D4,D5,D6,D7
#endif
LCD_CLASS lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7); //RS,Enable,D4,D5,D6,D7
static unsigned long previous_millis_lcd=0;
//static long previous_millis_buttons=0;
#ifdef NEWPANEL
static long blocking=0;
static unsigned long blocking=0;
#else
static long blocking[8]={0,0,0,0,0,0,0,0};
static unsigned long blocking[8]={0,0,0,0,0,0,0,0};
#endif
static MainMenu menu;
@@ -70,7 +70,7 @@ void lcdProgMemprint(const char *str)
ch=pgm_read_byte(++str);
}
}
#define lcdprintPGM(x) lcdProgMemprint(MYPGM(x))
#define LCD_PRINT_PGM(x) lcdProgMemprint(PSTR(x))
//===========================================================================
@@ -225,7 +225,7 @@ void lcd_status()
//static long previous_lcdinit=0;
// buttons_check(); // Done in temperature interrupt
//previous_millis_buttons=millis();
long ms=millis();
unsigned long ms=millis();
for(int8_t i=0; i<8; i++) {
#ifndef NEWPANEL
if((blocking[i]>ms))
@@ -366,11 +366,11 @@ void MainMenu::showStatus()
{
encoderpos=feedmultiply;
clear();
lcd.setCursor(0,0);lcdprintPGM("\002000/000\001 ");
lcd.setCursor(0,0);LCD_PRINT_PGM("\002000/000\001 ");
#if defined BED_USES_THERMISTOR || defined BED_USES_AD595
lcd.setCursor(10,0);lcdprintPGM("B000/000\001 ");
lcd.setCursor(10,0);LCD_PRINT_PGM("B000/000\001 ");
#elif EXTRUDERS > 1
lcd.setCursor(10,0);lcdprintPGM("\002000/000\001 ");
lcd.setCursor(10,0);LCD_PRINT_PGM("\002000/000\001 ");
#endif
}
@@ -432,7 +432,7 @@ void MainMenu::showStatus()
if(starttime!=oldtime)
{
lcd.print(itostr2(time/60));lcdprintPGM("h ");lcd.print(itostr2(time%60));lcdprintPGM("m");
lcd.print(itostr2(time/60));LCD_PRINT_PGM("h ");lcd.print(itostr2(time%60));LCD_PRINT_PGM("m");
oldtime=time;
}
}
@@ -441,7 +441,7 @@ void MainMenu::showStatus()
if((currentz!=oldzpos)||force_lcd_update)
{
lcd.setCursor(10,1);
lcdprintPGM("Z:");lcd.print(ftostr52(current_position[2]));
LCD_PRINT_PGM("Z:");lcd.print(ftostr52(current_position[2]));
oldzpos=currentz;
}
@@ -468,7 +468,7 @@ void MainMenu::showStatus()
{
oldfeedmultiply=curfeedmultiply;
lcd.setCursor(0,2);
lcd.print(itostr3(curfeedmultiply));lcdprintPGM("% ");
lcd.print(itostr3(curfeedmultiply));LCD_PRINT_PGM("% ");
}
if(messagetext[0]!='\0')
@@ -487,7 +487,7 @@ void MainMenu::showStatus()
{
lcd.setCursor(10,2);
lcd.print(itostr3((int)percent));
lcdprintPGM("%SD");
LCD_PRINT_PGM("%SD");
}
#endif
#else //smaller LCDS----------------------------------
@@ -496,7 +496,7 @@ void MainMenu::showStatus()
if(force_lcd_update) //initial display of content
{
encoderpos=feedmultiply;
lcd.setCursor(0,0);lcdprintPGM("\002---/---\001 ");
lcd.setCursor(0,0);LCD_PRINT_PGM("\002---/---\001 ");
}
int tHotEnd0=intround(degHotend0());
@@ -550,26 +550,26 @@ void MainMenu::showPrepare()
switch(i)
{
case ItemP_exit:
MENUITEM( lcdprintPGM(MSG_MAIN) , BLOCK;status=Main_Menu;beepshort(); ) ;
MENUITEM( LCD_PRINT_PGM(MSG_MAIN) , BLOCK;status=Main_Menu;beepshort(); ) ;
break;
case ItemP_autostart:
MENUITEM( lcdprintPGM(MSG_AUTOSTART) , BLOCK;
MENUITEM( LCD_PRINT_PGM(MSG_AUTOSTART) , BLOCK;
#ifdef SDSUPPORT
card.lastnr=0;card.setroot();card.checkautostart(true);
#endif
beepshort(); ) ;
break;
case ItemP_disstep:
MENUITEM( lcdprintPGM(MSG_DISABLE_STEPPERS) , BLOCK;enquecommand("M84");beepshort(); ) ;
MENUITEM( LCD_PRINT_PGM(MSG_DISABLE_STEPPERS) , BLOCK;enquecommand("M84");beepshort(); ) ;
break;
case ItemP_home:
MENUITEM( lcdprintPGM(MSG_AUTO_HOME) , BLOCK;enquecommand("G28");beepshort(); ) ;
MENUITEM( LCD_PRINT_PGM(MSG_AUTO_HOME) , BLOCK;enquecommand("G28");beepshort(); ) ;
break;
case ItemP_origin:
MENUITEM( lcdprintPGM(MSG_SET_ORIGIN) , BLOCK;enquecommand("G92 X0 Y0 Z0");beepshort(); ) ;
MENUITEM( LCD_PRINT_PGM(MSG_SET_ORIGIN) , BLOCK;enquecommand("G92 X0 Y0 Z0");beepshort(); ) ;
break;
case ItemP_preheat_pla:
MENUITEM( lcdprintPGM(MSG_PREHEAT_PLA) , BLOCK;setTargetHotend0(plaPreheatHotendTemp);setTargetBed(plaPreheatHPBTemp);
MENUITEM( LCD_PRINT_PGM(MSG_PREHEAT_PLA) , BLOCK;setTargetHotend0(plaPreheatHotendTemp);setTargetBed(plaPreheatHPBTemp);
#if FAN_PIN > -1
FanSpeed = plaPreheatFanSpeed;
analogWrite(FAN_PIN, FanSpeed);
@@ -577,7 +577,7 @@ void MainMenu::showPrepare()
beepshort(); );
break;
case ItemP_preheat_abs:
MENUITEM( lcdprintPGM(MSG_PREHEAT_ABS) , BLOCK;setTargetHotend0(absPreheatHotendTemp);setTargetBed(absPreheatHPBTemp);
MENUITEM( LCD_PRINT_PGM(MSG_PREHEAT_ABS) , BLOCK;setTargetHotend0(absPreheatHotendTemp);setTargetBed(absPreheatHPBTemp);
#if FAN_PIN > -1
FanSpeed = absPreheatFanSpeed;
analogWrite(FAN_PIN, FanSpeed);
@@ -585,13 +585,13 @@ void MainMenu::showPrepare()
beepshort(); );
break;
case ItemP_cooldown:
MENUITEM( lcdprintPGM(MSG_COOLDOWN) , BLOCK;setTargetHotend0(0);setTargetHotend1(0);setTargetHotend2(0);setTargetBed(0);beepshort(); ) ;
MENUITEM( LCD_PRINT_PGM(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(); ) ;
// MENUITEM( LCD_PRINT_PGM(" Extrude") , BLOCK;enquecommand("G92 E0");enquecommand("G1 F700 E50");beepshort(); ) ;
// break;
case ItemP_move:
MENUITEM( lcdprintPGM(MSG_MOVE_AXIS) , BLOCK;status=Sub_PrepareMove;beepshort(); );
MENUITEM( LCD_PRINT_PGM(MSG_MOVE_AXIS) , BLOCK;status=Sub_PrepareMove;beepshort(); );
break;
default:
break;
@@ -617,14 +617,14 @@ void MainMenu::showAxisMove()
switch(i)
{
case ItemAM_exit:
MENUITEM( lcdprintPGM(MSG_PREPARE_ALT) , BLOCK;status=Main_Prepare;beepshort(); ) ;
MENUITEM( LCD_PRINT_PGM(MSG_PREPARE_ALT) , BLOCK;status=Main_Prepare;beepshort(); ) ;
break;
case ItemAM_X:
{
//oldencoderpos=0;
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" X:");
lcd.setCursor(0,line);LCD_PRINT_PGM(" X:");
lcd.setCursor(11,line);lcd.print(ftostr52(current_position[X_AXIS]));
}
@@ -669,7 +669,7 @@ void MainMenu::showAxisMove()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" Y:");
lcd.setCursor(0,line);LCD_PRINT_PGM(" Y:");
lcd.setCursor(11,line);lcd.print(ftostr52(current_position[Y_AXIS]));
}
@@ -714,7 +714,7 @@ void MainMenu::showAxisMove()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" Z:");
lcd.setCursor(0,line);LCD_PRINT_PGM(" Z:");
lcd.setCursor(11,line);lcd.print(ftostr52(current_position[Z_AXIS]));
}
@@ -757,11 +757,11 @@ 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 F70 E1");beepshort(); ) ;
MENUITEM( LCD_PRINT_PGM(MSG_EXTRUDE) , BLOCK;enquecommand("G92 E0");enquecommand("G1 F70 E1");beepshort(); ) ;
break;
case ItemAM_ERetract:
// ErikDB: TODO: this length should be changed for volumetric.
MENUITEM( lcdprintPGM(MSG_RETRACT) , BLOCK;enquecommand("G92 E0");enquecommand("G1 F700 E-1");beepshort(); ) ;
MENUITEM( LCD_PRINT_PGM(MSG_RETRACT) , BLOCK;enquecommand("G92 E0");enquecommand("G1 F700 E-1");beepshort(); ) ;
break;
default:
break;
@@ -787,13 +787,13 @@ void MainMenu::showTune()
switch(i)
{
case ItemT_exit:
MENUITEM( lcdprintPGM(MSG_MAIN) , BLOCK;status=Main_Menu;beepshort(); ) ;
MENUITEM( LCD_PRINT_PGM(MSG_MAIN) , BLOCK;status=Main_Menu;beepshort(); ) ;
break;
case ItemT_speed:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_SPEED);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_SPEED);
lcd.setCursor(13,line);lcd.print(ftostr3(feedmultiply));
}
@@ -828,7 +828,7 @@ void MainMenu::showTune()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_NOZZLE);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_NOZZLE);
lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetHotend0())));
}
@@ -862,7 +862,7 @@ void MainMenu::showTune()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_BED);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_BED);
lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetBed())));
}
@@ -898,7 +898,7 @@ void MainMenu::showTune()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_FAN_SPEED);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_FAN_SPEED);
lcd.setCursor(13,line);lcd.print(ftostr3(FanSpeed));
}
@@ -933,7 +933,7 @@ void MainMenu::showTune()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_FLOW);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_FLOW);
lcd.setCursor(13,line);lcd.print(ftostr52(axis_steps_per_unit[E_AXIS]));
}
@@ -975,22 +975,22 @@ void MainMenu::showTune()
updateActiveLines(ItemT_fan,encoderpos);
}
//does not work
// #define MENUCHANGEITEM(repaint_action, enter_action, accept_action, change_action) \
// {\
// if(force_lcd_update) { lcd.setCursor(0,line); repaint_action; } \
// if(activeline==line) \
// { \
// if(CLICKED) \
// { \
// linechanging=!linechanging; \
// if(linechanging) {enter_action;} \
// else {accept_action;} \
// } \
// else \
// if(linechanging) {change_action};}\
// }
//
/*does not work
#define MENUCHANGEITEM(repaint_action, enter_action, accept_action, change_action) \
{\
if(force_lcd_update) { lcd.setCursor(0,line); repaint_action; } \
if(activeline==line) \
{ \
if(CLICKED) \
{ \
linechanging=!linechanging; \
if(linechanging) {enter_action;} \
else {accept_action;} \
} \
else \
if(linechanging) {change_action};}\
}
*/
enum {
ItemCT_exit,ItemCT_nozzle0,
@@ -1022,13 +1022,13 @@ void MainMenu::showControlTemp()
switch(i)
{
case ItemCT_exit:
MENUITEM( lcdprintPGM(MSG_CONTROL) , BLOCK;status=Main_Control;beepshort(); ) ;
MENUITEM( LCD_PRINT_PGM(MSG_CONTROL) , BLOCK;status=Main_Control;beepshort(); ) ;
break;
case ItemCT_nozzle0:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_NOZZLE);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_NOZZLE);
lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetHotend0())));
}
@@ -1063,7 +1063,7 @@ void MainMenu::showControlTemp()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_NOZZLE1);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_NOZZLE1);
lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetHotend1())));
}
@@ -1099,7 +1099,7 @@ void MainMenu::showControlTemp()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_NOZZLE2);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_NOZZLE2);
lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetHotend2())));
}
@@ -1135,7 +1135,7 @@ void MainMenu::showControlTemp()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_MIN);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_MIN);
lcd.setCursor(13,line);lcd.print(ftostr3(autotemp_min));
}
@@ -1169,7 +1169,7 @@ void MainMenu::showControlTemp()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_MAX);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_MAX);
lcd.setCursor(13,line);lcd.print(ftostr3(autotemp_max));
}
@@ -1203,7 +1203,7 @@ void MainMenu::showControlTemp()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_FACTOR);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_FACTOR);
lcd.setCursor(13,line);lcd.print(ftostr32(autotemp_factor));
}
@@ -1237,12 +1237,12 @@ void MainMenu::showControlTemp()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_AUTOTEMP);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_AUTOTEMP);
lcd.setCursor(13,line);
if(autotemp_enabled)
lcdprintPGM(MSG_ON);
LCD_PRINT_PGM(MSG_ON);
else
lcdprintPGM(MSG_OFF);
LCD_PRINT_PGM(MSG_OFF);
}
if((activeline!=line) )
@@ -1253,9 +1253,9 @@ void MainMenu::showControlTemp()
autotemp_enabled=!autotemp_enabled;
lcd.setCursor(13,line);
if(autotemp_enabled)
lcdprintPGM(MSG_ON);
LCD_PRINT_PGM(MSG_ON);
else
lcdprintPGM(MSG_OFF);
LCD_PRINT_PGM(MSG_OFF);
BLOCK;
}
@@ -1266,7 +1266,7 @@ void MainMenu::showControlTemp()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_BED);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_BED);
lcd.setCursor(13,line);lcd.print(ftostr3(intround(degTargetBed())));
}
@@ -1300,7 +1300,7 @@ void MainMenu::showControlTemp()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_FAN_SPEED);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_FAN_SPEED);
lcd.setCursor(13,line);lcd.print(ftostr3(FanSpeed));
}
@@ -1336,7 +1336,7 @@ void MainMenu::showControlTemp()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" PID-P: ");
lcd.setCursor(0,line);LCD_PRINT_PGM(" PID-P: ");
lcd.setCursor(13,line);lcd.print(itostr4(Kp));
}
@@ -1371,7 +1371,7 @@ void MainMenu::showControlTemp()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_PID_I);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_PID_I);
lcd.setCursor(13,line);lcd.print(ftostr51(Ki/PID_dT));
}
@@ -1406,7 +1406,7 @@ void MainMenu::showControlTemp()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_PID_D);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_PID_D);
lcd.setCursor(13,line);lcd.print(itostr4(Kd*PID_dT));
}
@@ -1443,7 +1443,7 @@ void MainMenu::showControlTemp()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_PID_C);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_PID_C);
lcd.setCursor(13,line);lcd.print(itostr3(Kc));
}
@@ -1478,10 +1478,10 @@ void MainMenu::showControlTemp()
#endif
break;
case ItemCT_PLA_PreHeat_Setting:
MENUITEM( lcdprintPGM(MSG_PREHEAT_PLA_SETTINGS) , BLOCK;status=Sub_PreheatPLASettings;beepshort(); ) ;
MENUITEM( LCD_PRINT_PGM(MSG_PREHEAT_PLA_SETTINGS) , BLOCK;status=Sub_PreheatPLASettings;beepshort(); ) ;
break;
case ItemCT_ABS_PreHeat_Setting:
MENUITEM( lcdprintPGM(MSG_PREHEAT_ABS_SETTINGS) , BLOCK;status=Sub_PreheatABSSettings;beepshort(); ) ;
MENUITEM( LCD_PRINT_PGM(MSG_PREHEAT_ABS_SETTINGS) , BLOCK;status=Sub_PreheatABSSettings;beepshort(); ) ;
break;
default:
break;
@@ -1513,14 +1513,14 @@ void MainMenu::showControlMotion()
switch(i)
{
case ItemCM_exit:
MENUITEM( lcdprintPGM(MSG_CONTROL) , BLOCK;status=Main_Control;beepshort(); ) ;
MENUITEM( LCD_PRINT_PGM(MSG_CONTROL) , BLOCK;status=Main_Control;beepshort(); ) ;
break;
case ItemCM_acc:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_ACC);
lcd.setCursor(13,line);lcd.print(itostr3(acceleration/100));lcdprintPGM("00");
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_ACC);
lcd.setCursor(13,line);lcd.print(itostr3(acceleration/100));LCD_PRINT_PGM("00");
}
if((activeline!=line) )
@@ -1545,7 +1545,7 @@ void MainMenu::showControlMotion()
{
if(encoderpos<5) encoderpos=5;
if(encoderpos>990) encoderpos=990;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));lcdprintPGM("00");
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));LCD_PRINT_PGM("00");
}
}break;
@@ -1553,7 +1553,7 @@ void MainMenu::showControlMotion()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_VXY_JERK);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_VXY_JERK);
lcd.setCursor(13,line);lcd.print(itostr3(max_xy_jerk));
}
@@ -1592,11 +1592,11 @@ void MainMenu::showControlMotion()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_VMAX);
if(i==ItemCM_vmaxx)lcdprintPGM(MSG_X);
if(i==ItemCM_vmaxy)lcdprintPGM(MSG_Y);
if(i==ItemCM_vmaxz)lcdprintPGM(MSG_Z);
if(i==ItemCM_vmaxe)lcdprintPGM(MSG_E);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_VMAX);
if(i==ItemCM_vmaxx)LCD_PRINT_PGM(MSG_X);
if(i==ItemCM_vmaxy)LCD_PRINT_PGM(MSG_Y);
if(i==ItemCM_vmaxz)LCD_PRINT_PGM(MSG_Z);
if(i==ItemCM_vmaxe)LCD_PRINT_PGM(MSG_E);
lcd.setCursor(13,line);lcd.print(itostr3(max_feedrate[i-ItemCM_vmaxx]));
}
@@ -1632,7 +1632,7 @@ void MainMenu::showControlMotion()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_VMIN);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_VMIN);
lcd.setCursor(13,line);lcd.print(itostr3(minimumfeedrate));
}
@@ -1667,7 +1667,7 @@ void MainMenu::showControlMotion()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_VTRAV_MIN);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_VTRAV_MIN);
lcd.setCursor(13,line);lcd.print(itostr3(mintravelfeedrate));
}
@@ -1706,12 +1706,12 @@ void MainMenu::showControlMotion()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(" Amax ");
if(i==ItemCM_amaxx)lcdprintPGM(MSG_X);
if(i==ItemCM_amaxy)lcdprintPGM(MSG_Y);
if(i==ItemCM_amaxz)lcdprintPGM(MSG_Z);
if(i==ItemCM_amaxe)lcdprintPGM(MSG_E);
lcd.setCursor(13,line);lcd.print(itostr3(max_acceleration_units_per_sq_second[i-ItemCM_amaxx]/100));lcdprintPGM("00");
lcd.setCursor(0,line);LCD_PRINT_PGM(" Amax ");
if(i==ItemCM_amaxx)LCD_PRINT_PGM(MSG_X);
if(i==ItemCM_amaxy)LCD_PRINT_PGM(MSG_Y);
if(i==ItemCM_amaxz)LCD_PRINT_PGM(MSG_Z);
if(i==ItemCM_amaxe)LCD_PRINT_PGM(MSG_E);
lcd.setCursor(13,line);lcd.print(itostr3(max_acceleration_units_per_sq_second[i-ItemCM_amaxx]/100));LCD_PRINT_PGM("00");
}
if((activeline!=line) )
@@ -1736,7 +1736,7 @@ void MainMenu::showControlMotion()
{
if(encoderpos<1) encoderpos=1;
if(encoderpos>990) encoderpos=990;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));lcdprintPGM("00");
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));LCD_PRINT_PGM("00");
}
}break;
@@ -1746,8 +1746,8 @@ void MainMenu::showControlMotion()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_A_RETRACT);
lcd.setCursor(13,line);lcd.print(ftostr3(retract_acceleration/100));lcdprintPGM("00");
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_A_RETRACT);
lcd.setCursor(13,line);lcd.print(ftostr3(retract_acceleration/100));LCD_PRINT_PGM("00");
}
if((activeline!=line) )
@@ -1773,7 +1773,7 @@ void MainMenu::showControlMotion()
{
if(encoderpos<10) encoderpos=10;
if(encoderpos>990) encoderpos=990;
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));lcdprintPGM("00");
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));LCD_PRINT_PGM("00");
}
}break;
@@ -1781,7 +1781,7 @@ void MainMenu::showControlMotion()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_XSTEPS);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_XSTEPS);
lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[X_AXIS]));
}
@@ -1818,7 +1818,7 @@ void MainMenu::showControlMotion()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_YSTEPS);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_YSTEPS);
lcd.setCursor(11,line);lcd.print(ftostr52(axis_steps_per_unit[Y_AXIS]));
}
@@ -1856,7 +1856,7 @@ void MainMenu::showControlMotion()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_ZSTEPS);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_ZSTEPS);
lcd.setCursor(11,line);lcd.print(ftostr51(axis_steps_per_unit[Z_AXIS]));
}
@@ -1895,7 +1895,7 @@ void MainMenu::showControlMotion()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_ESTEPS);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_ESTEPS);
lcd.setCursor(11,line);lcd.print(ftostr51(axis_steps_per_unit[E_AXIS]));
}
@@ -1958,7 +1958,7 @@ void MainMenu::showControlRetract()
switch(i)
{
case ItemR_exit:
MENUITEM( lcdprintPGM(MSG_CONTROL) , BLOCK;status=Main_Control;beepshort(); ) ;
MENUITEM( LCD_PRINT_PGM(MSG_CONTROL) , BLOCK;status=Main_Control;beepshort(); ) ;
break;
//float retract_length=2, retract_feedrate=1200, retract_zlift=0.4;
@@ -1967,12 +1967,12 @@ void MainMenu::showControlRetract()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_AUTORETRACT);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_AUTORETRACT);
lcd.setCursor(13,line);
if(autoretract_enabled)
lcdprintPGM(MSG_ON);
LCD_PRINT_PGM(MSG_ON);
else
lcdprintPGM(MSG_OFF);
LCD_PRINT_PGM(MSG_OFF);
}
if((activeline!=line) )
@@ -1983,9 +1983,9 @@ void MainMenu::showControlRetract()
autoretract_enabled=!autoretract_enabled;
lcd.setCursor(13,line);
if(autoretract_enabled)
lcdprintPGM(MSG_ON);
LCD_PRINT_PGM(MSG_ON);
else
lcdprintPGM(MSG_OFF);
LCD_PRINT_PGM(MSG_OFF);
BLOCK;
}
@@ -1995,7 +1995,7 @@ void MainMenu::showControlRetract()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_CONTROL_RETRACT);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_CONTROL_RETRACT);
lcd.setCursor(13,line);lcd.print(ftostr52(retract_length));
}
@@ -2030,7 +2030,7 @@ void MainMenu::showControlRetract()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_CONTROL_RETRACTF);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_CONTROL_RETRACTF);
lcd.setCursor(13,line);lcd.print(itostr4(retract_feedrate));
}
@@ -2065,7 +2065,7 @@ void MainMenu::showControlRetract()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_CONTROL_RETRACT_ZLIFT);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_CONTROL_RETRACT_ZLIFT);
lcd.setCursor(13,line);lcd.print(ftostr52(retract_zlift));;
}
@@ -2100,7 +2100,7 @@ void MainMenu::showControlRetract()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_CONTROL_RETRACT_RECOVER);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_CONTROL_RETRACT_RECOVER);
lcd.setCursor(13,line);lcd.print(ftostr52(retract_recover_length));;
}
@@ -2136,7 +2136,7 @@ void MainMenu::showControlRetract()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_CONTROL_RETRACT_RECOVERF);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_CONTROL_RETRACT_RECOVERF);
lcd.setCursor(13,line);lcd.print(itostr4(retract_recover_feedrate));
}
@@ -2196,59 +2196,59 @@ void MainMenu::showControl()
switch(i)
{
case ItemC_exit:
MENUITEM( lcdprintPGM(MSG_MAIN_WIDE) , BLOCK;status=Main_Menu;beepshort(); ) ;
MENUITEM( LCD_PRINT_PGM(MSG_MAIN_WIDE) , BLOCK;status=Main_Menu;beepshort(); ) ;
break;
case ItemC_temp:
MENUITEM( lcdprintPGM(MSG_TEMPERATURE_WIDE) , BLOCK;status=Sub_TempControl;beepshort(); ) ;
MENUITEM( LCD_PRINT_PGM(MSG_TEMPERATURE_WIDE) , BLOCK;status=Sub_TempControl;beepshort(); ) ;
break;
case ItemC_move:
MENUITEM( lcdprintPGM(MSG_MOTION_WIDE) , BLOCK;status=Sub_MotionControl;beepshort(); ) ;
MENUITEM( LCD_PRINT_PGM(MSG_MOTION_WIDE) , BLOCK;status=Sub_MotionControl;beepshort(); ) ;
break;
#ifdef FWRETRACT
case ItemC_rectract:
MENUITEM( lcdprintPGM(MSG_RECTRACT_WIDE) , BLOCK;status=Sub_RetractControl;beepshort(); ) ;
MENUITEM( LCD_PRINT_PGM(MSG_RECTRACT_WIDE) , BLOCK;status=Sub_RetractControl;beepshort(); ) ;
break;
#endif
case ItemC_store:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_STORE_EPROM);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_STORE_EPROM);
}
if((activeline==line) && CLICKED)
{
//enquecommand("M84");
beepshort();
BLOCK;
EEPROM_StoreSettings();
Config_StoreSettings();
}
}break;
case ItemC_load:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_LOAD_EPROM);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_LOAD_EPROM);
}
if((activeline==line) && CLICKED)
{
//enquecommand("M84");
beepshort();
BLOCK;
EEPROM_RetrieveSettings();
Config_RetrieveSettings();
}
}break;
case ItemC_failsafe:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_RESTORE_FAILSAFE);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_RESTORE_FAILSAFE);
}
if((activeline==line) && CLICKED)
{
//enquecommand("M84");
beepshort();
BLOCK;
EEPROM_RetrieveSettings(true);
Config_ResetDefault();
}
}break;
default:
@@ -2288,7 +2288,7 @@ void MainMenu::showSD()
switch(i)
{
case 0:
MENUITEM( lcdprintPGM(MSG_MAIN) , BLOCK;status=Main_Menu;beepshort(); ) ;
MENUITEM( LCD_PRINT_PGM(MSG_MAIN) , BLOCK;status=Main_Menu;beepshort(); ) ;
break;
// case 1:
// {
@@ -2301,11 +2301,11 @@ void MainMenu::showSD()
// if(true)
// #endif
// {
// lcdprintPGM(" \004Refresh");
// LCD_PRINT_PGM(" \004Refresh");
// }
// else
// {
// lcdprintPGM(" \004Insert Card");
// LCD_PRINT_PGM(" \004Insert Card");
// }
//
// }
@@ -2320,7 +2320,7 @@ void MainMenu::showSD()
// }break;
case 1:
MENUITEM( lcd.print(" ");card.getWorkDirName();
if(card.filename[0]=='/') lcdprintPGM(MSG_REFRESH);
if(card.filename[0]=='/') LCD_PRINT_PGM(MSG_REFRESH);
else {
lcd.print("\005");
lcd.print(card.filename);
@@ -2343,8 +2343,12 @@ void MainMenu::showSD()
{
card.getfilename(i-FIRSTITEM);
//Serial.print("Filenr:");Serial.println(i-2);
lcd.setCursor(0,line);lcdprintPGM(" ");
if(card.filenameIsDir) lcd.print("\005");
lcd.setCursor(0,line);LCD_PRINT_PGM(" ");
if(card.filenameIsDir)
{
lcd.print("\005");
card.longFilename[LCD_WIDTH-2] = '\0';
}
if (card.longFilename[0])
{
card.longFilename[LCD_WIDTH-1] = '\0';
@@ -2361,7 +2365,7 @@ void MainMenu::showSD()
card.getfilename(i-FIRSTITEM);
if(card.filenameIsDir)
{
for(int8_t i=0;i<strlen(card.filename);i++)
for(uint8_t i=0;i<strlen(card.filename);i++)
card.filename[i]=tolower(card.filename[i]);
card.chdir(card.filename);
lineoffset=0;
@@ -2370,7 +2374,7 @@ void MainMenu::showSD()
else
{
char cmd[30];
for(int8_t i=0;i<strlen(card.filename);i++)
for(uint8_t i=0;i<strlen(card.filename);i++)
card.filename[i]=tolower(card.filename[i]);
sprintf(cmd,"M23 %s",card.filename);
//sprintf(cmd,"M115");
@@ -2436,14 +2440,14 @@ void MainMenu::showMainMenu()
switch(i)
{
case ItemM_watch:
MENUITEM( lcdprintPGM(MSG_WATCH) , BLOCK;status=Main_Status;beepshort(); ) ;
MENUITEM( LCD_PRINT_PGM(MSG_WATCH) , BLOCK;status=Main_Status;beepshort(); ) ;
break;
case ItemM_prepare:
MENUITEM( if(!tune) lcdprintPGM(MSG_PREPARE);else lcdprintPGM(MSG_TUNE); , BLOCK;status=Main_Prepare;beepshort(); ) ;
MENUITEM( if(!tune) LCD_PRINT_PGM(MSG_PREPARE);else LCD_PRINT_PGM(MSG_TUNE); , BLOCK;status=Main_Prepare;beepshort(); ) ;
break;
case ItemM_control:
MENUITEM( lcdprintPGM(MSG_CONTROL_ARROW) , BLOCK;status=Main_Control;beepshort(); ) ;
MENUITEM( LCD_PRINT_PGM(MSG_CONTROL_ARROW) , BLOCK;status=Main_Control;beepshort(); ) ;
break;
#ifdef SDSUPPORT
case ItemM_file:
@@ -2458,13 +2462,13 @@ void MainMenu::showMainMenu()
#endif
{
if(card.sdprinting)
lcdprintPGM(MSG_STOP_PRINT);
LCD_PRINT_PGM(MSG_STOP_PRINT);
else
lcdprintPGM(MSG_CARD_MENU);
LCD_PRINT_PGM(MSG_CARD_MENU);
}
else
{
lcdprintPGM(MSG_NO_CARD);
LCD_PRINT_PGM(MSG_NO_CARD);
}
}
#ifdef CARDINSERTED
@@ -2490,13 +2494,13 @@ void MainMenu::showMainMenu()
#endif
{
if(card.sdprinting)
lcdprintPGM(MSG_PAUSE_PRINT);
LCD_PRINT_PGM(MSG_PAUSE_PRINT);
else
lcdprintPGM(MSG_RESUME_PRINT);
LCD_PRINT_PGM(MSG_RESUME_PRINT);
}
else
{
//lcdprintPGM(MSG_NO_CARD);
//LCD_PRINT_PGM(MSG_NO_CARD);
}
}
#ifdef CARDINSERTED
@@ -2545,7 +2549,7 @@ void MainMenu::showMainMenu()
void MainMenu::update()
{
static MainStatus oldstatus=Main_Menu; //init automatically causes foce_lcd_update=true
static long timeoutToStatus=0;
static unsigned long timeoutToStatus=0;
static bool oldcardstatus=false;
#ifdef CARDINSERTED
if((CARDINSERTED != oldcardstatus))
@@ -2666,14 +2670,14 @@ void MainMenu::showPLAsettings()
{
case ItemPLAPreHeat_Exit:
MENUITEM( lcdprintPGM(MSG_TEMPERATURE_RTN) , BLOCK;status=Sub_TempControl;beepshort(); ) ;
MENUITEM( LCD_PRINT_PGM(MSG_TEMPERATURE_RTN) , BLOCK;status=Sub_TempControl;beepshort(); ) ;
break;
case ItemPLAPreHeat_set_PLA_FanSpeed:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_FAN_SPEED);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_FAN_SPEED);
lcd.setCursor(13,line);lcd.print(ftostr3(plaPreheatFanSpeed));
}
@@ -2707,7 +2711,7 @@ void MainMenu::showPLAsettings()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_NOZZLE);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_NOZZLE);
lcd.setCursor(13,line);lcd.print(ftostr3(plaPreheatHotendTemp));
}
@@ -2741,7 +2745,7 @@ void MainMenu::showPLAsettings()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_BED);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_BED);
lcd.setCursor(13,line);lcd.print(ftostr3(plaPreheatHPBTemp));
}
@@ -2774,14 +2778,14 @@ void MainMenu::showPLAsettings()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_STORE_EPROM);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_STORE_EPROM);
}
if((activeline==line) && CLICKED)
{
//enquecommand("M84");
beepshort();
BLOCK;
EEPROM_StoreSettings();
Config_StoreSettings();
}
}break;
default:
@@ -2812,14 +2816,14 @@ void MainMenu::showABSsettings()
{
case ItemABSPreHeat_Exit:
MENUITEM( lcdprintPGM(MSG_TEMPERATURE_RTN) , BLOCK;status=Sub_TempControl;beepshort(); ) ;
MENUITEM( LCD_PRINT_PGM(MSG_TEMPERATURE_RTN) , BLOCK;status=Sub_TempControl;beepshort(); ) ;
break;
case ItemABSPreHeat_set_FanSpeed:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_FAN_SPEED);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_FAN_SPEED);
lcd.setCursor(13,line);lcd.print(ftostr3(absPreheatFanSpeed));
}
@@ -2853,7 +2857,7 @@ void MainMenu::showABSsettings()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_NOZZLE);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_NOZZLE);
lcd.setCursor(13,line);lcd.print(ftostr3(absPreheatHotendTemp));
}
@@ -2887,7 +2891,7 @@ void MainMenu::showABSsettings()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_BED);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_BED);
lcd.setCursor(13,line);lcd.print(ftostr3(absPreheatHPBTemp));
}
@@ -2920,14 +2924,14 @@ void MainMenu::showABSsettings()
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcdprintPGM(MSG_STORE_EPROM);
lcd.setCursor(0,line);LCD_PRINT_PGM(MSG_STORE_EPROM);
}
if((activeline==line) && CLICKED)
{
//enquecommand("M84");
beepshort();
BLOCK;
EEPROM_StoreSettings();
Config_StoreSettings();
}
}break;
default:
+44 -30
View File
@@ -1,46 +1,41 @@
#ifndef ULTRALCD_H
#define ULTRALCD_H
#include "Marlin.h"
#ifdef ULTRA_LCD
#include "language.h"
#if LANGUAGE_CHOICE == 6
#include "LiquidCrystalRus.h"
#define LCD_CLASS LiquidCrystalRus
#else
#include <LiquidCrystal.h>
#define LCD_CLASS LiquidCrystal
#endif
void lcd_status();
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
#if LANGUAGE_CHOICE == 6
extern LiquidCrystalRus lcd;
#else
extern LiquidCrystal lcd;
#endif
extern volatile char buttons; //the last checked buttons in a bit array.
void lcd_status();
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 LCD_CLASS lcd;
extern volatile char buttons; //the last checked buttons in a bit array.
#ifdef NEWPANEL
#ifdef NEWPANEL
#define EN_C (1<<BLEN_C)
#define EN_B (1<<BLEN_B)
#define EN_A (1<<BLEN_A)
#define CLICKED (buttons&EN_C)
#define BLOCK {blocking=millis()+blocktime;}
#if (SDCARDDETECT > -1)
#ifdef SDCARDDETECTINVERTED
#define CARDINSERTED (READ(SDCARDDETECT)!=0)
#else
#define CARDINSERTED (READ(SDCARDDETECT)==0)
#endif
#endif //SDCARDTETECTINVERTED
#else
#else
//atomatic, do not change
#define B_LE (1<<BL_LE)
#define B_UP (1<<BL_UP)
@@ -53,9 +48,18 @@
#define CLICKED ((buttons&B_MI)||(buttons&B_ST))
#define BLOCK {blocking[BL_MI]=millis()+blocktime;blocking[BL_ST]=millis()+blocktime;}
#endif
#endif
#if (SDCARDDETECT > -1)
#ifdef SDCARDDETECTINVERTED
#define CARDINSERTED (READ(SDCARDDETECT)!=0)
#else
#define CARDINSERTED (READ(SDCARDDETECT)==0)
#endif //SDCARDTETECTINVERTED
#else
//If we don't have a card detect line, aways asume the card is inserted
#define CARDINSERTED true
#endif
// blocking time for recognizing a new keypress of one key, ms
@@ -152,8 +156,8 @@
#define LCD_INIT lcd_init();
#define LCD_MESSAGE(x) lcd_status(x);
#define LCD_MESSAGEPGM(x) lcd_statuspgm(MYPGM(x));
#define LCD_ALERTMESSAGEPGM(x) lcd_alertstatuspgm(MYPGM(x));
#define LCD_MESSAGEPGM(x) lcd_statuspgm(PSTR(x));
#define LCD_ALERTMESSAGEPGM(x) lcd_alertstatuspgm(PSTR(x));
#define LCD_STATUS lcd_status()
#else //no lcd
#define LCD_INIT
@@ -178,4 +182,14 @@ char *itostr31(const int &xx);
char *itostr3(const int &xx);
char *itostr4(const int &xx);
char *ftostr51(const float &x);
//TODO: These do not belong here.
extern int plaPreheatHotendTemp;
extern int plaPreheatHPBTemp;
extern int plaPreheatFanSpeed;
extern int absPreheatHotendTemp;
extern int absPreheatHPBTemp;
extern int absPreheatFanSpeed;
#endif //ULTRALCD
+56
View File
@@ -0,0 +1,56 @@
#include "Marlin.h"
#ifdef USE_WATCHDOG
#include <avr/wdt.h>
#include "watchdog.h"
#include "ultralcd.h"
//===========================================================================
//=============================private variables ============================
//===========================================================================
//===========================================================================
//=============================functinos ============================
//===========================================================================
/// intialise watch dog with a 1 sec interrupt time
void watchdog_init()
{
#ifdef WATCHDOG_RESET_MANUAL
//We enable the watchdog timer, but only for the interrupt.
//Take care, as this requires the correct order of operation, with interrupts disabled. See the datasheet of any AVR chip for details.
wdt_reset();
_WD_CONTROL_REG = _BV(_WD_CHANGE_BIT) | _BV(WDE);
_WD_CONTROL_REG = _BV(WDIE) | WDTO_1S;
#else
wdt_enable(WDTO_1S);
#endif
}
/// reset watchdog. MUST be called every 1s after init or avr will reset.
void watchdog_reset()
{
wdt_reset();
}
//===========================================================================
//=============================ISR ============================
//===========================================================================
//Watchdog timer interrupt, called if main program blocks >1sec and manual reset is enabled.
#ifdef WATCHDOG_RESET_MANUAL
ISR(WDT_vect)
{
//TODO: This message gets overwritten by the kill() call
LCD_MESSAGEPGM("ERR:Please Reset");//16 characters so it fits on a 16x2 display
LCD_STATUS;
SERIAL_ERROR_START;
SERIAL_ERRORLNPGM("Something is wrong, please turn off the printer.");
kill(); //kill blocks
while(1); //wait for user or serial reset
}
#endif//RESET_MANUAL
#endif//USE_WATCHDOG
+8 -7
View File
@@ -1,16 +1,17 @@
#ifndef WATCHDOG_H
#define WATCHDOG_H
#include "Marlin.h"
#ifdef USE_WATCHDOG
// intialise watch dog with a 1 sec interrupt time
void wd_init();
// pad the dog/reset watchdog. MUST be called at least every second after the first wd_init or avr will go into emergency procedures..
void wd_reset();
void watchdog_init();
// pad the dog/reset watchdog. MUST be called at least every second after the first watchdog_init or avr will go into emergency procedures..
void watchdog_reset();
#else
FORCE_INLINE void wd_init() {};
FORCE_INLINE void wd_reset() {};
//If we do not have a watchdog, then we can have empty functions which are optimized away.
FORCE_INLINE void watchdog_init() {};
FORCE_INLINE void watchdog_reset() {};
#endif
#endif
-63
View File
@@ -1,63 +0,0 @@
#ifdef USE_WATCHDOG
#include "Marlin.h"
#include "watchdog.h"
//===========================================================================
//=============================private variables ============================
//===========================================================================
static volatile uint8_t timeout_seconds=0;
void(* ctrlaltdelete) (void) = 0; //does not work on my atmega2560
//===========================================================================
//=============================functinos ============================
//===========================================================================
/// intialise watch dog with a 1 sec interrupt time
void wd_init()
{
WDTCSR |= (1<<WDCE )|(1<<WDE ); //allow changes
WDTCSR = (1<<WDCE )|(1<<WDE )|(1<<WDP3 )|(1<<WDP0); // Reset after 8 sec.
// WDTCSR = (1<<WDIF)|(1<<WDIE)| (1<<WDCE )|(1<<WDE )| (1<<WDP3) | (1<<WDP0);
}
/// reset watchdog. MUST be called every 1s after init or avr will reset.
void wd_reset()
{
wdt_reset();
}
//===========================================================================
//=============================ISR ============================
//===========================================================================
//Watchdog timer interrupt, called if main program blocks >1sec
ISR(WDT_vect)
{
if(timeout_seconds++ >= WATCHDOG_TIMEOUT)
{
#ifdef RESET_MANUAL
LCD_MESSAGEPGM("Please Reset!");
LCD_STATUS;
SERIAL_ERROR_START;
SERIAL_ERRORLNPGM("Something is wrong, please turn off the printer.");
#else
LCD_MESSAGEPGM("Timeout, resetting!");
LCD_STATUS;
#endif
//disable watchdog, it will survife reboot.
WDTCSR |= (1<<WDCE) | (1<<WDE);
WDTCSR = 0;
#ifdef RESET_MANUAL
kill(); //kill blocks
while(1); //wait for user or serial reset
#else
ctrlaltdelete();
#endif
}
}
#endif /* USE_WATCHDOG */