mirror of
https://github.com/EyeTrackVR/OpenIris.git
synced 2025-11-04 15:39:42 +08:00
feat: add esp32s3 support
- add beta simulator environment
This commit is contained in:
parent
b4d56af69c
commit
3eeae182ee
76
ESP/diagram.json
Normal file
76
ESP/diagram.json
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
{
|
||||||
|
"version": 1,
|
||||||
|
"author": "DaOfficialWizard",
|
||||||
|
"editor": "wokwi",
|
||||||
|
"parts": [
|
||||||
|
{
|
||||||
|
"type": "wokwi-esp32-devkit-v1",
|
||||||
|
"id": "esp",
|
||||||
|
"top": 0,
|
||||||
|
"left": 0,
|
||||||
|
"attrs": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "wokwi-led",
|
||||||
|
"id": "led1",
|
||||||
|
"top": 82.91,
|
||||||
|
"left": 128.93,
|
||||||
|
"rotate": 180,
|
||||||
|
"attrs": {
|
||||||
|
"color": "red"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "wokwi-resistor",
|
||||||
|
"id": "r1",
|
||||||
|
"top": 149.11,
|
||||||
|
"left": 125.63,
|
||||||
|
"attrs": {
|
||||||
|
"value": "1000"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"connections": [
|
||||||
|
[
|
||||||
|
"esp:TX0",
|
||||||
|
"$serialMonitor:RX",
|
||||||
|
"",
|
||||||
|
[]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"esp:RX0",
|
||||||
|
"$serialMonitor:TX",
|
||||||
|
"",
|
||||||
|
[]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"esp:GND.1",
|
||||||
|
"r1:1",
|
||||||
|
"black",
|
||||||
|
[
|
||||||
|
"h0"
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"led1:C",
|
||||||
|
"r1:2",
|
||||||
|
"green",
|
||||||
|
[
|
||||||
|
"v-4.6",
|
||||||
|
"h38.86",
|
||||||
|
"v72.64"
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"led1:A",
|
||||||
|
"esp:D4",
|
||||||
|
"green",
|
||||||
|
[
|
||||||
|
"v-3.11",
|
||||||
|
"h-23.78",
|
||||||
|
"v30.85"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"dependencies": {}
|
||||||
|
}
|
||||||
@ -130,7 +130,7 @@ build_flags = ${env.build_flags}
|
|||||||
board = esp-wrover-kit
|
board = esp-wrover-kit
|
||||||
board_build.f_flash = 80000000L
|
board_build.f_flash = 80000000L
|
||||||
board_build.flash_mode = qio
|
board_build.flash_mode = qio
|
||||||
build_type = debug
|
build_type = release
|
||||||
build_flags = ${env.build_flags}
|
build_flags = ${env.build_flags}
|
||||||
-DDEBUG_MODE=0 ; Set the debug mode
|
-DDEBUG_MODE=0 ; Set the debug mode
|
||||||
-DCORE_DEBUG_LEVEL=1
|
-DCORE_DEBUG_LEVEL=1
|
||||||
@ -145,4 +145,34 @@ upload_protocol = espota
|
|||||||
upload_flags =
|
upload_flags =
|
||||||
--port=${ota.otaserverport}
|
--port=${ota.otaserverport}
|
||||||
--auth=${ota.otapassword}
|
--auth=${ota.otapassword}
|
||||||
|
|
||||||
|
[env:wrovers3]
|
||||||
|
board = esp32-s3-devkitc-1
|
||||||
|
#board_build.f_flash = 80000000L
|
||||||
|
#board_build.flash_mode = qio
|
||||||
|
build_type = debug
|
||||||
|
build_flags = ${env.build_flags}
|
||||||
|
-DCORE_DEBUG_LEVEL=4 ; set the debug level
|
||||||
|
-DDEBUG_MODE=1 ; Set the debug mode
|
||||||
|
; CAMERA PINOUT DEFINITIONS
|
||||||
|
${pinoutsESPWROVER.build_flags}
|
||||||
|
|
||||||
|
[env:wrovers3_release]
|
||||||
|
board = esp32-s3-devkitc-1
|
||||||
|
#board_build.f_flash = 80000000L
|
||||||
|
#board_build.flash_mode = qio
|
||||||
build_type = release
|
build_type = release
|
||||||
|
build_flags = ${env.build_flags}
|
||||||
|
-DDEBUG_MODE=0 ; Set the debug mode
|
||||||
|
-DCORE_DEBUG_LEVEL=1
|
||||||
|
-DDEBUG_ESP_OTA
|
||||||
|
; CAMERA PINOUT DEFINITIONS
|
||||||
|
${pinoutsESPWROVER.build_flags}
|
||||||
|
|
||||||
|
[env:wrovers3_OTA]
|
||||||
|
extends = env:wrover_release
|
||||||
|
upload_port = ${ota.otaserverip}
|
||||||
|
upload_protocol = espota
|
||||||
|
upload_flags =
|
||||||
|
--port=${ota.otaserverport}
|
||||||
|
--auth=${ota.otapassword}
|
||||||
|
|||||||
40
ESP/ini/sim.ini
Normal file
40
ESP/ini/sim.ini
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
[sim]
|
||||||
|
ssid = "Wokwi-GUEST" # required for simulator
|
||||||
|
password = ""
|
||||||
|
|
||||||
|
[env:esp32AIThinker_sim]
|
||||||
|
board = esp32cam
|
||||||
|
build_type = debug
|
||||||
|
extra_scripts =
|
||||||
|
${env.extra_scripts}
|
||||||
|
post:tools/createwokwi.py
|
||||||
|
build_flags = -DENABLE_ADHOC=${wifi.enableadhoc}
|
||||||
|
-DADHOC_CHANNEL=${wifi.adhocchannel}
|
||||||
|
-DWIFI_CHANNEL=${wifi.channel}
|
||||||
|
-DDEBUG_ESP_PORT=Serial ; set the debug port
|
||||||
|
'-DMDNS_HOSTNAME=${wifi.mDNSName}' ; Set the OTA password
|
||||||
|
# required for simulator
|
||||||
|
'-DWIFI_SSID=${sim.ssid}'
|
||||||
|
'-DWIFI_PASSWORD=${sim.password}'
|
||||||
|
'-DWIFI_AP_SSID=${wifi.ap_ssid}'
|
||||||
|
'-DWIFI_AP_PASSWORD=${wifi.ap_password}'
|
||||||
|
'-DWIFI_AP_CHANNEL=${wifi.adhocchannel}'
|
||||||
|
|
||||||
|
-DENABLE_OTA=${ota.enableota}
|
||||||
|
-DOTA_SERVER_PORT=${ota.otaserverport}
|
||||||
|
'-DOTA_PASSWORD=${ota.otapassword}' ; Set the OTA password
|
||||||
|
'-DOTA_IP=${ota.otaserverip}' ; Set the OTA password
|
||||||
|
|
||||||
|
-O2 ; optimize for speed
|
||||||
|
-DASYNCWEBSERVER_REGEX ; enable regex in asyncwebserver
|
||||||
|
|
||||||
|
# Comment these out if you are not using psram
|
||||||
|
-DBOARD_HAS_PSRAM ; enable psram
|
||||||
|
-mfix-esp32-psram-cache-issue ; fix for psram
|
||||||
|
; Compile with -DHTTP_PARSER_STRICT=0 to make less checks, but run faster
|
||||||
|
-DHTTP_PARSER_STRICT=0
|
||||||
|
-DCORE_DEBUG_LEVEL=4 ; set the debug level
|
||||||
|
-DDEBUG_MODE=1
|
||||||
|
-DSIM_ENABLED
|
||||||
|
; CAMERA PINOUT DEFINITIONS
|
||||||
|
${pinoutsAIThinker.build_flags}
|
||||||
@ -15,8 +15,8 @@
|
|||||||
#define XHTTP_OPTIONS 0b01000000;
|
#define XHTTP_OPTIONS 0b01000000;
|
||||||
#define XHTTP_ANY 0b01111111; */
|
#define XHTTP_ANY 0b01111111; */
|
||||||
|
|
||||||
#define HTTP_ANY 0b01111111
|
//constexpr int HTTP_GET = 0b00000001;
|
||||||
#define HTTP_GET 0b00000001
|
constexpr int HTTP_ANY = 0b01111111;
|
||||||
|
|
||||||
#include <ESPAsyncWebServer.h>
|
#include <ESPAsyncWebServer.h>
|
||||||
#include <AsyncTCP.h>
|
#include <AsyncTCP.h>
|
||||||
|
|||||||
@ -16,3 +16,4 @@ extra_configs =
|
|||||||
ini/pinouts.ini
|
ini/pinouts.ini
|
||||||
ini/user_config.ini
|
ini/user_config.ini
|
||||||
ini/dev_config.ini
|
ini/dev_config.ini
|
||||||
|
ini/sim.ini
|
||||||
|
|||||||
@ -1,17 +1,18 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <network/WifiHandler/WifiHandler.hpp>
|
|
||||||
#include <network/mDNS/MDNSManager.hpp>
|
|
||||||
#include <io/camera/cameraHandler.hpp>
|
|
||||||
#include <io/LEDManager/LEDManager.hpp>
|
#include <io/LEDManager/LEDManager.hpp>
|
||||||
#include <network/stream/streamServer.hpp>
|
#include <io/camera/cameraHandler.hpp>
|
||||||
|
#include <network/WifiHandler/WifiHandler.hpp>
|
||||||
#include <network/api/webserverHandler.hpp>
|
#include <network/api/webserverHandler.hpp>
|
||||||
|
#include <network/mDNS/MDNSManager.hpp>
|
||||||
|
#include <network/stream/streamServer.hpp>
|
||||||
|
|
||||||
//! TODO: Setup OTA enabled state to be controllable by API if enabled at compile time
|
//! TODO: Setup OTA enabled state to be controllable by API if enabled at
|
||||||
|
//! compile time
|
||||||
#if ENABLE_OTA
|
#if ENABLE_OTA
|
||||||
#include <network/OTA/OTA.hpp>
|
#include <network/OTA/OTA.hpp>
|
||||||
#endif // ENABLE_OTA
|
#endif // ENABLE_OTA
|
||||||
#include <logo/logo.hpp>
|
|
||||||
#include <data/config/project_config.hpp>
|
#include <data/config/project_config.hpp>
|
||||||
|
#include <logo/logo.hpp>
|
||||||
|
|
||||||
int STREAM_SERVER_PORT = 80;
|
int STREAM_SERVER_PORT = 80;
|
||||||
int CONTROL_SERVER_PORT = 81;
|
int CONTROL_SERVER_PORT = 81;
|
||||||
@ -27,15 +28,36 @@ ProjectConfig deviceConfig("openiris", MDNS_HOSTNAME);
|
|||||||
OTA ota(&deviceConfig);
|
OTA ota(&deviceConfig);
|
||||||
#endif // ENABLE_OTA
|
#endif // ENABLE_OTA
|
||||||
LEDManager ledManager(33);
|
LEDManager ledManager(33);
|
||||||
|
|
||||||
|
#ifndef SIM_ENABLED
|
||||||
CameraHandler cameraHandler(&deviceConfig, &ledStateManager);
|
CameraHandler cameraHandler(&deviceConfig, &ledStateManager);
|
||||||
|
#endif // SIM_ENABLED
|
||||||
|
WiFiHandler wifiHandler(&deviceConfig,
|
||||||
|
&wifiStateManager,
|
||||||
|
WIFI_SSID,
|
||||||
|
WIFI_PASSWORD,
|
||||||
|
WIFI_CHANNEL);
|
||||||
|
|
||||||
WiFiHandler wifiHandler(&deviceConfig, &wifiStateManager, WIFI_SSID, WIFI_PASSWORD, WIFI_CHANNEL);
|
#ifndef SIM_ENABLED
|
||||||
APIServer apiServer(CONTROL_SERVER_PORT, &deviceConfig, &cameraHandler, &wifiStateManager, "/control");
|
APIServer apiServer(CONTROL_SERVER_PORT,
|
||||||
|
&deviceConfig,
|
||||||
|
&cameraHandler,
|
||||||
|
&wifiStateManager,
|
||||||
|
"/control");
|
||||||
|
#else
|
||||||
|
APIServer apiServer(CONTROL_SERVER_PORT,
|
||||||
|
&deviceConfig,
|
||||||
|
NULL,
|
||||||
|
&wifiStateManager,
|
||||||
|
"/control");
|
||||||
|
#endif // SIM_ENABLED
|
||||||
MDNSHandler mdnsHandler(&mdnsStateManager, &deviceConfig);
|
MDNSHandler mdnsHandler(&mdnsStateManager, &deviceConfig);
|
||||||
StreamServer streamServer(STREAM_SERVER_PORT, &wifiStateManager);
|
|
||||||
|
|
||||||
void setup()
|
#ifndef SIM_ENABLED
|
||||||
{
|
StreamServer streamServer(STREAM_SERVER_PORT, &wifiStateManager);
|
||||||
|
#endif // SIM_ENABLED
|
||||||
|
|
||||||
|
void setup() {
|
||||||
setCpuFrequencyMhz(240); // set to 240mhz for performance boost
|
setCpuFrequencyMhz(240); // set to 240mhz for performance boost
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
// Serial.setDebugOutput(DEBUG_MODE);
|
// Serial.setDebugOutput(DEBUG_MODE);
|
||||||
@ -45,7 +67,9 @@ void setup()
|
|||||||
// Serial.println("Free Heap: " + String(ESP.getFreeHeap()));
|
// Serial.println("Free Heap: " + String(ESP.getFreeHeap()));
|
||||||
|
|
||||||
ledManager.begin();
|
ledManager.begin();
|
||||||
|
#ifndef SIM_ENABLED
|
||||||
deviceConfig.attach(&cameraHandler);
|
deviceConfig.attach(&cameraHandler);
|
||||||
|
#endif // SIM_ENABLED
|
||||||
deviceConfig.attach(&mdnsHandler);
|
deviceConfig.attach(&mdnsHandler);
|
||||||
deviceConfig.initConfig();
|
deviceConfig.initConfig();
|
||||||
deviceConfig.load();
|
deviceConfig.load();
|
||||||
@ -67,41 +91,38 @@ void setup()
|
|||||||
break;
|
break;
|
||||||
} */
|
} */
|
||||||
|
|
||||||
switch (wifiStateManager.getCurrentState())
|
switch (wifiStateManager.getCurrentState()) {
|
||||||
{
|
case WiFiState_e::WiFiState_Disconnected: {
|
||||||
case WiFiState_e::WiFiState_Disconnected:
|
|
||||||
{
|
|
||||||
//! TODO: Implement
|
//! TODO: Implement
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WiFiState_e::WiFiState_Disconnecting:
|
case WiFiState_e::WiFiState_Disconnecting: {
|
||||||
{
|
|
||||||
//! TODO: Implement
|
//! TODO: Implement
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WiFiState_e::WiFiState_ADHOC:
|
case WiFiState_e::WiFiState_ADHOC: {
|
||||||
{
|
#ifndef SIM_ENABLED
|
||||||
streamServer.startStreamServer();
|
streamServer.startStreamServer();
|
||||||
log_d("[SETUP]: Starting Stream Server");
|
log_d("[SETUP]: Starting Stream Server");
|
||||||
|
#endif // SIM_ENABLED
|
||||||
apiServer.begin();
|
apiServer.begin();
|
||||||
log_d("[SETUP]: Starting API Server");
|
log_d("[SETUP]: Starting API Server");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WiFiState_e::WiFiState_Connected:
|
case WiFiState_e::WiFiState_Connected: {
|
||||||
{
|
#ifndef SIM_ENABLED
|
||||||
streamServer.startStreamServer();
|
streamServer.startStreamServer();
|
||||||
log_d("[SETUP]: Starting Stream Server");
|
log_d("[SETUP]: Starting Stream Server");
|
||||||
|
#endif // SIM_ENABLED
|
||||||
apiServer.begin();
|
apiServer.begin();
|
||||||
log_d("[SETUP]: Starting API Server");
|
log_d("[SETUP]: Starting API Server");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WiFiState_e::WiFiState_Connecting:
|
case WiFiState_e::WiFiState_Connecting: {
|
||||||
{
|
|
||||||
//! TODO: Implement
|
//! TODO: Implement
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WiFiState_e::WiFiState_Error:
|
case WiFiState_e::WiFiState_Error: {
|
||||||
{
|
|
||||||
//! TODO: Implement
|
//! TODO: Implement
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -111,8 +132,7 @@ void setup()
|
|||||||
#endif // ENABLE_OTA
|
#endif // ENABLE_OTA
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop() {
|
||||||
{
|
|
||||||
#if ENABLE_OTA
|
#if ENABLE_OTA
|
||||||
ota.handleOTAUpdate();
|
ota.handleOTAUpdate();
|
||||||
#endif // ENABLE_OTA
|
#endif // ENABLE_OTA
|
||||||
|
|||||||
41
ESP/tools/createwokwi.py
Normal file
41
ESP/tools/createwokwi.py
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# https://docs.wokwi.com/vscode/getting-started
|
||||||
|
|
||||||
|
# TODO: Add generation of diagram.json file per board environment
|
||||||
|
|
||||||
|
Import("env")
|
||||||
|
try:
|
||||||
|
|
||||||
|
def createTOML(source, target, env):
|
||||||
|
try:
|
||||||
|
firmware_name = env.subst("$BUILD_DIR\${PROGNAME}")
|
||||||
|
firmware_name = firmware_name.split(".pio")[1]
|
||||||
|
|
||||||
|
firmware_name = firmware_name.replace("\\", "/")
|
||||||
|
|
||||||
|
print("Creating wokwi.toml for %s" % firmware_name)
|
||||||
|
|
||||||
|
wokwi_string = """\
|
||||||
|
[wokwi]
|
||||||
|
version = 1
|
||||||
|
elf = ".pio{name}.elf"
|
||||||
|
firmware = ".pio{name}.bin"
|
||||||
|
[[net.forward]]
|
||||||
|
from = "localhost:8180"
|
||||||
|
to = "target:80"
|
||||||
|
"""
|
||||||
|
toml_string = wokwi_string.format(name=firmware_name)
|
||||||
|
print(toml_string)
|
||||||
|
with open("wokwi.toml", "w") as f:
|
||||||
|
f.write(toml_string)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
print("wokwi.toml created \n")
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print("Error creating wokwi.toml: %s" % e)
|
||||||
|
|
||||||
|
env.AddPostAction("$BUILD_DIR\${PROGNAME}.bin", createTOML)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print("Error creating wokwi.toml: %s" % e)
|
||||||
7
ESP/wokwi.toml
Normal file
7
ESP/wokwi.toml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
[wokwi]
|
||||||
|
version = 1
|
||||||
|
elf = ".pio/build/esp32AIThinker_sim/OpenIris-v1.9.4-esp32AIThinker_sim-b4d56af-master.elf"
|
||||||
|
firmware = ".pio/build/esp32AIThinker_sim/OpenIris-v1.9.4-esp32AIThinker_sim-b4d56af-master.bin"
|
||||||
|
[[net.forward]]
|
||||||
|
from = "localhost:8180"
|
||||||
|
to = "target:80"
|
||||||
Loading…
Reference in New Issue
Block a user