From 2775c70bc3616fb5fb0985dc158152ec322acfc5 Mon Sep 17 00:00:00 2001 From: alastaira Date: Tue, 26 Sep 2023 10:27:52 +0100 Subject: [PATCH] Minor changes --- EyePresets.h | 2 +- FaceExpression.cpp | 4 +- doc/eyes.svg | 380 +++++++++++++++++++++++++++++++++++++++++++++ esp32-eyes.ino | 18 ++- 4 files changed, 393 insertions(+), 11 deletions(-) create mode 100644 doc/eyes.svg diff --git a/EyePresets.h b/EyePresets.h index 7864875..68348e4 100644 --- a/EyePresets.h +++ b/EyePresets.h @@ -205,7 +205,7 @@ static const EyeConfig Preset_Skeptic_Alt = { .Inverse_Offset_Bottom = 0 }; -static const EyeConfig Preset_Fustrated = { +static const EyeConfig Preset_Frustrated = { .OffsetX = 3, .OffsetY = -5, .Height = 12, diff --git a/FaceExpression.cpp b/FaceExpression.cpp index aae3933..1a1ac80 100644 --- a/FaceExpression.cpp +++ b/FaceExpression.cpp @@ -119,8 +119,8 @@ void FaceExpression::GoTo_Skeptic() void FaceExpression::GoTo_Frustrated() { ClearVariations(); - _face.RightEye.TransitionTo(Preset_Fustrated); - _face.LeftEye.TransitionTo(Preset_Fustrated); + _face.RightEye.TransitionTo(Preset_Frustrated); + _face.LeftEye.TransitionTo(Preset_Frustrated); } void FaceExpression::GoTo_Unimpressed() diff --git a/doc/eyes.svg b/doc/eyes.svg new file mode 100644 index 0000000..d08a952 --- /dev/null +++ b/doc/eyes.svg @@ -0,0 +1,380 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Height + + + Width + RadiusBottom + + RadiusTop + + Slope x Height + + diff --git a/esp32-eyes.ino b/esp32-eyes.ino index 1232a79..35282ea 100644 --- a/esp32-eyes.ino +++ b/esp32-eyes.ino @@ -11,8 +11,10 @@ #include "Face.h" // CONSTANTS -const byte joystickPins[] = {26, 25}; +const byte joystickPins[] = {25, 26}; const byte blinkPin = 16; +const byte moodPins[] = {12, 13, 15}; +const eEmotions moods[] = {eEmotions::Angry, eEmotions::Sad, eEmotions::Surprised}; // GLOBALS Face *face; @@ -31,7 +33,7 @@ void setup(void) { face->Expression.GoTo_Normal(); // Assign a weight to each emotion - face->Behavior.SetEmotion(eEmotions::Normal, 1.0); + //face->Behavior.SetEmotion(eEmotions::Normal, 1.0); //face->Behavior.SetEmotion(eEmotions::Angry, 1.0); //face->Behavior.SetEmotion(eEmotions::Sad, 1.0); // Automatically switch between behaviours (selecting new behaviour randomly based on the weight assigned to each emotion) @@ -67,7 +69,7 @@ void loop(){ int yRaw = analogRead(25); int xRaw = analogRead(26); float y = mapFloat(yRaw, 0, 4095, 1.0, -1.0); - float x = mapFloat(xRaw, 0, 4095, 1.0, -1.0); + float x = mapFloat(xRaw, 0, 4095, -1.0, 1.0); face->Look.LookAt(x, y); lastMoveTime = millis(); } @@ -76,12 +78,12 @@ void loop(){ face->DoBlink(); } - /* // Use this code to set a particular emotion from a button - int32_t potValue = analogRead(15); - float anger = map(potValue, 0, 4095, 0.0, 2.0); - face->Behavior.SetEmotion(eEmotions::Angry, anger); - */ + for(int i=0; i<3; i++){ + int32_t potValue = analogRead(moodPins[i]); + float moodLevel = map(potValue, 0, 4095, 0.0, 2.0); + face->Behavior.SetEmotion(moods[i], moodLevel); + } // Update the face! face->Update();