How fuling0519/esp32-electronic-pet works
This repository is firmware for an offline ESP32 electronic bird pet. The principal loop samples joystick events, advances pet time and needs, renders the resulting state, and dispatches care, sleep, adoption, or memorial actions; saves preserve the current pet and graveyard across restarts. Distinct stages include egg cracking and hatching, growth, care and illness, death, memorial browsing, and adoption. The README documents additional behavior beyond the sampled excerpts; uncertain internal wiring for those details is not inferred here.
Main entry points: main.cpp Application loop · UiController.cpp Screens and actions · Save.cpp Current pet saves · PetData.cpp Pet state and needs
Components 17
Application
- Application loop
src/main.cpp - Input events
src/hardware/Input.cpp
Pet lifecycle
- Pet clock
src/pet/PetClock.cpp - Pet state and needs
src/pet/PetData.cpp - Pet naming
src/pet/PetName.cpp - Pet snapshot
src/pet/PetSnapshot.cpp
User interface
- Screens and actions
src/ui/UiController.cpp - Pet artwork
src/ui/PetIcons.cpp - OLED display
src/hardware/Display.cpp - Buzzer audio
src/hardware/Sound.cpp
Persistence
- Current pet saves
src/storage/Save.cpp - Save format
src/storage/SaveFormat.h - Graveyard records
src/storage/Memorials.cpp
Other components
- Pet owner
- Joystick
- ESP32 hardware
- Preferences NVS
Connections 21
- Pet owner → Joystick: operates
- Joystick → Input events: GPIO input
- ESP32 hardware → Application loop: runs firmware
- Application loop → Input events: polls events
- Application loop → Pet clock: advances time
- Pet clock → Pet state and needs: elapsed seconds
- Application loop → Pet state and needs: applies actions
- Application loop → Pet naming: creates names
- Application loop → Screens and actions: updates and dispatches
- Input events → Screens and actions: input events
- Screens and actions → Pet state and needs: reads state
- Screens and actions → OLED display: draws screens
- Screens and actions → Buzzer audio: plays cues
- Screens and actions → Pet artwork: uses artwork
- Application loop → Current pet saves: loads and saves
- Application loop → Graveyard records: manages records
- Current pet saves → Pet state and needs: restores state
- Current pet saves → Pet snapshot: serializes snapshot
- Current pet saves → Save format: uses layout
- Current pet saves → Preferences NVS: reads and writes
- Graveyard records → Preferences NVS: reads and writes