diff --git a/src/main.ino b/src/main.ino
@@ -51,6 +51,18 @@ std::vector<String> lines; // Possible rename to bufferLines ?
std::vector<bool> mentions;
std::vector<WiFiNetwork> wifiNetworks;
+// Global variables to cache preferences
+String irc_nickname;
+String irc_username;
+String irc_realname;
+String irc_server;
+int irc_port;
+bool irc_tls;
+String irc_channel;
+String irc_nickserv;
+String wifi_ssid;
+String wifi_password;
+
// IRC connection (These will eventually be set dynamically when we have a settings menu)
const char* server = "irc.supernets.org";
const int port = 6697;
@@ -63,6 +75,7 @@ const char* realname = "ACID DROP Firmware v0.1.0b"; // Need to eventually set t
// Timing variables
unsigned long infoScreenStartTime = 0;
+unsigned long configScreenStartTime = 0;
unsigned long joinChannelTime = 0;
unsigned long lastStatusUpdateTime = 0;
unsigned long lastActivityTime = 0;
@@ -73,6 +86,7 @@ const unsigned long INACTIVITY_TIMEOUT = 30000; // 30 seconds
// Dynamic variables
bool infoScreen = false;
+bool configScreen = false;
bool readyToJoinChannel = false;
bool screenOn = true;
int selectedNetworkIndex = 0;
@@ -121,6 +135,7 @@ void setup() {
preferences.begin("wifi", false);
ssid = preferences.getString("ssid", "");
password = preferences.getString("password", "");
+ preferences.end();
// Connect to WiFi if credentials are stored, otherwise scan for networks
if (ssid.length() > 0 && password.length() > 0) {
@@ -147,6 +162,12 @@ void loop() {
tft.fillScreen(TFT_BLACK);
displayLines(); // Redraw the previous buffer
}
+ } else if (configScreen) {
+ if (millis() - configScreenStartTime > 10000) { // 10 seconds
+ configScreen = false;
+ tft.fillScreen(TFT_BLACK);
+ displayLines(); // Redraw the previous buffer
+ }
} else {
// Handle keyboard input for WiFi if the SSID is empty still (aka not connected)
if (ssid.isEmpty()) {
@@ -170,6 +191,7 @@ void loop() {
if (WiFi.status() == WL_CONNECTED) {
displayCenteredText("CONNECTING TO " + String(server));
if (connectToIRC()) {
+ Serial.println("Connected to IRC!");
displayCenteredText("CONNECTED TO " + String(server));
sendIRC("NICK " + String(nick));
sendIRC("USER " + String(user) + " 0 * :" + String(realname));
@@ -212,7 +234,7 @@ void loop() {
// WiFi functions ---------------------------------------------------------------------------------
void connectToWiFi() {
- Serial.println("Connecting to WiFi...");
+ Serial.println("Connecting to WiFi network: " + ssid);
WiFi.begin(ssid.c_str(), password.c_str());
// Wait for the WiFi connection to complete (or timeout after 10 seconds)
@@ -225,7 +247,7 @@ void connectToWiFi() {
// Handle the connection result
if (WiFi.status() == WL_CONNECTED) {
- Serial.println("Connected to WiFi network: " + ssid);
+ Serial.println("Connected to WiFi!");
displayCenteredText("CONNECTED TO " + ssid);
// Sync time with NTP server
@@ -404,11 +426,11 @@ void handleWiFiSelection(char key) {
// IRC functions ----------------------------------------------------------------------------------
bool connectToIRC() {
if (useSSL) {
- Serial.println("Connecting to IRC with TLS...");
+ Serial.println("Connecting to IRC with TLS: " + String(server) + ":" + String(port));
client.setInsecure();
return client.connect(server, port);
} else {
- Serial.println("Connecting to IRC...");
+ Serial.println("Connecting to IRC: " + String(server) + ":" + String(port));
WiFiClient nonSecureClient;
return nonSecureClient.connect(server, port);
}
@@ -543,7 +565,100 @@ uint16_t getColorFromCode(int colorCode) {
case 2: return tft.color565(0, 0, 128); // Dark Blue (Navy)
case 3: return TFT_GREEN;
case 4: return TFT_RED;
-
+ case 5: return tft.color565(128, 0, 0); // Brown (Maroon)
+ case 6: return tft.color565(128, 0, 128); // Purple
+ case 7: return tft.color565(255, 165, 0); // Orange
+ case 8: return TFT_YELLOW;
+ case 9: return tft.color565(144, 238, 144); // Light Green
+ case 10: return tft.color565(0, 255, 255); // Cyan (Light Blue)
+ case 11: return tft.color565(224, 255, 255); // Light Cyan (Aqua)
+ case 12: return TFT_BLUE;
+ case 13: return tft.color565(255, 192, 203); // Pink (Light Purple)
+ case 14: return tft.color565(128, 128, 128); // Grey
+ case 15: return tft.color565(211, 211, 211); // Light Grey
+ case 16: return 0x4000;
+ case 17: return 0x4100;
+ case 18: return 0x4220;
+ case 19: return 0x3220;
+ case 20: return 0x0220;
+ case 21: return 0x0225;
+ case 22: return 0x0228;
+ case 23: return 0x0128;
+ case 24: return 0x0008;
+ case 25: return 0x2808;
+ case 26: return 0x4008;
+ case 27: return 0x4005;
+ case 28: return 0x7000;
+ case 29: return 0x71C0;
+ case 30: return 0x73A0;
+ case 31: return 0x53A0;
+ case 32: return 0x03A0;
+ case 33: return 0x03A9;
+ case 34: return 0x03AE;
+ case 35: return 0x020E;
+ case 36: return 0x000E;
+ case 37: return 0x480E;
+ case 38: return 0x700E;
+ case 39: return 0x7008;
+ case 40: return 0xB000;
+ case 41: return 0xB300;
+ case 42: return 0xB5A0;
+ case 43: return 0x7DA0;
+ case 44: return 0x05A0;
+ case 45: return 0x05AE;
+ case 46: return 0x05B6;
+ case 47: return 0x0316;
+ case 48: return 0x0016;
+ case 49: return 0x7016;
+ case 50: return 0xB016;
+ case 51: return 0xB00D;
+ case 52: return 0xF800;
+ case 53: return 0xFC60;
+ case 54: return 0xFFE0;
+ case 55: return 0xB7E0;
+ case 56: return 0x07E0;
+ case 57: return 0x07F4;
+ case 58: return 0x07FF;
+ case 59: return 0x047F;
+ case 60: return 0x001F;
+ case 61: return 0xA01F;
+ case 62: return 0xF81F;
+ case 63: return 0xF813;
+ case 64: return 0xFACB;
+ case 65: return 0xFDAB;
+ case 66: return 0xFFEE;
+ case 67: return 0xCFEC;
+ case 68: return 0x6FED;
+ case 69: return 0x67F9;
+ case 70: return 0x6FFF;
+ case 71: return 0x5DBF;
+ case 72: return 0x5ADF;
+ case 73: return 0xC2DF;
+ case 74: return 0xFB3F;
+ case 75: return 0xFAD7;
+ case 76: return 0xFCF3;
+ case 77: return 0xFE93;
+ case 78: return 0xFFF3;
+ case 79: return 0xE7F3;
+ case 80: return 0x9FF3;
+ case 81: return 0x9FFB;
+ case 82: return 0x9FFF;
+ case 83: return 0x9E9F;
+ case 84: return 0x9CFF;
+ case 85: return 0xDCFF;
+ case 86: return 0xFCFF;
+ case 87: return 0xFCBA;
+ case 88: return 0x0000;
+ case 89: return 0x1082;
+ case 90: return 0x2945;
+ case 91: return 0x31A6;
+ case 92: return 0x4A69;
+ case 93: return 0x632C;
+ case 94: return 0x8410;
+ case 95: return 0x9CF3;
+ case 96: return 0xBDF7;
+ case 97: return 0xE71C;
+ case 98: return 0xFFFF;
default: return TFT_WHITE;
}
}
@@ -925,6 +1040,11 @@ void handleKeyboardInput(char key) {
sendIRC("NICK " + newNick);
inputBuffer = "";
displayInputLine();
+ } else if (inputBuffer.startsWith("/config")) {
+ configScreen = true;
+ configScreenStartTime = millis();
+ //displayPreferences();
+ inputBuffer = "";
} else if (inputBuffer.startsWith("/info")) {
infoScreen = true;
infoScreenStartTime = millis();
@@ -1102,6 +1222,9 @@ void printDeviceInfo() {
}
// Print to Serial Monitor
+ Serial.println("MCU: ESP32-S3FN16R8");
+ Serial.println("LoRa Tranciever: Semtech SX1262 (915 MHz)"); // Need to set the frequency in pins.h
+ Serial.println("LCD: ST7789 SPI"); // Update this
Serial.println("Chip ID: " + String(chipId, HEX));
Serial.println("MAC Address: " + macAddress);
Serial.println("Chip Info: " + chipInfo);
|