mirror of
https://github.com/playfultechnology/esp32-eyes.git
synced 2025-12-06 17:15:42 -08:00
Added manual look and blink control
Added ability to override "random" look, blink, and behaviour change operation, so that look direction and blink can be set with, e.g. a joystick control.
This commit is contained in:
@@ -17,8 +17,7 @@ You should have received a copy of the GNU Affero General Public License along w
|
||||
FaceBehavior::FaceBehavior(Face& face) : _face(face), Timer(500) {
|
||||
Timer.Start();
|
||||
Clear();
|
||||
Emotions[(int)eEmotions::Normal] = 2.0;
|
||||
Emotions[(int)eEmotions::Happy] = 1.0;
|
||||
Emotions[(int)eEmotions::Normal] = 1.0;
|
||||
}
|
||||
|
||||
void FaceBehavior::SetEmotion(eEmotions emotion, float value) {
|
||||
@@ -45,13 +44,12 @@ eEmotions FaceBehavior::GetRandomEmotion() {
|
||||
return eEmotions::Normal;
|
||||
}
|
||||
|
||||
float rand = random(0, 1000 * eEmotions::EMOTIONS_COUNT) / 1000.0;
|
||||
float rand = random(0, 1000 * sum_of_weight) / 1000.0;
|
||||
|
||||
float acc = 0;
|
||||
for (int emotion = 0; emotion < eEmotions::EMOTIONS_COUNT; emotion++) {
|
||||
if (Emotions[emotion] == 0) continue;
|
||||
acc += Emotions[emotion] * (eEmotions::EMOTIONS_COUNT - 1) / sum_of_weight;
|
||||
|
||||
acc += Emotions[emotion];
|
||||
if (rand <= acc) {
|
||||
return (eEmotions)emotion;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user