Files
iot-objets-connectes/T-Display-S3-main/lib/arduino-nofrendo/examples/esp32-nofrendo/esp32-nofrendo.ino

100 lines
2.3 KiB
Arduino
Raw Normal View History

2026-03-31 13:17:21 +02:00
/* Arduino Nofrendo
* Please check hw_config.h and display.cpp for configuration details
*/
#include <esp_wifi.h>
#include <esp_task_wdt.h>
#include <SD.h>
#include <SD_MMC.h>
#include <SPIFFS.h>
#include <Arduino_GFX_Library.h>
#include "hw_config.h"
extern "C"
{
#include <nofrendo.h>
}
int16_t bg_color;
extern Arduino_TFT *gfx;
void setup()
{
Serial.begin(115200);
// turn off WiFi
esp_wifi_deinit();
// disable Core 0 WDT
TaskHandle_t idle_0 = xTaskGetIdleTaskHandleForCPU(0);
esp_task_wdt_delete(idle_0);
// init display
gfx->begin();
bg_color = gfx->color565(24, 28, 24); // DARK DARK GREY
gfx->fillScreen(bg_color);
#ifdef TFT_BL
// turn display backlight on
ledcAttachPin(TFT_BL, 1); // assign TFT_BL pin to channel 1
ledcSetup(1, 12000, 8); // 12 kHz PWM, 8-bit resolution
ledcWrite(1, TFT_BRIGHTNESS); // brightness 0 - 255
#endif
// filesystem defined in hw_config.h
FILESYSTEM_BEGIN
// find first rom file (*.nes)
File root = filesystem.open("/");
char *argv[1];
if (!root)
{
Serial.println("Filesystem mount failed! Please check hw_config.h settings.");
gfx->println("Filesystem mount failed! Please check hw_config.h settings.");
}
else
{
bool foundRom = false;
File file = root.openNextFile();
while (file)
{
if (file.isDirectory())
{
// skip
}
else
{
char *filename = (char *)file.name();
int8_t len = strlen(filename);
if (strstr(strlwr(filename + (len - 4)), ".nes"))
{
foundRom = true;
char fullFilename[256];
sprintf(fullFilename, "%s%s", FSROOT, filename);
Serial.println(fullFilename);
argv[0] = fullFilename;
break;
}
}
file = root.openNextFile();
}
if (!foundRom)
{
Serial.println("Failed to find rom file, please copy rom file to data folder and upload with \"ESP32 Sketch Data Upload\"");
argv[0] = "/";
}
Serial.println("NoFrendo start!\n");
nofrendo_main(1, argv);
Serial.println("NoFrendo end!\n");
}
}
void loop()
{
}