Skip to content

Commit 23bbb76

Browse files
committed
Fix facialLoop and addTask
1 parent 71b86e5 commit 23bbb76

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

src/Avatar.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#include "Avatar.h"
66
namespace m5avatar {
7-
const uint32_t DEFAULT_STACK_SIZE = 1024;//2048;
7+
const uint32_t DEFAULT_STACK_SIZE = 1024;
88

99
unsigned int seed = 0;
1010

@@ -22,7 +22,7 @@ void drawLoop(void *args) {
2222
if (avatar->isDrawing()) {
2323
avatar->draw();
2424
}
25-
vTaskDelay(10);
25+
vTaskDelay(33);
2626
}
2727
vTaskDelete(NULL);
2828
}
@@ -36,7 +36,7 @@ void facialLoop(void *args) {
3636
unsigned long last_saccade_millis = 0;
3737
unsigned long last_blink_millis = 0;
3838
bool eye_open = true;
39-
for (;;) {
39+
while (avatar->isDrawing()) {
4040

4141
if ((millis() - last_saccade_millis) > saccade_interval) {
4242
float vertical = rand_r(&seed) / (RAND_MAX / 2.0) - 1;
@@ -57,11 +57,12 @@ void facialLoop(void *args) {
5757
eye_open = !eye_open;
5858
last_blink_millis = millis();
5959
}
60-
c = c + 1 % 100;
60+
c = (c + 1) % 100;
6161
float f = sin(c * 2 * PI / 100.0);
6262
avatar->setBreath(f);
6363
vTaskDelay(33);
6464
}
65+
vTaskDelete(NULL);
6566
}
6667

6768
Avatar::Avatar() : Avatar(new Face()) {}
@@ -89,12 +90,13 @@ Face *Avatar::getFace() const { return face; }
8990
void Avatar::addTask(TaskFunction_t f, const char* name) {
9091
DriveContext *ctx = new DriveContext(this);
9192
// TODO(meganetaaan): set a task handler
92-
xTaskCreate(f, /* Function to implement the task */
93+
xTaskCreateUniversal(f, /* Function to implement the task */
9394
name, /* Name of the task */
9495
DEFAULT_STACK_SIZE, /* Stack size in words */
9596
ctx, /* Task input parameter */
96-
3, /* P2014riority of the task */
97-
NULL); /* Task handle. */
97+
4, /* P2014riority of the task */
98+
NULL, /* Task handle. */
99+
APP_CPU_NUM);
98100
// xTaskCreatePinnedToCore(f, /* Function to implement the task */
99101
// name, /* Name of the task */
100102
// DEFAULT_STACK_SIZE, /* Stack size in words */

0 commit comments

Comments
 (0)