Commit 4e9b158c authored by MagoKimbra's avatar MagoKimbra

Upgrade Nextion

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