Added more verbose serial logging for debug
This commit is contained in:
parent
56186e4e33
commit
74f3d443b9
@ -35,7 +35,10 @@ A compiled "release" will be done once I finish somoe fo the basic features, but
|
|||||||
5. Flash the device: `esptool.py --chip esp32-s3 --port /dev/ttyUSB0 --baud 115200 write_flash -z 0x1000 firmware.bin`
|
5. Flash the device: `esptool.py --chip esp32-s3 --port /dev/ttyUSB0 --baud 115200 write_flash -z 0x1000 firmware.bin`
|
||||||
6. Press the RST *(reset)* button ont he device.
|
6. Press the RST *(reset)* button ont he device.
|
||||||
|
|
||||||
###### Debugging over Serial
|
# Connecting to WiFi
|
||||||
|
The device will scan for WiFi networks on boot. Once the list is displayed, you can scroll up and down the list with the "u" key for UP and the "d" key for down.
|
||||||
|
|
||||||
|
# Debugging over Serial
|
||||||
1. Install screen: `apt-get install screen` *(or whatever package manager you use)*
|
1. Install screen: `apt-get install screen` *(or whatever package manager you use)*
|
||||||
2. `screen /dev/ttyAMC0 9600`
|
2. `screen /dev/ttyAMC0 9600`
|
||||||
|
|
||||||
@ -55,6 +58,7 @@ A compiled "release" will be done once I finish somoe fo the basic features, but
|
|||||||
- [ ] XBM icons for status bar items
|
- [ ] XBM icons for status bar items
|
||||||
- [ ] Allow specifying the IRC server, port, TLS, nick, etc...
|
- [ ] Allow specifying the IRC server, port, TLS, nick, etc...
|
||||||
- [ ] Screensaver
|
- [ ] Screensaver
|
||||||
|
- [X] Serial debug logs
|
||||||
|
|
||||||
###### Applications
|
###### Applications
|
||||||
- [X] IRC Client
|
- [X] IRC Client
|
||||||
|
28
src/main.ino
28
src/main.ino
@ -70,6 +70,10 @@ struct WiFiNetwork {
|
|||||||
std::vector<WiFiNetwork> wifiNetworks;
|
std::vector<WiFiNetwork> wifiNetworks;
|
||||||
int selectedNetworkIndex = 0;
|
int selectedNetworkIndex = 0;
|
||||||
|
|
||||||
|
void debugPrint(String message) {
|
||||||
|
Serial.println(message);
|
||||||
|
}
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
Serial.println("Booting device...");
|
Serial.println("Booting device...");
|
||||||
@ -81,10 +85,13 @@ void setup() {
|
|||||||
digitalWrite(TFT_BL, HIGH); // Turn on the backlight initially
|
digitalWrite(TFT_BL, HIGH); // Turn on the backlight initially
|
||||||
|
|
||||||
Wire.begin(BOARD_I2C_SDA, BOARD_I2C_SCL);
|
Wire.begin(BOARD_I2C_SDA, BOARD_I2C_SCL);
|
||||||
|
|
||||||
tft.begin();
|
tft.begin();
|
||||||
tft.setRotation(1);
|
tft.setRotation(1);
|
||||||
tft.invertDisplay(1);
|
tft.invertDisplay(1);
|
||||||
|
|
||||||
|
Serial.println("TFT initialized");
|
||||||
|
|
||||||
displayXBM();
|
displayXBM();
|
||||||
delay(3000);
|
delay(3000);
|
||||||
displayCenteredText("SCANNING WIFI");
|
displayCenteredText("SCANNING WIFI");
|
||||||
@ -176,6 +183,7 @@ int renderFormattedMessage(String message, int cursorY, int lineHeight, bool hig
|
|||||||
}
|
}
|
||||||
|
|
||||||
void turnOffScreen() {
|
void turnOffScreen() {
|
||||||
|
Serial.println("Screen turned off");
|
||||||
tft.writecommand(TFT_DISPOFF); // Turn off display
|
tft.writecommand(TFT_DISPOFF); // Turn off display
|
||||||
tft.writecommand(TFT_SLPIN); // Put display into sleep mode
|
tft.writecommand(TFT_SLPIN); // Put display into sleep mode
|
||||||
digitalWrite(TFT_BL, LOW); // Turn off the backlight (Assuming TFT_BL is the backlight pin)
|
digitalWrite(TFT_BL, LOW); // Turn off the backlight (Assuming TFT_BL is the backlight pin)
|
||||||
@ -183,6 +191,7 @@ void turnOffScreen() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void turnOnScreen() {
|
void turnOnScreen() {
|
||||||
|
Serial.println("Screen turned on");
|
||||||
digitalWrite(TFT_BL, HIGH); // Turn on the backlight (Assuming TFT_BL is the backlight pin)
|
digitalWrite(TFT_BL, HIGH); // Turn on the backlight (Assuming TFT_BL is the backlight pin)
|
||||||
tft.writecommand(TFT_SLPOUT); // Wake up display from sleep mode
|
tft.writecommand(TFT_SLPOUT); // Wake up display from sleep mode
|
||||||
tft.writecommand(TFT_DISPON); // Turn on display
|
tft.writecommand(TFT_DISPON); // Turn on display
|
||||||
@ -382,9 +391,8 @@ void loop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool connectToIRC() {
|
bool connectToIRC() {
|
||||||
|
Serial.println("Connecting to IRC...");
|
||||||
if (useSSL) {
|
if (useSSL) {
|
||||||
client.setInsecure();
|
client.setInsecure();
|
||||||
return client.connect(server, port);
|
return client.connect(server, port);
|
||||||
@ -396,6 +404,7 @@ bool connectToIRC() {
|
|||||||
|
|
||||||
void connectToWiFi() {
|
void connectToWiFi() {
|
||||||
WiFi.begin(ssid.c_str(), password.c_str());
|
WiFi.begin(ssid.c_str(), password.c_str());
|
||||||
|
Serial.println("Connecting to WiFi...");
|
||||||
int attempts = 0;
|
int attempts = 0;
|
||||||
while (WiFi.status() != WL_CONNECTED && attempts < 10) { // Try to connect for up to 10 seconds
|
while (WiFi.status() != WL_CONNECTED && attempts < 10) { // Try to connect for up to 10 seconds
|
||||||
delay(500);
|
delay(500);
|
||||||
@ -403,6 +412,7 @@ void connectToWiFi() {
|
|||||||
attempts++;
|
attempts++;
|
||||||
}
|
}
|
||||||
if (WiFi.status() == WL_CONNECTED) {
|
if (WiFi.status() == WL_CONNECTED) {
|
||||||
|
Serial.println("Connected to WiFi network: " + ssid);
|
||||||
displayCenteredText("CONNECTED TO " + ssid);
|
displayCenteredText("CONNECTED TO " + ssid);
|
||||||
delay(1000);
|
delay(1000);
|
||||||
updateTimeFromNTP();
|
updateTimeFromNTP();
|
||||||
@ -414,7 +424,7 @@ void connectToWiFi() {
|
|||||||
|
|
||||||
void sendIRC(String command) {
|
void sendIRC(String command) {
|
||||||
if (client.println(command))
|
if (client.println(command))
|
||||||
Serial.println(">>> " + command);
|
Serial.println("IRC: >>> " + command);
|
||||||
else
|
else
|
||||||
Serial.println("Failed to send: " + command);
|
Serial.println("Failed to send: " + command);
|
||||||
}
|
}
|
||||||
@ -423,7 +433,7 @@ void handleIRC() {
|
|||||||
while (client.available()) {
|
while (client.available()) {
|
||||||
String line = client.readStringUntil('\n');
|
String line = client.readStringUntil('\n');
|
||||||
line.trim();
|
line.trim();
|
||||||
Serial.println(line);
|
Serial.println("IRC: " + line);
|
||||||
|
|
||||||
int firstSpace = line.indexOf(' ');
|
int firstSpace = line.indexOf(' ');
|
||||||
int secondSpace = line.indexOf(' ', firstSpace + 1);
|
int secondSpace = line.indexOf(' ', firstSpace + 1);
|
||||||
@ -445,7 +455,7 @@ void handleIRC() {
|
|||||||
sendIRC(pingResponse);
|
sendIRC(pingResponse);
|
||||||
} else {
|
} else {
|
||||||
parseAndDisplay(line);
|
parseAndDisplay(line);
|
||||||
lastActivityTime = millis();
|
lastActivityTime = millis(); // Reset activity timer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -527,9 +537,6 @@ void handleKeyboardInput(char key) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void sendRawCommand(String command) {
|
void sendRawCommand(String command) {
|
||||||
if (client.connected()) {
|
if (client.connected()) {
|
||||||
sendIRC(command);
|
sendIRC(command);
|
||||||
@ -649,7 +656,10 @@ void updateSelectedNetwork(int delta) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void scanWiFiNetworks() {
|
void scanWiFiNetworks() {
|
||||||
|
Serial.println("Scanning for WiFi networks...");
|
||||||
int n = WiFi.scanNetworks();
|
int n = WiFi.scanNetworks();
|
||||||
|
Serial.print("Total number of networks found: ");
|
||||||
|
Serial.println(n);
|
||||||
for (int i = 0; i < n && i < 100; i++) {
|
for (int i = 0; i < n && i < 100; i++) {
|
||||||
WiFiNetwork net;
|
WiFiNetwork net;
|
||||||
net.index = i + 1;
|
net.index = i + 1;
|
||||||
@ -731,6 +741,7 @@ void handleWiFiSelection(char key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void updateStatusBar() {
|
void updateStatusBar() {
|
||||||
|
Serial.println("Updating status bar...");
|
||||||
uint16_t darkerGrey = tft.color565(25, 25, 25);
|
uint16_t darkerGrey = tft.color565(25, 25, 25);
|
||||||
tft.fillRect(0, 0, SCREEN_WIDTH, STATUS_BAR_HEIGHT, darkerGrey);
|
tft.fillRect(0, 0, SCREEN_WIDTH, STATUS_BAR_HEIGHT, darkerGrey);
|
||||||
|
|
||||||
@ -799,6 +810,7 @@ uint16_t getColorFromPercentage(int rssi) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void updateTimeFromNTP() {
|
void updateTimeFromNTP() {
|
||||||
|
Serial.println("Syncing time with NTP server...");
|
||||||
configTime(-5 * 3600, 0, "pool.ntp.org", "time.nist.gov");
|
configTime(-5 * 3600, 0, "pool.ntp.org", "time.nist.gov");
|
||||||
|
|
||||||
for (int i = 0; i < 10; ++i) { // Try up to 10 times
|
for (int i = 0; i < 10; ++i) { // Try up to 10 times
|
||||||
|
Loading…
Reference in New Issue
Block a user