From 0111dea7cd0b997bc31f3c1af2bb2b2de0395e5d Mon Sep 17 00:00:00 2001 From: legop3 Date: Tue, 4 Nov 2025 19:28:09 -0500 Subject: [PATCH] havent started yet --- .gitignore | 9 ++++++++ README.md | 12 +++++++++- notes.md | 24 ++++++++++++++++++++ platformio.ini | 9 ++++++++ src/main.cpp | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 notes.md create mode 100644 platformio.ini create mode 100644 src/main.cpp diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..93bbf0ec --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +create_2_Open_Interface_Spec.pdf +create_2_Open_Interface_Spec.txt + + + + +.node_modules +.pio +.vscode \ No newline at end of file diff --git a/README.md b/README.md index ae4fee91..886a412a 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,13 @@ # Multi Roomba Rover -a remake of my RoombaRover project with a decentralized and embedded approach \ No newline at end of file +a remake of my RoombaRover project with a decentralized and embedded approach + +on each roomba: +- an esp32 + - a level shifter +- a power supply +- an openIPC camera + - USB wifi card + - microphone + - speaker +- MAYBE a master relay which can be turned off programatically \ No newline at end of file diff --git a/notes.md b/notes.md new file mode 100644 index 00000000..1d435dbe --- /dev/null +++ b/notes.md @@ -0,0 +1,24 @@ +# notes and ideas + +## frontend + +each frontend module will have a JSON state update over socket.io +each module will export a function to update it's state + +use these functions to update all modules on connect, from a UI init state event. +this event will be sent all of the module data at once, in JSON + +split each JSON element to the UI element functions + + +## esp-server comms + +the ESP will report to the server when it connects: + +rover's name +enable / disable for each motor +camera IP address +battery info (for different battery behaviors): + full number + warn number + urgent number \ No newline at end of file diff --git a/platformio.ini b/platformio.ini new file mode 100644 index 00000000..17ce3a24 --- /dev/null +++ b/platformio.ini @@ -0,0 +1,9 @@ +[env:esp32dev] +platform = espressif32 +board = esp32dev +framework = arduino +monitor_speed = 115200 + +; Enable verbose FreeRTOS symbols in Arduino builds (optional but handy for demos) +build_flags = + -DCORE_DEBUG_LEVEL=3 diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 00000000..0ca6584c --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,59 @@ +#include + +// Use two GPIOs with onboard-friendly defaults; adjust to match your dev kit. +constexpr gpio_num_t LED1_PIN = GPIO_NUM_2; // Often labeled "LED_BUILTIN". +constexpr gpio_num_t LED2_PIN = GPIO_NUM_4; + +constexpr TickType_t LED1_DELAY = pdMS_TO_TICKS(250); // 4 Hz blink. +constexpr TickType_t LED2_DELAY = pdMS_TO_TICKS(700); // ~1.4 Hz blink. + +// FreeRTOS tasks must have C linkage-compatible signatures. +void ledTask(void *parameter) { + const gpio_num_t pin = static_cast(reinterpret_cast(parameter)); + const TickType_t delay = (pin == LED1_PIN) ? LED1_DELAY : LED2_DELAY; + + pinMode(pin, OUTPUT); + + // Align the first toggle with system tick so the cadence stays consistent. + TickType_t nextWake = xTaskGetTickCount(); + + bool state = false; + while (true) { + digitalWrite(pin, state ? HIGH : LOW); + state = !state; + + // vTaskDelayUntil keeps a steady period even if the loop body jitters. + vTaskDelayUntil(&nextWake, delay); + } +} + +void setup() { + Serial.begin(115200); + while (!Serial && millis() < 3000) { + // Give USB CDC boards a moment to enumerate; safe to ignore for pure UART boards. + delay(10); + } + Serial.println("FreeRTOS dual LED blink demo starting up..."); + + // The Arduino core already starts the scheduler after setup() returns. + xTaskCreate( + ledTask, // Task function. + "LED1", // Label (shows up in diagnostics). + 2048, // Stack size in words. + reinterpret_cast(static_cast(LED1_PIN)), + 1, // Priority. + nullptr); + + xTaskCreate( + ledTask, + "LED2", + 2048, + reinterpret_cast(static_cast(LED2_PIN)), + 1, + nullptr); +} + +void loop() { + // Leave loop() empty; the FreeRTOS tasks do the work. + vTaskDelay(pdMS_TO_TICKS(1000)); +}