#include <Arduino.h>
#include <pgmspace.h>


void setup() {
  Serial.begin(115200);
  delay(1000); // Delay to allow serial monitor to start

  // Check if PSRAM is available
  if (psramFound()) {
    Serial.println("PSRAM is available.");
  } else {
    Serial.println("PSRAM not available.");
  }

  // Print memory information
  printMemoryInfo();
}

void loop() {
  // Reprint memory information every 10 seconds
  delay(10000);
  printMemoryInfo();
}

void printMemoryInfo() {
  // Heap memory information
  Serial.println("\n--- Heap Memory Information ---");
  Serial.printf("Total heap: %u bytes\n", ESP.getHeapSize());
  Serial.printf("Free heap: %u bytes\n", ESP.getFreeHeap());
  Serial.printf("Minimum free heap ever: %u bytes\n", ESP.getMinFreeHeap());

  // PSRAM memory information (only if available)
  if (psramFound()) {
    Serial.println("\n--- PSRAM Memory Information ---");
    Serial.printf("Total PSRAM: %u bytes\n", ESP.getPsramSize());
    Serial.printf("Free PSRAM: %u bytes\n", ESP.getFreePsram());
    Serial.printf("Minimum free PSRAM ever: %u bytes\n", ESP.getMinFreePsram());
  } else {
    Serial.println("PSRAM not available.");
  }
}