Commit 4e9b158c authored by MagoKimbra's avatar MagoKimbra

Upgrade Nextion

parent da44d760
...@@ -2409,20 +2409,21 @@ NexPage page4 = NexPage(4, 0, "sdcard"); ...@@ -2409,20 +2409,21 @@ NexPage page4 = NexPage(4, 0, "sdcard");
NexPage page5 = NexPage(5, 0, "setup"); NexPage page5 = NexPage(5, 0, "setup");
// Text // Text
NexText Hotend0 = NexText(1, 1, "t0"); NexText Hotend0 = NexText(1, 1, "t0");
NexText Hotend1 = NexText(1, 4, "t1"); NexText Hotend1 = NexText(1, 4, "t1");
NexText Hotend2 = NexText(1, 5, "t2"); NexText Hotend2 = NexText(1, 5, "t2");
NexText Hotend21 = NexText(1, 6, "h2"); NexText Hotend21 = NexText(1, 6, "h2");
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 set1 = NexText(2, 15, "set1");
NexText sdrow0 = NexText(4, 3, "t1"); NexText sdrow0 = NexText(4, 3, "t0");
NexText sdrow1 = NexText(4, 4, "t2"); NexText sdrow1 = NexText(4, 4, "t1");
NexText sdrow2 = NexText(4, 5, "t3"); NexText sdrow2 = NexText(4, 5, "t2");
NexText sdrow3 = NexText(4, 6, "t4"); NexText sdrow3 = NexText(4, 6, "t3");
NexText sdrow4 = NexText(4, 7, "t5"); NexText sdrow4 = NexText(4, 7, "t4");
NexText sdrow5 = NexText(4, 8, "t6"); NexText sdrow5 = NexText(4, 8, "t5");
NexText sdcmd = NexText(4, 15, "sdcmd");
// Picture // Picture
NexPicture Menu = NexPicture(1, 10, "p0"); NexPicture Menu = NexPicture(1, 10, "p0");
...@@ -2475,6 +2476,12 @@ NexTouch *nex_listen_list[] = ...@@ -2475,6 +2476,12 @@ NexTouch *nex_listen_list[] =
&tup, &tup,
&tdown, &tdown,
&sdlist, &sdlist,
&sdrow0,
&sdrow1,
&sdrow2,
&sdrow3,
&sdrow4,
&sdrow5,
NULL NULL
}; };
...@@ -2496,121 +2503,157 @@ void setpageInfo() { ...@@ -2496,121 +2503,157 @@ void setpageInfo() {
sendCommand("bed.val=1"); sendCommand("bed.val=1");
#endif #endif
#if ENABLED(SDSUPPORT)
MSD.setPic(7);
#endif
lcd_setstatus(lcd_status_message); lcd_setstatus(lcd_status_message);
} }
void setrowsdcard(uint32_t number = 0) { #if ENABLED(SDSUPPORT)
uint16_t fileCnt = card.getnrfilenames(); void printrowsd(uint8_t row, const bool folder, const char* filename, char* longFilename) {
uint32_t ii = 0; String cmd;
if (longFilename[0])
filename = longFilename;
ECHO_EMV("FILE CONT = ", fileCnt); switch (row) {
card.getWorkDirName(); case 0:
for (uint8_t i = 0; i < 6; i++) { {
ii = i + number; if (folder) {
if (ii <= fileCnt) { Folder0.setPic(18);
card.getfilename(ii); sdrow0.attachPop(sdfolderPopCallback);
switch (i) {
case 0:
{
if (card.filenameIsDir) {
Folder0.setPic(18);
sdrow0.setText(card.filename);
}
else {
Folder0.setPic(17);
sdrow0.setText(card.longFilename);
}
break;
} }
case 1: else {
{ Folder0.setPic(17);
if (card.filenameIsDir) { sdrow0.attachPop(sdfilePopCallback);
Folder1.setPic(18);
sdrow1.setText(card.filename);
}
else {
Folder1.setPic(17);
sdrow1.setText(card.longFilename);
}
break;
} }
case 2: sdrow0.setText(filename);
{ }
if (card.filenameIsDir) { case 1:
Folder2.setPic(18); {
sdrow2.setText(card.filename); if (folder) {
} Folder1.setPic(18);
else { sdrow1.attachPop(sdfolderPopCallback);
Folder2.setPic(17);
sdrow2.setText(card.longFilename);
}
break;
} }
case 3: else {
{ Folder1.setPic(17);
if (card.filenameIsDir) { sdrow1.attachPop(sdfilePopCallback);
Folder3.setPic(18);
sdrow3.setText(card.filename);
}
else {
Folder3.setPic(17);
sdrow3.setText(card.longFilename);
}
break;
} }
case 4: sdrow1.setText(filename);
{ }
if (card.filenameIsDir) { case 2:
Folder4.setPic(18); {
sdrow4.setText(card.filename); if (folder) {
} Folder2.setPic(18);
else { sdrow2.attachPop(sdfolderPopCallback);
Folder4.setPic(17);
sdrow4.setText(card.longFilename);
}
break;
} }
case 5: else {
{ Folder2.setPic(17);
if (card.filenameIsDir) { sdrow2.attachPop(sdfilePopCallback);
Folder5.setPic(18); }
sdrow5.setText(card.filename); sdrow2.setText(filename);
} }
else { case 3:
Folder5.setPic(17); {
sdrow5.setText(card.longFilename); if (folder) {
} Folder3.setPic(18);
break; sdrow3.attachPop(sdfolderPopCallback);
}
else {
Folder3.setPic(17);
sdrow3.attachPop(sdfilePopCallback);
}
sdrow3.setText(filename);
}
case 4:
{
if (folder) {
Folder4.setPic(18);
sdrow4.attachPop(sdfolderPopCallback);
} }
else {
Folder4.setPic(17);
sdrow4.attachPop(sdfilePopCallback);
}
sdrow4.setText(filename);
}
case 5:
{
if (folder) {
Folder5.setPic(18);
sdrow5.attachPop(sdfolderPopCallback);
}
else {
Folder5.setPic(17);
sdrow5.attachPop(sdfilePopCallback);
}
sdrow5.setText(filename);
} }
} }
} }
sendCommand("ref 0");
}
void setpagesdcard() { static void setrowsdcard(uint32_t number = 0) {
PageInfo = false; uint16_t fileCnt = card.getnrfilenames();
page4.show(); uint32_t i = 0;
uint16_t fileCnt = card.getnrfilenames(); card.getWorkDirName();
if (fileCnt <= 6) for (uint8_t row = 0; row < 6; row++) {
slidermaxval = 1; i = row + number;
else if (i <= fileCnt) {
slidermaxval = (fileCnt / 6) + 1; card.getfilename(i);
printrowsd(row, card.filenameIsDir, card.filename, card.longFilename);
}
}
sendCommand("ref 0");
}
static void setpagesdcard() {
PageInfo = false;
page4.show();
uint16_t fileCnt = card.getnrfilenames();
const int sliderhig = 230 / slidermaxval; if (fileCnt <= 6)
slidermaxval = 1;
else
slidermaxval = fileCnt - 6;
sdlist.setMaxValue(slidermaxval);
sdlist.setValue(slidermaxval);
sdlist.setMaxValue(slidermaxval); setrowsdcard();
sdlist.setValue(slidermaxval); }
sdlist.setHigValue(sliderhig);
setrowsdcard(); void sdlistPopCallback(void *ptr) {
uint32_t number = 0;
sdlist.getValue(&number);
number = slidermaxval - 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) {
memset(buffer, 0, sizeof(buffer));
sdcmd.getText(buffer, sizeof(buffer));
menu_action_sdfile(buffer);
}
void sdfolderPopCallback(void *ptr) {
memset(buffer, 0, sizeof(buffer));
sdcmd.getText(buffer, sizeof(buffer));
menu_action_sddirectory(buffer);
}
#endif
void page0PopCallback(void *ptr) { void page0PopCallback(void *ptr) {
setpageInfo(); setpageInfo();
} }
...@@ -2678,10 +2721,13 @@ void sethotPopCallback(void *ptr) { ...@@ -2678,10 +2721,13 @@ void sethotPopCallback(void *ptr) {
void setpagePopCallback(void *ptr) { void setpagePopCallback(void *ptr) {
if (ptr == &Menu) if (ptr == &Menu)
sendCommand("page menu"); sendCommand("page menu");
if (ptr == &MSD)
setpagesdcard();
if (ptr == &MSetup) if (ptr == &MSetup)
sendCommand("page setup"); sendCommand("page setup");
#if ENABLED(SDSUPPORT)
if (ptr == &MSD)
setpagesdcard();
#endif
} }
void setfanPopCallback(void *ptr) { void setfanPopCallback(void *ptr) {
...@@ -2689,13 +2735,6 @@ void setfanPopCallback(void *ptr) { ...@@ -2689,13 +2735,6 @@ void setfanPopCallback(void *ptr) {
else fanSpeed = 255; else fanSpeed = 255;
} }
void sdlistPopCallback(void *ptr) {
uint32_t number = 0;
sdlist.getValue(&number);
number = slidermaxval - number;
setrowsdcard(number);
}
millis_t next_lcd_update_ms; millis_t next_lcd_update_ms;
void lcd_init() { void lcd_init() {
...@@ -2707,7 +2746,10 @@ void lcd_init() { ...@@ -2707,7 +2746,10 @@ void lcd_init() {
ECHO_LM(DB, "Nextion LCD connected!"); ECHO_LM(DB, "Nextion LCD connected!");
page0.attachPop(page0PopCallback); page0.attachPop(page0PopCallback);
sdlist.attachPop(sdlistPopCallback);
#if ENABLED(SDSUPPORT)
sdlist.attachPop(sdlistPopCallback);
#endif
#if HAS_TEMP_0 #if HAS_TEMP_0
hot0.attachPop(hotPopCallback, &hot0); hot0.attachPop(hotPopCallback, &hot0);
...@@ -2843,6 +2885,13 @@ void lcd_update() { ...@@ -2843,6 +2885,13 @@ void lcd_update() {
coordtoLCD(); coordtoLCD();
#if ENABLED(SDSUPPORT)
if (card.cardOK)
MSD.setPic(7);
else
MSD.setPic(6);
#endif
next_lcd_update_ms = ms + LCD_UPDATE_INTERVAL; next_lcd_update_ms = ms + LCD_UPDATE_INTERVAL;
} }
} }
......
...@@ -119,7 +119,6 @@ ...@@ -119,7 +119,6 @@
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 sdlistPopCallback(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);
...@@ -127,6 +126,12 @@ ...@@ -127,6 +126,12 @@
void lcd_setalertstatuspgm(const char* message); void lcd_setalertstatuspgm(const char* message);
void lcd_reset_alert_level(); void lcd_reset_alert_level();
#if ENABLED(SDSUPPORT)
void sdlistPopCallback(void *ptr);
void sdfilePopCallback(void *ptr);
void sdfolderPopCallback(void *ptr);
#endif
FORCE_INLINE bool lcd_hasstatus() { return false; } FORCE_INLINE bool lcd_hasstatus() { return false; }
FORCE_INLINE void lcd_buttons_update() {} FORCE_INLINE void lcd_buttons_update() {}
FORCE_INLINE bool lcd_detected(void) { return true; } FORCE_INLINE bool lcd_detected(void) { return true; }
......
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