Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

curentPageID, lastPageID #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions src/NextionX2.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,22 @@ class NextionComPort {
*/
void cls(uint16_t color);

/**
* @brief return currentPage
*
* add printh 0x24 pageID FF FF FF to preinit event
* pageID in hex
*
*/

uint8_t getCurrentPageID();

/**
* @brief return lastPage
*
*/
uint8_t getLastPageID();

/**
* @brief draw a line
*
Expand Down Expand Up @@ -379,6 +395,8 @@ class NextionComPort {
uint8_t inputPointer = 0;
uint8_t counterFF = 0;
uint8_t lastPointer = 0;
uint8_t currentPageID;
uint8_t lastPageID;
listElement_t lastList[MAX_LIST_LENGTH];

friend NextionComponent;
Expand Down Expand Up @@ -527,6 +545,10 @@ void NextionComPort::update() {
uint8_t listpos = indexByGuid(component.guid);
if (listpos < MAX_LIST_LENGTH) lastList[listpos].component->callback(inputString[3]);
}
else if ((length == 2) && (inputString[0] == 0x24)) {
lastPageID = currentPageID;
currentPageID = inputString[1];
}
}

void NextionComPort::addComponentList(NextionComponent *component) {
Expand All @@ -538,6 +560,16 @@ void NextionComPort::addComponentList(NextionComponent *component) {
}
}

uint8_t NextionComPort::getCurrentPageID()
{
return currentPageID;
}

uint8_t NextionComPort::getLastPageID()
{
return lastPageID;
}

void NextionComPort::dbgLoop() {
if ((length == 1) && ((inputString[0] < 0x25) || (inputString[0] > 0x85))) {
if (inputString[0] == 1) debugSerial->write("Success\n");
Expand All @@ -561,6 +593,10 @@ void NextionComPort::dbgLoop() {
debugSerial->println(inputString[2], DEC);
debugSerial->println();
}
else if ((length == 2) && (inputString[0] == 0x24)) {
debugSerial->write(" currentPageID ");
debugSerial->println(inputString[1], DEC);
}
}

uint8_t NextionComPort::readNextionReturn() {
Expand Down