From 3c87e6515ae8068664b17f723bf0a49a2674a5fd Mon Sep 17 00:00:00 2001 From: richonguzman Date: Fri, 16 Jun 2023 19:08:25 -0400 Subject: [PATCH] new screen 0.1 --- data/igate_conf.json | 32 +++++++------- src/LoRa_APRS_iGate.cpp | 8 ++-- src/aprs_is_utils.cpp | 16 ++++--- src/aprs_is_utils.h | 2 +- src/configuration.cpp | 2 +- src/display.cpp | 92 +++++++++++++++++++++++++++++++++++++++++ src/display.h | 6 ++- src/utils.cpp | 45 +++++++++++--------- src/utils.h | 2 +- src/wifi_utils.cpp | 8 ++-- 10 files changed, 159 insertions(+), 54 deletions(-) diff --git a/data/igate_conf.json b/data/igate_conf.json index 70f50ca..e1c72bd 100644 --- a/data/igate_conf.json +++ b/data/igate_conf.json @@ -1,28 +1,28 @@ { - "callsign": "NOCALL-10", - "stationMode": 1, + "callsign": "CD2RXU-11", + "stationMode": 2, "iGateComment": "LoRa_APRS_iGate", "wifi": { "AP": [ - { "ssid": "WIFI_1", - "password": "password_1", - "latitude": 0.0000000, - "longitude": 0.0000000 + { "ssid": "Richon", + "password": "k4fPnmg5qnyf", + "latitude": -33.0338131, + "longitude": -71.5737237 }, - { "ssid": "WIFI_2", - "password": "password_2", - "latitude": 0.0000000, - "longitude": 0.0000000 + { "ssid": "Jimenita", + "password": "mg6wyMhqRnxk", + "latitude": -33.0312492, + "longitude": -71.5796215 } ] }, "digi": { "comment": "LoRa_APRS_Digirepeater", - "latitude": 0.0000000, - "longitude": 0.0000000 + "latitude": -33.0338131, + "longitude": -71.5737237 }, "aprs_is": { - "passcode": "VWXYZ", + "passcode": "23201", "server": "soam.aprs2.net", "port": 14580, "reportingDistance": 30 @@ -41,12 +41,12 @@ "timeout": 4 }, "syslog": { - "active": false, - "server": "192.168.0.100", + "active": true, + "server": "192.168.20.10", "port": 514 }, "other": { - "beaconInterval": 15, + "beaconInterval": 5, "rememberStationTime": 30 } } \ No newline at end of file diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index 9dd6b99..26c67df 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -19,7 +19,7 @@ Configuration Config; WiFiClient espClient; -String versionDate = "2023.06.13"; +String versionDate = "2023.06.16"; int myWiFiAPIndex = 0; int myWiFiAPSize = Config.wifiAPs.size(); WiFi_AP *currentWiFi = &Config.wifiAPs[myWiFiAPIndex]; @@ -34,7 +34,7 @@ uint32_t lastScreenOn = millis(); std::vector lastHeardStation; std::vector lastHeardStation_temp; -String firstLine, secondLine, thirdLine, fourthLine, iGateBeaconPacket; +String firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, eigthLine, iGateBeaconPacket; void setup() { Serial.begin(115200); @@ -55,8 +55,8 @@ void loop() { if (!espClient.connected()) { APRS_IS_Utils::connect(); } - secondLine = APRS_IS_Utils::checkStatus(); - show_display(firstLine, secondLine, thirdLine, fourthLine, 0); + APRS_IS_Utils::checkStatus(); + show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, eigthLine, 0); while (espClient.connected()) { Utils::checkDisplayInterval(); Utils::checkBeaconInterval(); diff --git a/src/aprs_is_utils.cpp b/src/aprs_is_utils.cpp index bee0fe3..321baeb 100644 --- a/src/aprs_is_utils.cpp +++ b/src/aprs_is_utils.cpp @@ -16,6 +16,10 @@ extern String firstLine; extern String secondLine; extern String thirdLine; extern String fourthLine; +extern String fifthLine; +extern String sixthLine; +extern String seventhLine; +extern String eigthLine; namespace APRS_IS_Utils { @@ -43,7 +47,7 @@ void connect(){ } } -String checkStatus() { +void checkStatus() { String wifiState, aprsisState; if (WiFi.status() == WL_CONNECTED) { wifiState = "OK"; @@ -63,7 +67,7 @@ String checkStatus() { } lastScreenOn = millis(); } - return "WiFi: " + wifiState + "/ APRS-IS: " + aprsisState; + secondLine = "WiFi: " + wifiState + "/ APRS-IS: " + aprsisState; } String createPacket(String packet) { @@ -110,7 +114,7 @@ void processLoRaPacket(String packet) { } LoRa_Utils::sendNewPacket("APRS", QUERY_Utils::process(receivedMessage, Sender, "LoRa")); lastScreenOn = millis(); - show_display(firstLine, secondLine, "Callsign = " + Sender, "TYPE --> QUERY", 0); + show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, "Callsign = " + Sender, "TYPE --> QUERY", 0); } } } @@ -125,7 +129,7 @@ void processLoRaPacket(String packet) { Serial.println(" ---> Uploaded to APRS-IS"); STATION_Utils::updateLastHeard(Sender); Utils::typeOfPacket(aprsPacket); - show_display(firstLine, secondLine, thirdLine, fourthLine, 0); + show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, eigthLine, 0); } } } else { @@ -167,7 +171,7 @@ void processAPRSISPacket(String packet) { lastScreenOn = millis(); delay(500); espClient.write(queryAnswer.c_str()); - show_display(firstLine, secondLine, "Callsign = " + Sender, "TYPE --> QUERY", 1000); + show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, "Callsign = " + Sender, "TYPE --> QUERY", 1000); } } else { Serial.print("Received from APRS-IS : " + packet); @@ -176,7 +180,7 @@ void processAPRSISPacket(String packet) { display_toggle(true); lastScreenOn = millis(); Utils::typeOfPacket(packet); - show_display(firstLine, secondLine, Sender + " -> " + Addressee, fourthLine, 0); + show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, Sender + " -> " + Addressee, eigthLine, 0); } } } diff --git a/src/aprs_is_utils.h b/src/aprs_is_utils.h index d97ae21..6a2e428 100644 --- a/src/aprs_is_utils.h +++ b/src/aprs_is_utils.h @@ -6,7 +6,7 @@ namespace APRS_IS_Utils { void connect(); -String checkStatus(); +void checkStatus(); String createPacket(String unprocessedPacket); void processLoRaPacket(String packet); void processAPRSISPacket(String packet); diff --git a/src/configuration.cpp b/src/configuration.cpp index 972078a..7557151 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -67,7 +67,7 @@ void Configuration::readFile(fs::FS &fs, const char *fileName) { void Configuration::validateConfigFile(String currentBeaconCallsign) { if (currentBeaconCallsign == "NOCALL-10") { Serial.println("Change Callsign in /data/igate_conf.json"); - show_display("ERROR", "Change your settings", "'igate_conf.json'", "--> File System image", 0); + show_display("------- ERROR -------", "Change your settings", "on 'igate_conf.json'", "--> File System image", 0); while (true) { delay(1000); } diff --git a/src/display.cpp b/src/display.cpp index 5b37ad8..857f80e 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -90,4 +90,96 @@ void show_display(String line1, String line2, String line3, String line4, int wa display.ssd1306_command(1); display.display(); delay(wait); +} + +void show_display(String line1, String line2, String line3, String line4, String line5, int wait) { + display.clearDisplay(); + display.setTextColor(WHITE); + display.setTextSize(1); + display.setCursor(0, 0); + display.println(line1); + display.setCursor(0, 8); + display.println(line2); + display.setCursor(0, 16); + display.println(line3); + display.setCursor(0, 24); + display.println(line4); + display.setCursor(0, 32); + display.println(line5); + display.ssd1306_command(SSD1306_SETCONTRAST); + display.ssd1306_command(1); + display.display(); + delay(wait); +} + +void show_display(String line1, String line2, String line3, String line4, String line5, String line6, int wait) { + display.clearDisplay(); + display.setTextColor(WHITE); + display.setTextSize(1); + display.setCursor(0, 0); + display.println(line1); + display.setCursor(0, 8); + display.println(line2); + display.setCursor(0, 16); + display.println(line3); + display.setCursor(0, 24); + display.println(line4); + display.setCursor(0, 32); + display.println(line5); + display.setCursor(0, 40); + display.println(line6); + display.ssd1306_command(SSD1306_SETCONTRAST); + display.ssd1306_command(1); + display.display(); + delay(wait); +} + +void show_display(String line1, String line2, String line3, String line4, String line5, String line6, String line7, int wait) { + display.clearDisplay(); + display.setTextColor(WHITE); + display.setTextSize(1); + display.setCursor(0, 0); + display.println(line1); + display.setCursor(0, 8); + display.println(line2); + display.setCursor(0, 16); + display.println(line3); + display.setCursor(0, 24); + display.println(line4); + display.setCursor(0, 32); + display.println(line5); + display.setCursor(0, 40); + display.println(line6); + display.setCursor(0, 48); + display.println(line7); + display.ssd1306_command(SSD1306_SETCONTRAST); + display.ssd1306_command(1); + display.display(); + delay(wait); +} + +void show_display(String line1, String line2, String line3, String line4, String line5, String line6, String line7, String line8, int wait) { + display.clearDisplay(); + display.setTextColor(WHITE); + display.setTextSize(1); + display.setCursor(0, 0); + display.println(line1); + display.setCursor(0, 8); + display.println(line2); + display.setCursor(0, 16); + display.println(line3); + display.setCursor(0, 24); + display.println(line4); + display.setCursor(0, 32); + display.println(line5); + display.setCursor(0, 40); + display.println(line6); + display.setCursor(0, 48); + display.println(line7); + display.setCursor(0, 56); + display.println(line8); + display.ssd1306_command(SSD1306_SETCONTRAST); + display.ssd1306_command(1); + display.display(); + delay(wait); } \ No newline at end of file diff --git a/src/display.h b/src/display.h index cea9a55..f0e7630 100644 --- a/src/display.h +++ b/src/display.h @@ -4,7 +4,7 @@ #include #define SCREEN_WIDTH 128 // OLED display width, in pixels -#define SCREEN_HEIGHT 32 // OLED display height, in pixels +#define SCREEN_HEIGHT 64 // OLED display height, in pixels #define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin) #define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32 @@ -15,5 +15,9 @@ void show_display(String line1, int wait = 0); void show_display(String line1, String line2, int wait = 0); void show_display(String line1, String line2, String line3, int wait = 0); void show_display(String line1, String line2, String line3, String line4, int wait = 0); +void show_display(String line1, String line2, String line3, String line4, String line5, int wait = 0); +void show_display(String line1, String line2, String line3, String line4, String line5, String line6, int wait = 0); +void show_display(String line1, String line2, String line3, String line4, String line5, String line6, String line7, int wait = 0); +void show_display(String line1, String line2, String line3, String line4, String line5, String line6, String line7, String line8, int wait = 0); #endif \ No newline at end of file diff --git a/src/utils.cpp b/src/utils.cpp index a02964f..f66d6b1 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -22,6 +22,10 @@ extern String firstLine; extern String secondLine; extern String thirdLine; extern String fourthLine; +extern String fifthLine; +extern String sixthLine; +extern String seventhLine; +extern String eigthLine; extern uint32_t lastBeaconTx; extern uint32_t lastScreenOn; extern bool beacon_update; @@ -51,24 +55,24 @@ void processStatus() { statusAfterBoot = false; } +String getLocalIP() { + return "IP : " + String(WiFi.localIP()[0]) + "." + String(WiFi.localIP()[1]) + "." + String(WiFi.localIP()[2]) + "." + String(WiFi.localIP()[3]); +} + void setupDiplay() { setup_display(); digitalWrite(greenLed,HIGH); Serial.println("\nStarting iGate: " + Config.callsign + " Version: " + versionDate); - show_display(" LoRa APRS iGate", " Richonguzman", " -- CD2RXU --", " " + versionDate, 4000); + show_display("", " LoRa APRS iGate", "", " Richonguzman", "", " -- CD2RXU --", "", " " + versionDate, 4000); digitalWrite(greenLed,LOW); firstLine = "LoRa iGate: " + Config.callsign; if (stationMode==3 || stationMode==4) { secondLine = ""; } else { secondLine = ""; - } - thirdLine = ""; - fourthLine = " listening..."; -} - -String getLocalIP() { - return "IP : " + String(WiFi.localIP()[0]) + "." + String(WiFi.localIP()[1]) + "." + String(WiFi.localIP()[2]) + "." + String(WiFi.localIP()[3]); + } + seventhLine = ""; + eigthLine = " listening..."; } void checkBeaconInterval() { @@ -78,17 +82,18 @@ void checkBeaconInterval() { } if (beacon_update) { display_toggle(true); - //thirdLine = getLocalIP(); Serial.println("---- Sending iGate Beacon ----"); if (stationMode==1 || stationMode==2) { - show_display(firstLine, secondLine, thirdLine, "SENDING iGate BEACON", 1000); thirdLine = getLocalIP(); - fourthLine = " listening..."; + seventhLine = ""; + show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, "SENDING iGate BEACON", 1000); + eigthLine = " listening..."; espClient.write((iGateBeaconPacket + "\n").c_str()); - show_display(firstLine, secondLine, thirdLine, fourthLine, 0); + show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, eigthLine, 0); } else if (stationMode==3 || stationMode==4) { - show_display(firstLine, secondLine, thirdLine, "SENDING iGate BEACON", 0); - fourthLine = " listening..."; + seventhLine = ""; + show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, "SENDING iGate BEACON", 0); + eigthLine = " listening..."; if (stationMode == 4) { LoRa_Utils::changeFreqTx(); } @@ -127,18 +132,18 @@ void validateDigiFreqs() { void typeOfPacket(String packet) { if (stationMode==1 || stationMode==2) { - thirdLine = "Callsign = " + packet.substring(0,packet.indexOf(">")); + seventhLine = "Callsign = " + packet.substring(0,packet.indexOf(">")); } else { - thirdLine = "Callsign = " + packet.substring(3,packet.indexOf(">")); + seventhLine = "Callsign = " + packet.substring(3,packet.indexOf(">")); } if (packet.indexOf("::") >= 10) { - fourthLine = "TYPE ----> MESSAGE"; + eigthLine = "TYPE ----> MESSAGE"; } else if (packet.indexOf(":>") >= 10) { - fourthLine = "TYPE ----> NEW STATUS"; + eigthLine = "TYPE ----> NEW STATUS"; } else if (packet.indexOf(":!") >= 10 || packet.indexOf(":=") >= 10) { - fourthLine = "TYPE ----> GPS BEACON"; + eigthLine = "TYPE ----> GPS BEACON"; } else { - fourthLine = "TYPE ----> ??????????"; + eigthLine = "TYPE ----> ??????????"; } } diff --git a/src/utils.h b/src/utils.h index d05fbc5..78758f8 100644 --- a/src/utils.h +++ b/src/utils.h @@ -6,8 +6,8 @@ namespace Utils { void processStatus(); -void setupDiplay(); String getLocalIP(); +void setupDiplay(); void checkBeaconInterval(); void checkDisplayInterval(); void validateDigiFreqs(); diff --git a/src/wifi_utils.cpp b/src/wifi_utils.cpp index 4c65208..9e264f3 100644 --- a/src/wifi_utils.cpp +++ b/src/wifi_utils.cpp @@ -29,7 +29,7 @@ void startWiFi() { WiFi.disconnect(); delay(500); unsigned long start = millis(); - show_display("", "Connecting to Wifi:", currentWiFi->ssid + " ...", 0); + show_display("", "", "Connecting to Wifi:", "", currentWiFi->ssid + " ...", 0); Serial.print("\nConnecting to '"); Serial.print(currentWiFi->ssid); Serial.println("' WiFi ..."); WiFi.begin(currentWiFi->ssid.c_str(), currentWiFi->password.c_str()); while (WiFi.status() != WL_CONNECTED) { @@ -48,7 +48,7 @@ void startWiFi() { currentWiFi = &Config.wifiAPs[myWiFiAPIndex]; start = millis(); Serial.print("\nConnecting to WiFi '"); Serial.print(currentWiFi->ssid); Serial.println("' ..."); - show_display("", "Connecting to Wifi:", currentWiFi->ssid + " ...", 0); + show_display("", "", "Connecting to Wifi:", "", currentWiFi->ssid + " ...", 0); WiFi.disconnect(); WiFi.begin(currentWiFi->ssid.c_str(), currentWiFi->password.c_str()); } @@ -56,7 +56,7 @@ void startWiFi() { digitalWrite(greenLed,LOW); Serial.print("Connected as "); Serial.println(WiFi.localIP()); - show_display("", " Connected!", " ( " + currentWiFi->ssid + " )", 1000); + show_display("", "", " Connected!!", 1000); } void setup() { @@ -78,7 +78,7 @@ void setup() { btStop(); } else { Serial.println("stationMode ---> NOT VALID, check '/data/igate_conf.json'"); - show_display("stationMode Not Valid", "change it on : /data/", "igate_conf.json", 0); + show_display("------- ERROR -------", "stationMode Not Valid", "change it on : /data/", "igate_conf.json", 0); while (1); } }