Hi all,
trying everything but I got the same error every change I do. When I upload the sketch, the display is completely pixelated as immage pinned.
What I'm doing wrong?
If i comment everything except the lvgl code the display works fine, so it's a problem with my code for sure.
#include "Arduino_H7_Video.h"
#include "Arduino_GigaDisplayTouch.h"
#include "lvgl.h"
#include "ui.h"
#include <ArduinoJson.h>
#include "Communications.h"
#include "Index.h"
#include "FlipDot7Segments.h"
WiFiSSLClient clientSSL;
const int MAX_RETRY = 3;
String ssid_string;
String pass_string;
char ssid[50];
char pass[50];
/* Insert resolution WxH according to your SquareLine studio project settings */
Arduino_H7_Video Display(800, 480, GigaDisplayShield);
Arduino_GigaDisplayTouch Touch;
unsigned long previousMillis = 0;
unsigned long currentMillis = 0; // Aggiungi questa linea
const long interval = 1000;
const long interval2 = 5000;
void setup() {
Display.begin();
Touch.begin();
ui_init();
Serial.begin(115200);
Serial.println("Application Started");
Serial1.begin(9600);
ssid_string = String(lv_textarea_get_text(ui_SSID));
pass_string = String(lv_textarea_get_text(ui_PASS));
ssid_string.toCharArray(ssid, ssid_string.length() + 1);
pass_string.toCharArray(pass, pass_string.length() + 1);
connectToWiFi(ssid, pass);
printWifiStatus();
previousMillis = millis();
}
void loop() {
/* Feed LVGL engine */
lv_timer_handler();
delay(5);
unsigned long currentMillis = millis();
if (clientSSL.available()) {
StartIndexRequest(&clientSSL);
if(currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
String data = "";
unsigned long startTime = millis();
do {
data = read_response(&clientSSL);
} while (data == "" && (millis() - startTime) < 10000);
if ((millis() - startTime) < 10000) {
if (data != "") {
String json = get_json(data);
String index = get_index(json);
Serial.println("DATA:\n" + json + "\n----------------- END JSON");
Serial.println("INDEX:" + index + "\n----------------- END INDEX");
visualize(index.toInt());
}
Serial.println("----------------- START DELAY 5000");
previousMillis = millis();
while(millis() - previousMillis < interval2) {
// do nothing
}
Serial.println("----------------- END DELAY");
} else {
Serial.println("TIMEOUT:" + (String)(millis() - startTime));
clientSSL.stop();
}
}
}
if (WiFi.status() != WL_CONNECTED)
connectToWiFi(ssid, pass);
if (!clientSSL.connected())
connectToServer();
}
void connectToServer() {
if (!clientSSL.connected()) {
int retries = 0;
while (!clientSSL.connect(HOST_NAME, 443) && retries++ < MAX_RETRY) {
if(currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
Serial.println("Connecting to server: " + (String)HOST_NAME);
}
}
if (clientSSL.available())
Serial.println("Connected to server: " + (String)HOST_NAME);
else {
Serial.println("Not connected to server: " + (String)HOST_NAME);
WiFi.disconnect();
}
if(currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
}
}
}