watchdog,percent done,

master
Bernhard Kubicek 13 years ago
parent c57906b627
commit 7919a40d06

@ -220,11 +220,12 @@ const bool ENDSTOPS_INVERTING = true; // set to true to invert the logic of the
// The watchdog waits for the watchperiod in milliseconds whenever an M104 or M109 increases the target temperature // The watchdog waits for the watchperiod in milliseconds whenever an M104 or M109 increases the target temperature
// this enables the watchdog interrupt. // this enables the watchdog interrupt.
#define USE_WATCHDOG //#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: // 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 RESET_MANUAL
#define WATCHDOG_TIMEOUT 4 //seconds #define WATCHDOG_TIMEOUT 4 //seconds
#endif

@ -100,7 +100,7 @@ void prepare_move();
void kill(); void kill();
void enquecommand(const char *cmd); //put an ascii command at the end of the current buffer. void enquecommand(const char *cmd); //put an ascii command at the end of the current buffer.
void prepare_arc_move(char isclockwise);
#ifndef CRITICAL_SECTION_START #ifndef CRITICAL_SECTION_START
#define CRITICAL_SECTION_START unsigned char _sreg = SREG; cli(); #define CRITICAL_SECTION_START unsigned char _sreg = SREG; cli();

@ -37,6 +37,7 @@
#include "temperature.h" #include "temperature.h"
#include "motion_control.h" #include "motion_control.h"
#include "cardreader.h" #include "cardreader.h"
#include "watchdog.h"
#define VERSION_STRING "1.0.0 Alpha 1" #define VERSION_STRING "1.0.0 Alpha 1"
@ -191,6 +192,36 @@ extern "C"{
} }
inline void get_coordinates()
{
for(int8_t i=0; i < NUM_AXIS; i++) {
if(code_seen(axis_codes[i])) destination[i] = (float)code_value() + (axis_relative_modes[i] || relative_mode)*current_position[i];
else destination[i] = current_position[i]; //Are these else lines really needed?
}
if(code_seen('F')) {
next_feedrate = code_value();
if(next_feedrate > 0.0) feedrate = next_feedrate;
}
}
inline void get_arc_coordinates()
{
get_coordinates();
if(code_seen('I')) offset[0] = code_value();
if(code_seen('J')) offset[1] = code_value();
}
void prepare_move()
{
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60.0/100.0);
for(int8_t i=0; i < NUM_AXIS; i++) {
current_position[i] = destination[i];
}
}
//adds an command to the main command buffer //adds an command to the main command buffer
//thats really done in a non-safe way. //thats really done in a non-safe way.
//needs overworking someday //needs overworking someday
@ -234,6 +265,7 @@ void setup()
plan_init(); // Initialize planner; plan_init(); // Initialize planner;
st_init(); // Initialize stepper; st_init(); // Initialize stepper;
tp_init(); // Initialize temperature loop tp_init(); // Initialize temperature loop
wd_init();
} }
@ -656,7 +688,8 @@ inline void process_commands()
break; break;
case 105: // M105 case 105: // M105
//SERIAL_ECHOLN(freeMemory()); //SERIAL_ECHOLN(freeMemory());
//test watchdog:
//delay(20000);
#if (TEMP_0_PIN > -1) || defined (HEATER_USES_AD595) #if (TEMP_0_PIN > -1) || defined (HEATER_USES_AD595)
SERIAL_PROTOCOLPGM("ok T:"); SERIAL_PROTOCOLPGM("ok T:");
SERIAL_PROTOCOL( degHotend0()); SERIAL_PROTOCOL( degHotend0());
@ -975,32 +1008,7 @@ void ClearToSend()
SERIAL_PROTOCOLLNPGM("ok"); SERIAL_PROTOCOLLNPGM("ok");
} }
inline void get_coordinates()
{
for(int8_t i=0; i < NUM_AXIS; i++) {
if(code_seen(axis_codes[i])) destination[i] = (float)code_value() + (axis_relative_modes[i] || relative_mode)*current_position[i];
else destination[i] = current_position[i]; //Are these else lines really needed?
}
if(code_seen('F')) {
next_feedrate = code_value();
if(next_feedrate > 0.0) feedrate = next_feedrate;
}
}
inline void get_arc_coordinates()
{
get_coordinates();
if(code_seen('I')) offset[0] = code_value();
if(code_seen('J')) offset[1] = code_value();
}
void prepare_move()
{
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60.0/100.0);
for(int8_t i=0; i < NUM_AXIS; i++) {
current_position[i] = destination[i];
}
}
void prepare_arc_move(char isclockwise) { void prepare_arc_move(char isclockwise) {
float r = hypot(offset[X_AXIS], offset[Y_AXIS]); // Compute arc radius for mc_arc float r = hypot(offset[X_AXIS], offset[Y_AXIS]); // Compute arc radius for mc_arc

@ -33,6 +33,7 @@ public:
inline bool eof() { return sdpos>=filesize ;}; inline bool eof() { return sdpos>=filesize ;};
inline int16_t get() { sdpos = file.curPosition();return (int16_t)file.read();}; inline int16_t get() { sdpos = file.curPosition();return (int16_t)file.read();};
inline void setIndex(long index) {sdpos = index;file.seekSet(index);}; inline void setIndex(long index) {sdpos = index;file.seekSet(index);};
inline uint8_t percentDone(){if(!sdprinting) return 0; if(filesize) return sdpos*100/filesize; else return 0;};
public: public:
bool saving; bool saving;

@ -96,7 +96,7 @@
#define BLOCK ; #define BLOCK ;
#endif #endif
void lcd_statuspgm(const char* message);
#endif //ULTRALCD #endif //ULTRALCD

@ -374,6 +374,16 @@ void MainMenu::showStatus()
lcd.print(fillto(LCD_WIDTH,messagetext)); lcd.print(fillto(LCD_WIDTH,messagetext));
messagetext[0]='\0'; messagetext[0]='\0';
} }
static uint8_t oldpercent=101;
uint8_t percent=card.percentDone();
if(oldpercent!=percent)
{
lcd.setCursor(6,3);
lcd.print(oldpercent);
lcdprintPGM("done");
}
#else //smaller LCDS---------------------------------- #else //smaller LCDS----------------------------------
static int olddegHotEnd0=-1; static int olddegHotEnd0=-1;
static int oldtargetHotEnd0=-1; static int oldtargetHotEnd0=-1;

@ -42,10 +42,12 @@ ISR(WDT_vect)
#ifdef RESET_MANUAL #ifdef RESET_MANUAL
LCD_MESSAGEPGM("Please Reset!"); LCD_MESSAGEPGM("Please Reset!");
LCD_STATUS;
SERIAL_ERROR_START; SERIAL_ERROR_START;
SERIAL_ERRORLNPGM("Something is wrong, please turn off the printer."); SERIAL_ERRORLNPGM("Something is wrong, please turn off the printer.");
#else #else
LCD_MESSAGEPGM("Timeout, resetting!"); LCD_MESSAGEPGM("Timeout, resetting!");
LCD_STATUS;
#endif #endif
//disable watchdog, it will survife reboot. //disable watchdog, it will survife reboot.
WDTCSR |= (1<<WDCE) | (1<<WDE); WDTCSR |= (1<<WDCE) | (1<<WDE);

Loading…
Cancel
Save