Oled Oval Eyes
// Emotion overlay
if (currentEmotion == EMOTION_HAPPY) {
// Happy: draw an upward curved arch using small overlapping circles
int radius = 4;
int step = 2; // spacing between circles
for (int i = 0; i <= EYE_WIDTH; i += step) {
float angle = map(i, 0, EYE_WIDTH, -PI, 0); // from left to right, create a half arch
int x = EYE1_X + dx + i;
int y = BASE_EYE_Y + dy + EYE_HEIGHT - 2 - sin(angle) * 6; // adjust -2 and *6 for arch position and height
display.fillCircle(x, y, radius, SSD1306_BLACK);
}
for (int i = 0; i <= EYE_WIDTH; i += step) {
float angle = map(i, 0, EYE_WIDTH, -PI, 0);
int x = EYE2_X + dx + i;
int y = BASE_EYE_Y + dy + EYE_HEIGHT - 2 - sin(angle) * 6;
display.fillCircle(x, y, radius, SSD1306_BLACK);
}
}
else if (currentEmotion == EMOTION_SAD) {
// Sad: draw a downward curved arch using small overlapping circles
int radius = 4;
int step = 2;
for (int i = 0; i <= EYE_WIDTH; i += step) {
float angle = map(i, 0, EYE_WIDTH, 0, PI); // mirrored arch
int x = EYE1_X + dx + i;
int y = BASE_EYE_Y + dy + 2 + sin(angle) * 6; // +2 and *6 adjust for position/height
display.fillCircle(x, y, radius, SSD1306_BLACK);
}
for (int i = 0; i <= EYE_WIDTH; i += step) {
float angle = map(i, 0, EYE_WIDTH, 0, PI);
int x = EYE2_X + dx + i;
int y = BASE_EYE_Y + dy + 2 + sin(angle) * 6;
display.fillCircle(x, y, radius, SSD1306_BLACK);
}
}
this is the code that im tryna edit
instead of it being triangles i want it to be rounded triangles but i dont know how to make that.
the picture is a similar example of how im tryna make them look like but this is what i ended up with


44 Replies
rest of code ?
@༺ ☾ ༻
theres another one made with python that makes it change emotions based on what i say


you may want to fix your name @༺ ☾ ༻ (see #code-of-conduct #9)
🤓 effectively, you're just drawing the rounded rectangle shape in "white" then drawing it again (but moved down) in "black" to effectively erase the bottom part...
o
ur right
👉 ideally, you'd have a function that draws the "wink" at a particular position (so you can use the same code to draw the left & right eye)... so you can do:
... and so on to show different emotions ... 😉
(
eyeJoy()
draws the curved closed eye; eyeOpen()
will be the full rounded rectangle; & eyeShut()
could be just a line)okay wait i'll try to add more emotions soon i might need your help again guys
thank you for now
i appreciate it
// how are you questions
else if (currentEmotion == EMOTION_HOWAREYOU) {
// Show happy eyes
display.fillRoundRect(EYE1_X + dx , BASE_EYE_Y + dy + 8, EYE_WIDTH, EYE_HEIGHT, 12, SSD1306_BLACK);
display.fillRoundRect(EYE2_X + dx , BASE_EYE_Y + dy + 8, EYE_WIDTH, EYE_HEIGHT, 12, SSD1306_BLACK);
display.display();
delay(3000); // Keep happy eyes for 2 seconds
// Show text: "I'm okay"
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(SSD1306_WHITE);
display.setCursor((SCREEN_WIDTH - 80) / 2, (SCREEN_HEIGHT - 16) / 2);
display.println("I'm okay");
display.display();
delay(3000);
// Clear screen and return to default
display.clearDisplay();
display.display();
currentEmotion = EMOTION_DEFAULT;
}
hi again
im trying to add an animation here but im not sure how, i tried using chatgpt but im not understanding the code that its giving me nor is it working.
i want it to show the eyes first with a nod animation yet im not sure how to make it do that
// how are you questions
else if (currentEmotion == EMOTION_HOWAREYOU) {
// Show happy eyes
display.clearDisplay();
display.fillRoundRect(EYE1_X + dx, BASE_EYE_Y + dy + 4, EYE_WIDTH, EYE_HEIGHT, 12, SSD1306_BLACK);
display.fillRoundRect(EYE2_X + dx, BASE_EYE_Y + dy + 4, EYE_WIDTH, EYE_HEIGHT, 12, SSD1306_BLACK);
display.display();
delay(300);
// Nod up
display.clearDisplay();
display.fillRoundRect(EYE1_X + dx, BASE_EYE_Y + dy + 10, EYE_WIDTH, EYE_HEIGHT, 12, SSD1306_BLACK);
display.fillRoundRect(EYE2_X + dx, BASE_EYE_Y + dy + 10, EYE_WIDTH, EYE_HEIGHT, 12, SSD1306_BLACK);
display.display();
delay(300);
// Nod down again
display.clearDisplay();
display.fillRoundRect(EYE1_X + dx, BASE_EYE_Y + dy + 4, EYE_WIDTH, EYE_HEIGHT, 12, SSD1306_BLACK);
display.fillRoundRect(EYE2_X + dx, BASE_EYE_Y + dy + 4, EYE_WIDTH, EYE_HEIGHT, 12, SSD1306_BLACK);
display.display();
delay(300);
delay(3000); // Keep happy eyes for 2 seconds
// Show text: "I'm okay"
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(SSD1306_WHITE);
display.setCursor((SCREEN_WIDTH - 80) / 2, (SCREEN_HEIGHT - 16) / 2);
display.println("I'm okay");
display.display();
delay(3000);
// Clear screen and return to default
display.clearDisplay();
display.display();
currentEmotion = EMOTION_DEFAULT;
}
i tried doing something like this but the eyes just dont appear and i dont know why
here is the full code
what color does
SSD1306_BLACK
draw?Its basically black eyes ontop of my white eyes
yes, I saw what you were doing after i wrote that, nice effect!
I’m aiming for a big project but i dont have enough experience and knowledge
that bothers me
the code is long too its leaving me confused myself at times 💀
One thing to try is using functions to break up the long code.
like
same with other emotions
then use
rather than have all the eye code there in the decisions area
@wisso
so for each emotion i’ll make a void ?
for example for sad eyes
void sadeyes(){}
and so on
yes a function
void myFunction() {}
void here means "this is a function that doesn't return anything"can u explain to me what the concept of return does i never really got it
a very simple example:
this function is declared as
int
because it returns to the place it was called from the inputValue + 2 as an integer
you'd call it like
and after the above line executes myReturnValue
would equal 11Btw. You can use a switch case for selection since your emotions variables are ints.
@AnonEngineering I am on phone, so maybe you explain switch case if you feel like it. Otherwise I can do tomorrow.
Yall can take your time its ok
@wisso
now one thing - you do not need to use else if on things that are exclusive like commands
eg
it doesnt require
just got off work, now about
switch case
and else if
...NOw he turns up...
I've developed this horrible addiction to food and shelter 😉
sleep rough, it will free you
sleep
ANYWAY
since the emotions are enumerated (numbers) you can use switch case.
in such a case (no pun intended) do you usually skip a
default
clause?I dont think it gets to there without an rmotion being set
ahh, so no possibility of a value without a case
not sure - the input string could use some work.
I think the op been directed there but prefers own eyes code development
Dont quote me on that
I would chuck all the emotions into functions to clean up the switch case.
eg
and of course - fix all the local variables that are not globally defined
sigh
replace all the local dx, dy with currentX and currentY...
esp32 oled eyes Copy - Wokwi ESP32, STM32, Arduino Simulator
Run IoT and embedded projects in your browser: ESP32, STM32, Arduino, Pi Pico, and more. No installation required!
that's a new one, wokwi compiles that for > 100 seconds, and won't let me cancel...
Wokwi went down, back now
oops - sorry about that.. 😆
been working on other graphic methods

what the frick
I think im kind of getting somewhere
but im still unsure
I gave every emotion its own function or its own void
idk about the switches tho
are they better to use?
@DarwinWasWrong I tried to do it as you said with switches and cases
i used ai tho
how the hell
do you know how i can draw eyes like these

by using the one of the various robot eyes libraries that were sent in the begining
FluxGarage
YouTube
#2 - Getting Started With the Free Robo Eyes Arduino Library
Download the Robo Eyes Library Here:
https://github.com/FluxGarage/RoboEyes
Check the First Demonstration Video:
https://youtu.be/ibSaDEkfUOI
00:00 INTRO AND OVERVIEW
00:23 Prepare basic hardware
01:15 Install library and upload test sketch
03:34 Custom eye shapes
04:26 Face expressions and behaviour
05:39 OUTRO
05:55 WHAT COMES NEXT?
ooo
are yall familiar with esp32?
I have an issue that i cant figure out at all
Im using an esp32-s3 tiny devboard, i switched the arduino with it and i changed the code to befit the esp and it worked the first time
next day it just stopped working
its showing me that its connected and its active but its not responding to my codes at all
its just not responding in any way
I cant figure out why