Commit 3ecc37ff authored by MagoKimbra's avatar MagoKimbra

Update V4_2_8

Update Nextion 0.6.9
Add Endtime on display
parent 44f6ee28
### Version 4.2.8 ### Version 4.2.8
* Add board folder with files of various board containing the pins * Add board folder with files of various board containing the pins
* Add End time on Graphics display when SD print
* Rewrite macros * Rewrite macros
* Fix M109 so it won't wait for cooling * Fix M109 so it won't wait for cooling
* Clear code * Clear code
......
...@@ -38,6 +38,62 @@ ...@@ -38,6 +38,62 @@
// be displayed. // be displayed.
#if HOTENDS == 1 #if HOTENDS == 1
#ifdef COLOR_MIXING_EXTRUDER
#define STATUS_SCREENWIDTH 115 //Width in pixels
#define STATUS_SCREENHEIGHT 19 //Height in pixels
#define STATUS_SCREENBYTEWIDTH 15 //Width in bytes
const unsigned char status_screen0_bmp[] PROGMEM = {
0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 127, 255, 224,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 112, 0, 224, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 99, 252, 96, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 252, 32, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 240, 32, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 64, 96, 32, 31, 192, 15, 224,
7, 240, 3, 248, 0, 0, 0, 0, 88, 1, 160, 249, 240, 124,
120, 61, 220, 30, 238, 0, 65, 4, 0, 92, 99, 160, 246,
240, 123, 248, 60, 156, 31, 94, 0, 32, 130, 0, 94, 247,
160, 246, 240, 123, 248, 61, 92, 31, 190, 0, 32, 130,
0, 94, 247, 160, 49, 192, 27, 224, 13, 208, 7, 184, 0,
65, 4, 0, 92, 99, 160, 54, 192, 27, 224, 13, 208, 7,
184, 0, 130, 8, 0, 88,1, 160, 246, 240, 123, 248, 61,
220, 31, 190, 1, 4, 16, 0, 64, 96, 32, 241, 240, 124,
120, 61, 220, 31, 190, 1, 4, 16, 0, 64, 240, 32, 255,
240, 127, 248, 63, 252, 31, 254, 0, 130, 8, 0, 65, 248,
32, 31, 192, 15, 224, 7, 240, 3, 248, 0, 65, 4, 0, 97,
248, 96, 15, 128, 7, 192, 3, 224, 1, 240, 0, 0, 0, 0,
112, 0, 224, 7, 0, 3, 128, 1, 192, 0, 224, 1, 255, 255,
128, 127, 255, 224, 0, 0, 0, 0, 0, 0, 0, 0, 1, 255,
255, 128, 0, 0, 0
};
#define STATUS_SCREENWIDTH 115 //Width in pixels
#define STATUS_SCREENHEIGHT 19 //Height in pixels
#define STATUS_SCREENBYTEWIDTH 15 //Width in bytes
const unsigned char status_screen1_bmp[] PROGMEM = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127, 255, 224,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 112, 0, 224, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 103, 14, 96, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 79, 15, 32, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 95, 15, 160, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 95, 15, 160, 31, 192, 15,
224, 7, 240, 3, 248, 0, 0, 0, 0, 95, 15, 160, 249,
240, 124, 120, 61, 220, 30, 238, 0, 65, 4, 0, 64,
240, 32, 246, 240, 123, 248, 60, 156, 31, 94, 0, 32,
130, 0, 64, 240, 32, 246, 240, 123, 248, 61, 92, 31,
190, 0, 32, 130, 0, 64, 240, 32, 49, 192, 27, 224,
13, 208, 7, 184, 0, 65, 4, 0, 64, 240, 32, 54, 192,
27, 224, 13, 208, 7, 184, 0, 130, 8, 0, 95, 15, 160,
246, 240, 123, 248, 61, 220, 31, 190, 1, 4, 16, 0, 95,
15, 160, 241, 240, 124, 120, 61, 220, 31, 190, 1, 4,
16, 0, 95, 15, 160, 255, 240, 127, 248, 63, 252, 31,
254, 0, 130, 8, 0, 79, 15, 32, 31, 192, 15, 224, 7,
240, 3, 248, 0, 65, 4, 0, 103, 14, 96, 15, 128, 7,
192, 3, 224, 1, 240, 0, 0, 0, 0, 112, 0, 224, 7, 0,
3, 128, 1, 192, 0, 224, 1, 255, 255, 128, 127, 255,
224, 0, 0, 0, 0, 0, 0, 0, 0, 1, 255, 255, 128, 0,
0, 0
};
#else // no COLOR_MIXING_EXTRUDER
#define STATUS_SCREENWIDTH 115 //Width in pixels #define STATUS_SCREENWIDTH 115 //Width in pixels
#define STATUS_SCREENHEIGHT 19 //Height in pixels #define STATUS_SCREENHEIGHT 19 //Height in pixels
#define STATUS_SCREENBYTEWIDTH 15 //Width in bytes #define STATUS_SCREENBYTEWIDTH 15 //Width in bytes
...@@ -87,6 +143,7 @@ ...@@ -87,6 +143,7 @@
0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0x80, 0x7F, 0xFF, 0xE0, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0x80, 0x7F, 0xFF, 0xE0,
0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00
}; };
#endif // no COLOR_MIXING_EXTRUDER
#elif HOTENDS == 2 #elif HOTENDS == 2
#define STATUS_SCREENWIDTH 115 //Width in pixels #define STATUS_SCREENWIDTH 115 //Width in pixels
#define STATUS_SCREENHEIGHT 19 //Height in pixels #define STATUS_SCREENHEIGHT 19 //Height in pixels
......
...@@ -308,28 +308,56 @@ static void lcd_implementation_status_screen() { ...@@ -308,28 +308,56 @@ static void lcd_implementation_status_screen() {
u8g.drawBox(55, 50, (unsigned int)(71.f * card.percentDone() / 100.f), 2 - TALL_FONT_CORRECTION); u8g.drawBox(55, 50, (unsigned int)(71.f * card.percentDone() / 100.f), 2 - TALL_FONT_CORRECTION);
} }
u8g.setPrintPos(80, 48); u8g.setPrintPos(53, 47);
if (print_job_start_ms != 0) { if (print_job_start_ms != 0) {
#if HAS(LCD_POWER_SENSOR) #if HAS(LCD_POWER_SENSOR)
if (millis() < print_millis + 1000) { if (millis() < print_millis + 1000) {
uint16_t time = (millis() - print_job_start_ms) / 60000; uint16_t time = (millis() - print_job_start_ms) / 60000;
uint16_t end_time = (time * (100 - card.percentDone())) / card.percentDone();
lcd_print('S');
lcd_print(itostr2(time/60)); lcd_print(itostr2(time/60));
lcd_print(':'); lcd_print(':');
lcd_print(itostr2(time%60)); lcd_print(itostr2(time%60));
u8g.setPrintPos(90,47);
if (end_time > 1380 || end_time == 0)
u8g.print('E--:--');
else if (end_time > 0) {
u8g.print('E');
u8g.print(itostr2(end_time / 60));
u8g.print(':');
u8g.print(itostr2(end_time %60));
}
} }
else { else {
lcd_print(itostr4(power_consumption_hour-startpower)); lcd_print(itostr4(power_consumption_hour - startpower));
lcd_print((char*)"Wh"); lcd_print((char*)"Wh");
} }
#else #else
uint16_t time = (millis() - print_job_start_ms) / 60000; uint16_t time = (millis() - print_job_start_ms) / 60000;
uint16_t end_time = (time * (100 - card.percentDone())) / card.percentDone();
lcd_print('S');
lcd_print(itostr2(time / 60)); lcd_print(itostr2(time / 60));
lcd_print(':'); lcd_print(':');
lcd_print(itostr2(time % 60)); lcd_print(itostr2(time %60));
u8g.setPrintPos(90,47);
if (end_time > (60 * 23))
u8g.print('E--:--');
else if (end_time >= 0) {
u8g.print('E');
u8g.print(itostr2(end_time / 60));
u8g.print(':');
u8g.print(itostr2(end_time %60));
}
#endif #endif
} }
else { else {
lcd_printPGM(PSTR("--:--")); lcd_printPGM(PSTR("S--:--"));
u8g.setPrintPos(90,47);
lcd_printPGM(PSTR("E--:--"));
} }
#endif #endif
......
...@@ -614,7 +614,7 @@ float junction_deviation = 0.1; ...@@ -614,7 +614,7 @@ float junction_deviation = 0.1;
// For a mixing extruder, get steps for each // For a mixing extruder, get steps for each
#if ENABLED(COLOR_MIXING_EXTRUDER) #if ENABLED(COLOR_MIXING_EXTRUDER)
for (uint8_t i = 0; i < DRIVER_EXTRUDERS; i++) for (uint8_t i = 0; i < DRIVER_EXTRUDERS; i++)
block->mix_steps[i] = block->steps[E_AXIS] * mixing_factor[i]; block->mix_event_count[i] = block->step_event_count / mixing_factor[i];
#endif #endif
// Add update block variables for LASER BEAM control // Add update block variables for LASER BEAM control
......
...@@ -31,7 +31,7 @@ typedef struct { ...@@ -31,7 +31,7 @@ typedef struct {
long steps[NUM_AXIS]; // Step count along each axis long steps[NUM_AXIS]; // Step count along each axis
#if ENABLED(COLOR_MIXING_EXTRUDER) #if ENABLED(COLOR_MIXING_EXTRUDER)
float mix_steps[DRIVER_EXTRUDERS]; // Step count for each stepper in a mixing extruder unsigned long mix_event_count[DRIVER_EXTRUDERS]; // Step count for each stepper in a mixing extruder
#endif #endif
unsigned long step_event_count; // The number of step events required to complete this block unsigned long step_event_count; // The number of step events required to complete this block
......
...@@ -658,7 +658,8 @@ ISR(TIMER1_COMPA_vect) { ...@@ -658,7 +658,8 @@ ISR(TIMER1_COMPA_vect) {
counter_x = counter_y = counter_z = counter_e = new_count; counter_x = counter_y = counter_z = counter_e = new_count;
#if ENABLED(COLOR_MIXING_EXTRUDER) #if ENABLED(COLOR_MIXING_EXTRUDER)
for (int8_t i = 0; i < DRIVER_EXTRUDERS; i++) counter_m[i] = new_count; for (uint8_t i = 0; i < DRIVER_EXTRUDERS; i++)
counter_m[i] = -(current_block->mix_event_count[i] >> 1);
#endif #endif
step_events_completed = 0; step_events_completed = 0;
...@@ -703,9 +704,9 @@ ISR(TIMER1_COMPA_vect) { ...@@ -703,9 +704,9 @@ ISR(TIMER1_COMPA_vect) {
#if ENABLED(COLOR_MIXING_EXTRUDER) #if ENABLED(COLOR_MIXING_EXTRUDER)
long dir = TEST(out_bits, E_AXIS) ? -1 : 1; long dir = TEST(out_bits, E_AXIS) ? -1 : 1;
for (uint8_t j = 0; j < DRIVER_EXTRUDERS; j++) { for (uint8_t j = 0; j < DRIVER_EXTRUDERS; j++) {
counter_m[j] += current_block->mix_steps[j]; counter_m[j] += current_block->steps[E_AXIS];
if (counter_m[j] > 0) { if (counter_m[j] > 0) {
counter_m[j] -= current_block->step_event_count; counter_m[j] -= current_block->mix_event_count[j];
e_steps[j] += dir; e_steps[j] += dir;
} }
} }
...@@ -726,14 +727,10 @@ ISR(TIMER1_COMPA_vect) { ...@@ -726,14 +727,10 @@ ISR(TIMER1_COMPA_vect) {
#if DISABLED(ADVANCE) #if DISABLED(ADVANCE)
#if ENABLED(COLOR_MIXING_EXTRUDER) #if ENABLED(COLOR_MIXING_EXTRUDER)
counter_e += current_block->steps[E_AXIS]; counter_e += current_block->steps[E_AXIS];
if (counter_e > 0) {
for (uint8_t j = 0; j < DRIVER_EXTRUDERS; j++) { for (uint8_t j = 0; j < DRIVER_EXTRUDERS; j++) {
counter_m[j] += current_block->mix_steps[j]; counter_m[j] += current_block->steps[E_AXIS];
if (counter_m[j] > 0) En_STEP_WRITE(j, !INVERT_E_STEP_PIN); if (counter_m[j] > 0) En_STEP_WRITE(j, !INVERT_E_STEP_PIN);
} }
counter_e -= current_block->step_event_count;
count_position[E_AXIS] += count_direction[E_AXIS];
}
#else #else
STEP_START(e, E); STEP_START(e, E);
#endif #endif
...@@ -755,6 +752,11 @@ ISR(TIMER1_COMPA_vect) { ...@@ -755,6 +752,11 @@ ISR(TIMER1_COMPA_vect) {
STEP_END(z, Z); STEP_END(z, Z);
#if DISABLED(ADVANCE) #if DISABLED(ADVANCE)
#if ENABLED(COLOR_MIXING_EXTRUDER) #if ENABLED(COLOR_MIXING_EXTRUDER)
// Always count the single E axis
if (counter_e > 0) {
counter_e -= current_block->step_event_count;
count_position[E_AXIS] += count_direction[E_AXIS];
}
for (uint8_t j = 0; j < DRIVER_EXTRUDERS; j++) { for (uint8_t j = 0; j < DRIVER_EXTRUDERS; j++) {
if (counter_m[j] > 0) { if (counter_m[j] > 0) {
counter_m[j] -= current_block->step_event_count; counter_m[j] -= current_block->step_event_count;
...@@ -791,7 +793,14 @@ ISR(TIMER1_COMPA_vect) { ...@@ -791,7 +793,14 @@ ISR(TIMER1_COMPA_vect) {
//NOLESS(advance, current_block->advance); //NOLESS(advance, current_block->advance);
// Do E steps + advance steps // Do E steps + advance steps
#if ENABLED(COLOR_MIXING_EXTRUDER)
// Move mixing steppers proportionally
for (uint8_t j = 0; j < DRIVER_EXTRUDERS; j++)
e_steps[j] += ((advance >> 8) - old_advance) * current_block->step_event_count / current_block->mix_event_count[j];
#else
e_steps[current_block->active_driver] += ((advance >> 8) - old_advance); e_steps[current_block->active_driver] += ((advance >> 8) - old_advance);
#endif
old_advance = advance >> 8; old_advance = advance >> 8;
#endif // ADVANCE #endif // ADVANCE
...@@ -819,7 +828,14 @@ ISR(TIMER1_COMPA_vect) { ...@@ -819,7 +828,14 @@ ISR(TIMER1_COMPA_vect) {
// Do E steps + advance steps // Do E steps + advance steps
uint32_t advance_whole = advance >> 8; uint32_t advance_whole = advance >> 8;
#if ENABLED(MIXING_EXTRUDER_FEATURE)
for (uint8_t j = 0; j < DRIVER_EXTRUDERS; j++)
e_steps[current_block->active_driver] += (advance_whole - old_advance) * current_block->mix_factor[j];
#else
e_steps[current_block->active_driver] += advance_whole - old_advance; e_steps[current_block->active_driver] += advance_whole - old_advance;
#endif
old_advance = advance_whole; old_advance = advance_whole;
#endif //ADVANCE #endif //ADVANCE
} }
......
...@@ -55,4 +55,3 @@ void NexObject::printObjInfo(void) ...@@ -55,4 +55,3 @@ void NexObject::printObjInfo(void)
} }
dbSerialPrintln("]"); dbSerialPrintln("]");
} }
...@@ -43,3 +43,22 @@ bool NexPicture::setPic(uint32_t number) ...@@ -43,3 +43,22 @@ bool NexPicture::setPic(uint32_t number)
return recvRetCommandFinished(); return recvRetCommandFinished();
} }
bool NexPicture::setHide()
{
String cmd;
cmd += "vis ";
cmd += getObjName();
cmd += ",0";
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
bool NexPicture::setShow()
{
String cmd;
cmd += "vis ";
cmd += getObjName();
cmd += ",1";
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
...@@ -54,6 +54,14 @@ public: /* methods */ ...@@ -54,6 +54,14 @@ public: /* methods */
* @retval false - failed. * @retval false - failed.
*/ */
bool setPic(uint32_t number); bool setPic(uint32_t number);
/**
* Set Hide / Show component
*
* @return true if success, false for failure.
*/
bool setHide();
bool setShow();
}; };
/** /**
......
...@@ -53,3 +53,23 @@ bool NexText::setColor(uint32_t value) ...@@ -53,3 +53,23 @@ bool NexText::setColor(uint32_t value)
sendCommand(cmd.c_str()); sendCommand(cmd.c_str());
return recvRetCommandFinished(); return recvRetCommandFinished();
} }
bool NexText::setHide()
{
String cmd;
cmd += "vis ";
cmd += getObjName();
cmd += ",0";
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
bool NexText::setShow()
{
String cmd;
cmd += "vis ";
cmd += getObjName();
cmd += ",1";
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
...@@ -52,6 +52,14 @@ public: /* methods */ ...@@ -52,6 +52,14 @@ public: /* methods */
*/ */
bool setText(const char *buffer); bool setText(const char *buffer);
bool setColor(uint32_t value); bool setColor(uint32_t value);
/**
* Set Hide / Show component
*
* @return true if success, false for failure.
*/
bool setHide();
bool setShow();
}; };
/** /**
......
...@@ -92,4 +92,3 @@ void NexTouch::iterate(NexTouch **list, uint8_t pid, uint8_t cid, int32_t event) ...@@ -92,4 +92,3 @@ void NexTouch::iterate(NexTouch **list, uint8_t pid, uint8_t cid, int32_t event)
} }
} }
} }
...@@ -7,13 +7,17 @@ ...@@ -7,13 +7,17 @@
#include "Nextion.h" #include "Nextion.h"
bool NextionON = false; bool NextionON = false;
bool PageInfo = false; uint8_t NextionPage = 0;
char buffer[100] = {0}; char buffer[100] = {0};
uint32_t slidermaxval = 20; uint32_t slidermaxval = 20;
char lcd_status_message[30] = WELCOME_MSG; char lcd_status_message[30] = WELCOME_MSG;
uint8_t lcd_status_message_level = 0; uint8_t lcd_status_message_level = 0;
static millis_t next_lcd_update_ms; static millis_t next_lcd_update_ms;
#if ENABLED(SDSUPPORT)
uint8_t SDstatus = 0; // 0 SD not insert, 1 SD insert, 2 SD printing
#endif
#if ENABLED(NEXTION_GFX) #if ENABLED(NEXTION_GFX)
GFX gfx = GFX(200, 190); GFX gfx = GFX(200, 190);
#endif #endif
...@@ -26,6 +30,7 @@ ...@@ -26,6 +30,7 @@
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"); NexPage Pmove = NexPage(6, 0, "move");
NexPage Pfeed = NexPage(7, 0, "feed");
// Page 0 Start // Page 0 Start
NexTimer startimer = NexTimer(0, 1, "tm0"); NexTimer startimer = NexTimer(0, 1, "tm0");
...@@ -35,10 +40,10 @@ ...@@ -35,10 +40,10 @@
NexText Hotend1 = NexText(1, 4, "t1"); NexText Hotend1 = NexText(1, 4, "t1");
NexText Hotend21 = NexText(1, 5, "h2"); NexText Hotend21 = NexText(1, 5, "h2");
NexText Hotend2 = NexText(1, 6, "t2"); NexText Hotend2 = NexText(1, 6, "t2");
NexText LedStatus = NexText(1, 7, "t4"); NexText LedStatus = NexText(1, 7, "status");
NexText LedCoord = NexText(1, 8, "t5"); NexText LedCoord1 = NexText(1, 8, "icoord");
NexPicture Menu = NexPicture(1, 9, "p0"); NexPicture Menu = NexPicture(1, 9, "p0");
NexPicture MSD = NexPicture(1, 10, "p1"); NexPicture MSD1 = NexPicture(1, 10, "p1");
NexPicture MSetup = NexPicture(1, 11, "p2"); NexPicture MSetup = NexPicture(1, 11, "p2");
NexPicture Hend0 = NexPicture(1, 12, "p3"); NexPicture Hend0 = NexPicture(1, 12, "p3");
NexHotspot hot0 = NexHotspot(1, 13, "hot0"); NexHotspot hot0 = NexHotspot(1, 13, "hot0");
...@@ -49,10 +54,14 @@ ...@@ -49,10 +54,14 @@
NexPicture Fanpic = NexPicture(1, 18, "p6"); NexPicture Fanpic = NexPicture(1, 18, "p6");
NexVar Hotend = NexVar(1, 19, "he"); NexVar Hotend = NexVar(1, 19, "he");
NexVar Bed = NexVar(1, 20, "bed"); NexVar Bed = NexVar(1, 20, "bed");
NexVar Fan = NexVar(1, 21, "fn");
NexTimer fantimer = NexTimer(1, 22, "tm0"); NexTimer fantimer = NexTimer(1, 22, "tm0");
NexProgressBar sdbar = NexProgressBar(1, 23, "j0"); NexProgressBar sdbar = NexProgressBar(1, 23, "j0");
NexPicture NPlay = NexPicture(1, 24, "p7"); NexPicture NPlay = NexPicture(1, 24, "p7");
NexPicture NStop = NexPicture(1, 25, "p8"); NexPicture NStop = NexPicture(1, 25, "p8");
NexVar SD = NexVar(1, 26, "sd");
NexVar RFID = NexVar(1, 27, "rfid");
NexPicture Feedpic = NexPicture(1, 18, "p9");
// Page 2 Temp // Page 2 Temp
NexText set0 = NexText(2, 2, "set0"); NexText set0 = NexText(2, 2, "set0");
...@@ -62,6 +71,7 @@ ...@@ -62,6 +71,7 @@
NexVar set1 = NexVar(2, 17, "set1"); NexVar set1 = NexVar(2, 17, "set1");
// Page 3 Menu // Page 3 Menu
NexPicture MSD3 = NexPicture(3, 2, "p1");
NexPicture Exit1 = NexPicture(3, 4, "p3"); NexPicture Exit1 = NexPicture(3, 4, "p3");
// Page 4 SDCard // Page 4 SDCard
...@@ -85,9 +95,11 @@ ...@@ -85,9 +95,11 @@
NexHotspot ScrollDown = NexHotspot(4, 22, "m1"); NexHotspot ScrollDown = NexHotspot(4, 22, "m1");
// Page 5 Setup // Page 5 Setup
NexPicture MSD5 = NexPicture(5, 2, "p1");
NexPicture Exit3 = NexPicture(5, 4, "p3"); NexPicture Exit3 = NexPicture(5, 4, "p3");
// Page 6 Move // Page 6 Move
NexPicture MSD6 = NexPicture(6, 2, "p1");
NexPicture XYHome = NexPicture(6, 5, "p4"); NexPicture XYHome = NexPicture(6, 5, "p4");
NexPicture XYUp = NexPicture(6, 6, "p5"); NexPicture XYUp = NexPicture(6, 6, "p5");
NexPicture XYRight = NexPicture(6, 7, "p6"); NexPicture XYRight = NexPicture(6, 7, "p6");
...@@ -97,14 +109,23 @@ ...@@ -97,14 +109,23 @@
NexPicture ZUp = NexPicture(6, 11, "p10"); NexPicture ZUp = NexPicture(6, 11, "p10");
NexPicture ZDown = NexPicture(6, 12, "p11"); NexPicture ZDown = NexPicture(6, 12, "p11");
NexVar movecmd = NexVar(6, 18, "vacmd"); NexVar movecmd = NexVar(6, 18, "vacmd");
NexText LedCoord6 = NexText(6, 19, "mcoord");
// Page 7 Feed
NexVar Feedrate = NexVar(7, 1, "feedrate");
NexPicture Feedok = NexPicture(7, 3, "p0");
NexTouch *nex_listen_list[] = NexTouch *nex_listen_list[] =
{ {
&Pstart, &Pstart,
&Menu, &Menu,
&MSD, &MSD1,
&MSD3,
&MSD5,
&MSD6,
&MSetup, &MSetup,
&Fanpic, &Fanpic,
&Feedpic,
&NPlay, &NPlay,
&NStop, &NStop,
&hot0, &hot0,
...@@ -134,6 +155,7 @@ ...@@ -134,6 +155,7 @@
&ZHome, &ZHome,
&ZUp, &ZUp,
&ZDown, &ZDown,
&Feedok,
NULL NULL
}; };
...@@ -168,45 +190,53 @@ ...@@ -168,45 +190,53 @@
}; };
void setpageInfo() { void setpageInfo() {
if (NextionPage == 0) {
Pinfo.show(); Pinfo.show();
PageInfo = true; #if HAS(TEMP_0)
#if ENABLED(NEXTION_GFX)
#if MECH(DELTA)
gfx_clear((X_MAX_POS) * 2, (Y_MAX_POS) * 2, Z_MAX_POS);
#else
gfx_clear(X_MAX_POS, Y_MAX_POS, Z_MAX_POS);
#endif
#endif
#if HAS_TEMP_0
Hotend.setValue(1); Hotend.setValue(1);
#endif #endif
#if HAS_TEMP_1 #if HAS(TEMP_1)
Hotend.setValue(2); Hotend.setValue(2);
#endif #endif
#if HAS_TEMP_2 #if HAS(TEMP_2)
Hotend.setValue(3); Hotend.setValue(3);
#elif HAS_TEMP_BED #elif HAS(TEMP_BED)
Hotend21.setText("BED");
Bed.setValue(1); Bed.setValue(1);
Hotend21.setText("BED");
#endif
Feedrate.setValue(100);
#if HAS(FAN)
Fan.setValue(1);
#endif #endif
lcd_setstatus(lcd_status_message); lcd_setstatus(lcd_status_message);
} }
Pinfo.show();
NextionPage = 1;
#if ENABLED(NEXTION_GFX)
#if MECH(DELTA)
gfx_clear((X_MAX_POS) * 2, (Y_MAX_POS) * 2, Z_MAX_POS);
#else
gfx_clear(X_MAX_POS, Y_MAX_POS, Z_MAX_POS);
#endif
#endif
}
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
void printrowsd(uint8_t row, const bool folder, const char* filename) { void printrowsd(uint8_t row, const bool folder, const char* filename) {
if (folder) { if (folder) {
folder_list[row]->setPic(18); folder_list[row]->setShow();
row_list[row]->attachPop(sdfolderPopCallback, row_list[row]); row_list[row]->attachPop(sdfolderPopCallback, row_list[row]);
} else if (filename == "") { } else if (filename == "") {
folder_list[row]->setPic(17); folder_list[row]->setHide();
row_list[row]->detachPop(); row_list[row]->detachPop();
} else { } else {
folder_list[row]->setPic(17); folder_list[row]->setHide();
row_list[row]->attachPop(sdfilePopCallback, row_list[row]); row_list[row]->attachPop(sdfilePopCallback, row_list[row]);
} }
row_list[row]->setText(filename); row_list[row]->setText(filename);
...@@ -218,12 +248,12 @@ ...@@ -218,12 +248,12 @@
card.getWorkDirName(); card.getWorkDirName();
if (fullName[0] != '/') { if (fullName[0] != '/') {
Folderup.setPic(20); Folderup.setShow();
Folderup.attachPop(sdfolderUpPopCallback); Folderup.attachPop(sdfolderUpPopCallback);
sdfolder.setText(fullName); sdfolder.setText(fullName);
} else { } else {
Folderup.detachPop(); Folderup.detachPop();
Folderup.setPic(19); Folderup.setHide();
sdfolder.setText(""); sdfolder.setText("");
} }
...@@ -239,8 +269,23 @@ ...@@ -239,8 +269,23 @@
sendCommand("ref 0"); sendCommand("ref 0");
} }
static void setpagesdcard() { static void menu_action_sdfile(const char* filename) {
PageInfo = false; char cmd[30];
char* c;
sprintf_P(cmd, PSTR("M23 %s"), filename);
for(c = &cmd[4]; *c; c++) *c = tolower(*c);
enqueuecommand(cmd);
enqueuecommands_P(PSTR("M24"));
setpageInfo();
}
static void menu_action_sddirectory(const char* filename) {
card.chdir(filename);
setpageSDPopCallback(&MSD1);
}
void setpageSDPopCallback(void *ptr) {
NextionPage = 4;
Psdcard.show(); Psdcard.show();
uint16_t fileCnt = card.getnrfilenames(); uint16_t fileCnt = card.getnrfilenames();
...@@ -267,21 +312,6 @@ ...@@ -267,21 +312,6 @@
setrowsdcard(number); setrowsdcard(number);
} }
static void menu_action_sdfile(const char* filename) {
char cmd[30];
char* c;
sprintf_P(cmd, PSTR("M23 %s"), filename);
for(c = &cmd[4]; *c; c++) *c = tolower(*c);
enqueuecommand(cmd);
enqueuecommands_P(PSTR("M24"));
setpageInfo();
}
static void menu_action_sddirectory(const char* filename) {
card.chdir(filename);
setpagesdcard();
}
void sdfilePopCallback(void *ptr) { void sdfilePopCallback(void *ptr) {
memset(buffer, 0, sizeof(buffer)); memset(buffer, 0, sizeof(buffer));
...@@ -322,9 +352,8 @@ ...@@ -322,9 +352,8 @@
void sdfolderUpPopCallback(void *ptr) { void sdfolderUpPopCallback(void *ptr) {
card.updir(); card.updir();
setpagesdcard(); setpageSDPopCallback(&MSD1);
} }
#endif #endif
void ExitPopCallback(void *ptr) { void ExitPopCallback(void *ptr) {
...@@ -337,7 +366,7 @@ ...@@ -337,7 +366,7 @@
void hotPopCallback(void *ptr) { void hotPopCallback(void *ptr) {
Ptemp.show(); Ptemp.show();
PageInfo = false; NextionPage = 2;
memset(buffer, 0, sizeof(buffer)); memset(buffer, 0, sizeof(buffer));
if (ptr == &hot0) { if (ptr == &hot0) {
if (degTargetHotend(0) != 0) { if (degTargetHotend(0) != 0) {
...@@ -397,18 +426,17 @@ ...@@ -397,18 +426,17 @@
void setpagePopCallback(void *ptr) { void setpagePopCallback(void *ptr) {
if (ptr == &Menu) { if (ptr == &Menu) {
PageInfo = false; NextionPage = 3;
Pmenu.show(); Pmenu.show();
} }
else if (ptr == &MSetup) { else if (ptr == &MSetup) {
PageInfo = false; NextionPage = 5;
Psetup.show(); Psetup.show();
} }
else if (ptr == &Feedpic) {
#if ENABLED(SDSUPPORT) NextionPage = 7;
else if (ptr == &MSD) Pfeed.show();
setpagesdcard(); }
#endif
} }
void setfanPopCallback(void *ptr) { void setfanPopCallback(void *ptr) {
...@@ -422,12 +450,13 @@ ...@@ -422,12 +450,13 @@
enqueuecommands_P(PSTR("G91")); enqueuecommands_P(PSTR("G91"));
enqueuecommands_P(buffer); enqueuecommands_P(buffer);
enqueuecommands_P(PSTR("G90")); enqueuecommands_P(PSTR("G90"));
NextionPage = 6;
} }
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
void PlayPausePopCallback(void *ptr) { void PlayPausePopCallback(void *ptr) {
if (card.cardOK && card.isFileOpen()) { if (card.cardOK && card.isFileOpen()) {
if (card.sdprinting) if (IS_SD_PRINTING)
card.pausePrint(); card.pausePrint();
else else
card.startPrint(); card.startPrint();
...@@ -443,6 +472,8 @@ ...@@ -443,6 +472,8 @@
#endif #endif
void lcd_init() { void lcd_init() {
HAL::delayMilliseconds(2000);
for (uint8_t i = 0; i < 10; i++) { for (uint8_t i = 0; i < 10; i++) {
NextionON = nexInit(); NextionON = nexInit();
if (NextionON) break; if (NextionON) break;
...@@ -468,7 +499,10 @@ ...@@ -468,7 +499,10 @@
#endif #endif
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
MSD.attachPop(setpagePopCallback, &MSD); MSD1.attachPop(setpageSDPopCallback);
MSD3.attachPop(setpageSDPopCallback);
MSD5.attachPop(setpageSDPopCallback);
MSD6.attachPop(setpageSDPopCallback);
sdlist.attachPop(sdlistPopCallback); sdlist.attachPop(sdlistPopCallback);
ScrollUp.attachPop(sdlistPopCallback); ScrollUp.attachPop(sdlistPopCallback);
ScrollDown.attachPop(sdlistPopCallback); ScrollDown.attachPop(sdlistPopCallback);
...@@ -489,6 +523,7 @@ ...@@ -489,6 +523,7 @@
Menu.attachPop(setpagePopCallback, &Menu); Menu.attachPop(setpagePopCallback, &Menu);
MSetup.attachPop(setpagePopCallback, &MSetup); MSetup.attachPop(setpagePopCallback, &MSetup);
Feedpic.attachPop(setpagePopCallback, &Feedpic);
Fanpic.attachPop(setfanPopCallback, &Fanpic); Fanpic.attachPop(setfanPopCallback, &Fanpic);
m11.attachPop(sethotPopCallback, &m11); m11.attachPop(sethotPopCallback, &m11);
tup.attachPop(settempPopCallback, &tup); tup.attachPop(settempPopCallback, &tup);
...@@ -501,6 +536,7 @@ ...@@ -501,6 +536,7 @@
ZHome.attachPop(setmovePopCallback); ZHome.attachPop(setmovePopCallback);
ZUp.attachPop(setmovePopCallback); ZUp.attachPop(setmovePopCallback);
ZDown.attachPop(setmovePopCallback); ZDown.attachPop(setmovePopCallback);
Feedok.attachPop(ExitPopCallback);
startimer.enable(); startimer.enable();
} }
...@@ -548,7 +584,7 @@ ...@@ -548,7 +584,7 @@
else else
strcat(buffer, "---"); strcat(buffer, "---");
strcat(buffer, TEST(axis_known_position, Z_AXIS) || !TEST(axis_was_homed, Z_AXIS) ? PSTR("Z ") : PSTR("? ")); strcat(buffer, TEST(axis_known_position, Z_AXIS) || !TEST(axis_was_homed, Z_AXIS) ? PSTR(" Z ") : PSTR("? "));
if (TEST(axis_was_homed, Z_AXIS)) { if (TEST(axis_was_homed, Z_AXIS)) {
valuetemp = ftostr32sp(current_position[Z_AXIS] + 0.00001); valuetemp = ftostr32sp(current_position[Z_AXIS] + 0.00001);
strcat(buffer, valuetemp); strcat(buffer, valuetemp);
...@@ -556,7 +592,8 @@ ...@@ -556,7 +592,8 @@
else else
strcat(buffer, "---"); strcat(buffer, "---");
LedCoord.setText(buffer); LedCoord1.setText(buffer);
LedCoord6.setText(buffer);
} }
void lcd_update() { void lcd_update() {
...@@ -567,51 +604,78 @@ ...@@ -567,51 +604,78 @@
millis_t ms = millis(); millis_t ms = millis();
if (ms > next_lcd_update_ms && PageInfo) { if (ms > next_lcd_update_ms) {
if (NextionPage == 1) {
if (fanSpeed > 0) fantimer.enable(); if (fanSpeed > 0) fantimer.enable();
else fantimer.disable(); else fantimer.disable();
#if HAS_TEMP_0 uint32_t* temp_feedrate;
Feedrate.getValue(temp_feedrate);
feedrate_multiplier = (int)temp_feedrate;
#if HAS(TEMP_0)
temptoLCD(0, degHotend(0), degTargetHotend(0)); temptoLCD(0, degHotend(0), degTargetHotend(0));
#endif #endif
#if HAS_TEMP_1 #if HAS(TEMP_1)
temptoLCD(1, degHotend(1), degTargetHotend(1)); temptoLCD(1, degHotend(1), degTargetHotend(1));
#endif #endif
#if HAS_TEMP_2 #if HAS(TEMP_2)
temptoLCD(2, degHotend(2), degTargetHotend(2)); temptoLCD(2, degHotend(2), degTargetHotend(2));
#elif HAS_TEMP_BED #elif HAS(TEMP_BED)
temptoLCD(2, degBed(), degTargetBed()); temptoLCD(2, degBed(), degTargetBed());
#endif #endif
coordtoLCD(); coordtoLCD();
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
if (card.cardOK) {
MSD.setPic(7);
NPlay.setPic(38);
NStop.setPic(41);
}
else {
MSD.setPic(6);
NPlay.setPic(39);
NStop.setPic(42);
}
if (card.isFileOpen()) { if (card.isFileOpen()) {
if (card.sdprinting) { if (SDstatus != 2) {
SDstatus = 2;
SD.setValue(2);
NPlay.setShow();
NStop.setShow();
}
if(IS_SD_PRINTING) {
// Progress bar solid part // Progress bar solid part
sdbar.setValue(card.percentDone()); sdbar.setValue(card.percentDone());
NPlay.setPic(40); NPlay.setPic(15);
// Estimate End Time
uint16_t time = (millis() - print_job_start_ms) / 60000;
uint16_t end_time = (time * (100 - card.percentDone())) / card.percentDone();
if (end_time > (60 * 23)) {
lcd_setstatus("End --:--");
}
else if (end_time >= 0) {
char temp[30];
sprintf_P(temp, PSTR("End %i:%i"), end_time / 60, end_time%60);
lcd_setstatus(temp);
}
} }
else { else {
NPlay.setPic(38); NPlay.setPic(14);
} }
} }
else if (card.cardOK && SDstatus != 1) {
SDstatus = 1;
SD.setValue(1);
MSD1.setShow();
NPlay.setHide();
NStop.setHide();
}
else if (!card.cardOK && SDstatus != 0) {
SDstatus = 0;
SD.setValue(0);
MSD1.setHide();
NPlay.setHide();
NStop.setHide();
}
#endif #endif
}
else if (NextionPage == 6) {
coordtoLCD();
}
next_lcd_update_ms = ms + LCD_UPDATE_INTERVAL; next_lcd_update_ms = ms + LCD_UPDATE_INTERVAL;
} }
} }
...@@ -638,17 +702,17 @@ ...@@ -638,17 +702,17 @@
#if ENABLED(NEXTION_GFX) #if ENABLED(NEXTION_GFX)
void gfx_clear(float x, float y, float z) { void gfx_clear(float x, float y, float z) {
if (PageInfo && (Printing || IS_SD_PRINTING)) if ((NextionPage == 1) && (Printing || IS_SD_PRINTING))
gfx.clear(x, y, z); gfx.clear(x, y, z);
} }
void gfx_cursor_to(float x, float y, float z) { void gfx_cursor_to(float x, float y, float z) {
if (PageInfo && (Printing || IS_SD_PRINTING)) if ((NextionPage == 1) && (Printing || IS_SD_PRINTING))
gfx.cursor_to(x, y, z); gfx.cursor_to(x, y, z);
} }
void gfx_line_to(float x, float y, float z){ void gfx_line_to(float x, float y, float z){
if (PageInfo && (Printing || IS_SD_PRINTING)) if ((NextionPage == 1) && (Printing || IS_SD_PRINTING))
gfx.line_to(VC_TOOL, x, y, z); gfx.line_to(VC_TOOL, x, y, z);
} }
#endif #endif
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#define NEXTIONLCD_H #define NEXTIONLCD_H
#if ENABLED(NEXTION) #if ENABLED(NEXTION)
#define LCD_UPDATE_INTERVAL 5000 #define LCD_UPDATE_INTERVAL 4000
void ExitPopCallback(void *ptr); void ExitPopCallback(void *ptr);
void setpagePopCallback(void *ptr); void setpagePopCallback(void *ptr);
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#endif #endif
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
void setpageSDPopCallback(void *ptr);
void sdlistPopCallback(void *ptr); void sdlistPopCallback(void *ptr);
void sdfilePopCallback(void *ptr); void sdfilePopCallback(void *ptr);
void sdfolderPopCallback(void *ptr); void sdfolderPopCallback(void *ptr);
......
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