Skip to content

Commit

Permalink
update to display h and cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
richonguzman committed Aug 14, 2024
1 parent 22203a7 commit 39276b0
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 55 deletions.
20 changes: 10 additions & 10 deletions src/A7670_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
bool checkModemOn() {
bool modemReady = false;
Serial.print("Starting Modem ... ");
show_display(firstLine, "Starting Modem...", " ", " ", 0);
displayShow(firstLine, "Starting Modem...", " ", " ", 0);

pinMode(A7670_ResetPin, OUTPUT); //A7670 Reset
digitalWrite(A7670_ResetPin, LOW);
Expand All @@ -60,7 +60,7 @@
modemReady = true;
i = 1;
Serial.println("Modem Ready!\n");
show_display(firstLine, "Starting Modem...", "---> Modem Ready", " ", 0);
displayShow(firstLine, "Starting Modem...", "---> Modem Ready", " ", 0);
return true;
}
}
Expand All @@ -78,7 +78,7 @@
delay(1000);
//setup_gps(); // if gps active / won't be need for now
} else {
show_display(firstLine, "Starting Modem...", "---> Failed !!!", " ", 0);
displayShow(firstLine, "Starting Modem...", "---> Failed !!!", " ", 0);
Serial.println(F("*********** Failed to connect to the modem! ***********"));
}
}
Expand All @@ -98,26 +98,26 @@
//Serial.println(response); // DEBUG of Modem AT message
if(response.indexOf("verified") >= 0) {
Serial.println("Logged! (User Validated)\n");
show_display(firstLine, "Connecting APRS-IS...", "---> Logged!", " ", 1000);
displayShow(firstLine, "Connecting APRS-IS...", "---> Logged!", " ", 1000);
Serial.println("#################### APRS-IS FEED ####################");
validAT = true;
i = 1;
delayATMessage = 0;
} else if (ATMessage == "AT+NETOPEN" && response.indexOf("OK") >= 0) {
Serial.println("Port Open!");
show_display(firstLine, "Opening Port...", "---> Port Open", " ", 0);
displayShow(firstLine, "Opening Port...", "---> Port Open", " ", 0);
validAT = true;
i = 1;
delayATMessage = 0;
} else if (ATMessage == "AT+NETOPEN" && response.indexOf("Network is already opened") >= 0) {
Serial.println("Port Open! (was already opened)");
show_display(firstLine, "Opening Port...", "---> Port Open", " ", 0);
displayShow(firstLine, "Opening Port...", "---> Port Open", " ", 0);
validAT = true;
i = 1;
delayATMessage = 0;
} else if (ATMessage.indexOf("AT+CIPOPEN") == 0 && response.indexOf("PB DONE") >= 0) {
Serial.println("Contacted!");
show_display(firstLine, "Connecting APRS-IS...", "---> Contacted", " ", 0);
displayShow(firstLine, "Connecting APRS-IS...", "---> Contacted", " ", 0);
validAT = true;
i = 1;
delayATMessage = 0;
Expand Down Expand Up @@ -155,17 +155,17 @@
Serial.println("-----> Connecting to APRS IS");
while (!modemStartUp) {
Serial.print("Opening Port... ");
show_display(firstLine, "Opening Port...", " ", " ", 0);
displayShow(firstLine, "Opening Port...", " ", " ", 0);
modemStartUp = checkATResponse("AT+NETOPEN");
delay(2000);
} while (!serverStartUp) {
Serial.print("Connecting APRS-IS Server... ");
show_display(firstLine, "Connecting APRS-IS...", " ", " ", 0);
displayShow(firstLine, "Connecting APRS-IS...", " ", " ", 0);
serverStartUp = checkATResponse("AT+CIPOPEN=0,\"TCP\",\"" + String(Config.aprs_is.server) + "\"," + String(Config.aprs_is.port));
delay(2000);
} while (!userBytesSended) {
Serial.print("Writing User Login Data ");
show_display(firstLine, "Connecting APRS-IS...", "---> User Login Data", " ", 0);
displayShow(firstLine, "Connecting APRS-IS...", "---> User Login Data", " ", 0);
userBytesSended = checkATResponse("AT+CIPSEND=0," + String(loginInfo.length()+1));
delay(2000);
} while (!modemLoggedToAPRSIS) {
Expand Down
4 changes: 2 additions & 2 deletions src/LoRa_APRS_iGate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void setup() {
GPS_Utils::generateBeacons();

#ifdef STARTUP_DELAY // (TEST) just to wait for WiFi init of Routers
show_display("", " STARTUP DELAY ...", "", "", 0);
displayShow("", " STARTUP DELAY ...", "", "", 0);
delay(STARTUP_DELAY * 60 * 1000);
#endif

Expand Down Expand Up @@ -181,7 +181,7 @@ void loop() {

STATION_Utils::processOutputPacketBuffer();

show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
displayShow(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
Utils::checkRebootTime();
Utils::checkSleepByLowBatteryVoltage(1);
}
20 changes: 10 additions & 10 deletions src/aprs_is_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ namespace APRS_IS_Utils {
wifiState = "AP";
}
if (!Config.display.alwaysOn && Config.display.timeout != 0) {
display_toggle(true);
displayToggle(true);
}
lastScreenOn = millis();
}
Expand All @@ -99,7 +99,7 @@ namespace APRS_IS_Utils {
}
#endif
if(aprsisState == "--" && !Config.display.alwaysOn && Config.display.timeout != 0) {
display_toggle(true);
displayToggle(true);
lastScreenOn = millis();
}
}
Expand Down Expand Up @@ -160,11 +160,11 @@ namespace APRS_IS_Utils {
}
if (receivedMessage.indexOf("?") == 0) {
if (!Config.display.alwaysOn && Config.display.timeout != 0) {
display_toggle(true);
displayToggle(true);
}
STATION_Utils::addToOutputPacketBuffer(QUERY_Utils::process(receivedMessage, sender, false, thirdParty));
lastScreenOn = millis();
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, "Callsign = " + sender, "TYPE --> QUERY", 0);
displayShow(firstLine, secondLine, thirdLine, fourthLine, fifthLine, "Callsign = " + sender, "TYPE --> QUERY", 0);
return true;
}
else {
Expand Down Expand Up @@ -192,7 +192,7 @@ namespace APRS_IS_Utils {
if (!queryMessage) {
const String& aprsPacket = buildPacketToUpload(packet);
if (!Config.display.alwaysOn && Config.display.timeout != 0) {
display_toggle(true);
displayToggle(true);
}
lastScreenOn = millis();
#ifdef HAS_A7670
Expand All @@ -203,7 +203,7 @@ namespace APRS_IS_Utils {
upload(aprsPacket);
#endif
Utils::println("---> Uploaded to APRS-IS");
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
displayShow(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
}
}
}
Expand Down Expand Up @@ -294,7 +294,7 @@ namespace APRS_IS_Utils {
String queryAnswer = QUERY_Utils::process(receivedMessage, Sender, true, false);
//Serial.println("---> QUERY Answer : " + queryAnswer.substring(0,queryAnswer.indexOf("\n")));
if (!Config.display.alwaysOn && Config.display.timeout != 0) {
display_toggle(true);
displayToggle(true);
}
lastScreenOn = millis();
delay(500);
Expand All @@ -318,16 +318,16 @@ namespace APRS_IS_Utils {
Utils::print("Received Message from APRS-IS : " + packet);
if (STATION_Utils::wasHeard(Addressee)) {
STATION_Utils::addToOutputPacketBuffer(buildPacketToTx(packet, 1));
display_toggle(true);
displayToggle(true);
lastScreenOn = millis();
Utils::typeOfPacket(packet, 1); // APRS-LoRa
}
}
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
displayShow(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
} else if (Config.aprs_is.objectsToRF && packet.indexOf(":;") > 0) {
Utils::println("Received Object from APRS-IS : " + packet);
STATION_Utils::addToOutputPacketBuffer(buildPacketToTx(packet, 5));
display_toggle(true);
displayToggle(true);
lastScreenOn = millis();
Utils::typeOfPacket(packet, 1); // APRS-LoRa
}
Expand Down
2 changes: 1 addition & 1 deletion src/bme_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ namespace BME_Utils {
}
}
if (!wxModuleFound) {
show_display("ERROR", "", "BME/BMP/Si7021 sensor active", "but no sensor found...", 2000);
displayShow("ERROR", "", "BME/BMP/Si7021 sensor active", "but no sensor found...", 2000);
Serial.println("BME/BMP/Si7021 sensor Active in config but not found! Check Wiring");
} else {
switch (wxModuleType) {
Expand Down
2 changes: 1 addition & 1 deletion src/digi_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ namespace DIGI_Utils {
} else {
STATION_Utils::addToOutputPacketBuffer(loraPacket);
}
display_toggle(true);
displayToggle(true);
lastScreenOn = millis();
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void cleanTFT() {
#endif
}

void setup_display() {
void displaySetup() {
#ifdef HAS_DISPLAY
delay(500);
#ifdef HAS_TFT
Expand Down Expand Up @@ -83,7 +83,7 @@ void setup_display() {
#endif
}

void display_toggle(bool toggle) {
void displayToggle(bool toggle) {
#ifdef HAS_DISPLAY
if (toggle) {
#ifdef HAS_TFT
Expand Down Expand Up @@ -128,7 +128,7 @@ bool shouldCleanTFT(const String& header, const String& line1, const String& lin
}
}

void show_display(const String& header, const String& line1, const String& line2, const String& line3, int wait) {
void displayShow(const String& header, const String& line1, const String& line2, const String& line3, int wait) {
#ifdef HAS_DISPLAY
const String* const lines[] = {&line1, &line2, &line3};
#ifdef HAS_TFT
Expand Down Expand Up @@ -162,7 +162,7 @@ void show_display(const String& header, const String& line1, const String& line2
#endif
}

void show_display(const String& header, const String& line1, const String& line2, const String& line3, const String& line4, const String& line5, const String& line6, int wait) {
void displayShow(const String& header, const String& line1, const String& line2, const String& line3, const String& line4, const String& line5, const String& line6, int wait) {
#ifdef HAS_DISPLAY
const String* const lines[] = {&line1, &line2, &line3, &line4, &line5, &line6};
#ifdef HAS_TFT
Expand Down
8 changes: 4 additions & 4 deletions src/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32

void cleanTFT();
void setup_display();
void display_toggle(bool toggle);
void displaySetup();
void displayToggle(bool toggle);

bool shouldCleanTFT(const String& header, const String& line1, const String& line2, const String& line3);
bool shouldCleanTFT(const String& header, const String& line1, const String& line2, const String& line3, const String& line4, const String& line5, const String& line6);

void show_display(const String& header, const String& line1, const String& line2, const String& line3, int wait = 0);
void show_display(const String& header, const String& line1, const String& line2, const String& line3, const String& line4, const String& line5, const String& line6, int wait = 0);
void displayShow(const String& header, const String& line1, const String& line2, const String& line3, int wait = 0);
void displayShow(const String& header, const String& line1, const String& line2, const String& line3, const String& line4, const String& line5, const String& line6, int wait = 0);

#endif
2 changes: 1 addition & 1 deletion src/gps_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace GPS_Utils {

void generateBeacons() {
if (Config.callsign.indexOf("NOCALL-10") != 0 && !Utils::checkValidCallsign(Config.callsign)) {
show_display("***** ERROR ******", "CALLSIGN = NOT VALID!", "", "Only Rx Mode Active", 3000);
displayShow("***** ERROR ******", "CALLSIGN = NOT VALID!", "", "Only Rx Mode Active", 3000);
Config.loramodule.txActive = false;
Config.aprs_is.messagesToRF = false;
Config.aprs_is.objectsToRF = false;
Expand Down
14 changes: 7 additions & 7 deletions src/ota_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,31 @@ namespace OTA_Utils {

void onOTAStart() {
Serial.println("OTA update started!");
display_toggle(true);
displayToggle(true);
lastScreenOn = millis();
show_display("", "", "", " OTA update started!", "", "", "", 1000);
displayShow("", "", "", " OTA update started!", "", "", "", 1000);
isUpdatingOTA = true;
}

void onOTAProgress(size_t current, size_t final) {
if (millis() - ota_progress_millis > 1000) {
display_toggle(true);
displayToggle(true);
lastScreenOn = millis();
ota_progress_millis = millis();
Serial.printf("OTA Progress Current: %u bytes, Final: %u bytes\n", current, final);
show_display("", "", " OTA Progress : " + String((current*100)/final) + "%", "", "", "", "", 100);
displayShow("", "", " OTA Progress : " + String((current*100)/final) + "%", "", "", "", "", 100);
}
}

void onOTAEnd(bool success) {
display_toggle(true);
displayToggle(true);
lastScreenOn = millis();
if (success) {
Serial.println("OTA update finished successfully!");
show_display("", "", " OTA update success!", "", " Rebooting ...", "", "", 4000);
displayShow("", "", " OTA update success!", "", " Rebooting ...", "", "", 4000);
} else {
Serial.println("There was an error during OTA update!");
show_display("", "", " OTA update fail!", "", "", "", "", 4000);
displayShow("", "", " OTA update fail!", "", "", "", "", 4000);
}
isUpdatingOTA = false;
}
Expand Down
16 changes: 8 additions & 8 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ namespace Utils {
}

void setupDisplay() {
setup_display();
displaySetup();
#ifdef INTERNAL_LED_PIN
digitalWrite(INTERNAL_LED_PIN,HIGH);
#endif
Serial.println("\nStarting Station: " + Config.callsign + " Version: " + versionDate);
show_display(" LoRa APRS", "", " ( iGATE & DIGI )", "", "", "Richonguzman / CA2RXU", " " + versionDate, 4000);
displayShow(" LoRa APRS", "", "", " ( iGATE & DIGI )", "", "" , " CA2RXU " + versionDate, 4000);
#ifdef INTERNAL_LED_PIN
digitalWrite(INTERNAL_LED_PIN,LOW);
#endif
Expand All @@ -110,7 +110,7 @@ namespace Utils {

if (beaconUpdate) {
if (!Config.display.alwaysOn && Config.display.timeout != 0) {
display_toggle(true);
displayToggle(true);
}
Utils::println("-- Sending Beacon to APRSIS --");

Expand Down Expand Up @@ -172,7 +172,7 @@ namespace Utils {
}

if (Config.aprs_is.active && Config.beacon.sendViaAPRSIS && !backUpDigiMode) {
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, "SENDING IGATE BEACON", 0);
displayShow(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, "SENDING IGATE BEACON", 0);
seventhLine = " listening...";
#ifdef HAS_A7670
A7670_Utils::uploadToAPRSIS(beaconPacket);
Expand All @@ -182,7 +182,7 @@ namespace Utils {
}

if (Config.beacon.sendViaRF || backUpDigiMode) {
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, "SENDING DIGI BEACON", 0);
displayShow(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, "SENDING DIGI BEACON", 0);
seventhLine = " listening...";
STATION_Utils::addToOutputPacketBuffer(secondaryBeaconPacket);
}
Expand All @@ -200,14 +200,14 @@ namespace Utils {
void checkDisplayInterval() {
uint32_t lastDisplayTime = millis() - lastScreenOn;
if (!Config.display.alwaysOn && lastDisplayTime >= Config.display.timeout * 1000) {
display_toggle(false);
displayToggle(false);
}
}

void validateFreqs() {
if (Config.loramodule.txFreq != Config.loramodule.rxFreq && abs(Config.loramodule.txFreq - Config.loramodule.rxFreq) < 125000) {
Serial.println("Tx Freq less than 125kHz from Rx Freq ---> NOT VALID");
show_display("Tx Freq is less than ", "125kHz from Rx Freq", "device will autofix", "and then reboot", 1000);
displayShow("Tx Freq is less than ", "125kHz from Rx Freq", "device will autofix", "and then reboot", 1000);
Config.loramodule.txFreq = Config.loramodule.rxFreq; // Inform about that but then change the TX QRG to RX QRG and reset the device
Config.writeFile();
ESP.restart();
Expand Down Expand Up @@ -313,7 +313,7 @@ namespace Utils {
Serial.println("\n\n*** Sleeping Low Battey Voltage ***\n\n");
esp_sleep_enable_timer_wakeup(30 * 60 * 1000000); // sleep 30 min
if (mode == 1) {
display_toggle(false);
displayToggle(false);
}
#ifdef VEXT_CTRL
#ifndef HELTEC_WSL_V3
Expand Down
4 changes: 2 additions & 2 deletions src/web_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ namespace WEB_Utils {
AsyncWebServerResponse *response = request->beginResponse(302, "text/html", "");
response->addHeader("Location", "/");
request->send(response);
display_toggle(false);
displayToggle(false);
ESP.restart();
}

Expand All @@ -222,7 +222,7 @@ namespace WEB_Utils {

request->send(200, "text/plain", "Beacon will be sent in a while");
} else if (type == "reboot") {
display_toggle(false);
displayToggle(false);
ESP.restart();
} else {
request->send(404, "text/plain", "Not Found");
Expand Down
Loading

0 comments on commit 39276b0

Please sign in to comment.