-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor face tracking control pipeline for smoother arbitration #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Sa1koro
merged 7 commits into
main
from
cursor/-bc-9423ef01-f95d-4c6c-a830-8ff169c47f81-63c9
Mar 25, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8520f37
Refactor ESP32 face tracking control and WiFi recovery
cursoragent 59bb726
Add weighted face control mode and face-track XY panel
cursoragent ab9a508
feat(esp32): add eye tracking functionality with servo control and di…
Sa1koro 92c1e33
feat(esp32): enhance WiFi and mDNS connectivity with retry mechanisms
Sa1koro 6896c5f
feat(esp32): enhance eye tracking with gaze limits and pupil auto-spi…
Sa1koro 96a0666
feat(ui): add camera mirror functionality and invert X tracking option
Sa1koro b5b8732
feat(osc): enhance OSC history management and UI controls
Sa1koro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| #include <Arduino_GFX_Library.h> | ||
| #include <ESP32Servo.h> | ||
|
|
||
| // DISPLAY | ||
| #define TFT_MOSI 23 | ||
| #define TFT_SCLK 18 | ||
| #define TFT_CS 19 | ||
| #define TFT_DC 21 | ||
| #define TFT_RST 22 | ||
|
|
||
| Arduino_DataBus *bus = new Arduino_ESP32SPI(TFT_DC, TFT_CS, TFT_SCLK, TFT_MOSI, -1); | ||
| Arduino_GFX *panel = new Arduino_GC9A01(bus, TFT_RST, 0); | ||
|
|
||
| // Local canvas covering only the pupil + iris region | ||
| // Iris radius = 30, pupil radius = 13, pupil travels x = 110~130 | ||
| // Bounding box with margin: x=90~150 (w=60), y=84~156 (h=72) | ||
| #define CANVAS_X 90 | ||
| #define CANVAS_Y 84 | ||
| #define CANVAS_W 60 | ||
| #define CANVAS_H 72 | ||
|
|
||
| Arduino_GFX *sprite = new Arduino_Canvas(CANVAS_W, CANVAS_H, panel, CANVAS_X, CANVAS_Y); | ||
|
|
||
| // Local-space center (offset from canvas origin) | ||
| #define LCX (120 - CANVAS_X) // 30 | ||
| #define LCY (120 - CANVAS_Y) // 36 | ||
|
|
||
| // SERVO | ||
| Servo servo1; | ||
| #define SERVO1_PIN 4 | ||
|
|
||
| // COLORS | ||
| #define BLACK 0x0000 | ||
| #define WHITE 0xFFFF | ||
| #define SCLERA 0xEF7D | ||
| #define IRIS_DARK 0x0015 | ||
| #define IRIS_MID 0x027F | ||
| #define IRIS_LIGHT 0x3DFF | ||
| #define SHADOW 0x4208 | ||
|
|
||
| #define CX 120 | ||
| #define CY 120 | ||
|
|
||
|
|
||
| // Draw full static eye directly to panel — called ONCE in setup() | ||
| void drawStaticEye() | ||
| { | ||
| panel->fillScreen(BLACK); | ||
| // eyeball | ||
| panel->fillCircle(CX, CY, 65, SCLERA); | ||
| // iris | ||
| panel->fillCircle(CX, CY, 30, IRIS_DARK); | ||
| panel->fillCircle(CX, CY, 24, IRIS_MID); | ||
| panel->fillCircle(CX, CY, 16, IRIS_LIGHT); | ||
|
|
||
| panel->fillRoundRect(35, 40, 170, 20, 10, SHADOW); | ||
| } | ||
|
|
||
|
|
||
| // Redraw pupil region into sprite buffer, flush patch to screen | ||
| void drawPupil(int pupilX) | ||
| { | ||
| int lx = pupilX - CANVAS_X; // pupil x in local canvas space | ||
|
|
||
| // clear sprite and redraw iris layers that fall inside this region | ||
| sprite->fillScreen(BLACK); | ||
| sprite->fillCircle(LCX, LCY, 65, SCLERA); | ||
| sprite->fillCircle(LCX, LCY, 30, IRIS_DARK); | ||
| sprite->fillCircle(LCX, LCY, 24, IRIS_MID); | ||
| sprite->fillCircle(LCX, LCY, 16, IRIS_LIGHT); | ||
|
|
||
| // pupil + highlight in local coords | ||
| sprite->fillCircle(lx, LCY, 13, BLACK); | ||
| sprite->fillCircle(lx - 4, LCY - 6, 4, WHITE); | ||
|
|
||
| // push sprite patch to screen — only 60×72 = 4320 pixels over SPI | ||
| ((Arduino_Canvas *)sprite)->flush(); | ||
| } | ||
|
|
||
|
|
||
| void setup() | ||
| { | ||
| Serial.begin(115200); | ||
| Serial.print("MaxAllocHeap: "); Serial.println(ESP.getMaxAllocHeap()); | ||
|
|
||
| panel->begin(); | ||
| panel->setRotation(2); | ||
|
|
||
| Serial.println("panel ok"); | ||
|
|
||
| sprite->begin(); | ||
|
|
||
| Serial.println("sprite ok"); | ||
|
|
||
| servo1.setPeriodHertz(50); | ||
| servo1.attach(SERVO1_PIN, 500, 2400); | ||
|
|
||
| drawStaticEye(); // full background drawn once to panel GRAM | ||
| drawPupil(CX); // initial pupil | ||
| } | ||
|
|
||
|
|
||
| void loop() | ||
| { | ||
| // sweep 0 → 180 | ||
| for (int pos = 0; pos <= 120; pos++) | ||
| { | ||
| servo1.write(pos); | ||
| int pupilX = map(pos, 0, 180, 110, 130); | ||
| drawPupil(pupilX); | ||
| delay(2); | ||
| } | ||
|
|
||
| delay(500); | ||
|
|
||
| // sweep 180 → 0 | ||
| for (int pos = 100; pos >= 0; pos--) | ||
| { | ||
| servo1.write(pos); | ||
| int pupilX = map(pos, 0, 180, 110, 130); | ||
| drawPupil(pupilX); | ||
| delay(2); | ||
| } | ||
|
|
||
| delay(500); | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Servo sweep loops are asymmetric and comments wrong
Medium Severity
The first sweep comment says "sweep 0 → 180" but the loop only iterates to 120. The second sweep comment says "sweep 180 → 0" but starts at 100. This causes a hard jump from servo position 120 to 100 between sweeps. Additionally,
map(pos, 0, 180, 110, 130)uses an input range of 0–180, butposonly reaches 120 max, sopupilXnever reaches 130 — the pupil eye animation won't use its full travel range.