Commit d4504571 authored by MagoKimbra's avatar MagoKimbra

Update and fix

parent 49ff3bfa
...@@ -44,8 +44,8 @@ ...@@ -44,8 +44,8 @@
//#define FIRMWARE_TEST // ONLY BAUDRATE 115200 //#define FIRMWARE_TEST // ONLY BAUDRATE 115200
// Some particular clients re-start sending commands only after receiving a 'wait' when there is a bed serial-connection. // Some particular clients re-start sending commands only after receiving a 'wait' when there is a bed serial-connection.
//#define NO_TIMEOUTS 1000 // Milliseconds #define NO_TIMEOUTS 1000 // Milliseconds
//#define ADVANCED_OK // Uncomment to include more info in ok command //#define ADVANCED_OK // Uncomment to include more info in ok command
/***********************************************************************/ /***********************************************************************/
......
...@@ -350,8 +350,8 @@ ...@@ -350,8 +350,8 @@
* (i.e. the software might assume it can be done instantaneously) * * (i.e. the software might assume it can be done instantaneously) *
* * * *
*****************************************************************************************/ *****************************************************************************************/
#define DEFAULT_XYJERK 10.0 // (mm/sec) #define DEFAULT_XYJERK 20.0 // (mm/sec)
#define DEFAULT_ZJERK 0.4 // (mm/sec) #define DEFAULT_ZJERK 20.0 // (mm/sec)
// max initial speed for retract moves E0... (mm/sec) per extruder // max initial speed for retract moves E0... (mm/sec) per extruder
#define DEFAULT_EJERK {5.0, 5.0, 5.0, 5.0} #define DEFAULT_EJERK {5.0, 5.0, 5.0, 5.0}
/*****************************************************************************************/ /*****************************************************************************************/
......
...@@ -93,7 +93,6 @@ ...@@ -93,7 +93,6 @@
* * * *
*****************************************************************************************/ *****************************************************************************************/
#define AUTOTEMP #define AUTOTEMP
#define AUTOTEMP_OLDWEIGHT 0.98 #define AUTOTEMP_OLDWEIGHT 0.98
/*****************************************************************************************/ /*****************************************************************************************/
...@@ -983,6 +982,8 @@ ...@@ -983,6 +982,8 @@
//#define SDEXTRASLOW // Use even slower SD transfer mode (not normally needed - uncomment if you're getting volume init error) //#define SDEXTRASLOW // Use even slower SD transfer mode (not normally needed - uncomment if you're getting volume init error)
//#define SD_CHECK_AND_RETRY // Use CRC checks and retries on the SD communication //#define SD_CHECK_AND_RETRY // Use CRC checks and retries on the SD communication
// Decomment thi if you are external SD without DETECT_PIN
//#define SD_DISABLED_DETECT
// Some RAMPS and other boards don't detect when an SD card is inserted. You can work // Some RAMPS and other boards don't detect when an SD card is inserted. You can work
// around this by connecting a push button or single throw switch to the pin defined // around this by connecting a push button or single throw switch to the pin defined
// as SD_DETECT_PIN in your board's pins definitions. // as SD_DETECT_PIN in your board's pins definitions.
...@@ -1480,4 +1481,4 @@ ...@@ -1480,4 +1481,4 @@
//#define WATCHDOG_RESET_MANUAL //#define WATCHDOG_RESET_MANUAL
/*****************************************************************************************/ /*****************************************************************************************/
#endif #endif
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#ifndef MACROS_H #ifndef MACROS_H
#define MACROS_H #define MACROS_H
// Compiler warning on unused varable.
#define UNUSED(x) (void) (x)
// Macros for bit masks // Macros for bit masks
#define BIT(b) (1<<(b)) #define BIT(b) (1<<(b))
#define TEST(n,b) (((n)&BIT(b))!=0) #define TEST(n,b) (((n)&BIT(b))!=0)
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
NexPage Pmenu = NexPage(3, 0, "menu"); NexPage Pmenu = NexPage(3, 0, "menu");
NexPage Psdcard = NexPage(4, 0, "sdcard"); NexPage Psdcard = NexPage(4, 0, "sdcard");
NexPage Psetup = NexPage(5, 0, "setup"); NexPage Psetup = NexPage(5, 0, "setup");
NexPage Pmove = NexPage(6, 0, "move");
// Text // Text
NexText Hotend0 = NexText(1, 1, "t0"); NexText Hotend0 = NexText(1, 1, "t0");
...@@ -41,7 +42,6 @@ ...@@ -41,7 +42,6 @@
NexText LedStatus = NexText(1, 7, "t4"); NexText LedStatus = NexText(1, 7, "t4");
NexText LedCoord = NexText(1, 8, "t5"); NexText LedCoord = NexText(1, 8, "t5");
NexText set0 = NexText(2, 2, "set0"); NexText set0 = NexText(2, 2, "set0");
NexText set1 = NexText(2, 15, "set1");
NexText sdrow0 = NexText(4, 3, "t0"); NexText sdrow0 = NexText(4, 3, "t0");
NexText sdrow1 = NexText(4, 4, "t1"); NexText sdrow1 = NexText(4, 4, "t1");
NexText sdrow2 = NexText(4, 5, "t2"); NexText sdrow2 = NexText(4, 5, "t2");
...@@ -58,6 +58,9 @@ ...@@ -58,6 +58,9 @@
NexPicture Hend1 = NexPicture(1, 14, "p4"); NexPicture Hend1 = NexPicture(1, 14, "p4");
NexPicture Hend2 = NexPicture(1, 15, "p5"); NexPicture Hend2 = NexPicture(1, 15, "p5");
NexPicture Fanpic = NexPicture(1, 19, "p6"); NexPicture Fanpic = NexPicture(1, 19, "p6");
NexPicture NPlay = NexPicture(1, 27, "p7");
NexPicture NStop = NexPicture(1, 28, "p8");
NexPicture Exit1 = NexPicture(3, 4, "p3");
NexPicture Folder0 = NexPicture(4, 9, "p0"); NexPicture Folder0 = NexPicture(4, 9, "p0");
NexPicture Folder1 = NexPicture(4, 10, "p1"); NexPicture Folder1 = NexPicture(4, 10, "p1");
NexPicture Folder2 = NexPicture(4, 11, "p2"); NexPicture Folder2 = NexPicture(4, 11, "p2");
...@@ -65,7 +68,16 @@ ...@@ -65,7 +68,16 @@
NexPicture Folder4 = NexPicture(4, 13, "p4"); NexPicture Folder4 = NexPicture(4, 13, "p4");
NexPicture Folder5 = NexPicture(4, 14, "p5"); NexPicture Folder5 = NexPicture(4, 14, "p5");
NexPicture Folderup = NexPicture(4, 15, "p6"); NexPicture Folderup = NexPicture(4, 15, "p6");
NexPicture Exit = NexPicture(4, 16, "p7"); NexPicture Exit2 = NexPicture(4, 16, "p7");
NexPicture Exit3 = NexPicture(5, 4, "p3");
NexPicture XYHome = NexPicture(6, 5, "p4");
NexPicture XYUp = NexPicture(6, 6, "p5");
NexPicture XYRight = NexPicture(6, 7, "p6");
NexPicture XYDown = NexPicture(6, 8, "p7");
NexPicture XYLeft = NexPicture(6, 9, "p8");
NexPicture ZHome = NexPicture(6, 10, "p9");
NexPicture ZUp = NexPicture(6, 11, "p10");
NexPicture ZDown = NexPicture(6, 12, "p11");
// Progress Bar // Progress Bar
NexProgressBar sdbar = NexProgressBar(1, 26, "j0"); NexProgressBar sdbar = NexProgressBar(1, 26, "j0");
...@@ -92,6 +104,7 @@ ...@@ -92,6 +104,7 @@
// Variable // Variable
NexVar Hotend = NexVar(1, 20, "he"); NexVar Hotend = NexVar(1, 20, "he");
NexVar set1 = NexVar(2, 17, "set1");
NexVar Bed = NexVar(1, 21, "bed"); NexVar Bed = NexVar(1, 21, "bed");
NexVar filename0 = NexVar(4, 19, "va0"); NexVar filename0 = NexVar(4, 19, "va0");
NexVar filename1 = NexVar(4, 20, "va1"); NexVar filename1 = NexVar(4, 20, "va1");
...@@ -99,6 +112,7 @@ ...@@ -99,6 +112,7 @@
NexVar filename3 = NexVar(4, 22, "va3"); NexVar filename3 = NexVar(4, 22, "va3");
NexVar filename4 = NexVar(4, 23, "va4"); NexVar filename4 = NexVar(4, 23, "va4");
NexVar filename5 = NexVar(4, 24, "va5"); NexVar filename5 = NexVar(4, 24, "va5");
NexVar movecmd = NexVar(6, 18, "vacmd");
NexTouch *nex_listen_list[] = NexTouch *nex_listen_list[] =
{ {
...@@ -107,6 +121,8 @@ ...@@ -107,6 +121,8 @@
&MSD, &MSD,
&MSetup, &MSetup,
&Fanpic, &Fanpic,
&NPlay,
&NStop,
&hot0, &hot0,
&hot1, &hot1,
&hot2, &hot2,
...@@ -121,7 +137,17 @@ ...@@ -121,7 +137,17 @@
&sdrow4, &sdrow4,
&sdrow5, &sdrow5,
&Folderup, &Folderup,
&Exit, &Exit1,
&Exit2,
&Exit3,
&XYHome,
&XYUp,
&XYRight,
&XYDown,
&XYLeft,
&ZHome,
&ZUp,
&ZDown,
NULL NULL
}; };
...@@ -266,21 +292,21 @@ ...@@ -266,21 +292,21 @@
} }
void sdlistPopCallback(void *ptr) { void sdlistPopCallback(void *ptr) {
uint32_t number = 0; uint32_t number = 0;
sdlist.getValue(&number); sdlist.getValue(&number);
number = slidermaxval - number; number = slidermaxval - number;
setrowsdcard(number); setrowsdcard(number);
} }
static void menu_action_sdfile(const char* filename) { static void menu_action_sdfile(const char* filename) {
char cmd[30]; char cmd[30];
char* c; char* c;
sprintf_P(cmd, PSTR("M23 %s"), filename); sprintf_P(cmd, PSTR("M23 %s"), filename);
for(c = &cmd[4]; *c; c++) *c = tolower(*c); for(c = &cmd[4]; *c; c++) *c = tolower(*c);
enqueuecommand(cmd); enqueuecommand(cmd);
enqueuecommands_P(PSTR("M24")); enqueuecommands_P(PSTR("M24"));
setpageInfo(); setpageInfo();
} }
static void menu_action_sddirectory(const char* filename) { static void menu_action_sddirectory(const char* filename) {
card.chdir(filename); card.chdir(filename);
...@@ -330,13 +356,14 @@ ...@@ -330,13 +356,14 @@
setpagesdcard(); setpagesdcard();
} }
void ExitPopCallback(void *ptr) {
setpageInfo();
}
#endif #endif
void ExitPopCallback(void *ptr) {
setpageInfo();
}
void PstartPopCallback(void *ptr) { void PstartPopCallback(void *ptr) {
setpageInfo(); setpageInfo();
} }
void hotPopCallback(void *ptr) { void hotPopCallback(void *ptr) {
...@@ -400,13 +427,17 @@ ...@@ -400,13 +427,17 @@
} }
void setpagePopCallback(void *ptr) { void setpagePopCallback(void *ptr) {
if (ptr == &Menu) if (ptr == &Menu) {
PageInfo = false;
Pmenu.show(); Pmenu.show();
if (ptr == &MSetup) }
else if (ptr == &MSetup) {
PageInfo = false;
Psetup.show(); Psetup.show();
}
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
if (ptr == &MSD) else if (ptr == &MSD)
setpagesdcard(); setpagesdcard();
#endif #endif
} }
...@@ -416,6 +447,31 @@ ...@@ -416,6 +447,31 @@
else fanSpeed = 255; else fanSpeed = 255;
} }
void setmovePopCallback(void *ptr) {
memset(buffer, 0, sizeof(buffer));
movecmd.getText(buffer, sizeof(buffer));
enqueuecommands_P(PSTR("G91"));
enqueuecommands_P(buffer);
enqueuecommands_P(PSTR("G90"));
}
void PlayPausePopCallback(void *ptr) {
if (card.cardOK && card.isFileOpen()) {
if (card.sdprinting)
card.pauseSDPrint();
else
card.startFileprint();
}
}
void StopPopCallback(void *ptr) {
quickStop();
card.sdprinting = false;
card.closeFile();
autotempShutdown();
lcd_setstatus(MSG_PRINT_ABORTED, true);
}
void lcd_init() { void lcd_init() {
delay(1000); delay(1000);
NextionON = nexInit(); NextionON = nexInit();
...@@ -425,12 +481,16 @@ ...@@ -425,12 +481,16 @@
} else { } else {
ECHO_LM(DB, "Nextion LCD connected!"); ECHO_LM(DB, "Nextion LCD connected!");
Pstart.attachPop(PstartPopCallback); Pstart.attachPop(ExitPopCallback);
Exit1.attachPop(ExitPopCallback);
Exit3.attachPop(ExitPopCallback);
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
MSD.attachPop(setpagePopCallback, &MSD); MSD.attachPop(setpagePopCallback, &MSD);
sdlist.attachPop(sdlistPopCallback); sdlist.attachPop(sdlistPopCallback);
Exit.attachPop(ExitPopCallback); Exit2.attachPop(ExitPopCallback);
NPlay.attachPop(PlayPausePopCallback);
NStop.attachPop(StopPopCallback);
#endif #endif
#if HAS_TEMP_0 #if HAS_TEMP_0
...@@ -444,11 +504,19 @@ ...@@ -444,11 +504,19 @@
#endif #endif
Menu.attachPop(setpagePopCallback, &Menu); Menu.attachPop(setpagePopCallback, &Menu);
MSetup.attachPop(setpagePopCallback, &Menu); MSetup.attachPop(setpagePopCallback, &MSetup);
Fanpic.attachPop(setfanPopCallback, &Fanpic); Fanpic.attachPop(setfanPopCallback, &Fanpic);
m11.attachPop(sethotPopCallback, &m11); m11.attachPop(sethotPopCallback, &m11);
tup.attachPop(settempPopCallback, &tup); tup.attachPop(settempPopCallback, &tup);
tdown.attachPop(settempPopCallback, &tdown); tdown.attachPop(settempPopCallback, &tdown);
XYHome.attachPop(setmovePopCallback);
XYUp.attachPop(setmovePopCallback);
XYRight.attachPop(setmovePopCallback);
XYDown.attachPop(setmovePopCallback);
XYLeft.attachPop(setmovePopCallback);
ZHome.attachPop(setmovePopCallback);
ZUp.attachPop(setmovePopCallback);
ZDown.attachPop(setmovePopCallback);
startimer.enable(); startimer.enable();
} }
...@@ -479,7 +547,7 @@ ...@@ -479,7 +547,7 @@
} }
static void coordtoLCD() { static void coordtoLCD() {
char *valuetemp; char* valuetemp;
memset(buffer, 0, sizeof(buffer)); memset(buffer, 0, sizeof(buffer));
strcat(buffer, "X"); strcat(buffer, "X");
...@@ -545,13 +613,29 @@ ...@@ -545,13 +613,29 @@
coordtoLCD(); coordtoLCD();
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
if (card.cardOK)
if (card.cardOK) {
MSD.setPic(7); MSD.setPic(7);
else NPlay.setPic(38);
NStop.setPic(41);
}
else {
MSD.setPic(6); MSD.setPic(6);
if (IS_SD_PRINTING) NPlay.setPic(39);
// Progress bar solid part NStop.setPic(42);
sdbar.setValue(card.percentDone()); }
if (card.isFileOpen()) {
if (card.sdprinting) {
// Progress bar solid part
sdbar.setValue(card.percentDone());
NPlay.setPic(38);
}
else {
NPlay.setPic(40);
}
}
#endif #endif
next_lcd_update_ms = ms + LCD_UPDATE_INTERVAL; next_lcd_update_ms = ms + LCD_UPDATE_INTERVAL;
......
...@@ -4,12 +4,13 @@ ...@@ -4,12 +4,13 @@
#if ENABLED(NEXTION) #if ENABLED(NEXTION)
#define LCD_UPDATE_INTERVAL 5000 #define LCD_UPDATE_INTERVAL 5000
void PstartPopCallback(void *ptr); void ExitUpPopCallback(void *ptr);
void setpagePopCallback(void *ptr); void setpagePopCallback(void *ptr);
void hotPopCallback(void *ptr); void hotPopCallback(void *ptr);
void sethotPopCallback(void *ptr); void sethotPopCallback(void *ptr);
void settempPopCallback(void *ptr); void settempPopCallback(void *ptr);
void setfanPopCallback(void *ptr); void setfanPopCallback(void *ptr);
void setmovePopCallback(void *ptr);
void lcd_update(); void lcd_update();
void lcd_init(); void lcd_init();
void lcd_setstatus(const char* message, const bool persist = false); void lcd_setstatus(const char* message, const bool persist = false);
...@@ -22,7 +23,8 @@ ...@@ -22,7 +23,8 @@
void sdfilePopCallback(void *ptr); void sdfilePopCallback(void *ptr);
void sdfolderPopCallback(void *ptr); void sdfolderPopCallback(void *ptr);
void sdfolderUpPopCallback(void *ptr); void sdfolderUpPopCallback(void *ptr);
void ExitUpPopCallback(void *ptr); void PlayPausePopCallback(void *ptr);
void StopPopCallback(void *ptr);
#endif #endif
FORCE_INLINE bool lcd_hasstatus() { return false; } FORCE_INLINE bool lcd_hasstatus() { return false; }
......
This diff is collapsed.
This diff is collapsed.
...@@ -19,17 +19,17 @@ ...@@ -19,17 +19,17 @@
*/ */
#ifndef TEMPERATURE_H #ifndef TEMPERATURE_H
#define TEMPERATURE_H #define TEMPERATURE_H
// public functions // public functions
void tp_init(); //initialize the heating void tp_init(); //initialize the heating
void manage_heater(); //it is critical that this is called periodically. void manage_heater(); //it is critical that this is called periodically.
#if ENABLED(FILAMENT_SENSOR) #if ENABLED(FILAMENT_SENSOR)
// For converting raw Filament Width to milimeters // For converting raw Filament Width to milimeters
float analog2widthFil(); float analog2widthFil();
// For converting raw Filament Width to an extrusion ratio // For converting raw Filament Width to an extrusion ratio
int widthFil_to_size_ratio(); int widthFil_to_size_ratio();
#endif #endif
...@@ -80,7 +80,7 @@ extern float current_temperature_bed; ...@@ -80,7 +80,7 @@ extern float current_temperature_bed;
#if ENABLED(BABYSTEPPING) #if ENABLED(BABYSTEPPING)
extern volatile int babystepsTodo[3]; extern volatile int babystepsTodo[3];
#endif #endif
//high level conversion routines, for use outside of temperature.cpp //high level conversion routines, for use outside of temperature.cpp
//inline so that there is no performance decrease. //inline so that there is no performance decrease.
//deg=degreeCelsius //deg=degreeCelsius
...@@ -102,16 +102,16 @@ FORCE_INLINE float degTargetHotend(uint8_t hotend) { return target_temperature[H ...@@ -102,16 +102,16 @@ FORCE_INLINE float degTargetHotend(uint8_t hotend) { return target_temperature[H
FORCE_INLINE float degTargetBed() { return target_temperature_bed; } FORCE_INLINE float degTargetBed() { return target_temperature_bed; }
#if ENABLED(THERMAL_PROTECTION_HOTENDS) #if ENABLED(THERMAL_PROTECTION_HOTENDS)
void start_watching_heater(int e=0); void start_watching_heater(int h = 0);
#endif #endif
FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t hotend) { FORCE_INLINE void setTargetHotend(const float& celsius, uint8_t hotend) {
target_temperature[HOTEND_ARG] = celsius; target_temperature[HOTEND_ARG] = celsius;
#if ENABLED(THERMAL_PROTECTION_HOTENDS) #if ENABLED(THERMAL_PROTECTION_HOTENDS)
start_watching_heater(HOTEND_ARG); start_watching_heater(HOTEND_ARG);
#endif #endif
} }
FORCE_INLINE void setTargetBed(const float &celsius) { target_temperature_bed = celsius; } FORCE_INLINE void setTargetBed(const float& celsius) { target_temperature_bed = celsius; }
FORCE_INLINE bool isHeatingHotend(uint8_t hotend) { return target_temperature[HOTEND_ARG] > current_temperature[HOTEND_ARG]; } FORCE_INLINE bool isHeatingHotend(uint8_t hotend) { return target_temperature[HOTEND_ARG] > current_temperature[HOTEND_ARG]; }
FORCE_INLINE bool isHeatingBed() { return target_temperature_bed > current_temperature_bed; } FORCE_INLINE bool isHeatingBed() { return target_temperature_bed > current_temperature_bed; }
......
...@@ -339,10 +339,14 @@ static void lcd_status_screen() { ...@@ -339,10 +339,14 @@ static void lcd_status_screen() {
lcd_status_message[0] = '\0'; lcd_status_message[0] = '\0';
expire_status_ms = 0; expire_status_ms = 0;
} }
} else }
else {
expire_status_ms += LCD_UPDATE_INTERVAL; expire_status_ms += LCD_UPDATE_INTERVAL;
} else }
}
else {
expire_status_ms = 0; expire_status_ms = 0;
}
#else #else
expire_status_ms = 0; expire_status_ms = 0;
#endif // SDSUPPORT #endif // SDSUPPORT
...@@ -377,7 +381,8 @@ static void lcd_status_screen() { ...@@ -377,7 +381,8 @@ static void lcd_status_screen() {
ignore_click = wait_for_unclick = false; ignore_click = wait_for_unclick = false;
else else
current_click = false; current_click = false;
} else if (current_click) { }
else if (current_click) {
lcd_quick_feedback(); lcd_quick_feedback();
wait_for_unclick = true; wait_for_unclick = true;
current_click = false; current_click = false;
...@@ -399,7 +404,7 @@ static void lcd_status_screen() { ...@@ -399,7 +404,7 @@ static void lcd_status_screen() {
#if ENABLED(ULTIPANEL_FEEDMULTIPLY) #if ENABLED(ULTIPANEL_FEEDMULTIPLY)
// Dead zone at 100% feedrate // Dead zone at 100% feedrate
if ((feedrate_multiplier < 100 && (feedrate_multiplier + int(encoderPosition)) > 100) || if ((feedrate_multiplier < 100 && (feedrate_multiplier + int(encoderPosition)) > 100) ||
(feedrate_multiplier > 100 && (feedrate_multiplier + int(encoderPosition)) < 100)) { (feedrate_multiplier > 100 && (feedrate_multiplier + int(encoderPosition)) < 100)) {
encoderPosition = 0; encoderPosition = 0;
feedrate_multiplier = 100; feedrate_multiplier = 100;
} }
...@@ -472,13 +477,15 @@ static void lcd_main_menu() { ...@@ -472,13 +477,15 @@ static void lcd_main_menu() {
else else
MENU_ITEM(function, MSG_RESUME_PRINT, lcd_sdcard_resume); MENU_ITEM(function, MSG_RESUME_PRINT, lcd_sdcard_resume);
MENU_ITEM(function, MSG_STOP_PRINT, lcd_sdcard_stop); MENU_ITEM(function, MSG_STOP_PRINT, lcd_sdcard_stop);
} else { }
else {
MENU_ITEM(submenu, MSG_CARD_MENU, lcd_sdcard_menu); MENU_ITEM(submenu, MSG_CARD_MENU, lcd_sdcard_menu);
#if !PIN_EXISTS(SD_DETECT) #if !PIN_EXISTS(SD_DETECT)
MENU_ITEM(gcode, MSG_CNG_SDCARD, PSTR("M21")); // SD-card changed by user MENU_ITEM(gcode, MSG_CNG_SDCARD, PSTR("M21")); // SD-card changed by user
#endif #endif
} }
} else { }
else {
MENU_ITEM(submenu, MSG_NO_CARD, lcd_sdcard_menu); MENU_ITEM(submenu, MSG_NO_CARD, lcd_sdcard_menu);
#if !PIN_EXISTS(SD_DETECT) #if !PIN_EXISTS(SD_DETECT)
MENU_ITEM(gcode, MSG_INIT_SDCARD, PSTR("M21")); // Manually initialize the SD-card via user interface MENU_ITEM(gcode, MSG_INIT_SDCARD, PSTR("M21")); // Manually initialize the SD-card via user interface
...@@ -509,7 +516,7 @@ void lcd_set_home_offsets() { ...@@ -509,7 +516,7 @@ void lcd_set_home_offsets() {
#if ENABLED(BABYSTEPPING) #if ENABLED(BABYSTEPPING)
static void _lcd_babystep(menuFunc_t menu, int axis, const char *msg) { static void _lcd_babystep(menuFunc_t menu, int axis, const char* msg) {
if (encoderPosition != 0) { if (encoderPosition != 0) {
babystepsTodo[axis] += (int)encoderPosition; babystepsTodo[axis] += (int)encoderPosition;
encoderPosition = 0; encoderPosition = 0;
...@@ -1644,31 +1651,31 @@ void lcd_init() { ...@@ -1644,31 +1651,31 @@ void lcd_init() {
SET_INPUT(BTN_EN2); SET_INPUT(BTN_EN2);
WRITE(BTN_EN1,HIGH); WRITE(BTN_EN1,HIGH);
WRITE(BTN_EN2,HIGH); WRITE(BTN_EN2,HIGH);
#if BTN_ENC > 0 #if BTN_ENC > 0
SET_INPUT(BTN_ENC); SET_INPUT(BTN_ENC);
WRITE(BTN_ENC,HIGH); WRITE(BTN_ENC,HIGH);
#endif #endif
#if ENABLED(REPRAPWORLD_KEYPAD) #if ENABLED(REPRAPWORLD_KEYPAD)
pinMode(SHIFT_CLK,OUTPUT); pinMode(SHIFT_CLK,OUTPUT);
pinMode(SHIFT_LD,OUTPUT); pinMode(SHIFT_LD,OUTPUT);
pinMode(SHIFT_OUT,INPUT); pinMode(SHIFT_OUT,INPUT);
WRITE(SHIFT_OUT,HIGH); WRITE(SHIFT_OUT,HIGH);
WRITE(SHIFT_LD,HIGH); WRITE(SHIFT_LD,HIGH);
#endif #endif
#else // Not NEWPANEL #else // Not NEWPANEL
#if ENABLED(SR_LCD_2W_NL) // Non latching 2 wire shift register #if ENABLED(SR_LCD_2W_NL) // Non latching 2 wire shift register
pinMode (SR_DATA_PIN, OUTPUT); pinMode (SR_DATA_PIN, OUTPUT);
pinMode (SR_CLK_PIN, OUTPUT); pinMode (SR_CLK_PIN, OUTPUT);
#elif ENABLED(SHIFT_CLK) #elif ENABLED(SHIFT_CLK)
pinMode(SHIFT_CLK,OUTPUT); pinMode(SHIFT_CLK,OUTPUT);
pinMode(SHIFT_LD,OUTPUT); pinMode(SHIFT_LD,OUTPUT);
pinMode(SHIFT_EN,OUTPUT); pinMode(SHIFT_EN,OUTPUT);
pinMode(SHIFT_OUT,INPUT); pinMode(SHIFT_OUT,INPUT);
WRITE(SHIFT_OUT,HIGH); WRITE(SHIFT_OUT,HIGH);
WRITE(SHIFT_LD,HIGH); WRITE(SHIFT_LD,HIGH);
WRITE(SHIFT_EN,LOW); WRITE(SHIFT_EN,LOW);
#endif // SR_LCD_2W_NL #endif // SR_LCD_2W_NL
#endif//!NEWPANEL #endif//!NEWPANEL
#if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT) #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT)
pinMode(SD_DETECT_PIN, INPUT); pinMode(SD_DETECT_PIN, INPUT);
......
#include "base.h" #include "base.h"
#if ENABLED(USE_WATCHDOG) #if ENABLED(USE_WATCHDOG)
#include <avr/wdt.h>
#include "whatchdog.h"
//===========================================================================
//============================ private variables ============================
//===========================================================================
//===========================================================================
//================================ functions ================================
//===========================================================================
#include "watchdog.h"
/// intialise watch dog with a 4 sec interrupt time // Initialize watchdog with a 4 sec interrupt time
void watchdog_init() void watchdog_init() {
{
#if ENABLED(WATCHDOG_RESET_MANUAL) #if ENABLED(WATCHDOG_RESET_MANUAL)
//We enable the watchdog timer, but only for the interrupt. // 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. // Take care, as this requires the correct order of operation, with interrupts disabled. See the datasheet of any AVR chip for details.
wdt_reset(); wdt_reset();
_WD_CONTROL_REG = _BV(_WD_CHANGE_BIT) | _BV(WDE); _WD_CONTROL_REG = _BV(_WD_CHANGE_BIT) | _BV(WDE);
_WD_CONTROL_REG = _BV(WDIE) | WDTO_4S; _WD_CONTROL_REG = _BV(WDIE) | WDTO_4S;
...@@ -27,23 +17,18 @@ void watchdog_init() ...@@ -27,23 +17,18 @@ void watchdog_init()
#endif #endif
} }
/// reset watchdog. MUST be called every 1s after init or avr will reset.
void watchdog_reset()
{
wdt_reset();
}
//=========================================================================== //===========================================================================
//=================================== ISR =================================== //=================================== ISR ===================================
//=========================================================================== //===========================================================================
// Watchdog timer interrupt, called if main program blocks >1sec and manual reset is enabled. // Watchdog timer interrupt, called if main program blocks >1sec and manual reset is enabled.
#if ENABLED(WATCHDOG_RESET_MANUAL) #if ENABLED(WATCHDOG_RESET_MANUAL)
ISR(WDT_vect) { ISR(WDT_vect) {
ECHO_LM(ER, MSG_WATCHDOG_RESET); SERIAL_ERROR_START;
kill(PSTR("ERR:Please Reset")); // kill blocks //16 characters so it fits on a 16x2 display SERIAL_ERRORLNPGM("Something is wrong, please turn off the printer.");
while(1); // wait for user or serial reset kill(PSTR("ERR:Please Reset")); //kill blocks //16 characters so it fits on a 16x2 display
} while (1); //wait for user or serial reset
#endif // RESET_MANUAL }
#endif //WATCHDOG_RESET_MANUAL
#endif // USE_WATCHDOG
#endif //USE_WATCHDOG
#ifndef WATCHDOG_H #ifndef WATCHDOG_H
#define WATCHDOG_H #define WATCHDOG_H
// initialize watch dog with a 1 sec interrupt time #include "Marlin_main.h"
#include <avr/wdt.h>
// Initialize watchdog with a 4 second interrupt time
void watchdog_init(); 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(); // Reset watchdog. MUST be called at least every 4 seconds after the
// first watchdog_init or AVR will go into emergency procedures.
inline void watchdog_reset() { wdt_reset(); }
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment