// ========= Start of MainDwg.cpp generated code ========== // MainDwg.cpp from MainDwg by pfodGUIdesigner V1.0.4192 /* (c)2022 Forward Computing and Control Pty. Ltd. NSW Australia, www.forward.com.au This code is not warranted to be fit for any purpose. You may only use it at your own risk. This code may be freely used for both private and commercial use Provided this copyright is maintained. */ #ifndef MAINDWG_H #include "MainDwg.h" #endif MainDwg::MainDwg(pfodParser* parserPtr, pfodDwgs* dwgsPtr) : pfodDrawing(parserPtr, dwgsPtr) { forceReload = true; // force reload on reboot, e.g. reprogrammed } bool MainDwg::processDwgCmds() { // return true if handled else false byte dwgCmd = parserPtr->parseDwgCmd(); // dwgCmd is '\0' if this is NOT a dwg cmd if (!dwgCmd) { return false; // not dwg cmd not handled } return false; // not handled } void MainDwg::drawDwg0() { dwgsPtr->circle().color(0).offset(0.00,0.00).radius(5.00).send(); } void MainDwg::updateDwg() { } bool MainDwg::sendDwg() { if (!parserPtr->cmdEquals(*this)) { return false; // not this dwg's loadCmd } // else // ======== begin debugging Serial.print(" sendDwg() cmd "); Serial.print((char*)parserPtr->getCmd()); if (parserPtr->isRefresh()) { Serial.print(" isRefresh"); } byte* argPtr = parserPtr->getFirstArg(); if (*argPtr) { Serial.print(" args: "); while (*argPtr) { Serial.print(" "); Serial.print((char*)argPtr); argPtr = parserPtr->getNextArg(argPtr); } } Serial.print("\n"); //======= end debugging ======= if (parserPtr->isRefresh() && !forceReload) { // refresh and not forceReload just send update sendUpdate(); } else { forceReload = false; // long pfodLongRtn = 0; uint8_t* pfodFirstArg = parserPtr->getFirstArg(); // may point to \0 if no arguments in this msg. parserPtr->parseLong(pfodFirstArg, &pfodLongRtn); // parse first arg as a long sendFullDrawing(pfodLongRtn); } return true; } void MainDwg::sendFullDrawing(long dwgIdx) { if (dwgIdx == 0) { dwgsPtr->start(50, 50, dwgsPtr->WHITE, true); // the dwg size 50x50 and color (WHITE) are ignored when this drawing is inserted in the main dwg //true means more to come parserPtr->sendRefreshAndVersion(0); //need to set a version number for image refresh to work!! drawDwg0(); // dwgsPtr->end(); // if drawing msg is >1023 split it in to two or more parts and add extra else if (dwgIdx == .. ) blocks here } else if (dwgIdx == 1) { dwgsPtr->startUpdate(false); // always send update last so this is the last msg => false updateDwg(); // update with current state, // defined in display.cpp dwgsPtr->end(); } else { parserPtr->print(F("{}")); // always return somthing } } void MainDwg::sendUpdate() { dwgsPtr->startUpdate(); // dwg refresh updates must be <1024 bytes, i.e. can only be 1 msg updateDwg(); dwgsPtr->end(); } void MainDwg::printDwgCmdReceived(Print *outPtr) { if (!outPtr) { return; } outPtr->print(" touchZone cmd "); outPtr->print((const char*)parserPtr->getDwgCmd()); outPtr->print(" at "); outPtr->print("("); outPtr->print(parserPtr->getTouchedX()); outPtr->print(","); outPtr->print(parserPtr->getTouchedY()); outPtr->print(") "); if (parserPtr->isTouch()) { outPtr->print("touch type:TOUCHED"); } outPtr->println(); if (*parserPtr->getEditedText()) { // first char not '\0' outPtr->print(" Edited text '"); outPtr->print((const char*)parserPtr->getEditedText()); outPtr->println("'"); } } // ========= End of MainDwg.cpp generated code ==========