How ahsanulhoque22/waifos works
Project Type and Purpose
• This is an embedded full-stack (firmware) application that implements a lightweight OS (FreeRTOS + Arduino) on an ESP32, providing a modular app framework, display/UI, input handling, WiFi, NTP, and filesystem support.
Break Down the File Structure into Architectural Layers
• Top-level files (platformio.ini, sdkconfig, CMakeLists, partitions.csv) define the build/deploy environment.
• The lib/esp8266-oled-ssd1306 directory holds the display driver (hardware abstraction).
• The include/ folder contains headers for all managers, the kernel, state_manager, and individual apps.
• The src/ folder contains corresponding implementations, plus main.cpp (entry point) and upload_fs.py (files-to-LittleFS uploader).
Extract Core Components from README and Code
a. Hardware Layer
– ESP32 DevKit v1 (WROOM-32)
– SH1106 I2C OLED (SDA=21, SCL=22)
– 6 Buttons (GPIOs 14,25,26,27,32,33)
– Onboard WiFi radio
– LittleFS partition for file storage
b. OS & HAL Layer
– FreeRTOS scheduler (dual-core)
– HAL drivers: display_manager, input_manager, bt_keyboard_manager, files_app (LittleFS adapter)
– Mutex (displayMutex) for display synchronization
c. System Services Layer
– kernel (initialization, task wrapper)
– state_manager (UI state machine)
– app_manager (launches and tears down app tasks)
– ui_manager (coordinates screen updates, app menu)
– task_manager_app (in-OS task viewer/manager)
d. Application Layer (Modular Apps)
– splash_screen (startup)
– snake_game
– weather_app (WiFi, NTP, JSON parsing)
– files_app (file browser)
– dummy_app (template/example)
e. External Services & Libraries
– NTP server (pool.ntp.org)
– WiFi network
– PlatformIO build environment & extra_scripts (upload_fs.py)
– Arduino libraries: WiFi, AsyncTCP, PubSubClient, ArduinoJson, BLE Keyboard
Component Interactions
• On boot (main.cpp): kernel → initialize managers → splash_screen.
• app_manager spawns each app as a FreeRTOS task.
• Apps call display_manager (under displayMutex) for drawing.
• User input flows from buttons → input_manager → state_manager → ui_manager → app_manager.
• weather_app uses WiFi driver → NTP → HTTPClient + JSON parser.
• files_app uses upload_fs.py to populate LittleFS and then reads via an SPIFFS client.
• BLE input is handled by bt_keyboard_manager and presented to the UI layer.
Architectural Patterns & Design Principles
– Layered architecture (Hardware → HAL → Kernel/Services → App)
– Modular apps loaded/unloaded at runtime via a central app_manager
– FreeRTOS task-based concurrency with per-app tasks
– Mutex-protected shared resources (OLED display)
– State machine for UI navigation (state_manager)